2007-03-04 21:35:37 +01:00
|
|
|
/*
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2007 by Alexander Wiedenbruch <mail@wiedenbruch.de>
|
2007-03-04 21:35:37 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-09-14 22:17:11 +02:00
|
|
|
* it under the terms of the GNU Library General Public License as
|
2007-09-14 21:06:18 +02:00
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
2007-03-04 21:35:37 +01:00
|
|
|
*
|
|
|
|
* 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-09-02 19:49:34 +02:00
|
|
|
Q_PROPERTY( bool styled READ styled WRITE setStyled )
|
|
|
|
Q_PROPERTY( bool multiLine READ multiLine WRITE setMultiLine )
|
|
|
|
Q_PROPERTY( QString defaultText WRITE setDefaultText )
|
|
|
|
Q_PROPERTY( QString html READ toHtml )
|
|
|
|
Q_PROPERTY( QString plainText READ toPlainText )
|
2007-05-23 05:08:47 +02:00
|
|
|
|
2007-03-04 21:35:37 +01:00
|
|
|
public:
|
2007-11-04 06:36:10 +01:00
|
|
|
explicit LineEdit(QGraphicsItem *parent = 0);
|
2007-03-04 21:35:37 +01:00
|
|
|
~LineEdit();
|
|
|
|
|
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
2007-08-01 22:51:27 +02:00
|
|
|
void paintWidget(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
2007-11-04 06:36:10 +01:00
|
|
|
|
2007-05-28 07:52:56 +02:00
|
|
|
Qt::Orientations expandingDirections() const;
|
|
|
|
|
|
|
|
QSizeF minimumSize() const;
|
|
|
|
QSizeF maximumSize() const;
|
|
|
|
|
2007-07-17 01:56:57 +02:00
|
|
|
void setStyled(bool style);
|
|
|
|
bool styled() const;
|
|
|
|
|
2007-07-22 15:41:34 +02:00
|
|
|
void setMultiLine(bool multi);
|
|
|
|
bool multiLine() const;
|
|
|
|
|
2007-05-28 07:52:56 +02:00
|
|
|
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-07-20 10:06:27 +02:00
|
|
|
void setDefaultText(const QString &text);
|
2007-06-21 17:42:05 +02:00
|
|
|
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-11-06 08:20:08 +01:00
|
|
|
void dataUpdated(const QString&, const Plasma::DataEngine::Data&);
|
2007-05-24 21:36:05 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private* const d;
|
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
|