diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2014-05-27 20:06:24 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-27 20:03:29 -0700 |
commit | 7320748acead7eb1853c32348c7cff26d7482e58 (patch) | |
tree | 470e3a236dc4bbca1ef5a8ee0c7b3c60c66ab7ea /qt-ui/groupedlineedit.cpp | |
parent | f2ecb6d0ebb9183fad9fd2d33e1cb7dbd6a712d7 (diff) | |
download | subsurface-7320748acead7eb1853c32348c7cff26d7482e58.tar.gz |
Much, much smarter way of finding the Tags
The old way manually implemented a parser, where it could simply call a
regexp (or, in my case, a QChar) that will split the QString into many, to
find the beginning and end of the strings on the tags.
This patch also fixes a Qt5 off-by-one bug on the tag Visualization.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/groupedlineedit.cpp')
-rw-r--r-- | qt-ui/groupedlineedit.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/qt-ui/groupedlineedit.cpp b/qt-ui/groupedlineedit.cpp index 4ba6621e6..38f75cad8 100644 --- a/qt-ui/groupedlineedit.cpp +++ b/qt-ui/groupedlineedit.cpp @@ -42,7 +42,6 @@ #include <QBrush> #include <QColor> #include <QPalette> -#include <QDebug> struct GroupedLineEdit::Private { struct Block { @@ -66,7 +65,6 @@ GroupedLineEdit::GroupedLineEdit(QWidget *parent) : QPlainTextEdit(parent), document()->setMaximumBlockCount(1); } - GroupedLineEdit::~GroupedLineEdit() { delete d; @@ -86,7 +84,6 @@ int GroupedLineEdit::cursorPosition() const void GroupedLineEdit::addBlock(int start, int end) { Private::Block block; - block.start = start; block.end = end; block.text = text().mid(start, end - start + 1).trimmed(); @@ -107,8 +104,7 @@ void GroupedLineEdit::removeAllColors() QStringList GroupedLineEdit::getBlockStringList() { QStringList retList; - Private::Block block; - foreach (block, d->blocks) + foreach (Private::Block block, d->blocks) retList.append(block.text); return retList; } @@ -134,9 +130,7 @@ void GroupedLineEdit::clear() void GroupedLineEdit::selectAll() { QTextCursor c = textCursor(); - c.select(QTextCursor::LineUnderCursor); - setTextCursor(c); } @@ -153,7 +147,6 @@ QSize GroupedLineEdit::sizeHint() const document()->findBlock(0).layout()->lineAt(0).height() + document()->documentMargin() * 2 + frameWidth() * 2); - return rs; } @@ -190,8 +183,12 @@ void GroupedLineEdit::paintEvent(QPaintEvent *e) QVectorIterator<QColor> i(d->colors); i.toFront(); foreach (const Private::Block &block, d->blocks) { - qreal start_x = line.cursorToX(block.start, QTextLine::Trailing); - qreal end_x = line.cursorToX(block.end + 1, QTextLine::Leading); + qreal start_x = line.cursorToX(block.start, QTextLine::Leading); +#if QT_VERSION >= 0x050000 + qreal end_x = line.cursorToX(block.end-1, QTextLine::Trailing); +#else + qreal end_x = line.cursorToX(block.end, QTextLine::Trailing); +#endif QPainterPath path; QRectF rectangle( start_x - 1.0 - double(horizontalScrollBar()->value()), |