Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/widgets/qlineedit_p.h

    r2 r561  
    22**
    33** 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)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    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.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** 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.
    3838** $QT_END_LICENSE$
    3939**
     
    6666#include "QtGui/qlineedit.h"
    6767
     68#include "private/qlinecontrol_p.h"
     69
    6870QT_BEGIN_NAMESPACE
    6971
     
    7476
    7577    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    }
    8984
    9085    ~QLineEditPrivate()
    9186    {
    92         delete [] maskData;
     87        delete control;
    9388    }
    94     void init(const QString&);
    9589
    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;
    11991
    12092#ifndef QT_NO_CONTEXTMENU
    12193    QPointer<QAction> selectAllAction;
    12294#endif
     95    void init(const QString&);
    12396
    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);
    126100
    127     void finishChange(int validateFromState = -1, bool update = false, bool edited = true);
     101    void updatePasswordEchoEditing(bool);
    128102
    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();
    148106    }
    149107
    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;
    151120
    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);
    209122
    210123    QRect adjustedContentsRect() const;
    211124
     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
    212135#ifndef QT_NO_DRAGANDDROP
    213     // drag and drop
    214136    QPoint dndPos;
    215137    QBasicTimer dndTimer;
    216138    void drag();
    217 #endif
    218 
    219     void _q_clipboardChanged();
    220     void _q_handleWindowActivate();
    221     void _q_deleteSelected();
    222     bool userInput;
    223     bool emitingEditingFinished;
    224 
    225 #ifdef QT_KEYPAD_NAVIGATION
    226     QBasicTimer deleteAllTimer; // keypad navigation
    227     QString origText;
    228 #endif
    229 
    230     bool passwordEchoEditing;
    231     void updatePasswordEchoEditing(bool editing);
    232 
    233 #ifndef QT_NO_COMPLETER
    234     QPointer<QCompleter> completer;
    235     void complete(int key = -1);
    236     void _q_completionHighlighted(QString);
    237     bool advanceToEnabledItem(int n);
    238139#endif
    239140
     
    242143    int rightTextMargin;
    243144    int bottomTextMargin;
     145
     146    QString placeholderText;
    244147};
    245148
Note: See TracChangeset for help on using the changeset viewer.