Commit 4c95dfb9 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

modernize code

parent 8835035e
Pipeline #60355 passed with stage
in 6 minutes and 47 seconds
......@@ -24,14 +24,14 @@ AlarmDialog::AlarmDialog(KCalendarCore::Incidence::IncidenceType incidenceType,
{
setWindowTitle(i18nc("@title:window", "Create a new reminder"));
auto mainLayout = new QVBoxLayout(this);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::accepted, this, &AlarmDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &AlarmDialog::reject);
QWidget *mainWidget = new QWidget(this);
auto mainWidget = new QWidget(this);
mUi->setupUi(mainWidget);
mainLayout->addWidget(mainWidget);
mainLayout->addWidget(buttonBox);
......
......@@ -37,9 +37,9 @@ AttachmentEditDialog::AttachmentEditDialog(AttachmentIconItem *item, QWidget *pa
setWindowTitle(i18nc("@title:window", "Edit Attachment"));
QMimeDatabase db;
mMimeType = db.mimeTypeForName(item->mimeType());
QWidget *page = new QWidget(this);
auto page = new QWidget(this);
auto mainLayout = new QVBoxLayout(this);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
mOkButton = buttonBox->button(QDialogButtonBox::Ok);
mOkButton->setDefault(true);
mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return);
......
......@@ -16,8 +16,8 @@ namespace IncidenceEditorNG
class AttendeeData : public KPIM::MultiplyingLineData, public KCalendarCore::Attendee
{
public:
typedef QSharedPointer<AttendeeData> Ptr;
typedef QList<AttendeeData::Ptr> List;
using Ptr = QSharedPointer<AttendeeData>;
using List = QList<AttendeeData::Ptr>;
AttendeeData(const QString &name,
const QString &email,
......
......@@ -22,7 +22,7 @@
using namespace IncidenceEditorNG;
typedef QPair<QString, QIcon> TextIconPair;
using TextIconPair = QPair<QString, QIcon>;
AttendeeComboBox::AttendeeComboBox(QWidget *parent)
: QToolButton(parent)
......
......@@ -134,11 +134,11 @@ int ConflictResolver::tryDate(QDateTime &tryFrom, QDateTime &tryTo)
int conflicts_count = 0;
for (int i = 0; i < mFBModel->rowCount(); ++i) {
QModelIndex index = mFBModel->index(i);
KCalendarCore::Attendee attendee = mFBModel->data(index, CalendarSupport::FreeBusyItemModel::AttendeeRole).value<KCalendarCore::Attendee>();
auto attendee = mFBModel->data(index, CalendarSupport::FreeBusyItemModel::AttendeeRole).value<KCalendarCore::Attendee>();
if (!matchesRoleConstraint(attendee)) {
continue;
}
KCalendarCore::FreeBusy::Ptr freebusy = mFBModel->data(index, CalendarSupport::FreeBusyItemModel::FreeBusyRole).value<KCalendarCore::FreeBusy::Ptr>();
auto freebusy = mFBModel->data(index, CalendarSupport::FreeBusyItemModel::FreeBusyRole).value<KCalendarCore::FreeBusy::Ptr>();
if (!tryDate(freebusy, tryFrom, tryTo)) {
++conflicts_count;
}
......@@ -252,11 +252,11 @@ void ConflictResolver::findAllFreeSlots()
QList<KCalendarCore::FreeBusy::Ptr> filteredFBItems;
for (int i = 0; i < mFBModel->rowCount(); ++i) {
QModelIndex index = mFBModel->index(i);
KCalendarCore::Attendee attendee = mFBModel->data(index, CalendarSupport::FreeBusyItemModel::AttendeeRole).value<KCalendarCore::Attendee>();
auto attendee = mFBModel->data(index, CalendarSupport::FreeBusyItemModel::AttendeeRole).value<KCalendarCore::Attendee>();
if (!matchesRoleConstraint(attendee)) {
continue;
}
KCalendarCore::FreeBusy::Ptr freebusy = mFBModel->data(index, CalendarSupport::FreeBusyItemModel::FreeBusyRole).value<KCalendarCore::FreeBusy::Ptr>();
auto freebusy = mFBModel->data(index, CalendarSupport::FreeBusyItemModel::FreeBusyRole).value<KCalendarCore::FreeBusy::Ptr>();
if (freebusy) {
filteredFBItems << freebusy;
}
......
......@@ -170,7 +170,7 @@ void ItemEditorPrivate::onModifyFinished(int, const Akonadi::Item &item, Akonadi
Q_EMIT q->itemSaveFinished(EditorItemManager::Modify);
setupMonitor();
} else { // There's a collection move too.
Akonadi::ItemMoveJob *moveJob = new Akonadi::ItemMoveJob(mItem, mItemUi->selectedCollection());
auto moveJob = new Akonadi::ItemMoveJob(mItem, mItemUi->selectedCollection());
q->connect(moveJob, SIGNAL(result(KJob *)), SLOT(moveJobFinished(KJob *)));
}
} else if (resultCode == Akonadi::IncidenceChanger::ResultCodeUserCanceled) {
......@@ -328,7 +328,7 @@ void EditorItemManager::save()
if (d->mItemUi->isDirty()) {
(void) d->mChanger->modifyIncidence(d->mItem, oldPayload);
} else {
Akonadi::ItemMoveJob *itemMoveJob = new Akonadi::ItemMoveJob(d->mItem, d->mItemUi->selectedCollection());
auto itemMoveJob = new Akonadi::ItemMoveJob(d->mItem, d->mItemUi->selectedCollection());
connect(itemMoveJob, SIGNAL(result(KJob *)), SLOT(itemMoveResult(KJob *)));
}
}
......
......@@ -42,8 +42,7 @@ QVariant FreeBusyGanttProxyModel::data(const QModelIndex &index, int role) const
}
// if the index is valid, then it corresponds to a free busy period
KCalendarCore::FreeBusyPeriod period =
sourceModel()->data(source_index, CalendarSupport::FreeBusyItemModel::FreeBusyPeriodRole).value<KCalendarCore::FreeBusyPeriod>();
auto period = sourceModel()->data(source_index, CalendarSupport::FreeBusyItemModel::FreeBusyPeriodRole).value<KCalendarCore::FreeBusyPeriod>();
switch (role) {
case KGantt::ItemTypeRole:
......
......@@ -29,8 +29,8 @@ FreeBusyUrlDialog::FreeBusyUrlDialog(const AttendeeData::Ptr &attendee, QWidget
setWindowTitle(i18nc("@title:window", "Edit Free/Busy Location"));
auto mainLayout = new QVBoxLayout(this);
QFrame *topFrame = new QFrame(this);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
auto topFrame = new QFrame(this);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
mainLayout->addWidget(topFrame);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
......@@ -60,7 +60,7 @@ FreeBusyUrlWidget::FreeBusyUrlWidget(const AttendeeData::Ptr &attendee, QWidget
{
QBoxLayout *topLayout = new QVBoxLayout(this);
QLabel *label = new QLabel(xi18n("Location of Free/Busy information for %1 <placeholder>%2</placeholder>:", mAttendee->name(), mAttendee->email()), this);
auto label = new QLabel(xi18n("Location of Free/Busy information for %1 <placeholder>%2</placeholder>:", mAttendee->name(), mAttendee->email()), this);
topLayout->addWidget(label);
mUrlEdit = new KLineEdit(this);
......
......@@ -75,7 +75,7 @@ void IncidenceAttachment::save(const KCalendarCore::Incidence::Ptr &incidence)
for (int itemIndex = 0; itemIndex < mAttachmentView->count(); ++itemIndex) {
QListWidgetItem *item = mAttachmentView->item(itemIndex);
auto *attitem = dynamic_cast<AttachmentIconItem *>(item);
auto attitem = dynamic_cast<AttachmentIconItem *>(item);
Q_ASSERT(item);
incidence->addAttachment(attitem->attachment());
}
......@@ -123,7 +123,7 @@ int IncidenceAttachment::attachmentCount() const
void IncidenceAttachment::addAttachment()
{
QPointer<QObject> that(this);
AttachmentIconItem *item = new AttachmentIconItem(KCalendarCore::Attachment(), mAttachmentView);
auto item = new AttachmentIconItem(KCalendarCore::Attachment(), mAttachmentView);
QPointer<AttachmentEditDialog> dialog(new AttachmentEditDialog(item, mAttachmentView));
dialog->setWindowTitle(i18nc("@title", "Add Attachment"));
......@@ -269,7 +269,7 @@ void IncidenceAttachment::showAttachment(QListWidgetItem *item)
if (att.isUri()) {
openURL(QUrl(att.uri()));
} else {
KIO::OpenUrlJob *job = new KIO::OpenUrlJob(attitem->tempFileForAttachment(), att.mimeType());
auto job = new KIO::OpenUrlJob(attitem->tempFileForAttachment(), att.mimeType());
job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, mAttachmentView));
job->setDeleteTemporaryFile(true);
job->start();
......@@ -467,7 +467,7 @@ void IncidenceAttachment::downloadComplete(KJob *)
void IncidenceAttachment::setupActions()
{
KActionCollection *ac = new KActionCollection(this);
auto ac = new KActionCollection(this);
// ac->addAssociatedWidget( this );
mOpenAction = new QAction(QIcon::fromTheme(QStringLiteral("document-open")), i18nc("@action:inmenu open the attachment in a viewer", "&Open"), this);
......@@ -532,7 +532,7 @@ void IncidenceAttachment::setupAttachmentIconView()
void IncidenceAttachment::addDataAttachment(const QByteArray &data, const QString &mimeType, const QString &label)
{
AttachmentIconItem *item = new AttachmentIconItem(KCalendarCore::Attachment(), mAttachmentView);
auto item = new AttachmentIconItem(KCalendarCore::Attachment(), mAttachmentView);
QString nlabel = label;
if (mimeType == QLatin1String("message/rfc822")) {
......@@ -558,7 +558,7 @@ void IncidenceAttachment::addDataAttachment(const QByteArray &data, const QStrin
void IncidenceAttachment::addUriAttachment(const QString &uri, const QString &mimeType, const QString &label, bool inLine)
{
if (!inLine) {
AttachmentIconItem *item = new AttachmentIconItem(KCalendarCore::Attachment(), mAttachmentView);
auto item = new AttachmentIconItem(KCalendarCore::Attachment(), mAttachmentView);
item->setUri(uri);
item->setLabel(label);
if (mimeType.isEmpty()) {
......
......@@ -433,7 +433,7 @@ void IncidenceAttendee::slotSelectAddresses()
const Akonadi::EmailAddressSelection::List list = dialog->selectedAddresses();
for (const Akonadi::EmailAddressSelection &selection : list) {
if (selection.item().hasPayload<KContacts::ContactGroup>()) {
Akonadi::ContactGroupExpandJob *job = new Akonadi::ContactGroupExpandJob(selection.item().payload<KContacts::ContactGroup>(), this);
auto job = new Akonadi::ContactGroupExpandJob(selection.item().payload<KContacts::ContactGroup>(), this);
connect(job, &Akonadi::ContactGroupExpandJob::result, this, &IncidenceAttendee::expandResult);
KCalendarCore::Attendee::PartStat partStat = KCalendarCore::Attendee::NeedsAction;
bool rsvp = true;
......@@ -478,7 +478,7 @@ void IncidenceAttendee::slotConflictResolverAttendeeChanged(const QModelIndex &t
if (AttendeeTableModel::FullName <= bottomRight.column() && AttendeeTableModel::FullName >= topLeft.column()) {
for (int i = topLeft.row(); i <= bottomRight.row(); ++i) {
QModelIndex email = dataModel()->index(i, AttendeeTableModel::Email);
KCalendarCore::Attendee attendee = dataModel()->data(email, AttendeeTableModel::AttendeeRole).value<KCalendarCore::Attendee>();
auto attendee = dataModel()->data(email, AttendeeTableModel::AttendeeRole).value<KCalendarCore::Attendee>();
if (mConflictResolver->containsAttendee(attendee)) {
mConflictResolver->removeAttendee(attendee);
}
......@@ -624,7 +624,7 @@ void IncidenceAttendee::slotGroupSubstitutionAttendeeChanged(const QModelIndex &
if (AttendeeTableModel::FullName <= bottomRight.column() && AttendeeTableModel::FullName >= topLeft.column()) {
for (int i = topLeft.row(); i <= bottomRight.row(); ++i) {
QModelIndex email = dataModel()->index(i, AttendeeTableModel::Email);
KCalendarCore::Attendee attendee = dataModel()->data(email, AttendeeTableModel::AttendeeRole).value<KCalendarCore::Attendee>();
auto attendee = dataModel()->data(email, AttendeeTableModel::AttendeeRole).value<KCalendarCore::Attendee>();
checkIfExpansionIsNeeded(attendee);
}
}
......@@ -636,7 +636,7 @@ void IncidenceAttendee::slotGroupSubstitutionAttendeeAdded(const QModelIndex &in
Q_UNUSED(index)
for (int i = first; i <= last; ++i) {
QModelIndex email = dataModel()->index(i, AttendeeTableModel::Email);
KCalendarCore::Attendee attendee = dataModel()->data(email, AttendeeTableModel::AttendeeRole).value<KCalendarCore::Attendee>();
auto attendee = dataModel()->data(email, AttendeeTableModel::AttendeeRole).value<KCalendarCore::Attendee>();
checkIfExpansionIsNeeded(attendee);
}
updateGroupExpand();
......@@ -647,7 +647,7 @@ void IncidenceAttendee::slotGroupSubstitutionAttendeeRemoved(const QModelIndex &
Q_UNUSED(index)
for (int i = first; i <= last; ++i) {
QModelIndex email = dataModel()->index(i, AttendeeTableModel::Email);
KCalendarCore::Attendee attendee = dataModel()->data(email, AttendeeTableModel::AttendeeRole).value<KCalendarCore::Attendee>();
auto attendee = dataModel()->data(email, AttendeeTableModel::AttendeeRole).value<KCalendarCore::Attendee>();
KJob *job = mMightBeGroupJobs.key(attendee.uid());
if (job) {
disconnect(job);
......@@ -690,7 +690,7 @@ void IncidenceAttendee::slotGroupSubstitutionLayoutChanged()
QModelIndex index = model->index(i, AttendeeTableModel::FullName);
if (!model->data(index).toString().isEmpty()) {
QModelIndex email = dataModel()->index(i, AttendeeTableModel::Email);
KCalendarCore::Attendee attendee = dataModel()->data(email, AttendeeTableModel::AttendeeRole).value<KCalendarCore::Attendee>();
auto attendee = dataModel()->data(email, AttendeeTableModel::AttendeeRole).value<KCalendarCore::Attendee>();
checkIfExpansionIsNeeded(attendee);
}
}
......
......@@ -129,7 +129,7 @@ void IncidenceDescription::toggleRichTextDescription()
void IncidenceDescription::setupToolBar()
{
#ifndef QT_NO_TOOLBAR
KActionCollection *collection = new KActionCollection(this);
auto collection = new KActionCollection(this);
mUi->mDescriptionEdit->richTextComposer()->createActions(collection);
auto mEditToolBar = new KToolBar(mUi->mEditToolBarPlaceHolder);
......
......@@ -10,13 +10,11 @@
#include "incidenceattendee.h"
#include "incidenceeditor-ng.h"
#include <QCompleter>
namespace Ui
{
class EventOrTodoDesktop;
}
class QCompleter;
namespace IncidenceEditorNG
{
class ResourceManagement;
......
......@@ -29,7 +29,7 @@ public:
/**
A shared pointer to an ResourceItem object.
*/
typedef QSharedPointer<ResourceItem> Ptr;
using Ptr = QSharedPointer<ResourceItem>;
ResourceItem(const KLDAP::LdapDN &dn, const QStringList &attrs, const KLDAP::LdapClient &ldapClient, const ResourceItem::Ptr &parent = ResourceItem::Ptr());
~ResourceItem() override;
......
......@@ -96,7 +96,7 @@ ResourceManagement::ResourceManagement(QWidget *parent)
: QDialog(parent)
{
setWindowTitle(i18nc("@title:window", "Resource Management"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Close, this);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Close, this);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
......@@ -107,7 +107,7 @@ ResourceManagement::ResourceManagement(QWidget *parent)
mUi = new Ui_resourceManagement;
QWidget *w = new QWidget(this);
auto w = new QWidget(this);
mUi->setupUi(w);
auto mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(w);
......@@ -179,7 +179,7 @@ void ResourceManagement::slotStartSearch(const QString &text)
void ResourceManagement::slotShowDetails(const QModelIndex &current)
{
ResourceItem::Ptr item = current.model()->data(current, ResourceModel::Resource).value<ResourceItem::Ptr>();
auto item = current.model()->data(current, ResourceModel::Resource).value<ResourceItem::Ptr>();
mSelectedItem = item;
showDetails(item->ldapObject(), item->ldapClient());
}
......
......@@ -27,9 +27,9 @@ SchedulingDialog::SchedulingDialog(const QDate &startDate, const QTime &startTim
{
setWindowTitle(i18nc("@title:window", "Scheduling"));
auto mainLayout = new QVBoxLayout(this);
QWidget *w = new QWidget(this);
auto w = new QWidget(this);
setupUi(w);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
......@@ -158,7 +158,7 @@ void SchedulingDialog::slotRowSelectionChanged(const QModelIndex &current, const
mMoveApptGroupBox->hide();
return;
}
KCalendarCore::Period period = current.data(CalendarSupport::FreePeriodModel::PeriodRole).value<KCalendarCore::Period>();
auto period = current.data(CalendarSupport::FreePeriodModel::PeriodRole).value<KCalendarCore::Period>();
const QDate startDate = period.start().date();
const int dayOfWeek = startDate.dayOfWeek();
......
......@@ -28,7 +28,7 @@ TemplateManagementDialog::TemplateManagementDialog(QWidget *parent, const QStrin
{
QString m_type_translated = i18n(qPrintable(m_type));
setWindowTitle(i18nc("@title:window", "Manage %1 Templates", m_type_translated));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, this);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, this);
auto mainLayout = new QVBoxLayout(this);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
......@@ -36,7 +36,7 @@ TemplateManagementDialog::TemplateManagementDialog(QWidget *parent, const QStrin
connect(buttonBox, &QDialogButtonBox::rejected, this, &TemplateManagementDialog::reject);
setObjectName(QStringLiteral("template_management_dialog"));
connect(buttonBox->button(QDialogButtonBox::Help), &QPushButton::clicked, this, &TemplateManagementDialog::slotHelp);
QWidget *widget = new QWidget(this);
auto widget = new QWidget(this);
mainLayout->addWidget(widget);
mainLayout->addWidget(buttonBox);
......
......@@ -136,7 +136,7 @@ VisualFreeBusyWidget::VisualFreeBusyWidget(CalendarSupport::FreeBusyItemModel *m
controlLayout->setSpacing(topLayout->spacing());
topLayout->addItem(controlLayout);
QLabel *label = new QLabel(i18nc("@label", "Scale: "), this);
auto label = new QLabel(i18nc("@label", "Scale: "), this);
controlLayout->addWidget(label);
mScaleCombo = new QComboBox(this);
......@@ -158,7 +158,7 @@ VisualFreeBusyWidget::VisualFreeBusyWidget(CalendarSupport::FreeBusyItemModel *m
connect(mScaleCombo, qOverload<int>(&QComboBox::activated), this, &VisualFreeBusyWidget::slotScaleChanged);
controlLayout->addWidget(mScaleCombo);
QPushButton *button = new QPushButton(i18nc("@action:button", "Center on Start"), this);
auto button = new QPushButton(i18nc("@action:button", "Center on Start"), this);
button->setToolTip(i18nc("@info:tooltip", "Center the Gantt chart on the event start date and time"));
button->setWhatsThis(i18nc("@info:whatsthis",
"Click this button to center the Gantt chart on the start "
......
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