diff options
Diffstat (limited to 'sigmodr/tree/SigmodrTreeModel.cpp')
-rw-r--r-- | sigmodr/tree/SigmodrTreeModel.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/sigmodr/tree/SigmodrTreeModel.cpp b/sigmodr/tree/SigmodrTreeModel.cpp index b3832a7b..39320840 100644 --- a/sigmodr/tree/SigmodrTreeModel.cpp +++ b/sigmodr/tree/SigmodrTreeModel.cpp @@ -30,19 +30,21 @@ #include <QtCore/QUrl> #include <QtXml/QDomDocument> -Sigmodr::Tree::SigmodrTreeModel::SigmodrTreeModel(QObject* parent) : +using namespace Sigmodr::Tree; + +SigmodrTreeModel::SigmodrTreeModel(QObject* parent) : QAbstractItemModel(parent), m_root(new RootModel) { connect(m_root, SIGNAL(rowsChanged(QList<int>)), this, SLOT(rowsChanged(QList<int>))); } -Sigmodr::Tree::SigmodrTreeModel::~SigmodrTreeModel() +SigmodrTreeModel::~SigmodrTreeModel() { delete m_root; } -QVariant Sigmodr::Tree::SigmodrTreeModel::data(const QModelIndex& index, int role) const +QVariant SigmodrTreeModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) return QVariant(); @@ -50,7 +52,7 @@ QVariant Sigmodr::Tree::SigmodrTreeModel::data(const QModelIndex& index, int rol return object->data(role); } -QVariant Sigmodr::Tree::SigmodrTreeModel::headerData(int section, Qt::Orientation orientation, int role) const +QVariant SigmodrTreeModel::headerData(int section, Qt::Orientation orientation, int role) const { Q_UNUSED(section) Q_UNUSED(orientation) @@ -58,7 +60,7 @@ QVariant Sigmodr::Tree::SigmodrTreeModel::headerData(int section, Qt::Orientatio return QVariant(); } -QModelIndex Sigmodr::Tree::SigmodrTreeModel::index(int row, int column, const QModelIndex& parent) const +QModelIndex SigmodrTreeModel::index(int row, int column, const QModelIndex& parent) const { if ((row < -1) || (column < -1)) return QModelIndex(); @@ -71,7 +73,7 @@ QModelIndex Sigmodr::Tree::SigmodrTreeModel::index(int row, int column, const QM return createIndex(row, 0, object); } -QModelIndex Sigmodr::Tree::SigmodrTreeModel::parent(const QModelIndex& index) const +QModelIndex SigmodrTreeModel::parent(const QModelIndex& index) const { if (!index.isValid()) return QModelIndex(); @@ -81,19 +83,19 @@ QModelIndex Sigmodr::Tree::SigmodrTreeModel::parent(const QModelIndex& index) co return createIndex(parent->indexNumber(), 0, parent); } -int Sigmodr::Tree::SigmodrTreeModel::rowCount(const QModelIndex& parent) const +int SigmodrTreeModel::rowCount(const QModelIndex& parent) const { BaseModel* object = getItem(parent); return object->rowCount(); } -int Sigmodr::Tree::SigmodrTreeModel::columnCount(const QModelIndex& parent) const +int SigmodrTreeModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent) return 1; } -Qt::ItemFlags Sigmodr::Tree::SigmodrTreeModel::flags(const QModelIndex& index) const +Qt::ItemFlags SigmodrTreeModel::flags(const QModelIndex& index) const { if (!index.isValid()) return 0; @@ -101,7 +103,7 @@ Qt::ItemFlags Sigmodr::Tree::SigmodrTreeModel::flags(const QModelIndex& index) c return object->flags(); } -bool Sigmodr::Tree::SigmodrTreeModel::setData(const QModelIndex& index, const QVariant& value, int role) +bool SigmodrTreeModel::setData(const QModelIndex& index, const QVariant& value, int role) { if (!index.isValid()) return false; @@ -117,7 +119,7 @@ bool Sigmodr::Tree::SigmodrTreeModel::setData(const QModelIndex& index, const QV return success; } -Sigmodr::Tree::BaseModel* Sigmodr::Tree::SigmodrTreeModel::getItem(const QModelIndex& index) const +BaseModel* SigmodrTreeModel::getItem(const QModelIndex& index) const { if (index.isValid()) { @@ -128,12 +130,12 @@ Sigmodr::Tree::BaseModel* Sigmodr::Tree::SigmodrTreeModel::getItem(const QModelI return m_root; } -QStringList Sigmodr::Tree::SigmodrTreeModel::mimeTypes() const +QStringList SigmodrTreeModel::mimeTypes() const { return QStringList() << "application/x-sigmod+xml" << "text/uri-list"; } -QMimeData* Sigmodr::Tree::SigmodrTreeModel::mimeData(const QModelIndexList& indexes) const +QMimeData* SigmodrTreeModel::mimeData(const QModelIndexList& indexes) const { QMimeData *mimeData = new QMimeData; if ((indexes.size() == 1) && indexes[0].isValid()) @@ -145,7 +147,7 @@ QMimeData* Sigmodr::Tree::SigmodrTreeModel::mimeData(const QModelIndexList& inde return mimeData; } -bool Sigmodr::Tree::SigmodrTreeModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) +bool SigmodrTreeModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) { Q_UNUSED(row) Q_UNUSED(column) @@ -175,19 +177,19 @@ bool Sigmodr::Tree::SigmodrTreeModel::dropMimeData(const QMimeData* data, Qt::Dr return success; } -void Sigmodr::Tree::SigmodrTreeModel::addGame(Sigmod::Game* game) +void SigmodrTreeModel::addGame(Sigmod::Game* game) { - m_root->addGame(sigmod); + m_root->addGame(game); reset(); } -void Sigmodr::Tree::SigmodrTreeModel::deleteGame(const Sigmod::Game* game) +void SigmodrTreeModel::deleteGame(const Sigmod::Game* game) { m_root->deleteGame(game); reset(); } -const Sigmod::Game* Sigmodr::Tree::SigmodrTreeModel::findGame(const QModelIndex& index) const +const Sigmod::Game* SigmodrTreeModel::findGame(const QModelIndex& index) const { QModelIndex curIndex = index; QModelIndex parIndex = parent(curIndex); @@ -199,7 +201,7 @@ const Sigmod::Game* Sigmodr::Tree::SigmodrTreeModel::findGame(const QModelIndex& return qobject_cast<const Sigmod::Game*>(getItem(curIndex)->object()); } -void Sigmodr::Tree::SigmodrTreeModel::rowsChanged(const QList<int>& rows) +void SigmodrTreeModel::rowsChanged(const QList<int>& rows) { QModelIndex curIndex; foreach (int row, rows) |