summaryrefslogtreecommitdiffstats
path: root/Source/QtDialog
diff options
context:
space:
mode:
authorMarc Bartholomaeus <marc.bartholomaeus@carmeq.com>2013-04-17 23:06:00 (GMT)
committerAlex Neundorf <neundorf@kde.org>2013-04-24 19:32:42 (GMT)
commit6e57724fc3f95f954666fbe9c33ea14e22c858a3 (patch)
tree5d68237fec1d3194d2b23ab236bd8e6928fd3809 /Source/QtDialog
parent7be2d8acc64e371748b8758f16b7aa6bdaf3fd0f (diff)
downloadCMake-6e57724fc3f95f954666fbe9c33ea14e22c858a3.zip
CMake-6e57724fc3f95f954666fbe9c33ea14e22c858a3.tar.gz
CMake-6e57724fc3f95f954666fbe9c33ea14e22c858a3.tar.bz2
cmake-gui: Add function for going to next error message in Output window
Using new shortcuts: F8 (Visual Studio) and Ctrl-. (Eclipse) Signed-off-by: Alex Neundorf <neundorf@kde.org>
Diffstat (limited to 'Source/QtDialog')
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx68
-rw-r--r--Source/QtDialog/CMakeSetupDialog.h1
2 files changed, 67 insertions, 2 deletions
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index fb74aaf..91279fd 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -133,6 +133,11 @@ CMakeSetupDialog::CMakeSetupDialog()
ToolsMenu->addAction(tr("&Find Previous"),
this, SLOT(doOutputFindPrev()),
QKeySequence::FindPrevious);
+ ToolsMenu->addAction(tr("Goto Next Error"),
+ this, SLOT(doOutputErrorNext()),
+ QKeySequence(Qt::Key_F8)); // in Visual Studio
+ new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Period),
+ this, SLOT(doOutputErrorNext())); // in Eclipse
QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options"));
this->SuppressDevWarningsAction =
@@ -649,7 +654,13 @@ void CMakeSetupDialog::showProgress(const QString& /*msg*/, float percent)
void CMakeSetupDialog::error(const QString& msg)
{
this->Output->setCurrentCharFormat(this->ErrorFormat);
- this->Output->append(msg);
+ //QTextEdit will terminate the msg with a ParagraphSeparator, but it also replaces
+ //all newlines with ParagraphSeparators. By replacing the newlines by ourself, one
+ //error msg will be one paragraph.
+ QString paragraph(msg);
+ paragraph.replace(QLatin1Char('\n'), QChar::LineSeparator);
+ this->Output->append(paragraph);
+
}
void CMakeSetupDialog::message(const QString& msg)
@@ -1172,6 +1183,9 @@ void CMakeSetupDialog::doOutputContextMenu(const QPoint &pt)
this, SLOT(doOutputFindNext()), QKeySequence::FindNext);
menu->addAction(tr("Find Previous"),
this, SLOT(doOutputFindPrev()), QKeySequence::FindPrevious);
+ menu->addSeparator();
+ menu->addAction(tr("Goto Next Error"),
+ this, SLOT(doOutputErrorNext()), QKeySequence(Qt::Key_F8));
menu->exec(this->Output->mapToGlobal(pt));
delete menu;
@@ -1182,7 +1196,9 @@ void CMakeSetupDialog::doOutputFindDialog()
QStringList strings(this->FindHistory);
QString selection = this->Output->textCursor().selectedText();
- if (!selection.isEmpty() && !selection.contains(QChar::ParagraphSeparator))
+ if (!selection.isEmpty() &&
+ !selection.contains(QChar::ParagraphSeparator) &&
+ !selection.contains(QChar::LineSeparator))
{
strings.push_front(selection);
}
@@ -1239,3 +1255,51 @@ void CMakeSetupDialog::doOutputFindNext(bool directionForward)
this->Output->setTextCursor(cursor);
}
}
+
+void CMakeSetupDialog::doOutputErrorNext()
+{
+ QTextCursor cursor = this->Output->textCursor();
+ bool atEnd = false;
+
+ // move cursor out of current error-block
+ if (cursor.blockCharFormat() == this->ErrorFormat)
+ {
+ atEnd = !cursor.movePosition(QTextCursor::NextBlock);
+ }
+
+ // move cursor to next error-block
+ while (cursor.blockCharFormat() != this->ErrorFormat && !atEnd)
+ {
+ atEnd = !cursor.movePosition(QTextCursor::NextBlock);
+ }
+
+ if (atEnd)
+ {
+ // first search found nothing, wrap around and search again
+ atEnd = !cursor.movePosition(QTextCursor::Start);
+
+ // move cursor to next error-block
+ while (cursor.blockCharFormat() != this->ErrorFormat && !atEnd)
+ {
+ atEnd = !cursor.movePosition(QTextCursor::NextBlock);
+ }
+ }
+
+ if (!atEnd)
+ {
+ cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
+
+ QTextCharFormat selectionFormat;
+ selectionFormat.setBackground(Qt::yellow);
+ QTextEdit::ExtraSelection extraSelection = {cursor, selectionFormat};
+ this->Output->setExtraSelections(QList<QTextEdit::ExtraSelection>()
+ << extraSelection);
+
+ // make the whole error-block visible
+ this->Output->setTextCursor(cursor);
+
+ // remove the selection to see the extraSelection
+ cursor.setPosition(cursor.anchor());
+ this->Output->setTextCursor(cursor);
+ }
+}
diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h
index 100834d..963c7d1 100644
--- a/Source/QtDialog/CMakeSetupDialog.h
+++ b/Source/QtDialog/CMakeSetupDialog.h
@@ -81,6 +81,7 @@ protected slots:
void doOutputFindDialog();
void doOutputFindNext(bool directionForward = true);
void doOutputFindPrev();
+ void doOutputErrorNext();
protected: