From 2fe1ec286b4b6ccb17f31a5b4ca4ae5e576cc45c Mon Sep 17 00:00:00 2001 From: stv Date: Mon, 11 Sep 2006 13:36:58 +0000 Subject: [PATCH] Property "Selection" --- src/QDS/QDS_LineEdit.cxx | 28 ++++++++++++++++++++++++++++ src/QDS/QDS_LineEdit.h | 6 ++++++ 2 files changed, 34 insertions(+) diff --git a/src/QDS/QDS_LineEdit.cxx b/src/QDS/QDS_LineEdit.cxx index 803d9397f..cb5ddf148 100644 --- a/src/QDS/QDS_LineEdit.cxx +++ b/src/QDS/QDS_LineEdit.cxx @@ -125,6 +125,34 @@ void QDS_LineEdit::selectAll() lineEdit()->selectAll(); } +/*! + Deselect all text in the editor. +*/ +void QDS_LineEdit::deselect() +{ + if ( lineEdit() ) + lineEdit()->deselect(); +} + +/*! + Select or deselect all text in the editor. +*/ +void QDS_LineEdit::setSelection( const bool on ) +{ + if ( on ) + selectAll(); + else + deselect(); +} + +/*! + Returns true if the editor has selected text. +*/ +bool QDS_LineEdit::hasSelection() const +{ + return lineEdit() ? lineEdit()->hasSelectedText() : false; +} + /*! Set the aligment of line edit. Reimplemented from QDS_Datum. */ diff --git a/src/QDS/QDS_LineEdit.h b/src/QDS/QDS_LineEdit.h index e67b86e2b..293e57eed 100644 --- a/src/QDS/QDS_LineEdit.h +++ b/src/QDS/QDS_LineEdit.h @@ -27,6 +27,8 @@ class QDS_EXPORT QDS_LineEdit : public QDS_Datum { Q_OBJECT + Q_PROPERTY( bool Selection READ hasSelection WRITE setSelection ) + protected: class Editor; @@ -34,9 +36,13 @@ public: QDS_LineEdit( const QString&, QWidget* = 0, const int = All, const QString& = QString::null ); virtual ~QDS_LineEdit(); + virtual void deselect(); virtual void selectAll(); virtual void setAlignment( const int, const int = Label ); + bool hasSelection() const; + void setSelection( const bool ); + signals: void returnPressed(); -- 2.39.2