diff options
author | Marius Bugge Monsen <mmonsen@trolltech.com> | 2009-07-14 13:19:35 (GMT) |
---|---|---|
committer | Marius Bugge Monsen <mmonsen@trolltech.com> | 2009-07-14 13:19:35 (GMT) |
commit | 363221747e68b7a5930afdeef87a5454f40c5ffb (patch) | |
tree | 51c299d36c1942ca9ba2ff8d1a36023e9d0199e9 | |
parent | 1bd89d1c8a9bc41f8ea76f55a2ebd17447fc2d70 (diff) | |
download | Qt-363221747e68b7a5930afdeef87a5454f40c5ffb.zip Qt-363221747e68b7a5930afdeef87a5454f40c5ffb.tar.gz Qt-363221747e68b7a5930afdeef87a5454f40c5ffb.tar.bz2 |
Some minor style and whitespace fixes.
-rw-r--r-- | src/gui/widgets/qlinecontrol.cpp | 59 | ||||
-rw-r--r-- | src/gui/widgets/qlinecontrol_p.h | 23 |
2 files changed, 44 insertions, 38 deletions
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 9b2a47a..6d8fe06 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -275,7 +275,7 @@ void QLineControl::_q_deleteSelected() Initializes the line control with a starting text value of \a txt. */ -void QLineControl::init(const QString& txt) +void QLineControl::init(const QString &txt) { m_text = txt; updateDisplayText(); @@ -571,7 +571,7 @@ bool QLineControl::finishChange(int validateFromState, bool update, bool edited) An internal function for setting the text of the line control. */ -void QLineControl::p_setText(const QString& txt, int pos, bool edited) +void QLineControl::p_setText(const QString &txt, int pos, bool edited) { p_deselect(); emit resetInputContext(); @@ -596,7 +596,7 @@ void QLineControl::p_setText(const QString& txt, int pos, bool edited) Adds the given \a command to the undo history of the line control. Does not apply the command. */ -void QLineControl::addCommand(const Command& cmd) +void QLineControl::addCommand(const Command &cmd) { if (separator && undoState && history[undoState-1].type != Separator) { history.resize(undoState + 2); @@ -618,15 +618,15 @@ void QLineControl::addCommand(const Command& cmd) This function does not call finishChange(), and may leave the text in an invalid state. */ -void QLineControl::p_insert(const QString& s) +void QLineControl::p_insert(const QString &s) { if (hasSelectedText()) addCommand(Command(SetSelection, m_cursor, 0, selstart, selend)); if (maskData) { QString ms = maskString(m_cursor, s); for (int i = 0; i < (int) ms.length(); ++i) { - addCommand (Command(DeleteSelection, m_cursor+i, m_text.at(m_cursor+i), -1, -1)); - addCommand(Command(Insert, m_cursor+i, ms.at(i), -1, -1)); + addCommand (Command(DeleteSelection, m_cursor + i, m_text.at(m_cursor + i), -1, -1)); + addCommand(Command(Insert, m_cursor + i, ms.at(i), -1, -1)); } m_text.replace(m_cursor, ms.length(), ms); m_cursor += ms.length(); @@ -659,7 +659,8 @@ void QLineControl::p_del(bool wasBackspace) if (m_cursor < (int) m_text.length()) { if (hasSelectedText()) addCommand(Command(SetSelection, m_cursor, 0, selstart, selend)); - addCommand (Command((CommandType)((maskData?2:0)+(wasBackspace?Remove:Delete)), m_cursor, m_text.at(m_cursor), -1, -1)); + addCommand(Command((CommandType)((maskData ? 2 : 0) + (wasBackspace ? Remove : Delete)), + m_cursor, m_text.at(m_cursor), -1, -1)); if (maskData) { m_text.replace(m_cursor, 1, clearString(m_cursor, 1)); addCommand(Command(Insert, m_cursor, m_text.at(m_cursor), -1, -1)); @@ -990,7 +991,7 @@ QString QLineControl::maskString(uint pos, const QString &str, bool clear) const } } } - strIndex++; + ++strIndex; } } else break; @@ -1014,7 +1015,7 @@ QString QLineControl::clearString(uint pos, uint len) const QString s; int end = qMin((uint)m_maxLength, pos + len); - for (int i=pos; i<end; i++) + for (int i = pos; i < end; ++i) if (maskData[i].separator) s += maskData[i].maskChar; else @@ -1036,7 +1037,7 @@ QString QLineControl::stripString(const QString &str) const QString s; int end = qMin(m_maxLength, (int)str.length()); - for (int i=0; i < end; i++) + for (int i = 0; i < end; ++i) if (maskData[i].separator) s += maskData[i].maskChar; else @@ -1243,32 +1244,32 @@ void QLineControl::complete(int key) void QLineControl::setCursorBlinkPeriod(int msec) { - if(msec == m_blinkPeriod) + if (msec == m_blinkPeriod) return; - if(m_blinkTimer){ + if (m_blinkTimer) { killTimer(m_blinkTimer); } - if(msec){ - m_blinkTimer = startTimer(msec/2); + if (msec) { + m_blinkTimer = startTimer(msec / 2); m_blinkStatus = 1; - }else{ + } else { m_blinkTimer = 0; - if(m_blinkStatus == 0) - emit updateNeeded(inputMask().isEmpty()?cursorRect():QRect()); + if (m_blinkStatus == 0) + emit updateNeeded(inputMask().isEmpty() ? cursorRect() : QRect()); } m_blinkPeriod = msec; } -void QLineControl::timerEvent ( QTimerEvent * event ) +void QLineControl::timerEvent(QTimerEvent *event) { - if(event->timerId() == m_blinkTimer) { + if (event->timerId() == m_blinkTimer) { m_blinkStatus = !m_blinkStatus; - emit updateNeeded(inputMask().isEmpty()?cursorRect():QRect()); - }else if(event->timerId() == m_deleteAllTimer){ + emit updateNeeded(inputMask().isEmpty() ? cursorRect() : QRect()); + } else if (event->timerId() == m_deleteAllTimer) { killTimer(m_deleteAllTimer); m_deleteAllTimer = 0; clear(); - }else if(event->timerId() == m_tripleClickTimer){ + } else if (event->timerId() == m_tripleClickTimer) { killTimer(m_tripleClickTimer); m_tripleClickTimer = 0; } @@ -1371,11 +1372,12 @@ bool QLineControl::processEvent(QEvent* ev) void QLineControl::processMouseEvent(QMouseEvent* ev) { - switch (ev->type()){ + switch (ev->type()) { case QEvent::GraphicsSceneMousePress: case QEvent::MouseButtonPress:{ - if (m_tripleClickTimer && (ev->pos() - m_tripleClick).manhattanLength() < - QApplication::startDragDistance()) { + if (m_tripleClickTimer + && (ev->pos() - m_tripleClick).manhattanLength() + < QApplication::startDragDistance()) { selectAll(); return; } @@ -1390,7 +1392,7 @@ void QLineControl::processMouseEvent(QMouseEvent* ev) case QEvent::MouseButtonDblClick: if (ev->button() == Qt::LeftButton) { selectWordAtPos(xToPos(ev->pos().x())); - if(m_tripleClickTimer) + if (m_tripleClickTimer) killTimer(m_tripleClickTimer); m_tripleClickTimer = startTimer(QApplication::doubleClickInterval()); m_tripleClick = ev->pos(); @@ -1412,7 +1414,7 @@ void QLineControl::processMouseEvent(QMouseEvent* ev) case QEvent::GraphicsSceneMouseMove: case QEvent::MouseMove: if (ev->buttons() & Qt::LeftButton) { - moveCursor(xToPos(ev->pos().x()), true); + moveCursor(xToPos(ev->pos().x()), true); } break; default: @@ -1422,7 +1424,6 @@ void QLineControl::processMouseEvent(QMouseEvent* ev) void QLineControl::processKeyEvent(QKeyEvent* event) { - bool inlineCompletionAccepted = false; #ifndef QT_NO_COMPLETER @@ -1472,8 +1473,6 @@ void QLineControl::processKeyEvent(QKeyEvent* event) } #endif // QT_NO_COMPLETER - - if (echoMode() == QLineEdit::PasswordEchoOnEdit && !passwordEchoEditing() && !isReadOnly() diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index 4ecedcd..2d93e90 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -462,8 +462,10 @@ inline void QLineControl::removeSelection() inline bool QLineControl::inSelection(int x) const { - if (selstart >= selend) return false; - int pos = xToPos(x, QTextLine::CursorOnCharacter); return pos >= selstart && pos < selend; + if (selstart >= selend) + return false; + int pos = xToPos(x, QTextLine::CursorOnCharacter); + return pos >= selstart && pos < selend; } inline int QLineControl::cursor() const @@ -557,22 +559,26 @@ inline QString QLineControl::displayText() const inline void QLineControl::deselect() { - p_deselect(); finishChange(); + p_deselect(); + finishChange(); } inline void QLineControl::selectAll() { - selstart = selend = m_cursor = 0; moveCursor(m_text.length(), true); + selstart = selend = m_cursor = 0; + moveCursor(m_text.length(), true); } inline void QLineControl::undo() { - p_undo(), finishChange(-1, true); + p_undo(); + finishChange(-1, true); } inline void QLineControl::redo() { - p_redo(), finishChange(); + p_redo(); + finishChange(); } inline uint QLineControl::echoMode() const @@ -625,7 +631,8 @@ inline void QLineControl::setCompleter(const QCompleter* c) inline void QLineControl::setCursorPosition(int pos) { - if (pos < 0) pos = 0; + if (pos < 0) + pos = 0; if (pos < m_text.length()) moveCursor(pos); } @@ -723,7 +730,7 @@ inline void QLineControl::setCancelText(QString s) QT_END_NAMESPACE QT_END_HEADER -#endif // QT_NO_LINEEDIT +#endif // QT_NO_LINEEDIT #endif // QLINECONTROL_P_H |