MCPcopy Create free account
hub / github.com/Liniyous/ElaWidgetTools / data

Method data

ElaWidgetToolsExample/ModelView/T_IconModel.cpp:41–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41QVariant T_IconModel::data(const QModelIndex& index, int role) const
42{
43 if (!index.isValid() || index.row() < 0 || index.row() >= _rowCount)
44 {
45 return {};
46 }
47 if (role == Qt::ToolTipRole)
48 {
49 return getIconNameFromModelIndex(index);
50 }
51 if (role == Qt::UserRole)
52 {
53 if (!_pIsSearchMode)
54 {
55 if (index.row() >= _metaEnum.keyCount() - 1)
56 {
57 return QVariant();
58 }
59 return QStringList{_metaEnum.key(index.row() + 1), QChar(_metaEnum.value(index.row() + 1))};
60 }
61 else
62 {
63 QStringList iconList;
64 if (index.row() >= _searchKeyList.count())
65 {
66 return QVariant();
67 }
68 iconList.append(_searchKeyList.at(index.row()));
69 iconList.append(QChar(_metaEnum.keyToValue(_searchKeyList.at(index.row()).toUtf8().constData())));

Callers

nothing calls this directly

Calls 1

countMethod · 0.80

Tested by

no test coverage detected