forked from qt-creator/qt-creator
Disable the find usage and symbol renaming while indexing is done.
Reviewed-by: Roberto Raggi
This commit is contained in:
@@ -57,17 +57,22 @@ void ProgressManagerPrivate::init()
|
|||||||
|
|
||||||
void ProgressManagerPrivate::cancelTasks(const QString &type)
|
void ProgressManagerPrivate::cancelTasks(const QString &type)
|
||||||
{
|
{
|
||||||
|
bool found = false;
|
||||||
QMap<QFutureWatcher<void> *, QString>::iterator task = m_runningTasks.begin();
|
QMap<QFutureWatcher<void> *, QString>::iterator task = m_runningTasks.begin();
|
||||||
while (task != m_runningTasks.end()) {
|
while (task != m_runningTasks.end()) {
|
||||||
if (task.value() != type) {
|
if (task.value() != type) {
|
||||||
++task;
|
++task;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
found = true;
|
||||||
disconnect(task.key(), SIGNAL(finished()), this, SLOT(taskFinished()));
|
disconnect(task.key(), SIGNAL(finished()), this, SLOT(taskFinished()));
|
||||||
task.key()->cancel();
|
task.key()->cancel();
|
||||||
delete task.key();
|
delete task.key();
|
||||||
task = m_runningTasks.erase(task);
|
task = m_runningTasks.erase(task);
|
||||||
}
|
}
|
||||||
|
if (found) {
|
||||||
|
emit allTasksFinished(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgressManagerPrivate::cancelAllRunningTasks()
|
void ProgressManagerPrivate::cancelAllRunningTasks()
|
||||||
@@ -88,6 +93,7 @@ FutureProgress *ProgressManagerPrivate::addTask(const QFuture<void> &future, con
|
|||||||
m_runningTasks.insert(watcher, type);
|
m_runningTasks.insert(watcher, type);
|
||||||
connect(watcher, SIGNAL(finished()), this, SLOT(taskFinished()));
|
connect(watcher, SIGNAL(finished()), this, SLOT(taskFinished()));
|
||||||
watcher->setFuture(future);
|
watcher->setFuture(future);
|
||||||
|
emit taskStarted(type);
|
||||||
return m_progressView->addTask(future, title, type, persistency);
|
return m_progressView->addTask(future, title, type, persistency);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +107,11 @@ void ProgressManagerPrivate::taskFinished()
|
|||||||
QObject *taskObject = sender();
|
QObject *taskObject = sender();
|
||||||
QTC_ASSERT(taskObject, return);
|
QTC_ASSERT(taskObject, return);
|
||||||
QFutureWatcher<void> *task = static_cast<QFutureWatcher<void> *>(taskObject);
|
QFutureWatcher<void> *task = static_cast<QFutureWatcher<void> *>(taskObject);
|
||||||
|
QString type = m_runningTasks.value(task);
|
||||||
m_runningTasks.remove(task);
|
m_runningTasks.remove(task);
|
||||||
delete task;
|
delete task;
|
||||||
|
|
||||||
|
if (!m_runningTasks.values().contains(type)) {
|
||||||
|
emit allTasksFinished(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void cancelTasks(const QString &type) = 0;
|
virtual void cancelTasks(const QString &type) = 0;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void taskStarted(const QString &type);
|
||||||
|
void allTasksFinished(const QString &type);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/actionmanager/command.h>
|
#include <coreplugin/actionmanager/command.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
#include <coreplugin/progressmanager/progressmanager.h>
|
||||||
#include <texteditor/completionsupport.h>
|
#include <texteditor/completionsupport.h>
|
||||||
#include <texteditor/fontsettings.h>
|
#include <texteditor/fontsettings.h>
|
||||||
#include <texteditor/storagesettings.h>
|
#include <texteditor/storagesettings.h>
|
||||||
@@ -55,7 +56,6 @@
|
|||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtGui/QMenu>
|
#include <QtGui/QMenu>
|
||||||
#include <QtGui/QAction>
|
|
||||||
|
|
||||||
using namespace CppEditor::Internal;
|
using namespace CppEditor::Internal;
|
||||||
|
|
||||||
@@ -211,18 +211,18 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
|
|||||||
contextMenu->addAction(cmd);
|
contextMenu->addAction(cmd);
|
||||||
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
|
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
|
||||||
|
|
||||||
QAction *findUsagesAction = new QAction(tr("Find Usages"), this);
|
m_findUsagesAction = new QAction(tr("Find Usages"), this);
|
||||||
cmd = am->registerAction(findUsagesAction, Constants::FIND_USAGES, context);
|
cmd = am->registerAction(m_findUsagesAction, Constants::FIND_USAGES, context);
|
||||||
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U")));
|
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U")));
|
||||||
connect(findUsagesAction, SIGNAL(triggered()), this, SLOT(findUsages()));
|
connect(m_findUsagesAction, SIGNAL(triggered()), this, SLOT(findUsages()));
|
||||||
contextMenu->addAction(cmd);
|
contextMenu->addAction(cmd);
|
||||||
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
|
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
|
||||||
|
|
||||||
QAction *renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol under Cursor"), this);
|
m_renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol under Cursor"), this);
|
||||||
cmd = am->registerAction(renameSymbolUnderCursorAction,
|
cmd = am->registerAction(m_renameSymbolUnderCursorAction,
|
||||||
Constants::RENAME_SYMBOL_UNDER_CURSOR, context);
|
Constants::RENAME_SYMBOL_UNDER_CURSOR, context);
|
||||||
cmd->setDefaultKeySequence(QKeySequence("CTRL+SHIFT+R"));
|
cmd->setDefaultKeySequence(QKeySequence("CTRL+SHIFT+R"));
|
||||||
connect(renameSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(renameSymbolUnderCursor()));
|
connect(m_renameSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(renameSymbolUnderCursor()));
|
||||||
contextMenu->addAction(cmd);
|
contextMenu->addAction(cmd);
|
||||||
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
|
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
|
||||||
|
|
||||||
@@ -244,7 +244,10 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
|
|||||||
cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION);
|
cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION);
|
||||||
contextMenu->addAction(cmd);
|
contextMenu->addAction(cmd);
|
||||||
|
|
||||||
|
connect(core->progressManager(), SIGNAL(taskStarted(QString)),
|
||||||
|
this, SLOT(onTaskStarted(QString)));
|
||||||
|
connect(core->progressManager(), SIGNAL(allTasksFinished(QString)),
|
||||||
|
this, SLOT(onAllTasksFinished(QString)));
|
||||||
readSettings();
|
readSettings();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -300,4 +303,20 @@ void CppPlugin::findUsages()
|
|||||||
editor->findUsages();
|
editor->findUsages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CppPlugin::onTaskStarted(const QString &type)
|
||||||
|
{
|
||||||
|
if (type == CppTools::Constants::TASK_INDEX) {
|
||||||
|
m_renameSymbolUnderCursorAction->setEnabled(false);
|
||||||
|
m_findUsagesAction->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CppPlugin::onAllTasksFinished(const QString &type)
|
||||||
|
{
|
||||||
|
if (type == CppTools::Constants::TASK_INDEX) {
|
||||||
|
m_renameSymbolUnderCursorAction->setEnabled(true);
|
||||||
|
m_findUsagesAction->setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN(CppPlugin)
|
Q_EXPORT_PLUGIN(CppPlugin)
|
||||||
|
|||||||
@@ -30,12 +30,13 @@
|
|||||||
#ifndef CPPPLUGIN_H
|
#ifndef CPPPLUGIN_H
|
||||||
#define CPPPLUGIN_H
|
#define CPPPLUGIN_H
|
||||||
|
|
||||||
#include <QtCore/QtPlugin>
|
|
||||||
#include <QtCore/QStringList>
|
|
||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
#include <extensionsystem/iplugin.h>
|
||||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||||
|
|
||||||
|
#include <QtCore/QtPlugin>
|
||||||
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtGui/QAction>
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
class TextEditorActionHandler;
|
class TextEditorActionHandler;
|
||||||
} // namespace TextEditor
|
} // namespace TextEditor
|
||||||
@@ -74,6 +75,8 @@ private slots:
|
|||||||
void switchDeclarationDefinition();
|
void switchDeclarationDefinition();
|
||||||
void jumpToDefinition();
|
void jumpToDefinition();
|
||||||
void renameSymbolUnderCursor();
|
void renameSymbolUnderCursor();
|
||||||
|
void onTaskStarted(const QString &type);
|
||||||
|
void onAllTasksFinished(const QString &type);
|
||||||
void findUsages();
|
void findUsages();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -85,6 +88,8 @@ private:
|
|||||||
|
|
||||||
TextEditor::TextEditorActionHandler *m_actionHandler;
|
TextEditor::TextEditorActionHandler *m_actionHandler;
|
||||||
bool m_sortedMethodOverview;
|
bool m_sortedMethodOverview;
|
||||||
|
QAction *m_renameSymbolUnderCursorAction;
|
||||||
|
QAction *m_findUsagesAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CppEditorFactory : public Core::IEditorFactory
|
class CppEditorFactory : public Core::IEditorFactory
|
||||||
|
|||||||
Reference in New Issue
Block a user