diff options
Diffstat (limited to 'sigmodr/tree/SigmodrTree.cpp')
-rw-r--r-- | sigmodr/tree/SigmodrTree.cpp | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/sigmodr/tree/SigmodrTree.cpp b/sigmodr/tree/SigmodrTree.cpp index 63cc5a4c..f7e9790e 100644 --- a/sigmodr/tree/SigmodrTree.cpp +++ b/sigmodr/tree/SigmodrTree.cpp @@ -32,7 +32,9 @@ // Qt includes #include <QtGui/QHeaderView> -Sigmodr::Tree::SigmodrTree::SigmodrTree(QWidget* parent) : +using namespace Sigmodr::Tree; + +SigmodrTree::SigmodrTree(QWidget* parent) : QTreeView(parent) { SigmodrTreeModel* model = new SigmodrTreeModel(this); @@ -42,7 +44,7 @@ Sigmodr::Tree::SigmodrTree::SigmodrTree(QWidget* parent) : setRootIndex(model->index(-1, 0, QModelIndex())); } -QString Sigmodr::Tree::SigmodrTree::description(const QModelIndex& index) +QString SigmodrTree::description(const QModelIndex& index) { QString type = model()->data(index, BaseModel::TypeRole).toString(); QString name = model()->data(index, Qt::DisplayRole).toString(); @@ -51,18 +53,18 @@ QString Sigmodr::Tree::SigmodrTree::description(const QModelIndex& index) return QString("%1: %2").arg(type).arg(name); } -Sigmodr::Widgets::ObjectUI* Sigmodr::Tree::SigmodrTree::editorWidget(const QModelIndex& index) +Sigmodr::Widgets::ObjectUI* SigmodrTree::editorWidget(const QModelIndex& index) { Widgets::ObjectUI* widget = qobject_cast<Widgets::ObjectUI*>(model()->data(index, BaseModel::WidgetRole).value<QWidget*>()); return widget; } -KMenu* Sigmodr::Tree::SigmodrTree::contextMenu(const QModelIndex& index) +KMenu* SigmodrTree::contextMenu(const QModelIndex& index) { return model()->data(index, BaseModel::ContextMenuRole).value<KMenu*>(); } -const Sigmod::Game* Sigmodr::Tree::SigmodrTree::currentGame() const +const Sigmod::Game* SigmodrTree::currentGame() const { QModelIndex index = currentIndex(); if (index.isValid()) @@ -74,30 +76,30 @@ const Sigmod::Game* Sigmodr::Tree::SigmodrTree::currentGame() const return NULL; } -QDomDocument Sigmodr::Tree::SigmodrTree::copy(const QModelIndex& index) +QDomDocument SigmodrTree::copy(const QModelIndex& index) { QDomDocument xml; xml.setContent(model()->data(index, BaseModel::XmlRole).toString()); return xml; } -void Sigmodr::Tree::SigmodrTree::paste(const QModelIndex& index, const QDomDocument& data) +void SigmodrTree::paste(const QModelIndex& index, const QDomDocument& data) { model()->setData(index, data.toString(), BaseModel::XmlRole); } -QList<const Sigmod::Game*> Sigmodr::Tree::SigmodrTree::openedGames() const +QList<const Sigmod::Game*> SigmodrTree::openedGames() const { return m_games.keys(); } -void Sigmodr::Tree::SigmodrTree::addSigmod(Sigmod::Game* game, const KUrl& url) +void SigmodrTree::addGame(Sigmod::Game* game, const KUrl& url) { qobject_cast<SigmodrTreeModel*>(model())->addGame(game); m_games[game] = UrlDirty(url, false); } -void Sigmodr::Tree::SigmodrTree::deleteSigmod(const Sigmod::Game* game) +void SigmodrTree::deleteGame(const Sigmod::Game* game) { if (m_games.contains(game)) { @@ -106,7 +108,7 @@ void Sigmodr::Tree::SigmodrTree::deleteSigmod(const Sigmod::Game* game) } } -bool Sigmodr::Tree::SigmodrTree::isOpen(const KUrl& url) const +bool SigmodrTree::isOpen(const KUrl& url) const { foreach (const UrlDirty& pair, m_games.values()) { @@ -116,14 +118,14 @@ bool Sigmodr::Tree::SigmodrTree::isOpen(const KUrl& url) const return false; } -KUrl Sigmodr::Tree::SigmodrTree::url(const Sigmod::Game* game) const +KUrl SigmodrTree::url(const Sigmod::Game* game) const { if (m_games.contains(game)) return m_games[game].first; return KUrl(); } -QStringList Sigmodr::Tree::SigmodrTree::urls() const +QStringList SigmodrTree::urls() const { QStringList urls; foreach (const UrlDirty& pair, m_games.values()) @@ -131,31 +133,31 @@ QStringList Sigmodr::Tree::SigmodrTree::urls() const return urls; } -void Sigmodr::Tree::SigmodrTree::setUrl(const Sigmod::Game* game, const KUrl& url) +void SigmodrTree::setUrl(const Sigmod::Game* game, const KUrl& url) { if (m_games.contains(game)) m_games[game] = UrlDirty(url, false); } -bool Sigmodr::Tree::SigmodrTree::dirty(const Sigmod::Game* game) const +bool SigmodrTree::dirty(const Sigmod::Game* game) const { if (m_games.contains(game)) return m_games[game].second; return false; } -bool Sigmodr::Tree::SigmodrTree::dirty() const +bool SigmodrTree::dirty() const { - return dirty(currentSigmod()); + return dirty(currentGame()); } -void Sigmodr::Tree::SigmodrTree::setDirty(const Sigmod::Game* game, const bool dirty) +void SigmodrTree::setDirty(const Sigmod::Game* game, const bool dirty) { if (m_games.contains(game)) m_games[game].second = dirty; } -void Sigmodr::Tree::SigmodrTree::setDirty() +void SigmodrTree::setDirty() { - setDirty(currentSigmod(), true); + setDirty(currentGame(), true); } |