Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwintabbox/layoutpreview.cpp
Show First 20 Lines • Show All 145 Lines • ▼ Show 20 Line(s) | |||||
146 | 146 | | |||
147 | QVariant ExampleClientModel::data(const QModelIndex &index, int role) const | 147 | QVariant ExampleClientModel::data(const QModelIndex &index, int role) const | ||
148 | { | 148 | { | ||
149 | if (!index.isValid()) { | 149 | if (!index.isValid()) { | ||
150 | return QVariant(); | 150 | return QVariant(); | ||
151 | } | 151 | } | ||
152 | switch (role) { | 152 | switch (role) { | ||
153 | case Qt::DisplayRole: | 153 | case Qt::DisplayRole: | ||
154 | case Qt::UserRole: | 154 | case CaptionRole: | ||
155 | return m_services.at(index.row())->name(); | 155 | return m_services.at(index.row())->name(); | ||
156 | case Qt::UserRole+1: | 156 | case MinimizedRole: | ||
157 | return false; | 157 | return false; | ||
158 | case Qt::UserRole+2: | 158 | case DesktopNameRole: | ||
159 | return i18nc("An example Desktop Name", "Desktop 1"); | 159 | return i18nc("An example Desktop Name", "Desktop 1"); | ||
160 | case Qt::UserRole+3: | 160 | case IconRole: | ||
161 | return m_services.at(index.row())->icon(); | 161 | return m_services.at(index.row())->icon(); | ||
162 | case Qt::UserRole+4: | 162 | case WindowIdRole: | ||
163 | const auto s = m_services.at(index.row()); | 163 | const auto s = m_services.at(index.row()); | ||
164 | if (s == m_browser) { | 164 | if (s == m_browser) { | ||
165 | return WindowThumbnailItem::Konqueror; | 165 | return WindowThumbnailItem::Konqueror; | ||
166 | } else if (s == m_email) { | 166 | } else if (s == m_email) { | ||
167 | return WindowThumbnailItem::KMail; | 167 | return WindowThumbnailItem::KMail; | ||
168 | } else if (s == m_systemSettings) { | 168 | } else if (s == m_systemSettings) { | ||
169 | return WindowThumbnailItem::Systemsettings; | 169 | return WindowThumbnailItem::Systemsettings; | ||
170 | } else if (s == m_fileManager) { | 170 | } else if (s == m_fileManager) { | ||
Show All 19 Lines | |||||
190 | int ExampleClientModel::rowCount(const QModelIndex &parent) const | 190 | int ExampleClientModel::rowCount(const QModelIndex &parent) const | ||
191 | { | 191 | { | ||
192 | Q_UNUSED(parent) | 192 | Q_UNUSED(parent) | ||
193 | return m_services.size(); | 193 | return m_services.size(); | ||
194 | } | 194 | } | ||
195 | 195 | | |||
196 | QHash<int, QByteArray> ExampleClientModel::roleNames() const | 196 | QHash<int, QByteArray> ExampleClientModel::roleNames() const | ||
197 | { | 197 | { | ||
198 | // FIXME: Use an enum. | | |||
199 | return { | 198 | return { | ||
200 | { Qt::UserRole, QByteArrayLiteral("caption") }, | 199 | { CaptionRole, QByteArrayLiteral("caption") }, | ||
201 | { Qt::UserRole + 1, QByteArrayLiteral("minimized") }, | 200 | { MinimizedRole, QByteArrayLiteral("minimized") }, | ||
202 | { Qt::UserRole + 2, QByteArrayLiteral("desktopName") }, | 201 | { DesktopNameRole, QByteArrayLiteral("desktopName") }, | ||
203 | { Qt::UserRole + 3, QByteArrayLiteral("icon") }, | 202 | { IconRole, QByteArrayLiteral("icon") }, | ||
204 | { Qt::UserRole + 4, QByteArrayLiteral("windowId") }, | 203 | { WindowIdRole, QByteArrayLiteral("windowId") }, | ||
205 | }; | 204 | }; | ||
206 | } | 205 | } | ||
207 | 206 | | |||
208 | SwitcherItem::SwitcherItem(QObject *parent) | 207 | SwitcherItem::SwitcherItem(QObject *parent) | ||
209 | : QObject(parent) | 208 | : QObject(parent) | ||
210 | , m_model(new ExampleClientModel(this)) | 209 | , m_model(new ExampleClientModel(this)) | ||
211 | , m_item(nullptr) | 210 | , m_item(nullptr) | ||
212 | , m_currentIndex(0) | 211 | , m_currentIndex(0) | ||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |