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

Modernize code + const'ify

parent 24dac9ef
Pipeline #36758 failed with stage
in 51 minutes and 15 seconds
......@@ -31,7 +31,7 @@ NotesResource::~NotesResource()
QStringList NotesResource::allMimeTypes() const
{
return QStringList() << sNotesType;
return {sNotesType};
}
QString NotesResource::mimeType(const KCalendarCore::IncidenceBase::Ptr &) const
......
......@@ -82,7 +82,7 @@ void ICalResourceBase::itemRemoved(const Akonadi::Item &item)
return;
}
Incidence::Ptr i = mCalendar->instance(item.remoteId());
const Incidence::Ptr i = mCalendar->instance(item.remoteId());
if (i) {
if (!mCalendar->deleteIncidence(i)) {
qCritical() << "akonadi_ical_resource: Can't delete incidence with instance identifier "
......
......@@ -15,13 +15,7 @@ BatchFetcher::BatchFetcher(MessageHelper::Ptr messageHelper, const KIMAP::ImapSe
, m_scope(scope)
, m_session(session)
, m_batchSize(batchSize)
, m_uidBased(false)
, m_fetchedItemsInCurrentBatch(0)
, m_messageHelper(messageHelper)
, m_fetchInProgress(false)
, m_continuationRequested(false)
, m_gmailEnabled(false)
, m_searchInChunks(false)
{
}
......
......@@ -41,17 +41,17 @@ private Q_SLOTS:
private:
//Batch fetching
KIMAP::ImapSet m_currentSet;
KIMAP::FetchJob::FetchScope m_scope;
KIMAP::Session *m_session = nullptr;
int m_batchSize;
bool m_uidBased;
int m_fetchedItemsInCurrentBatch;
const KIMAP::FetchJob::FetchScope m_scope;
KIMAP::Session *const m_session;
const int m_batchSize;
bool m_uidBased = false;
int m_fetchedItemsInCurrentBatch = 0;
const MessageHelper::Ptr m_messageHelper;
bool m_fetchInProgress;
bool m_continuationRequested;
bool m_fetchInProgress = false;
bool m_continuationRequested = false;
KIMAP::ImapInterval m_searchUidInterval;
bool m_gmailEnabled;
bool m_searchInChunks;
bool m_gmailEnabled = false;
bool m_searchInChunks = false;
};
#endif // BATCHFETCHER_H
......@@ -23,7 +23,6 @@ ReplaceMessageJob::ReplaceMessageJob(const KMime::Message::Ptr &msg, KIMAP::Sess
, mMailbox(mailbox)
, mUidNext(uidNext)
, mOldUids(oldUids)
, mNewUid(-1)
, mMessageId(msg->messageID()->asUnicodeString().toUtf8())
{
}
......
......@@ -41,7 +41,7 @@ private:
const QString mMailbox;
qint64 mUidNext;
KIMAP::ImapSet mOldUids;
qint64 mNewUid;
qint64 mNewUid = -1;
const QByteArray mMessageId;
};
......
......@@ -198,7 +198,7 @@ public:
void setItemMergingMode(Akonadi::ItemSync::MergeMode mergeMode) override;
private:
ImapResourceBase *m_resource = nullptr;
ImapResourceBase *const m_resource;
const TaskArguments m_arguments;
};
......
......@@ -37,18 +37,7 @@
RetrieveItemsTask::RetrieveItemsTask(const ResourceStateInterface::Ptr &resource, QObject *parent)
: ResourceTask(CancelIfNoSession, resource, parent)
, m_session(nullptr)
, m_fetchedMissingBodies(-1)
, m_fetchMissingBodies(false)
, m_incremental(true)
, m_localHighestModSeq(-1)
, m_batchFetcher(nullptr)
, m_uidBasedFetch(true)
, m_flagsChanged(false)
, m_messageCount(-1)
, m_uidValidity(-1)
, m_nextUid(-1)
, m_highestModSeq(-1)
{
}
......
......@@ -58,22 +58,22 @@ private:
KIMAP::Session *m_session = nullptr;
QVector<qint64> m_messageUidsMissingBody;
int m_fetchedMissingBodies;
bool m_fetchMissingBodies;
bool m_incremental;
qint64 m_localHighestModSeq;
int m_fetchedMissingBodies = -1;
bool m_fetchMissingBodies = false;
bool m_incremental = true;
qint64 m_localHighestModSeq = -1;
BatchFetcher *m_batchFetcher = nullptr;
Akonadi::Collection m_modifiedCollection;
bool m_uidBasedFetch;
bool m_flagsChanged;
bool m_uidBasedFetch = true;
bool m_flagsChanged = false;
QElapsedTimer m_time;
// Results of SELECT
QString m_mailBox;
int m_messageCount;
int m_uidValidity;
qint64 m_nextUid;
qint64 m_highestModSeq;
int m_messageCount = -1;
int m_uidValidity = -1;
qint64 m_nextUid = -1;
qint64 m_highestModSeq = -1;
QList<QByteArray> m_flags;
};
......
......@@ -27,7 +27,7 @@ private Q_SLOTS:
private:
void doSearch(KIMAP::Session *session);
QString m_query;
const QString m_query;
};
#endif // SEARCHTASK_H
......@@ -103,7 +103,7 @@ private:
static qint64 m_requestCounter;
int m_maxPoolSize;
const int m_maxPoolSize;
ImapAccount *m_account = nullptr;
PasswordRequesterInterface *m_passwordRequester = nullptr;
KIMAP::SessionUiProxy::Ptr m_sessionUiProxy;
......
......@@ -34,9 +34,9 @@ private Q_SLOTS:
void onSettingsDialogFinished(int result);
private:
QString requestManualAuth(bool *userRejected);
Q_REQUIRED_RESULT QString requestManualAuth(bool *userRejected);
ImapResourceBase *m_resource = nullptr;
ImapResourceBase *const m_resource;
QDialog *m_requestDialog = nullptr;
QDialog *m_settingsDialog = nullptr;
};
......
......@@ -68,8 +68,8 @@ private:
void readSettings();
void populateDefaultAuthenticationOptions();
ImapResourceBase *m_parentResource = nullptr;
Ui::SetupServerView *m_ui = nullptr;
ImapResourceBase *const m_parentResource;
Ui::SetupServerView *const m_ui;
MailTransport::ServerTest *m_serverTest = nullptr;
bool m_subscriptionsChanged = false;
bool m_shouldClearCache = false;
......
......@@ -90,8 +90,8 @@ private:
QLineEdit *m_lineEdit = nullptr;
QCheckBox *m_enableSubscription = nullptr;
SubscriptionFilterProxyModel *m_filter = nullptr;
QStandardItemModel *m_model = nullptr;
SubscriptionFilterProxyModel *const m_filter;
QStandardItemModel *const m_model;
QMap<QString, QStandardItem *> m_itemsMap;
QPushButton *mUser1Button = nullptr;
};
......
......@@ -57,10 +57,7 @@ static const char warningFile[] = "WARNING_README.txt";
KAlarmDirResource::KAlarmDirResource(const QString &id)
: ResourceBase(id)
, mSettings(new Settings(config()))
, mCollectionId(-1)
, mCompatibility(KACalendar::Incompatible)
, mCollectionFetched(false)
, mWaitingToRetrieve(false)
{
qCDebug(KALARMDIRRESOURCE_LOG) << "Starting:" << id;
KAlarmResourceCommon::initialise(this);
......
......@@ -95,12 +95,12 @@ private:
QHash<QString, EventFile> mEvents; // cached alarms and file names, indexed by ID
QHash<QString, QString> mFileEventIds; // alarm IDs, indexed by file name
Akonadi_KAlarm_Dir_Resource::Settings *mSettings = nullptr;
Akonadi::Collection::Id mCollectionId; // ID of this resource's collection
Akonadi::Collection::Id mCollectionId = -1; // ID of this resource's collection
KACalendar::Compat mCompatibility;
int mVersion; // calendar format version
QStringList mChangedFiles; // files being written to
bool mCollectionFetched; // mCollectionId has been initialised
bool mWaitingToRetrieve; // retrieveCollections() needs to be called
bool mCollectionFetched = false; // mCollectionId has been initialised
bool mWaitingToRetrieve = false; // retrieveCollections() needs to be called
};
#endif
......@@ -23,7 +23,6 @@ namespace Akonadi_KAlarm_Dir_Resource {
SettingsDialog::SettingsDialog(WId windowId, Settings *settings)
: QDialog()
, mSettings(settings)
, mReadOnlySelected(false)
{
QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
......
......@@ -25,8 +25,6 @@
KolabChangeItemsRelationsTask::KolabChangeItemsRelationsTask(const ResourceStateInterface::Ptr &resource, QObject *parent)
: KolabRelationResourceTask(resource, parent)
, mSession(nullptr)
, mAdding(false)
{
}
......
......@@ -16,7 +16,6 @@
KolabChangeItemsTagsTask::KolabChangeItemsTagsTask(const ResourceStateInterface::Ptr &resource, const QSharedPointer<TagConverter> &tagConverter, QObject *parent)
: KolabRelationResourceTask(resource, parent)
, mSession(nullptr)
, mTagConverter(tagConverter)
{
}
......
......@@ -23,7 +23,7 @@ protected:
private:
KIMAP::Session *mSession = nullptr;
QList<Akonadi::Tag> mChangedTags;
QSharedPointer<TagConverter> mTagConverter;
const QSharedPointer<TagConverter> mTagConverter;
private:
void processNextTag();
......
......@@ -14,7 +14,6 @@
KolabChangeTagTask::KolabChangeTagTask(const ResourceStateInterface::Ptr &resource, const QSharedPointer<TagConverter> &tagConverter, QObject *parent)
: KolabRelationResourceTask(resource, parent)
, mSession(nullptr)
, mTagConverter(tagConverter)
{
}
......
......@@ -22,7 +22,7 @@ protected:
private:
KIMAP::Session *mSession = nullptr;
QSharedPointer<TagConverter> mTagConverter;
const QSharedPointer<TagConverter> mTagConverter;
private Q_SLOTS:
void onItemsFetchDone(KJob *job);
......
......@@ -18,7 +18,7 @@ public:
Akonadi::Item createItemFromMessage(const KMime::Message::Ptr &message, const qint64 uid, const qint64 size, const QMap<QByteArray, QVariant> &attrs, const QList<QByteArray> &flags, const KIMAP::FetchJob::FetchScope &scope, bool &ok) const override;
private:
Akonadi::Collection mCollection;
const Akonadi::Collection mCollection;
};
#endif
......@@ -19,7 +19,6 @@
KolabRelationResourceTask::KolabRelationResourceTask(const ResourceStateInterface::Ptr &resource, QObject *parent)
: ResourceTask(DeferIfNoSession, resource, parent)
, mImapSession(nullptr)
{
}
......
......@@ -49,7 +49,6 @@ static bool isNamespaceFolder(const QString &path, const QList<KIMAP::MailBoxDes
RetrieveMetadataJob::RetrieveMetadataJob(KIMAP::Session *session, const QStringList &mailboxes, const QStringList &serverCapabilities, const QSet<QByteArray> &requestedMetadata, const QString &separator, const QList<KIMAP::MailBoxDescriptor> &sharedNamespace,
const QList<KIMAP::MailBoxDescriptor> &userNamespace, QObject *parent)
: KJob(parent)
, mJobs(0)
, mRequestedMetadata(requestedMetadata)
, mServerCapabilities(serverCapabilities)
, mMailboxes(mailboxes)
......@@ -172,8 +171,6 @@ void RetrieveMetadataJob::checkDone()
KolabRetrieveCollectionsTask::KolabRetrieveCollectionsTask(const ResourceStateInterface::Ptr &resource, QObject *parent)
: ResourceTask(CancelIfNoSession, resource, parent)
, mJobs(0)
, mSession(nullptr)
, cContentMimeTypes("CONTENTMIMETYPES")
, cAccessRights("AccessRights")
, cImapAcl("imapacl")
......
......@@ -42,7 +42,7 @@ private:
void applyRights(const QHash<QString, KIMAP::Acl::Rights> &rights);
void applyMetadata(const QHash<QString, QMap<QByteArray, QByteArray> > &metadata);
int mJobs;
int mJobs = 0;
QHash<QString, Akonadi::Collection> mMailCollections;
QSet<QString> mSubscribedMailboxes;
QSet<QByteArray> mRequestedMetadata;
......@@ -71,7 +71,7 @@ public:
private:
void checkDone();
int mJobs;
int mJobs = 0;
QSet<QByteArray> mRequestedMetadata;
QStringList mServerCapabilities;
QStringList mMailboxes;
......
......@@ -16,7 +16,6 @@
KolabRetrieveTagTask::KolabRetrieveTagTask(const ResourceStateInterface::Ptr &resource, RetrieveType type, QObject *parent)
: KolabRelationResourceTask(resource, parent)
, mSession(nullptr)
, mRetrieveType(type)
{
}
......
......@@ -34,7 +34,7 @@ private:
Akonadi::Tag::List mTags;
QHash<QString, Akonadi::Item::List> mTagMembers;
Akonadi::Relation::List mRelations;
RetrieveType mRetrieveType;
const RetrieveType mRetrieveType;
private Q_SLOTS:
void onFinalSelectDone(KJob *job);
......
......@@ -45,7 +45,8 @@ Note fromNote(const KMime::Message::Ptr &m)
std::vector<Kolab::Attachment> attachments;
attachments.reserve(note.attachments().count());
foreach (const Akonadi::NoteUtils::Attachment &a, note.attachments()) {
const auto noteAttachments = note.attachments();
for (const Akonadi::NoteUtils::Attachment &a : noteAttachments) {
Kolab::Attachment attachment;
if (a.url().isValid()) {
attachment.setUri(toStdString(a.url().toString()), toStdString(a.mimetype()));
......@@ -91,7 +92,8 @@ KMime::Message::Ptr toNote(const Note &n)
note.attachments().append(attachment);
}
}
foreach (const Kolab::CustomProperty &a, n.customProperties()) {
const auto customProperties = n.customProperties();
for (const Kolab::CustomProperty &a : customProperties) {
note.custom().insert(fromStdString(a.identifier), fromStdString(a.value));
}
return note.message();
......
......@@ -240,7 +240,7 @@ Freebusy aggregateFreeBusy(const std::vector< Freebusy > &fbList, const std::str
QDateTime start;
QDateTime end;
bool allDay = false;
Q_FOREACH (const Freebusy &fb, fbList) {
for (const Freebusy &fb : fbList) {
const QDateTime &tmpStart = Kolab::Conversion::toDate(fb.start());
if (!start.isValid() || tmpStart < start) {
start = tmpStart;
......
......@@ -28,7 +28,6 @@ UpdateMessageJob::UpdateMessageJob(const KMime::Message::Ptr &msg, KIMAP::Sessio
, mMailbox(mailbox)
, mUidNext(uidNext)
, mOldUid(oldUid)
, mNewUid(-1)
, mMessageId(msg->messageID()->asUnicodeString().toUtf8())
, mKolabUid(kolabUid)
, mMerger(merger)
......
......@@ -53,7 +53,7 @@ private:
qint64 mUidNext;
qint64 mOldUid;
KIMAP::ImapSet mOldUids;
qint64 mNewUid;
qint64 mNewUid = -1;
const QByteArray mMessageId;
const QByteArray mKolabUid;
QList<qint64> mFoundUids;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment