mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 11:08:41 +00:00
next one
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20766 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f3d1cf3ca1
commit
85b05737d4
@ -1,57 +0,0 @@
|
||||
/**
|
||||
* \file ControlBranch.cpp
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
* \author Martin Vermeer
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "ControlBranch.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "BufferParams.h"
|
||||
#include "BranchList.h"
|
||||
#include "FuncRequest.h"
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
ControlBranch::ControlBranch(Dialog & parent)
|
||||
: Controller(parent)
|
||||
{}
|
||||
|
||||
|
||||
bool ControlBranch::initialiseParams(string const & data)
|
||||
{
|
||||
InsetBranchMailer::string2params(data, params_);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ControlBranch::clearParams()
|
||||
{
|
||||
params_ = InsetBranchParams();
|
||||
}
|
||||
|
||||
void ControlBranch::dispatchParams()
|
||||
{
|
||||
string const lfun = InsetBranchMailer::params2string(params());
|
||||
dispatch(FuncRequest(getLfun(), lfun));
|
||||
}
|
||||
|
||||
|
||||
BranchList const & ControlBranch::branchlist() const
|
||||
{
|
||||
return buffer().params().branchlist();
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,52 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file ControlBranch.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Angus Leeming
|
||||
* \author Martin Vermeer
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef CONTROLBRANCH_H
|
||||
#define CONTROLBRANCH_H
|
||||
|
||||
#include "Dialog.h"
|
||||
#include "insets/InsetBranch.h"
|
||||
|
||||
namespace lyx {
|
||||
|
||||
class BranchList;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
class ControlBranch : public Controller
|
||||
{
|
||||
public:
|
||||
///
|
||||
ControlBranch(Dialog &);
|
||||
///
|
||||
virtual bool initialiseParams(std::string const & data);
|
||||
///
|
||||
virtual void clearParams();
|
||||
///
|
||||
virtual void dispatchParams();
|
||||
///
|
||||
virtual bool isBufferDependent() const { return true; }
|
||||
///
|
||||
InsetBranchParams & params() { return params_; }
|
||||
///
|
||||
InsetBranchParams const & params() const { return params_; }
|
||||
///
|
||||
BranchList const & branchlist() const;
|
||||
private:
|
||||
///
|
||||
InsetBranchParams params_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif // CONTROLBRANCH_H
|
@ -11,7 +11,6 @@ SOURCEFILES = \
|
||||
ButtonPolicy.cpp \
|
||||
ControlBibtex.cpp \
|
||||
ControlBox.cpp \
|
||||
ControlBranch.cpp \
|
||||
ControlCharacter.cpp \
|
||||
ControlChanges.cpp \
|
||||
ControlCitation.cpp \
|
||||
@ -43,7 +42,6 @@ HEADERFILES = \
|
||||
ButtonPolicy.h \
|
||||
ControlBibtex.h \
|
||||
ControlBox.h \
|
||||
ControlBranch.h \
|
||||
ControlCharacter.h \
|
||||
ControlChanges.h \
|
||||
ControlCitation.h \
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "GuiBibitem.h"
|
||||
#include "GuiBibtex.h"
|
||||
#include "GuiBox.h"
|
||||
#include "GuiBranch.h"
|
||||
#include "GuiChanges.h"
|
||||
#include "GuiCharacter.h"
|
||||
#include "GuiCitation.h"
|
||||
@ -166,7 +165,7 @@ Dialog * Dialogs::build(string const & name)
|
||||
} else if (name == "box") {
|
||||
dialog = new GuiBoxDialog(lyxview_);
|
||||
} else if (name == "branch") {
|
||||
dialog = new GuiBranchDialog(lyxview_);
|
||||
dialog = createGuiBranch(lyxview_);
|
||||
} else if (name == "changes") {
|
||||
dialog = new GuiChangesDialog(lyxview_);
|
||||
} else if (name == "character") {
|
||||
|
@ -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.
|
||||
@ -12,25 +14,30 @@
|
||||
|
||||
#include "GuiBranch.h"
|
||||
|
||||
#include "ControlBranch.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 std::string;
|
||||
using std::vector;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
GuiBranchDialog::GuiBranchDialog(LyXView & lv)
|
||||
: GuiDialog(lv, "branch")
|
||||
GuiBranch::GuiBranch(LyXView & lv)
|
||||
: GuiDialog(lv, "branch"), Controller(this)
|
||||
{
|
||||
setupUi(this);
|
||||
setController(new ControlBranch(*this));
|
||||
setController(this, false);
|
||||
setViewTitle(_("Branch Settings"));
|
||||
|
||||
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
||||
@ -43,31 +50,25 @@ GuiBranchDialog::GuiBranchDialog(LyXView & lv)
|
||||
}
|
||||
|
||||
|
||||
ControlBranch & GuiBranchDialog::controller()
|
||||
{
|
||||
return static_cast<ControlBranch &>(GuiDialog::controller());
|
||||
}
|
||||
|
||||
|
||||
void GuiBranchDialog::closeEvent(QCloseEvent * e)
|
||||
void GuiBranch::closeEvent(QCloseEvent * e)
|
||||
{
|
||||
slotClose();
|
||||
e->accept();
|
||||
}
|
||||
|
||||
|
||||
void GuiBranchDialog::change_adaptor()
|
||||
void GuiBranch::change_adaptor()
|
||||
{
|
||||
changed();
|
||||
}
|
||||
|
||||
|
||||
void GuiBranchDialog::updateContents()
|
||||
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;
|
||||
|
||||
branchCO->clear();
|
||||
|
||||
@ -86,12 +87,34 @@ void GuiBranchDialog::updateContents()
|
||||
}
|
||||
|
||||
|
||||
void GuiBranchDialog::applyView()
|
||||
void GuiBranch::applyView()
|
||||
{
|
||||
docstring const type = qstring_to_ucs4(branchCO->currentText());
|
||||
controller().params().branch = type;
|
||||
params_.branch = qstring_to_ucs4(branchCO->currentText());
|
||||
}
|
||||
|
||||
|
||||
bool GuiBranch::initialiseParams(string const & data)
|
||||
{
|
||||
InsetBranchMailer::string2params(data, params_);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void GuiBranch::clearParams()
|
||||
{
|
||||
params_ = InsetBranchParams();
|
||||
}
|
||||
|
||||
|
||||
void GuiBranch::dispatchParams()
|
||||
{
|
||||
dispatch(FuncRequest(getLfun(), InsetBranchMailer::params2string(params_)));
|
||||
}
|
||||
|
||||
|
||||
Dialog * createGuiBranch(LyXView & lv) { return new GuiBranch(lv); }
|
||||
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
|
@ -4,6 +4,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.
|
||||
@ -13,18 +15,19 @@
|
||||
#define GUIBRANCH_H
|
||||
|
||||
#include "GuiDialog.h"
|
||||
#include "ControlBranch.h"
|
||||
#include "ui_BranchUi.h"
|
||||
#include "insets/InsetBranch.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class GuiBranchDialog : public GuiDialog, public Ui::BranchUi
|
||||
class GuiBranch : public GuiDialog, public Ui::BranchUi, public Controller
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GuiBranchDialog(LyXView & lv);
|
||||
GuiBranch(LyXView & lv);
|
||||
|
||||
private Q_SLOTS:
|
||||
void change_adaptor();
|
||||
@ -33,13 +36,23 @@ private:
|
||||
///
|
||||
void closeEvent(QCloseEvent * e);
|
||||
/// parent controller
|
||||
ControlBranch & controller();
|
||||
Controller & controller() { return *this; }
|
||||
/// 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_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#include "GuiBranches.h"
|
||||
|
||||
#include "ControlBranch.h"
|
||||
#include "ControlDocument.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "Validator.h"
|
||||
@ -52,6 +51,7 @@ void GuiBranches::update(BufferParams const & params)
|
||||
updateView();
|
||||
}
|
||||
|
||||
|
||||
void GuiBranches::updateView()
|
||||
{
|
||||
// store the selected branch
|
||||
@ -65,8 +65,7 @@ void GuiBranches::updateView()
|
||||
BranchList::const_iterator it = branchlist_.begin();
|
||||
BranchList::const_iterator const end = branchlist_.end();
|
||||
for (; it != end; ++it) {
|
||||
QTreeWidgetItem * newItem =
|
||||
new QTreeWidgetItem(branchesTW);
|
||||
QTreeWidgetItem * newItem = new QTreeWidgetItem(branchesTW);
|
||||
|
||||
QString const bname = toqstr(it->getBranch());
|
||||
newItem->setText(0, bname);
|
||||
@ -90,11 +89,13 @@ void GuiBranches::updateView()
|
||||
changed();
|
||||
}
|
||||
|
||||
|
||||
void GuiBranches::apply(BufferParams & params) const
|
||||
{
|
||||
params.branchlist() = branchlist_;
|
||||
}
|
||||
|
||||
|
||||
void GuiBranches::on_addBranchPB_pressed()
|
||||
{
|
||||
QString const new_branch = newBranchLE->text();
|
||||
@ -108,8 +109,7 @@ void GuiBranches::on_addBranchPB_pressed()
|
||||
|
||||
void GuiBranches::on_removePB_pressed()
|
||||
{
|
||||
QTreeWidgetItem * selItem =
|
||||
branchesTW->currentItem();
|
||||
QTreeWidgetItem * selItem = branchesTW->currentItem();
|
||||
QString sel_branch;
|
||||
if (selItem != 0)
|
||||
sel_branch = selItem->text(0);
|
||||
@ -142,13 +142,14 @@ void GuiBranches::toggleBranch(QTreeWidgetItem * item)
|
||||
return;
|
||||
|
||||
QString sel_branch = item->text(0);
|
||||
if (!sel_branch.isEmpty()) {
|
||||
bool const selected = item->text(1) == qt_("Yes");
|
||||
Branch * branch = branchlist_.find(qstring_to_ucs4(sel_branch));
|
||||
if (branch && branch->setSelected(!selected)) {
|
||||
newBranchLE->clear();
|
||||
updateView();
|
||||
}
|
||||
if (sel_branch.isEmpty())
|
||||
return;
|
||||
|
||||
bool const selected = (item->text(1) == qt_("Yes"));
|
||||
Branch * branch = branchlist_.find(qstring_to_ucs4(sel_branch));
|
||||
if (branch && branch->setSelected(!selected)) {
|
||||
newBranchLE->clear();
|
||||
updateView();
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,22 +166,24 @@ void GuiBranches::toggleColor(QTreeWidgetItem * item)
|
||||
return;
|
||||
|
||||
QString sel_branch = item->text(0);
|
||||
if (!sel_branch.isEmpty()) {
|
||||
docstring current_branch = qstring_to_ucs4(sel_branch);
|
||||
Branch * branch =
|
||||
branchlist_.find(current_branch);
|
||||
if (!branch)
|
||||
return;
|
||||
if (sel_branch.isEmpty())
|
||||
return;
|
||||
|
||||
QColor const initial = rgb2qcolor(branch->getColor());
|
||||
QColor ncol(QColorDialog::getColor(initial, qApp->focusWidget()));
|
||||
if (ncol.isValid()){
|
||||
// add the color to the branchlist
|
||||
branch->setColor(fromqstr(ncol.name()));
|
||||
newBranchLE->clear();
|
||||
updateView();
|
||||
}
|
||||
}
|
||||
docstring current_branch = qstring_to_ucs4(sel_branch);
|
||||
Branch * branch =
|
||||
branchlist_.find(current_branch);
|
||||
if (!branch)
|
||||
return;
|
||||
|
||||
QColor const initial = rgb2qcolor(branch->getColor());
|
||||
QColor ncol = QColorDialog::getColor(initial, qApp->focusWidget());
|
||||
if (!ncol.isValid())
|
||||
return;
|
||||
|
||||
// add the color to the branchlist
|
||||
branch->setColor(fromqstr(ncol.name()));
|
||||
newBranchLE->clear();
|
||||
updateView();
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
|
Loading…
Reference in New Issue
Block a user