RowsJoinerProxy.cpp - /* * -* "THE BEER-WARE LICENSE"...

This preview shows page 1 - 3 out of 7 pages.

The preview shows page 1 - 3 out of 7 pages.
/** ----------------------------------------------------------------------------* "THE BEER-WARE LICENSE" (Revision 42):* [email protected] wrote this file. As long as you retain this notice you* can do whatever you want with this stuff. If we meet some day, and you think* this stuff is worth it, you can buy me a beer in return Oleksandr Iakovliev* ----------------------------------------------------------------------------*/#include <QtCore>#include "RowsJoinerProxy.h"class RowsJoinerProxy::Private {public:RowsJoinerProxy * instance;QList<QAbstractItemModel *> models;int columnCount;int rowCount;struct Addr;typedef QSharedPointer<Addr> AddrPtr;typedef QList<AddrPtr> AddrRow;typedef QList<AddrRow> AddrMatrix;struct Addr {Addr(const QAbstractItemModel * _m, void * _p):m(_m),p(_p),root(true) {}const QAbstractItemModel * m;void * p;bool root;AddrMatrix down;};AddrMatrix tops;int topRowShift(const QAbstractItemModel *) const;void checkExpand(AddrMatrix &, int row, int col);AddrPtr initAddrFromSource(QModelIndex source);};RowsJoinerProxy::RowsJoinerProxy(QObject * parent):QAbstractItemModel(parent){d = new Private;d->instance = this;d->columnCount = -1;d->rowCount = -1;}RowsJoinerProxy::~RowsJoinerProxy() {while(d->models.size())removeSourceModel(d->models.back());delete d;}QList<QAbstractItemModel *> RowsJoinerProxy::models() const { return d->models; }int RowsJoinerProxy::indexOf(QAbstractItemModel * m) const { return d->models.indexOf(m); }void RowsJoinerProxy::insertSourceModel(QAbstractItemModel * m, int idx){
if (!m)return;if (idx < 0)d->models.append(m);else d->models.insert(idx, m);connect(m,SIGNAL(rowsAboutToBeInserted(QModelIndex, int, int)),this, SLOT(s_rowsAboutToBeInserted(QModelIndex, int, int)));connect(m,SIGNAL(rowsInserted(QModelIndex, int, int)),this, SLOT(s_rowsInserted(QModelIndex, int, int)));connect(m,SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)),this, SLOT(s_rowsAboutToBeRemoved(QModelIndex, int, int)));connect(m,SIGNAL(rowsRemoved(QModelIndex, int, int)),this, SLOT(s_rowsRemoved(QModelIndex, int, int)));connect(m,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this, SLOT(s_dataChanged(QModelIndex,QModelIndex)));connect(m,SIGNAL(modelReset()),this, SLOT(s_modelReset()));connect(m,SIGNAL(layoutAboutToBeChanged()),this, SIGNAL(layoutAboutToBeChanged()));connect(m,SIGNAL(layoutChanged()),this, SIGNAL(layoutChanged()));connect(m,SIGNAL(destroyed(QObject *)),this, SLOT(s_destroyed(QObject *)));d->columnCount = -1;d->rowCount = -1;d->tops.clear();reset();}void RowsJoinerProxy::removeSourceModel(QAbstractItemModel * m){if (!m)return;disconnect(m,

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 7 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
One
Professor
N/A
Tags
Return statement, Void type, include, Row

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture