Commit d6c37e1e authored by con's avatar con

Disable the find usage and symbol renaming while indexing is done.

Reviewed-by: Roberto Raggi
parent 00298ab2
......@@ -57,17 +57,22 @@ void ProgressManagerPrivate::init()
void ProgressManagerPrivate::cancelTasks(const QString &type)
{
bool found = false;
QMap<QFutureWatcher<void> *, QString>::iterator task = m_runningTasks.begin();
while (task != m_runningTasks.end()) {
if (task.value() != type) {
++task;
continue;
}
found = true;
disconnect(task.key(), SIGNAL(finished()), this, SLOT(taskFinished()));
task.key()->cancel();
delete task.key();
task = m_runningTasks.erase(task);
}
if (found) {
emit allTasksFinished(type);
}
}
void ProgressManagerPrivate::cancelAllRunningTasks()
......@@ -88,6 +93,7 @@ FutureProgress *ProgressManagerPrivate::addTask(const QFuture<void> &future, con
m_runningTasks.insert(watcher, type);
connect(watcher, SIGNAL(finished()), this, SLOT(taskFinished()));
watcher->setFuture(future);
emit taskStarted(type);
return m_progressView->addTask(future, title, type, persistency);
}
......@@ -101,6 +107,11 @@ void ProgressManagerPrivate::taskFinished()
QObject *taskObject = sender();
QTC_ASSERT(taskObject, return);
QFutureWatcher<void> *task = static_cast<QFutureWatcher<void> *>(taskObject);
QString type = m_runningTasks.value(task);
m_runningTasks.remove(task);
delete task;
if (!m_runningTasks.values().contains(type)) {
emit allTasksFinished(type);
}
}
......@@ -51,6 +51,10 @@ public:
public slots:
virtual void cancelTasks(const QString &type) = 0;
signals:
void taskStarted(const QString &type);
void allTasksFinished(const QString &type);
};
} // namespace Core
......
......@@ -43,6 +43,7 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <texteditor/completionsupport.h>
#include <texteditor/fontsettings.h>
#include <texteditor/storagesettings.h>
......@@ -55,7 +56,6 @@
#include <QtCore/QFileInfo>
#include <QtCore/QSettings>
#include <QtGui/QMenu>
#include <QtGui/QAction>
using namespace CppEditor::Internal;
......@@ -211,18 +211,18 @@ bool CppPlugin::initialize(const QStringList & /*arguments*/, QString *errorMess
contextMenu->addAction(cmd);
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
QAction *findUsagesAction = new QAction(tr("Find Usages"), this);
cmd = am->registerAction(findUsagesAction, Constants::FIND_USAGES, context);
m_findUsagesAction = new QAction(tr("Find Usages"), this);
cmd = am->registerAction(m_findUsagesAction, Constants::FIND_USAGES, context);
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);
am->actionContainer(CppTools::Constants::M_TOOLS_CPP)->addAction(cmd);
QAction *renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol under Cursor"), this);
cmd = am->registerAction(renameSymbolUnderCursorAction,
m_renameSymbolUnderCursorAction = new QAction(tr("Rename Symbol under Cursor"), this);
cmd = am->registerAction(m_renameSymbolUnderCursorAction,
Constants::RENAME_SYMBOL_UNDER_CURSOR, context);
cmd->setDefaultKeySequence(QKeySequence("CTRL+SHIFT+R"));
connect(renameSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(renameSymbolUnderCursor()));
connect(m_renameSymbolUnderCursorAction, SIGNAL(triggered()), this, SLOT(renameSymbolUnderCursor()));
contextMenu->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);
contextMenu->addAction(cmd);
connect(core->progressManager(), SIGNAL(taskStarted(QString)),
this, SLOT(onTaskStarted(QString)));
connect(core->progressManager(), SIGNAL(allTasksFinished(QString)),
this, SLOT(onAllTasksFinished(QString)));
readSettings();
return true;
}
......@@ -300,4 +303,20 @@ void CppPlugin::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)
......@@ -30,12 +30,13 @@
#ifndef CPPPLUGIN_H
#define CPPPLUGIN_H
#include <QtCore/QtPlugin>
#include <QtCore/QStringList>
#include <extensionsystem/iplugin.h>
#include <coreplugin/editormanager/ieditorfactory.h>
#include <QtCore/QtPlugin>
#include <QtCore/QStringList>
#include <QtGui/QAction>
namespace TextEditor {
class TextEditorActionHandler;
} // namespace TextEditor
......@@ -74,6 +75,8 @@ private slots:
void switchDeclarationDefinition();
void jumpToDefinition();
void renameSymbolUnderCursor();
void onTaskStarted(const QString &type);
void onAllTasksFinished(const QString &type);
void findUsages();
private:
......@@ -85,6 +88,8 @@ private:
TextEditor::TextEditorActionHandler *m_actionHandler;
bool m_sortedMethodOverview;
QAction *m_renameSymbolUnderCursorAction;
QAction *m_findUsagesAction;
};
class CppEditorFactory : public Core::IEditorFactory
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment