Commit 4619d693 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code

parent 6b92034d
Pipeline #39272 passed with stage
in 12 minutes and 47 seconds
......@@ -38,9 +38,9 @@ NotesAgentAlarmDialog::NotesAgentAlarmDialog(QWidget *parent)
setWindowTitle(i18nc("@title:window", "Alarm"));
setWindowIcon(QIcon::fromTheme(QStringLiteral("knotes")));
setAttribute(Qt::WA_DeleteOnClose);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
QVBoxLayout *vbox = new QVBoxLayout;
auto *vbox = new QVBoxLayout;
mainLayout->addLayout(vbox);
mCurrentDateTime = new QLabel(this);
......@@ -84,7 +84,7 @@ void NotesAgentAlarmDialog::slotCustomContextMenuRequested(const QPoint &pos)
return;
}
Q_UNUSED(pos);
QMenu *entriesContextMenu = new QMenu(this);
auto *entriesContextMenu = new QMenu(this);
QAction *removeAlarm = new QAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18n("Remove Alarm"), entriesContextMenu);
connect(removeAlarm, &QAction::triggered, this, &NotesAgentAlarmDialog::slotRemoveAlarm);
QAction *showNote = new QAction(i18n("Show Note..."), entriesContextMenu);
......@@ -134,7 +134,7 @@ void NotesAgentAlarmDialog::slotShowNote()
//deleted on close
const Akonadi::Item::Id id = mListWidget->currentItemId();
if (id != -1) {
NotesAgentNoteDialog *dlg = new NotesAgentNoteDialog;
auto *dlg = new NotesAgentNoteDialog;
dlg->setNoteId(id);
dlg->show();
}
......@@ -146,7 +146,7 @@ void NotesAgentAlarmDialog::slotRemoveAlarm()
const Akonadi::Item::Id id = mListWidget->currentItemId();
if (id != -1) {
Akonadi::Item item(id);
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(item, this);
auto *job = new Akonadi::ItemFetchJob(item, this);
job->fetchScope().fetchAttribute<NoteShared::NoteAlarmAttribute>();
connect(job, &Akonadi::ItemFetchJob::result, this, &NotesAgentAlarmDialog::slotFetchItem);
}
......@@ -159,12 +159,12 @@ void NotesAgentAlarmDialog::slotFetchItem(KJob *job)
qCDebug(NOTESAGENT_LOG) << "fetch item failed " << job->errorString();
return;
}
Akonadi::ItemFetchJob *itemFetchJob = static_cast<Akonadi::ItemFetchJob *>(job);
auto *itemFetchJob = static_cast<Akonadi::ItemFetchJob *>(job);
Akonadi::Item::List items = itemFetchJob->items();
if (!items.isEmpty()) {
Akonadi::Item item = items.first();
item.removeAttribute<NoteShared::NoteAlarmAttribute>();
Akonadi::ItemModifyJob *modify = new Akonadi::ItemModifyJob(item);
auto *modify = new Akonadi::ItemModifyJob(item);
connect(modify, &Akonadi::ItemModifyJob::result, this, &NotesAgentAlarmDialog::slotModifyItem);
}
}
......@@ -182,7 +182,7 @@ void NotesAgentAlarmDialog::slotModifyAlarm()
Akonadi::Item::Id id = mListWidget->currentItemId();
if (id != -1) {
Akonadi::Item item(id);
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(item, this);
auto *job = new Akonadi::ItemFetchJob(item, this);
job->fetchScope().fetchFullPayload(true);
job->fetchScope().fetchAttribute<NoteShared::NoteAlarmAttribute>();
connect(job, &Akonadi::ItemFetchJob::result, this, &NotesAgentAlarmDialog::slotFetchAlarmItem);
......@@ -195,11 +195,11 @@ void NotesAgentAlarmDialog::slotFetchAlarmItem(KJob *job)
qCDebug(NOTESAGENT_LOG) << "fetch item failed " << job->errorString();
return;
}
Akonadi::ItemFetchJob *itemFetchJob = static_cast<Akonadi::ItemFetchJob *>(job);
auto *itemFetchJob = static_cast<Akonadi::ItemFetchJob *>(job);
Akonadi::Item::List items = itemFetchJob->items();
if (!items.isEmpty()) {
Akonadi::Item item = items.first();
NoteShared::NoteAlarmAttribute *attr = item.attribute<NoteShared::NoteAlarmAttribute>();
auto *attr = item.attribute<NoteShared::NoteAlarmAttribute>();
if (attr) {
KMime::Message::Ptr noteMessage = item.payload<KMime::Message::Ptr>();
if (!noteMessage) {
......@@ -221,7 +221,7 @@ void NotesAgentAlarmDialog::slotFetchAlarmItem(KJob *job)
} else {
item.removeAttribute<NoteShared::NoteAlarmAttribute>();
}
Akonadi::ItemModifyJob *modify = new Akonadi::ItemModifyJob(item);
auto *modify = new Akonadi::ItemModifyJob(item);
connect(modify, &Akonadi::ItemModifyJob::result, this, &NotesAgentAlarmDialog::slotModifyItem);
}
delete dlg;
......
......@@ -26,7 +26,7 @@
NotesAgentNoteDialog::NotesAgentNoteDialog(QWidget *parent)
: QDialog(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
setAttribute(Qt::WA_DeleteOnClose);
setWindowIcon(QIcon::fromTheme(QStringLiteral("knotes")));
......@@ -53,7 +53,7 @@ NotesAgentNoteDialog::~NotesAgentNoteDialog()
void NotesAgentNoteDialog::setNoteId(Akonadi::Item::Id id)
{
Akonadi::Item item(id);
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(item, this);
auto *job = new Akonadi::ItemFetchJob(item, this);
job->fetchScope().fetchFullPayload(true);
job->fetchScope().fetchAttribute< NoteShared::NoteDisplayAttribute >();
connect(job, &Akonadi::ItemFetchJob::result, this, &NotesAgentNoteDialog::slotFetchItem);
......@@ -65,7 +65,7 @@ void NotesAgentNoteDialog::slotFetchItem(KJob *job)
qCDebug(NOTESAGENT_LOG) << "fetch item failed " << job->errorString();
return;
}
Akonadi::ItemFetchJob *itemFetchJob = static_cast<Akonadi::ItemFetchJob *>(job);
auto *itemFetchJob = static_cast<Akonadi::ItemFetchJob *>(job);
const Akonadi::Item::List lstItem = itemFetchJob->items();
if (!lstItem.isEmpty()) {
const Akonadi::Item item = lstItem.first();
......@@ -84,7 +84,7 @@ void NotesAgentNoteDialog::slotFetchItem(KJob *job)
}
}
if (item.hasAttribute<NoteShared::NoteDisplayAttribute>()) {
const NoteShared::NoteDisplayAttribute *attr = item.attribute<NoteShared::NoteDisplayAttribute>();
const auto *attr = item.attribute<NoteShared::NoteDisplayAttribute>();
if (attr) {
mNote->editor()->setTextColor(attr->backgroundColor());
//TODO add background color.
......
......@@ -28,7 +28,7 @@ NotesAgentSettingsDialog::NotesAgentSettingsDialog(QWidget *parent)
{
setWindowTitle(i18nc("@title:window", "Configure Notes Agent"));
setWindowIcon(QIcon::fromTheme(QStringLiteral("knotes")));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
setModal(true);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, this);
......@@ -38,7 +38,7 @@ NotesAgentSettingsDialog::NotesAgentSettingsDialog(QWidget *parent)
connect(buttonBox, &QDialogButtonBox::rejected, this, &NotesAgentSettingsDialog::reject);
connect(okButton, &QPushButton::clicked, this, &NotesAgentSettingsDialog::slotOkClicked);
QTabWidget *tab = new QTabWidget(this);
auto *tab = new QTabWidget(this);
mNotify = new KNotifyConfigWidget(this);
mNotify->setApplication(QStringLiteral("akonadi_notes_agent"));
......@@ -67,7 +67,7 @@ NotesAgentSettingsDialog::NotesAgentSettingsDialog(QWidget *parent)
aboutData.setTranslator(i18nc("NAME OF TRANSLATORS", "Your names"),
i18nc("EMAIL OF TRANSLATORS", "Your emails"));
KHelpMenu *helpMenu = new KHelpMenu(this, aboutData, true);
auto *helpMenu = new KHelpMenu(this, aboutData, true);
//Initialize menu
QMenu *menu = helpMenu->menu();
helpMenu->action(KHelpMenu::menuAboutApp)->setIcon(QIcon::fromTheme(QStringLiteral("knotes")));
......
......@@ -127,7 +127,7 @@ void NotesManager::slotCheckAlarm()
Akonadi::Item::List lst;
for (const Akonadi::Item &item : qAsConst(mListItem)) {
const NoteShared::NoteAlarmAttribute *attrAlarm = item.attribute<NoteShared::NoteAlarmAttribute>();
const auto *attrAlarm = item.attribute<NoteShared::NoteAlarmAttribute>();
if (attrAlarm) {
if (attrAlarm->dateTime() < QDateTime::currentDateTime()) {
lst.append(item);
......@@ -169,7 +169,7 @@ void NotesManager::slotAcceptConnection()
QTcpSocket *s = mListener->nextPendingConnection();
if (s) {
NoteShared::NotesNetworkReceiver *recv = new NoteShared::NotesNetworkReceiver(s);
auto *recv = new NoteShared::NotesNetworkReceiver(s);
connect(recv, &NoteShared::NotesNetworkReceiver::sigNoteReceived, this, &NotesManager::slotNewNote);
}
}
......@@ -183,7 +183,7 @@ void NotesManager::slotNewNote(const QString &name, const QString &text)
nullptr,
KNotification::CloseOnTimeout,
QStringLiteral("akonadi_notes_agent"));
NoteShared::CreateNewNoteJob *job = new NoteShared::CreateNewNoteJob(this, nullptr);
auto *job = new NoteShared::CreateNewNoteJob(this, nullptr);
//For the moment it doesn't support richtext.
job->setRichText(false);
job->setNote(name, text);
......
......@@ -39,7 +39,7 @@ void NoteEditorUtilsTest::testAddCheckmark()
const QString checkMark = QString::fromRawData(unicode, size);
NoteShared::NoteEditorUtils noteUtils;
QTextDocument *document = new QTextDocument(this);
auto *document = new QTextDocument(this);
document->setPlainText(input);
QTextCursor textCursor(document);
if (position < 1) {
......
......@@ -40,20 +40,20 @@ NoteAlarmDialog::NoteAlarmDialog(const QString &caption, QWidget *parent)
, d(new NoteShared::NoteAlarmDialogPrivate)
{
setWindowTitle(caption);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
QDialogButtonBox *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::rejected, this, &NoteAlarmDialog::reject);
QWidget *page = new QWidget(this);
QVBoxLayout *pageVBoxLayout = new QVBoxLayout(page);
auto *pageVBoxLayout = new QVBoxLayout(page);
pageVBoxLayout->setContentsMargins(0, 0, 0, 0);
d->m_buttons = new QButtonGroup(this);
QGroupBox *group = new QGroupBox(i18n("Scheduled Alarm"), page);
pageVBoxLayout->addWidget(group);
QVBoxLayout *layout = new QVBoxLayout;
auto *layout = new QVBoxLayout;
QRadioButton *none = new QRadioButton(i18n("&No alarm"));
layout->addWidget(none);
d->m_buttons->addButton(none, 0);
......@@ -61,7 +61,7 @@ NoteAlarmDialog::NoteAlarmDialog(const QString &caption, QWidget *parent)
group->setLayout(layout);
QWidget *at = new QWidget;
QHBoxLayout *atHBoxLayout = new QHBoxLayout(at);
auto *atHBoxLayout = new QHBoxLayout(at);
atHBoxLayout->setContentsMargins(0, 0, 0, 0);
QRadioButton *label_at = new QRadioButton(i18n("Alarm &at:"), at);
atHBoxLayout->addWidget(label_at);
......
......@@ -20,7 +20,7 @@ NoteAlarmAttribute::~NoteAlarmAttribute()
NoteAlarmAttribute *NoteAlarmAttribute::clone() const
{
NoteAlarmAttribute *attr = new NoteAlarmAttribute();
auto *attr = new NoteAlarmAttribute();
attr->setDateTime(dateTime());
return attr;
}
......
......@@ -40,7 +40,7 @@ NoteDisplayAttribute::~NoteDisplayAttribute()
NoteDisplayAttribute *NoteDisplayAttribute::clone() const
{
NoteDisplayAttribute *attr = new NoteDisplayAttribute();
auto *attr = new NoteDisplayAttribute();
attr->setBackgroundColor(backgroundColor());
attr->setForegroundColor(foregroundColor());
attr->setSize(size());
......
......@@ -17,13 +17,13 @@ using namespace NoteShared;
NoteActionConfig::NoteActionConfig(QWidget *parent)
: KCModule(parent)
{
QGridLayout *layout = new QGridLayout(this);
auto *layout = new QGridLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
QLabel *label_MailAction = new QLabel(i18n("&Mail action:"), this);
layout->addWidget(label_MailAction, 0, 0);
QLineEdit *kcfg_MailAction = new QLineEdit(this);
auto *kcfg_MailAction = new QLineEdit(this);
kcfg_MailAction->setObjectName(QStringLiteral("kcfg_MailAction"));
label_MailAction->setBuddy(kcfg_MailAction);
layout->addWidget(kcfg_MailAction, 0, 1);
......
......@@ -35,11 +35,11 @@ NoteNetworkConfigWidget::NoteNetworkConfigWidget(QWidget *parent)
: QWidget(parent)
, d(new NoteShared::NoteNetworkConfigWidgetPrivate)
{
QVBoxLayout *layout = new QVBoxLayout(this);
auto *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
QGroupBox *incoming = new QGroupBox(i18n("Incoming Notes"));
QHBoxLayout *tmpLayout = new QHBoxLayout;
auto *tmpLayout = new QHBoxLayout;
d->mTmpChkB = new QCheckBox(i18n("Accept incoming notes"));
d->mTmpChkB->setObjectName(QStringLiteral("kcfg_ReceiveNotes"));
......@@ -99,9 +99,9 @@ void NoteNetworkConfigWidget::load()
NoteNetworkConfig::NoteNetworkConfig(QWidget *parent)
: KCModule(parent)
{
QVBoxLayout *lay = new QVBoxLayout(this);
auto *lay = new QVBoxLayout(this);
lay->setContentsMargins(0, 0, 0, 0);
NoteNetworkConfigWidget *noteNetworkConfigWidget = new NoteNetworkConfigWidget(this);
auto *noteNetworkConfigWidget = new NoteNetworkConfigWidget(this);
lay->addWidget(noteNetworkConfigWidget);
addConfig(NoteShared::NoteSharedGlobalConfig::self(), noteNetworkConfigWidget);
load();
......
......@@ -100,7 +100,7 @@ void CreateNewNoteJob::createFetchCollectionJob(bool useSettings)
col = Akonadi::Collection(id);
}
NoteShared::NoteSharedGlobalConfig::self()->save();
Akonadi::CollectionFetchJob *fetchCollection = new Akonadi::CollectionFetchJob(col, Akonadi::CollectionFetchJob::Base);
auto *fetchCollection = new Akonadi::CollectionFetchJob(col, Akonadi::CollectionFetchJob::Base);
connect(fetchCollection, &Akonadi::CollectionFetchJob::result, this, &CreateNewNoteJob::slotFetchCollection);
}
......@@ -115,7 +115,7 @@ void CreateNewNoteJob::slotFetchCollection(KJob *job)
}
return;
}
Akonadi::CollectionFetchJob *fetchCollection = qobject_cast<Akonadi::CollectionFetchJob *>(job);
auto *fetchCollection = qobject_cast<Akonadi::CollectionFetchJob *>(job);
if (fetchCollection->collections().isEmpty()) {
qCDebug(NOTESHARED_LOG) << "No collection fetched";
if (KMessageBox::Yes == KMessageBox::warningYesNo(nullptr, i18n("An error occurred during fetching. Do you want to select a new default collection?"))) {
......@@ -130,7 +130,7 @@ void CreateNewNoteJob::slotFetchCollection(KJob *job)
if (!col.hasAttribute<NoteShared::ShowFolderNotesAttribute>()) {
if (KMessageBox::Yes == KMessageBox::warningYesNo(nullptr, i18n("Collection is hidden. New note will be stored but not displayed. Do you want to show collection?"))) {
col.addAttribute(new NoteShared::ShowFolderNotesAttribute());
Akonadi::CollectionModifyJob *job = new Akonadi::CollectionModifyJob(col);
auto *job = new Akonadi::CollectionModifyJob(col);
connect(job, &Akonadi::CollectionModifyJob::result, this, &CreateNewNoteJob::slotCollectionModifyFinished);
}
}
......@@ -164,12 +164,12 @@ void CreateNewNoteJob::slotFetchCollection(KJob *job)
newItem.setPayload(newPage);
Akonadi::EntityDisplayAttribute *eda = new Akonadi::EntityDisplayAttribute();
auto *eda = new Akonadi::EntityDisplayAttribute();
eda->setIconName(QStringLiteral("text-plain"));
newItem.addAttribute(eda);
Akonadi::ItemCreateJob *job = new Akonadi::ItemCreateJob(newItem, col, this);
auto *job = new Akonadi::ItemCreateJob(newItem, col, this);
connect(job, &Akonadi::ItemCreateJob::result, this, &CreateNewNoteJob::slotNoteCreationFinished);
} else {
deleteLater();
......
......@@ -29,7 +29,7 @@ NoteHostDialog::NoteHostDialog(const QString &caption, QWidget *parent)
{
setWindowTitle(caption);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
auto *mainLayout = new QVBoxLayout(this);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
mOkButton = buttonBox->button(QDialogButtonBox::Ok);
......
......@@ -75,7 +75,7 @@ void NoteUtils::sendToNetwork(QWidget *parent, const QString &title, const QStri
// Send the note
auto socket = new QSslSocket;
socket->connectToHost(host, port);
NoteShared::NotesNetworkSender *sender = new NoteShared::NotesNetworkSender(socket);
auto *sender = new NoteShared::NotesNetworkSender(socket);
sender->setSenderId(NoteShared::NoteSharedGlobalConfig::senderID());
sender->setNote(title, message); // FIXME: plainText ??
}
......@@ -96,7 +96,7 @@ QString NoteUtils::createToolTip(const Akonadi::Item &item)
QString tip;
if (item.hasAttribute<NoteDisplayAttribute>()) {
const NoteDisplayAttribute *attr = item.attribute<NoteDisplayAttribute>();
const auto *attr = item.attribute<NoteDisplayAttribute>();
if (attr) {
const QString bckColorName = attr->backgroundColor().name();
const QString txtColorName = attr->foregroundColor().name();
......
......@@ -50,7 +50,7 @@ void LocalResourceCreator::createInstance()
{
Akonadi::AgentType notesType = Akonadi::AgentManager::self()->type(akonadiNotesInstanceName());
Akonadi::AgentInstanceCreateJob *job = new Akonadi::AgentInstanceCreateJob(notesType);
auto *job = new Akonadi::AgentInstanceCreateJob(notesType);
connect(job, &Akonadi::AgentInstanceCreateJob::result, this, &LocalResourceCreator::slotInstanceCreated);
job->start();
......@@ -64,7 +64,7 @@ void LocalResourceCreator::slotInstanceCreated(KJob *job)
return;
}
Akonadi::AgentInstanceCreateJob *createJob = qobject_cast<Akonadi::AgentInstanceCreateJob *>(job);
auto *createJob = qobject_cast<Akonadi::AgentInstanceCreateJob *>(job);
Akonadi::AgentInstance instance = createJob->instance();
instance.setName(i18nc("Default name for resource holding notes", "Local Notes"));
......@@ -79,7 +79,7 @@ void LocalResourceCreator::slotInstanceCreated(KJob *job)
}
instance.reconfigure();
Akonadi::ResourceSynchronizationJob *syncJob = new Akonadi::ResourceSynchronizationJob(instance, this);
auto *syncJob = new Akonadi::ResourceSynchronizationJob(instance, this);
connect(syncJob, &Akonadi::ResourceSynchronizationJob::result, this, &LocalResourceCreator::slotSyncDone);
syncJob->start();
}
......
......@@ -68,7 +68,7 @@ void NoteListWidget::createItem(const Akonadi::Item &note)
if (!noteMessage) {
return;
}
QListWidgetItem *item = new QListWidgetItem(this);
auto *item = new QListWidgetItem(this);
const KMime::Headers::Subject *const subject = noteMessage->subject(false);
if (subject) {
......
......@@ -74,7 +74,7 @@ KNotesApp::KNotesApp(QWidget *parent)
mDebugAkonadiSearch = !qEnvironmentVariableIsEmpty("KDEPIM_DEBUGGING");
if (KNotesGlobalConfig::self()->autoCreateResourceOnStart()) {
NoteShared::LocalResourceCreator *creator = new NoteShared::LocalResourceCreator(this);
auto *creator = new NoteShared::LocalResourceCreator(this);
creator->createIfMissing();
}
......@@ -258,7 +258,7 @@ void KNotesApp::slotDeleteSelectedNotes()
if (dlg->exec()) {
const Akonadi::Item::List lst = dlg->selectedNotes();
if (!lst.isEmpty()) {
Akonadi::ItemDeleteJob *deleteJob = new Akonadi::ItemDeleteJob(lst, this);
auto *deleteJob = new Akonadi::ItemDeleteJob(lst, this);
connect(deleteJob, &KJob::result, this, &KNotesApp::slotNoteDeleteFinished);
}
}
......@@ -310,7 +310,7 @@ void KNotesApp::slotRowInserted(const QModelIndex &parent, int start, int end)
void KNotesApp::createNote(const Akonadi::Item &item)
{
if (item.hasPayload<KMime::Message::Ptr>() && !mNotes.contains(item.id())) {
KNote *note = new KNote(m_noteGUI, item, mDebugAkonadiSearch);
auto *note = new KNote(m_noteGUI, item, mDebugAkonadiSearch);
mNotes.insert(item.id(), note);
connect(note, &KNote::sigShowNextNote,
this, &KNotesApp::slotWalkThroughNotes);
......@@ -336,7 +336,7 @@ void KNotesApp::updateSystray()
void KNotesApp::newNote(const QString &name, const QString &text)
{
NoteShared::CreateNewNoteJob *job = new NoteShared::CreateNewNoteJob(this, this);
auto *job = new NoteShared::CreateNewNoteJob(this, this);
job->setRichText(KNotesGlobalConfig::self()->richText());
job->setNote(name, text);
job->start();
......@@ -706,7 +706,7 @@ void KNotesApp::slotOpenFindDialog()
void KNotesApp::fetchNotesFromCollection(const Akonadi::Collection &col)
{
Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob(col);
auto *job = new Akonadi::ItemFetchJob(col);
job->fetchScope().fetchFullPayload(true);
job->fetchScope().fetchAttribute<NoteShared::NoteLockAttribute>();
job->fetchScope().fetchAttribute<NoteShared::NoteDisplayAttribute>();
......@@ -722,7 +722,7 @@ void KNotesApp::slotItemFetchFinished(KJob *job)
return;
}
Akonadi::ItemFetchJob *fetchJob = qobject_cast<Akonadi::ItemFetchJob *>(job);
auto *fetchJob = qobject_cast<Akonadi::ItemFetchJob *>(job);
const Akonadi::Item::List items = fetchJob->items();
for (const Akonadi::Item &item : items) {
......
......@@ -48,7 +48,7 @@ QVariant KNoteCollectionDisplayProxyModel::data(const QModelIndex &index, int ro
if (mDisplayCollection.contains(collection)) {
return mDisplayCollection.value(collection) ? Qt::Checked : Qt::Unchecked;
} else {
const NoteShared::ShowFolderNotesAttribute *attr = collection.attribute<NoteShared::ShowFolderNotesAttribute>();
const auto *attr = collection.attribute<NoteShared::ShowFolderNotesAttribute>();
if (attr) {
return Qt::Checked;
}
......@@ -91,14 +91,14 @@ QHash<Akonadi::Collection, bool> KNoteCollectionDisplayProxyModel::displayCollec
KNoteCollectionConfigWidget::KNoteCollectionConfigWidget(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *mainLayout = new QHBoxLayout(this);
auto *mainLayout = new QHBoxLayout(this);
mainLayout->setContentsMargins(0, 0, 0, 0);
QTabWidget *tabWidget = new QTabWidget;
auto *tabWidget = new QTabWidget;
mainLayout->addWidget(tabWidget);
QWidget *collectionWidget = new QWidget;
QVBoxLayout *vbox = new QVBoxLayout;
auto *vbox = new QVBoxLayout;
collectionWidget->setLayout(vbox);
tabWidget->addTab(collectionWidget, i18n("Folders"));
......@@ -115,7 +115,7 @@ KNoteCollectionConfigWidget::KNoteCollectionConfigWidget(QWidget *parent)
// Set the model to show only collections, not items.
mModel->setItemPopulationStrategy(Akonadi::EntityTreeModel::NoItemPopulation);
Akonadi::CollectionFilterProxyModel *mimeTypeProxy = new Akonadi::CollectionFilterProxyModel(this);
auto *mimeTypeProxy = new Akonadi::CollectionFilterProxyModel(this);
mimeTypeProxy->setExcludeVirtualCollections(true);
mimeTypeProxy->addMimeTypeFilters(QStringList() << Akonadi::NoteUtils::noteMimeType());
mimeTypeProxy->setSourceModel(mModel);
......@@ -132,7 +132,7 @@ KNoteCollectionConfigWidget::KNoteCollectionConfigWidget(QWidget *parent)
mCollectionFilter->setDynamicSortFilter(true);
mCollectionFilter->setFilterCaseSensitivity(Qt::CaseInsensitive);
QLineEdit *searchLine = new QLineEdit(this);
auto *searchLine = new QLineEdit(this);
searchLine->setPlaceholderText(i18n("Search..."));
searchLine->setClearButtonEnabled(true);
connect(searchLine, &QLineEdit::textChanged, this, &KNoteCollectionConfigWidget::slotSetCollectionFilter);
......@@ -148,7 +148,7 @@ KNoteCollectionConfigWidget::KNoteCollectionConfigWidget(QWidget *parent)
mFolderView->setModel(mCollectionFilter);
connect(mFolderView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &KNoteCollectionConfigWidget::slotUpdateButtons);
QHBoxLayout *hbox = new QHBoxLayout;
auto *hbox = new QHBoxLayout;
vbox->addLayout(hbox);
QPushButton *button = new QPushButton(i18n("&Select All"), this);
......@@ -179,10 +179,10 @@ KNoteCollectionConfigWidget::KNoteCollectionConfigWidget(QWidget *parent)
vbox->addWidget(mDefaultSaveFolder);
QWidget *accountWidget = new QWidget;
QVBoxLayout *vboxAccountWidget = new QVBoxLayout;
auto *vboxAccountWidget = new QVBoxLayout;
accountWidget->setLayout(vboxAccountWidget);
Akonadi::ManageAccountWidget *manageAccountWidget = new Akonadi::ManageAccountWidget(this);
auto *manageAccountWidget = new Akonadi::ManageAccountWidget(this);
manageAccountWidget->setDescriptionLabelText(i18n("Notes accounts"));
vboxAccountWidget->addWidget(manageAccountWidget);
......@@ -231,7 +231,7 @@ void KNoteCollectionConfigWidget::slotRenameCollection()
col.setName(name);
}
Akonadi::CollectionModifyJob *job = new Akonadi::CollectionModifyJob(col, this);
auto *job = new Akonadi::CollectionModifyJob(col, this);
connect(job, &Akonadi::CollectionModifyJob::result, this, &KNoteCollectionConfigWidget::slotCollectionModifyFinished);
job->start();
}
......@@ -299,7 +299,7 @@ void KNoteCollectionConfigWidget::updateCollectionsRecursive()
i.next();
Akonadi::Collection collection = i.key();
Akonadi::CollectionModifyJob *modifyJob = nullptr;
NoteShared::ShowFolderNotesAttribute *attr = collection.attribute<NoteShared::ShowFolderNotesAttribute>();
auto *attr = collection.attribute<NoteShared::ShowFolderNotesAttribute>();
const bool selected = i.value();
if (selected && !attr) {
attr = collection.attribute<NoteShared::ShowFolderNotesAttribute>(Akonadi::Collection::AddIfMissing);
......@@ -319,7 +319,7 @@ void KNoteCollectionConfigWidget::updateCollectionsRecursive()
void KNoteCollectionConfigWidget::slotModifyJobDone(KJob *job)
{
Akonadi::CollectionModifyJob *modifyJob = qobject_cast<Akonadi::CollectionModifyJob *>(job);
auto *modifyJob = qobject_cast<Akonadi::CollectionModifyJob *>(job);
if (modifyJob && job->error()) {
if (job->property("AttributeAdded").toBool()) {
qCWarning(KNOTES_LOG) << "Failed to append ShowFolderNotesAttribute to collection"
......
......@@ -123,7 +123,7 @@ Q_DECL_EXPORT KCModule *create_knote_config_misc(QWidget *parent)
KNoteDisplayConfig::KNoteDisplayConfig(QWidget *parent)
: KCModule(parent)
{
QVBoxLayout *lay = new QVBoxLayout(this);
auto *lay = new QVBoxLayout(this);
QWidget *w = new KNoteDisplayConfigWidget(true);
lay->addWidget(w);
lay->addStretch();
......@@ -144,7 +144,7 @@ void KNoteDisplayConfig::save()
KNoteEditorConfig::KNoteEditorConfig(QWidget *parent)
: KCModule(parent)
{
QVBoxLayout *lay = new QVBoxLayout(this);
auto *lay = new QVBoxLayout(this);
QWidget *w = new KNoteEditorConfigWidget(this);
lay->addWidget(w);
lay->addStretch();
......@@ -165,7 +165,7 @@ void KNoteEditorConfig::load()
KNoteMiscConfig::KNoteMiscConfig(QWidget *parent)
: KCModule(parent)
{
QVBoxLayout *lay = new QVBoxLayout(this);
auto *lay = new QVBoxLayout(this);
lay->setContentsMargins(0, 0, 0, 0);
QCheckBox *kcfg_SystemTrayShowNotes = new QCheckBox(i18n("Show number of notes in tray icon"), this);
......@@ -173,7 +173,7 @@ KNoteMiscConfig::KNoteMiscConfig(QWidget *parent)
kcfg_SystemTrayShowNotes->setObjectName(QStringLiteral("kcfg_SystemTrayShowNotes"));
lay->addWidget(kcfg_SystemTrayShowNotes);
QHBoxLayout *hbox = new QHBoxLayout;
auto *hbox = new QHBoxLayout;
lay->addLayout(hbox);
QLabel *label_DefaultTitle = new QLabel(i18n("Default Title:"), this);
hbox->addWidget(label_DefaultTitle);
......@@ -232,10 +232,10 @@ void KNoteMiscConfig::slotHelpLinkClicked(const QString &)
KNotePrintConfig::KNotePrintConfig(QWidget *parent)
: KCModule(parent)
{
QVBoxLayout *lay = new QVBoxLayout(this);
auto *lay = new QVBoxLayout(this);
QWidget *w = new QWidget(this);
lay->addWidget(w);
QGridLayout *layout = new QGridLayout(w);
auto *layout = new QGridLayout(w);
layout->setContentsMargins(0, 0, 0, 0);
QLabel *label_PrintAction = new QLabel(i18n("Theme:"), this);
......@@ -246,7 +246,7 @@ KNotePrintConfig::KNotePrintConfig(QWidget *parent)
label_PrintAction->setBuddy(mSelectTheme);
layout->addWidget(mSelectTheme, 0, 1);
if (KAuthorized::authorize(QStringLiteral("ghns"))) {