[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:56 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=9adbbe0
The following commit has been merged in the master branch:
commit 9adbbe083f7744abeeef5018249c02873d710661
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Tue Sep 10 21:47:09 2013 +0100
Draw branches for contacts in KPeople mode
REVIEW: 112658
BUG: 324602
BUG: 324300
---
contact-delegate-compact.cpp | 4 ----
contact-list-widget.cpp | 38 +++++++++++++++++++++++++++++++++-----
contact-list-widget_p.h | 4 ++++
3 files changed, 37 insertions(+), 9 deletions(-)
diff --git a/contact-delegate-compact.cpp b/contact-delegate-compact.cpp
index 945def1..5b92c8e 100644
--- a/contact-delegate-compact.cpp
+++ b/contact-delegate-compact.cpp
@@ -63,10 +63,6 @@ void ContactDelegateCompact::paintContact(QPainter *painter, const QStyleOptionV
QStyle *style = QApplication::style();
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));
iconRect.moveTo(QPoint(iconRect.x() + m_spacing, iconRect.y() + m_spacing));
diff --git a/contact-list-widget.cpp b/contact-list-widget.cpp
index 7c4c930..6a7a5cf 100644
--- a/contact-list-widget.cpp
+++ b/contact-list-widget.cpp
@@ -64,6 +64,28 @@
#include <kpeople/personsmodel.h>
#endif
+//create a new style that does not draw the vertical lines in the tree view
+//this maps "draw branch" to "draw right arrow" and "draw down arrow"
+//we cannot just override drawBranches as then we cannot highlight the active branch
+//Qt does so by utilising some internal methods of QTreeView
+class NoLinesStyle: public QProxyStyle
+{
+ void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const
+ {
+ if (element == QStyle::PE_IndicatorBranch) {
+ if (option->state & QStyle::State_Children) {
+ if (option->state & QStyle::State_Open) {
+ return QProxyStyle::drawPrimitive(PE_IndicatorArrowDown, option, painter, widget);
+ } else {
+ return QProxyStyle::drawPrimitive(PE_IndicatorArrowRight, option, painter, widget);
+ }
+ }
+ } else {
+ return QProxyStyle::drawPrimitive(element, option, painter, widget);
+ }
+ }
+};
+
ContactListWidget::ContactListWidget(QWidget *parent)
: QTreeView(parent),
d_ptr(new ContactListWidgetPrivate)
@@ -80,8 +102,9 @@ ContactListWidget::ContactListWidget(QWidget *parent)
d->model->setTrackUnreadMessages(true);
d->model->setDynamicSortFilter(true);
d->model->setSortRole(Qt::DisplayRole);
+ d->style.reset(new NoLinesStyle());
-
+ setStyle(d->style.data());
setSortingEnabled(true);
sortByColumn(0, Qt::AscendingOrder);
loadGroupStatesFromConfig();
@@ -94,7 +117,11 @@ ContactListWidget::ContactListWidget(QWidget *parent)
setSortingEnabled(true);
setEditTriggers(NoEditTriggers);
setContextMenuPolicy(Qt::CustomContextMenu);
- setIndentation(0);
+ if (KTp::kpeopleEnabled()) {
+ setIndentation(25);
+ } else {
+ setIndentation(0);
+ }
setMouseTracking(true);
setExpandsOnDoubleClick(false); //the expanding/collapsing is handled manually
setDragEnabled(false); // we handle drag&drop ourselves
@@ -923,10 +950,11 @@ void ContactListWidget::paintEvent(QPaintEvent *event)
void ContactListWidget::drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const
{
- Q_UNUSED(painter);
- Q_UNUSED(rect);
- Q_UNUSED(index);
+ if (indentation() > 0) {
+ QTreeView::drawBranches(painter, rect, index);
+ }
+ //if no indentation (non kpeople mode) do nothing
// There is a 0px identation set in the constructor, with setIndentation(0).
// Because of that, no branches are shown, so they should be disabled completely (overriding drawBranches).
// Leaving branches enabled with 0px identation results in a 1px branch line on the left of all items,
diff --git a/contact-list-widget_p.h b/contact-list-widget_p.h
index 5baae87..e4a5eb3 100644
--- a/contact-list-widget_p.h
+++ b/contact-list-widget_p.h
@@ -20,6 +20,8 @@
#ifndef CONTACT_LIST_WIDGET_P_H
#define CONTACT_LIST_WIDGET_P_H
+#include <QProxyStyle>
+
#include <TelepathyQt/Types>
#include <KTp/Models/contacts-model.h>
@@ -29,6 +31,7 @@ namespace KTp {
class ContactDelegate;
class ContactDelegateCompact;
+class QStyle;
class ContactListWidgetPrivate {
public:
@@ -51,6 +54,7 @@ public:
Tp::AccountManagerPtr accountManager;
KTp::ContactsModel::GroupMode groupMode; // Stores current grouping mode (by accounts or by groups)
QPersistentModelIndex selectedIndex;
+ QScopedPointer<QStyle> style;
};
#endif //CONTACT_LIST_WIDGET_P_H
--
ktp-contact-list packaging
More information about the pkg-kde-commits
mailing list