forked from qt-creator/qt-creator
UrlLocatorFilter: Remove the old matchesFor() implementation
Change-Id: I2d04f4bf66ec12c8c641cbfb39a4c2b0049ecdc4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -16,7 +16,6 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QMutexLocker>
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -163,8 +162,6 @@ UrlLocatorFilter::UrlLocatorFilter(const QString &displayName, Id id)
|
|||||||
setDefaultIncludedByDefault(false);
|
setDefaultIncludedByDefault(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
UrlLocatorFilter::~UrlLocatorFilter() = default;
|
|
||||||
|
|
||||||
LocatorMatcherTasks UrlLocatorFilter::matchers()
|
LocatorMatcherTasks UrlLocatorFilter::matchers()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
using namespace Tasking;
|
||||||
@@ -191,28 +188,6 @@ LocatorMatcherTasks UrlLocatorFilter::matchers()
|
|||||||
return {{Sync(onSetup), storage}};
|
return {{Sync(onSetup), storage}};
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Core::LocatorFilterEntry> UrlLocatorFilter::matchesFor(
|
|
||||||
QFutureInterface<Core::LocatorFilterEntry> &future, const QString &entry)
|
|
||||||
{
|
|
||||||
QList<Core::LocatorFilterEntry> entries;
|
|
||||||
const QStringList urls = remoteUrls();
|
|
||||||
for (const QString &url : urls) {
|
|
||||||
if (future.isCanceled())
|
|
||||||
break;
|
|
||||||
const QString name = url.arg(entry);
|
|
||||||
Core::LocatorFilterEntry filterEntry;
|
|
||||||
filterEntry.displayName = name;
|
|
||||||
filterEntry.acceptor = [name] {
|
|
||||||
if (!name.isEmpty())
|
|
||||||
QDesktopServices::openUrl(name);
|
|
||||||
return AcceptResult();
|
|
||||||
};
|
|
||||||
filterEntry.highlightInfo = {int(name.lastIndexOf(entry)), int(entry.length())};
|
|
||||||
entries.append(filterEntry);
|
|
||||||
}
|
|
||||||
return entries;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char kDisplayNameKey[] = "displayName";
|
const char kDisplayNameKey[] = "displayName";
|
||||||
const char kRemoteUrlsKey[] = "remoteUrls";
|
const char kRemoteUrlsKey[] = "remoteUrls";
|
||||||
|
|
||||||
@@ -266,7 +241,6 @@ bool UrlLocatorFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
|
|||||||
Q_UNUSED(needsRefresh)
|
Q_UNUSED(needsRefresh)
|
||||||
Internal::UrlFilterOptions optionsDialog(this, parent);
|
Internal::UrlFilterOptions optionsDialog(this, parent);
|
||||||
if (optionsDialog.exec() == QDialog::Accepted) {
|
if (optionsDialog.exec() == QDialog::Accepted) {
|
||||||
QMutexLocker lock(&m_mutex);
|
|
||||||
m_remoteUrls.clear();
|
m_remoteUrls.clear();
|
||||||
setIncludedByDefault(optionsDialog.includeByDefault->isChecked());
|
setIncludedByDefault(optionsDialog.includeByDefault->isChecked());
|
||||||
setShortcutString(optionsDialog.shortcutEdit->text().trimmed());
|
setShortcutString(optionsDialog.shortcutEdit->text().trimmed());
|
||||||
@@ -285,20 +259,4 @@ void UrlLocatorFilter::addDefaultUrl(const QString &urlTemplate)
|
|||||||
m_defaultUrls.append(urlTemplate);
|
m_defaultUrls.append(urlTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList UrlLocatorFilter::remoteUrls() const
|
|
||||||
{
|
|
||||||
QMutexLocker lock(&m_mutex);
|
|
||||||
return m_remoteUrls;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UrlLocatorFilter::setIsCustomFilter(bool value)
|
|
||||||
{
|
|
||||||
m_isCustomFilter = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UrlLocatorFilter::isCustomFilter() const
|
|
||||||
{
|
|
||||||
return m_isCustomFilter;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
#include <coreplugin/core_global.h>
|
#include <coreplugin/core_global.h>
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QMutex>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
@@ -21,23 +20,18 @@ namespace Core {
|
|||||||
|
|
||||||
class CORE_EXPORT UrlLocatorFilter final : public Core::ILocatorFilter
|
class CORE_EXPORT UrlLocatorFilter final : public Core::ILocatorFilter
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
public:
|
public:
|
||||||
UrlLocatorFilter(Utils::Id id);
|
UrlLocatorFilter(Utils::Id id);
|
||||||
UrlLocatorFilter(const QString &displayName, Utils::Id id);
|
UrlLocatorFilter(const QString &displayName, Utils::Id id);
|
||||||
~UrlLocatorFilter() final;
|
|
||||||
|
|
||||||
// ILocatorFilter
|
void restoreState(const QByteArray &state) final;
|
||||||
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
|
bool openConfigDialog(QWidget *parent, bool &needsRefresh) final;
|
||||||
const QString &entry) override;
|
|
||||||
void restoreState(const QByteArray &state) override;
|
|
||||||
bool openConfigDialog(QWidget *parent, bool &needsRefresh) override;
|
|
||||||
|
|
||||||
void addDefaultUrl(const QString &urlTemplate);
|
void addDefaultUrl(const QString &urlTemplate);
|
||||||
QStringList remoteUrls() const;
|
QStringList remoteUrls() const { return m_remoteUrls; }
|
||||||
|
|
||||||
void setIsCustomFilter(bool value);
|
void setIsCustomFilter(bool value) { m_isCustomFilter = value; }
|
||||||
bool isCustomFilter() const;
|
bool isCustomFilter() const { return m_isCustomFilter; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void saveState(QJsonObject &object) const final;
|
void saveState(QJsonObject &object) const final;
|
||||||
@@ -50,7 +44,6 @@ private:
|
|||||||
QStringList m_defaultUrls;
|
QStringList m_defaultUrls;
|
||||||
QStringList m_remoteUrls;
|
QStringList m_remoteUrls;
|
||||||
bool m_isCustomFilter = false;
|
bool m_isCustomFilter = false;
|
||||||
mutable QMutex m_mutex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -81,5 +74,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
Reference in New Issue
Block a user