]> git.lyx.org Git - features.git/commitdiff
Rationalize the interface to the log dialog.
authorAngus Leeming <leeming@lyx.org>
Fri, 5 Dec 2003 13:37:23 +0000 (13:37 +0000)
committerAngus Leeming <leeming@lyx.org>
Fri, 5 Dec 2003 13:37:23 +0000 (13:37 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8204 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlLog.C
src/frontends/controllers/ControlLog.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/Dialogs.C
src/frontends/qt2/QLog.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/Dialogs.C
src/frontends/xforms/FormLog.C
src/lyxfunc.C

index 630da56e7d9fec2e6900e5169d93b259d84edc85..b8e67ebaa0d0cb7a9c379fb4d2e9478a13328041 100644 (file)
@@ -1,3 +1,8 @@
+2003-12-05  Angus Leeming  <leeming@lyx.org>
+
+       * lyxfunc.C (dispatch): DIALOG_SHOW now handles "latexlog" and
+       "vclog" explicitly, passing the appropriate "<logtype> <filename>"
+       data to the re-worked "log" dialog.
 
 2003-12-03  André Pönitz  <poenitz@gmx.net>
 
index cb4b82c8b85faa560171f47f8d78a7cadee023cc..0d8ff120c321d71f149cb13c5e51f59838d5daf1 100644 (file)
@@ -1,3 +1,8 @@
+2003-12-05  Angus Leeming  <leeming@lyx.org>
+
+       * ControlLog.[Ch]: re-worked so that it is passed the logtype and
+       filename rather than extracting them from the kernel.
+
 2003-12-04  Angus Leeming  <leeming@lyx.org>
 
        * ControlExternal.[Ch] (bbChanged): new accessor functions to a
index 5cbbab2d30dc0fa0f4eab5ca2b64f3a2cb78da60..f83803a29b0acdb035949d2b297d644c60b13af6 100644 (file)
 
 #include "ControlLog.h"
 
+#include "gettext.h"
+#include "lyxlex.h"
 
+#include "support/std_sstream.h"
+
+#include <fstream>
+
+using std::istringstream;
+using std::ostream;
 using std::string;
 
 
 ControlLog::ControlLog(Dialog & parent)
-       : Dialog::Controller(parent)
+       : Dialog::Controller(parent),
+         type_(LatexLog)
 {}
 
 
-bool ControlLog::initialiseParams(string const &)
+bool ControlLog::initialiseParams(string const & data)
 {
-       logfile_ = kernel().buffer().getLogName();
+       istringstream is(data);
+       LyXLex lex(0,0);
+       lex.setStream(is);
+
+       string logtype, logfile;
+       lex >> logtype >> logfile;
+       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_ = logfile;
        return true;
 }
 
 
 void ControlLog::clearParams()
 {
-       logfile_.second.erase();
+       logfile_.erase();
+}
+
+
+string const ControlLog::title() const
+{
+       string t;
+       switch (type_) {
+       case LatexLog:
+               t = _("LyX: LaTeX Log");
+               break;
+       case LiterateLog:
+               t = _("LyX: Literate Programming Build Log");
+               break;
+       case Lyx2lyxLog:
+               t = _("LyX: lyx2lyx error Log");
+               break;
+       case VCLog:
+               t = _("Version Control Log");
+               break;
+       }
+       return t;
+}
+
+
+void ControlLog::getContents(std::ostream & ss) const
+{
+       std::ifstream in(logfile_.c_str());
+
+       bool success = false;
+
+       if (in) {
+               ss << in.rdbuf();
+               success = ss.good();
+       }
+
+       if (success)
+               return;
+
+       switch (type_) {
+       case LatexLog:
+               ss << _("No LaTeX log file found.");
+               break;
+       case LiterateLog:
+               ss << _("No literate programming build log file found.");
+               break;
+       case Lyx2lyxLog:
+               ss << _("No lyx2lyx error log file found.");
+               break;
+       case VCLog:
+               ss << _("No version control log file found.");
+               break;
+       }
 }
index 0843d1e6c5d60ddc3e1290bc8864b491ea0211c3..699cab0c256f0ac1f27f80707a9b1df09a58e5ce 100644 (file)
@@ -14,8 +14,6 @@
 #define CONTROLLOG_H
 
 #include "Dialog.h"
-#include "buffer.h" // Buffer::LogType
-#include <utility>
 
 /**
  * A controller for a read-only text browser.
@@ -24,7 +22,9 @@ class ControlLog : public Dialog::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();
@@ -32,13 +32,23 @@ public:
        virtual void dispatchParams() {}
        ///
        virtual bool isBufferDependent() const { return true; }
-       ///
-       std::pair<Buffer::LogType, std::string> const & logfile() const {
-               return logfile_;
-       }
+
+       /// The title displayed by the dialog reflects the \c LOGTYPE
+       std::string 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
+       };
 
-       std::pair<Buffer::LogType, std::string> logfile_;
+       LOGTYPE type_;
+       std::string logfile_;
 };
 
 #endif // CONTROLLOG_H
index b3fc62abbba04b298d11c50d922b3f973583f4b1..8959e8257349ced09b307e50012ee03202f5cdf6 100644 (file)
@@ -1,3 +1,10 @@
+2003-12-05  Angus Leeming  <leeming@lyx.org>
+
+       * QLog.C: much simplified, thanks to the more powerful interface
+       of ControlLog.
+
+       * Dialogs.C: no need anymore to build a separate VCLog dialog.
+
 2003-12-05  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * ui/QExternalDialogBase.ui: improved layout.
index 72d8d9dce5750f81ad4c7ea3cc6e42a3ffede285..f5b5eec40417563801f77d84297ab2bf8902e782 100644 (file)
@@ -34,7 +34,6 @@
 #include "ControlTabular.h"
 #include "ControlTabularCreate.h"
 #include "ControlToc.h"
-#include "ControlVCLog.h"
 #include "ControlVSpace.h"
 #include "ControlWrap.h"
 
@@ -70,7 +69,6 @@
 #include "QTexinfo.h"
 #include "QToc.h"
 #include "QURL.h"
-#include "QVCLog.h"
 #include "QVSpace.h"
 #include "QWrap.h"
 
@@ -88,7 +86,7 @@ namespace {
 
 char const * const dialognames[] = { "aboutlyx", "bibitem", "bibtex", "branch",
 "changes", "character", "citation", "error", "errorlist", "ert", "external", "file",
-"float", "graphics", "include", "index", "label", "latexlog",
+"float", "graphics", "include", "index", "label", "log",
 "mathpanel", "mathdelimiter", "mathmatrix",
 "minipage", "note", "paragraph", "ref", "tabular", "tabularcreate", "texinfo",
 
@@ -96,7 +94,7 @@ char const * const dialognames[] = { "aboutlyx", "bibitem", "bibtex", "branch",
 "thesaurus",
 #endif
 
-"toc", "url", "vclog", "vspace", "wrap" };
+"toc", "url", "vspace", "wrap" };
 
 char const * const * const end_dialognames =
        dialognames + (sizeof(dialognames) / sizeof(char *));
@@ -197,7 +195,7 @@ Dialog * Dialogs::build(string const & name)
                                           _("LyX: Label"),
                                           qt_("&Label")));
                dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
-       } else if (name == "latexlog") {
+       } else if (name == "log") {
                dialog->setController(new ControlLog(*dialog));
                dialog->setView(new QLog(*dialog));
                dialog->bc().bp(new OkCancelPolicy);
@@ -255,10 +253,6 @@ Dialog * Dialogs::build(string const & name)
                dialog->setController(new ControlCommand(*dialog, name));
                dialog->setView(new QURL(*dialog));
                dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
-       } else if (name == "vclog") {
-               dialog->setController(new ControlVCLog(*dialog));
-               dialog->setView(new QVCLog(*dialog));
-               dialog->bc().bp(new OkCancelPolicy);
        } else if (name == "vspace") {
                dialog->setController(new ControlVSpace(*dialog));
                dialog->setView(new QVSpace(*dialog));
index 843d3aa08de7c51730d0134ca7adfbba78c4692f..64dabd1f6682c11017bb827e7f8cb6c1858473ec 100644 (file)
 
 #include <config.h>
 
-#include "debug.h"
-#include "qt_helpers.h"
-#include "ControlLog.h"
-#include "support/std_sstream.h"
+#include "controllers/ControlLog.h"
 
-#include <qtextview.h>
-#include <qpushbutton.h>
+#include "support/std_sstream.h"
 
-#include "QLogDialog.h"
 #include "QLog.h"
-#include "Qt2BC.h"
+#include "QLogDialog.h"
 
-#include <fstream>
+#include "qt_helpers.h"
+
+#include <qtextview.h>
+#include <qpushbutton.h>
 
-using std::ifstream;
-using std::ostringstream;
-using std::string;
 
 typedef QController<ControlLog, QView<QLogDialog> > base_class;
 
 QLog::QLog(Dialog & parent)
-       : base_class(parent, _("LyX: LaTeX Log"))
-{
-}
+       : base_class(parent, "")
+{}
 
 
 void QLog::build_dialog()
 {
        dialog_.reset(new QLogDialog(this));
-
-       bcview().setCancel(dialog_->closePB);
 }
 
 
 void QLog::update_contents()
 {
-       std::pair<Buffer::LogType, string> const & logfile =
-               controller().logfile();
-
-       if (logfile.first == Buffer::buildlog)
-               setTitle(_("Build log"));
-       else
-               setTitle(_("LaTeX log"));
-
-       dialog_->logTV->setText("");
-
-       ifstream ifstr(logfile.second.c_str());
-       if (!ifstr) {
-               if (logfile.first == Buffer::buildlog)
-                       dialog_->logTV->setText(qt_("No build log file found."));
-               else
-                       dialog_->logTV->setText(qt_("No LaTeX log file found."));
-               return;
-       }
+       setTitle(controller().title());
 
-       ostringstream ost;
-       ost << ifstr.rdbuf();
+       std::ostringstream ss;
+       controller().getContents(ss);
 
-       dialog_->logTV->setText(toqstr(ost.str()));
+       dialog_->logTV->setText(toqstr(ss.str()));
 }
index bb1b592802cc9b22b2f4af08676f4331c6d5a52c..55c96416ab231c5445c0515e17e37b53f87c604d 100644 (file)
@@ -1,3 +1,10 @@
+2003-12-05  Angus Leeming  <leeming@lyx.org>
+
+       * FormLog.C: much simplified, thanks to the more powerful interface
+       of ControlLog.
+
+       * Dialogs.C: no need anymore to build a separate VCLog dialog.
+
 2003-12-05  Angus Leeming  <leeming@lyx.org>
 
        * forms/form_external.fd: try and mimic Jürgen's changes to
index 5cafa29dd2f48554c38f7e95b7f0e1f9ff341ec5..11444a3c1e21d0e75ed41d9f3660dc59be2ff2c6 100644 (file)
@@ -36,7 +36,6 @@
 #include "ControlTabular.h"
 #include "ControlTabularCreate.h"
 #include "ControlToc.h"
-#include "ControlVCLog.h"
 #include "ControlVSpace.h"
 #include "ControlWrap.h"
 
@@ -72,7 +71,6 @@
 #include "FormText.h"
 #include "FormToc.h"
 #include "FormUrl.h"
-#include "FormVCLog.h"
 #include "FormVSpace.h"
 #include "FormWrap.h"
 
@@ -116,7 +114,7 @@ FormMathsBitmap * createFormBitmap(Dialog & parent, string const & title,
 char const * const dialognames[] = {
 "aboutlyx", "bibitem", "bibtex", "branch", "box", "changes",
 "character", "citation", "error", "errorlist" , "ert", "external", "file",
-"float", "graphics", "include", "index", "label", "latexlog", "mathpanel",
+"float", "graphics", "include", "index", "label", "log", "mathpanel",
 "mathaccents", "matharrows", "mathoperators", "mathrelations", "mathgreek",
 "mathmisc", "mathdots", "mathbigoperators", "mathamsmisc",
 "mathamsarrows", "mathamsrelations", "mathamsnegatedrelations", "mathamsoperators",
@@ -127,7 +125,7 @@ char const * const dialognames[] = {
 "thesaurus",
 #endif
 
-"toc", "url", "vclog", "vspace", "wrap" };
+"toc", "url", "vspace", "wrap" };
 
 char const * const * const end_dialognames =
        dialognames + (sizeof(dialognames) / sizeof(char *));
@@ -221,7 +219,7 @@ Dialog * Dialogs::build(string const & name)
                dialog->setView(new FormText(*dialog,
                                             _("Label"), _("Label:|#L")));
                dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
-       } else if (name == "latexlog") {
+       } else if (name == "log") {
                dialog->setController(new ControlLog(*dialog));
                dialog->setView(new FormLog(*dialog));
                dialog->bc().bp(new OkCancelPolicy);
@@ -457,10 +455,6 @@ Dialog * Dialogs::build(string const & name)
                dialog->setController(new ControlCommand(*dialog, name));
                dialog->setView(new FormUrl(*dialog));
                dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
-       } else if (name == "vclog") {
-               dialog->setController(new ControlVCLog(*dialog));
-               dialog->setView(new FormVCLog(*dialog));
-               dialog->bc().bp(new OkCancelPolicy);
        } else if (name == "vspace") {
                dialog->setController(new ControlVSpace(*dialog));
                dialog->setView(new FormVSpace(*dialog));
index 8560d19ca9b1635456d077159456f980613e4dac..bcbf7ffb38c93b9c2c2f75a3d204e606bc6e8d9d 100644 (file)
 #include "ControlLog.h"
 #include "forms/form_browser.h"
 
-#include "xformsBC.h"
+#include "support/std_sstream.h"
 
 #include "lyx_forms.h"
 
 
-using std::string;
-
-
 FormLog::FormLog(Dialog & parent)
-       : FormController<ControlLog, FormBrowser>(parent, _("LaTeX Log"))
+       : FormController<ControlLog, FormBrowser>(parent, "")
 {}
 
 
 void FormLog::update()
 {
-       bool const buildlog = controller().logfile().first == Buffer::buildlog;
+       setTitle(controller().title());
 
-       string const title = buildlog ?
-               _("LyX: LaTeX Log") :
-               _("LyX: Literate Programming Build Log");
-       setTitle(title);
+       std::ostringstream ss;
+       controller().getContents(ss);
 
        fl_clear_browser(dialog_->browser);
-       int const valid = fl_load_browser(dialog_->browser,
-                                         controller().logfile().second.c_str());
-       if (!valid) {
-               string const error = buildlog ?
-                       _("No LaTeX log file found.") :
-                       _("No Literate Programming build log file found.");
-               fl_add_browser_line(dialog_->browser, error.c_str());
-       }
+       fl_add_browser_line(dialog_->browser, ss.str().c_str());
 }
index 51fe3b7ae6e31ecd13280b6119b31461b8133aa1..a2682d04a299710f0ec30134a4dc84cfea57e5c1 100644 (file)
@@ -109,6 +109,7 @@ using lyx::support::os::getTmpDir;
 
 using std::endl;
 using std::make_pair;
+using std::pair;
 using std::string;
 using std::istringstream;
 
@@ -1195,7 +1196,8 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                                data = freefont2string();
                                if (!data.empty())
                                        owner->getDialogs().show("character", data);
-                       } else if (name == "document")
+                       }
+                       else if (name == "document")
                                owner->getDialogs().showDocument();
                        else if (name == "findreplace")
                                owner->getDialogs().showSearch();
@@ -1209,6 +1211,26 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                                owner->getDialogs().showPrint();
                        else if (name == "spellchecker")
                                owner->getDialogs().showSpellchecker();
+
+                       else if (name == "latexlog") {
+                               pair<Buffer::LogType, string> const logfile =
+                                       owner->buffer()->getLogName();
+                               switch (logfile.first) {
+                               case Buffer::latexlog:
+                                       data = "latex ";
+                                       break;
+                               case Buffer::buildlog:
+                                       data = "literate ";
+                                       break;
+                               }
+                               data += logfile.second;
+                               owner->getDialogs().show("log", data);
+                       }
+                       else if (name == "vclog") {
+                               string const data = "vc " +
+                                       owner->buffer()->lyxvc().getLogFile();
+                               owner->getDialogs().show("log", data);
+                       }
                        else
                                owner->getDialogs().show(name, data);
                        break;