mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-25 01:26:51 +00:00
Migrate Branch dialog to InsetParamsWidget
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33521 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
bebd53821a
commit
4db2685cbe
@ -19,7 +19,6 @@
|
|||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "BufferParams.h"
|
#include "BufferParams.h"
|
||||||
#include "BranchList.h"
|
#include "BranchList.h"
|
||||||
#include "FuncRequest.h"
|
|
||||||
|
|
||||||
#include "insets/InsetBranch.h"
|
#include "insets/InsetBranch.h"
|
||||||
|
|
||||||
@ -30,36 +29,21 @@ using namespace std;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
GuiBranch::GuiBranch(GuiView & lv)
|
GuiBranch::GuiBranch(QWidget * parent) : InsetParamsWidget(parent)
|
||||||
: GuiDialog(lv, "branch", qt_("Branch Settings"))
|
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
connect(branchCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
|
||||||
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()
|
void GuiBranch::paramsToDialog(Inset const * inset)
|
||||||
{
|
|
||||||
changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiBranch::updateContents()
|
|
||||||
{
|
{
|
||||||
|
InsetBranch const * ib = static_cast<InsetBranch const *>(inset);
|
||||||
typedef BranchList::const_iterator const_iterator;
|
typedef BranchList::const_iterator const_iterator;
|
||||||
|
BranchList const & branchlist = ib->buffer().params().branchlist();
|
||||||
BranchList const & branchlist = buffer().params().branchlist();
|
docstring const cur_branch = ib->branch();
|
||||||
docstring const cur_branch = params_.branch;
|
|
||||||
|
|
||||||
branchCO->clear();
|
branchCO->clear();
|
||||||
|
|
||||||
const_iterator const begin = branchlist.begin();
|
const_iterator const begin = branchlist.begin();
|
||||||
const_iterator const end = branchlist.end();
|
const_iterator const end = branchlist.end();
|
||||||
int id = 0;
|
int id = 0;
|
||||||
@ -67,7 +51,6 @@ void GuiBranch::updateContents()
|
|||||||
for (const_iterator it = begin; it != end; ++it, ++count) {
|
for (const_iterator it = begin; it != end; ++it, ++count) {
|
||||||
docstring const & branch = it->branch();
|
docstring const & branch = it->branch();
|
||||||
branchCO->addItem(toqstr(branch));
|
branchCO->addItem(toqstr(branch));
|
||||||
|
|
||||||
if (cur_branch == branch)
|
if (cur_branch == branch)
|
||||||
id = count;
|
id = count;
|
||||||
}
|
}
|
||||||
@ -75,34 +58,12 @@ void GuiBranch::updateContents()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiBranch::applyView()
|
docstring GuiBranch::dialogToParams() const
|
||||||
{
|
{
|
||||||
params_.branch = qstring_to_ucs4(branchCO->currentText());
|
InsetBranchParams params(qstring_to_ucs4(branchCO->currentText()));
|
||||||
|
return from_utf8(InsetBranch::params2string(params));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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 frontend
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
|
@ -14,40 +14,27 @@
|
|||||||
#ifndef GUIBRANCH_H
|
#ifndef GUIBRANCH_H
|
||||||
#define GUIBRANCH_H
|
#define GUIBRANCH_H
|
||||||
|
|
||||||
#include "GuiDialog.h"
|
#include "InsetParamsWidget.h"
|
||||||
#include "ui_BranchUi.h"
|
#include "ui_BranchUi.h"
|
||||||
#include "insets/InsetBranch.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
class GuiBranch : public GuiDialog, public Ui::BranchUi
|
class GuiBranch : public InsetParamsWidget, public Ui::BranchUi
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GuiBranch(GuiView & lv);
|
GuiBranch(QWidget * parent = 0);
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void change_adaptor();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Apply changes
|
/// \name DialogView inherited methods
|
||||||
void applyView();
|
//@{
|
||||||
/// Update dialog before showing it
|
InsetCode insetCode() const { return BRANCH_CODE; }
|
||||||
void updateContents();
|
FuncCode creationCode() const { return LFUN_BRANCH_INSERT; }
|
||||||
///
|
void paramsToDialog(Inset const *);
|
||||||
bool initialiseParams(std::string const & data);
|
docstring dialogToParams() const;
|
||||||
///
|
//@}
|
||||||
void clearParams();
|
|
||||||
///
|
|
||||||
void dispatchParams();
|
|
||||||
///
|
|
||||||
bool isBufferDependent() const { return true; }
|
|
||||||
|
|
||||||
///
|
|
||||||
InsetBranchParams params_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -3443,7 +3443,6 @@ Dialog * createDialog(GuiView & lv, string const & name);
|
|||||||
Dialog * createGuiAbout(GuiView & lv);
|
Dialog * createGuiAbout(GuiView & lv);
|
||||||
Dialog * createGuiBibitem(GuiView & lv);
|
Dialog * createGuiBibitem(GuiView & lv);
|
||||||
Dialog * createGuiBibtex(GuiView & lv);
|
Dialog * createGuiBibtex(GuiView & lv);
|
||||||
Dialog * createGuiBranch(GuiView & lv);
|
|
||||||
Dialog * createGuiChanges(GuiView & lv);
|
Dialog * createGuiChanges(GuiView & lv);
|
||||||
Dialog * createGuiCharacter(GuiView & lv);
|
Dialog * createGuiCharacter(GuiView & lv);
|
||||||
Dialog * createGuiCitation(GuiView & lv);
|
Dialog * createGuiCitation(GuiView & lv);
|
||||||
@ -3501,8 +3500,6 @@ Dialog * GuiView::build(string const & name)
|
|||||||
return createGuiBibitem(*this);
|
return createGuiBibitem(*this);
|
||||||
if (name == "bibtex")
|
if (name == "bibtex")
|
||||||
return createGuiBibtex(*this);
|
return createGuiBibtex(*this);
|
||||||
if (name == "branch")
|
|
||||||
return createGuiBranch(*this);
|
|
||||||
if (name == "changes")
|
if (name == "changes")
|
||||||
return createGuiChanges(*this);
|
return createGuiChanges(*this);
|
||||||
if (name == "character")
|
if (name == "character")
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "InsetParamsDialog.h"
|
#include "InsetParamsDialog.h"
|
||||||
|
|
||||||
#include "GuiBox.h"
|
#include "GuiBox.h"
|
||||||
|
#include "GuiBranch.h"
|
||||||
#include "GuiERT.h"
|
#include "GuiERT.h"
|
||||||
#include "GuiInfo.h"
|
#include "GuiInfo.h"
|
||||||
#include "GuiTabular.h"
|
#include "GuiTabular.h"
|
||||||
@ -204,6 +205,9 @@ Dialog * createDialog(GuiView & lv, InsetCode code)
|
|||||||
case FLOAT_CODE:
|
case FLOAT_CODE:
|
||||||
widget = new FloatPlacement(true);
|
widget = new FloatPlacement(true);
|
||||||
break;
|
break;
|
||||||
|
case BRANCH_CODE:
|
||||||
|
widget = new GuiBranch;
|
||||||
|
break;
|
||||||
case BOX_CODE:
|
case BOX_CODE:
|
||||||
widget = new GuiBox;
|
widget = new GuiBox;
|
||||||
break;
|
break;
|
||||||
|
@ -1,96 +1,42 @@
|
|||||||
<ui version="4.0" >
|
<ui version="4.0">
|
||||||
<class>BranchUi</class>
|
<class>BranchUi</class>
|
||||||
<widget class="QDialog" name="BranchUi" >
|
<widget class="QWidget" name="BranchUi">
|
||||||
<property name="geometry" >
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>219</width>
|
<width>259</width>
|
||||||
<height>99</height>
|
<height>38</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeGripEnabled" >
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<bool>true</bool>
|
<item row="0" column="0">
|
||||||
</property>
|
<widget class="QLabel" name="branchLA">
|
||||||
<layout class="QGridLayout" >
|
<property name="text">
|
||||||
<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>
|
<string>&Available branches:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="buddy" >
|
<property name="buddy">
|
||||||
<cstring>branchCO</cstring>
|
<cstring>branchCO</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="0" column="1">
|
||||||
<widget class="QComboBox" name="branchCO" >
|
<widget class="QComboBox" name="branchCO">
|
||||||
<property name="toolTip" >
|
<property name="toolTip">
|
||||||
<string>Select your branch</string>
|
<string>Select your branch</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
|
||||||
<item row="1" column="0" >
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation" >
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</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>
|
|
||||||
</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>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>branchCO</tabstop>
|
<tabstop>branchCO</tabstop>
|
||||||
<tabstop>okPB</tabstop>
|
|
||||||
<tabstop>closePB</tabstop>
|
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<includes>
|
<includes>
|
||||||
<include location="local" >qt_i18n.h</include>
|
<include location="local">qt_i18n.h</include>
|
||||||
</includes>
|
</includes>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@ -100,7 +100,7 @@ static void build_translator()
|
|||||||
insetnames[OPTARG_CODE] = InsetName("optarg");
|
insetnames[OPTARG_CODE] = InsetName("optarg");
|
||||||
insetnames[NEWLINE_CODE] = InsetName("newline");
|
insetnames[NEWLINE_CODE] = InsetName("newline");
|
||||||
insetnames[LINE_CODE] = InsetName("line");
|
insetnames[LINE_CODE] = InsetName("line");
|
||||||
insetnames[BRANCH_CODE] = InsetName("branch");
|
insetnames[BRANCH_CODE] = InsetName("branch", _("Branch"));
|
||||||
insetnames[BOX_CODE] = InsetName("box", _("Box"));
|
insetnames[BOX_CODE] = InsetName("box", _("Box"));
|
||||||
insetnames[FLEX_CODE] = InsetName("flex");
|
insetnames[FLEX_CODE] = InsetName("flex");
|
||||||
insetnames[SPACE_CODE] = InsetName("space");
|
insetnames[SPACE_CODE] = InsetName("space");
|
||||||
@ -296,8 +296,8 @@ bool Inset::showInsetDialog(BufferView * bv) const
|
|||||||
case ERT_CODE:
|
case ERT_CODE:
|
||||||
case FLOAT_CODE:
|
case FLOAT_CODE:
|
||||||
case BOX_CODE:
|
case BOX_CODE:
|
||||||
|
case BRANCH_CODE:
|
||||||
case INFO_CODE:
|
case INFO_CODE:
|
||||||
//FIXME: not ready yet.
|
|
||||||
case TABULAR_CODE:
|
case TABULAR_CODE:
|
||||||
case VSPACE_CODE:
|
case VSPACE_CODE:
|
||||||
bv->showDialog(insetName(code));
|
bv->showDialog(insetName(code));
|
||||||
|
@ -46,12 +46,6 @@ InsetBranch::InsetBranch(Buffer * buf, InsetBranchParams const & params)
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
InsetBranch::~InsetBranch()
|
|
||||||
{
|
|
||||||
hideDialogs("branch", this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetBranch::write(ostream & os) const
|
void InsetBranch::write(ostream & os) const
|
||||||
{
|
{
|
||||||
params_.write(os);
|
params_.write(os);
|
||||||
@ -116,14 +110,6 @@ ColorCode InsetBranch::backgroundColor(PainterInfo const & pi) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool InsetBranch::showInsetDialog(BufferView * bv) const
|
|
||||||
{
|
|
||||||
bv->showDialog("branch", params2string(params()),
|
|
||||||
const_cast<InsetBranch *>(this));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
|
void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
|
||||||
{
|
{
|
||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
@ -133,11 +119,6 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
params_.branch = params.branch;
|
params_.branch = params.branch;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_INSET_DIALOG_UPDATE:
|
|
||||||
cur.bv().updateDialog("branch", params2string(params()));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LFUN_BRANCH_ACTIVATE:
|
case LFUN_BRANCH_ACTIVATE:
|
||||||
case LFUN_BRANCH_DEACTIVATE: {
|
case LFUN_BRANCH_DEACTIVATE: {
|
||||||
// FIXME: I do not like this cast, but have no other idea...
|
// FIXME: I do not like this cast, but have no other idea...
|
||||||
@ -153,7 +134,6 @@ void InsetBranch::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
our_branch->setSelected(cmd.action == LFUN_BRANCH_ACTIVATE);
|
our_branch->setSelected(cmd.action == LFUN_BRANCH_ACTIVATE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_INSET_TOGGLE:
|
case LFUN_INSET_TOGGLE:
|
||||||
if (cmd.argument() == "assign")
|
if (cmd.argument() == "assign")
|
||||||
setStatus(cur, isBranchSelected() ? Open : Collapsed);
|
setStatus(cur, isBranchSelected() ? Open : Collapsed);
|
||||||
@ -173,7 +153,6 @@ bool InsetBranch::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|||||||
{
|
{
|
||||||
switch (cmd.action) {
|
switch (cmd.action) {
|
||||||
case LFUN_INSET_MODIFY:
|
case LFUN_INSET_MODIFY:
|
||||||
case LFUN_INSET_DIALOG_UPDATE:
|
|
||||||
flag.setEnabled(true);
|
flag.setEnabled(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
#include "InsetCollapsable.h"
|
#include "InsetCollapsable.h"
|
||||||
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
class InsetBranchParams {
|
class InsetBranchParams {
|
||||||
@ -44,8 +43,6 @@ class InsetBranch : public InsetCollapsable
|
|||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
InsetBranch(Buffer *, InsetBranchParams const &);
|
InsetBranch(Buffer *, InsetBranchParams const &);
|
||||||
///
|
|
||||||
~InsetBranch();
|
|
||||||
|
|
||||||
///
|
///
|
||||||
static std::string params2string(InsetBranchParams const &);
|
static std::string params2string(InsetBranchParams const &);
|
||||||
@ -68,8 +65,6 @@ private:
|
|||||||
///
|
///
|
||||||
ColorCode backgroundColor(PainterInfo const &) const;
|
ColorCode backgroundColor(PainterInfo const &) const;
|
||||||
///
|
///
|
||||||
bool showInsetDialog(BufferView *) const;
|
|
||||||
///
|
|
||||||
int latex(odocstream &, OutputParams const &) const;
|
int latex(odocstream &, OutputParams const &) const;
|
||||||
///
|
///
|
||||||
int plaintext(odocstream &, OutputParams const &) const;
|
int plaintext(odocstream &, OutputParams const &) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user