[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/plasma/runners/wikipedia
From: Sebastian Kügler <sebas () kde ! org>
Date: 2009-10-31 22:31:30
Message-ID: 1257028290.335521.27631.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1043166 by sebas:
Make it possible to use the same library for different runners
And add a techbase runner. The URL, name and icon are now loaded
from
This needs an updated servicetype from kdelibs to work.
M +1 -0 CMakeLists.txt
M +30 -4 wikipedia.cpp
M +3 -0 wikipedia.h
M +2 -0 wikipediarunner.desktop
--- trunk/playground/base/plasma/runners/wikipedia/CMakeLists.txt #1043165:1043166
@@ -9,4 +9,5 @@
install(TARGETS krunner_wikipedia DESTINATION ${PLUGIN_INSTALL_DIR} )
install(FILES wikipediarunner.desktop DESTINATION ${SERVICES_INSTALL_DIR})
+install(FILES userbaserunner.desktop DESTINATION ${SERVICES_INSTALL_DIR})
--- trunk/playground/base/plasma/runners/wikipedia/wikipedia.cpp #1043165:1043166
@@ -23,6 +23,9 @@
#include <KDebug>
#include <KToolInvocation>
+#include <KPluginInfo>
+#include <KServiceTypeTrader>
+
#include "mediawiki.h"
@@ -33,8 +36,31 @@
Q_UNUSED(args);
setObjectName("Wikipedia");
m_icon = KIcon("applications-internet");
+ //m_apiUrl = QUrl("http://en.wikipedia.org/w/api.php");
+ QString constraint;
+ if (!id().isEmpty()) {
+ //QString _id = "krunner_" + id();
+ constraint.append(QString("[X-KDE-PluginInfo-Name] == '%1'").arg(id()));
+ }
+ KService::List offers = KServiceTypeTrader::self()->query("Plasma/Runner", constraint);
+ foreach (const KPluginInfo &info, KPluginInfo::fromServices(offers)) {
+
+ QStringList _urls = info.property("X-Plasma-Args").toStringList();
+ QString _u;
+ kDebug() << info.name() << info.property("X-Plasma-Args").toStringList() << _urls.count();
+ if (_urls.count()) {
+ _u = _urls[0];
+ kDebug() << _u << m_name << m_comment;
+ }
+ m_name = info.name();
+ m_comment = info.comment();
+ m_icon = KIcon(info.icon());
+ m_apiUrl = _u;
+ }
+
+ kDebug() << "ID:" << id();
Plasma::RunnerSyntax s(":q:", i18n("Finds entries on Wikipedia matching :q:."));
s.addExampleQuery(":q:");
addSyntax(s);
@@ -63,14 +89,14 @@
m_wikipedia = new MediaWiki();
m_wikipedia->setMaxItems(3);
- m_wikipedia->setApiUrl( QUrl("http://en.wikipedia.org/w/api.php") );
+ m_wikipedia->setApiUrl( m_apiUrl );
connect( m_wikipedia, SIGNAL(finished(bool)), SLOT(wikipediaFinished(bool)) );
connect( this, SIGNAL(done()), &loop, SLOT(quit()) );
m_context = &context;
m_wikipedia->search(term);
kDebug() << "Wikisearch:" << term;
-
+
loop.exec();
delete m_wikipedia;
@@ -86,8 +112,8 @@
kDebug() << ">>>>>>>>> Match:" << res.url << res.title;
Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::PossibleMatch);
- match.setIcon(KIcon("applications-internet"));
- match.setText(QString("Wikipedia: %1").arg(res.title));
+ match.setIcon(m_icon);
+ match.setText(QString("%1: %2").arg(m_name, res.title));
match.setData(res.url);
m_context->addMatch(res.title, match);
}
--- trunk/playground/base/plasma/runners/wikipedia/wikipedia.h #1043165:1043166
@@ -44,7 +44,10 @@
private:
KIcon m_icon;
+ QString m_name;
+ QString m_comment;
MediaWiki* m_wikipedia;
+ QUrl m_apiUrl;
Plasma::RunnerContext* m_context;
};
--- trunk/playground/base/plasma/runners/wikipedia/wikipediarunner.desktop #1043165:1043166
@@ -33,3 +33,5 @@
X-KDE-PluginInfo-Version=1.0
X-KDE-PluginInfo-License=LGPL
X-KDE-PluginInfo-EnabledByDefault=true
+
+X-Plasma-Args=http://wikipedia.org/w/api.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic