Commit a42c3c49 authored by con's avatar con

IQuickOpenFilter->ILocatorFilter and QuickOpenToolWindow->LocatorWidget

parent b7a0dbfa
...@@ -162,7 +162,7 @@ ...@@ -162,7 +162,7 @@
\row \row
\o Add a new filter to Locator. \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 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 \row
\o \o
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#define CPPCURRENTDOCUMENTFILTER_H #define CPPCURRENTDOCUMENTFILTER_H
#include "searchsymbols.h" #include "searchsymbols.h"
#include <quickopen/iquickopenfilter.h> #include <quickopen/ilocatorfilter.h>
namespace Core { namespace Core {
class EditorManager; class EditorManager;
...@@ -42,7 +42,7 @@ namespace Internal { ...@@ -42,7 +42,7 @@ namespace Internal {
class CppModelManager; class CppModelManager;
class CppCurrentDocumentFilter : public QuickOpen::IQuickOpenFilter class CppCurrentDocumentFilter : public QuickOpen::ILocatorFilter
{ {
Q_OBJECT Q_OBJECT
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "searchsymbols.h" #include "searchsymbols.h"
#include <quickopen/iquickopenfilter.h> #include <quickopen/ilocatorfilter.h>
namespace Core { namespace Core {
class EditorManager; class EditorManager;
...@@ -43,7 +43,7 @@ namespace Internal { ...@@ -43,7 +43,7 @@ namespace Internal {
class CppModelManager; class CppModelManager;
class CppQuickOpenFilter : public QuickOpen::IQuickOpenFilter class CppQuickOpenFilter : public QuickOpen::ILocatorFilter
{ {
Q_OBJECT Q_OBJECT
public: public:
......
...@@ -41,7 +41,7 @@ using namespace QuickOpen; ...@@ -41,7 +41,7 @@ using namespace QuickOpen;
using namespace Help; using namespace Help;
using namespace Help::Internal; using namespace Help::Internal;
Q_DECLARE_METATYPE(IQuickOpenFilter*); Q_DECLARE_METATYPE(ILocatorFilter*);
HelpIndexFilter::HelpIndexFilter(HelpPlugin *plugin, QHelpEngine *helpEngine): HelpIndexFilter::HelpIndexFilter(HelpPlugin *plugin, QHelpEngine *helpEngine):
m_plugin(plugin), m_plugin(plugin),
...@@ -77,7 +77,7 @@ QString HelpIndexFilter::name() const ...@@ -77,7 +77,7 @@ QString HelpIndexFilter::name() const
return QLatin1String("HelpIndexFilter"); return QLatin1String("HelpIndexFilter");
} }
IQuickOpenFilter::Priority HelpIndexFilter::priority() const ILocatorFilter::Priority HelpIndexFilter::priority() const
{ {
return Medium; return Medium;
} }
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#ifndef HELPINDEXFILTER_H #ifndef HELPINDEXFILTER_H
#define HELPINDEXFILTER_H #define HELPINDEXFILTER_H
#include <quickopen/iquickopenfilter.h> #include <quickopen/ilocatorfilter.h>
#include <QtGui/QIcon> #include <QtGui/QIcon>
...@@ -44,14 +44,14 @@ namespace Internal { ...@@ -44,14 +44,14 @@ namespace Internal {
class HelpPlugin; class HelpPlugin;
class HelpIndexFilter : public QuickOpen::IQuickOpenFilter class HelpIndexFilter : public QuickOpen::ILocatorFilter
{ {
Q_OBJECT Q_OBJECT
public: public:
HelpIndexFilter(HelpPlugin *plugin, QHelpEngine *helpEngine); HelpIndexFilter(HelpPlugin *plugin, QHelpEngine *helpEngine);
// IQuickOpenFilter // ILocatorFilter
QString trName() const; QString trName() const;
QString name() const; QString name() const;
Priority priority() const; Priority priority() const;
......
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,7 @@ public:
explicit AllProjectsFilter(ProjectExplorerPlugin *pe); explicit AllProjectsFilter(ProjectExplorerPlugin *pe);
QString trName() const { return tr("Files in any project"); } QString trName() const { return tr("Files in any project"); }
QString name() const { return "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); void refresh(QFutureInterface<void> &future);
protected: protected:
......
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
CurrentProjectFilter(ProjectExplorerPlugin *pe); CurrentProjectFilter(ProjectExplorerPlugin *pe);
QString trName() const { return tr("Files in current project"); } QString trName() const { return tr("Files in current project"); }
QString name() const { return "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); void refresh(QFutureInterface<void> &future);
protected: protected:
......
...@@ -31,14 +31,14 @@ ...@@ -31,14 +31,14 @@
#define BASEFILEFILTER_H #define BASEFILEFILTER_H
#include "quickopen_global.h" #include "quickopen_global.h"
#include "iquickopenfilter.h" #include "ilocatorfilter.h"
#include <QtCore/QString> #include <QtCore/QString>
#include <QtCore/QList> #include <QtCore/QList>
namespace QuickOpen { namespace QuickOpen {
class QUICKOPEN_EXPORT BaseFileFilter : public QuickOpen::IQuickOpenFilter class QUICKOPEN_EXPORT BaseFileFilter : public QuickOpen::ILocatorFilter
{ {
Q_OBJECT Q_OBJECT
......
...@@ -52,7 +52,7 @@ public: ...@@ -52,7 +52,7 @@ public:
DirectoryFilter(); DirectoryFilter();
QString trName() const { return m_name; } QString trName() const { return m_name; }
QString name() 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; QByteArray saveState() const;
bool restoreState(const QByteArray &state); bool restoreState(const QByteArray &state);
bool openConfigDialog(QWidget *parent, bool &needsRefresh); bool openConfigDialog(QWidget *parent, bool &needsRefresh);
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
**************************************************************************/ **************************************************************************/
#include "filesystemfilter.h" #include "filesystemfilter.h"
#include "quickopentoolwindow.h" #include "locatorwidget.h"
#include <coreplugin/editormanager/ieditor.h> #include <coreplugin/editormanager/ieditor.h>
#include <QtCore/QDir> #include <QtCore/QDir>
...@@ -37,8 +37,8 @@ using namespace Core; ...@@ -37,8 +37,8 @@ using namespace Core;
using namespace QuickOpen; using namespace QuickOpen;
using namespace QuickOpen::Internal; using namespace QuickOpen::Internal;
FileSystemFilter::FileSystemFilter(EditorManager *editorManager, QuickOpenToolWindow *toolWindow) FileSystemFilter::FileSystemFilter(EditorManager *editorManager, LocatorWidget *locatorWidget)
: m_editorManager(editorManager), m_toolWindow(toolWindow), m_includeHidden(true) : m_editorManager(editorManager), m_locatorWidget(locatorWidget), m_includeHidden(true)
{ {
setShortcutString("f"); setShortcutString("f");
setIncludedByDefault(false); setIncludedByDefault(false);
...@@ -96,7 +96,7 @@ void FileSystemFilter::accept(FilterEntry selection) const ...@@ -96,7 +96,7 @@ void FileSystemFilter::accept(FilterEntry selection) const
QFileInfo info(selection.internalData.toString()); QFileInfo info(selection.internalData.toString());
if (info.isDir()) { if (info.isDir()) {
QString value = shortcutString() + " " + QDir::toNativeSeparators(info.absoluteFilePath()+"/"); QString value = shortcutString() + " " + QDir::toNativeSeparators(info.absoluteFilePath()+"/");
m_toolWindow->show(value, value.length()); m_locatorWidget->show(value, value.length());
return; return;
} }
m_editorManager->openEditor(selection.internalData.toString()); m_editorManager->openEditor(selection.internalData.toString());
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#ifndef FILESYSTEMFILTER_H #ifndef FILESYSTEMFILTER_H
#define FILESYSTEMFILTER_H #define FILESYSTEMFILTER_H
#include "iquickopenfilter.h" #include "ilocatorfilter.h"
#include "ui_filesystemfilter.h" #include "ui_filesystemfilter.h"
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
...@@ -43,17 +43,17 @@ ...@@ -43,17 +43,17 @@
namespace QuickOpen { namespace QuickOpen {
namespace Internal { namespace Internal {
class QuickOpenToolWindow; class LocatorWidget;
class FileSystemFilter : public QuickOpen::IQuickOpenFilter class FileSystemFilter : public QuickOpen::ILocatorFilter
{ {
Q_OBJECT Q_OBJECT
public: public:
FileSystemFilter(Core::EditorManager *editorManager, QuickOpenToolWindow *toolWindow); FileSystemFilter(Core::EditorManager *editorManager, LocatorWidget *locatorWidget);
QString trName() const { return tr("Files in file system"); } QString trName() const { return tr("Files in file system"); }
QString name() const { return "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); QList<QuickOpen::FilterEntry> matchesFor(const QString &entry);
void accept(QuickOpen::FilterEntry selection) const; void accept(QuickOpen::FilterEntry selection) const;
QByteArray saveState() const; QByteArray saveState() const;
...@@ -63,7 +63,7 @@ public: ...@@ -63,7 +63,7 @@ public:
private: private:
Core::EditorManager *m_editorManager; Core::EditorManager *m_editorManager;
QuickOpenToolWindow *m_toolWindow; LocatorWidget *m_locatorWidget;
bool m_includeHidden; bool m_includeHidden;
}; };
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
** **
**************************************************************************/ **************************************************************************/
#include "iquickopenfilter.h" #include "ilocatorfilter.h"
#include <QtGui/QBoxLayout> #include <QtGui/QBoxLayout>
#include <QtGui/QCheckBox> #include <QtGui/QCheckBox>
...@@ -38,24 +38,24 @@ ...@@ -38,24 +38,24 @@
using namespace QuickOpen; using namespace QuickOpen;
IQuickOpenFilter::IQuickOpenFilter(QObject *parent): ILocatorFilter::ILocatorFilter(QObject *parent):
QObject(parent), QObject(parent),
m_includedByDefault(false), m_includedByDefault(false),
m_hidden(false) m_hidden(false)
{ {
} }
QString IQuickOpenFilter::shortcutString() const QString ILocatorFilter::shortcutString() const
{ {
return m_shortcut; return m_shortcut;
} }
void IQuickOpenFilter::setShortcutString(const QString &shortcut) void ILocatorFilter::setShortcutString(const QString &shortcut)
{ {
m_shortcut = shortcut; m_shortcut = shortcut;
} }
QByteArray IQuickOpenFilter::saveState() const QByteArray ILocatorFilter::saveState() const
{ {
QByteArray value; QByteArray value;
QDataStream out(&value, QIODevice::WriteOnly); QDataStream out(&value, QIODevice::WriteOnly);
...@@ -64,7 +64,7 @@ QByteArray IQuickOpenFilter::saveState() const ...@@ -64,7 +64,7 @@ QByteArray IQuickOpenFilter::saveState() const
return value; return value;
} }
bool IQuickOpenFilter::restoreState(const QByteArray &state) bool ILocatorFilter::restoreState(const QByteArray &state)
{ {
QString shortcut; QString shortcut;
bool defaultFilter; bool defaultFilter;
...@@ -78,7 +78,7 @@ bool IQuickOpenFilter::restoreState(const QByteArray &state) ...@@ -78,7 +78,7 @@ bool IQuickOpenFilter::restoreState(const QByteArray &state)
return true; return true;
} }
bool IQuickOpenFilter::openConfigDialog(QWidget *parent, bool &needsRefresh) bool ILocatorFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
{ {
Q_UNUSED(needsRefresh) Q_UNUSED(needsRefresh)
...@@ -113,27 +113,27 @@ bool IQuickOpenFilter::openConfigDialog(QWidget *parent, bool &needsRefresh) ...@@ -113,27 +113,27 @@ bool IQuickOpenFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
return false; return false;
} }
bool IQuickOpenFilter::isConfigurable() const bool ILocatorFilter::isConfigurable() const
{ {
return true; return true;
} }
bool IQuickOpenFilter::isIncludedByDefault() const bool ILocatorFilter::isIncludedByDefault() const
{ {
return m_includedByDefault; return m_includedByDefault;
} }
void IQuickOpenFilter::setIncludedByDefault(bool includedByDefault) void ILocatorFilter::setIncludedByDefault(bool includedByDefault)
{ {
m_includedByDefault = includedByDefault; m_includedByDefault = includedByDefault;
} }
bool IQuickOpenFilter::isHidden() const bool ILocatorFilter::isHidden() const
{ {
return m_hidden; return m_hidden;
} }
void IQuickOpenFilter::setHidden(bool hidden) void ILocatorFilter::setHidden(bool hidden)
{ {
m_hidden = hidden; m_hidden = hidden;
} }
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
** **
**************************************************************************/ **************************************************************************/
#ifndef IQUICKOPENFILTER_H #ifndef ILOCATORFILTER_H
#define IQUICKOPENFILTER_H #define ILOCATORFILTER_H
#include "quickopen_global.h" #include "quickopen_global.h"
...@@ -39,12 +39,12 @@ ...@@ -39,12 +39,12 @@
namespace QuickOpen { namespace QuickOpen {
class IQuickOpenFilter; class ILocatorFilter;
struct FilterEntry struct FilterEntry
{ {
FilterEntry() {} FilterEntry() {}
FilterEntry(IQuickOpenFilter *fromFilter, const QString &name, const QVariant &data, FilterEntry(ILocatorFilter *fromFilter, const QString &name, const QVariant &data,
const QIcon &icon = QIcon()) const QIcon &icon = QIcon())
: filter(fromFilter) : filter(fromFilter)
, displayName(name) , displayName(name)
...@@ -60,7 +60,7 @@ struct FilterEntry ...@@ -60,7 +60,7 @@ struct FilterEntry
} }
/* backpointer to creating filter */ /* backpointer to creating filter */
IQuickOpenFilter *filter; ILocatorFilter *filter;
/* displayed string */ /* displayed string */
QString displayName; QString displayName;
/* extra information displayed in light-gray in a second column (optional) */ /* extra information displayed in light-gray in a second column (optional) */
...@@ -73,15 +73,15 @@ struct FilterEntry ...@@ -73,15 +73,15 @@ struct FilterEntry
bool resolveFileIcon; bool resolveFileIcon;
}; };
class QUICKOPEN_EXPORT IQuickOpenFilter : public QObject class QUICKOPEN_EXPORT ILocatorFilter : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
enum Priority {High = 0, Medium = 1, Low = 2}; enum Priority {High = 0, Medium = 1, Low = 2};
IQuickOpenFilter(QObject *parent = 0); ILocatorFilter(QObject *parent = 0);
virtual ~IQuickOpenFilter() {} virtual ~ILocatorFilter() {}
/* Visible name. */ /* Visible name. */
virtual QString trName() const = 0; virtual QString trName() const = 0;
...@@ -153,4 +153,4 @@ private: ...@@ -153,4 +153,4 @@ private:
} // namespace QuickOpen } // namespace QuickOpen
#endif // IQUICKOPENFILTER_H #endif // ILOCATORFILTER_H
<
...@@ -37,7 +37,7 @@ QT_BEGIN_NAMESPACE ...@@ -37,7 +37,7 @@ QT_BEGIN_NAMESPACE
unsigned int qHash(const QuickOpen::FilterEntry &entry); unsigned int qHash(const QuickOpen::FilterEntry &entry);
QT_END_NAMESPACE QT_END_NAMESPACE
#include "quickopentoolwindow.h" #include "locatorwidget.h"
#include "quickopenplugin.h" #include "quickopenplugin.h"
#include "quickopenconstants.h" #include "quickopenconstants.h"
...@@ -67,7 +67,7 @@ QT_END_NAMESPACE ...@@ -67,7 +67,7 @@ QT_END_NAMESPACE
#include <QtGui/QScrollBar> #include <QtGui/QScrollBar>
#include <QtGui/QTreeView> #include <QtGui/QTreeView>
Q_DECLARE_METATYPE(QuickOpen::IQuickOpenFilter*); Q_DECLARE_METATYPE(QuickOpen::ILocatorFilter*);
Q_DECLARE_METATYPE(QuickOpen::FilterEntry); Q_DECLARE_METATYPE(QuickOpen::FilterEntry);
namespace QuickOpen { namespace QuickOpen {
...@@ -244,9 +244,9 @@ void CompletionList::updatePreferredSize() ...@@ -244,9 +244,9 @@ void CompletionList::updatePreferredSize()
} }
// =========== QuickOpenToolWindow =========== // =========== LocatorWidget ===========
QuickOpenToolWindow::QuickOpenToolWindow(QuickOpenPlugin *qop) : LocatorWidget::LocatorWidget(QuickOpenPlugin *qop) :
m_quickOpenPlugin(qop), m_quickOpenPlugin(qop),
m_quickOpenModel(new QuickOpenModel(this)), m_quickOpenModel(new QuickOpenModel(this)),
m_completionList(new CompletionList(this)), m_completionList(new CompletionList(this)),
...@@ -301,15 +301,15 @@ QuickOpenToolWindow::QuickOpenToolWindow(QuickOpenPlugin *qop) : ...@@ -301,15 +301,15 @@ QuickOpenToolWindow::QuickOpenToolWindow(QuickOpenPlugin *qop) :
this, SLOT(acceptCurrentEntry())); this, SLOT(acceptCurrentEntry()));
} }
bool QuickOpenToolWindow::isShowingTypeHereMessage() const bool LocatorWidget::isShowingTypeHereMessage() const
{ {
return m_fileLineEdit->isShowingHintText(); return m_fileLineEdit->isShowingHintText();
} }
void QuickOpenToolWindow::updateFilterList() void LocatorWidget::updateFilterList()
{ {
m_filterMenu->clear(); m_filterMenu->clear();
foreach (IQuickOpenFilter *filter, m_quickOpenPlugin->filters()) { foreach (ILocatorFilter *filter, m_quickOpenPlugin->filters()) {
if (!filter->shortcutString().isEmpty() && !filter->isHidden()) { if (!filter->shortcutString().isEmpty() && !filter->isHidden()) {
QAction *action = m_filterMenu->addAction(filter->trName(), this, SLOT(filterSelected())); QAction *action = m_filterMenu->addAction(filter->trName(), this, SLOT(filterSelected()));
action->setData(qVariantFromValue(filter)); action->setData(qVariantFromValue(filter));
...@@ -320,7 +320,7 @@ void QuickOpenToolWindow::updateFilterList() ...@@ -320,7 +320,7 @@ void QuickOpenToolWindow::updateFilterList()
m_filterMenu->addAction(m_configureAction); 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) { if (obj == m_fileLineEdit && event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
...@@ -357,7 +357,7 @@ bool QuickOpenToolWindow::eventFilter(QObject *obj, QEvent *event) ...@@ -357,7 +357,7 @@ bool QuickOpenToolWindow::eventFilter(QObject *obj, QEvent *event)
return QWidget::eventFilter(obj, event); return QWidget::eventFilter(obj, event);
} }
void QuickOpenToolWindow::showCompletionList() void LocatorWidget::showCompletionList()
{ {
const int border = m_completionList->frameWidth(); const int border = m_completionList->frameWidth();
const QSize size = m_completionList->preferredSize(); const QSize size = m_completionList->preferredSize();
...@@ -366,44 +366,44 @@ void QuickOpenToolWindow::showCompletionList() ...@@ -366,44 +366,44 @@ void QuickOpenToolWindow::showCompletionList()
m_completionList->show(); m_completionList->show();
} }
void QuickOpenToolWindow::showPopup() void LocatorWidget::showPopup()
{ {
updateCompletionList(m_fileLineEdit->typedText()); updateCompletionList(m_fileLineEdit->typedText());
showCompletionList(); 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(" "); int whiteSpace = text.indexOf(" ");
QString prefix; QString prefix;
if (whiteSpace >= 0) if (whiteSpace >= 0)
prefix = text.left(whiteSpace); prefix = text.left(whiteSpace);
if (!prefix.isEmpty()) { if (!prefix.isEmpty()) {
prefix = prefix.toLower(); prefix = prefix.toLower();
foreach (IQuickOpenFilter *filter, filters) { foreach (ILocatorFilter *filter, filters) {
if (prefix == filter->shortcutString()) { if (prefix == filter->shortcutString()) {
searchText = text.mid(whiteSpace+1); searchText = text.mid(whiteSpace+1);
return QList<IQuickOpenFilter*>() << filter; return QList<ILocatorFilter*>() << filter;
} }
} }