[kcmkwin/tabbox] Use an enum for role names
Summary: This way we have fewer magical constants. Reviewers: #kwin, apol Reviewed By: apol Subscribers: ngraham, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D25457
This commit is contained in:
parent
1f8e4bba85
commit
07099676ef
2 changed files with 18 additions and 11 deletions
|
@ -151,15 +151,15 @@ QVariant ExampleClientModel::data(const QModelIndex &index, int role) const
|
|||
}
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
case Qt::UserRole:
|
||||
case CaptionRole:
|
||||
return m_services.at(index.row())->name();
|
||||
case Qt::UserRole+1:
|
||||
case MinimizedRole:
|
||||
return false;
|
||||
case Qt::UserRole+2:
|
||||
case DesktopNameRole:
|
||||
return i18nc("An example Desktop Name", "Desktop 1");
|
||||
case Qt::UserRole+3:
|
||||
case IconRole:
|
||||
return m_services.at(index.row())->icon();
|
||||
case Qt::UserRole+4:
|
||||
case WindowIdRole:
|
||||
const auto s = m_services.at(index.row());
|
||||
if (s == m_browser) {
|
||||
return WindowThumbnailItem::Konqueror;
|
||||
|
@ -195,13 +195,12 @@ int ExampleClientModel::rowCount(const QModelIndex &parent) const
|
|||
|
||||
QHash<int, QByteArray> ExampleClientModel::roleNames() const
|
||||
{
|
||||
// FIXME: Use an enum.
|
||||
return {
|
||||
{ Qt::UserRole, QByteArrayLiteral("caption") },
|
||||
{ Qt::UserRole + 1, QByteArrayLiteral("minimized") },
|
||||
{ Qt::UserRole + 2, QByteArrayLiteral("desktopName") },
|
||||
{ Qt::UserRole + 3, QByteArrayLiteral("icon") },
|
||||
{ Qt::UserRole + 4, QByteArrayLiteral("windowId") },
|
||||
{ CaptionRole, QByteArrayLiteral("caption") },
|
||||
{ MinimizedRole, QByteArrayLiteral("minimized") },
|
||||
{ DesktopNameRole, QByteArrayLiteral("desktopName") },
|
||||
{ IconRole, QByteArrayLiteral("icon") },
|
||||
{ WindowIdRole, QByteArrayLiteral("windowId") },
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,14 @@ class ExampleClientModel : public QAbstractListModel
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum {
|
||||
CaptionRole = Qt::UserRole + 1,
|
||||
MinimizedRole,
|
||||
DesktopNameRole,
|
||||
IconRole,
|
||||
WindowIdRole
|
||||
};
|
||||
|
||||
explicit ExampleClientModel(QObject *parent = nullptr);
|
||||
~ExampleClientModel() override;
|
||||
|
||||
|
|
Loading…
Reference in a new issue