From 28988d22bc3eaa7aa5961980d11aa910c03ed234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Thu, 9 Jul 2009 15:54:13 +0000 Subject: [PATCH] * GuiLog.{cpp,h}: * LogUi.ui: - add some basic navigation facilities. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@30426 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiLog.cpp | 52 +++++++++++++++++-- src/frontends/qt4/GuiLog.h | 12 ++++- src/frontends/qt4/ui/LogUi.ui | 97 +++++++++++++++++++++++++++-------- status.16x | 2 + 4 files changed, 137 insertions(+), 26 deletions(-) diff --git a/src/frontends/qt4/GuiLog.cpp b/src/frontends/qt4/GuiLog.cpp index a1a46d02c8..da2c40af38 100644 --- a/src/frontends/qt4/GuiLog.cpp +++ b/src/frontends/qt4/GuiLog.cpp @@ -5,6 +5,7 @@ * * \author John Levon * \author Angus Leeming + * \author Jürgen Spitzmüller * * Full author contact details are available in file CREDITS. */ @@ -33,6 +34,16 @@ using namespace lyx::support; namespace lyx { namespace frontend { + +// Regular expressions needed at several places +// Information +QRegExp exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|Underfull|Overfull|\\(|\\\\).*$"); +// Warnings +QRegExp exprWarning("^LaTeX Warning.*$"); +// Errors +QRegExp exprError("^!.*$"); + + ///////////////////////////////////////////////////////////////////// // // LogHighlighter @@ -67,7 +78,6 @@ LogHighlighter::LogHighlighter(QTextDocument * parent) void LogHighlighter::highlightBlock(QString const & text) { // Info - QRegExp exprInfo("^(Document Class:|LaTeX Font Info:|File:|Package:|Language:|Underfull|Overfull|\\(|\\\\).*$"); int index = exprInfo.indexIn(text); while (index >= 0) { int length = exprInfo.matchedLength(); @@ -75,7 +85,6 @@ void LogHighlighter::highlightBlock(QString const & text) index = exprInfo.indexIn(text, index + length); } // LaTeX Warning: - QRegExp exprWarning("^LaTeX Warning.*$"); index = exprWarning.indexIn(text); while (index >= 0) { int length = exprWarning.matchedLength(); @@ -83,7 +92,6 @@ void LogHighlighter::highlightBlock(QString const & text) index = exprWarning.indexIn(text, index + length); } // ! error - QRegExp exprError("^!.*$"); index = exprError.indexIn(text); while (index >= 0) { int length = exprError.matchedLength(); @@ -106,6 +114,9 @@ GuiLog::GuiLog(GuiView & lv) connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); connect(updatePB, SIGNAL(clicked()), this, SLOT(updateContents())); + connect(findPB, SIGNAL(clicked()), this, SLOT(find())); + // FIXME: find via returnPressed() does not work! + connect(findLE, SIGNAL(returnPressed()), this, SLOT(find())); bc().setPolicy(ButtonPolicy::OkCancelPolicy); @@ -129,6 +140,41 @@ void GuiLog::updateContents() getContents(ss); logTB->setPlainText(toqstr(ss.str())); + + nextErrorPB->setEnabled(contains(exprError)); + nextWarningPB->setEnabled(contains(exprWarning)); +} + + +void GuiLog::find() +{ + logTB->find(findLE->text()); +} + + +void GuiLog::on_nextErrorPB_clicked() +{ + goTo(exprError); +} + + +void GuiLog::on_nextWarningPB_clicked() +{ + goTo(exprWarning); +} + + +void GuiLog::goTo(QRegExp const & exp) const +{ + QTextCursor const newc = + logTB->document()->find(exp, logTB->textCursor()); + logTB->setTextCursor(newc); +} + + +bool GuiLog::contains(QRegExp const & exp) const +{ + return !logTB->document()->find(exp, logTB->textCursor()).isNull(); } diff --git a/src/frontends/qt4/GuiLog.h b/src/frontends/qt4/GuiLog.h index f7829c73f9..e8bdbb901b 100644 --- a/src/frontends/qt4/GuiLog.h +++ b/src/frontends/qt4/GuiLog.h @@ -33,8 +33,14 @@ public: private Q_SLOTS: void updateContents(); - // copy log to clipboard + /// copy log to clipboard void on_copyPB_clicked(); + /// find content + void find(); + /// jump to next error message + void on_nextErrorPB_clicked(); + /// jump to next warning + void on_nextWarningPB_clicked(); private: /// Apply changes @@ -58,6 +64,10 @@ private: docstring title() const; /// put the log file into the ostream void getContents(std::ostream & ss) const; + /// go to the next occurence of the RegExp + void goTo(QRegExp const & exp) const; + /// does the document after cursor position contain the RegExp? + bool contains(QRegExp const & exp) const; private: /// Recognized log file-types diff --git a/src/frontends/qt4/ui/LogUi.ui b/src/frontends/qt4/ui/LogUi.ui index 8efe0e834b..a00615bebe 100644 --- a/src/frontends/qt4/ui/LogUi.ui +++ b/src/frontends/qt4/ui/LogUi.ui @@ -1,7 +1,4 @@ - - - LogUi @@ -9,7 +6,7 @@ 0 0 421 - 359 + 441 @@ -25,14 +22,27 @@ 6 - - + + + + Update the display + - Copy to Clip&board + &Update + + + true - + + + + &Close + + + + Qt::Horizontal @@ -48,32 +58,75 @@ - - + + - &Close + Copy to Clip&board - - + + + + Qt::Horizontal + + + + 201 + 20 + + + + + + + + &Go! + + + + + - Update the display - - - &Update - - - true + Enter search string, hit return or thr "Go!" button. - + + + + &Find: + + + findLE + + + + + + + Jump to the next warning message. + + + Next &Warning + + + + + + + Jump to the next error message. + + + Next &Error + + + + - logTB copyPB diff --git a/status.16x b/status.16x index 73316a3e27..1209629faf 100644 --- a/status.16x +++ b/status.16x @@ -52,6 +52,8 @@ What's new to begin/end of insets (and outside of the inset if the cursor is already in place). There are also versions that select text. +- The LaTeX Log File dialog has a search facility. + - Notes context menu has a new item for toggling all notes. - Math context menu has a new item for numbering a single line in a formula.