[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:13:21 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=bd43754
The following commit has been merged in the master branch:
commit bd43754296fb631091f4ec39eea3bd088af36447
Author: Martin Klapetek <martin.klapetek at gmail.com>
Date: Tue Jun 25 17:37:56 2013 +0200
Merge changes from KPeople branch delegate
REVIEW: 111237
---
abstract-contact-delegate.cpp | 11 +++--------
contact-delegate-compact.cpp | 21 +++++++++++++++------
2 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/abstract-contact-delegate.cpp b/abstract-contact-delegate.cpp
index 95c9007..c60407e 100644
--- a/abstract-contact-delegate.cpp
+++ b/abstract-contact-delegate.cpp
@@ -34,7 +34,7 @@
#include <KTp/types.h>
-const int SPACING = 4;
+const int SPACING = 2;
const int ACCOUNT_ICON_SIZE = 22;
const qreal GROUP_ICON_OPACITY = 0.6;
@@ -49,7 +49,7 @@ AbstractContactDelegate::~AbstractContactDelegate()
void AbstractContactDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
- if (index.data(KTp::RowTypeRole).toInt() == KTp::ContactRowType) {
+ if (index.data(KTp::RowTypeRole).toInt() == KTp::ContactRowType || index.data(KTp::RowTypeRole).toInt() == KTp::PersonRowType) {
paintContact(painter, option, index);
} else {
paintHeader(painter, option, index);
@@ -58,16 +58,13 @@ void AbstractContactDelegate::paint(QPainter *painter, const QStyleOptionViewIte
QSize AbstractContactDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
- Q_UNUSED(option);
-
- if (index.data(KTp::RowTypeRole).toInt() == KTp::ContactRowType) {
+ if (index.data(KTp::RowTypeRole).toInt() == KTp::ContactRowType || index.data(KTp::RowTypeRole).toInt() == KTp::PersonRowType) {
return sizeHintContact(option, index);
} else {
return sizeHintHeader(option, index);
}
}
-
void AbstractContactDelegate::paintHeader(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyleOptionViewItemV4 optV4 = option;
@@ -137,9 +134,7 @@ void AbstractContactDelegate::paintHeader(QPainter *painter, const QStyleOptionV
QRect groupLabelRect = groupRect.adjusted(expandSignOption.rect.width() + SPACING * 2, 0, -groupIconRect.width() -SPACING, 0);
QString countsString = QString("(%1/%2)").arg(index.data(KTp::HeaderOnlineUsersRole).toString(),
index.data(KTp::HeaderTotalUsersRole).toString());
-
QString groupHeaderString = index.data(Qt::DisplayRole).toString();
-
QFontMetrics groupFontMetrics(groupFont);
painter->setFont(groupFont);
diff --git a/contact-delegate-compact.cpp b/contact-delegate-compact.cpp
index 46bee7b..945def1 100644
--- a/contact-delegate-compact.cpp
+++ b/contact-delegate-compact.cpp
@@ -33,10 +33,11 @@
#include <KDebug>
#include <KGlobalSettings>
#include <KDE/KLocale>
+#include <KStandardDirs>
#include <KTp/types.h>
-ContactDelegateCompact::ContactDelegateCompact(ContactDelegateCompact::ListSize size, QObject * parent)
+ContactDelegateCompact::ContactDelegateCompact(ContactDelegateCompact::ListSize size, QObject *parent)
: AbstractContactDelegate(parent)
{
setListMode(size);
@@ -47,18 +48,24 @@ ContactDelegateCompact::~ContactDelegateCompact()
}
-void ContactDelegateCompact::paintContact(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);
+ bool isSubcontact = index.parent().isValid() && index.parent().data(KTp::RowTypeRole).toUInt() == KTp::PersonRowType;
+
painter->save();
painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
painter->setClipRect(optV4.rect);
QStyle *style = QApplication::style();
- style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter);
+ style->drawPrimitive(QStyle::PE_PanelItemViewItem, &optV4, painter);
+
+ if (isSubcontact) {
+ optV4.rect.setLeft(optV4.rect.left() + 10);
+ }
QRect iconRect = optV4.rect;
iconRect.setSize(QSize(m_avatarSize, m_avatarSize));
@@ -80,7 +87,7 @@ void ContactDelegateCompact::paintContact(QPainter * painter, const QStyleOption
QRect statusIconRect = optV4.rect;
statusIconRect.setSize(QSize(m_presenceIconSize, m_presenceIconSize));
- statusIconRect.moveTo(QPoint(optV4.rect.right() - rightIconsWidth,
+ statusIconRect.moveTo(QPoint(optV4.rect.right() - (rightIconsWidth),
optV4.rect.top() + (optV4.rect.height() - m_presenceIconSize) / 2));
painter->drawPixmap(statusIconRect, icon);
@@ -121,8 +128,10 @@ void ContactDelegateCompact::paintContact(QPainter * painter, const QStyleOption
userNameRect.setY(userNameRect.y() + (userNameRect.height()/2 - nameFontMetrics.height()/2));
userNameRect.setWidth(userNameRect.width() - rightIconsWidth);
+ QString nameText = index.data(Qt::DisplayRole).toString();
+
painter->drawText(userNameRect,
- nameFontMetrics.elidedText(optV4.text, Qt::ElideRight, userNameRect.width()));
+ nameFontMetrics.elidedText(nameText, Qt::ElideRight, userNameRect.width()));
QRect presenceMessageRect = optV4.rect;
presenceMessageRect.setX(userNameRect.x() + nameFontMetrics.boundingRect(optV4.text).width() + m_spacing * 2);
@@ -146,6 +155,7 @@ QSize ContactDelegateCompact::sizeHintContact(const QStyleOptionViewItem &option
{
Q_UNUSED(option);
Q_UNUSED(index);
+
return QSize(0, qMax(m_avatarSize + 2 * m_spacing, KGlobalSettings::smallestReadableFont().pixelSize() + m_spacing));
}
@@ -168,5 +178,4 @@ void ContactDelegateCompact::setListMode(ContactDelegateCompact::ListSize size)
m_listSize = size;
}
-
#include "contact-delegate-compact.moc"
--
ktp-contact-list packaging
More information about the pkg-kde-commits
mailing list