forked from qt-creator/qt-creator
IQuickOpenFilter->ILocatorFilter and QuickOpenToolWindow->LocatorWidget
This commit is contained in:
@@ -162,7 +162,7 @@
|
||||
\row
|
||||
\o Add a new filter to Locator.
|
||||
\o For a text typed in by the user you provide a list of things to show in the popup. When the user selects an entry you are requested to do whatever you want.
|
||||
\o \l{QuickOpen::IQuickOpenFilter}, \l{QuickOpen::FilterEntry}, \l{QuickOpen::BaseFileFilter}
|
||||
\o \l{QuickOpen::ILocatorFilter}, \l{QuickOpen::FilterEntry}, \l{QuickOpen::BaseFileFilter}
|
||||
|
||||
\row
|
||||
\o
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#define CPPCURRENTDOCUMENTFILTER_H
|
||||
|
||||
#include "searchsymbols.h"
|
||||
#include <quickopen/iquickopenfilter.h>
|
||||
#include <quickopen/ilocatorfilter.h>
|
||||
|
||||
namespace Core {
|
||||
class EditorManager;
|
||||
@@ -42,7 +42,7 @@ namespace Internal {
|
||||
|
||||
class CppModelManager;
|
||||
|
||||
class CppCurrentDocumentFilter : public QuickOpen::IQuickOpenFilter
|
||||
class CppCurrentDocumentFilter : public QuickOpen::ILocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include "searchsymbols.h"
|
||||
|
||||
#include <quickopen/iquickopenfilter.h>
|
||||
#include <quickopen/ilocatorfilter.h>
|
||||
|
||||
namespace Core {
|
||||
class EditorManager;
|
||||
@@ -43,7 +43,7 @@ namespace Internal {
|
||||
|
||||
class CppModelManager;
|
||||
|
||||
class CppQuickOpenFilter : public QuickOpen::IQuickOpenFilter
|
||||
class CppQuickOpenFilter : public QuickOpen::ILocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
@@ -41,7 +41,7 @@ using namespace QuickOpen;
|
||||
using namespace Help;
|
||||
using namespace Help::Internal;
|
||||
|
||||
Q_DECLARE_METATYPE(IQuickOpenFilter*);
|
||||
Q_DECLARE_METATYPE(ILocatorFilter*);
|
||||
|
||||
HelpIndexFilter::HelpIndexFilter(HelpPlugin *plugin, QHelpEngine *helpEngine):
|
||||
m_plugin(plugin),
|
||||
@@ -77,7 +77,7 @@ QString HelpIndexFilter::name() const
|
||||
return QLatin1String("HelpIndexFilter");
|
||||
}
|
||||
|
||||
IQuickOpenFilter::Priority HelpIndexFilter::priority() const
|
||||
ILocatorFilter::Priority HelpIndexFilter::priority() const
|
||||
{
|
||||
return Medium;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#ifndef HELPINDEXFILTER_H
|
||||
#define HELPINDEXFILTER_H
|
||||
|
||||
#include <quickopen/iquickopenfilter.h>
|
||||
#include <quickopen/ilocatorfilter.h>
|
||||
|
||||
#include <QtGui/QIcon>
|
||||
|
||||
@@ -44,14 +44,14 @@ namespace Internal {
|
||||
|
||||
class HelpPlugin;
|
||||
|
||||
class HelpIndexFilter : public QuickOpen::IQuickOpenFilter
|
||||
class HelpIndexFilter : public QuickOpen::ILocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HelpIndexFilter(HelpPlugin *plugin, QHelpEngine *helpEngine);
|
||||
|
||||
// IQuickOpenFilter
|
||||
// ILocatorFilter
|
||||
QString trName() const;
|
||||
QString name() const;
|
||||
Priority priority() const;
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
explicit AllProjectsFilter(ProjectExplorerPlugin *pe);
|
||||
QString trName() const { return tr("Files in any project"); }
|
||||
QString name() const { return "Files in any project"; }
|
||||
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Low; }
|
||||
QuickOpen::ILocatorFilter::Priority priority() const { return QuickOpen::ILocatorFilter::Low; }
|
||||
void refresh(QFutureInterface<void> &future);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
CurrentProjectFilter(ProjectExplorerPlugin *pe);
|
||||
QString trName() const { return tr("Files in current project"); }
|
||||
QString name() const { return "Files in current project"; }
|
||||
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Low; }
|
||||
QuickOpen::ILocatorFilter::Priority priority() const { return QuickOpen::ILocatorFilter::Low; }
|
||||
void refresh(QFutureInterface<void> &future);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -31,14 +31,14 @@
|
||||
#define BASEFILEFILTER_H
|
||||
|
||||
#include "quickopen_global.h"
|
||||
#include "iquickopenfilter.h"
|
||||
#include "ilocatorfilter.h"
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QList>
|
||||
|
||||
namespace QuickOpen {
|
||||
|
||||
class QUICKOPEN_EXPORT BaseFileFilter : public QuickOpen::IQuickOpenFilter
|
||||
class QUICKOPEN_EXPORT BaseFileFilter : public QuickOpen::ILocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
DirectoryFilter();
|
||||
QString trName() const { return m_name; }
|
||||
QString name() const { return m_name; }
|
||||
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Medium; }
|
||||
QuickOpen::ILocatorFilter::Priority priority() const { return QuickOpen::ILocatorFilter::Medium; }
|
||||
QByteArray saveState() const;
|
||||
bool restoreState(const QByteArray &state);
|
||||
bool openConfigDialog(QWidget *parent, bool &needsRefresh);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "filesystemfilter.h"
|
||||
#include "quickopentoolwindow.h"
|
||||
#include "locatorwidget.h"
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
|
||||
#include <QtCore/QDir>
|
||||
@@ -37,8 +37,8 @@ using namespace Core;
|
||||
using namespace QuickOpen;
|
||||
using namespace QuickOpen::Internal;
|
||||
|
||||
FileSystemFilter::FileSystemFilter(EditorManager *editorManager, QuickOpenToolWindow *toolWindow)
|
||||
: m_editorManager(editorManager), m_toolWindow(toolWindow), m_includeHidden(true)
|
||||
FileSystemFilter::FileSystemFilter(EditorManager *editorManager, LocatorWidget *locatorWidget)
|
||||
: m_editorManager(editorManager), m_locatorWidget(locatorWidget), m_includeHidden(true)
|
||||
{
|
||||
setShortcutString("f");
|
||||
setIncludedByDefault(false);
|
||||
@@ -96,7 +96,7 @@ void FileSystemFilter::accept(FilterEntry selection) const
|
||||
QFileInfo info(selection.internalData.toString());
|
||||
if (info.isDir()) {
|
||||
QString value = shortcutString() + " " + QDir::toNativeSeparators(info.absoluteFilePath()+"/");
|
||||
m_toolWindow->show(value, value.length());
|
||||
m_locatorWidget->show(value, value.length());
|
||||
return;
|
||||
}
|
||||
m_editorManager->openEditor(selection.internalData.toString());
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#ifndef FILESYSTEMFILTER_H
|
||||
#define FILESYSTEMFILTER_H
|
||||
|
||||
#include "iquickopenfilter.h"
|
||||
#include "ilocatorfilter.h"
|
||||
#include "ui_filesystemfilter.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
@@ -43,17 +43,17 @@
|
||||
namespace QuickOpen {
|
||||
namespace Internal {
|
||||
|
||||
class QuickOpenToolWindow;
|
||||
class LocatorWidget;
|
||||
|
||||
class FileSystemFilter : public QuickOpen::IQuickOpenFilter
|
||||
class FileSystemFilter : public QuickOpen::ILocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FileSystemFilter(Core::EditorManager *editorManager, QuickOpenToolWindow *toolWindow);
|
||||
FileSystemFilter(Core::EditorManager *editorManager, LocatorWidget *locatorWidget);
|
||||
QString trName() const { return tr("Files in file system"); }
|
||||
QString name() const { return "Files in file system"; }
|
||||
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Medium; }
|
||||
QuickOpen::ILocatorFilter::Priority priority() const { return QuickOpen::ILocatorFilter::Medium; }
|
||||
QList<QuickOpen::FilterEntry> matchesFor(const QString &entry);
|
||||
void accept(QuickOpen::FilterEntry selection) const;
|
||||
QByteArray saveState() const;
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
|
||||
private:
|
||||
Core::EditorManager *m_editorManager;
|
||||
QuickOpenToolWindow *m_toolWindow;
|
||||
LocatorWidget *m_locatorWidget;
|
||||
bool m_includeHidden;
|
||||
};
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "iquickopenfilter.h"
|
||||
#include "ilocatorfilter.h"
|
||||
|
||||
#include <QtGui/QBoxLayout>
|
||||
#include <QtGui/QCheckBox>
|
||||
@@ -38,24 +38,24 @@
|
||||
|
||||
using namespace QuickOpen;
|
||||
|
||||
IQuickOpenFilter::IQuickOpenFilter(QObject *parent):
|
||||
ILocatorFilter::ILocatorFilter(QObject *parent):
|
||||
QObject(parent),
|
||||
m_includedByDefault(false),
|
||||
m_hidden(false)
|
||||
{
|
||||
}
|
||||
|
||||
QString IQuickOpenFilter::shortcutString() const
|
||||
QString ILocatorFilter::shortcutString() const
|
||||
{
|
||||
return m_shortcut;
|
||||
}
|
||||
|
||||
void IQuickOpenFilter::setShortcutString(const QString &shortcut)
|
||||
void ILocatorFilter::setShortcutString(const QString &shortcut)
|
||||
{
|
||||
m_shortcut = shortcut;
|
||||
}
|
||||
|
||||
QByteArray IQuickOpenFilter::saveState() const
|
||||
QByteArray ILocatorFilter::saveState() const
|
||||
{
|
||||
QByteArray value;
|
||||
QDataStream out(&value, QIODevice::WriteOnly);
|
||||
@@ -64,7 +64,7 @@ QByteArray IQuickOpenFilter::saveState() const
|
||||
return value;
|
||||
}
|
||||
|
||||
bool IQuickOpenFilter::restoreState(const QByteArray &state)
|
||||
bool ILocatorFilter::restoreState(const QByteArray &state)
|
||||
{
|
||||
QString shortcut;
|
||||
bool defaultFilter;
|
||||
@@ -78,7 +78,7 @@ bool IQuickOpenFilter::restoreState(const QByteArray &state)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IQuickOpenFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
|
||||
bool ILocatorFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
|
||||
{
|
||||
Q_UNUSED(needsRefresh)
|
||||
|
||||
@@ -113,27 +113,27 @@ bool IQuickOpenFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IQuickOpenFilter::isConfigurable() const
|
||||
bool ILocatorFilter::isConfigurable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IQuickOpenFilter::isIncludedByDefault() const
|
||||
bool ILocatorFilter::isIncludedByDefault() const
|
||||
{
|
||||
return m_includedByDefault;
|
||||
}
|
||||
|
||||
void IQuickOpenFilter::setIncludedByDefault(bool includedByDefault)
|
||||
void ILocatorFilter::setIncludedByDefault(bool includedByDefault)
|
||||
{
|
||||
m_includedByDefault = includedByDefault;
|
||||
}
|
||||
|
||||
bool IQuickOpenFilter::isHidden() const
|
||||
bool ILocatorFilter::isHidden() const
|
||||
{
|
||||
return m_hidden;
|
||||
}
|
||||
|
||||
void IQuickOpenFilter::setHidden(bool hidden)
|
||||
void ILocatorFilter::setHidden(bool hidden)
|
||||
{
|
||||
m_hidden = hidden;
|
||||
}
|
||||
@@ -27,8 +27,8 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef IQUICKOPENFILTER_H
|
||||
#define IQUICKOPENFILTER_H
|
||||
#ifndef ILOCATORFILTER_H
|
||||
#define ILOCATORFILTER_H
|
||||
|
||||
#include "quickopen_global.h"
|
||||
|
||||
@@ -39,12 +39,12 @@
|
||||
|
||||
namespace QuickOpen {
|
||||
|
||||
class IQuickOpenFilter;
|
||||
class ILocatorFilter;
|
||||
|
||||
struct FilterEntry
|
||||
{
|
||||
FilterEntry() {}
|
||||
FilterEntry(IQuickOpenFilter *fromFilter, const QString &name, const QVariant &data,
|
||||
FilterEntry(ILocatorFilter *fromFilter, const QString &name, const QVariant &data,
|
||||
const QIcon &icon = QIcon())
|
||||
: filter(fromFilter)
|
||||
, displayName(name)
|
||||
@@ -60,7 +60,7 @@ struct FilterEntry
|
||||
}
|
||||
|
||||
/* backpointer to creating filter */
|
||||
IQuickOpenFilter *filter;
|
||||
ILocatorFilter *filter;
|
||||
/* displayed string */
|
||||
QString displayName;
|
||||
/* extra information displayed in light-gray in a second column (optional) */
|
||||
@@ -73,15 +73,15 @@ struct FilterEntry
|
||||
bool resolveFileIcon;
|
||||
};
|
||||
|
||||
class QUICKOPEN_EXPORT IQuickOpenFilter : public QObject
|
||||
class QUICKOPEN_EXPORT ILocatorFilter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Priority {High = 0, Medium = 1, Low = 2};
|
||||
|
||||
IQuickOpenFilter(QObject *parent = 0);
|
||||
virtual ~IQuickOpenFilter() {}
|
||||
ILocatorFilter(QObject *parent = 0);
|
||||
virtual ~ILocatorFilter() {}
|
||||
|
||||
/* Visible name. */
|
||||
virtual QString trName() const = 0;
|
||||
@@ -153,4 +153,4 @@ private:
|
||||
|
||||
} // namespace QuickOpen
|
||||
|
||||
#endif // IQUICKOPENFILTER_H
|
||||
#endif // ILOCATORFILTER_H
|
||||
@@ -37,7 +37,7 @@ QT_BEGIN_NAMESPACE
|
||||
unsigned int qHash(const QuickOpen::FilterEntry &entry);
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "quickopentoolwindow.h"
|
||||
#include "locatorwidget.h"
|
||||
#include "quickopenplugin.h"
|
||||
#include "quickopenconstants.h"
|
||||
|
||||
@@ -67,7 +67,7 @@ QT_END_NAMESPACE
|
||||
#include <QtGui/QScrollBar>
|
||||
#include <QtGui/QTreeView>
|
||||
|
||||
Q_DECLARE_METATYPE(QuickOpen::IQuickOpenFilter*);
|
||||
Q_DECLARE_METATYPE(QuickOpen::ILocatorFilter*);
|
||||
Q_DECLARE_METATYPE(QuickOpen::FilterEntry);
|
||||
|
||||
namespace QuickOpen {
|
||||
@@ -244,9 +244,9 @@ void CompletionList::updatePreferredSize()
|
||||
}
|
||||
|
||||
|
||||
// =========== QuickOpenToolWindow ===========
|
||||
// =========== LocatorWidget ===========
|
||||
|
||||
QuickOpenToolWindow::QuickOpenToolWindow(QuickOpenPlugin *qop) :
|
||||
LocatorWidget::LocatorWidget(QuickOpenPlugin *qop) :
|
||||
m_quickOpenPlugin(qop),
|
||||
m_quickOpenModel(new QuickOpenModel(this)),
|
||||
m_completionList(new CompletionList(this)),
|
||||
@@ -301,15 +301,15 @@ QuickOpenToolWindow::QuickOpenToolWindow(QuickOpenPlugin *qop) :
|
||||
this, SLOT(acceptCurrentEntry()));
|
||||
}
|
||||
|
||||
bool QuickOpenToolWindow::isShowingTypeHereMessage() const
|
||||
bool LocatorWidget::isShowingTypeHereMessage() const
|
||||
{
|
||||
return m_fileLineEdit->isShowingHintText();
|
||||
}
|
||||
|
||||
void QuickOpenToolWindow::updateFilterList()
|
||||
void LocatorWidget::updateFilterList()
|
||||
{
|
||||
m_filterMenu->clear();
|
||||
foreach (IQuickOpenFilter *filter, m_quickOpenPlugin->filters()) {
|
||||
foreach (ILocatorFilter *filter, m_quickOpenPlugin->filters()) {
|
||||
if (!filter->shortcutString().isEmpty() && !filter->isHidden()) {
|
||||
QAction *action = m_filterMenu->addAction(filter->trName(), this, SLOT(filterSelected()));
|
||||
action->setData(qVariantFromValue(filter));
|
||||
@@ -320,7 +320,7 @@ void QuickOpenToolWindow::updateFilterList()
|
||||
m_filterMenu->addAction(m_configureAction);
|
||||
}
|
||||
|
||||
bool QuickOpenToolWindow::eventFilter(QObject *obj, QEvent *event)
|
||||
bool LocatorWidget::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (obj == m_fileLineEdit && event->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
@@ -357,7 +357,7 @@ bool QuickOpenToolWindow::eventFilter(QObject *obj, QEvent *event)
|
||||
return QWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void QuickOpenToolWindow::showCompletionList()
|
||||
void LocatorWidget::showCompletionList()
|
||||
{
|
||||
const int border = m_completionList->frameWidth();
|
||||
const QSize size = m_completionList->preferredSize();
|
||||
@@ -366,44 +366,44 @@ void QuickOpenToolWindow::showCompletionList()
|
||||
m_completionList->show();
|
||||
}
|
||||
|
||||
void QuickOpenToolWindow::showPopup()
|
||||
void LocatorWidget::showPopup()
|
||||
{
|
||||
updateCompletionList(m_fileLineEdit->typedText());
|
||||
showCompletionList();
|
||||
}
|
||||
|
||||
QList<IQuickOpenFilter*> QuickOpenToolWindow::filtersFor(const QString &text, QString &searchText)
|
||||
QList<ILocatorFilter*> LocatorWidget::filtersFor(const QString &text, QString &searchText)
|
||||
{
|
||||
QList<IQuickOpenFilter*> filters = m_quickOpenPlugin->filters();
|
||||
QList<ILocatorFilter*> filters = m_quickOpenPlugin->filters();
|
||||
int whiteSpace = text.indexOf(" ");
|
||||
QString prefix;
|
||||
if (whiteSpace >= 0)
|
||||
prefix = text.left(whiteSpace);
|
||||
if (!prefix.isEmpty()) {
|
||||
prefix = prefix.toLower();
|
||||
foreach (IQuickOpenFilter *filter, filters) {
|
||||
foreach (ILocatorFilter *filter, filters) {
|
||||
if (prefix == filter->shortcutString()) {
|
||||
searchText = text.mid(whiteSpace+1);
|
||||
return QList<IQuickOpenFilter*>() << filter;
|
||||
return QList<ILocatorFilter*>() << filter;
|
||||
}
|
||||
}
|
||||
}
|
||||
searchText = text;
|
||||
QList<IQuickOpenFilter*> activeFilters;
|
||||
foreach (IQuickOpenFilter *filter, filters)
|
||||
QList<ILocatorFilter*> activeFilters;
|
||||
foreach (ILocatorFilter *filter, filters)
|
||||
if (filter->isIncludedByDefault())
|
||||
activeFilters << filter;
|
||||
return activeFilters;
|
||||
}
|
||||
|
||||
void QuickOpenToolWindow::updateCompletionList(const QString &text)
|
||||
void LocatorWidget::updateCompletionList(const QString &text)
|
||||
{
|
||||
QString searchText;
|
||||
const QList<IQuickOpenFilter*> filters = filtersFor(text, searchText);
|
||||
const QList<ILocatorFilter*> filters = filtersFor(text, searchText);
|
||||
QSet<FilterEntry> alreadyAdded;
|
||||
const bool checkDuplicates = (filters.size() > 1);
|
||||
QList<FilterEntry> entries;
|
||||
foreach (IQuickOpenFilter *filter, filters) {
|
||||
foreach (ILocatorFilter *filter, filters) {
|
||||
foreach (const FilterEntry &entry, filter->matchesFor(searchText)) {
|
||||
if (checkDuplicates && alreadyAdded.contains(entry))
|
||||
continue;
|
||||
@@ -421,7 +421,7 @@ void QuickOpenToolWindow::updateCompletionList(const QString &text)
|
||||
#endif
|
||||
}
|
||||
|
||||
void QuickOpenToolWindow::acceptCurrentEntry()
|
||||
void LocatorWidget::acceptCurrentEntry()
|
||||
{
|
||||
if (!m_completionList->isVisible())
|
||||
return;
|
||||
@@ -433,7 +433,7 @@ void QuickOpenToolWindow::acceptCurrentEntry()
|
||||
entry.filter->accept(entry);
|
||||
}
|
||||
|
||||
void QuickOpenToolWindow::show(const QString &text, int selectionStart, int selectionLength)
|
||||
void LocatorWidget::show(const QString &text, int selectionStart, int selectionLength)
|
||||
{
|
||||
m_fileLineEdit->hideHintText();
|
||||
if (!text.isEmpty())
|
||||
@@ -452,18 +452,18 @@ void QuickOpenToolWindow::show(const QString &text, int selectionStart, int sele
|
||||
}
|
||||
}
|
||||
|
||||
void QuickOpenToolWindow::filterSelected()
|
||||
void LocatorWidget::filterSelected()
|
||||
{
|
||||
QString searchText = tr("<type here>");
|
||||
QAction *action = qobject_cast<QAction*>(sender());
|
||||
QTC_ASSERT(action, return);
|
||||
IQuickOpenFilter *filter = action->data().value<IQuickOpenFilter*>();
|
||||
ILocatorFilter *filter = action->data().value<ILocatorFilter*>();
|
||||
QTC_ASSERT(filter, return);
|
||||
QString currentText = m_fileLineEdit->text().trimmed();
|
||||
// add shortcut string at front or replace existing shortcut string
|
||||
if (!currentText.isEmpty()) {
|
||||
searchText = currentText;
|
||||
foreach (IQuickOpenFilter *otherfilter, m_quickOpenPlugin->filters()) {
|
||||
foreach (ILocatorFilter *otherfilter, m_quickOpenPlugin->filters()) {
|
||||
if (currentText.startsWith(otherfilter->shortcutString() + " ")) {
|
||||
searchText = currentText.mid(otherfilter->shortcutString().length()+1);
|
||||
break;
|
||||
@@ -477,12 +477,12 @@ void QuickOpenToolWindow::filterSelected()
|
||||
m_fileLineEdit->setFocus();
|
||||
}
|
||||
|
||||
void QuickOpenToolWindow::showEvent(QShowEvent *event)
|
||||
void LocatorWidget::showEvent(QShowEvent *event)
|
||||
{
|
||||
QWidget::showEvent(event);
|
||||
}
|
||||
|
||||
void QuickOpenToolWindow::showConfigureDialog()
|
||||
void LocatorWidget::showConfigureDialog()
|
||||
{
|
||||
Core::ICore::instance()->showOptionsDialog(Constants::QUICKOPEN_CATEGORY,
|
||||
Constants::FILTER_OPTIONS_PAGE);
|
||||
@@ -27,8 +27,8 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef QUICKOPENTOOLWINDOW_H
|
||||
#define QUICKOPENTOOLWINDOW_H
|
||||
#ifndef LOCATORWIDGET_H
|
||||
#define LOCATORWIDGET_H
|
||||
|
||||
#include "quickopenplugin.h"
|
||||
|
||||
@@ -53,13 +53,13 @@ namespace Internal {
|
||||
class QuickOpenModel;
|
||||
class CompletionList;
|
||||
|
||||
class QuickOpenToolWindow
|
||||
class LocatorWidget
|
||||
: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QuickOpenToolWindow(QuickOpenPlugin *qop);
|
||||
LocatorWidget(QuickOpenPlugin *qop);
|
||||
|
||||
void updateFilterList();
|
||||
|
||||
@@ -79,7 +79,7 @@ private:
|
||||
bool isShowingTypeHereMessage() const;
|
||||
void showCompletionList();
|
||||
void updateCompletionList(const QString &text);
|
||||
QList<IQuickOpenFilter*> filtersFor(const QString &text, QString &searchText);
|
||||
QList<ILocatorFilter*> filtersFor(const QString &text, QString &searchText);
|
||||
|
||||
QuickOpenPlugin *m_quickOpenPlugin;
|
||||
QuickOpenModel *m_quickOpenModel;
|
||||
@@ -94,4 +94,4 @@ private:
|
||||
} // namespace Internal
|
||||
} // namespace QuickOpen
|
||||
|
||||
#endif // QUICKOPENTOOLWINDOW_H
|
||||
#endif // LOCATORWIDGET_H
|
||||
@@ -30,7 +30,7 @@
|
||||
#ifndef OPENDOCUMENTSFILTER_H
|
||||
#define OPENDOCUMENTSFILTER_H
|
||||
|
||||
#include "iquickopenfilter.h"
|
||||
#include "ilocatorfilter.h"
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QList>
|
||||
@@ -44,7 +44,7 @@
|
||||
namespace QuickOpen {
|
||||
namespace Internal {
|
||||
|
||||
class OpenDocumentsFilter : public QuickOpen::IQuickOpenFilter
|
||||
class OpenDocumentsFilter : public QuickOpen::ILocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
OpenDocumentsFilter(Core::EditorManager *editorManager);
|
||||
QString trName() const { return tr("Open documents"); }
|
||||
QString name() const { return "Open documents"; }
|
||||
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::Medium; }
|
||||
QuickOpen::ILocatorFilter::Priority priority() const { return QuickOpen::ILocatorFilter::Medium; }
|
||||
QList<QuickOpen::FilterEntry> matchesFor(const QString &entry);
|
||||
void accept(QuickOpen::FilterEntry selection) const;
|
||||
void refresh(QFutureInterface<void> &future);
|
||||
|
||||
@@ -4,10 +4,10 @@ DEFINES += QUICKOPEN_LIBRARY
|
||||
include(../../qtcreatorplugin.pri)
|
||||
include(quickopen_dependencies.pri)
|
||||
HEADERS += quickopenplugin.h \
|
||||
quickopentoolwindow.h \
|
||||
locatorwidget.h \
|
||||
quickopenfiltersfilter.h \
|
||||
settingspage.h \
|
||||
iquickopenfilter.h \
|
||||
ilocatorfilter.h \
|
||||
opendocumentsfilter.h \
|
||||
filesystemfilter.h \
|
||||
quickopenconstants.h \
|
||||
@@ -16,7 +16,7 @@ HEADERS += quickopenplugin.h \
|
||||
basefilefilter.h \
|
||||
quickopen_global.h
|
||||
SOURCES += quickopenplugin.cpp \
|
||||
quickopentoolwindow.cpp \
|
||||
locatorwidget.cpp \
|
||||
quickopenfiltersfilter.cpp \
|
||||
opendocumentsfilter.cpp \
|
||||
filesystemfilter.cpp \
|
||||
@@ -24,7 +24,7 @@ SOURCES += quickopenplugin.cpp \
|
||||
directoryfilter.cpp \
|
||||
quickopenmanager.cpp \
|
||||
basefilefilter.cpp \
|
||||
iquickopenfilter.cpp
|
||||
ilocatorfilter.cpp
|
||||
FORMS += settingspage.ui \
|
||||
filesystemfilter.ui \
|
||||
directoryfilter.ui
|
||||
|
||||
@@ -29,19 +29,19 @@
|
||||
|
||||
#include "quickopenfiltersfilter.h"
|
||||
#include "quickopenplugin.h"
|
||||
#include "quickopentoolwindow.h"
|
||||
#include "locatorwidget.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
|
||||
using namespace QuickOpen;
|
||||
using namespace QuickOpen::Internal;
|
||||
|
||||
Q_DECLARE_METATYPE(IQuickOpenFilter*);
|
||||
Q_DECLARE_METATYPE(ILocatorFilter*);
|
||||
|
||||
QuickOpenFiltersFilter::QuickOpenFiltersFilter(QuickOpenPlugin *plugin,
|
||||
QuickOpenToolWindow *toolWindow):
|
||||
LocatorWidget *locatorWidget):
|
||||
m_plugin(plugin),
|
||||
m_toolWindow(toolWindow),
|
||||
m_locatorWidget(locatorWidget),
|
||||
m_icon(QIcon(Core::Constants::ICON_NEXT))
|
||||
{
|
||||
setIncludedByDefault(true);
|
||||
@@ -58,7 +58,7 @@ QString QuickOpenFiltersFilter::name() const
|
||||
return QLatin1String("FiltersFilter");
|
||||
}
|
||||
|
||||
IQuickOpenFilter::Priority QuickOpenFiltersFilter::priority() const
|
||||
ILocatorFilter::Priority QuickOpenFiltersFilter::priority() const
|
||||
{
|
||||
return High;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ QList<FilterEntry> QuickOpenFiltersFilter::matchesFor(const QString &entry)
|
||||
{
|
||||
QList<FilterEntry> entries;
|
||||
if (entry.isEmpty()) {
|
||||
foreach (IQuickOpenFilter *filter, m_plugin->filters()) {
|
||||
foreach (ILocatorFilter *filter, m_plugin->filters()) {
|
||||
if (!filter->shortcutString().isEmpty() && !filter->isHidden()) {
|
||||
FilterEntry entry(this,
|
||||
filter->shortcutString(),
|
||||
@@ -83,9 +83,9 @@ QList<FilterEntry> QuickOpenFiltersFilter::matchesFor(const QString &entry)
|
||||
|
||||
void QuickOpenFiltersFilter::accept(FilterEntry selection) const
|
||||
{
|
||||
IQuickOpenFilter *filter = selection.internalData.value<IQuickOpenFilter*>();
|
||||
ILocatorFilter *filter = selection.internalData.value<ILocatorFilter*>();
|
||||
if (filter)
|
||||
m_toolWindow->show(filter->shortcutString() + " ",
|
||||
m_locatorWidget->show(filter->shortcutString() + " ",
|
||||
filter->shortcutString().length() + 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#ifndef QUICKOPENFILTERSFILTER_H
|
||||
#define QUICKOPENFILTERSFILTER_H
|
||||
|
||||
#include "iquickopenfilter.h"
|
||||
#include "ilocatorfilter.h"
|
||||
|
||||
#include <QtGui/QIcon>
|
||||
|
||||
@@ -38,21 +38,21 @@ namespace QuickOpen {
|
||||
namespace Internal {
|
||||
|
||||
class QuickOpenPlugin;
|
||||
class QuickOpenToolWindow;
|
||||
class LocatorWidget;
|
||||
|
||||
/*!
|
||||
This filter provides the user with the list of available QuickOpen filters.
|
||||
The list is only shown when nothing has been typed yet.
|
||||
*/
|
||||
class QuickOpenFiltersFilter : public IQuickOpenFilter
|
||||
class QuickOpenFiltersFilter : public ILocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QuickOpenFiltersFilter(QuickOpenPlugin *plugin,
|
||||
QuickOpenToolWindow *toolWindow);
|
||||
LocatorWidget *locatorWidget);
|
||||
|
||||
// IQuickOpenFilter
|
||||
// ILocatorFilter
|
||||
QString trName() const;
|
||||
QString name() const;
|
||||
Priority priority() const;
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
|
||||
private:
|
||||
QuickOpenPlugin *m_plugin;
|
||||
QuickOpenToolWindow *m_toolWindow;
|
||||
LocatorWidget *m_locatorWidget;
|
||||
QIcon m_icon;
|
||||
};
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "quickopenmanager.h"
|
||||
#include "quickopentoolwindow.h"
|
||||
#include "locatorwidget.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -38,9 +38,9 @@ using namespace QuickOpen::Internal;
|
||||
|
||||
QuickOpenManager *QuickOpenManager::m_instance = 0;
|
||||
|
||||
QuickOpenManager::QuickOpenManager(QuickOpenToolWindow *toolWindow)
|
||||
: QObject(toolWindow),
|
||||
m_toolWindow(toolWindow)
|
||||
QuickOpenManager::QuickOpenManager(LocatorWidget *locatorWidget)
|
||||
: QObject(locatorWidget),
|
||||
m_locatorWidget(locatorWidget)
|
||||
{
|
||||
m_instance = this;
|
||||
}
|
||||
@@ -54,6 +54,6 @@ QuickOpenManager::~QuickOpenManager()
|
||||
void QuickOpenManager::show(const QString &text,
|
||||
int selectionStart, int selectionLength)
|
||||
{
|
||||
QTC_ASSERT(m_toolWindow, return);
|
||||
m_toolWindow->show(text, selectionStart, selectionLength);
|
||||
QTC_ASSERT(m_locatorWidget, return);
|
||||
m_locatorWidget->show(text, selectionStart, selectionLength);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
namespace QuickOpen {
|
||||
|
||||
namespace Internal {
|
||||
class QuickOpenToolWindow;
|
||||
class LocatorWidget;
|
||||
}
|
||||
|
||||
class QUICKOPEN_EXPORT QuickOpenManager : public QObject
|
||||
@@ -45,7 +45,7 @@ class QUICKOPEN_EXPORT QuickOpenManager : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QuickOpenManager(Internal::QuickOpenToolWindow *toolWindow);
|
||||
QuickOpenManager(Internal::LocatorWidget *locatorWidget);
|
||||
~QuickOpenManager();
|
||||
|
||||
static QuickOpenManager* instance() { return m_instance; }
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
void show(const QString &text, int selectionStart = -1, int selectionLength = 0);
|
||||
|
||||
private:
|
||||
Internal::QuickOpenToolWindow *m_toolWindow;
|
||||
Internal::LocatorWidget *m_locatorWidget;
|
||||
static QuickOpenManager *m_instance;
|
||||
};
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "quickopenconstants.h"
|
||||
#include "quickopenfiltersfilter.h"
|
||||
#include "quickopenmanager.h"
|
||||
#include "quickopentoolwindow.h"
|
||||
#include "locatorwidget.h"
|
||||
#include "opendocumentsfilter.h"
|
||||
#include "filesystemfilter.h"
|
||||
#include "settingspage.h"
|
||||
@@ -64,7 +64,7 @@ using namespace QuickOpen;
|
||||
using namespace QuickOpen::Internal;
|
||||
|
||||
namespace {
|
||||
static bool filterLessThan(const IQuickOpenFilter *first, const IQuickOpenFilter *second)
|
||||
static bool filterLessThan(const ILocatorFilter *first, const ILocatorFilter *second)
|
||||
{
|
||||
return first->priority() < second->priority();
|
||||
}
|
||||
@@ -93,18 +93,18 @@ bool QuickOpenPlugin::initialize(const QStringList &, QString *)
|
||||
m_settingsPage = new SettingsPage(this);
|
||||
addObject(m_settingsPage);
|
||||
|
||||
m_quickOpenToolWindow = new QuickOpenToolWindow(this);
|
||||
m_quickOpenToolWindow->setEnabled(false);
|
||||
m_locatorWidget = new LocatorWidget(this);
|
||||
m_locatorWidget->setEnabled(false);
|
||||
Core::BaseView *view = new Core::BaseView;
|
||||
view->setUniqueViewName("QuickOpen");
|
||||
view->setWidget(m_quickOpenToolWindow);
|
||||
view->setWidget(m_locatorWidget);
|
||||
view->setContext(QList<int>() << core->uniqueIDManager()
|
||||
->uniqueIdentifier(QLatin1String("QuickOpenToolWindow")));
|
||||
->uniqueIdentifier(QLatin1String("LocatorWidget")));
|
||||
view->setDefaultPosition(Core::IView::First);
|
||||
addAutoReleasedObject(view);
|
||||
|
||||
const QString actionId = QLatin1String("QtCreator.Locate");
|
||||
QAction *action = new QAction(m_quickOpenToolWindow->windowIcon(), m_quickOpenToolWindow->windowTitle(), this);
|
||||
QAction *action = new QAction(m_locatorWidget->windowIcon(), m_locatorWidget->windowTitle(), this);
|
||||
Core::Command *cmd = core->actionManager()->registerAction(action, actionId, QList<int>() << Core::Constants::C_GLOBAL_ID);
|
||||
cmd->setDefaultKeySequence(QKeySequence("Ctrl+K"));
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(openQuickOpen()));
|
||||
@@ -112,15 +112,15 @@ bool QuickOpenPlugin::initialize(const QStringList &, QString *)
|
||||
Core::ActionContainer *mtools = core->actionManager()->actionContainer(Core::Constants::M_TOOLS);
|
||||
mtools->addAction(cmd);
|
||||
|
||||
addObject(new QuickOpenManager(m_quickOpenToolWindow));
|
||||
addObject(new QuickOpenManager(m_locatorWidget));
|
||||
|
||||
m_openDocumentsFilter = new OpenDocumentsFilter(core->editorManager());
|
||||
addObject(m_openDocumentsFilter);
|
||||
|
||||
m_fileSystemFilter = new FileSystemFilter(core->editorManager(), m_quickOpenToolWindow);
|
||||
m_fileSystemFilter = new FileSystemFilter(core->editorManager(), m_locatorWidget);
|
||||
addObject(m_fileSystemFilter);
|
||||
|
||||
addAutoReleasedObject(new QuickOpenFiltersFilter(this, m_quickOpenToolWindow));
|
||||
addAutoReleasedObject(new QuickOpenFiltersFilter(this, m_locatorWidget));
|
||||
|
||||
connect(core, SIGNAL(coreOpened()), this, SLOT(startSettingsLoad()));
|
||||
return true;
|
||||
@@ -128,12 +128,12 @@ bool QuickOpenPlugin::initialize(const QStringList &, QString *)
|
||||
|
||||
void QuickOpenPlugin::openQuickOpen()
|
||||
{
|
||||
m_quickOpenToolWindow->show("");
|
||||
m_locatorWidget->show("");
|
||||
}
|
||||
|
||||
void QuickOpenPlugin::extensionsInitialized()
|
||||
{
|
||||
m_filters = ExtensionSystem::PluginManager::instance()->getObjects<IQuickOpenFilter>();
|
||||
m_filters = ExtensionSystem::PluginManager::instance()->getObjects<ILocatorFilter>();
|
||||
qSort(m_filters.begin(), m_filters.end(), filterLessThan);
|
||||
}
|
||||
|
||||
@@ -161,8 +161,8 @@ void QuickOpenPlugin::loadSettings()
|
||||
|
||||
void QuickOpenPlugin::settingsLoaded()
|
||||
{
|
||||
m_quickOpenToolWindow->updateFilterList();
|
||||
m_quickOpenToolWindow->setEnabled(true);
|
||||
m_locatorWidget->updateFilterList();
|
||||
m_locatorWidget->setEnabled(true);
|
||||
if (m_refreshTimer.interval() > 0)
|
||||
m_refreshTimer.start();
|
||||
}
|
||||
@@ -175,13 +175,13 @@ void QuickOpenPlugin::saveSettings()
|
||||
s->beginGroup("QuickOpen");
|
||||
s->remove("");
|
||||
s->setValue("RefreshInterval", refreshInterval());
|
||||
foreach (IQuickOpenFilter *filter, m_filters) {
|
||||
foreach (ILocatorFilter *filter, m_filters) {
|
||||
if (!m_customFilters.contains(filter))
|
||||
s->setValue(filter->name(), filter->saveState());
|
||||
}
|
||||
s->beginGroup("CustomFilters");
|
||||
int i = 0;
|
||||
foreach (IQuickOpenFilter *filter, m_customFilters) {
|
||||
foreach (ILocatorFilter *filter, m_customFilters) {
|
||||
s->setValue(QString("directory%1").arg(i), filter->saveState());
|
||||
++i;
|
||||
}
|
||||
@@ -191,33 +191,33 @@ void QuickOpenPlugin::saveSettings()
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QList<IQuickOpenFilter*> QuickOpenPlugin::filter()
|
||||
\fn QList<ILocatorFilter*> QuickOpenPlugin::filter()
|
||||
|
||||
Return all filters, including the ones created by the user.
|
||||
*/
|
||||
QList<IQuickOpenFilter*> QuickOpenPlugin::filters()
|
||||
QList<ILocatorFilter*> QuickOpenPlugin::filters()
|
||||
{
|
||||
return m_filters;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QList<IQuickOpenFilter*> QuickOpenPlugin::customFilter()
|
||||
\fn QList<ILocatorFilter*> QuickOpenPlugin::customFilter()
|
||||
|
||||
This returns a subset of all the filters, that contains only the filters that
|
||||
have been created by the user at some point (maybe in a previous session).
|
||||
*/
|
||||
QList<IQuickOpenFilter*> QuickOpenPlugin::customFilters()
|
||||
QList<ILocatorFilter*> QuickOpenPlugin::customFilters()
|
||||
{
|
||||
return m_customFilters;
|
||||
}
|
||||
|
||||
void QuickOpenPlugin::setFilters(QList<IQuickOpenFilter*> f)
|
||||
void QuickOpenPlugin::setFilters(QList<ILocatorFilter*> f)
|
||||
{
|
||||
m_filters = f;
|
||||
m_quickOpenToolWindow->updateFilterList();
|
||||
m_locatorWidget->updateFilterList();
|
||||
}
|
||||
|
||||
void QuickOpenPlugin::setCustomFilters(QList<IQuickOpenFilter *> filters)
|
||||
void QuickOpenPlugin::setCustomFilters(QList<ILocatorFilter *> filters)
|
||||
{
|
||||
m_customFilters = filters;
|
||||
}
|
||||
@@ -238,11 +238,11 @@ void QuickOpenPlugin::setRefreshInterval(int interval)
|
||||
m_refreshTimer.start();
|
||||
}
|
||||
|
||||
void QuickOpenPlugin::refresh(QList<IQuickOpenFilter*> filters)
|
||||
void QuickOpenPlugin::refresh(QList<ILocatorFilter*> filters)
|
||||
{
|
||||
if (filters.isEmpty())
|
||||
filters = m_filters;
|
||||
QFuture<void> task = QtConcurrent::run(&IQuickOpenFilter::refresh, filters);
|
||||
QFuture<void> task = QtConcurrent::run(&ILocatorFilter::refresh, filters);
|
||||
Core::FutureProgress *progress = Core::ICore::instance()
|
||||
->progressManager()->addTask(task, tr("Indexing"),
|
||||
QuickOpen::Constants::TASK_INDEX,
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#ifndef QUICKOPENPLUGIN_H
|
||||
#define QUICKOPENPLUGIN_H
|
||||
|
||||
#include "iquickopenfilter.h"
|
||||
#include "ilocatorfilter.h"
|
||||
#include "directoryfilter.h"
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
@@ -42,7 +42,7 @@
|
||||
namespace QuickOpen {
|
||||
namespace Internal {
|
||||
|
||||
class QuickOpenToolWindow;
|
||||
class LocatorWidget;
|
||||
class OpenDocumentsFilter;
|
||||
class FileSystemFilter;
|
||||
class SettingsPage;
|
||||
@@ -59,15 +59,15 @@ public:
|
||||
bool initialize(const QStringList &arguments, QString *error_message);
|
||||
void extensionsInitialized();
|
||||
|
||||
QList<IQuickOpenFilter*> filters();
|
||||
QList<IQuickOpenFilter*> customFilters();
|
||||
void setFilters(QList<IQuickOpenFilter*> f);
|
||||
void setCustomFilters(QList<IQuickOpenFilter*> f);
|
||||
QList<ILocatorFilter*> filters();
|
||||
QList<ILocatorFilter*> customFilters();
|
||||
void setFilters(QList<ILocatorFilter*> f);
|
||||
void setCustomFilters(QList<ILocatorFilter*> f);
|
||||
int refreshInterval();
|
||||
void setRefreshInterval(int interval);
|
||||
|
||||
public slots:
|
||||
void refresh(QList<IQuickOpenFilter*> filters = QList<IQuickOpenFilter*>());
|
||||
void refresh(QList<ILocatorFilter*> filters = QList<ILocatorFilter*>());
|
||||
void saveSettings();
|
||||
void openQuickOpen();
|
||||
|
||||
@@ -81,11 +81,11 @@ private:
|
||||
template <typename S>
|
||||
void loadSettingsHelper(S *settings);
|
||||
|
||||
QuickOpenToolWindow *m_quickOpenToolWindow;
|
||||
LocatorWidget *m_locatorWidget;
|
||||
SettingsPage *m_settingsPage;
|
||||
|
||||
QList<IQuickOpenFilter*> m_filters;
|
||||
QList<IQuickOpenFilter*> m_customFilters;
|
||||
QList<ILocatorFilter*> m_filters;
|
||||
QList<ILocatorFilter*> m_customFilters;
|
||||
int m_refreshInterval;
|
||||
QTimer m_refreshTimer;
|
||||
OpenDocumentsFilter *m_openDocumentsFilter;
|
||||
@@ -99,7 +99,7 @@ void QuickOpenPlugin::loadSettingsHelper(S *settings)
|
||||
settings->beginGroup("QuickOpen");
|
||||
m_refreshTimer.setInterval(settings->value("RefreshInterval", 60).toInt() * 60000);
|
||||
|
||||
foreach (IQuickOpenFilter *filter, m_filters) {
|
||||
foreach (ILocatorFilter *filter, m_filters) {
|
||||
if (settings->contains(filter->name())) {
|
||||
const QByteArray state = settings->value(filter->name()).toByteArray();
|
||||
if (!state.isEmpty())
|
||||
@@ -107,10 +107,10 @@ void QuickOpenPlugin::loadSettingsHelper(S *settings)
|
||||
}
|
||||
}
|
||||
settings->beginGroup("CustomFilters");
|
||||
QList<IQuickOpenFilter *> customFilters;
|
||||
QList<ILocatorFilter *> customFilters;
|
||||
const QStringList keys = settings->childKeys();
|
||||
foreach (const QString &key, keys) {
|
||||
IQuickOpenFilter *filter = new DirectoryFilter;
|
||||
ILocatorFilter *filter = new DirectoryFilter;
|
||||
filter->restoreState(settings->value(key).toByteArray());
|
||||
m_filters.append(filter);
|
||||
customFilters.append(filter);
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "quickopenconstants.h"
|
||||
|
||||
#include "quickopenplugin.h"
|
||||
#include "iquickopenfilter.h"
|
||||
#include "ilocatorfilter.h"
|
||||
#include "directoryfilter.h"
|
||||
|
||||
#include <qtconcurrent/QtConcurrentTools>
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
|
||||
Q_DECLARE_METATYPE(QuickOpen::IQuickOpenFilter*)
|
||||
Q_DECLARE_METATYPE(QuickOpen::ILocatorFilter*)
|
||||
|
||||
using namespace QuickOpen;
|
||||
using namespace QuickOpen::Internal;
|
||||
@@ -135,20 +135,20 @@ void SettingsPage::requestRefresh()
|
||||
void SettingsPage::saveFilterStates()
|
||||
{
|
||||
m_filterStates.clear();
|
||||
foreach (IQuickOpenFilter *filter, m_filters)
|
||||
foreach (ILocatorFilter *filter, m_filters)
|
||||
m_filterStates.insert(filter, filter->saveState());
|
||||
}
|
||||
|
||||
void SettingsPage::restoreFilterStates()
|
||||
{
|
||||
foreach (IQuickOpenFilter *filter, m_filterStates.keys())
|
||||
foreach (ILocatorFilter *filter, m_filterStates.keys())
|
||||
filter->restoreState(m_filterStates.value(filter));
|
||||
}
|
||||
|
||||
void SettingsPage::updateFilterList()
|
||||
{
|
||||
m_ui.filterList->clear();
|
||||
foreach (IQuickOpenFilter *filter, m_filters) {
|
||||
foreach (ILocatorFilter *filter, m_filters) {
|
||||
if (filter->isHidden())
|
||||
continue;
|
||||
|
||||
@@ -168,7 +168,7 @@ void SettingsPage::updateFilterList()
|
||||
void SettingsPage::updateButtonStates()
|
||||
{
|
||||
QListWidgetItem *item = m_ui.filterList->currentItem();
|
||||
IQuickOpenFilter *filter = (item ? item->data(Qt::UserRole).value<IQuickOpenFilter *>() : 0);
|
||||
ILocatorFilter *filter = (item ? item->data(Qt::UserRole).value<ILocatorFilter *>() : 0);
|
||||
m_ui.editButton->setEnabled(filter && filter->isConfigurable());
|
||||
m_ui.removeButton->setEnabled(filter && m_customFilters.contains(filter));
|
||||
}
|
||||
@@ -178,7 +178,7 @@ void SettingsPage::configureFilter(QListWidgetItem *item)
|
||||
if (!item)
|
||||
item = m_ui.filterList->currentItem();
|
||||
QTC_ASSERT(item, return);
|
||||
IQuickOpenFilter *filter = item->data(Qt::UserRole).value<IQuickOpenFilter *>();
|
||||
ILocatorFilter *filter = item->data(Qt::UserRole).value<ILocatorFilter *>();
|
||||
QTC_ASSERT(filter, return);
|
||||
|
||||
if (!filter->isConfigurable())
|
||||
@@ -192,7 +192,7 @@ void SettingsPage::configureFilter(QListWidgetItem *item)
|
||||
|
||||
void SettingsPage::addCustomFilter()
|
||||
{
|
||||
IQuickOpenFilter *filter = new DirectoryFilter;
|
||||
ILocatorFilter *filter = new DirectoryFilter;
|
||||
bool needsRefresh = false;
|
||||
if (filter->openConfigDialog(m_page, needsRefresh)) {
|
||||
m_filters.append(filter);
|
||||
@@ -207,7 +207,7 @@ void SettingsPage::removeCustomFilter()
|
||||
{
|
||||
QListWidgetItem *item = m_ui.filterList->currentItem();
|
||||
QTC_ASSERT(item, return);
|
||||
IQuickOpenFilter *filter = item->data(Qt::UserRole).value<IQuickOpenFilter *>();
|
||||
ILocatorFilter *filter = item->data(Qt::UserRole).value<ILocatorFilter *>();
|
||||
QTC_ASSERT(m_customFilters.contains(filter), return);
|
||||
m_filters.removeAll(filter);
|
||||
m_customFilters.removeAll(filter);
|
||||
|
||||
@@ -43,7 +43,7 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace QuickOpen {
|
||||
|
||||
class IQuickOpenFilter;
|
||||
class ILocatorFilter;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
@@ -79,12 +79,12 @@ private:
|
||||
Ui::SettingsWidget m_ui;
|
||||
QuickOpenPlugin *m_plugin;
|
||||
QWidget* m_page;
|
||||
QList<IQuickOpenFilter *> m_filters;
|
||||
QList<IQuickOpenFilter *> m_addedFilters;
|
||||
QList<IQuickOpenFilter *> m_removedFilters;
|
||||
QList<IQuickOpenFilter *> m_customFilters;
|
||||
QList<IQuickOpenFilter *> m_refreshFilters;
|
||||
QHash<IQuickOpenFilter *, QByteArray> m_filterStates;
|
||||
QList<ILocatorFilter *> m_filters;
|
||||
QList<ILocatorFilter *> m_addedFilters;
|
||||
QList<ILocatorFilter *> m_removedFilters;
|
||||
QList<ILocatorFilter *> m_customFilters;
|
||||
QList<ILocatorFilter *> m_refreshFilters;
|
||||
QHash<ILocatorFilter *, QByteArray> m_filterStates;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -40,7 +40,7 @@ using namespace TextEditor;
|
||||
using namespace TextEditor::Internal;
|
||||
|
||||
LineNumberFilter::LineNumberFilter(QObject *parent)
|
||||
: IQuickOpenFilter(parent)
|
||||
: ILocatorFilter(parent)
|
||||
{
|
||||
setShortcutString("l");
|
||||
setIncludedByDefault(true);
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#ifndef LINENUMBERFILTER_H
|
||||
#define LINENUMBERFILTER_H
|
||||
|
||||
#include <quickopen/iquickopenfilter.h>
|
||||
#include <quickopen/ilocatorfilter.h>
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QList>
|
||||
@@ -42,7 +42,7 @@ class ITextEditor;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class LineNumberFilter : public QuickOpen::IQuickOpenFilter
|
||||
class LineNumberFilter : public QuickOpen::ILocatorFilter
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
|
||||
QString trName() const { return tr("Line in current document"); }
|
||||
QString name() const { return "Line in current document"; }
|
||||
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::High; }
|
||||
QuickOpen::ILocatorFilter::Priority priority() const { return QuickOpen::ILocatorFilter::High; }
|
||||
QList<QuickOpen::FilterEntry> matchesFor(const QString &entry);
|
||||
void accept(QuickOpen::FilterEntry selection) const;
|
||||
void refresh(QFutureInterface<void> &) {}
|
||||
|
||||
Reference in New Issue
Block a user