diff --git a/widgets/lineedit.cpp b/widgets/lineedit.cpp index df55e6e64..8c23dfdfd 100644 --- a/widgets/lineedit.cpp +++ b/widgets/lineedit.cpp @@ -19,6 +19,7 @@ #include "lineedit.h" #include +#include namespace Plasma { @@ -61,15 +62,69 @@ void LineEdit::updated(const QString&, const DataEngine::Data& data) { DataEngine::DataIterator it(data); - //TODO: this only shows the first possible data item. - // should it do more? + QString text; while (it.hasNext()) { it.next(); if (it.value().canConvert(QVariant::String)) { - setPlainText(it.value().toString()); - return; + text.append(QString("

%1: %2

").arg(it.key(), it.value().toString())); } } + setHtml(text); +} + +Qt::Orientations LineEdit::expandingDirections() const +{ + return Qt::Vertical; +} + +QSizeF LineEdit::minimumSize() const +{ + return boundingRect().size(); +} + +QSizeF LineEdit::maximumSize() const +{ + return minimumSize(); +} + +bool LineEdit::hasHeightForWidth() const +{ + return true; +} + +qreal LineEdit::heightForWidth(qreal w) const +{ + QTextDocument* doc = document(); + doc->setTextWidth(w); + qreal height = doc->size().height(); + kDebug() << "LineEdit::heightForWidth(" << w << ") is " << height << endl; + return height; +} + +bool LineEdit::hasWidthForHeight() const +{ + return false; +} + +qreal LineEdit::widthForHeight(qreal h) const +{ + return 0; +} + +QRectF LineEdit::geometry() const +{ + return boundingRect().toRect(); +} + +void LineEdit::setGeometry(const QRectF& geometry) +{ + setTextWidth(geometry.width()); +} + +QSizeF LineEdit::sizeHint() const +{ + kDebug() << "LineEdit::sizeeHint() " << document()->size() << endl; + return document()->size(); } } // namespace Plasma diff --git a/widgets/lineedit.h b/widgets/lineedit.h index 7fb56dce7..629da4592 100644 --- a/widgets/lineedit.h +++ b/widgets/lineedit.h @@ -25,6 +25,7 @@ #include #include +#include namespace Plasma { @@ -32,7 +33,7 @@ namespace Plasma /** * Class that emulates a QLineEdit inside plasma */ -class KDE_EXPORT LineEdit : public QGraphicsTextItem +class KDE_EXPORT LineEdit : public QGraphicsTextItem, public LayoutItem { Q_OBJECT @@ -42,6 +43,22 @@ class KDE_EXPORT LineEdit : public QGraphicsTextItem void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); + Qt::Orientations expandingDirections() const; + + QSizeF minimumSize() const; + QSizeF maximumSize() const; + + bool hasHeightForWidth() const; + qreal heightForWidth(qreal w) const; + + bool hasWidthForHeight() const; + qreal widthForHeight(qreal h) const; + + QRectF geometry() const; + void setGeometry(const QRectF& geometry); + QSizeF sizeHint() const; + + public Q_SLOTS: void updated(const QString&, const Plasma::DataEngine::Data&);