]> git.lyx.org Git - lyx.git/blobdiff - src/LyXFunc.cpp
Restor 1.4.x behaviour: Don't touch the preamble QTextEdit if the preamble text is...
[lyx.git] / src / LyXFunc.cpp
index f13a2970dca1ed81f7b845291a0dae3fcf602525..cabf8afa1f60b92fcbcda6c18c28981102905a1b 100644 (file)
@@ -53,8 +53,8 @@
 #include "Lexer.h"
 #include "LyXRC.h"
 #include "Row.h"
-#include "LyXServer.h"
-#include "LyXTextClassList.h"
+#include "Server.h"
+#include "TextClassList.h"
 #include "LyXVC.h"
 #include "Paragraph.h"
 #include "ParIterator.h"
@@ -467,7 +467,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                break;
 
        case LFUN_LAYOUT_TABULAR:
-               enable = cur.innerInsetOfType(InsetBase::TABULAR_CODE);
+               enable = cur.innerInsetOfType(Inset::TABULAR_CODE);
                break;
 
        case LFUN_LAYOUT:
@@ -496,27 +496,27 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                enable = false;
                if (!cur)
                        break;
-               InsetBase::Code code = cur.inset().lyxCode();
+               Inset::Code code = cur.inset().lyxCode();
                switch (code) {
-                       case InsetBase::TABULAR_CODE:
+                       case Inset::TABULAR_CODE:
                                enable = cmd.argument() == "tabular";
                                break;
-                       case InsetBase::ERT_CODE:
+                       case Inset::ERT_CODE:
                                enable = cmd.argument() == "ert";
                                break;
-                       case InsetBase::FLOAT_CODE:
+                       case Inset::FLOAT_CODE:
                                enable = cmd.argument() == "float";
                                break;
-                       case InsetBase::WRAP_CODE:
+                       case Inset::WRAP_CODE:
                                enable = cmd.argument() == "wrap";
                                break;
-                       case InsetBase::NOTE_CODE:
+                       case Inset::NOTE_CODE:
                                enable = cmd.argument() == "note";
                                break;
-                       case InsetBase::BRANCH_CODE:
+                       case Inset::BRANCH_CODE:
                                enable = cmd.argument() == "branch";
                                break;
-                       case InsetBase::BOX_CODE:
+                       case Inset::BOX_CODE:
                                enable = cmd.argument() == "box";
                                break;
                        default:
@@ -527,7 +527,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
 
        case LFUN_INSET_APPLY: {
                string const name = cmd.getArg(0);
-               InsetBase * inset = lyx_view_->getDialogs().getOpenInset(name);
+               Inset * inset = lyx_view_->getDialogs().getOpenInset(name);
                if (inset) {
                        FuncRequest fr(LFUN_INSET_MODIFY, cmd.argument());
                        FuncStatus fs;
@@ -544,6 +544,9 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                break;
        }
 
+       case LFUN_DIALOG_TOGGLE:
+               flag.setOnOff(lyx_view_->getDialogs().visible(cmd.getArg(0)));
+               // fall through to set "enable"
        case LFUN_DIALOG_SHOW: {
                string const name = cmd.getArg(0);
                if (!buf)
@@ -555,7 +558,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                        enable = Exporter::isExportable(*buf, "dvi")
                                && lyxrc.print_command != "none";
                else if (name == "character")
-                       enable = cur.inset().lyxCode() != InsetBase::ERT_CODE;
+                       enable = cur.inset().lyxCode() != Inset::ERT_CODE;
                else if (name == "latexlog")
                        enable = isFileReadable(FileName(buf->getLogName().second));
                else if (name == "spellchecker")
@@ -570,8 +573,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        }
 
        case LFUN_DIALOG_SHOW_NEW_INSET:
-               enable = cur.inset().lyxCode() != InsetBase::ERT_CODE;
-               if (cur.inset().lyxCode() == InsetBase::CAPTION_CODE) {
+               enable = cur.inset().lyxCode() != Inset::ERT_CODE;
+               if (cur.inset().lyxCode() == Inset::CAPTION_CODE) {
                        FuncStatus flag;
                        if (cur.inset().getStatus(cur, cmd, flag))
                                return flag;
@@ -637,7 +640,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        case LFUN_BUFFER_UPDATE:
        case LFUN_BUFFER_VIEW:
        case LFUN_BUFFER_IMPORT:
-       case LFUN_TOC_VIEW:
        case LFUN_BUFFER_AUTO_SAVE:
        case LFUN_RECONFIGURE:
        case LFUN_HELP_OPEN:
@@ -1091,14 +1093,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                                theApp()->gui().closeAllViews();
                        break;
 
-               case LFUN_TOC_VIEW: {
-                       BOOST_ASSERT(lyx_view_);
-                       InsetCommandParams p("tableofcontents");
-                       string const data = InsetCommandMailer::params2string("toc", p);
-                       lyx_view_->getDialogs().show("toc", data, 0);
-                       break;
-               }
-
                case LFUN_BUFFER_AUTO_SAVE:
                        autoSave(view());
                        break;
@@ -1220,7 +1214,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
 
                case LFUN_SERVER_NOTIFY:
                        dispatch_buffer = keyseq->print(false);
-                       theLyXServer().notifyClient(to_utf8(dispatch_buffer));
+                       theServer().notifyClient(to_utf8(dispatch_buffer));
                        break;
 
                case LFUN_SERVER_GOTO_FILE_ROW: {
@@ -1345,7 +1339,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        BOOST_ASSERT(lyx_view_);
                        string const & name = argument;
                        // Can only update a dialog connected to an existing inset
-                       InsetBase * inset = lyx_view_->getDialogs().getOpenInset(name);
+                       Inset * inset = lyx_view_->getDialogs().getOpenInset(name);
                        if (inset) {
                                FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument());
                                inset->dispatch(view()->cursor(), fr);
@@ -1361,6 +1355,15 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        Dialogs::hide(argument, 0);
                        break;
 
+               case LFUN_DIALOG_TOGGLE: {
+                       BOOST_ASSERT(lyx_view_);
+                       if (lyx_view_->getDialogs().visible(cmd.getArg(0)))
+                               dispatch(FuncRequest(LFUN_DIALOG_HIDE, argument));
+                       else
+                               dispatch(FuncRequest(LFUN_DIALOG_SHOW, argument));
+                       break;
+               }
+
                case LFUN_DIALOG_DISCONNECT_INSET:
                        BOOST_ASSERT(lyx_view_);
                        lyx_view_->getDialogs().disconnect(argument);
@@ -1535,7 +1538,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                case LFUN_INSET_APPLY: {
                        BOOST_ASSERT(lyx_view_);
                        string const name = cmd.getArg(0);
-                       InsetBase * inset = lyx_view_->getDialogs().getOpenInset(name);
+                       Inset * inset = lyx_view_->getDialogs().getOpenInset(name);
                        if (inset) {
                                FuncRequest fr(LFUN_INSET_MODIFY, argument);
                                inset->dispatch(view()->cursor(), fr);
@@ -1553,18 +1556,18 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        BOOST_ASSERT(lyx_view_);
                        string action;
                        string const name = split(argument, action, ' ');
-                       InsetBase::Code const inset_code =
-                               InsetBase::translate(name);
+                       Inset::Code const inset_code =
+                               Inset::translate(name);
 
                        Cursor & cur = view()->cursor();
                        FuncRequest fr(LFUN_INSET_TOGGLE, action);
 
-                       InsetBase & inset = lyx_view_->buffer()->inset();
+                       Inset & inset = lyx_view_->buffer()->inset();
                        InsetIterator it  = inset_iterator_begin(inset);
                        InsetIterator const end = inset_iterator_end(inset);
                        for (; it != end; ++it) {
                                if (!it->asInsetMath()
-                                   && (inset_code == InsetBase::NO_CODE
+                                   && (inset_code == Inset::NO_CODE
                                    || inset_code == it->lyxCode())) {
                                        Cursor tmpcur = cur;
                                        tmpcur.pushLeft(*it);
@@ -1638,11 +1641,11 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                        Cursor & cur = view()->cursor();
                        FuncRequest fr(LFUN_INSET_REFRESH);
 
-                       InsetBase & inset = lyx_view_->buffer()->inset();
+                       Inset & inset = lyx_view_->buffer()->inset();
                        InsetIterator it  = inset_iterator_begin(inset);
                        InsetIterator const end = inset_iterator_end(inset);
                        for (; it != end; ++it)
-                               if (it->lyxCode() == InsetBase::CITE_CODE)
+                               if (it->lyxCode() == Inset::CITE_CODE)
                                        it->dispatch(cur, fr);
                        break;
                }