mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
plasma: remove unused and redundant Plasma::RunnerContext methods
nothing but the manager is supposed to remove matches and there is a Plasma::RunnerContext::reset() method Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
ac5d407fd5
commit
f452997709
6 changed files with 11 additions and 180 deletions
|
@ -133,7 +133,7 @@ void AbstractRunner::clearActions()
|
||||||
d->actions.clear();
|
d->actions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QMimeData* AbstractRunner::mimeDataForMatch(const QueryMatch *match)
|
QMimeData* AbstractRunner::mimeDataForMatch(const QueryMatch &match)
|
||||||
{
|
{
|
||||||
Q_UNUSED(match)
|
Q_UNUSED(match)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -241,6 +241,12 @@ class PLASMA_EXPORT AbstractRunner : public QObject
|
||||||
*/
|
*/
|
||||||
void setPriority(Priority newPriority);
|
void setPriority(Priority newPriority);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reimplement this method if you want your runner to support drag and drop.
|
||||||
|
* @since 4.5
|
||||||
|
*/
|
||||||
|
virtual QMimeData* mimeDataForMatch(const Plasma::QueryMatch &match);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A given match can have more than action that can be performed on it.
|
* A given match can have more than action that can be performed on it.
|
||||||
* For example, a song match returned by a music player runner can be queued,
|
* For example, a song match returned by a music player runner can be queued,
|
||||||
|
@ -324,13 +330,6 @@ class PLASMA_EXPORT AbstractRunner : public QObject
|
||||||
*/
|
*/
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
/**
|
|
||||||
* Reimplement this slot if you want your runner
|
|
||||||
* to support serialization and drag and drop
|
|
||||||
* @since 4.5
|
|
||||||
*/
|
|
||||||
QMimeData * mimeDataForMatch(const Plasma::QueryMatch *match);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AbstractRunnerPrivate *const d;
|
AbstractRunnerPrivate *const d;
|
||||||
};
|
};
|
||||||
|
|
|
@ -385,94 +385,6 @@ bool RunnerContext::addMatch(const QueryMatch &match)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RunnerContext::removeMatches(const QStringList &matchIdList)
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList presentMatchIdList;
|
|
||||||
QList<const QueryMatch*> presentMatchList;
|
|
||||||
|
|
||||||
LOCK_FOR_READ(d)
|
|
||||||
foreach(const QString &matchId, matchIdList) {
|
|
||||||
const QueryMatch* match = d->matchesById.value(matchId, 0);
|
|
||||||
if (match) {
|
|
||||||
presentMatchList << match;
|
|
||||||
presentMatchIdList << matchId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UNLOCK(d)
|
|
||||||
|
|
||||||
if (presentMatchIdList.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOCK_FOR_WRITE(d)
|
|
||||||
foreach(const QueryMatch *match, presentMatchList) {
|
|
||||||
d->matches.removeAll(*match);
|
|
||||||
}
|
|
||||||
foreach(const QString &matchId, presentMatchIdList) {
|
|
||||||
d->matchesById.remove(matchId);
|
|
||||||
}
|
|
||||||
UNLOCK(d)
|
|
||||||
|
|
||||||
emit d->q->matchesChanged();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RunnerContext::removeMatch(const QString &matchId)
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
LOCK_FOR_READ(d)
|
|
||||||
const QueryMatch* match = d->matchesById.value(matchId, nullptr);
|
|
||||||
UNLOCK(d)
|
|
||||||
if (!match) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
LOCK_FOR_WRITE(d)
|
|
||||||
d->matches.removeAll(*match);
|
|
||||||
d->matchesById.remove(matchId);
|
|
||||||
UNLOCK(d)
|
|
||||||
emit d->q->matchesChanged();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RunnerContext::removeMatches(Plasma::AbstractRunner *runner)
|
|
||||||
{
|
|
||||||
if (!isValid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QueryMatch> presentMatchList;
|
|
||||||
|
|
||||||
LOCK_FOR_READ(d)
|
|
||||||
foreach(const QueryMatch &match, d->matches) {
|
|
||||||
if (match.runner() == runner) {
|
|
||||||
presentMatchList << match;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UNLOCK(d)
|
|
||||||
|
|
||||||
if (presentMatchList.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOCK_FOR_WRITE(d)
|
|
||||||
foreach (const QueryMatch &match, presentMatchList) {
|
|
||||||
d->matchesById.remove(match.id());
|
|
||||||
d->matches.removeAll(match);
|
|
||||||
}
|
|
||||||
UNLOCK(d)
|
|
||||||
|
|
||||||
emit d->q->matchesChanged();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QueryMatch> RunnerContext::matches() const
|
QList<QueryMatch> RunnerContext::matches() const
|
||||||
{
|
{
|
||||||
LOCK_FOR_READ(d)
|
LOCK_FOR_READ(d)
|
||||||
|
@ -481,19 +393,6 @@ QList<QueryMatch> RunnerContext::matches() const
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryMatch RunnerContext::match(const QString &id) const
|
|
||||||
{
|
|
||||||
LOCK_FOR_READ(d)
|
|
||||||
const QueryMatch *match = d->matchesById.value(id, nullptr);
|
|
||||||
UNLOCK(d)
|
|
||||||
|
|
||||||
if (match) {
|
|
||||||
return *match;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QueryMatch(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
|
||||||
#include "moc_runnercontext.cpp"
|
#include "moc_runnercontext.cpp"
|
||||||
|
|
|
@ -22,13 +22,10 @@
|
||||||
|
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/qshareddata.h>
|
#include <QtCore/QExplicitlySharedDataPointer>
|
||||||
|
|
||||||
#include <plasma/plasma_export.h>
|
#include <plasma/plasma_export.h>
|
||||||
|
|
||||||
class KCompletion;
|
|
||||||
class KConfigGroup;
|
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -77,9 +74,7 @@ public:
|
||||||
~RunnerContext();
|
~RunnerContext();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the search term for this object.
|
* Resets the search term for this object. This removes all current matches in the process.
|
||||||
* This removes all current matches in the process and
|
|
||||||
* turns off single runner query mode.
|
|
||||||
*/
|
*/
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
@ -140,42 +135,6 @@ public:
|
||||||
*/
|
*/
|
||||||
bool addMatch(const QueryMatch &match);
|
bool addMatch(const QueryMatch &match);
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a match from the existing list of matches.
|
|
||||||
*
|
|
||||||
* If you are going to be removing multiple matches, use removeMatches instead.
|
|
||||||
*
|
|
||||||
* @param matchId the id of match to remove
|
|
||||||
*
|
|
||||||
* @return true if the match was removed, false otherwise.
|
|
||||||
* @since 4.4
|
|
||||||
*/
|
|
||||||
bool removeMatch(const QString &matchId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes lists of matches from the existing list of matches.
|
|
||||||
*
|
|
||||||
* This method is thread safe and causes the matchesChanged() signal to be emitted.
|
|
||||||
*
|
|
||||||
* @param matchIdList the list of matches id to remove
|
|
||||||
*
|
|
||||||
* @return true if at least one match was removed, false otherwise.
|
|
||||||
* @since 4.4
|
|
||||||
*/
|
|
||||||
bool removeMatches(const QStringList &matchIdList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes lists of matches from a given AbstractRunner
|
|
||||||
*
|
|
||||||
* This method is thread safe and causes the matchesChanged() signal to be emitted.
|
|
||||||
*
|
|
||||||
* @param runner the AbstractRunner from which to remove matches
|
|
||||||
*
|
|
||||||
* @return true if at least one match was removed, false otherwise.
|
|
||||||
* @since 4.10
|
|
||||||
*/
|
|
||||||
bool removeMatches(AbstractRunner *runner);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all available matches for the current search term.
|
* Retrieves all available matches for the current search term.
|
||||||
*
|
*
|
||||||
|
@ -183,15 +142,6 @@ public:
|
||||||
*/
|
*/
|
||||||
QList<QueryMatch> matches() const;
|
QList<QueryMatch> matches() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a match by id.
|
|
||||||
*
|
|
||||||
* @param id the id of the match to return
|
|
||||||
* @return the match associated with this id, or an invalid QueryMatch object
|
|
||||||
* if the id does not eixst
|
|
||||||
*/
|
|
||||||
QueryMatch match(const QString &id) const;
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void matchesChanged();
|
void matchesChanged();
|
||||||
|
|
||||||
|
|
|
@ -277,22 +277,11 @@ QList<QAction*> RunnerManager::actionsForMatch(const QueryMatch &match)
|
||||||
return QList<QAction*>();
|
return QList<QAction*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
QMimeData* RunnerManager::mimeDataForMatch(const QString &id) const
|
|
||||||
{
|
|
||||||
return mimeDataForMatch(d->context.match(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
QMimeData* RunnerManager::mimeDataForMatch(const QueryMatch &match) const
|
QMimeData* RunnerManager::mimeDataForMatch(const QueryMatch &match) const
|
||||||
{
|
{
|
||||||
AbstractRunner *runner = match.runner();
|
AbstractRunner *runner = match.runner();
|
||||||
QMimeData *mimeData;
|
if (runner) {
|
||||||
if (runner && QMetaObject::invokeMethod(
|
return runner->mimeDataForMatch(match);
|
||||||
runner,
|
|
||||||
"mimeDataForMatch", Qt::DirectConnection,
|
|
||||||
Q_RETURN_ARG(QMimeData*, mimeData),
|
|
||||||
Q_ARG(const Plasma::QueryMatch *, &match)
|
|
||||||
)) {
|
|
||||||
return mimeData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -126,12 +126,6 @@ class PLASMA_EXPORT RunnerManager : public QObject
|
||||||
*/
|
*/
|
||||||
QMimeData* mimeDataForMatch(const QueryMatch &match) const;
|
QMimeData* mimeDataForMatch(const QueryMatch &match) const;
|
||||||
|
|
||||||
/**
|
|
||||||
* @return mime data of the specified match
|
|
||||||
* @since 4.5
|
|
||||||
*/
|
|
||||||
QMimeData* mimeDataForMatch(const QString &id) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all known Runner implementations
|
* Returns a list of all known Runner implementations
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue