diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2016-06-27 22:25:11 +0300 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2016-06-28 08:47:26 +0000 |
commit | 7609e56ee365520011920eee07e7e7c876eb5683 (patch) | |
tree | a84a40889c3906913f87a5aac481503689bb3b37 | |
parent | 090c1069297883fd4073152d0c62fd4c8e08afb3 (diff) |
QmlJS[|Editor|Tools]: Use Qt5-style connects
The heavy lifting was done by clazy.
Change-Id: I56550546b341d486d321329e9a90b9369d56af40
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
32 files changed, 143 insertions, 166 deletions
diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp index aa388312f4..f739668f9f 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.cpp +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.cpp @@ -104,12 +104,13 @@ ModelManagerInterface::ModelManagerInterface(QObject *parent) m_updateCppQmlTypesTimer = new QTimer(this); m_updateCppQmlTypesTimer->setInterval(1000); m_updateCppQmlTypesTimer->setSingleShot(true); - connect(m_updateCppQmlTypesTimer, SIGNAL(timeout()), SLOT(startCppQmlTypeUpdate())); + connect(m_updateCppQmlTypesTimer, &QTimer::timeout, + this, &ModelManagerInterface::startCppQmlTypeUpdate); m_asyncResetTimer = new QTimer(this); m_asyncResetTimer->setInterval(15000); m_asyncResetTimer->setSingleShot(true); - connect(m_asyncResetTimer, SIGNAL(timeout()), SLOT(resetCodeModel())); + connect(m_asyncResetTimer, &QTimer::timeout, this, &ModelManagerInterface::resetCodeModel); qRegisterMetaType<QmlJS::Document::Ptr>("QmlJS::Document::Ptr"); qRegisterMetaType<QmlJS::LibraryInfo>("QmlJS::LibraryInfo"); diff --git a/src/libs/qmljs/qmljsmodelmanagerinterface.h b/src/libs/qmljs/qmljsmodelmanagerinterface.h index 142fc54c17..568fb63593 100644 --- a/src/libs/qmljs/qmljsmodelmanagerinterface.h +++ b/src/libs/qmljs/qmljsmodelmanagerinterface.h @@ -205,9 +205,11 @@ public: PathsAndLanguages paths, ModelManagerInterface *modelManager, bool emitDocChangedOnDisk, bool libOnly = true); -public slots: + virtual void resetCodeModel(); void removeProjectInfo(ProjectExplorer::Project *project); + void maybeQueueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc); + signals: void documentUpdated(QmlJS::Document::Ptr doc); void documentChangedOnDisk(QmlJS::Document::Ptr doc); @@ -215,12 +217,11 @@ signals: void libraryInfoUpdated(const QString &path, const QmlJS::LibraryInfo &info); void projectInfoUpdated(const ProjectInfo &pinfo); void projectPathChanged(const QString &projectPath); -protected slots: - void maybeQueueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc); - void queueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc, bool scan); - void asyncReset(); - virtual void startCppQmlTypeUpdate(); + protected: + Q_INVOKABLE void queueCppQmlTypeUpdate(const CPlusPlus::Document::Ptr &doc, bool scan); + Q_INVOKABLE void asyncReset(); + virtual void startCppQmlTypeUpdate(); QMutex *mutex() const; virtual QHash<QString,Dialect> languageForSuffix() const; virtual void writeMessageInternal(const QString &msg) const; diff --git a/src/libs/qmljs/qmljsplugindumper.cpp b/src/libs/qmljs/qmljsplugindumper.cpp index f8f726f2cf..7d13482272 100644 --- a/src/libs/qmljs/qmljsplugindumper.cpp +++ b/src/libs/qmljs/qmljsplugindumper.cpp @@ -51,8 +51,8 @@ Utils::FileSystemWatcher *PluginDumper::pluginWatcher() if (!m_pluginWatcher) { m_pluginWatcher = new Utils::FileSystemWatcher(this); m_pluginWatcher->setObjectName(QLatin1String("PluginDumperWatcher")); - connect(m_pluginWatcher, SIGNAL(fileChanged(QString)), - this, SLOT(pluginChanged(QString))); + connect(m_pluginWatcher, &Utils::FileSystemWatcher::fileChanged, + this, &PluginDumper::pluginChanged); } return m_pluginWatcher; } @@ -509,8 +509,10 @@ void PluginDumper::runQmlDump(const QmlJS::ModelManagerInterface::ProjectInfo &i { QProcess *process = new QProcess(this); process->setEnvironment(info.qmlDumpEnvironment.toStringList()); - connect(process, SIGNAL(finished(int)), SLOT(qmlPluginTypeDumpDone(int))); - connect(process, SIGNAL(error(QProcess::ProcessError)), SLOT(qmlPluginTypeDumpError(QProcess::ProcessError))); + connect(process, static_cast<void (QProcess::*)(int)>(&QProcess::finished), + this, &PluginDumper::qmlPluginTypeDumpDone); + connect(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error), + this, &PluginDumper::qmlPluginTypeDumpError); process->start(info.qmlDumpPath, arguments); m_runningQmldumps.insert(process, importPath); } diff --git a/src/libs/qmljs/qmljsplugindumper.h b/src/libs/qmljs/qmljsplugindumper.h index 31c9b5e019..7d29e6ef3d 100644 --- a/src/libs/qmljs/qmljsplugindumper.h +++ b/src/libs/qmljs/qmljsplugindumper.h @@ -52,13 +52,13 @@ public: void scheduleRedumpPlugins(); void scheduleMaybeRedumpBuiltins(const QmlJS::ModelManagerInterface::ProjectInfo &info); -private slots: - void onLoadBuiltinTypes(const QmlJS::ModelManagerInterface::ProjectInfo &info, - bool force = false); - void onLoadPluginTypes(const QString &libraryPath, const QString &importPath, - const QString &importUri, const QString &importVersion); - void dumpBuiltins(const QmlJS::ModelManagerInterface::ProjectInfo &info); - void dumpAllPlugins(); +private: + Q_INVOKABLE void onLoadBuiltinTypes(const QmlJS::ModelManagerInterface::ProjectInfo &info, + bool force = false); + Q_INVOKABLE void onLoadPluginTypes(const QString &libraryPath, const QString &importPath, + const QString &importUri, const QString &importVersion); + Q_INVOKABLE void dumpBuiltins(const QmlJS::ModelManagerInterface::ProjectInfo &info); + Q_INVOKABLE void dumpAllPlugins(); void qmlPluginTypeDumpDone(int exitCode); void qmlPluginTypeDumpError(QProcess::ProcessError error); void pluginChanged(const QString &pluginLibrary); diff --git a/src/plugins/qmljseditor/qmljscomponentnamedialog.cpp b/src/plugins/qmljseditor/qmljscomponentnamedialog.cpp index 3f9ce30019..6c53cfe62a 100644 --- a/src/plugins/qmljseditor/qmljscomponentnamedialog.cpp +++ b/src/plugins/qmljseditor/qmljscomponentnamedialog.cpp @@ -38,10 +38,10 @@ ComponentNameDialog::ComponentNameDialog(QWidget *parent) : { ui->setupUi(this); - connect(ui->pathEdit, SIGNAL(rawPathChanged(QString)), - this, SLOT(validate())); - connect(ui->componentNameEdit, SIGNAL(textChanged(QString)), - this, SLOT(validate())); + connect(ui->pathEdit, &Utils::PathChooser::rawPathChanged, + this, &ComponentNameDialog::validate); + connect(ui->componentNameEdit, &QLineEdit::textChanged, + this, &ComponentNameDialog::validate); } ComponentNameDialog::~ComponentNameDialog() @@ -139,14 +139,6 @@ void ComponentNameDialog::generateCodePreview() ui->plainTextEdit->appendPlainText(QLatin1String("}")); } -void ComponentNameDialog::choosePath() -{ - QString dir = QFileDialog::getExistingDirectory(this, tr("Choose a path"), - ui->pathEdit->path()); - if (!dir.isEmpty()) - ui->pathEdit->setPath(dir); -} - void ComponentNameDialog::validate() { const QString message = isValid(); diff --git a/src/plugins/qmljseditor/qmljscomponentnamedialog.h b/src/plugins/qmljseditor/qmljscomponentnamedialog.h index 4530914236..dc3f3674c9 100644 --- a/src/plugins/qmljseditor/qmljscomponentnamedialog.h +++ b/src/plugins/qmljseditor/qmljscomponentnamedialog.h @@ -51,8 +51,6 @@ public: void generateCodePreview(); -public slots: - void choosePath(); void validate(); protected: diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index b3ae499c2e..232bbd2b25 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -78,6 +78,7 @@ #include <QFileInfo> #include <QHeaderView> #include <QMenu> +#include <QMetaMethod> #include <QPointer> #include <QScopedPointer> #include <QSignalMapper> @@ -147,11 +148,11 @@ void QmlJSEditorWidget::finalizeInitialization() connect(this->document(), &QTextDocument::modificationChanged, this, &QmlJSEditorWidget::modificationChanged); - connect(m_qmlJsEditorDocument, SIGNAL(updateCodeWarnings(QmlJS::Document::Ptr)), - this, SLOT(updateCodeWarnings(QmlJS::Document::Ptr))); + connect(m_qmlJsEditorDocument, &QmlJSEditorDocument::updateCodeWarnings, + this, &QmlJSEditorWidget::updateCodeWarnings); - connect(m_qmlJsEditorDocument, SIGNAL(semanticInfoUpdated(QmlJSTools::SemanticInfo)), - this, SLOT(semanticInfoUpdated(QmlJSTools::SemanticInfo))); + connect(m_qmlJsEditorDocument, &QmlJSEditorDocument::semanticInfoUpdated, + this, &QmlJSEditorWidget::semanticInfoUpdated); setRequestMarkEnabled(true); createToolBar(); @@ -445,7 +446,9 @@ protected: void QmlJSEditorWidget::setSelectedElements() { - if (!receivers(SIGNAL(selectedElementsChanged(QList<QmlJS::AST::UiObjectMember*>,QString)))) + static const QMetaMethod selectedChangedSignal = + QMetaMethod::fromSignal(&QmlJSEditorWidget::selectedElementsChanged); + if (!isSignalConnected(selectedChangedSignal)) return; QTextCursor tc = textCursor(); @@ -540,11 +543,12 @@ void QmlJSEditorWidget::createToolBar() policy.setHorizontalPolicy(QSizePolicy::Expanding); m_outlineCombo->setSizePolicy(policy); - connect(m_outlineCombo, SIGNAL(activated(int)), this, SLOT(jumpToOutlineElement(int))); - connect(m_qmlJsEditorDocument->outlineModel(), SIGNAL(updated()), - m_outlineCombo->view()/*QTreeView*/, SLOT(expandAll())); - connect(m_qmlJsEditorDocument->outlineModel(), SIGNAL(updated()), - this, SLOT(updateOutlineIndexNow())); + connect(m_outlineCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), + this, &QmlJSEditorWidget::jumpToOutlineElement); + connect(m_qmlJsEditorDocument->outlineModel(), &QmlOutlineModel::updated, + static_cast<QTreeView *>(m_outlineCombo->view()), &QTreeView::expandAll); + connect(m_qmlJsEditorDocument->outlineModel(), &QmlOutlineModel::updated, + this, &QmlJSEditorWidget::updateOutlineIndexNow); connect(this, &QmlJSEditorWidget::cursorPositionChanged, &m_updateOutlineIndexTimer, static_cast<void (QTimer::*)()>(&QTimer::start)); @@ -819,19 +823,12 @@ void QmlJSEditorWidget::showContextPane() } } -void QmlJSEditorWidget::performQuickFix(int index) -{ - m_quickFixes.at(index)->perform(); -} - void QmlJSEditorWidget::contextMenuEvent(QContextMenuEvent *e) { QPointer<QMenu> menu(new QMenu(this)); QMenu *refactoringMenu = new QMenu(tr("Refactoring"), menu); - QSignalMapper mapper; - connect(&mapper, SIGNAL(mapped(int)), this, SLOT(performQuickFix(int))); if (!m_qmlJsEditorDocument->isSemanticInfoOutdated()) { AssistInterface *interface = createAssistInterface(QuickFix, ExplicitlyInvoked); if (interface) { @@ -843,10 +840,8 @@ void QmlJSEditorWidget::contextMenuEvent(QContextMenuEvent *e) for (int index = 0; index < model->size(); ++index) { AssistProposalItem *item = static_cast<AssistProposalItem *>(model->proposalItem(index)); QuickFixOperation::Ptr op = item->data().value<QuickFixOperation::Ptr>(); - m_quickFixes.append(op); QAction *action = refactoringMenu->addAction(op->description()); - mapper.setMapping(action, index); - connect(action, SIGNAL(triggered()), &mapper, SLOT(map())); + connect(action, &QAction::triggered, this, [op]() { op->perform(); }); } delete model; } @@ -873,9 +868,6 @@ void QmlJSEditorWidget::contextMenuEvent(QContextMenuEvent *e) appendStandardContextMenuActions(menu); menu->exec(e->globalPos()); - if (!menu) - return; - m_quickFixes.clear(); delete menu; } diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h index 79d86dbb5a..9a086e65c0 100644 --- a/src/plugins/qmljseditor/qmljseditor.h +++ b/src/plugins/qmljseditor/qmljseditor.h @@ -72,7 +72,6 @@ public: void inspectElementUnderCursor() const; -public slots: void findUsages(); void renameUsages(); void showContextPane(); @@ -81,7 +80,7 @@ signals: void outlineModelIndexChanged(const QModelIndex &index); void selectedElementsChanged(QList<QmlJS::AST::UiObjectMember*> offsets, const QString &wordAtCursor); -private slots: +private: void modificationChanged(bool); void jumpToOutlineElement(int index); @@ -93,7 +92,6 @@ private slots: void semanticInfoUpdated(const QmlJSTools::SemanticInfo &semanticInfo); - void performQuickFix(int index); void updateCodeWarnings(QmlJS::Document::Ptr doc); protected: @@ -127,8 +125,6 @@ private: QModelIndex m_outlineModelIndex; QmlJS::ModelManagerInterface *m_modelManager; - TextEditor::QuickFixOperations m_quickFixes; - QmlJS::IContextPane *m_contextPane; int m_oldCursorPosition; diff --git a/src/plugins/qmljseditor/qmljseditordocument.cpp b/src/plugins/qmljseditor/qmljseditordocument.cpp index 45a01ee5d3..6ef9f3bdee 100644 --- a/src/plugins/qmljseditor/qmljseditordocument.cpp +++ b/src/plugins/qmljseditor/qmljseditordocument.cpp @@ -467,28 +467,32 @@ QmlJSEditorDocumentPrivate::QmlJSEditorDocumentPrivate(QmlJSEditorDocument *pare // code model m_updateDocumentTimer.setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL); m_updateDocumentTimer.setSingleShot(true); - connect(q->document(), SIGNAL(contentsChanged()), &m_updateDocumentTimer, SLOT(start())); - connect(&m_updateDocumentTimer, SIGNAL(timeout()), this, SLOT(reparseDocument())); - connect(modelManager, SIGNAL(documentUpdated(QmlJS::Document::Ptr)), - this, SLOT(onDocumentUpdated(QmlJS::Document::Ptr))); + connect(q->document(), &QTextDocument::contentsChanged, + &m_updateDocumentTimer, static_cast<void (QTimer::*)()>(&QTimer::start)); + connect(&m_updateDocumentTimer, &QTimer::timeout, + this, &QmlJSEditorDocumentPrivate::reparseDocument); + connect(modelManager, &ModelManagerInterface::documentUpdated, + this, &QmlJSEditorDocumentPrivate::onDocumentUpdated); // semantic info m_semanticInfoUpdater = new SemanticInfoUpdater(this); - connect(m_semanticInfoUpdater, SIGNAL(updated(QmlJSTools::SemanticInfo)), - this, SLOT(acceptNewSemanticInfo(QmlJSTools::SemanticInfo))); + connect(m_semanticInfoUpdater, &SemanticInfoUpdater::updated, + this, &QmlJSEditorDocumentPrivate::acceptNewSemanticInfo); m_semanticInfoUpdater->start(); // library info changes m_reupdateSemanticInfoTimer.setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL); m_reupdateSemanticInfoTimer.setSingleShot(true); - connect(&m_reupdateSemanticInfoTimer, SIGNAL(timeout()), this, SLOT(reupdateSemanticInfo())); - connect(modelManager, SIGNAL(libraryInfoUpdated(QString,QmlJS::LibraryInfo)), - &m_reupdateSemanticInfoTimer, SLOT(start())); + connect(&m_reupdateSemanticInfoTimer, &QTimer::timeout, + this, &QmlJSEditorDocumentPrivate::reupdateSemanticInfo); + connect(modelManager, &ModelManagerInterface::libraryInfoUpdated, + &m_reupdateSemanticInfoTimer, static_cast<void (QTimer::*)()>(&QTimer::start)); // outline model m_updateOutlineModelTimer.setInterval(UPDATE_OUTLINE_INTERVAL); m_updateOutlineModelTimer.setSingleShot(true); - connect(&m_updateOutlineModelTimer, SIGNAL(timeout()), this, SLOT(updateOutlineModel())); + connect(&m_updateOutlineModelTimer, &QTimer::timeout, + this, &QmlJSEditorDocumentPrivate::updateOutlineModel); modelManager->updateSourceFiles(QStringList(parent->filePath().toString()), false); } @@ -589,8 +593,8 @@ QmlJSEditorDocument::QmlJSEditorDocument() : d(new Internal::QmlJSEditorDocumentPrivate(this)) { setId(Constants::C_QMLJSEDITOR_ID); - connect(this, SIGNAL(tabSettingsChanged()), - d, SLOT(invalidateFormatterCache())); + connect(this, &TextEditor::TextDocument::tabSettingsChanged, + d, &Internal::QmlJSEditorDocumentPrivate::invalidateFormatterCache); setSyntaxHighlighter(new QmlJSHighlighter(document())); setIndenter(new Internal::Indenter); } diff --git a/src/plugins/qmljseditor/qmljseditordocument_p.h b/src/plugins/qmljseditor/qmljseditordocument_p.h index 46a6a36c65..f2cee06d76 100644 --- a/src/plugins/qmljseditor/qmljseditordocument_p.h +++ b/src/plugins/qmljseditor/qmljseditordocument_p.h @@ -50,7 +50,6 @@ public: QmlJSEditorDocumentPrivate(QmlJSEditorDocument *parent); ~QmlJSEditorDocumentPrivate(); -public slots: void invalidateFormatterCache(); void reparseDocument(); void onDocumentUpdated(QmlJS::Document::Ptr doc); diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index 794bd99416..6bd676e7b8 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -104,16 +104,16 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e // QML task updating manager m_qmlTaskManager = new QmlTaskManager; addAutoReleasedObject(m_qmlTaskManager); - connect(m_modelManager, SIGNAL(documentChangedOnDisk(QmlJS::Document::Ptr)), - m_qmlTaskManager, SLOT(updateMessages())); + connect(m_modelManager, &QmlJS::ModelManagerInterface::documentChangedOnDisk, + m_qmlTaskManager, &QmlTaskManager::updateMessages); // recompute messages when information about libraries changes - connect(m_modelManager, SIGNAL(libraryInfoUpdated(QString,QmlJS::LibraryInfo)), - m_qmlTaskManager, SLOT(updateMessages())); + connect(m_modelManager, &QmlJS::ModelManagerInterface::libraryInfoUpdated, + m_qmlTaskManager, &QmlTaskManager::updateMessages); // recompute messages when project data changes (files added or removed) - connect(m_modelManager, SIGNAL(projectInfoUpdated(ProjectInfo)), - m_qmlTaskManager, SLOT(updateMessages())); - connect(m_modelManager, SIGNAL(aboutToRemoveFiles(QStringList)), - m_qmlTaskManager, SLOT(documentsRemoved(QStringList))); + connect(m_modelManager, &QmlJS::ModelManagerInterface::projectInfoUpdated, + m_qmlTaskManager, &QmlTaskManager::updateMessages); + connect(m_modelManager, &QmlJS::ModelManagerInterface::aboutToRemoveFiles, + m_qmlTaskManager, &QmlTaskManager::documentsRemoved); Context context(Constants::C_QMLJSEDITOR_ID); @@ -132,26 +132,26 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e QAction *findUsagesAction = new QAction(tr("Find Usages"), this); cmd = ActionManager::registerAction(findUsagesAction, Constants::FIND_USAGES, context); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U"))); - connect(findUsagesAction, SIGNAL(triggered()), this, SLOT(findUsages())); + connect(findUsagesAction, &QAction::triggered, this, &QmlJSEditorPlugin::findUsages); contextMenu->addAction(cmd); qmlToolsMenu->addAction(cmd); QAction *renameUsagesAction = new QAction(tr("Rename Symbol Under Cursor"), this); cmd = ActionManager::registerAction(renameUsagesAction, Constants::RENAME_USAGES, context); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+R"))); - connect(renameUsagesAction, SIGNAL(triggered()), this, SLOT(renameUsages())); + connect(renameUsagesAction, &QAction::triggered, this, &QmlJSEditorPlugin::renameUsages); contextMenu->addAction(cmd); qmlToolsMenu->addAction(cmd); QAction *semanticScan = new QAction(tr("Run Checks"), this); cmd = ActionManager::registerAction(semanticScan, Id(Constants::RUN_SEMANTIC_SCAN)); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+C"))); - connect(semanticScan, SIGNAL(triggered()), this, SLOT(runSemanticScan())); + connect(semanticScan, &QAction::triggered, this, &QmlJSEditorPlugin::runSemanticScan); qmlToolsMenu->addAction(cmd); m_reformatFileAction = new QAction(tr("Reformat File"), this); cmd = ActionManager::registerAction(m_reformatFileAction, Id(Constants::REFORMAT_FILE), context); - connect(m_reformatFileAction, SIGNAL(triggered()), this, SLOT(reformatFile())); + connect(m_reformatFileAction, &QAction::triggered, this, &QmlJSEditorPlugin::reformatFile); qmlToolsMenu->addAction(cmd); QAction *inspectElementAction = new QAction(tr("Inspect API for Element Under Cursor"), this); @@ -167,7 +167,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e cmd = ActionManager::registerAction(showQuickToolbar, Constants::SHOW_QT_QUICK_HELPER, context); cmd->setDefaultKeySequence(UseMacShortcuts ? QKeySequence(Qt::META + Qt::ALT + Qt::Key_Space) : QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Space)); - connect(showQuickToolbar, SIGNAL(triggered()), this, SLOT(showContextPane())); + connect(showQuickToolbar, &QAction::triggered, this, &QmlJSEditorPlugin::showContextPane); contextMenu->addAction(cmd); qmlToolsMenu->addAction(cmd); @@ -195,7 +195,8 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e addAutoReleasedObject(new QuickToolBar); addAutoReleasedObject(new QuickToolBarSettingsPage); - connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), SLOT(currentEditorChanged(Core::IEditor*))); + connect(EditorManager::instance(), &EditorManager::currentEditorChanged, + this, &QmlJSEditorPlugin::currentEditorChanged); return true; } @@ -275,10 +276,10 @@ void QmlJSEditorPlugin::currentEditorChanged(IEditor *editor) m_currentDocument->disconnect(this); m_currentDocument = document; if (document) { - connect(document->document(), SIGNAL(contentsChanged()), - this, SLOT(checkCurrentEditorSemanticInfoUpToDate())); - connect(document, SIGNAL(semanticInfoUpdated(QmlJSTools::SemanticInfo)), - this, SLOT(checkCurrentEditorSemanticInfoUpToDate())); + connect(document->document(), &QTextDocument::contentsChanged, + this, &QmlJSEditorPlugin::checkCurrentEditorSemanticInfoUpToDate); + connect(document, &QmlJSEditorDocument::semanticInfoUpdated, + this, &QmlJSEditorPlugin::checkCurrentEditorSemanticInfoUpToDate); } } diff --git a/src/plugins/qmljseditor/qmljseditorplugin.h b/src/plugins/qmljseditor/qmljseditorplugin.h index e96e59163b..a85f16b389 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.h +++ b/src/plugins/qmljseditor/qmljseditorplugin.h @@ -73,18 +73,16 @@ public: Utils::JsonSchemaManager *jsonManager() const; -public Q_SLOTS: void findUsages(); void renameUsages(); void reformatFile(); void showContextPane(); -private Q_SLOTS: +private: void currentEditorChanged(Core::IEditor *editor); void runSemanticScan(); void checkCurrentEditorSemanticInfoUpToDate(); -private: Core::Command *addToolAction(QAction *a, Core::Context &context, Core::Id id, Core::ActionContainer *c1, const QString &keySequence); diff --git a/src/plugins/qmljseditor/qmljsfindreferences.cpp b/src/plugins/qmljseditor/qmljsfindreferences.cpp index 6c7ff6eb13..8927407c87 100644 --- a/src/plugins/qmljseditor/qmljsfindreferences.cpp +++ b/src/plugins/qmljseditor/qmljsfindreferences.cpp @@ -782,8 +782,8 @@ FindReferences::FindReferences(QObject *parent) : QObject(parent) { m_watcher.setPendingResultsLimit(1); - connect(&m_watcher, SIGNAL(resultsReadyAt(int,int)), this, SLOT(displayResults(int,int))); - connect(&m_watcher, SIGNAL(finished()), this, SLOT(searchFinished())); + connect(&m_watcher, &QFutureWatcherBase::resultsReadyAt, this, &FindReferences::displayResults); + connect(&m_watcher, &QFutureWatcherBase::finished, this, &FindReferences::searchFinished); } FindReferences::~FindReferences() @@ -955,19 +955,19 @@ void FindReferences::displayResults(int first, int last) label, QString(), symbolName, SearchResultWindow::SearchAndReplace, SearchResultWindow::PreserveCaseDisabled); m_currentSearch->setTextToReplace(replacement); - connect(m_currentSearch, SIGNAL(replaceButtonClicked(QString,QList<Core::SearchResultItem>,bool)), - SLOT(onReplaceButtonClicked(QString,QList<Core::SearchResultItem>,bool))); + connect(m_currentSearch.data(), &SearchResult::replaceButtonClicked, + this, &FindReferences::onReplaceButtonClicked); } - connect(m_currentSearch, SIGNAL(activated(Core::SearchResultItem)), - this, SLOT(openEditor(Core::SearchResultItem))); - connect(m_currentSearch, SIGNAL(cancelled()), this, SLOT(cancel())); - connect(m_currentSearch, SIGNAL(paused(bool)), this, SLOT(setPaused(bool))); + connect(m_currentSearch.data(), &SearchResult::activated, + this, &FindReferences::openEditor); + connect(m_currentSearch.data(), &SearchResult::cancelled, this, &FindReferences::cancel); + connect(m_currentSearch.data(), &SearchResult::paused, this, &FindReferences::setPaused); SearchResultWindow::instance()->popup(IOutputPane::Flags(IOutputPane::ModeSwitch | IOutputPane::WithFocus)); FutureProgress *progress = ProgressManager::addTask( m_watcher.future(), tr("Searching for Usages"), QmlJSEditor::Constants::TASK_SEARCH); - connect(progress, SIGNAL(clicked()), m_currentSearch, SLOT(popup())); + connect(progress, &FutureProgress::clicked, m_currentSearch.data(), &SearchResult::popup); ++first; } diff --git a/src/plugins/qmljseditor/qmljsfindreferences.h b/src/plugins/qmljseditor/qmljsfindreferences.h index 2d8cb9aaeb..e7075b4799 100644 --- a/src/plugins/qmljseditor/qmljsfindreferences.h +++ b/src/plugins/qmljseditor/qmljsfindreferences.h @@ -67,7 +67,7 @@ public: FindReferences(QObject *parent = 0); virtual ~FindReferences(); -Q_SIGNALS: +signals: void changed(); public: @@ -77,7 +77,7 @@ public: static QList<Usage> findUsageOfType(const QString &fileName, const QString typeName); -private Q_SLOTS: +private: void displayResults(int first, int last); void searchFinished(); void cancel(); @@ -85,7 +85,6 @@ private Q_SLOTS: void openEditor(const Core::SearchResultItem &item); void onReplaceButtonClicked(const QString &text, const QList<Core::SearchResultItem> &items, bool preserveCase); -private: QPointer<Core::SearchResult> m_currentSearch; QFutureWatcher<Usage> m_watcher; }; diff --git a/src/plugins/qmljseditor/qmljsoutline.cpp b/src/plugins/qmljseditor/qmljsoutline.cpp index 5018befbc8..bf37940983 100644 --- a/src/plugins/qmljseditor/qmljsoutline.cpp +++ b/src/plugins/qmljseditor/qmljsoutline.cpp @@ -117,7 +117,7 @@ QmlJSOutlineWidget::QmlJSOutlineWidget(QWidget *parent) : m_showBindingsAction->setText(tr("Show All Bindings")); m_showBindingsAction->setCheckable(true); m_showBindingsAction->setChecked(true); - connect(m_showBindingsAction, SIGNAL(toggled(bool)), this, SLOT(setShowBindings(bool))); + connect(m_showBindingsAction, &QAction::toggled, this, &QmlJSOutlineWidget::setShowBindings); setLayout(layout); } @@ -129,16 +129,16 @@ void QmlJSOutlineWidget::setEditor(QmlJSEditorWidget *editor) m_filterModel->setSourceModel(m_editor->qmlJsEditorDocument()->outlineModel()); modelUpdated(); - connect(m_treeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - this, SLOT(updateSelectionInText(QItemSelection))); + connect(m_treeView->selectionModel(), &QItemSelectionModel::selectionChanged, + this, &QmlJSOutlineWidget::updateSelectionInText); - connect(m_treeView, SIGNAL(activated(QModelIndex)), - this, SLOT(focusEditor())); + connect(m_treeView, &QAbstractItemView::activated, + this, &QmlJSOutlineWidget::focusEditor); - connect(m_editor, SIGNAL(outlineModelIndexChanged(QModelIndex)), - this, SLOT(updateSelectionInTree(QModelIndex))); - connect(m_editor->qmlJsEditorDocument()->outlineModel(), SIGNAL(updated()), - this, SLOT(modelUpdated())); + connect(m_editor, &QmlJSEditorWidget::outlineModelIndexChanged, + this, &QmlJSOutlineWidget::updateSelectionInTree); + connect(m_editor->qmlJsEditorDocument()->outlineModel(), &QmlOutlineModel::updated, + this, &QmlJSOutlineWidget::modelUpdated); } QList<QAction*> QmlJSOutlineWidget::filterMenuActions() const diff --git a/src/plugins/qmljseditor/qmljsoutline.h b/src/plugins/qmljseditor/qmljsoutline.h index fc475ed689..799aaf812a 100644 --- a/src/plugins/qmljseditor/qmljsoutline.h +++ b/src/plugins/qmljseditor/qmljsoutline.h @@ -71,15 +71,13 @@ public: virtual void restoreSettings(const QVariantMap &map); virtual QVariantMap settings() const; -private slots: +private: void modelUpdated(); void updateSelectionInTree(const QModelIndex &index); void updateSelectionInText(const QItemSelection &selection); void updateTextCursor(const QModelIndex &index); void focusEditor(); void setShowBindings(bool showBindings); - -private: bool syncCursor(); private: diff --git a/src/plugins/qmljseditor/qmljsoutlinetreeview.cpp b/src/plugins/qmljseditor/qmljsoutlinetreeview.cpp index a63c6431a8..f20715ad50 100644 --- a/src/plugins/qmljseditor/qmljsoutlinetreeview.cpp +++ b/src/plugins/qmljseditor/qmljsoutlinetreeview.cpp @@ -57,8 +57,8 @@ void QmlJSOutlineTreeView::contextMenuEvent(QContextMenuEvent *event) QMenu contextMenu; - contextMenu.addAction(tr("Expand All"), this, SLOT(expandAll())); - contextMenu.addAction(tr("Collapse All"), this, SLOT(collapseAllExceptRoot())); + contextMenu.addAction(tr("Expand All"), this, [this] { expandAll(); }); + contextMenu.addAction(tr("Collapse All"), this, [this] { collapseAllExceptRoot(); }); contextMenu.exec(event->globalPos()); diff --git a/src/plugins/qmljseditor/qmljsoutlinetreeview.h b/src/plugins/qmljseditor/qmljsoutlinetreeview.h index 7b651f4c24..53e919b484 100644 --- a/src/plugins/qmljseditor/qmljsoutlinetreeview.h +++ b/src/plugins/qmljseditor/qmljsoutlinetreeview.h @@ -38,7 +38,7 @@ public: void contextMenuEvent(QContextMenuEvent *event); -private slots: +private: void collapseAllExceptRoot(); }; diff --git a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp index 0f2dea0442..d21ddb387a 100644 --- a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp +++ b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp @@ -534,10 +534,10 @@ SemanticHighlighter::SemanticHighlighter(QmlJSEditorDocument *document) , m_document(document) , m_startRevision(0) { - connect(&m_watcher, SIGNAL(resultsReadyAt(int,int)), - this, SLOT(applyResults(int,int))); - connect(&m_watcher, SIGNAL(finished()), - this, SLOT(finished())); + connect(&m_watcher, &QFutureWatcherBase::resultsReadyAt, + this, &SemanticHighlighter::applyResults); + connect(&m_watcher, &QFutureWatcherBase::finished, + this, &SemanticHighlighter::finished); } void SemanticHighlighter::rerun(const QmlJSTools::SemanticInfo &semanticInfo) diff --git a/src/plugins/qmljseditor/qmljssemantichighlighter.h b/src/plugins/qmljseditor/qmljssemantichighlighter.h index 7491e71eed..c32a69df89 100644 --- a/src/plugins/qmljseditor/qmljssemantichighlighter.h +++ b/src/plugins/qmljseditor/qmljssemantichighlighter.h @@ -80,11 +80,9 @@ public: void reportMessagesInfo(const QVector<QTextLayout::FormatRange> &diagnosticMessages, const QHash<int,QTextCharFormat> &formats); -private slots: +private: void applyResults(int from, int to); void finished(); - -private: void run(QFutureInterface<Use> &futureInterface, const QmlJSTools::SemanticInfo &semanticInfo); QFutureWatcher<Use> m_watcher; diff --git a/src/plugins/qmljseditor/qmljssemanticinfoupdater.h b/src/plugins/qmljseditor/qmljssemanticinfoupdater.h index 3d7696f466..0bc3533a42 100644 --- a/src/plugins/qmljseditor/qmljssemanticinfoupdater.h +++ b/src/plugins/qmljseditor/qmljssemanticinfoupdater.h @@ -47,7 +47,7 @@ public: void update(const QmlJS::Document::Ptr &doc, const QmlJS::Snapshot &snapshot); void reupdate(const QmlJS::Snapshot &snapshot); -Q_SIGNALS: +signals: void updated(const QmlJSTools::SemanticInfo &semanticInfo); protected: diff --git a/src/plugins/qmljseditor/qmltaskmanager.cpp b/src/plugins/qmljseditor/qmltaskmanager.cpp index f0e28ad6d3..8977d45359 100644 --- a/src/plugins/qmljseditor/qmltaskmanager.cpp +++ b/src/plugins/qmljseditor/qmltaskmanager.cpp @@ -52,15 +52,14 @@ QmlTaskManager::QmlTaskManager(QObject *parent) : m_updatingSemantic(false) { // displaying results incrementally leads to flickering -// connect(&m_messageCollector, SIGNAL(resultsReadyAt(int,int)), -// SLOT(displayResults(int,int))); - connect(&m_messageCollector, SIGNAL(finished()), - SLOT(displayAllResults())); +// connect(&m_messageCollector, &QFutureWatcherBase::resultsReadyAt, +// this, &QmlTaskManager::displayResults); + connect(&m_messageCollector, &QFutureWatcherBase::finished, + this, &QmlTaskManager::displayAllResults); m_updateDelay.setInterval(500); m_updateDelay.setSingleShot(true); - connect(&m_updateDelay, SIGNAL(timeout()), - SLOT(updateMessagesNow())); + connect(&m_updateDelay, &QTimer::timeout, this, [this] { updateMessagesNow(); }); } static QList<Task> convertToTasks(const QList<DiagnosticMessage> &messages, const FileName &fileName, Core::Id category) diff --git a/src/plugins/qmljseditor/qmltaskmanager.h b/src/plugins/qmljseditor/qmltaskmanager.h index 9c56e7a93b..415dcde393 100644 --- a/src/plugins/qmljseditor/qmltaskmanager.h +++ b/src/plugins/qmljseditor/qmltaskmanager.h @@ -47,17 +47,15 @@ public: void extensionsInitialized(); -public slots: void updateMessages(); void updateSemanticMessagesNow(); void documentsRemoved(const QStringList &path); -private slots: +private: void displayResults(int begin, int end); void displayAllResults(); void updateMessagesNow(bool updateSemantic = false); -private: void insertTask(const ProjectExplorer::Task &task); void removeTasksForFile(const QString &fileName); void removeAllTasks(bool clearSemantic); diff --git a/src/plugins/qmljseditor/quicktoolbar.cpp b/src/plugins/qmljseditor/quicktoolbar.cpp index 6a9c50a445..863b778c17 100644 --- a/src/plugins/qmljseditor/quicktoolbar.cpp +++ b/src/plugins/qmljseditor/quicktoolbar.cpp @@ -436,12 +436,17 @@ ContextPaneWidget* QuickToolBar::contextWidget() { if (m_widget.isNull()) { //lazily recreate widget m_widget = new ContextPaneWidget; - connect(m_widget.data(), SIGNAL(propertyChanged(QString,QVariant)), this, SLOT(onPropertyChanged(QString,QVariant))); - connect(m_widget.data(), SIGNAL(removeProperty(QString)), this, SLOT(onPropertyRemoved(QString))); - connect(m_widget.data(), SIGNAL(removeAndChangeProperty(QString,QString,QVariant,bool)), this, SLOT(onPropertyRemovedAndChange(QString,QString,QVariant,bool))); - connect(m_widget.data(), SIGNAL(enabledChanged(bool)), this, SLOT(onEnabledChanged(bool))); - connect(m_widget.data(), SIGNAL(pinnedChanged(bool)), this, SLOT(onPinnedChanged(bool))); - connect(m_widget.data(), SIGNAL(closed()), this, SIGNAL(closed())); + connect(m_widget.data(), &ContextPaneWidget::propertyChanged, + this, &QuickToolBar::onPropertyChanged); + connect(m_widget.data(), &ContextPaneWidget::removeProperty, + this, &QuickToolBar::onPropertyRemoved); + connect(m_widget.data(), &ContextPaneWidget::removeAndChangeProperty, + this, &QuickToolBar::onPropertyRemovedAndChange); + connect(m_widget.data(), &ContextPaneWidget::enabledChanged, + this, &QuickToolBar::onEnabledChanged); + connect(m_widget.data(), &ContextPaneWidget::pinnedChanged, + this, &QuickToolBar::onPinnedChanged); + connect(m_widget.data(), &ContextPaneWidget::closed, this, &IContextPane::closed); } return m_widget.data(); } diff --git a/src/plugins/qmljseditor/quicktoolbar.h b/src/plugins/qmljseditor/quicktoolbar.h index df7a5e6514..6d75bb7bed 100644 --- a/src/plugins/qmljseditor/quicktoolbar.h +++ b/src/plugins/qmljseditor/quicktoolbar.h @@ -47,7 +47,6 @@ public: void setEnabled(bool); QWidget* widget(); -public slots: void onPropertyChanged(const QString &, const QVariant &); void onPropertyRemoved(const QString &); void onPropertyRemovedAndChange(const QString &, const QString &, const QVariant &, bool removeFirst = true); diff --git a/src/plugins/qmljstools/qmljscodestylesettingspage.cpp b/src/plugins/qmljstools/qmljscodestylesettingspage.cpp index 909de2f1a6..a41d685451 100644 --- a/src/plugins/qmljstools/qmljscodestylesettingspage.cpp +++ b/src/plugins/qmljstools/qmljscodestylesettingspage.cpp @@ -65,8 +65,8 @@ QmlJSCodeStylePreferencesWidget::QmlJSCodeStylePreferencesWidget(QWidget *parent provider->decorateEditor(m_ui->previewTextEdit); decorateEditor(TextEditorSettings::fontSettings()); - connect(TextEditorSettings::instance(), SIGNAL(fontSettingsChanged(TextEditor::FontSettings)), - this, SLOT(decorateEditor(TextEditor::FontSettings))); + connect(TextEditorSettings::instance(), &TextEditorSettings::fontSettingsChanged, + this, &QmlJSCodeStylePreferencesWidget::decorateEditor); setVisualizeWhitespace(true); diff --git a/src/plugins/qmljstools/qmljscodestylesettingspage.h b/src/plugins/qmljstools/qmljscodestylesettingspage.h index cae3a9c2b4..96d377fc8c 100644 --- a/src/plugins/qmljstools/qmljscodestylesettingspage.h +++ b/src/plugins/qmljstools/qmljscodestylesettingspage.h @@ -55,13 +55,12 @@ public: void setPreferences(TextEditor::ICodeStylePreferences *preferences); -private slots: +private: void decorateEditor(const TextEditor::FontSettings &fontSettings); void setVisualizeWhitespace(bool on); void slotSettingsChanged(); void updatePreview(); -private: TextEditor::ICodeStylePreferences *m_preferences; Ui::QmlJSCodeStyleSettingsPage *m_ui; }; diff --git a/src/plugins/qmljstools/qmljslocatordata.h b/src/plugins/qmljstools/qmljslocatordata.h index 39b728d6f1..238b4f059d 100644 --- a/src/plugins/qmljstools/qmljslocatordata.h +++ b/src/plugins/qmljstools/qmljslocatordata.h @@ -60,11 +60,10 @@ public: QHash<QString, QList<Entry> > entries() const; -private slots: +private: void onDocumentUpdated(const QmlJS::Document::Ptr &doc); void onAboutToRemoveFiles(const QStringList &files); -private: mutable QMutex m_mutex; QHash<QString, QList<Entry> > m_entries; }; diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp index a1c153438a..1fdf60b808 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -219,8 +219,8 @@ void ModelManager::delayedInitialization() CppTools::CppModelManager *cppModelManager = CppTools::CppModelManager::instance(); // It's important to have a direct connection here so we can prevent // the source and AST of the cpp document being cleaned away. - connect(cppModelManager, SIGNAL(documentUpdated(CPlusPlus::Document::Ptr)), - this, SLOT(maybeQueueCppQmlTypeUpdate(CPlusPlus::Document::Ptr)), Qt::DirectConnection); + connect(cppModelManager, &CppTools::CppModelManager::documentUpdated, + this, &ModelManagerInterface::maybeQueueCppQmlTypeUpdate, Qt::DirectConnection); connect(SessionManager::instance(), &SessionManager::projectRemoved, this, &ModelManager::removeProjectInfo); diff --git a/src/plugins/qmljstools/qmljsmodelmanager.h b/src/plugins/qmljstools/qmljsmodelmanager.h index c2ab6c4eac..4a02117c87 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.h +++ b/src/plugins/qmljstools/qmljsmodelmanager.h @@ -56,9 +56,8 @@ protected: WorkingCopy workingCopyInternal() const override; void addTaskInternal(QFuture<void> result, const QString &msg, const char *taskId) const override; ProjectInfo defaultProjectInfoForProject(ProjectExplorer::Project *project) const override; -private slots: - void updateDefaultProjectInfo(); private: + void updateDefaultProjectInfo(); void loadDefaultQmlTypeDescriptions(); QHash<QString, QmlJS::Dialect> initLanguageForSuffix() const; }; diff --git a/src/plugins/qmljstools/qmljstoolsplugin.cpp b/src/plugins/qmljstools/qmljstoolsplugin.cpp index 1e173109e4..356ea6252e 100644 --- a/src/plugins/qmljstools/qmljstoolsplugin.cpp +++ b/src/plugins/qmljstools/qmljstoolsplugin.cpp @@ -105,10 +105,10 @@ bool QmlJSToolsPlugin::initialize(const QStringList &arguments, QString *error) mqmljstools->addAction(cmd); // watch task progress - connect(ProgressManager::instance(), SIGNAL(taskStarted(Core::Id)), - this, SLOT(onTaskStarted(Core::Id))); - connect(ProgressManager::instance(), SIGNAL(allTasksFinished(Core::Id)), - this, SLOT(onAllTasksFinished(Core::Id))); + connect(ProgressManager::instance(), &ProgressManager::taskStarted, + this, &QmlJSToolsPlugin::onTaskStarted); + connect(ProgressManager::instance(), &ProgressManager::allTasksFinished, + this, &QmlJSToolsPlugin::onAllTasksFinished); return true; } diff --git a/src/plugins/qmljstools/qmljstoolsplugin.h b/src/plugins/qmljstools/qmljstoolsplugin.h index 02faedb505..c032978de5 100644 --- a/src/plugins/qmljstools/qmljstoolsplugin.h +++ b/src/plugins/qmljstools/qmljstoolsplugin.h @@ -58,20 +58,20 @@ public: ShutdownFlag aboutToShutdown(); ModelManager *modelManager() { return m_modelManager; } -private slots: +private: void onTaskStarted(Core::Id type); void onAllTasksFinished(Core::Id type); -#ifdef WITH_TESTS - void test_basic(); -#endif - -private: ModelManager *m_modelManager; QmlJSToolsSettings *m_settings; QAction *m_resetCodeModelAction; static QmlJSToolsPlugin *m_instance; + +#ifdef WITH_TESTS +private slots: + void test_basic(); +#endif }; } // namespace Internal |