Commit df361843 authored by hjk's avatar hjk

Core: Static pattern for ProgressManager, clean up all users

Change-Id: I4af8793ca69a3af9e99baeb7c31dad3864266f91
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent ba1d8e2c
......@@ -38,7 +38,6 @@
#include <projectexplorer/session.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <cpptools/cpptoolsconstants.h>
#include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
......@@ -48,6 +47,8 @@
#include <QMutex>
#include <QMutexLocker>
using namespace Core;
namespace ClassView {
namespace Internal {
......@@ -234,9 +235,9 @@ void Manager::initialize()
SLOT(onProjectListChanged()), Qt::QueuedConnection);
// connect to the progress manager for signals about Parsing tasks
connect(Core::ICore::progressManager(), SIGNAL(taskStarted(QString)),
connect(ProgressManager::instance(), SIGNAL(taskStarted(QString)),
SLOT(onTaskStarted(QString)), Qt::QueuedConnection);
connect(Core::ICore::progressManager(), SIGNAL(allTasksFinished(QString)),
connect(ProgressManager::instance(), SIGNAL(allTasksFinished(QString)),
SLOT(onAllTasksFinished(QString)), Qt::QueuedConnection);
// when we signals that really document is updated - sent it to the parser
......@@ -440,7 +441,7 @@ void Manager::onDocumentUpdated(CPlusPlus::Document::Ptr doc)
void Manager::gotoLocation(const QString &fileName, int line, int column)
{
Core::EditorManager::openEditorAt(fileName, line, column);
EditorManager::openEditorAt(fileName, line, column);
}
/*!
......@@ -462,9 +463,9 @@ void Manager::gotoLocations(const QList<QVariant> &list)
bool currentPositionAvailable = false;
// what is open now?
if (Core::IEditor *editor = Core::EditorManager::currentEditor()) {
if (IEditor *editor = EditorManager::currentEditor()) {
// get current file name
if (Core::IDocument *document = editor->document())
if (IDocument *document = editor->document())
fileName = document->filePath();
// if text file - what is current position?
......
This diff is collapsed.
......@@ -356,11 +356,6 @@ bool ICore::showWarningWithOptions(const QString &title, const QString &text,
settingsId, parent);
}
ProgressManager *ICore::progressManager()
{
return m_mainwindow->progressManager();
}
VcsManager *ICore::vcsManager()
{
return m_mainwindow->vcsManager();
......
......@@ -85,7 +85,6 @@ public:
Id settingsId = Id(),
QWidget *parent = 0);
static ProgressManager *progressManager();
static VcsManager *vcsManager();
static MimeDatabase *mimeDatabase();
......
......@@ -348,7 +348,7 @@ void ProgressManagerPrivate::init()
initInternal();
}
void ProgressManagerPrivate::cancelTasks(const QString &type)
void ProgressManagerPrivate::doCancelTasks(const QString &type)
{
bool found = false;
QMap<QFutureWatcher<void> *, QString>::iterator task = m_runningTasks.begin();
......@@ -412,7 +412,7 @@ void ProgressManagerPrivate::cancelAllRunningTasks()
updateSummaryProgressBar();
}
FutureProgress *ProgressManagerPrivate::addTask(const QFuture<void> &future, const QString &title,
FutureProgress *ProgressManagerPrivate::doAddTask(const QFuture<void> &future, const QString &title,
const QString &type, ProgressFlags flags)
{
// watch
......@@ -717,3 +717,36 @@ void ToggleButton::paintEvent(QPaintEvent *event)
arrowOpt.rect = QRect(rect().center().x() - 3, rect().center().y() - 6, 9, 9);
s->drawPrimitive(QStyle::PE_IndicatorArrowUp, &arrowOpt, &p, this);
}
static ProgressManager *m_instance = 0;
ProgressManager::ProgressManager(QObject *parent)
{
m_instance = this;
}
ProgressManager::~ProgressManager()
{
m_instance = 0;
}
QObject *ProgressManager::instance()
{
return m_instance;
}
FutureProgress *ProgressManager::addTask(const QFuture<void> &future, const QString &title, const QString &type, ProgressFlags flags)
{
return m_instance->doAddTask(future, title, type, flags);
}
void ProgressManager::setApplicationLabel(const QString &text)
{
m_instance->doSetApplicationLabel(text);
}
void ProgressManager::cancelTasks(const QString &type)
{
m_instance->doCancelTasks(type);
}
......@@ -50,20 +50,28 @@ public:
};
Q_DECLARE_FLAGS(ProgressFlags, ProgressFlag)
virtual FutureProgress *addTask(const QFuture<void> &future, const QString &title,
const QString &type, ProgressFlags flags = 0) = 0;
virtual void setApplicationLabel(const QString &text) = 0;
static QObject *instance();
static FutureProgress *addTask(const QFuture<void> &future, const QString &title,
const QString &type, ProgressFlags flags = 0);
static void setApplicationLabel(const QString &text);
public slots:
virtual void cancelTasks(const QString &type) = 0;
static void cancelTasks(const QString &type);
signals:
void taskStarted(const QString &type);
void allTasksFinished(const QString &type);
protected:
virtual void doCancelTasks(const QString &type) = 0;
virtual FutureProgress *doAddTask(const QFuture<void> &future, const QString &title,
const QString &type, ProgressFlags flags = 0) = 0;
virtual void doSetApplicationLabel(const QString &text) = 0;
private:
ProgressManager(QObject *parent = 0) : QObject(parent) {}
virtual ~ProgressManager() {}
ProgressManager(QObject *parent = 0);
~ProgressManager();
friend class Core::Internal::ProgressManagerPrivate;
};
......
......@@ -125,7 +125,7 @@ static ApplicationProgressView *sharedProgressView = nil;
@end
void Core::Internal::ProgressManagerPrivate::setApplicationLabel(const QString &text)
void Core::Internal::ProgressManagerPrivate::doSetApplicationLabel(const QString &text)
{
NSString *cocoaString = [[NSString alloc] initWithUTF8String:text.toUtf8().constData()];
[[NSApp dockTile] setBadgeLabel:cocoaString];
......
......@@ -58,14 +58,14 @@ public:
void init();
void cleanup();
FutureProgress *addTask(const QFuture<void> &future, const QString &title, const QString &type,
FutureProgress *doAddTask(const QFuture<void> &future, const QString &title, const QString &type,
ProgressFlags flags);
void setApplicationLabel(const QString &text);
void doSetApplicationLabel(const QString &text);
ProgressView *progressView();
public slots:
void cancelTasks(const QString &type);
void doCancelTasks(const QString &type);
protected:
bool eventFilter(QObject *obj, QEvent *event);
......
......@@ -174,7 +174,7 @@ void Core::Internal::ProgressManagerPrivate::cleanup()
{
}
void Core::Internal::ProgressManagerPrivate::setApplicationLabel(const QString &text)
void Core::Internal::ProgressManagerPrivate::doSetApplicationLabel(const QString &text)
{
Q_UNUSED(text)
}
......
......@@ -37,7 +37,7 @@ void Core::Internal::ProgressManagerPrivate::cleanup()
{
}
void Core::Internal::ProgressManagerPrivate::setApplicationLabel(const QString &text)
void Core::Internal::ProgressManagerPrivate::doSetApplicationLabel(const QString &text)
{
Q_UNUSED(text)
}
......
This diff is collapsed.
......@@ -192,8 +192,7 @@ QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(const QStringList &sour
m_synchronizer.addFuture(result);
if (mode == CppModelManagerInterface::ForcedProgressNotification || sourceFiles.count() > 1) {
Core::ICore::progressManager()->addTask(result,
QCoreApplication::translate("CppTools::Internal::BuiltinIndexingSupport", "Parsing"),
Core::ProgressManager::addTask(result, QCoreApplication::translate("CppTools::Internal::BuiltinIndexingSupport", "Parsing"),
QLatin1String(CppTools::Constants::TASK_INDEX));
}
......
......@@ -48,6 +48,7 @@
#include <functional>
using namespace Core;
using namespace CppTools::Internal;
using namespace CppTools;
using namespace CPlusPlus;
......@@ -61,7 +62,7 @@ static QString getSource(const QString &fileName,
QString fileContents;
Utils::TextFileFormat format;
QString error;
QTextCodec *defaultCodec = Core::EditorManager::defaultTextCodec();
QTextCodec *defaultCodec = EditorManager::defaultTextCodec();
Utils::TextFileFormat::ReadResult result = Utils::TextFileFormat::readFile(
fileName, defaultCodec, &fileContents, &format, &error);
if (result != Utils::TextFileFormat::ReadSuccess)
......@@ -272,15 +273,14 @@ void CppFindReferences::findAll_helper(Find::SearchResult *search)
connect(search, SIGNAL(activated(Find::SearchResultItem)),
this, SLOT(openEditor(Find::SearchResultItem)));
Find::SearchResultWindow::instance()->popup(Core::IOutputPane::ModeSwitch | Core::IOutputPane::WithFocus);
Find::SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
const CppModelManagerInterface::WorkingCopy workingCopy = _modelManager->workingCopy();
QFuture<Usage> result;
result = QtConcurrent::run(&find_helper, workingCopy,
parameters.context, this, parameters.symbol);
createWatcher(result, search);
Core::ProgressManager *progressManager = Core::ICore::progressManager();
Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching"),
FutureProgress *progress = ProgressManager::addTask(result, tr("Searching"),
QLatin1String(CppTools::Constants::TASK_SEARCH));
connect(progress, SIGNAL(clicked()), search, SLOT(popup()));
......@@ -512,10 +512,10 @@ void CppFindReferences::setPaused(bool paused)
void CppFindReferences::openEditor(const Find::SearchResultItem &item)
{
if (item.path.size() > 0) {
Core::EditorManager::openEditorAt(QDir::fromNativeSeparators(item.path.first()),
EditorManager::openEditorAt(QDir::fromNativeSeparators(item.path.first()),
item.lineNumber, item.textMarkPos);
} else {
Core::EditorManager::openEditor(QDir::fromNativeSeparators(item.text));
EditorManager::openEditor(QDir::fromNativeSeparators(item.text));
}
}
......@@ -640,7 +640,7 @@ void CppFindReferences::findMacroUses(const Macro &macro, const QString &replace
connect(search, SIGNAL(replaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)),
SLOT(onReplaceButtonClicked(QString,QList<Find::SearchResultItem>,bool)));
Find::SearchResultWindow::instance()->popup(Core::IOutputPane::ModeSwitch | Core::IOutputPane::WithFocus);
Find::SearchResultWindow::instance()->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
connect(search, SIGNAL(activated(Find::SearchResultItem)),
this, SLOT(openEditor(Find::SearchResultItem)));
......@@ -663,8 +663,7 @@ void CppFindReferences::findMacroUses(const Macro &macro, const QString &replace
result = QtConcurrent::run(&findMacroUses_helper, workingCopy, snapshot, this, macro);
createWatcher(result, search);
Core::ProgressManager *progressManager = Core::ICore::progressManager();
Core::FutureProgress *progress = progressManager->addTask(result, tr("Searching"),
FutureProgress *progress = ProgressManager::addTask(result, tr("Searching"),
QLatin1String(CppTools::Constants::TASK_SEARCH));
connect(progress, SIGNAL(clicked()), search, SLOT(popup()));
}
......
......@@ -828,8 +828,8 @@ void CppModelManager::onAboutToLoadSession()
void CppModelManager::onAboutToUnloadSession()
{
if (Core::ProgressManager *pm = Core::ICore::progressManager())
pm->cancelTasks(QLatin1String(CppTools::Constants::TASK_INDEX));
if (Core::ProgressManager::instance())
Core::ProgressManager::cancelTasks(QLatin1String(CppTools::Constants::TASK_INDEX));
do {
QMutexLocker locker(&m_projectMutex);
m_projectToProjectsInfo.clear();
......
......@@ -45,14 +45,14 @@
#include <QLabel>
#include <QButtonGroup>
using namespace CppTools;
using namespace CppTools::Internal;
using namespace Core;
namespace {
const char * const SETTINGS_GROUP = "CppSymbols";
const char * const SETTINGS_SYMBOLTYPES = "SymbolsToSearchFor";
const char * const SETTINGS_SEARCHSCOPE = "SearchScope";
} // anonymous namespace
namespace CppTools {
namespace Internal {
const char SETTINGS_GROUP[] = "CppSymbols";
const char SETTINGS_SYMBOLTYPES[] = "SymbolsToSearchFor";
const char SETTINGS_SEARCHSCOPE[] = "SearchScope";
SymbolsFindFilter::SymbolsFindFilter(CppModelManager *manager)
: m_manager(manager),
......@@ -61,9 +61,9 @@ SymbolsFindFilter::SymbolsFindFilter(CppModelManager *manager)
m_scope(SymbolSearcher::SearchProjectsOnly)
{
// for disabling while parser is running
connect(Core::ICore::progressManager(), SIGNAL(taskStarted(QString)),
connect(ProgressManager::instance(), SIGNAL(taskStarted(QString)),
this, SLOT(onTaskStarted(QString)));
connect(Core::ICore::progressManager(), SIGNAL(allTasksFinished(QString)),
connect(ProgressManager::instance(), SIGNAL(allTasksFinished(QString)),
this, SLOT(onAllTasksFinished(QString)));
}
......@@ -117,7 +117,7 @@ void SymbolsFindFilter::findAll(const QString &txt, Find::FindFlags findFlags)
connect(search, SIGNAL(paused(bool)), this, SLOT(setPaused(bool)));
connect(search, SIGNAL(searchAgainRequested()), this, SLOT(searchAgain()));
connect(this, SIGNAL(enabledChanged(bool)), search, SLOT(setSearchAgainEnabled(bool)));
window->popup(Core::IOutputPane::ModeSwitch | Core::IOutputPane::WithFocus);
window->popup(IOutputPane::ModeSwitch | IOutputPane::WithFocus);
SymbolSearcher::Parameters parameters;
parameters.text = txt;
......@@ -149,8 +149,7 @@ void SymbolsFindFilter::startSearch(Find::SearchResult *search)
connect(watcher, SIGNAL(finished()),
symbolSearcher, SLOT(deleteLater()));
watcher->setFuture(QtConcurrent::run(&SymbolSearcher::runSearch, symbolSearcher));
Core::FutureProgress *progress = Core::ICore::progressManager()->addTask(watcher->future(),
tr("Searching"),
FutureProgress *progress = ProgressManager::addTask(watcher->future(), tr("Searching"),
QLatin1String(Find::Constants::TASK_SEARCH));
connect(progress, SIGNAL(clicked()), search, SLOT(popup()));
}
......@@ -187,9 +186,7 @@ void SymbolsFindFilter::openEditor(const Find::SearchResultItem &item)
if (!item.userData.canConvert<ModelItemInfo>())
return;
ModelItemInfo info = item.userData.value<ModelItemInfo>();
Core::EditorManager::openEditorAt(info.fileName,
info.line,
info.column);
EditorManager::openEditorAt(info.fileName, info.line, info.column);
}
QWidget *SymbolsFindFilter::createConfigWidget()
......@@ -346,3 +343,6 @@ void SymbolsFindFilterConfigWidget::setState() const
else
m_filter->setSearchScope(SymbolSearcher::SearchGlobal);
}
} // namespace Internal
} // namespace CppTools
......@@ -47,7 +47,6 @@
#include "threadshandler.h"
#include "watchhandler.h"
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/progressmanager/progressmanager.h>
......@@ -489,10 +488,9 @@ void DebuggerEngine::startDebugger(DebuggerRunControl *runControl)
QTC_ASSERT(!d->m_runControl, notifyEngineSetupFailed(); return);
d->m_progress.setProgressRange(0, 1000);
Core::FutureProgress *fp = Core::ICore::progressManager()
->addTask(d->m_progress.future(),
FutureProgress *fp = ProgressManager::addTask(d->m_progress.future(),
tr("Launching"), _("Debugger.Launcher"));
fp->setKeepOnFinish(Core::FutureProgress::HideOnFinish);
fp->setKeepOnFinish(FutureProgress::HideOnFinish);
d->m_progress.reportStarted();
d->m_runControl = runControl;
......@@ -539,7 +537,7 @@ void DebuggerEngine::gotoLocation(const Location &loc)
const QString file = loc.fileName();
const int line = loc.lineNumber();
bool newEditor = false;
IEditor *editor = EditorManager::openEditor(file, Core::Id(),
IEditor *editor = EditorManager::openEditor(file, Id(),
EditorManager::IgnoreNavigationHistory, &newEditor);
QTC_ASSERT(editor, return); // Unreadable file?
editor->gotoLine(line, 0);
......@@ -1408,7 +1406,7 @@ void DebuggerEngine::reloadDebuggingHelpers()
{
}
void DebuggerEngine::addOptionPages(QList<Core::IOptionsPage*> *) const
void DebuggerEngine::addOptionPages(QList<IOptionsPage*> *) const
{
}
......
......@@ -32,7 +32,6 @@
#include "../gitplugin.h"
#include "../gitclient.h"
#include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/progressmanager/futureprogress.h>
#include <vcsbase/vcsbaseoutputwindow.h>
......@@ -323,8 +322,7 @@ QueryContext::~QueryContext()
void QueryContext::start()
{
Core::ProgressManager *pm = Core::ICore::instance()->progressManager();
Core::FutureProgress *fp = pm->addTask(m_progress.future(), tr("Gerrit"),
Core::FutureProgress *fp = Core::ProgressManager::addTask(m_progress.future(), tr("Gerrit"),
QLatin1String("gerrit-query"));
fp->setKeepOnFinish(Core::FutureProgress::HideOnFinish);
m_progress.reportStarted();
......
......@@ -67,6 +67,8 @@
#include <QDir>
#include <QMap>
using namespace Core;
enum { debug = 0 };
namespace Gerrit {
......@@ -165,10 +167,9 @@ FetchContext::~FetchContext()
void FetchContext::start()
{
m_progress.setProgressRange(0, 2);
Core::ProgressManager *pm = Core::ICore::instance()->progressManager();
Core::FutureProgress *fp = pm->addTask(m_progress.future(), tr("Gerrit Fetch"),
FutureProgress *fp = ProgressManager::addTask(m_progress.future(), tr("Gerrit Fetch"),
QLatin1String("gerrit-fetch"));
fp->setKeepOnFinish(Core::FutureProgress::HideOnFinish);
fp->setKeepOnFinish(FutureProgress::HideOnFinish);
m_progress.reportStarted();
// Order: initialize future before starting the process in case error handling is invoked.
const QStringList args = m_change->gitFetchArguments(m_parameters);
......@@ -247,8 +248,8 @@ void FetchContext::show()
void FetchContext::cherryPick()
{
// Point user to errors.
VcsBase::VcsBaseOutputWindow::instance()->popup(Core::IOutputPane::ModeSwitch
| Core::IOutputPane::WithFocus);
VcsBase::VcsBaseOutputWindow::instance()->popup(IOutputPane::ModeSwitch
| IOutputPane::WithFocus);
Git::Internal::GitPlugin::instance()->gitClient()->synchronousCherryPick(
m_repository, QLatin1String("FETCH_HEAD"));
}
......@@ -270,23 +271,23 @@ GerritPlugin::~GerritPlugin()
{
}
bool GerritPlugin::initialize(Core::ActionContainer *ac)
bool GerritPlugin::initialize(ActionContainer *ac)
{
m_parameters->fromSettings(Core::ICore::instance()->settings());
m_parameters->fromSettings(ICore::instance()->settings());
QAction *openViewAction = new QAction(tr("Gerrit..."), this);
m_gerritCommand =
Core::ActionManager::registerAction(openViewAction, Constants::GERRIT_OPEN_VIEW,
Core::Context(Core::Constants::C_GLOBAL));
ActionManager::registerAction(openViewAction, Constants::GERRIT_OPEN_VIEW,
Context(Core::Constants::C_GLOBAL));
connect(openViewAction, SIGNAL(triggered()), this, SLOT(openView()));
ac->addAction(m_gerritCommand);
QAction *pushAction = new QAction(tr("Push to Gerrit..."), this);
Core::Command *pushCommand =
Core::ActionManager::registerAction(pushAction, Constants::GERRIT_PUSH,
Core::Context(Core::Constants::C_GLOBAL));
Command *pushCommand =
ActionManager::registerAction(pushAction, Constants::GERRIT_PUSH,
Context(Core::Constants::C_GLOBAL));
connect(pushAction, SIGNAL(triggered()), this, SLOT(push()));
ac->addAction(pushCommand);
......@@ -312,13 +313,13 @@ void GerritPlugin::push()
const QString topLevel = Git::Internal::GitPlugin::instance()->currentState().topLevel();
// QScopedPointer is required to delete the dialog when leaving the function
GerritPushDialog dialog(topLevel, m_reviewers, Core::ICore::mainWindow());
GerritPushDialog dialog(topLevel, m_reviewers, ICore::mainWindow());
if (!dialog.localChangesFound())
return;
if (!dialog.valid()) {
QMessageBox::warning(Core::ICore::mainWindow(), tr("Initialization Failed"),
QMessageBox::warning(ICore::mainWindow(), tr("Initialization Failed"),
tr("Failed to initialize dialog. Aborting."));
return;
}
......@@ -362,11 +363,11 @@ void GerritPlugin::openView()
while (!m_parameters->isValid()) {
QMessageBox::warning(0, tr("Error"),
tr("Invalid Gerrit configuration. Host, user and ssh binary are mandatory."));
const Core::Id group = VcsBase::Constants::VCS_SETTINGS_CATEGORY;
if (!Core::ICore::instance()->showOptionsDialog(group, Core::Id("Gerrit")))
const Id group = VcsBase::Constants::VCS_SETTINGS_CATEGORY;
if (!ICore::instance()->showOptionsDialog(group, "Gerrit"))
return;
}
GerritDialog *gd = new GerritDialog(m_parameters, Core::ICore::mainWindow());
GerritDialog *gd = new GerritDialog(m_parameters, ICore::mainWindow());
gd->setModal(false);
connect(gd, SIGNAL(fetchDisplay(QSharedPointer<Gerrit::Internal::GerritChange>)),
this, SLOT(fetchDisplay(QSharedPointer<Gerrit::Internal::GerritChange>)));
......@@ -467,7 +468,7 @@ void GerritPlugin::fetch(const QSharedPointer<Gerrit::Internal::GerritChange> &c
if (!verifiedRepository) {
QMessageBox::StandardButton answer = QMessageBox::question(
Core::ICore::mainWindow(), tr("Remote Not Verified"),
ICore::mainWindow(), tr("Remote Not Verified"),
tr("Change host %1\nand project %2\n\nwere not verified among remotes"
" in %3. Select different folder?")
.arg(m_parameters->host,
......@@ -511,7 +512,7 @@ void GerritPlugin::fetch(const QSharedPointer<Gerrit::Internal::GerritChange> &c
// Try to find a matching repository for a project by asking the VcsManager.
QString GerritPlugin::findLocalRepository(QString project, const QString &branch) const
{
const Core::VcsManager *vcsManager = Core::ICore::instance()->vcsManager();
const Core::VcsManager *vcsManager = ICore::instance()->vcsManager();
const QStringList gitRepositories = vcsManager->repositories(Git::Internal::GitPlugin::instance()->gitVersionControl());
// Determine key (file name) to look for (qt/qtbase->'qtbase').
const int slashPos = project.lastIndexOf(QLatin1Char('/'));
......@@ -546,7 +547,7 @@ QString GerritPlugin::findLocalRepository(QString project, const QString &branch
} // for repositories
// No match, do we have a projects folder?
if (Core::DocumentManager::useProjectsDirectory())
return Core::DocumentManager::projectsDirectory();
return DocumentManager::projectsDirectory();
return QDir::currentPath();
}
......
......@@ -194,7 +194,7 @@ void SearchWidget::indexingStarted()
{
Q_ASSERT(!m_progress);
m_progress = new QFutureInterface<void>();
Core::ICore::progressManager() ->addTask(m_progress->future(),
Core::ProgressManager::addTask(m_progress->future(),
tr("Indexing"), QLatin1String("Help.Indexer"));
m_progress->setProgressRange(0, 2);
m_progress->setProgressValueAndText(1, tr("Indexing Documentation..."));
......
......@@ -62,6 +62,7 @@
\internal
*/
using namespace Core;
using namespace Locator;
using namespace Locator::Internal;
......@@ -103,21 +104,21 @@ bool LocatorPlugin::initialize(const QStringList &, QString *)
m_locatorWidget = new LocatorWidget(this);
m_locatorWidget->setEnabled(false);
Core::StatusBarWidget *view = new Core::StatusBarWidget;
StatusBarWidget *view = new StatusBarWidget;
view->setWidget(m_locatorWidget);
view->setContext(Core::Context("LocatorWidget"));
view->setPosition(Core::StatusBarWidget::First);
view->setContext(Context("LocatorWidget"));
view->setPosition(StatusBarWidget::First);
addAutoReleasedObject(view);
QAction *action = new QAction(m_locatorWidget->windowIcon(), m_locatorWidget->windowTitle(), this);
Core::Command *cmd = Core::ActionManager::registerAction(action, "QtCreator.Locate",
Core::Context(Core::Constants::C_GLOBAL));
Command *cmd = ActionManager::registerAction(action, "QtCreator.Locate",
Context(Core::Constants::C_GLOBAL));
cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+K")));
connect(action, SIGNAL(triggered()), this, SLOT(openLocator()));
connect(cmd, SIGNAL(keySequenceChanged()), this, SLOT(updatePlaceholderText()));
updatePlaceholderText(cmd);
Core::ActionContainer *mtools = Core::ActionManager::actionContainer(Core::Constants::M_TOOLS);
ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
mtools->addAction(cmd);
addObject(new LocatorManager(m_locatorWidget));
......@@ -136,10 +137,10 @@ bool LocatorPlugin::initialize(const QStringList &, QString *)
return true;
}
void LocatorPlugin::updatePlaceholderText(Core::Command *command)
void LocatorPlugin::updatePlaceholderText(Command *command)
{
if (!command)
command = qobject_cast<Core::Command *>(sender());
command = qobject_cast<Command *>(sender());
QTC_ASSERT(command, return);
if (command->keySequence().isEmpty())
m_locatorWidget->setPlaceholderText(tr("Type to locate"));
......@@ -168,13 +169,13 @@ bool LocatorPlugin::delayedInitialize()
void LocatorPlugin::loadSettings()
{
QSettings *qs = Core::ICore::settings();
QSettings *qs = ICore::settings();
// Backwards compatibility to old settings location
if (qs->contains(QLatin1String("QuickOpen/FiltersFilter"))) {
loadSettingsHelper(qs);
} else {
Core::SettingsDatabase *settings = Core::ICore::settingsDatabase();
SettingsDatabase *settings = ICore::settingsDatabase();
loadSettingsHelper(settings);
}
......@@ -190,7 +191,7 @@ void LocatorPlugin::loadSettings()
void LocatorPlugin::saveSettings()
{
if (m_settingsInitialized) {
Core::SettingsDatabase *s = Core::ICore::settingsDatabase();
SettingsDatabase *s = ICore::settingsDatabase();
s->beginGroup(QLatin1String("QuickOpen"));
s->remove(QString());
s->setValue(QLatin1String("RefreshInterval"), refreshInterval());
......@@ -259,9 +260,8 @@ void LocatorPlugin::refresh(QList<ILocatorFilter *> filters)
if (filters.isEmpty())
filters = m_filters;
QFuture<void> task = QtConcurrent::run(&ILocatorFilter::refresh, filters);
Core::FutureProgress *progress = Core::ICore::progressManager()
->addTask(task, tr("Indexing"), QLatin1String(Locator::Constants::TASK_INDEX));
connect(progress, SIGNAL(finished()), this, SLOT(saveSettings()));
ProgressManager::addTask(task, tr("Indexing"), QLatin1String(Locator::Constants::TASK_INDEX));
connect(ProgressManager::instance(), SIGNAL(finished()), this, SLOT(saveSettings()));
}