prep DataEngine::Private for direct loading of packages, ala plasmoids

svn path=/trunk/KDE/kdelibs/; revision=1159707
This commit is contained in:
Aaron J. Seigo 2010-08-06 01:26:11 +00:00
parent 1cef7c2a8d
commit 36c90e7137
2 changed files with 12 additions and 11 deletions

View File

@ -48,13 +48,13 @@ namespace Plasma
DataEngine::DataEngine(QObject *parent, KService::Ptr service) DataEngine::DataEngine(QObject *parent, KService::Ptr service)
: QObject(parent), : QObject(parent),
d(new DataEnginePrivate(this, service)) d(new DataEnginePrivate(this, KPluginInfo(service)))
{ {
} }
DataEngine::DataEngine(QObject *parent, const QVariantList &args) DataEngine::DataEngine(QObject *parent, const QVariantList &args)
: QObject(parent), : QObject(parent),
d(new DataEnginePrivate(this, KService::serviceByStorageId(args.count() > 0 ? args[0].toString() : QString()))) d(new DataEnginePrivate(this, KPluginInfo(KService::serviceByStorageId(args.count() > 0 ? args[0].toString() : QString()))))
{ {
} }
@ -508,9 +508,9 @@ void DataEngine::setStorageEnable(const QString &source, bool store)
} }
// Private class implementations // Private class implementations
DataEnginePrivate::DataEnginePrivate(DataEngine *e, KService::Ptr service) DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginInfo &info)
: q(e), : q(e),
dataEngineDescription(service), dataEngineDescription(info),
refCount(-1), // first ref refCount(-1), // first ref
checkSourcesTimerId(0), checkSourcesTimerId(0),
updateTimerId(0), updateTimerId(0),
@ -523,17 +523,17 @@ DataEnginePrivate::DataEnginePrivate(DataEngine *e, KService::Ptr service)
{ {
updateTimestamp.start(); updateTimestamp.start();
if (!service) { if (!info.isValid()) {
engineName = i18n("Unnamed"); engineName = i18n("Unnamed");
return; return;
} }
engineName = service->name(); engineName = info.name();
if (engineName.isEmpty()) { if (engineName.isEmpty()) {
engineName = i18n("Unnamed"); engineName = i18n("Unnamed");
} }
e->setObjectName(engineName); e->setObjectName(engineName);
icon = service->icon(); icon = info.icon();
if (dataEngineDescription.isValid()) { if (dataEngineDescription.isValid()) {
QString api = dataEngineDescription.property("X-Plasma-API").toString(); QString api = dataEngineDescription.property("X-Plasma-API").toString();
@ -542,8 +542,7 @@ DataEnginePrivate::DataEnginePrivate(DataEngine *e, KService::Ptr service)
const QString path = const QString path =
KStandardDirs::locate("data", KStandardDirs::locate("data",
"plasma/dataengines/" + dataEngineDescription.pluginName() + '/'); "plasma/dataengines/" + dataEngineDescription.pluginName() + '/');
PackageStructure::Ptr structure = PackageStructure::Ptr structure = Plasma::packageStructure(api, Plasma::DataEngineComponent);
Plasma::packageStructure(api, Plasma::DataEngineComponent);
structure->setPath(path); structure->setPath(path);
package = new Package(path, structure); package = new Package(path, structure);
@ -737,9 +736,11 @@ void DataEnginePrivate::setupScriptSupport()
return; return;
} }
kDebug() << "setting up script support, package is in" << package->path() /*
kDebug() << "sletting up script support, package is in" << package->path()
<< "which is a" << package->structure()->type() << "package" << "which is a" << package->structure()->type() << "package"
<< ", main script is" << package->filePath("mainscript"); << ", main script is" << package->filePath("mainscript");
*/
QString translationsPath = package->filePath("translations"); QString translationsPath = package->filePath("translations");
if (!translationsPath.isEmpty()) { if (!translationsPath.isEmpty()) {

View File

@ -35,7 +35,7 @@ class Service;
class DataEnginePrivate class DataEnginePrivate
{ {
public: public:
DataEnginePrivate(DataEngine *e, KService::Ptr service); DataEnginePrivate(DataEngine *e, const KPluginInfo &info);
~DataEnginePrivate(); ~DataEnginePrivate();
DataContainer *source(const QString &sourceName, bool createWhenMissing = true); DataContainer *source(const QString &sourceName, bool createWhenMissing = true);
void connectSource(DataContainer *s, QObject *visualization, uint pollingInterval, void connectSource(DataContainer *s, QObject *visualization, uint pollingInterval,