#include "Buffer.h"
#include "BufferParams.h"
#include "BranchList.h"
-#include "FuncRequest.h"
#include "insets/InsetBranch.h"
namespace lyx {
namespace frontend {
-GuiBranch::GuiBranch(GuiView & lv)
- : GuiDialog(lv, "branch", qt_("Branch Settings"))
+GuiBranch::GuiBranch(QWidget * parent) : InsetParamsWidget(parent)
{
setupUi(this);
-
- connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
- connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
- connect(branchCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
-
- bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
- bc().setOK(okPB);
- bc().setCancel(closePB);
-}
-
-
-void GuiBranch::change_adaptor()
-{
- changed();
+ connect(branchCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
}
-void GuiBranch::updateContents()
+void GuiBranch::paramsToDialog(Inset const * inset)
{
+ InsetBranch const * ib = static_cast<InsetBranch const *>(inset);
typedef BranchList::const_iterator const_iterator;
-
- BranchList const & branchlist = buffer().params().branchlist();
- docstring const cur_branch = params_.branch;
+ BranchList const & branchlist = ib->buffer().params().branchlist();
+ docstring const cur_branch = ib->branch();
branchCO->clear();
-
const_iterator const begin = branchlist.begin();
const_iterator const end = branchlist.end();
int id = 0;
for (const_iterator it = begin; it != end; ++it, ++count) {
docstring const & branch = it->branch();
branchCO->addItem(toqstr(branch));
-
if (cur_branch == branch)
id = count;
}
}
-void GuiBranch::applyView()
-{
- 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()
+docstring GuiBranch::dialogToParams() const
{
- dispatch(FuncRequest(getLfun(), InsetBranch::params2string(params_)));
+ InsetBranchParams params(qstring_to_ucs4(branchCO->currentText()));
+ return from_utf8(InsetBranch::params2string(params));
}
-
-Dialog * createGuiBranch(GuiView & lv) { return new GuiBranch(lv); }
-
-
} // namespace frontend
} // namespace lyx
#ifndef GUIBRANCH_H
#define GUIBRANCH_H
-#include "GuiDialog.h"
+#include "InsetParamsWidget.h"
#include "ui_BranchUi.h"
-#include "insets/InsetBranch.h"
-
namespace lyx {
namespace frontend {
-class GuiBranch : public GuiDialog, public Ui::BranchUi
+class GuiBranch : public InsetParamsWidget, public Ui::BranchUi
{
Q_OBJECT
public:
- GuiBranch(GuiView & lv);
-
-private Q_SLOTS:
- void change_adaptor();
+ GuiBranch(QWidget * parent = 0);
private:
- /// Apply changes
- void applyView();
- /// Update dialog before showing it
- void updateContents();
- ///
- bool initialiseParams(std::string const & data);
- ///
- void clearParams();
- ///
- void dispatchParams();
- ///
- bool isBufferDependent() const { return true; }
-
- ///
- InsetBranchParams params_;
+ /// \name DialogView inherited methods
+ //@{
+ InsetCode insetCode() const { return BRANCH_CODE; }
+ FuncCode creationCode() const { return LFUN_BRANCH_INSERT; }
+ void paramsToDialog(Inset const *);
+ docstring dialogToParams() const;
+ //@}
};
} // namespace frontend
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);
return createGuiBibitem(*this);
if (name == "bibtex")
return createGuiBibtex(*this);
- if (name == "branch")
- return createGuiBranch(*this);
if (name == "changes")
return createGuiChanges(*this);
if (name == "character")
#include "InsetParamsDialog.h"\r
\r
#include "GuiBox.h"\r
+#include "GuiBranch.h"\r
#include "GuiERT.h"\r
#include "GuiInfo.h"\r
#include "GuiTabular.h"\r
case FLOAT_CODE:\r
widget = new FloatPlacement(true);\r
break;\r
+ case BRANCH_CODE:\r
+ widget = new GuiBranch;\r
+ break;\r
case BOX_CODE:\r
widget = new GuiBox;\r
break;\r
-<ui version="4.0" >
+<ui version="4.0">
<class>BranchUi</class>
- <widget class="QDialog" name="BranchUi" >
- <property name="geometry" >
+ <widget class="QWidget" name="BranchUi">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
- <width>219</width>
- <height>99</height>
+ <width>259</width>
+ <height>38</height>
</rect>
</property>
- <property name="windowTitle" >
+ <property name="windowTitle">
<string/>
</property>
- <property name="sizeGripEnabled" >
- <bool>true</bool>
- </property>
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>9</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="0" column="0" colspan="3" >
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <widget class="QLabel" name="branchLA" >
- <property name="text" >
- <string>&Available branches:</string>
- </property>
- <property name="buddy" >
- <cstring>branchCO</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="branchCO" >
- <property name="toolTip" >
- <string>Select your branch</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0" >
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="branchLA">
+ <property name="text">
+ <string>&Available branches:</string>
</property>
- <property name="sizeHint" >
- <size>
- <width>31</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="1" column="2" >
- <widget class="QPushButton" name="closePB" >
- <property name="text" >
- <string>&Close</string>
- </property>
- <property name="default" >
- <bool>true</bool>
+ <property name="buddy">
+ <cstring>branchCO</cstring>
</property>
</widget>
</item>
- <item row="1" column="1" >
- <widget class="QPushButton" name="okPB" >
- <property name="text" >
- <string>&OK</string>
- </property>
- <property name="default" >
- <bool>false</bool>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="branchCO">
+ <property name="toolTip">
+ <string>Select your branch</string>
</property>
</widget>
</item>
</widget>
<tabstops>
<tabstop>branchCO</tabstop>
- <tabstop>okPB</tabstop>
- <tabstop>closePB</tabstop>
</tabstops>
<includes>
- <include location="local" >qt_i18n.h</include>
+ <include location="local">qt_i18n.h</include>
</includes>
<resources/>
<connections/>
insetnames[OPTARG_CODE] = InsetName("optarg");
insetnames[NEWLINE_CODE] = InsetName("newline");
insetnames[LINE_CODE] = InsetName("line");
- insetnames[BRANCH_CODE] = InsetName("branch");
+ insetnames[BRANCH_CODE] = InsetName("branch", _("Branch"));
insetnames[BOX_CODE] = InsetName("box", _("Box"));
insetnames[FLEX_CODE] = InsetName("flex");
insetnames[SPACE_CODE] = InsetName("space");
case ERT_CODE:
case FLOAT_CODE:
case BOX_CODE:
+ case BRANCH_CODE:
case INFO_CODE:
- //FIXME: not ready yet.
case TABULAR_CODE:
case VSPACE_CODE:
bv->showDialog(insetName(code));
{}
-InsetBranch::~InsetBranch()
-{
- hideDialogs("branch", this);
-}
-
-
void InsetBranch::write(ostream & os) const
{
params_.write(os);
}
-bool InsetBranch::showInsetDialog(BufferView * bv) const
-{
- bv->showDialog("branch", params2string(params()),
- const_cast<InsetBranch *>(this));
- return true;
-}
-
-
void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
{
switch (cmd.action) {
params_.branch = params.branch;
break;
}
-
- case LFUN_INSET_DIALOG_UPDATE:
- cur.bv().updateDialog("branch", params2string(params()));
- break;
-
case LFUN_BRANCH_ACTIVATE:
case LFUN_BRANCH_DEACTIVATE: {
// FIXME: I do not like this cast, but have no other idea...
our_branch->setSelected(cmd.action == LFUN_BRANCH_ACTIVATE);
break;
}
-
case LFUN_INSET_TOGGLE:
if (cmd.argument() == "assign")
setStatus(cur, isBranchSelected() ? Open : Collapsed);
{
switch (cmd.action) {
case LFUN_INSET_MODIFY:
- case LFUN_INSET_DIALOG_UPDATE:
flag.setEnabled(true);
break;
#include "InsetCollapsable.h"
-
namespace lyx {
class InsetBranchParams {
public:
///
InsetBranch(Buffer *, InsetBranchParams const &);
- ///
- ~InsetBranch();
///
static std::string params2string(InsetBranchParams const &);
///
ColorCode backgroundColor(PainterInfo const &) const;
///
- bool showInsetDialog(BufferView *) const;
- ///
int latex(odocstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) const;