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

Modernize code

parent 43865949
Pipeline #39288 passed with stage
in 16 minutes and 25 seconds
......@@ -96,15 +96,15 @@ void KCMAkonadiContactActions::load()
{
mConfigManager->updateWidgets();
ContactActionsSettings::EnumShowAddressAction enumValueAddress = static_cast<ContactActionsSettings::EnumShowAddressAction>(ContactActionsSettings::self()->showAddressAction());
auto enumValueAddress = static_cast<ContactActionsSettings::EnumShowAddressAction>(ContactActionsSettings::self()->showAddressAction());
const int indexAddress = ui.ShowAddressAction->findData(enumValueAddress);
ui.ShowAddressAction->setCurrentIndex(indexAddress);
ContactActionsSettings::EnumDialPhoneNumberAction enumValue = static_cast<ContactActionsSettings::EnumDialPhoneNumberAction>(ContactActionsSettings::self()->dialPhoneNumberAction());
auto enumValue = static_cast<ContactActionsSettings::EnumDialPhoneNumberAction>(ContactActionsSettings::self()->dialPhoneNumberAction());
const int index = ui.DialPhoneNumberAction->findData(enumValue);
ui.DialPhoneNumberAction->setCurrentIndex(index);
ContactActionsSettings::EnumSendSmsAction enumValueSms = static_cast<ContactActionsSettings::EnumSendSmsAction>(ContactActionsSettings::self()->sendSmsAction());
auto enumValueSms = static_cast<ContactActionsSettings::EnumSendSmsAction>(ContactActionsSettings::self()->sendSmsAction());
const int indexSms = ui.SendSmsAction->findData(enumValueSms);
ui.SendSmsAction->setCurrentIndex(indexSms);
}
......
......@@ -99,10 +99,10 @@ void SerializerPluginContactGroup::compare(Akonadi::AbstractDifferencesReporter
}
// using job->exec() is ok here, not a hot path
Akonadi::ContactGroupExpandJob *leftJob = new Akonadi::ContactGroupExpandJob(leftContactGroup);
auto *leftJob = new Akonadi::ContactGroupExpandJob(leftContactGroup);
leftJob->exec();
Akonadi::ContactGroupExpandJob *rightJob = new Akonadi::ContactGroupExpandJob(rightContactGroup);
auto *rightJob = new Akonadi::ContactGroupExpandJob(rightContactGroup);
rightJob->exec();
compareVector(reporter, i18n("Member"), leftJob->contacts(), rightJob->contacts());
......
......@@ -67,7 +67,7 @@ void DialPhoneNumberAction::dialNumber(const KContacts::PhoneNumber &number)
command.replace(QLatin1String("%N"), number.number());
command.replace(QLatin1String("%n"), number.normalizedNumber());
KIO::CommandLauncherJob *job = new KIO::CommandLauncherJob(command);
auto *job = new KIO::CommandLauncherJob(command);
job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, nullptr));
job->start();
......
......@@ -85,7 +85,7 @@ void SendSmsAction::sendSms(const KContacts::PhoneNumber &phoneNumber)
//Bug: 293232 In KDE3 We used %F to replace text
command.replace(QLatin1String("%F"), message);
KIO::CommandLauncherJob *job = new KIO::CommandLauncherJob(command);
auto *job = new KIO::CommandLauncherJob(command);
job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, nullptr));
job->start();
}
......@@ -44,7 +44,7 @@ void ShowAddressAction::showAddress(const KContacts::Address &address)
replaceArguments(commandTemplate, address);
if (!commandTemplate.isEmpty()) {
KIO::CommandLauncherJob *job = new KIO::CommandLauncherJob(commandTemplate);
auto *job = new KIO::CommandLauncherJob(commandTemplate);
job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, nullptr));
job->start();
}
......
......@@ -36,7 +36,7 @@ void SmsDialog::initUI()
{
setWindowTitle(i18nc("@title:window", "SMS text"));
QVBoxLayout *topLayout = new QVBoxLayout(this);
auto *topLayout = new QVBoxLayout(this);
QLabel *label = new QLabel(i18n("Please insert SMS text for an SMS to the following number: %1", mNumber), this);
topLayout->addWidget(label);
......
......@@ -46,7 +46,7 @@ QByteArray ContactMetaDataAttribute::type() const
Attribute *ContactMetaDataAttribute::clone() const
{
ContactMetaDataAttribute *copy = new ContactMetaDataAttribute;
auto *copy = new ContactMetaDataAttribute;
copy->setMetaData(d->mData);
return copy;
......
......@@ -37,7 +37,7 @@ void ContactMetaDataAttributeTest::clone()
Akonadi::ContactMetaDataAttribute attribute1;
attribute1.setMetaData(content1);
Akonadi::ContactMetaDataAttribute *attribute2 = static_cast<Akonadi::ContactMetaDataAttribute *>(attribute1.clone());
auto *attribute2 = static_cast<Akonadi::ContactMetaDataAttribute *>(attribute1.clone());
const QVariantMap content2 = attribute2->metaData();
QVERIFY(content1 == content2);
......
......@@ -25,16 +25,16 @@ QAbstractItemModel *ContactCompletionModel::self()
return mSelf;
}
Monitor *monitor = new Monitor;
auto *monitor = new Monitor;
monitor->setObjectName(QStringLiteral("ContactCompletionModelMonitor"));
monitor->fetchCollection(true);
monitor->itemFetchScope().fetchFullPayload();
monitor->setCollectionMonitored(Akonadi::Collection::root());
monitor->setMimeTypeMonitored(KContacts::Addressee::mimeType());
ContactCompletionModel *model = new ContactCompletionModel(monitor);
auto *model = new ContactCompletionModel(monitor);
EntityMimeTypeFilterModel *filter = new Akonadi::EntityMimeTypeFilterModel(model);
auto *filter = new Akonadi::EntityMimeTypeFilterModel(model);
filter->setSourceModel(model);
filter->addMimeTypeExclusionFilter(Akonadi::Collection::mimeType());
filter->addMimeTypeExclusionFilter(Akonadi::Collection::virtualMimeType());
......
......@@ -43,7 +43,7 @@ public:
mEditorWidget = new ContactEditorWidget(displayMode == FullMode ? ContactEditorWidget::FullMode : ContactEditorWidget::VCardMode, mParent);
}
QVBoxLayout *layout = new QVBoxLayout(mParent);
auto *layout = new QVBoxLayout(mParent);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(mEditorWidget);
......@@ -81,7 +81,7 @@ void Akonadi::AkonadiContactEditor::Private::itemFetchDone(KJob *job)
return;
}
Akonadi::ItemFetchJob *fetchJob = qobject_cast<Akonadi::ItemFetchJob *>(job);
auto *fetchJob = qobject_cast<Akonadi::ItemFetchJob *>(job);
if (!fetchJob) {
return;
}
......@@ -97,7 +97,7 @@ void Akonadi::AkonadiContactEditor::Private::itemFetchDone(KJob *job)
// if in edit mode we have to fetch the parent collection to find out
// about the modify rights of the item
Akonadi::CollectionFetchJob *collectionFetchJob = new Akonadi::CollectionFetchJob(mItem.parentCollection(),
auto *collectionFetchJob = new Akonadi::CollectionFetchJob(mItem.parentCollection(),
Akonadi::CollectionFetchJob::Base);
mParent->connect(collectionFetchJob, &CollectionFetchJob::result, mParent, [this](KJob *job) {
parentCollectionFetchDone(job);
......@@ -118,7 +118,7 @@ void Akonadi::AkonadiContactEditor::Private::parentCollectionFetchDone(KJob *job
return;
}
Akonadi::CollectionFetchJob *fetchJob = qobject_cast<Akonadi::CollectionFetchJob *>(job);
auto *fetchJob = qobject_cast<Akonadi::CollectionFetchJob *>(job);
if (!fetchJob) {
return;
}
......@@ -160,7 +160,7 @@ void Akonadi::AkonadiContactEditor::Private::itemChanged(const Akonadi::Item &it
dlg->addButton(i18n("Ignore and Overwrite changes"), QMessageBox::RejectRole);
if (dlg->exec() == QMessageBox::AcceptRole) {
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(mItem);
auto *job = new Akonadi::ItemFetchJob(mItem);
job->fetchScope().fetchFullPayload();
job->fetchScope().fetchAttribute<ContactMetaDataAttribute>();
job->fetchScope().setAncestorRetrieval(Akonadi::ItemFetchScope::Parent);
......@@ -225,7 +225,7 @@ void Akonadi::AkonadiContactEditor::loadContact(const Akonadi::Item &item)
Q_ASSERT_X(false, "ContactEditor::loadContact", "You are calling loadContact in CreateMode!");
}
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(item);
auto *job = new Akonadi::ItemFetchJob(item);
job->fetchScope().fetchFullPayload();
job->fetchScope().fetchAttribute<ContactMetaDataAttribute>();
job->fetchScope().setAncestorRetrieval(Akonadi::ItemFetchScope::Parent);
......@@ -261,7 +261,7 @@ void Akonadi::AkonadiContactEditor::saveContactInAddressBook()
d->mItem.setPayload<KContacts::Addressee>(addr);
Akonadi::ItemModifyJob *job = new Akonadi::ItemModifyJob(d->mItem);
auto *job = new Akonadi::ItemModifyJob(d->mItem);
connect(job, &ItemModifyJob::result, this, [this](KJob *job) {
d->storeDone(job);
});
......@@ -292,7 +292,7 @@ void Akonadi::AkonadiContactEditor::saveContactInAddressBook()
d->mContactMetaData.store(item);
Akonadi::ItemCreateJob *job = new Akonadi::ItemCreateJob(item, d->mDefaultCollection);
auto *job = new Akonadi::ItemCreateJob(item, d->mDefaultCollection);
connect(job, &ItemCreateJob::result, this, [this](KJob *job) {
d->storeDone(job);
});
......
......@@ -38,7 +38,7 @@ public:
QWidget *mainWidget = new QWidget(q);
q->setWindowTitle(mode == ContactEditorDialog::CreateMode ? i18n("New Contact") : i18n("Edit Contact"));
QVBoxLayout *mainLayout = new QVBoxLayout(q);
auto *mainLayout = new QVBoxLayout(q);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, q);
q->connect(buttonBox, &QDialogButtonBox::accepted, q, [this]() {
slotOkClicked();
......@@ -50,7 +50,7 @@ public:
mainLayout->addWidget(mainWidget);
mainLayout->addWidget(buttonBox);
QGridLayout *layout = new QGridLayout(mainWidget);
auto *layout = new QGridLayout(mainWidget);
layout->setContentsMargins(0, 0, 0, 0);
if (editorWidget) {
......
......@@ -53,7 +53,7 @@ void ContactGroupEditor::Private::itemFetchDone(KJob *job)
return;
}
ItemFetchJob *fetchJob = qobject_cast<ItemFetchJob *>(job);
auto *fetchJob = qobject_cast<ItemFetchJob *>(job);
if (!fetchJob) {
return;
}
......@@ -69,7 +69,7 @@ void ContactGroupEditor::Private::itemFetchDone(KJob *job)
// if in edit mode we have to fetch the parent collection to find out
// about the modify rights of the item
Akonadi::CollectionFetchJob *collectionFetchJob = new Akonadi::CollectionFetchJob(mItem.parentCollection(),
auto *collectionFetchJob = new Akonadi::CollectionFetchJob(mItem.parentCollection(),
Akonadi::CollectionFetchJob::Base);
mParent->connect(collectionFetchJob, &CollectionFetchJob::result, mParent, [this](KJob *job) {
parentCollectionFetchDone(job);
......@@ -92,7 +92,7 @@ void ContactGroupEditor::Private::parentCollectionFetchDone(KJob *job)
return;
}
Akonadi::CollectionFetchJob *fetchJob = qobject_cast<Akonadi::CollectionFetchJob *>(job);
auto *fetchJob = qobject_cast<Akonadi::CollectionFetchJob *>(job);
if (!fetchJob) {
return;
}
......@@ -136,7 +136,7 @@ void ContactGroupEditor::Private::itemChanged(const Item &item, const QSet<QByte
dlg->addButton(i18n("Ignore and Overwrite changes"), QMessageBox::RejectRole);
if (dlg->exec() == QMessageBox::AcceptRole) {
ItemFetchJob *job = new ItemFetchJob(mItem);
auto *job = new ItemFetchJob(mItem);
job->fetchScope().fetchFullPayload();
job->fetchScope().setAncestorRetrieval(Akonadi::ItemFetchScope::Parent);
......@@ -237,7 +237,7 @@ void ContactGroupEditor::loadContactGroup(const Akonadi::Item &item)
Q_ASSERT_X(false, "ContactGroupEditor::loadContactGroup", "You are calling loadContactGroup in CreateMode!");
}
ItemFetchJob *job = new ItemFetchJob(item);
auto *job = new ItemFetchJob(item);
job->fetchScope().fetchFullPayload();
job->fetchScope().setAncestorRetrieval(Akonadi::ItemFetchScope::Parent);
......@@ -270,7 +270,7 @@ bool ContactGroupEditor::saveContactGroup()
d->mItem.setPayload<KContacts::ContactGroup>(group);
ItemModifyJob *job = new ItemModifyJob(d->mItem);
auto *job = new ItemModifyJob(d->mItem);
connect(job, &ItemModifyJob::result, this, [this](KJob *job) {
d->storeDone(job);
});
......@@ -302,7 +302,7 @@ bool ContactGroupEditor::saveContactGroup()
item.setPayload<KContacts::ContactGroup>(group);
item.setMimeType(KContacts::ContactGroup::mimeType());
ItemCreateJob *job = new ItemCreateJob(item, d->mDefaultCollection);
auto *job = new ItemCreateJob(item, d->mDefaultCollection);
connect(job, &ItemCreateJob::result, this, [this](KJob *job) {
d->storeDone(job);
});
......
......@@ -54,10 +54,10 @@ ContactLineEdit::ContactLineEdit(bool isReference, ContactCompletionModel::Colum
{
setFrame(false);
ContactsWithEmailFilterModel *filter = new ContactsWithEmailFilterModel(this);
auto *filter = new ContactsWithEmailFilterModel(this);
filter->setSourceModel(Akonadi::ContactCompletionModel::self());
QCompleter *completer = new QCompleter(filter, this);
auto *completer = new QCompleter(filter, this);
completer->setCompletionColumn(column);
completer->setCaseSensitivity(Qt::CaseInsensitive);
connect(completer, QOverload<const QModelIndex &>::of(&QCompleter::activated), this, QOverload<const QModelIndex &>::of(&ContactLineEdit::completed));
......@@ -127,13 +127,13 @@ QWidget *ContactGroupEditorDelegate::createEditor(QWidget *parent, const QStyleO
const bool isReference = index.data(ContactGroupModel::IsReferenceRole).toBool();
Q_UNUSED(option)
if (index.column() == 0) {
ContactLineEdit *edit = new ContactLineEdit(isReference, ContactCompletionModel::EmailColumn, parent);
auto *edit = new ContactLineEdit(isReference, ContactCompletionModel::EmailColumn, parent);
connect(edit, QOverload<QWidget *>::of(&ContactLineEdit::completed), this, &ContactGroupEditorDelegate::completed);
return edit;
} else {
if (index.data(ContactGroupModel::IsReferenceRole).toBool()) {
KComboBox *comboBox = new KComboBox(parent);
auto *comboBox = new KComboBox(parent);
comboBox->setFrame(false);
comboBox->setAutoFillBackground(true);
return comboBox;
......@@ -149,14 +149,14 @@ void ContactGroupEditorDelegate::setEditorData(QWidget *editor, const QModelInde
{
if (index.data(ContactGroupModel::IsReferenceRole).toBool()) {
if (index.column() == 0) {
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(editor);
auto *lineEdit = qobject_cast<QLineEdit *>(editor);
if (!lineEdit) {
return;
}
lineEdit->setText(index.data(Qt::EditRole).toString());
} else {
KComboBox *comboBox = qobject_cast<KComboBox *>(editor);
auto *comboBox = qobject_cast<KComboBox *>(editor);
if (!comboBox) {
return;
}
......@@ -167,7 +167,7 @@ void ContactGroupEditorDelegate::setEditorData(QWidget *editor, const QModelInde
comboBox->setCurrentIndex(comboBox->findText(index.data(Qt::EditRole).toString()));
}
} else {
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(editor);
auto *lineEdit = qobject_cast<QLineEdit *>(editor);
if (!lineEdit) {
return;
}
......@@ -180,7 +180,7 @@ void ContactGroupEditorDelegate::setModelData(QWidget *editor, QAbstractItemMode
{
if (index.data(ContactGroupModel::IsReferenceRole).toBool()) {
if (index.column() == 0) {
ContactLineEdit *lineEdit = static_cast<ContactLineEdit *>(editor);
auto *lineEdit = static_cast<ContactLineEdit *>(editor);
const bool isReference = lineEdit->isReference();
const Item item = lineEdit->completedItem();
......@@ -195,7 +195,7 @@ void ContactGroupEditorDelegate::setModelData(QWidget *editor, QAbstractItemMode
}
if (index.column() == 1) {
KComboBox *comboBox = qobject_cast<KComboBox *>(editor);
auto *comboBox = qobject_cast<KComboBox *>(editor);
if (!comboBox) {
return;
}
......@@ -203,7 +203,7 @@ void ContactGroupEditorDelegate::setModelData(QWidget *editor, QAbstractItemMode
model->setData(index, comboBox->currentText(), Qt::EditRole);
}
} else {
ContactLineEdit *lineEdit = static_cast<ContactLineEdit *>(editor);
auto *lineEdit = static_cast<ContactLineEdit *>(editor);
const bool isReference = lineEdit->isReference();
const Item item = lineEdit->completedItem();
......
......@@ -74,7 +74,7 @@ ContactGroupEditorDialog::ContactGroupEditorDialog(Mode mode, QWidget *parent)
, d(new Private(this, mode))
{
setWindowTitle(mode == CreateMode ? i18n("New Contact Group") : i18n("Edit Contact Group"));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
d->okButton = buttonBox->button(QDialogButtonBox::Ok);
......@@ -90,7 +90,7 @@ ContactGroupEditorDialog::ContactGroupEditorDialog(Mode mode, QWidget *parent)
QWidget *mainWidget = new QWidget(this);
QGridLayout *layout = new QGridLayout(mainWidget);
auto *layout = new QGridLayout(mainWidget);
layout->setContentsMargins(0, 0, 0, 0);
d->mEditor = new Akonadi::ContactGroupEditor(mode == CreateMode
......
......@@ -43,7 +43,7 @@ public:
} else {
item.setId(reference.uid().toLongLong());
}
ItemFetchJob *job = new ItemFetchJob(item, mParent);
auto *job = new ItemFetchJob(item, mParent);
job->setProperty("row", row);
job->fetchScope().fetchFullPayload();
......@@ -62,7 +62,7 @@ public:
return;
}
ItemFetchJob *fetchJob = qobject_cast<ItemFetchJob *>(job);
auto *fetchJob = qobject_cast<ItemFetchJob *>(job);
if (fetchJob->items().count() != 1) {
mMembers[row].loadingError = true;
......
......@@ -93,7 +93,7 @@ public:
mExpandJob = nullptr;
if (!job->error()) {
ContactGroupExpandJob *expandJob = qobject_cast<ContactGroupExpandJob *>(job);
auto *expandJob = qobject_cast<ContactGroupExpandJob *>(job);
mCurrentContacts = expandJob->contacts();
}
......@@ -116,7 +116,7 @@ public:
mCurrentAddressBookName.clear();
if (!job->error()) {
CollectionFetchJob *fetchJob = qobject_cast<CollectionFetchJob *>(job);
auto *fetchJob = qobject_cast<CollectionFetchJob *>(job);
if (!fetchJob->collections().isEmpty()) {
const Collection collection = fetchJob->collections().at(0);
mCurrentAddressBookName = collection.displayName();
......@@ -144,7 +144,7 @@ ContactGroupViewer::ContactGroupViewer(QWidget *parent)
: QWidget(parent)
, d(new Private(this))
{
QVBoxLayout *layout = new QVBoxLayout(this);
auto *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
connect(d->mBrowser, &TextBrowser::anchorClicked, this, [this](const QUrl &url) {
......
......@@ -30,7 +30,7 @@ ContactGroupViewerDialog::ContactGroupViewerDialog(QWidget *parent)
, d(new Private)
{
setWindowTitle(i18nc("@title:window", "Show Contact Group"));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok, this);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
......
......@@ -27,14 +27,14 @@ void ContactMetaDataAkonadi::load(const Akonadi::Item &contact)
if (!contact.hasAttribute("contactmetadata")) {
return;
}
const ContactMetaDataAttribute *attribute = contact.attribute<ContactMetaDataAttribute>();
const auto *attribute = contact.attribute<ContactMetaDataAttribute>();
const QVariantMap metaData = attribute->metaData();
loadMetaData(metaData);
}
void ContactMetaDataAkonadi::store(Akonadi::Item &contact)
{
ContactMetaDataAttribute *attribute = contact.attribute<ContactMetaDataAttribute>(Item::AddIfMissing);
auto *attribute = contact.attribute<ContactMetaDataAttribute>(Item::AddIfMissing);
attribute->setMetaData(storeMetaData());
}
......@@ -212,7 +212,7 @@ public:
QString addressBookName;
if (!job->error()) {
CollectionFetchJob *fetchJob = qobject_cast<CollectionFetchJob *>(job);
auto *fetchJob = qobject_cast<CollectionFetchJob *>(job);
if (!fetchJob->collections().isEmpty()) {
const Collection collection = fetchJob->collections().at(0);
addressBookName = collection.displayName();
......@@ -242,7 +242,7 @@ ContactViewer::ContactViewer(QWidget *parent)
: QWidget(parent)
, d(new Private(this))
{
QVBoxLayout *layout = new QVBoxLayout(this);
auto *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
d->mBrowser = new TextBrowser;
......
......@@ -56,7 +56,7 @@ ContactViewerDialog::ContactViewerDialog(QWidget *parent)
, d(new Private(this))
{
setWindowTitle(i18nc("@title:window", "Show Contact"));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok, this);
QWidget *mainWidget = new QWidget(this);
......@@ -67,12 +67,12 @@ ContactViewerDialog::ContactViewerDialog(QWidget *parent)
connect(buttonBox, &QDialogButtonBox::accepted, this, &ContactViewerDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &ContactViewerDialog::reject);
QVBoxLayout *layout = new QVBoxLayout(mainWidget);
auto *layout = new QVBoxLayout(mainWidget);
d->mViewer = new ContactViewer(this);
layout->addWidget(d->mViewer);
ContactDefaultActions *actions = new ContactDefaultActions(this);
auto *actions = new ContactDefaultActions(this);
actions->connectToView(d->mViewer);
mainLayout->addWidget(buttonBox);
......
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