• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kde-runtime API Reference
  • KDE Home
  • Contact Us
 

PlasmaCore

  • sources
  • kde-4.14
  • kde-runtime
  • plasma
  • declarativeimports
  • core
datamodel.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2010 by Marco Martin <mart@kde.org>
3 
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Library General Public License as
6  * published by the Free Software Foundation; either version 2, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 #include "datamodel.h"
21 #include "datasource.h"
22 
23 #include <QTimer>
24 
25 #include <KDebug>
26 
27 namespace Plasma
28 {
29 
30 SortFilterModel::SortFilterModel(QObject* parent)
31  : QSortFilterProxyModel(parent)
32 {
33  setObjectName("SortFilterModel");
34  setDynamicSortFilter(true);
35  connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
36  this, SIGNAL(countChanged()));
37  connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
38  this, SIGNAL(countChanged()));
39  connect(this, SIGNAL(modelReset()),
40  this, SIGNAL(countChanged()));
41  connect(this, SIGNAL(countChanged()), this, SLOT(syncRoleNames()));
42 }
43 
44 SortFilterModel::~SortFilterModel()
45 {
46 }
47 
48 void SortFilterModel::syncRoleNames()
49 {
50  if (!sourceModel()) {
51  return;
52  }
53 
54  m_roleIds.clear();
55  QHash<int, QByteArray>::const_iterator i;
56  for (i = roleNames().constBegin(); i != roleNames().constEnd(); ++i) {
57  m_roleIds[i.value()] = i.key();
58  }
59 
60  setRoleNames(sourceModel()->roleNames());
61  setFilterRole(m_filterRole);
62  setSortRole(m_sortRole);
63 }
64 
65 int SortFilterModel::roleNameToId(const QString &name)
66 {
67  if (!m_roleIds.contains(name)) {
68  return Qt::DisplayRole;
69  }
70  return m_roleIds.value(name);
71 }
72 
73 void SortFilterModel::setModel(QAbstractItemModel* model)
74 {
75  if (model == sourceModel()) {
76  return;
77  }
78 
79  if (sourceModel()) {
80  disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(syncRoleNames()));
81  }
82 
83  QSortFilterProxyModel::setSourceModel(model);
84 
85  if (model) {
86  connect(model, SIGNAL(modelReset()), this, SLOT(syncRoleNames()));
87  syncRoleNames();
88  }
89 
90  emit sourceModelChanged(model);
91 }
92 
93 void SortFilterModel::setFilterRegExp(const QString &exp)
94 {
95  if (exp == filterRegExp()) {
96  return;
97  }
98  QSortFilterProxyModel::setFilterRegExp(QRegExp(exp, Qt::CaseInsensitive));
99  filterRegExpChanged(exp);
100 }
101 
102 QString SortFilterModel::filterRegExp() const
103 {
104  return QSortFilterProxyModel::filterRegExp().pattern();
105 }
106 
107 void SortFilterModel::setFilterRole(const QString &role)
108 {
109  QSortFilterProxyModel::setFilterRole(roleNameToId(role));
110  m_filterRole = role;
111 }
112 
113 QString SortFilterModel::filterRole() const
114 {
115  return m_filterRole;
116 }
117 
118 void SortFilterModel::setSortRole(const QString &role)
119 {
120  m_sortRole = role;
121  if (role.isEmpty()) {
122  sort(-1, Qt::AscendingOrder);
123  } else if (sourceModel()) {
124  QSortFilterProxyModel::setSortRole(roleNameToId(role));
125  sort(0, sortOrder());
126  }
127 }
128 
129 QString SortFilterModel::sortRole() const
130 {
131  return m_sortRole;
132 }
133 
134 void SortFilterModel::setSortOrder(const Qt::SortOrder order)
135 {
136  if (order != sortOrder()) {
137  emit sortOrderChanged(order);
138  }
139 
140  sort(0, order);
141 }
142 
143 QVariantHash SortFilterModel::get(int row) const
144 {
145  QModelIndex idx = index(row, 0);
146  QVariantHash hash;
147 
148  QHash<int, QByteArray>::const_iterator i;
149  for (i = roleNames().constBegin(); i != roleNames().constEnd(); ++i) {
150  hash[i.value()] = data(idx, i.key());
151  }
152 
153  return hash;
154 }
155 
156 int SortFilterModel::mapRowToSource(int row) const
157 {
158  QModelIndex idx = index(row, 0);
159  return mapToSource(idx).row();
160 }
161 
162 int SortFilterModel::mapRowFromSource(int row) const
163 {
164  if (!sourceModel()) {
165  kWarning() << "No source model defined!";
166  return -1;
167  }
168  QModelIndex idx = sourceModel()->index(row, 0);
169  return mapFromSource(idx).row();
170 }
171 
172 DataModel::DataModel(QObject* parent)
173  : QAbstractItemModel(parent),
174  m_dataSource(0),
175  m_maxRoleId(Qt::UserRole+1)
176 {
177  //There is one reserved role name: DataEngineSource
178  m_roleNames[m_maxRoleId] = "DataEngineSource";
179  m_roleIds["DataEngineSource"] = m_maxRoleId;
180  ++m_maxRoleId;
181 
182  setObjectName("DataModel");
183  connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
184  this, SIGNAL(countChanged()));
185  connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)),
186  this, SIGNAL(countChanged()));
187  connect(this, SIGNAL(modelReset()),
188  this, SIGNAL(countChanged()));
189 }
190 
191 DataModel::~DataModel()
192 {
193 }
194 
195 void DataModel::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
196 {
197  if (!m_sourceFilter.isEmpty() && m_sourceFilterRE.isValid() && !m_sourceFilterRE.exactMatch(sourceName)) {
198  return;
199  }
200 
201  if (m_keyRoleFilter.isEmpty()) {
202  //an item is represented by a source: keys are roles m_roleLevel == FirstLevel
203  QVariantList list;
204 
205  if (!m_dataSource->data().isEmpty()) {
206  QVariantHash::const_iterator i = m_dataSource->data().constBegin();
207 
208  while (i != m_dataSource->data().constEnd()) {
209  if (!m_sourceFilter.isEmpty() && m_sourceFilterRE.isValid() && !m_sourceFilterRE.exactMatch(i.key())) {
210  ++i;
211  continue;
212  }
213  QVariant value = i.value();
214  if (value.isValid() && value.canConvert<Plasma::DataEngine::Data>()) {
215  Plasma::DataEngine::Data data = value.value<Plasma::DataEngine::Data>();
216  data["DataEngineSource"] = i.key();
217  list.append(data);
218  }
219  ++i;
220  }
221  }
222  setItems(QString(), list);
223  } else {
224  //a key that matches the one we want exists and is a list of DataEngine::Data
225  if (data.contains(m_keyRoleFilter) &&
226  data.value(m_keyRoleFilter).canConvert<QVariantList>()) {
227  setItems(sourceName, data.value(m_keyRoleFilter).value<QVariantList>());
228  } else if (m_keyRoleFilterRE.isValid()) {
229  //try to match the key we want with a regular expression if set
230  QVariantList list;
231  QHash<QString, QVariant>::const_iterator i;
232  for (i = data.constBegin(); i != data.constEnd(); ++i) {
233  if (m_keyRoleFilterRE.exactMatch(i.key())) {
234  list.append(i.value());
235  }
236  }
237  setItems(sourceName, list);
238  }
239  }
240 }
241 
242 void DataModel::setDataSource(QObject *object)
243 {
244  DataSource *source = qobject_cast<DataSource *>(object);
245  if (!source) {
246  kWarning() << "Error: DataSource type expected";
247  return;
248  }
249  if (m_dataSource == source) {
250  return;
251  }
252 
253  if (m_dataSource) {
254  disconnect(m_dataSource, 0, this, 0);
255  }
256 
257  m_dataSource = source;
258 
259  const QHash<QString, QVariant> data = source->data();
260  QHash<QString, QVariant>::const_iterator i = data.constBegin();
261  while (i != data.constEnd()) {
262  dataUpdated(i.key(), i.value().value<Plasma::DataEngine::Data>());
263  ++i;
264  }
265 
266  connect(m_dataSource, SIGNAL(newData(const QString &, const Plasma::DataEngine::Data &)),
267  this, SLOT(dataUpdated(const QString &, const Plasma::DataEngine::Data &)));
268  connect(m_dataSource, SIGNAL(sourceRemoved(const QString &)), this, SLOT(removeSource(const QString &)));
269  connect(m_dataSource, SIGNAL(sourceDisconnected(const QString &)), this, SLOT(removeSource(const QString &)));
270 }
271 
272 QObject *DataModel::dataSource() const
273 {
274  return m_dataSource;
275 }
276 
277 void DataModel::setKeyRoleFilter(const QString& key)
278 {
279  // the "key role filter" can be used in one of three ways:
280  //
281  // 1) empty string -> all data is used, each source is one row in the model
282  // 2) matches a key in the data exactly -> only that key/value pair is used, and the value is
283  // treated as a collection where each item in the collection becomes a row in the model
284  // 3) regular expression -> matches zero or more keys in the data, and each matching key/value
285  // pair becomes a row in the model
286  if (m_keyRoleFilter == key) {
287  return;
288  }
289 
290  m_keyRoleFilter = key;
291  m_keyRoleFilterRE = QRegExp(m_keyRoleFilter);
292 }
293 
294 QString DataModel::keyRoleFilter() const
295 {
296  return m_keyRoleFilter;
297 }
298 
299 void DataModel::setSourceFilter(const QString& key)
300 {
301  if (m_sourceFilter == key) {
302  return;
303  }
304 
305  m_sourceFilter = key;
306  m_sourceFilterRE = QRegExp(key);
307  /*
308  FIXME: if the user changes the source filter, it won't immediately be reflected in the
309  available data
310  if (m_sourceFilterRE.isValid()) {
311  .. iterate through all items and weed out the ones that don't match ..
312  }
313  */
314 }
315 
316 QString DataModel::sourceFilter() const
317 {
318  return m_sourceFilter;
319 }
320 
321 void DataModel::setItems(const QString &sourceName, const QVariantList &list)
322 {
323  const int oldLength = m_items.value(sourceName).count();
324  const int delta = list.length() - oldLength;
325  const bool firstRun = m_items.isEmpty();
326 
327  //At what row number the first item associated to this source starts
328  int sourceIndex = 0;
329  QMap<QString, QVector<QVariant> >::const_iterator i;
330  for (i = m_items.constBegin(); i != m_items.constEnd(); ++i) {
331  if (i.key() == sourceName) {
332  break;
333  }
334  sourceIndex += i.value().count();
335  }
336  //signal as inserted the rows at the end, all the other rows will signal a dataupdated.
337  //better than a model reset because doesn't cause deletion and re-creation of every list item on a qml ListView, repeaters etc.
338  //the first run it gets reset because otherwise setRoleNames gets broken
339  if (firstRun) {
340  beginResetModel();
341  } else if (delta > 0) {
342  beginInsertRows(QModelIndex(), sourceIndex + oldLength, sourceIndex + list.length() - 1);
343  } else if (delta < 0) {
344  beginRemoveRows(QModelIndex(), sourceIndex + list.length(), sourceIndex + oldLength - 1);
345  }
346  //convert to vector, so data() will be O(1)
347  m_items[sourceName] = list.toVector();
348 
349  if (!list.isEmpty()) {
350  if (list.first().canConvert<QVariantHash>()) {
351  foreach (const QVariant &item, list) {
352  const QVariantHash &vh = item.value<QVariantHash>();
353  QHashIterator<QString, QVariant> it(vh);
354  while (it.hasNext()) {
355  it.next();
356  const QString &roleName = it.key();
357  if (!m_roleIds.contains(roleName)) {
358  ++m_maxRoleId;
359  m_roleNames[m_maxRoleId] = roleName.toLatin1();
360  m_roleIds[roleName] = m_maxRoleId;
361  }
362  }
363  }
364  } else {
365  foreach (const QVariant &item, list) {
366  const QVariantMap &vh = item.value<QVariantMap>();
367  QMapIterator<QString, QVariant> it(vh);
368  while (it.hasNext()) {
369  it.next();
370  const QString &roleName = it.key();
371  if (!m_roleIds.contains(roleName)) {
372  ++m_maxRoleId;
373  m_roleNames[m_maxRoleId] = roleName.toLatin1();
374  m_roleIds[roleName] = m_maxRoleId;
375  }
376  }
377  }
378  }
379  }
380 
381  setRoleNames(m_roleNames);
382 
383  if (firstRun) {
384  endResetModel();
385  } else if (delta > 0) {
386  endInsertRows();
387  } else if (delta < 0) {
388  endRemoveRows();
389  }
390  emit dataChanged(createIndex(sourceIndex, 0),
391  createIndex(sourceIndex + qMin(list.length(), oldLength), 0));
392 }
393 
394 void DataModel::removeSource(const QString &sourceName)
395 {
396  //FIXME: this could be way more efficient by not resetting the whole model
397  //FIXME: find a way to remove only the proper things also in the case where sources are items
398 
399  if (m_keyRoleFilter.isEmpty()) {
400  //source name in the map, linear scan
401  for (int i = 0; i < m_items.value(QString()).count(); ++i) {
402  if (m_items.value(QString())[i].value<QVariantHash>().value("DataEngineSource") == sourceName) {
403  beginResetModel();
404  m_items[QString()].remove(i);
405  endResetModel();
406  break;
407  }
408  }
409  } else {
410  //source name as key of the map
411  if (m_items.contains(sourceName)) {
412  beginResetModel();
413  m_items.remove(sourceName);
414  endResetModel();
415  }
416  }
417 }
418 
419 QVariant DataModel::data(const QModelIndex &index, int role) const
420 {
421  if (!index.isValid() || index.column() > 0 ||
422  index.row() < 0 || index.row() >= countItems()){
423  return QVariant();
424  }
425 
426  int count = 0;
427  int actualRow = 0;
428  QString source;
429  QMap<QString, QVector<QVariant> >::const_iterator i;
430  for (i = m_items.constBegin(); i != m_items.constEnd(); ++i) {
431  const int oldCount = count;
432  count += i.value().count();
433 
434  if (index.row() < count) {
435  source = i.key();
436  actualRow = index.row() - oldCount;
437  break;
438  }
439  }
440 
441  //is it the reserved role: DataEngineSource ?
442  //also, if each source is an item DataEngineSource is a role between all the others, otherwise we know it from the role variable
443  //finally, sub items are some times QVariantHash some times QVariantMaps
444  if (!m_keyRoleFilter.isEmpty() && m_roleNames.value(role) == "DataEngineSource") {
445  return source;
446  } else if (m_items.value(source).value(actualRow).canConvert<QVariantHash>()) {
447  return m_items.value(source).value(actualRow).value<QVariantHash>().value(m_roleNames.value(role));
448  } else {
449  return m_items.value(source).value(actualRow).value<QVariantMap>().value(m_roleNames.value(role));
450  }
451 }
452 
453 QVariant DataModel::headerData(int section, Qt::Orientation orientation, int role) const
454 {
455  Q_UNUSED(section)
456  Q_UNUSED(orientation)
457  Q_UNUSED(role)
458 
459  return QVariant();
460 }
461 
462 QModelIndex DataModel::index(int row, int column, const QModelIndex &parent) const
463 {
464  if (parent.isValid() || column > 0 || row < 0 || row >= countItems()) {
465  return QModelIndex();
466  }
467 
468  return createIndex(row, column, 0);
469 }
470 
471 QModelIndex DataModel::parent(const QModelIndex &child) const
472 {
473  Q_UNUSED(child)
474 
475  return QModelIndex();
476 }
477 
478 int DataModel::rowCount(const QModelIndex &parent) const
479 {
480  //this is not a tree
481  //TODO: make it possible some day?
482  if (parent.isValid()) {
483  return 0;
484  }
485 
486  return countItems();
487 }
488 
489 int DataModel::columnCount(const QModelIndex &parent) const
490 {
491  if (parent.isValid()) {
492  return 0;
493  }
494 
495  return 1;
496 }
497 
498 QVariantHash DataModel::get(int row) const
499 {
500  QModelIndex idx = index(row, 0);
501  QVariantHash hash;
502 
503  QHash<int, QByteArray>::const_iterator i;
504  for (i = roleNames().constBegin(); i != roleNames().constEnd(); ++i) {
505  hash[i.value()] = data(idx, i.key());
506  }
507 
508  return hash;
509 }
510 
511 int DataModel::roleNameToId(const QString &name)
512 {
513  if (!m_roleIds.contains(name)) {
514  return -1;
515  }
516  return m_roleIds.value(name);
517 }
518 
519 }
520 
521 #include "datamodel.moc"
QSortFilterProxyModel::index
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
QVariant::canConvert
bool canConvert(Type t) const
datasource.h
Plasma::SortFilterModel::setFilterRole
void setFilterRole(const QString &role)
Definition: datamodel.cpp:107
QModelIndex
QSortFilterProxyModel::setSortRole
void setSortRole(int role)
Plasma::DataModel::get
Q_INVOKABLE QVariantHash get(int i) const
Returns the item at index in the list model.
Definition: datamodel.cpp:498
Plasma::DataModel::setSourceFilter
void setSourceFilter(const QString &key)
Include only sources that matches this regexp in the model.
Definition: datamodel.cpp:299
Plasma::DataModel::dataSource
QObject * dataSource() const
QAbstractItemModel::index
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const =0
QMap::contains
bool contains(const Key &key) const
QHash::key
const Key key(const T &value) const
Plasma::SortFilterModel::sortRole
QString sortRole() const
QSortFilterProxyModel::sort
virtual void sort(int column, Qt::SortOrder order)
QAbstractItemModel::setRoleNames
void setRoleNames(const QHash< int, QByteArray > &roleNames)
QSortFilterProxyModel::setSourceModel
virtual void setSourceModel(QAbstractItemModel *sourceModel)
Plasma::SortFilterModel::filterRegExpChanged
void filterRegExpChanged(const QString &)
Plasma::SortFilterModel::filterRegExp
QString filterRegExp() const
QAbstractItemModel::roleNames
const QHash< int, QByteArray > & roleNames() const
QMap::constBegin
const_iterator constBegin() const
QMap
Plasma::SortFilterModel::countChanged
void countChanged()
QVariant::value
T value() const
Plasma::DataModel::DataModel
DataModel(QObject *parent=0)
Definition: datamodel.cpp:172
Plasma::SortFilterModel::get
Q_INVOKABLE QVariantHash get(int i) const
Returns the item at index in the list model.
Definition: datamodel.cpp:143
QAbstractItemModel::modelReset
void modelReset()
QObject::disconnect
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
Plasma::DataModel::keyRoleFilter
QString keyRoleFilter() const
Plasma::DataModel::setKeyRoleFilter
void setKeyRoleFilter(const QString &key)
Include only items with a key that matches this regexp in the model.
Definition: datamodel.cpp:277
QAbstractItemModel::beginResetModel
void beginResetModel()
Plasma::DataModel::countChanged
void countChanged()
QRegExp
Plasma::DataSource::data
QVariantHash data
All the data fetched by this dataengine.
Definition: datasource.h:95
QModelIndex::isValid
bool isValid() const
QSortFilterProxyModel::setFilterRole
void setFilterRole(int role)
Plasma::DataModel::roleNameToId
int roleNameToId(const QString &name)
Definition: datamodel.cpp:511
QMapIterator
Plasma::DataModel::setDataSource
void setDataSource(QObject *source)
Definition: datamodel.cpp:242
QHash::constEnd
const_iterator constEnd() const
QAbstractItemModel::dataChanged
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
QHash
QAbstractItemModel::endInsertRows
void endInsertRows()
Plasma::DataModel::~DataModel
~DataModel()
Definition: datamodel.cpp:191
QObject
Plasma::SortFilterModel::mapRowToSource
Q_INVOKABLE int mapRowToSource(int i) const
Definition: datamodel.cpp:156
QObject::setObjectName
void setObjectName(const QString &name)
QHashIterator
QString::isEmpty
bool isEmpty() const
QMap::constEnd
const_iterator constEnd() const
QAbstractItemModel::beginRemoveRows
void beginRemoveRows(const QModelIndex &parent, int first, int last)
QModelIndex::row
int row() const
Plasma::DataModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: datamodel.cpp:478
QSortFilterProxyModel::setDynamicSortFilter
void setDynamicSortFilter(bool enable)
Plasma::DataModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Definition: datamodel.cpp:453
QString
Plasma::SortFilterModel::mapRowFromSource
Q_INVOKABLE int mapRowFromSource(int i) const
Definition: datamodel.cpp:162
QAbstractItemModel::rowsRemoved
void rowsRemoved(const QModelIndex &parent, int start, int end)
QAbstractItemModel::createIndex
QModelIndex createIndex(int row, int column, void *ptr) const
QHash::clear
void clear()
QHash::value
const T value(const Key &key) const
QSortFilterProxyModel
QAbstractItemModel::beginInsertRows
void beginInsertRows(const QModelIndex &parent, int first, int last)
Plasma::DataModel::countItems
int countItems() const
Definition: datamodel.h:220
Plasma::SortFilterModel::setSortOrder
void setSortOrder(const Qt::SortOrder order)
Definition: datamodel.cpp:134
QMap::key
const Key key(const T &value) const
Plasma::DataModel::data
QVariant data(const QModelIndex &index, int role) const
Definition: datamodel.cpp:419
QHash::const_iterator
datamodel.h
QHash::constBegin
const_iterator constBegin() const
QAbstractProxyModel::sourceModel
QAbstractItemModel * sourceModel() const
QSortFilterProxyModel::mapToSource
virtual QModelIndex mapToSource(const QModelIndex &proxyIndex) const
QString::toLatin1
QByteArray toLatin1() const
QSortFilterProxyModel::sortOrder
Qt::SortOrder sortOrder() const
Plasma::DataModel::setItems
void setItems(const QString &sourceName, const QVariantList &list)
Definition: datamodel.cpp:321
Plasma::SortFilterModel::syncRoleNames
void syncRoleNames()
Definition: datamodel.cpp:48
QSortFilterProxyModel::mapFromSource
virtual QModelIndex mapFromSource(const QModelIndex &sourceIndex) const
Plasma::SortFilterModel::filterRole
QString filterRole() const
QRegExp::isValid
bool isValid() const
Plasma::SortFilterModel::sourceModelChanged
void sourceModelChanged(QObject *)
QRegExp::pattern
QString pattern() const
Plasma::SortFilterModel::setSortRole
void setSortRole(const QString &role)
Definition: datamodel.cpp:118
Plasma::DataModel::sourceFilter
QString sourceFilter() const
QModelIndex::column
int column() const
QAbstractItemModel
Plasma::SortFilterModel::~SortFilterModel
~SortFilterModel()
Definition: datamodel.cpp:44
QVariant::isValid
bool isValid() const
QHash::contains
bool contains(const Key &key) const
Plasma::SortFilterModel::setModel
void setModel(QAbstractItemModel *source)
Definition: datamodel.cpp:73
QMap::isEmpty
bool isEmpty() const
Plasma::DataModel::index
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Definition: datamodel.cpp:462
QAbstractItemModel::endRemoveRows
void endRemoveRows()
Plasma::DataModel::count
int count() const
Definition: datamodel.h:184
Plasma::DataSource
Definition: datasource.h:42
QAbstractItemModel::rowsInserted
void rowsInserted(const QModelIndex &parent, int start, int end)
Plasma::SortFilterModel::sortOrderChanged
void sortOrderChanged(const Qt::SortOrder)
QAbstractItemModel::endResetModel
void endResetModel()
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject::parent
QObject * parent() const
QRegExp::exactMatch
bool exactMatch(const QString &str) const
Plasma::SortFilterModel::setFilterRegExp
void setFilterRegExp(const QString &exp)
Definition: datamodel.cpp:93
Plasma::SortFilterModel::roleNameToId
int roleNameToId(const QString &name)
Definition: datamodel.cpp:65
Plasma::DataModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition: datamodel.cpp:489
QSortFilterProxyModel::data
virtual QVariant data(const QModelIndex &index, int role) const
QSortFilterProxyModel::setFilterRegExp
void setFilterRegExp(const QRegExp &regExp)
QMap::value
const T value(const Key &key) const
Plasma::SortFilterModel::SortFilterModel
SortFilterModel(QObject *parent=0)
Definition: datamodel.cpp:30
QMap::remove
int remove(const Key &key)
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:08:28 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

PlasmaCore

Skip menu "PlasmaCore"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kde-runtime API Reference

Skip menu "kde-runtime API Reference"
  • KCMShell
  • KNotify
  • Plasma Runtime
  •     PlasmaCore
  •     DragAndDrop
  •     PlasmaComponents
  •     PlasmaExtraComponents
  •     QtExtraComponents

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal