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

run git clang-format

parent 50b23328
......@@ -9,17 +9,17 @@
#include "widgets/unitcombobox.h"
#include <MailCommon/FolderRequester>
#include <KLocalizedString>
#include <KUrlRequester>
#include <KLineEdit>
#include <QSpinBox>
#include <KLocalizedString>
#include <KSeparator>
#include <KUrlRequester>
#include <QIcon>
#include <QSpinBox>
#include <QGridLayout>
#include <QLabel>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QGridLayout>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
......@@ -49,7 +49,7 @@ AddArchiveMailDialog::AddArchiveMailDialog(ArchiveMailInfo *info, QWidget *paren
mFolderRequester->setMustBeReadWrite(false);
mFolderRequester->setNotAllowToCreateNewFolder(true);
connect(mFolderRequester, &MailCommon::FolderRequester::folderChanged, this, &AddArchiveMailDialog::slotFolderChanged);
if (info) { //Don't autorize to modify folder when we just modify item.
if (info) { // Don't autorize to modify folder when we just modify item.
mFolderRequester->setEnabled(false);
}
folderLabel->setBuddy(mFolderRequester);
......@@ -129,8 +129,7 @@ AddArchiveMailDialog::AddArchiveMailDialog(ArchiveMailInfo *info, QWidget *paren
resize(500, minimumSize().height());
}
AddArchiveMailDialog::~AddArchiveMailDialog()
= default;
AddArchiveMailDialog::~AddArchiveMailDialog() = default;
void AddArchiveMailDialog::load(ArchiveMailInfo *info)
{
......
......@@ -7,10 +7,10 @@
#ifndef ADDARCHIVEMAILDIALOG_H
#define ADDARCHIVEMAILDIALOG_H
#include <MailCommon/BackupJob>
#include "archivemailinfo.h"
#include <QDialog>
#include <Collection>
#include <MailCommon/BackupJob>
#include <QDialog>
class QUrl;
class QCheckBox;
class KUrlRequester;
......@@ -19,7 +19,8 @@ class QPushButton;
class FormatComboBox;
class UnitComboBox;
namespace MailCommon {
namespace MailCommon
{
class FolderRequester;
}
......
......@@ -6,17 +6,17 @@
#include "archivemailagent.h"
#include "archivemailagentadaptor.h"
#include "archivemailmanager.h"
#include "archivemailagentsettings.h"
#include "archivemailmanager.h"
#include <AkonadiCore/ServerManager>
#include <MailCommon/MailKernel>
#include <QDBusConnection>
#include <Monitor>
#include <Session>
#include <CollectionFetchScope>
#include <KMime/Message>
#include <MailCommon/MailKernel>
#include <Monitor>
#include <QDBusConnection>
#include <QTimer>
#include <Session>
#include <Kdelibs4ConfigMigrator>
......@@ -62,8 +62,7 @@ ArchiveMailAgent::ArchiveMailAgent(const QString &id)
mTimer->start(24 * 60 * 60 * 1000);
}
ArchiveMailAgent::~ArchiveMailAgent()
= default;
ArchiveMailAgent::~ArchiveMailAgent() = default;
void ArchiveMailAgent::setEnableAgent(bool enabled)
{
......
......@@ -10,7 +10,8 @@
#include "archivemailinfo.h"
#include <QDate>
namespace ArchiveMailAgentUtil {
namespace ArchiveMailAgentUtil
{
static QString archivePattern = QStringLiteral("ArchiveMailCollection %1");
Q_REQUIRED_RESULT QDate diffDate(ArchiveMailInfo *info);
Q_REQUIRED_RESULT bool needToArchive(ArchiveMailInfo *info);
......
......@@ -5,12 +5,11 @@
*/
#include "archivemailinfo.h"
#include <KLocalizedString>
#include "archivemailagent_debug.h"
#include <KLocalizedString>
#include <QDir>
ArchiveMailInfo::ArchiveMailInfo()
= default;
ArchiveMailInfo::ArchiveMailInfo() = default;
ArchiveMailInfo::ArchiveMailInfo(const KConfigGroup &config)
{
......@@ -30,8 +29,7 @@ ArchiveMailInfo::ArchiveMailInfo(const ArchiveMailInfo &info)
mIsEnabled = info.isEnabled();
}
ArchiveMailInfo::~ArchiveMailInfo()
= default;
ArchiveMailInfo::~ArchiveMailInfo() = default;
ArchiveMailInfo &ArchiveMailInfo::operator=(const ArchiveMailInfo &old)
{
......@@ -72,12 +70,11 @@ QUrl ArchiveMailInfo::realUrl(const QString &folderName, bool &dirExist) const
{
const int numExtensions = 4;
// The extensions here are also sorted, like the enum order of BackupJob::ArchiveType
const char *extensions[numExtensions] = { ".zip", ".tar", ".tar.bz2", ".tar.gz" };
const char *extensions[numExtensions] = {".zip", ".tar", ".tar.bz2", ".tar.gz"};
const QString dirPath = dirArchive(dirExist);
const QString path = dirPath + QLatin1Char('/') + i18nc("Start of the filename for a mail archive file", "Archive")
+ QLatin1Char('_') + normalizeFolderName(folderName) + QLatin1Char('_')
+ QDate::currentDate().toString(Qt::ISODate) + QString::fromLatin1(extensions[mArchiveType]);
const QString path = dirPath + QLatin1Char('/') + i18nc("Start of the filename for a mail archive file", "Archive") + QLatin1Char('_')
+ normalizeFolderName(folderName) + QLatin1Char('_') + QDate::currentDate().toString(Qt::ISODate) + QString::fromLatin1(extensions[mArchiveType]);
QUrl real(QUrl::fromLocalFile(path));
return real;
}
......@@ -86,14 +83,14 @@ QStringList ArchiveMailInfo::listOfArchive(const QString &folderName, bool &dirE
{
const int numExtensions = 4;
// The extensions here are also sorted, like the enum order of BackupJob::ArchiveType
const char *extensions[numExtensions] = { ".zip", ".tar", ".tar.bz2", ".tar.gz" };
const char *extensions[numExtensions] = {".zip", ".tar", ".tar.bz2", ".tar.gz"};
const QString dirPath = dirArchive(dirExist);
QDir dir(dirPath);
QStringList nameFilters;
nameFilters << i18nc("Start of the filename for a mail archive file", "Archive") + QLatin1Char('_')
+normalizeFolderName(folderName) + QLatin1Char('_') + QLatin1String("*") + QString::fromLatin1(extensions[mArchiveType]);
nameFilters << i18nc("Start of the filename for a mail archive file", "Archive") + QLatin1Char('_') + normalizeFolderName(folderName) + QLatin1Char('_')
+ QLatin1String("*") + QString::fromLatin1(extensions[mArchiveType]);
const QStringList lst = dir.entryList(nameFilters, QDir::Files | QDir::NoDotAndDotDot, QDir::Time | QDir::Reversed);
return lst;
}
......@@ -235,13 +232,7 @@ void ArchiveMailInfo::setEnabled(bool b)
bool ArchiveMailInfo::operator==(const ArchiveMailInfo &other) const
{
return saveCollectionId() == other.saveCollectionId()
&& saveSubCollection() == other.saveSubCollection()
&& url() == other.url()
&& archiveType() == other.archiveType()
&& archiveUnit() == other.archiveUnit()
&& archiveAge() == other.archiveAge()
&& lastDateSaved() == other.lastDateSaved()
&& maximumArchiveCount() == other.maximumArchiveCount()
&& isEnabled() == other.isEnabled();
return saveCollectionId() == other.saveCollectionId() && saveSubCollection() == other.saveSubCollection() && url() == other.url()
&& archiveType() == other.archiveType() && archiveUnit() == other.archiveUnit() && archiveAge() == other.archiveAge()
&& lastDateSaved() == other.lastDateSaved() && maximumArchiveCount() == other.maximumArchiveCount() && isEnabled() == other.isEnabled();
}
......@@ -6,11 +6,11 @@
#ifndef ARCHIVEMAILINFO_H
#define ARCHIVEMAILINFO_H
#include <MailCommon/BackupJob>
#include <KConfigGroup>
#include <Collection>
#include <QUrl>
#include <KConfigGroup>
#include <MailCommon/BackupJob>
#include <QDate>
#include <QUrl>
class ArchiveMailInfo
{
......@@ -22,12 +22,7 @@ public:
ArchiveMailInfo &operator=(const ArchiveMailInfo &old);
enum ArchiveUnit {
ArchiveDays = 0,
ArchiveWeeks,
ArchiveMonths,
ArchiveYears
};
enum ArchiveUnit { ArchiveDays = 0, ArchiveWeeks, ArchiveMonths, ArchiveYears };
Q_REQUIRED_RESULT QUrl realUrl(const QString &folderName, bool &dirExist) const;
......@@ -65,7 +60,7 @@ public:
Q_REQUIRED_RESULT bool isEnabled() const;
void setEnabled(bool b);
Q_REQUIRED_RESULT bool operator ==(const ArchiveMailInfo &other) const;
Q_REQUIRED_RESULT bool operator==(const ArchiveMailInfo &other) const;
private:
QString dirArchive(bool &dirExit) const;
......
......@@ -6,14 +6,14 @@
#include "archivemailkernel.h"
#include <AkonadiCore/changerecorder.h>
#include <AkonadiCore/entitymimetypefiltermodel.h>
#include <AkonadiCore/entitytreemodel.h>
#include <AkonadiCore/session.h>
#include <KIdentityManagement/kidentitymanagement/identitymanager.h>
#include <KSharedConfig>
#include <MailCommon/FolderCollectionMonitor>
#include <MailCommon/JobScheduler>
#include <AkonadiCore/session.h>
#include <AkonadiCore/entitytreemodel.h>
#include <AkonadiCore/entitymimetypefiltermodel.h>
#include <AkonadiCore/changerecorder.h>
#include <KSharedConfig>
ArchiveMailKernel::ArchiveMailKernel(QObject *parent)
: QObject(parent)
......
......@@ -9,12 +9,14 @@
#include <MailCommon/MailInterfaces>
namespace Akonadi {
namespace Akonadi
{
class EntityTreeModel;
class EntityMimeTypeFilterModel;
}
namespace MailCommon {
namespace MailCommon
{
class FolderCollectionMonitor;
class JobScheduler;
}
......
......@@ -5,16 +5,16 @@
*/
#include "archivemailmanager.h"
#include "archivemailagentutil.h"
#include "archivemailinfo.h"
#include "job/archivejob.h"
#include "archivemailkernel.h"
#include "archivemailagentutil.h"
#include "job/archivejob.h"
#include <MailCommon/MailKernel>
#include <MailCommon/MailUtil>
#include <KConfigGroup>
#include "archivemailagent_debug.h"
#include <KConfigGroup>
#include <QDate>
#include <QFile>
......@@ -24,8 +24,8 @@ ArchiveMailManager::ArchiveMailManager(QObject *parent)
: QObject(parent)
{
mArchiveMailKernel = ArchiveMailKernel::self();
CommonKernel->registerKernelIf(mArchiveMailKernel); //register KernelIf early, it is used by the Filter classes
CommonKernel->registerSettingsIf(mArchiveMailKernel); //SettingsIf is used in FolderTreeWidget
CommonKernel->registerKernelIf(mArchiveMailKernel); // register KernelIf early, it is used by the Filter classes
CommonKernel->registerSettingsIf(mArchiveMailKernel); // SettingsIf is used in FolderTreeWidget
mConfig = KSharedConfig::openConfig();
}
......@@ -48,14 +48,14 @@ void ArchiveMailManager::load()
if (ArchiveMailAgentUtil::needToArchive(info)) {
for (ArchiveMailInfo *oldInfo : qAsConst(mListArchiveInfo)) {
if (oldInfo->saveCollectionId() == info->saveCollectionId()) {
//already in jobscheduler
// already in jobscheduler
delete info;
info = nullptr;
break;
}
}
if (info) {
//Store task started
// Store task started
mListArchiveInfo.append(info);
auto task = new ScheduledArchiveTask(this, info, Akonadi::Collection(info->saveCollectionId()), /*immediate*/ false);
mArchiveMailKernel->jobScheduler()->registerTask(task);
......@@ -92,7 +92,7 @@ void ArchiveMailManager::backupDone(ArchiveMailInfo *info)
{
info->setLastDateSaved(QDate::currentDate());
const QString groupname = ArchiveMailAgentUtil::archivePattern.arg(info->saveCollectionId());
//Don't store it if we removed this task
// Don't store it if we removed this task
if (mConfig->hasGroup(groupname)) {
KConfigGroup group = mConfig->group(groupname);
info->writeConfig(group);
......
......@@ -9,8 +9,8 @@
#include <QObject>
#include <KSharedConfig>
#include <Collection>
#include <KSharedConfig>
class ArchiveMailKernel;
class ArchiveMailInfo;
......
......@@ -9,23 +9,24 @@
#include "archivemailagentutil.h"
#include "archivemailkernel.h"
#include <KIO/OpenUrlJob>
#include <KIO/JobUiDelegate>
#include <KIO/OpenUrlJob>
#include "kmail-version.h"
#include <MailCommon/MailUtil>
#include <MailCommon/MailKernel>
#include <MailCommon/MailUtil>
#include <QLocale>
#include <KLocalizedString>
#include <KSharedConfig>
#include <KAboutData>
#include <KConfigGroup>
#include <KLocalizedString>
#include <KMessageBox>
#include <KSharedConfig>
#include <QLocale>
#include <QMenu>
#include <KAboutData>
namespace {
namespace
{
inline QString archiveMailCollectionPattern()
{
return QStringLiteral("ArchiveMailCollection \\d+");
......@@ -58,8 +59,8 @@ ArchiveMailWidget::ArchiveMailWidget(const KSharedConfigPtr &config, QWidget *pa
: Akonadi::AgentConfigurationBase(config, parent, args)
{
ArchiveMailKernel *archiveMailKernel = ArchiveMailKernel::self();
CommonKernel->registerKernelIf(archiveMailKernel); //register KernelIf early, it is used by the Filter classes
CommonKernel->registerSettingsIf(archiveMailKernel); //SettingsIf is used in FolderTreeWidget
CommonKernel->registerKernelIf(archiveMailKernel); // register KernelIf early, it is used by the Filter classes
CommonKernel->registerSettingsIf(archiveMailKernel); // SettingsIf is used in FolderTreeWidget
auto w = new QWidget(parent);
mWidget.setupUi(w);
......@@ -74,8 +75,7 @@ ArchiveMailWidget::ArchiveMailWidget(const KSharedConfigPtr &config, QWidget *pa
mWidget.treeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
mWidget.treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(mWidget.treeWidget, &QWidget::customContextMenuRequested,
this, &ArchiveMailWidget::slotCustomContextMenuRequested);
connect(mWidget.treeWidget, &QWidget::customContextMenuRequested, this, &ArchiveMailWidget::slotCustomContextMenuRequested);
connect(mWidget.removeItem, &QAbstractButton::clicked, this, &ArchiveMailWidget::slotRemoveItem);
connect(mWidget.modifyItem, &QAbstractButton::clicked, this, &ArchiveMailWidget::slotModifyItem);
......@@ -85,23 +85,19 @@ ArchiveMailWidget::ArchiveMailWidget(const KSharedConfigPtr &config, QWidget *pa
connect(mWidget.treeWidget, &QTreeWidget::itemDoubleClicked, this, &ArchiveMailWidget::slotModifyItem);
updateButtons();
KAboutData aboutData(
QStringLiteral("archivemailagent"),
i18n("Archive Mail Agent"),
QStringLiteral(KDEPIM_VERSION),
i18n("Archive emails automatically."),
KAboutLicense::GPL_V2,
i18n("Copyright (C) 2014-2020 Laurent Montel"));
aboutData.addAuthor(i18n("Laurent Montel"),
i18n("Maintainer"), QStringLiteral("montel@kde.org"));
aboutData.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"),
i18nc("EMAIL OF TRANSLATORS", "Your emails"));
KAboutData aboutData(QStringLiteral("archivemailagent"),
i18n("Archive Mail Agent"),
QStringLiteral(KDEPIM_VERSION),
i18n("Archive emails automatically."),
KAboutLicense::GPL_V2,
i18n("Copyright (C) 2014-2020 Laurent Montel"));
aboutData.addAuthor(i18n("Laurent Montel"), i18n("Maintainer"), QStringLiteral("montel@kde.org"));
aboutData.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"), i18nc("EMAIL OF TRANSLATORS", "Your emails"));
setKAboutData(aboutData);
}
ArchiveMailWidget::~ArchiveMailWidget()
= default;
ArchiveMailWidget::~ArchiveMailWidget() = default;
void ArchiveMailWidget::slotCustomContextMenuRequested(const QPoint &)
{
......@@ -135,7 +131,7 @@ void ArchiveMailWidget::updateButtons()
void ArchiveMailWidget::needReloadConfig()
{
//TODO add messagebox which informs that we save settings here.
// TODO add messagebox which informs that we save settings here.
mWidget.treeWidget->clear();
load();
}
......
......@@ -7,8 +7,8 @@
#ifndef ARCHIVEMAILWIDGET_H
#define ARCHIVEMAILWIDGET_H
#include "ui_archivemailwidget.h"
#include "archivemailinfo.h"
#include "ui_archivemailwidget.h"
#include <QTreeWidgetItem>
#include <AkonadiCore/AgentConfigurationBase>
......@@ -33,12 +33,7 @@ public:
explicit ArchiveMailWidget(const KSharedConfigPtr &config, QWidget *parentWidget, const QVariantList &args);
~ArchiveMailWidget() override;
enum ArchiveMailColumn {
Name = 0,
LastArchiveDate,
NextArchive,
StorageDirectory
};
enum ArchiveMailColumn { Name = 0, LastArchiveDate, NextArchive, StorageDirectory };
Q_REQUIRED_RESULT bool save() const override;
void load() override;
......
......@@ -7,10 +7,10 @@
#include "archivemailinfotest.h"
#include "../archivemailinfo.h"
#include <AkonadiCore/Collection>
#include <QTest>
#include <KConfigGroup>
#include <KSharedConfig>
#include <QStandardPaths>
#include <QTest>
ArchiveMailInfoTest::ArchiveMailInfoTest(QObject *parent)
: QObject(parent)
......@@ -18,8 +18,7 @@ ArchiveMailInfoTest::ArchiveMailInfoTest(QObject *parent)
QStandardPaths::setTestModeEnabled(true);
}
ArchiveMailInfoTest::~ArchiveMailInfoTest()
= default;
ArchiveMailInfoTest::~ArchiveMailInfoTest() = default;
void ArchiveMailInfoTest::shouldHaveDefaultValue()
{
......
......@@ -7,9 +7,9 @@
#include "archivemailwidgettest.h"
#include "../archivemailwidget.h"
#include <QStandardPaths>
#include <QTest>
#include <QTreeWidget>
#include <QStandardPaths>
ArchiveMailWidgetTest::ArchiveMailWidgetTest(QObject *parent)
: QObject(parent)
......@@ -17,8 +17,7 @@ ArchiveMailWidgetTest::ArchiveMailWidgetTest(QObject *parent)
QStandardPaths::setTestModeEnabled(true);
}
ArchiveMailWidgetTest::~ArchiveMailWidgetTest()
= default;
ArchiveMailWidgetTest::~ArchiveMailWidgetTest() = default;
void ArchiveMailWidgetTest::shouldHaveDefaultValue()
{
......
......@@ -5,16 +5,15 @@
*/
#include "formatcomboboxtest.h"
#include <QTest>
#include "../widgets/formatcombobox.h"
#include <QTest>
FormatComboBoxTest::FormatComboBoxTest(QObject *parent)
: QObject(parent)
{
}
FormatComboBoxTest::~FormatComboBoxTest()
= default;
FormatComboBoxTest::~FormatComboBoxTest() = default;
void FormatComboBoxTest::shouldHaveDefaultValue()
{
......@@ -26,11 +25,11 @@ void FormatComboBoxTest::changeCurrentItem_data()
{
QTest::addColumn<int>("input");
QTest::addColumn<int>("output");
QTest::newRow("first") << 0 << 0;
QTest::newRow("second") << 1 << 1;
QTest::newRow("third") << 2 << 2;
QTest::newRow("fourth") << 3 << 3;
QTest::newRow("invalid") << 5 << 0;
QTest::newRow("first") << 0 << 0;
QTest::newRow("second") << 1 << 1;
QTest::newRow("third") << 2 << 2;
QTest::newRow("fourth") << 3 << 3;
QTest::newRow("invalid") << 5 << 0;
}
void FormatComboBoxTest::changeCurrentItem()
......
......@@ -13,8 +13,7 @@ UnitComboBoxTest::UnitComboBoxTest(QObject *parent)
{
}
UnitComboBoxTest::~UnitComboBoxTest()
= default;
UnitComboBoxTest::~UnitComboBoxTest() = default;
void UnitComboBoxTest::shouldHaveDefaultValue()
{
......@@ -26,11 +25,11 @@ void UnitComboBoxTest::changeCurrentItem_data()
{
QTest::addColumn<int>("input");
QTest::addColumn<int>("output");
QTest::newRow("first") << 0 << 0;
QTest::newRow("second") << 1 << 1;
QTest::newRow("third") << 2 << 2;
QTest::newRow("fourth") << 3 << 3;
QTest::newRow("invalid") << 5 << 0;
QTest::newRow("first") << 0 << 0;
QTest::newRow("second") << 1 << 1;
QTest::newRow("third") << 2 << 2;
QTest::newRow("fourth") << 3 << 3;
QTest::newRow("invalid") << 5 << 0;
}
void UnitComboBoxTest::changeCurrentItem()
......
......@@ -5,18 +5,18 @@
*/
#include "archivejob.h"
#include "archivemailagent_debug.h"
#include "archivemailinfo.h"
#include "archivemailmanager.h"
#include "archivemailkernel.h"
#include "archivemailagent_debug.h"
#include "archivemailmanager.h"
#include <MailCommon/MailUtil>
#include <MailCommon/BackupJob>
#include <MailCommon/MailUtil>
#include <AkonadiCore/EntityMimeTypeFilterModel>
#include <KNotification>
#include <KLocalizedString>
#include <KNotification>
ArchiveJob::ArchiveJob(ArchiveMailManager *manager, ArchiveMailInfo *info, const Akonadi::Collection &folder, bool immediate)
: MailCommon::ScheduledJob(folder, immediate)
......
......@@ -7,8 +7,8 @@
#ifndef ARCHIVEJOB_H
#define ARCHIVEJOB_H