mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
next one
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20779 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c417412fd4
commit
a5f7d951d1
@ -1,131 +0,0 @@
|
||||
/**
|
||||
* \file ControlLog.cpp
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "ControlLog.h"
|
||||
|
||||
#include "gettext.h"
|
||||
#include "Lexer.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
using std::istringstream;
|
||||
using std::ostream;
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::FileName;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
ControlLog::ControlLog(Dialog & parent)
|
||||
: Controller(parent),
|
||||
type_(LatexLog)
|
||||
{}
|
||||
|
||||
|
||||
bool ControlLog::initialiseParams(string const & data)
|
||||
{
|
||||
istringstream is(data);
|
||||
Lexer lex(0,0);
|
||||
lex.setStream(is);
|
||||
|
||||
string logtype, logfile;
|
||||
lex >> logtype;
|
||||
if (lex) {
|
||||
lex.next(true);
|
||||
logfile = lex.getString();
|
||||
}
|
||||
if (!lex)
|
||||
// Parsing of the data failed.
|
||||
return false;
|
||||
|
||||
if (logtype == "latex")
|
||||
type_ = LatexLog;
|
||||
else if (logtype == "literate")
|
||||
type_ = LiterateLog;
|
||||
else if (logtype == "lyx2lyx")
|
||||
type_ = Lyx2lyxLog;
|
||||
else if (logtype == "vc")
|
||||
type_ = VCLog;
|
||||
else
|
||||
return false;
|
||||
|
||||
logfile_ = FileName(logfile);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ControlLog::clearParams()
|
||||
{
|
||||
logfile_.erase();
|
||||
}
|
||||
|
||||
|
||||
docstring const ControlLog::title() const
|
||||
{
|
||||
docstring t;
|
||||
switch (type_) {
|
||||
case LatexLog:
|
||||
t = _("LaTeX Log");
|
||||
break;
|
||||
case LiterateLog:
|
||||
t = _("Literate Programming Build Log");
|
||||
break;
|
||||
case Lyx2lyxLog:
|
||||
t = _("lyx2lyx Error Log");
|
||||
break;
|
||||
case VCLog:
|
||||
t = _("Version Control Log");
|
||||
break;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
void ControlLog::getContents(std::ostream & ss) const
|
||||
{
|
||||
std::ifstream in(logfile_.toFilesystemEncoding().c_str());
|
||||
|
||||
bool success = false;
|
||||
|
||||
// FIXME UNICODE
|
||||
// Our caller interprets the file contents as UTF8, but is that
|
||||
// correct?
|
||||
if (in) {
|
||||
ss << in.rdbuf();
|
||||
success = ss.good();
|
||||
}
|
||||
|
||||
if (success)
|
||||
return;
|
||||
|
||||
switch (type_) {
|
||||
case LatexLog:
|
||||
ss << lyx::to_utf8(_("No LaTeX log file found."));
|
||||
break;
|
||||
case LiterateLog:
|
||||
ss << lyx::to_utf8(_("No literate programming build log file found."));
|
||||
break;
|
||||
case Lyx2lyxLog:
|
||||
ss << lyx::to_utf8(_("No lyx2lyx error log file found."));
|
||||
break;
|
||||
case VCLog:
|
||||
ss << lyx::to_utf8(_("No version control log file found."));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,62 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file ControlLog.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef CONTROLLOG_H
|
||||
#define CONTROLLOG_H
|
||||
|
||||
#include "Dialog.h"
|
||||
|
||||
#include "support/FileName.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
/**
|
||||
* A controller for a read-only text browser.
|
||||
*/
|
||||
class ControlLog : public Controller {
|
||||
public:
|
||||
///
|
||||
ControlLog(Dialog &);
|
||||
/** \param data should contain "<logtype> <logfile>"
|
||||
* where <logtype> is one of "latex", "literate", "lyx2lyx", "vc".
|
||||
*/
|
||||
virtual bool initialiseParams(std::string const & data);
|
||||
///
|
||||
virtual void clearParams();
|
||||
///
|
||||
virtual void dispatchParams() {}
|
||||
///
|
||||
virtual bool isBufferDependent() const { return true; }
|
||||
|
||||
/// The title displayed by the dialog reflects the \c LOGTYPE
|
||||
docstring const title() const;
|
||||
/// put the log file into the ostream
|
||||
void getContents(std::ostream & ss) const;
|
||||
|
||||
private:
|
||||
/// Recognized log file-types
|
||||
enum LOGTYPE {
|
||||
LatexLog,
|
||||
LiterateLog,
|
||||
Lyx2lyxLog,
|
||||
VCLog
|
||||
};
|
||||
|
||||
LOGTYPE type_;
|
||||
support::FileName logfile_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // CONTROLLOG_H
|
@ -17,7 +17,6 @@ SOURCEFILES = \
|
||||
ControlExternal.cpp \
|
||||
ControlGraphics.cpp \
|
||||
ControlInclude.cpp \
|
||||
ControlLog.cpp \
|
||||
ControlViewSource.cpp \
|
||||
ControlMath.cpp \
|
||||
ControlParagraph.cpp \
|
||||
@ -40,7 +39,6 @@ HEADERFILES = \
|
||||
ControlExternal.h \
|
||||
ControlGraphics.h \
|
||||
ControlInclude.h \
|
||||
ControlLog.h \
|
||||
ControlViewSource.h \
|
||||
ControlMath.h \
|
||||
ControlParagraph.h \
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include "GuiIndex.h"
|
||||
#include "GuiMathMatrix.h"
|
||||
#include "GuiNomencl.h"
|
||||
#include "GuiLog.h"
|
||||
#include "GuiParagraph.h"
|
||||
#include "GuiPrefs.h"
|
||||
#include "GuiPrint.h"
|
||||
@ -191,7 +190,7 @@ Dialog * Dialogs::build(string const & name)
|
||||
} else if (name == "label") {
|
||||
dialog = new GuiLabelDialog(lyxview_);
|
||||
} else if (name == "log") {
|
||||
dialog = new GuiLogDialog(lyxview_);
|
||||
createGuiLog(lyxview_);
|
||||
} else if (name == "view-source") {
|
||||
dialog = new DockView<ControlViewSource, GuiViewSourceDialog>(
|
||||
guiview, name, Qt::BottomDockWidgetArea);
|
||||
|
@ -4,6 +4,7 @@
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -12,8 +13,9 @@
|
||||
|
||||
#include "GuiLog.h"
|
||||
|
||||
#include "ControlLog.h"
|
||||
#include "qt_helpers.h"
|
||||
#include "gettext.h"
|
||||
#include "Lexer.h"
|
||||
|
||||
#include "frontends/Application.h"
|
||||
|
||||
@ -21,12 +23,18 @@
|
||||
#include <QTextBrowser>
|
||||
#include <QSyntaxHighlighter>
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
using std::istringstream;
|
||||
using std::ostream;
|
||||
using std::string;
|
||||
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
using support::FileName;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -94,14 +102,14 @@ void LogHighlighter::highlightBlock(QString const & text)
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
GuiLogDialog::GuiLogDialog(LyXView & lv)
|
||||
: GuiDialog(lv, "log")
|
||||
GuiLog::GuiLog(LyXView & lv)
|
||||
: GuiDialog(lv, "log"), Controller(this), type_(LatexLog)
|
||||
{
|
||||
setupUi(this);
|
||||
setController(new ControlLog(*this));
|
||||
setController(this, false);
|
||||
|
||||
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
||||
connect(updatePB, SIGNAL(clicked()), this, SLOT(updateClicked()));
|
||||
connect(updatePB, SIGNAL(clicked()), this, SLOT(updateContents()));
|
||||
|
||||
bc().setPolicy(ButtonPolicy::OkCancelPolicy);
|
||||
|
||||
@ -117,35 +125,116 @@ GuiLogDialog::GuiLogDialog(LyXView & lv)
|
||||
}
|
||||
|
||||
|
||||
ControlLog & GuiLogDialog::controller()
|
||||
{
|
||||
return static_cast<ControlLog &>(GuiDialog::controller());
|
||||
}
|
||||
|
||||
|
||||
void GuiLogDialog::closeEvent(QCloseEvent * e)
|
||||
void GuiLog::closeEvent(QCloseEvent * e)
|
||||
{
|
||||
slotClose();
|
||||
e->accept();
|
||||
}
|
||||
|
||||
|
||||
void GuiLogDialog::updateClicked()
|
||||
void GuiLog::updateContents()
|
||||
{
|
||||
updateContents();
|
||||
}
|
||||
|
||||
|
||||
void GuiLogDialog::updateContents()
|
||||
{
|
||||
setViewTitle(controller().title());
|
||||
setViewTitle(title());
|
||||
|
||||
std::ostringstream ss;
|
||||
controller().getContents(ss);
|
||||
getContents(ss);
|
||||
|
||||
logTB->setPlainText(toqstr(ss.str()));
|
||||
}
|
||||
|
||||
|
||||
bool GuiLog::initialiseParams(string const & data)
|
||||
{
|
||||
istringstream is(data);
|
||||
Lexer lex(0,0);
|
||||
lex.setStream(is);
|
||||
|
||||
string logtype, logfile;
|
||||
lex >> logtype;
|
||||
if (lex) {
|
||||
lex.next(true);
|
||||
logfile = lex.getString();
|
||||
}
|
||||
if (!lex)
|
||||
// Parsing of the data failed.
|
||||
return false;
|
||||
|
||||
if (logtype == "latex")
|
||||
type_ = LatexLog;
|
||||
else if (logtype == "literate")
|
||||
type_ = LiterateLog;
|
||||
else if (logtype == "lyx2lyx")
|
||||
type_ = Lyx2lyxLog;
|
||||
else if (logtype == "vc")
|
||||
type_ = VCLog;
|
||||
else
|
||||
return false;
|
||||
|
||||
logfile_ = FileName(logfile);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void GuiLog::clearParams()
|
||||
{
|
||||
logfile_.erase();
|
||||
}
|
||||
|
||||
|
||||
docstring GuiLog::title() const
|
||||
{
|
||||
switch (type_) {
|
||||
case LatexLog:
|
||||
return _("LaTeX Log");
|
||||
case LiterateLog:
|
||||
return _("Literate Programming Build Log");
|
||||
case Lyx2lyxLog:
|
||||
return _("lyx2lyx Error Log");
|
||||
case VCLog:
|
||||
return _("Version Control Log");
|
||||
default:
|
||||
return docstring();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GuiLog::getContents(std::ostream & ss) const
|
||||
{
|
||||
std::ifstream in(logfile_.toFilesystemEncoding().c_str());
|
||||
|
||||
bool success = false;
|
||||
|
||||
// FIXME UNICODE
|
||||
// Our caller interprets the file contents as UTF8, but is that
|
||||
// correct?
|
||||
if (in) {
|
||||
ss << in.rdbuf();
|
||||
success = ss.good();
|
||||
}
|
||||
|
||||
if (success)
|
||||
return;
|
||||
|
||||
switch (type_) {
|
||||
case LatexLog:
|
||||
ss << to_utf8(_("No LaTeX log file found."));
|
||||
break;
|
||||
case LiterateLog:
|
||||
ss << to_utf8(_("No literate programming build log file found."));
|
||||
break;
|
||||
case Lyx2lyxLog:
|
||||
ss << to_utf8(_("No lyx2lyx error log file found."));
|
||||
break;
|
||||
case VCLog:
|
||||
ss << to_utf8(_("No version control log file found."));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Dialog * createGuiLog(LyXView & lv) { return new GuiLog(lv); }
|
||||
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
* \author Angus Leeming
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
@ -13,36 +14,67 @@
|
||||
#define GUILOG_H
|
||||
|
||||
#include "GuiDialog.h"
|
||||
#include "ControlLog.h"
|
||||
#include "ui_LogUi.h"
|
||||
|
||||
#include "support/FileName.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class LogHighlighter;
|
||||
|
||||
class GuiLogDialog : public GuiDialog, public Ui::LogUi
|
||||
class GuiLog : public GuiDialog, public Ui::LogUi, public Controller
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GuiLogDialog(LyXView & lv);
|
||||
GuiLog(LyXView & lv);
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateClicked();
|
||||
void updateContents();
|
||||
|
||||
private:
|
||||
void closeEvent(QCloseEvent * e);
|
||||
/// parent controller
|
||||
ControlLog & controller();
|
||||
Controller & controller() { return *this; }
|
||||
/// Apply changes
|
||||
void applyView() {}
|
||||
/// update
|
||||
void updateContents();
|
||||
|
||||
/// log syntax highlighter
|
||||
LogHighlighter * highlighter;
|
||||
|
||||
/** \param data should contain "<logtype> <logfile>"
|
||||
* where <logtype> is one of "latex", "literate", "lyx2lyx", "vc".
|
||||
*/
|
||||
bool initialiseParams(std::string const & data);
|
||||
///
|
||||
void clearParams();
|
||||
///
|
||||
void dispatchParams() {}
|
||||
///
|
||||
bool isBufferDependent() const { return true; }
|
||||
|
||||
/// The title displayed by the dialog reflects the \c LogType
|
||||
docstring title() const;
|
||||
/// put the log file into the ostream
|
||||
void getContents(std::ostream & ss) const;
|
||||
|
||||
private:
|
||||
/// Recognized log file-types
|
||||
enum LogType {
|
||||
LatexLog,
|
||||
LiterateLog,
|
||||
Lyx2lyxLog,
|
||||
VCLog
|
||||
};
|
||||
|
||||
LogType type_;
|
||||
support::FileName logfile_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // QLOG_H
|
||||
#endif // GUILOG_H
|
||||
|
Loading…
Reference in New Issue
Block a user