diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2009-04-19 01:09:45 -0400 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2009-04-19 01:09:45 -0400 |
commit | c00fb11482ec7c103f05eb9ac8a210242064024a (patch) | |
tree | 7705b3635210c5f0fb09f80abf4f520ba06a208c /sigmodr/tree/SigmodrTreeModel.cpp | |
parent | afef610298a2803877e79fc1f781f224ca90b832 (diff) | |
download | sigen-c00fb11482ec7c103f05eb9ac8a210242064024a.tar.gz sigen-c00fb11482ec7c103f05eb9ac8a210242064024a.tar.xz sigen-c00fb11482ec7c103f05eb9ac8a210242064024a.zip |
Add how the model changed in signals and slots for notification of changes
Diffstat (limited to 'sigmodr/tree/SigmodrTreeModel.cpp')
-rw-r--r-- | sigmodr/tree/SigmodrTreeModel.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sigmodr/tree/SigmodrTreeModel.cpp b/sigmodr/tree/SigmodrTreeModel.cpp index 6dd42fb0..dcfd04f3 100644 --- a/sigmodr/tree/SigmodrTreeModel.cpp +++ b/sigmodr/tree/SigmodrTreeModel.cpp @@ -37,7 +37,7 @@ SigmodrTreeModel::SigmodrTreeModel(QObject* parent) : QAbstractItemModel(parent), m_root(new RootModel) { - connect(m_root, SIGNAL(rowsChanged(QList<int>)), this, SLOT(rowsChanged(QList<int>))); + connect(m_root, SIGNAL(rowsChanged(QList<int>, Sigmodr::Tree::BaseModel::Change)), this, SLOT(rowsChanged(QList<int>, Sigmodr::Tree::BaseModel::Change))); } SigmodrTreeModel::~SigmodrTreeModel() @@ -186,13 +186,22 @@ const Game* SigmodrTreeModel::findGame(const QModelIndex& index) const return qobject_cast<const Game*>(getItem(curIndex)->object()); } -void SigmodrTreeModel::rowsChanged(const QList<int>& rows) +void SigmodrTreeModel::rowsChanged(const QList<int>& rows, const BaseModel::Change change) { QModelIndex curIndex; foreach (int row, rows) curIndex = index(row, 0, curIndex); if (curIndex.isValid()) { + switch (change) + { + case BaseModel::Addition: + insertRow(rows.back(), parent(curIndex)); + break; + case BaseModel::Removal: + removeRow(rows.back(), parent(curIndex)); + break; + } emit(dataChanged(curIndex, curIndex)); emit(dirty(findGame(curIndex), true)); } |