2007-03-04 21:35:37 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 by Alexander Wiedenbruch <mail@wiedenbruch.de>
|
|
|
|
*
|
|
|
|
* 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 LINEEDIT_H
|
|
|
|
#define LINEEDIT_H
|
|
|
|
|
2007-05-25 04:27:33 +02:00
|
|
|
#include <QtCore/QObject>
|
2007-04-22 11:35:04 +02:00
|
|
|
#include <QtGui/QGraphicsTextItem>
|
2007-03-04 21:35:37 +01:00
|
|
|
|
2007-06-02 19:29:39 +02:00
|
|
|
#include <plasma/plasma_export.h>
|
2007-03-04 21:35:37 +01:00
|
|
|
|
2007-06-02 19:29:39 +02:00
|
|
|
#include <plasma/dataengine.h>
|
2007-06-21 20:07:39 +02:00
|
|
|
#include <plasma/plasma.h>
|
2007-06-02 19:29:39 +02:00
|
|
|
#include <plasma/widgets/layoutitem.h>
|
2007-03-04 21:35:37 +01:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2007-05-20 18:25:07 +02:00
|
|
|
/**
|
|
|
|
* Class that emulates a QLineEdit inside plasma
|
|
|
|
*/
|
2007-05-29 10:02:01 +02:00
|
|
|
class PLASMA_EXPORT LineEdit : public QGraphicsTextItem, public LayoutItem
|
2007-03-04 21:35:37 +01:00
|
|
|
{
|
2007-05-23 05:08:47 +02:00
|
|
|
Q_OBJECT
|
|
|
|
|
2007-03-04 21:35:37 +01:00
|
|
|
public:
|
2007-05-21 16:28:03 +02:00
|
|
|
explicit LineEdit(QGraphicsItem *parent = 0, QGraphicsScene *scene = 0);
|
2007-03-04 21:35:37 +01:00
|
|
|
~LineEdit();
|
|
|
|
|
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
|
|
|
|
2007-05-28 07:52:56 +02:00
|
|
|
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;
|
2007-06-21 20:07:39 +02:00
|
|
|
|
2007-06-21 17:42:05 +02:00
|
|
|
void setDefaultText(QString text);
|
|
|
|
const QString toHtml();
|
|
|
|
const QString toPlainText();
|
2007-05-28 07:52:56 +02:00
|
|
|
|
2007-06-21 20:07:39 +02:00
|
|
|
/**
|
|
|
|
* Reimplented from QGraphicsItem
|
|
|
|
**/
|
|
|
|
enum { Type = Plasma::LineEditType };
|
|
|
|
int type() const { return Type; }
|
|
|
|
|
2007-06-20 21:49:31 +02:00
|
|
|
Q_SIGNALS:
|
|
|
|
void editingFinished();
|
2007-06-20 22:12:38 +02:00
|
|
|
void textChanged(const QString &text);
|
2007-05-28 07:52:56 +02:00
|
|
|
|
2007-03-04 21:35:37 +01:00
|
|
|
public Q_SLOTS:
|
2007-05-23 05:08:47 +02:00
|
|
|
void updated(const QString&, const Plasma::DataEngine::Data&);
|
2007-05-24 21:36:05 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private* const d;
|
2007-06-20 22:12:38 +02:00
|
|
|
QString oldText;
|
2007-06-21 17:42:05 +02:00
|
|
|
QString defaultText;
|
|
|
|
QString defaultTextPlain;
|
2007-06-20 21:49:31 +02:00
|
|
|
|
|
|
|
protected:
|
2007-06-21 17:42:05 +02:00
|
|
|
void keyPressEvent(QKeyEvent *event);
|
|
|
|
void focusInEvent(QFocusEvent *event);
|
|
|
|
void focusOutEvent(QFocusEvent *event);
|
2007-03-04 21:35:37 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
#endif
|