]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiBranch.cpp
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[lyx.git] / src / frontends / qt4 / GuiBranch.cpp
index 17d53df2416e575e92e67eafcb02deb9201f89ed..10c24e1ec51e02d37149b6ec59882492b677f2bf 100644 (file)
@@ -3,6 +3,8 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
+ * \author Angus Leeming
+ * \author Martin Vermeer
  * \author Jürgen Spitzmüller
  *
  * Full author contact details are available in file CREDITS.
 #include <config.h>
 
 #include "GuiBranch.h"
+
 #include "qt_helpers.h"
+#include "BranchList.h"
 
+#include "Buffer.h"
+#include "BufferParams.h"
 #include "BranchList.h"
+#include "FuncRequest.h"
 
 #include "insets/InsetBranch.h"
 
 #include <QPushButton>
-#include <QCloseEvent>
+
+using namespace std;
 
 namespace lyx {
 namespace frontend {
 
-/////////////////////////////////////////////////////////////////////
-//
-// GuiBranchDialog
-//
-/////////////////////////////////////////////////////////////////////
-
-GuiBranchDialog::GuiBranchDialog(GuiBranch * form)
-       : form_(form)
+GuiBranch::GuiBranch(GuiView & lv)
+       : GuiDialog(lv, "branch", qt_("Branch Settings"))
 {
        setupUi(this);
-       connect(okPB, SIGNAL(clicked()),
-               form, SLOT(slotOK()));
-       connect(closePB, SIGNAL(clicked()),
-               form, SLOT(slotClose()));
-       connect(branchCO, SIGNAL( activated(int) ),
-               this, SLOT( change_adaptor() ) );
-}
 
+       connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
+       connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
+       connect(branchCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
 
-void GuiBranchDialog::closeEvent(QCloseEvent * e)
-{
-       form_->slotWMHide();
-       e->accept();
+       bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
+       bc().setOK(okPB);
+       bc().setCancel(closePB);
 }
 
 
-void GuiBranchDialog::change_adaptor()
+void GuiBranch::change_adaptor()
 {
-       form_->changed();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// GuiBranch
-//
-/////////////////////////////////////////////////////////////////////
-
-
-GuiBranch::GuiBranch(GuiDialog & parent)
-       : GuiView<GuiBranchDialog>(parent, _("Branch Settings"))
-{}
-
-
-void GuiBranch::build_dialog()
-{
-       dialog_.reset(new GuiBranchDialog(this));
-
-       bc().setOK(dialog_->okPB);
-       bc().setCancel(dialog_->closePB);
+       changed();
 }
 
 
-void GuiBranch::update_contents()
+void GuiBranch::updateContents()
 {
        typedef BranchList::const_iterator const_iterator;
 
-       BranchList const & branchlist = controller().branchlist();
-       docstring const cur_branch = controller().params().branch;
+       BranchList const & branchlist = buffer().params().branchlist();
+       docstring const cur_branch = params_.branch;
 
-       dialog_->branchCO->clear();
+       branchCO->clear();
 
        const_iterator const begin = branchlist.begin();
        const_iterator const end = branchlist.end();
@@ -91,21 +67,43 @@ void GuiBranch::update_contents()
        int count = 0;
        for (const_iterator it = begin; it != end; ++it, ++count) {
                docstring const & branch = it->getBranch();
-               dialog_->branchCO->addItem(toqstr(branch));
+               branchCO->addItem(toqstr(branch));
 
                if (cur_branch == branch)
                        id = count;
        }
-       dialog_->branchCO->setCurrentIndex(id);
+       branchCO->setCurrentIndex(id);
 }
 
 
 void GuiBranch::applyView()
 {
-       docstring const type = qstring_to_ucs4(dialog_->branchCO->currentText());
-       controller().params().branch = type;
+       params_.branch = qstring_to_ucs4(branchCO->currentText());
 }
 
+
+bool GuiBranch::initialiseParams(string const & data)
+{
+       InsetBranch::string2params(data, params_);
+       return true;
+}
+
+
+void GuiBranch::clearParams()
+{
+       params_ = InsetBranchParams();
+}
+
+
+void GuiBranch::dispatchParams()
+{
+       dispatch(FuncRequest(getLfun(), InsetBranch::params2string(params_)));
+}
+
+
+Dialog * createGuiBranch(GuiView & lv) { return new GuiBranch(lv); }
+
+
 } // namespace frontend
 } // namespace lyx