11 #ifndef smtk_extension_qtDescriptivePhraseModel_h
12 #define smtk_extension_qtDescriptivePhraseModel_h
15 #include "smtk/extension/qt/Exports.h"
16 #include "smtk/view/DescriptivePhrase.h"
17 #include "smtk/view/PhraseModel.h"
18 #include "smtk/view/PhraseModelObserver.h"
20 #include <QAbstractItemModel>
47 static void setDefaultPhraseColor(
const std::string& entityType,
const QColor& color)
49 s_defaultColors[entityType] = color;
51 static QColor defaultPhraseColor(
const std::string& entityType);
55 std::string invisibleIconURL()
const {
return m_invisibleIconURL; }
56 void setVisibleIconURL(
const std::string& url) { m_visibleIconURL = url; }
57 void setInvisibleIconURL(
const std::string& url) { m_invisibleIconURL = url; }
62 TitleTextRole = Qt::UserRole + 100,
63 EditableTitleTextRole =
65 SubtitleTextRole = Qt::UserRole + 102,
70 PhraseCleanRole = Qt::UserRole + 107,
71 PhraseLockRole = Qt::UserRole + 108,
72 ModelActiveRole = Qt::UserRole + 109,
73 TitleTextMutableRole = Qt::UserRole + 110,
75 PhrasePtrRole = Qt::UserRole + 112,
76 BadgesRole = Qt::UserRole + 113
82 QModelIndex index(
int row,
int column,
const QModelIndex& parent)
const override;
83 QModelIndex parent(
const QModelIndex& child)
const override;
84 bool hasChildren(
const QModelIndex& parent)
const override;
86 int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
87 int columnCount(
const QModelIndex& inParent = QModelIndex())
const override
93 QVariant headerData(
int section, Qt::Orientation orientation,
int role)
const override;
94 QVariant data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
97 bool removeRows(
int position,
int rows,
const QModelIndex& parent = QModelIndex())
override;
98 bool setData(
const QModelIndex& index,
const QVariant& value,
int role = Qt::EditRole)
override;
100 Qt::ItemFlags flags(
const QModelIndex& index)
const override;
102 void setDeleteOnRemoval(
bool del) { m_deleteOnRemoval = del; }
105 QModelIndex indexFromPath(
const std::vector<int>& path)
const;
107 template<
typename T,
typename C>
111 const QModelIndex& top = QModelIndex(),
112 bool onlyBuilt =
true);
113 template<
typename T,
typename C>
117 const QModelIndex& top = QModelIndex(),
118 bool onlyBuilt =
true)
const;
120 void rebuildSubphrases(
const QModelIndex& qidx);
122 Qt::DropActions supportedDropActions()
const override;
124 void setColumnName(
const std::string& name) { m_columnName = name; }
125 const std::string& columnName()
const {
return m_columnName; }
128 void phraseTitleChanged(
const QModelIndex&);
134 const std::vector<int>& src,
135 const std::vector<int>& dst,
136 const std::vector<int>& range);
140 bool m_deleteOnRemoval;
141 std::string m_visibleIconURL;
142 std::string m_invisibleIconURL;
143 static std::map<std::string, QColor> s_defaultColors;
144 std::string m_columnName;
153 template<
typename T,
typename C>
157 const QModelIndex& top,
161 if (!visitor(
this, top, collector))
168 if (phrase && (!onlyBuilt || phrase->areSubphrasesBuilt()))
170 for (
int row = 0; row < this->
rowCount(top); ++row)
172 if (this->
foreach_phrase(visitor, collector, this->index(row, 0, top), onlyBuilt))
181 template<
typename T,
typename C>
185 const QModelIndex& top,
186 bool onlyBuilt)
const
189 if (!visitor(
this, top, collector))
196 if (phrase && (!onlyBuilt || phrase->areSubphrasesBuilt()))
198 for (
int row = 0; row < this->
rowCount(top); ++row)
200 if (this->
foreach_phrase(visitor, collector, this->index(row, 0, top), onlyBuilt))
211 #endif // smtk_extension_qtDescriptivePhraseModel_h