]> git.lyx.org Git - features.git/commitdiff
next one
authorAndré Pönitz <poenitz@gmx.net>
Sat, 6 Oct 2007 11:45:53 +0000 (11:45 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sat, 6 Oct 2007 11:45:53 +0000 (11:45 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20779 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/controllers/ControlLog.cpp [deleted file]
src/frontends/controllers/ControlLog.h [deleted file]
src/frontends/controllers/Makefile.am
src/frontends/qt4/Dialogs.cpp
src/frontends/qt4/GuiLog.cpp
src/frontends/qt4/GuiLog.h

diff --git a/src/frontends/controllers/ControlLog.cpp b/src/frontends/controllers/ControlLog.cpp
deleted file mode 100644 (file)
index 437cd96..0000000
+++ /dev/null
@@ -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
diff --git a/src/frontends/controllers/ControlLog.h b/src/frontends/controllers/ControlLog.h
deleted file mode 100644 (file)
index de76eaf..0000000
+++ /dev/null
@@ -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
index b3b357d0ff2571369529c288f7578ba575ed4430..8e14c963350b016467765d8c322f85a212c557d1 100644 (file)
@@ -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 \
index 326e45fa27ab9eae06adacf5d4c185b9a5044659..6e4a1c1758970e5b2b211504c5ff6a2895494ab8 100644 (file)
@@ -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);
index 290015ff16bc12d82973428e17f2cc833a8cd6a9..67609d9fb41e98cab81ba2f24168034dccb5e91c 100644 (file)
@@ -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"
 
 #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()
+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
 
index 07940d94ff1f6382e3950244552e4c053a1d9c6b..6be299386ac9e06de8574b984308e9b1dc428c81 100644 (file)
@@ -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.
  */
 #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