]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiBranch.cpp
Remove special code for Qt5 to manage HiDPI. It's not needed anymore and leads to...
[lyx.git] / src / frontends / qt4 / GuiBranch.cpp
index f292dc73115f709c17e518539199254a4a7ca69e..c3629051155f3e5d6ef61cb0056568405354250c 100644 (file)
@@ -3,7 +3,9 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author Jürgen Spitzmüller
+ * \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 "Qt2BC.h"
+
 #include "qt_helpers.h"
 
+#include "Buffer.h"
+#include "BufferParams.h"
 #include "BranchList.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(QWidget * parent) : InsetParamsWidget(parent)
 {
        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() ) );
-}
-
-
-void GuiBranchDialog::closeEvent(QCloseEvent * e)
-{
-       form_->slotWMHide();
-       e->accept();
-}
-
-
-void GuiBranchDialog::change_adaptor()
-{
-       form_->changed();
-}
-
-
-/////////////////////////////////////////////////////////////////////
-//
-// GuiBranch
-//
-/////////////////////////////////////////////////////////////////////
-
-
-GuiBranch::GuiBranch(Dialog & parent)
-       : GuiView<GuiBranchDialog>(parent, _("Branch Settings"))
-{}
-
-
-void GuiBranch::build_dialog()
-{
-       dialog_.reset(new GuiBranchDialog(this));
-
-       bcview().setOK(dialog_->okPB);
-       bcview().setCancel(dialog_->closePB);
+       connect(branchCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
 }
 
 
-void GuiBranch::update_contents()
+void GuiBranch::paramsToDialog(Inset const * inset)
 {
+       InsetBranch const * ib = static_cast<InsetBranch const *>(inset);
        typedef BranchList::const_iterator const_iterator;
+       BranchList const & branchlist = ib->buffer().params().branchlist();
+       docstring const cur_branch = ib->branch();
 
-       BranchList const & branchlist = controller().branchlist();
-       docstring const cur_branch = controller().params().branch;
-
-       dialog_->branchCO->clear();
-
+       branchCO->clear();
        const_iterator const begin = branchlist.begin();
        const_iterator const end = branchlist.end();
        int id = 0;
        int count = 0;
        for (const_iterator it = begin; it != end; ++it, ++count) {
-               docstring const & branch = it->getBranch();
-               dialog_->branchCO->addItem(toqstr(branch));
-
+               docstring const & branch = it->branch();
+               branchCO->addItem(toqstr(branch));
                if (cur_branch == branch)
                        id = count;
        }
-       dialog_->branchCO->setCurrentIndex(id);
+       branchCO->setCurrentIndex(id);
 }
 
 
-void GuiBranch::apply()
+docstring GuiBranch::dialogToParams() const
 {
-       docstring const type = qstring_to_ucs4(dialog_->branchCO->currentText());
-       controller().params().branch = type;
+       InsetBranchParams params(qstring_to_ucs4(branchCO->currentText()));
+       return from_utf8(InsetBranch::params2string(params));
 }
 
+
+bool GuiBranch::checkWidgets(bool readonly) const
+{
+       branchCO->setEnabled(!readonly);
+       return InsetParamsWidget::checkWidgets();
+}
+
+
 } // namespace frontend
 } // namespace lyx
 
-#include "GuiBranch_moc.cpp"
+#include "moc_GuiBranch.cpp"