[SCM] libkpeople packaging branch, master, updated. eb55c3aa7149c870f3258775b05d83266112fcac
Diane Trout
diane-guest at moszumanska.debian.org
Tue May 6 18:25:27 UTC 2014
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/libkpeople.git;a=commitdiff;h=6e6a93a
The following commit has been merged in the master branch:
commit 6e6a93a4f0357369b82199e324bf1a59bbe32e20
Author: Diane Trout <diane at ghic.org>
Date: Sun Apr 27 16:39:04 2014 -0700
Imported Upstream version 0.2.2
---
CMakeLists.txt | 2 +-
po/CMakeLists.txt | 4 +-
po/da/libkpeople.po | 6 +-
po/el/CMakeLists.txt | 2 -
po/fi/CMakeLists.txt | 2 +
po/{cs => fi}/libkpeople.po | 28 +++----
po/fr/libkpeople.po | 6 +-
po/pl/CMakeLists.txt | 2 +
po/{cs => pl}/libkpeople.po | 25 ++++---
po/ro/CMakeLists.txt | 2 +
po/{el => ro}/libkpeople.po | 27 +++----
po/sl/libkpeople.po | 6 +-
src/global.h | 7 +-
src/personmanager.cpp | 29 +++++++-
src/personmanager_p.h | 3 +-
src/personsmodel.cpp | 119 ++++++++++++++++++------------
src/plugins/akonadi/akonadidatasource.cpp | 19 ++++-
src/widgets/persondetailsdialog.cpp | 2 +
src/widgets/persondetailsview.cpp | 2 +-
19 files changed, 183 insertions(+), 110 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f460475..98985d7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,7 +12,7 @@ set (KDE_MIN_VERSION "4.10.1")
set(KPEOPLE_VERSION_MAJOR 0)
set(KPEOPLE_VERSION_MINOR 2)
-set(KPEOPLE_VERSION_PATCH 1)
+set(KPEOPLE_VERSION_PATCH 2)
set(KPEOPLE_VERSION "${KPEOPLE_VERSION_MAJOR}.${KPEOPLE_VERSION_MINOR}.${KPEOPLE_VERSION_PATCH}")
set(KPEOPLE_SOVERSION 3)
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
index fa4d826..eef1efe 100644
--- a/po/CMakeLists.txt
+++ b/po/CMakeLists.txt
@@ -2,13 +2,15 @@ add_subdirectory( bs )
add_subdirectory( cs )
add_subdirectory( da )
add_subdirectory( de )
-add_subdirectory( el )
+add_subdirectory( fi )
add_subdirectory( fr )
add_subdirectory( hu )
add_subdirectory( lt )
add_subdirectory( nl )
+add_subdirectory( pl )
add_subdirectory( pt )
add_subdirectory( pt_BR )
+add_subdirectory( ro )
add_subdirectory( ru )
add_subdirectory( sk )
add_subdirectory( sl )
diff --git a/po/da/libkpeople.po b/po/da/libkpeople.po
index ae2de11..f052dd4 100644
--- a/po/da/libkpeople.po
+++ b/po/da/libkpeople.po
@@ -1,13 +1,13 @@
# Copyright (C) YEAR This_file_is_part_of_KDE
# This file is distributed under the same license as the PACKAGE package.
#
-# Martin Schlander <mschlander at opensuse.org>, 2013.
+# Martin Schlander <mschlander at opensuse.org>, 2013, 2014.
msgid ""
msgstr ""
"Project-Id-Version:
"
"Report-Msgid-Bugs-To: http://bugs.kde.org
"
"POT-Creation-Date: 2014-02-18 01:50+0000
"
-"PO-Revision-Date: 2013-09-23 19:40+0200
"
+"PO-Revision-Date: 2014-02-23 14:40+0100
"
"Last-Translator: Martin Schlander <mschlander at opensuse.org>
"
"Language-Team: Danish <kde-i18n-doc at kde.org>
"
"Language: da
"
@@ -32,7 +32,7 @@ msgstr "Vælg kontakter der skal flettes"
#. i18n: ectx: property (text), widget (QLabel, avatarPixmapLabel)
#: widgets/person-details-presentation.ui:43
msgid "Avatar"
-msgstr ""
+msgstr "Avatar"
#: widgets/plugins/emaildetailswidget.cpp:51
msgid "Email"
diff --git a/po/el/CMakeLists.txt b/po/el/CMakeLists.txt
deleted file mode 100644
index dd59b1a..0000000
--- a/po/el/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-file(GLOB _po_files *.po)
-GETTEXT_PROCESS_PO_FILES( el ALL INSTALL_DESTINATION ${LOCALE_INSTALL_DIR} ${_po_files} )
diff --git a/po/fi/CMakeLists.txt b/po/fi/CMakeLists.txt
new file mode 100644
index 0000000..f5e43fe
--- /dev/null
+++ b/po/fi/CMakeLists.txt
@@ -0,0 +1,2 @@
+file(GLOB _po_files *.po)
+GETTEXT_PROCESS_PO_FILES( fi ALL INSTALL_DESTINATION ${LOCALE_INSTALL_DIR} ${_po_files} )
diff --git a/po/cs/libkpeople.po b/po/fi/libkpeople.po
similarity index 65%
copy from po/cs/libkpeople.po
copy to po/fi/libkpeople.po
index 91da9d3..2239aa0 100644
--- a/po/cs/libkpeople.po
+++ b/po/fi/libkpeople.po
@@ -1,51 +1,51 @@
# Copyright (C) YEAR This_file_is_part_of_KDE
# This file is distributed under the same license as the PACKAGE package.
-# Vít Pelčák <vit at pelcak.org>, 2013.
+# Lasse Liehu <lasse.liehu at gmail.com>, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version:
"
"Report-Msgid-Bugs-To: http://bugs.kde.org
"
"POT-Creation-Date: 2014-02-18 01:50+0000
"
-"PO-Revision-Date: 2013-09-26 15:18+0200
"
-"Last-Translator: Vít Pelčák <vit at pelcak.org>
"
-"Language-Team: Czech <kde-i18n-doc at kde.org>
"
-"Language: cs
"
+"PO-Revision-Date: 2014-02-17 17:02+0200
"
+"Last-Translator: Lasse Liehu <lasse.liehu at gmail.com>
"
+"Language-Team: Finnish <lokalisointi at lists.coss.fi>
"
+"Language: fi
"
"MIME-Version: 1.0
"
"Content-Type: text/plain; charset=UTF-8
"
"Content-Transfer-Encoding: 8bit
"
-"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;
"
+"Plural-Forms: nplurals=2; plural=(n != 1);
"
"X-Generator: Lokalize 1.5
"
#: examples/contactlistqml.cpp:29
msgid "SweetPeople - KPeople Example"
-msgstr ""
+msgstr "SweetPeople – KPeople-esimerkki"
#: widgets/mergedialog.cpp:65
msgid "Duplicates Manager"
-msgstr ""
+msgstr "Kaksoiskappaleiden hallinta"
#: widgets/mergedialog.cpp:74
msgid "Select contacts to be merged"
-msgstr ""
+msgstr "Valitse yhdistettävät yhteystiedot"
#. i18n: ectx: property (text), widget (QLabel, avatarPixmapLabel)
#: widgets/person-details-presentation.ui:43
msgid "Avatar"
-msgstr ""
+msgstr "Avatar"
#: widgets/plugins/emaildetailswidget.cpp:51
msgid "Email"
-msgstr "E-mail"
+msgstr "Sähköposti"
#: widgets/plugins/mergecontactswidget.cpp:51
msgid "Show Merge Suggestions..."
-msgstr ""
+msgstr "Näytä yhdistämisehdotukset…"
#: widgets/plugins/mergecontactswidget.cpp:89
msgid "Merge with Selected Contacts"
-msgstr ""
+msgstr "Yhdistä valitut yhteystiedot"
#: widgets/plugins/phonedetailswidget.cpp:40
msgid "Phone"
-msgstr "Telefon"
+msgstr "Puhelin"
diff --git a/po/fr/libkpeople.po b/po/fr/libkpeople.po
index d60bf21..a17bc91 100644
--- a/po/fr/libkpeople.po
+++ b/po/fr/libkpeople.po
@@ -1,13 +1,13 @@
# Copyright (C) YEAR This_file_is_part_of_KDE
# This file is distributed under the same license as the PACKAGE package.
-# Sebastien Renard <renard at kde.org>, 2013.
+# Sebastien Renard <renard at kde.org>, 2013, 2014.
#
msgid ""
msgstr ""
"Project-Id-Version:
"
"Report-Msgid-Bugs-To: http://bugs.kde.org
"
"POT-Creation-Date: 2014-02-18 01:50+0000
"
-"PO-Revision-Date: 2013-12-01 14:55+0100
"
+"PO-Revision-Date: 2014-03-16 18:45+0100
"
"Last-Translator: Sebastien Renard <renard at kde.org>
"
"Language-Team: French <kde-francophone at kde.org>
"
"Language: fr
"
@@ -35,7 +35,7 @@ msgstr "Sélectionnez les contacts à fusionner"
#. i18n: ectx: property (text), widget (QLabel, avatarPixmapLabel)
#: widgets/person-details-presentation.ui:43
msgid "Avatar"
-msgstr ""
+msgstr "Avatar"
#: widgets/plugins/emaildetailswidget.cpp:51
msgid "Email"
diff --git a/po/pl/CMakeLists.txt b/po/pl/CMakeLists.txt
new file mode 100644
index 0000000..64107bd
--- /dev/null
+++ b/po/pl/CMakeLists.txt
@@ -0,0 +1,2 @@
+file(GLOB _po_files *.po)
+GETTEXT_PROCESS_PO_FILES( pl ALL INSTALL_DESTINATION ${LOCALE_INSTALL_DIR} ${_po_files} )
diff --git a/po/cs/libkpeople.po b/po/pl/libkpeople.po
similarity index 65%
copy from po/cs/libkpeople.po
copy to po/pl/libkpeople.po
index 91da9d3..b4aae97 100644
--- a/po/cs/libkpeople.po
+++ b/po/pl/libkpeople.po
@@ -1,38 +1,39 @@
# Copyright (C) YEAR This_file_is_part_of_KDE
# This file is distributed under the same license as the PACKAGE package.
-# Vít Pelčák <vit at pelcak.org>, 2013.
#
+# Łukasz Wojniłowicz <lukasz.wojnilowicz at gmail.com>, 2014.
msgid ""
msgstr ""
"Project-Id-Version:
"
"Report-Msgid-Bugs-To: http://bugs.kde.org
"
"POT-Creation-Date: 2014-02-18 01:50+0000
"
-"PO-Revision-Date: 2013-09-26 15:18+0200
"
-"Last-Translator: Vít Pelčák <vit at pelcak.org>
"
-"Language-Team: Czech <kde-i18n-doc at kde.org>
"
-"Language: cs
"
+"PO-Revision-Date: 2014-03-22 15:03+0100
"
+"Last-Translator: Łukasz Wojniłowicz <lukasz.wojnilowicz at gmail.com>
"
+"Language-Team: Polish <kde-i18n-doc at kde.org>
"
+"Language: pl
"
"MIME-Version: 1.0
"
"Content-Type: text/plain; charset=UTF-8
"
"Content-Transfer-Encoding: 8bit
"
-"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;
"
+"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
+"|| n%100>=20) ? 1 : 2);
"
"X-Generator: Lokalize 1.5
"
#: examples/contactlistqml.cpp:29
msgid "SweetPeople - KPeople Example"
-msgstr ""
+msgstr "SweetPeople - Przykład KPeople"
#: widgets/mergedialog.cpp:65
msgid "Duplicates Manager"
-msgstr ""
+msgstr "Zarządca powieleń"
#: widgets/mergedialog.cpp:74
msgid "Select contacts to be merged"
-msgstr ""
+msgstr "Wybierz kontakty do scalenia"
#. i18n: ectx: property (text), widget (QLabel, avatarPixmapLabel)
#: widgets/person-details-presentation.ui:43
msgid "Avatar"
-msgstr ""
+msgstr "Awatar"
#: widgets/plugins/emaildetailswidget.cpp:51
msgid "Email"
@@ -40,11 +41,11 @@ msgstr "E-mail"
#: widgets/plugins/mergecontactswidget.cpp:51
msgid "Show Merge Suggestions..."
-msgstr ""
+msgstr "Pokaż sugestie scalania..."
#: widgets/plugins/mergecontactswidget.cpp:89
msgid "Merge with Selected Contacts"
-msgstr ""
+msgstr "Scal z wybranymi kontaktami"
#: widgets/plugins/phonedetailswidget.cpp:40
msgid "Phone"
diff --git a/po/ro/CMakeLists.txt b/po/ro/CMakeLists.txt
new file mode 100644
index 0000000..8c08a20
--- /dev/null
+++ b/po/ro/CMakeLists.txt
@@ -0,0 +1,2 @@
+file(GLOB _po_files *.po)
+GETTEXT_PROCESS_PO_FILES( ro ALL INSTALL_DESTINATION ${LOCALE_INSTALL_DIR} ${_po_files} )
diff --git a/po/el/libkpeople.po b/po/ro/libkpeople.po
similarity index 62%
rename from po/el/libkpeople.po
rename to po/ro/libkpeople.po
index bb9a90a..257e1ef 100644
--- a/po/el/libkpeople.po
+++ b/po/ro/libkpeople.po
@@ -1,38 +1,39 @@
# Copyright (C) YEAR This_file_is_part_of_KDE
# This file is distributed under the same license as the PACKAGE package.
#
-# Antonis Geralis <gaantonio at civil.auth.gr>, 2014.
+# Sergiu Bivol <sergiu at ase.md>, 2014.
msgid ""
msgstr ""
"Project-Id-Version:
"
"Report-Msgid-Bugs-To: http://bugs.kde.org
"
"POT-Creation-Date: 2014-02-18 01:50+0000
"
-"PO-Revision-Date: 2014-02-04 21:37+0200
"
-"Last-Translator: Antonis Geralis <gaantonio at civil.auth.gr>
"
-"Language-Team: Greek <kde-i18n-doc at kde.org>
"
-"Language: el
"
+"PO-Revision-Date: 2014-03-25 16:18+0200
"
+"Last-Translator: Sergiu Bivol <sergiu at ase.md>
"
+"Language-Team: Romanian <kde-i18n-ro at kde.org>
"
+"Language: ro
"
"MIME-Version: 1.0
"
"Content-Type: text/plain; charset=UTF-8
"
"Content-Transfer-Encoding: 8bit
"
-"Plural-Forms: nplurals=2; plural=n != 1;
"
+"Plural-Forms: nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < "
+"20)) ? 1 : 2;
"
"X-Generator: Lokalize 1.5
"
#: examples/contactlistqml.cpp:29
msgid "SweetPeople - KPeople Example"
-msgstr "SweetPeople - Παράδειγμα KPeople"
+msgstr ""
#: widgets/mergedialog.cpp:65
msgid "Duplicates Manager"
-msgstr "Διαχειριστής διπλότυπων"
+msgstr "Gestionar de duplicate"
#: widgets/mergedialog.cpp:74
msgid "Select contacts to be merged"
-msgstr "Επιλέξτε επαφές για συγχώνευση"
+msgstr "Alegeți contactele de îmbinat"
#. i18n: ectx: property (text), widget (QLabel, avatarPixmapLabel)
#: widgets/person-details-presentation.ui:43
msgid "Avatar"
-msgstr ""
+msgstr "Avatar"
#: widgets/plugins/emaildetailswidget.cpp:51
msgid "Email"
@@ -40,12 +41,12 @@ msgstr "Email"
#: widgets/plugins/mergecontactswidget.cpp:51
msgid "Show Merge Suggestions..."
-msgstr "Εμφάνιση προτάσεων για συγχώνευση..."
+msgstr "Arată sugestii de îmbinare..."
#: widgets/plugins/mergecontactswidget.cpp:89
msgid "Merge with Selected Contacts"
-msgstr "Συγχώνευση με επιλεγμένες επαφές"
+msgstr "Îmbină cu contactele alese"
#: widgets/plugins/phonedetailswidget.cpp:40
msgid "Phone"
-msgstr "Τηλέφωνο"
+msgstr "Telefon"
diff --git a/po/sl/libkpeople.po b/po/sl/libkpeople.po
index 7c33af3..5f65c91 100644
--- a/po/sl/libkpeople.po
+++ b/po/sl/libkpeople.po
@@ -1,13 +1,13 @@
# Copyright (C) YEAR This_file_is_part_of_KDE
# This file is distributed under the same license as the PACKAGE package.
#
-# Andrej Mernik <andrejm at ubuntu.si>, 2013.
+# Andrej Mernik <andrejm at ubuntu.si>, 2013, 2014.
msgid ""
msgstr ""
"Project-Id-Version:
"
"Report-Msgid-Bugs-To: http://bugs.kde.org
"
"POT-Creation-Date: 2014-02-18 01:50+0000
"
-"PO-Revision-Date: 2013-12-02 22:15+0100
"
+"PO-Revision-Date: 2014-02-21 10:13+0100
"
"Last-Translator: Andrej Mernik <andrejm at ubuntu.si>
"
"Language-Team: Slovenian <lugos-slo at lugos.si>
"
"Language: sl
"
@@ -33,7 +33,7 @@ msgstr "Izberite stike za združevanje"
#. i18n: ectx: property (text), widget (QLabel, avatarPixmapLabel)
#: widgets/person-details-presentation.ui:43
msgid "Avatar"
-msgstr ""
+msgstr "Podoba"
#: widgets/plugins/emaildetailswidget.cpp:51
msgid "Email"
diff --git a/src/global.h b/src/global.h
index 126ca0e..a84c56d 100644
--- a/src/global.h
+++ b/src/global.h
@@ -34,11 +34,12 @@ class QAction;
namespace KPeople
{
/**
- * Merge all ids (person IDs and contactIds into a single person)
- * returns the ID that will be created.
+ * Merge all ids into a single person.
+ * Ids can be a mix of person Ids and contact IDs.
+ *
* @arg ids a list of all identifiers to be merged
*
- * @return the identifier of the new person
+ * @return the identifier of the new person or an empty string upon failure
*/
KPEOPLE_EXPORT QString mergeContacts(const QStringList &ids);
diff --git a/src/personmanager.cpp b/src/personmanager.cpp
index f71e70d..8b4f5ba 100644
--- a/src/personmanager.cpp
+++ b/src/personmanager.cpp
@@ -136,6 +136,10 @@ QString PersonManager::mergeContacts(const QStringList& ids)
QStringList metacontacts;
QStringList contacts;
+ bool rc = true;
+
+ QList<QDBusMessage> pendingMessages;
+
// separate the passed ids to metacontacts and simple contacts
Q_FOREACH (const QString &id, ids) {
if (id.startsWith(QLatin1String("kpeople://"))) {
@@ -182,32 +186,38 @@ QString PersonManager::mergeContacts(const QStringList& ids)
updateQuery.prepare("UPDATE persons SET personID = ? WHERE contactID = ?");
updateQuery.bindValue(0, personIdString.mid(strlen("kpeople://")));
updateQuery.bindValue(1, id);
- updateQuery.exec();
+ if (!updateQuery.exec()) {
+ rc = false;
+ }
QDBusMessage message = QDBusMessage::createSignal(QLatin1String("/KPeople"),
QLatin1String("org.kde.KPeople"),
QLatin1String("ContactRemovedFromPerson"));
message.setArguments(QVariantList() << id);
- QDBusConnection::sessionBus().send(message);
+ pendingMessages << message;
message = QDBusMessage::createSignal(QLatin1String("/KPeople"),
QLatin1String("org.kde.KPeople"),
QLatin1String("ContactAddedToPerson"));
message.setArguments(QVariantList() << id << personIdString);
- QDBusConnection::sessionBus().send(message);
+
}
}
// process passed contacts
if (contacts.size() > 0) {
+
+
Q_FOREACH (const QString &id, contacts) {
QSqlQuery insertQuery(m_db);
insertQuery.prepare("INSERT INTO persons VALUES (?, ?)");
insertQuery.bindValue(0, id);
insertQuery.bindValue(1, personIdString.mid(strlen("kpeople://"))); //strip kpeople://
- insertQuery.exec();
+ if (!insertQuery.exec()) {
+ rc = false;
+ }
//FUTURE OPTIMIZATION - this would be best as one signal, but arguments become complex
QDBusMessage message = QDBusMessage::createSignal(QLatin1String("/KPeople"),
@@ -215,8 +225,19 @@ QString PersonManager::mergeContacts(const QStringList& ids)
QLatin1String("ContactAddedToPerson"));
message.setArguments(QVariantList() << id << personIdString);
+ pendingMessages << message;
+ }
+ }
+
+ //if success send all messages to other clients
+ //otherwise roll back our database changes and return an empty string
+ if (rc) {
+ Q_FOREACH(const QDBusMessage &message, pendingMessages) {
QDBusConnection::sessionBus().send(message);
}
+ } else {
+ t.cancel();
+ personIdString.clear();
}
return personIdString;
diff --git a/src/personmanager_p.h b/src/personmanager_p.h
index 8a0e1f8..66d9cfb 100644
--- a/src/personmanager_p.h
+++ b/src/personmanager_p.h
@@ -74,10 +74,11 @@ public:
public Q_SLOTS:
//merge all ids (person IDs and contactIds into a single person)
//returns the ID that will be created
+ //users should KPeople::mergeContacts from global.h
QString mergeContacts(const QStringList &ids);
//unmerge a contact. Either remove a contact from a given person or remove a person
- //
+ //users should KPeople::unmergeContact from global.h
bool unmergeContact(const QString &id);
Q_SIGNALS:
diff --git a/src/personsmodel.cpp b/src/personsmodel.cpp
index 367d849..eda10cf 100644
--- a/src/personsmodel.cpp
+++ b/src/personsmodel.cpp
@@ -9,7 +9,6 @@
#include <KStandardDirs>
#include <KDebug>
-#include <QDebug>
#include <QPixmap>
#include <QTimer>
@@ -20,9 +19,10 @@ public:
QHash<QString /*contactId*/, QString /*PersonId*/> contactToPersons;
//hash of person objects indexed by ID
- QHash<QString /*Person ID*/, MetaContact> metacontacts;
+ QHash<QString /*Person ID*/, QPersistentModelIndex /*Row*/> personIndex;
+
//a list so we have an order in the model
- QStringList personIds;
+ QList<MetaContact> metacontacts;
QString genericAvatarImagePath;
QList<AllContactsMonitorPtr> m_sourceMonitors;
@@ -43,10 +43,15 @@ PersonsModel::PersonsModel(QObject *parent):
d->initialFetchesDoneCount = 0;
Q_FOREACH (BasePersonsDataSource* dataSource, PersonPluginManager::dataSourcePlugins()) {
const AllContactsMonitorPtr monitor = dataSource->allContactsMonitor();
- connect(monitor.data(), SIGNAL(initialFetchComplete()),
- this, SLOT(onMonitorInitialFetchComplete()));
+ if (monitor.data()->isInitialFetchComplete()) {
+ QTimer::singleShot(0, this, SLOT(onMonitorInitialFetchComplete()));
+ } else {
+ connect(monitor.data(), SIGNAL(initialFetchComplete()),
+ this, SLOT(onMonitorInitialFetchComplete()));
+ }
d->m_sourceMonitors << monitor;
}
+ onContactsFetched();
connect(PersonManager::instance(), SIGNAL(contactAddedToPerson(QString,QString)), SLOT(onAddContactToPerson(QString,QString)));
connect(PersonManager::instance(), SIGNAL(contactRemovedFromPerson(QString)), SLOT(onRemoveContactsFromPerson(QString)));
@@ -63,6 +68,7 @@ PersonsModel::~PersonsModel()
QVariant PersonsModel::data(const QModelIndex &index, int role) const
{
+
Q_D(const PersonsModel);
//optimization - if we don't cover this role, ignore it
@@ -78,13 +84,12 @@ QVariant PersonsModel::data(const QModelIndex &index, int role) const
if (role == ContactsVCardRole) {
return QVariant::fromValue<KABC::AddresseeList>(KABC::AddresseeList());
}
- const QString &personId = d->personIds[index.parent().row()];
- const MetaContact &mc = d->metacontacts[personId];
+ const MetaContact &mc = d->metacontacts.at(index.parent().row());
- return dataForAddressee(personId, mc.contacts().at(index.row()), role);
+ return dataForAddressee(mc.id(), mc.contacts().at(index.row()), role);
} else {
- const QString &personId = d->personIds[index.row()];
- return dataForAddressee(personId, d->metacontacts[personId].personAddressee(), role);
+ const MetaContact &mc = d->metacontacts.at(index.row());
+ return dataForAddressee(mc.id(), mc.personAddressee(), role);
}
}
@@ -108,7 +113,7 @@ QVariant PersonsModel::dataForAddressee(const QString &personId, const KABC::Add
case PersonVCardRole:
return QVariant::fromValue<KABC::Addressee>(person);
case ContactsVCardRole:
- return QVariant::fromValue<KABC::AddresseeList>(d->metacontacts[personId].contacts());
+ return QVariant::fromValue<KABC::AddresseeList>(d->metacontacts[d->personIndex[personId].row()].contacts());
case GroupsRole:
return person.categories();
}
@@ -127,11 +132,11 @@ int PersonsModel::rowCount(const QModelIndex &parent) const
Q_D(const PersonsModel);
if (!parent.isValid()) {
- return d->personIds.size();
+ return d->metacontacts.size();
}
if (parent.isValid() && !parent.parent().isValid()) {
- return d->metacontacts[d->personIds.at(parent.row())].contacts().count();
+ return d->metacontacts.at(parent.row()).contacts().count();
}
return 0;
@@ -166,8 +171,6 @@ void PersonsModel::onMonitorInitialFetchComplete()
d->initialFetchesDoneCount++;
Q_ASSERT(d->initialFetchesDoneCount <= d->m_sourceMonitors.count());
if (d->initialFetchesDoneCount == d->m_sourceMonitors.count()) {
-
- onContactsFetched();
Q_EMIT modelInitialized();
}
}
@@ -175,10 +178,10 @@ void PersonsModel::onMonitorInitialFetchComplete()
void PersonsModel::onContactsFetched()
{
Q_D(PersonsModel);
+
KABC::Addressee::Map addresseeMap;
//fetch all already loaded contacts from plugins
- KABC::AddresseeList contactList;
Q_FOREACH (const AllContactsMonitorPtr &contactWatcher, d->m_sourceMonitors) {
addresseeMap.unite(contactWatcher->contacts());
}
@@ -218,8 +221,9 @@ void PersonsModel::onContactAdded(const QString &contactId, const KABC::Addresse
const QString &personId = personIdForContact(contactId);
- if (d->personIds.contains(personId)) {
- MetaContact &mc = d->metacontacts[personId];
+ if (d->personIndex.contains(personId)) {
+ int personRow = d->personIndex[personId].row();
+ MetaContact &mc = d->metacontacts[personRow];
//if the MC object already contains this object, we want to update the row, not do an insert
if (mc.contactIds().contains(contactId)) {
@@ -227,7 +231,7 @@ void PersonsModel::onContactAdded(const QString &contactId, const KABC::Addresse
onContactChanged(contactId, contact);
} else {
int newContactPos = mc.contacts().size();
- beginInsertRows(index(d->personIds.indexOf(personId)), newContactPos, newContactPos);
+ beginInsertRows(index(personRow), newContactPos, newContactPos);
mc.insertContact(contactId, contact);
endInsertRows();
personChanged(personId);
@@ -244,11 +248,12 @@ void PersonsModel::onContactChanged(const QString &contactId, const KABC::Addres
Q_D(PersonsModel);
const QString &personId = personIdForContact(contactId);
- int row = d->metacontacts[personId].updateContact(contactId, contact);
+ int personRow = d->personIndex[personId].row();
+ int contactRow = d->metacontacts[personRow].updateContact(contactId, contact);
- const QModelIndex contactIndex = index(row,
+ const QModelIndex contactIndex = index(contactRow,
0,
- index(d->personIds.indexOf(personId)));
+ index(personRow));
Q_EMIT dataChanged(contactIndex, contactIndex);
@@ -261,10 +266,12 @@ void PersonsModel::onContactRemoved(const QString &contactId)
const QString &personId = personIdForContact(contactId);
- MetaContact &mc = d->metacontacts[personId];
- int contactPosition = d->metacontacts[personId].contactIds().indexOf(contactId);
- beginRemoveRows(index(d->personIds.indexOf(personId), 0), contactPosition, contactPosition);
- d->metacontacts[personId].removeContact(contactId);
+ int personRow = d->personIndex[personId].row();
+
+ MetaContact &mc = d->metacontacts[personRow];
+ int contactPosition = mc.contactIds().indexOf(contactId);
+ beginRemoveRows(index(personRow, 0), contactPosition, contactPosition);
+ mc.removeContact(contactId);
endRemoveRows();
//if MC object is now invalid remove the person from the list
@@ -279,26 +286,38 @@ void PersonsModel::onAddContactToPerson(const QString &contactId, const QString
Q_D(PersonsModel);
const QString oldPersonId = personIdForContact(contactId);
+
d->contactToPersons.insert(contactId, newPersonId);
+ int oldPersonRow = d->personIndex[oldPersonId].row();
+
+ if (oldPersonRow < 0) {
+ return;
+ }
+
+ MetaContact &oldMc = d->metacontacts[oldPersonRow];
+
//get contact already in the model, remove it from the previous contact
- const KABC::Addressee &contact = d->metacontacts[oldPersonId].contact(contactId);
- int contactPosition = d->metacontacts[oldPersonId].contacts().indexOf(contact);
- beginRemoveRows(index(d->personIds.indexOf(oldPersonId), 0), contactPosition, contactPosition);
- d->metacontacts[oldPersonId].removeContact(contactId);
+ int contactPosition = oldMc.contactIds().indexOf(contactId);
+ const KABC::Addressee contact = oldMc.contacts().at(contactPosition);
+
+ beginRemoveRows(index(oldPersonRow), contactPosition, contactPosition);
+ oldMc.removeContact(contactId);
endRemoveRows();
- if (!d->metacontacts[oldPersonId].isValid()) {
+ if (!oldMc.isValid()) {
removePerson(oldPersonId);
} else {
personChanged(oldPersonId);
}
//if the new person is already in the model, add the contact to it
- if (d->personIds.contains(newPersonId)) {
- int newContactPos = d->metacontacts[newPersonId].contacts().size();
- beginInsertRows(index(d->personIds.indexOf(newPersonId), 0), newContactPos, newContactPos);
- d->metacontacts[newPersonId].insertContact(contactId, contact);
+ if (d->personIndex.contains(newPersonId)) {
+ int newPersonRow = d->personIndex[newPersonId].row();
+ MetaContact &newMc = d->metacontacts[newPersonRow];
+ int newContactPos = newMc.contacts().size();
+ beginInsertRows(index(newPersonRow), newContactPos, newContactPos);
+ newMc.insertContact(contactId, contact);
endInsertRows();
personChanged(newPersonId);
} else { //if the person is not in the model, create a new person and insert it
@@ -314,12 +333,15 @@ void PersonsModel::onRemoveContactsFromPerson(const QString &contactId)
Q_D(PersonsModel);
const QString personId = personIdForContact(contactId);
- const KABC::Addressee &contact = d->metacontacts[personId].contact(contactId);
- d->metacontacts[personId].removeContact(contactId);
+ int personRow = d->personIndex[personId].row();
+ MetaContact &mc = d->metacontacts[personRow];
+
+ const KABC::Addressee &contact = mc.contact(contactId);
+ mc.removeContact(contactId);
d->contactToPersons.remove(contactId);
//if we don't want the person object anymore
- if (!d->metacontacts[personId].isValid()) {
+ if (!mc.isValid()) {
removePerson(personId);
} else {
personChanged(personId);
@@ -336,9 +358,10 @@ void PersonsModel::addPerson(const KPeople::MetaContact &mc)
const QString &id = mc.id();
- beginInsertRows(QModelIndex(), d->personIds.size(), d->personIds.size());
- d->metacontacts[id] = mc;
- d->personIds << id;
+ int row = d->metacontacts.size();
+ beginInsertRows(QModelIndex(), row, row);
+ d->metacontacts.append(mc);
+ d->personIndex[id] = index(row);
endInsertRows();
}
@@ -346,21 +369,22 @@ void PersonsModel::removePerson(const QString& id)
{
Q_D(PersonsModel);
- int row = d->personIds.indexOf(id);
- if (row < 0) { //item not found
+ QPersistentModelIndex index = d->personIndex.value(id);
+ if (!index.isValid()) { //item not found
return;
}
- beginRemoveRows(QModelIndex(), row, row);
- d->metacontacts.remove(id);
- d->personIds.removeOne(id);
+ beginRemoveRows(QModelIndex(), index.row(), index.row());
+ d->personIndex.remove(id);
+ d->metacontacts.removeAt(index.row());
endRemoveRows();
}
void PersonsModel::personChanged(const QString &personId)
{
Q_D(const PersonsModel);
- int row = d->personIds.indexOf(personId);
+
+ int row = d->personIndex[personId].row();
if (row >= 0) {
const QModelIndex personIndex = index(row);
dataChanged(personIndex, personIndex);
@@ -370,6 +394,7 @@ void PersonsModel::personChanged(const QString &personId)
QString PersonsModel::personIdForContact(const QString &contactId) const
{
Q_D(const PersonsModel);
+
//TODO optimize with constFind()
if (d->contactToPersons.contains(contactId)) {
return d->contactToPersons[contactId];
diff --git a/src/plugins/akonadi/akonadidatasource.cpp b/src/plugins/akonadi/akonadidatasource.cpp
index 2f006c9..3920e19 100644
--- a/src/plugins/akonadi/akonadidatasource.cpp
+++ b/src/plugins/akonadi/akonadidatasource.cpp
@@ -27,6 +27,7 @@
#include <Akonadi/Collection>
#include <Akonadi/CollectionFetchJob>
#include <Akonadi/CollectionFetchScope>
+#include <Akonadi/ServerManager>
#include <KABC/Addressee>
@@ -50,6 +51,7 @@ private Q_SLOTS:
void onItemAdded(const Akonadi::Item &item);
void onItemChanged(const Akonadi::Item &item);
void onItemRemoved(const Akonadi::Item &item);
+ void onServerStateChanged(Akonadi::ServerManager::State);
private:
Akonadi::Monitor *m_monitor;
KABC::Addressee::Map m_contacts;
@@ -60,6 +62,9 @@ AkonadiAllContacts::AkonadiAllContacts():
m_monitor(new Akonadi::Monitor(this)),
m_activeFetchJobsCount(0)
{
+ connect(Akonadi::ServerManager::self(), SIGNAL(stateChanged(Akonadi::ServerManager::State)), SLOT(onServerStateChanged(Akonadi::ServerManager::State)));
+ onServerStateChanged(Akonadi::ServerManager::state());
+
connect(m_monitor, SIGNAL(itemAdded(Akonadi::Item,Akonadi::Collection)), SLOT(onItemAdded(Akonadi::Item)));
connect(m_monitor, SIGNAL(itemChanged(Akonadi::Item,QSet<QByteArray>)), SLOT(onItemChanged(Akonadi::Item)));
connect(m_monitor, SIGNAL(itemRemoved(Akonadi::Item)), SLOT(onItemRemoved(Akonadi::Item)));
@@ -131,7 +136,7 @@ void AkonadiAllContacts::onItemsFetched(KJob *job)
onItemAdded(item);
}
- if (--m_activeFetchJobsCount == 0) {
+ if (--m_activeFetchJobsCount == 0 && !isInitialFetchComplete()) {
emitInitialFetchComplete();
}
}
@@ -153,11 +158,21 @@ void AkonadiAllContacts::onCollectionsFetched(KJob* job)
++m_activeFetchJobsCount;
}
}
- if (m_activeFetchJobsCount == 0) {
+ if (m_activeFetchJobsCount == 0 && !isInitialFetchComplete()) {
emitInitialFetchComplete();
+
}
}
+void AkonadiAllContacts::onServerStateChanged(ServerManager::State state)
+{
+ //if we're broken tell kpeople we've loaded so kpeople doesn't block
+ if(state == Akonadi::ServerManager::Broken && !isInitialFetchComplete()) {
+ emitInitialFetchComplete();
+ qWarning() << "Akonadi failed to load, some metacontact features may not be available";
+ qWarning() << "For more information please load akonadi_console" ;
+ }
+}
diff --git a/src/widgets/persondetailsdialog.cpp b/src/widgets/persondetailsdialog.cpp
index e9ac86c..8ca0a99 100644
--- a/src/widgets/persondetailsdialog.cpp
+++ b/src/widgets/persondetailsdialog.cpp
@@ -61,6 +61,8 @@ void PersonDetailsDialog::setPerson(PersonData *person)
{
Q_D(PersonDetailsDialog);
d->view->setPerson(person);
+
+ setWindowTitle(person->person().formattedName());
}
diff --git a/src/widgets/persondetailsview.cpp b/src/widgets/persondetailsview.cpp
index f1e7ef3..8c247db 100644
--- a/src/widgets/persondetailsview.cpp
+++ b/src/widgets/persondetailsview.cpp
@@ -88,7 +88,7 @@ QWidget* CoreFieldsPlugin::createDetailsWidget(const KABC::Addressee &person, co
{
Q_UNUSED(contacts)
//don't handle emails here - KABC::Field just lists one which is rubbish. Instead use a custom plugin that lists everything
- if (m_field->category() == KABC::Field::Email) {
+ if (m_field->category() & KABC::Field::Email) {
return 0;
}
--
libkpeople packaging
More information about the pkg-kde-commits
mailing list