* GuiLog.{cpp,h}:

* LogUi.ui:
	- add some basic navigation facilities.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30153 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2009-06-18 09:35:51 +00:00
parent a842957959
commit 8e109a4153
3 changed files with 135 additions and 26 deletions

View File

@ -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();
}

View File

@ -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

View File

@ -1,7 +1,4 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>LogUi</class>
<widget class="QDialog" name="LogUi" >
<property name="geometry" >
@ -9,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>421</width>
<height>359</height>
<height>441</height>
</rect>
</property>
<property name="windowTitle" >
@ -25,14 +22,27 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="0" >
<widget class="QPushButton" name="copyPB" >
<item row="3" column="3" colspan="2" >
<widget class="QPushButton" name="updatePB" >
<property name="toolTip" >
<string>Update the display</string>
</property>
<property name="text" >
<string>Copy to Clip&amp;board</string>
<string>&amp;Update</string>
</property>
<property name="default" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1" >
<item row="3" column="5" >
<widget class="QPushButton" name="closePB" >
<property name="text" >
<string>&amp;Close</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
@ -48,32 +58,75 @@
</property>
</spacer>
</item>
<item row="1" column="3" >
<widget class="QPushButton" name="closePB" >
<item row="3" column="0" >
<widget class="QPushButton" name="copyPB" >
<property name="text" >
<string>&amp;Close</string>
<string>Copy to Clip&amp;board</string>
</property>
</widget>
</item>
<item row="1" column="2" >
<widget class="QPushButton" name="updatePB" >
<item row="1" column="0" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>201</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="5" >
<widget class="QPushButton" name="findPB" >
<property name="text" >
<string>&amp;Go!</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="4" >
<widget class="QLineEdit" name="findLE" >
<property name="toolTip" >
<string>Update the display</string>
</property>
<property name="text" >
<string>&amp;Update</string>
</property>
<property name="default" >
<bool>true</bool>
<string>Enter search string, hit return or thr "Go!" button.</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4" >
<item row="2" column="0" >
<widget class="QLabel" name="findLA" >
<property name="text" >
<string>&amp;Find:</string>
</property>
<property name="buddy" >
<cstring>findLE</cstring>
</property>
</widget>
</item>
<item row="1" column="4" colspan="2" >
<widget class="QPushButton" name="nextWarningPB" >
<property name="toolTip" >
<string>Jump to the next warning message.</string>
</property>
<property name="text" >
<string>Next &amp;Warning</string>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2" >
<widget class="QPushButton" name="nextErrorPB" >
<property name="toolTip" >
<string>Jump to the next error message.</string>
</property>
<property name="text" >
<string>Next &amp;Error</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="6" >
<widget class="QTextBrowser" name="logTB" />
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<tabstops>
<tabstop>logTB</tabstop>
<tabstop>copyPB</tabstop>