Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/agentinstancewidget.cpp
Show All 17 Lines | |||||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "agentinstancewidget.h" | 20 | #include "agentinstancewidget.h" | ||
21 | 21 | | |||
22 | #include "agentfilterproxymodel.h" | 22 | #include "agentfilterproxymodel.h" | ||
23 | #include "agentinstance.h" | 23 | #include "agentinstance.h" | ||
24 | #include "agentinstancemodel.h" | 24 | #include "agentinstancemodel.h" | ||
25 | 25 | | |||
26 | #include <QIcon> | | |||
27 | #include <KIconLoader> | | |||
28 | 26 | | |||
29 | #include <QApplication> | 27 | #include <QApplication> | ||
30 | #include <QHBoxLayout> | 28 | #include <QHBoxLayout> | ||
29 | #include <QIcon> | ||||
31 | #include <QListView> | 30 | #include <QListView> | ||
32 | #include <QPainter> | 31 | #include <QPainter> | ||
32 | #include <QStyle> | ||||
33 | 33 | | |||
34 | namespace Akonadi | 34 | namespace Akonadi | ||
35 | { | 35 | { | ||
36 | namespace Internal | 36 | namespace Internal | ||
37 | { | 37 | { | ||
38 | 38 | | |||
39 | static void iconsEarlyCleanup(); | 39 | static void iconsEarlyCleanup(); | ||
40 | 40 | | |||
▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Line(s) | 225 | { | |||
247 | } else { | 247 | } else { | ||
248 | statusPixmap = s_icons->errorPixmap; | 248 | statusPixmap = s_icons->errorPixmap; | ||
249 | } | 249 | } | ||
250 | 250 | | |||
251 | if (status == 1) { | 251 | if (status == 1) { | ||
252 | statusMessage.append(QStringLiteral(" (%1%)").arg(progress)); | 252 | statusMessage.append(QStringLiteral(" (%1%)").arg(progress)); | ||
253 | } | 253 | } | ||
254 | 254 | | |||
255 | const QPixmap iconPixmap = icon.pixmap(IconSize(KIconLoader::Desktop), IconSize(KIconLoader::Desktop)); | 255 | const QPixmap iconPixmap = icon.pixmap(style->pixelMetric(QStyle::PM_MessageBoxIconSize)); | ||
256 | QRect innerRect = option.rect.adjusted(s_delegatePaddingSize, s_delegatePaddingSize, -s_delegatePaddingSize, -s_delegatePaddingSize); //add some padding round entire delegate | 256 | QRect innerRect = option.rect.adjusted(s_delegatePaddingSize, s_delegatePaddingSize, -s_delegatePaddingSize, -s_delegatePaddingSize); //add some padding round entire delegate | ||
257 | 257 | | |||
258 | const QSize decorationSize = iconPixmap.size(); | 258 | const QSize decorationSize = iconPixmap.size(); | ||
259 | const QSize statusIconSize = statusPixmap.size();//= KIconLoader::global()->currentSize(KIconLoader::Small); | 259 | const QSize statusIconSize = statusPixmap.size();//= KIconLoader::global()->currentSize(KIconLoader::Small); | ||
260 | 260 | | |||
261 | QFont nameFont = option.font; | 261 | QFont nameFont = option.font; | ||
262 | nameFont.setBold(true); | 262 | nameFont.setBold(true); | ||
263 | 263 | | |||
Show All 22 Lines | |||||
286 | painter->drawText(statusTextRect.adjusted(statusIconSize.width() + 4, 0, 0, 0), Qt::AlignVCenter | Qt::AlignLeft, statusMessage); | 286 | painter->drawText(statusTextRect.adjusted(statusIconSize.width() + 4, 0, 0, 0), Qt::AlignVCenter | Qt::AlignLeft, statusMessage); | ||
287 | painter->drawPixmap(style->itemPixmapRect(statusTextRect, Qt::AlignVCenter | Qt::AlignLeft, statusPixmap), statusPixmap); | 287 | painter->drawPixmap(style->itemPixmapRect(statusTextRect, Qt::AlignVCenter | Qt::AlignLeft, statusPixmap), statusPixmap); | ||
288 | } | 288 | } | ||
289 | 289 | | |||
290 | QSize AgentInstanceWidgetDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const | 290 | QSize AgentInstanceWidgetDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const | ||
291 | { | 291 | { | ||
292 | Q_UNUSED(index); | 292 | Q_UNUSED(index); | ||
293 | 293 | | |||
294 | const int iconHeight = KIconLoader::global()->currentSize(KIconLoader::Desktop) + (s_delegatePaddingSize * 2); //icon height + padding either side | 294 | const int iconHeight = QApplication::style()->pixelMetric(QStyle::PM_MessageBoxIconSize) + (s_delegatePaddingSize * 2); //icon height + padding either side | ||
295 | const int textHeight = option.fontMetrics.height() + qMax(option.fontMetrics.height(), 16) + (s_delegatePaddingSize * 2); //height of text + icon/text + padding either side | 295 | const int textHeight = option.fontMetrics.height() + qMax(option.fontMetrics.height(), 16) + (s_delegatePaddingSize * 2); //height of text + icon/text + padding either side | ||
296 | 296 | | |||
297 | return QSize(1, qMax(iconHeight, textHeight)); //any width,the view will give us the whole thing in list mode | 297 | return QSize(1, qMax(iconHeight, textHeight)); //any width,the view will give us the whole thing in list mode | ||
298 | } | 298 | } | ||
299 | 299 | | |||
300 | } | 300 | } | ||
301 | 301 | | |||
302 | #include "moc_agentinstancewidget.cpp" | 302 | #include "moc_agentinstancewidget.cpp" |