Changeset 561 for trunk/src/gui/widgets/qlineedit_p.h
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/widgets/qlineedit_p.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 66 66 #include "QtGui/qlineedit.h" 67 67 68 #include "private/qlinecontrol_p.h" 69 68 70 QT_BEGIN_NAMESPACE 69 71 … … 74 76 75 77 QLineEditPrivate() 76 : cursor(0), preeditCursor(0), cursorTimer(0), frame(1), 77 cursorVisible(0), hideCursor(false), separator(0), readOnly(0), 78 dragEnabled(0), contextMenuEnabled(1), echoMode(0), textDirty(0), 79 selDirty(0), validInput(1), alignment(Qt::AlignLeading | Qt::AlignVCenter), ascent(0), 80 maxLength(32767), hscroll(0), vscroll(0), lastCursorPos(-1), maskData(0), 81 modifiedState(0), undoState(0), selstart(0), selend(0), userInput(false), 82 emitingEditingFinished(false), passwordEchoEditing(false) 83 #ifndef QT_NO_COMPLETER 84 , completer(0) 85 #endif 86 , leftTextMargin(0), topTextMargin(0), rightTextMargin(0), bottomTextMargin(0) 87 { 88 } 78 : control(0), frame(1), contextMenuEnabled(1), cursorVisible(0), 79 dragEnabled(0), clickCausedFocus(0), hscroll(0), vscroll(0), 80 alignment(Qt::AlignLeading | Qt::AlignVCenter), 81 leftTextMargin(0), topTextMargin(0), rightTextMargin(0), bottomTextMargin(0) 82 { 83 } 89 84 90 85 ~QLineEditPrivate() 91 86 { 92 delete [] maskData;87 delete control; 93 88 } 94 void init(const QString&);95 89 96 QString text; 97 int cursor; 98 int preeditCursor; 99 int cursorTimer; // -1 for non blinking cursor. 100 QPoint tripleClick; 101 QBasicTimer tripleClickTimer; 102 uint frame : 1; 103 uint cursorVisible : 1; 104 uint hideCursor : 1; // used to hide the cursor inside preedit areas 105 uint separator : 1; 106 uint readOnly : 1; 107 uint dragEnabled : 1; 108 uint contextMenuEnabled : 1; 109 uint echoMode : 2; 110 uint textDirty : 1; 111 uint selDirty : 1; 112 uint validInput : 1; 113 uint alignment; 114 int ascent; 115 int maxLength; 116 int hscroll; 117 int vscroll; 118 int lastCursorPos; 90 QLineControl *control; 119 91 120 92 #ifndef QT_NO_CONTEXTMENU 121 93 QPointer<QAction> selectAllAction; 122 94 #endif 95 void init(const QString&); 123 96 124 inline void emitCursorPositionChanged(); 125 bool sendMouseEventToInputContext(QMouseEvent *e); 97 int xToPos(int x, QTextLine::CursorPosition = QTextLine::CursorBetweenCharacters) const; 98 QRect cursorRect() const; 99 void setCursorVisible(bool visible); 126 100 127 void finishChange(int validateFromState = -1, bool update = false, bool edited = true);101 void updatePasswordEchoEditing(bool); 128 102 129 QPointer<QValidator> validator; 130 struct MaskInputData { 131 enum Casemode { NoCaseMode, Upper, Lower }; 132 QChar maskChar; // either the separator char or the inputmask 133 bool separator; 134 Casemode caseMode; 135 }; 136 QString inputMask; 137 QChar blank; 138 MaskInputData *maskData; 139 inline int nextMaskBlank(int pos) { 140 int c = findInMask(pos, true, false); 141 separator |= (c != pos); 142 return (c != -1 ? c : maxLength); 143 } 144 inline int prevMaskBlank(int pos) { 145 int c = findInMask(pos, false, false); 146 separator |= (c != pos); 147 return (c != -1 ? c : 0); 103 inline bool shouldEnableInputMethod() const 104 { 105 return !control->isReadOnly(); 148 106 } 149 107 150 void setCursorVisible(bool visible); 108 QPoint tripleClick; 109 QBasicTimer tripleClickTimer; 110 uint frame : 1; 111 uint contextMenuEnabled : 1; 112 uint cursorVisible : 1; 113 uint dragEnabled : 1; 114 uint clickCausedFocus : 1; 115 int hscroll; 116 int vscroll; 117 uint alignment; 118 static const int verticalMargin; 119 static const int horizontalMargin; 151 120 152 153 // undo/redo handling 154 enum CommandType { Separator, Insert, Remove, Delete, RemoveSelection, DeleteSelection, SetSelection }; 155 struct Command { 156 inline Command() {} 157 inline Command(CommandType t, int p, QChar c, int ss, int se) : type(t),uc(c),pos(p),selStart(ss),selEnd(se) {} 158 uint type : 4; 159 QChar uc; 160 int pos, selStart, selEnd; 161 }; 162 int modifiedState; 163 int undoState; 164 QVector<Command> history; 165 void addCommand(const Command& cmd); 166 void insert(const QString& s); 167 void del(bool wasBackspace = false); 168 void remove(int pos); 169 170 inline void separate() { separator = true; } 171 void undo(int until = -1); 172 void redo(); 173 inline bool isUndoAvailable() const { return !readOnly && undoState; } 174 inline bool isRedoAvailable() const { return !readOnly && undoState < (int)history.size(); } 175 176 // selection 177 int selstart, selend; 178 inline bool allSelected() const { return !text.isEmpty() && selstart == 0 && selend == (int)text.length(); } 179 inline bool hasSelectedText() const { return !text.isEmpty() && selend > selstart; } 180 inline void deselect() { selDirty |= (selend > selstart); selstart = selend = 0; } 181 void removeSelectedText(); 182 #ifndef QT_NO_CLIPBOARD 183 void copy(bool clipboard = true) const; 184 #endif 185 inline bool inSelection(int x) const 186 { if (selstart >= selend) return false; 187 int pos = xToPos(x, QTextLine::CursorOnCharacter); return pos >= selstart && pos < selend; } 188 189 // masking 190 void parseInputMask(const QString &maskFields); 191 bool isValidInput(QChar key, QChar mask) const; 192 bool hasAcceptableInput(const QString &text) const; 193 QString maskString(uint pos, const QString &str, bool clear = false) const; 194 QString clearString(uint pos, uint len) const; 195 QString stripString(const QString &str) const; 196 int findInMask(int pos, bool forward, bool findSeparator, QChar searchChar = QChar()) const; 197 198 // input methods 199 bool composeMode() const { return !textLayout.preeditAreaText().isEmpty(); } 200 201 // complex text layout 202 QTextLayout textLayout; 203 void updateTextLayout(); 204 void moveCursor(int pos, bool mark = false); 205 void setText(const QString& txt, int pos = -1, bool edited = true); 206 int xToPos(int x, QTextLine::CursorPosition = QTextLine::CursorBetweenCharacters) const; 207 QRect cursorRect() const; 208 bool fixup(); 121 bool sendMouseEventToInputContext(QMouseEvent *e); 209 122 210 123 QRect adjustedContentsRect() const; 211 124 125 void _q_handleWindowActivate(); 126 void _q_textEdited(const QString &); 127 void _q_cursorPositionChanged(int, int); 128 #ifdef QT_KEYPAD_NAVIGATION 129 void _q_editFocusChange(bool); 130 #endif 131 void _q_selectionChanged(); 132 #ifndef QT_NO_COMPLETER 133 void _q_completionHighlighted(QString); 134 #endif 212 135 #ifndef QT_NO_DRAGANDDROP 213 // drag and drop214 136 QPoint dndPos; 215 137 QBasicTimer dndTimer; 216 138 void drag(); 217 #endif218 219 void _q_clipboardChanged();220 void _q_handleWindowActivate();221 void _q_deleteSelected();222 bool userInput;223 bool emitingEditingFinished;224 225 #ifdef QT_KEYPAD_NAVIGATION226 QBasicTimer deleteAllTimer; // keypad navigation227 QString origText;228 #endif229 230 bool passwordEchoEditing;231 void updatePasswordEchoEditing(bool editing);232 233 #ifndef QT_NO_COMPLETER234 QPointer<QCompleter> completer;235 void complete(int key = -1);236 void _q_completionHighlighted(QString);237 bool advanceToEnabledItem(int n);238 139 #endif 239 140 … … 242 143 int rightTextMargin; 243 144 int bottomTextMargin; 145 146 QString placeholderText; 244 147 }; 245 148
Note:
See TracChangeset
for help on using the changeset viewer.