Commit 80a76ef4 authored by Laurent Montel's avatar Laurent Montel 😁

Coding style

parent de1fb3cb
......@@ -37,12 +37,13 @@ class KLDAP::AddHostDialogPrivate
{
public:
AddHostDialogPrivate(AddHostDialog *qq)
: mCfg(nullptr),
mServer(nullptr),
mOkButton(nullptr),
q(qq)
: mCfg(nullptr)
, mServer(nullptr)
, mOkButton(nullptr)
, q(qq)
{
}
~AddHostDialogPrivate()
{
writeConfig();
......@@ -73,8 +74,8 @@ void AddHostDialogPrivate::writeConfig()
}
AddHostDialog::AddHostDialog(KLDAP::LdapServer *server, QWidget *parent)
: QDialog(parent),
d(new KLDAP::AddHostDialogPrivate(this))
: QDialog(parent)
, d(new KLDAP::AddHostDialogPrivate(this))
{
setWindowTitle(i18n("Add Host"));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
......@@ -95,20 +96,20 @@ AddHostDialog::AddHostDialog(KLDAP::LdapServer *server, QWidget *parent)
layout->setMargin(0);
d->mCfg = new KLDAP::LdapConfigWidget(
KLDAP::LdapConfigWidget::W_USER |
KLDAP::LdapConfigWidget::W_PASS |
KLDAP::LdapConfigWidget::W_BINDDN |
KLDAP::LdapConfigWidget::W_REALM |
KLDAP::LdapConfigWidget::W_HOST |
KLDAP::LdapConfigWidget::W_PORT |
KLDAP::LdapConfigWidget::W_VER |
KLDAP::LdapConfigWidget::W_TIMELIMIT |
KLDAP::LdapConfigWidget::W_SIZELIMIT |
KLDAP::LdapConfigWidget::W_PAGESIZE |
KLDAP::LdapConfigWidget::W_DN |
KLDAP::LdapConfigWidget::W_FILTER |
KLDAP::LdapConfigWidget::W_SECBOX |
KLDAP::LdapConfigWidget::W_AUTHBOX,
KLDAP::LdapConfigWidget::W_USER
|KLDAP::LdapConfigWidget::W_PASS
|KLDAP::LdapConfigWidget::W_BINDDN
|KLDAP::LdapConfigWidget::W_REALM
|KLDAP::LdapConfigWidget::W_HOST
|KLDAP::LdapConfigWidget::W_PORT
|KLDAP::LdapConfigWidget::W_VER
|KLDAP::LdapConfigWidget::W_TIMELIMIT
|KLDAP::LdapConfigWidget::W_SIZELIMIT
|KLDAP::LdapConfigWidget::W_PAGESIZE
|KLDAP::LdapConfigWidget::W_DN
|KLDAP::LdapConfigWidget::W_FILTER
|KLDAP::LdapConfigWidget::W_SECBOX
|KLDAP::LdapConfigWidget::W_AUTHBOX,
page);
layout->addWidget(d->mCfg);
......
......@@ -25,8 +25,7 @@
#include "kdepim_export.h"
#include <qdialog.h>
namespace KLDAP
{
namespace KLDAP {
class LdapServer;
class AddHostDialogPrivate;
class KDEPIM_EXPORT AddHostDialog : public QDialog
......@@ -47,7 +46,6 @@ private Q_SLOTS:
private:
AddHostDialogPrivate *const d;
};
}
#endif // ADDHOSTDIALOG_H
......@@ -46,14 +46,15 @@
#include "addhostdialog.h"
K_PLUGIN_FACTORY_WITH_JSON(KCMLdapFactory, "kcmldap.json", registerPlugin<KCMLdap>();)
K_PLUGIN_FACTORY_WITH_JSON(KCMLdapFactory, "kcmldap.json", registerPlugin<KCMLdap>();
)
class LDAPItem : public QListWidgetItem
{
public:
LDAPItem(QListWidget *parent, const KLDAP::LdapServer &server, bool isActive = false)
: QListWidgetItem(parent, QListWidgetItem::UserType),
mIsActive(isActive)
: QListWidgetItem(parent, QListWidgetItem::UserType)
, mIsActive(isActive)
{
setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
setCheckState(isActive ? Qt::Checked : Qt::Unchecked);
......@@ -76,6 +77,7 @@ public:
{
mIsActive = isActive;
}
bool isActive() const
{
return mIsActive;
......
......@@ -30,8 +30,7 @@ class QListWidgetItem;
class QPushButton;
class QToolButton;
namespace KLDAP
{
namespace KLDAP {
class LdapClientSearchConfig;
}
......
......@@ -39,10 +39,10 @@ class Q_DECL_HIDDEN LdapClient::Private
{
public:
Private(LdapClient *qq)
: q(qq),
mJob(nullptr),
mActive(false),
mClientNumber(0)
: q(qq)
, mJob(nullptr)
, mActive(false)
, mClientNumber(0)
{
}
......@@ -74,11 +74,11 @@ public:
KLDAP::Ldif mLdif;
int mClientNumber;
int mCompletionWeight;
};
LdapClient::LdapClient(int clientNumber, QObject *parent)
: QObject(parent), d(new Private(this))
: QObject(parent)
, d(new Private(this))
{
d->mClientNumber = clientNumber;
d->mCompletionWeight = 50 - d->mClientNumber;
......@@ -142,11 +142,11 @@ void LdapClient::startQuery(const QString &filter)
d->startParseLDIF();
d->mActive = true;
d->mJob = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo);
connect(d->mJob, SIGNAL(data(KIO::Job*,QByteArray)),
this, SLOT(slotData(KIO::Job*,QByteArray)));
connect(d->mJob, SIGNAL(infoMessage(KJob*,QString,QString)),
this, SLOT(slotInfoMessage(KJob*,QString,QString)));
connect(d->mJob, SIGNAL(result(KJob*)),
connect(d->mJob, SIGNAL(data(KIO::Job *,QByteArray)),
this, SLOT(slotData(KIO::Job *,QByteArray)));
connect(d->mJob, SIGNAL(infoMessage(KJob *,QString,QString)),
this, SLOT(slotInfoMessage(KJob *,QString,QString)));
connect(d->mJob, SIGNAL(result(KJob *)),
this, SLOT(slotDone()));
}
......@@ -205,8 +205,7 @@ void LdapClient::Private::finishCurrentObject()
KLDAP::LdapAttrValue objectclasses;
const KLDAP::LdapAttrMap::ConstIterator end = mCurrentObject.attributes().constEnd();
for (KLDAP::LdapAttrMap::ConstIterator it = mCurrentObject.attributes().constBegin();
it != end; ++it) {
it != end; ++it) {
if (it.key().toLower() == QLatin1String("objectclass")) {
objectclasses = it.value();
break;
......@@ -216,8 +215,7 @@ void LdapClient::Private::finishCurrentObject()
bool groupofnames = false;
const KLDAP::LdapAttrValue::ConstIterator endValue(objectclasses.constEnd());
for (KLDAP::LdapAttrValue::ConstIterator it = objectclasses.constBegin();
it != endValue; ++it) {
it != endValue; ++it) {
const QByteArray sClass = (*it).toLower();
if (sClass == "groupofnames" || sClass == "kolabgroupofnames") {
groupofnames = true;
......@@ -266,12 +264,13 @@ void LdapClient::Private::parseLDIF(const QByteArray &data)
do {
ret = mLdif.nextItem();
switch (ret) {
case KLDAP::Ldif::Item: {
case KLDAP::Ldif::Item:
{
name = mLdif.attr();
const QByteArray value = mLdif.value();
mCurrentObject.addValue(name, value);
break;
}
break;
case KLDAP::Ldif::EndEntry:
finishCurrentObject();
break;
......
......@@ -29,9 +29,7 @@
class KJob;
namespace KLDAP
{
namespace KLDAP {
class LdapObject;
class LdapServer;
......@@ -159,7 +157,6 @@ private:
Q_PRIVATE_SLOT(d, void slotDone())
//@endcond
};
}
#endif
......@@ -51,9 +51,9 @@ class Q_DECL_HIDDEN LdapClientSearch::Private
{
public:
Private(LdapClientSearch *qq)
: q(qq),
mActiveClients(0),
mNoLDAPLookup(false)
: q(qq)
, mActiveClients(0)
, mNoLDAPLookup(false)
{
mClientSearchConfig = new LdapClientSearchConfig;
}
......@@ -88,7 +88,8 @@ public:
};
LdapClientSearch::LdapClientSearch(QObject *parent)
: QObject(parent), d(new Private(this))
: QObject(parent)
, d(new Private(this))
{
Kdelibs4ConfigMigrator migrate(QStringLiteral("ldapsettings"));
migrate.setConfigFiles(QStringList() << QStringLiteral("kabldaprc"));
......@@ -111,7 +112,6 @@ LdapClientSearch::LdapClientSearch(QObject *parent)
d->readConfig();
connect(KDirWatch::self(), SIGNAL(dirty(QString)), this,
SLOT(slotFileChanged(QString)));
}
LdapClientSearch::~LdapClientSearch()
......@@ -119,8 +119,7 @@ LdapClientSearch::~LdapClientSearch()
delete d;
}
void LdapClientSearch::Private::readWeighForClient(LdapClient *client, const KConfigGroup &config,
int clientNumber)
void LdapClientSearch::Private::readWeighForClient(LdapClient *client, const KConfigGroup &config, int clientNumber)
{
const int completionWeight = config.readEntry(QStringLiteral("SelectedCompletionWeight%1").arg(clientNumber), -1);
if (completionWeight != -1) {
......@@ -158,7 +157,6 @@ QStringList LdapClientSearch::attributes() const
void LdapClientSearch::setAttributes(const QStringList &attrs)
{
if (attrs != d->mAttributes) {
d->mAttributes = attrs;
d->readConfig();
......@@ -258,8 +256,7 @@ void LdapClientSearch::cancelSearch()
d->mResults.clear();
}
void LdapClientSearch::Private::slotLDAPResult(const LdapClient &client,
const KLDAP::LdapObject &obj)
void LdapClientSearch::Private::slotLDAPResult(const LdapClient &client, const KLDAP::LdapObject &obj)
{
LdapResultObject result;
result.client = &client;
......@@ -312,7 +309,6 @@ void LdapClientSearch::Private::finish()
void LdapClientSearch::Private::makeSearchData(QStringList &ret, LdapResult::List &resList)
{
LdapResultObject::List::ConstIterator it1(mResults.constBegin());
const LdapResultObject::List::ConstIterator end1(mResults.constEnd());
for (; it1 != end1; ++it1) {
......@@ -326,7 +322,7 @@ void LdapClientSearch::Private::makeSearchData(QStringList &ret, LdapResult::Lis
KLDAP::LdapAttrMap::ConstIterator it2;
for (it2 = (*it1).object.attributes().constBegin();
it2 != (*it1).object.attributes().constEnd(); ++it2) {
it2 != (*it1).object.attributes().constEnd(); ++it2) {
QByteArray val = (*it2).first();
int len = val.size();
if (len > 0 && '\0' == val[len - 1]) {
......@@ -369,8 +365,8 @@ void LdapClientSearch::Private::makeSearchData(QStringList &ret, LdapResult::Lis
givenname = tmp;
} else if (it2.key() == QLatin1String("sn")) {
sn = tmp;
} else if (it2.key() == QLatin1String("objectClass") &&
(tmp == QLatin1String("groupOfNames") || tmp == QLatin1String("kolabGroupOfNames"))) {
} else if (it2.key() == QLatin1String("objectClass")
&& (tmp == QLatin1String("groupOfNames") || tmp == QLatin1String("kolabGroupOfNames"))) {
isDistributionList = true;
}
}
......
......@@ -27,8 +27,7 @@
#include <QObject>
#include <QStringList>
namespace KLDAP
{
namespace KLDAP {
class LdapClient;
/**
......@@ -180,7 +179,6 @@ private:
Q_PRIVATE_SLOT(d, void slotFileChanged(const QString &))
//@endcond
};
}
Q_DECLARE_TYPEINFO(KLDAP::LdapResult, Q_MOVABLE_TYPE);
Q_DECLARE_TYPEINFO(KLDAP::LdapResultObject, Q_MOVABLE_TYPE);
......
......@@ -32,12 +32,12 @@ class Q_DECL_HIDDEN LdapClientSearchConfig::Private
{
public:
Private()
: useWallet(false),
askWallet(true),
wallet(nullptr)
: useWallet(false)
, askWallet(true)
, wallet(nullptr)
{
}
~Private()
{
if (useWallet) {
......@@ -45,6 +45,7 @@ public:
wallet = nullptr;
}
}
bool useWallet;
bool askWallet;
KWallet::Wallet *wallet;
......@@ -58,7 +59,8 @@ KConfig *LdapClientSearchConfig::config()
}
LdapClientSearchConfig::LdapClientSearchConfig(QObject *parent)
: QObject(parent), d(new LdapClientSearchConfig::Private())
: QObject(parent)
, d(new LdapClientSearchConfig::Private())
{
}
......@@ -74,8 +76,8 @@ void LdapClientSearchConfig::readConfig(KLDAP::LdapServer &server, KConfigGroup
prefix = QStringLiteral("Selected");
}
const QString host = config.readEntry(prefix + QStringLiteral("Host%1").arg(j),
QString()).trimmed();
const QString host = config.readEntry(prefix + QStringLiteral("Host%1").arg(j),
QString()).trimmed();
if (!host.isEmpty()) {
server.setHost(host);
}
......@@ -104,10 +106,10 @@ void LdapClientSearchConfig::readConfig(KLDAP::LdapServer &server, KConfigGroup
QString pwdBindDN = config.readEntry(pwdBindBNEntry, QString());
if (!pwdBindDN.isEmpty()) {
if (d->askWallet && KMessageBox::Yes == KMessageBox::questionYesNo(nullptr, i18n("LDAP password is stored as clear text, do you want to store it in kwallet?"),
i18n("Store clear text password in KWallet"),
KStandardGuiItem::yes(),
KStandardGuiItem::no(),
QStringLiteral("DoAskToStoreToKwallet"))) {
i18n("Store clear text password in KWallet"),
KStandardGuiItem::yes(),
KStandardGuiItem::no(),
QStringLiteral("DoAskToStoreToKwallet"))) {
d->wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), 0);
if (d->wallet) {
connect(d->wallet, &KWallet::Wallet::walletClosed, this, &LdapClientSearchConfig::slotWalletClosed);
......
......@@ -27,8 +27,7 @@
class KConfigGroup;
class KConfig;
namespace KLDAP
{
namespace KLDAP {
class LdapServer;
class LdapClient;
class KDEPIM_EXPORT LdapClientSearchConfig : public QObject
......@@ -49,8 +48,7 @@ public:
*
* @param active Defines whether the active settings shall be read.
*/
void readConfig(KLDAP::LdapServer &server, KConfigGroup &group,
int clientNumber, bool active);
void readConfig(KLDAP::LdapServer &server, KConfigGroup &group, int clientNumber, bool active);
/**
* Writes the LDAP @p server settings to the given config @p group for the
......@@ -58,8 +56,7 @@ public:
*
* @param active Defines whether the active settings shall be written.
*/
void writeConfig(const KLDAP::LdapServer &server, KConfigGroup &group,
int clientNumber, bool active);
void writeConfig(const KLDAP::LdapServer &server, KConfigGroup &group, int clientNumber, bool active);
/**
* Should LdapClientSearchConfig ask, if it should use the KWallet to store passwords
......@@ -74,7 +71,6 @@ private:
class Private;
Private *const d;
};
}
#endif // LDAPCLIENTSEARCHCONFIG_H
......@@ -304,8 +304,7 @@ public:
}
}
virtual QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const Q_DECL_OVERRIDE
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE
{
if (orientation == Qt::Vertical || role != Qt::DisplayRole || section < 0 || section > 17) {
return QVariant();
......@@ -370,7 +369,7 @@ public:
default:
return QVariant();
break;
};
}
return QVariant();
}
......@@ -381,8 +380,8 @@ public:
return QVariant();
}
if (index.row() < 0 || index.row() >= mContactList.count() ||
index.column() < 0 || index.column() > 17) {
if (index.row() < 0 || index.row() >= mContactList.count()
|| index.column() < 0 || index.column() > 17) {
return QVariant();
}
......@@ -468,20 +467,20 @@ class Q_DECL_HIDDEN LdapSearchDialog::Private
{
public:
Private(LdapSearchDialog *qq)
: q(qq),
mNumHosts(0),
mIsConfigured(false),
mFilterCombo(nullptr),
mSearchType(nullptr),
mSearchEdit(nullptr),
mRecursiveCheckbox(nullptr),
mResultView(nullptr),
mSearchButton(nullptr),
mModel(nullptr),
progressIndication(nullptr),
sortproxy(nullptr),
searchLine(nullptr),
user1Button(nullptr)
: q(qq)
, mNumHosts(0)
, mIsConfigured(false)
, mFilterCombo(nullptr)
, mSearchType(nullptr)
, mSearchEdit(nullptr)
, mRecursiveCheckbox(nullptr)
, mResultView(nullptr)
, mSearchButton(nullptr)
, mModel(nullptr)
, progressIndication(nullptr)
, sortproxy(nullptr)
, searchLine(nullptr)
, user1Button(nullptr)
{
}
......@@ -536,7 +535,8 @@ public:
};
LdapSearchDialog::LdapSearchDialog(QWidget *parent)
: QDialog(parent), d(new Private(this))
: QDialog(parent)
, d(new Private(this))
{
setWindowTitle(i18n("Import Contacts from LDAP"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel);
......@@ -650,7 +650,7 @@ LdapSearchDialog::LdapSearchDialog(QWidget *parent)
QDialogButtonBox *buttons = new QDialogButtonBox(page);
QPushButton *button = buttons->addButton(i18n("Select All"),
QDialogButtonBox::ActionRole);
QDialogButtonBox::ActionRole);
connect(button, SIGNAL(clicked()), this, SLOT(slotSelectAll()));
button = buttons->addButton(i18n("Unselect All"),
QDialogButtonBox::ActionRole);
......@@ -740,7 +740,7 @@ void LdapSearchDialog::Private::restoreSettings()
QMap<QString, QString>::ConstIterator end(adrbookattr2ldap().constEnd());
for (QMap<QString, QString>::ConstIterator it = adrbookattr2ldap().constBegin();
it != end; ++it) {
it != end; ++it) {
attrs << *it;
}
......@@ -792,8 +792,7 @@ void LdapSearchDialog::Private::cancelQuery()
}
}
void LdapSearchDialog::Private::slotAddResult(const KLDAP::LdapClient &client,
const KLDAP::LdapObject &obj)
void LdapSearchDialog::Private::slotAddResult(const KLDAP::LdapClient &client, const KLDAP::LdapObject &obj)
{
mModel->addContact(obj.attributes(), client.server().host());
}
......
......@@ -31,9 +31,7 @@
class QCloseEvent;
namespace KLDAP
{
namespace KLDAP {
class LdapClient;
class LdapObject;
......@@ -113,7 +111,6 @@ private:
Q_PRIVATE_SLOT(d, void slotSelectionChanged())
//@endcond
};
}
Q_DECLARE_METATYPE(KLDAP::LdapSearchDialog::FilterType)
#endif
......@@ -34,9 +34,7 @@ static void deleteGlobalStaticBroadcastStatus()
instance_ = nullptr;
}
namespace KPIM
{
namespace KPIM {
BroadcastStatus *BroadcastStatus::instance()
{
if (!instance_) {
......@@ -52,7 +50,6 @@ public:
BroadcastStatusPrivate()
: mTransientActive(false)
{
}
QString mStatusMsg;
......@@ -95,6 +92,4 @@ void BroadcastStatus::reset()
// restore
Q_EMIT statusMsg(d->mStatusMsg);
}
}
......@@ -28,9 +28,7 @@
#undef None
namespace KPIM
{
namespace KPIM {
/**
Provides a singleton which broadcasts status messages by emitting
signals. Interested mainwindows can connect to the statusMsg()
......@@ -39,7 +37,6 @@ namespace KPIM
class BroadcastStatusPrivate;
class KDEPIM_EXPORT BroadcastStatus : public QObject
{
Q_OBJECT
public:
......@@ -78,7 +75,6 @@ protected:
BroadcastStatus();