diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-02-27 20:09:57 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-02-27 20:09:57 -0800 |
commit | 76e6420f6b3503b76bd3eec00ab0e53d6ea17a20 (patch) | |
tree | 8b50298f41bd29d55bbd6f4301f36ad31dc0b008 /qt-ui/tagwidget.cpp | |
parent | 006265d7a088cff4fea665159dbb454956c2cd76 (diff) | |
download | subsurface-76e6420f6b3503b76bd3eec00ab0e53d6ea17a20.tar.gz |
Massive automated whitespace cleanup
I know everyone will hate it.
Go ahead. Complain. Call me names.
At least now things are consistent and reproducible.
If you want changes, have your complaint come with a patch to
scripts/whitespace.pl so that we can automate it.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/tagwidget.cpp')
-rw-r--r-- | qt-ui/tagwidget.cpp | 73 |
1 files changed, 42 insertions, 31 deletions
diff --git a/qt-ui/tagwidget.cpp b/qt-ui/tagwidget.cpp index e7585dff1..6ba4a0404 100644 --- a/qt-ui/tagwidget.cpp +++ b/qt-ui/tagwidget.cpp @@ -14,18 +14,18 @@ TagWidget::TagWidget(QWidget *parent) : GroupedLineEdit(parent), m_completer(NUL qreal h, s, l, a; textColor.getHslF(&h, &s, &l, &a); // I use dark themes - if (l <= 0.3 ) { // very dark text. get a brigth background - addColor( QColor(Qt::red).lighter(120) ); - addColor( QColor(Qt::green).lighter(120) ); - addColor( QColor(Qt::blue).lighter(120) ); - } else if ( l <= 0.6 ) { // moderated dark text. get a somewhat brigth background - addColor( QColor(Qt::red).lighter(60) ); - addColor( QColor(Qt::green).lighter(60) ); - addColor( QColor(Qt::blue).lighter(60) ); + if (l <= 0.3) { // very dark text. get a brigth background + addColor(QColor(Qt::red).lighter(120)); + addColor(QColor(Qt::green).lighter(120)); + addColor(QColor(Qt::blue).lighter(120)); + } else if (l <= 0.6) { // moderated dark text. get a somewhat brigth background + addColor(QColor(Qt::red).lighter(60)); + addColor(QColor(Qt::green).lighter(60)); + addColor(QColor(Qt::blue).lighter(60)); } else { - addColor( QColor(Qt::red).darker(120) ); - addColor( QColor(Qt::green).darker(120) ); - addColor( QColor(Qt::blue).darker(120) ); + addColor(QColor(Qt::red).darker(120)); + addColor(QColor(Qt::green).darker(120)); + addColor(QColor(Qt::blue).darker(120)); } // light text. get a dark background. setFocusPolicy(Qt::StrongFocus); } @@ -38,13 +38,14 @@ void TagWidget::setCompleter(QCompleter *completer) connect(m_completer, SIGNAL(highlighted(QString)), this, SLOT(completionSelected(QString))); } -QPair<int,int> TagWidget::getCursorTagPosition() { +QPair<int, int> TagWidget::getCursorTagPosition() +{ int i = 0, start = 0, end = 0; /* Parse string near cursor */ i = cursorPosition(); while (--i > 0) { if (text().at(i) == ',') { - if (i > 0 && text().at(i-1) != '\\') { + if (i > 0 && text().at(i - 1) != '\\') { i++; break; } @@ -53,7 +54,7 @@ QPair<int,int> TagWidget::getCursorTagPosition() { start = i; while (++i < text().length()) { if (text().at(i) == ',') { - if (i > 0 && text().at(i-1) != '\\') + if (i > 0 && text().at(i - 1) != '\\') break; } } @@ -62,24 +63,28 @@ QPair<int,int> TagWidget::getCursorTagPosition() { start = 0; end = 0; } - return qMakePair(start,end); + return qMakePair(start, end); } -enum ParseState {FINDSTART, FINDEND}; +enum ParseState { + FINDSTART, + FINDEND +}; -void TagWidget::highlight() { +void TagWidget::highlight() +{ int i = 0, start = 0, end = 0; ParseState state = FINDEND; removeAllBlocks(); - while(i < text().length()) { + while (i < text().length()) { if (text().at(i) == ',') { if (state == FINDSTART) { /* Detect empty tags */ } else if (state == FINDEND) { /* Found end of tag */ if (i > 1) { - if (text().at(i-1) != '\\') { + if (text().at(i - 1) != '\\') { addBlock(start, end); state = FINDSTART; } @@ -102,7 +107,7 @@ void TagWidget::highlight() { } if (state == FINDEND) { if (end < start) - end = text().length()-1; + end = text().length() - 1; if (text().length() > 0) addBlock(start, end); } @@ -111,10 +116,10 @@ void TagWidget::highlight() { void TagWidget::reparse() { highlight(); - QPair<int,int> pos = getCursorTagPosition(); + QPair<int, int> pos = getCursorTagPosition(); QString currentText; if (pos.first >= 0 && pos.second > 0) - currentText = text().mid(pos.first, pos.second-pos.first).trimmed(); + currentText = text().mid(pos.first, pos.second - pos.first).trimmed(); else currentText = ""; if (m_completer) { @@ -133,12 +138,13 @@ void TagWidget::reparse() } } -void TagWidget::completionSelected(QString completion) { - QPair <int,int> pos; +void TagWidget::completionSelected(QString completion) +{ + QPair<int, int> pos; pos = getCursorTagPosition(); if (pos.first >= 0 && pos.second > 0) { - setText(text().remove(pos.first, pos.second-pos.first).insert(pos.first, completion)); - setCursorPosition(pos.first+completion.length()); + setText(text().remove(pos.first, pos.second - pos.first).insert(pos.first, completion)); + setCursorPosition(pos.first + completion.length()); } else { setText(completion.append(", ")); setCursorPosition(text().length()); @@ -146,26 +152,30 @@ void TagWidget::completionSelected(QString completion) { emit(textChanged()); } -void TagWidget::setCursorPosition(int position) { +void TagWidget::setCursorPosition(int position) +{ blockSignals(true); GroupedLineEdit::setCursorPosition(position); blockSignals(false); } -void TagWidget::setText(QString text) { +void TagWidget::setText(QString text) +{ blockSignals(true); GroupedLineEdit::setText(text); blockSignals(false); highlight(); } -void TagWidget::clear() { +void TagWidget::clear() +{ blockSignals(true); GroupedLineEdit::clear(); blockSignals(false); } -void TagWidget::keyPressEvent(QKeyEvent *e) { +void TagWidget::keyPressEvent(QKeyEvent *e) +{ switch (e->key()) { case Qt::Key_Return: case Qt::Key_Enter: @@ -188,7 +198,8 @@ void TagWidget::keyPressEvent(QKeyEvent *e) { } } -void TagWidget::wheelEvent(QWheelEvent *event) { +void TagWidget::wheelEvent(QWheelEvent *event) +{ if (hasFocus()) { GroupedLineEdit::wheelEvent(event); } |