]> git.lyx.org Git - features.git/commitdiff
get rid of InsetError users
authorAlfredo Braunstein <abraunst@lyx.org>
Tue, 20 May 2003 16:51:31 +0000 (16:51 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Tue, 20 May 2003 16:51:31 +0000 (16:51 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6986 a592a061-630c-0410-9148-cb99ea01b6c8

22 files changed:
src/BufferView.C
src/BufferView.h
src/BufferView_pimpl.h
src/ChangeLog
src/CutAndPaste.C
src/CutAndPaste.h
src/Makefile.am
src/buffer.C
src/errorlist.C [new file with mode: 0644]
src/errorlist.h [new file with mode: 0644]
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlDocument.C
src/frontends/controllers/ControlErrorList.C
src/frontends/controllers/ControlErrorList.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/QErrorList.C
src/frontends/qt2/QErrorList.h
src/frontends/qt2/QErrorListDialog.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormErrorList.C
src/insets/insettext.C
src/text2.C

index c7da720e5aa97d31eb801759d54cd2e5c6313d3a..4de7fcd0615b5df24c4e7b0c578f978f0f5c7098 100644 (file)
@@ -19,6 +19,7 @@
 #include "bufferlist.h"
 #include "debug.h"
 #include "gettext.h"
+#include "errorlist.h"
 #include "iterators.h"
 #include "language.h"
 #include "lyxcursor.h"
@@ -466,9 +467,38 @@ bool BufferView::removeAutoInsets()
 }
 
 
-void BufferView::showErrorList()
+void BufferView::resetErrorList()
 {
-       owner()->getDialogs().show("errorlist");
+       pimpl_->errorlist_.clear();
+}
+
+
+void BufferView::setErrorList(ErrorList const & el)
+{
+       pimpl_->errorlist_ = el;
+}
+
+
+void BufferView::addError(ErrorItem const & ei)
+{
+       pimpl_->errorlist_.push_back(ei);
+
+}
+
+
+void BufferView::showErrorList(string const & action) const
+{
+       if (getErrorList().size()) {
+               string const title = bformat(_("LyX: %1$s errors (%2$s)"), action, buffer()->fileName());
+               owner()->getDialogs().show("errorlist", title);
+       }
+}
+
+
+ErrorList const & 
+BufferView::getErrorList() const
+{
+       return pimpl_->errorlist_;
 }
 
 
index fe00dc967238f3ba4a18c9413ff22b59a3c23809..056e405dcc0bf679e554ce38b34c9d94acfa734c 100644 (file)
@@ -28,6 +28,8 @@ class Painter;
 class UpdatableInset;
 class WordLangTuple;
 class Encoding;
+class ErrorList;
+class ErrorItem;
 
 /**
  * A buffer view encapsulates a view onto a particular
@@ -153,8 +155,16 @@ public:
 
        /// removes all autodeletable insets
        bool removeAutoInsets();
+       /// get the stored error list
+       ErrorList const & getErrorList() const;
+       /// clears the stored error list
+       void resetErrorList();
+       /// stored this  error list
+       void setErrorList(ErrorList const &);
+       /// adds a single error to the list
+       void addError(ErrorItem const &);
        /// show the error list to the user
-       void showErrorList();
+       void showErrorList(string const &) const;
        /// set the cursor based on the given TeX source row
        void setCursorFromRow(int row);
 
index 0f2ad9f51b28c0c3df7dfea9d662f310892c6073..5f4baf4f635fbb657009473fd8cfdee7fd95b3e4 100644 (file)
@@ -10,6 +10,7 @@
 #ifndef BUFFERVIEW_PIMPL_H
 #define BUFFERVIEW_PIMPL_H
 
+#include "errorlist.h"
 #include "BufferView.h"
 #include "frontends/Timeout.h"
 #include "frontends/key_state.h"
@@ -103,6 +104,9 @@ struct BufferView::Pimpl : public boost::signals::trackable {
        /// a function should be executed
        bool dispatch(FuncRequest const & ev);
 private:
+       /// An error list (replaces the error insets)
+       ErrorList errorlist_;
+
        /// track changes for the document
        void trackChanges();
 
index 19859d9a826bc4594b2edbd409945dbdb2647144..0ef74fc4055d4ffd83f40796b9058d2a7c7080a5 100644 (file)
@@ -1,3 +1,13 @@
+
+2003-05-08  Alfredo Braunstein  <abraunst@libero.it>
+
+       * errorlist.[Ch]: added
+       * buffer.C:
+       * BufferView.[Ch]:
+       * BufferView_pimpl.C:
+       * CutAndPaste.[Ch]: get rid of InsetError users, use ErrorList
+       instead
+
 2003-05-08  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * Makefile.am: ensure that lyx is relinked upon changes to the
index 10ba8fb70c668f17645c530f7a063e3ac38b8dc8..91762f895ee9da0ff41faffac32bf06a449d5ee7 100644 (file)
@@ -13,6 +13,7 @@
 #include "CutAndPaste.h"
 #include "BufferView.h"
 #include "buffer.h"
+#include "errorlist.h"
 #include "paragraph.h"
 #include "ParagraphParameters.h"
 #include "lyxtext.h"
@@ -197,15 +198,17 @@ bool CutAndPaste::copySelection(ParagraphList::iterator startpit,
 pair<PitPosPair, ParagraphList::iterator>
 CutAndPaste::pasteSelection(ParagraphList & pars,
                            ParagraphList::iterator pit, int pos,
-                           textclass_type tc)
+                           textclass_type tc,
+                           ErrorList & errorlist)
 {
-       return pasteSelection(pars, pit, pos, tc, 0);
+       return pasteSelection(pars, pit, pos, tc, 0, errorlist);
 }
 
 pair<PitPosPair, ParagraphList::iterator>
 CutAndPaste::pasteSelection(ParagraphList & pars,
                            ParagraphList::iterator pit, int pos,
-                           textclass_type tc, size_t cut_index)
+                           textclass_type tc, size_t cut_index,
+                           ErrorList & errorlist)
 {
        if (!checkPastePossible())
                return make_pair(PitPosPair(pit, pos), pit);
@@ -220,7 +223,8 @@ CutAndPaste::pasteSelection(ParagraphList & pars,
        // new environment and set also another font if that is required.
 
        // Make sure there is no class difference.
-       SwitchLayoutsBetweenClasses(textclass, tc, simple_cut_clone);
+       SwitchLayoutsBetweenClasses(textclass, tc, simple_cut_clone, 
+                                   errorlist);
 
        ParagraphList::iterator tmpbuf = simple_cut_clone.begin();
        int depth_delta = pit->params().depth() - tmpbuf->params().depth();
@@ -329,7 +333,8 @@ int CutAndPaste::nrOfParagraphs()
 
 int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1,
                                             textclass_type c2,
-                                            ParagraphList & pars)
+                                            ParagraphList & pars,
+                                            ErrorList & errorlist)
 {
        lyx::Assert(!pars.empty());
 
@@ -359,7 +364,9 @@ int CutAndPaste::SwitchLayoutsBetweenClasses(textclass_type c1,
                                "because of class conversion from\n%3$s to %4$s"),
                         name, par->layout()->name(), tclass1.name(), tclass2.name());
                        // To warn the user that something had to be done.
-                       par->insertInset(0, new InsetError(s));
+                       errorlist.push_back(ErrorItem("Changed Layout", s, 
+                                                     par->id(), 0, 
+                                                     par->size()));
                }
        }
        return ret;
index 860703ef94f64c709280095c257345c2ea9ce80c..a26d7ba24c7f367d8f9f1f90230aba016404f334 100644 (file)
@@ -18,6 +18,7 @@
 class Paragraph;
 class BufferParams;
 class LyXTextClass;
+class ErrorList;
 
 ///
 namespace CutAndPaste {
@@ -40,14 +41,14 @@ bool copySelection(ParagraphList::iterator startpit,
 std::pair<PitPosPair, ParagraphList::iterator>
 pasteSelection(ParagraphList & pars,
               ParagraphList::iterator pit, int pos,
-              lyx::textclass_type tc);
+              lyx::textclass_type tc, ErrorList &);
 
 ///
 std::pair<PitPosPair, ParagraphList::iterator>
 pasteSelection(ParagraphList & pars,
               ParagraphList::iterator pit, int pos,
               lyx::textclass_type tc,
-              size_t cuts_index);
+              size_t cuts_indexm, ErrorList &);
 
 ///
 int nrOfParagraphs();
@@ -58,7 +59,8 @@ int nrOfParagraphs();
 */
 int SwitchLayoutsBetweenClasses(lyx::textclass_type c1,
                                lyx::textclass_type c2,
-                               ParagraphList & par);
+                               ParagraphList & par, 
+                               ErrorList &);
 ///
 bool checkPastePossible();
 
index a62dbc50ec27bd594ecdcdb50ca0f7f4c7af82da..9079d1b6944fcd0a1472cf1a3e93283e43fa27c6 100644 (file)
@@ -127,6 +127,8 @@ lyx_SOURCES = \
        dimension.h \
        encoding.C \
        encoding.h \
+       errorlist.C \
+       errorlist.h \
        exporter.C \
        exporter.h \
        gettext.C \
index 146de3472fb9f4d3c79fff8baab7c35eb2a35217..ccb271815e175d2b3616dc2cbc637f0919e6b0ec 100644 (file)
@@ -28,6 +28,7 @@
 #include "gettext.h"
 #include "language.h"
 #include "exporter.h"
+#include "errorlist.h"
 #include "Lsstream.h"
 #include "format.h"
 #include "BufferView.h"
@@ -1167,6 +1168,8 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
        string item_name;
        vector<string> environment_stack(5);
 
+       users->resetErrorList();
+
        ParagraphList::iterator pit = paragraphs.begin();
        ParagraphList::iterator pend = paragraphs.end();
        for (; pit != pend; ++pit) {
@@ -1205,7 +1208,7 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
 
                case LATEX_COMMAND:
                        if (depth != 0)
-                               sgmlError(&*pit, 0,
+                               sgmlError(pit, 0,
                                          _("Error: Wrong depth for LatexType Command.\n"));
 
                        if (!environment_stack[depth].empty()) {
@@ -1296,6 +1299,8 @@ void Buffer::makeLinuxDocFile(string const & fname, bool nice, bool body_only)
 
        // we want this to be true outside previews (for insetexternal)
        niceFile = true;
+
+       users->showErrorList(_("LinuxDoc"));
 }
 
 
@@ -1549,23 +1554,10 @@ void Buffer::simpleLinuxDocOnePar(ostream & os,
 
 
 // Print an error message.
-void Buffer::sgmlError(ParagraphList::iterator /*par*/, int /*pos*/,
-       string const & /*message*/) const
-{
-#ifdef WITH_WARNINGS
-#warning This is wrong we cannot insert an inset like this!!!
-       // I guess this was Jose' so I explain you more or less why this
-       // is wrong. This way you insert something in the paragraph and
-       // don't tell it to LyXText (row rebreaking and undo handling!!!)
-       // I deactivate this code, have a look at BufferView::insertErrors
-       // how you should do this correctly! (Jug 20020315)
-#endif
-#if 0
-       // insert an error marker in text
-       InsetError * new_inset = new InsetError(message);
-       par->insertInset(pos, new_inset, LyXFont(LyXFont::ALL_INHERIT,
-                        params.language));
-#endif
+void Buffer::sgmlError(ParagraphList::iterator pit, int pos,
+                      string const & message) const
+{
+       users->addError(ErrorItem(message, string(), pit->id(), pos, pos));
 }
 
 
@@ -1633,6 +1625,8 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
        string item_name;
        string command_name;
 
+       users->resetErrorList();
+
        ParagraphList::iterator par = paragraphs.begin();
        ParagraphList::iterator pend = paragraphs.end();
 
@@ -1849,6 +1843,7 @@ void Buffer::makeDocBookFile(string const & fname, bool nice, bool only_body)
 
        // we want this to be true outside previews (for insetexternal)
        niceFile = true;
+       users->showErrorList(_("DocBook"));
 }
 
 
@@ -1974,7 +1969,9 @@ int Buffer::runChktex()
                        _("Could not run chktex successfully."));
        } else if (res > 0) {
                // Insert all errors as errors boxes
-               users->showErrorList();
+               ErrorList el (*this, terr); 
+               users->setErrorList(el);
+               users->showErrorList(_("ChkTeX"));
        }
 
        // if we removed error insets before we ran chktex or if we inserted
diff --git a/src/errorlist.C b/src/errorlist.C
new file mode 100644 (file)
index 0000000..b9a3c34
--- /dev/null
@@ -0,0 +1,47 @@
+/**
+ * \file errorlist.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 "errorlist.h"
+#include "buffer.h"
+#include "LaTeX.h"
+
+
+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)
+{}
+
+
+ErrorItem::ErrorItem()
+       : par_id(-1),  pos_start(0),  pos_end(0)
+{}
+
+
+ErrorList::ErrorList(Buffer const & buf, 
+                    TeXErrors const & terr) 
+{
+       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);
+               push_back(ErrorItem(cit->error_desc,
+                                   cit->error_text,
+                                   par_id, posstart, posend));
+       }
+}
diff --git a/src/errorlist.h b/src/errorlist.h
new file mode 100644 (file)
index 0000000..a102257
--- /dev/null
@@ -0,0 +1,53 @@
+// -*- C++ -*-
+
+#ifndef ERRORLIST_H
+#define ERRORLIST_H
+
+/**
+ * \file errorlist.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
+ */
+
+
+#include <vector>
+#include "support/lstrings.h"
+
+class Buffer;
+class TeXErrors;
+
+/// A class to hold an error item
+struct ErrorItem {
+       string error;
+       string description;
+       int par_id;
+       int pos_start;
+       int pos_end;
+       ErrorItem(string const &, string const &, 
+                 int, int, int);
+       ErrorItem();
+};
+
+class ErrorList : private std::vector<ErrorItem>
+{
+public:        
+       ErrorList() : std::vector<ErrorItem> () {};
+       ErrorList(Buffer const & buf, TeXErrors const &);
+
+       using std::vector<ErrorItem>::push_back;
+       using std::vector<ErrorItem>::end;
+       using std::vector<ErrorItem>::begin;
+       using std::vector<ErrorItem>::operator[];
+       using std::vector<ErrorItem>::size;
+       using std::vector<ErrorItem>::clear;
+       using std::vector<ErrorItem>::empty;
+       using std::vector<ErrorItem>::const_iterator;
+};
+
+
+
+#endif
index ef5663c04e1bfdf515ab2d51a723d08fa716f039..bbf08e3cd66438b682579afa65b54f4401d87759 100644 (file)
@@ -1,5 +1,8 @@
+2003-05-20  Alfredo Braunstein  <abraunst@libero.it>
 
-2003-05-13 André Pönitz <poenitz@gmx.net>
+       ControlErrorList.[Ch]: small bugs fixed, use ErrorList
+
+2003-05-13  André Pönitz  <poenitz@gmx.net>
 
        * ControlForks.[Ch]: use vector<pid_t> instead of strings
 
index 295eb9e844fabf0084fc6040e3b06ead8d68a994..1edecf88c613c2616cf727c398cb77bcdd4ce34b 100644 (file)
@@ -19,6 +19,7 @@
 #include "lyxfind.h"
 
 #include "buffer.h"
+#include "errorlist.h"
 #include "language.h"
 #include "lyx_main.h"
 #include "lyxtextclass.h"
@@ -117,24 +118,14 @@ void ControlDocument::classApply()
        buffer()->params = *bp_;
 
        lv_.message(_("Converting document to new document class..."));
-       int ret = CutAndPaste::SwitchLayoutsBetweenClasses(
-               old_class, new_class,
-               lv_.buffer()->paragraphs);
 
-       if (!ret)
-               return;
+       ErrorList el;
+       CutAndPaste::SwitchLayoutsBetweenClasses(old_class, new_class,
+                                                lv_.buffer()->paragraphs,
+                                                el);
 
-       string s;
-       if (ret == 1) {
-               s = bformat(_("One paragraph could not be converted\n"
-                       "into the document class %1$s."),
-                       textclasslist[new_class].name());
-       } else {
-               s = bformat(_("%1$s paragraphs could not be converted\n"
-                       "into the document class %2$s."),
-                       textclasslist[new_class].name());
-       }
-       Alert::warning(_("Class conversion errors"), s);
+       bufferview()->setErrorList(el);
+       bufferview()->showErrorList(_("Class switch"));
 }
 
 
index 18d871a7ea5e2eedf53d1df4a6349e3bda0cf7d8..128dc2334dbb4d3d8647d9b4905708ee30a271c7 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "ControlErrorList.h"
 #include "support/lstrings.h" // tostr
-#include "LaTeX.h"
+#include "errorlist.h"
 #include "buffer.h"
 #include "BufferView.h"
 #include "lyxtext.h"
 using std::endl;
 
 
-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)
+       : Dialog::Controller(d)
 {}
 
 
 void ControlErrorList::clearParams()
-{
-       logfilename_.erase();
-       clearErrors();
-}
-
-
-std::vector<ControlErrorList::ErrorItem> const &
-ControlErrorList::ErrorList() const
-{
-       return ErrorList_;
-}
+{}
 
 
-int ControlErrorList::currentItem() const
+ErrorList const &
+ControlErrorList::errorList() const
 {
-       return current_;
+       return errorlist_;
 }
 
 
-bool ControlErrorList::initialiseParams(string const &)
+bool ControlErrorList::initialiseParams(string const & name)
 {
-       logfilename_ = kernel().buffer()->getLogName().second;
-       clearErrors();
-       fillErrors();
-       current_ = 0;
+       errorlist_ = kernel().bufferview()->getErrorList();
+       name_ = name;
        return true;
 }
 
 
-void ControlErrorList::clearErrors()
+string const & ControlErrorList::name()
 {
-       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();
+       return name_;
 }
 
 
@@ -108,9 +57,7 @@ void ControlErrorList::goTo(int item)
        BufferView * const bv = kernel().bufferview();
        Buffer * const buf = kernel().buffer();
 
-       current_ = item;
-
-       ControlErrorList::ErrorItem const & err = ErrorList_[item];
+       ErrorItem const & err = errorlist_[item];
 
 
        if (err.par_id == -1)
index 8c194a1093450464ba01a0419c9592f55b917a71..50b76fad779ddf83062be95299bfbe6e9474a365 100644 (file)
@@ -12,7 +12,7 @@
 #ifndef CONTROLERRORLIST_H
 #define CONTROLERRORLIST_H
 
-
+#include "errorlist.h"
 #include "Dialog.h"
 #include <vector>
 
 
 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);
        ///
@@ -44,25 +35,17 @@ public:
        ///
        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();
+       string const & name();
        ///
-       std::vector<ErrorItem> const & ErrorList() const;
+       ErrorList const & errorList() const;
 private:
        ///
-       std::vector<ErrorItem> ErrorList_;
-       ///
-       string logfilename_;
+       ErrorList errorlist_;
        ///
-       int current_;
+       string name_;
 };
 
 #endif // CONTROLERRORLIST_H
index 859795d5b5e771f88b00104b2c2f2ae5df8705dd..92ac9bd463d54243ca5aa8e9a18f6652f9709dc6 100644 (file)
@@ -1,3 +1,12 @@
+2003-05-20  Alfredo Braunstein  <abraunst@libero.it>
+
+       * QErrorList.[Ch]: small bugs fixed. 
+
+2003-05-17  Alfredo Braunstein  <abraunst@libero.it>
+
+       * QErrorList.C (update_contents): replace TextBrowser::clear() by
+       TextBrowser::setText(QString()) 
+
 2003-05-14  Juergen Spitzmueller <juergen.sp@t-online.de>
 
        * QErrorList.C (select): added a missing toqstr()
index c4f4e2e5b0ee2f441b3b3266d7c436731a225df5..76c7a09ced322449ccad4bea236a408045579033 100644 (file)
@@ -11,6 +11,7 @@
 #include <config.h>
 
 #include "LyXView.h"
+#include "errorlist.h"
 #include "qt_helpers.h"
 #include "support/lstrings.h"
 #include "debug.h"
@@ -27,7 +28,7 @@
 typedef QController<ControlErrorList, QView<QErrorListDialog> > base_class;
 
 QErrorList::QErrorList(Dialog & parent)
-       : base_class(parent, qt_("LyX: LaTeX error list"))
+       : base_class(parent, "")
 {}
 
 
@@ -41,28 +42,22 @@ void QErrorList::build_dialog()
 void QErrorList::select(int item)
 {
        controller().goTo(item);
-       dialog_->descriptionTB->setText(toqstr(controller().ErrorList()[item].description));
+       dialog_->descriptionTB->setText(toqstr(controller().errorList()[item].description));
 }
 
 
 void QErrorList::update_contents()
 {
-       string const caption = string(_("LyX: LaTex error List")) + '(' +
-               controller().docName() + ')';
-
-       dialog_->setCaption(qt_(caption));
+       dialog_->setCaption(toqstr(controller().name()));
        dialog_->errorsLB->clear();
-       dialog_->descriptionTB->clear();
+       dialog_->descriptionTB->setText(QString());
 
-       std::vector<ControlErrorList::ErrorItem>::const_iterator 
-               it = controller().ErrorList().begin();
-       std::vector<ControlErrorList::ErrorItem>::const_iterator 
-               end = controller().ErrorList().end();
+       ErrorList::const_iterator it = controller().errorList().begin();
+       ErrorList::const_iterator end = controller().errorList().end();
        for(; it != end; ++it) {
-               QListBoxItem * error = new QListBoxText(dialog_->errorsLB, 
-                                                       toqstr(it->error));
+               new QListBoxText(dialog_->errorsLB, toqstr(it->error));
        }
 
-       dialog_->errorsLB->setSelected(controller().currentItem(), true);
+       dialog_->errorsLB->setSelected(0, true);
 }
 
index 65b71cbcd1070014a23d5766292bce74ab2d7b24..245f73b2ff5d4837e1b77ea5655915a8447560d2 100644 (file)
@@ -34,8 +34,6 @@ private:
        virtual void build_dialog();
        /// update contents
        virtual void update_contents();
-       /// run latex
-       void runLaTeX();
 };
 
 #endif // QERRORLIST_H
index 2e08b9f25341075f2d3f89652358cc580d7d7176..05a14a555abfd9784247bbc97c98a5095f85f4d2 100644 (file)
@@ -27,6 +27,8 @@ QErrorListDialog::QErrorListDialog(QErrorList * form)
 {
        connect(closePB, SIGNAL(clicked()),
                form, SLOT(slotClose()));
+       connect(errorsLB, SIGNAL(returnPressed(QListBoxItem *)),
+               form, SLOT(slotClose()));
 }
 
 
index 93306184f4f99d9b5d58407173fff0e0b5ddc23b..7b021bd9ec4296761f8841f488760a76a158d282 100644 (file)
@@ -1,3 +1,7 @@
+2003-05-20  Alfredo Braunstein  <abraunst@libero.it>
+
+       * FormErrorList.[Ch]: small bugs fixed
+
 2003-05-13  Rob Lahaye  <lahaye@snu.ac.kr>
 
        * FormPreferences.C: Change conversions-tooltip.
index 8837dd507633a47e453b0571c511156ed95e946c..afb0b723b3d0846898a2553d325221e960466158 100644 (file)
@@ -11,6 +11,7 @@
 #include <config.h>
 
 
+#include "errorlist.h"
 #include "FormErrorList.h"
 #include "xformsBC.h"
 #include "xforms_helpers.h"
 #include "gettext.h"
 #include "lyx_forms.h"
 
-#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"))
+       : base_class(parent, "")
 {}
 
 
 void FormErrorList::build()
 {
        dialog_.reset(build_errorlist(this));
-
-       // Manage the cancel/close button
-       bcview().setCancel(dialog_->button_close);
-       bcview().addReadOnly(dialog_->browser_errors);
+       setEnabled(dialog_->input_description, false);
 }
 
 
 void FormErrorList::update()
 {
+        fl_set_form_title(dialog_->form, controller().name().c_str());
        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());
-               }
+               goTo(choice);
                return ButtonPolicy::SMI_VALID;
        }
 
-       updateContents();
-
        return ButtonPolicy::SMI_VALID;
 }
 
 
+void FormErrorList::goTo(int where)
+{
+       ErrorList const & errors = controller().errorList();
+
+       if (0 <= where && where < int(errors.size())) {
+               controller().goTo(where);
+               fl_set_input(dialog_->input_description,
+                            errors[where].description.c_str());
+               setEnabled(dialog_->input_description, false);
+       }
+}
+
+
 void FormErrorList::updateContents()
 {
-       std::vector<ControlErrorList::ErrorItem> const &
-               Errors = controller().ErrorList();
+       fl_clear_browser(dialog_->browser_errors);
 
-       if (Errors.empty()) {
-               fl_clear_browser(dialog_->browser_errors);
+       ErrorList const & errors = controller().errorList();
+       if (errors.empty()) {
                fl_add_browser_line(dialog_->browser_errors,
                                    _("*** No Lists ***").c_str());
                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();
+       ErrorList::const_iterator cit = errors.begin();
+       ErrorList::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);
+       fl_select_browser_line(dialog_->browser_errors, 1);
+       goTo(1);
 }
index f0cc7fb301d577000761d2a61490767338244de3..73612da99d366f8c79cbbf90ce17a19a30b7e1b9 100644 (file)
@@ -1532,7 +1532,7 @@ int InsetText::docbook(Buffer const * buf, ostream & os, bool mixcont) const
                        break;
 
                case LATEX_COMMAND:
-                       buf->sgmlError(&*pit, 0,  _("Error: LatexType Command not allowed here.\n"));
+                       buf->sgmlError(pit, 0,  _("Error: LatexType Command not allowed here.\n"));
                        return -1;
                        break;
 
index 92939fcae503430b8c712880bd288a5751bae442..9cc7edc767f2da8ecff50d219e4442a193e6ba1b 100644 (file)
@@ -19,6 +19,7 @@
 #include "undo_funcs.h"
 #include "buffer.h"
 #include "bufferparams.h"
+#include "errorlist.h"
 #include "gettext.h"
 #include "BufferView.h"
 #include "CutAndPaste.h"
@@ -1406,10 +1407,15 @@ void LyXText::pasteSelection()
        ParagraphList::iterator endpit;
        PitPosPair ppp;
 
+       ErrorList el;
+
        boost::tie(ppp, endpit) =
                CutAndPaste::pasteSelection(ownerParagraphs(),
                                            cursor.par(), cursor.pos(),
-                                           bv()->buffer()->params.textclass);
+                                           bv()->buffer()->params.textclass,
+                                           el);
+       bv()->setErrorList(el);
+       bv()->showErrorList(_("Paste"));
 
        redoParagraphs(cursor, endpit);