[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:14:27 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-contact-list.git;a=commitdiff;h=1c14dda
The following commit has been merged in the master branch:
commit 1c14dda08a117cbbcb4365f5259e0570de052f00
Author: Siddhartha Sahu <sh.siddhartha at gmail.com>
Date: Thu Mar 20 17:03:52 2014 +0530
Use PresenceModel from K-C-I
REVIEW: 116910
---
CMakeLists.txt | 3 +-
dialogs/custom-presence-dialog.cpp | 10 +--
dialogs/custom-presence-dialog.h | 10 ++-
global-presence-chooser.cpp | 29 +++---
global-presence-chooser.h | 6 +-
presence-model.cpp | 180 -------------------------------------
presence-model.h | 77 ----------------
7 files changed, 29 insertions(+), 286 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 14eaf16..09061bf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,7 +35,7 @@ include_directories (${KDE4_INCLUDES}
)
-set (ktp_contactlist_SRCS
+set (ktp_contactlist_SRCS
contact-list-widget.cpp
context-menu.cpp
abstract-contact-delegate.cpp
@@ -53,7 +53,6 @@ set (ktp_contactlist_SRCS
global-presence-chooser.cpp
dialogs/remove-contact-dialog.cpp
dialogs/custom-presence-dialog.cpp
- presence-model.cpp
tooltips/ktooltip.cpp
tooltips/tooltipmanager.cpp
tooltips/ktooltipwindow.cpp
diff --git a/dialogs/custom-presence-dialog.cpp b/dialogs/custom-presence-dialog.cpp
index 228a57c..5e7b76e 100644
--- a/dialogs/custom-presence-dialog.cpp
+++ b/dialogs/custom-presence-dialog.cpp
@@ -20,8 +20,6 @@
#include "custom-presence-dialog.h"
-#include "presence-model.h"
-
#include <QtGui/QListView>
#include <QtGui/QHBoxLayout>
#include <QtGui/QVBoxLayout>
@@ -38,6 +36,8 @@
#include <QLineEdit>
#include <QKeyEvent>
+#include <KTp/Models/presence-model.h>
+
class FilteredModel : public QSortFilterProxyModel
{
Q_OBJECT
@@ -54,11 +54,11 @@ FilteredModel::FilteredModel(QObject *parent)
bool FilteredModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
- KTp::Presence presence = index.data(PresenceModel::PresenceRole).value<KTp::Presence>();
+ KTp::Presence presence = index.data(KTp::PresenceModel::PresenceRole).value<KTp::Presence>();
return ! presence.statusMessage().isEmpty();
}
-CustomPresenceDialog::CustomPresenceDialog(PresenceModel *model, QWidget *parent)
+CustomPresenceDialog::CustomPresenceDialog(KTp::PresenceModel *model, QWidget *parent)
: KDialog(parent),
m_model(model)
{
@@ -150,7 +150,7 @@ void CustomPresenceDialog::removeCustomPresence()
return;
}
- KTp::Presence presence = m_listView->currentIndex().data(PresenceModel::PresenceRole).value<KTp::Presence>();
+ KTp::Presence presence = m_listView->currentIndex().data(KTp::PresenceModel::PresenceRole).value<KTp::Presence>();
m_model->removePresence(presence);
if (m_listView->model()->rowCount(QModelIndex()) == 0) {
diff --git a/dialogs/custom-presence-dialog.h b/dialogs/custom-presence-dialog.h
index f48788a..4c2cca6 100644
--- a/dialogs/custom-presence-dialog.h
+++ b/dialogs/custom-presence-dialog.h
@@ -26,17 +26,19 @@
#include <KDialog>
class QPushButton;
-//Forward declrare classes
class KIcon;
class QListView;
-class PresenceModel;
+
+namespace KTp {
+ class PresenceModel;
+}
class CustomPresenceDialog : public KDialog
{
Q_OBJECT
public:
- explicit CustomPresenceDialog(PresenceModel *model, QWidget *parent = 0);
+ explicit CustomPresenceDialog(KTp::PresenceModel *model, QWidget *parent = 0);
bool eventFilter(QObject* obj, QEvent* event);
private Q_SLOTS:
@@ -59,7 +61,7 @@ private:
///Combobox to type custom presence's
KComboBox *m_statusMessage;
- PresenceModel *m_model;
+ KTp::PresenceModel *m_model;
QPushButton *m_addStatus;
QPushButton *m_removeStatus;
diff --git a/global-presence-chooser.cpp b/global-presence-chooser.cpp
index 2a4ee78..64c5966 100644
--- a/global-presence-chooser.cpp
+++ b/global-presence-chooser.cpp
@@ -20,10 +20,9 @@
#include "global-presence-chooser.h"
-#include "presence-model.h"
-
#include <KTp/global-presence.h>
#include <KTp/presence.h>
+#include <KTp/Models/presence-model.h>
#include "dialogs/custom-presence-dialog.h"
@@ -44,13 +43,13 @@
#include <QtGui/QPushButton>
#include <QMenu>
-//A sneaky class that adds an extra entry to the end of the presence model
-//called "Configure Presences"
+//A sneaky class that adds an extra entries to the end of the presence model,
+//currently "Now listening to" and "Configure Custom Presences"
class PresenceModelExtended : public QAbstractListModel
{
Q_OBJECT
public:
- PresenceModelExtended(PresenceModel *presenceModel, QObject *parent);
+ PresenceModelExtended(KTp::PresenceModel *presenceModel, QObject *parent);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
KTp::Presence temporaryPresence() const;
@@ -62,10 +61,10 @@ private slots:
void sourceRowsRemoved(const QModelIndex &index, int start, int end);
private:
KTp::Presence m_temporaryPresence;
- PresenceModel *m_model;
+ KTp::PresenceModel *m_model;
};
-PresenceModelExtended::PresenceModelExtended(PresenceModel *presenceModel, QObject *parent) :
+PresenceModelExtended::PresenceModelExtended(KTp::PresenceModel *presenceModel, QObject *parent) :
QAbstractListModel(parent),
m_model(presenceModel)
{
@@ -73,7 +72,7 @@ PresenceModelExtended::PresenceModelExtended(PresenceModel *presenceModel, QObje
connect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(sourceRowsRemoved(QModelIndex,int,int)));
}
-//return number of rows + an extra item for the "configure presences" button
+//return number of rows + the extra items added to end of list
int PresenceModelExtended::rowCount(const QModelIndex &parent) const
{
if (parent.isValid()) {
@@ -112,7 +111,7 @@ QVariant PresenceModelExtended::data(const QModelIndex &index, int role) const
return m_temporaryPresence.statusMessage();
case Qt::DecorationRole:
return m_temporaryPresence.icon();
- case PresenceModel::PresenceRole:
+ case KTp::PresenceModel::PresenceRole:
return QVariant::fromValue<KTp::Presence>(m_temporaryPresence);
}
} else {
@@ -174,7 +173,7 @@ void PresenceModelExtended::removeTemporaryPresence()
GlobalPresenceChooser::GlobalPresenceChooser(QWidget *parent) :
KComboBox(parent),
m_globalPresence(new KTp::GlobalPresence(this)),
- m_model(new PresenceModel(this)),
+ m_model(new KTp::PresenceModel(this)),
m_modelExtended(new PresenceModelExtended(m_model, this)),
m_busyOverlay(new KPixmapSequenceOverlayPainter(this)),
m_changePresenceMessageButton(new QPushButton(this))
@@ -358,7 +357,7 @@ void GlobalPresenceChooser::onUserActivatedComboChange(int index)
QLatin1String("deactivateNowPlaying"));
QDBusConnection::sessionBus().send(message);
// only set global presence on user change
- KTp::Presence presence = itemData(index, PresenceModel::PresenceRole).value<KTp::Presence>();
+ KTp::Presence presence = itemData(index, KTp::PresenceModel::PresenceRole).value<KTp::Presence>();
m_globalPresence->setPresence(presence);
}
}
@@ -367,7 +366,7 @@ void GlobalPresenceChooser::onAllComboChanges(int index)
{
int lastPresenceIndex = m_model->rowCount();
if (index < lastPresenceIndex) {
- KTp::Presence presence = itemData(index, PresenceModel::PresenceRole).value<KTp::Presence>();
+ KTp::Presence presence = itemData(index, KTp::PresenceModel::PresenceRole).value<KTp::Presence>();
if ((presence.type() == Tp::ConnectionPresenceTypeOffline) ||
(presence.type() == Tp::ConnectionPresenceTypeHidden)) {
m_changePresenceMessageButton->hide();
@@ -387,7 +386,7 @@ void GlobalPresenceChooser::onPresenceChanged(const KTp::Presence &presence)
return;
}
for (int i = 0; i < count() ; i++) {
- KTp::Presence itemPresence = itemData(i, PresenceModel::PresenceRole).value<KTp::Presence>();
+ KTp::Presence itemPresence = itemData(i, KTp::PresenceModel::PresenceRole).value<KTp::Presence>();
if (itemPresence.type() == presence.type() && itemPresence.statusMessage() == presence.statusMessage()) {
setCurrentIndex(i);
if (itemPresence != m_modelExtended->temporaryPresence()) {
@@ -446,7 +445,7 @@ void GlobalPresenceChooser::onConfirmPresenceMessageClicked()
{
m_changePresenceMessageButton->show();
- KTp::Presence presence = itemData(currentIndex(), PresenceModel::PresenceRole).value<KTp::Presence>();
+ KTp::Presence presence = itemData(currentIndex(), KTp::PresenceModel::PresenceRole).value<KTp::Presence>();
presence.setStatus(presence.type(), presence.status(), lineEdit()->text());
QModelIndex newPresence = m_model->addPresence(presence); //m_model->addPresence(presence);
setEditable(false);
@@ -458,4 +457,4 @@ void GlobalPresenceChooser::onConfirmPresenceMessageClicked()
#include "global-presence-chooser.moc"
-#include "moc_global-presence-chooser.cpp" //hack because we have two QObejcts in teh same file
+#include "moc_global-presence-chooser.cpp" //hack because we have two QObjects in the same file
diff --git a/global-presence-chooser.h b/global-presence-chooser.h
index c240682..e41ae07 100644
--- a/global-presence-chooser.h
+++ b/global-presence-chooser.h
@@ -29,11 +29,11 @@
class QMenu;
class QPushButton;
class KPixmapSequenceOverlayPainter;
-class PresenceModel;
class PresenceModelExtended;
namespace KTp {
-class GlobalPresence;
+ class GlobalPresence;
+ class PresenceModel;
}
class GlobalPresenceChooser : public KComboBox
@@ -59,7 +59,7 @@ private Q_SLOTS:
private:
KTp::GlobalPresence *m_globalPresence;
- PresenceModel *m_model;
+ KTp::PresenceModel *m_model;
PresenceModelExtended *m_modelExtended;
KPixmapSequenceOverlayPainter *m_busyOverlay;
diff --git a/presence-model.cpp b/presence-model.cpp
deleted file mode 100644
index c6ca099..0000000
--- a/presence-model.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Presence Model - A model of settable presences.
- *
- * Copyright (C) 2011 David Edmundson <kde at davidedmundson.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 "presence-model.h"
-
-#include <QtGui/QFont>
-#include <QtDBus/QtDBus>
-
-#include <KDE/KIcon>
-#include <KDE/KLocalizedString>
-
-#include <KDE/KConfig>
-#include <KDE/KConfigGroup>
-#include <KDE/KGlobalSettings>
-#include <KDE/KDebug>
-
-
-PresenceModel::PresenceModel(QObject *parent) :
- QAbstractListModel(parent)
-{
- KSharedConfigPtr config = KSharedConfig::openConfig("ktelepathyrc");
- m_presenceGroup = config->group("Custom Presence List");
-
- loadDefaultPresences();
- loadCustomPresences();
-}
-
-PresenceModel::~PresenceModel()
-{
- syncCustomPresencesToDisk();
-}
-
-void PresenceModel::syncCustomPresencesToDisk()
-{
- m_presenceGroup.deleteGroup();
-
- Q_FOREACH(const KTp::Presence &presence, m_presences) {
- if (!presence.statusMessage().isEmpty()) {
- QVariantList presenceVariant;
- presenceVariant.append(presence.type());
- presenceVariant.append(presence.statusMessage());
- QString id = QString::number(presence.type()).append(presence.statusMessage());
- m_presenceGroup.writeEntry(id, presenceVariant);
- }
- }
- m_presenceGroup.sync();
-}
-
-QVariant PresenceModel::data(const QModelIndex &index, int role) const
-{
- if (!index.isValid()) {
- kDebug() << "invalid index data requested" << index;
- return QVariant();
- }
-
- KTp::Presence presence = m_presences[index.row()];
- switch (role) {
- case Qt::DisplayRole:
- if (presence.statusMessage().isEmpty()) {
- return presence.displayString();
- } else {
- return presence.statusMessage();
- }
-
- case Qt::DecorationRole:
- return presence.icon();
-
- case Qt::FontRole:
- if (presence.statusMessage().isEmpty()) {
- QFont font = KGlobalSettings::generalFont();
- font.setBold(true);
- return font;
- }
- else {
- return QVariant();
- }
-
- case PresenceModel::PresenceRole:
- return QVariant::fromValue<KTp::Presence>(presence);
-
- }
-
- return QVariant();
-}
-
-int PresenceModel::rowCount(const QModelIndex &parent) const
-{
- Q_UNUSED(parent)
- return m_presences.size();
-}
-
-void PresenceModel::loadDefaultPresences()
-{
- addPresence(Tp::Presence::available());
- addPresence(Tp::Presence::busy());
- addPresence(Tp::Presence::away());
- addPresence(Tp::Presence::xa());
- addPresence(Tp::Presence::hidden());
- addPresence(Tp::Presence::offline());
-}
-
-
-void PresenceModel::loadCustomPresences()
-{
- Q_FOREACH(const QString &key, m_presenceGroup.keyList()) {
- QVariantList entry = m_presenceGroup.readEntry(key, QVariantList());
-
- QString statusMessage = entry.last().toString();
-
- switch (entry.first().toInt()) {
- case Tp::ConnectionPresenceTypeAvailable:
- addPresence(Tp::Presence::available(statusMessage));
- break;
- case Tp::ConnectionPresenceTypeAway:
- addPresence(Tp::Presence::away(statusMessage));
- break;
- case Tp::ConnectionPresenceTypeBusy:
- addPresence(Tp::Presence::busy(statusMessage));
- break;
- case Tp::ConnectionPresenceTypeExtendedAway:
- addPresence(Tp::Presence::xa(statusMessage));
- }
- }
-}
-
-QModelIndex PresenceModel::addPresence(const KTp::Presence &presence)
-{
- if(m_presences.contains(presence)) {
- return createIndex(m_presences.indexOf(presence),0);
- }
-
- QList<KTp::Presence>::iterator i = qLowerBound(m_presences.begin(), m_presences.end(), KTp::Presence(presence));
- m_presences.insert(i, presence);
-
- int index = m_presences.indexOf(presence);
- //this is technically a backwards and wrong, but I can't get a row from a const iterator, and using qLowerBound does seem a good approach
- beginInsertRows(QModelIndex(), index, index);
- endInsertRows();
- return createIndex(index, 0);
-}
-
-void PresenceModel::removePresence(const KTp::Presence &presence)
-{
- int row = m_presences.indexOf(presence);
- beginRemoveRows(QModelIndex(), row, row);
- m_presences.removeOne(presence);
- endRemoveRows();
- QString id = QString::number(presence.type()).append(presence.statusMessage());
-}
-
-int PresenceModel::updatePresenceApplet()
-{
- if (!QDBusConnection::sessionBus().isConnected()) {
- return 1;
- }
-
- QDBusInterface callApplet("org.kde.Telepathy.PresenceAppletActive", "/", "", QDBusConnection::sessionBus());
- if (callApplet.isValid()) {
- callApplet.asyncCall("handleCustomPresenceChange");
- return 0;
- }
- return 1;
-}
diff --git a/presence-model.h b/presence-model.h
deleted file mode 100644
index d85e63d..0000000
--- a/presence-model.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Presence Model - A model of settable presences.
- *
- * Copyright (C) 2011 David Edmundson <kde at davidedmundson.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 PRESENCEMODEL_H
-#define PRESENCEMODEL_H
-
-#include <KTp/presence.h>
-
-#include <QAbstractListModel>
-
-#include <KConfigGroup>
-
-class PresenceModel : public QAbstractListModel
-{
- Q_OBJECT
-
-public:
- explicit PresenceModel(QObject *parent = 0);
- ~PresenceModel();
-
- enum Roles {
- //Also supplies Qt::DisplayRole and Qt::DecorationRole
- PresenceRole = Qt::UserRole
- };
-
- /** Adds a custom presence to the model, and write value to config file.
- @return the newly added item
- */
- QModelIndex addPresence(const KTp::Presence &presence);
-
- void removePresence(const KTp::Presence &presence);
-
- //updates context menu of presence applet
- void syncCustomPresencesToDisk();
-
- //updates context menu of presence applet
- int updatePresenceApplet();
-
- /** Returns the index of a given presence, adding it if needed*/
- QModelIndex indexOf(const KTp::Presence &presence);
-
- //protected:
- virtual QVariant data(const QModelIndex &index, int role) const;
- virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
-
-private:
-
- /** Loads standard presences (online, away etc) into */
- void loadDefaultPresences();
-
- /** Loads any user custom presences into the model*/
- void loadCustomPresences();
-
- QList<KTp::Presence> m_presences;
-
- //this is wrong, KConfigGroup is a sharedptr..
- KConfigGroup m_presenceGroup;
-};
-
-#endif // PRESENCEMODEL_H
--
ktp-contact-list packaging
More information about the pkg-kde-commits
mailing list