model()->modelForSource()
This commit is contained in:
parent
dea7942533
commit
a7470063a0
@ -64,7 +64,7 @@ bool SourcesOnRequestEngine::sourceRequestEvent(const QString &source)
|
||||
// expects. So ALWAYS key the new data by the source string as below:
|
||||
setData(source, "Update Count", 0);
|
||||
|
||||
if (!model(source)) {
|
||||
if (!modelForSource(source)) {
|
||||
QStandardItemModel *m = new QStandardItemModel;
|
||||
m->appendRow(new QStandardItem("Item1, first update"));
|
||||
m->appendRow(new QStandardItem("Item2, first update"));
|
||||
@ -95,7 +95,7 @@ bool SourcesOnRequestEngine::updateSourceEvent(const QString &source)
|
||||
const int updateCount = containerForSource(source)->data().value("Update Count").toInt() + 1;
|
||||
setData(source, "Update Count", updateCount);
|
||||
|
||||
QStandardItemModel *m = qobject_cast<QStandardItemModel *>(model(source));
|
||||
QStandardItemModel *m = qobject_cast<QStandardItemModel *>(modelForSource(source));
|
||||
if (m) {
|
||||
m->clear();
|
||||
m->appendRow(new QStandardItem(QString("Item1, update %1").arg(updateCount)));
|
||||
|
@ -117,6 +117,8 @@ class PLASMA_EXPORT DataContainer : public QObject
|
||||
* DataContainer itself is deleted, so it will be deleted when there won't be any
|
||||
* visualization associated to this source.
|
||||
*
|
||||
* Normally you should set the model from DataEngine::setModel instead from here.
|
||||
*
|
||||
* @param model the model that will be associated with this DataContainer
|
||||
*/
|
||||
void setModel(QAbstractItemModel *model);
|
||||
|
@ -243,7 +243,7 @@ void DataEngine::setModel(const QString &source, QAbstractItemModel *model)
|
||||
}
|
||||
}
|
||||
|
||||
QAbstractItemModel *DataEngine::model(const QString &source)
|
||||
QAbstractItemModel *DataEngine::modelForSource(const QString &source)
|
||||
{
|
||||
Plasma::DataContainer *s = containerForSource(source);
|
||||
|
||||
|
@ -177,6 +177,12 @@ Types::NoAlignment) const;
|
||||
**/
|
||||
Q_INVOKABLE DataContainer *containerForSource(const QString &source);
|
||||
|
||||
/**
|
||||
* @return The model associated to a source if any. The ownership of the model stays with the DataContainer.
|
||||
* Returns 0 if there isn't any model associated or if the source doesn't exists.
|
||||
*/
|
||||
QAbstractItemModel *modelForSource(const QString &source);
|
||||
|
||||
/**
|
||||
* Returns true if this engine is valid, otherwise returns false
|
||||
*
|
||||
@ -323,12 +329,6 @@ Types::NoAlignment) const;
|
||||
*/
|
||||
void setModel(const QString &source, QAbstractItemModel *model);
|
||||
|
||||
/**
|
||||
* @return The model associated to a source if any. The ownership of the model stays with the DataContainer.
|
||||
* Returns 0 if there isn't any model associated or if the source doesn't exists.
|
||||
*/
|
||||
QAbstractItemModel *model(const QString &source);
|
||||
|
||||
/**
|
||||
* Adds an already constructed data source. The DataEngine takes
|
||||
* ownership of the DataContainer object. The objectName of the source
|
||||
|
Loading…
Reference in New Issue
Block a user