Commit d23b122a authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

run git clang-format

parent c8e1e313
......@@ -3,17 +3,17 @@
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "qtest.h"
#include "identitytest.h"
#include "identitymanager.h"
#include "identity.h"
#include "identitymanager.h"
#include "qtest.h"
#include <KConfig>
#include <KConfigGroup>
#include <QDataStream>
#include <QMimeData>
#include <QStandardPaths>
#include <QDataStream>
using namespace KIdentityManagement;
......@@ -31,7 +31,7 @@ bool IdentityTester::compareIdentities(const Identity &actual, const Identity &e
QCOMPARE(actual.uoid(), expected.uoid());
// Don't compare isDefault - only one copy can be default, so this property
// is not copied! It does not affect result of operator==() either.
//QCOMPARE(actual.isDefault(), expected.isDefault());
// QCOMPARE(actual.isDefault(), expected.isDefault());
QCOMPARE(actual.identityName(), expected.identityName());
QCOMPARE(actual.fullName(), expected.fullName());
QCOMPARE(actual.organization(), expected.organization());
......@@ -62,7 +62,7 @@ bool IdentityTester::compareIdentities(const Identity &actual, const Identity &e
QCOMPARE(actual.isXFaceEnabled(), expected.isXFaceEnabled());
QCOMPARE(actual.xface(), expected.xface());
ok = true;
} ();
}();
return ok;
}
......@@ -91,7 +91,7 @@ void IdentityTester::test_Identity()
identity.setPreferredCryptoMessageFormat(QStringLiteral("PGP"));
QCOMPARE(identity.preferredCryptoMessageFormat(), QStringLiteral("PGP"));
identity.setPrimaryEmailAddress(QStringLiteral("dvratil@kde.org"));
const QStringList aliases = { QStringLiteral("dvratil1@kde.org"), QStringLiteral("example@example.org") };
const QStringList aliases = {QStringLiteral("dvratil1@kde.org"), QStringLiteral("example@example.org")};
identity.setEmailAliases(aliases);
QCOMPARE(identity.emailAliases(), aliases);
QVERIFY(identity.matchesEmailAddress(QStringLiteral("dvratil@kde.org")));
......@@ -99,10 +99,11 @@ void IdentityTester::test_Identity()
QVERIFY(identity.matchesEmailAddress(aliases[1]));
QCOMPARE(identity.primaryEmailAddress(), QStringLiteral("dvratil@kde.org"));
const auto vcardFile = QStringLiteral("BEGIN:VCARD\n"
"VERSION:2.1\n"
"N:Vrátil;Daniel;;\n"
"END:VCARD");
const auto vcardFile = QStringLiteral(
"BEGIN:VCARD\n"
"VERSION:2.1\n"
"N:Vrátil;Daniel;;\n"
"END:VCARD");
identity.setVCardFile(vcardFile);
QCOMPARE(identity.vCardFile(), vcardFile);
identity.setReplyToAddr(QStringLiteral("dvratil+reply@kde.org"));
......
......@@ -9,7 +9,8 @@
#include <QObject>
namespace KIdentityManagement {
namespace KIdentityManagement
{
class Identity;
}
......
......@@ -8,17 +8,17 @@
#undef QT_USE_FAST_CONCATENATION
#undef QT_USE_FAST_OPERATOR_PLUS
#include "qtest.h"
#include "signaturetest.h"
#include "qtest.h"
#include "signature.h"
#include <KConfigGroup>
#include <QStandardPaths>
#include <KConfig>
#include <QDir>
#include <KActionCollection>
#include <KConfig>
#include <KConfigGroup>
#include <KShell>
#include <QDir>
#include <QStandardPaths>
#include <kpimtextedit/richtextcomposer.h>
#include <kpimtextedit/richtextcomposercontroler.h>
......@@ -117,8 +117,7 @@ void SignatureTester::testTextEditInsertion()
// lines are inserted before the signature
edit.setPlainText(QStringLiteral("Bla Bla"));
sig.insertIntoTextEdit(Signature::Start, Signature::AddSeparator | Signature::AddNewLines,
&edit);
sig.insertIntoTextEdit(Signature::Start, Signature::AddSeparator | Signature::AddNewLines, &edit);
QVERIFY(edit.textMode() == KPIMTextEdit::RichTextComposer::Plain);
QCOMPARE(edit.toPlainText(), QStringLiteral("\n\n-- \nHello World\nBla Bla"));
......@@ -126,8 +125,7 @@ void SignatureTester::testTextEditInsertion()
edit.clear();
edit.setPlainText(QStringLiteral("Bla Bla"));
setCursorPos(edit, 4);
sig.insertIntoTextEdit(Signature::End, Signature::AddSeparator | Signature::AddNewLines,
&edit);
sig.insertIntoTextEdit(Signature::End, Signature::AddSeparator | Signature::AddNewLines, &edit);
QCOMPARE(edit.toPlainText(), QStringLiteral("Bla Bla\n-- \nHello World"));
QCOMPARE(edit.textCursor().position(), 4);
......@@ -137,8 +135,7 @@ void SignatureTester::testTextEditInsertion()
edit.setPlainText(QStringLiteral("Bla Bla"));
setCursorPos(edit, 4);
edit.document()->setModified(false);
sig.insertIntoTextEdit(Signature::AtCursor, Signature::AddSeparator | Signature::AddNewLines,
&edit);
sig.insertIntoTextEdit(Signature::AtCursor, Signature::AddSeparator | Signature::AddNewLines, &edit);
QCOMPARE(edit.toPlainText(), QStringLiteral("-- \nHello World\nBla Bla"));
QCOMPARE(edit.textCursor().position(), 20);
QVERIFY(!edit.document()->isModified());
......@@ -164,8 +161,7 @@ void SignatureTester::testTextEditInsertion()
// test that html signatures turn html on and have correct line endings (<br> vs \n)
edit.clear();
edit.setPlainText(QStringLiteral("Bla Bla"));
sig.insertIntoTextEdit(Signature::End, Signature::AddSeparator | Signature::AddNewLines,
&edit);
sig.insertIntoTextEdit(Signature::End, Signature::AddSeparator | Signature::AddNewLines, &edit);
QVERIFY(edit.textMode() == KPIMTextEdit::RichTextComposer::Rich);
QCOMPARE(edit.toPlainText(), QStringLiteral("Bla Bla\n-- \nHello\nWorld"));
}
......@@ -193,8 +189,8 @@ void SignatureTester::testBug167961()
class MySignature : public Signature
{
public:
using Signature::writeConfig;
using Signature::readConfig;
using Signature::writeConfig;
};
void SignatureTester::testImages()
......@@ -252,8 +248,7 @@ void SignatureTester::testImages()
// read the images, and it does not mess up
MySignature sig2;
sig2.readConfig(group1);
sig2.insertIntoTextEdit(KIdentityManagement::Signature::End, Signature::AddSeparator | Signature::AddNewLines,
&edit);
sig2.insertIntoTextEdit(KIdentityManagement::Signature::End, Signature::AddSeparator | Signature::AddNewLines, &edit);
QCOMPARE(edit.composerControler()->composerImages()->embeddedImages().count(), 2);
QCOMPARE(sig2.text(), QStringLiteral("Bla<img src=\"folder-new.png\">Bla<img src=\"arrow-up.png\">Bla"));
sig2.writeConfig(group1);
......@@ -266,8 +261,7 @@ void SignatureTester::testImages()
sig2.setText(QStringLiteral("<img src=\"folder-new.png\">"));
sig2.writeConfig(group1);
edit.clear();
sig2.insertIntoTextEdit(Signature::End, Signature::AddSeparator | Signature::AddNewLines,
&edit);
sig2.insertIntoTextEdit(Signature::End, Signature::AddSeparator | Signature::AddNewLines, &edit);
QCOMPARE(edit.composerControler()->composerImages()->embeddedImages().size(), 1);
entryList = dir.entryList(QDir::Files | QDir::NoDotAndDotDot | QDir::NoSymLinks);
QCOMPARE(entryList.count(), 1);
......
......@@ -11,9 +11,9 @@
#include <KConfigGroup>
#include <KEmailAddress>
#include <QMimeData>
#include <QByteArray>
#include <QHostInfo>
#include <QMimeData>
using namespace KIdentityManagement;
......@@ -34,7 +34,7 @@ Identity::Identity(const QString &id, const QString &fullName, const QString &em
setProperty(QLatin1String(s_organization), organization);
setProperty(QLatin1String(s_replyto), replyToAddr);
// FIXME KF5: Sonnet::defaultLanguageName is gone
//setDictionary( Sonnet::defaultLanguageName() );
// setDictionary( Sonnet::defaultLanguageName() );
setProperty(QLatin1String(s_disabledFcc), false);
setProperty(QLatin1String(s_defaultDomainName), QHostInfo::localHostName());
}
......@@ -70,8 +70,7 @@ bool Identity::isNull() const
}
// The uoid is 0 by default, so ignore this
if (!(key == QLatin1String(s_uoid) && i.value().toUInt() == 0)) {
if (!i.value().isNull()
|| (i.value().type() == QVariant::String && !i.value().toString().isEmpty())) {
if (!i.value().isNull() || (i.value().type() == QVariant::String && !i.value().toString().isEmpty())) {
empty = false;
}
}
......@@ -153,76 +152,34 @@ Identity Identity::fromMimeData(const QMimeData *md)
// ------------------ Operators --------------------------//
QDataStream &KIdentityManagement::operator<<
(QDataStream &stream, const KIdentityManagement::Identity &i)
{
return stream << static_cast<quint32>(i.uoid())
<< i.mPropertiesMap[QLatin1String(s_identity)]
<< i.mPropertiesMap[QLatin1String(s_name)]
<< i.mPropertiesMap[QLatin1String(s_organization)]
<< i.mPropertiesMap[QLatin1String(s_pgps)]
<< i.mPropertiesMap[QLatin1String(s_pgpe)]
<< i.mPropertiesMap[QLatin1String(s_smimes)]
<< i.mPropertiesMap[QLatin1String(s_smimee)]
<< i.mPropertiesMap[QLatin1String(s_primaryEmail)]
<< i.mPropertiesMap[QLatin1String(s_emailAliases)]
<< i.mPropertiesMap[QLatin1String(s_replyto)]
<< i.mPropertiesMap[QLatin1String(s_bcc)]
<< i.mPropertiesMap[QLatin1String(s_vcard)]
<< i.mPropertiesMap[QLatin1String(s_transport)]
<< i.mPropertiesMap[QLatin1String(s_fcc)]
<< i.mPropertiesMap[QLatin1String(s_drafts)]
<< i.mPropertiesMap[QLatin1String(s_templates)]
<< i.mSignature
<< i.mPropertiesMap[QLatin1String(s_dict)]
<< i.mPropertiesMap[QLatin1String(s_xface)]
<< i.mPropertiesMap[QLatin1String(s_xfaceenabled)]
<< i.mPropertiesMap[QLatin1String(s_prefcrypt)]
<< i.mPropertiesMap[QLatin1String(s_cc)]
<< i.mPropertiesMap[QLatin1String(s_attachVcard)]
<< i.mPropertiesMap[QLatin1String(s_autocorrectionLanguage)]
<< i.mPropertiesMap[QLatin1String(s_disabledFcc)]
<< i.mPropertiesMap[QLatin1String(s_pgpautosign)]
<< i.mPropertiesMap[QLatin1String(s_pgpautoencrypt)]
<< i.mPropertiesMap[QLatin1String(s_autocryptEnabled)]
<< i.mPropertiesMap[QLatin1String(s_defaultDomainName)];
}
QDataStream &KIdentityManagement::operator>>
(QDataStream &stream, KIdentityManagement::Identity &i)
QDataStream &KIdentityManagement::operator<<(QDataStream &stream, const KIdentityManagement::Identity &i)
{
return stream << static_cast<quint32>(i.uoid()) << i.mPropertiesMap[QLatin1String(s_identity)] << i.mPropertiesMap[QLatin1String(s_name)]
<< i.mPropertiesMap[QLatin1String(s_organization)] << i.mPropertiesMap[QLatin1String(s_pgps)] << i.mPropertiesMap[QLatin1String(s_pgpe)]
<< i.mPropertiesMap[QLatin1String(s_smimes)] << i.mPropertiesMap[QLatin1String(s_smimee)] << i.mPropertiesMap[QLatin1String(s_primaryEmail)]
<< i.mPropertiesMap[QLatin1String(s_emailAliases)] << i.mPropertiesMap[QLatin1String(s_replyto)] << i.mPropertiesMap[QLatin1String(s_bcc)]
<< i.mPropertiesMap[QLatin1String(s_vcard)] << i.mPropertiesMap[QLatin1String(s_transport)] << i.mPropertiesMap[QLatin1String(s_fcc)]
<< i.mPropertiesMap[QLatin1String(s_drafts)] << i.mPropertiesMap[QLatin1String(s_templates)] << i.mSignature
<< i.mPropertiesMap[QLatin1String(s_dict)] << i.mPropertiesMap[QLatin1String(s_xface)] << i.mPropertiesMap[QLatin1String(s_xfaceenabled)]
<< i.mPropertiesMap[QLatin1String(s_prefcrypt)] << i.mPropertiesMap[QLatin1String(s_cc)] << i.mPropertiesMap[QLatin1String(s_attachVcard)]
<< i.mPropertiesMap[QLatin1String(s_autocorrectionLanguage)] << i.mPropertiesMap[QLatin1String(s_disabledFcc)]
<< i.mPropertiesMap[QLatin1String(s_pgpautosign)] << i.mPropertiesMap[QLatin1String(s_pgpautoencrypt)]
<< i.mPropertiesMap[QLatin1String(s_autocryptEnabled)] << i.mPropertiesMap[QLatin1String(s_defaultDomainName)];
}
QDataStream &KIdentityManagement::operator>>(QDataStream &stream, KIdentityManagement::Identity &i)
{
quint32 uoid;
stream
>> uoid
>> i.mPropertiesMap[QLatin1String(s_identity)]
>> i.mPropertiesMap[QLatin1String(s_name)]
>> i.mPropertiesMap[QLatin1String(s_organization)]
>> i.mPropertiesMap[QLatin1String(s_pgps)]
>> i.mPropertiesMap[QLatin1String(s_pgpe)]
>> i.mPropertiesMap[QLatin1String(s_smimes)]
>> i.mPropertiesMap[QLatin1String(s_smimee)]
>> i.mPropertiesMap[QLatin1String(s_primaryEmail)]
>> i.mPropertiesMap[QLatin1String(s_emailAliases)]
>> i.mPropertiesMap[QLatin1String(s_replyto)]
>> i.mPropertiesMap[QLatin1String(s_bcc)]
>> i.mPropertiesMap[QLatin1String(s_vcard)]
>> i.mPropertiesMap[QLatin1String(s_transport)]
>> i.mPropertiesMap[QLatin1String(s_fcc)]
>> i.mPropertiesMap[QLatin1String(s_drafts)]
>> i.mPropertiesMap[QLatin1String(s_templates)]
>> i.mSignature
>> i.mPropertiesMap[QLatin1String(s_dict)]
>> i.mPropertiesMap[QLatin1String(s_xface)]
>> i.mPropertiesMap[QLatin1String(s_xfaceenabled)]
>> i.mPropertiesMap[QLatin1String(s_prefcrypt)]
>> i.mPropertiesMap[QLatin1String(s_cc)]
>> i.mPropertiesMap[QLatin1String(s_attachVcard)]
>> i.mPropertiesMap[QLatin1String(s_autocorrectionLanguage)]
>> i.mPropertiesMap[QLatin1String(s_disabledFcc)]
>> i.mPropertiesMap[QLatin1String(s_pgpautosign)]
>> i.mPropertiesMap[QLatin1String(s_pgpautoencrypt)]
>> i.mPropertiesMap[QLatin1String(s_autocryptEnabled)]
>> i.mPropertiesMap[QLatin1String(s_defaultDomainName)];
stream >> uoid >> i.mPropertiesMap[QLatin1String(s_identity)] >> i.mPropertiesMap[QLatin1String(s_name)] >> i.mPropertiesMap[QLatin1String(s_organization)]
>> i.mPropertiesMap[QLatin1String(s_pgps)] >> i.mPropertiesMap[QLatin1String(s_pgpe)] >> i.mPropertiesMap[QLatin1String(s_smimes)]
>> i.mPropertiesMap[QLatin1String(s_smimee)] >> i.mPropertiesMap[QLatin1String(s_primaryEmail)] >> i.mPropertiesMap[QLatin1String(s_emailAliases)]
>> i.mPropertiesMap[QLatin1String(s_replyto)] >> i.mPropertiesMap[QLatin1String(s_bcc)] >> i.mPropertiesMap[QLatin1String(s_vcard)]
>> i.mPropertiesMap[QLatin1String(s_transport)] >> i.mPropertiesMap[QLatin1String(s_fcc)] >> i.mPropertiesMap[QLatin1String(s_drafts)]
>> i.mPropertiesMap[QLatin1String(s_templates)] >> i.mSignature >> i.mPropertiesMap[QLatin1String(s_dict)] >> i.mPropertiesMap[QLatin1String(s_xface)]
>> i.mPropertiesMap[QLatin1String(s_xfaceenabled)] >> i.mPropertiesMap[QLatin1String(s_prefcrypt)] >> i.mPropertiesMap[QLatin1String(s_cc)]
>> i.mPropertiesMap[QLatin1String(s_attachVcard)] >> i.mPropertiesMap[QLatin1String(s_autocorrectionLanguage)]
>> i.mPropertiesMap[QLatin1String(s_disabledFcc)] >> i.mPropertiesMap[QLatin1String(s_pgpautosign)] >> i.mPropertiesMap[QLatin1String(s_pgpautoencrypt)]
>> i.mPropertiesMap[QLatin1String(s_autocryptEnabled)] >> i.mPropertiesMap[QLatin1String(s_defaultDomainName)];
i.setProperty(QLatin1String(s_uoid), uoid);
return stream;
......@@ -267,10 +224,7 @@ bool Identity::operator==(const Identity &other) const
// regular mPropertiesMap == other.mPropertiesMap comparison will fail.
// This algo considers both maps equal even if one map does not contain the
// key and the other one contains the key but with an invalid value
for (const auto &pair : {
qMakePair(mPropertiesMap, other.mPropertiesMap),
qMakePair(other.mPropertiesMap, mPropertiesMap)
}) {
for (const auto &pair : {qMakePair(mPropertiesMap, other.mPropertiesMap), qMakePair(other.mPropertiesMap, mPropertiesMap)}) {
const auto lhs = pair.first;
const auto rhs = pair.second;
for (auto lhsIt = lhs.constBegin(), lhsEnd = lhs.constEnd(); lhsIt != lhsEnd; ++lhsIt) {
......@@ -524,8 +478,7 @@ void Identity::setProperty(const QString &key, const QVariant &value)
if (key == QLatin1String(s_signature)) {
mSignature = value.value<Signature>();
} else {
if (value.isNull()
|| (value.type() == QVariant::String && value.toString().isEmpty())) {
if (value.isNull() || (value.type() == QVariant::String && value.toString().isEmpty())) {
mPropertiesMap.remove(key);
} else {
mPropertiesMap.insert(key, value);
......
......@@ -12,13 +12,14 @@
#include "kidentitymanagement_export.h"
#include "signature.h"
#include <QHash>
#include <QString>
#include <QStringList>
#include <QVector>
#include <QHash>
#include <QVariant>
#include <QVector>
namespace KIdentityManagement {
namespace KIdentityManagement
{
class Identity;
class Signature;
}
......@@ -26,7 +27,8 @@ class KConfigGroup;
class QDataStream;
class QMimeData;
namespace KIdentityManagement {
namespace KIdentityManagement
{
static const char s_uoid[] = "uoid";
static const char s_identity[] = "Identity";
static const char s_name[] = "Name";
......@@ -76,7 +78,11 @@ public:
typedef QVector<Identity> List;
/** Constructor */
explicit Identity(const QString &id = QString(), const QString &realName = QString(), const QString &emailAddr = QString(), const QString &organization = QString(), const QString &replyToAddress = QString());
explicit Identity(const QString &id = QString(),
const QString &realName = QString(),
const QString &emailAddr = QString(),
const QString &organization = QString(),
const QString &replyToAddress = QString());
/** used for comparison */
bool operator==(const Identity &other) const;
......@@ -274,7 +280,7 @@ public:
*
* Note that this is the localized language name (e.g. "British English"),
* _not_ the language code or dictionary name!
*/
*/
Q_REQUIRED_RESULT QString dictionary() const;
void setDictionary(const QString &);
......
......@@ -115,7 +115,7 @@ void IdentityCombo::setCurrentIdentity(const QString &name)
return;
}
blockSignals(true); // just in case Qt gets fixed to emit activated() here
blockSignals(true); // just in case Qt gets fixed to emit activated() here
setCurrentIndex(idx);
blockSignals(false);
......@@ -136,7 +136,7 @@ void IdentityCombo::setCurrentIdentity(uint uoid)
return;
}
blockSignals(true); // just in case Qt gets fixed to emit activated() here
blockSignals(true); // just in case Qt gets fixed to emit activated() here
setCurrentIndex(idx);
blockSignals(false);
......
......@@ -20,7 +20,8 @@
#include "kidentitymanagement_export.h"
#include <QComboBox>
namespace KIdentityManagement {
namespace KIdentityManagement
{
class IdentityComboPrivate;
class IdentityManager;
class Identity;
......
......@@ -12,17 +12,17 @@ static const char configKeyDefaultIdentity[] = "Default Identity";
#include <KEmailAddress> // for static helper functions
#include <KEMailSettings> // for IdentityEntry::fromControlCenter()
#include <KLocalizedString>
#include "kidentitymanagement_debug.h"
#include <KConfig>
#include <KEMailSettings> // for IdentityEntry::fromControlCenter()
#include <KLocalizedString>
#include <KSharedConfig>
#include <kuser.h>
#include <Kdelibs4ConfigMigrator>
#include <kuser.h>
#include <QList>
#include <QHostInfo>
#include <QDBusConnection>
#include <QHostInfo>
#include <QList>
#include <QRandomGenerator>
#include <QRegularExpression>
......@@ -30,7 +30,8 @@ static const char configKeyDefaultIdentity[] = "Default Identity";
#include "identitymanageradaptor.h"
namespace KIdentityManagement {
namespace KIdentityManagement
{
static QString newDBusObjectName()
{
static int s_count = 0;
......@@ -78,14 +79,12 @@ void IdentityManager::Private::writeConfig() const
{
const QStringList identities = groupList(mConfig);
QStringList::const_iterator groupEnd = identities.constEnd();
for (QStringList::const_iterator group = identities.constBegin();
group != groupEnd; ++group) {
for (QStringList::const_iterator group = identities.constBegin(); group != groupEnd; ++group) {
mConfig->deleteGroup(*group);
}
int i = 0;
ConstIterator end = mIdentities.constEnd();
for (ConstIterator it = mIdentities.constBegin();
it != end; ++it, ++i) {
for (ConstIterator it = mIdentities.constBegin(); it != end; ++it, ++i) {
KConfigGroup cg(mConfig, QStringLiteral("Identity #%1").arg(i));
(*it).writeConfig(cg);
if ((*it).isDefault()) {
......@@ -117,12 +116,11 @@ void IdentityManager::Private::readConfig(KConfig *config)
uint defaultIdentity = general.readEntry(configKeyDefaultIdentity, 0);
bool haveDefault = false;
QStringList::const_iterator groupEnd = identities.constEnd();
for (QStringList::const_iterator group = identities.constBegin();
group != groupEnd; ++group) {
for (QStringList::const_iterator group = identities.constBegin(); group != groupEnd; ++group) {
KConfigGroup configGroup(config, *group);
Identity identity;
identity.readConfig(configGroup);
//Don't load invalid identity
// Don't load invalid identity
if (!identity.isNull() && !identity.primaryEmailAddress().isEmpty()) {
if (!haveDefault && identity.uoid() == defaultIdentity) {
haveDefault = true;
......@@ -160,8 +158,7 @@ void IdentityManager::Private::createDefaultIdentity()
emailAddress = emailSettings.getSetting(KEMailSettings::EmailAddress);
if (!fullName.isEmpty() && !emailAddress.isEmpty()) {
q->newFromControlCenter(i18nc("use default address from control center",
"Default"));
q->newFromControlCenter(i18nc("use default address from control center", "Default"));
done = true;
} else {
// If KEmailSettings doesn't have name and address, generate something from KUser
......@@ -212,7 +209,7 @@ void IdentityManager::Private::createDefaultIdentity()
shadowIdentities.last().setIsDefault(true);
shadowIdentities.last().setUoid(newUoid());
if (mReadOnly) { // commit won't do it in readonly mode
if (mReadOnly) { // commit won't do it in readonly mode
mIdentities = shadowIdentities;
}
}
......@@ -230,8 +227,7 @@ int IdentityManager::Private::newUoid()
QList<uint> usedUOIDs;
usedUOIDs.reserve(1 + mIdentities.count() + (q->hasPendingChanges() ? shadowIdentities.count() : 0));
const QVector<Identity>::ConstIterator end(mIdentities.constEnd());
for (QVector<Identity>::ConstIterator it = mIdentities.constBegin();
it != end; ++it) {
for (QVector<Identity>::ConstIterator it = mIdentities.constBegin(); it != end; ++it) {
usedUOIDs << (*it).uoid();
}
......@@ -239,8 +235,7 @@ int IdentityManager::Private::newUoid()
// add UOIDs of all shadow identities. Yes, we will add a lot of duplicate
// UOIDs, but avoiding duplicate UOIDs isn't worth the effort.
const QVector<Identity>::ConstIterator endShadow(shadowIdentities.constEnd());
for (QVector<Identity>::ConstIterator it = shadowIdentities.constBegin();
it != endShadow; ++it) {
for (QVector<Identity>::ConstIterator it = shadowIdentities.constBegin(); it != endShadow; ++it) {
usedUOIDs << (*it).uoid();
}
}
......@@ -258,8 +253,7 @@ int IdentityManager::Private::newUoid()
void IdentityManager::Private::slotIdentitiesChanged(const QString &id)
{
qCDebug(KIDENTITYMANAGEMENT_LOG) << " KIdentityManagement::IdentityManager::slotIdentitiesChanged :" << id;
const QString ourIdentifier = QStringLiteral("%1/%2").
arg(QDBusConnection::sessionBus().baseService(), q->property("uniqueDBusPath").toString());
const QString ourIdentifier = QStringLiteral("%1/%2").arg(QDBusConnection::sessionBus().baseService(), q->property("uniqueDBusPath").toString());
if (id != ourIdentifier) {
mConfig->reparseConfiguration();
Q_ASSERT(!q->hasPendingChanges());
......@@ -295,8 +289,7 @@ IdentityManager::IdentityManager(bool readonly, QObject *parent, const char *nam
setProperty("uniqueDBusPath", dbusPath);
const QString dbusInterface = QStringLiteral("org.kde.pim.IdentityManager");
dbus.registerObject(dbusPath, this);
dbus.connect(QString(), QString(), dbusInterface, QStringLiteral("identitiesChanged"), this,
SLOT(slotIdentitiesChanged(QString)));
dbus.connect(QString(), QString(), dbusInterface, QStringLiteral("identitiesChanged"), this, SLOT(slotIdentitiesChanged(QString)));
d->mReadOnly = readonly;
d->mConfig = new KConfig(QStringLiteral("emailidentities"));
......@@ -367,9 +360,12 @@ QString IdentityManager::makeUnique(const QString &name) const
int suffix = 1;
QString result = name;
while (identities().contains(result)) {
result = i18nc("%1: name; %2: number appended to it to make it unique "
"among a list of names", "%1 #%2",
name, suffix);
result = i18nc(
"%1: name; %2: number appended to it to make it unique "
"among a list of names",
"%1 #%2",
name,
suffix);
++suffix;
}
return result;
......@@ -390,19 +386,17 @@ void IdentityManager::commit()
QList<uint> seenUOIDs;
seenUOIDs.reserve(d->mIdentities.count());
const QVector<Identity>::ConstIterator end = d->mIdentities.constEnd();
for (QVector<Identity>::ConstIterator it = d->mIdentities.constBegin();
it != end; ++it) {
for (QVector<Identity>::ConstIterator it = d->mIdentities.constBegin(); it != end; ++it) {
seenUOIDs << (*it).uoid();
}
QList<uint> changedUOIDs;
// find added and changed identities:
for (QVector<Identity>::ConstIterator it = d->shadowIdentities.constBegin();
it != d->shadowIdentities.constEnd(); ++it) {
for (QVector<Identity>::ConstIterator it = d->shadowIdentities.constBegin(); it != d->shadowIdentities.constEnd(); ++it) {
const int index = seenUOIDs.indexOf((*it).uoid());
if (index != -1) {
uint uoid = seenUOIDs.at(index);
const Identity &orig = identityForUoid(uoid); // look up in mIdentities
const Identity &orig = identityForUoid(uoid); // look up in mIdentities
if (*it != orig) {
// changed identity
qCDebug(KIDENTITYMANAGEMENT_LOG) << "emitting changed() for identity" << uoid;
......@@ -418,8 +412,7 @@ void IdentityManager::commit()
}
// what's left are deleted identities:
for (QList<uint>::ConstIterator it = seenUOIDs.constBegin();
it != seenUOIDs.constEnd(); ++it) {
for (QList<uint>::ConstIterator it = seenUOIDs.constBegin(); it != seenUOIDs.constEnd(); ++it) {
qCDebug(KIDENTITYMANAGEMENT_LOG) << "emitting deleted() for identity" << (*it);
Q_EMIT deleted(*it);
}
......@@ -431,16 +424,14 @@ void IdentityManager::commit()
// signals that ship a uoid. This is because the slots might use
// identityForUoid(uoid)...
QList<uint>::ConstIterator changedEnd(changedUOIDs.constEnd());
for (QList<uint>::ConstIterator it = changedUOIDs.constBegin();
it != changedEnd; ++it) {
for (QList<uint>::ConstIterator it = changedUOIDs.constBegin(); it != changedEnd; ++it) {
Q_EMIT changed(*it);
}
Q_EMIT changed(); // normal signal
// DBus signal for other IdentityManager instances
const QString ourIdentifier = QStringLiteral("%1/%2").
arg(QDBusConnection::sessionBus().baseService(), property("uniqueDBusPath").toString());
const QString ourIdentifier = QStringLiteral("%1/%2").arg(QDBusConnection::sessionBus().baseService(), property("uniqueDBusPath").toString());
Q_EMIT identitiesChanged(ourIdentifier);
}
......@@ -459,8 +450,7 @@ QStringList IdentityManager::identities() const
QStringList result;
result.reserve(d->mIdentities.count());
ConstIterator end = d->mIdentities.constEnd();
for (ConstIterator it = d->mIdentities.constBegin();
it != end; ++it) {
for (ConstIterator it = d->mIdentities.constBegin(); it != end; ++it) {
result << (*it).identityName();
}
return result;
......@@ -471,8 +461,7 @@ QStringList IdentityManager::shadowIdentities() const
QStringList result;
result.reserve(d->shadowIdentities.count());
ConstIterator end = d->shadowIdentities.constEnd();
for (ConstIterator it = d->shadowIdentities.constBegin();
it != end; ++it) {
for (ConstIterator it = d->shadowIdentities.constBegin(); it != end; ++it) {
result << (*it).identityName();
}
return result;
......@@ -523,8 +512,7 @@ const Identity &IdentityManager::identityForUoidOrDefault(uint uoid) const
}
}