diff --git a/plasma/abstractrunner.cpp b/plasma/abstractrunner.cpp index bfa31dd0..d2442e49 100644 --- a/plasma/abstractrunner.cpp +++ b/plasma/abstractrunner.cpp @@ -133,7 +133,7 @@ void AbstractRunner::clearActions() d->actions.clear(); } -QMimeData* AbstractRunner::mimeDataForMatch(const QueryMatch *match) +QMimeData* AbstractRunner::mimeDataForMatch(const QueryMatch &match) { Q_UNUSED(match) return nullptr; diff --git a/plasma/abstractrunner.h b/plasma/abstractrunner.h index ca4e2a49..3f3419cb 100644 --- a/plasma/abstractrunner.h +++ b/plasma/abstractrunner.h @@ -241,6 +241,12 @@ class PLASMA_EXPORT AbstractRunner : public QObject */ 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. * 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(); - /** - * 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: AbstractRunnerPrivate *const d; }; diff --git a/plasma/runnercontext.cpp b/plasma/runnercontext.cpp index 2d40733a..e78518c3 100644 --- a/plasma/runnercontext.cpp +++ b/plasma/runnercontext.cpp @@ -385,94 +385,6 @@ bool RunnerContext::addMatch(const QueryMatch &match) return true; } -bool RunnerContext::removeMatches(const QStringList &matchIdList) -{ - if (!isValid()) { - return false; - } - - QStringList presentMatchIdList; - QList 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 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 RunnerContext::matches() const { LOCK_FOR_READ(d) @@ -481,19 +393,6 @@ QList RunnerContext::matches() const 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 #include "moc_runnercontext.cpp" diff --git a/plasma/runnercontext.h b/plasma/runnercontext.h index c122ff8a..69341bfc 100644 --- a/plasma/runnercontext.h +++ b/plasma/runnercontext.h @@ -22,13 +22,10 @@ #include #include -#include +#include #include -class KCompletion; -class KConfigGroup; - namespace Plasma { @@ -77,9 +74,7 @@ public: ~RunnerContext(); /** - * Resets the search term for this object. - * This removes all current matches in the process and - * turns off single runner query mode. + * Resets the search term for this object. This removes all current matches in the process. */ void reset(); @@ -140,42 +135,6 @@ public: */ 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. * @@ -183,15 +142,6 @@ public: */ QList 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: void matchesChanged(); diff --git a/plasma/runnermanager.cpp b/plasma/runnermanager.cpp index 8b89fc65..b5c6f211 100644 --- a/plasma/runnermanager.cpp +++ b/plasma/runnermanager.cpp @@ -277,22 +277,11 @@ QList RunnerManager::actionsForMatch(const QueryMatch &match) return QList(); } -QMimeData* RunnerManager::mimeDataForMatch(const QString &id) const -{ - return mimeDataForMatch(d->context.match(id)); -} - QMimeData* RunnerManager::mimeDataForMatch(const QueryMatch &match) const { AbstractRunner *runner = match.runner(); - QMimeData *mimeData; - if (runner && QMetaObject::invokeMethod( - runner, - "mimeDataForMatch", Qt::DirectConnection, - Q_RETURN_ARG(QMimeData*, mimeData), - Q_ARG(const Plasma::QueryMatch *, &match) - )) { - return mimeData; + if (runner) { + return runner->mimeDataForMatch(match); } return nullptr; diff --git a/plasma/runnermanager.h b/plasma/runnermanager.h index 80071e30..8089cb40 100644 --- a/plasma/runnermanager.h +++ b/plasma/runnermanager.h @@ -126,12 +126,6 @@ class PLASMA_EXPORT RunnerManager : public QObject */ 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 *