[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:13:36 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-desktop-applets.git;a=commitdiff;h=5391e08
The following commit has been merged in the master branch:
commit 5391e081e84ae6c6dea9a5b0fd522a4d23e12136
Author: David Edmundson <kde at davidedmundson.co.uk>
Date: Wed Mar 14 19:13:53 2012 +0000
Fix crash, initialise models at the start. Removed code duplication of FlatProxyModel.
---
CMakeLists.txt | 1 -
src/flat-model-proxy.cpp | 182 -------------------------------------------
src/flat-model-proxy.h | 64 ---------------
src/telepathyContactList.cpp | 12 +--
src/telepathyContactList.h | 3 +
5 files changed, 10 insertions(+), 252 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d05fb73..c2ed221 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,7 +31,6 @@ include_directories(${CMAKE_SOURCE_DIR}
set(telepathy_contact_list_applet_SRCS
src/telepathyContactList.cpp
- src/flat-model-proxy.cpp
)
kde4_add_plugin(plasma_applet_telepathy_contact_list ${telepathy_contact_list_applet_SRCS})
diff --git a/src/flat-model-proxy.cpp b/src/flat-model-proxy.cpp
deleted file mode 100644
index 19312c2..0000000
--- a/src/flat-model-proxy.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * This file is part of TelepathyQt4Yell Models
- *
- * Copyright (C) 2010 Collabora Ltd. <http://www.collabora.co.uk/>
- *
- * 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 "flat-model-proxy.h"
-
-#include <QDebug>
-
-struct FlatModelProxy::Private
-{
- int offsetOf(const FlatModelProxy *model, int index) const;
-};
-
-int FlatModelProxy::Private::offsetOf(const FlatModelProxy *model, int index) const
-{
- int offset = 0;
- for (int i = 0; i < index; i++) {
- offset += model->sourceModel()->rowCount(model->sourceModel()->index(i, 0, QModelIndex()));
- }
- return offset;
-}
-
-FlatModelProxy::FlatModelProxy(QAbstractItemModel *source)
- : QAbstractProxyModel(source),
- mPriv(new Private())
-{
- setSourceModel(source);
-
- connect(source,
- SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
- SLOT(onRowsAboutToBeInserted(QModelIndex,int,int)));
- connect(source,
- SIGNAL(rowsInserted(QModelIndex,int,int)),
- SLOT(onRowsInserted(QModelIndex,int,int)));
- connect(source,
- SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
- SLOT(onRowsAboutToBeRemoved(QModelIndex,int,int)));
- connect(source,
- SIGNAL(rowsRemoved(QModelIndex,int,int)),
- SLOT(onRowsRemoved(QModelIndex,int,int)));
- connect(source,
- SIGNAL(rowsInserted(QModelIndex,int,int)),
- SIGNAL(rowCountChanged()));
- connect(source,
- SIGNAL(rowsRemoved(QModelIndex,int,int)),
- SIGNAL(rowCountChanged()));
- connect(source,
- SIGNAL(dataChanged(QModelIndex,QModelIndex)),
- SLOT(onDataChanged(QModelIndex,QModelIndex)));
-}
-
-FlatModelProxy::~FlatModelProxy()
-{
- delete mPriv;
-}
-
-QModelIndex FlatModelProxy::mapFromSource(const QModelIndex &index) const
-{
- if (!index.isValid()) {
- return QModelIndex();
- }
-
- QModelIndex parent = index.parent();
-
- if (!parent.isValid()) {
- return QModelIndex();
- }
-
- return createIndex(mPriv->offsetOf(this, parent.row()) + index.row(), index.column(), parent.row());
-}
-
-QModelIndex FlatModelProxy::mapToSource(const QModelIndex &index) const
-{
- int parentRow = index.internalId();
- QModelIndex parent = sourceModel()->index(parentRow, 0, QModelIndex());
- int row = index.row() - mPriv->offsetOf(this, parent.row());
- return sourceModel()->index(row, index.column(), parent);
-}
-
-QModelIndex FlatModelProxy::index(int row, int column, const QModelIndex &parent) const
-{
- int count = 0;
- for (int i = 0; i < sourceModel()->rowCount(QModelIndex()); i++) {
- QModelIndex sourceIndex = sourceModel()->index(i, 0, QModelIndex());
- count += sourceModel()->rowCount(sourceIndex);
- if (row < count) {
- return createIndex(row, column, i);
- }
- }
-
- return QModelIndex();
-}
-
-QModelIndex FlatModelProxy::parent(const QModelIndex &index) const
-{
- return QModelIndex();
-}
-
-int FlatModelProxy::columnCount(const QModelIndex &parent) const
-{
- return 1;
-}
-
-int FlatModelProxy::rowCount() const
-{
- return rowCount(QModelIndex());
-}
-
-int FlatModelProxy::rowCount(const QModelIndex &parent) const
-{
- qDebug() << "row count is " << mPriv->offsetOf(this, sourceModel()->rowCount(QModelIndex()));
- return mPriv->offsetOf(this, sourceModel()->rowCount(QModelIndex()));
-}
-
-void FlatModelProxy::onRowsAboutToBeInserted(const QModelIndex &index, int first, int last)
-{
- if (index.isValid()) {
- int offset = mPriv->offsetOf(this, index.row());
- int firstIndex = offset + first;
- int lastIndex = offset + last;
-
- beginInsertRows(QModelIndex(), firstIndex, lastIndex);
- }
-}
-
-void FlatModelProxy::onRowsAboutToBeRemoved(const QModelIndex &index, int first, int last)
-{
- if (index.isValid()) {
- int offset = mPriv->offsetOf(this, index.row());
- int firstIndex = offset + first;
- int lastIndex = offset + last;
-
- beginRemoveRows(QModelIndex(), firstIndex, lastIndex);
- }
-}
-
-void FlatModelProxy::onRowsInserted(const QModelIndex &index, int first, int last)
-{
- if (index.isValid()) {
- endInsertRows();
- }
-}
-
-void FlatModelProxy::onRowsRemoved(const QModelIndex &index, int first, int last)
-{
- if (index.isValid()) {
- endRemoveRows();
- }
-}
-
-void FlatModelProxy::onDataChanged(const QModelIndex &first, const QModelIndex &last)
-{
- if (!first.parent().isValid()) {
- int firstOffset = mPriv->offsetOf(this, first.row());
- int lastOffset = mPriv->offsetOf(this, last.row() + 1) - 1;
-
- QModelIndex firstIndex = createIndex(firstOffset, 0, first.row());
- QModelIndex lastIndex = createIndex(lastOffset, 0, last.row());
- emit dataChanged(firstIndex, lastIndex);
- }
- else if (first.parent() == last.parent()) {
- QModelIndex firstIndex = mapFromSource(first);
- QModelIndex lastIndex = mapFromSource(last);
- emit dataChanged(firstIndex, lastIndex);
- }
-}
diff --git a/src/flat-model-proxy.h b/src/flat-model-proxy.h
deleted file mode 100644
index b592f48..0000000
--- a/src/flat-model-proxy.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * This file is part of TelepathyQt4Yell Models
- *
- * Copyright (C) 2010 Collabora Ltd. <http://www.collabora.co.uk/>
- *
- * 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 _TelepathyQt4Yell_Models_flat_model_proxy_h_HEADER_GUARD_
-#define _TelepathyQt4Yell_Models_flat_model_proxy_h_HEADER_GUARD_
-
-
-#include <QAbstractProxyModel>
-
-class FlatModelProxy : public QAbstractProxyModel
-{
- Q_OBJECT
- Q_DISABLE_COPY(FlatModelProxy)
- Q_PROPERTY(int rowCount READ rowCount NOTIFY rowCountChanged)
-
-public:
- FlatModelProxy(QAbstractItemModel *source);
- virtual ~FlatModelProxy();
-
- virtual QModelIndex mapFromSource(const QModelIndex &index) const;
- virtual QModelIndex mapToSource(const QModelIndex &index) const;
- virtual QModelIndex index(int row, int column, const QModelIndex &parent) const;
- virtual QModelIndex parent(const QModelIndex &index) const;
- virtual int rowCount(const QModelIndex &parent) const;
- virtual int columnCount(const QModelIndex &parent) const;
-
- int rowCount() const;
-
-Q_SIGNALS:
- void rowCountChanged();
-
-private Q_SLOTS:
- void onRowsAboutToBeInserted(const QModelIndex &index, int first, int last);
- void onRowsInserted(const QModelIndex &index, int first, int last);
- void onRowsAboutToBeRemoved(const QModelIndex &index, int first, int last);
- void onRowsRemoved(const QModelIndex &index, int first, int last);
- void onDataChanged(const QModelIndex &first, const QModelIndex &last);
-
-private:
- struct Private;
- friend struct Private;
- Private *mPriv;
-};
-
-
-
-#endif // _TelepathyQt4Yell_Models_flat_model_proxy_h_HEADER_GUARD_
diff --git a/src/telepathyContactList.cpp b/src/telepathyContactList.cpp
index b07cfa3..2d844df 100644
--- a/src/telepathyContactList.cpp
+++ b/src/telepathyContactList.cpp
@@ -30,9 +30,8 @@
#include <TelepathyQt/AccountManager>
#include <TelepathyQt/PendingReady>
-#include "flat-model-proxy.h"
-
#include <KTp/Models/accounts-model.h>
+#include <KTp/Models/flat-model-proxy.h>
@@ -79,6 +78,11 @@ TelepathyContactList::TelepathyContactList(QObject* parent, const QVariantList&
connect(m_accountManager->becomeReady(),
SIGNAL(finished(Tp::PendingOperation*)),
SLOT(onAccountManagerReady(Tp::PendingOperation*)));
+
+ m_model = new AccountsModel(this);
+ m_proxyModel = new FlatModelProxy(m_model);
+
+
}
TelepathyContactList::~TelepathyContactList()
@@ -108,8 +112,7 @@ void TelepathyContactList::init()
// make C++ Plasma::Applet available to QML for resize signal
m_declarative->engine()->rootContext()->setContextProperty("TelepathyContactList", this);
- FlatModelProxy *proxyModel = new FlatModelProxy(m_model);
- m_declarative->engine()->rootContext()->setContextProperty("contactListModel", proxyModel);
+ m_declarative->engine()->rootContext()->setContextProperty("contactListModel", m_proxyModel);
// setup qml object so that we can talk to the declarative part
m_qmlObject = dynamic_cast<QObject*>(m_declarative->rootObject());
@@ -129,7 +132,6 @@ K_EXPORT_PLASMA_APPLET(telepathy-contact-list, TelepathyContactList)
void TelepathyContactList::onAccountManagerReady(Tp::PendingOperation *op)
{
- m_model = new AccountsModel(this);
m_model->setAccountManager(m_accountManager);
init();
}
diff --git a/src/telepathyContactList.h b/src/telepathyContactList.h
index 6054801..f2ae467 100644
--- a/src/telepathyContactList.h
+++ b/src/telepathyContactList.h
@@ -26,6 +26,7 @@
#include <TelepathyQt/Types>
class AccountsModel;
+class FlatModelProxy;
namespace Tp {
class PendingOperation;
@@ -53,7 +54,9 @@ private:
Plasma::DeclarativeWidget *m_declarative;
QObject *m_qmlObject;
Tp::AccountManagerPtr m_accountManager;
+
AccountsModel *m_model;
+ FlatModelProxy *m_proxyModel;
};
#endif // TELEPATHY_CONTACT_LIST_H
--
ktp-contact-applet packaging
More information about the pkg-kde-commits
mailing list