73 setWindowTitle(tr(
"Expression Editor"));
74 setMinimumHeight(100);
77 auto *exprAndErrors =
new QVBoxLayout;
78 exprAndErrors->setMargin(0);
79 setLayout(exprAndErrors);
83 exprTe->setObjectName(QString::fromUtf8(
"exprTe"));
84 exprTe->setMinimumHeight(50);
102 exprAndErrors->addWidget(
exprTe, 4);
106 errorWidget->setObjectName(QString::fromUtf8(
"errorWidget"));
107 errorWidget->setSelectionMode(QAbstractItemView::SingleSelection);
108 errorWidget->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
147 QListWidgetItem *item =
errorWidget->item(selected);
148 int start = item->data(Qt::UserRole).toInt();
149 int end = item->data(Qt::UserRole + 1).toInt();
150 QTextCursor cursor =
exprTe->textCursor();
151 cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
152 cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, start);
153 cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, end - start + 1);
154 exprTe->setTextCursor(cursor);
216 int startLine, startCol;
220 QTextCursor cursor =
exprTe->textCursor();
221 cursor.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
222 cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, startPos);
223 startLine = cursor.blockNumber();
224 startCol = cursor.columnNumber();
225 cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, endPos - startPos + 1);
226 QList<QTextEdit::ExtraSelection> extraSelections =
exprTe->extraSelections();
227 QTextEdit::ExtraSelection selection;
228 QColor lineColor = QColor(Qt::yellow).lighter(130);
229 selection.format.setUnderlineColor(lineColor);
230 selection.format.setUnderlineStyle(QTextCharFormat::UnderlineStyle::WaveUnderline);
231 selection.cursor = cursor;
232 extraSelections.append(selection);
233 exprTe->setExtraSelections(extraSelections);
235 QString message = tr(
"(%1, %2): %3").arg(startLine).arg(startCol).arg(error);
236 auto *item =
new QListWidgetItem(message,
errorWidget);
237 item->setData(Qt::UserRole, startPos);
238 item->setData(Qt::UserRole + 1, endPos);
252 exprTe->ensureCursorVisible();