[SCM] ktp-contact-list packaging branch, master, updated. debian/15.12.1-2-1070-g6c56f91
Maximiliano Curia
maxy at moszumanska.debian.org
Sat May 28 00:07:17 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=15318e9
The following commit has been merged in the master branch:
commit 15318e9423862d2848a4027f79b7f7867aaae919
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Wed Aug 10 14:49:51 2011 +0100
Make the abstractContactDelegate behave like an actual abstract class.
Simplifies the code in the two actual delegates.
Review: 102282
Reviewed by: Martin Klapetek
---
abstract-contact-delegate.cpp | 41 ++++++--
abstract-contact-delegate.h | 11 ++-
contact-delegate-compact.cpp | 170 ++++++++++++++++------------------
contact-delegate-compact.h | 4 +-
contact-delegate.cpp | 211 ++++++++++++++++++++----------------------
contact-delegate.h | 4 +-
6 files changed, 227 insertions(+), 214 deletions(-)
diff --git a/abstract-contact-delegate.cpp b/abstract-contact-delegate.cpp
index 098f3b5..37502ef 100644
--- a/abstract-contact-delegate.cpp
+++ b/abstract-contact-delegate.cpp
@@ -52,6 +52,30 @@ AbstractContactDelegate::~AbstractContactDelegate()
void AbstractContactDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
+ bool isContact = index.data(AccountsModel::ItemRole).userType() == qMetaTypeId<ContactModelItem*>();
+
+ if (isContact) {
+ paintContact(painter, option, index);
+ } else {
+ paintHeader(painter, option, index);
+ }
+}
+
+QSize AbstractContactDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
+{
+ Q_UNUSED(option);
+ bool isContact = index.data(AccountsModel::ItemRole).userType() == qMetaTypeId<ContactModelItem*>();
+
+ if (isContact) {
+ return sizeHintContact(option, index);
+ } else {
+ return sizeHintHeader(option, index);
+ }
+}
+
+
+void AbstractContactDelegate::paintHeader(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
QStyleOptionViewItemV4 optV4 = option;
initStyleOption(&optV4, index);
@@ -73,7 +97,7 @@ void AbstractContactDelegate::paint(QPainter* painter, const QStyleOptionViewIte
groupLabelRect.setRight(groupLabelRect.right() - SPACING);
QRect expandSignRect = groupLabelRect;
- expandSignRect.setLeft(ACCOUNT_ICON_SIZE + SPACING + SPACING);
+ expandSignRect.setLeft(ACCOUNT_ICON_SIZE + (SPACING*3));
expandSignRect.setRight(groupLabelRect.left() + 20); //keep it by the left side
QFont groupFont = KGlobalSettings::smallestReadableFont();
@@ -90,15 +114,15 @@ void AbstractContactDelegate::paint(QPainter* painter, const QStyleOptionViewIte
}
//create an area for text which does not overlap with the icons.
- QRect textRect = groupLabelRect.adjusted(ACCOUNT_ICON_SIZE + (SPACING*3),0,0,0);
+ QRect textRect = groupLabelRect.adjusted(ACCOUNT_ICON_SIZE + (SPACING*4),0,0,0);
QString groupHeaderString = index.data(GroupsModel::GroupNameRole).toString().append(counts);
-
+
painter->setPen(m_palette->color(QPalette::WindowText));
painter->setFont(groupFont);
painter->drawText(textRect, Qt::AlignVCenter | Qt::AlignRight,
optV4.fontMetrics.elidedText(groupHeaderString, Qt::ElideRight, textRect.width()));
-
+
QPen thinLinePen;
thinLinePen.setWidth(0);
thinLinePen.setColor(m_palette->color(QPalette::Disabled, QPalette::Button));
@@ -131,12 +155,13 @@ void AbstractContactDelegate::paint(QPainter* painter, const QStyleOptionViewIte
painter->restore();
}
-QSize AbstractContactDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
+QSize AbstractContactDelegate::sizeHintHeader(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
- return QSize(0, 20);
+ Q_UNUSED(option);
+ Q_UNUSED(index);
+ return QSize(0,20);
}
-
bool AbstractContactDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index)
{
Q_UNUSED(option);
@@ -226,3 +251,5 @@ bool AbstractContactDelegate::helpEvent(QHelpEvent *event, QAbstractItemView *vi
return true;
}
+
+
diff --git a/abstract-contact-delegate.h b/abstract-contact-delegate.h
index b6dcfc8..5f73670 100644
--- a/abstract-contact-delegate.h
+++ b/abstract-contact-delegate.h
@@ -49,7 +49,16 @@ Q_SIGNALS:
void repaintItem(QModelIndex);
protected:
- QPalette *m_palette;
+ /** Paint contact items. Pure virtual, items should be subclass this for painting*/
+ virtual void paintContact(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const = 0;
+ /** The size hint for painting contact items*/
+ virtual QSize sizeHintContact(const QStyleOptionViewItem& option, const QModelIndex& index) const = 0;
+ QPalette *m_palette;
+
+private:
+ /** Paints header items*/
+ void paintHeader(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
+ QSize sizeHintHeader(const QStyleOptionViewItem& option, const QModelIndex& index) const;
};
#endif // ABSTRACT_CONTACT_DELEGATE_H
diff --git a/contact-delegate-compact.cpp b/contact-delegate-compact.cpp
index 4415af8..9d456f5 100644
--- a/contact-delegate-compact.cpp
+++ b/contact-delegate-compact.cpp
@@ -54,7 +54,7 @@ ContactDelegateCompact::~ContactDelegateCompact()
}
-void ContactDelegateCompact::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
+void ContactDelegateCompact::paintContact(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
{
QStyleOptionViewItemV4 optV4 = option;
initStyleOption(&optV4, index);
@@ -67,103 +67,91 @@ void ContactDelegateCompact::paint(QPainter * painter, const QStyleOptionViewIte
QStyle *style = QApplication::style();
style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter);
- bool isContact = index.data(AccountsModel::ItemRole).userType() == qMetaTypeId<ContactModelItem*>();
-
- if (isContact) {
- QRect iconRect = optV4.rect;
- iconRect.setSize(QSize(AVATAR_SIZE, AVATAR_SIZE));
- iconRect.moveTo(QPoint(iconRect.x() + SPACING, iconRect.y() + SPACING));
-
- QPixmap avatar;
- avatar.load(index.data(AccountsModel::AvatarRole).toString());
-
- bool noContactAvatar = avatar.isNull();
-
- if (noContactAvatar) {
- avatar = SmallIcon("im-user", KIconLoader::SizeMedium);
- }
-
- painter->drawPixmap(iconRect, avatar);
-
- QPixmap icon;
-
- switch (index.data(AccountsModel::PresenceTypeRole).toInt()) {
- case Tp::ConnectionPresenceTypeAvailable:
- icon = SmallIcon("user-online", KIconLoader::SizeSmallMedium);
- break;
- case Tp::ConnectionPresenceTypeAway:
- icon = SmallIcon("user-away", KIconLoader::SizeSmallMedium);
- break;
- case Tp::ConnectionPresenceTypeExtendedAway:
- icon = SmallIcon("user-away-extended", KIconLoader::SizeSmallMedium);
- break;
- case Tp::ConnectionPresenceTypeBusy:
- icon = SmallIcon("user-busy", KIconLoader::SizeSmallMedium);
- break;
- case Tp::ConnectionPresenceTypeHidden:
- icon = SmallIcon("user-invisible", KIconLoader::SizeSmallMedium);
- break;
- case Tp::ConnectionPresenceTypeOffline:
- icon = SmallIcon("user-offline", KIconLoader::SizeSmallMedium);
- break;
- default:
- icon = SmallIcon("task-attention", KIconLoader::SizeSmallMedium);
- break;
- }
-
- QRect statusIconRect = optV4.rect;
- statusIconRect.setSize(QSize(PRESENCE_ICON_SIZE, PRESENCE_ICON_SIZE));
- statusIconRect.moveTo(QPoint(optV4.rect.right() - PRESENCE_ICON_SIZE - SPACING,
- optV4.rect.top() + (optV4.rect.height() - PRESENCE_ICON_SIZE) / 2));
-
- painter->drawPixmap(statusIconRect, icon);
-
- QFont nameFont = KGlobalSettings::smallestReadableFont();
- nameFont.setPointSize(nameFont.pointSize() + 1);
-
- const QFontMetrics nameFontMetrics(nameFont);
-
- painter->setFont(nameFont);
-
- QRect userNameRect = optV4.rect;
- userNameRect.setX(iconRect.x() + iconRect.width() + SPACING * 2);
- userNameRect.setY(userNameRect.y() + (userNameRect.height()/2 - nameFontMetrics.height()/2));
- userNameRect.setWidth(userNameRect.width() - PRESENCE_ICON_SIZE - SPACING);
-
- painter->drawText(userNameRect,
- nameFontMetrics.elidedText(optV4.text, Qt::ElideRight, userNameRect.width()));
-
- QRect presenceMessageRect = optV4.rect;
- presenceMessageRect.setX(userNameRect.x() + nameFontMetrics.boundingRect(optV4.text).width() + SPACING * 2);
- presenceMessageRect.setWidth(optV4.rect.width() - presenceMessageRect.x() - PRESENCE_ICON_SIZE - SPACING);
- presenceMessageRect.setY(presenceMessageRect.y() + (presenceMessageRect.height()/2 - nameFontMetrics.height()/2));
-
- QPen presenceMessagePen = painter->pen();
- presenceMessagePen.setColor(m_palette->color(QPalette::Disabled, QPalette::Text));
-
- painter->setPen(presenceMessagePen);
-
- painter->drawText(presenceMessageRect,
- nameFontMetrics.elidedText(index.data(AccountsModel::PresenceMessageRole).toString(),
- Qt::ElideRight, presenceMessageRect.width()));
- } else {
- AbstractContactDelegate::paint(painter, option, index);
+ QRect iconRect = optV4.rect;
+ iconRect.setSize(QSize(AVATAR_SIZE, AVATAR_SIZE));
+ iconRect.moveTo(QPoint(iconRect.x() + SPACING, iconRect.y() + SPACING));
+
+ QPixmap avatar;
+ avatar.load(index.data(AccountsModel::AvatarRole).toString());
+
+ bool noContactAvatar = avatar.isNull();
+
+ if (noContactAvatar) {
+ avatar = SmallIcon("im-user", KIconLoader::SizeMedium);
+ }
+
+ painter->drawPixmap(iconRect, avatar);
+
+ QPixmap icon;
+
+ switch (index.data(AccountsModel::PresenceTypeRole).toInt()) {
+ case Tp::ConnectionPresenceTypeAvailable:
+ icon = SmallIcon("user-online", KIconLoader::SizeSmallMedium);
+ break;
+ case Tp::ConnectionPresenceTypeAway:
+ icon = SmallIcon("user-away", KIconLoader::SizeSmallMedium);
+ break;
+ case Tp::ConnectionPresenceTypeExtendedAway:
+ icon = SmallIcon("user-away-extended", KIconLoader::SizeSmallMedium);
+ break;
+ case Tp::ConnectionPresenceTypeBusy:
+ icon = SmallIcon("user-busy", KIconLoader::SizeSmallMedium);
+ break;
+ case Tp::ConnectionPresenceTypeHidden:
+ icon = SmallIcon("user-invisible", KIconLoader::SizeSmallMedium);
+ break;
+ case Tp::ConnectionPresenceTypeOffline:
+ icon = SmallIcon("user-offline", KIconLoader::SizeSmallMedium);
+ break;
+ default:
+ icon = SmallIcon("task-attention", KIconLoader::SizeSmallMedium);
+ break;
}
+ QRect statusIconRect = optV4.rect;
+ statusIconRect.setSize(QSize(PRESENCE_ICON_SIZE, PRESENCE_ICON_SIZE));
+ statusIconRect.moveTo(QPoint(optV4.rect.right() - PRESENCE_ICON_SIZE - SPACING,
+ optV4.rect.top() + (optV4.rect.height() - PRESENCE_ICON_SIZE) / 2));
+
+ painter->drawPixmap(statusIconRect, icon);
+
+ QFont nameFont = KGlobalSettings::smallestReadableFont();
+ nameFont.setPointSize(nameFont.pointSize() + 1);
+
+ const QFontMetrics nameFontMetrics(nameFont);
+
+ painter->setFont(nameFont);
+
+ QRect userNameRect = optV4.rect;
+ userNameRect.setX(iconRect.x() + iconRect.width() + SPACING * 2);
+ userNameRect.setY(userNameRect.y() + (userNameRect.height()/2 - nameFontMetrics.height()/2));
+ userNameRect.setWidth(userNameRect.width() - PRESENCE_ICON_SIZE - SPACING);
+
+ painter->drawText(userNameRect,
+ nameFontMetrics.elidedText(optV4.text, Qt::ElideRight, userNameRect.width()));
+
+ QRect presenceMessageRect = optV4.rect;
+ presenceMessageRect.setX(userNameRect.x() + nameFontMetrics.boundingRect(optV4.text).width() + SPACING * 2);
+ presenceMessageRect.setWidth(optV4.rect.width() - presenceMessageRect.x() - PRESENCE_ICON_SIZE - SPACING);
+ presenceMessageRect.setY(presenceMessageRect.y() + (presenceMessageRect.height()/2 - nameFontMetrics.height()/2));
+
+ QPen presenceMessagePen = painter->pen();
+ presenceMessagePen.setColor(m_palette->color(QPalette::Disabled, QPalette::Text));
+
+ painter->setPen(presenceMessagePen);
+
+ painter->drawText(presenceMessageRect,
+ nameFontMetrics.elidedText(index.data(AccountsModel::PresenceMessageRole).toString(),
+ Qt::ElideRight, presenceMessageRect.width()));
+
painter->restore();
}
-QSize ContactDelegateCompact::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
+QSize ContactDelegateCompact::sizeHintContact(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_UNUSED(option);
- bool isContact = index.data(AccountsModel::ItemRole).userType() == qMetaTypeId<ContactModelItem*>();
-
- if (isContact) {
- return QSize(0, 28);
- } else {
- return AbstractContactDelegate::sizeHint(option, index);
- }
+ Q_UNUSED(index);
+ return QSize(0, 28);
}
-
#include "contact-delegate-compact.moc"
diff --git a/contact-delegate-compact.h b/contact-delegate-compact.h
index 4387e0c..7fa2907 100644
--- a/contact-delegate-compact.h
+++ b/contact-delegate-compact.h
@@ -32,8 +32,8 @@ public:
ContactDelegateCompact(QObject *parent = 0);
~ContactDelegateCompact();
- void paint(QPainter *painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
- QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
+ void paintContact(QPainter *painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
+ QSize sizeHintContact(const QStyleOptionViewItem & option, const QModelIndex & index) const;
};
#endif // CONTACTDELEGATECOMPACT_H
diff --git a/contact-delegate.cpp b/contact-delegate.cpp
index e75d094..d450710 100644
--- a/contact-delegate.cpp
+++ b/contact-delegate.cpp
@@ -55,7 +55,7 @@ ContactDelegate::~ContactDelegate()
}
-void ContactDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
+void ContactDelegate::paintContact(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
{
QStyleOptionViewItemV4 optV4 = option;
initStyleOption(&optV4, index);
@@ -68,123 +68,112 @@ void ContactDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opt
QStyle *style = QApplication::style();
style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter);
- bool isContact = index.data(AccountsModel::ItemRole).userType() == qMetaTypeId<ContactModelItem*>();
-
- if (isContact) {
- QRect iconRect = optV4.rect;
- iconRect.setSize(QSize(AVATAR_SIZE, AVATAR_SIZE));
- iconRect.moveTo(QPoint(iconRect.x() + SPACING, iconRect.y() + SPACING));
-
- QPixmap avatar;
- avatar.load(index.data(AccountsModel::AvatarRole).toString());
-
- bool noContactAvatar = avatar.isNull();
-
- if (noContactAvatar) {
- avatar = SmallIcon("im-user", KIconLoader::SizeMedium);
- }
-
- QPainterPath roundedPath;
- roundedPath.addRoundedRect(iconRect, 20, 20, Qt::RelativeSize);
-
- if (!noContactAvatar) {
- painter->save();
- painter->setClipPath(roundedPath);
- }
-
- painter->drawPixmap(iconRect, avatar);
-
- if (!noContactAvatar) {
- painter->restore();
- painter->drawPath(roundedPath);
- }
-
- QPixmap icon;
-
- switch (index.data(AccountsModel::PresenceTypeRole).toInt()) {
- case Tp::ConnectionPresenceTypeAvailable:
- icon = SmallIcon("user-online", KIconLoader::SizeSmallMedium);
- break;
- case Tp::ConnectionPresenceTypeAway:
- icon = SmallIcon("user-away", KIconLoader::SizeSmallMedium);
- break;
- case Tp::ConnectionPresenceTypeExtendedAway:
- icon = SmallIcon("user-away-extended", KIconLoader::SizeSmallMedium);
- break;
- case Tp::ConnectionPresenceTypeBusy:
- icon = SmallIcon("user-busy", KIconLoader::SizeSmallMedium);
- break;
- case Tp::ConnectionPresenceTypeHidden:
- icon = SmallIcon("user-invisible", KIconLoader::SizeSmallMedium);
- break;
- case Tp::ConnectionPresenceTypeOffline:
- icon = SmallIcon("user-offline", KIconLoader::SizeSmallMedium);
- break;
- default:
- icon = SmallIcon("task-attention", KIconLoader::SizeSmallMedium);
- break;
- }
-
- QRect statusIconRect = optV4.rect;
- statusIconRect.setSize(QSize(PRESENCE_ICON_SIZE, PRESENCE_ICON_SIZE));
- statusIconRect.moveTo(QPoint(optV4.rect.right() - PRESENCE_ICON_SIZE - SPACING,
- optV4.rect.top() + (optV4.rect.height() - PRESENCE_ICON_SIZE) / 2));
-
- painter->drawPixmap(statusIconRect, icon);
-
- QRect userNameRect = optV4.rect;
- userNameRect.setX(iconRect.x() + iconRect.width() + SPACING);
- userNameRect.setY(userNameRect.y() + 3);
- userNameRect.setWidth(userNameRect.width() - PRESENCE_ICON_SIZE - SPACING);
-
- QFont nameFont = KGlobalSettings::smallestReadableFont();
- nameFont.setPointSize(nameFont.pointSize() + 1);
- nameFont.setWeight(QFont::Bold);
-
- const QFontMetrics nameFontMetrics(nameFont);
-
- painter->setFont(nameFont);
- painter->drawText(userNameRect,
- nameFontMetrics.elidedText(optV4.text, Qt::ElideRight, userNameRect.width()));
-
- QRect statusMsgRect = optV4.rect;
- statusMsgRect.setX(iconRect.x() + iconRect.width() + SPACING);
- statusMsgRect.setY(userNameRect.top() + 16);
- statusMsgRect.setWidth(statusMsgRect.width() - PRESENCE_ICON_SIZE - SPACING);
-
- QFont statusFont = KGlobalSettings::smallestReadableFont();
-
- const QFontMetrics statusFontMetrics(statusFont);
-
- QColor fadingColor(m_palette->color(QPalette::WindowText));
-
- if (index == m_indexForHiding) {
- fadingColor.setAlpha(m_fadingValue);
- painter->setPen(fadingColor);
- }
-
- painter->setFont(statusFont);
- painter->drawText(statusMsgRect,
- statusFontMetrics.elidedText(index.data(AccountsModel::PresenceMessageRole).toString(),
- Qt::ElideRight, statusMsgRect.width()));
-
- } else {
- AbstractContactDelegate::paint(painter, option, index);
+ QRect iconRect = optV4.rect;
+ iconRect.setSize(QSize(AVATAR_SIZE, AVATAR_SIZE));
+ iconRect.moveTo(QPoint(iconRect.x() + SPACING, iconRect.y() + SPACING));
+
+ QPixmap avatar;
+ avatar.load(index.data(AccountsModel::AvatarRole).toString());
+
+ bool noContactAvatar = avatar.isNull();
+
+ if (noContactAvatar) {
+ avatar = SmallIcon("im-user", KIconLoader::SizeMedium);
+ }
+
+ QPainterPath roundedPath;
+ roundedPath.addRoundedRect(iconRect, 20, 20, Qt::RelativeSize);
+
+ if (!noContactAvatar) {
+ painter->save();
+ painter->setClipPath(roundedPath);
+ }
+
+ painter->drawPixmap(iconRect, avatar);
+
+ if (!noContactAvatar) {
+ painter->restore();
+ painter->drawPath(roundedPath);
+ }
+
+ QPixmap icon;
+
+ switch (index.data(AccountsModel::PresenceTypeRole).toInt()) {
+ case Tp::ConnectionPresenceTypeAvailable:
+ icon = SmallIcon("user-online", KIconLoader::SizeSmallMedium);
+ break;
+ case Tp::ConnectionPresenceTypeAway:
+ icon = SmallIcon("user-away", KIconLoader::SizeSmallMedium);
+ break;
+ case Tp::ConnectionPresenceTypeExtendedAway:
+ icon = SmallIcon("user-away-extended", KIconLoader::SizeSmallMedium);
+ break;
+ case Tp::ConnectionPresenceTypeBusy:
+ icon = SmallIcon("user-busy", KIconLoader::SizeSmallMedium);
+ break;
+ case Tp::ConnectionPresenceTypeHidden:
+ icon = SmallIcon("user-invisible", KIconLoader::SizeSmallMedium);
+ break;
+ case Tp::ConnectionPresenceTypeOffline:
+ icon = SmallIcon("user-offline", KIconLoader::SizeSmallMedium);
+ break;
+ default:
+ icon = SmallIcon("task-attention", KIconLoader::SizeSmallMedium);
+ break;
}
+ QRect statusIconRect = optV4.rect;
+ statusIconRect.setSize(QSize(PRESENCE_ICON_SIZE, PRESENCE_ICON_SIZE));
+ statusIconRect.moveTo(QPoint(optV4.rect.right() - PRESENCE_ICON_SIZE - SPACING,
+ optV4.rect.top() + (optV4.rect.height() - PRESENCE_ICON_SIZE) / 2));
+
+ painter->drawPixmap(statusIconRect, icon);
+
+ QRect userNameRect = optV4.rect;
+ userNameRect.setX(iconRect.x() + iconRect.width() + SPACING);
+ userNameRect.setY(userNameRect.y() + 3);
+ userNameRect.setWidth(userNameRect.width() - PRESENCE_ICON_SIZE - SPACING);
+
+ QFont nameFont = KGlobalSettings::smallestReadableFont();
+ nameFont.setPointSize(nameFont.pointSize() + 1);
+ nameFont.setWeight(QFont::Bold);
+
+ const QFontMetrics nameFontMetrics(nameFont);
+
+ painter->setFont(nameFont);
+ painter->drawText(userNameRect,
+ nameFontMetrics.elidedText(optV4.text, Qt::ElideRight, userNameRect.width()));
+
+ QRect statusMsgRect = optV4.rect;
+ statusMsgRect.setX(iconRect.x() + iconRect.width() + SPACING);
+ statusMsgRect.setY(userNameRect.top() + 16);
+ statusMsgRect.setWidth(statusMsgRect.width() - PRESENCE_ICON_SIZE - SPACING);
+
+ QFont statusFont = KGlobalSettings::smallestReadableFont();
+
+ const QFontMetrics statusFontMetrics(statusFont);
+
+ QColor fadingColor(m_palette->color(QPalette::WindowText));
+
+ if (index == m_indexForHiding) {
+ fadingColor.setAlpha(m_fadingValue);
+ painter->setPen(fadingColor);
+ }
+
+ painter->setFont(statusFont);
+ painter->drawText(statusMsgRect,
+ statusFontMetrics.elidedText(index.data(AccountsModel::PresenceMessageRole).toString(),
+ Qt::ElideRight, statusMsgRect.width()));
+
+
painter->restore();
}
-QSize ContactDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
+QSize ContactDelegate::sizeHintContact(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_UNUSED(option);
- bool isContact = index.data(AccountsModel::ItemRole).userType() == qMetaTypeId<ContactModelItem*>();
-
- if (isContact) {
- return QSize(0, 32 + 4 * SPACING);
- } else {
- return AbstractContactDelegate::sizeHint(option, index);
- }
+ Q_UNUSED(index);
+ return QSize(0, 32 + 4 * SPACING);
}
void ContactDelegate::hideStatusMessageSlot(const QModelIndex& index)
diff --git a/contact-delegate.h b/contact-delegate.h
index bc81bd4..8508f7e 100644
--- a/contact-delegate.h
+++ b/contact-delegate.h
@@ -35,8 +35,8 @@ public:
ContactDelegate(QObject *parent = 0);
~ContactDelegate();
- void paint(QPainter *painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
- QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
+ virtual void paintContact(QPainter *painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
+ virtual QSize sizeHintContact(const QStyleOptionViewItem & option, const QModelIndex & index) const;
int fadingValue() const;
void setFadingValue(int value);
--
ktp-contact-list packaging
More information about the pkg-kde-commits
mailing list