Changeset View
Changeset View
Standalone View
Standalone View
tabbox/desktopmodel.cpp
Show All 28 Lines | |||||
29 | namespace KWin | 29 | namespace KWin | ||
30 | { | 30 | { | ||
31 | namespace TabBox | 31 | namespace TabBox | ||
32 | { | 32 | { | ||
33 | 33 | | |||
34 | DesktopModel::DesktopModel(QObject* parent) | 34 | DesktopModel::DesktopModel(QObject* parent) | ||
35 | : QAbstractItemModel(parent) | 35 | : QAbstractItemModel(parent) | ||
36 | { | 36 | { | ||
37 | QHash<int, QByteArray> roleNames; | | |||
38 | roleNames.insert(Qt::DisplayRole, "display"); | | |||
39 | roleNames.insert(DesktopNameRole, "caption"); | | |||
40 | roleNames.insert(DesktopRole, "desktop"); | | |||
41 | roleNames.insert(ClientModelRole, "client"); | | |||
42 | setRoleNames(roleNames); | | |||
43 | } | 37 | } | ||
44 | 38 | | |||
45 | DesktopModel::~DesktopModel() | 39 | DesktopModel::~DesktopModel() | ||
46 | { | 40 | { | ||
47 | } | 41 | } | ||
48 | 42 | | |||
49 | QVariant DesktopModel::data(const QModelIndex& index, int role) const | 43 | QVariant DesktopModel::data(const QModelIndex& index, int role) const | ||
50 | { | 44 | { | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 121 | if (parent.isValid()) { | |||
135 | } | 129 | } | ||
136 | return createIndex(row, column, parent.row() + 1); | 130 | return createIndex(row, column, parent.row() + 1); | ||
137 | } | 131 | } | ||
138 | if (row > m_desktopList.count() || m_desktopList.isEmpty()) | 132 | if (row > m_desktopList.count() || m_desktopList.isEmpty()) | ||
139 | return QModelIndex(); | 133 | return QModelIndex(); | ||
140 | return createIndex(row, column); | 134 | return createIndex(row, column); | ||
141 | } | 135 | } | ||
142 | 136 | | |||
137 | QHash<int, QByteArray> DesktopModel::roleNames() const | ||||
138 | { | ||||
139 | return { | ||||
140 | { Qt::DisplayRole, QByteArrayLiteral("display") }, | ||||
141 | { DesktopNameRole, QByteArrayLiteral("caption") }, | ||||
142 | { DesktopRole, QByteArrayLiteral("desktop") }, | ||||
143 | { ClientModelRole, QByteArrayLiteral("client") }, | ||||
144 | }; | ||||
145 | } | ||||
146 | | ||||
143 | QModelIndex DesktopModel::desktopIndex(int desktop) const | 147 | QModelIndex DesktopModel::desktopIndex(int desktop) const | ||
144 | { | 148 | { | ||
145 | if (desktop > m_desktopList.count()) | 149 | if (desktop > m_desktopList.count()) | ||
146 | return QModelIndex(); | 150 | return QModelIndex(); | ||
147 | return createIndex(m_desktopList.indexOf(desktop), 0); | 151 | return createIndex(m_desktopList.indexOf(desktop), 0); | ||
148 | } | 152 | } | ||
149 | 153 | | |||
150 | void DesktopModel::createDesktopList() | 154 | void DesktopModel::createDesktopList() | ||
Show All 33 Lines |