Port away from setRoleNames where easily possible
It is deprecated. Instead re-implement roleNames(). Done in places where only static roles were used. Differential Revision: https://phabricator.kde.org/D4891
This commit is contained in:
parent
f8bedf84b7
commit
dfbf2c1c30
@ -33,15 +33,7 @@ DaysModel::DaysModel(QObject *parent) :
|
||||
m_lastRequestedEventsStartDate(QDate()),
|
||||
m_agendaNeedsUpdate(false)
|
||||
{
|
||||
QHash<int, QByteArray> roleNames;
|
||||
|
||||
roleNames.insert(isCurrent, "isCurrent");
|
||||
roleNames.insert(containsEventItems, "containsEventItems");
|
||||
roleNames.insert(dayNumber, "dayNumber");
|
||||
roleNames.insert(monthNumber, "monthNumber");
|
||||
roleNames.insert(yearNumber, "yearNumber");
|
||||
|
||||
setRoleNames(roleNames);
|
||||
}
|
||||
|
||||
DaysModel::~DaysModel()
|
||||
@ -244,3 +236,14 @@ void DaysModel::setPluginsManager(QObject *manager)
|
||||
|
||||
QMetaObject::invokeMethod(this, "update", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> DaysModel::roleNames() const
|
||||
{
|
||||
return {
|
||||
{isCurrent, "isCurrent"},
|
||||
{containsEventItems, "containsEventItems"},
|
||||
{dayNumber, "dayNumber"},
|
||||
{monthNumber, "monthNumber"},
|
||||
{yearNumber, "yearNumber"}
|
||||
};
|
||||
}
|
||||
|
@ -54,6 +54,8 @@ public:
|
||||
|
||||
Q_INVOKABLE QList<QObject*> eventsForDate(const QDate &date);
|
||||
|
||||
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
|
||||
|
||||
Q_SIGNALS:
|
||||
void agendaUpdated(const QDate &updatedDate);
|
||||
|
||||
|
@ -175,15 +175,7 @@ ConfigModel::ConfigModel(QObject *parent)
|
||||
: QAbstractListModel(parent),
|
||||
d(new ConfigModelPrivate(this))
|
||||
{
|
||||
QHash<int, QByteArray> roleNames;
|
||||
roleNames[NameRole] = "name";
|
||||
roleNames[IconRole] = "icon";
|
||||
roleNames[SourceRole] = "source";
|
||||
roleNames[PluginNameRole] = "pluginName";
|
||||
roleNames[VisibleRole] = "visible";
|
||||
roleNames[KCMRole] = "kcm";
|
||||
|
||||
setRoleNames(roleNames);
|
||||
}
|
||||
|
||||
ConfigModel::~ConfigModel()
|
||||
@ -255,6 +247,18 @@ QVariant ConfigModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ConfigModel::roleNames() const
|
||||
{
|
||||
return {
|
||||
{NameRole, "name"},
|
||||
{IconRole, "icon"},
|
||||
{SourceRole, "source"},
|
||||
{PluginNameRole, "pluginName"},
|
||||
{VisibleRole, "visible"},
|
||||
{KCMRole, "kcm"},
|
||||
};
|
||||
}
|
||||
|
||||
QVariant ConfigModel::get(int row) const
|
||||
{
|
||||
return d->get(row);
|
||||
|
@ -100,6 +100,7 @@ public:
|
||||
}
|
||||
int rowCount(const QModelIndex &index = QModelIndex()) const Q_DECL_OVERRIDE;
|
||||
QVariant data(const QModelIndex &, int) const Q_DECL_OVERRIDE;
|
||||
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
|
||||
|
||||
/**
|
||||
* @param row the row for which the data will be returned
|
||||
|
Loading…
Reference in New Issue
Block a user