Commit 2f8322e6 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code

parent bdc9adf4
Pipeline #60419 passed with stage
in 12 minutes and 49 seconds
......@@ -140,7 +140,7 @@ AlarmDialog::AlarmDialog(const Akonadi::ETMCalendar::Ptr &calendar, QWidget *par
int suspendVal = defSuspendVal;
int suspendUnit = defSuspendUnit;
QWidget *topBox = new QWidget(this);
auto topBox = new QWidget(this);
setWindowTitle(i18nc("@title:window", "Reminders"));
setWindowIcon(QIcon::fromTheme(QStringLiteral("korgac")));
auto buttonBox = new QDialogButtonBox(this);
......@@ -237,7 +237,7 @@ AlarmDialog::AlarmDialog(const Akonadi::ETMCalendar::Ptr &calendar, QWidget *par
mDetailView->hide();
mLastItem = nullptr;
QWidget *suspendBox = new QWidget(topBox);
auto suspendBox = new QWidget(topBox);
auto suspendBoxHBoxLayout = new QHBoxLayout(suspendBox);
suspendBoxHBoxLayout->setContentsMargins({});
topLayout->addWidget(suspendBox);
......@@ -281,10 +281,10 @@ AlarmDialog::AlarmDialog(const Akonadi::ETMCalendar::Ptr &calendar, QWidget *par
QDBusConnection dbusConn = QDBusConnection::sessionBus();
if (dbusConn.interface()->isServiceRegistered(QString::fromLatin1(s_fdo_notifications_service))) {
OrgFreedesktopDBusPropertiesInterface *propsIface = new OrgFreedesktopDBusPropertiesInterface(QString::fromLatin1(s_fdo_notifications_service),
QString::fromLatin1(s_fdo_notifications_path),
dbusConn,
this);
auto propsIface = new OrgFreedesktopDBusPropertiesInterface(QString::fromLatin1(s_fdo_notifications_service),
QString::fromLatin1(s_fdo_notifications_path),
dbusConn,
this);
connect(propsIface, &OrgFreedesktopDBusPropertiesInterface::PropertiesChanged, this, &AlarmDialog::slotDBusNotificationsPropertiesChanged);
}
}
......@@ -896,7 +896,7 @@ void AlarmDialog::showDetails(QTreeWidgetItem *item)
return;
}
auto *reminderItem = dynamic_cast<ReminderTreeItem *>(item);
auto reminderItem = dynamic_cast<ReminderTreeItem *>(item);
if (!reminderItem) {
mDetailView->setIncidence(Akonadi::Item());
......
......@@ -267,7 +267,7 @@ public:
const Akonadi::Collection collection = CalendarSupport::collectionFromIndex(index);
if (!collection.contentMimeTypes().isEmpty() && KOHelper::isStandardCalendar(collection.id())
&& collection.rights() & Akonadi::Collection::CanCreateItem) {
QFont font = qvariant_cast<QFont>(QSortFilterProxyModel::data(index, Qt::FontRole));
auto font = qvariant_cast<QFont>(QSortFilterProxyModel::data(index, Qt::FontRole));
font.setBold(true);
if (!mInitDefaultCalendar) {
mInitDefaultCalendar = true;
......@@ -315,7 +315,7 @@ protected:
Q_ASSERT(sourceIndex.isValid());
const Akonadi::Collection &col = sourceIndex.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
const auto *attr = col.attribute<Akonadi::CollectionIdentificationAttribute>();
const auto attr = col.attribute<Akonadi::CollectionIdentificationAttribute>();
// We filter the user folders because we insert person nodes for user folders.
if ((attr && attr->collectionNamespace().startsWith("usertoplevel")) || col.name().contains(QLatin1String("Other Users"))) {
......@@ -800,7 +800,7 @@ Akonadi::Collection::List AkonadiCollectionView::checkedCollections() const
const QModelIndexList indexes = selectionModel->selectedIndexes();
for (const QModelIndex &index : indexes) {
if (index.isValid()) {
const Akonadi::Collection collection = index.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
const auto collection = index.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
if (collection.isValid()) {
collections << collection;
}
......@@ -821,7 +821,7 @@ bool AkonadiCollectionView::isChecked(const Akonadi::Collection &collection) con
const QModelIndexList indexes = selectionModel->selectedIndexes();
for (const QModelIndex &index : indexes) {
if (index.isValid()) {
const Akonadi::Collection c = index.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
const auto c = index.data(Akonadi::EntityTreeModel::CollectionRole).value<Akonadi::Collection>();
if (c.id() == collection.id()) {
return true;
}
......@@ -850,7 +850,7 @@ void AkonadiCollectionView::onAction(const QModelIndex &index, int a)
const auto action = static_cast<StyledCalendarDelegate::Action>(a);
switch (action) {
case StyledCalendarDelegate::Quickview: {
Quickview *quickview = new Quickview(CalendarSupport::collectionFromIndex(index));
auto quickview = new Quickview(CalendarSupport::collectionFromIndex(index));
quickview->setAttribute(Qt::WA_DeleteOnClose, true);
quickview->show();
break;
......
......@@ -38,7 +38,7 @@ void KoEventPopupMenuTest::createEventFromEvent()
auto createevent = menu.findChild<QAction *>(QStringLiteral("createevent"));
createevent->trigger();
auto *dlg = menu.findChild<IncidenceEditorNG::IncidenceDialog *>(QStringLiteral("incidencedialog"));
auto dlg = menu.findChild<IncidenceEditorNG::IncidenceDialog *>(QStringLiteral("incidencedialog"));
QVERIFY(!dlg);
}
......@@ -57,7 +57,7 @@ void KoEventPopupMenuTest::createTodoFromTodo()
auto createtodo = menu.findChild<QAction *>(QStringLiteral("createtodo"));
createtodo->trigger();
auto *dlg = menu.findChild<IncidenceEditorNG::IncidenceDialog *>(QStringLiteral("incidencedialog"));
auto dlg = menu.findChild<IncidenceEditorNG::IncidenceDialog *>(QStringLiteral("incidencedialog"));
QVERIFY(!dlg);
}
......@@ -83,9 +83,9 @@ void KoEventPopupMenuTest::createEventFromTodo()
menu.showIncidencePopup(item, QDate());
auto createevent = menu.findChild<QAction *>(QStringLiteral("createevent"));
createevent->trigger();
auto *dlg = menu.findChild<IncidenceEditorNG::IncidenceDialog *>();
auto dlg = menu.findChild<IncidenceEditorNG::IncidenceDialog *>();
QVERIFY(dlg);
auto *editor = menu.findChild<IncidenceEditorNG::IncidenceEditor *>();
auto editor = menu.findChild<IncidenceEditorNG::IncidenceEditor *>();
QVERIFY(editor);
KCalendarCore::Event::Ptr event(editor->incidence<KCalendarCore::Event>());
QVERIFY(event->uid() != todo->uid());
......@@ -117,9 +117,9 @@ void KoEventPopupMenuTest::createTodoFromEvent()
menu.showIncidencePopup(item, QDate());
auto createtodo = menu.findChild<QAction *>(QStringLiteral("createtodo"));
createtodo->trigger();
auto *dlg = menu.findChild<IncidenceEditorNG::IncidenceDialog *>();
auto dlg = menu.findChild<IncidenceEditorNG::IncidenceDialog *>();
QVERIFY(dlg);
auto *editor = menu.findChild<IncidenceEditorNG::IncidenceEditor *>();
auto editor = menu.findChild<IncidenceEditorNG::IncidenceEditor *>();
QVERIFY(editor);
KCalendarCore::Todo::Ptr todo(editor->incidence<KCalendarCore::Todo>());
QVERIFY(todo->uid() != event->uid());
......
......@@ -12,7 +12,7 @@
#include <QTest>
QTEST_MAIN(KODayMatrixTest)
typedef QPair<QDate, QDate> DateRange;
using DateRange = QPair<QDate, QDate>;
void KODayMatrixTest::testMatrixLimits()
{
......
......@@ -12,7 +12,7 @@
#include <QTest>
QTEST_MAIN(KODayMatrixTest)
typedef QPair<QDate, QDate> DateRange;
using DateRange = QPair<QDate, QDate>;
void KODayMatrixTest::testMatrixLimits()
{
......
......@@ -161,7 +161,7 @@ CalendarView::CalendarView(QWidget *parent)
mEventViewer->setObjectName(QStringLiteral("EventViewer"));
mEventViewerBoxVBoxLayout->addWidget(mEventViewer);
QWidget *rightBox = new QWidget(mPanner);
auto rightBox = new QWidget(mPanner);
auto rightBoxVBoxLayout = new QVBoxLayout(rightBox);
rightBoxVBoxLayout->setContentsMargins({});
mNavigatorBar = new NavigatorBar(rightBox);
......@@ -1648,7 +1648,7 @@ void CalendarView::schedule(KCalendarCore::iTIPMethod method, const Akonadi::Ite
void CalendarView::openAddressbook()
{
KIO::CommandLauncherJob *job = new KIO::CommandLauncherJob(QStringLiteral("kaddressbook"), {}, this);
auto job = new KIO::CommandLauncherJob(QStringLiteral("kaddressbook"), {}, this);
job->setDesktopName(QStringLiteral("org.kde.kaddressbook"));
job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
job->start();
......
......@@ -77,7 +77,7 @@ void CollectionGeneralPage::init(const Akonadi::Collection &collection)
hbox->addStretch();
if ((collection.parentCollection() != Akonadi::Collection::root()) && PimCommon::Util::isImapResource(collection.resource())) {
const auto *annotationAttribute = collection.attribute<PimCommon::CollectionAnnotationsAttribute>();
const auto annotationAttribute = collection.attribute<PimCommon::CollectionAnnotationsAttribute>();
const QMap<QByteArray, QByteArray> annotations = (annotationAttribute ? annotationAttribute->annotations() : QMap<QByteArray, QByteArray>());
......@@ -140,7 +140,7 @@ void CollectionGeneralPage::save(Collection &collection)
collection.setName(mNameEdit->text());
}
auto *attr = collection.attribute<BlockAlarmsAttribute>(Collection::AddIfMissing);
auto attr = collection.attribute<BlockAlarmsAttribute>(Collection::AddIfMissing);
attr->blockEverything(mBlockAlarmsCheckBox->isChecked());
if (mIconCheckBox->isChecked()) {
......@@ -148,7 +148,7 @@ void CollectionGeneralPage::save(Collection &collection)
} else if (collection.hasAttribute<EntityDisplayAttribute>()) {
collection.attribute<EntityDisplayAttribute>()->setIconName(QString());
}
auto *annotationsAttribute = collection.attribute<PimCommon::CollectionAnnotationsAttribute>(Collection::AddIfMissing);
auto annotationsAttribute = collection.attribute<PimCommon::CollectionAnnotationsAttribute>(Collection::AddIfMissing);
QMap<QByteArray, QByteArray> annotations = annotationsAttribute->annotations();
......
......@@ -33,7 +33,7 @@ SearchDialog::SearchDialog(CalendarView *calendarview)
auto mainLayout = new QVBoxLayout(this);
QWidget *mainWidget = new QWidget(this);
auto mainWidget = new QWidget(this);
m_ui->setupUi(mainWidget);
// Set nice initial start and end dates for the search
......
......@@ -37,7 +37,7 @@ SearchCollectionHelper::SearchCollectionHelper(QObject *parent)
void SearchCollectionHelper::setupSearchCollections()
{
// Collection "Search", has always ID 1
Akonadi::CollectionFetchJob *fetchJob = new Akonadi::CollectionFetchJob(Akonadi::Collection(1), Akonadi::CollectionFetchJob::FirstLevel);
auto fetchJob = new Akonadi::CollectionFetchJob(Akonadi::Collection(1), Akonadi::CollectionFetchJob::FirstLevel);
fetchJob->fetchScope().setListFilter(Akonadi::CollectionFetchScope::NoFilter);
connect(fetchJob, &Akonadi::CollectionFetchJob::result, this, &SearchCollectionHelper::onSearchCollectionsFetched);
}
......@@ -85,8 +85,8 @@ void SearchCollectionHelper::updateSearchCollection(Akonadi::Collection col,
connect(job, &Akonadi::SearchCreateJob::result, this, &SearchCollectionHelper::createSearchJobFinished);
qCDebug(KORGANIZER_LOG) << "We have to create a " << name << " virtual Collection";
} else {
auto *attribute = col.attribute<Akonadi::PersistentSearchAttribute>(Akonadi::Collection::AddIfMissing);
auto *displayname = col.attribute<Akonadi::EntityDisplayAttribute>(Akonadi::Collection::AddIfMissing);
auto attribute = col.attribute<Akonadi::PersistentSearchAttribute>(Akonadi::Collection::AddIfMissing);
auto displayname = col.attribute<Akonadi::EntityDisplayAttribute>(Akonadi::Collection::AddIfMissing);
attribute->setQueryString(QString::fromLatin1(query.toJSON()));
attribute->setRemoteSearchEnabled(false);
displayname->setDisplayName(displayName);
......
......@@ -125,12 +125,12 @@ private:
KCMDesignerFields::KCMDesignerFields(QWidget *parent, const QVariantList &args)
: KCModule(parent, args)
{
KAboutData *about = new KAboutData(QStringLiteral("KCMDesignerfields"),
i18n("KCMDesignerfields"),
QString(),
i18n("Qt Designer Fields Dialog"),
KAboutLicense::LGPL,
i18n("(c) 2004 Tobias Koenig"));
auto about = new KAboutData(QStringLiteral("KCMDesignerfields"),
i18n("KCMDesignerfields"),
QString(),
i18n("Qt Designer Fields Dialog"),
KAboutLicense::LGPL,
i18n("(c) 2004 Tobias Koenig"));
about->addAuthor(ki18n("Tobias Koenig").toString(), QString(), QStringLiteral("tokoe@kde.org"));
about->addAuthor(ki18n("Cornelius Schumacher").toString(), QString(), QStringLiteral("schumacher@kde.org"));
setAboutData(about);
......@@ -275,7 +275,7 @@ void KCMDesignerFields::initGUI()
const QString txt = i18n(
"<qt><b>Warning:</b> Qt Designer could not be found. It is probably not "
"installed. You will only be able to import existing designer files.</qt>");
QLabel *lbl = new QLabel(txt, this);
auto lbl = new QLabel(txt, this);
layout->addWidget(lbl);
}
......@@ -289,7 +289,7 @@ void KCMDesignerFields::initGUI()
mPageView->header()->setSectionResizeMode(QHeaderView::Stretch);
hbox->addWidget(mPageView);
QGroupBox *box = new QGroupBox(i18n("Preview of Selected Page"), this);
auto box = new QGroupBox(i18n("Preview of Selected Page"), this);
auto boxLayout = new QVBoxLayout(box);
mPagePreview = new QLabel(box);
......@@ -438,7 +438,7 @@ void KCMDesignerFields::startDesigner()
args.append(pageItem->path());
}
KIO::CommandLauncherJob *job = new KIO::CommandLauncherJob(QStringLiteral("designer"), args, this);
auto job = new KIO::CommandLauncherJob(QStringLiteral("designer"), args, this);
job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
job->start();
}
......
......@@ -612,7 +612,7 @@ void KODayMatrix::dropEvent(QDropEvent *e)
if (urls.count() >= 1) {
QUrl res = urls.at(0);
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(Akonadi::Item::fromUrl(res));
auto job = new Akonadi::ItemFetchJob(Akonadi::Item::fromUrl(res));
job->fetchScope().setAncestorRetrieval(Akonadi::ItemFetchScope::Parent);
job->fetchScope().fetchFullPayload();
Akonadi::Item::List items;
......
......@@ -45,7 +45,7 @@ KOEventView::~KOEventView()
KOEventPopupMenu *KOEventView::eventPopup()
{
KOEventPopupMenu *eventPopup = new KOEventPopupMenu(calendar(), this);
auto eventPopup = new KOEventPopupMenu(calendar(), this);
connect(eventPopup, &KOEventPopupMenu::editIncidenceSignal, this, &KOEventView::editIncidenceSignal);
connect(eventPopup, &KOEventPopupMenu::showIncidenceSignal, this, &KOEventView::showIncidenceSignal);
......
......@@ -206,7 +206,7 @@ void ApptSummaryWidget::updateView()
qDeleteAll(events);
if (!counter) {
QLabel *noEvents =
auto noEvents =
new QLabel(i18np("No upcoming events starting within the next day", "No upcoming events starting within the next %1 days", mDaysAhead), this);
noEvents->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
mLayout->addWidget(noEvents, 0, 0);
......
......@@ -25,7 +25,7 @@ JournalPlugin::JournalPlugin(KontactInterface::Core *core, const QVariantList &)
{
setComponentName(QStringLiteral("korganizer"), i18n("KOrganizer"));
QAction *action = new QAction(QIcon::fromTheme(QStringLiteral("journal-new")), i18nc("@action:inmenu", "New Journal..."), this);
auto action = new QAction(QIcon::fromTheme(QStringLiteral("journal-new")), i18nc("@action:inmenu", "New Journal..."), this);
actionCollection()->addAction(QStringLiteral("new_journal"), action);
actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_J));
QString str = i18nc("@info:status", "Create a new journal");
......
......@@ -149,13 +149,13 @@ void KCMApptSummary::defaults()
const KAboutData *KCMApptSummary::aboutData() const
{
KAboutData *about = new KAboutData(QStringLiteral("kcmapptsummary"),
i18n("Upcoming Events Configuration Dialog"),
QString(),
QString(),
KAboutLicense::GPL,
i18n("Copyright © 2003–2004 Tobias Koenig\n"
"Copyright © 2005–2010 Allen Winter"));
auto about = new KAboutData(QStringLiteral("kcmapptsummary"),
i18n("Upcoming Events Configuration Dialog"),
QString(),
QString(),
KAboutLicense::GPL,
i18n("Copyright © 2003–2004 Tobias Koenig\n"
"Copyright © 2005–2010 Allen Winter"));
about->addAuthor(i18n("Tobias Koenig"), QString(), QStringLiteral("tokoe@kde.org"));
about->addAuthor(i18n("Allen Winter"), QString(), QStringLiteral("winter@kde.org"));
......
......@@ -138,13 +138,13 @@ void KCMTodoSummary::defaults()
const KAboutData *KCMTodoSummary::aboutData() const
{
KAboutData *about = new KAboutData(QStringLiteral("kcmtodosummary"),
i18n("Pending To-dos Configuration Dialog"),
QString(),
QString(),
KAboutLicense::GPL,
i18n("Copyright © 2003–2004 Tobias Koenig\n"
"Copyright © 2005–2010 Allen Winter"));
auto about = new KAboutData(QStringLiteral("kcmtodosummary"),
i18n("Pending To-dos Configuration Dialog"),
QString(),
QString(),
KAboutLicense::GPL,
i18n("Copyright © 2003–2004 Tobias Koenig\n"
"Copyright © 2005–2010 Allen Winter"));
about->addAuthor(i18n("Tobias Koenig"), QString(), QStringLiteral("tokoe@kde.org"));
about->addAuthor(i18n("Allen Winter"), QString(), QStringLiteral("winter@kde.org"));
......
......@@ -36,7 +36,7 @@ KOrganizerPlugin::KOrganizerPlugin(KontactInterface::Core *core, const QVariantL
{
setComponentName(QStringLiteral("korganizer"), i18n("KOrganizer"));
QAction *action = new QAction(QIcon::fromTheme(QStringLiteral("appointment-new")), i18nc("@action:inmenu", "New Event..."), this);
auto action = new QAction(QIcon::fromTheme(QStringLiteral("appointment-new")), i18nc("@action:inmenu", "New Event..."), this);
actionCollection()->addAction(QStringLiteral("new_event"), action);
actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_E));
const QString str = i18nc("@info:status", "Create a new event");
......
......@@ -28,7 +28,7 @@ using namespace KCalUtils;
bool SummaryEventInfo::mShowBirthdays = true;
bool SummaryEventInfo::mShowAnniversaries = true;
typedef QHash<QString, QDateTime> DateTimeByUidHash;
using DateTimeByUidHash = QHash<QString, QDateTime>;
Q_GLOBAL_STATIC(DateTimeByUidHash, sDateTimeByUid)
static bool eventLessThan(const KCalendarCore::Event::Ptr &event1, const KCalendarCore::Event::Ptr &event2)
......
......@@ -35,7 +35,7 @@ TodoPlugin::TodoPlugin(KontactInterface::Core *core, const QVariantList &)
{
setComponentName(QStringLiteral("korganizer"), i18n("KOrganizer"));
QAction *action = new QAction(QIcon::fromTheme(QStringLiteral("task-new")), i18nc("@action:inmenu", "New To-do..."), this);
auto action = new QAction(QIcon::fromTheme(QStringLiteral("task-new")), i18nc("@action:inmenu", "New To-do..."), this);
actionCollection()->addAction(QStringLiteral("new_todo"), action);
actionCollection()->setDefaultShortcut(action, QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_T));
QString str = i18nc("@info:status", "Create a new to-do");
......
......@@ -155,13 +155,13 @@ void KCMSDSummary::defaults()
const KAboutData *KCMSDSummary::aboutData() const
{
KAboutData *about = new KAboutData(QStringLiteral("kcmsdsummary"),
i18n("Upcoming Special Dates Configuration Dialog"),
QString(),
QString(),
KAboutLicense::GPL,
i18n("Copyright © 2004 Tobias Koenig\n"
"Copyright © 2004–2010 Allen Winter"));
auto about = new KAboutData(QStringLiteral("kcmsdsummary"),
i18n("Upcoming Special Dates Configuration Dialog"),
QString(),
QString(),
KAboutLicense::GPL,
i18n("Copyright © 2004 Tobias Koenig\n"
"Copyright © 2004–2010 Allen Winter"));
about->addAuthor(i18n("Tobias Koenig"), QString(), QStringLiteral("tokoe@kde.org"));
about->addAuthor(i18n("Allen Winter"), QString(), QStringLiteral("winter@kde.org"));
......
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