src/gui/widgets/qlinecontrol_p.h
changeset 0 1918ee327afb
child 3 41300fa6a67c
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtGui module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    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 **
       
    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 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QLINECONTROL_P_H
       
    43 #define QLINECONTROL_P_H
       
    44 
       
    45 //
       
    46 //  W A R N I N G
       
    47 //  -------------
       
    48 //
       
    49 // This file is not part of the Qt API.  It exists purely as an
       
    50 // implementation detail.  This header file may change from version to
       
    51 // version without notice, or even be removed.
       
    52 //
       
    53 // We mean it.
       
    54 //
       
    55 
       
    56 #include "QtCore/qglobal.h"
       
    57 
       
    58 #ifndef QT_NO_LINEEDIT
       
    59 #include "private/qwidget_p.h"
       
    60 #include "QtGui/qlineedit.h"
       
    61 #include "QtGui/qtextlayout.h"
       
    62 #include "QtGui/qstyleoption.h"
       
    63 #include "QtCore/qpointer.h"
       
    64 #include "QtGui/qlineedit.h"
       
    65 #include "QtGui/qclipboard.h"
       
    66 #include "QtCore/qpoint.h"
       
    67 #include "QtGui/qcompleter.h"
       
    68 
       
    69 QT_BEGIN_HEADER
       
    70 
       
    71 QT_BEGIN_NAMESPACE
       
    72 
       
    73 QT_MODULE(Gui)
       
    74 
       
    75 class Q_GUI_EXPORT QLineControl : public QObject
       
    76 {
       
    77     Q_OBJECT
       
    78 
       
    79 public:
       
    80     QLineControl(const QString &txt = QString())
       
    81         : m_cursor(0), m_preeditCursor(0), m_cursorWidth(0), m_layoutDirection(Qt::LeftToRight),
       
    82         m_hideCursor(false), m_separator(0), m_readOnly(0),
       
    83         m_dragEnabled(0), m_echoMode(0), m_textDirty(0), m_selDirty(0),
       
    84         m_validInput(1), m_blinkStatus(0), m_blinkPeriod(0), m_blinkTimer(0), m_deleteAllTimer(0),
       
    85         m_ascent(0), m_maxLength(32767), m_lastCursorPos(-1),
       
    86         m_tripleClickTimer(0), m_maskData(0), m_modifiedState(0), m_undoState(0),
       
    87         m_selstart(0), m_selend(0), m_passwordEchoEditing(false)
       
    88     {
       
    89         init(txt);
       
    90     }
       
    91 
       
    92     ~QLineControl()
       
    93     {
       
    94         delete [] m_maskData;
       
    95     }
       
    96 
       
    97     int nextMaskBlank(int pos);
       
    98     int prevMaskBlank(int pos);
       
    99 
       
   100     bool isUndoAvailable() const;
       
   101     bool isRedoAvailable() const;
       
   102     void clearUndo();
       
   103     bool isModified() const;
       
   104     void setModified(bool modified);
       
   105 
       
   106     bool allSelected() const;
       
   107     bool hasSelectedText() const;
       
   108 
       
   109     int width() const;
       
   110     int height() const;
       
   111     int ascent() const;
       
   112     qreal naturalTextWidth() const;
       
   113 
       
   114     void setSelection(int start, int length);
       
   115 
       
   116     QString selectedText() const;
       
   117     QString textBeforeSelection() const;
       
   118     QString textAfterSelection() const;
       
   119 
       
   120     int selectionStart() const;
       
   121     int selectionEnd() const;
       
   122     bool inSelection(int x) const;
       
   123 
       
   124     void removeSelection();
       
   125 
       
   126     int start() const;
       
   127     int end() const;
       
   128 
       
   129 #ifndef QT_NO_CLIPBOARD
       
   130     void copy(QClipboard::Mode mode = QClipboard::Clipboard) const;
       
   131     void paste();
       
   132 #endif
       
   133 
       
   134     int cursor() const;
       
   135     int preeditCursor() const;
       
   136 
       
   137     int cursorWidth() const;
       
   138     void setCursorWidth(int value);
       
   139 
       
   140     void moveCursor(int pos, bool mark = false);
       
   141     void cursorForward(bool mark, int steps);
       
   142     void cursorWordForward(bool mark);
       
   143     void cursorWordBackward(bool mark);
       
   144     void home(bool mark);
       
   145     void end(bool mark);
       
   146 
       
   147     int xToPos(int x, QTextLine::CursorPosition = QTextLine::CursorBetweenCharacters) const;
       
   148     QRect cursorRect() const;
       
   149 
       
   150     qreal cursorToX(int cursor) const;
       
   151     qreal cursorToX() const;
       
   152 
       
   153     bool isReadOnly() const;
       
   154     void setReadOnly(bool enable);
       
   155 
       
   156     QString text() const;
       
   157     void setText(const QString &txt);
       
   158 
       
   159     QString displayText() const;
       
   160 
       
   161     void backspace();
       
   162     void del();
       
   163     void deselect();
       
   164     void selectAll();
       
   165     void insert(const QString &);
       
   166     void clear();
       
   167     void undo();
       
   168     void redo();
       
   169     void selectWordAtPos(int);
       
   170 
       
   171     uint echoMode() const;
       
   172     void setEchoMode(uint mode);
       
   173 
       
   174     void setMaxLength(int maxLength);
       
   175     int maxLength() const;
       
   176 
       
   177     const QValidator *validator() const;
       
   178     void setValidator(const QValidator *);
       
   179 
       
   180 #ifndef QT_NO_COMPLETER
       
   181     QCompleter *completer() const;
       
   182     void setCompleter(const QCompleter*);
       
   183     void complete(int key);
       
   184 #endif
       
   185 
       
   186     void setCursorPosition(int pos);
       
   187     int cursorPosition() const;
       
   188 
       
   189     bool hasAcceptableInput() const;
       
   190     bool fixup();
       
   191 
       
   192     QString inputMask() const;
       
   193     void setInputMask(const QString &mask);
       
   194 
       
   195     // input methods
       
   196 #ifndef QT_NO_IM
       
   197     bool composeMode() const;
       
   198     void setPreeditArea(int cursor, const QString &text);
       
   199 #endif
       
   200 
       
   201     QString preeditAreaText() const;
       
   202 
       
   203     void updatePasswordEchoEditing(bool editing);
       
   204     bool passwordEchoEditing() const;
       
   205 
       
   206     QChar passwordCharacter() const;
       
   207     void setPasswordCharacter(const QChar &character);
       
   208 
       
   209     Qt::LayoutDirection layoutDirection() const;
       
   210     void setLayoutDirection(Qt::LayoutDirection direction);
       
   211     void setFont(const QFont &font);
       
   212 
       
   213     void processInputMethodEvent(QInputMethodEvent *event);
       
   214     void processMouseEvent(QMouseEvent* ev);
       
   215     void processKeyEvent(QKeyEvent* ev);
       
   216 
       
   217     int cursorBlinkPeriod() const;
       
   218     void setCursorBlinkPeriod(int msec);
       
   219 
       
   220     QString cancelText() const;
       
   221     void setCancelText(const QString &text);
       
   222 
       
   223     const QPalette &palette() const;
       
   224     void setPalette(const QPalette &);
       
   225 
       
   226     enum DrawFlags {
       
   227         DrawText = 0x01,
       
   228         DrawSelections = 0x02,
       
   229         DrawCursor = 0x04,
       
   230         DrawAll = DrawText | DrawSelections | DrawCursor
       
   231     };
       
   232     void draw(QPainter *, const QPoint &, const QRect &, int flags = DrawAll);
       
   233 
       
   234     bool processEvent(QEvent *ev);
       
   235 
       
   236 private:
       
   237     void init(const QString &txt);
       
   238     void removeSelectedText();
       
   239     void internalSetText(const QString &txt, int pos = -1, bool edited = true);
       
   240     void updateDisplayText();
       
   241 
       
   242     void internalInsert(const QString &s);
       
   243     void internalDelete(bool wasBackspace = false);
       
   244     void internalRemove(int pos);
       
   245 
       
   246     inline void internalDeselect()
       
   247     {
       
   248         m_selDirty |= (m_selend > m_selstart);
       
   249         m_selstart = m_selend = 0;
       
   250     }
       
   251 
       
   252     void internalUndo(int until = -1);
       
   253     void internalRedo();
       
   254 
       
   255     QString m_text;
       
   256     QPalette m_palette;
       
   257     int m_cursor;
       
   258     int m_preeditCursor;
       
   259     int m_cursorWidth;
       
   260     Qt::LayoutDirection m_layoutDirection;
       
   261     uint m_hideCursor : 1; // used to hide the m_cursor inside preedit areas
       
   262     uint m_separator : 1;
       
   263     uint m_readOnly : 1;
       
   264     uint m_dragEnabled : 1;
       
   265     uint m_echoMode : 2;
       
   266     uint m_textDirty : 1;
       
   267     uint m_selDirty : 1;
       
   268     uint m_validInput : 1;
       
   269     uint m_blinkStatus : 1;
       
   270     int m_blinkPeriod; // 0 for non-blinking cursor
       
   271     int m_blinkTimer;
       
   272     int m_deleteAllTimer;
       
   273     int m_ascent;
       
   274     int m_maxLength;
       
   275     int m_lastCursorPos;
       
   276     QList<int> m_transactions;
       
   277     QPoint m_tripleClick;
       
   278     int m_tripleClickTimer;
       
   279     QString m_cancelText;
       
   280 
       
   281     void emitCursorPositionChanged();
       
   282 
       
   283     bool finishChange(int validateFromState = -1, bool update = false, bool edited = true);
       
   284 
       
   285     QPointer<QValidator> m_validator;
       
   286     QPointer<QCompleter> m_completer;
       
   287 #ifndef QT_NO_COMPLETER
       
   288     bool advanceToEnabledItem(int dir);
       
   289 #endif
       
   290 
       
   291     struct MaskInputData {
       
   292         enum Casemode { NoCaseMode, Upper, Lower };
       
   293         QChar maskChar; // either the separator char or the inputmask
       
   294         bool separator;
       
   295         Casemode caseMode;
       
   296     };
       
   297     QString m_inputMask;
       
   298     QChar m_blank;
       
   299     MaskInputData *m_maskData;
       
   300 
       
   301     // undo/redo handling
       
   302     enum CommandType { Separator, Insert, Remove, Delete, RemoveSelection, DeleteSelection, SetSelection };
       
   303     struct Command {
       
   304         inline Command() {}
       
   305         inline Command(CommandType t, int p, QChar c, int ss, int se) : type(t),uc(c),pos(p),selStart(ss),selEnd(se) {}
       
   306         uint type : 4;
       
   307         QChar uc;
       
   308         int pos, selStart, selEnd;
       
   309     };
       
   310     int m_modifiedState;
       
   311     int m_undoState;
       
   312     QVector<Command> m_history;
       
   313     void addCommand(const Command& cmd);
       
   314 
       
   315     inline void separate() { m_separator = true; }
       
   316 
       
   317     // selection
       
   318     int m_selstart;
       
   319     int m_selend;
       
   320 
       
   321     // masking
       
   322     void parseInputMask(const QString &maskFields);
       
   323     bool isValidInput(QChar key, QChar mask) const;
       
   324     bool hasAcceptableInput(const QString &text) const;
       
   325     QString maskString(uint pos, const QString &str, bool clear = false) const;
       
   326     QString clearString(uint pos, uint len) const;
       
   327     QString stripString(const QString &str) const;
       
   328     int findInMask(int pos, bool forward, bool findSeparator, QChar searchChar = QChar()) const;
       
   329 
       
   330     // complex text layout
       
   331     QTextLayout m_textLayout;
       
   332 
       
   333     bool m_passwordEchoEditing;
       
   334     QChar m_passwordCharacter;
       
   335 
       
   336 Q_SIGNALS:
       
   337     void cursorPositionChanged(int, int);
       
   338     void selectionChanged();
       
   339 
       
   340     void displayTextChanged(const QString &);
       
   341     void textChanged(const QString &);
       
   342     void textEdited(const QString &);
       
   343 
       
   344     void resetInputContext();
       
   345 
       
   346     void accepted();
       
   347     void editingFinished();
       
   348     void updateNeeded(const QRect &);
       
   349 
       
   350 #ifdef QT_KEYPAD_NAVIGATION
       
   351     void editFocusChange(bool);
       
   352 #endif
       
   353 protected:
       
   354     virtual void timerEvent(QTimerEvent *event);
       
   355 
       
   356 private Q_SLOTS:
       
   357     void _q_clipboardChanged();
       
   358     void _q_deleteSelected();
       
   359 
       
   360 };
       
   361 
       
   362 inline int QLineControl::nextMaskBlank(int pos)
       
   363 {
       
   364     int c = findInMask(pos, true, false);
       
   365     m_separator |= (c != pos);
       
   366     return (c != -1 ?  c : m_maxLength);
       
   367 }
       
   368 
       
   369 inline int QLineControl::prevMaskBlank(int pos)
       
   370 {
       
   371     int c = findInMask(pos, false, false);
       
   372     m_separator |= (c != pos);
       
   373     return (c != -1 ? c : 0);
       
   374 }
       
   375 
       
   376 inline bool QLineControl::isUndoAvailable() const
       
   377 { 
       
   378     return !m_readOnly && m_undoState;
       
   379 }
       
   380 
       
   381 inline bool QLineControl::isRedoAvailable() const
       
   382 {
       
   383     return !m_readOnly && m_undoState < (int)m_history.size();
       
   384 }
       
   385 
       
   386 inline void QLineControl::clearUndo()
       
   387 {
       
   388     m_history.clear();
       
   389     m_modifiedState = m_undoState = 0;
       
   390 }
       
   391 
       
   392 inline bool QLineControl::isModified() const
       
   393 {
       
   394     return m_modifiedState != m_undoState;
       
   395 }
       
   396 
       
   397 inline void QLineControl::setModified(bool modified)
       
   398 {
       
   399     m_modifiedState = modified ? -1 : m_undoState;
       
   400 }
       
   401 
       
   402 inline bool QLineControl::allSelected() const
       
   403 {
       
   404     return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.length();
       
   405 }
       
   406 
       
   407 inline bool QLineControl::hasSelectedText() const
       
   408 {
       
   409     return !m_text.isEmpty() && m_selend > m_selstart;
       
   410 }
       
   411 
       
   412 inline int QLineControl::width() const
       
   413 {
       
   414     return qRound(m_textLayout.lineAt(0).width()) + 1;
       
   415 }
       
   416 
       
   417 inline qreal QLineControl::naturalTextWidth() const
       
   418 {
       
   419     return m_textLayout.lineAt(0).naturalTextWidth();
       
   420 }
       
   421 
       
   422 inline int QLineControl::height() const
       
   423 {
       
   424     return qRound(m_textLayout.lineAt(0).height()) + 1;
       
   425 }
       
   426 
       
   427 inline int QLineControl::ascent() const
       
   428 {
       
   429     return m_ascent;
       
   430 }
       
   431 
       
   432 inline QString QLineControl::selectedText() const
       
   433 {
       
   434     if (hasSelectedText())
       
   435         return m_text.mid(m_selstart, m_selend - m_selstart);
       
   436     return QString();
       
   437 }
       
   438 
       
   439 inline QString QLineControl::textBeforeSelection() const
       
   440 {
       
   441     if (hasSelectedText())
       
   442         return m_text.left(m_selstart);
       
   443     return QString();
       
   444 }
       
   445 
       
   446 inline QString QLineControl::textAfterSelection() const
       
   447 {
       
   448     if (hasSelectedText())
       
   449         return m_text.mid(m_selend);
       
   450     return QString();
       
   451 }
       
   452 
       
   453 inline int QLineControl::selectionStart() const
       
   454 {
       
   455     return hasSelectedText() ? m_selstart : -1;
       
   456 }
       
   457 
       
   458 inline int QLineControl::selectionEnd() const
       
   459 {
       
   460     return hasSelectedText() ? m_selend : -1;
       
   461 }
       
   462 
       
   463 inline int QLineControl::start() const
       
   464 {
       
   465     return 0;
       
   466 }
       
   467 
       
   468 inline int QLineControl::end() const
       
   469 {
       
   470     return m_text.length();
       
   471 }
       
   472 
       
   473 inline void QLineControl::removeSelection()
       
   474 {
       
   475     int priorState = m_undoState;
       
   476     removeSelectedText();
       
   477     finishChange(priorState);
       
   478 }
       
   479 
       
   480 inline bool QLineControl::inSelection(int x) const
       
   481 {
       
   482     if (m_selstart >= m_selend)
       
   483         return false;
       
   484     int pos = xToPos(x, QTextLine::CursorOnCharacter);
       
   485     return pos >= m_selstart && pos < m_selend;
       
   486 }
       
   487 
       
   488 inline int QLineControl::cursor() const
       
   489 {
       
   490     return m_cursor;
       
   491 }
       
   492 
       
   493 inline int QLineControl::preeditCursor() const
       
   494 {
       
   495     return m_preeditCursor;
       
   496 }
       
   497 
       
   498 inline int QLineControl::cursorWidth() const
       
   499 {
       
   500     return m_cursorWidth;
       
   501 }
       
   502 
       
   503 inline void QLineControl::setCursorWidth(int value)
       
   504 {
       
   505     m_cursorWidth = value;
       
   506 }
       
   507 
       
   508 inline void QLineControl::cursorForward(bool mark, int steps)
       
   509 {
       
   510     int c = m_cursor;
       
   511     if (steps > 0) {
       
   512         while (steps--)
       
   513             c = m_textLayout.nextCursorPosition(c);
       
   514     } else if (steps < 0) {
       
   515         while (steps++)
       
   516             c = m_textLayout.previousCursorPosition(c);
       
   517     }
       
   518     moveCursor(c, mark);
       
   519 }
       
   520 
       
   521 inline void QLineControl::cursorWordForward(bool mark)
       
   522 {
       
   523     moveCursor(m_textLayout.nextCursorPosition(m_cursor, QTextLayout::SkipWords), mark);
       
   524 }
       
   525 
       
   526 inline void QLineControl::home(bool mark)
       
   527 {
       
   528     moveCursor(0, mark);
       
   529 }
       
   530 
       
   531 inline void QLineControl::end(bool mark)
       
   532 {
       
   533     moveCursor(text().length(), mark);
       
   534 }
       
   535 
       
   536 inline void QLineControl::cursorWordBackward(bool mark)
       
   537 {
       
   538     moveCursor(m_textLayout.previousCursorPosition(m_cursor, QTextLayout::SkipWords), mark);
       
   539 }
       
   540 
       
   541 inline qreal QLineControl::cursorToX(int cursor) const
       
   542 {
       
   543     return m_textLayout.lineAt(0).cursorToX(cursor);
       
   544 }
       
   545 
       
   546 inline qreal QLineControl::cursorToX() const
       
   547 {
       
   548     return cursorToX(m_cursor);
       
   549 }
       
   550 
       
   551 inline bool QLineControl::isReadOnly() const
       
   552 {
       
   553     return m_readOnly;
       
   554 }
       
   555 
       
   556 inline void QLineControl::setReadOnly(bool enable)
       
   557 { 
       
   558     m_readOnly = enable;
       
   559 }
       
   560 
       
   561 inline QString QLineControl::text() const
       
   562 {
       
   563     QString res = m_maskData ? stripString(m_text) : m_text;
       
   564     return (res.isNull() ? QString::fromLatin1("") : res);
       
   565 }
       
   566 
       
   567 inline void QLineControl::setText(const QString &txt)
       
   568 {
       
   569     internalSetText(txt, -1, false);
       
   570 }
       
   571 
       
   572 inline QString QLineControl::displayText() const
       
   573 {
       
   574     return m_textLayout.text();
       
   575 }
       
   576 
       
   577 inline void QLineControl::deselect()
       
   578 {
       
   579     internalDeselect();
       
   580     finishChange();
       
   581 }
       
   582 
       
   583 inline void QLineControl::selectAll()
       
   584 {
       
   585     m_selstart = m_selend = m_cursor = 0;
       
   586     moveCursor(m_text.length(), true);
       
   587 }
       
   588 
       
   589 inline void QLineControl::undo()
       
   590 {
       
   591     internalUndo();
       
   592     finishChange(-1, true);
       
   593 }
       
   594 
       
   595 inline void QLineControl::redo()
       
   596 {
       
   597     internalRedo();
       
   598     finishChange();
       
   599 }
       
   600 
       
   601 inline uint QLineControl::echoMode() const
       
   602 {
       
   603     return m_echoMode;
       
   604 }
       
   605 
       
   606 inline void QLineControl::setEchoMode(uint mode)
       
   607 {
       
   608     m_echoMode = mode;
       
   609     m_passwordEchoEditing = false;
       
   610     updateDisplayText();
       
   611 }
       
   612 
       
   613 inline void QLineControl::setMaxLength(int maxLength)
       
   614 {
       
   615     if (m_maskData)
       
   616         return;
       
   617     m_maxLength = maxLength;
       
   618     setText(m_text);
       
   619 }
       
   620 
       
   621 inline int QLineControl::maxLength() const
       
   622 {
       
   623     return m_maxLength;
       
   624 }
       
   625 
       
   626 inline const QValidator *QLineControl::validator() const
       
   627 {
       
   628     return m_validator;
       
   629 }
       
   630 
       
   631 inline void QLineControl::setValidator(const QValidator *v)
       
   632 {
       
   633     m_validator = const_cast<QValidator*>(v);
       
   634 }
       
   635 
       
   636 #ifndef QT_NO_COMPLETER
       
   637 inline QCompleter *QLineControl::completer() const
       
   638 {
       
   639     return m_completer;
       
   640 }
       
   641 
       
   642 /* Note that you must set the widget for the completer seperately */
       
   643 inline void QLineControl::setCompleter(const QCompleter* c)
       
   644 {
       
   645     m_completer = const_cast<QCompleter*>(c);
       
   646 }
       
   647 #endif
       
   648 
       
   649 inline void QLineControl::setCursorPosition(int pos)
       
   650 {
       
   651     if (pos < 0)
       
   652         pos = 0;
       
   653     if (pos <= m_text.length())
       
   654         moveCursor(pos);
       
   655 }
       
   656 
       
   657 inline int QLineControl::cursorPosition() const
       
   658 {
       
   659     return m_cursor;
       
   660 }
       
   661 
       
   662 inline bool QLineControl::hasAcceptableInput() const
       
   663 {
       
   664     return hasAcceptableInput(m_text);
       
   665 }
       
   666 
       
   667 inline QString QLineControl::inputMask() const
       
   668 {
       
   669     return m_maskData ? m_inputMask + QLatin1Char(';') + m_blank : QString();
       
   670 }
       
   671 
       
   672 inline void QLineControl::setInputMask(const QString &mask)
       
   673 {
       
   674     parseInputMask(mask);
       
   675     if (m_maskData)
       
   676         moveCursor(nextMaskBlank(0));
       
   677 }
       
   678 
       
   679 // input methods
       
   680 #ifndef QT_NO_IM
       
   681 inline bool QLineControl::composeMode() const
       
   682 {
       
   683     return !m_textLayout.preeditAreaText().isEmpty();
       
   684 }
       
   685 
       
   686 inline void QLineControl::setPreeditArea(int cursor, const QString &text)
       
   687 {
       
   688     m_textLayout.setPreeditArea(cursor, text);
       
   689 }
       
   690 #endif
       
   691 
       
   692 inline QString QLineControl::preeditAreaText() const
       
   693 {
       
   694     return m_textLayout.preeditAreaText();
       
   695 }
       
   696 
       
   697 inline bool QLineControl::passwordEchoEditing() const
       
   698 {
       
   699     return m_passwordEchoEditing;
       
   700 }
       
   701 
       
   702 inline QChar QLineControl::passwordCharacter() const
       
   703 {
       
   704     return m_passwordCharacter;
       
   705 }
       
   706 
       
   707 inline void QLineControl::setPasswordCharacter(const QChar &character)
       
   708 {
       
   709     m_passwordCharacter = character;
       
   710     updateDisplayText();
       
   711 }
       
   712 
       
   713 inline Qt::LayoutDirection QLineControl::layoutDirection() const
       
   714 {
       
   715     return m_layoutDirection;
       
   716 }
       
   717 
       
   718 inline void QLineControl::setLayoutDirection(Qt::LayoutDirection direction)
       
   719 {
       
   720     if (direction != m_layoutDirection) {
       
   721         m_layoutDirection = direction;
       
   722         updateDisplayText();
       
   723     }
       
   724 }
       
   725 
       
   726 inline void QLineControl::setFont(const QFont &font)
       
   727 {
       
   728     m_textLayout.setFont(font);
       
   729     updateDisplayText();
       
   730 }
       
   731 
       
   732 inline int QLineControl::cursorBlinkPeriod() const
       
   733 {
       
   734     return m_blinkPeriod;
       
   735 }
       
   736 
       
   737 inline QString QLineControl::cancelText() const
       
   738 {
       
   739     return m_cancelText;
       
   740 }
       
   741 
       
   742 inline void QLineControl::setCancelText(const QString &text)
       
   743 {
       
   744     m_cancelText = text;
       
   745 }
       
   746 
       
   747 inline const QPalette & QLineControl::palette() const
       
   748 {
       
   749     return m_palette;
       
   750 }
       
   751 
       
   752 inline void QLineControl::setPalette(const QPalette &p)
       
   753 {
       
   754     m_palette = p;
       
   755 }
       
   756 
       
   757 QT_END_NAMESPACE
       
   758 
       
   759 QT_END_HEADER
       
   760 
       
   761 #endif // QT_NO_LINEEDIT
       
   762 
       
   763 #endif // QLINECONTROL_P_H