diff --git a/kcmkwin/kwintabbox/layoutpreview.h b/kcmkwin/kwintabbox/layoutpreview.h --- a/kcmkwin/kwintabbox/layoutpreview.h +++ b/kcmkwin/kwintabbox/layoutpreview.h @@ -49,6 +49,14 @@ { Q_OBJECT public: + enum { + CaptionRole = Qt::UserRole + 1, + MinimizedRole, + DesktopNameRole, + IconRole, + WindowIdRole + }; + explicit ExampleClientModel(QObject *parent = nullptr); ~ExampleClientModel() override; diff --git a/kcmkwin/kwintabbox/layoutpreview.cpp b/kcmkwin/kwintabbox/layoutpreview.cpp --- a/kcmkwin/kwintabbox/layoutpreview.cpp +++ b/kcmkwin/kwintabbox/layoutpreview.cpp @@ -151,15 +151,15 @@ } 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 @@ QHash 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") }, }; }