forked from qt-creator/qt-creator
Add "File Name Index" locator filter on Windows
Using the freely available "Everything" tool that creates a global file index and also provides a command line tool for accessing it. Change-Id: Ieade7a8c0dd94695dabbd5f95b1f86e0d950d62e Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -111,6 +111,7 @@ add_qtc_plugin(Core
|
|||||||
locator/locatorsettingspage.cpp locator/locatorsettingspage.h locator/locatorsettingspage.ui
|
locator/locatorsettingspage.cpp locator/locatorsettingspage.h locator/locatorsettingspage.ui
|
||||||
locator/locatorwidget.cpp locator/locatorwidget.h
|
locator/locatorwidget.cpp locator/locatorwidget.h
|
||||||
locator/opendocumentsfilter.cpp locator/opendocumentsfilter.h
|
locator/opendocumentsfilter.cpp locator/opendocumentsfilter.h
|
||||||
|
locator/spotlightlocatorfilter.h locator/spotlightlocatorfilter.cpp
|
||||||
locator/urllocatorfilter.cpp locator/urllocatorfilter.h locator/urllocatorfilter.ui
|
locator/urllocatorfilter.cpp locator/urllocatorfilter.h locator/urllocatorfilter.ui
|
||||||
mainwindow.cpp mainwindow.h
|
mainwindow.cpp mainwindow.h
|
||||||
manhattanstyle.cpp manhattanstyle.h
|
manhattanstyle.cpp manhattanstyle.h
|
||||||
@@ -180,12 +181,6 @@ extend_qtc_plugin(Core
|
|||||||
progressmanager/progressmanager_mac.mm
|
progressmanager/progressmanager_mac.mm
|
||||||
)
|
)
|
||||||
|
|
||||||
extend_qtc_plugin(Core
|
|
||||||
CONDITION NOT WIN32
|
|
||||||
SOURCES
|
|
||||||
locator/spotlightlocatorfilter.h locator/spotlightlocatorfilter.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
extend_qtc_plugin(Core
|
extend_qtc_plugin(Core
|
||||||
CONDITION (NOT WIN32) AND (NOT APPLE)
|
CONDITION (NOT WIN32) AND (NOT APPLE)
|
||||||
SOURCES progressmanager/progressmanager_x11.cpp
|
SOURCES progressmanager/progressmanager_x11.cpp
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
#include "locatorsettingspage.h"
|
#include "locatorsettingspage.h"
|
||||||
#include "locatorwidget.h"
|
#include "locatorwidget.h"
|
||||||
#include "opendocumentsfilter.h"
|
#include "opendocumentsfilter.h"
|
||||||
|
#include "spotlightlocatorfilter.h"
|
||||||
#include "urllocatorfilter.h"
|
#include "urllocatorfilter.h"
|
||||||
|
|
||||||
#include <coreplugin/coreplugin.h>
|
#include <coreplugin/coreplugin.h>
|
||||||
@@ -59,10 +60,6 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
#include "spotlightlocatorfilter.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
@@ -90,9 +87,7 @@ public:
|
|||||||
MenuBarFilter m_menubarFilter;
|
MenuBarFilter m_menubarFilter;
|
||||||
UrlLocatorFilter m_urlFilter{UrlLocatorFilter::tr("Web Search"), "RemoteHelpFilter"};
|
UrlLocatorFilter m_urlFilter{UrlLocatorFilter::tr("Web Search"), "RemoteHelpFilter"};
|
||||||
UrlLocatorFilter m_bugFilter{UrlLocatorFilter::tr("Qt Project Bugs"), "QtProjectBugs"};
|
UrlLocatorFilter m_bugFilter{UrlLocatorFilter::tr("Qt Project Bugs"), "QtProjectBugs"};
|
||||||
#ifdef Q_OS_UNIX
|
|
||||||
SpotlightLocatorFilter m_spotlightLocatorFilter;
|
SpotlightLocatorFilter m_spotlightLocatorFilter;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
LocatorData::LocatorData()
|
LocatorData::LocatorData()
|
||||||
|
@@ -94,9 +94,11 @@ SpotlightIterator::SpotlightIterator(const QStringList &command)
|
|||||||
scheduleKillProcess();
|
scheduleKillProcess();
|
||||||
});
|
});
|
||||||
QObject::connect(m_process.get(), &QProcess::readyReadStandardOutput, [this] {
|
QObject::connect(m_process.get(), &QProcess::readyReadStandardOutput, [this] {
|
||||||
const QStringList items = QString::fromUtf8(m_process->readAllStandardOutput()).split('\n');
|
QString output = QString::fromUtf8(m_process->readAllStandardOutput());
|
||||||
|
output.replace("\r\n", "\n");
|
||||||
|
const QStringList items = output.split('\n');
|
||||||
QMutexLocker lock(&m_mutex);
|
QMutexLocker lock(&m_mutex);
|
||||||
m_queue.append(Utils::transform(items, &FilePath::fromString));
|
m_queue.append(Utils::transform(items, &FilePath::fromUserInput));
|
||||||
if (m_filePaths.size() + m_queue.size() > 10000) // limit the amount of data
|
if (m_filePaths.size() + m_queue.size() > 10000) // limit the amount of data
|
||||||
scheduleKillProcess();
|
scheduleKillProcess();
|
||||||
m_waitForItems.wakeAll();
|
m_waitForItems.wakeAll();
|
||||||
@@ -180,7 +182,7 @@ SpotlightLocatorFilter::SpotlightLocatorFilter()
|
|||||||
QString("kMDItemFSName = '*%1*'%2")
|
QString("kMDItemFSName = '*%1*'%2")
|
||||||
.arg(quoted, sensitivity == Qt::CaseInsensitive ? QString("c") : QString())});
|
.arg(quoted, sensitivity == Qt::CaseInsensitive ? QString("c") : QString())});
|
||||||
};
|
};
|
||||||
} else {
|
} else if (HostOsInfo::isLinuxHost()) {
|
||||||
command = [](const QString &query, Qt::CaseSensitivity sensitivity) {
|
command = [](const QString &query, Qt::CaseSensitivity sensitivity) {
|
||||||
QString regex = query;
|
QString regex = query;
|
||||||
regex = regex.replace('*', ".*");
|
regex = regex.replace('*', ".*");
|
||||||
@@ -188,6 +190,14 @@ SpotlightLocatorFilter::SpotlightLocatorFilter()
|
|||||||
+ (sensitivity == Qt::CaseInsensitive ? QStringList({"-i"}) : QStringList())
|
+ (sensitivity == Qt::CaseInsensitive ? QStringList({"-i"}) : QStringList())
|
||||||
+ QStringList({"-l", "10000", "-r", regex});
|
+ QStringList({"-l", "10000", "-r", regex});
|
||||||
};
|
};
|
||||||
|
} else if (HostOsInfo::isWindowsHost()) {
|
||||||
|
command = [](const QString &query, Qt::CaseSensitivity sensitivity) {
|
||||||
|
QString regex = query;
|
||||||
|
regex = regex.replace('*', ".*");
|
||||||
|
return QStringList({"es.exe"})
|
||||||
|
+ (sensitivity == Qt::CaseSensitive ? QStringList({"-i"}) : QStringList())
|
||||||
|
+ QStringList({"-n", "10000", "-r", regex});
|
||||||
|
};
|
||||||
}
|
}
|
||||||
setId("SpotlightFileNamesLocatorFilter");
|
setId("SpotlightFileNamesLocatorFilter");
|
||||||
setDisplayName(tr("File Name Index"));
|
setDisplayName(tr("File Name Index"));
|
||||||
|
Reference in New Issue
Block a user