[2] | 1 | /****************************************************************************
|
---|
| 2 | **
|
---|
[846] | 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
[561] | 4 | ** All rights reserved.
|
---|
| 5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
[2] | 6 | **
|
---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
| 8 | **
|
---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
| 10 | ** Commercial Usage
|
---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
| 14 | ** a written agreement between you and Nokia.
|
---|
| 15 | **
|
---|
| 16 | ** GNU Lesser General Public License Usage
|
---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
| 20 | ** packaging of this file. Please review the following information to
|
---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
| 23 | **
|
---|
[561] | 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
[2] | 27 | **
|
---|
| 28 | ** GNU General Public License Usage
|
---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
| 32 | ** packaging of this file. Please review the following information to
|
---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
| 35 | **
|
---|
[561] | 36 | ** If you have questions regarding the use of this file, please contact
|
---|
| 37 | ** Nokia at qt-info@nokia.com.
|
---|
[2] | 38 | ** $QT_END_LICENSE$
|
---|
| 39 | **
|
---|
| 40 | ****************************************************************************/
|
---|
| 41 |
|
---|
| 42 | #ifndef QLINEEDIT_H
|
---|
| 43 | #define QLINEEDIT_H
|
---|
| 44 |
|
---|
| 45 | #include <QtGui/qframe.h>
|
---|
| 46 | #include <QtCore/qstring.h>
|
---|
[561] | 47 | #include <QtCore/qmargins.h>
|
---|
[2] | 48 |
|
---|
| 49 | QT_BEGIN_HEADER
|
---|
| 50 |
|
---|
| 51 | QT_BEGIN_NAMESPACE
|
---|
| 52 |
|
---|
| 53 | QT_MODULE(Gui)
|
---|
| 54 |
|
---|
| 55 | #ifndef QT_NO_LINEEDIT
|
---|
| 56 |
|
---|
| 57 | class QValidator;
|
---|
| 58 | class QMenu;
|
---|
| 59 | class QLineEditPrivate;
|
---|
| 60 | class QCompleter;
|
---|
| 61 | class QStyleOptionFrame;
|
---|
| 62 | class QAbstractSpinBox;
|
---|
| 63 | class QDateTimeEdit;
|
---|
| 64 |
|
---|
| 65 | class Q_GUI_EXPORT QLineEdit : public QWidget
|
---|
| 66 | {
|
---|
| 67 | Q_OBJECT
|
---|
| 68 |
|
---|
| 69 | Q_ENUMS(EchoMode)
|
---|
| 70 | Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask)
|
---|
| 71 | Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged USER true)
|
---|
| 72 | Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength)
|
---|
| 73 | Q_PROPERTY(bool frame READ hasFrame WRITE setFrame)
|
---|
| 74 | Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode)
|
---|
| 75 | Q_PROPERTY(QString displayText READ displayText)
|
---|
| 76 | Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition)
|
---|
| 77 | Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
|
---|
| 78 | Q_PROPERTY(bool modified READ isModified WRITE setModified DESIGNABLE false)
|
---|
| 79 | Q_PROPERTY(bool hasSelectedText READ hasSelectedText)
|
---|
| 80 | Q_PROPERTY(QString selectedText READ selectedText)
|
---|
| 81 | Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled)
|
---|
| 82 | Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
|
---|
| 83 | Q_PROPERTY(bool undoAvailable READ isUndoAvailable)
|
---|
| 84 | Q_PROPERTY(bool redoAvailable READ isRedoAvailable)
|
---|
| 85 | Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
|
---|
[561] | 86 | Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
|
---|
[2] | 87 |
|
---|
| 88 | public:
|
---|
| 89 | explicit QLineEdit(QWidget* parent=0);
|
---|
| 90 | explicit QLineEdit(const QString &, QWidget* parent=0);
|
---|
| 91 | #ifdef QT3_SUPPORT
|
---|
| 92 | QT3_SUPPORT_CONSTRUCTOR QLineEdit(QWidget* parent, const char* name);
|
---|
| 93 | QT3_SUPPORT_CONSTRUCTOR QLineEdit(const QString &, QWidget* parent, const char* name);
|
---|
| 94 | QT3_SUPPORT_CONSTRUCTOR QLineEdit(const QString &, const QString &, QWidget* parent=0, const char* name=0);
|
---|
| 95 | #endif
|
---|
| 96 | ~QLineEdit();
|
---|
| 97 |
|
---|
| 98 | QString text() const;
|
---|
| 99 |
|
---|
| 100 | QString displayText() const;
|
---|
| 101 |
|
---|
[561] | 102 | QString placeholderText() const;
|
---|
| 103 | void setPlaceholderText(const QString &);
|
---|
| 104 |
|
---|
[2] | 105 | int maxLength() const;
|
---|
| 106 | void setMaxLength(int);
|
---|
| 107 |
|
---|
| 108 | void setFrame(bool);
|
---|
| 109 | bool hasFrame() const;
|
---|
| 110 |
|
---|
| 111 | enum EchoMode { Normal, NoEcho, Password, PasswordEchoOnEdit };
|
---|
| 112 | EchoMode echoMode() const;
|
---|
| 113 | void setEchoMode(EchoMode);
|
---|
| 114 |
|
---|
| 115 | bool isReadOnly() const;
|
---|
| 116 | void setReadOnly(bool);
|
---|
| 117 |
|
---|
| 118 | #ifndef QT_NO_VALIDATOR
|
---|
| 119 | void setValidator(const QValidator *);
|
---|
| 120 | const QValidator * validator() const;
|
---|
| 121 | #endif
|
---|
| 122 |
|
---|
| 123 | #ifndef QT_NO_COMPLETER
|
---|
| 124 | void setCompleter(QCompleter *completer);
|
---|
| 125 | QCompleter *completer() const;
|
---|
| 126 | #endif
|
---|
| 127 |
|
---|
| 128 | QSize sizeHint() const;
|
---|
| 129 | QSize minimumSizeHint() const;
|
---|
| 130 |
|
---|
| 131 | int cursorPosition() const;
|
---|
| 132 | void setCursorPosition(int);
|
---|
| 133 | int cursorPositionAt(const QPoint &pos);
|
---|
| 134 |
|
---|
| 135 | void setAlignment(Qt::Alignment flag);
|
---|
| 136 | Qt::Alignment alignment() const;
|
---|
| 137 |
|
---|
| 138 | void cursorForward(bool mark, int steps = 1);
|
---|
| 139 | void cursorBackward(bool mark, int steps = 1);
|
---|
| 140 | void cursorWordForward(bool mark);
|
---|
| 141 | void cursorWordBackward(bool mark);
|
---|
| 142 | void backspace();
|
---|
| 143 | void del();
|
---|
| 144 | void home(bool mark);
|
---|
| 145 | void end(bool mark);
|
---|
| 146 |
|
---|
| 147 | bool isModified() const;
|
---|
| 148 | void setModified(bool);
|
---|
| 149 |
|
---|
| 150 | void setSelection(int, int);
|
---|
| 151 | bool hasSelectedText() const;
|
---|
| 152 | QString selectedText() const;
|
---|
| 153 | int selectionStart() const;
|
---|
| 154 |
|
---|
| 155 | bool isUndoAvailable() const;
|
---|
| 156 | bool isRedoAvailable() const;
|
---|
| 157 |
|
---|
| 158 | void setDragEnabled(bool b);
|
---|
| 159 | bool dragEnabled() const;
|
---|
| 160 |
|
---|
| 161 | QString inputMask() const;
|
---|
| 162 | void setInputMask(const QString &inputMask);
|
---|
| 163 | bool hasAcceptableInput() const;
|
---|
| 164 |
|
---|
| 165 | void setTextMargins(int left, int top, int right, int bottom);
|
---|
[561] | 166 | void setTextMargins(const QMargins &margins);
|
---|
[2] | 167 | void getTextMargins(int *left, int *top, int *right, int *bottom) const;
|
---|
[561] | 168 | QMargins textMargins() const;
|
---|
[2] | 169 |
|
---|
| 170 | public Q_SLOTS:
|
---|
| 171 | void setText(const QString &);
|
---|
| 172 | void clear();
|
---|
| 173 | void selectAll();
|
---|
| 174 | void undo();
|
---|
| 175 | void redo();
|
---|
| 176 | #ifndef QT_NO_CLIPBOARD
|
---|
| 177 | void cut();
|
---|
| 178 | void copy() const;
|
---|
| 179 | void paste();
|
---|
| 180 | #endif
|
---|
| 181 |
|
---|
| 182 | public:
|
---|
| 183 | void deselect();
|
---|
| 184 | void insert(const QString &);
|
---|
| 185 | #ifndef QT_NO_CONTEXTMENU
|
---|
| 186 | QMenu *createStandardContextMenu();
|
---|
| 187 | #endif
|
---|
| 188 |
|
---|
| 189 | Q_SIGNALS:
|
---|
| 190 | void textChanged(const QString &);
|
---|
| 191 | void textEdited(const QString &);
|
---|
| 192 | void cursorPositionChanged(int, int);
|
---|
| 193 | void returnPressed();
|
---|
| 194 | void editingFinished();
|
---|
| 195 | void selectionChanged();
|
---|
| 196 |
|
---|
| 197 | protected:
|
---|
| 198 | void mousePressEvent(QMouseEvent *);
|
---|
| 199 | void mouseMoveEvent(QMouseEvent *);
|
---|
| 200 | void mouseReleaseEvent(QMouseEvent *);
|
---|
| 201 | void mouseDoubleClickEvent(QMouseEvent *);
|
---|
| 202 | void keyPressEvent(QKeyEvent *);
|
---|
| 203 | void focusInEvent(QFocusEvent *);
|
---|
| 204 | void focusOutEvent(QFocusEvent *);
|
---|
| 205 | void paintEvent(QPaintEvent *);
|
---|
| 206 | #ifndef QT_NO_DRAGANDDROP
|
---|
| 207 | void dragEnterEvent(QDragEnterEvent *);
|
---|
| 208 | void dragMoveEvent(QDragMoveEvent *e);
|
---|
| 209 | void dragLeaveEvent(QDragLeaveEvent *e);
|
---|
| 210 | void dropEvent(QDropEvent *);
|
---|
| 211 | #endif
|
---|
| 212 | void changeEvent(QEvent *);
|
---|
| 213 | #ifndef QT_NO_CONTEXTMENU
|
---|
| 214 | void contextMenuEvent(QContextMenuEvent *);
|
---|
| 215 | #endif
|
---|
| 216 | #ifdef QT3_SUPPORT
|
---|
| 217 | inline QT3_SUPPORT void repaintArea(int, int) { update(); }
|
---|
| 218 | #endif
|
---|
| 219 |
|
---|
| 220 | void inputMethodEvent(QInputMethodEvent *);
|
---|
| 221 | void initStyleOption(QStyleOptionFrame *option) const;
|
---|
| 222 | public:
|
---|
| 223 | QVariant inputMethodQuery(Qt::InputMethodQuery) const;
|
---|
| 224 | bool event(QEvent *);
|
---|
| 225 | protected:
|
---|
| 226 | QRect cursorRect() const;
|
---|
| 227 |
|
---|
| 228 | public:
|
---|
| 229 | #ifdef QT3_SUPPORT
|
---|
| 230 | inline QT3_SUPPORT void clearModified() { setModified(false); }
|
---|
| 231 | inline QT3_SUPPORT void cursorLeft(bool mark, int steps = 1) { cursorForward(mark, -steps); }
|
---|
| 232 | inline QT3_SUPPORT void cursorRight(bool mark, int steps = 1) { cursorForward(mark, steps); }
|
---|
| 233 | QT3_SUPPORT bool validateAndSet(const QString &, int, int, int);
|
---|
| 234 | inline QT3_SUPPORT bool frame() const { return hasFrame(); }
|
---|
| 235 | #ifndef QT_NO_VALIDATOR
|
---|
| 236 | inline QT3_SUPPORT void clearValidator() { setValidator(0); }
|
---|
| 237 | #endif
|
---|
| 238 | inline QT3_SUPPORT bool hasMarkedText() const { return hasSelectedText(); }
|
---|
| 239 | inline QT3_SUPPORT QString markedText() const { return selectedText(); }
|
---|
| 240 | QT3_SUPPORT bool edited() const;
|
---|
| 241 | QT3_SUPPORT void setEdited(bool);
|
---|
| 242 | QT3_SUPPORT int characterAt(int, QChar*) const;
|
---|
| 243 | QT3_SUPPORT bool getSelection(int *, int *);
|
---|
| 244 |
|
---|
| 245 | QT3_SUPPORT void setFrameRect(QRect) {}
|
---|
| 246 | QT3_SUPPORT QRect frameRect() const { return QRect(); }
|
---|
| 247 | enum DummyFrame { Box, Sunken, Plain, Raised, MShadow, NoFrame, Panel, StyledPanel,
|
---|
| 248 | HLine, VLine, GroupBoxPanel, WinPanel, ToolBarPanel, MenuBarPanel,
|
---|
| 249 | PopupPanel, LineEditPanel, TabWidgetPanel, MShape };
|
---|
| 250 | QT3_SUPPORT void setFrameShadow(DummyFrame) {}
|
---|
| 251 | QT3_SUPPORT DummyFrame frameShadow() const { return Plain; }
|
---|
| 252 | QT3_SUPPORT void setFrameShape(DummyFrame) {}
|
---|
| 253 | QT3_SUPPORT DummyFrame frameShape() const { return NoFrame; }
|
---|
| 254 | QT3_SUPPORT void setFrameStyle(int) {}
|
---|
| 255 | QT3_SUPPORT int frameStyle() const { return 0; }
|
---|
| 256 | QT3_SUPPORT int frameWidth() const { return 0; }
|
---|
| 257 | QT3_SUPPORT void setLineWidth(int) {}
|
---|
| 258 | QT3_SUPPORT int lineWidth() const { return 0; }
|
---|
| 259 | QT3_SUPPORT void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); }
|
---|
| 260 | QT3_SUPPORT int margin() const
|
---|
| 261 | { int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy); return margin; }
|
---|
| 262 | QT3_SUPPORT void setMidLineWidth(int) {}
|
---|
| 263 | QT3_SUPPORT int midLineWidth() const { return 0; }
|
---|
| 264 |
|
---|
| 265 | Q_SIGNALS:
|
---|
| 266 | QT_MOC_COMPAT void lostFocus();
|
---|
| 267 | #endif
|
---|
| 268 |
|
---|
| 269 | private:
|
---|
| 270 | friend class QAbstractSpinBox;
|
---|
| 271 | #ifdef QT_KEYPAD_NAVIGATION
|
---|
| 272 | friend class QDateTimeEdit;
|
---|
| 273 | #endif
|
---|
| 274 | Q_DISABLE_COPY(QLineEdit)
|
---|
| 275 | Q_DECLARE_PRIVATE(QLineEdit)
|
---|
| 276 | Q_PRIVATE_SLOT(d_func(), void _q_handleWindowActivate())
|
---|
[561] | 277 | Q_PRIVATE_SLOT(d_func(), void _q_textEdited(const QString &))
|
---|
| 278 | Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged(int, int))
|
---|
[2] | 279 | #ifndef QT_NO_COMPLETER
|
---|
| 280 | Q_PRIVATE_SLOT(d_func(), void _q_completionHighlighted(QString))
|
---|
| 281 | #endif
|
---|
[561] | 282 | #ifdef QT_KEYPAD_NAVIGATION
|
---|
| 283 | Q_PRIVATE_SLOT(d_func(), void _q_editFocusChange(bool))
|
---|
| 284 | #endif
|
---|
| 285 | Q_PRIVATE_SLOT(d_func(), void _q_selectionChanged())
|
---|
[2] | 286 | };
|
---|
| 287 |
|
---|
| 288 | #endif // QT_NO_LINEEDIT
|
---|
| 289 |
|
---|
| 290 | QT_END_NAMESPACE
|
---|
| 291 |
|
---|
| 292 | QT_END_HEADER
|
---|
| 293 |
|
---|
| 294 | #endif // QLINEEDIT_H
|
---|