add MimeType and URLs to matches
every single runner thus written knows this at the time of matching, so more efficient to store it up-front than have to later resort to calling (the inneficient but perfect for drag and drop) mimeDataForMatch method.
This commit is contained in:
parent
9612317115
commit
53622d0214
@ -65,6 +65,8 @@ class QueryMatchPrivate : public QSharedData
|
|||||||
subtext = other.subtext;
|
subtext = other.subtext;
|
||||||
icon = other.icon;
|
icon = other.icon;
|
||||||
data = other.data;
|
data = other.data;
|
||||||
|
mimeType = other.mimeType;
|
||||||
|
urls = other.urls;
|
||||||
}
|
}
|
||||||
|
|
||||||
~QueryMatchPrivate()
|
~QueryMatchPrivate()
|
||||||
@ -78,6 +80,8 @@ class QueryMatchPrivate : public QSharedData
|
|||||||
QString id;
|
QString id;
|
||||||
QString text;
|
QString text;
|
||||||
QString subtext;
|
QString subtext;
|
||||||
|
QString mimeType;
|
||||||
|
QList<QUrl> urls;
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
QVariant data;
|
QVariant data;
|
||||||
qreal relevance;
|
qreal relevance;
|
||||||
@ -210,6 +214,30 @@ QIcon QueryMatch::icon() const
|
|||||||
return d->icon;
|
return d->icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QueryMatch::setMimeType(const QString &mimeType)
|
||||||
|
{
|
||||||
|
QWriteLocker locker(d->lock);
|
||||||
|
d->mimeType = mimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QueryMatch::mimeType() const
|
||||||
|
{
|
||||||
|
QReadLocker locker(d->lock);
|
||||||
|
return d->mimeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QueryMatch::setUrls(const QList<QUrl> &urls)
|
||||||
|
{
|
||||||
|
QWriteLocker locker(d->lock);
|
||||||
|
d->urls = urls;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QUrl> QueryMatch::urls() const
|
||||||
|
{
|
||||||
|
QReadLocker locker(d->lock);
|
||||||
|
return d->urls;
|
||||||
|
}
|
||||||
|
|
||||||
void QueryMatch::setEnabled(bool enabled)
|
void QueryMatch::setEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
d->enabled = enabled;
|
d->enabled = enabled;
|
||||||
|
41
querymatch.h
41
querymatch.h
@ -21,6 +21,7 @@
|
|||||||
#define PLASMA_QUERYMATCH_H
|
#define PLASMA_QUERYMATCH_H
|
||||||
|
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
|
#include <QtCore/QUrl>
|
||||||
#include <QtCore/QSharedDataPointer>
|
#include <QtCore/QSharedDataPointer>
|
||||||
|
|
||||||
#include <plasma/plasma_export.h>
|
#include <plasma/plasma_export.h>
|
||||||
@ -92,6 +93,15 @@ class PLASMA_EXPORT QueryMatch
|
|||||||
*/
|
*/
|
||||||
AbstractRunner *runner() const;
|
AbstractRunner *runner() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests this match to activae using the given context
|
||||||
|
*
|
||||||
|
* @param context the context to use in conjunction with this run
|
||||||
|
*
|
||||||
|
* @sa AbstractRunner::run
|
||||||
|
*/
|
||||||
|
void run(const RunnerContext &context) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if the match is valid and can therefore be run,
|
* @return true if the match is valid and can therefore be run,
|
||||||
* an invalid match does not have an associated AbstractRunner
|
* an invalid match does not have an associated AbstractRunner
|
||||||
@ -124,15 +134,6 @@ class PLASMA_EXPORT QueryMatch
|
|||||||
*/
|
*/
|
||||||
qreal relevance() const;
|
qreal relevance() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Requests this match to activae using the given context
|
|
||||||
*
|
|
||||||
* @param context the context to use in conjunction with this run
|
|
||||||
*
|
|
||||||
* @sa AbstractRunner::run
|
|
||||||
*/
|
|
||||||
void run(const RunnerContext &context) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets data to be used internally by the associated
|
* Sets data to be used internally by the associated
|
||||||
* AbstractRunner.
|
* AbstractRunner.
|
||||||
@ -208,6 +209,28 @@ class PLASMA_EXPORT QueryMatch
|
|||||||
*/
|
*/
|
||||||
QIcon icon() const;
|
QIcon icon() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the MimeType, if any, associated with this match.
|
||||||
|
* This overrides the MimeType provided by QueryContext, and should only be
|
||||||
|
* set when it is different from the QueryContext MimeType
|
||||||
|
*/
|
||||||
|
void setMimeType(const QString &mimeType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the mimtype for this match, or QString() is none
|
||||||
|
*/
|
||||||
|
QString mimeType() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the urls, if any, associated with this match
|
||||||
|
*/
|
||||||
|
void setUrls(const QList<QUrl> &urls);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the mimtype for this match, or QString() is none
|
||||||
|
*/
|
||||||
|
QList<QUrl> urls() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether or not this match can be activited
|
* Sets whether or not this match can be activited
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user