Added mapToSource mapFromSource
commitf4717ef84459b67b80e64e7f253258f1afb7d11b
authorNick Dedekind <nicholas.dedekind@gmail.com>
dateThu 15 Aug 2013, 17:03 (13 years ago)
parent5e49afc
plugins/Utils/qsortfilterproxymodelqml.cpp+20
@@ -121,3 +121,23 @@ QSortFilterProxyModelQML::findFirst(int role, const QVariant& value) const
121121 return -1;
122122 }
123123}
124+
125+int
126+QSortFilterProxyModelQML::mapFromSource(int row)
127+{
128+ if (sourceModel() != NULL) {
129+ return QSortFilterProxyModel::mapFromSource(sourceModel()->index(row, 0)).row();
130+ } else {
131+ return -1;
132+ }
133+}
134+
135+int
136+QSortFilterProxyModelQML::mapToSource(int row)
137+{
138+ if (sourceModel() != NULL) {
139+ return QSortFilterProxyModel::mapToSource(index(row, 0)).row();
140+ } else {
141+ return -1;
142+ }
143+}
plugins/Utils/qsortfilterproxymodelqml.h+3
@@ -45,6 +45,9 @@ public:
4545 void setModel(QAbstractItemModel *model);
4646 void setInvertMatch(bool invertMatch);
4747
48+ Q_INVOKABLE int mapFromSource(int row);
49+ Q_INVOKABLE int mapToSource(int row);
50+
4851Q_SIGNALS:
4952 void totalCountChanged();
5053 void countChanged();