+++ /dev/null
-/**
- * \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
+++ /dev/null
-// -*- 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
ControlExternal.cpp \
ControlGraphics.cpp \
ControlInclude.cpp \
- ControlLog.cpp \
ControlViewSource.cpp \
ControlMath.cpp \
ControlParagraph.cpp \
ControlExternal.h \
ControlGraphics.h \
ControlInclude.h \
- ControlLog.h \
ControlViewSource.h \
ControlMath.h \
ControlParagraph.h \
#include "GuiIndex.h"
#include "GuiMathMatrix.h"
#include "GuiNomencl.h"
-#include "GuiLog.h"
#include "GuiParagraph.h"
#include "GuiPrefs.h"
#include "GuiPrint.h"
} 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);
* 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 "GuiLog.h"
-#include "ControlLog.h"
#include "qt_helpers.h"
+#include "gettext.h"
+#include "Lexer.h"
#include "frontends/Application.h"
#include <QTextBrowser>
#include <QSyntaxHighlighter>
+#include <fstream>
#include <sstream>
+using std::istringstream;
+using std::ostream;
+using std::string;
+
namespace lyx {
namespace frontend {
+using support::FileName;
/////////////////////////////////////////////////////////////////////
//
//
/////////////////////////////////////////////////////////////////////
-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);
}
-ControlLog & GuiLogDialog::controller()
+void GuiLog::closeEvent(QCloseEvent * e)
{
- return static_cast<ControlLog &>(GuiDialog::controller());
+ slotClose();
+ e->accept();
}
-void GuiLogDialog::closeEvent(QCloseEvent * e)
+void GuiLog::updateContents()
{
- slotClose();
- e->accept();
+ setViewTitle(title());
+
+ std::ostringstream ss;
+ getContents(ss);
+
+ logTB->setPlainText(toqstr(ss.str()));
}
-void GuiLogDialog::updateClicked()
+bool GuiLog::initialiseParams(string const & data)
{
- updateContents();
+ 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 GuiLogDialog::updateContents()
+void GuiLog::clearParams()
{
- setViewTitle(controller().title());
+ logfile_.erase();
+}
- std::ostringstream ss;
- controller().getContents(ss);
- logTB->setPlainText(toqstr(ss.str()));
+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
* Licence details can be found in the file COPYING.
*
* \author John Levon
+ * \author Angus Leeming
*
* Full author contact details are available in file CREDITS.
*/
#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