diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2009-03-22 16:51:17 -0400 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2009-03-22 16:51:17 -0400 |
commit | f336da57a6d5c1737fdec4f957e1454bb63771b4 (patch) | |
tree | 8663a57722e0386824329219f57bc9bc447f87d4 /sigmodr | |
parent | 30b72ba48120d0d928524da84e36810506258470 (diff) | |
download | sigen-f336da57a6d5c1737fdec4f957e1454bb63771b4.tar.gz sigen-f336da57a6d5c1737fdec4f957e1454bb63771b4.tar.xz sigen-f336da57a6d5c1737fdec4f957e1454bb63771b4.zip |
Add convenience methods to SigmodrTree
Diffstat (limited to 'sigmodr')
-rw-r--r-- | sigmodr/tree/SigmodrTree.cpp | 14 | ||||
-rw-r--r-- | sigmodr/tree/SigmodrTree.h | 4 |
2 files changed, 15 insertions, 3 deletions
diff --git a/sigmodr/tree/SigmodrTree.cpp b/sigmodr/tree/SigmodrTree.cpp index 552fad0c..2caca70a 100644 --- a/sigmodr/tree/SigmodrTree.cpp +++ b/sigmodr/tree/SigmodrTree.cpp @@ -46,15 +46,25 @@ SigmodrTree::SigmodrTree(QWidget* parent) : setRootIndex(model->index(-1, 0, QModelIndex())); } -QString SigmodrTree::description(const QModelIndex& index) +QString SigmodrTree::description(const QModelIndex& index) const { - QString type = model()->data(index, BaseModel::TypeRole).toString(); + QString type = typeOf(index); QString name = model()->data(index, Qt::DisplayRole).toString(); if (type.isEmpty() && name.isEmpty()) return ""; return QString("%1: %2").arg(type).arg(name); } +QString SigmodrTree::typeOf(const QModelIndex& index) const +{ + return model()->data(index, BaseModel::TypeRole).toString(); +} + +QStringList SigmodrTree::dropTypes(const QModelIndex& index) const +{ + return model()->data(index, BaseModel::DropAcceptRole).toString().split(';'); +} + ObjectUI* SigmodrTree::editorWidget(const QModelIndex& index) { ObjectUI* widget = qobject_cast<ObjectUI*>(model()->data(index, BaseModel::WidgetRole).value<QWidget*>()); diff --git a/sigmodr/tree/SigmodrTree.h b/sigmodr/tree/SigmodrTree.h index e04c1eba..df808b15 100644 --- a/sigmodr/tree/SigmodrTree.h +++ b/sigmodr/tree/SigmodrTree.h @@ -52,7 +52,9 @@ class SIGMODRTREE_EXPORT SigmodrTree : public QTreeView public: SigmodrTree(QWidget* parent = 0); - QString description(const QModelIndex& index); + QString description(const QModelIndex& index) const; + QString typeOf(const QModelIndex& index) const; + QStringList dropTypes(const QModelIndex& index) const; Widgets::ObjectUI* editorWidget(const QModelIndex& index); KMenu* contextMenu(const QModelIndex& index); |