diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-09-10 00:43:08 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-09-10 00:43:08 +0000 |
| commit | 08040a630b6aed8b88246f3ba3ee85d5f7bd3afb (patch) | |
| tree | 2770012f6ce3c5a8b76d90d28be823603744e6c8 /sigmodr/SigmodTreeModel.cpp | |
| parent | ddb180ad4d8aa6e08ae725c83af9a52f57dd851f (diff) | |
| download | sigen-08040a630b6aed8b88246f3ba3ee85d5f7bd3afb.tar.gz sigen-08040a630b6aed8b88246f3ba3ee85d5f7bd3afb.tar.xz sigen-08040a630b6aed8b88246f3ba3ee85d5f7bd3afb.zip | |
[FIX] Players now have money
[FIX] Some more things added to Arena stuff
[FIX] Can now delete objects in the tree in Sigmodr
[FIX] Setting Sigmods as dirty is better now
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@258 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'sigmodr/SigmodTreeModel.cpp')
| -rw-r--r-- | sigmodr/SigmodTreeModel.cpp | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/sigmodr/SigmodTreeModel.cpp b/sigmodr/SigmodTreeModel.cpp index a2d8f5a0..1e01db61 100644 --- a/sigmodr/SigmodTreeModel.cpp +++ b/sigmodr/SigmodTreeModel.cpp @@ -21,6 +21,9 @@ // Model includes #include "models/RootModel.h" +// Sigmod includes +#include "../sigmod/Sigmod.h" + // Qt includes #include <QtCore/QMimeData> #include <QtCore/QStringList> @@ -30,6 +33,7 @@ Sigmodr::SigmodTreeModel::SigmodTreeModel(QObject* parent) : QAbstractItemModel(parent), m_root(new RootModel) { + connect(m_root, SIGNAL(rowsChanged(QList<int>)), this, SLOT(rowsChanged(QList<int>))); } Sigmodr::SigmodTreeModel::~SigmodTreeModel() @@ -99,8 +103,12 @@ bool Sigmodr::SigmodTreeModel::setData(const QModelIndex& index, const QVariant& BaseModel* object = static_cast<BaseModel*>(index.internalPointer()); emit(layoutAboutToBeChanged()); bool success = object->setData(value, role); - emit(dataChanged(index, index)); emit(layoutChanged()); + if (success) + { + emit(dataChanged(index, index)); + emit(dirty(findSigmod(index), true)); + } return success; } @@ -143,17 +151,45 @@ bool Sigmodr::SigmodTreeModel::dropMimeData(const QMimeData* data, Qt::DropActio emit(layoutAboutToBeChanged()); bool success = m_root->setData(data->data("application/x-sigmod+xml"), Sigmodr::BaseModel::XmlRole); emit(layoutChanged()); + if (success) + emit(dirty(findSigmod(parent), true)); return success; } void Sigmodr::SigmodTreeModel::addSigmod(Sigmod::Sigmod* sigmod) { m_root->addSigmod(sigmod); - emit(reset()); + reset(); } void Sigmodr::SigmodTreeModel::deleteSigmod(const Sigmod::Sigmod* sigmod) { m_root->deleteSigmod(sigmod); - emit(reset()); + reset(); +} + +const Sigmod::Sigmod* Sigmodr::SigmodTreeModel::findSigmod(const QModelIndex& index) const +{ + QModelIndex curIndex = index; + QModelIndex parIndex = parent(curIndex); + while (parIndex.isValid()) + { + curIndex = parIndex; + parIndex = parent(curIndex); + } + return qobject_cast<const Sigmod::Sigmod*>(getItem(curIndex)->object()); +} + +void Sigmodr::SigmodTreeModel::rowsChanged(const QList<int>& rows) +{ + QModelIndex curIndex; + foreach (int row, rows) + curIndex = index(row, 0, curIndex); + if (curIndex.isValid()) + { + emit(dataChanged(curIndex, curIndex)); + emit(dirty(findSigmod(curIndex), true)); + } + else + reset(); } |
