]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt4/GuiView.cpp
s/updateLabels/updateBuffer/g, per a suggestion of Abdel's.
[features.git] / src / frontends / qt4 / GuiView.cpp
index c5f51c5b2346c8f2223ecd6628bfa3a0a0c62501..a59284d2565a08dc8cb169613ee37e46dfa83d59 100644 (file)
@@ -39,6 +39,7 @@
 #include "BufferList.h"
 #include "BufferParams.h"
 #include "BufferView.h"
+#include "Compare.h"
 #include "Converter.h"
 #include "Cursor.h"
 #include "CutAndPaste.h"
 
 #define EXPORT_in_THREAD 1
 
-
 // QtConcurrent was introduced in Qt 4.4
 #if (QT_VERSION >= 0x040400)
 #include <QFuture>
@@ -1032,16 +1032,16 @@ GuiWorkArea * GuiView::currentWorkArea()
 
 GuiWorkArea const * GuiView::currentMainWorkArea() const
 {
-       if (d.currentTabWorkArea() == NULL)
-               return NULL;
+       if (!d.currentTabWorkArea())
+               return 0;
        return d.currentTabWorkArea()->currentWorkArea();
 }
 
 
 GuiWorkArea * GuiView::currentMainWorkArea()
 {
-       if (d.currentTabWorkArea() == NULL)
-               return NULL;
+       if (!d.currentTabWorkArea())
+               return 0;
        return d.currentTabWorkArea()->currentWorkArea();
 }
 
@@ -1049,13 +1049,17 @@ GuiWorkArea * GuiView::currentMainWorkArea()
 void GuiView::setCurrentWorkArea(GuiWorkArea * wa)
 {
        LYXERR(Debug::DEBUG, "Setting current wa: " << wa << endl);
-       if (wa == NULL) {
-               d.current_work_area_ = NULL;
+       if (!wa) {
+               d.current_work_area_ = 0;
                d.setBackground();
                return;
        }
-       GuiWorkArea * old_gwa = theGuiApp()->currentView()->currentWorkArea();
-       if (old_gwa == wa)
+
+       // FIXME: I've no clue why this is here and why it accesses
+       //  theGuiApp()->currentView, which might be 0 (bug 6464).
+       //  See also 27525 (vfr).
+       if (theGuiApp()->currentView() == this 
+                 && theGuiApp()->currentView()->currentWorkArea() == wa) 
                return;
 
        if (currentBufferView())
@@ -1172,7 +1176,7 @@ void GuiView::setBuffer(Buffer * newBuffer)
 
        GuiWorkArea * wa = workArea(*newBuffer);
        if (wa == 0) {
-               newBuffer->masterBuffer()->updateLabels();
+               newBuffer->masterBuffer()->updateBuffer();
                wa = addWorkArea(*newBuffer);
        } else {
                //Disconnect the old buffer...there's no new one.
@@ -1734,7 +1738,7 @@ void GuiView::openDocument(string const & fname)
        docstring str2;
        Buffer * buf = loadDocument(fullname);
        if (buf) {
-               buf->updateLabels();
+               buf->updateBuffer();
                setBuffer(buf);
                buf->errors("Parse");
                str2 = bformat(_("Document %1$s opened."), disp_fn);
@@ -1783,7 +1787,7 @@ static bool import(GuiView * lv, FileName const & filename,
                Buffer * buf = lv->loadDocument(lyxfile);
                if (!buf)
                        return false;
-               buf->updateLabels();
+               buf->updateBuffer();
                lv->setBuffer(buf);
                buf->errors("Parse");
        } else {
@@ -2597,9 +2601,20 @@ void GuiView::dispatchVC(FuncRequest const & cmd)
                        if (!buffer->lyxvc().prepareFileRevision(rev2, f2))
                                break;
                }
-               // FIXME We need to call comparison feature here
-               // I'm not sure whether with or without dialog.
-               // (Gui)Compare::compare(f1, f2);
+               // FIXME We need to call comparison feature here.
+               // This is quick and dirty code for testing VC.
+               // We need that comparison feature has some LFUN_COMPARE <FLAG> file1 file1
+               // where <FLAG> specifies whether we want GUI dialog or just launch
+               // running with defaults.
+               /*
+               FileName initpath(lyxrc.document_path);
+               Buffer * dest = newUnnamedFile(initpath, to_utf8(_("differences")));
+               CompareOptions options;
+               Compare * compare = new Compare(loadIfNeeded(FileName(f1)), loadIfNeeded(FileName(f2)), dest, options);
+               compare->start(QThread::LowPriority);
+               Sleep::millisec(200);
+               lyx::dispatch(FuncRequest(LFUN_BUFFER_SWITCH, dest->absFileName()));
+               */
                break;
        }
 
@@ -2635,7 +2650,7 @@ void GuiView::openChildDocument(string const & fname)
        // This makes insertion of citations and references in the child work,
        // when the target is in the parent or another child document.
        child->setParent(&buffer);
-       child->masterBuffer()->updateLabels();
+       child->masterBuffer()->updateBuffer();
        setBuffer(child);
        if (parsed)
                child->errors("Parse");
@@ -2683,7 +2698,7 @@ bool GuiView::goToFileRow(string const & argument)
                        buf = theBufferList().getBuffer(s);
                else if (s.exists()) {
                        buf = loadDocument(s);
-                       buf->updateLabels();
+                       buf->updateBuffer();
                        buf->errors("Parse");
                } else {
                        message(bformat(
@@ -2764,7 +2779,7 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                                         dr);
                                break;
                        }
-                       if (doc_buffer->doExport(argument, false)) {
+                       if (!doc_buffer->doExport(argument, false)) {
                                dr.setError(true);
                                dr.setMessage(bformat(_("Error exporting to format: %1$s."),
                                        cmd.argument()));
@@ -3441,9 +3456,7 @@ Dialog * createDialog(GuiView & lv, string const & name);
 
 // will be replaced by a proper factory...
 Dialog * createGuiAbout(GuiView & lv);
-Dialog * createGuiBibitem(GuiView & lv);
 Dialog * createGuiBibtex(GuiView & lv);
-Dialog * createGuiBranch(GuiView & lv);
 Dialog * createGuiChanges(GuiView & lv);
 Dialog * createGuiCharacter(GuiView & lv);
 Dialog * createGuiCitation(GuiView & lv);
@@ -3458,7 +3471,6 @@ Dialog * createGuiIndex(GuiView & lv);
 Dialog * createGuiLabel(GuiView & lv);
 Dialog * createGuiListings(GuiView & lv);
 Dialog * createGuiLog(GuiView & lv);
-Dialog * createGuiMathHSpace(GuiView & lv);
 Dialog * createGuiMathMatrix(GuiView & lv);
 Dialog * createGuiNomenclature(GuiView & lv);
 Dialog * createGuiNote(GuiView & lv);
@@ -3476,9 +3488,7 @@ Dialog * createGuiShowFile(GuiView & lv);
 Dialog * createGuiSpellchecker(GuiView & lv);
 Dialog * createGuiSymbols(GuiView & lv);
 Dialog * createGuiTabularCreate(GuiView & lv);
-Dialog * createGuiTabular(GuiView & lv);
 Dialog * createGuiTexInfo(GuiView & lv);
-Dialog * createGuiTextHSpace(GuiView & lv);
 Dialog * createGuiToc(GuiView & lv);
 Dialog * createGuiThesaurus(GuiView & lv);
 Dialog * createGuiHyperlink(GuiView & lv);
@@ -3498,12 +3508,8 @@ Dialog * GuiView::build(string const & name)
 
        if (name == "aboutlyx")
                return createGuiAbout(*this);
-       if (name == "bibitem")
-               return createGuiBibitem(*this);
        if (name == "bibtex")
                return createGuiBibtex(*this);
-       if (name == "branch")
-               return createGuiBranch(*this);
        if (name == "changes")
                return createGuiChanges(*this);
        if (name == "character")
@@ -3542,8 +3548,6 @@ Dialog * GuiView::build(string const & name)
                return createGuiLog(*this);
        if (name == "mathdelimiter")
                return createGuiDelimiter(*this);
-       if (name == "mathspace")
-               return createGuiMathHSpace(*this);
        if (name == "mathmatrix")
                return createGuiMathMatrix(*this);
        if (name == "nomenclature")
@@ -3564,14 +3568,10 @@ Dialog * GuiView::build(string const & name)
                return createGuiRef(*this);
        if (name == "sendto")
                return createGuiSendTo(*this);
-       if (name == "space")
-               return createGuiTextHSpace(*this);
        if (name == "spellchecker")
                return createGuiSpellchecker(*this);
        if (name == "symbols")
                return createGuiSymbols(*this);
-       if (name == "tabular")
-               return createGuiTabular(*this);
        if (name == "tabularcreate")
                return createGuiTabularCreate(*this);
        if (name == "texinfo")