[SCM] ktp-contact-applet packaging branch, master, updated. debian/15.12.1-1-966-gde83ac5

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:19:05 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-desktop-applets.git;a=commitdiff;h=8d7ff32

The following commit has been merged in the master branch:
commit 8d7ff327bf342aaff7270fbe88951fb7a3097cde
Author: Dan Vrátil <dvratil at redhat.com>
Date:   Tue Jun 18 19:10:32 2013 +0200

    Use KTp::ContactGridDialog for Contact applet configuration instead of custom UI
    
    REVIEW: 111097
---
 contact/CMakeLists.txt                    |   8 +-
 contact/src/abstract-contact-delegate.cpp | 170 -----------------------------
 contact/src/abstract-contact-delegate.h   |  63 -----------
 contact/src/applet_config.cpp             | 133 -----------------------
 contact/src/applet_config.h               |  67 ------------
 contact/src/applet_config.ui              |  39 -------
 contact/src/contact-delegate-compact.cpp  | 173 ------------------------------
 contact/src/contact-delegate-compact.h    |  52 ---------
 contact/src/telepathy-contact.cpp         |  23 +++-
 contact/src/telepathy-contact.h           |   1 +
 10 files changed, 21 insertions(+), 708 deletions(-)

diff --git a/contact/CMakeLists.txt b/contact/CMakeLists.txt
index a94a864..7a9415b 100644
--- a/contact/CMakeLists.txt
+++ b/contact/CMakeLists.txt
@@ -10,17 +10,10 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/plasma-applet-ktp-contact.desktop.cma
                @ONLY)
 
 set(plasma_applet_ktp_contact_SRCS
-    src/abstract-contact-delegate.cpp
-    src/applet_config.cpp
-    src/contact-delegate-compact.cpp
     src/contact-wrapper.cpp
     src/telepathy-contact.cpp
 )
 
-kde4_add_ui_files(plasma_applet_ktp_contact_SRCS
-                    src/applet_config.ui
-)
-
 kde4_add_plugin(plasma_applet_ktp_contact ${plasma_applet_ktp_contact_SRCS})
 target_link_libraries(plasma_applet_ktp_contact
                         ${KDE4_PLASMA_LIBS}
@@ -28,6 +21,7 @@ target_link_libraries(plasma_applet_ktp_contact
                         ${TELEPATHY_QT4_LIBRARIES}
                         ${KTP_LIBRARIES}
                         ${KTP_MODELS_LIBRARIES}
+                        ${KTP_WIDGETS_LIBRARIES}
                         ${QT_QTDECLARATIVE_LIBRARY})
 
 install(DIRECTORY src/declarative/ DESTINATION ${DATA_INSTALL_DIR}/plasma/plasmoids/org.kde.ktp-contact)
diff --git a/contact/src/abstract-contact-delegate.cpp b/contact/src/abstract-contact-delegate.cpp
deleted file mode 100644
index 836913f..0000000
--- a/contact/src/abstract-contact-delegate.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Abstract Contact Delegate - base class for other delegates
- *
- * Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "abstract-contact-delegate.h"
-
-#include <QtGui/QApplication>
-#include <QtGui/QStyle>
-#include <QtGui/QPainter>
-#include <QtGui/QToolTip>
-#include <QtGui/QHelpEvent>
-#include <QAbstractItemView>
-
-#include <KDE/KGlobalSettings>
-#include <KDE/KLocale>
-#include <KDE/KIconLoader>
-#include <KDE/KIcon>
-
-#include <KTp/types.h>
-#include <KDebug>
-
-const int SPACING = 2;
-const int ACCOUNT_ICON_SIZE = 16;
-
-AbstractContactDelegate::AbstractContactDelegate(QObject* parent)
-        : QStyledItemDelegate(parent)
-{
-}
-
-AbstractContactDelegate::~AbstractContactDelegate()
-{
-}
-
-void AbstractContactDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
-{
-    if (index.data(KTp::RowTypeRole).toInt() == KTp::ContactRowType) {
-        paintContact(painter, option, index);
-    } else {
-        paintHeader(painter, option, index);
-    }
-}
-
-QSize AbstractContactDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
-{
-    Q_UNUSED(option);
-
-    if (index.data(KTp::RowTypeRole).toInt() == KTp::ContactRowType) {
-        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);
-
-    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);
-
-    QRect groupRect = optV4.rect;
-
-    QRect accountGroupRect = groupRect;
-    accountGroupRect.setSize(QSize(ACCOUNT_ICON_SIZE, ACCOUNT_ICON_SIZE));
-    accountGroupRect.moveTo(QPoint(groupRect.left() + 2, groupRect.top() + 2));
-
-    QRect groupLabelRect = groupRect;
-    groupLabelRect.setRight(groupLabelRect.right() - SPACING);
-
-    QRect expandSignRect = groupLabelRect;
-    expandSignRect.setLeft(ACCOUNT_ICON_SIZE + (SPACING*5));
-    expandSignRect.setRight(groupLabelRect.left() + 20); //keep it by the left side
-
-    QFont groupFont = KGlobalSettings::smallestReadableFont();
-
-    QString counts = QString(" (%1/%2)").arg(index.data(KTp::HeaderOnlineUsersRole).toString(),
-                     index.data(KTp::HeaderTotalUsersRole).toString());
-
-    if (index.data(KTp::RowTypeRole).toInt() == KTp::AccountRowType) {
-        painter->drawPixmap(accountGroupRect, KIcon(index.data(Qt::DecorationRole).value<QIcon>()).pixmap(32));
-    } else {
-        painter->drawPixmap(accountGroupRect, KIconLoader::global()->loadIcon(QString("system-users"),
-                            KIconLoader::Desktop));
-    }
-
-    //create an area for text which does not overlap with the icons.
-    QRect textRect = groupLabelRect.adjusted(ACCOUNT_ICON_SIZE + (SPACING*4),0,0,0);
-    QString groupHeaderString =  index.data(Qt::DisplayRole).toString().append(counts);
-
-    if (option.state & QStyle::State_Selected) {
-        painter->setPen(option.palette.color(QPalette::Active, QPalette::HighlightedText));
-    } else {
-        painter->setPen(option.palette.color(QPalette::Active, QPalette::Text));
-    }
-
-    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(option.palette.color(QPalette::Inactive, QPalette::Button));
-
-    painter->setPen(thinLinePen);
-    painter->setRenderHint(QPainter::Antialiasing, false);
-
-    QFontMetrics fm = painter->fontMetrics();
-    int groupNameWidth = fm.width(groupHeaderString);
-
-    //show a horizontal line padding the header if there is any space left.
-    if (groupNameWidth < textRect.width()) {
-        painter->drawLine(expandSignRect.right() + SPACING * 4,
-                          groupRect.y() + groupRect.height() / 2,
-                          groupRect.width() - groupNameWidth - SPACING * 2,
-                          groupRect.y() + groupRect.height() / 2);
-    }
-
-    painter->setRenderHint(QPainter::Antialiasing, true);
-
-    QStyleOption expandSignOption = option;
-    expandSignOption.rect = expandSignRect;
-
-    if (option.state & QStyle::State_Open) {
-        style->drawPrimitive(QStyle::PE_IndicatorArrowDown, &expandSignOption, painter);
-    } else {
-        style->drawPrimitive(QStyle::PE_IndicatorArrowRight, &expandSignOption, painter);
-    }
-
-    painter->restore();
-}
-
-QSize AbstractContactDelegate::sizeHintHeader(const QStyleOptionViewItem &option, const QModelIndex &index) const
-{
-    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(event)
-    Q_UNUSED(view)
-    Q_UNUSED(option)
-    Q_UNUSED(index)
-    return false;
-}
diff --git a/contact/src/abstract-contact-delegate.h b/contact/src/abstract-contact-delegate.h
deleted file mode 100644
index b96e027..0000000
--- a/contact/src/abstract-contact-delegate.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Abstract Contact Delegate - base class for other delegates
- *
- * Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-
-#ifndef ABSTRACT_CONTACT_DELEGATE_H
-#define ABSTRACT_CONTACT_DELEGATE_H
-
-#include <QtGui/QStyledItemDelegate>
-
-
-class AbstractContactDelegate : public QStyledItemDelegate
-{
-    Q_OBJECT
-
-public:
-    AbstractContactDelegate(QObject* parent = 0);
-    virtual ~AbstractContactDelegate();
-
-    virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
-    virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const;
-
-public Q_SLOTS:
-    /**
-     * Reimplements the help tooltip for the contact delegate.
-     *
-     * When the user hovers over a contact it will display their information like Alias, which contact belongs to what account,
-     * is this contact blocked, their status message if their is one, etc.
-     */
-    bool helpEvent(QHelpEvent *event, QAbstractItemView *view, const QStyleOptionViewItem &option, const QModelIndex &index);
-
-Q_SIGNALS:
-    void repaintItem(QModelIndex);
-
-protected:
-    /** 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;
-
-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/src/applet_config.cpp b/contact/src/applet_config.cpp
deleted file mode 100644
index 52fff50..0000000
--- a/contact/src/applet_config.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2011 by Francesco Nwokeka <francesco.nwokeka at gmail.com> *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#include "applet_config.h"
-#include "contact-delegate-compact.h"
-
-#include <KTp/Models/contacts-model.h>
-
-#include <KDebug>
-#include <KPushButton>
-
-AppletConfig::AppletConfig(const Tp::AccountManagerPtr &accountManager, QWidget* parent)
-    : KDialog(parent)
-    , m_model(0)
-    , m_accountManager(accountManager)
-{
-    QWidget *widget = new QWidget(this);
-
-    ui.setupUi(widget);
-    setMainWidget(widget);
-    setCaption(i18n("Select a contact"));
-    setupContactsList();
-
-    connect(this, SIGNAL(buttonClicked(KDialog::ButtonCode)), this, SLOT(slotButtonClicked(int)));
-}
-
-AppletConfig::~AppletConfig()
-{
-    m_model->deleteLater();
-}
-
-void AppletConfig::enableGroupsView(bool enable)
-{
-    if (enable) {
-        m_model->setGroupMode(KTp::ContactsModel::GroupGrouping);
-    } else {
-        m_model->setGroupMode(KTp::ContactsModel::AccountGrouping);
-    }
-}
-
-void AppletConfig::enableOfflineContacts(bool enable)
-{
-    m_model->setPresenceTypeFilterFlags(enable ? KTp::ContactsFilterModel::DoNotFilterByPresence : KTp::ContactsFilterModel::ShowOnlyConnected);
-}
-
-void AppletConfig::setupContactsList()
-{
-    // prepare models
-    m_model = new KTp::ContactsModel(this);
-    m_model->setAccountManager(m_accountManager);
-
-    m_model->setDynamicSortFilter(true);
-    m_model->setPresenceTypeFilterFlags(ui.showOfflineContacts->isChecked() ? KTp::ContactsFilterModel::DoNotFilterByPresence : KTp::ContactsFilterModel::ShowOnlyConnected);
-    m_model->setSortRole(Qt::DisplayRole);
-
-    // set model for the contacts tree view
-    ui.contactsList->setModel(m_model);
-
-    // disable ok button until a list item is selected
-    button(Ok)->setEnabled(false);
-
-    ui.contactsList->header()->hide();
-    ui.contactsList->setRootIsDecorated(false);
-    ui.contactsList->setItemDelegate(new ContactDelegateCompact());
-    ui.contactsList->setSortingEnabled(true);
-    ui.contactsList->sortByColumn(0, Qt::AscendingOrder);
-    ui.contactsList->setSelectionMode(QAbstractItemView::SingleSelection);
-    ui.contactsList->setSelectionBehavior(QAbstractItemView::SelectItems);
-    ui.contactsList->setExpandsOnDoubleClick(false);
-
-    connect(ui.contactsList, SIGNAL(clicked(QModelIndex)), this, SLOT(contactListClicked(QModelIndex)));
-    connect(ui.contactsList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(contactListDoubleClicked(QModelIndex)));
-    connect(ui.showOfflineContacts, SIGNAL(toggled(bool)), this, SLOT(enableOfflineContacts(bool)));
-    connect(ui.showGroups, SIGNAL(toggled(bool)), this, SLOT(enableGroupsView(bool)));
-}
-
-void AppletConfig::contactListClicked(const QModelIndex& index)
-{
-    if (index.data(KTp::RowTypeRole).toInt() == KTp::ContactRowType) {
-        button(Ok)->setEnabled(true);
-    } else {
-        button(Ok)->setEnabled(false);
-
-        if (ui.contactsList->isExpanded(index)) {
-            ui.contactsList->collapse(index);
-        } else {
-            ui.contactsList->expand(index);
-        }
-    }
-}
-
-void AppletConfig::contactListDoubleClicked(const QModelIndex& index)
-{
-    if (index.data(KTp::RowTypeRole).toUInt() == KTp::ContactRowType) {
-        button(Ok)->setEnabled(true);
-        slotButtonClicked(Ok);
-    }
-}
-
-void AppletConfig::slotButtonClicked(int button)
-{
-    QModelIndex selectedItem = ui.contactsList->currentIndex();
-
-    if (button == KDialog::Ok && selectedItem.isValid()) {
-        if (selectedItem.data(KTp::RowTypeRole).toInt() == KTp::ContactRowType) {
-            KTp::ContactPtr contact = selectedItem.data(KTp::ContactRole).value<KTp::ContactPtr>();
-            Tp::AccountPtr account = selectedItem.data(KTp::AccountRole).value<Tp::AccountPtr>();
-
-            setNewContact(contact, account);
-            accept();
-        }
-    } else if (button == KDialog::Cancel) {
-        delayedDestruct();
-    }
-
-    KDialog::slotButtonClicked(button);
-}
diff --git a/contact/src/applet_config.h b/contact/src/applet_config.h
deleted file mode 100644
index 772b7cf..0000000
--- a/contact/src/applet_config.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2011 by Francesco Nwokeka <francesco.nwokeka at gmail.com> *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#ifndef APPLET_CONFIG_H
-#define APPLET_CONFIG_H
-
-#include "ui_applet_config.h"
-
-#include <KDialog>
-#include <TelepathyQt/AccountManager>
-
-namespace Ui {
-    class Config;
-}
-
-namespace KTp
-{
-    class ContactsModel;
-}
-
-class AppletConfig : public KDialog
-{
-    Q_OBJECT
-
-public:
-    explicit AppletConfig(const Tp::AccountManagerPtr &accountManager, QWidget *parent = 0);
-    ~AppletConfig();
-
-signals:
-    void setNewContact(const Tp::ContactPtr &newContact, const Tp::AccountPtr &relatedAccount);
-
-protected slots:
-    void slotButtonClicked(int button);
-
-private slots:
-    void contactListClicked(const QModelIndex &index);
-    void contactListDoubleClicked(const QModelIndex &index);
-    void enableGroupsView(bool enable);                     /** enable/disable groups view */
-    void enableOfflineContacts(bool enable);                /** enable/disable offline contacts */
-
-private:
-    void setupContactsList();                               /** prepare the contacts to be show in the list */
-
-    KTp::ContactsModel *m_model;
-    Tp::AccountManagerPtr m_accountManager;
-
-    Ui::Config ui;
-};
-
-
-#endif  // APPLET_CONFIG_H
diff --git a/contact/src/applet_config.ui b/contact/src/applet_config.ui
deleted file mode 100644
index 1b51c46..0000000
--- a/contact/src/applet_config.ui
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Config</class>
- <widget class="QWidget" name="Config">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>552</width>
-    <height>426</height>
-   </rect>
-  </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
-   <item>
-    <layout class="QVBoxLayout" name="verticalLayout_2">
-     <item>
-      <widget class="QCheckBox" name="showOfflineContacts">
-       <property name="text">
-        <string>Show offline contacts</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QCheckBox" name="showGroups">
-       <property name="text">
-        <string>Show groups</string>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
-   <item>
-    <widget class="QTreeView" name="contactsList"/>
-   </item>
-  </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/contact/src/contact-delegate-compact.cpp b/contact/src/contact-delegate-compact.cpp
deleted file mode 100644
index 7fedb1f..0000000
--- a/contact/src/contact-delegate-compact.cpp
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Contact Delegate - compact version
- *
- * Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
- * Copyright (C) 2012 Dominik Cermak <d.cermak at arcor.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "contact-delegate-compact.h"
-
-#include <QtGui/QPainter>
-#include <QtGui/QPainterPath>
-#include <QtGui/QToolTip>
-#include <QApplication>
-#include <QStyle>
-#include <QHelpEvent>
-
-#include <KIconLoader>
-#include <KIcon>
-#include <KDebug>
-#include <KGlobalSettings>
-#include <KDE/KLocale>
-
-#include <KTp/types.h>
-
-ContactDelegateCompact::ContactDelegateCompact(ContactDelegateCompact::ListSize size, QObject * parent)
-    : AbstractContactDelegate(parent)
-{
-    setListMode(size);
-}
-
-ContactDelegateCompact::~ContactDelegateCompact()
-{
-
-}
-
-void ContactDelegateCompact::paintContact(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
-{
-    QStyleOptionViewItemV4 optV4 = option;
-    initStyleOption(&optV4, index);
-
-    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);
-
-    QRect iconRect = optV4.rect;
-    iconRect.setSize(QSize(m_avatarSize, m_avatarSize));
-    iconRect.moveTo(QPoint(iconRect.x() + m_spacing, iconRect.y() + m_spacing));
-
-    QPixmap avatar;
-    avatar.load(index.data(KTp::ContactAvatarPathRole).toString());
-
-    bool noContactAvatar = avatar.isNull();
-
-    if (noContactAvatar) {
-        avatar = SmallIcon("im-user", KIconLoader::SizeMedium);
-    }
-
-    style->drawItemPixmap(painter, iconRect, Qt::AlignCenter, avatar.scaled(iconRect.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
-
-    // This value is used to set the correct width for the username and the presence message.
-    int rightIconsWidth = m_presenceIconSize + m_spacing;
-
-    QPixmap icon = KIcon(index.data(KTp::ContactPresenceIconRole).toString()).pixmap(KIconLoader::SizeSmallMedium);
-
-    QRect statusIconRect = optV4.rect;
-
-    statusIconRect.setSize(QSize(m_presenceIconSize, m_presenceIconSize));
-    statusIconRect.moveTo(QPoint(optV4.rect.right() - rightIconsWidth,
-                                 optV4.rect.top() + (optV4.rect.height() - m_presenceIconSize) / 2));
-
-    painter->drawPixmap(statusIconRect, icon);
-
-    // Right now we only check for 'phone', as that's the most interesting type.
-    if (index.data(KTp::ContactClientTypesRole).toStringList().contains(QLatin1String("phone"))) {
-        // Additional space is needed for the icons, don't add too much spacing between the two icons
-        rightIconsWidth += m_clientTypeIconSize + (m_spacing / 2);
-
-        QPixmap phone = QIcon::fromTheme("phone").pixmap(m_clientTypeIconSize);
-        QRect phoneIconRect = optV4.rect;
-        phoneIconRect.setSize(QSize(m_clientTypeIconSize, m_clientTypeIconSize));
-        phoneIconRect.moveTo(QPoint(optV4.rect.right() - rightIconsWidth,
-                                    optV4.rect.top() + (optV4.rect.height() - m_clientTypeIconSize) / 2));
-        painter->drawPixmap(phoneIconRect, phone);
-    }
-
-    QFont nameFont;
-
-    if (m_listSize == ContactDelegateCompact::Mini) {
-        nameFont = KGlobalSettings::smallestReadableFont();
-    } else {
-        nameFont = KGlobalSettings::generalFont();
-    }
-
-    const QFontMetrics nameFontMetrics(nameFont);
-
-    if (option.state & QStyle::State_Selected) {
-        painter->setPen(option.palette.color(QPalette::Active, QPalette::HighlightedText));
-    } else {
-        painter->setPen(option.palette.color(QPalette::Active, QPalette::Text));
-    }
-
-    painter->setFont(nameFont);
-
-    QRect userNameRect = optV4.rect;
-    userNameRect.setX(iconRect.x() + iconRect.width() + m_spacing * 2);
-    userNameRect.setY(userNameRect.y() + (userNameRect.height()/2 - nameFontMetrics.height()/2));
-    userNameRect.setWidth(userNameRect.width() - rightIconsWidth);
-
-    painter->drawText(userNameRect,
-                      nameFontMetrics.elidedText(optV4.text, Qt::ElideRight, userNameRect.width()));
-
-    QRect presenceMessageRect = optV4.rect;
-    presenceMessageRect.setX(userNameRect.x() + nameFontMetrics.boundingRect(optV4.text).width() + m_spacing * 2);
-    presenceMessageRect.setWidth(optV4.rect.width() - presenceMessageRect.x() - rightIconsWidth);
-    presenceMessageRect.setY(presenceMessageRect.y() + (presenceMessageRect.height()/2 - nameFontMetrics.height()/2));
-
-    if (option.state & QStyle::State_Selected) {
-        painter->setPen(option.palette.color(QPalette::Disabled, QPalette::HighlightedText));
-    } else {
-        painter->setPen(option.palette.color(QPalette::Disabled, QPalette::Text));
-    }
-
-    painter->drawText(presenceMessageRect,
-                      nameFontMetrics.elidedText(index.data(KTp::ContactPresenceMessageRole).toString().trimmed(),
-                                                 Qt::ElideRight, presenceMessageRect.width()));
-
-    painter->restore();
-}
-
-QSize ContactDelegateCompact::sizeHintContact(const QStyleOptionViewItem &option, const QModelIndex &index) const
-{
-    Q_UNUSED(option);
-    Q_UNUSED(index);
-    return QSize(0, qMax(m_avatarSize + 2 * m_spacing, KGlobalSettings::smallestReadableFont().pixelSize() + m_spacing));
-}
-
-void ContactDelegateCompact::setListMode(ContactDelegateCompact::ListSize size)
-{
-    if (size == ContactDelegateCompact::Mini) {
-        m_spacing = 2;
-        m_avatarSize = IconSize(KIconLoader::Toolbar);
-        m_presenceIconSize = qMax(12, KGlobalSettings::smallestReadableFont().pixelSize() + m_spacing);
-        m_clientTypeIconSize = qMax(12, KGlobalSettings::smallestReadableFont().pixelSize() + m_spacing);
-    } else if (size == ContactDelegateCompact::Normal) {
-        m_spacing = 4;
-        m_avatarSize = IconSize(KIconLoader::Toolbar);
-        m_presenceIconSize = IconSize(KIconLoader::Small);
-        m_clientTypeIconSize = IconSize(KIconLoader::Small);
-    }
-
-    m_listSize = size;
-}
-
-
-#include "contact-delegate-compact.moc"
diff --git a/contact/src/contact-delegate-compact.h b/contact/src/contact-delegate-compact.h
deleted file mode 100644
index e6013d5..0000000
--- a/contact/src/contact-delegate-compact.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Contact Delegate - compact version
- *
- * Copyright (C) 2011 Martin Klapetek <martin.klapetek at gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef CONTACTDELEGATECOMPACT_H
-#define CONTACTDELEGATECOMPACT_H
-
-#include "abstract-contact-delegate.h"
-
-class ContactDelegateCompact : public AbstractContactDelegate
-{
-    Q_OBJECT
-
-public:
-    enum ListSize {
-        Normal,
-        Mini
-    };
-    ContactDelegateCompact(ContactDelegateCompact::ListSize size = Normal, QObject *parent = 0);
-    ~ContactDelegateCompact();
-
-    void paintContact(QPainter *painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
-    QSize sizeHintContact(const QStyleOptionViewItem & option, const QModelIndex & index) const;
-
-    void setListMode(ContactDelegateCompact::ListSize size);
-
-private:
-    int m_spacing;
-    int m_avatarSize;
-    int m_presenceIconSize;
-    int m_accountIconSize;
-    int m_clientTypeIconSize;
-    ContactDelegateCompact::ListSize m_listSize;
-};
-
-#endif // CONTACTDELEGATECOMPACT_H
diff --git a/contact/src/telepathy-contact.cpp b/contact/src/telepathy-contact.cpp
index 9db8217..67c8a32 100644
--- a/contact/src/telepathy-contact.cpp
+++ b/contact/src/telepathy-contact.cpp
@@ -18,7 +18,6 @@
  ***************************************************************************/
 
 #include "telepathy-contact.h"
-#include "applet_config.h"
 #include "contact-wrapper.h"
 
 #include <KConfig>
@@ -37,6 +36,8 @@
 #include <TelepathyQt/Types>
 
 #include <KTp/contact-factory.h>
+#include <KTp/Widgets/contact-grid-dialog.h>
+#include <KTp/Models/contacts-filter-model.h>
 
 TelepathyContact::TelepathyContact(QObject* parent, const QVariantList& args)
     : Plasma::Applet(parent, args)
@@ -226,11 +227,25 @@ void TelepathyContact::setContact(const Tp::ContactPtr& newContact, const Tp::Ac
 void TelepathyContact::showConfigurationInterface()
 {
     if (!isUserConfiguring()) {
-        AppletConfig *config = new AppletConfig(m_accountManager, 0);
-        connect(config, SIGNAL(setNewContact(Tp::ContactPtr,Tp::AccountPtr)), this, SLOT(setContact(Tp::ContactPtr,Tp::AccountPtr)));
-        config->show();
+        KTp::ContactGridDialog *dlg = new KTp::ContactGridDialog(0);
+        dlg->filter()->setPresenceTypeFilterFlags(KTp::ContactsFilterModel::ShowAll);
+
+        connect(dlg, SIGNAL(accepted()), this, SLOT(configurationAccepted()));
+        connect(dlg, SIGNAL(rejected()), dlg, SLOT(deleteLater()));
+        dlg->show();
     }
 }
 
+void TelepathyContact::configurationAccepted()
+{
+    KTp::ContactGridDialog *dlg = qobject_cast<KTp::ContactGridDialog*>(sender());
+    Q_ASSERT(dlg);
+
+    setContact(dlg->contact(), dlg->account());
+
+    dlg->deleteLater();
+}
+
+
 // This is the command that links your applet to the .desktop file
 K_EXPORT_PLASMA_APPLET(org.kde.ktp-contact, TelepathyContact)
diff --git a/contact/src/telepathy-contact.h b/contact/src/telepathy-contact.h
index 6d4505f..fe95c83 100644
--- a/contact/src/telepathy-contact.h
+++ b/contact/src/telepathy-contact.h
@@ -53,6 +53,7 @@ public slots:
 
 private slots:
     void loadConfig();
+    void configurationAccepted();
     void onAccountManagerReady(Tp::PendingOperation *op);
 
 private:

-- 
ktp-contact-applet packaging



More information about the pkg-kde-commits mailing list