src/hbwidgets/editors/hblineedit.h
changeset 0 16d8024aca5e
child 1 f7ac710697a9
equal deleted inserted replaced
-1:000000000000 0:16d8024aca5e
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (developer.feedback@nokia.com)
       
     6 **
       
     7 ** This file is part of the HbWidgets module of the UI Extensions for Mobile.
       
     8 **
       
     9 ** GNU Lesser General Public License Usage
       
    10 ** This file may be used under the terms of the GNU Lesser General Public
       
    11 ** License version 2.1 as published by the Free Software Foundation and
       
    12 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
       
    13 ** Please review the following information to ensure the GNU Lesser General
       
    14 ** Public License version 2.1 requirements will be met:
       
    15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    16 **
       
    17 ** In addition, as a special exception, Nokia gives you certain additional
       
    18 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    20 **
       
    21 ** If you have questions regarding the use of this file, please contact
       
    22 ** Nokia at developer.feedback@nokia.com.
       
    23 **
       
    24 ****************************************************************************/
       
    25 
       
    26 #ifndef HBLINEEDIT_H
       
    27 #define HBLINEEDIT_H
       
    28 
       
    29 #include <hbglobal.h>
       
    30 #include <hbnamespace.h>
       
    31 #include <hbabstractedit.h>
       
    32 #include <QFont>
       
    33 
       
    34 class HbLineEditPrivate;
       
    35 
       
    36 class HB_WIDGETS_EXPORT HbLineEdit: public HbAbstractEdit
       
    37 {
       
    38     Q_OBJECT
       
    39 
       
    40     Q_ENUMS(EchoMode)
       
    41 
       
    42     Q_PROPERTY(QString text READ text WRITE setText USER true)
       
    43     Q_PROPERTY(QString displayText READ displayText)
       
    44     Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength)
       
    45     Q_PROPERTY(bool hasSelectedText READ hasSelectedText)
       
    46     Q_PROPERTY(QString selectedText READ selectedText)
       
    47     Q_PROPERTY(int selectionStart READ selectionStart)
       
    48     Q_PROPERTY(int maxRows READ maxRows WRITE setMaxRows)
       
    49     Q_PROPERTY(int minRows READ minRows WRITE setMinRows)
       
    50     Q_PROPERTY(bool expandable READ isExpandable)
       
    51     Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode)
       
    52 
       
    53 public:
       
    54 
       
    55     explicit HbLineEdit(QGraphicsItem *parent = 0);
       
    56     explicit HbLineEdit(const QString &text, QGraphicsItem *parent = 0);
       
    57     virtual ~HbLineEdit();
       
    58 
       
    59     enum {
       
    60         Type = Hb::ItemType_LineEdit
       
    61     };
       
    62 
       
    63     int type() const;
       
    64 
       
    65     int maxLength() const;
       
    66     void setMaxLength(int length);
       
    67 
       
    68     void setMinRows(int rows);
       
    69     int minRows() const;
       
    70 
       
    71     void setMaxRows(int rows);
       
    72     int maxRows() const;
       
    73 
       
    74     bool isExpandable() const;
       
    75 
       
    76     QString text() const;
       
    77     QString displayText() const;
       
    78 
       
    79     bool hasSelectedText() const;
       
    80     QString selectedText() const;
       
    81     int selectionStart() const;
       
    82     void setSelection(int start, int length);
       
    83 
       
    84     void setCursorPosition(int pos);
       
    85 
       
    86     enum EchoMode { Normal, NoEcho, Password, PasswordEchoOnEdit };
       
    87     EchoMode echoMode() const;
       
    88     void setEchoMode(EchoMode);
       
    89 
       
    90     void setCapitalization ( QFont::Capitalization caps );
       
    91     QFont::Capitalization capitalization () const;
       
    92 
       
    93 public slots:
       
    94     void setText(const QString &text);
       
    95 
       
    96 signals:
       
    97     void editingFinished();
       
    98     void textChanged(const QString &text);
       
    99     void selectionChanged();
       
   100 
       
   101 protected:
       
   102     HbLineEdit(HbLineEditPrivate &dd, QGraphicsItem *parent);
       
   103 
       
   104     void inputMethodEvent(QInputMethodEvent *event);
       
   105     void keyPressEvent(QKeyEvent *event);
       
   106     void keyReleaseEvent(QKeyEvent *event);
       
   107 
       
   108     void resizeEvent(QGraphicsSceneResizeEvent *event);
       
   109 
       
   110     bool canInsertFromMimeData(const QMimeData *source) const;
       
   111     void insertFromMimeData(const QMimeData *source);
       
   112 
       
   113     void focusOutEvent ( QFocusEvent * event );
       
   114     void focusInEvent ( QFocusEvent * event );
       
   115 private:
       
   116     Q_DISABLE_COPY(HbLineEdit)
       
   117     Q_DECLARE_PRIVATE_D(d_ptr, HbLineEdit)
       
   118     Q_PRIVATE_SLOT(d_func(), void _q_textChanged())
       
   119     Q_PRIVATE_SLOT(d_func(), void _q_textChange(int,int,int))
       
   120 };
       
   121 
       
   122 Q_DECLARE_METATYPE(HbLineEdit::EchoMode)
       
   123 
       
   124 #endif // HBLINEEDIT_H