Commit 0baddd53 authored by Laurent Montel's avatar Laurent Montel 😁

Coding style

parent 55d382d5
......@@ -75,7 +75,7 @@ bool IdentityTester::compareIdentities(const Identity &actual, const Identity &e
QCOMPARE(actual.isXFaceEnabled(), expected.isXFaceEnabled());
QCOMPARE(actual.xface(), expected.xface());
ok = true;
}();
} ();
return ok;
}
......
......@@ -22,8 +22,7 @@
#include <qobject.h>
namespace KIdentityManagement
{
namespace KIdentityManagement {
class Identity;
}
......@@ -32,8 +31,7 @@ class IdentityTester : public QObject
Q_OBJECT
private:
bool compareIdentities(const KIdentityManagement::Identity &actual,
const KIdentityManagement::Identity &expected);
bool compareIdentities(const KIdentityManagement::Identity &actual, const KIdentityManagement::Identity &expected);
private Q_SLOTS:
void initTestCase();
......
......@@ -298,4 +298,3 @@ void SignatureTester::testLinebreaks()
QEXPECT_FAIL("", "This test is probably bogus, since Qt doesn't seem to produce HTML like this anymore.", Continue);
QCOMPARE(edit.toPlainText(), QStringLiteral("-- \nHans Mustermann\nMusterstr. 42"));
}
This diff is collapsed.
......@@ -31,8 +31,7 @@
#include <QtCore/QHash>
#include <QtCore/QVariant>
namespace KIdentityManagement
{
namespace KIdentityManagement {
class Identity;
class Signature;
}
......@@ -40,9 +39,7 @@ 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";
......@@ -61,10 +58,10 @@ static const char s_transport[] = "Transport";
static const char s_fcc[] = "Fcc";
static const char s_drafts[] = "Drafts";
static const char s_templates[] = "Templates";
static const char s_dict[] = "Dictionary";
static const char s_xface[] = "X-Face";
static const char s_xfaceenabled[] = "X-FaceEnabled";
static const char s_signature[] = "Signature";
static const char s_dict[] = "Dictionary";
static const char s_xface[] = "X-Face";
static const char s_xfaceenabled[] = "X-FaceEnabled";
static const char s_signature[] = "Signature";
static const char s_emailAliases[] = "Email Aliases";
static const char s_attachVcard[] = "Attach Vcard";
static const char s_autocorrectionLanguage[] = "Autocorrection Language";
......@@ -73,10 +70,8 @@ static const char s_pgpautosign[] = "Pgp Auto Sign";
static const char s_pgpautoencrypt[] = "Pgp Auto Encrypt";
static const char s_defaultDomainName[] = "Default Domain";
KIDENTITYMANAGEMENT_EXPORT QDataStream &operator<<
(QDataStream &stream, const KIdentityManagement::Identity &ident);
KIDENTITYMANAGEMENT_EXPORT QDataStream &operator>>
(QDataStream &stream, KIdentityManagement::Identity &ident);
KIDENTITYMANAGEMENT_EXPORT QDataStream &operator<<(QDataStream &stream, const KIdentityManagement::Identity &ident);
KIDENTITYMANAGEMENT_EXPORT QDataStream &operator>>(QDataStream &stream, KIdentityManagement::Identity &ident);
/** User identity information */
class KIDENTITYMANAGEMENT_EXPORT Identity
......@@ -86,38 +81,33 @@ class KIDENTITYMANAGEMENT_EXPORT Identity
// QValueList<Identity> and especially qHeapSort().
friend class IdentityManager;
friend KIDENTITYMANAGEMENT_EXPORT QDataStream &operator<<
(QDataStream &stream, const KIdentityManagement::Identity &ident);
friend KIDENTITYMANAGEMENT_EXPORT QDataStream &operator>>
(QDataStream &stream, KIdentityManagement::Identity &ident);
friend KIDENTITYMANAGEMENT_EXPORT QDataStream &operator<<(QDataStream &stream, const KIdentityManagement::Identity &ident);
friend KIDENTITYMANAGEMENT_EXPORT QDataStream &operator>>(QDataStream &stream, KIdentityManagement::Identity &ident);
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;
bool operator==(const Identity &other) const;
/** used for comparison */
bool operator!= (const Identity &other) const;
bool operator!=(const Identity &other) const;
/** used for sorting */
bool operator< (const Identity &other) const;
bool operator<(const Identity &other) const;
/** used for sorting */
bool operator> (const Identity &other) const;
bool operator>(const Identity &other) const;
/** used for sorting */
bool operator<= (const Identity &other) const;
bool operator<=(const Identity &other) const;
/** used for sorting */
bool operator>= (const Identity &other) const;
bool operator>=(const Identity &other) const;
/** Tests if there are enough values set to allow mailing */
bool mailingAllowed() const;
......@@ -366,10 +356,9 @@ protected:
bool useSignatureFile() const;
Signature mSignature;
bool mIsDefault;
QHash<QString, QVariant> mPropertiesMap;
bool mIsDefault;
QHash<QString, QVariant> mPropertiesMap;
};
}
#endif /*kpim_identity_h*/
......@@ -46,11 +46,11 @@ class KIdentityManagement::IdentityComboPrivate
{
public:
IdentityComboPrivate(IdentityManager *manager, IdentityCombo *qq)
: mIdentityManager(manager),
q(qq)
: mIdentityManager(manager)
, q(qq)
{
}
void reloadCombo();
void reloadUoidList();
......@@ -81,7 +81,8 @@ void KIdentityManagement::IdentityComboPrivate::reloadUoidList()
//@endcond
IdentityCombo::IdentityCombo(IdentityManager *manager, QWidget *parent)
: KComboBox(parent), d(new IdentityComboPrivate(manager, this))
: KComboBox(parent)
, d(new IdentityComboPrivate(manager, this))
{
d->reloadCombo();
d->reloadUoidList();
......@@ -174,4 +175,3 @@ IdentityManager *IdentityCombo::identityManager() const
{
return d->mIdentityManager;
}
......@@ -35,8 +35,7 @@
class QString;
namespace KIdentityManagement
{
namespace KIdentityManagement {
class IdentityComboPrivate;
class IdentityManager;
class Identity;
......@@ -86,7 +85,6 @@ private:
IdentityComboPrivate *const d;
//@endcond
};
}
#endif
......@@ -44,9 +44,7 @@ static const char configKeyDefaultIdentity[] = "Default Identity";
#include "identitymanageradaptor.h"
namespace KIdentityManagement
{
namespace KIdentityManagement {
static QString newDBusObjectName()
{
static int s_count = 0;
......@@ -95,13 +93,13 @@ 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) {
group != groupEnd; ++group) {
mConfig->deleteGroup(*group);
}
int i = 0;
ConstIterator end = mIdentities.constEnd();
for (ConstIterator it = mIdentities.constBegin();
it != end; ++it, ++i) {
it != end; ++it, ++i) {
KConfigGroup cg(mConfig, QStringLiteral("Identity #%1").arg(i));
(*it).writeConfig(cg);
if ((*it).isDefault()) {
......@@ -118,7 +116,6 @@ void IdentityManager::Private::writeConfig() const
}
}
mConfig->sync();
}
void IdentityManager::Private::readConfig(KConfig *config)
......@@ -135,7 +132,7 @@ void IdentityManager::Private::readConfig(KConfig *config)
bool haveDefault = false;
QStringList::const_iterator groupEnd = identities.constEnd();
for (QStringList::const_iterator group = identities.constBegin();
group != groupEnd; ++group) {
group != groupEnd; ++group) {
KConfigGroup configGroup(config, *group);
Identity identity;
identity.readConfig(configGroup);
......@@ -248,7 +245,7 @@ int IdentityManager::Private::newUoid()
usedUOIDs.reserve(1 + mIdentities.count() + (q->hasPendingChanges() ? shadowIdentities.count() : 0));
QList<Identity>::ConstIterator end(mIdentities.constEnd());
for (QList<Identity>::ConstIterator it = mIdentities.constBegin();
it != end; ++it) {
it != end; ++it) {
usedUOIDs << (*it).uoid();
}
......@@ -257,7 +254,7 @@ int IdentityManager::Private::newUoid()
// UOIDs, but avoiding duplicate UOIDs isn't worth the effort.
QList<Identity>::ConstIterator endShadow(shadowIdentities.constEnd());
for (QList<Identity>::ConstIterator it = shadowIdentities.constBegin();
it != endShadow; ++it) {
it != endShadow; ++it) {
usedUOIDs << (*it).uoid();
}
}
......@@ -292,10 +289,9 @@ IdentityManager *IdentityManager::self()
return s_self;
}
IdentityManager::IdentityManager(bool readonly, QObject *parent,
const char *name)
: QObject(parent),
d(new Private(this))
IdentityManager::IdentityManager(bool readonly, QObject *parent, const char *name)
: QObject(parent)
, d(new Private(this))
{
static bool triedMigration = false;
if (!triedMigration) {
......@@ -405,14 +401,14 @@ void IdentityManager::commit()
seenUOIDs.reserve(d->mIdentities.count());
QList<Identity>::ConstIterator end = d->mIdentities.constEnd();
for (QList<Identity>::ConstIterator it = d->mIdentities.constBegin();
it != end; ++it) {
it != end; ++it) {
seenUOIDs << (*it).uoid();
}
QList<uint> changedUOIDs;
// find added and changed identities:
for (QList<Identity>::ConstIterator it = d->shadowIdentities.constBegin();
it != d->shadowIdentities.constEnd(); ++it) {
it != d->shadowIdentities.constEnd(); ++it) {
int index = seenUOIDs.indexOf((*it).uoid());
if (index != -1) {
uint uoid = seenUOIDs.at(index);
......@@ -433,7 +429,7 @@ void IdentityManager::commit()
// what's left are deleted identities:
for (QList<uint>::ConstIterator it = seenUOIDs.constBegin();
it != seenUOIDs.constEnd(); ++it) {
it != seenUOIDs.constEnd(); ++it) {
qCDebug(KIDENTITYMANAGEMENT_LOG) << "emitting deleted() for identity" << (*it);
emit deleted(*it);
}
......@@ -446,7 +442,7 @@ void IdentityManager::commit()
// identityForUoid(uoid)...
QList<uint>::ConstIterator changedEnd(changedUOIDs.constEnd());
for (QList<uint>::ConstIterator it = changedUOIDs.constBegin();
it != changedEnd; ++it) {
it != changedEnd; ++it) {
emit changed(*it);
}
......@@ -474,7 +470,7 @@ QStringList IdentityManager::identities() const
result.reserve(d->mIdentities.count());
ConstIterator end = d->mIdentities.constEnd();
for (ConstIterator it = d->mIdentities.constBegin();
it != end; ++it) {
it != end; ++it) {
result << (*it).identityName();
}
return result;
......@@ -486,7 +482,7 @@ QStringList IdentityManager::shadowIdentities() const
result.reserve(d->shadowIdentities.count());
ConstIterator end = d->shadowIdentities.constEnd();
for (ConstIterator it = d->shadowIdentities.constBegin();
it != end; ++it) {
it != end; ++it) {
result << (*it).identityName();
}
return result;
......@@ -521,7 +517,7 @@ const Identity &IdentityManager::identityForUoid(uint uoid) const
{
for (ConstIterator it = begin(); it != end(); ++it) {
if ((*it).uoid() == uoid) {
return (*it);
return *it;
}
}
return Identity::null();
......@@ -562,7 +558,7 @@ Identity &IdentityManager::modifyIdentityForName(const QString &name)
{
for (Iterator it = modifyBegin(); it != modifyEnd(); ++it) {
if ((*it).identityName() == name) {
return (*it);
return *it;
}
}
......@@ -576,7 +572,7 @@ Identity &IdentityManager::modifyIdentityForUoid(uint uoid)
{
for (Iterator it = modifyBegin(); it != modifyEnd(); ++it) {
if ((*it).uoid() == uoid) {
return (*it);
return *it;
}
}
......@@ -590,7 +586,7 @@ const Identity &IdentityManager::defaultIdentity() const
{
for (ConstIterator it = begin(); it != end(); ++it) {
if ((*it).isDefault()) {
return (*it);
return *it;
}
}
......@@ -608,7 +604,7 @@ bool IdentityManager::setAsDefault(uint uoid)
bool found = false;
ConstIterator end(d->shadowIdentities.constEnd());
for (ConstIterator it = d->shadowIdentities.constBegin();
it != end; ++it) {
it != end; ++it) {
if ((*it).uoid() == uoid) {
found = true;
break;
......@@ -714,6 +710,5 @@ IdentityManager::Private::~Private()
{
delete mConfig;
}
}
#include "moc_identitymanager.cpp"
......@@ -26,9 +26,7 @@
class QStringList;
namespace KIdentityManagement
{
namespace KIdentityManagement {
class Identity;
/**
* @short Manages the list of identities.
......@@ -46,8 +44,7 @@ public:
* the default identity created here will not be saved.
* It is assumed that a minimum of one identity is always present.
*/
explicit IdentityManager(bool readonly = false, QObject *parent = nullptr,
const char *name = nullptr);
explicit IdentityManager(bool readonly = false, QObject *parent = nullptr, const char *name = nullptr);
virtual ~IdentityManager();
/**
......@@ -187,8 +184,7 @@ public:
Identity &newFromScratch(const QString &name);
Identity &newFromControlCenter(const QString &name);
Identity &newFromExisting(const Identity &other,
const QString &name = QString());
Identity &newFromExisting(const Identity &other, const QString &name = QString());
/** Returns the list of all email addresses (only name@host) from all
identities */
......@@ -220,8 +216,9 @@ protected:
* values from KUser, but reimplementations of this method can give
* them another value.
*/
virtual void createDefaultIdentity(QString &/*fullName*/,
QString &/*emailAddress*/) {}
virtual void createDefaultIdentity(QString & /*fullName*/, QString & /*emailAddress*/)
{
}
protected Q_SLOTS:
void slotRollback();
......@@ -236,7 +233,6 @@ private:
//@endcond
Q_PRIVATE_SLOT(d, void slotIdentitiesChanged(const QString &id))
};
} // namespace
#endif // _KMAIL_IDENTITYMANAGER_H_
......@@ -44,10 +44,10 @@ class Q_DECL_HIDDEN KIdentityManagement::SignaturePrivate
{
public:
SignaturePrivate(Signature *qq)
: enabled(false),
type(Signature::Disabled),
inlinedHtml(false),
q(qq)
: enabled(false)
, type(Signature::Disabled)
, inlinedHtml(false)
, q(qq)
{
}
......@@ -79,14 +79,9 @@ static bool isCursorAtEndOfLine(const QTextCursor &cursor)
return !testCursor.hasSelection();
}
static void insertSignatureHelper(const QString &signature,
KPIMTextEdit::RichTextComposer *textEdit,
Signature::Placement placement,
bool isHtml,
bool addNewlines)
static void insertSignatureHelper(const QString &signature, KPIMTextEdit::RichTextComposer *textEdit, Signature::Placement placement, bool isHtml, bool addNewlines)
{
if (!signature.isEmpty()) {
// Save the modified state of the document, as inserting a signature
// shouldn't change this. Restore it at the end of this function.
bool isModified = textEdit->document()->isModified();
......@@ -313,8 +308,8 @@ void SignaturePrivate::insertSignatureText(Signature::Placement placement, Signa
signature = q->rawText();
}
insertSignatureHelper(signature, textEdit, placement,
(inlinedHtml &&
type == KIdentityManagement::Signature::Inlined),
(inlinedHtml
&& type == KIdentityManagement::Signature::Inlined),
(addedText & Signature::AddNewLines));
// We added the text of the signature above, now it is time to add the images as well.
......@@ -325,12 +320,12 @@ void SignaturePrivate::insertSignatureText(Signature::Placement placement, Signa
}
}
QDataStream &operator<< (QDataStream &stream, const KIdentityManagement::Signature::EmbeddedImagePtr &img)
QDataStream &operator<<(QDataStream &stream, const KIdentityManagement::Signature::EmbeddedImagePtr &img)
{
return stream << img->image << img->name;
}
QDataStream &operator>> (QDataStream &stream, KIdentityManagement::Signature::EmbeddedImagePtr &img)
QDataStream &operator>>(QDataStream &stream, KIdentityManagement::Signature::EmbeddedImagePtr &img)
{
return stream >> img->image >> img->name;
}
......@@ -363,7 +358,7 @@ Signature::Signature(const Signature &that)
d->assignFrom(that);
}
Signature &Signature::operator= (const KIdentityManagement::Signature &that)
Signature &Signature::operator=(const KIdentityManagement::Signature &that)
{
if (this == &that) {
return *this;
......@@ -395,7 +390,7 @@ QString Signature::rawText(bool *ok) const
return d->textFromFile(ok);
case FromCommand:
return d->textFromCommand(ok);
};
}
qCritical() << "Signature::type() returned unknown value!";
return QString(); // make compiler happy
}
......@@ -417,8 +412,8 @@ QString Signature::withSeparator(bool *ok) const
newline.clear();
}
if (signature.startsWith(QLatin1String("-- ") + newline) ||
(signature.indexOf(newline + QLatin1String("-- ") + newline) != -1)) {
if (signature.startsWith(QLatin1String("-- ") + newline)
|| (signature.indexOf(newline + QLatin1String("-- ") + newline) != -1)) {
// already have signature separator at start of sig or inside sig:
return signature;
} else {
......@@ -520,8 +515,7 @@ void Signature::writeConfig(KConfigGroup &config) const
d->saveImages();
}
void Signature::insertIntoTextEdit(Placement placement, AddedText addedText,
KPIMTextEdit::RichTextComposer *textEdit, bool forceDisplay) const
void Signature::insertIntoTextEdit(Placement placement, AddedText addedText, KPIMTextEdit::RichTextComposer *textEdit, bool forceDisplay) const
{
d->insertSignatureText(placement, addedText, textEdit, forceDisplay);
}
......@@ -539,14 +533,14 @@ void Signature::setEmbeddedImages(const QList<Signature::EmbeddedImagePtr> &embe
// --------------------- Operators -------------------//
QDataStream &KIdentityManagement::operator<<
(QDataStream &stream, const KIdentityManagement::Signature &sig)
(QDataStream &stream, const KIdentityManagement::Signature &sig)
{
return stream << static_cast<quint8>(sig.type()) << sig.path() << sig.text()
<< sig.imageLocation() << sig.embeddedImages() << sig.isEnabledSignature();
<< sig.imageLocation() << sig.embeddedImages() << sig.isEnabledSignature();
}
QDataStream &KIdentityManagement::operator>>
(QDataStream &stream, KIdentityManagement::Signature &sig)
(QDataStream &stream, KIdentityManagement::Signature &sig)
{
quint8 s;
QString path;
......@@ -564,7 +558,7 @@ QDataStream &KIdentityManagement::operator>>
return stream;
}
bool Signature::operator== (const Signature &other) const
bool Signature::operator==(const Signature &other) const
{
if (d->type != other.type()) {
return false;
......
......@@ -32,26 +32,21 @@
#include <QtCore/QVariant>
#include <QImage>
namespace KIdentityManagement
{
namespace KIdentityManagement {
class Signature;
class Identity;
}
class KConfigGroup;
class KRichTextEdit;
namespace KPIMTextEdit
{
namespace KPIMTextEdit {
class RichTextComposer;
}
namespace KIdentityManagement
{
namespace KIdentityManagement {
class SignaturePrivate;
KIDENTITYMANAGEMENT_EXPORT QDataStream &operator<<
(QDataStream &stream, const KIdentityManagement::Signature &sig);
KIDENTITYMANAGEMENT_EXPORT QDataStream &operator>>
(QDataStream &stream, KIdentityManagement::Signature &sig);
KIDENTITYMANAGEMENT_EXPORT QDataStream &operator<<(QDataStream &stream, const KIdentityManagement::Signature &sig);
KIDENTITYMANAGEMENT_EXPORT QDataStream &operator>>(QDataStream &stream, KIdentityManagement::Signature &sig);
/**
* @short Abstraction of a signature (aka "footer").
......@@ -89,8 +84,8 @@ class KIDENTITYMANAGEMENT_EXPORT Signature
{
friend class Identity;
friend KIDENTITYMANAGEMENT_EXPORT QDataStream &operator<< (QDataStream &stream, const Signature &sig);
friend KIDENTITYMANAGEMENT_EXPORT QDataStream &operator>> (QDataStream &stream, Signature &sig);
friend KIDENTITYMANAGEMENT_EXPORT QDataStream &operator<<(QDataStream &stream, const Signature &sig);
friend KIDENTITYMANAGEMENT_EXPORT QDataStream &operator>>(QDataStream &stream, Signature &sig);
public:
/** Type of signature (ie. way to obtain the signature text) */
......@@ -118,7 +113,7 @@ public:
typedef QSharedPointer<EmbeddedImage> EmbeddedImagePtr;
/** Used for comparison */
bool operator== (const Signature &other) const;
bool operator==(const Signature &other) const;
/** Constructor for disabled signature */
Signature();
......@@ -129,7 +124,7 @@ public:
/** Copy constructor */
Signature(const Signature &that);
/** Assignment operator */
Signature &operator= (const Signature &that);
Signature &operator=(const Signature &that);
/** Destructor */
~Signature();
......@@ -248,8 +243,7 @@ public:
*/
// TODO: KDE5: BIC: Reorder parameters, the order here is a workaround for ambiguous parameters
// with the deprecated method
void insertIntoTextEdit(Placement placement, AddedText addedText,
KPIMTextEdit::RichTextComposer *textEdit, bool forceDisplay = false) const;
void insertIntoTextEdit(Placement placement, AddedText addedText, KPIMTextEdit::RichTextComposer *textEdit, bool forceDisplay = false) const;
QList<Signature::EmbeddedImagePtr> embeddedImages() const;
void setEmbeddedImages(const QList<Signature::EmbeddedImagePtr> &embedded);
......@@ -267,7 +261,6 @@ private:
};
Q_DECLARE_OPERATORS_FOR_FLAGS(Signature::AddedText)
}
#endif /*kpim_signature_h*/
......@@ -52,9 +52,7 @@
using namespace KIdentityManagement;
namespace KIdentityManagement
{
namespace KIdentityManagement {
/**
Private class that helps to provide binary compatibility between releases.
@internal
......@@ -72,21 +70,21 @@ public:
SignatureConfigurator *q;
bool inlinedHtml;
QString imageLocation;
QCheckBox *mEnableCheck;
QCheckBox *mHtmlCheck;
KComboBox *mSourceCombo;
KUrlRequester *mFileRequester;
QPushButton *mEditButton;
KLineEdit *mCommandEdit;
KToolBar *mEditToolBar;
KToolBar *mFormatToolBar;
QCheckBox *mEnableCheck;
QCheckBox *mHtmlCheck;
KComboBox *mSourceCombo;
KUrlRequester *mFileRequester;
QPushButton *mEditButton;
KLineEdit *mCommandEdit;
KToolBar *mEditToolBar;
KToolBar *mFormatToolBar;
KPIMTextEdit::RichTextComposer *mTextEdit;
};
//@endcond
SignatureConfigurator::Private::Private(SignatureConfigurator *parent)
: q(parent), inlinedHtml(true)
: q(parent)
, inlinedHtml(true)
{