forked from qt-creator/qt-creator
UrlLocatorFilter: Use Acceptor for LocatorFilterEntry
Change-Id: Id4b97a10bc01ab4392d7e7fc6e5890dcd3d42be9 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDesktopServices>
|
||||
@@ -19,7 +18,6 @@
|
||||
#include <QListWidget>
|
||||
#include <QMutexLocker>
|
||||
#include <QPushButton>
|
||||
#include <QUrl>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
@@ -176,26 +174,19 @@ QList<Core::LocatorFilterEntry> UrlLocatorFilter::matchesFor(
|
||||
if (future.isCanceled())
|
||||
break;
|
||||
const QString name = url.arg(entry);
|
||||
Core::LocatorFilterEntry filterEntry(this, name);
|
||||
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;
|
||||
}
|
||||
|
||||
void UrlLocatorFilter::accept(const Core::LocatorFilterEntry &selection,
|
||||
QString *newText,
|
||||
int *selectionStart,
|
||||
int *selectionLength) const
|
||||
{
|
||||
Q_UNUSED(newText)
|
||||
Q_UNUSED(selectionStart)
|
||||
Q_UNUSED(selectionLength)
|
||||
const QString &url = selection.displayName;
|
||||
if (!url.isEmpty())
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
|
||||
const char kDisplayNameKey[] = "displayName";
|
||||
const char kRemoteUrlsKey[] = "remoteUrls";
|
||||
|
||||
|
@@ -30,8 +30,6 @@ public:
|
||||
// ILocatorFilter
|
||||
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
|
||||
const QString &entry) override;
|
||||
void accept(const Core::LocatorFilterEntry &selection,
|
||||
QString *newText, int *selectionStart, int *selectionLength) const override;
|
||||
void restoreState(const QByteArray &state) override;
|
||||
bool openConfigDialog(QWidget *parent, bool &needsRefresh) override;
|
||||
|
||||
|
Reference in New Issue
Block a user