put dataUpdated magic back into the text displayers

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=826536
This commit is contained in:
Aaron J. Seigo 2008-06-30 22:05:11 +00:00
parent 878966df21
commit a4ba7d48f2
4 changed files with 35 additions and 1 deletions

View File

@ -157,6 +157,20 @@ QLabel* Label::nativeWidget() const
return static_cast<QLabel*>(widget());
}
void Label::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
{
Q_UNUSED(sourceName)
QStringList texts;
foreach (const QVariant& v, data) {
if (v.canConvert(QVariant::String)) {
texts << v.toString();
}
}
setText(texts.join(" "));
}
void Label::resizeEvent(QGraphicsSceneResizeEvent *event)
{
d->setPixmap(this);

View File

@ -24,6 +24,7 @@
#include <QtGui/QGraphicsProxyWidget>
#include <plasma/plasma_export.h>
#include <plasma/dataengine.h>
class QLabel;
@ -85,7 +86,8 @@ public:
*/
QLabel* nativeWidget() const;
Q_SIGNALS:
public Q_SLOTS:
void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);
protected:
void resizeEvent(QGraphicsSceneResizeEvent *event);

View File

@ -83,6 +83,20 @@ KTextEdit* TextEdit::nativeWidget() const
return static_cast<KTextEdit*>(widget());
}
void TextEdit::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
{
Q_UNUSED(sourceName)
KTextEdit * te = nativeWidget();
te->clear();
foreach (const QVariant& v, data) {
if (v.canConvert(QVariant::String)) {
te->append(v.toString() + "\n");
}
}
}
void TextEdit::resizeEvent(QGraphicsSceneResizeEvent *event)
{
QGraphicsProxyWidget::resizeEvent(event);

View File

@ -26,6 +26,7 @@
class KTextEdit;
#include <plasma/plasma_export.h>
#include <plasma/dataengine.h>
namespace Plasma
{
@ -72,6 +73,9 @@ public:
*/
KTextEdit* nativeWidget() const;
public Q_SLOTS:
void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);
Q_SIGNALS:
void textChanged();