diff --git a/src/KJotsMain.cpp b/src/KJotsMain.cpp --- a/src/KJotsMain.cpp +++ b/src/KJotsMain.cpp @@ -47,14 +47,13 @@ // Main widget // - KStandardAction::quit(this, SLOT(onQuit()), actionCollection()); + KStandardAction::quit(this, &KJotsMain::onQuit, actionCollection()); component = new KJotsWidget(this, this); setCentralWidget(component); - connect(component, SIGNAL(activeAnchorChanged(QString,QString)), - SLOT(activeAnchorChanged(QString,QString))); + connect(component, &KJotsWidget::activeAnchorChanged, this, &KJotsMain::activeAnchorChanged); setupGUI(); connect(component, &KJotsWidget::captionChanged, this, &KJotsMain::updateCaption); diff --git a/src/kjotsbrowser.h b/src/kjotsbrowser.h --- a/src/kjotsbrowser.h +++ b/src/kjotsbrowser.h @@ -37,9 +37,6 @@ Q_SIGNALS: void linkClicked(const QUrl &); - -private: - QItemSelectionModel *m_itemSelectionModel; }; #endif diff --git a/src/kjotsconfigdlg.cpp b/src/kjotsconfigdlg.cpp --- a/src/kjotsconfigdlg.cpp +++ b/src/kjotsconfigdlg.cpp @@ -45,7 +45,7 @@ QHBoxLayout *lay = new QHBoxLayout(this); miscPage = new confPageMisc(nullptr); lay->addWidget(miscPage); - connect(miscPage->autoSaveInterval, static_cast(&QSpinBox::valueChanged), this, &KJotsConfigMisc::modified); + connect(miscPage->autoSaveInterval, qOverload(&QSpinBox::valueChanged), this, &KJotsConfigMisc::modified); connect(miscPage->autoSave, &QCheckBox::stateChanged, this, &KJotsConfigMisc::modified); load(); } diff --git a/src/kjotsedit.cpp b/src/kjotsedit.cpp --- a/src/kjotsedit.cpp +++ b/src/kjotsedit.cpp @@ -106,13 +106,13 @@ { actionCollection = collection; - connect(actionCollection->action(QLatin1String("auto_bullet")), SIGNAL(triggered()), SLOT(onAutoBullet())); - connect(actionCollection->action(QLatin1String("auto_decimal")), SIGNAL(triggered()), SLOT(onAutoDecimal())); //auto decimal list - connect(actionCollection->action(QLatin1String("manage_link")), SIGNAL(triggered()), SLOT(onLinkify())); - connect(actionCollection->action(QLatin1String("insert_checkmark")), SIGNAL(triggered()), SLOT(addCheckmark())); - connect(actionCollection->action(QLatin1String("manual_save")), SIGNAL(triggered()), SLOT(savePage())); - connect(actionCollection->action(QLatin1String("insert_date")), SIGNAL(triggered()), SLOT(insertDate())); - connect(actionCollection->action(QLatin1String("insert_image")), SIGNAL(triggered()), SLOT(insertImage())); + connect(actionCollection->action(QLatin1String("auto_bullet")), &QAction::triggered, this, &KJotsEdit::onAutoBullet); + connect(actionCollection->action(QLatin1String("auto_decimal")), &QAction::triggered, this, &KJotsEdit::onAutoDecimal); + connect(actionCollection->action(QLatin1String("manage_link")), &QAction::triggered, this, &KJotsEdit::onLinkify); + connect(actionCollection->action(QLatin1String("insert_checkmark")), &QAction::triggered, this, &KJotsEdit::addCheckmark); + connect(actionCollection->action(QLatin1String("manual_save")), &QAction::triggered, this, &KJotsEdit::savePage); + connect(actionCollection->action(QLatin1String("insert_date")), &QAction::triggered, this, &KJotsEdit::insertDate); + connect(actionCollection->action(QLatin1String("insert_image")), &QAction::triggered, this, &KJotsEdit::insertImage); } void KJotsEdit::insertDate() diff --git a/src/kjotslinkdialog.cpp b/src/kjotslinkdialog.cpp --- a/src/kjotslinkdialog.cpp +++ b/src/kjotslinkdialog.cpp @@ -111,8 +111,7 @@ mainLayout->addWidget(buttonBox); textLineEdit->setFocus(); - connect(hrefCombo, SIGNAL(editTextChanged(QString)), - this, SLOT(trySetEntry(QString))); + connect(hrefCombo, &QComboBox::editTextChanged, this, &KJotsLinkDialog::trySetEntry); } void KJotsLinkDialog::setLinkText(const QString &linkText) diff --git a/src/kjotsmodel.cpp b/src/kjotsmodel.cpp --- a/src/kjotsmodel.cpp +++ b/src/kjotsmodel.cpp @@ -43,8 +43,8 @@ Q_DECLARE_METATYPE(QTextDocument *) KJotsEntity::KJotsEntity(const QModelIndex &index, QObject *parent) : QObject(parent) + , m_index(index) { - m_index = QPersistentModelIndex(index); } void KJotsEntity::setIndex(const QModelIndex &index) diff --git a/src/kjotspart.cpp b/src/kjotspart.cpp --- a/src/kjotspart.cpp +++ b/src/kjotspart.cpp @@ -69,7 +69,7 @@ setComponentName(QStringLiteral("kjots"), QStringLiteral("kjots")); setXMLFile(QStringLiteral("kjotspartui.rc")); - QTimer::singleShot(0, this, SLOT(delayedInitialization())); + QTimer::singleShot(0, this, &KJotsPart::delayedInitialization); } KJotsPart::~KJotsPart() @@ -81,8 +81,7 @@ { QAction *action = new QAction(QIcon::fromTheme(QLatin1String("configure")), i18n("&Configure KJots..."), this); actionCollection()->addAction(QLatin1String("kjots_configure"), action); - connect(action, SIGNAL(triggered(bool)), mComponent, - SLOT(configure())); + connect(action, &QAction::triggered, mComponent, &KJotsWidget::configure); } bool KJotsPart::openFile() @@ -92,8 +91,7 @@ void KJotsPart::delayedInitialization() { - connect(mComponent, SIGNAL(activeAnchorChanged(QString,QString)), - SLOT(activeAnchorChanged(QString,QString))); + connect(mComponent, &KJotsWidget::activeAnchorChanged, this, &KJotsPart::activeAnchorChanged); } void KJotsPart::activeAnchorChanged(const QString &anchorTarget, const QString &anchorText) diff --git a/src/kjotsreplacenextdialog.cpp b/src/kjotsreplacenextdialog.cpp --- a/src/kjotsreplacenextdialog.cpp +++ b/src/kjotsreplacenextdialog.cpp @@ -38,21 +38,14 @@ QDialogButtonBox *buttonBox = new QDialogButtonBox; QPushButton *button = buttonBox->addButton(i18n("&All"), QDialogButtonBox::NoRole); - connect(button, SIGNAL(clicked(bool)), this, SLOT(onHandleAll())); + connect(button, &QPushButton::clicked, this, &KJotsReplaceNextDialog::onHandleAll); button = buttonBox->addButton(i18n("&Skip"), QDialogButtonBox::NoRole); - connect(button, SIGNAL(clicked(bool)), this, SLOT(onHandleSkip())); + connect(button, &QPushButton::clicked, this, &KJotsReplaceNextDialog::onHandleSkip); button = buttonBox->addButton(i18n("Replace"), QDialogButtonBox::NoRole); - connect(button, SIGNAL(clicked(bool)), this, SLOT(onHandleReplace())); + connect(button, &QPushButton::clicked, this, &KJotsReplaceNextDialog::onHandleReplace); button = buttonBox->addButton(QDialogButtonBox::Close); - connect(button, SIGNAL(clicked(bool)), this, SLOT(reject())); + connect(button, &QPushButton::clicked, this, &KJotsReplaceNextDialog::reject); layout->addWidget(buttonBox); - - QVBoxLayout - setMainWidget(m_mainLabel); - - connect(this, SIGNAL(user1Clicked()), SLOT(onHandleAll())); - connect(this, SIGNAL(user2Clicked()), SLOT(onHandleSkip())); - connect(this, SIGNAL(user3Clicked()), SLOT(onHandleReplace())); } void KJotsReplaceNextDialog::setLabel(const QString &pattern, const QString &replacement) diff --git a/src/kjotswidget.h b/src/kjotswidget.h --- a/src/kjotswidget.h +++ b/src/kjotswidget.h @@ -76,14 +76,11 @@ QTextEdit *activeEditor(); public Q_SLOTS: + void configure(); void prevPage(); void nextPage(); void prevBook(); void nextBook(); - bool canGoNextPage() const; - bool canGoPreviousPage() const; - bool canGoNextBook() const; - bool canGoPreviousBook() const; void updateCaption(); void updateMenu(); @@ -111,6 +108,12 @@ void activeAnchorChanged(const QString &anchorTarget, const QString &anchorText); protected: + bool canGo(int role, int step) const; + bool canGoNextPage() const; + bool canGoPreviousPage() const; + bool canGoNextBook() const; + bool canGoPreviousBook() const; + QString renderSelectionToHtml(); QString renderSelectionToXml(); QString renderSelectionToPlainText(); @@ -141,14 +144,12 @@ void delayedInitialization(); void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); void bookshelfEditItemFinished(QWidget *, QAbstractItemDelegate::EndEditHint); - bool canGo(int role, int step) const; void newPageResult(KJob *job); void newBookResult(KJob *job); void copySelectionToTitle(); void copy(); - void configure(); void onShowSearch(); void onUpdateSearch(); diff --git a/src/kjotswidget.cpp b/src/kjotswidget.cpp --- a/src/kjotswidget.cpp +++ b/src/kjotswidget.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include // Akonadi @@ -324,20 +325,20 @@ action->setText(i18n("Sort children by creation date")); connect(action, &QAction::triggered, this, &KJotsWidget::actionSortChildrenByDate); - action = KStandardAction::cut(editor, SLOT(cut()), actionCollection); + action = KStandardAction::cut(editor, &KJotsEdit::cut, actionCollection); connect(editor, &KJotsEdit::copyAvailable, action, &QAction::setEnabled); action->setEnabled(false); - action = KStandardAction::copy(this, SLOT(copy()), actionCollection); + action = KStandardAction::copy(this, &KJotsWidget::copy, actionCollection); connect(editor, &KJotsEdit::copyAvailable, action, &QAction::setEnabled); connect(browser, &KJotsBrowser::copyAvailable, action, &QAction::setEnabled); action->setEnabled(false); - KStandardAction::paste(editor, SLOT(paste()), actionCollection); + KStandardAction::paste(editor, &KJotsEdit::paste, actionCollection); - KStandardAction::undo(editor, SLOT(undo()), actionCollection); - KStandardAction::redo(editor, SLOT(redo()), actionCollection); - KStandardAction::selectAll(editor, SLOT(selectAll()), actionCollection); + KStandardAction::undo(editor, &KJotsEdit::undo, actionCollection); + KStandardAction::redo(editor, &KJotsEdit::redo, actionCollection); + KStandardAction::selectAll(editor, &KJotsEdit::selectAll, actionCollection); action = actionCollection->addAction(QLatin1String("copyIntoTitle")); action->setText(i18n("Copy &into Page Title")); @@ -351,15 +352,15 @@ action->setText(i18nc("@action Paste the text in the clipboard without rich text formatting.", "Paste Plain Text")); connect(action, &QAction::triggered, editor, &KJotsEdit::pastePlainText); - KStandardAction::preferences(this, SLOT(configure()), actionCollection); + KStandardAction::preferences(this, &KJotsWidget::configure, actionCollection); bookmarkMenu = actionCollection->add(QLatin1String("bookmarks")); bookmarkMenu->setText(i18n("&Bookmarks")); KJotsBookmarks *bookmarks = new KJotsBookmarks(treeview); connect(bookmarks, &KJotsBookmarks::openLink, this, &KJotsWidget::openLink); KBookmarkMenu *bmm = new KBookmarkMenu( KBookmarkManager::managerForFile( - QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).first() + QStringLiteral("/kjots/bookmarks.xml"), + QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/kjots/bookmarks.xml"), QStringLiteral("kjots")), bookmarks, bookmarkMenu->menu()); @@ -372,10 +373,10 @@ actionCollection->addAction(QStringLiteral("add_bookmarks_list"), bmm->bookmarkTabsAsFolderAction()); - KStandardAction::find(this, SLOT(onShowSearch()), actionCollection); - action = KStandardAction::findNext(this, SLOT(onRepeatSearch()), actionCollection); + KStandardAction::find(this, &KJotsWidget::onShowSearch, actionCollection); + action = KStandardAction::findNext(this, &KJotsWidget::onRepeatSearch, actionCollection); action->setEnabled(false); - KStandardAction::replace(this, SLOT(onShowReplace()), actionCollection); + KStandardAction::replace(this, &KJotsWidget::onShowReplace, actionCollection); action = actionCollection->addAction(QLatin1String("save_to")); action->setText(i18n("Rename...")); @@ -404,17 +405,17 @@ connect(action, &QAction::triggered, this, &KJotsWidget::exportSelectionToXml); exportMenu->menu()->addAction(action); - KStandardAction::print(this, SLOT(printSelection()), actionCollection); - KStandardAction::printPreview(this, SLOT(printPreviewSelection()), actionCollection); + KStandardAction::print(this, &KJotsWidget::printSelection, actionCollection); + KStandardAction::printPreview(this, &KJotsWidget::printPreviewSelection, actionCollection); if (!KJotsSettings::splitterSizes().isEmpty()) { m_splitter->setSizes(KJotsSettings::splitterSizes()); } - QTimer::singleShot(0, this, SLOT(delayedInitialization())); + QTimer::singleShot(0, this, &KJotsWidget::delayedInitialization); - connect(treeview->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(updateMenu())); - connect(treeview->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(updateCaption())); + connect(treeview->selectionModel(), &QItemSelectionModel::selectionChanged, this, &KJotsWidget::updateMenu); + connect(treeview->selectionModel(), &QItemSelectionModel::selectionChanged, this, &KJotsWidget::updateCaption); connect(m_kjotsModel, &Akonadi::EntityTreeModel::modelAboutToBeReset, this, &KJotsWidget::saveState); connect(m_kjotsModel, &Akonadi::EntityTreeModel::modelReset, this, &KJotsWidget::restoreState); @@ -457,7 +458,7 @@ connect(searchDialog, &KFindDialog::okClicked, this, &KJotsWidget::onStartSearch); connect(searchDialog, &KFindDialog::cancelClicked, this, &KJotsWidget::onEndSearch); - connect(treeview->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(onUpdateSearch())); + connect(treeview->selectionModel(), &QItemSelectionModel::selectionChanged, this, &KJotsWidget::onUpdateSearch); connect(searchDialog, &KFindDialog::optionsChanged, this, &KJotsWidget::onUpdateSearch); connect(searchAllPages, &QCheckBox::stateChanged, this, &KJotsWidget::onUpdateSearch); @@ -521,17 +522,15 @@ updateConfiguration(); connect(m_autosaveTimer, &QTimer::timeout, editor, &KJotsEdit::savePage); - connect(treeview->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), m_autosaveTimer, SLOT(start())); + connect(treeview->selectionModel(), &QItemSelectionModel::selectionChanged, m_autosaveTimer, qOverload<>(&QTimer::start)); treeview->delayedInitialization(); editor->delayedInitialization(m_xmlGuiClient->actionCollection()); browser->delayedInitialization(); - connect(treeview->itemDelegate(), SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), - SLOT(bookshelfEditItemFinished(QWidget*,QAbstractItemDelegate::EndEditHint))); + connect(treeview->itemDelegate(), &QItemDelegate::closeEditor, this, &KJotsWidget::bookshelfEditItemFinished); - connect(editor, SIGNAL(currentCharFormatChanged(QTextCharFormat)), - SLOT(currentCharFormatChanged(QTextCharFormat))); + connect(editor, &KJotsEdit::currentCharFormatChanged, this, &KJotsWidget::currentCharFormatChanged); updateMenu(); } @@ -655,7 +654,7 @@ { // create a new preferences dialog... KJotsConfigDlg *dialog = new KJotsConfigDlg(i18n("Settings"), this); - connect(dialog, SIGNAL(configCommitted()), SLOT(updateConfiguration())); + connect(dialog, qOverload<>(&KJotsConfigDlg::configCommitted), this, &KJotsWidget::updateConfiguration); dialog->show(); } @@ -1406,7 +1405,7 @@ replaceStartPage = treeview->selectionModel()->selectedRows().first(); //allow KReplaceDialog to exit so the user can see. - QTimer::singleShot(0, this, SLOT(onRepeatReplace())); + QTimer::singleShot(0, this, &KJotsWidget::onRepeatReplace); } /*! diff --git a/src/noteshared/localresourcecreator.cpp b/src/noteshared/localresourcecreator.cpp --- a/src/noteshared/localresourcecreator.cpp +++ b/src/noteshared/localresourcecreator.cpp @@ -21,7 +21,6 @@ #include #include -#pragma message("port QT5") #include "maildirsettings.h" @@ -47,13 +46,9 @@ void LocalResourceCreator::createIfMissing() { const Akonadi::AgentInstance::List instances = Akonadi::AgentManager::self()->instances(); - bool found = false; - for (const Akonadi::AgentInstance &instance : instances) { - if (instance.type().identifier() == akonadiNotesInstanceName()) { - found = true; - break; - } - } + const bool found = std::any_of(instances.cbegin(), instances.cend(), [](const Akonadi::AgentInstance &instance) { + return instance.type().identifier() == akonadiNotesInstanceName(); + }); if (found) { deleteLater(); return; diff --git a/src/noteshared/noteeditorutils.cpp b/src/noteshared/noteeditorutils.cpp --- a/src/noteshared/noteeditorutils.cpp +++ b/src/noteshared/noteeditorutils.cpp @@ -50,7 +50,7 @@ editor->insertPlainText(QLocale().toString(QDateTime::currentDateTime(), QLocale::ShortFormat) + QLatin1Char(' ')); } -void NoteEditorUtils::insertImage(QTextDocument *doc, QTextCursor &cursor, QTextEdit *par) +void NoteEditorUtils::insertImage(QTextDocument * /*doc*/, QTextCursor &/*cursor*/, QTextEdit *par) { QString imageFileName = QFileDialog::getOpenFileName(par, i18n("Select image file"), QLatin1String("."), QLatin1String("Images (*.png *.bmp *.jpg *.jpeg *.jpe)")); if (!imageFileName.isEmpty()) {