]> git.lyx.org Git - features.git/commitdiff
the errorlist change
authorAlfredo Braunstein <abraunst@lyx.org>
Tue, 13 May 2003 21:15:48 +0000 (21:15 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Tue, 13 May 2003 21:15:48 +0000 (21:15 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6958 a592a061-630c-0410-9148-cb99ea01b6c8

25 files changed:
src/BufferView.C
src/BufferView.h
src/ChangeLog
src/buffer.C
src/converter.C
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlErrorList.C [new file with mode: 0644]
src/frontends/controllers/ControlErrorList.h [new file with mode: 0644]
src/frontends/controllers/Makefile.am
src/frontends/qt2/ChangeLog
src/frontends/qt2/Dialogs.C
src/frontends/qt2/Makefile.am
src/frontends/qt2/Makefile.dialogs
src/frontends/qt2/QErrorList.C [new file with mode: 0644]
src/frontends/qt2/QErrorList.h [new file with mode: 0644]
src/frontends/qt2/QErrorListDialog.C [new file with mode: 0644]
src/frontends/qt2/QErrorListDialog.h [new file with mode: 0644]
src/frontends/qt2/ui/QErrorListDialogBase.ui [new file with mode: 0644]
src/frontends/xforms/ChangeLog
src/frontends/xforms/Dialogs.C
src/frontends/xforms/FormErrorList.C [new file with mode: 0644]
src/frontends/xforms/FormErrorList.h [new file with mode: 0644]
src/frontends/xforms/Makefile.am
src/frontends/xforms/forms/Makefile.am
src/frontends/xforms/forms/form_errorlist.fd [new file with mode: 0644]

index 49a2ed934180c6a0770a01dca291d272084276f4..7b2bece96e2528c59010f1e7978eafe05bc19c19 100644 (file)
@@ -467,48 +467,9 @@ bool BufferView::removeAutoInsets()
 }
 
 
-void BufferView::insertErrors(TeXErrors & terr)
+void BufferView::showErrorList()
 {
-       // Save the cursor position
-       LyXCursor cursor = text->cursor;
-
-       TeXErrors::Errors::const_iterator cit = terr.begin();
-       TeXErrors::Errors::const_iterator end = terr.end();
-       for (; cit != end; ++cit) {
-               string const desctext(cit->error_desc);
-               string const errortext(cit->error_text);
-               string const msgtxt = desctext + '\n' + errortext;
-               int const errorrow = cit->error_in_line;
-
-               // Insert error string for row number
-               int tmpid = -1;
-               int tmppos = -1;
-
-               if (buffer()->texrow.getIdFromRow(errorrow, tmpid, tmppos)) {
-                       buffer()->texrow.increasePos(tmpid, tmppos);
-               }
-
-               Paragraph * texrowpar = 0;
-
-               if (tmpid == -1) {
-                       texrowpar = &*text->ownerParagraphs().begin();
-                       tmppos = 0;
-               } else {
-                       texrowpar = &*buffer()->getParFromID(tmpid);
-               }
-
-               if (texrowpar == 0)
-                       continue;
-
-               freezeUndo();
-               InsetError * new_inset = new InsetError(msgtxt);
-               text->setCursorIntern(texrowpar, tmppos);
-               text->insertInset(new_inset);
-               text->fullRebreak();
-               unFreezeUndo();
-       }
-       // Restore the cursor position
-       text->setCursorIntern(cursor.par(), cursor.pos());
+       owner()->getDialogs().show("errorlist");
 }
 
 
index 9a586251083ef43b4ecd560154051a44983d897a..fe00dc967238f3ba4a18c9413ff22b59a3c23809 100644 (file)
@@ -153,8 +153,8 @@ public:
 
        /// removes all autodeletable insets
        bool removeAutoInsets();
-       /// insert all errors found when running latex
-       void insertErrors(TeXErrors & terr);
+       /// show the error list to the user
+       void showErrorList();
        /// set the cursor based on the given TeX source row
        void setCursorFromRow(int row);
 
index 3f4bdf4b62b613c657eefec54f4d0c81ae472563..76040301396d16aa3bd491bca64a6f097fc0fa9c 100644 (file)
@@ -1,3 +1,9 @@
+2003-05-12 Alfredo Braunstein <abraunst@libero.it>
+
+       * BufferView.[Ch] (insertErrors): removed
+       * BufferView.[Ch] (showErrorList): added
+       * buffer.C (runChkTeX):
+       * converter.C (scanLog): call showErrorList instead of inserterrors
 
 2003-05-13 André Pönitz <poenitz@gmx.net>
        
index da63f13f66bf1537f251e23c63e0803cd076d76d..07b9ccbf2c5b4114e39b737a8aec8d164162ba8c 100644 (file)
@@ -1977,7 +1977,7 @@ int Buffer::runChktex()
                        _("Could not run chktex successfully."));
        } else if (res > 0) {
                // Insert all errors as errors boxes
-               users->insertErrors(terr);
+               users->showErrorList();
        }
 
        // if we removed error insets before we ran chktex or if we inserted
index 6798b5a6a1de17f2449e0ce8e3b7423b50afe0f5..3577adb9c401cf6f433bff354323879827d83df3 100644 (file)
@@ -459,58 +459,19 @@ bool Converters::formatIsUsed(string const & format)
 }
 
 
-namespace {
-
-void alertErrors(string const & prog, int nr_errors)
-{
-       string s;
-       if (nr_errors == 1)
-               s = bformat(_("One error detected when running %1$s.\n"), prog);
-       else
-               s = bformat(_("%1$s errors detected when running %2$s.\n"),
-                       prog, tostr(nr_errors));
-       Alert::error(_("Errors found"), s);
-}
-
-}
-
-
 bool Converters::scanLog(Buffer const * buffer, string const & command,
-                       string const & filename)
+                        string const & filename)
 {
        if (!buffer)
                return false;
 
        BufferView * bv = buffer->getUser();
-       if (bv) {
-               bv->owner()->busy(true);
-               // all error insets should have been removed by now
-       }
-
        LaTeX latex("", filename, "");
        TeXErrors terr;
        int result = latex.scanLogFile(terr);
-       if (bv) {
-               if ((result & LaTeX::ERRORS)) {
-                       // Insert all errors as errors boxes
-                       bv->insertErrors(terr);
-#warning repaint() or update() or nothing ?
-                       bv->repaint();
-                       bv->fitCursor();
-               }
-               bv->owner()->busy(false);
-       }
+       if (bv && (result & LaTeX::ERRORS))
+               bv->showErrorList();
 
-       if ((result & LaTeX::ERRORS)) {
-               string head;
-               split(command, head, ' ');
-               alertErrors(head, latex.getNumErrors());
-               return false;
-       } else if (result & LaTeX::NO_OUTPUT) {
-               Alert::warning(_("Output is empty"),
-                       _("An empty output file was generated."));
-               return false;
-       }
        return true;
 }
 
@@ -535,14 +496,9 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command)
        int result = latex.run(terr,
                               bv ? &bv->owner()->getLyXFunc() : 0);
 
-       if (bv) {
-               if ((result & LaTeX::ERRORS)) {
-                       // Insert all errors as errors boxes
-                       bv->insertErrors(terr);
-#warning repaint() or update() or nothing ?
-                       bv->repaint();
-                       bv->fitCursor();
-               }
+       if (bv && (result & LaTeX::ERRORS)) {
+               //show errors
+               bv->showErrorList();
        }
 
        // check return value from latex.run().
@@ -550,9 +506,7 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command)
                string str = bformat(_("LaTeX did not run successfully. Additionally, LyX "
                        "could not locate the LaTeX log %1$s."), name);
                Alert::error(_("LaTeX failed"), str);
-       } else if ((result & LaTeX::ERRORS)) {
-               alertErrors("LaTeX", latex.getNumErrors());
-       }  else if (result & LaTeX::NO_OUTPUT) {
+       } else if (result & LaTeX::NO_OUTPUT) {
                Alert::warning(_("Output is empty"),
                        _("An empty output file was generated."));
        }
index e628108f77e37b1b68703f37d6f5ae73f6bf1618..a56f2fad76e9ea03f394cfd7af74a2cd9c0a64b9 100644 (file)
@@ -1,3 +1,7 @@
+2003-05-12  Alfredo Braunstein: <abraunst@libero.it>
+
+       * ControlErrorList.[Ch]: added
+       * Makefile.am: the above adittion
 
 2003-05-13 André Pönitz <poenitz@gmx.net>
 
diff --git a/src/frontends/controllers/ControlErrorList.C b/src/frontends/controllers/ControlErrorList.C
new file mode 100644 (file)
index 0000000..35e48ee
--- /dev/null
@@ -0,0 +1,136 @@
+/**
+ * \file ControlErrorList.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include <config.h>
+
+#include "ControlErrorList.h"
+#include "support/lstrings.h" // tostr
+#include "LaTeX.h"
+#include "buffer.h"
+#include "BufferView.h"
+#include "lyxtext.h"
+
+
+
+ControlErrorList::ErrorItem::ErrorItem(string const & error, 
+                                      string const & description, 
+                                      int par_id, int pos_start, int pos_end) 
+       : error(error), description(description), par_id(par_id), 
+         pos_start(pos_start),  pos_end(pos_end)
+{}
+
+ControlErrorList::ControlErrorList(Dialog & d) 
+       : Dialog::Controller(d), current_(0)
+{}
+
+
+void ControlErrorList::clearParams() 
+{
+       logfilename_.clear();
+       clearErrors();
+}
+
+
+std::vector<ControlErrorList::ErrorItem> const & 
+ControlErrorList::ErrorList() const
+{
+       return ErrorList_;
+}
+
+
+int ControlErrorList::currentItem() const
+{
+       return current_;
+}
+
+
+bool ControlErrorList::initialiseParams(string const &) 
+{
+       logfilename_ = kernel().buffer()->getLogName().second;
+       clearErrors();
+       fillErrors();
+       current_ = 0;
+       return true;
+}
+
+
+void ControlErrorList::clearErrors()
+{
+       ErrorList_.clear();
+       current_ = 0;
+}
+
+
+void ControlErrorList::fillErrors()
+{
+       LaTeX latex("", logfilename_, "");
+       TeXErrors terr;
+       latex.scanLogFile(terr);
+
+       Buffer * const buf = kernel().buffer();
+
+       TeXErrors::Errors::const_iterator cit = terr.begin();
+       TeXErrors::Errors::const_iterator end = terr.end();
+
+       for (; cit != end; ++cit) {
+               int par_id = -1;
+               int posstart = -1;
+               int const errorrow = cit->error_in_line;
+               buf->texrow.getIdFromRow(errorrow, par_id, posstart);
+               int posend = -1;
+               buf->texrow.getIdFromRow(errorrow + 1, par_id, posend);
+               ErrorList_.push_back(ErrorItem(cit->error_desc,
+                                              cit->error_text,
+                                              par_id, posstart, posend));
+       }
+}
+
+
+string const & ControlErrorList::docName()
+{
+       return kernel().buffer()->fileName();
+}
+
+
+void ControlErrorList::goTo(int item)
+{
+       BufferView * const bv = kernel().bufferview();
+       Buffer * const buf = kernel().buffer();
+
+       current_ = item;
+
+       ControlErrorList::ErrorItem const & err = ErrorList_[item];
+
+
+       if (err.par_id == -1)
+               return;
+
+       ParagraphList::iterator pit = buf->getParFromID(err.par_id);
+
+       if (pit == bv->text->ownerParagraphs().end()) {
+               cout << "par id not found" << endl;
+               return;
+       }
+
+       int range = err.pos_end - err.pos_start;
+
+       if (err.pos_end > pit->size() || range <= 0)
+               range = pit->size() - err.pos_start;
+
+       //now make the selection
+       bv->insetUnlock();
+       bv->toggleSelection();
+       bv->text->clearSelection();
+       bv->text->setCursor(pit, err.pos_start);
+       bv->text->setSelectionRange(range);
+       bv->toggleSelection(false);
+       bv->fitCursor();
+       bv->update(bv->text, BufferView::SELECT);
+}
diff --git a/src/frontends/controllers/ControlErrorList.h b/src/frontends/controllers/ControlErrorList.h
new file mode 100644 (file)
index 0000000..4ce577b
--- /dev/null
@@ -0,0 +1,68 @@
+// -*- C++ -*-
+/**
+ * \file ControlErrorList.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef CONTROLERRORLIST_H
+#define CONTROLERRORLIST_H
+
+
+#include "Dialog.h"
+#include <vector>
+
+
+
+/** A controller for the ErrorList dialog.
+ */
+
+
+class ControlErrorList : public Dialog::Controller {
+public:
+       /// A class to hold an error item
+       struct ErrorItem {
+               std::string error;
+               std::string description;
+               int par_id;
+               int pos_start;
+               int pos_end;
+               ErrorItem(string const &, string const &, int, int, int); 
+       };
+       ///
+       ControlErrorList(Dialog & parent);
+       ///
+       virtual bool isBufferDependent() const { return true; }
+       ///
+       virtual bool initialiseParams(const string & params);
+       ///
+       virtual void ControlErrorList::clearParams();
+       ///
+       virtual void ControlErrorList::dispatchParams() {}
+
+       /// get the current item
+       int currentItem() const;
+       /// goto this error in the parent bv
+       void goTo(int item);
+       /// return the parent document name
+       string const & docName();
+       /// rescan the log file and rebuild the error list
+       void fillErrors();
+       /// clear everything
+       void clearErrors();
+       ///
+       std::vector<ErrorItem> const & ErrorList() const;
+private:
+       ///
+       std::vector<ErrorItem> ErrorList_;
+       ///
+       string logfilename_;
+       ///
+       int current_;
+};
+
+#endif // CONTROLERRORLIST_H
index 8a2c5d828fd251ddbf6ebaa452e22dff7d57b9ed..b827c7d611e6bb3ab45c46f09f80afb8f62099be 100644 (file)
@@ -50,6 +50,8 @@ libcontrollers_la_SOURCES= \
        ControlDocument.h \
        ControlError.C \
        ControlError.h \
+       ControlErrorList.C \
+       ControlErrorList.h \
        ControlERT.C \
        ControlERT.h \
        ControlExternal.C \
index 478b52a4d253d6534dcb9e14ac29b814e4aa01fb..b4f0c109eb370feeb187860b9fb94e110c2975a3 100644 (file)
@@ -1,3 +1,10 @@
+2003-05-12  Alfredo Braunstein  <abraunst@libero.it>
+
+       * QErrorList.[Ch]:
+       * QErrorListDialog.[Ch]: added
+       * Makefile.dialogs:
+       * Makefile.am: the above additions
+       * Dialogs.C: ditto
 
 2003-05-13  André Pönitz  <poenitz@lyx.org>
 
index 8cbc94a255cf2abeebe6a48030fec2ff53b4b579..df632ca0572b9ea95c55cb26f9c637e7483162e5 100644 (file)
@@ -19,6 +19,7 @@
 #include "ControlCharacter.h"
 #include "ControlCitation.h"
 #include "ControlError.h"
+#include "ControlErrorList.h"
 #include "ControlERT.h"
 #include "ControlExternal.h"
 #include "ControlFloat.h"
@@ -42,6 +43,7 @@
 #include "QCharacter.h"
 #include "QCitation.h"
 #include "QError.h"
+#include "QErrorList.h"
 #include "QERT.h"
 #include "QExternal.h"
 #include "QFloat.h"
@@ -77,9 +79,9 @@
 namespace {
 
 char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes",
-"character", "citation", "error", "ert", "external", "file", "float",
-"graphics", "include", "index", "label", "log", "minipage", "paragraph",
-"ref", "tabular", "tabularcreate",
+"character", "citation", "error", "errorlist", "ert", "external", "file",
+"float", "graphics", "include", "index", "label", "log", "minipage",
+"paragraph", "ref", "tabular", "tabularcreate",
 
 #ifdef HAVE_LIBAIKSAURUS
 "thesaurus",
@@ -146,6 +148,10 @@ Dialog * Dialogs::build(string const & name)
                dialog->setController(new ControlError(*dialog));
                dialog->setView(new QError(*dialog));
                dialog->bc().bp(new OkCancelPolicy);
+       } else if (name == "errorlist") {
+               dialog->setController(new ControlErrorList(*dialog));
+               dialog->setView(new QErrorList(*dialog));
+               dialog->bc().bp(new OkCancelPolicy);
        } else if (name == "ert") {
                dialog->setController(new ControlERT(*dialog));
                dialog->setView(new QERT(*dialog));
index 61530c558c54df7120921a51d5782d2a73fc2067..ad56368790849a3991880bfe5a84264d904606bb 100644 (file)
@@ -35,6 +35,7 @@ libqt2_la_SOURCES = \
        QCitation.C QCitation.h \
        QDocument.C QDocument.h \
        QError.C QError.h \
+       QErrorList.C QErrorList.h \
        QERT.C QERT.h \
        QExternal.C QExternal.h \
        QFloat.C QFloat.h \
index 8e937a9688a13ae44707b630e8ce42fa36278b92..8431af2b9d0e8982728405b92b3dd773419e4e5a 100644 (file)
@@ -23,6 +23,7 @@ UIFILES = \
        QDelimiterDialogBase.ui \
        QDocumentDialogBase.ui \
        QErrorDialogBase.ui \
+       QErrorListDialogBase.ui \
        QERTDialogBase.ui \
        QExternalDialogBase.ui \
        QFloatDialogBase.ui \
@@ -87,6 +88,7 @@ MOCFILES = \
        QDelimiterDialog.C QDelimiterDialog.h \
        QDocumentDialog.C QDocumentDialog.h \
        QErrorDialog.C QErrorDialog.h \
+       QErrorListDialog.C QErrorListDialog.h \
        QERTDialog.C QERTDialog.h \
        QExternalDialog.C QExternalDialog.h \
        QFloatDialog.C QFloatDialog.h \
diff --git a/src/frontends/qt2/QErrorList.C b/src/frontends/qt2/QErrorList.C
new file mode 100644 (file)
index 0000000..d0e6407
--- /dev/null
@@ -0,0 +1,68 @@
+/**
+ * \file QErrorList.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include <config.h>
+
+#include "LyXView.h"
+#include "qt_helpers.h"
+#include "support/lstrings.h"
+#include "debug.h"
+
+#include "ControlErrorList.h"
+#include "QErrorList.h"
+#include "QErrorListDialog.h"
+#include "Qt2BC.h"
+
+#include <qlistbox.h>
+#include <qtextbrowser.h>
+#include <qpushbutton.h>
+
+typedef QController<ControlErrorList, QView<QErrorListDialog> > base_class;
+
+QErrorList::QErrorList(Dialog & parent)
+       : base_class(parent, qt_("LyX: LaTeX error list"))
+{}
+
+
+void QErrorList::build_dialog()
+{
+       dialog_.reset(new QErrorListDialog(this));
+       bcview().setCancel(dialog_->closePB);
+}
+
+
+void QErrorList::select(int item)
+{
+       controller().goTo(item);
+       dialog_->descriptionTB->setText(controller().ErrorList()[item].description);
+}
+
+
+void QErrorList::update_contents()
+{
+       string const caption = string(_("LyX: LaTex error List")) + '(' +
+               controller().docName() + ')';
+
+       dialog_->setCaption(qt_(caption));
+       dialog_->errorsLB->clear();
+       dialog_->descriptionTB->clear();
+
+       std::vector<ControlErrorList::ErrorItem>::const_iterator 
+               it = controller().ErrorList().begin();
+       std::vector<ControlErrorList::ErrorItem>::const_iterator 
+               end = controller().ErrorList().end();
+       for(; it != end; ++it) {
+               QListBoxItem * error = new QListBoxText(dialog_->errorsLB, 
+                                                       toqstr(it->error));
+       }
+
+       dialog_->errorsLB->setSelected(controller().currentItem(), true);
+}
+
diff --git a/src/frontends/qt2/QErrorList.h b/src/frontends/qt2/QErrorList.h
new file mode 100644 (file)
index 0000000..65b71cb
--- /dev/null
@@ -0,0 +1,41 @@
+// -*- C++ -*-
+/**
+ * \file QErrorList.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef QERRORLIST_H
+#define QERRORLIST_H
+
+
+#include "QDialogView.h"
+
+class ControlErrorList;
+class QErrorListDialog;
+
+class QErrorList :
+       public QController<ControlErrorList, QView<QErrorListDialog> >
+{
+public:
+       friend class QErrorListDialog;
+
+       QErrorList(Dialog &);
+private:
+       /// select an entry
+       void select(int item);
+       /// required apply
+       virtual void apply() {}
+       /// build dialog
+       virtual void build_dialog();
+       /// update contents
+       virtual void update_contents();
+       /// run latex
+       void runLaTeX();
+};
+
+#endif // QERRORLIST_H
diff --git a/src/frontends/qt2/QErrorListDialog.C b/src/frontends/qt2/QErrorListDialog.C
new file mode 100644 (file)
index 0000000..2e08b9f
--- /dev/null
@@ -0,0 +1,47 @@
+/**
+ * \file QErrorListDialog.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include <config.h>
+
+
+#include "QErrorList.h"
+#include "QErrorListDialog.h"
+#include "qt_helpers.h"
+
+#include <qlistbox.h>
+#include <qtextedit.h>
+#include <qtextbrowser.h>
+#include <qpushbutton.h>
+
+
+QErrorListDialog::QErrorListDialog(QErrorList * form)
+       : QErrorListDialogBase(0, 0, false, 0),
+       form_(form)
+{
+       connect(closePB, SIGNAL(clicked()),
+               form, SLOT(slotClose()));
+}
+
+
+QErrorListDialog::~QErrorListDialog()
+{}
+
+
+void QErrorListDialog::select_adaptor(int item)
+{
+       form_->select(item);
+}
+
+
+void QErrorListDialog::closeEvent(QCloseEvent * e)
+{
+       form_->slotWMHide();
+       e->accept();
+}
diff --git a/src/frontends/qt2/QErrorListDialog.h b/src/frontends/qt2/QErrorListDialog.h
new file mode 100644 (file)
index 0000000..03f4c29
--- /dev/null
@@ -0,0 +1,33 @@
+// -*- C++ -*-
+/**
+ * \file QErrorListDialog.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef QERRORLISTDIALOG_H
+#define QERRORLISTDIALOG_H
+
+
+#include "ui/QErrorListDialogBase.h"
+
+class QErrorList;
+
+class QErrorListDialog : public QErrorListDialogBase {
+       Q_OBJECT
+public:
+       QErrorListDialog(QErrorList * form);
+       ~QErrorListDialog();
+public slots:
+       void select_adaptor(int);
+protected:
+       void closeEvent(QCloseEvent * e);
+private:
+       QErrorList * form_;
+};
+
+#endif // QTOCERRORLIST_H
diff --git a/src/frontends/qt2/ui/QErrorListDialogBase.ui b/src/frontends/qt2/ui/QErrorListDialogBase.ui
new file mode 100644 (file)
index 0000000..4248ee0
--- /dev/null
@@ -0,0 +1,103 @@
+<!DOCTYPE UI><UI>
+<class>QErrorListDialogBase</class>
+<include location="global">config.h</include>
+<include location="local">qt_helpers.h</include>
+<widget>
+    <class>QDialog</class>
+    <property stdset="1">
+        <name>name</name>
+        <cstring>QErrorListDialogBase</cstring>
+    </property>
+    <property stdset="1">
+        <name>geometry</name>
+        <rect>
+            <x>0</x>
+            <y>0</y>
+            <width>349</width>
+            <height>367</height>
+        </rect>
+    </property>
+    <property stdset="1">
+        <name>caption</name>
+        <string>Form1</string>
+    </property>
+    <property stdset="1">
+        <name>sizeGripEnabled</name>
+        <bool>true</bool>
+    </property>
+    <grid>
+        <property stdset="1">
+            <name>margin</name>
+            <number>11</number>
+        </property>
+        <property stdset="1">
+            <name>spacing</name>
+            <number>6</number>
+        </property>
+        <widget row="0"  column="0"  rowspan="1"  colspan="2" >
+            <class>QListBox</class>
+            <item>
+                <property>
+                    <name>text</name>
+                    <string>New Item</string>
+                </property>
+            </item>
+            <property stdset="1">
+                <name>name</name>
+                <cstring>errorsLB</cstring>
+            </property>
+        </widget>
+        <widget row="2"  column="1" >
+            <class>QPushButton</class>
+            <property stdset="1">
+                <name>name</name>
+                <cstring>closePB</cstring>
+            </property>
+            <property stdset="1">
+                <name>text</name>
+                <string>&amp;Close</string>
+            </property>
+        </widget>
+        <spacer row="2"  column="0" >
+            <property>
+                <name>name</name>
+                <cstring>Spacer1</cstring>
+            </property>
+            <property stdset="1">
+                <name>orientation</name>
+                <enum>Horizontal</enum>
+            </property>
+            <property stdset="1">
+                <name>sizeType</name>
+                <enum>Expanding</enum>
+            </property>
+            <property>
+                <name>sizeHint</name>
+                <size>
+                    <width>20</width>
+                    <height>20</height>
+                </size>
+            </property>
+        </spacer>
+        <widget row="1"  column="0"  rowspan="1"  colspan="2" >
+            <class>QTextBrowser</class>
+            <property stdset="1">
+                <name>name</name>
+                <cstring>descriptionTB</cstring>
+            </property>
+        </widget>
+    </grid>
+</widget>
+<connections>
+    <connection>
+        <sender>errorsLB</sender>
+        <signal>highlighted(int)</signal>
+        <receiver>QErrorListDialogBase</receiver>
+        <slot>select_adaptor(int)</slot>
+    </connection>
+</connections>
+<slots>
+    <slot>close_adaptor()</slot>
+    <slot>select_adaptor(int)</slot>
+</slots>
+</UI>
index be29a42d8fad38b8fff9932a8958efc32defa72e..7f06f7e880725e6e8a8545b4121027906898f11d 100644 (file)
@@ -1,3 +1,10 @@
+2003-05-12  Alfredo Braunstein  <abraunst@libero.it>
+
+       * FormErrorList.[Ch]:
+       * forms/form_errorlist.fd: added
+       * forms/Makefile.am:
+       * Makefile.am: the above additions
+       * Dialogs.C: ditto
 
 2003-05-13 André Pönitz <poenitz@gmx.net>
 
index 8d912149d538223ad7579edb268fdad9a05969b4..07435c1e535346e310de5b5fdaa63e7dbcf9893f 100644 (file)
@@ -22,6 +22,7 @@
 #include "ControlCitation.h"
 #include "ControlCommand.h"
 #include "ControlError.h"
+#include "ControlErrorList.h"
 #include "ControlERT.h"
 #include "ControlExternal.h"
 #include "ControlFloat.h"
@@ -45,6 +46,7 @@
 #include "FormCharacter.h"
 #include "FormCitation.h"
 #include "FormError.h"
+#include "FormErrorList.h"
 #include "FormERT.h"
 #include "FormExternal.h"
 #include "FormFloat.h"
 
 namespace {
 
-char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes",
-"character", "citation", "error", "ert", "external", "file", "float",
-"graphics", "include", "index", "label", "log", "minipage", "paragraph",
-"ref", "tabular", "tabularcreate",
+char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes", "character", "citation", "error", "errorlist" , "ert", "external", "file", "float", "graphics", "include", "index", "label", "log", "minipage", "paragraph", "ref", "tabular", "tabularcreate",
 
 #ifdef HAVE_LIBAIKSAURUS
 "thesaurus",
@@ -144,6 +143,10 @@ Dialog * Dialogs::build(string const & name)
                dialog->setController(new ControlError(*dialog));
                dialog->setView(new FormError(*dialog));
                dialog->bc().bp(new OkCancelPolicy);
+       } else if (name == "errorlist") {
+               dialog->setController(new ControlErrorList(*dialog));
+               dialog->setView(new FormErrorList(*dialog));
+               dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
        } else if (name == "ert") {
                dialog->setController(new ControlERT(*dialog));
                dialog->setView(new FormERT(*dialog));
diff --git a/src/frontends/xforms/FormErrorList.C b/src/frontends/xforms/FormErrorList.C
new file mode 100644 (file)
index 0000000..3b533c7
--- /dev/null
@@ -0,0 +1,107 @@
+/**
+ * \file FormErrorList.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#include <config.h>
+
+
+#include "FormErrorList.h"
+#include "xformsBC.h"
+#include "xforms_helpers.h"
+#include "ControlErrorList.h"
+#include "forms/form_errorlist.h"
+#include "support/lstrings.h" // frontStrip, strip
+#include "debug.h"
+#include "gettext.h"
+#include FORMS_H_LOCATION
+
+#include <vector>
+
+using std::vector;
+using std::endl;
+
+
+typedef FormController<ControlErrorList, FormView<FD_errorlist> > base_class;
+
+FormErrorList::FormErrorList(Dialog & parent)
+       : base_class(parent, _("LaTeX error list"))
+{}
+
+
+void FormErrorList::build()
+{
+       dialog_.reset(build_errorlist(this));
+
+       // Manage the cancel/close button
+       bcview().setCancel(dialog_->button_close);
+       bcview().addReadOnly(dialog_->browser_errors);
+}
+
+
+void FormErrorList::update()
+{
+       updateContents();
+}
+
+
+ButtonPolicy::SMInput FormErrorList::input(FL_OBJECT * ob, long)
+{
+       std::vector<ControlErrorList::ErrorItem> const & 
+               Errors = controller().ErrorList();
+
+       if (ob == dialog_->browser_errors) {
+               //xforms return values 1..n
+               int const choice = int(fl_get_browser(dialog_->browser_errors)) - 1;
+               if (0 <= choice && choice < int(Errors.size())) {
+                       controller().goTo(choice);
+                       fl_set_input(dialog_->input_description,
+                                    Errors[choice].description.c_str());
+               }
+               return ButtonPolicy::SMI_VALID;
+       }
+
+       updateContents();
+
+       return ButtonPolicy::SMI_VALID;
+}
+
+
+void FormErrorList::updateContents()
+{
+       std::vector<ControlErrorList::ErrorItem> const & 
+               Errors = controller().ErrorList();
+
+       if (Errors.empty()) {
+               fl_clear_browser(dialog_->browser_errors);
+               fl_add_browser_line(dialog_->browser_errors,
+                                   _("*** No Lists ***"));
+               setEnabled(dialog_->browser_errors, false);
+               return;
+       }
+
+       unsigned int const topline =
+               fl_get_browser_topline(dialog_->browser_errors);
+       unsigned int const line = fl_get_browser(dialog_->browser_errors);
+
+       fl_clear_browser(dialog_->browser_errors);
+       setEnabled(dialog_->browser_errors, true);
+
+       std::vector<ControlErrorList::ErrorItem>::const_iterator
+               cit = Errors.begin();
+       std::vector<ControlErrorList::ErrorItem>::const_iterator
+               end = Errors.end();
+
+       for (; cit != end; ++cit) {
+               fl_add_browser_line(dialog_->browser_errors,
+                                   cit->error.c_str());
+       }
+
+       fl_set_browser_topline(dialog_->browser_errors, topline);
+       fl_select_browser_line(dialog_->browser_errors, line);
+}
diff --git a/src/frontends/xforms/FormErrorList.h b/src/frontends/xforms/FormErrorList.h
new file mode 100644 (file)
index 0000000..9a544fb
--- /dev/null
@@ -0,0 +1,41 @@
+// -*- C++ -*-
+/**
+ * \file FormErrorList.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Alfredo Braunstein
+ *
+ * Full author contact details are available in file CREDITS
+ */
+
+#ifndef FORMERRORLIST_H
+#define FORMERRORLIST_H
+
+
+#include "FormDialogView.h"
+
+class ControlErrorList;
+struct FD_errorlist;
+
+/** This class provides an XForms implementation of the FormErrorList Dialog.
+ */
+class FormErrorList : public FormController<ControlErrorList, FormView<FD_errorlist> > {
+public:
+       ///
+       FormErrorList(Dialog &);
+private:
+       /// not needed
+       virtual void apply() {}
+       /// Build the dialog
+       virtual void build();
+       /// Update dialog before showing it
+       virtual void update();
+       /// Filter the inputs on callback from xforms
+       virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
+
+       ///
+       void updateContents();
+};
+
+#endif // FORMERRORLIST_H
index fe3dd21d0776c710078db3de7c13ad88dc1258c5..d93d94afeb1d02ce506af47b6a288a9faefeca1d 100644 (file)
@@ -79,6 +79,8 @@ libxforms_la_SOURCES = \
        FormDocument.h \
        FormError.C \
        FormError.h \
+       FormErrorList.C \
+       FormErrorList.h \
        FormERT.C \
        FormERT.h \
        FormExternal.C \
index ad69367b1eba2adbd0ac6d7eb73da10cef217b8d..4c228b87bc06849dcce5e73b1e7265c06f735f5e 100644 (file)
@@ -18,6 +18,7 @@ SRCS =  form_aboutlyx.fd \
        form_citation.fd \
        form_document.fd \
        form_error.fd \
+       form_errorlist.fd \
        form_ert.fd \
        form_external.fd \
        form_filedialog.fd \
diff --git a/src/frontends/xforms/forms/form_errorlist.fd b/src/frontends/xforms/forms/form_errorlist.fd
new file mode 100644 (file)
index 0000000..850308c
--- /dev/null
@@ -0,0 +1,89 @@
+Magic: 13000
+
+Internal Form Definition File
+    (do not change)
+
+Number of forms: 1
+Unit of measure: FL_COORD_PIXEL
+SnapGrid: 5
+
+=============== FORM ===============
+Name: form_errorlist
+Width: 380
+Height: 295
+Number of Objects: 4
+
+--------------------
+class: FL_BOX
+type: FLAT_BOX
+box: 0 0 380 295
+boxtype: FL_FLAT_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: 
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: 
+callback: 
+argument: 
+
+--------------------
+class: FL_BROWSER
+type: HOLD_BROWSER
+box: 10 10 360 110
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_YELLOW
+alignment: FL_ALIGN_BOTTOM
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: 
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NorthWest FL_SouthEast
+name: browser_errors
+callback: C_FormDialogView_InputCB
+argument: 0
+
+--------------------
+class: FL_BUTTON
+type: NORMAL_BUTTON
+box: 280 260 90 25
+boxtype: FL_UP_BOX
+colors: FL_COL1 FL_COL1
+alignment: FL_ALIGN_CENTER
+style: FL_NORMAL_STYLE
+size: FL_NORMAL_SIZE
+lcol: FL_BLACK
+label: Close|^[^M
+shortcut: 
+resize: FL_RESIZE_NONE
+gravity: FL_SouthEast FL_SouthEast
+name: button_close
+callback: C_FormDialogView_CancelCB
+argument: 0
+
+--------------------
+class: FL_INPUT
+type: MULTILINE_INPUT
+box: 10 125 360 130
+boxtype: FL_DOWN_BOX
+colors: FL_COL1 FL_MCOL
+alignment: FL_ALIGN_LEFT
+style: FL_NORMAL_STYLE
+size: FL_DEFAULT_SIZE
+lcol: FL_BLACK
+label: 
+shortcut: 
+resize: FL_RESIZE_ALL
+gravity: FL_NoGravity FL_NoGravity
+name: input_description
+callback: 
+argument: 
+
+==============================
+create_the_forms