starting work on dataengines, datasource, datavisualizations, the plasma
app and applets ... doesn't compile atm as it's a work in progress off the design concepts. but dinner becons and i don't want to lose progress in case my laptop degrades further. svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=529282
This commit is contained in:
parent
842830bc29
commit
2664e2d35b
44
applet.cpp
44
applet.cpp
@ -19,12 +19,15 @@
|
||||
#include <QEvent>
|
||||
#include <QList>
|
||||
#include <QSize>
|
||||
#include <QStringList>
|
||||
#include <QTimer>
|
||||
|
||||
#include <kstandarddirs.h>
|
||||
|
||||
#include "applet.h"
|
||||
|
||||
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
@ -40,9 +43,13 @@ class Applet::Private
|
||||
chain(appletChain)
|
||||
{ }
|
||||
|
||||
// ~Private()
|
||||
// {
|
||||
// }
|
||||
~Private()
|
||||
{
|
||||
foreach (const QString& engine, loadedEngines)
|
||||
{
|
||||
Interface::interface()->unloadDataEngine(engine);
|
||||
}
|
||||
}
|
||||
|
||||
int id;
|
||||
KSharedConfig::Ptr globalConfig;
|
||||
@ -50,6 +57,7 @@ class Applet::Private
|
||||
KService::Ptr appletDescription;
|
||||
QList<QObject*> watchedForFocus;
|
||||
AppletChain::Ptr chain;
|
||||
QStringList loadedEngines;
|
||||
};
|
||||
|
||||
Applet::Applet(QWidget* parent,
|
||||
@ -67,6 +75,19 @@ Applet::~Applet()
|
||||
delete d;
|
||||
}
|
||||
|
||||
KSharedConfig::Ptr Applet::appletConfig() const
|
||||
{
|
||||
if (!d->appletConfig)
|
||||
{
|
||||
QString file = locateLocal("appdata",
|
||||
"applets/" + instanceName() + "rc",
|
||||
true);
|
||||
d->appletConfig = KSharedConfig::openConfig(file, false, true);
|
||||
}
|
||||
|
||||
return d->appletConfig;
|
||||
}
|
||||
|
||||
KSharedConfig::Ptr Applet::globalAppletConfig() const
|
||||
{
|
||||
if (!d->globalConfig)
|
||||
@ -80,17 +101,20 @@ KSharedConfig::Ptr Applet::globalAppletConfig() const
|
||||
return d->globalConfig;
|
||||
}
|
||||
|
||||
KSharedConfig::Ptr Applet::appletConfig() const
|
||||
bool Applet::loadDataEngine(const QString& name)
|
||||
{
|
||||
if (!d->appletConfig)
|
||||
if (d->loadedEngines.indexOf(name) != -1)
|
||||
{
|
||||
QString file = locateLocal("appdata",
|
||||
"applets/" + instanceName() + "rc",
|
||||
true);
|
||||
d->appletConfig = KSharedConfig::openConfig(file, false, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return d->appletConfig;
|
||||
if (PlasmaAppInterface::self()->loadDataEngine(name))
|
||||
{
|
||||
d->loadedEngines.append(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
const AppletChain::Ptr Applet::chain() const
|
||||
|
19
applet.h
19
applet.h
@ -50,16 +50,29 @@ class KDE_EXPORT Applet : public QWidget
|
||||
* named \<appletname\>rc in the user's local %KDE directory.
|
||||
*
|
||||
* For normal applets this config object will write to an instance
|
||||
* specific config file nameed \<appletname\>\<instanceid\>rc
|
||||
* specific config file named \<appletname\>\<instanceid\>rc
|
||||
* in the user's local %KDE directory.
|
||||
**/
|
||||
KSharedConfig::Ptr globalAppletConfig() const;
|
||||
KSharedConfig::Ptr appletConfig() const;
|
||||
|
||||
/**
|
||||
* Returns a KConfig object to be shared by all applets of this type
|
||||
* For unique applets, this will return the same config object as
|
||||
* appletConfig()
|
||||
*/
|
||||
KSharedConfig::Ptr globalAppletConfig() const;
|
||||
|
||||
/**
|
||||
* Ensures that the DataEngine named name is loaded and ready to be used
|
||||
*
|
||||
* @return returns true on success, false on failure
|
||||
*/
|
||||
bool loadDataEngine(const QString& name);
|
||||
|
||||
const AppletChain::Ptr chain() const;
|
||||
void setChain(const AppletChain::Ptr);
|
||||
|
||||
/*
|
||||
/**
|
||||
* called when any of the geometry constraints have been updated
|
||||
* this is always called prior to painting and should be used as an
|
||||
* opportunity to layout the widget, calculate sizings, etc.
|
||||
|
93
dataengine.h
Normal file
93
dataengine.h
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
* published by the Free Software Foundation
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef PLASMA_ENGINE_H
|
||||
#define PLASMA_ENGINE_H
|
||||
|
||||
#include <QAtomic>
|
||||
#include <QHash>
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class DataSource;
|
||||
class DataVisualization;
|
||||
|
||||
class DataSource : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
typedef QHash<QString, DataSource*> Dict;
|
||||
typedef QHash<QString, QVariant> Data;
|
||||
|
||||
DataSource(QObject* parent);
|
||||
virtual ~DataSource();
|
||||
|
||||
QString name();
|
||||
|
||||
signals:
|
||||
void data(const DataSource::Data&);
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private* d;
|
||||
};
|
||||
|
||||
class DataEngine : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
typedef QHash<QString, DataEngine*> Dict;
|
||||
|
||||
DataEngine(QObject* parent);
|
||||
virtual ~DataEngine();
|
||||
|
||||
virtual QStringList dataSources();
|
||||
void connect(const QString& source, DataVisualization* visualization);
|
||||
DataSource::Data query(const QString& source);
|
||||
|
||||
void ref();
|
||||
void deref();
|
||||
|
||||
protected:
|
||||
virtual void init();
|
||||
virtual void cleanup();
|
||||
virtual DataEngine* engine() = 0;
|
||||
virtual
|
||||
|
||||
private:
|
||||
QAtomic ref;
|
||||
class Private;
|
||||
Private* d;
|
||||
};
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#define K_EXPORT_PLASMA_ENGINE(libname, classname) \
|
||||
K_EXPORT_COMPONENT_FACTORY( \
|
||||
plasmaengine_##libname, \
|
||||
KGenericFactory<classname>("libplasmaengine_" #libname))
|
||||
|
||||
#endif // multiple inclusion guard
|
||||
|
||||
|
||||
#endif
|
48
datavisualization.h
Normal file
48
datavisualization.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
* published by the Free Software Foundation
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef PLASMA_DATAVISUALIZATION_H
|
||||
#define PLASMA_DATAVISUALIZATION_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "dataengine.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
// this will end up being multiple-inherited?
|
||||
class DataVisualization : QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DataVisualization(QObject* parent);
|
||||
virtual ~DataVisualization();
|
||||
|
||||
public slots:
|
||||
void data(const DataSource::Data&) = 0;
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private* d;
|
||||
};
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#endif // multiple inclusion guard
|
40
interface.h
Normal file
40
interface.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
* published by the Free Software Foundation
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef PLASMA_INTERFACE_H
|
||||
#define PLASMA_INTERFACE_H
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class Interface
|
||||
{
|
||||
public:
|
||||
static Interface* interface() { return m_interface; }
|
||||
|
||||
bool loadDataEngine(const QString& name) = 0;
|
||||
bool unloadDataEngine(const QString& name) = 0;
|
||||
|
||||
protected:
|
||||
Interface() : m_interface(0) {}
|
||||
static Interface* m_interface;
|
||||
};
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#endif // multiple inclusion guard
|
Loading…
Reference in New Issue
Block a user