[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9

Maximiliano Curia maxy at moszumanska.debian.org
Mon May 9 09:07:58 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=82e0712

The following commit has been merged in the master branch:
commit 82e07127142a7e28c4ddaca03ba748d98a0d5952
Author: Amandeep Singh <aman.dedman at gmail.com>
Date:   Thu Jan 16 21:05:05 2014 +0530

    Moving ContactGridWidget to ContactViewWidget
    
    Review: 115029
    By default contacts are shown in list mode,
    ContactGridWidget inherits it to select Icon mode.
---
 KTp/Widgets/CMakeLists.txt                         |   2 +
 KTp/Widgets/contact-grid-widget.cpp                | 240 +--------------------
 KTp/Widgets/contact-grid-widget.h                  |  55 +----
 ...act-grid-widget.cpp => contact-view-widget.cpp} | 105 ++++-----
 ...contact-grid-widget.h => contact-view-widget.h} |  24 ++-
 5 files changed, 83 insertions(+), 343 deletions(-)

diff --git a/KTp/Widgets/CMakeLists.txt b/KTp/Widgets/CMakeLists.txt
index 8c42029..f6b8176 100644
--- a/KTp/Widgets/CMakeLists.txt
+++ b/KTp/Widgets/CMakeLists.txt
@@ -4,6 +4,7 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR}
 
 set (ktp_widgets_private_SRCS
     ${KTP_GLOBAL_SOURCES}
+    contact-view-widget.cpp
     contact-grid-widget.cpp
     contact-grid-dialog.cpp
     add-contact-dialog.cpp
@@ -14,6 +15,7 @@ set (ktp_widgets_private_SRCS
 )
 
 set (ktp_widgets_private_HDRS
+     contact-view-widget.h
      contact-grid-widget.h
      contact-grid-dialog.h
      add-contact-dialog.h
diff --git a/KTp/Widgets/contact-grid-widget.cpp b/KTp/Widgets/contact-grid-widget.cpp
index 284f9fc..1f7c2df 100644
--- a/KTp/Widgets/contact-grid-widget.cpp
+++ b/KTp/Widgets/contact-grid-widget.cpp
@@ -1,6 +1,5 @@
 /*
- * Copyright (C) 2011 David Edmundson <kde at davidedmundson.co.uk>
- * Copyright (C) 2012 Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
+ * Copyright (C) 2014 Amandeep Singh <aman.dedman 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
@@ -20,241 +19,12 @@
 
 #include "contact-grid-widget.h"
 
-#include <KDE/KIcon>
-#include <KDE/KLineEdit>
-#include <KDE/KDebug>
+#include <QListView>
 
-#include <QtGui/QApplication>
-#include <QtGui/QTextOption>
-#include <QtGui/QPainter>
-#include <QtGui/QVBoxLayout>
-#include <QtGui/QListView>
-
-#include "types.h"
-#include <KTp/Models/contacts-list-model.h>
-#include <KTp/Models/contacts-filter-model.h>
-
-namespace KTp {
-
-class ContactGridDelegate : public QAbstractItemDelegate
-{
-    Q_OBJECT
-    Q_DISABLE_COPY(ContactGridDelegate)
-
-public:
-    ContactGridDelegate(QObject *parent);
-    virtual ~ContactGridDelegate();
-
-    virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
-    virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
-
-}; // class ContactGridDelegate
-
-} // namespace KTp
-
-
-KTp::ContactGridDelegate::ContactGridDelegate(QObject *parent)
-    : QAbstractItemDelegate(parent)
-{
-}
-
-KTp::ContactGridDelegate::~ContactGridDelegate()
-{
-}
-
-void KTp::ContactGridDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
-{
-    QStyle *style = QApplication::style();
-    int textHeight = option.fontMetrics.height() * 2;
-
-    style->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter);
-
-    QRect avatarRect = option.rect.adjusted(0, 0, 0, -textHeight);
-    QRect textRect = option.rect.adjusted(0, option.rect.height() - textHeight, 0, -3);
-
-    QPixmap avatar;
-    avatar.load(index.data(KTp::ContactAvatarPathRole).toString());
-    if (avatar.isNull()) {
-        avatar = KIcon(QLatin1String("im-user-online")).pixmap(option.decorationSize);
-    } else if (avatar.width() > option.decorationSize.width() || avatar.height() > option.decorationSize.height()) {
-        //resize larger avatars if required
-        avatar = avatar.scaled(option.decorationSize, Qt::KeepAspectRatio);
-        //draw leaving paddings on smaller (or non square) avatars
-    }
-    style->drawItemPixmap(painter, avatarRect, Qt::AlignCenter, avatar);
-
-
-    QTextOption textOption;
-    textOption.setAlignment(Qt::AlignCenter);
-    textOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
-    painter->drawText(textRect, index.data().toString(), textOption);
-
-}
-
-QSize KTp::ContactGridDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
-{
-    Q_UNUSED(index);
-    int textHeight = option.fontMetrics.height() * 2;
-    return QSize(option.decorationSize.width() + 4, option.decorationSize.height() + textHeight + 3);
-}
-
-// -----------------------------------------------------------------------------
-
-class KTp::ContactGridWidget::Private
-{
-public:
-    Private(KTp::ContactGridWidget *parent)
-        : q(parent),
-          layout(new QVBoxLayout(parent)),
-          contactGridView(new QListView(parent)),
-          contactFilterLineEdit(new KLineEdit(parent)),
-          contactsModel(0),
-          filterModel(0)
-    {
-    }
-
-    ~Private()
-    {
-    }
-
-    void _k_onSelectionChanged(const QItemSelection &newSelection, const QItemSelection &oldSelection);
-    void _k_onDoubleClicked(const QModelIndex &index);
-
-    KTp::ContactGridWidget *q;
-    QVBoxLayout *layout;
-    QListView *contactGridView;
-    KLineEdit *contactFilterLineEdit;
-    KTp::ContactsListModel *contactsModel;
-    KTp::ContactsFilterModel *filterModel;
-};
-
-void KTp::ContactGridWidget::Private::_k_onSelectionChanged(const QItemSelection &newSelection,
-                                                            const QItemSelection &oldSelection)
-{
-    Q_UNUSED(oldSelection)
-    kDebug() << newSelection << oldSelection;
-
-    if (newSelection.isEmpty()) {
-        Q_EMIT q->selectionChanged(Tp::AccountPtr(), KTp::ContactPtr());
-        return;
-    }
-
-    Q_EMIT q->selectionChanged(q->selectedAccount(), q->selectedContact());
-}
-
-void KTp::ContactGridWidget::Private::_k_onDoubleClicked(const QModelIndex& index)
-{
-    if (!index.isValid()) {
-        return;
-    }
-
-    Q_EMIT q->contactDoubleClicked(index.data(KTp::AccountRole).value<Tp::AccountPtr>(),
-                                   index.data(KTp::ContactRole).value<KTp::ContactPtr>());
-}
-
-
-// -----------------------------------------------------------------------------
-
-KTp::ContactGridWidget::ContactGridWidget(KTp::ContactsListModel* model, QWidget *parent)
-    : QWidget(parent),
-      d(new Private(this))
-{
-    d->filterModel = new KTp::ContactsFilterModel(this);
-
-    d->contactsModel = model;
-    d->filterModel->setSourceModel(d->contactsModel);
-
-    d->contactGridView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
-    d->contactGridView->setResizeMode(QListView::Adjust);
-    d->contactGridView->setSpacing(5);
-    d->contactGridView->setViewMode(QListView::IconMode);
-    d->contactGridView->setIconSize(QSize(80, 80));
-
-    d->contactFilterLineEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
-    d->contactFilterLineEdit->setClearButtonShown(true);
-
-    d->layout->setMargin(0);
-    d->layout->addWidget(d->contactGridView);
-    d->layout->addWidget(d->contactFilterLineEdit);
-    setLayout(d->layout);
-
-    d->contactGridView->setModel(d->filterModel);
-    d->contactGridView->setItemDelegate(new ContactGridDelegate(d->contactGridView));
-
-    connect(d->contactGridView->selectionModel(),
-            SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
-            SLOT(_k_onSelectionChanged(QItemSelection,QItemSelection)));
-    connect(d->contactGridView,
-            SIGNAL(doubleClicked(QModelIndex)),
-            SLOT(_k_onDoubleClicked(QModelIndex)));
-
-    connect(d->contactFilterLineEdit,
-            SIGNAL(textChanged(QString)),
-            d->filterModel,
-            SLOT(setDisplayNameFilterString(QString)));
-}
-
-KTp::ContactGridWidget::~ContactGridWidget()
-{
-    delete d;
-}
-
-QString KTp::ContactGridWidget::displayNameFilter() const
-{
-    return d->contactFilterLineEdit->text();
-}
-
-void KTp::ContactGridWidget::clearDisplayNameFilter()
-{
-    setDisplayNameFilter(QString());
-}
-
-void KTp::ContactGridWidget::setDisplayNameFilter(const QString& displayNameFilter)
-{
-    if (displayNameFilter != d->contactFilterLineEdit->text()) {
-        d->contactFilterLineEdit->setText(displayNameFilter);
-        Q_EMIT displayNameFilterChanged(displayNameFilter);
-    }
-}
-
-QSize KTp::ContactGridWidget::iconSize() const
-{
-    return d->contactGridView->iconSize();
-}
-
-void KTp::ContactGridWidget::setIconSize(const QSize& iconSize)
-{
-    kDebug();
-    if (iconSize != d->contactGridView->iconSize()) {
-        d->contactGridView->setIconSize(iconSize);
-        Q_EMIT iconSizeChanged(iconSize);
-    }
-}
-
-bool KTp::ContactGridWidget::hasSelection() const
-{
-    return d->contactGridView->selectionModel()->hasSelection();
-}
-
-Tp::AccountPtr KTp::ContactGridWidget::selectedAccount() const
-{
-    return d->contactGridView->currentIndex().data(KTp::AccountRole).value<Tp::AccountPtr>();
-}
-
-KTp::ContactPtr KTp::ContactGridWidget::selectedContact() const
-{
-    return d->contactGridView->currentIndex().data(KTp::ContactRole).value<KTp::ContactPtr>();
-}
-
-KTp::ContactsFilterModel* KTp::ContactGridWidget::filter() const
-{
-    return d->filterModel;
-}
-
-KLineEdit* KTp::ContactGridWidget::contactFilterLineEdit() const
+KTp::ContactGridWidget::ContactGridWidget(ContactsListModel *model, QWidget *parent)
+    : ContactViewWidget(model, parent)
 {
-    return d->contactFilterLineEdit;
+    setViewMode(QListView::IconMode);
 }
 
-#include "contact-grid-widget.moc"
 #include "moc_contact-grid-widget.cpp"
diff --git a/KTp/Widgets/contact-grid-widget.h b/KTp/Widgets/contact-grid-widget.h
index 8421b31..5780332 100644
--- a/KTp/Widgets/contact-grid-widget.h
+++ b/KTp/Widgets/contact-grid-widget.h
@@ -1,6 +1,5 @@
 /*
- * Copyright (C) 2011 David Edmundson <kde at davidedmundson.co.uk>
- * Copyright (C) 2012 Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
+ * Copyright (C) 2014 Amandeep Singh <aman.dedman 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
@@ -21,66 +20,18 @@
 #ifndef CONTACT_GRID_WIDGET_H
 #define CONTACT_GRID_WIDGET_H
 
-#include <QtGui/QWidget>
-
-#include <TelepathyQt/Types>
-
-#include <KTp/contact.h>
-#include <KTp/ktp-export.h>
-
-class KLineEdit;
-class QItemSelection;
+#include <KTp/Widgets/contact-view-widget.h>
 
 namespace KTp
 {
-class ContactsFilterModel;
-class ContactsListModel;
 
-class KTP_EXPORT ContactGridWidget : public QWidget
+class KTP_EXPORT ContactGridWidget : public ContactViewWidget
 {
     Q_OBJECT
     Q_DISABLE_COPY(ContactGridWidget)
 
-    Q_PROPERTY(QString displayNameFilter
-               READ displayNameFilter
-               RESET clearDisplayNameFilter
-               WRITE setDisplayNameFilter
-               NOTIFY displayNameFilterChanged)
-    Q_PROPERTY(QSize iconSize
-               READ iconSize
-               WRITE setIconSize
-               NOTIFY iconSizeChanged)
 public:
     explicit ContactGridWidget(ContactsListModel *model, QWidget *parent = 0);
-    virtual ~ContactGridWidget();
-
-    virtual QString displayNameFilter() const;
-    Q_SLOT virtual void clearDisplayNameFilter();
-    Q_SLOT virtual void setDisplayNameFilter(const QString &displayNameFilter);
-    Q_SIGNAL void displayNameFilterChanged(const QString &displayNameFilter);
-
-    virtual QSize iconSize() const;
-    Q_SLOT virtual void setIconSize(const QSize &iconSize);
-    Q_SIGNAL void iconSizeChanged(const QSize &iconSize);
-
-    virtual KTp::ContactsFilterModel* filter() const;
-    virtual KLineEdit* contactFilterLineEdit() const;
-
-    virtual bool hasSelection() const;
-    virtual Tp::AccountPtr selectedAccount() const;
-    virtual KTp::ContactPtr selectedContact() const;
-
-Q_SIGNALS:
-    void selectionChanged(const Tp::AccountPtr &selectedAccount, const KTp::ContactPtr &selectedContact);
-    void contactDoubleClicked(const Tp::AccountPtr &account, const KTp::ContactPtr &contact);
-
-private:
-    class Private;
-    Private * const d;
-
-    Q_PRIVATE_SLOT(d, void _k_onSelectionChanged(const QItemSelection &currentSelection,
-                                                 const QItemSelection &previousSelection));
-    Q_PRIVATE_SLOT(d, void _k_onDoubleClicked(const QModelIndex &index));
 
 }; // class ContactGridWidget
 
diff --git a/KTp/Widgets/contact-grid-widget.cpp b/KTp/Widgets/contact-view-widget.cpp
similarity index 67%
copy from KTp/Widgets/contact-grid-widget.cpp
copy to KTp/Widgets/contact-view-widget.cpp
index 284f9fc..8a4846b 100644
--- a/KTp/Widgets/contact-grid-widget.cpp
+++ b/KTp/Widgets/contact-view-widget.cpp
@@ -18,7 +18,7 @@
  */
 
 
-#include "contact-grid-widget.h"
+#include "contact-view-widget.h"
 
 #include <KDE/KIcon>
 #include <KDE/KLineEdit>
@@ -28,7 +28,6 @@
 #include <QtGui/QTextOption>
 #include <QtGui/QPainter>
 #include <QtGui/QVBoxLayout>
-#include <QtGui/QListView>
 
 #include "types.h"
 #include <KTp/Models/contacts-list-model.h>
@@ -36,33 +35,33 @@
 
 namespace KTp {
 
-class ContactGridDelegate : public QAbstractItemDelegate
+class ContactViewDelegate : public QAbstractItemDelegate
 {
     Q_OBJECT
-    Q_DISABLE_COPY(ContactGridDelegate)
+    Q_DISABLE_COPY(ContactViewDelegate)
 
 public:
-    ContactGridDelegate(QObject *parent);
-    virtual ~ContactGridDelegate();
+    ContactViewDelegate(QObject *parent);
+    virtual ~ContactViewDelegate();
 
     virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
     virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
 
-}; // class ContactGridDelegate
+}; // class ContactViewDelegate
 
 } // namespace KTp
 
 
-KTp::ContactGridDelegate::ContactGridDelegate(QObject *parent)
+KTp::ContactViewDelegate::ContactViewDelegate(QObject *parent)
     : QAbstractItemDelegate(parent)
 {
 }
 
-KTp::ContactGridDelegate::~ContactGridDelegate()
+KTp::ContactViewDelegate::~ContactViewDelegate()
 {
 }
 
-void KTp::ContactGridDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
+void KTp::ContactViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
 {
     QStyle *style = QApplication::style();
     int textHeight = option.fontMetrics.height() * 2;
@@ -91,7 +90,7 @@ void KTp::ContactGridDelegate::paint(QPainter *painter, const QStyleOptionViewIt
 
 }
 
-QSize KTp::ContactGridDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
+QSize KTp::ContactViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
 {
     Q_UNUSED(index);
     int textHeight = option.fontMetrics.height() * 2;
@@ -100,13 +99,13 @@ QSize KTp::ContactGridDelegate::sizeHint(const QStyleOptionViewItem &option, con
 
 // -----------------------------------------------------------------------------
 
-class KTp::ContactGridWidget::Private
+class KTp::ContactViewWidget::Private
 {
 public:
-    Private(KTp::ContactGridWidget *parent)
+    Private(KTp::ContactViewWidget *parent)
         : q(parent),
           layout(new QVBoxLayout(parent)),
-          contactGridView(new QListView(parent)),
+          contactView(new QListView(parent)),
           contactFilterLineEdit(new KLineEdit(parent)),
           contactsModel(0),
           filterModel(0)
@@ -120,15 +119,15 @@ public:
     void _k_onSelectionChanged(const QItemSelection &newSelection, const QItemSelection &oldSelection);
     void _k_onDoubleClicked(const QModelIndex &index);
 
-    KTp::ContactGridWidget *q;
+    KTp::ContactViewWidget *q;
     QVBoxLayout *layout;
-    QListView *contactGridView;
+    QListView *contactView;
     KLineEdit *contactFilterLineEdit;
     KTp::ContactsListModel *contactsModel;
     KTp::ContactsFilterModel *filterModel;
 };
 
-void KTp::ContactGridWidget::Private::_k_onSelectionChanged(const QItemSelection &newSelection,
+void KTp::ContactViewWidget::Private::_k_onSelectionChanged(const QItemSelection &newSelection,
                                                             const QItemSelection &oldSelection)
 {
     Q_UNUSED(oldSelection)
@@ -142,7 +141,7 @@ void KTp::ContactGridWidget::Private::_k_onSelectionChanged(const QItemSelection
     Q_EMIT q->selectionChanged(q->selectedAccount(), q->selectedContact());
 }
 
-void KTp::ContactGridWidget::Private::_k_onDoubleClicked(const QModelIndex& index)
+void KTp::ContactViewWidget::Private::_k_onDoubleClicked(const QModelIndex& index)
 {
     if (!index.isValid()) {
         return;
@@ -155,7 +154,7 @@ void KTp::ContactGridWidget::Private::_k_onDoubleClicked(const QModelIndex& inde
 
 // -----------------------------------------------------------------------------
 
-KTp::ContactGridWidget::ContactGridWidget(KTp::ContactsListModel* model, QWidget *parent)
+KTp::ContactViewWidget::ContactViewWidget(KTp::ContactsListModel* model, QWidget *parent)
     : QWidget(parent),
       d(new Private(this))
 {
@@ -164,27 +163,27 @@ KTp::ContactGridWidget::ContactGridWidget(KTp::ContactsListModel* model, QWidget
     d->contactsModel = model;
     d->filterModel->setSourceModel(d->contactsModel);
 
-    d->contactGridView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
-    d->contactGridView->setResizeMode(QListView::Adjust);
-    d->contactGridView->setSpacing(5);
-    d->contactGridView->setViewMode(QListView::IconMode);
-    d->contactGridView->setIconSize(QSize(80, 80));
+    d->contactView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+    d->contactView->setResizeMode(QListView::Adjust);
+    d->contactView->setSpacing(5);
+    d->contactView->setViewMode(QListView::ListMode);
+    d->contactView->setIconSize(QSize(80, 80));
 
     d->contactFilterLineEdit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
     d->contactFilterLineEdit->setClearButtonShown(true);
 
     d->layout->setMargin(0);
-    d->layout->addWidget(d->contactGridView);
+    d->layout->addWidget(d->contactView);
     d->layout->addWidget(d->contactFilterLineEdit);
     setLayout(d->layout);
 
-    d->contactGridView->setModel(d->filterModel);
-    d->contactGridView->setItemDelegate(new ContactGridDelegate(d->contactGridView));
+    d->contactView->setModel(d->filterModel);
+    d->contactView->setItemDelegate(new ContactViewDelegate(d->contactView));
 
-    connect(d->contactGridView->selectionModel(),
+    connect(d->contactView->selectionModel(),
             SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
             SLOT(_k_onSelectionChanged(QItemSelection,QItemSelection)));
-    connect(d->contactGridView,
+    connect(d->contactView,
             SIGNAL(doubleClicked(QModelIndex)),
             SLOT(_k_onDoubleClicked(QModelIndex)));
 
@@ -194,22 +193,22 @@ KTp::ContactGridWidget::ContactGridWidget(KTp::ContactsListModel* model, QWidget
             SLOT(setDisplayNameFilterString(QString)));
 }
 
-KTp::ContactGridWidget::~ContactGridWidget()
+KTp::ContactViewWidget::~ContactViewWidget()
 {
     delete d;
 }
 
-QString KTp::ContactGridWidget::displayNameFilter() const
+QString KTp::ContactViewWidget::displayNameFilter() const
 {
     return d->contactFilterLineEdit->text();
 }
 
-void KTp::ContactGridWidget::clearDisplayNameFilter()
+void KTp::ContactViewWidget::clearDisplayNameFilter()
 {
     setDisplayNameFilter(QString());
 }
 
-void KTp::ContactGridWidget::setDisplayNameFilter(const QString& displayNameFilter)
+void KTp::ContactViewWidget::setDisplayNameFilter(const QString& displayNameFilter)
 {
     if (displayNameFilter != d->contactFilterLineEdit->text()) {
         d->contactFilterLineEdit->setText(displayNameFilter);
@@ -217,44 +216,54 @@ void KTp::ContactGridWidget::setDisplayNameFilter(const QString& displayNameFilt
     }
 }
 
-QSize KTp::ContactGridWidget::iconSize() const
+QSize KTp::ContactViewWidget::iconSize() const
 {
-    return d->contactGridView->iconSize();
+    return d->contactView->iconSize();
 }
 
-void KTp::ContactGridWidget::setIconSize(const QSize& iconSize)
+void KTp::ContactViewWidget::setIconSize(const QSize& iconSize)
 {
     kDebug();
-    if (iconSize != d->contactGridView->iconSize()) {
-        d->contactGridView->setIconSize(iconSize);
+    if (iconSize != d->contactView->iconSize()) {
+        d->contactView->setIconSize(iconSize);
         Q_EMIT iconSizeChanged(iconSize);
     }
 }
 
-bool KTp::ContactGridWidget::hasSelection() const
+bool KTp::ContactViewWidget::hasSelection() const
 {
-    return d->contactGridView->selectionModel()->hasSelection();
+    return d->contactView->selectionModel()->hasSelection();
 }
 
-Tp::AccountPtr KTp::ContactGridWidget::selectedAccount() const
+Tp::AccountPtr KTp::ContactViewWidget::selectedAccount() const
 {
-    return d->contactGridView->currentIndex().data(KTp::AccountRole).value<Tp::AccountPtr>();
+    return d->contactView->currentIndex().data(KTp::AccountRole).value<Tp::AccountPtr>();
 }
 
-KTp::ContactPtr KTp::ContactGridWidget::selectedContact() const
+KTp::ContactPtr KTp::ContactViewWidget::selectedContact() const
 {
-    return d->contactGridView->currentIndex().data(KTp::ContactRole).value<KTp::ContactPtr>();
+    return d->contactView->currentIndex().data(KTp::ContactRole).value<KTp::ContactPtr>();
 }
 
-KTp::ContactsFilterModel* KTp::ContactGridWidget::filter() const
+void KTp::ContactViewWidget::setViewMode(QListView::ViewMode mode)
+{
+    d->contactView->setViewMode(mode);
+}
+
+QListView::ViewMode KTp::ContactViewWidget::viewMode() const
+{
+    return d->contactView->viewMode();
+}
+
+KTp::ContactsFilterModel* KTp::ContactViewWidget::filter() const
 {
     return d->filterModel;
 }
 
-KLineEdit* KTp::ContactGridWidget::contactFilterLineEdit() const
+KLineEdit* KTp::ContactViewWidget::contactFilterLineEdit() const
 {
     return d->contactFilterLineEdit;
 }
 
-#include "contact-grid-widget.moc"
-#include "moc_contact-grid-widget.cpp"
+#include "contact-view-widget.moc"
+#include "moc_contact-view-widget.cpp"
diff --git a/KTp/Widgets/contact-grid-widget.h b/KTp/Widgets/contact-view-widget.h
similarity index 83%
copy from KTp/Widgets/contact-grid-widget.h
copy to KTp/Widgets/contact-view-widget.h
index 8421b31..1a2e763 100644
--- a/KTp/Widgets/contact-grid-widget.h
+++ b/KTp/Widgets/contact-view-widget.h
@@ -18,10 +18,11 @@
  */
 
 
-#ifndef CONTACT_GRID_WIDGET_H
-#define CONTACT_GRID_WIDGET_H
+#ifndef CONTACT_VIEW_WIDGET_H
+#define CONTACT_VIEW_WIDGET_H
 
 #include <QtGui/QWidget>
+#include <QtGui/QListView>
 
 #include <TelepathyQt/Types>
 
@@ -30,16 +31,17 @@
 
 class KLineEdit;
 class QItemSelection;
+class QListView;
 
 namespace KTp
 {
 class ContactsFilterModel;
 class ContactsListModel;
 
-class KTP_EXPORT ContactGridWidget : public QWidget
+class KTP_EXPORT ContactViewWidget : public QWidget
 {
     Q_OBJECT
-    Q_DISABLE_COPY(ContactGridWidget)
+    Q_DISABLE_COPY(ContactViewWidget)
 
     Q_PROPERTY(QString displayNameFilter
                READ displayNameFilter
@@ -50,9 +52,12 @@ class KTP_EXPORT ContactGridWidget : public QWidget
                READ iconSize
                WRITE setIconSize
                NOTIFY iconSizeChanged)
+    Q_PROPERTY(QListView::ViewMode viewMode
+               READ viewMode
+               WRITE setViewMode)
 public:
-    explicit ContactGridWidget(ContactsListModel *model, QWidget *parent = 0);
-    virtual ~ContactGridWidget();
+    explicit ContactViewWidget(ContactsListModel *model, QWidget *parent = 0);
+    virtual ~ContactViewWidget();
 
     virtual QString displayNameFilter() const;
     Q_SLOT virtual void clearDisplayNameFilter();
@@ -70,6 +75,9 @@ public:
     virtual Tp::AccountPtr selectedAccount() const;
     virtual KTp::ContactPtr selectedContact() const;
 
+    void setViewMode(QListView::ViewMode);
+    QListView::ViewMode viewMode() const;
+
 Q_SIGNALS:
     void selectionChanged(const Tp::AccountPtr &selectedAccount, const KTp::ContactPtr &selectedContact);
     void contactDoubleClicked(const Tp::AccountPtr &account, const KTp::ContactPtr &contact);
@@ -82,8 +90,8 @@ private:
                                                  const QItemSelection &previousSelection));
     Q_PRIVATE_SLOT(d, void _k_onDoubleClicked(const QModelIndex &index));
 
-}; // class ContactGridWidget
+}; // class ContactViewWidget
 
 } // namespace KTp
 
-#endif // CONTACT_GRID_WIDGET_H
+#endif // CONTACT_VIEW_WIDGET_H

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list