18 #ifndef QGSLOCATORFILTER_H
19 #define QGSLOCATORFILTER_H
25 #include "qgis_core.h"
52 , displayString( displayString )
53 , userData( userData )
62 QVariant getUserData()
const;
124 , iconPath( iconPath )
137 QList<QgsLocatorResult::ResultAction>
actions;
174 Q_DECLARE_FLAGS( Flags, Flag )
192 virtual QString
name()
const = 0;
209 virtual QgsLocatorFilter::Flags flags()
const;
228 virtual QString
prefix()
const {
return QString(); }
237 virtual QStringList
prepare(
const QString &
string,
const QgsLocatorContext &context ) { Q_UNUSED(
string ) Q_UNUSED( context );
return QStringList();}
272 virtual void triggerResultFromAction(
const QgsLocatorResult &result,
const int actionId );
289 bool useWithoutPrefix()
const;
296 void setUseWithoutPrefix(
bool useWithoutPrefix );
304 QString activePrefix()
const;
312 void setActivePrefix(
const QString &activePrefix )
SIP_SKIP;
320 static bool stringMatches(
const QString &candidate,
const QString &search );
327 static double fuzzyScore(
const QString &candidate,
const QString &search );
333 bool enabled()
const;
339 void setEnabled(
bool enabled );
345 virtual bool hasConfigWidget()
const;
353 virtual void openConfigWidget( QWidget *parent =
nullptr );
361 void logMessage(
const QString &message,
Qgis::MessageLevel level = Qgis::MessageLevel::Info );
393 bool mEnabled =
true;
394 bool mUseWithoutPrefix =
true;
395 QString mActivePrefifx = QString();
396 int mFetchResultsDelay = 0;
MessageLevel
Level for messages This will be used both for message log and message bar in application.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Encapsulates the properties relating to the context of a locator search.
Abstract base class for filters which collect locator results.
virtual QString prefix() const
Returns the search prefix character(s) for this filter.
virtual QgsLocatorFilter * clone() const =0
Creates a clone of the filter.
Flag
Flags for locator behavior.
int fetchResultsDelay() const
Returns the delay (in milliseconds) for the filter to wait prior to fetching results.
Priority
Filter priority. Controls the order of results in the locator.
@ Highest
Highest priority.
void setFetchResultsDelay(int delay)
Sets a delay (in milliseconds) for the filter to wait prior to fetching results.
virtual QString description() const
Returns a translated, description for the filter.
void finished()
Emitted when the filter finishes fetching results.
virtual QString displayName() const =0
Returns a translated, user-friendly name for the filter.
virtual Priority priority() const
Returns the priority for the filter, which controls how results are ordered in the locator.
virtual QString name() const =0
Returns the unique name for the filter.
virtual void triggerResult(const QgsLocatorResult &result)=0
Triggers a filter result from this filter.
virtual void clearPreviousResults()
This method will be called on main thread on the original filter (not a clone) before fetching result...
void resultFetched(const QgsLocatorResult &result)
Should be emitted by filters whenever they encounter a matching result during within their fetchResul...
virtual void fetchResults(const QString &string, const QgsLocatorContext &context, QgsFeedback *feedback)=0
Retrieves the filter results for a specified search string.
virtual QStringList prepare(const QString &string, const QgsLocatorContext &context)
Prepares the filter instance for an upcoming search for the specified string.
Encapsulates properties of an individual matching result found by a QgsLocatorFilter.
QList< QgsLocatorResult::ResultAction > actions
Additional actions to be used in a locator widget for the given result.
QVariant userData
Custom reference or other data set by the filter.
QString description
Descriptive text for result.
QgsLocatorResult()=default
Constructor for QgsLocatorResult.
QString displayString
String displayed for result.
QString group
Group the results by categories If left as empty string, this means that results are all shown withou...
QIcon icon
Icon for result.
QgsLocatorResult(QgsLocatorFilter *filter, const QString &displayString, const QVariant &userData=QVariant())
Constructor for QgsLocatorResult.
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
The ResultAction stores basic information for additional actions to be used in a locator widget for t...
ResultAction(int id, QString text, QString iconPath=QString())
Constructor for ResultAction The id used to recognized the action when the result is triggered.
ResultAction()=default
Constructor for ResultAction.