* make DataSource emit the name of the source along with the data; this makes it possible widgets connected to multiple DataSources to have a chance of doing the right thing
* make DataEngine take a QObject in the connect, making DataVisualization somewhere superfluous. unless it ends up doing something useful soon, DataVisualization as a class will be going away. svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=667167
This commit is contained in:
parent
ad5351fa3f
commit
879e215a43
@ -50,6 +50,7 @@ class DataEngine::Private
|
|||||||
<< ": could not find DataSource " << sourceName
|
<< ": could not find DataSource " << sourceName
|
||||||
<< ", creating" << endl;
|
<< ", creating" << endl;
|
||||||
DataSource* s = new DataSource(engine);
|
DataSource* s = new DataSource(engine);
|
||||||
|
emit engine->newDataSource(sourceName);
|
||||||
s->setName(sourceName);
|
s->setName(sourceName);
|
||||||
sources.insert(sourceName, s);
|
sources.insert(sourceName, s);
|
||||||
return s;
|
return s;
|
||||||
@ -89,19 +90,14 @@ QStringList DataEngine::dataSources()
|
|||||||
return d->sources.keys();
|
return d->sources.keys();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataEngine::connectSource(const QString& source, DataVisualization* visualization)
|
void DataEngine::connectSource(const QString& source, QObject* visualization)
|
||||||
{
|
{
|
||||||
Q_UNUSED(source)
|
Q_UNUSED(source)
|
||||||
Q_UNUSED(visualization)
|
Q_UNUSED(visualization)
|
||||||
|
|
||||||
DataSource* s = d->source(source);
|
DataSource* s = d->source(source);
|
||||||
// if (!s) {
|
connect(s, SIGNAL(updated(QString,Plasma::DataEngine::Data)),
|
||||||
// kDebug() << "DataEngine " << objectName() << ": could not find DataSource " << source << endl;
|
visualization, SLOT(updated(QString,Plasma::DataEngine::Data)));
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
connect(s, SIGNAL(updated(Plasma::DataEngine::Data)),
|
|
||||||
visualization, SLOT(updated(Plasma::DataEngine::Data)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataEngine::Data DataEngine::query(const QString& source)
|
DataEngine::Data DataEngine::query(const QString& source)
|
||||||
@ -146,6 +142,7 @@ void DataEngine::removeDataSource(const QString& source)
|
|||||||
{
|
{
|
||||||
DataSource::Dict::iterator it = d->sources.find(source);
|
DataSource::Dict::iterator it = d->sources.find(source);
|
||||||
if (it != d->sources.end()) {
|
if (it != d->sources.end()) {
|
||||||
|
emit dataSourceRemoved(it.key());
|
||||||
d->sources.erase(it);
|
d->sources.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,6 +152,7 @@ void DataEngine::clearAllDataSources()
|
|||||||
QMutableHashIterator<QString, Plasma::DataSource*> it(d->sources);
|
QMutableHashIterator<QString, Plasma::DataSource*> it(d->sources);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
|
emit dataSourceRemoved(it.key());
|
||||||
delete it.value();
|
delete it.value();
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
|
@ -44,13 +44,18 @@ class PLASMA_EXPORT DataEngine : public QObject
|
|||||||
virtual ~DataEngine();
|
virtual ~DataEngine();
|
||||||
|
|
||||||
virtual QStringList dataSources();
|
virtual QStringList dataSources();
|
||||||
void connectSource(const QString& source, DataVisualization* visualization);
|
void connectSource(const QString& source, QObject* visualization);
|
||||||
Data query(const QString& source);
|
Data query(const QString& source);
|
||||||
|
|
||||||
void ref();
|
void ref();
|
||||||
void deref();
|
void deref();
|
||||||
bool isUsed();
|
bool isUsed();
|
||||||
|
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void newDataSource(const QString& source);
|
||||||
|
void dataSourceRemoved(const QString& source);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void init();
|
virtual void init();
|
||||||
void setData(const QString& source, const QVariant& value);
|
void setData(const QString& source, const QVariant& value);
|
||||||
|
@ -33,7 +33,6 @@ class DataSource::Private
|
|||||||
: dirty(false)
|
: dirty(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QString name;
|
|
||||||
DataEngine::Data data;
|
DataEngine::Data data;
|
||||||
bool dirty;
|
bool dirty;
|
||||||
};
|
};
|
||||||
@ -73,7 +72,7 @@ void DataSource::setData(const QString& key, const QVariant& value)
|
|||||||
void DataSource::checkForUpdate()
|
void DataSource::checkForUpdate()
|
||||||
{
|
{
|
||||||
if (d->dirty) {
|
if (d->dirty) {
|
||||||
emit updated(d->data);
|
emit updated(objectName(), d->data);
|
||||||
d->dirty = false;
|
d->dirty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ class PLASMA_EXPORT DataSource : public QObject
|
|||||||
void checkForUpdate();
|
void checkForUpdate();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void updated(const Plasma::DataEngine::Data&);
|
void updated(const QString& source, const Plasma::DataEngine::Data& data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
|
@ -35,7 +35,7 @@ class PLASMA_EXPORT DataVisualization : public QObject
|
|||||||
virtual ~DataVisualization();
|
virtual ~DataVisualization();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
virtual void updated(const Plasma::DataEngine::Data&) = 0;
|
virtual void updated(const QString& source, const Plasma::DataEngine::Data&) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
|
@ -112,7 +112,7 @@ void CheckBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckBox::updated(const DataEngine::Data&)
|
void CheckBox::updated(const QString&, const DataEngine::Data&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ class KDE_EXPORT CheckBox : public DataVisualization,public QGraphicsItem
|
|||||||
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void updated(const DataEngine::Data&);
|
void updated(const QString&, const DataEngine::Data&);
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void clicked();
|
void clicked();
|
||||||
protected:
|
protected:
|
||||||
|
@ -24,8 +24,7 @@ namespace Plasma
|
|||||||
{
|
{
|
||||||
|
|
||||||
LineEdit::LineEdit(QGraphicsItem *parent, QGraphicsScene *scene)
|
LineEdit::LineEdit(QGraphicsItem *parent, QGraphicsScene *scene)
|
||||||
: QGraphicsTextItem(parent, scene),
|
: QGraphicsTextItem(parent, scene)
|
||||||
DataVisualization()
|
|
||||||
{
|
{
|
||||||
setTextInteractionFlags(Qt::TextEditorInteraction);
|
setTextInteractionFlags(Qt::TextEditorInteraction);
|
||||||
}
|
}
|
||||||
@ -53,7 +52,7 @@ void LineEdit::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||||||
QGraphicsTextItem::paint(painter, style, widget);
|
QGraphicsTextItem::paint(painter, style, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineEdit::updated(const DataEngine::Data& data)
|
void LineEdit::updated(const QString&, const DataEngine::Data& data)
|
||||||
{
|
{
|
||||||
DataEngine::DataIterator it(data);
|
DataEngine::DataIterator it(data);
|
||||||
|
|
||||||
|
@ -31,8 +31,7 @@ namespace Plasma
|
|||||||
/**
|
/**
|
||||||
* Class that emulates a QLineEdit inside plasma
|
* Class that emulates a QLineEdit inside plasma
|
||||||
*/
|
*/
|
||||||
class KDE_EXPORT LineEdit : public QGraphicsTextItem,
|
class KDE_EXPORT LineEdit : public QGraphicsTextItem
|
||||||
public DataVisualization
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit LineEdit(QGraphicsItem *parent = 0, QGraphicsScene *scene = 0);
|
explicit LineEdit(QGraphicsItem *parent = 0, QGraphicsScene *scene = 0);
|
||||||
@ -41,7 +40,7 @@ class KDE_EXPORT LineEdit : public QGraphicsTextItem,
|
|||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void updated(const DataEngine::Data&);
|
void updated(const QString&, const DataEngine::Data&);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Plasma
|
} // namespace Plasma
|
||||||
|
@ -82,7 +82,7 @@ PushButton::~PushButton()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PushButton::updated(const DataEngine::Data &data)
|
void PushButton::updated(const QString&, const DataEngine::Data &data)
|
||||||
{
|
{
|
||||||
Q_UNUSED(data)
|
Q_UNUSED(data)
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ class KDE_EXPORT PushButton : public DataVisualization,
|
|||||||
void clicked();
|
void clicked();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
virtual void updated(const DataEngine::Data &);
|
virtual void updated(const QString&, const DataEngine::Data &);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool isDown();
|
bool isDown();
|
||||||
|
@ -148,7 +148,7 @@ void RadioButton::setText(const QString &text)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RadioButton::updated(const Plasma::DataEngine::Data &data)
|
void RadioButton::updated(const QString&, const Plasma::DataEngine::Data &data)
|
||||||
{
|
{
|
||||||
Q_UNUSED(data);
|
Q_UNUSED(data);
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public:
|
|||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
// DataVisualization overridden virtual slots
|
// DataVisualization overridden virtual slots
|
||||||
void updated(const Plasma::DataEngine::Data &data);
|
void updated(const QString&, const Plasma::DataEngine::Data &data);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void clicked();
|
void clicked();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user