From a5bfacecb7aa926e6685708eb15d4817c14b6901 Mon Sep 17 00:00:00 2001 From: con Date: Fri, 16 Oct 2009 11:44:18 +0200 Subject: Rename directory quickopen --> locator --- doc/api/qtcreator-api.qdocconf | 10 +- src/plugins/cpptools/cppcurrentdocumentfilter.h | 2 +- src/plugins/cpptools/cpplocatorfilter.h | 2 +- src/plugins/cpptools/cpptools.pro | 2 +- src/plugins/help/help_dependencies.pri | 2 +- src/plugins/help/helpindexfilter.h | 2 +- src/plugins/locator/QuickOpen.pluginspec | 24 + src/plugins/locator/basefilefilter.cpp | 112 +++++ src/plugins/locator/basefilefilter.h | 64 +++ src/plugins/locator/directoryfilter.cpp | 255 +++++++++++ src/plugins/locator/directoryfilter.h | 81 ++++ src/plugins/locator/directoryfilter.ui | 194 ++++++++ src/plugins/locator/directoryparser.cpp | 101 +++++ src/plugins/locator/directoryparser.h | 74 ++++ src/plugins/locator/filesystemfilter.cpp | 152 +++++++ src/plugins/locator/filesystemfilter.h | 73 +++ src/plugins/locator/filesystemfilter.ui | 111 +++++ src/plugins/locator/ilocatorfilter.cpp | 139 ++++++ src/plugins/locator/ilocatorfilter.h | 156 +++++++ src/plugins/locator/images/locator.png | Bin 0 -> 767 bytes src/plugins/locator/images/reload.png | Bin 0 -> 735 bytes src/plugins/locator/locator.pro | 33 ++ src/plugins/locator/locator.qrc | 6 + src/plugins/locator/locator_global.h | 41 ++ src/plugins/locator/locatorconstants.h | 45 ++ src/plugins/locator/locatorfiltersfilter.cpp | 101 +++++ src/plugins/locator/locatorfiltersfilter.h | 73 +++ src/plugins/locator/locatormanager.cpp | 59 +++ src/plugins/locator/locatormanager.h | 62 +++ src/plugins/locator/locatorplugin.cpp | 253 +++++++++++ src/plugins/locator/locatorplugin.h | 126 ++++++ src/plugins/locator/locatorwidget.cpp | 489 +++++++++++++++++++++ src/plugins/locator/locatorwidget.h | 97 ++++ src/plugins/locator/opendocumentsfilter.cpp | 98 +++++ src/plugins/locator/opendocumentsfilter.h | 72 +++ src/plugins/locator/quickopen.cp | 0 src/plugins/locator/quickopen.pri | 3 + src/plugins/locator/quickopen_dependencies.pri | 2 + src/plugins/locator/settingspage.cpp | 222 ++++++++++ src/plugins/locator/settingspage.h | 93 ++++ src/plugins/locator/settingspage.ui | 127 ++++++ src/plugins/locator/settingswidget.ui | 133 ++++++ src/plugins/plugins.pro | 12 +- src/plugins/projectexplorer/allprojectsfilter.h | 2 +- src/plugins/projectexplorer/currentprojectfilter.h | 2 +- .../projectexplorer_dependencies.pri | 2 +- src/plugins/quickopen/QuickOpen.pluginspec | 24 - src/plugins/quickopen/basefilefilter.cpp | 112 ----- src/plugins/quickopen/basefilefilter.h | 64 --- src/plugins/quickopen/directoryfilter.cpp | 255 ----------- src/plugins/quickopen/directoryfilter.h | 81 ---- src/plugins/quickopen/directoryfilter.ui | 194 -------- src/plugins/quickopen/directoryparser.cpp | 101 ----- src/plugins/quickopen/directoryparser.h | 74 ---- src/plugins/quickopen/filesystemfilter.cpp | 152 ------- src/plugins/quickopen/filesystemfilter.h | 73 --- src/plugins/quickopen/filesystemfilter.ui | 111 ----- src/plugins/quickopen/ilocatorfilter.cpp | 139 ------ src/plugins/quickopen/ilocatorfilter.h | 156 ------- src/plugins/quickopen/images/locator.png | Bin 767 -> 0 bytes src/plugins/quickopen/images/reload.png | Bin 735 -> 0 bytes src/plugins/quickopen/locator.qrc | 6 - src/plugins/quickopen/locator_global.h | 41 -- src/plugins/quickopen/locatorconstants.h | 45 -- src/plugins/quickopen/locatorfiltersfilter.cpp | 101 ----- src/plugins/quickopen/locatorfiltersfilter.h | 73 --- src/plugins/quickopen/locatormanager.cpp | 59 --- src/plugins/quickopen/locatormanager.h | 62 --- src/plugins/quickopen/locatorplugin.cpp | 253 ----------- src/plugins/quickopen/locatorplugin.h | 126 ------ src/plugins/quickopen/locatorwidget.cpp | 489 --------------------- src/plugins/quickopen/locatorwidget.h | 97 ---- src/plugins/quickopen/opendocumentsfilter.cpp | 98 ----- src/plugins/quickopen/opendocumentsfilter.h | 72 --- src/plugins/quickopen/quickopen.cp | 0 src/plugins/quickopen/quickopen.pri | 3 - src/plugins/quickopen/quickopen.pro | 33 -- src/plugins/quickopen/quickopen_dependencies.pri | 2 - src/plugins/quickopen/settingspage.cpp | 222 ---------- src/plugins/quickopen/settingspage.h | 93 ---- src/plugins/quickopen/settingspage.ui | 127 ------ src/plugins/quickopen/settingswidget.ui | 133 ------ src/plugins/texteditor/linenumberfilter.h | 2 +- src/plugins/texteditor/texteditor_dependencies.pri | 2 +- src/plugins/texteditor/texteditoractionhandler.cpp | 2 +- 85 files changed, 3693 insertions(+), 3693 deletions(-) create mode 100644 src/plugins/locator/QuickOpen.pluginspec create mode 100644 src/plugins/locator/basefilefilter.cpp create mode 100644 src/plugins/locator/basefilefilter.h create mode 100644 src/plugins/locator/directoryfilter.cpp create mode 100644 src/plugins/locator/directoryfilter.h create mode 100644 src/plugins/locator/directoryfilter.ui create mode 100644 src/plugins/locator/directoryparser.cpp create mode 100644 src/plugins/locator/directoryparser.h create mode 100644 src/plugins/locator/filesystemfilter.cpp create mode 100644 src/plugins/locator/filesystemfilter.h create mode 100644 src/plugins/locator/filesystemfilter.ui create mode 100644 src/plugins/locator/ilocatorfilter.cpp create mode 100644 src/plugins/locator/ilocatorfilter.h create mode 100644 src/plugins/locator/images/locator.png create mode 100644 src/plugins/locator/images/reload.png create mode 100644 src/plugins/locator/locator.pro create mode 100644 src/plugins/locator/locator.qrc create mode 100644 src/plugins/locator/locator_global.h create mode 100644 src/plugins/locator/locatorconstants.h create mode 100644 src/plugins/locator/locatorfiltersfilter.cpp create mode 100644 src/plugins/locator/locatorfiltersfilter.h create mode 100644 src/plugins/locator/locatormanager.cpp create mode 100644 src/plugins/locator/locatormanager.h create mode 100644 src/plugins/locator/locatorplugin.cpp create mode 100644 src/plugins/locator/locatorplugin.h create mode 100644 src/plugins/locator/locatorwidget.cpp create mode 100644 src/plugins/locator/locatorwidget.h create mode 100644 src/plugins/locator/opendocumentsfilter.cpp create mode 100644 src/plugins/locator/opendocumentsfilter.h create mode 100644 src/plugins/locator/quickopen.cp create mode 100644 src/plugins/locator/quickopen.pri create mode 100644 src/plugins/locator/quickopen_dependencies.pri create mode 100644 src/plugins/locator/settingspage.cpp create mode 100644 src/plugins/locator/settingspage.h create mode 100644 src/plugins/locator/settingspage.ui create mode 100644 src/plugins/locator/settingswidget.ui delete mode 100644 src/plugins/quickopen/QuickOpen.pluginspec delete mode 100644 src/plugins/quickopen/basefilefilter.cpp delete mode 100644 src/plugins/quickopen/basefilefilter.h delete mode 100644 src/plugins/quickopen/directoryfilter.cpp delete mode 100644 src/plugins/quickopen/directoryfilter.h delete mode 100644 src/plugins/quickopen/directoryfilter.ui delete mode 100644 src/plugins/quickopen/directoryparser.cpp delete mode 100644 src/plugins/quickopen/directoryparser.h delete mode 100644 src/plugins/quickopen/filesystemfilter.cpp delete mode 100644 src/plugins/quickopen/filesystemfilter.h delete mode 100644 src/plugins/quickopen/filesystemfilter.ui delete mode 100644 src/plugins/quickopen/ilocatorfilter.cpp delete mode 100644 src/plugins/quickopen/ilocatorfilter.h delete mode 100644 src/plugins/quickopen/images/locator.png delete mode 100644 src/plugins/quickopen/images/reload.png delete mode 100644 src/plugins/quickopen/locator.qrc delete mode 100644 src/plugins/quickopen/locator_global.h delete mode 100644 src/plugins/quickopen/locatorconstants.h delete mode 100644 src/plugins/quickopen/locatorfiltersfilter.cpp delete mode 100644 src/plugins/quickopen/locatorfiltersfilter.h delete mode 100644 src/plugins/quickopen/locatormanager.cpp delete mode 100644 src/plugins/quickopen/locatormanager.h delete mode 100644 src/plugins/quickopen/locatorplugin.cpp delete mode 100644 src/plugins/quickopen/locatorplugin.h delete mode 100644 src/plugins/quickopen/locatorwidget.cpp delete mode 100644 src/plugins/quickopen/locatorwidget.h delete mode 100644 src/plugins/quickopen/opendocumentsfilter.cpp delete mode 100644 src/plugins/quickopen/opendocumentsfilter.h delete mode 100644 src/plugins/quickopen/quickopen.cp delete mode 100644 src/plugins/quickopen/quickopen.pri delete mode 100644 src/plugins/quickopen/quickopen.pro delete mode 100644 src/plugins/quickopen/quickopen_dependencies.pri delete mode 100644 src/plugins/quickopen/settingspage.cpp delete mode 100644 src/plugins/quickopen/settingspage.h delete mode 100644 src/plugins/quickopen/settingspage.ui delete mode 100644 src/plugins/quickopen/settingswidget.ui diff --git a/doc/api/qtcreator-api.qdocconf b/doc/api/qtcreator-api.qdocconf index bd0212e989..74ff036df9 100644 --- a/doc/api/qtcreator-api.qdocconf +++ b/doc/api/qtcreator-api.qdocconf @@ -9,7 +9,7 @@ headerdirs = . \ ../../src/libs/extensionsystem \ ../../src/plugins/coreplugin \ ../../src/plugins/find \ - ../../src/plugins/quickopen + ../../src/plugins/locator sourcedirs = . \ ../../src/libs/aggregation \ @@ -17,7 +17,7 @@ sourcedirs = . \ ../../src/libs/extensionsystem \ ../../src/plugins/coreplugin \ ../../src/plugins/find \ - ../../src/plugins/quickopen + ../../src/plugins/locator headers.fileextesnions = "*.h" sources.fileextensions = "*.cpp *.qdoc" @@ -62,7 +62,7 @@ macro.endquote = "\\endquotation" macro.relatesto = "\\relates" spurious = "Missing comma in .*" \ - "Missing pattern .*" + "Missing pattern .*" ## macros.qdocconf macro.aring.HTML = "å" @@ -224,7 +224,7 @@ defines = Q_QDOC \ Q_WS_.* \ Q_OS_.* \ Q_BYTE_ORDER \ - QT_DEPRECATED \ + QT_DEPRECATED \ Q_NO_USING_KEYWORD \ __cplusplus @@ -232,4 +232,4 @@ defines = Q_QDOC \ # See also qhp.Qt.extraFiles extraimages.HTML = qt-logo \ trolltech-logo - + diff --git a/src/plugins/cpptools/cppcurrentdocumentfilter.h b/src/plugins/cpptools/cppcurrentdocumentfilter.h index a72a75fea4..905f1da4fb 100644 --- a/src/plugins/cpptools/cppcurrentdocumentfilter.h +++ b/src/plugins/cpptools/cppcurrentdocumentfilter.h @@ -30,7 +30,7 @@ #define CPPCURRENTDOCUMENTFILTER_H #include "searchsymbols.h" -#include +#include namespace Core { class EditorManager; diff --git a/src/plugins/cpptools/cpplocatorfilter.h b/src/plugins/cpptools/cpplocatorfilter.h index 39dde0f8dc..c33fcf45ae 100644 --- a/src/plugins/cpptools/cpplocatorfilter.h +++ b/src/plugins/cpptools/cpplocatorfilter.h @@ -32,7 +32,7 @@ #include "searchsymbols.h" -#include +#include namespace Core { class EditorManager; diff --git a/src/plugins/cpptools/cpptools.pro b/src/plugins/cpptools/cpptools.pro index c39ec6f095..056757f2af 100644 --- a/src/plugins/cpptools/cpptools.pro +++ b/src/plugins/cpptools/cpptools.pro @@ -1,7 +1,7 @@ TEMPLATE = lib TARGET = CppTools include(../../qtcreatorplugin.pri) -include(../../plugins/quickopen/quickopen.pri) +include(../../plugins/locator/quickopen.pri) include(cpptools_dependencies.pri) # DEFINES += QT_NO_CAST_FROM_ASCII diff --git a/src/plugins/help/help_dependencies.pri b/src/plugins/help/help_dependencies.pri index 2b46febe3b..412f99efb6 100644 --- a/src/plugins/help/help_dependencies.pri +++ b/src/plugins/help/help_dependencies.pri @@ -1,4 +1,4 @@ include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/find/find.pri) -include(../../plugins/quickopen/quickopen.pri) +include(../../plugins/locator/quickopen.pri) diff --git a/src/plugins/help/helpindexfilter.h b/src/plugins/help/helpindexfilter.h index 038670792a..7094e9adf2 100644 --- a/src/plugins/help/helpindexfilter.h +++ b/src/plugins/help/helpindexfilter.h @@ -30,7 +30,7 @@ #ifndef HELPINDEXFILTER_H #define HELPINDEXFILTER_H -#include +#include #include diff --git a/src/plugins/locator/QuickOpen.pluginspec b/src/plugins/locator/QuickOpen.pluginspec new file mode 100644 index 0000000000..d9a45e89ba --- /dev/null +++ b/src/plugins/locator/QuickOpen.pluginspec @@ -0,0 +1,24 @@ + + Nokia Corporation + (C) 2008-2009 Nokia Corporation + +Commercial Usage + +Licensees holding valid Qt Commercial licenses may use this plugin in +accordance with the Qt Commercial License Agreement provided with the +Software or, alternatively, in accordance with the terms contained in +a written agreement between you and Nokia. + +GNU Lesser General Public License Usage + +Alternatively, this plugin may be used under the terms of the GNU Lesser +General Public License version 2.1 as published by the Free Software +Foundation. Please review the following information to +ensure the GNU Lesser General Public License version 2.1 requirements +will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + Provides the Locator widget and the hooks for QuickOpen filter implementations. + http://qt.nokia.com + + + + diff --git a/src/plugins/locator/basefilefilter.cpp b/src/plugins/locator/basefilefilter.cpp new file mode 100644 index 0000000000..ed5e02f76a --- /dev/null +++ b/src/plugins/locator/basefilefilter.cpp @@ -0,0 +1,112 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "basefilefilter.h" + +#include + +#include +#include + +using namespace Core; +using namespace Locator; + +BaseFileFilter::BaseFileFilter() + : m_forceNewSearchList(false) +{ +} + +QList BaseFileFilter::matchesFor(const QString &origEntry) +{ + updateFiles(); + QList matches; + QList badMatches; + QString needle = trimWildcards(origEntry); + QStringMatcher matcher(needle, Qt::CaseInsensitive); + const QRegExp regexp("*"+needle+"*", Qt::CaseInsensitive, QRegExp::Wildcard); + if (!regexp.isValid()) + return matches; + bool hasWildcard = (needle.contains('*') || needle.contains('?')); + QStringList searchListPaths; + QStringList searchListNames; + if (!m_previousEntry.isEmpty() && !m_forceNewSearchList && needle.contains(m_previousEntry)) { + searchListPaths = m_previousResultPaths; + searchListNames = m_previousResultNames; + } else { + searchListPaths = m_files; + searchListNames = m_fileNames; + } + m_previousResultPaths.clear(); + m_previousResultNames.clear(); + m_forceNewSearchList = false; + m_previousEntry = needle; + QStringListIterator paths(searchListPaths); + QStringListIterator names(searchListNames); + while (paths.hasNext() && names.hasNext()) { + QString path = paths.next(); + QString name = names.next(); + if ((hasWildcard && regexp.exactMatch(name)) + || (!hasWildcard && matcher.indexIn(name) != -1)) { + QFileInfo fi(path); + FilterEntry entry(this, fi.fileName(), path); + entry.extraInfo = QDir::toNativeSeparators(fi.path()); + entry.resolveFileIcon = true; + if (name.startsWith(needle)) + matches.append(entry); + else + badMatches.append(entry); + m_previousResultPaths.append(path); + m_previousResultNames.append(name); + } + } + + matches.append(badMatches); + return matches; +} + +void BaseFileFilter::accept(Locator::FilterEntry selection) const +{ + Core::EditorManager *em = Core::EditorManager::instance(); + em->openEditor(selection.internalData.toString()); + em->ensureEditorManagerVisible(); +} + +void BaseFileFilter::generateFileNames() +{ + m_fileNames.clear(); + foreach (const QString &fileName, m_files) { + QFileInfo fi(fileName); + m_fileNames.append(fi.fileName()); + } + m_forceNewSearchList = true; +} + +void BaseFileFilter::updateFiles() +{ +} diff --git a/src/plugins/locator/basefilefilter.h b/src/plugins/locator/basefilefilter.h new file mode 100644 index 0000000000..ee2e4248c9 --- /dev/null +++ b/src/plugins/locator/basefilefilter.h @@ -0,0 +1,64 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef BASEFILEFILTER_H +#define BASEFILEFILTER_H + +#include "locator_global.h" +#include "ilocatorfilter.h" + +#include +#include + +namespace Locator { + +class LOCATOR_EXPORT BaseFileFilter : public Locator::ILocatorFilter +{ + Q_OBJECT + +public: + BaseFileFilter(); + QList matchesFor(const QString &entry); + void accept(Locator::FilterEntry selection) const; + +protected: + virtual void updateFiles(); + void generateFileNames(); + + QStringList m_files; + QStringList m_fileNames; + QStringList m_previousResultPaths; + QStringList m_previousResultNames; + bool m_forceNewSearchList; + QString m_previousEntry; +}; + +} // namespace Locator + +#endif // BASEFILEFILTER_H diff --git a/src/plugins/locator/directoryfilter.cpp b/src/plugins/locator/directoryfilter.cpp new file mode 100644 index 0000000000..983b51c92e --- /dev/null +++ b/src/plugins/locator/directoryfilter.cpp @@ -0,0 +1,255 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "directoryfilter.h" + +#include +#include +#include +#include +#include + +#include + +using namespace Locator; +using namespace Locator::Internal; + +DirectoryFilter::DirectoryFilter() + : m_name(tr("Generic Directory Filter")), + m_filters(QStringList() << QLatin1String("*.h") << QLatin1String("*.cpp") + << QLatin1String("*.ui") << QLatin1String("*.qrc")) +{ + setIncludedByDefault(true); +} + +QByteArray DirectoryFilter::saveState() const +{ + QMutexLocker locker(&m_lock); + QByteArray value; + QDataStream out(&value, QIODevice::WriteOnly); + out << m_name; + out << m_directories; + out << m_filters; + out << shortcutString(); + out << isIncludedByDefault(); + out << m_files; + return value; +} + +bool DirectoryFilter::restoreState(const QByteArray &state) +{ + QMutexLocker locker(&m_lock); + + QStringList dirEntries; + QString shortcut; + bool defaultFilter; + + QDataStream in(state); + in >> m_name; + in >> dirEntries; + in >> m_filters; + in >> shortcut; + in >> defaultFilter; + in >> m_files; + + setShortcutString(shortcut); + setIncludedByDefault(defaultFilter); + + // ### TODO throw that out again: + // clear the list of directories of empty entries (which might at least happen at a format change) + m_directories.clear(); + foreach (const QString &dir, dirEntries) { + if (dir.isEmpty()) + continue; + m_directories.append(dir); + } + + generateFileNames(); + return true; +} + +bool DirectoryFilter::openConfigDialog(QWidget *parent, bool &needsRefresh) +{ + bool success = false; + QDialog dialog(parent); + m_dialog = &dialog; + m_ui.setupUi(&dialog); + dialog.setWindowTitle(tr("Filter Configuration")); + connect(m_ui.addButton, SIGNAL(clicked()), + this, SLOT(addDirectory()), Qt::DirectConnection); + connect(m_ui.editButton, SIGNAL(clicked()), + this, SLOT(editDirectory()), Qt::DirectConnection); + connect(m_ui.removeButton, SIGNAL(clicked()), + this, SLOT(removeDirectory()), Qt::DirectConnection); + connect(m_ui.directoryList, SIGNAL(itemSelectionChanged()), + this, SLOT(updateOptionButtons()), Qt::DirectConnection); + m_ui.nameEdit->setText(m_name); + m_ui.nameEdit->selectAll(); + m_ui.directoryList->clear(); + m_ui.directoryList->addItems(m_directories); + m_ui.fileTypeEdit->setText(m_filters.join(QString(QLatin1Char(',')))); + m_ui.shortcutEdit->setText(shortcutString()); + m_ui.defaultFlag->setChecked(!isIncludedByDefault()); + updateOptionButtons(); + if (dialog.exec() == QDialog::Accepted) { + QMutexLocker locker(&m_lock); + bool directoriesChanged = false; + QStringList oldDirectories = m_directories; + QStringList oldFilters = m_filters; + m_name = m_ui.nameEdit->text().trimmed(); + m_directories.clear(); + int oldCount = oldDirectories.count(); + int newCount = m_ui.directoryList->count(); + if (oldCount != newCount) + directoriesChanged = true; + for (int i = 0; i < newCount; ++i) { + m_directories.append(m_ui.directoryList->item(i)->text()); + if (!directoriesChanged && m_directories.at(i) != oldDirectories.at(i)) + directoriesChanged = true; + } + m_filters = m_ui.fileTypeEdit->text().trimmed().split(QLatin1Char(',')); + setShortcutString(m_ui.shortcutEdit->text().trimmed()); + setIncludedByDefault(!m_ui.defaultFlag->isChecked()); + if (directoriesChanged || oldFilters != m_filters) + needsRefresh = true; + success = true; + } + return success; +} + +void DirectoryFilter::addDirectory() +{ + QString dir = QFileDialog::getExistingDirectory(m_dialog, tr("Choose a directory to add")); + if (!dir.isEmpty()) { + m_ui.directoryList->addItem(dir); + } +} + +void DirectoryFilter::editDirectory() +{ + if (m_ui.directoryList->selectedItems().count() < 1) + return; + QListWidgetItem *currentItem = m_ui.directoryList->selectedItems().at(0); + QString dir = QFileDialog::getExistingDirectory(m_dialog, tr("Choose a directory to add"), + currentItem->text()); + if (!dir.isEmpty()) { + currentItem->setText(dir); + } +} + +void DirectoryFilter::removeDirectory() +{ + if (m_ui.directoryList->selectedItems().count() < 1) + return; + QListWidgetItem *currentItem = m_ui.directoryList->selectedItems().at(0); + delete m_ui.directoryList->takeItem(m_ui.directoryList->row(currentItem)); +} + +void DirectoryFilter::updateOptionButtons() +{ + bool haveSelectedItem = (m_ui.directoryList->selectedItems().count() > 0); + m_ui.editButton->setEnabled(haveSelectedItem); + m_ui.removeButton->setEnabled(haveSelectedItem); +} + +void DirectoryFilter::refresh(QFutureInterface &future) +{ + const int MAX = 360; + future.setProgressRange(0, MAX); + if (m_directories.count() < 1) { + QMutexLocker locker(&m_lock); + m_files.clear(); + generateFileNames(); + future.setProgressValueAndText(MAX, tr("%1 filter update: 0 files").arg(m_name)); + return; + } + int progress = 0; + int MAX_PER = MAX; + QStringList files; + QStack dirs; + QStack progressValues; + QStack processedValues; + { // initialize + QMutexLocker locker(&m_lock); + MAX_PER = MAX/m_directories.count(); + foreach (const QString &directoryEntry, m_directories) { + if (!directoryEntry.isEmpty()) { + dirs.push(QDir(directoryEntry)); + progressValues.push(MAX_PER); + processedValues.push(false); + } + } + } + while (!dirs.isEmpty() && !future.isCanceled()) { + if (future.isProgressUpdateNeeded()) { + future.setProgressValueAndText(progress, + tr("%1 filter update: %n files", 0, files.size()).arg(m_name)); + } + QDir dir = dirs.pop(); + int dirProgressMax = progressValues.pop(); + bool processed = processedValues.pop(); + if (dir.exists()) { + QStringList subDirs; + if (!processed) { + subDirs = dir.entryList(QDir::Dirs|QDir::Hidden|QDir::NoDotAndDotDot, + QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); + } + if (subDirs.isEmpty()) { + QStringList fileEntries = dir.entryList(m_filters, + QDir::Files|QDir::Hidden, + QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); + foreach (const QString &file, fileEntries) + files.append(dir.path()+"/"+file); + progress += dirProgressMax; + } else { + int subProgress = dirProgressMax/(subDirs.size()+1); + int selfProgress = subProgress + dirProgressMax%(subDirs.size()+1); + dirs.push(dir); + progressValues.push(selfProgress); + processedValues.push(true); + foreach (const QString &directory, subDirs) { + dirs.push(QDir(dir.path()+"/"+directory)); + progressValues.push(subProgress); + processedValues.push(false); + } + } + } else { + progress += dirProgressMax; + } + } + + if (!future.isCanceled()) { + QMutexLocker locker(&m_lock); + m_files = files; + generateFileNames(); + future.setProgressValue(MAX); + } else { + future.setProgressValueAndText(progress, tr("%1 filter update: canceled").arg(m_name)); + } +} diff --git a/src/plugins/locator/directoryfilter.h b/src/plugins/locator/directoryfilter.h new file mode 100644 index 0000000000..2140a18d1f --- /dev/null +++ b/src/plugins/locator/directoryfilter.h @@ -0,0 +1,81 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef DIRECTORYFILTER_H +#define DIRECTORYFILTER_H + +#include "ui_directoryfilter.h" +#include "basefilefilter.h" + +#include +#include +#include +#include +#include +#include +#include + +namespace Locator { +namespace Internal { + +class DirectoryFilter : public BaseFileFilter +{ + Q_OBJECT + +public: + DirectoryFilter(); + QString trName() const { return m_name; } + QString name() const { return m_name; } + Locator::ILocatorFilter::Priority priority() const { return Locator::ILocatorFilter::Medium; } + QByteArray saveState() const; + bool restoreState(const QByteArray &state); + bool openConfigDialog(QWidget *parent, bool &needsRefresh); + void refresh(QFutureInterface &future); + +private slots: + void addDirectory(); + void editDirectory(); + void removeDirectory(); + void updateOptionButtons(); + +private: + QString m_name; + QStringList m_directories; + QStringList m_filters; + // Our config dialog, uses in addDirectory and editDirectory + // to give their dialogs the right parent + QDialog *m_dialog; + Ui::DirectoryFilterOptions m_ui; + mutable QMutex m_lock; +}; + +} // namespace Internal +} // namespace Locator + +#endif // DIRECTORYFILTER_H diff --git a/src/plugins/locator/directoryfilter.ui b/src/plugins/locator/directoryfilter.ui new file mode 100644 index 0000000000..8b8ddfe59a --- /dev/null +++ b/src/plugins/locator/directoryfilter.ui @@ -0,0 +1,194 @@ + + + Locator::Internal::DirectoryFilterOptions + + + + 0 + 0 + 393 + 275 + + + + + + + + + Name: + + + + + + + + + + File Types: + + + + + + + Specify file name filters, separated by comma. Filters may contain wildcards. + + + + + + + Prefix: + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Specify a short word/abbreviation that can be used to restrict completions to files from this directory tree. +To do this, you type this shortcut and a space in the Locator entry field, and then the word to search for. + + + + + + + + 2 + 0 + + + + Limit to prefix + + + false + + + + + + + + + Add... + + + + + + + Edit... + + + + + + + Remove + + + + + + + + + + + Directories: + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + Qt::Vertical + + + + 369 + 31 + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + Locator::Internal::DirectoryFilterOptions + accept() + + + 353 + 174 + + + 390 + 152 + + + + + buttonBox + rejected() + Locator::Internal::DirectoryFilterOptions + reject() + + + 280 + 176 + + + 391 + 141 + + + + + diff --git a/src/plugins/locator/directoryparser.cpp b/src/plugins/locator/directoryparser.cpp new file mode 100644 index 0000000000..6bd8f431d5 --- /dev/null +++ b/src/plugins/locator/directoryparser.cpp @@ -0,0 +1,101 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "directoryparser.h" +#include "quickopenplugin.h" + +using namespace QuickOpen::Internal; + +DirectoryParser::DirectoryParser(QObject *parent) + : QThread(parent) +{ +} + +DirectoryParser::~DirectoryParser() +{ + if (isRunning()) + terminate(); +} + +void DirectoryParser::parse(Filter filter) +{ + m_dirs = filter.directories(); + m_filters = filter.acceptedFileExtensions().split(';'); + m_blackList.clear(); + foreach (QString s, filter.skipDirectories()) { + if (!s.trimmed().isEmpty() && !m_blackList.contains(s)) + m_blackList.insert(s); + } + if (!isRunning()) + start(QThread::NormalPriority); +} + +void DirectoryParser::setDirectoryNameBlackList(const QStringList &lst) +{ + m_blackList.clear(); + foreach (QString s, lst) { + if (!m_blackList.contains(s)) + m_blackList.insert(s); + } +} + +QSet DirectoryParser::files() const +{ + return m_files; +} + +void DirectoryParser::run() +{ + m_files.clear(); + m_runFiles.clear(); + foreach (QString s, m_dirs) { + if (s.isEmpty()) + continue; + QDir dir(s); + if (dir.exists()) { + m_runFilters = m_filters; + m_runBlackList = m_blackList; + collectFiles(dir); + } + } + m_files = m_runFiles; + emit directoriesParsed(); +} + +void DirectoryParser::collectFiles(const QDir &dir) +{ + QString dirName = dir.absolutePath() + QLatin1String("/"); + foreach (QString f, dir.entryList(m_runFilters, QDir::Files)) { + m_runFiles.insert(dirName + f); + } + foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { + if (!m_runBlackList.contains(d)) + collectFiles(dir.absolutePath() + QDir::separator() + d); + } +} diff --git a/src/plugins/locator/directoryparser.h b/src/plugins/locator/directoryparser.h new file mode 100644 index 0000000000..35618f33e3 --- /dev/null +++ b/src/plugins/locator/directoryparser.h @@ -0,0 +1,74 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef DIRECTORYPARSER_H +#define DIRECTORYPARSER_H + +#include +#include +#include + +namespace QuickOpen { +namespace Internal { + +class Filter; + +class DirectoryParser : public QThread +{ + Q_OBJECT + +public: + DirectoryParser(QObject *parent); + ~DirectoryParser(); + void parse(Filter filter); + + void setDirectoryNameBlackList(const QStringList &lst); + QSet files() const; + +signals: + void directoriesParsed(); + +private: + void run(); + void collectFiles(const QDir &dir); + + QStringList m_dirs; + QSet m_files; + + QSet m_runFiles; + QStringList m_filters; + QStringList m_runFilters; + QSet m_blackList; + QSet m_runBlackList; +}; + +} // namespace Internal +} // namespace QuickOpen + +#endif // DIRECTORYPARSER_H diff --git a/src/plugins/locator/filesystemfilter.cpp b/src/plugins/locator/filesystemfilter.cpp new file mode 100644 index 0000000000..99506b0760 --- /dev/null +++ b/src/plugins/locator/filesystemfilter.cpp @@ -0,0 +1,152 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "filesystemfilter.h" +#include "locatorwidget.h" +#include + +#include + +using namespace Core; +using namespace Locator; +using namespace Locator::Internal; + +FileSystemFilter::FileSystemFilter(EditorManager *editorManager, LocatorWidget *locatorWidget) + : m_editorManager(editorManager), m_locatorWidget(locatorWidget), m_includeHidden(true) +{ + setShortcutString("f"); + setIncludedByDefault(false); +} + +QList FileSystemFilter::matchesFor(const QString &entry) +{ + QList value; + QFileInfo entryInfo(entry); + QString name = entryInfo.fileName(); + QString directory = entryInfo.path(); + QString filePath = entryInfo.filePath(); + if (entryInfo.isRelative()) { + if (filePath.startsWith("~/")) { + directory.replace(0, 1, QDir::homePath()); + } else { + IEditor *editor = m_editorManager->currentEditor(); + if (editor && !editor->file()->fileName().isEmpty()) { + QFileInfo info(editor->file()->fileName()); + directory.prepend(info.absolutePath()+"/"); + } + } + } + QDir dirInfo(directory); + QDir::Filters dirFilter = QDir::Dirs|QDir::Drives; + QDir::Filters fileFilter = QDir::Files; + if (m_includeHidden) { + dirFilter |= QDir::Hidden; + fileFilter |= QDir::Hidden; + } + QStringList dirs = dirInfo.entryList(dirFilter, + QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); + QStringList files = dirInfo.entryList(fileFilter, + QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); + foreach (const QString &dir, dirs) { + if (dir != "." && (name.isEmpty() || dir.startsWith(name, Qt::CaseInsensitive))) { + FilterEntry entry(this, dir, dirInfo.filePath(dir)); + entry.resolveFileIcon = true; + value.append(entry); + } + } + foreach (const QString &file, files) { + if (name.isEmpty() || file.startsWith(name, Qt::CaseInsensitive)) { + const QString fullPath = dirInfo.filePath(file); + FilterEntry entry(this, file, fullPath); + entry.resolveFileIcon = true; + value.append(entry); + } + } + return value; +} + +void FileSystemFilter::accept(FilterEntry selection) const +{ + QFileInfo info(selection.internalData.toString()); + if (info.isDir()) { + QString value = shortcutString() + " " + QDir::toNativeSeparators(info.absoluteFilePath()+"/"); + m_locatorWidget->show(value, value.length()); + return; + } + m_editorManager->openEditor(selection.internalData.toString()); + m_editorManager->ensureEditorManagerVisible(); +} + +bool FileSystemFilter::openConfigDialog(QWidget *parent, bool &needsRefresh) +{ + Q_UNUSED(needsRefresh) + Ui::FileSystemFilterOptions ui; + QDialog dialog(parent); + ui.setupUi(&dialog); + + ui.hiddenFilesFlag->setChecked(m_includeHidden); + ui.limitCheck->setChecked(!isIncludedByDefault()); + ui.shortcutEdit->setText(shortcutString()); + + if (dialog.exec() == QDialog::Accepted) { + m_includeHidden = ui.hiddenFilesFlag->isChecked(); + setShortcutString(ui.shortcutEdit->text().trimmed()); + setIncludedByDefault(!ui.limitCheck->isChecked()); + return true; + } + return false; +} + +QByteArray FileSystemFilter::saveState() const +{ + QByteArray value; + QDataStream out(&value, QIODevice::WriteOnly); + out << m_includeHidden; + out << shortcutString(); + out << isIncludedByDefault(); + return value; +} + +bool FileSystemFilter::restoreState(const QByteArray &state) +{ + QDataStream in(state); + in >> m_includeHidden; + + // An attempt to prevent setting this on old configuration + if (!in.atEnd()) { + QString shortcut; + bool defaultFilter; + in >> shortcut; + in >> defaultFilter; + setShortcutString(shortcut); + setIncludedByDefault(defaultFilter); + } + + return true; +} diff --git a/src/plugins/locator/filesystemfilter.h b/src/plugins/locator/filesystemfilter.h new file mode 100644 index 0000000000..319637192a --- /dev/null +++ b/src/plugins/locator/filesystemfilter.h @@ -0,0 +1,73 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef FILESYSTEMFILTER_H +#define FILESYSTEMFILTER_H + +#include "ilocatorfilter.h" +#include "ui_filesystemfilter.h" + +#include + +#include +#include +#include +#include + +namespace Locator { +namespace Internal { + +class LocatorWidget; + +class FileSystemFilter : public Locator::ILocatorFilter +{ + Q_OBJECT + +public: + FileSystemFilter(Core::EditorManager *editorManager, LocatorWidget *locatorWidget); + QString trName() const { return tr("Files in file system"); } + QString name() const { return "Files in file system"; } + Locator::ILocatorFilter::Priority priority() const { return Locator::ILocatorFilter::Medium; } + QList matchesFor(const QString &entry); + void accept(Locator::FilterEntry selection) const; + QByteArray saveState() const; + bool restoreState(const QByteArray &state); + bool openConfigDialog(QWidget *parent, bool &needsRefresh); + void refresh(QFutureInterface &) {} + +private: + Core::EditorManager *m_editorManager; + LocatorWidget *m_locatorWidget; + bool m_includeHidden; +}; + +} // namespace Internal +} // namespace Locator + +#endif // FILESYSTEMFILTER_H diff --git a/src/plugins/locator/filesystemfilter.ui b/src/plugins/locator/filesystemfilter.ui new file mode 100644 index 0000000000..0c56a86032 --- /dev/null +++ b/src/plugins/locator/filesystemfilter.ui @@ -0,0 +1,111 @@ + + + Locator::Internal::FileSystemFilterOptions + + + + 0 + 0 + 335 + 131 + + + + Filter configuration + + + + + + Prefix: + + + shortcutEdit + + + + + + + + + + Limit to prefix + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + Include hidden files + + + + + + + Filter: + + + + + + + + + buttonBox + accepted() + Locator::Internal::FileSystemFilterOptions + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Locator::Internal::FileSystemFilterOptions + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/plugins/locator/ilocatorfilter.cpp b/src/plugins/locator/ilocatorfilter.cpp new file mode 100644 index 0000000000..fb9c682eac --- /dev/null +++ b/src/plugins/locator/ilocatorfilter.cpp @@ -0,0 +1,139 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "ilocatorfilter.h" + +#include +#include +#include +#include +#include +#include + +using namespace Locator; + +ILocatorFilter::ILocatorFilter(QObject *parent): + QObject(parent), + m_includedByDefault(false), + m_hidden(false) +{ +} + +QString ILocatorFilter::shortcutString() const +{ + return m_shortcut; +} + +void ILocatorFilter::setShortcutString(const QString &shortcut) +{ + m_shortcut = shortcut; +} + +QByteArray ILocatorFilter::saveState() const +{ + QByteArray value; + QDataStream out(&value, QIODevice::WriteOnly); + out << shortcutString(); + out << isIncludedByDefault(); + return value; +} + +bool ILocatorFilter::restoreState(const QByteArray &state) +{ + QString shortcut; + bool defaultFilter; + + QDataStream in(state); + in >> shortcut; + in >> defaultFilter; + + setShortcutString(shortcut); + setIncludedByDefault(defaultFilter); + return true; +} + +bool ILocatorFilter::openConfigDialog(QWidget *parent, bool &needsRefresh) +{ + Q_UNUSED(needsRefresh) + + QDialog dialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint); + dialog.setWindowTitle(tr("Filter Configuration")); + + QVBoxLayout *vlayout = new QVBoxLayout(&dialog); + QHBoxLayout *hlayout = new QHBoxLayout; + QLineEdit *shortcutEdit = new QLineEdit(shortcutString()); + QCheckBox *limitCheck = new QCheckBox(tr("Limit to prefix")); + limitCheck->setChecked(!isIncludedByDefault()); + + hlayout->addWidget(new QLabel(tr("Prefix:"))); + hlayout->addWidget(shortcutEdit); + hlayout->addWidget(limitCheck); + + QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | + QDialogButtonBox::Cancel); + connect(buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept())); + connect(buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject())); + + vlayout->addLayout(hlayout); + vlayout->addStretch(); + vlayout->addWidget(buttonBox); + + if (dialog.exec() == QDialog::Accepted) { + setShortcutString(shortcutEdit->text().trimmed()); + setIncludedByDefault(!limitCheck->isChecked()); + return true; + } + + return false; +} + +bool ILocatorFilter::isConfigurable() const +{ + return true; +} + +bool ILocatorFilter::isIncludedByDefault() const +{ + return m_includedByDefault; +} + +void ILocatorFilter::setIncludedByDefault(bool includedByDefault) +{ + m_includedByDefault = includedByDefault; +} + +bool ILocatorFilter::isHidden() const +{ + return m_hidden; +} + +void ILocatorFilter::setHidden(bool hidden) +{ + m_hidden = hidden; +} diff --git a/src/plugins/locator/ilocatorfilter.h b/src/plugins/locator/ilocatorfilter.h new file mode 100644 index 0000000000..4957eecd05 --- /dev/null +++ b/src/plugins/locator/ilocatorfilter.h @@ -0,0 +1,156 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef ILOCATORFILTER_H +#define ILOCATORFILTER_H + +#include "locator_global.h" + +#include +#include +#include +#include + +namespace Locator { + +class ILocatorFilter; + +struct FilterEntry +{ + FilterEntry() {} + FilterEntry(ILocatorFilter *fromFilter, const QString &name, const QVariant &data, + const QIcon &icon = QIcon()) + : filter(fromFilter) + , displayName(name) + , internalData(data) + , displayIcon(icon) + , resolveFileIcon(false) + {} + + bool operator==(const FilterEntry &other) const { + if (internalData.canConvert(QVariant::String)) + return (internalData.toString() == other.internalData.toString()); + return internalData.constData() == other.internalData.constData(); + } + + /* backpointer to creating filter */ + ILocatorFilter *filter; + /* displayed string */ + QString displayName; + /* extra information displayed in light-gray in a second column (optional) */ + QString extraInfo; + /* can be used by the filter to save more information about the entry */ + QVariant internalData; + /* icon to display along with the entry */ + QIcon displayIcon; + /* internal data is interpreted as file name and icon is retrieved from the file system if true */ + bool resolveFileIcon; +}; + +class LOCATOR_EXPORT ILocatorFilter : public QObject +{ + Q_OBJECT + +public: + enum Priority {High = 0, Medium = 1, Low = 2}; + + ILocatorFilter(QObject *parent = 0); + virtual ~ILocatorFilter() {} + + /* Visible name. */ + virtual QString trName() const = 0; + + /* Internal name. */ + virtual QString name() const = 0; + + /* Selection list order in case of multiple active filters (high goes on top). */ + virtual Priority priority() const = 0; + + /* String to type to use this filter exclusively. */ + QString shortcutString() const; + + /* List of matches for the given user entry. */ + virtual QList matchesFor(const QString &entry) = 0; + + /* User has selected the given entry that belongs to this filter. */ + virtual void accept(FilterEntry selection) const = 0; + + /* Implement to update caches on user request, if that's a long operation. */ + virtual void refresh(QFutureInterface &future) = 0; + + /* Saved state is used to restore the filter at start up. */ + virtual QByteArray saveState() const; + + /* Used to restore the filter at start up. */ + virtual bool restoreState(const QByteArray &state); + + /* User wants to configure this filter (if supported). Use it to pop up a dialog. + * needsRefresh is used as a hint to indicate that refresh should be called. + * The default implementation allows changing the shortcut and whether the filter + * is enabled by default. + */ + virtual bool openConfigDialog(QWidget *parent, bool &needsRefresh); + + /* If there is a configure dialog available for this filter. The default + * implementation returns true. */ + virtual bool isConfigurable() const; + + /* Is this filter used also when the shortcutString is not used? */ + bool isIncludedByDefault() const; + + /* Returns whether the filter should be hidden from configuration and menus. */ + bool isHidden() const; + + static QString trimWildcards(const QString &str) { + if (str.isEmpty()) + return str; + int first = 0, last = str.size()-1; + while (first < str.size() && (str.at(first) == '*' || str.at(first) == '?')) + ++first; + while (last >= 0 && (str.at(last) == '*' || str.at(last) == '?')) + --last; + if (first > last) + return QString(); + return str.mid(first, last-first+1); + } + +protected: + void setShortcutString(const QString &shortcut); + void setIncludedByDefault(bool includedByDefault); + void setHidden(bool hidden); + +private: + QString m_shortcut; + bool m_includedByDefault; + bool m_hidden; +}; + +} // namespace Locator + +#endif // ILOCATORFILTER_H diff --git a/src/plugins/locator/images/locator.png b/src/plugins/locator/images/locator.png new file mode 100644 index 0000000000..000ee1c018 Binary files /dev/null and b/src/plugins/locator/images/locator.png differ diff --git a/src/plugins/locator/images/reload.png b/src/plugins/locator/images/reload.png new file mode 100644 index 0000000000..b5afefb32b Binary files /dev/null and b/src/plugins/locator/images/reload.png differ diff --git a/src/plugins/locator/locator.pro b/src/plugins/locator/locator.pro new file mode 100644 index 0000000000..73de643c9c --- /dev/null +++ b/src/plugins/locator/locator.pro @@ -0,0 +1,33 @@ +TEMPLATE = lib +TARGET = QuickOpen +DEFINES += LOCATOR_LIBRARY +include(../../qtcreatorplugin.pri) +include(quickopen_dependencies.pri) +HEADERS += locatorplugin.h \ + locatorwidget.h \ + locatorfiltersfilter.h \ + settingspage.h \ + ilocatorfilter.h \ + opendocumentsfilter.h \ + filesystemfilter.h \ + locatorconstants.h \ + directoryfilter.h \ + locatormanager.h \ + basefilefilter.h \ + locator_global.h +SOURCES += locatorplugin.cpp \ + locatorwidget.cpp \ + locatorfiltersfilter.cpp \ + opendocumentsfilter.cpp \ + filesystemfilter.cpp \ + settingspage.cpp \ + directoryfilter.cpp \ + locatormanager.cpp \ + basefilefilter.cpp \ + ilocatorfilter.cpp +FORMS += settingspage.ui \ + filesystemfilter.ui \ + directoryfilter.ui +RESOURCES += locator.qrc + +OTHER_FILES += QuickOpen.pluginspec diff --git a/src/plugins/locator/locator.qrc b/src/plugins/locator/locator.qrc new file mode 100644 index 0000000000..4cd5df4f13 --- /dev/null +++ b/src/plugins/locator/locator.qrc @@ -0,0 +1,6 @@ + + + images/reload.png + images/locator.png + + diff --git a/src/plugins/locator/locator_global.h b/src/plugins/locator/locator_global.h new file mode 100644 index 0000000000..7dc95b7fde --- /dev/null +++ b/src/plugins/locator/locator_global.h @@ -0,0 +1,41 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef LOCATOR_GLOBAL_H +#define LOCATOR_GLOBAL_H + +#include + +#if defined(LOCATOR_LIBRARY) +# define LOCATOR_EXPORT Q_DECL_EXPORT +#else +# define LOCATOR_EXPORT Q_DECL_IMPORT +#endif + +#endif // LOCATOR_GLOBAL_H diff --git a/src/plugins/locator/locatorconstants.h b/src/plugins/locator/locatorconstants.h new file mode 100644 index 0000000000..4a78341f79 --- /dev/null +++ b/src/plugins/locator/locatorconstants.h @@ -0,0 +1,45 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef LOCATORCONSTANTS_H +#define LOCATORCONSTANTS_H + +#include + +namespace Locator { +namespace Constants { + +const char * const FILTER_OPTIONS_PAGE = QT_TRANSLATE_NOOP("Locator", "Filters"); +const char * const LOCATOR_CATEGORY = QT_TRANSLATE_NOOP("Locator", "Locator"); +const char * const TASK_INDEX = "Locator.Task.Index"; + +} // namespace Constants +} // namespace Locator + +#endif // LOCATORCONSTANTS_H diff --git a/src/plugins/locator/locatorfiltersfilter.cpp b/src/plugins/locator/locatorfiltersfilter.cpp new file mode 100644 index 0000000000..4b81b73e5d --- /dev/null +++ b/src/plugins/locator/locatorfiltersfilter.cpp @@ -0,0 +1,101 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "locatorfiltersfilter.h" +#include "locatorplugin.h" +#include "locatorwidget.h" + +#include + +using namespace Locator; +using namespace Locator::Internal; + +Q_DECLARE_METATYPE(ILocatorFilter*); + +LocatorFiltersFilter::LocatorFiltersFilter(LocatorPlugin *plugin, + LocatorWidget *locatorWidget): + m_plugin(plugin), + m_locatorWidget(locatorWidget), + m_icon(QIcon(Core::Constants::ICON_NEXT)) +{ + setIncludedByDefault(true); + setHidden(true); +} + +QString LocatorFiltersFilter::trName() const +{ + return tr("Available filters"); +} + +QString LocatorFiltersFilter::name() const +{ + return QLatin1String("FiltersFilter"); +} + +ILocatorFilter::Priority LocatorFiltersFilter::priority() const +{ + return High; +} + +QList LocatorFiltersFilter::matchesFor(const QString &entry) +{ + QList entries; + if (entry.isEmpty()) { + foreach (ILocatorFilter *filter, m_plugin->filters()) { + if (!filter->shortcutString().isEmpty() && !filter->isHidden()) { + FilterEntry entry(this, + filter->shortcutString(), + QVariant::fromValue(filter), + m_icon); + entry.extraInfo = filter->trName(); + entries.append(entry); + } + } + } + return entries; +} + +void LocatorFiltersFilter::accept(FilterEntry selection) const +{ + ILocatorFilter *filter = selection.internalData.value(); + if (filter) + m_locatorWidget->show(filter->shortcutString() + " ", + filter->shortcutString().length() + 1); +} + +void LocatorFiltersFilter::refresh(QFutureInterface &future) +{ + Q_UNUSED(future) + // Nothing to refresh +} + +bool LocatorFiltersFilter::isConfigurable() const +{ + return false; +} diff --git a/src/plugins/locator/locatorfiltersfilter.h b/src/plugins/locator/locatorfiltersfilter.h new file mode 100644 index 0000000000..622b653f1a --- /dev/null +++ b/src/plugins/locator/locatorfiltersfilter.h @@ -0,0 +1,73 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef LOCATORFILTERSFILTER_H +#define LOCATORFILTERSFILTER_H + +#include "ilocatorfilter.h" + +#include + +namespace Locator { +namespace Internal { + +class LocatorPlugin; +class LocatorWidget; + +/*! + This filter provides the user with the list of available Locator filters. + The list is only shown when nothing has been typed yet. + */ +class LocatorFiltersFilter : public ILocatorFilter +{ + Q_OBJECT + +public: + LocatorFiltersFilter(LocatorPlugin *plugin, + LocatorWidget *locatorWidget); + + // ILocatorFilter + QString trName() const; + QString name() const; + Priority priority() const; + QList matchesFor(const QString &entry); + void accept(FilterEntry selection) const; + void refresh(QFutureInterface &future); + bool isConfigurable() const; + +private: + LocatorPlugin *m_plugin; + LocatorWidget *m_locatorWidget; + QIcon m_icon; +}; + +} // namespace Internal +} // namespace Locator + +#endif // LOCATORFILTERSFILTER_H diff --git a/src/plugins/locator/locatormanager.cpp b/src/plugins/locator/locatormanager.cpp new file mode 100644 index 0000000000..d1df7d8746 --- /dev/null +++ b/src/plugins/locator/locatormanager.cpp @@ -0,0 +1,59 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "locatormanager.h" +#include "locatorwidget.h" + +#include +#include + +using namespace Locator; +using namespace Locator::Internal; + +LocatorManager *LocatorManager::m_instance = 0; + +LocatorManager::LocatorManager(LocatorWidget *locatorWidget) + : QObject(locatorWidget), + m_locatorWidget(locatorWidget) +{ + m_instance = this; +} + +LocatorManager::~LocatorManager() +{ + ExtensionSystem::PluginManager::instance()->removeObject(this); + m_instance = 0; +} + +void LocatorManager::show(const QString &text, + int selectionStart, int selectionLength) +{ + QTC_ASSERT(m_locatorWidget, return); + m_locatorWidget->show(text, selectionStart, selectionLength); +} diff --git a/src/plugins/locator/locatormanager.h b/src/plugins/locator/locatormanager.h new file mode 100644 index 0000000000..d3f296c85e --- /dev/null +++ b/src/plugins/locator/locatormanager.h @@ -0,0 +1,62 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef LOCATORMANAGER_H +#define LOCATORMANAGER_H + +#include "locator_global.h" + +#include + +namespace Locator { + +namespace Internal { +class LocatorWidget; +} + +class LOCATOR_EXPORT LocatorManager : public QObject +{ + Q_OBJECT + +public: + LocatorManager(Internal::LocatorWidget *locatorWidget); + ~LocatorManager(); + + static LocatorManager* instance() { return m_instance; } + + void show(const QString &text, int selectionStart = -1, int selectionLength = 0); + +private: + Internal::LocatorWidget *m_locatorWidget; + static LocatorManager *m_instance; +}; + +} // namespace Locator + +#endif // LOCATORMANAGER_H diff --git a/src/plugins/locator/locatorplugin.cpp b/src/plugins/locator/locatorplugin.cpp new file mode 100644 index 0000000000..c37d218a1c --- /dev/null +++ b/src/plugins/locator/locatorplugin.cpp @@ -0,0 +1,253 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "locatorplugin.h" +#include "locatorconstants.h" +#include "locatorfiltersfilter.h" +#include "locatormanager.h" +#include "locatorwidget.h" +#include "opendocumentsfilter.h" +#include "filesystemfilter.h" +#include "settingspage.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*! + \namespace Locator + The Locator namespace provides the hooks for Locator content. +*/ +/*! + \namespace Locator::Internal + \internal +*/ + +using namespace Locator; +using namespace Locator::Internal; + +namespace { + static bool filterLessThan(const ILocatorFilter *first, const ILocatorFilter *second) + { + return first->priority() < second->priority(); + } +} + +LocatorPlugin::LocatorPlugin() +{ + m_refreshTimer.setSingleShot(false); + connect(&m_refreshTimer, SIGNAL(timeout()), this, SLOT(refresh())); +} + +LocatorPlugin::~LocatorPlugin() +{ + removeObject(m_openDocumentsFilter); + removeObject(m_fileSystemFilter); + removeObject(m_settingsPage); + delete m_openDocumentsFilter; + delete m_fileSystemFilter; + delete m_settingsPage; + qDeleteAll(m_customFilters); +} + +bool LocatorPlugin::initialize(const QStringList &, QString *) +{ + Core::ICore *core = Core::ICore::instance(); + m_settingsPage = new SettingsPage(this); + addObject(m_settingsPage); + + m_locatorWidget = new LocatorWidget(this); + m_locatorWidget->setEnabled(false); + Core::BaseView *view = new Core::BaseView; + view->setUniqueViewName("Locator"); + view->setWidget(m_locatorWidget); + view->setContext(QList() << core->uniqueIDManager() + ->uniqueIdentifier(QLatin1String("LocatorWidget"))); + view->setDefaultPosition(Core::IView::First); + addAutoReleasedObject(view); + + const QString actionId = QLatin1String("QtCreator.Locate"); + QAction *action = new QAction(m_locatorWidget->windowIcon(), m_locatorWidget->windowTitle(), this); + Core::Command *cmd = core->actionManager()->registerAction(action, actionId, QList() << Core::Constants::C_GLOBAL_ID); + cmd->setDefaultKeySequence(QKeySequence("Ctrl+K")); + connect(action, SIGNAL(triggered()), this, SLOT(openLocator())); + + Core::ActionContainer *mtools = core->actionManager()->actionContainer(Core::Constants::M_TOOLS); + mtools->addAction(cmd); + + addObject(new LocatorManager(m_locatorWidget)); + + m_openDocumentsFilter = new OpenDocumentsFilter(core->editorManager()); + addObject(m_openDocumentsFilter); + + m_fileSystemFilter = new FileSystemFilter(core->editorManager(), m_locatorWidget); + addObject(m_fileSystemFilter); + + addAutoReleasedObject(new LocatorFiltersFilter(this, m_locatorWidget)); + + connect(core, SIGNAL(coreOpened()), this, SLOT(startSettingsLoad())); + return true; +} + +void LocatorPlugin::openLocator() +{ + m_locatorWidget->show(""); +} + +void LocatorPlugin::extensionsInitialized() +{ + m_filters = ExtensionSystem::PluginManager::instance()->getObjects(); + qSort(m_filters.begin(), m_filters.end(), filterLessThan); +} + +void LocatorPlugin::startSettingsLoad() +{ + m_loadWatcher.setFuture(QtConcurrent::run(this, &LocatorPlugin::loadSettings)); + connect(&m_loadWatcher, SIGNAL(finished()), this, SLOT(settingsLoaded())); +} + +void LocatorPlugin::loadSettings() +{ + Core::ICore *core = Core::ICore::instance(); + QSettings *qs = core->settings(); + + // Backwards compatibility to old settings location + if (qs->contains("QuickOpen/FiltersFilter")) { + loadSettingsHelper(qs); + } else { + Core::SettingsDatabase *settings = core->settingsDatabase(); + loadSettingsHelper(settings); + } + + qs->remove("QuickOpen"); +} + +void LocatorPlugin::settingsLoaded() +{ + m_locatorWidget->updateFilterList(); + m_locatorWidget->setEnabled(true); + if (m_refreshTimer.interval() > 0) + m_refreshTimer.start(); +} + +void LocatorPlugin::saveSettings() +{ + Core::ICore *core = Core::ICore::instance(); + if (core && core->settingsDatabase()) { + Core::SettingsDatabase *s = core->settingsDatabase(); + s->beginGroup("QuickOpen"); + s->remove(""); + s->setValue("RefreshInterval", refreshInterval()); + foreach (ILocatorFilter *filter, m_filters) { + if (!m_customFilters.contains(filter)) + s->setValue(filter->name(), filter->saveState()); + } + s->beginGroup("CustomFilters"); + int i = 0; + foreach (ILocatorFilter *filter, m_customFilters) { + s->setValue(QString("directory%1").arg(i), filter->saveState()); + ++i; + } + s->endGroup(); + s->endGroup(); + } +} + +/*! + \fn QList LocatorPlugin::filter() + + Return all filters, including the ones created by the user. +*/ +QList LocatorPlugin::filters() +{ + return m_filters; +} + +/*! + \fn QList LocatorPlugin::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 LocatorPlugin::customFilters() +{ + return m_customFilters; +} + +void LocatorPlugin::setFilters(QList f) +{ + m_filters = f; + m_locatorWidget->updateFilterList(); +} + +void LocatorPlugin::setCustomFilters(QList filters) +{ + m_customFilters = filters; +} + +int LocatorPlugin::refreshInterval() +{ + return m_refreshTimer.interval() / 60000; +} + +void LocatorPlugin::setRefreshInterval(int interval) +{ + if (interval < 1) { + m_refreshTimer.stop(); + m_refreshTimer.setInterval(0); + return; + } + m_refreshTimer.setInterval(interval * 60000); + m_refreshTimer.start(); +} + +void LocatorPlugin::refresh(QList filters) +{ + if (filters.isEmpty()) + filters = m_filters; + QFuture task = QtConcurrent::run(&ILocatorFilter::refresh, filters); + Core::FutureProgress *progress = Core::ICore::instance() + ->progressManager()->addTask(task, tr("Indexing"), + Locator::Constants::TASK_INDEX, + Core::ProgressManager::CloseOnSuccess); + connect(progress, SIGNAL(finished()), this, SLOT(saveSettings())); +} + +Q_EXPORT_PLUGIN(LocatorPlugin) diff --git a/src/plugins/locator/locatorplugin.h b/src/plugins/locator/locatorplugin.h new file mode 100644 index 0000000000..525f291f4a --- /dev/null +++ b/src/plugins/locator/locatorplugin.h @@ -0,0 +1,126 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef LOCATORPLUGIN_H +#define LOCATORPLUGIN_H + +#include "ilocatorfilter.h" +#include "directoryfilter.h" + +#include + +#include +#include +#include + +namespace Locator { +namespace Internal { + +class LocatorWidget; +class OpenDocumentsFilter; +class FileSystemFilter; +class SettingsPage; +class LocatorPlugin; + +class LocatorPlugin : public ExtensionSystem::IPlugin +{ + Q_OBJECT + +public: + LocatorPlugin(); + ~LocatorPlugin(); + + bool initialize(const QStringList &arguments, QString *error_message); + void extensionsInitialized(); + + QList filters(); + QList customFilters(); + void setFilters(QList f); + void setCustomFilters(QList f); + int refreshInterval(); + void setRefreshInterval(int interval); + +public slots: + void refresh(QList filters = QList()); + void saveSettings(); + void openLocator(); + +private slots: + void startSettingsLoad(); + void settingsLoaded(); + +private: + void loadSettings(); + + template + void loadSettingsHelper(S *settings); + + LocatorWidget *m_locatorWidget; + SettingsPage *m_settingsPage; + + QList m_filters; + QList m_customFilters; + int m_refreshInterval; + QTimer m_refreshTimer; + OpenDocumentsFilter *m_openDocumentsFilter; + FileSystemFilter *m_fileSystemFilter; + QFutureWatcher m_loadWatcher; +}; + +template +void LocatorPlugin::loadSettingsHelper(S *settings) +{ + settings->beginGroup("QuickOpen"); + m_refreshTimer.setInterval(settings->value("RefreshInterval", 60).toInt() * 60000); + + foreach (ILocatorFilter *filter, m_filters) { + if (settings->contains(filter->name())) { + const QByteArray state = settings->value(filter->name()).toByteArray(); + if (!state.isEmpty()) + filter->restoreState(state); + } + } + settings->beginGroup("CustomFilters"); + QList customFilters; + const QStringList keys = settings->childKeys(); + foreach (const QString &key, keys) { + ILocatorFilter *filter = new DirectoryFilter; + filter->restoreState(settings->value(key).toByteArray()); + m_filters.append(filter); + customFilters.append(filter); + } + setCustomFilters(customFilters); + settings->endGroup(); + settings->endGroup(); +} + +} // namespace Internal +} // namespace Locator + +#endif // LOCATORPLUGIN_H diff --git a/src/plugins/locator/locatorwidget.cpp b/src/plugins/locator/locatorwidget.cpp new file mode 100644 index 0000000000..da15cd1100 --- /dev/null +++ b/src/plugins/locator/locatorwidget.cpp @@ -0,0 +1,489 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include + +namespace Locator { +struct FilterEntry; +} + +QT_BEGIN_NAMESPACE +unsigned int qHash(const Locator::FilterEntry &entry); +QT_END_NAMESPACE + +#include "locatorwidget.h" +#include "locatorplugin.h" +#include "locatorconstants.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +Q_DECLARE_METATYPE(Locator::ILocatorFilter*); +Q_DECLARE_METATYPE(Locator::FilterEntry); + +namespace Locator { +namespace Internal { + +/*! A model to represent the Locator results. */ +class LocatorModel : public QAbstractListModel +{ +public: + LocatorModel(QObject *parent = 0) + : QAbstractListModel(parent) +// , mDisplayCount(64) + {} + + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + + void setEntries(const QList &entries); + //void setDisplayCount(int count); + +private: + mutable QList mEntries; + //int mDisplayCount; +}; + +class CompletionList : public QTreeView +{ +public: + CompletionList(QWidget *parent = 0); + + void updatePreferredSize(); + QSize preferredSize() const { return m_preferredSize; } + +private: + QSize m_preferredSize; +}; + +} // namespace Internal +} // namespace Locator + +using namespace Locator; +using namespace Locator::Internal; + +QT_BEGIN_NAMESPACE +uint qHash(const FilterEntry &entry) +{ + if (entry.internalData.canConvert(QVariant::String)) + return qHash(entry.internalData.toString()); + return qHash(entry.internalData.constData()); +} +QT_END_NAMESPACE + + +// =========== LocatorModel =========== + +int LocatorModel::rowCount(const QModelIndex & /* parent */) const +{ + return mEntries.size(); +} + +int LocatorModel::columnCount(const QModelIndex &parent) const +{ + return parent.isValid() ? 0 : 2; +} + +/*! + * When asked for the icon via Qt::DecorationRole, the LocatorModel lazily + * resolves and caches the Greehouse-specific file icon when + * FilterEntry::resolveFileIcon is true. FilterEntry::internalData is assumed + * to be the filename. + */ +QVariant LocatorModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid() || index.row() >= mEntries.size()) + return QVariant(); + + if (role == Qt::DisplayRole || role == Qt::ToolTipRole) { + if (index.column() == 0) { + return mEntries.at(index.row()).displayName; + } else if (index.column() == 1) { + return mEntries.at(index.row()).extraInfo; + } + } else if (role == Qt::DecorationRole && index.column() == 0) { + FilterEntry &entry = mEntries[index.row()]; + if (entry.resolveFileIcon && entry.displayIcon.isNull()) { + entry.resolveFileIcon = false; + entry.displayIcon = + Core::FileIconProvider::instance()->icon(QFileInfo(entry.internalData.toString())); + } + return entry.displayIcon; + } else if (role == Qt::ForegroundRole && index.column() == 1) { + return Qt::darkGray; + } else if (role == Qt::UserRole) { + return qVariantFromValue(mEntries.at(index.row())); + } + + return QVariant(); +} + +void LocatorModel::setEntries(const QList &entries) +{ + mEntries = entries; + reset(); +} +#if 0 +void LocatorModel::setDisplayCount(int count) +{ + // TODO: This method is meant to be used for increasing the number of items displayed at the + // user's request. There is however no way yet for the user to request this. + if (count == mDisplayCount) + return; + + const int displayedOld = qMin(mDisplayCount, mEntries.size()); + const int displayedNew = qMin(count, mEntries.size()); + + if (displayedNew < displayedOld) + beginRemoveRows(QModelIndex(), displayedNew - 1, displayedOld - 1); + else if (displayedNew > displayedOld) + beginInsertRows(QModelIndex(), displayedOld - 1, displayedNew - 1); + + mDisplayCount = count; + + if (displayedNew < displayedOld) + endRemoveRows(); + else if (displayedNew > displayedOld) + endInsertRows(); +} +#endif + +// =========== CompletionList =========== + +CompletionList::CompletionList(QWidget *parent) + : QTreeView(parent) +{ + setRootIsDecorated(false); + setUniformRowHeights(true); + setMaximumWidth(900); + header()->hide(); + header()->setStretchLastSection(true); + // This is too slow when done on all results + //header()->setResizeMode(QHeaderView::ResizeToContents); + setWindowFlags(Qt::ToolTip); +} + +void CompletionList::updatePreferredSize() +{ + //header()->setStretchLastSection(false); + //updateGeometries(); + + const QStyleOptionViewItem &option = viewOptions(); + const QSize shint = itemDelegate()->sizeHint(option, model()->index(0, 0)); +#if 0 + const int visibleItems = model()->rowCount(); + + // TODO: Look into enabling preferred height as well. Current problem is that this doesn't + // work nicely from the user perspective if the list is popping up instead of down. + //const int h = shint.height() * visibleItems; + + const QScrollBar *vscroll = verticalScrollBar(); + int preferredWidth = header()->length() + frameWidth() * 2 + + (vscroll->isVisibleTo(this) ? vscroll->width() : 0); + const int diff = preferredWidth - width(); + + // Avoid resizing the list widget when there are no results or when the preferred size is + // only a little smaller than our current size + if (visibleItems == 0 || (diff > -100 && diff < 0)) + preferredWidth = width(); +#endif + + m_preferredSize = QSize(730, //qMax(600, preferredWidth), + shint.height() * 17 + frameWidth() * 2); + //header()->setStretchLastSection(true); +} + + +// =========== LocatorWidget =========== + +LocatorWidget::LocatorWidget(LocatorPlugin *qop) : + m_locatorPlugin(qop), + m_locatorModel(new LocatorModel(this)), + m_completionList(new CompletionList(this)), + m_filterMenu(new QMenu(this)), + m_refreshAction(new QAction(tr("Refresh"), this)), + m_configureAction(new QAction(tr("Configure..."), this)), + m_fileLineEdit(new Utils::FancyLineEdit) +{ + // Explicitly hide the completion list popup. + m_completionList->hide(); + + setFocusProxy(m_fileLineEdit); + setWindowTitle(tr("Locate...")); + resize(200, 90); + QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + sizePolicy.setHorizontalStretch(0); + sizePolicy.setVerticalStretch(0); + setSizePolicy(sizePolicy); + setMinimumSize(QSize(200, 0)); + + QHBoxLayout *layout = new QHBoxLayout(this); + setLayout(layout); + layout->setMargin(0); + layout->addWidget(m_fileLineEdit); + + setWindowIcon(QIcon(":/locator/images/locator.png")); + QPixmap image(Core::Constants::ICON_MAGNIFIER); + m_fileLineEdit->setPixmap(image); + m_fileLineEdit->setUseLayoutDirection(true); + m_fileLineEdit->setHintText(tr("Type to locate")); + m_fileLineEdit->setFocusPolicy(Qt::ClickFocus); + m_fileLineEdit->setAttribute(Qt::WA_MacShowFocusRect, false); + + m_fileLineEdit->installEventFilter(this); + this->installEventFilter(this); + + m_completionList->setModel(m_locatorModel); + m_completionList->header()->resizeSection(0, 300); + m_completionList->updatePreferredSize(); + m_completionList->resize(m_completionList->preferredSize()); + + m_filterMenu->addAction(m_refreshAction); + m_filterMenu->addAction(m_configureAction); + + m_fileLineEdit->setMenu( m_filterMenu); + + connect(m_refreshAction, SIGNAL(triggered()), m_locatorPlugin, SLOT(refresh())); + connect(m_configureAction, SIGNAL(triggered()), this, SLOT(showConfigureDialog())); + connect(m_fileLineEdit, SIGNAL(textEdited(const QString&)), + this, SLOT(showPopup())); + connect(m_completionList, SIGNAL(activated(QModelIndex)), + this, SLOT(acceptCurrentEntry())); +} + +bool LocatorWidget::isShowingTypeHereMessage() const +{ + return m_fileLineEdit->isShowingHintText(); +} + +void LocatorWidget::updateFilterList() +{ + m_filterMenu->clear(); + foreach (ILocatorFilter *filter, m_locatorPlugin->filters()) { + if (!filter->shortcutString().isEmpty() && !filter->isHidden()) { + QAction *action = m_filterMenu->addAction(filter->trName(), this, SLOT(filterSelected())); + action->setData(qVariantFromValue(filter)); + } + } + m_filterMenu->addSeparator(); + m_filterMenu->addAction(m_refreshAction); + m_filterMenu->addAction(m_configureAction); +} + +bool LocatorWidget::eventFilter(QObject *obj, QEvent *event) +{ + if (obj == m_fileLineEdit && event->type() == QEvent::KeyPress) { + QKeyEvent *keyEvent = static_cast(event); + switch (keyEvent->key()) { + case Qt::Key_Up: + case Qt::Key_Down: + case Qt::Key_PageUp: + case Qt::Key_PageDown: + showCompletionList(); + QApplication::sendEvent(m_completionList, event); + return true; + case Qt::Key_Enter: + case Qt::Key_Return: + acceptCurrentEntry(); + return true; + case Qt::Key_Escape: + m_completionList->hide(); + return true; + default: + break; + } + } else if (obj == m_fileLineEdit && event->type() == QEvent::FocusOut) { + m_completionList->hide(); + } else if (obj == m_fileLineEdit && event->type() == QEvent::FocusIn) { + showPopup(); + } else if (obj == this && event->type() == QEvent::ShortcutOverride) { + QKeyEvent *ke = static_cast(event); + if (ke->key() == Qt::Key_Escape && !ke->modifiers()) { + event->accept(); + QTimer::singleShot(0, Core::ModeManager::instance(), SLOT(setFocusToCurrentMode())); + return true; + } + } + return QWidget::eventFilter(obj, event); +} + +void LocatorWidget::showCompletionList() +{ + const int border = m_completionList->frameWidth(); + const QSize size = m_completionList->preferredSize(); + const QRect rect(mapToGlobal(QPoint(-border, -size.height() - border)), size); + m_completionList->setGeometry(rect); + m_completionList->show(); +} + +void LocatorWidget::showPopup() +{ + updateCompletionList(m_fileLineEdit->typedText()); + showCompletionList(); +} + +QList LocatorWidget::filtersFor(const QString &text, QString &searchText) +{ + QList filters = m_locatorPlugin->filters(); + int whiteSpace = text.indexOf(" "); + QString prefix; + if (whiteSpace >= 0) + prefix = text.left(whiteSpace); + if (!prefix.isEmpty()) { + prefix = prefix.toLower(); + foreach (ILocatorFilter *filter, filters) { + if (prefix == filter->shortcutString()) { + searchText = text.mid(whiteSpace+1); + return QList() << filter; + } + } + } + searchText = text; + QList activeFilters; + foreach (ILocatorFilter *filter, filters) + if (filter->isIncludedByDefault()) + activeFilters << filter; + return activeFilters; +} + +void LocatorWidget::updateCompletionList(const QString &text) +{ + QString searchText; + const QList filters = filtersFor(text, searchText); + QSet alreadyAdded; + const bool checkDuplicates = (filters.size() > 1); + QList entries; + foreach (ILocatorFilter *filter, filters) { + foreach (const FilterEntry &entry, filter->matchesFor(searchText)) { + if (checkDuplicates && alreadyAdded.contains(entry)) + continue; + entries.append(entry); + if (checkDuplicates) + alreadyAdded.insert(entry); + } + } + m_locatorModel->setEntries(entries); + if (m_locatorModel->rowCount() > 0) { + m_completionList->setCurrentIndex(m_locatorModel->index(0, 0)); + } +#if 0 + m_completionList->updatePreferredSize(); +#endif +} + +void LocatorWidget::acceptCurrentEntry() +{ + if (!m_completionList->isVisible()) + return; + const QModelIndex index = m_completionList->currentIndex(); + if (!index.isValid()) + return; + const FilterEntry entry = m_locatorModel->data(index, Qt::UserRole).value(); + m_completionList->hide(); + entry.filter->accept(entry); +} + +void LocatorWidget::show(const QString &text, int selectionStart, int selectionLength) +{ + m_fileLineEdit->hideHintText(); + if (!text.isEmpty()) + m_fileLineEdit->setText(text); + if (!m_fileLineEdit->hasFocus()) + m_fileLineEdit->setFocus(); + else + showPopup(); + + if (selectionStart >= 0) { + m_fileLineEdit->setSelection(selectionStart, selectionLength); + if (selectionLength == 0) // make sure the cursor is at the right position (Mac-vs.-rest difference) + m_fileLineEdit->setCursorPosition(selectionStart); + } else { + m_fileLineEdit->selectAll(); + } +} + +void LocatorWidget::filterSelected() +{ + QString searchText = tr(""); + QAction *action = qobject_cast(sender()); + QTC_ASSERT(action, return); + ILocatorFilter *filter = action->data().value(); + 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 (ILocatorFilter *otherfilter, m_locatorPlugin->filters()) { + if (currentText.startsWith(otherfilter->shortcutString() + " ")) { + searchText = currentText.mid(otherfilter->shortcutString().length()+1); + break; + } + } + } + show(filter->shortcutString() + " " + searchText, + filter->shortcutString().length() + 1, + searchText.length()); + updateCompletionList(m_fileLineEdit->text()); + m_fileLineEdit->setFocus(); +} + +void LocatorWidget::showEvent(QShowEvent *event) +{ + QWidget::showEvent(event); +} + +void LocatorWidget::showConfigureDialog() +{ + Core::ICore::instance()->showOptionsDialog(Constants::LOCATOR_CATEGORY, + Constants::FILTER_OPTIONS_PAGE); +} diff --git a/src/plugins/locator/locatorwidget.h b/src/plugins/locator/locatorwidget.h new file mode 100644 index 0000000000..4fefd4cb12 --- /dev/null +++ b/src/plugins/locator/locatorwidget.h @@ -0,0 +1,97 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef LOCATORWIDGET_H +#define LOCATORWIDGET_H + +#include "locatorplugin.h" + +#include +#include + +QT_BEGIN_NAMESPACE +class QAction; +class QLabel; +class QLineEdit; +class QMenu; +class QTreeView; +QT_END_NAMESPACE + +namespace Utils { + class FancyLineEdit; +} + +namespace Locator { +namespace Internal { + +class LocatorModel; +class CompletionList; + +class LocatorWidget + : public QWidget +{ + Q_OBJECT + +public: + LocatorWidget(LocatorPlugin *qop); + + void updateFilterList(); + + void show(const QString &text, int selectionStart = -1, int selectionLength = 0); + +private slots: + void showPopup(); + void acceptCurrentEntry(); + void filterSelected(); + void showConfigureDialog(); + +private: + bool eventFilter(QObject *obj, QEvent *event); + + void showEvent(QShowEvent *e); + + bool isShowingTypeHereMessage() const; + void showCompletionList(); + void updateCompletionList(const QString &text); + QList filtersFor(const QString &text, QString &searchText); + + LocatorPlugin *m_locatorPlugin; + LocatorModel *m_locatorModel; + + CompletionList *m_completionList; + QMenu *m_filterMenu; + QAction *m_refreshAction; + QAction *m_configureAction; + Utils::FancyLineEdit *m_fileLineEdit; +}; + +} // namespace Internal +} // namespace Locator + +#endif // LOCATORWIDGET_H diff --git a/src/plugins/locator/opendocumentsfilter.cpp b/src/plugins/locator/opendocumentsfilter.cpp new file mode 100644 index 0000000000..a85da7fee9 --- /dev/null +++ b/src/plugins/locator/opendocumentsfilter.cpp @@ -0,0 +1,98 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "opendocumentsfilter.h" + +Q_DECLARE_METATYPE(Core::IEditor*); + +using namespace Core; +using namespace Locator; +using namespace Locator::Internal; + +OpenDocumentsFilter::OpenDocumentsFilter(EditorManager *editorManager) : + m_editorManager(editorManager) +{ + connect(m_editorManager, SIGNAL(editorOpened(Core::IEditor*)), + this, SLOT(refreshInternally())); + connect(m_editorManager, SIGNAL(editorsClosed(QList)), + this, SLOT(refreshInternally())); + setShortcutString("o"); + setIncludedByDefault(true); +} + +QList OpenDocumentsFilter::matchesFor(const QString &entry) +{ + QList value; + const QChar asterisk = QLatin1Char('*'); + QString pattern = QString(asterisk); + pattern += entry; + pattern += asterisk; + const QRegExp regexp(pattern, Qt::CaseInsensitive, QRegExp::Wildcard); + if (!regexp.isValid()) + return value; + foreach (IEditor *editor, m_editors) { + QString fileName = editor->file()->fileName(); + if (regexp.exactMatch(editor->displayName())) { + QString visibleName; + QVariant data; + if (fileName.isEmpty()) { + value.append(FilterEntry(this, editor->displayName(), qVariantFromValue(editor))); + } else { + QFileInfo fi(fileName); + FilterEntry entry(this, fi.fileName(), fileName); + entry.extraInfo = QDir::toNativeSeparators(fi.path()); + entry.resolveFileIcon = true; + value.append(entry); + } + } + } + return value; +} + +void OpenDocumentsFilter::refreshInternally() +{ + m_editors = m_editorManager->openedEditors(); +} + +void OpenDocumentsFilter::refresh(QFutureInterface &future) +{ + Q_UNUSED(future) + QMetaObject::invokeMethod(this, "refreshInternally", Qt::BlockingQueuedConnection); +} + +void OpenDocumentsFilter::accept(FilterEntry selection) const +{ + IEditor *editor = selection.internalData.value(); + if (editor) { + m_editorManager->activateEditor(editor); + return; + } + m_editorManager->openEditor(selection.internalData.toString()); + m_editorManager->ensureEditorManagerVisible(); +} diff --git a/src/plugins/locator/opendocumentsfilter.h b/src/plugins/locator/opendocumentsfilter.h new file mode 100644 index 0000000000..fc040971f7 --- /dev/null +++ b/src/plugins/locator/opendocumentsfilter.h @@ -0,0 +1,72 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef OPENDOCUMENTSFILTER_H +#define OPENDOCUMENTSFILTER_H + +#include "ilocatorfilter.h" + +#include +#include +#include +#include +#include + +#include +#include + +namespace Locator { +namespace Internal { + +class OpenDocumentsFilter : public Locator::ILocatorFilter +{ + Q_OBJECT + +public: + OpenDocumentsFilter(Core::EditorManager *editorManager); + QString trName() const { return tr("Open documents"); } + QString name() const { return "Open documents"; } + Locator::ILocatorFilter::Priority priority() const { return Locator::ILocatorFilter::Medium; } + QList matchesFor(const QString &entry); + void accept(Locator::FilterEntry selection) const; + void refresh(QFutureInterface &future); + +public slots: + void refreshInternally(); + +private: + Core::EditorManager *m_editorManager; + + QList m_editors; +}; + +} // namespace Internal +} // namespace Locator + +#endif // OPENDOCUMENTSFILTER_H diff --git a/src/plugins/locator/quickopen.cp b/src/plugins/locator/quickopen.cp new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/plugins/locator/quickopen.pri b/src/plugins/locator/quickopen.pri new file mode 100644 index 0000000000..a5645e529e --- /dev/null +++ b/src/plugins/locator/quickopen.pri @@ -0,0 +1,3 @@ +include(quickopen_dependencies.pri) + +LIBS *= -l$$qtLibraryTarget(QuickOpen) diff --git a/src/plugins/locator/quickopen_dependencies.pri b/src/plugins/locator/quickopen_dependencies.pri new file mode 100644 index 0000000000..96d71e68c8 --- /dev/null +++ b/src/plugins/locator/quickopen_dependencies.pri @@ -0,0 +1,2 @@ +include(../../libs/qtconcurrent/qtconcurrent.pri) +include(../../plugins/coreplugin/coreplugin.pri) diff --git a/src/plugins/locator/settingspage.cpp b/src/plugins/locator/settingspage.cpp new file mode 100644 index 0000000000..99453132fe --- /dev/null +++ b/src/plugins/locator/settingspage.cpp @@ -0,0 +1,222 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#include "settingspage.h" +#include "locatorconstants.h" + +#include "locatorplugin.h" +#include "ilocatorfilter.h" +#include "directoryfilter.h" + +#include +#include + +#include + +Q_DECLARE_METATYPE(Locator::ILocatorFilter*) + +using namespace Locator; +using namespace Locator::Internal; + +SettingsPage::SettingsPage(LocatorPlugin *plugin) + : m_plugin(plugin), m_page(0) +{ +} + +QString SettingsPage::id() const +{ + return QLatin1String(Constants::FILTER_OPTIONS_PAGE); +} + +QString SettingsPage::trName() const +{ + return QCoreApplication::translate("Locator", Locator::Constants::FILTER_OPTIONS_PAGE); +} + +QString SettingsPage::category() const +{ + return Constants::LOCATOR_CATEGORY; +} + +QString SettingsPage::trCategory() const +{ + return QCoreApplication::translate("Locator", Locator::Constants::LOCATOR_CATEGORY); +} + +QWidget *SettingsPage::createPage(QWidget *parent) +{ + + m_page = new QWidget(parent); + m_ui.setupUi(m_page); + connect(m_ui.filterList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), + this, SLOT(updateButtonStates())); + connect(m_ui.filterList, SIGNAL(itemActivated(QListWidgetItem *)), + this, SLOT(configureFilter(QListWidgetItem *))); + connect(m_ui.editButton, SIGNAL(clicked()), + this, SLOT(configureFilter())); + connect(m_ui.addButton, SIGNAL(clicked()), + this, SLOT(addCustomFilter())); + connect(m_ui.removeButton, SIGNAL(clicked()), + this, SLOT(removeCustomFilter())); + + m_ui.refreshInterval->setValue(m_plugin->refreshInterval()); + m_filters = m_plugin->filters(); + m_customFilters = m_plugin->customFilters(); + saveFilterStates(); + updateFilterList(); + return m_page; +} + +void SettingsPage::apply() +{ + // Delete removed filters and clear added filters + qDeleteAll(m_removedFilters); + m_removedFilters.clear(); + m_addedFilters.clear(); + + // Pass the new configuration on to the plugin + m_plugin->setFilters(m_filters); + m_plugin->setCustomFilters(m_customFilters); + m_plugin->setRefreshInterval(m_ui.refreshInterval->value()); + requestRefresh(); + m_plugin->saveSettings(); + saveFilterStates(); +} + +void SettingsPage::finish() +{ + // If settings were applied, this shouldn't change anything. Otherwise it + // makes sure the filter states aren't changed permanently. + restoreFilterStates(); + + // Delete added filters and clear removed filters + qDeleteAll(m_addedFilters); + m_addedFilters.clear(); + m_removedFilters.clear(); + + // Further cleanup + m_filters.clear(); + m_customFilters.clear(); + m_refreshFilters.clear(); +} + +void SettingsPage::requestRefresh() +{ + if (!m_refreshFilters.isEmpty()) + m_plugin->refresh(m_refreshFilters); +} + +void SettingsPage::saveFilterStates() +{ + m_filterStates.clear(); + foreach (ILocatorFilter *filter, m_filters) + m_filterStates.insert(filter, filter->saveState()); +} + +void SettingsPage::restoreFilterStates() +{ + foreach (ILocatorFilter *filter, m_filterStates.keys()) + filter->restoreState(m_filterStates.value(filter)); +} + +void SettingsPage::updateFilterList() +{ + m_ui.filterList->clear(); + foreach (ILocatorFilter *filter, m_filters) { + if (filter->isHidden()) + continue; + + QString title; + if (filter->isIncludedByDefault()) + title = filter->trName(); + else + title = tr("%1 (Prefix: %2)").arg(filter->trName()).arg(filter->shortcutString()); + QListWidgetItem *item = new QListWidgetItem(title); + item->setData(Qt::UserRole, qVariantFromValue(filter)); + m_ui.filterList->addItem(item); + } + if (m_ui.filterList->count() > 0) + m_ui.filterList->setCurrentRow(0); +} + +void SettingsPage::updateButtonStates() +{ + QListWidgetItem *item = m_ui.filterList->currentItem(); + ILocatorFilter *filter = (item ? item->data(Qt::UserRole).value() : 0); + m_ui.editButton->setEnabled(filter && filter->isConfigurable()); + m_ui.removeButton->setEnabled(filter && m_customFilters.contains(filter)); +} + +void SettingsPage::configureFilter(QListWidgetItem *item) +{ + if (!item) + item = m_ui.filterList->currentItem(); + QTC_ASSERT(item, return); + ILocatorFilter *filter = item->data(Qt::UserRole).value(); + QTC_ASSERT(filter, return); + + if (!filter->isConfigurable()) + return; + bool needsRefresh = false; + filter->openConfigDialog(m_page, needsRefresh); + if (needsRefresh && !m_refreshFilters.contains(filter)) + m_refreshFilters.append(filter); + updateFilterList(); +} + +void SettingsPage::addCustomFilter() +{ + ILocatorFilter *filter = new DirectoryFilter; + bool needsRefresh = false; + if (filter->openConfigDialog(m_page, needsRefresh)) { + m_filters.append(filter); + m_addedFilters.append(filter); + m_customFilters.append(filter); + m_refreshFilters.append(filter); + updateFilterList(); + } +} + +void SettingsPage::removeCustomFilter() +{ + QListWidgetItem *item = m_ui.filterList->currentItem(); + QTC_ASSERT(item, return); + ILocatorFilter *filter = item->data(Qt::UserRole).value(); + QTC_ASSERT(m_customFilters.contains(filter), return); + m_filters.removeAll(filter); + m_customFilters.removeAll(filter); + m_refreshFilters.removeAll(filter); + if (m_addedFilters.contains(filter)) { + m_addedFilters.removeAll(filter); + delete filter; + } else { + m_removedFilters.append(filter); + } + updateFilterList(); +} diff --git a/src/plugins/locator/settingspage.h b/src/plugins/locator/settingspage.h new file mode 100644 index 0000000000..1fb55661e0 --- /dev/null +++ b/src/plugins/locator/settingspage.h @@ -0,0 +1,93 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** Commercial Usage +** +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** +**************************************************************************/ + +#ifndef SETTINGSPAGE_H +#define SETTINGSPAGE_H + +#include "ui_settingspage.h" + +#include +#include + +#include + +QT_BEGIN_NAMESPACE +class QListWidgetItem; +QT_END_NAMESPACE + +namespace Locator { + +class ILocatorFilter; + +namespace Internal { + +class LocatorPlugin; + +class SettingsPage : public Core::IOptionsPage +{ + Q_OBJECT + +public: + explicit SettingsPage(LocatorPlugin *plugin); + QString id() const; + QString trName() const; + QString category() const; + QString trCategory() const; + + QWidget *createPage(QWidget *parent); + void apply(); + void finish(); + +private slots: + void updateButtonStates(); + void configureFilter(QListWidgetItem *item = 0); + void addCustomFilter(); + void removeCustomFilter(); + +private: + void updateFilterList(); + void saveFilterStates(); + void restoreFilterStates(); + void requestRefresh(); + + Ui::SettingsWidget m_ui; + LocatorPlugin *m_plugin; + QWidget* m_page; + QList m_filters; + QList m_addedFilters; + QList m_removedFilters; + QList m_customFilters; + QList m_refreshFilters; + QHash m_filterStates; +}; + +} // namespace Internal +} // namespace Locator + +#endif // SETTINGSPAGE_H diff --git a/src/plugins/locator/settingspage.ui b/src/plugins/locator/settingspage.ui new file mode 100644 index 0000000000..f2f055c57b --- /dev/null +++ b/src/plugins/locator/settingspage.ui @@ -0,0 +1,127 @@ + + + Locator::Internal::SettingsWidget + + + + 0 + 0 + 460 + 353 + + + + Configure Filters + + + + + + Configure Filters + + + + + + + + + + + + + + + Add + + + + + + + false + + + Remove + + + + + + + false + + + Edit + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + Refresh Interval: + + + + + + + true + + + QAbstractSpinBox::PlusMinus + + + min + + + 320 + + + 5 + + + 60 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + diff --git a/src/plugins/locator/settingswidget.ui b/src/plugins/locator/settingswidget.ui new file mode 100644 index 0000000000..03653fe6a0 --- /dev/null +++ b/src/plugins/locator/settingswidget.ui @@ -0,0 +1,133 @@ + + QuickOpen::Internal::SettingsDialog + + + + 0 + 0 + 460 + 353 + + + + Configure Filters + + + + + + + + + + + + + + + false + + + Add + + + + + + + false + + + Remove + + + + + + + false + + + Edit... + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Refresh Interval: + + + + + + + true + + + QAbstractSpinBox::PlusMinus + + + min + + + 320 + + + 5 + + + 60 + + + + + + + + + + Refresh now! + + + Qt::ToolButtonTextBesideIcon + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 44c0ddd032..c74bda15a2 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -19,7 +19,7 @@ SUBDIRS = plugin_coreplugin \ plugin_cpptools \ plugin_qt4projectmanager \ # plugin_snippets \ # buggy and annoying - plugin_quickopen \ + plugin_locator \ plugin_debugger \ # plugin_qtestlib \ # this seems to be dead # plugin_helloworld \ # sample plugin @@ -46,7 +46,7 @@ plugin_find.depends += plugin_coreplugin plugin_texteditor.subdir = texteditor plugin_texteditor.depends = plugin_find -plugin_texteditor.depends += plugin_quickopen +plugin_texteditor.depends += plugin_locator plugin_texteditor.depends += plugin_coreplugin plugin_cppeditor.subdir = cppeditor @@ -88,7 +88,7 @@ plugin_subversion.depends += plugin_projectexplorer plugin_subversion.depends += plugin_coreplugin plugin_projectexplorer.subdir = projectexplorer -plugin_projectexplorer.depends = plugin_quickopen +plugin_projectexplorer.depends = plugin_locator plugin_projectexplorer.depends += plugin_find plugin_projectexplorer.depends += plugin_coreplugin plugin_projectexplorer.depends += plugin_texteditor @@ -102,8 +102,8 @@ plugin_qt4projectmanager.depends += plugin_help plugin_qt4projectmanager.depends += plugin_designer plugin_qt4projectmanager.depends += plugin_debugger -plugin_quickopen.subdir = quickopen -plugin_quickopen.depends = plugin_coreplugin +plugin_locator.subdir = locator +plugin_locator.depends = plugin_coreplugin plugin_cpptools.subdir = cpptools plugin_cpptools.depends = plugin_projectexplorer @@ -139,7 +139,7 @@ plugin_helloworld.depends = plugin_coreplugin plugin_help.subdir = help plugin_help.depends = plugin_find -plugin_help.depends += plugin_quickopen +plugin_help.depends += plugin_locator plugin_help.depends += plugin_coreplugin plugin_resourceeditor.subdir = resourceeditor diff --git a/src/plugins/projectexplorer/allprojectsfilter.h b/src/plugins/projectexplorer/allprojectsfilter.h index 71b948b6f0..9d2455e560 100644 --- a/src/plugins/projectexplorer/allprojectsfilter.h +++ b/src/plugins/projectexplorer/allprojectsfilter.h @@ -30,7 +30,7 @@ #ifndef ALLPROJECTSFILTER_H #define ALLPROJECTSFILTER_H -#include +#include #include #include diff --git a/src/plugins/projectexplorer/currentprojectfilter.h b/src/plugins/projectexplorer/currentprojectfilter.h index 1d9d3fcee0..aefc8f5818 100644 --- a/src/plugins/projectexplorer/currentprojectfilter.h +++ b/src/plugins/projectexplorer/currentprojectfilter.h @@ -30,7 +30,7 @@ #ifndef CURRENTPROJECTFILTER_H #define CURRENTPROJECTFILTER_H -#include +#include #include #include diff --git a/src/plugins/projectexplorer/projectexplorer_dependencies.pri b/src/plugins/projectexplorer/projectexplorer_dependencies.pri index 674c8bbb36..99d163d6f1 100644 --- a/src/plugins/projectexplorer/projectexplorer_dependencies.pri +++ b/src/plugins/projectexplorer/projectexplorer_dependencies.pri @@ -1,5 +1,5 @@ include(../../libs/utils/utils.pri) -include(../../plugins/quickopen/quickopen.pri) +include(../../plugins/locator/quickopen.pri) include(../../plugins/find/find.pri) include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/texteditor/texteditor.pri) diff --git a/src/plugins/quickopen/QuickOpen.pluginspec b/src/plugins/quickopen/QuickOpen.pluginspec deleted file mode 100644 index d9a45e89ba..0000000000 --- a/src/plugins/quickopen/QuickOpen.pluginspec +++ /dev/null @@ -1,24 +0,0 @@ - - Nokia Corporation - (C) 2008-2009 Nokia Corporation - -Commercial Usage - -Licensees holding valid Qt Commercial licenses may use this plugin in -accordance with the Qt Commercial License Agreement provided with the -Software or, alternatively, in accordance with the terms contained in -a written agreement between you and Nokia. - -GNU Lesser General Public License Usage - -Alternatively, this plugin may be used under the terms of the GNU Lesser -General Public License version 2.1 as published by the Free Software -Foundation. Please review the following information to -ensure the GNU Lesser General Public License version 2.1 requirements -will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. - Provides the Locator widget and the hooks for QuickOpen filter implementations. - http://qt.nokia.com - - - - diff --git a/src/plugins/quickopen/basefilefilter.cpp b/src/plugins/quickopen/basefilefilter.cpp deleted file mode 100644 index ed5e02f76a..0000000000 --- a/src/plugins/quickopen/basefilefilter.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "basefilefilter.h" - -#include - -#include -#include - -using namespace Core; -using namespace Locator; - -BaseFileFilter::BaseFileFilter() - : m_forceNewSearchList(false) -{ -} - -QList BaseFileFilter::matchesFor(const QString &origEntry) -{ - updateFiles(); - QList matches; - QList badMatches; - QString needle = trimWildcards(origEntry); - QStringMatcher matcher(needle, Qt::CaseInsensitive); - const QRegExp regexp("*"+needle+"*", Qt::CaseInsensitive, QRegExp::Wildcard); - if (!regexp.isValid()) - return matches; - bool hasWildcard = (needle.contains('*') || needle.contains('?')); - QStringList searchListPaths; - QStringList searchListNames; - if (!m_previousEntry.isEmpty() && !m_forceNewSearchList && needle.contains(m_previousEntry)) { - searchListPaths = m_previousResultPaths; - searchListNames = m_previousResultNames; - } else { - searchListPaths = m_files; - searchListNames = m_fileNames; - } - m_previousResultPaths.clear(); - m_previousResultNames.clear(); - m_forceNewSearchList = false; - m_previousEntry = needle; - QStringListIterator paths(searchListPaths); - QStringListIterator names(searchListNames); - while (paths.hasNext() && names.hasNext()) { - QString path = paths.next(); - QString name = names.next(); - if ((hasWildcard && regexp.exactMatch(name)) - || (!hasWildcard && matcher.indexIn(name) != -1)) { - QFileInfo fi(path); - FilterEntry entry(this, fi.fileName(), path); - entry.extraInfo = QDir::toNativeSeparators(fi.path()); - entry.resolveFileIcon = true; - if (name.startsWith(needle)) - matches.append(entry); - else - badMatches.append(entry); - m_previousResultPaths.append(path); - m_previousResultNames.append(name); - } - } - - matches.append(badMatches); - return matches; -} - -void BaseFileFilter::accept(Locator::FilterEntry selection) const -{ - Core::EditorManager *em = Core::EditorManager::instance(); - em->openEditor(selection.internalData.toString()); - em->ensureEditorManagerVisible(); -} - -void BaseFileFilter::generateFileNames() -{ - m_fileNames.clear(); - foreach (const QString &fileName, m_files) { - QFileInfo fi(fileName); - m_fileNames.append(fi.fileName()); - } - m_forceNewSearchList = true; -} - -void BaseFileFilter::updateFiles() -{ -} diff --git a/src/plugins/quickopen/basefilefilter.h b/src/plugins/quickopen/basefilefilter.h deleted file mode 100644 index ee2e4248c9..0000000000 --- a/src/plugins/quickopen/basefilefilter.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef BASEFILEFILTER_H -#define BASEFILEFILTER_H - -#include "locator_global.h" -#include "ilocatorfilter.h" - -#include -#include - -namespace Locator { - -class LOCATOR_EXPORT BaseFileFilter : public Locator::ILocatorFilter -{ - Q_OBJECT - -public: - BaseFileFilter(); - QList matchesFor(const QString &entry); - void accept(Locator::FilterEntry selection) const; - -protected: - virtual void updateFiles(); - void generateFileNames(); - - QStringList m_files; - QStringList m_fileNames; - QStringList m_previousResultPaths; - QStringList m_previousResultNames; - bool m_forceNewSearchList; - QString m_previousEntry; -}; - -} // namespace Locator - -#endif // BASEFILEFILTER_H diff --git a/src/plugins/quickopen/directoryfilter.cpp b/src/plugins/quickopen/directoryfilter.cpp deleted file mode 100644 index 983b51c92e..0000000000 --- a/src/plugins/quickopen/directoryfilter.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "directoryfilter.h" - -#include -#include -#include -#include -#include - -#include - -using namespace Locator; -using namespace Locator::Internal; - -DirectoryFilter::DirectoryFilter() - : m_name(tr("Generic Directory Filter")), - m_filters(QStringList() << QLatin1String("*.h") << QLatin1String("*.cpp") - << QLatin1String("*.ui") << QLatin1String("*.qrc")) -{ - setIncludedByDefault(true); -} - -QByteArray DirectoryFilter::saveState() const -{ - QMutexLocker locker(&m_lock); - QByteArray value; - QDataStream out(&value, QIODevice::WriteOnly); - out << m_name; - out << m_directories; - out << m_filters; - out << shortcutString(); - out << isIncludedByDefault(); - out << m_files; - return value; -} - -bool DirectoryFilter::restoreState(const QByteArray &state) -{ - QMutexLocker locker(&m_lock); - - QStringList dirEntries; - QString shortcut; - bool defaultFilter; - - QDataStream in(state); - in >> m_name; - in >> dirEntries; - in >> m_filters; - in >> shortcut; - in >> defaultFilter; - in >> m_files; - - setShortcutString(shortcut); - setIncludedByDefault(defaultFilter); - - // ### TODO throw that out again: - // clear the list of directories of empty entries (which might at least happen at a format change) - m_directories.clear(); - foreach (const QString &dir, dirEntries) { - if (dir.isEmpty()) - continue; - m_directories.append(dir); - } - - generateFileNames(); - return true; -} - -bool DirectoryFilter::openConfigDialog(QWidget *parent, bool &needsRefresh) -{ - bool success = false; - QDialog dialog(parent); - m_dialog = &dialog; - m_ui.setupUi(&dialog); - dialog.setWindowTitle(tr("Filter Configuration")); - connect(m_ui.addButton, SIGNAL(clicked()), - this, SLOT(addDirectory()), Qt::DirectConnection); - connect(m_ui.editButton, SIGNAL(clicked()), - this, SLOT(editDirectory()), Qt::DirectConnection); - connect(m_ui.removeButton, SIGNAL(clicked()), - this, SLOT(removeDirectory()), Qt::DirectConnection); - connect(m_ui.directoryList, SIGNAL(itemSelectionChanged()), - this, SLOT(updateOptionButtons()), Qt::DirectConnection); - m_ui.nameEdit->setText(m_name); - m_ui.nameEdit->selectAll(); - m_ui.directoryList->clear(); - m_ui.directoryList->addItems(m_directories); - m_ui.fileTypeEdit->setText(m_filters.join(QString(QLatin1Char(',')))); - m_ui.shortcutEdit->setText(shortcutString()); - m_ui.defaultFlag->setChecked(!isIncludedByDefault()); - updateOptionButtons(); - if (dialog.exec() == QDialog::Accepted) { - QMutexLocker locker(&m_lock); - bool directoriesChanged = false; - QStringList oldDirectories = m_directories; - QStringList oldFilters = m_filters; - m_name = m_ui.nameEdit->text().trimmed(); - m_directories.clear(); - int oldCount = oldDirectories.count(); - int newCount = m_ui.directoryList->count(); - if (oldCount != newCount) - directoriesChanged = true; - for (int i = 0; i < newCount; ++i) { - m_directories.append(m_ui.directoryList->item(i)->text()); - if (!directoriesChanged && m_directories.at(i) != oldDirectories.at(i)) - directoriesChanged = true; - } - m_filters = m_ui.fileTypeEdit->text().trimmed().split(QLatin1Char(',')); - setShortcutString(m_ui.shortcutEdit->text().trimmed()); - setIncludedByDefault(!m_ui.defaultFlag->isChecked()); - if (directoriesChanged || oldFilters != m_filters) - needsRefresh = true; - success = true; - } - return success; -} - -void DirectoryFilter::addDirectory() -{ - QString dir = QFileDialog::getExistingDirectory(m_dialog, tr("Choose a directory to add")); - if (!dir.isEmpty()) { - m_ui.directoryList->addItem(dir); - } -} - -void DirectoryFilter::editDirectory() -{ - if (m_ui.directoryList->selectedItems().count() < 1) - return; - QListWidgetItem *currentItem = m_ui.directoryList->selectedItems().at(0); - QString dir = QFileDialog::getExistingDirectory(m_dialog, tr("Choose a directory to add"), - currentItem->text()); - if (!dir.isEmpty()) { - currentItem->setText(dir); - } -} - -void DirectoryFilter::removeDirectory() -{ - if (m_ui.directoryList->selectedItems().count() < 1) - return; - QListWidgetItem *currentItem = m_ui.directoryList->selectedItems().at(0); - delete m_ui.directoryList->takeItem(m_ui.directoryList->row(currentItem)); -} - -void DirectoryFilter::updateOptionButtons() -{ - bool haveSelectedItem = (m_ui.directoryList->selectedItems().count() > 0); - m_ui.editButton->setEnabled(haveSelectedItem); - m_ui.removeButton->setEnabled(haveSelectedItem); -} - -void DirectoryFilter::refresh(QFutureInterface &future) -{ - const int MAX = 360; - future.setProgressRange(0, MAX); - if (m_directories.count() < 1) { - QMutexLocker locker(&m_lock); - m_files.clear(); - generateFileNames(); - future.setProgressValueAndText(MAX, tr("%1 filter update: 0 files").arg(m_name)); - return; - } - int progress = 0; - int MAX_PER = MAX; - QStringList files; - QStack dirs; - QStack progressValues; - QStack processedValues; - { // initialize - QMutexLocker locker(&m_lock); - MAX_PER = MAX/m_directories.count(); - foreach (const QString &directoryEntry, m_directories) { - if (!directoryEntry.isEmpty()) { - dirs.push(QDir(directoryEntry)); - progressValues.push(MAX_PER); - processedValues.push(false); - } - } - } - while (!dirs.isEmpty() && !future.isCanceled()) { - if (future.isProgressUpdateNeeded()) { - future.setProgressValueAndText(progress, - tr("%1 filter update: %n files", 0, files.size()).arg(m_name)); - } - QDir dir = dirs.pop(); - int dirProgressMax = progressValues.pop(); - bool processed = processedValues.pop(); - if (dir.exists()) { - QStringList subDirs; - if (!processed) { - subDirs = dir.entryList(QDir::Dirs|QDir::Hidden|QDir::NoDotAndDotDot, - QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); - } - if (subDirs.isEmpty()) { - QStringList fileEntries = dir.entryList(m_filters, - QDir::Files|QDir::Hidden, - QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); - foreach (const QString &file, fileEntries) - files.append(dir.path()+"/"+file); - progress += dirProgressMax; - } else { - int subProgress = dirProgressMax/(subDirs.size()+1); - int selfProgress = subProgress + dirProgressMax%(subDirs.size()+1); - dirs.push(dir); - progressValues.push(selfProgress); - processedValues.push(true); - foreach (const QString &directory, subDirs) { - dirs.push(QDir(dir.path()+"/"+directory)); - progressValues.push(subProgress); - processedValues.push(false); - } - } - } else { - progress += dirProgressMax; - } - } - - if (!future.isCanceled()) { - QMutexLocker locker(&m_lock); - m_files = files; - generateFileNames(); - future.setProgressValue(MAX); - } else { - future.setProgressValueAndText(progress, tr("%1 filter update: canceled").arg(m_name)); - } -} diff --git a/src/plugins/quickopen/directoryfilter.h b/src/plugins/quickopen/directoryfilter.h deleted file mode 100644 index 2140a18d1f..0000000000 --- a/src/plugins/quickopen/directoryfilter.h +++ /dev/null @@ -1,81 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef DIRECTORYFILTER_H -#define DIRECTORYFILTER_H - -#include "ui_directoryfilter.h" -#include "basefilefilter.h" - -#include -#include -#include -#include -#include -#include -#include - -namespace Locator { -namespace Internal { - -class DirectoryFilter : public BaseFileFilter -{ - Q_OBJECT - -public: - DirectoryFilter(); - QString trName() const { return m_name; } - QString name() const { return m_name; } - Locator::ILocatorFilter::Priority priority() const { return Locator::ILocatorFilter::Medium; } - QByteArray saveState() const; - bool restoreState(const QByteArray &state); - bool openConfigDialog(QWidget *parent, bool &needsRefresh); - void refresh(QFutureInterface &future); - -private slots: - void addDirectory(); - void editDirectory(); - void removeDirectory(); - void updateOptionButtons(); - -private: - QString m_name; - QStringList m_directories; - QStringList m_filters; - // Our config dialog, uses in addDirectory and editDirectory - // to give their dialogs the right parent - QDialog *m_dialog; - Ui::DirectoryFilterOptions m_ui; - mutable QMutex m_lock; -}; - -} // namespace Internal -} // namespace Locator - -#endif // DIRECTORYFILTER_H diff --git a/src/plugins/quickopen/directoryfilter.ui b/src/plugins/quickopen/directoryfilter.ui deleted file mode 100644 index 8b8ddfe59a..0000000000 --- a/src/plugins/quickopen/directoryfilter.ui +++ /dev/null @@ -1,194 +0,0 @@ - - - Locator::Internal::DirectoryFilterOptions - - - - 0 - 0 - 393 - 275 - - - - - - - - - Name: - - - - - - - - - - File Types: - - - - - - - Specify file name filters, separated by comma. Filters may contain wildcards. - - - - - - - Prefix: - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Specify a short word/abbreviation that can be used to restrict completions to files from this directory tree. -To do this, you type this shortcut and a space in the Locator entry field, and then the word to search for. - - - - - - - - 2 - 0 - - - - Limit to prefix - - - false - - - - - - - - - Add... - - - - - - - Edit... - - - - - - - Remove - - - - - - - - - - - Directories: - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - Qt::Vertical - - - - 369 - 31 - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - Locator::Internal::DirectoryFilterOptions - accept() - - - 353 - 174 - - - 390 - 152 - - - - - buttonBox - rejected() - Locator::Internal::DirectoryFilterOptions - reject() - - - 280 - 176 - - - 391 - 141 - - - - - diff --git a/src/plugins/quickopen/directoryparser.cpp b/src/plugins/quickopen/directoryparser.cpp deleted file mode 100644 index 6bd8f431d5..0000000000 --- a/src/plugins/quickopen/directoryparser.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "directoryparser.h" -#include "quickopenplugin.h" - -using namespace QuickOpen::Internal; - -DirectoryParser::DirectoryParser(QObject *parent) - : QThread(parent) -{ -} - -DirectoryParser::~DirectoryParser() -{ - if (isRunning()) - terminate(); -} - -void DirectoryParser::parse(Filter filter) -{ - m_dirs = filter.directories(); - m_filters = filter.acceptedFileExtensions().split(';'); - m_blackList.clear(); - foreach (QString s, filter.skipDirectories()) { - if (!s.trimmed().isEmpty() && !m_blackList.contains(s)) - m_blackList.insert(s); - } - if (!isRunning()) - start(QThread::NormalPriority); -} - -void DirectoryParser::setDirectoryNameBlackList(const QStringList &lst) -{ - m_blackList.clear(); - foreach (QString s, lst) { - if (!m_blackList.contains(s)) - m_blackList.insert(s); - } -} - -QSet DirectoryParser::files() const -{ - return m_files; -} - -void DirectoryParser::run() -{ - m_files.clear(); - m_runFiles.clear(); - foreach (QString s, m_dirs) { - if (s.isEmpty()) - continue; - QDir dir(s); - if (dir.exists()) { - m_runFilters = m_filters; - m_runBlackList = m_blackList; - collectFiles(dir); - } - } - m_files = m_runFiles; - emit directoriesParsed(); -} - -void DirectoryParser::collectFiles(const QDir &dir) -{ - QString dirName = dir.absolutePath() + QLatin1String("/"); - foreach (QString f, dir.entryList(m_runFilters, QDir::Files)) { - m_runFiles.insert(dirName + f); - } - foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { - if (!m_runBlackList.contains(d)) - collectFiles(dir.absolutePath() + QDir::separator() + d); - } -} diff --git a/src/plugins/quickopen/directoryparser.h b/src/plugins/quickopen/directoryparser.h deleted file mode 100644 index 35618f33e3..0000000000 --- a/src/plugins/quickopen/directoryparser.h +++ /dev/null @@ -1,74 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef DIRECTORYPARSER_H -#define DIRECTORYPARSER_H - -#include -#include -#include - -namespace QuickOpen { -namespace Internal { - -class Filter; - -class DirectoryParser : public QThread -{ - Q_OBJECT - -public: - DirectoryParser(QObject *parent); - ~DirectoryParser(); - void parse(Filter filter); - - void setDirectoryNameBlackList(const QStringList &lst); - QSet files() const; - -signals: - void directoriesParsed(); - -private: - void run(); - void collectFiles(const QDir &dir); - - QStringList m_dirs; - QSet m_files; - - QSet m_runFiles; - QStringList m_filters; - QStringList m_runFilters; - QSet m_blackList; - QSet m_runBlackList; -}; - -} // namespace Internal -} // namespace QuickOpen - -#endif // DIRECTORYPARSER_H diff --git a/src/plugins/quickopen/filesystemfilter.cpp b/src/plugins/quickopen/filesystemfilter.cpp deleted file mode 100644 index 99506b0760..0000000000 --- a/src/plugins/quickopen/filesystemfilter.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "filesystemfilter.h" -#include "locatorwidget.h" -#include - -#include - -using namespace Core; -using namespace Locator; -using namespace Locator::Internal; - -FileSystemFilter::FileSystemFilter(EditorManager *editorManager, LocatorWidget *locatorWidget) - : m_editorManager(editorManager), m_locatorWidget(locatorWidget), m_includeHidden(true) -{ - setShortcutString("f"); - setIncludedByDefault(false); -} - -QList FileSystemFilter::matchesFor(const QString &entry) -{ - QList value; - QFileInfo entryInfo(entry); - QString name = entryInfo.fileName(); - QString directory = entryInfo.path(); - QString filePath = entryInfo.filePath(); - if (entryInfo.isRelative()) { - if (filePath.startsWith("~/")) { - directory.replace(0, 1, QDir::homePath()); - } else { - IEditor *editor = m_editorManager->currentEditor(); - if (editor && !editor->file()->fileName().isEmpty()) { - QFileInfo info(editor->file()->fileName()); - directory.prepend(info.absolutePath()+"/"); - } - } - } - QDir dirInfo(directory); - QDir::Filters dirFilter = QDir::Dirs|QDir::Drives; - QDir::Filters fileFilter = QDir::Files; - if (m_includeHidden) { - dirFilter |= QDir::Hidden; - fileFilter |= QDir::Hidden; - } - QStringList dirs = dirInfo.entryList(dirFilter, - QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); - QStringList files = dirInfo.entryList(fileFilter, - QDir::Name|QDir::IgnoreCase|QDir::LocaleAware); - foreach (const QString &dir, dirs) { - if (dir != "." && (name.isEmpty() || dir.startsWith(name, Qt::CaseInsensitive))) { - FilterEntry entry(this, dir, dirInfo.filePath(dir)); - entry.resolveFileIcon = true; - value.append(entry); - } - } - foreach (const QString &file, files) { - if (name.isEmpty() || file.startsWith(name, Qt::CaseInsensitive)) { - const QString fullPath = dirInfo.filePath(file); - FilterEntry entry(this, file, fullPath); - entry.resolveFileIcon = true; - value.append(entry); - } - } - return value; -} - -void FileSystemFilter::accept(FilterEntry selection) const -{ - QFileInfo info(selection.internalData.toString()); - if (info.isDir()) { - QString value = shortcutString() + " " + QDir::toNativeSeparators(info.absoluteFilePath()+"/"); - m_locatorWidget->show(value, value.length()); - return; - } - m_editorManager->openEditor(selection.internalData.toString()); - m_editorManager->ensureEditorManagerVisible(); -} - -bool FileSystemFilter::openConfigDialog(QWidget *parent, bool &needsRefresh) -{ - Q_UNUSED(needsRefresh) - Ui::FileSystemFilterOptions ui; - QDialog dialog(parent); - ui.setupUi(&dialog); - - ui.hiddenFilesFlag->setChecked(m_includeHidden); - ui.limitCheck->setChecked(!isIncludedByDefault()); - ui.shortcutEdit->setText(shortcutString()); - - if (dialog.exec() == QDialog::Accepted) { - m_includeHidden = ui.hiddenFilesFlag->isChecked(); - setShortcutString(ui.shortcutEdit->text().trimmed()); - setIncludedByDefault(!ui.limitCheck->isChecked()); - return true; - } - return false; -} - -QByteArray FileSystemFilter::saveState() const -{ - QByteArray value; - QDataStream out(&value, QIODevice::WriteOnly); - out << m_includeHidden; - out << shortcutString(); - out << isIncludedByDefault(); - return value; -} - -bool FileSystemFilter::restoreState(const QByteArray &state) -{ - QDataStream in(state); - in >> m_includeHidden; - - // An attempt to prevent setting this on old configuration - if (!in.atEnd()) { - QString shortcut; - bool defaultFilter; - in >> shortcut; - in >> defaultFilter; - setShortcutString(shortcut); - setIncludedByDefault(defaultFilter); - } - - return true; -} diff --git a/src/plugins/quickopen/filesystemfilter.h b/src/plugins/quickopen/filesystemfilter.h deleted file mode 100644 index 319637192a..0000000000 --- a/src/plugins/quickopen/filesystemfilter.h +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef FILESYSTEMFILTER_H -#define FILESYSTEMFILTER_H - -#include "ilocatorfilter.h" -#include "ui_filesystemfilter.h" - -#include - -#include -#include -#include -#include - -namespace Locator { -namespace Internal { - -class LocatorWidget; - -class FileSystemFilter : public Locator::ILocatorFilter -{ - Q_OBJECT - -public: - FileSystemFilter(Core::EditorManager *editorManager, LocatorWidget *locatorWidget); - QString trName() const { return tr("Files in file system"); } - QString name() const { return "Files in file system"; } - Locator::ILocatorFilter::Priority priority() const { return Locator::ILocatorFilter::Medium; } - QList matchesFor(const QString &entry); - void accept(Locator::FilterEntry selection) const; - QByteArray saveState() const; - bool restoreState(const QByteArray &state); - bool openConfigDialog(QWidget *parent, bool &needsRefresh); - void refresh(QFutureInterface &) {} - -private: - Core::EditorManager *m_editorManager; - LocatorWidget *m_locatorWidget; - bool m_includeHidden; -}; - -} // namespace Internal -} // namespace Locator - -#endif // FILESYSTEMFILTER_H diff --git a/src/plugins/quickopen/filesystemfilter.ui b/src/plugins/quickopen/filesystemfilter.ui deleted file mode 100644 index 0c56a86032..0000000000 --- a/src/plugins/quickopen/filesystemfilter.ui +++ /dev/null @@ -1,111 +0,0 @@ - - - Locator::Internal::FileSystemFilterOptions - - - - 0 - 0 - 335 - 131 - - - - Filter configuration - - - - - - Prefix: - - - shortcutEdit - - - - - - - - - - Limit to prefix - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - Qt::Vertical - - - - 20 - 20 - - - - - - - - Include hidden files - - - - - - - Filter: - - - - - - - - - buttonBox - accepted() - Locator::Internal::FileSystemFilterOptions - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Locator::Internal::FileSystemFilterOptions - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/plugins/quickopen/ilocatorfilter.cpp b/src/plugins/quickopen/ilocatorfilter.cpp deleted file mode 100644 index fb9c682eac..0000000000 --- a/src/plugins/quickopen/ilocatorfilter.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "ilocatorfilter.h" - -#include -#include -#include -#include -#include -#include - -using namespace Locator; - -ILocatorFilter::ILocatorFilter(QObject *parent): - QObject(parent), - m_includedByDefault(false), - m_hidden(false) -{ -} - -QString ILocatorFilter::shortcutString() const -{ - return m_shortcut; -} - -void ILocatorFilter::setShortcutString(const QString &shortcut) -{ - m_shortcut = shortcut; -} - -QByteArray ILocatorFilter::saveState() const -{ - QByteArray value; - QDataStream out(&value, QIODevice::WriteOnly); - out << shortcutString(); - out << isIncludedByDefault(); - return value; -} - -bool ILocatorFilter::restoreState(const QByteArray &state) -{ - QString shortcut; - bool defaultFilter; - - QDataStream in(state); - in >> shortcut; - in >> defaultFilter; - - setShortcutString(shortcut); - setIncludedByDefault(defaultFilter); - return true; -} - -bool ILocatorFilter::openConfigDialog(QWidget *parent, bool &needsRefresh) -{ - Q_UNUSED(needsRefresh) - - QDialog dialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint); - dialog.setWindowTitle(tr("Filter Configuration")); - - QVBoxLayout *vlayout = new QVBoxLayout(&dialog); - QHBoxLayout *hlayout = new QHBoxLayout; - QLineEdit *shortcutEdit = new QLineEdit(shortcutString()); - QCheckBox *limitCheck = new QCheckBox(tr("Limit to prefix")); - limitCheck->setChecked(!isIncludedByDefault()); - - hlayout->addWidget(new QLabel(tr("Prefix:"))); - hlayout->addWidget(shortcutEdit); - hlayout->addWidget(limitCheck); - - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | - QDialogButtonBox::Cancel); - connect(buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject())); - - vlayout->addLayout(hlayout); - vlayout->addStretch(); - vlayout->addWidget(buttonBox); - - if (dialog.exec() == QDialog::Accepted) { - setShortcutString(shortcutEdit->text().trimmed()); - setIncludedByDefault(!limitCheck->isChecked()); - return true; - } - - return false; -} - -bool ILocatorFilter::isConfigurable() const -{ - return true; -} - -bool ILocatorFilter::isIncludedByDefault() const -{ - return m_includedByDefault; -} - -void ILocatorFilter::setIncludedByDefault(bool includedByDefault) -{ - m_includedByDefault = includedByDefault; -} - -bool ILocatorFilter::isHidden() const -{ - return m_hidden; -} - -void ILocatorFilter::setHidden(bool hidden) -{ - m_hidden = hidden; -} diff --git a/src/plugins/quickopen/ilocatorfilter.h b/src/plugins/quickopen/ilocatorfilter.h deleted file mode 100644 index 4957eecd05..0000000000 --- a/src/plugins/quickopen/ilocatorfilter.h +++ /dev/null @@ -1,156 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef ILOCATORFILTER_H -#define ILOCATORFILTER_H - -#include "locator_global.h" - -#include -#include -#include -#include - -namespace Locator { - -class ILocatorFilter; - -struct FilterEntry -{ - FilterEntry() {} - FilterEntry(ILocatorFilter *fromFilter, const QString &name, const QVariant &data, - const QIcon &icon = QIcon()) - : filter(fromFilter) - , displayName(name) - , internalData(data) - , displayIcon(icon) - , resolveFileIcon(false) - {} - - bool operator==(const FilterEntry &other) const { - if (internalData.canConvert(QVariant::String)) - return (internalData.toString() == other.internalData.toString()); - return internalData.constData() == other.internalData.constData(); - } - - /* backpointer to creating filter */ - ILocatorFilter *filter; - /* displayed string */ - QString displayName; - /* extra information displayed in light-gray in a second column (optional) */ - QString extraInfo; - /* can be used by the filter to save more information about the entry */ - QVariant internalData; - /* icon to display along with the entry */ - QIcon displayIcon; - /* internal data is interpreted as file name and icon is retrieved from the file system if true */ - bool resolveFileIcon; -}; - -class LOCATOR_EXPORT ILocatorFilter : public QObject -{ - Q_OBJECT - -public: - enum Priority {High = 0, Medium = 1, Low = 2}; - - ILocatorFilter(QObject *parent = 0); - virtual ~ILocatorFilter() {} - - /* Visible name. */ - virtual QString trName() const = 0; - - /* Internal name. */ - virtual QString name() const = 0; - - /* Selection list order in case of multiple active filters (high goes on top). */ - virtual Priority priority() const = 0; - - /* String to type to use this filter exclusively. */ - QString shortcutString() const; - - /* List of matches for the given user entry. */ - virtual QList matchesFor(const QString &entry) = 0; - - /* User has selected the given entry that belongs to this filter. */ - virtual void accept(FilterEntry selection) const = 0; - - /* Implement to update caches on user request, if that's a long operation. */ - virtual void refresh(QFutureInterface &future) = 0; - - /* Saved state is used to restore the filter at start up. */ - virtual QByteArray saveState() const; - - /* Used to restore the filter at start up. */ - virtual bool restoreState(const QByteArray &state); - - /* User wants to configure this filter (if supported). Use it to pop up a dialog. - * needsRefresh is used as a hint to indicate that refresh should be called. - * The default implementation allows changing the shortcut and whether the filter - * is enabled by default. - */ - virtual bool openConfigDialog(QWidget *parent, bool &needsRefresh); - - /* If there is a configure dialog available for this filter. The default - * implementation returns true. */ - virtual bool isConfigurable() const; - - /* Is this filter used also when the shortcutString is not used? */ - bool isIncludedByDefault() const; - - /* Returns whether the filter should be hidden from configuration and menus. */ - bool isHidden() const; - - static QString trimWildcards(const QString &str) { - if (str.isEmpty()) - return str; - int first = 0, last = str.size()-1; - while (first < str.size() && (str.at(first) == '*' || str.at(first) == '?')) - ++first; - while (last >= 0 && (str.at(last) == '*' || str.at(last) == '?')) - --last; - if (first > last) - return QString(); - return str.mid(first, last-first+1); - } - -protected: - void setShortcutString(const QString &shortcut); - void setIncludedByDefault(bool includedByDefault); - void setHidden(bool hidden); - -private: - QString m_shortcut; - bool m_includedByDefault; - bool m_hidden; -}; - -} // namespace Locator - -#endif // ILOCATORFILTER_H diff --git a/src/plugins/quickopen/images/locator.png b/src/plugins/quickopen/images/locator.png deleted file mode 100644 index 000ee1c018..0000000000 Binary files a/src/plugins/quickopen/images/locator.png and /dev/null differ diff --git a/src/plugins/quickopen/images/reload.png b/src/plugins/quickopen/images/reload.png deleted file mode 100644 index b5afefb32b..0000000000 Binary files a/src/plugins/quickopen/images/reload.png and /dev/null differ diff --git a/src/plugins/quickopen/locator.qrc b/src/plugins/quickopen/locator.qrc deleted file mode 100644 index 4cd5df4f13..0000000000 --- a/src/plugins/quickopen/locator.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - images/reload.png - images/locator.png - - diff --git a/src/plugins/quickopen/locator_global.h b/src/plugins/quickopen/locator_global.h deleted file mode 100644 index 7dc95b7fde..0000000000 --- a/src/plugins/quickopen/locator_global.h +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef LOCATOR_GLOBAL_H -#define LOCATOR_GLOBAL_H - -#include - -#if defined(LOCATOR_LIBRARY) -# define LOCATOR_EXPORT Q_DECL_EXPORT -#else -# define LOCATOR_EXPORT Q_DECL_IMPORT -#endif - -#endif // LOCATOR_GLOBAL_H diff --git a/src/plugins/quickopen/locatorconstants.h b/src/plugins/quickopen/locatorconstants.h deleted file mode 100644 index 4a78341f79..0000000000 --- a/src/plugins/quickopen/locatorconstants.h +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef LOCATORCONSTANTS_H -#define LOCATORCONSTANTS_H - -#include - -namespace Locator { -namespace Constants { - -const char * const FILTER_OPTIONS_PAGE = QT_TRANSLATE_NOOP("Locator", "Filters"); -const char * const LOCATOR_CATEGORY = QT_TRANSLATE_NOOP("Locator", "Locator"); -const char * const TASK_INDEX = "Locator.Task.Index"; - -} // namespace Constants -} // namespace Locator - -#endif // LOCATORCONSTANTS_H diff --git a/src/plugins/quickopen/locatorfiltersfilter.cpp b/src/plugins/quickopen/locatorfiltersfilter.cpp deleted file mode 100644 index 4b81b73e5d..0000000000 --- a/src/plugins/quickopen/locatorfiltersfilter.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "locatorfiltersfilter.h" -#include "locatorplugin.h" -#include "locatorwidget.h" - -#include - -using namespace Locator; -using namespace Locator::Internal; - -Q_DECLARE_METATYPE(ILocatorFilter*); - -LocatorFiltersFilter::LocatorFiltersFilter(LocatorPlugin *plugin, - LocatorWidget *locatorWidget): - m_plugin(plugin), - m_locatorWidget(locatorWidget), - m_icon(QIcon(Core::Constants::ICON_NEXT)) -{ - setIncludedByDefault(true); - setHidden(true); -} - -QString LocatorFiltersFilter::trName() const -{ - return tr("Available filters"); -} - -QString LocatorFiltersFilter::name() const -{ - return QLatin1String("FiltersFilter"); -} - -ILocatorFilter::Priority LocatorFiltersFilter::priority() const -{ - return High; -} - -QList LocatorFiltersFilter::matchesFor(const QString &entry) -{ - QList entries; - if (entry.isEmpty()) { - foreach (ILocatorFilter *filter, m_plugin->filters()) { - if (!filter->shortcutString().isEmpty() && !filter->isHidden()) { - FilterEntry entry(this, - filter->shortcutString(), - QVariant::fromValue(filter), - m_icon); - entry.extraInfo = filter->trName(); - entries.append(entry); - } - } - } - return entries; -} - -void LocatorFiltersFilter::accept(FilterEntry selection) const -{ - ILocatorFilter *filter = selection.internalData.value(); - if (filter) - m_locatorWidget->show(filter->shortcutString() + " ", - filter->shortcutString().length() + 1); -} - -void LocatorFiltersFilter::refresh(QFutureInterface &future) -{ - Q_UNUSED(future) - // Nothing to refresh -} - -bool LocatorFiltersFilter::isConfigurable() const -{ - return false; -} diff --git a/src/plugins/quickopen/locatorfiltersfilter.h b/src/plugins/quickopen/locatorfiltersfilter.h deleted file mode 100644 index 622b653f1a..0000000000 --- a/src/plugins/quickopen/locatorfiltersfilter.h +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef LOCATORFILTERSFILTER_H -#define LOCATORFILTERSFILTER_H - -#include "ilocatorfilter.h" - -#include - -namespace Locator { -namespace Internal { - -class LocatorPlugin; -class LocatorWidget; - -/*! - This filter provides the user with the list of available Locator filters. - The list is only shown when nothing has been typed yet. - */ -class LocatorFiltersFilter : public ILocatorFilter -{ - Q_OBJECT - -public: - LocatorFiltersFilter(LocatorPlugin *plugin, - LocatorWidget *locatorWidget); - - // ILocatorFilter - QString trName() const; - QString name() const; - Priority priority() const; - QList matchesFor(const QString &entry); - void accept(FilterEntry selection) const; - void refresh(QFutureInterface &future); - bool isConfigurable() const; - -private: - LocatorPlugin *m_plugin; - LocatorWidget *m_locatorWidget; - QIcon m_icon; -}; - -} // namespace Internal -} // namespace Locator - -#endif // LOCATORFILTERSFILTER_H diff --git a/src/plugins/quickopen/locatormanager.cpp b/src/plugins/quickopen/locatormanager.cpp deleted file mode 100644 index d1df7d8746..0000000000 --- a/src/plugins/quickopen/locatormanager.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "locatormanager.h" -#include "locatorwidget.h" - -#include -#include - -using namespace Locator; -using namespace Locator::Internal; - -LocatorManager *LocatorManager::m_instance = 0; - -LocatorManager::LocatorManager(LocatorWidget *locatorWidget) - : QObject(locatorWidget), - m_locatorWidget(locatorWidget) -{ - m_instance = this; -} - -LocatorManager::~LocatorManager() -{ - ExtensionSystem::PluginManager::instance()->removeObject(this); - m_instance = 0; -} - -void LocatorManager::show(const QString &text, - int selectionStart, int selectionLength) -{ - QTC_ASSERT(m_locatorWidget, return); - m_locatorWidget->show(text, selectionStart, selectionLength); -} diff --git a/src/plugins/quickopen/locatormanager.h b/src/plugins/quickopen/locatormanager.h deleted file mode 100644 index d3f296c85e..0000000000 --- a/src/plugins/quickopen/locatormanager.h +++ /dev/null @@ -1,62 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef LOCATORMANAGER_H -#define LOCATORMANAGER_H - -#include "locator_global.h" - -#include - -namespace Locator { - -namespace Internal { -class LocatorWidget; -} - -class LOCATOR_EXPORT LocatorManager : public QObject -{ - Q_OBJECT - -public: - LocatorManager(Internal::LocatorWidget *locatorWidget); - ~LocatorManager(); - - static LocatorManager* instance() { return m_instance; } - - void show(const QString &text, int selectionStart = -1, int selectionLength = 0); - -private: - Internal::LocatorWidget *m_locatorWidget; - static LocatorManager *m_instance; -}; - -} // namespace Locator - -#endif // LOCATORMANAGER_H diff --git a/src/plugins/quickopen/locatorplugin.cpp b/src/plugins/quickopen/locatorplugin.cpp deleted file mode 100644 index c37d218a1c..0000000000 --- a/src/plugins/quickopen/locatorplugin.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "locatorplugin.h" -#include "locatorconstants.h" -#include "locatorfiltersfilter.h" -#include "locatormanager.h" -#include "locatorwidget.h" -#include "opendocumentsfilter.h" -#include "filesystemfilter.h" -#include "settingspage.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/*! - \namespace Locator - The Locator namespace provides the hooks for Locator content. -*/ -/*! - \namespace Locator::Internal - \internal -*/ - -using namespace Locator; -using namespace Locator::Internal; - -namespace { - static bool filterLessThan(const ILocatorFilter *first, const ILocatorFilter *second) - { - return first->priority() < second->priority(); - } -} - -LocatorPlugin::LocatorPlugin() -{ - m_refreshTimer.setSingleShot(false); - connect(&m_refreshTimer, SIGNAL(timeout()), this, SLOT(refresh())); -} - -LocatorPlugin::~LocatorPlugin() -{ - removeObject(m_openDocumentsFilter); - removeObject(m_fileSystemFilter); - removeObject(m_settingsPage); - delete m_openDocumentsFilter; - delete m_fileSystemFilter; - delete m_settingsPage; - qDeleteAll(m_customFilters); -} - -bool LocatorPlugin::initialize(const QStringList &, QString *) -{ - Core::ICore *core = Core::ICore::instance(); - m_settingsPage = new SettingsPage(this); - addObject(m_settingsPage); - - m_locatorWidget = new LocatorWidget(this); - m_locatorWidget->setEnabled(false); - Core::BaseView *view = new Core::BaseView; - view->setUniqueViewName("Locator"); - view->setWidget(m_locatorWidget); - view->setContext(QList() << core->uniqueIDManager() - ->uniqueIdentifier(QLatin1String("LocatorWidget"))); - view->setDefaultPosition(Core::IView::First); - addAutoReleasedObject(view); - - const QString actionId = QLatin1String("QtCreator.Locate"); - QAction *action = new QAction(m_locatorWidget->windowIcon(), m_locatorWidget->windowTitle(), this); - Core::Command *cmd = core->actionManager()->registerAction(action, actionId, QList() << Core::Constants::C_GLOBAL_ID); - cmd->setDefaultKeySequence(QKeySequence("Ctrl+K")); - connect(action, SIGNAL(triggered()), this, SLOT(openLocator())); - - Core::ActionContainer *mtools = core->actionManager()->actionContainer(Core::Constants::M_TOOLS); - mtools->addAction(cmd); - - addObject(new LocatorManager(m_locatorWidget)); - - m_openDocumentsFilter = new OpenDocumentsFilter(core->editorManager()); - addObject(m_openDocumentsFilter); - - m_fileSystemFilter = new FileSystemFilter(core->editorManager(), m_locatorWidget); - addObject(m_fileSystemFilter); - - addAutoReleasedObject(new LocatorFiltersFilter(this, m_locatorWidget)); - - connect(core, SIGNAL(coreOpened()), this, SLOT(startSettingsLoad())); - return true; -} - -void LocatorPlugin::openLocator() -{ - m_locatorWidget->show(""); -} - -void LocatorPlugin::extensionsInitialized() -{ - m_filters = ExtensionSystem::PluginManager::instance()->getObjects(); - qSort(m_filters.begin(), m_filters.end(), filterLessThan); -} - -void LocatorPlugin::startSettingsLoad() -{ - m_loadWatcher.setFuture(QtConcurrent::run(this, &LocatorPlugin::loadSettings)); - connect(&m_loadWatcher, SIGNAL(finished()), this, SLOT(settingsLoaded())); -} - -void LocatorPlugin::loadSettings() -{ - Core::ICore *core = Core::ICore::instance(); - QSettings *qs = core->settings(); - - // Backwards compatibility to old settings location - if (qs->contains("QuickOpen/FiltersFilter")) { - loadSettingsHelper(qs); - } else { - Core::SettingsDatabase *settings = core->settingsDatabase(); - loadSettingsHelper(settings); - } - - qs->remove("QuickOpen"); -} - -void LocatorPlugin::settingsLoaded() -{ - m_locatorWidget->updateFilterList(); - m_locatorWidget->setEnabled(true); - if (m_refreshTimer.interval() > 0) - m_refreshTimer.start(); -} - -void LocatorPlugin::saveSettings() -{ - Core::ICore *core = Core::ICore::instance(); - if (core && core->settingsDatabase()) { - Core::SettingsDatabase *s = core->settingsDatabase(); - s->beginGroup("QuickOpen"); - s->remove(""); - s->setValue("RefreshInterval", refreshInterval()); - foreach (ILocatorFilter *filter, m_filters) { - if (!m_customFilters.contains(filter)) - s->setValue(filter->name(), filter->saveState()); - } - s->beginGroup("CustomFilters"); - int i = 0; - foreach (ILocatorFilter *filter, m_customFilters) { - s->setValue(QString("directory%1").arg(i), filter->saveState()); - ++i; - } - s->endGroup(); - s->endGroup(); - } -} - -/*! - \fn QList LocatorPlugin::filter() - - Return all filters, including the ones created by the user. -*/ -QList LocatorPlugin::filters() -{ - return m_filters; -} - -/*! - \fn QList LocatorPlugin::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 LocatorPlugin::customFilters() -{ - return m_customFilters; -} - -void LocatorPlugin::setFilters(QList f) -{ - m_filters = f; - m_locatorWidget->updateFilterList(); -} - -void LocatorPlugin::setCustomFilters(QList filters) -{ - m_customFilters = filters; -} - -int LocatorPlugin::refreshInterval() -{ - return m_refreshTimer.interval() / 60000; -} - -void LocatorPlugin::setRefreshInterval(int interval) -{ - if (interval < 1) { - m_refreshTimer.stop(); - m_refreshTimer.setInterval(0); - return; - } - m_refreshTimer.setInterval(interval * 60000); - m_refreshTimer.start(); -} - -void LocatorPlugin::refresh(QList filters) -{ - if (filters.isEmpty()) - filters = m_filters; - QFuture task = QtConcurrent::run(&ILocatorFilter::refresh, filters); - Core::FutureProgress *progress = Core::ICore::instance() - ->progressManager()->addTask(task, tr("Indexing"), - Locator::Constants::TASK_INDEX, - Core::ProgressManager::CloseOnSuccess); - connect(progress, SIGNAL(finished()), this, SLOT(saveSettings())); -} - -Q_EXPORT_PLUGIN(LocatorPlugin) diff --git a/src/plugins/quickopen/locatorplugin.h b/src/plugins/quickopen/locatorplugin.h deleted file mode 100644 index 525f291f4a..0000000000 --- a/src/plugins/quickopen/locatorplugin.h +++ /dev/null @@ -1,126 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef LOCATORPLUGIN_H -#define LOCATORPLUGIN_H - -#include "ilocatorfilter.h" -#include "directoryfilter.h" - -#include - -#include -#include -#include - -namespace Locator { -namespace Internal { - -class LocatorWidget; -class OpenDocumentsFilter; -class FileSystemFilter; -class SettingsPage; -class LocatorPlugin; - -class LocatorPlugin : public ExtensionSystem::IPlugin -{ - Q_OBJECT - -public: - LocatorPlugin(); - ~LocatorPlugin(); - - bool initialize(const QStringList &arguments, QString *error_message); - void extensionsInitialized(); - - QList filters(); - QList customFilters(); - void setFilters(QList f); - void setCustomFilters(QList f); - int refreshInterval(); - void setRefreshInterval(int interval); - -public slots: - void refresh(QList filters = QList()); - void saveSettings(); - void openLocator(); - -private slots: - void startSettingsLoad(); - void settingsLoaded(); - -private: - void loadSettings(); - - template - void loadSettingsHelper(S *settings); - - LocatorWidget *m_locatorWidget; - SettingsPage *m_settingsPage; - - QList m_filters; - QList m_customFilters; - int m_refreshInterval; - QTimer m_refreshTimer; - OpenDocumentsFilter *m_openDocumentsFilter; - FileSystemFilter *m_fileSystemFilter; - QFutureWatcher m_loadWatcher; -}; - -template -void LocatorPlugin::loadSettingsHelper(S *settings) -{ - settings->beginGroup("QuickOpen"); - m_refreshTimer.setInterval(settings->value("RefreshInterval", 60).toInt() * 60000); - - foreach (ILocatorFilter *filter, m_filters) { - if (settings->contains(filter->name())) { - const QByteArray state = settings->value(filter->name()).toByteArray(); - if (!state.isEmpty()) - filter->restoreState(state); - } - } - settings->beginGroup("CustomFilters"); - QList customFilters; - const QStringList keys = settings->childKeys(); - foreach (const QString &key, keys) { - ILocatorFilter *filter = new DirectoryFilter; - filter->restoreState(settings->value(key).toByteArray()); - m_filters.append(filter); - customFilters.append(filter); - } - setCustomFilters(customFilters); - settings->endGroup(); - settings->endGroup(); -} - -} // namespace Internal -} // namespace Locator - -#endif // LOCATORPLUGIN_H diff --git a/src/plugins/quickopen/locatorwidget.cpp b/src/plugins/quickopen/locatorwidget.cpp deleted file mode 100644 index da15cd1100..0000000000 --- a/src/plugins/quickopen/locatorwidget.cpp +++ /dev/null @@ -1,489 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include - -namespace Locator { -struct FilterEntry; -} - -QT_BEGIN_NAMESPACE -unsigned int qHash(const Locator::FilterEntry &entry); -QT_END_NAMESPACE - -#include "locatorwidget.h" -#include "locatorplugin.h" -#include "locatorconstants.h" - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -Q_DECLARE_METATYPE(Locator::ILocatorFilter*); -Q_DECLARE_METATYPE(Locator::FilterEntry); - -namespace Locator { -namespace Internal { - -/*! A model to represent the Locator results. */ -class LocatorModel : public QAbstractListModel -{ -public: - LocatorModel(QObject *parent = 0) - : QAbstractListModel(parent) -// , mDisplayCount(64) - {} - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - - void setEntries(const QList &entries); - //void setDisplayCount(int count); - -private: - mutable QList mEntries; - //int mDisplayCount; -}; - -class CompletionList : public QTreeView -{ -public: - CompletionList(QWidget *parent = 0); - - void updatePreferredSize(); - QSize preferredSize() const { return m_preferredSize; } - -private: - QSize m_preferredSize; -}; - -} // namespace Internal -} // namespace Locator - -using namespace Locator; -using namespace Locator::Internal; - -QT_BEGIN_NAMESPACE -uint qHash(const FilterEntry &entry) -{ - if (entry.internalData.canConvert(QVariant::String)) - return qHash(entry.internalData.toString()); - return qHash(entry.internalData.constData()); -} -QT_END_NAMESPACE - - -// =========== LocatorModel =========== - -int LocatorModel::rowCount(const QModelIndex & /* parent */) const -{ - return mEntries.size(); -} - -int LocatorModel::columnCount(const QModelIndex &parent) const -{ - return parent.isValid() ? 0 : 2; -} - -/*! - * When asked for the icon via Qt::DecorationRole, the LocatorModel lazily - * resolves and caches the Greehouse-specific file icon when - * FilterEntry::resolveFileIcon is true. FilterEntry::internalData is assumed - * to be the filename. - */ -QVariant LocatorModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid() || index.row() >= mEntries.size()) - return QVariant(); - - if (role == Qt::DisplayRole || role == Qt::ToolTipRole) { - if (index.column() == 0) { - return mEntries.at(index.row()).displayName; - } else if (index.column() == 1) { - return mEntries.at(index.row()).extraInfo; - } - } else if (role == Qt::DecorationRole && index.column() == 0) { - FilterEntry &entry = mEntries[index.row()]; - if (entry.resolveFileIcon && entry.displayIcon.isNull()) { - entry.resolveFileIcon = false; - entry.displayIcon = - Core::FileIconProvider::instance()->icon(QFileInfo(entry.internalData.toString())); - } - return entry.displayIcon; - } else if (role == Qt::ForegroundRole && index.column() == 1) { - return Qt::darkGray; - } else if (role == Qt::UserRole) { - return qVariantFromValue(mEntries.at(index.row())); - } - - return QVariant(); -} - -void LocatorModel::setEntries(const QList &entries) -{ - mEntries = entries; - reset(); -} -#if 0 -void LocatorModel::setDisplayCount(int count) -{ - // TODO: This method is meant to be used for increasing the number of items displayed at the - // user's request. There is however no way yet for the user to request this. - if (count == mDisplayCount) - return; - - const int displayedOld = qMin(mDisplayCount, mEntries.size()); - const int displayedNew = qMin(count, mEntries.size()); - - if (displayedNew < displayedOld) - beginRemoveRows(QModelIndex(), displayedNew - 1, displayedOld - 1); - else if (displayedNew > displayedOld) - beginInsertRows(QModelIndex(), displayedOld - 1, displayedNew - 1); - - mDisplayCount = count; - - if (displayedNew < displayedOld) - endRemoveRows(); - else if (displayedNew > displayedOld) - endInsertRows(); -} -#endif - -// =========== CompletionList =========== - -CompletionList::CompletionList(QWidget *parent) - : QTreeView(parent) -{ - setRootIsDecorated(false); - setUniformRowHeights(true); - setMaximumWidth(900); - header()->hide(); - header()->setStretchLastSection(true); - // This is too slow when done on all results - //header()->setResizeMode(QHeaderView::ResizeToContents); - setWindowFlags(Qt::ToolTip); -} - -void CompletionList::updatePreferredSize() -{ - //header()->setStretchLastSection(false); - //updateGeometries(); - - const QStyleOptionViewItem &option = viewOptions(); - const QSize shint = itemDelegate()->sizeHint(option, model()->index(0, 0)); -#if 0 - const int visibleItems = model()->rowCount(); - - // TODO: Look into enabling preferred height as well. Current problem is that this doesn't - // work nicely from the user perspective if the list is popping up instead of down. - //const int h = shint.height() * visibleItems; - - const QScrollBar *vscroll = verticalScrollBar(); - int preferredWidth = header()->length() + frameWidth() * 2 - + (vscroll->isVisibleTo(this) ? vscroll->width() : 0); - const int diff = preferredWidth - width(); - - // Avoid resizing the list widget when there are no results or when the preferred size is - // only a little smaller than our current size - if (visibleItems == 0 || (diff > -100 && diff < 0)) - preferredWidth = width(); -#endif - - m_preferredSize = QSize(730, //qMax(600, preferredWidth), - shint.height() * 17 + frameWidth() * 2); - //header()->setStretchLastSection(true); -} - - -// =========== LocatorWidget =========== - -LocatorWidget::LocatorWidget(LocatorPlugin *qop) : - m_locatorPlugin(qop), - m_locatorModel(new LocatorModel(this)), - m_completionList(new CompletionList(this)), - m_filterMenu(new QMenu(this)), - m_refreshAction(new QAction(tr("Refresh"), this)), - m_configureAction(new QAction(tr("Configure..."), this)), - m_fileLineEdit(new Utils::FancyLineEdit) -{ - // Explicitly hide the completion list popup. - m_completionList->hide(); - - setFocusProxy(m_fileLineEdit); - setWindowTitle(tr("Locate...")); - resize(200, 90); - QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); - sizePolicy.setHorizontalStretch(0); - sizePolicy.setVerticalStretch(0); - setSizePolicy(sizePolicy); - setMinimumSize(QSize(200, 0)); - - QHBoxLayout *layout = new QHBoxLayout(this); - setLayout(layout); - layout->setMargin(0); - layout->addWidget(m_fileLineEdit); - - setWindowIcon(QIcon(":/locator/images/locator.png")); - QPixmap image(Core::Constants::ICON_MAGNIFIER); - m_fileLineEdit->setPixmap(image); - m_fileLineEdit->setUseLayoutDirection(true); - m_fileLineEdit->setHintText(tr("Type to locate")); - m_fileLineEdit->setFocusPolicy(Qt::ClickFocus); - m_fileLineEdit->setAttribute(Qt::WA_MacShowFocusRect, false); - - m_fileLineEdit->installEventFilter(this); - this->installEventFilter(this); - - m_completionList->setModel(m_locatorModel); - m_completionList->header()->resizeSection(0, 300); - m_completionList->updatePreferredSize(); - m_completionList->resize(m_completionList->preferredSize()); - - m_filterMenu->addAction(m_refreshAction); - m_filterMenu->addAction(m_configureAction); - - m_fileLineEdit->setMenu( m_filterMenu); - - connect(m_refreshAction, SIGNAL(triggered()), m_locatorPlugin, SLOT(refresh())); - connect(m_configureAction, SIGNAL(triggered()), this, SLOT(showConfigureDialog())); - connect(m_fileLineEdit, SIGNAL(textEdited(const QString&)), - this, SLOT(showPopup())); - connect(m_completionList, SIGNAL(activated(QModelIndex)), - this, SLOT(acceptCurrentEntry())); -} - -bool LocatorWidget::isShowingTypeHereMessage() const -{ - return m_fileLineEdit->isShowingHintText(); -} - -void LocatorWidget::updateFilterList() -{ - m_filterMenu->clear(); - foreach (ILocatorFilter *filter, m_locatorPlugin->filters()) { - if (!filter->shortcutString().isEmpty() && !filter->isHidden()) { - QAction *action = m_filterMenu->addAction(filter->trName(), this, SLOT(filterSelected())); - action->setData(qVariantFromValue(filter)); - } - } - m_filterMenu->addSeparator(); - m_filterMenu->addAction(m_refreshAction); - m_filterMenu->addAction(m_configureAction); -} - -bool LocatorWidget::eventFilter(QObject *obj, QEvent *event) -{ - if (obj == m_fileLineEdit && event->type() == QEvent::KeyPress) { - QKeyEvent *keyEvent = static_cast(event); - switch (keyEvent->key()) { - case Qt::Key_Up: - case Qt::Key_Down: - case Qt::Key_PageUp: - case Qt::Key_PageDown: - showCompletionList(); - QApplication::sendEvent(m_completionList, event); - return true; - case Qt::Key_Enter: - case Qt::Key_Return: - acceptCurrentEntry(); - return true; - case Qt::Key_Escape: - m_completionList->hide(); - return true; - default: - break; - } - } else if (obj == m_fileLineEdit && event->type() == QEvent::FocusOut) { - m_completionList->hide(); - } else if (obj == m_fileLineEdit && event->type() == QEvent::FocusIn) { - showPopup(); - } else if (obj == this && event->type() == QEvent::ShortcutOverride) { - QKeyEvent *ke = static_cast(event); - if (ke->key() == Qt::Key_Escape && !ke->modifiers()) { - event->accept(); - QTimer::singleShot(0, Core::ModeManager::instance(), SLOT(setFocusToCurrentMode())); - return true; - } - } - return QWidget::eventFilter(obj, event); -} - -void LocatorWidget::showCompletionList() -{ - const int border = m_completionList->frameWidth(); - const QSize size = m_completionList->preferredSize(); - const QRect rect(mapToGlobal(QPoint(-border, -size.height() - border)), size); - m_completionList->setGeometry(rect); - m_completionList->show(); -} - -void LocatorWidget::showPopup() -{ - updateCompletionList(m_fileLineEdit->typedText()); - showCompletionList(); -} - -QList LocatorWidget::filtersFor(const QString &text, QString &searchText) -{ - QList filters = m_locatorPlugin->filters(); - int whiteSpace = text.indexOf(" "); - QString prefix; - if (whiteSpace >= 0) - prefix = text.left(whiteSpace); - if (!prefix.isEmpty()) { - prefix = prefix.toLower(); - foreach (ILocatorFilter *filter, filters) { - if (prefix == filter->shortcutString()) { - searchText = text.mid(whiteSpace+1); - return QList() << filter; - } - } - } - searchText = text; - QList activeFilters; - foreach (ILocatorFilter *filter, filters) - if (filter->isIncludedByDefault()) - activeFilters << filter; - return activeFilters; -} - -void LocatorWidget::updateCompletionList(const QString &text) -{ - QString searchText; - const QList filters = filtersFor(text, searchText); - QSet alreadyAdded; - const bool checkDuplicates = (filters.size() > 1); - QList entries; - foreach (ILocatorFilter *filter, filters) { - foreach (const FilterEntry &entry, filter->matchesFor(searchText)) { - if (checkDuplicates && alreadyAdded.contains(entry)) - continue; - entries.append(entry); - if (checkDuplicates) - alreadyAdded.insert(entry); - } - } - m_locatorModel->setEntries(entries); - if (m_locatorModel->rowCount() > 0) { - m_completionList->setCurrentIndex(m_locatorModel->index(0, 0)); - } -#if 0 - m_completionList->updatePreferredSize(); -#endif -} - -void LocatorWidget::acceptCurrentEntry() -{ - if (!m_completionList->isVisible()) - return; - const QModelIndex index = m_completionList->currentIndex(); - if (!index.isValid()) - return; - const FilterEntry entry = m_locatorModel->data(index, Qt::UserRole).value(); - m_completionList->hide(); - entry.filter->accept(entry); -} - -void LocatorWidget::show(const QString &text, int selectionStart, int selectionLength) -{ - m_fileLineEdit->hideHintText(); - if (!text.isEmpty()) - m_fileLineEdit->setText(text); - if (!m_fileLineEdit->hasFocus()) - m_fileLineEdit->setFocus(); - else - showPopup(); - - if (selectionStart >= 0) { - m_fileLineEdit->setSelection(selectionStart, selectionLength); - if (selectionLength == 0) // make sure the cursor is at the right position (Mac-vs.-rest difference) - m_fileLineEdit->setCursorPosition(selectionStart); - } else { - m_fileLineEdit->selectAll(); - } -} - -void LocatorWidget::filterSelected() -{ - QString searchText = tr(""); - QAction *action = qobject_cast(sender()); - QTC_ASSERT(action, return); - ILocatorFilter *filter = action->data().value(); - 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 (ILocatorFilter *otherfilter, m_locatorPlugin->filters()) { - if (currentText.startsWith(otherfilter->shortcutString() + " ")) { - searchText = currentText.mid(otherfilter->shortcutString().length()+1); - break; - } - } - } - show(filter->shortcutString() + " " + searchText, - filter->shortcutString().length() + 1, - searchText.length()); - updateCompletionList(m_fileLineEdit->text()); - m_fileLineEdit->setFocus(); -} - -void LocatorWidget::showEvent(QShowEvent *event) -{ - QWidget::showEvent(event); -} - -void LocatorWidget::showConfigureDialog() -{ - Core::ICore::instance()->showOptionsDialog(Constants::LOCATOR_CATEGORY, - Constants::FILTER_OPTIONS_PAGE); -} diff --git a/src/plugins/quickopen/locatorwidget.h b/src/plugins/quickopen/locatorwidget.h deleted file mode 100644 index 4fefd4cb12..0000000000 --- a/src/plugins/quickopen/locatorwidget.h +++ /dev/null @@ -1,97 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef LOCATORWIDGET_H -#define LOCATORWIDGET_H - -#include "locatorplugin.h" - -#include -#include - -QT_BEGIN_NAMESPACE -class QAction; -class QLabel; -class QLineEdit; -class QMenu; -class QTreeView; -QT_END_NAMESPACE - -namespace Utils { - class FancyLineEdit; -} - -namespace Locator { -namespace Internal { - -class LocatorModel; -class CompletionList; - -class LocatorWidget - : public QWidget -{ - Q_OBJECT - -public: - LocatorWidget(LocatorPlugin *qop); - - void updateFilterList(); - - void show(const QString &text, int selectionStart = -1, int selectionLength = 0); - -private slots: - void showPopup(); - void acceptCurrentEntry(); - void filterSelected(); - void showConfigureDialog(); - -private: - bool eventFilter(QObject *obj, QEvent *event); - - void showEvent(QShowEvent *e); - - bool isShowingTypeHereMessage() const; - void showCompletionList(); - void updateCompletionList(const QString &text); - QList filtersFor(const QString &text, QString &searchText); - - LocatorPlugin *m_locatorPlugin; - LocatorModel *m_locatorModel; - - CompletionList *m_completionList; - QMenu *m_filterMenu; - QAction *m_refreshAction; - QAction *m_configureAction; - Utils::FancyLineEdit *m_fileLineEdit; -}; - -} // namespace Internal -} // namespace Locator - -#endif // LOCATORWIDGET_H diff --git a/src/plugins/quickopen/opendocumentsfilter.cpp b/src/plugins/quickopen/opendocumentsfilter.cpp deleted file mode 100644 index a85da7fee9..0000000000 --- a/src/plugins/quickopen/opendocumentsfilter.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "opendocumentsfilter.h" - -Q_DECLARE_METATYPE(Core::IEditor*); - -using namespace Core; -using namespace Locator; -using namespace Locator::Internal; - -OpenDocumentsFilter::OpenDocumentsFilter(EditorManager *editorManager) : - m_editorManager(editorManager) -{ - connect(m_editorManager, SIGNAL(editorOpened(Core::IEditor*)), - this, SLOT(refreshInternally())); - connect(m_editorManager, SIGNAL(editorsClosed(QList)), - this, SLOT(refreshInternally())); - setShortcutString("o"); - setIncludedByDefault(true); -} - -QList OpenDocumentsFilter::matchesFor(const QString &entry) -{ - QList value; - const QChar asterisk = QLatin1Char('*'); - QString pattern = QString(asterisk); - pattern += entry; - pattern += asterisk; - const QRegExp regexp(pattern, Qt::CaseInsensitive, QRegExp::Wildcard); - if (!regexp.isValid()) - return value; - foreach (IEditor *editor, m_editors) { - QString fileName = editor->file()->fileName(); - if (regexp.exactMatch(editor->displayName())) { - QString visibleName; - QVariant data; - if (fileName.isEmpty()) { - value.append(FilterEntry(this, editor->displayName(), qVariantFromValue(editor))); - } else { - QFileInfo fi(fileName); - FilterEntry entry(this, fi.fileName(), fileName); - entry.extraInfo = QDir::toNativeSeparators(fi.path()); - entry.resolveFileIcon = true; - value.append(entry); - } - } - } - return value; -} - -void OpenDocumentsFilter::refreshInternally() -{ - m_editors = m_editorManager->openedEditors(); -} - -void OpenDocumentsFilter::refresh(QFutureInterface &future) -{ - Q_UNUSED(future) - QMetaObject::invokeMethod(this, "refreshInternally", Qt::BlockingQueuedConnection); -} - -void OpenDocumentsFilter::accept(FilterEntry selection) const -{ - IEditor *editor = selection.internalData.value(); - if (editor) { - m_editorManager->activateEditor(editor); - return; - } - m_editorManager->openEditor(selection.internalData.toString()); - m_editorManager->ensureEditorManagerVisible(); -} diff --git a/src/plugins/quickopen/opendocumentsfilter.h b/src/plugins/quickopen/opendocumentsfilter.h deleted file mode 100644 index fc040971f7..0000000000 --- a/src/plugins/quickopen/opendocumentsfilter.h +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef OPENDOCUMENTSFILTER_H -#define OPENDOCUMENTSFILTER_H - -#include "ilocatorfilter.h" - -#include -#include -#include -#include -#include - -#include -#include - -namespace Locator { -namespace Internal { - -class OpenDocumentsFilter : public Locator::ILocatorFilter -{ - Q_OBJECT - -public: - OpenDocumentsFilter(Core::EditorManager *editorManager); - QString trName() const { return tr("Open documents"); } - QString name() const { return "Open documents"; } - Locator::ILocatorFilter::Priority priority() const { return Locator::ILocatorFilter::Medium; } - QList matchesFor(const QString &entry); - void accept(Locator::FilterEntry selection) const; - void refresh(QFutureInterface &future); - -public slots: - void refreshInternally(); - -private: - Core::EditorManager *m_editorManager; - - QList m_editors; -}; - -} // namespace Internal -} // namespace Locator - -#endif // OPENDOCUMENTSFILTER_H diff --git a/src/plugins/quickopen/quickopen.cp b/src/plugins/quickopen/quickopen.cp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/plugins/quickopen/quickopen.pri b/src/plugins/quickopen/quickopen.pri deleted file mode 100644 index a5645e529e..0000000000 --- a/src/plugins/quickopen/quickopen.pri +++ /dev/null @@ -1,3 +0,0 @@ -include(quickopen_dependencies.pri) - -LIBS *= -l$$qtLibraryTarget(QuickOpen) diff --git a/src/plugins/quickopen/quickopen.pro b/src/plugins/quickopen/quickopen.pro deleted file mode 100644 index 73de643c9c..0000000000 --- a/src/plugins/quickopen/quickopen.pro +++ /dev/null @@ -1,33 +0,0 @@ -TEMPLATE = lib -TARGET = QuickOpen -DEFINES += LOCATOR_LIBRARY -include(../../qtcreatorplugin.pri) -include(quickopen_dependencies.pri) -HEADERS += locatorplugin.h \ - locatorwidget.h \ - locatorfiltersfilter.h \ - settingspage.h \ - ilocatorfilter.h \ - opendocumentsfilter.h \ - filesystemfilter.h \ - locatorconstants.h \ - directoryfilter.h \ - locatormanager.h \ - basefilefilter.h \ - locator_global.h -SOURCES += locatorplugin.cpp \ - locatorwidget.cpp \ - locatorfiltersfilter.cpp \ - opendocumentsfilter.cpp \ - filesystemfilter.cpp \ - settingspage.cpp \ - directoryfilter.cpp \ - locatormanager.cpp \ - basefilefilter.cpp \ - ilocatorfilter.cpp -FORMS += settingspage.ui \ - filesystemfilter.ui \ - directoryfilter.ui -RESOURCES += locator.qrc - -OTHER_FILES += QuickOpen.pluginspec diff --git a/src/plugins/quickopen/quickopen_dependencies.pri b/src/plugins/quickopen/quickopen_dependencies.pri deleted file mode 100644 index 96d71e68c8..0000000000 --- a/src/plugins/quickopen/quickopen_dependencies.pri +++ /dev/null @@ -1,2 +0,0 @@ -include(../../libs/qtconcurrent/qtconcurrent.pri) -include(../../plugins/coreplugin/coreplugin.pri) diff --git a/src/plugins/quickopen/settingspage.cpp b/src/plugins/quickopen/settingspage.cpp deleted file mode 100644 index 99453132fe..0000000000 --- a/src/plugins/quickopen/settingspage.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#include "settingspage.h" -#include "locatorconstants.h" - -#include "locatorplugin.h" -#include "ilocatorfilter.h" -#include "directoryfilter.h" - -#include -#include - -#include - -Q_DECLARE_METATYPE(Locator::ILocatorFilter*) - -using namespace Locator; -using namespace Locator::Internal; - -SettingsPage::SettingsPage(LocatorPlugin *plugin) - : m_plugin(plugin), m_page(0) -{ -} - -QString SettingsPage::id() const -{ - return QLatin1String(Constants::FILTER_OPTIONS_PAGE); -} - -QString SettingsPage::trName() const -{ - return QCoreApplication::translate("Locator", Locator::Constants::FILTER_OPTIONS_PAGE); -} - -QString SettingsPage::category() const -{ - return Constants::LOCATOR_CATEGORY; -} - -QString SettingsPage::trCategory() const -{ - return QCoreApplication::translate("Locator", Locator::Constants::LOCATOR_CATEGORY); -} - -QWidget *SettingsPage::createPage(QWidget *parent) -{ - - m_page = new QWidget(parent); - m_ui.setupUi(m_page); - connect(m_ui.filterList, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), - this, SLOT(updateButtonStates())); - connect(m_ui.filterList, SIGNAL(itemActivated(QListWidgetItem *)), - this, SLOT(configureFilter(QListWidgetItem *))); - connect(m_ui.editButton, SIGNAL(clicked()), - this, SLOT(configureFilter())); - connect(m_ui.addButton, SIGNAL(clicked()), - this, SLOT(addCustomFilter())); - connect(m_ui.removeButton, SIGNAL(clicked()), - this, SLOT(removeCustomFilter())); - - m_ui.refreshInterval->setValue(m_plugin->refreshInterval()); - m_filters = m_plugin->filters(); - m_customFilters = m_plugin->customFilters(); - saveFilterStates(); - updateFilterList(); - return m_page; -} - -void SettingsPage::apply() -{ - // Delete removed filters and clear added filters - qDeleteAll(m_removedFilters); - m_removedFilters.clear(); - m_addedFilters.clear(); - - // Pass the new configuration on to the plugin - m_plugin->setFilters(m_filters); - m_plugin->setCustomFilters(m_customFilters); - m_plugin->setRefreshInterval(m_ui.refreshInterval->value()); - requestRefresh(); - m_plugin->saveSettings(); - saveFilterStates(); -} - -void SettingsPage::finish() -{ - // If settings were applied, this shouldn't change anything. Otherwise it - // makes sure the filter states aren't changed permanently. - restoreFilterStates(); - - // Delete added filters and clear removed filters - qDeleteAll(m_addedFilters); - m_addedFilters.clear(); - m_removedFilters.clear(); - - // Further cleanup - m_filters.clear(); - m_customFilters.clear(); - m_refreshFilters.clear(); -} - -void SettingsPage::requestRefresh() -{ - if (!m_refreshFilters.isEmpty()) - m_plugin->refresh(m_refreshFilters); -} - -void SettingsPage::saveFilterStates() -{ - m_filterStates.clear(); - foreach (ILocatorFilter *filter, m_filters) - m_filterStates.insert(filter, filter->saveState()); -} - -void SettingsPage::restoreFilterStates() -{ - foreach (ILocatorFilter *filter, m_filterStates.keys()) - filter->restoreState(m_filterStates.value(filter)); -} - -void SettingsPage::updateFilterList() -{ - m_ui.filterList->clear(); - foreach (ILocatorFilter *filter, m_filters) { - if (filter->isHidden()) - continue; - - QString title; - if (filter->isIncludedByDefault()) - title = filter->trName(); - else - title = tr("%1 (Prefix: %2)").arg(filter->trName()).arg(filter->shortcutString()); - QListWidgetItem *item = new QListWidgetItem(title); - item->setData(Qt::UserRole, qVariantFromValue(filter)); - m_ui.filterList->addItem(item); - } - if (m_ui.filterList->count() > 0) - m_ui.filterList->setCurrentRow(0); -} - -void SettingsPage::updateButtonStates() -{ - QListWidgetItem *item = m_ui.filterList->currentItem(); - ILocatorFilter *filter = (item ? item->data(Qt::UserRole).value() : 0); - m_ui.editButton->setEnabled(filter && filter->isConfigurable()); - m_ui.removeButton->setEnabled(filter && m_customFilters.contains(filter)); -} - -void SettingsPage::configureFilter(QListWidgetItem *item) -{ - if (!item) - item = m_ui.filterList->currentItem(); - QTC_ASSERT(item, return); - ILocatorFilter *filter = item->data(Qt::UserRole).value(); - QTC_ASSERT(filter, return); - - if (!filter->isConfigurable()) - return; - bool needsRefresh = false; - filter->openConfigDialog(m_page, needsRefresh); - if (needsRefresh && !m_refreshFilters.contains(filter)) - m_refreshFilters.append(filter); - updateFilterList(); -} - -void SettingsPage::addCustomFilter() -{ - ILocatorFilter *filter = new DirectoryFilter; - bool needsRefresh = false; - if (filter->openConfigDialog(m_page, needsRefresh)) { - m_filters.append(filter); - m_addedFilters.append(filter); - m_customFilters.append(filter); - m_refreshFilters.append(filter); - updateFilterList(); - } -} - -void SettingsPage::removeCustomFilter() -{ - QListWidgetItem *item = m_ui.filterList->currentItem(); - QTC_ASSERT(item, return); - ILocatorFilter *filter = item->data(Qt::UserRole).value(); - QTC_ASSERT(m_customFilters.contains(filter), return); - m_filters.removeAll(filter); - m_customFilters.removeAll(filter); - m_refreshFilters.removeAll(filter); - if (m_addedFilters.contains(filter)) { - m_addedFilters.removeAll(filter); - delete filter; - } else { - m_removedFilters.append(filter); - } - updateFilterList(); -} diff --git a/src/plugins/quickopen/settingspage.h b/src/plugins/quickopen/settingspage.h deleted file mode 100644 index 1fb55661e0..0000000000 --- a/src/plugins/quickopen/settingspage.h +++ /dev/null @@ -1,93 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://qt.nokia.com/contact. -** -**************************************************************************/ - -#ifndef SETTINGSPAGE_H -#define SETTINGSPAGE_H - -#include "ui_settingspage.h" - -#include -#include - -#include - -QT_BEGIN_NAMESPACE -class QListWidgetItem; -QT_END_NAMESPACE - -namespace Locator { - -class ILocatorFilter; - -namespace Internal { - -class LocatorPlugin; - -class SettingsPage : public Core::IOptionsPage -{ - Q_OBJECT - -public: - explicit SettingsPage(LocatorPlugin *plugin); - QString id() const; - QString trName() const; - QString category() const; - QString trCategory() const; - - QWidget *createPage(QWidget *parent); - void apply(); - void finish(); - -private slots: - void updateButtonStates(); - void configureFilter(QListWidgetItem *item = 0); - void addCustomFilter(); - void removeCustomFilter(); - -private: - void updateFilterList(); - void saveFilterStates(); - void restoreFilterStates(); - void requestRefresh(); - - Ui::SettingsWidget m_ui; - LocatorPlugin *m_plugin; - QWidget* m_page; - QList m_filters; - QList m_addedFilters; - QList m_removedFilters; - QList m_customFilters; - QList m_refreshFilters; - QHash m_filterStates; -}; - -} // namespace Internal -} // namespace Locator - -#endif // SETTINGSPAGE_H diff --git a/src/plugins/quickopen/settingspage.ui b/src/plugins/quickopen/settingspage.ui deleted file mode 100644 index f2f055c57b..0000000000 --- a/src/plugins/quickopen/settingspage.ui +++ /dev/null @@ -1,127 +0,0 @@ - - - Locator::Internal::SettingsWidget - - - - 0 - 0 - 460 - 353 - - - - Configure Filters - - - - - - Configure Filters - - - - - - - - - - - - - - - Add - - - - - - - false - - - Remove - - - - - - - false - - - Edit - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - Refresh Interval: - - - - - - - true - - - QAbstractSpinBox::PlusMinus - - - min - - - 320 - - - 5 - - - 60 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - diff --git a/src/plugins/quickopen/settingswidget.ui b/src/plugins/quickopen/settingswidget.ui deleted file mode 100644 index 03653fe6a0..0000000000 --- a/src/plugins/quickopen/settingswidget.ui +++ /dev/null @@ -1,133 +0,0 @@ - - QuickOpen::Internal::SettingsDialog - - - - 0 - 0 - 460 - 353 - - - - Configure Filters - - - - - - - - - - - - - - - false - - - Add - - - - - - - false - - - Remove - - - - - - - false - - - Edit... - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Refresh Interval: - - - - - - - true - - - QAbstractSpinBox::PlusMinus - - - min - - - 320 - - - 5 - - - 60 - - - - - - - - - - Refresh now! - - - Qt::ToolButtonTextBesideIcon - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - diff --git a/src/plugins/texteditor/linenumberfilter.h b/src/plugins/texteditor/linenumberfilter.h index 9147908eed..54bb858bfe 100644 --- a/src/plugins/texteditor/linenumberfilter.h +++ b/src/plugins/texteditor/linenumberfilter.h @@ -30,7 +30,7 @@ #ifndef LINENUMBERFILTER_H #define LINENUMBERFILTER_H -#include +#include #include #include diff --git a/src/plugins/texteditor/texteditor_dependencies.pri b/src/plugins/texteditor/texteditor_dependencies.pri index 87f23e9eed..60c22f8477 100644 --- a/src/plugins/texteditor/texteditor_dependencies.pri +++ b/src/plugins/texteditor/texteditor_dependencies.pri @@ -1,4 +1,4 @@ include(../../libs/utils/utils.pri) include(../../plugins/find/find.pri) -include(../../plugins/quickopen/quickopen.pri) +include(../../plugins/locator/quickopen.pri) include(../../plugins/coreplugin/coreplugin.pri) diff --git a/src/plugins/texteditor/texteditoractionhandler.cpp b/src/plugins/texteditor/texteditoractionhandler.cpp index ffa9343687..5043583a46 100644 --- a/src/plugins/texteditor/texteditoractionhandler.cpp +++ b/src/plugins/texteditor/texteditoractionhandler.cpp @@ -33,7 +33,7 @@ #include "texteditorplugin.h" #include "linenumberfilter.h" -#include +#include #include #include #include -- cgit v1.2.1