38 m_sourceIndex(srcIndex),
39 m_isSourceItem(isSrcItem)
55 qDeleteAll(m_childItems);
62 return parent()->childRow(const_cast<GroupedProxyItem *>(
this));
70 m_childItems.append(item);
77 m_childItems.removeAll(item);
84 m_itemData.insert(role,
data);
92 b = b &&
setData(it.value(), it.key());
117 setReloadSuspended(!groupColumns.
isEmpty());
119 setReloadSuspended(
false);
165 if (!parentItem || parentItem ==
m_root)
297 bool prev = setReloadSuspended(
true);
298 for (
int i : columns)
300 setReloadSuspended(prev);
310 bool prev = setReloadSuspended(
true);
313 setReloadSuspended(prev);
336 bool prev = setReloadSuspended(
true);
339 setReloadSuspended(prev);
345 if (idx != pos && idx >=0 && pos >= 0) {
351 qWarning() <<
"Invalid move detected:" <<
"idx" << idx<<
"pos" << pos <<
"pIdx" << pIdx ;
357 qDebug() <<
"move: idx" << idx <<
"pos" << pos;
415 if (!item || item->
row() < 0 || col < 0)
501 grpItem = grpParent->
addChild(sourceIndex,
false);
521 if (!item || !item->
parent())
529 parent->removeChild(item);
550 if (reloadSuspended())
575 int startCol = qMax(topLeft.
column(), 0);
577 bool modified =
false;
578 for (
int row = topLeft.
row(); row <= endRow; ++row) {
580 if (startCol < col || endCol > col)
592 if (newParent && currParent == newParent)
609 for (
int row = first; row <= last; ++row)
618 for (
int row = first; row <= last; ++row) {
620 if (!currItem || !currItem->
parent()) {
virtual void modelResetHandler()
int groupColumnProxySrc() const
virtual int rowCount(const QModelIndex &parent) const const=0
GroupedProxyItem(const QModelIndex &srcIndex, const bool isSrcItem=false, GroupedProxyItem *parent=NULL)
GroupedProxyItem.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QModelIndex mapToSource(const QModelIndex &proxyIndex) const override
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const=0
virtual GroupedProxyItem * findGroupItem(const int group, const QVariant &value=QVariant(), GroupedProxyItem *parent=NULL) const
QVariant data(const QModelIndex &index, int role=Qt::EditRole) const override
int removeAll(const T &t)
virtual void setSourceModel(QAbstractItemModel *newSourceModel) override
virtual void dataChangedHandler(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles=QVector< int >())
QModelIndex index(int row, int column, const QModelIndex &parent) const override
bool beginMoveRows(const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild)
virtual QSize span(const QModelIndex &index) const const
int indexOf(const T &value, int from) const const
virtual QMap< int, QVariant > itemData(const QModelIndex &index) const const
virtual void setGroupMatchRole(int role)
virtual QHash< int, QByteArray > roleNames() const const
const QObjectList & children() const const
void insert(int i, T &&value)
QModelIndex sourceIndex() const
virtual QModelIndex sourceIndexForProxy(GroupedProxyItem *item) const
bool isSourceItem() const
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
virtual void clearGroups()
Remove the previously-added groupings.
bool setData(const QVariant &data, int role=Qt::EditRole)
bool isValid() const const
void setSourceModel(QAbstractItemModel *newSourceModel) override
virtual void removeUnusedGroups(GroupedProxyItem *parent=NULL)
GroupedProxyItem * m_root
void rowsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
bool contains(const T &value) const const
int groupRowSelectable() const
virtual GroupedProxyItem * itemForIndex(const QModelIndex &index, const bool rootDefault=false) const
GroupedItemsProxyModel(QObject *parent=Q_NULLPTR, QAbstractItemModel *sourceModel=Q_NULLPTR, const QVector< int > &groupColumns=QVector< int >())
GroupedItemProxyModel.
int toInt(bool *ok) const const
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
void move(int idx, int pos, int parent=-1)
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
void removeChild(GroupedProxyItem *item)
bool isEmpty() const const
bool isEmpty() const const
void beginRemoveRows(const QModelIndex &parent, int first, int last)
Qt::ItemFlags flags(const QModelIndex &index) const override
void * internalPointer() const const
virtual void setGroupColumnIsProxy(bool enable)
virtual QVariant data(const QModelIndex &index, int role) const const=0
QModelIndex parent() const const
void rowsRemoved(const QModelIndex &parent, int first, int last)
virtual ~GroupedProxyItem()
GroupedProxyItem * parent() const
QModelIndex createIndex(int row, int column, void *ptr) const const
virtual uint extraColumns() const
virtual void removeGroup(int column)
Remove the previously-added column grouping.
QVariant data(int role=Qt::EditRole) const
void beginInsertRows(const QModelIndex &parent, int first, int last)
virtual void reloadSourceModel()
QVector< GroupedProxyItem * > m_childItems
QAbstractItemModel * sourceModel() const const
virtual void removeItem(GroupedProxyItem *item)
int groupMatchRole() const
QVariant data(int role) const const
QVector< GroupedProxyItem * > children() const
virtual void addGroups(const QVector< int > &columns)
Add multiple groupings based on columns.
bool isEmpty() const const
virtual void setGroupRowSelectable(bool selectable)
virtual int columnCount(const QModelIndex &parent) const const=0
virtual void setGroupHeaderTitle(const QString &title, const QString &tooltip=QString())
virtual QModelIndex indexForItem(GroupedProxyItem *item, const int col=0) const
virtual void setGroups(const QVector< int > &columns)
Add multiple groupings based on columns.
QHash< int, GroupedProxyItem * > m_sourceMap
virtual void setGroupColumnVisible(bool visible)
virtual void rowsRemovedHandler(const QModelIndex &parent, int first, int last)
int totalRowCount(GroupedProxyItem *parent=NULL) const
QString tr(const char *s, const char *c, int n)
GroupedProxyItem * m_defaultParent
bool isValid() const const
virtual Qt::ItemFlags flags(const QModelIndex &index) const const
virtual void insertGroup(int index, int column)
Insert a new grouping at index based on column.
GroupedProxyItem * addChild(const QModelIndex &srcIndex, const bool isSrcItem=true)
virtual void setRootGroup(int column=-1, const QVariant &value=QVariant())
Sets parent group.
virtual void rowsMovedHandler(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
void rowsInserted(const QModelIndex &parent, int first, int last)
virtual bool isProxyColumn(const QModelIndex &index) const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const const
virtual void rowsInsertedHandler(const QModelIndex &parent, int first, int last)
int columnCount(const QModelIndex &parent=QModelIndex()) const override
bool hasChildren(const QModelIndex &parent=QModelIndex()) const override
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override
bool setItemData(const QMap< int, QVariant > &roles)
virtual GroupedProxyItem * placeSourceRow(const int row)
virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override
QMap< int, QVariant > itemData(const QModelIndex &index) const override
virtual void setGroupColumnProxySrc(int column)
QHash< int, QByteArray > roleNames() const
GroupedProxyItem * itemForRow(int row, GroupedProxyItem *parent=NULL) const
~GroupedItemsProxyModel()
QSize span(const QModelIndex &index) const override