mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 03:36:39 +00:00
next one
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20762 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1a5acd927f
commit
d1d0501625
@ -1,56 +0,0 @@
|
||||
/**
|
||||
* \file ControlListings.cpp
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Bo Peng
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "ControlListings.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "insets/InsetListings.h"
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
ControlListings::ControlListings(Dialog & parent)
|
||||
: Controller(parent), params_()
|
||||
{}
|
||||
|
||||
|
||||
bool ControlListings::initialiseParams(string const & data)
|
||||
{
|
||||
InsetListingsMailer::string2params(data, params_);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ControlListings::clearParams()
|
||||
{
|
||||
params_.clear();
|
||||
}
|
||||
|
||||
|
||||
void ControlListings::dispatchParams()
|
||||
{
|
||||
string const lfun = InsetListingsMailer::params2string(params());
|
||||
dispatch(FuncRequest(getLfun(), lfun));
|
||||
}
|
||||
|
||||
|
||||
void ControlListings::setParams(InsetListingsParams const & params)
|
||||
{
|
||||
params_ = params;
|
||||
}
|
||||
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
@ -1,50 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file ControlListings.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author Bo Peng
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef CONTROLLISTINGS_H
|
||||
#define CONTROLLISTINGS_H
|
||||
|
||||
#include "Dialog.h"
|
||||
#include "insets/InsetListingsParams.h"
|
||||
|
||||
namespace lyx {
|
||||
|
||||
class InsetListingsParams;
|
||||
|
||||
namespace frontend {
|
||||
|
||||
class ControlListings : public Controller {
|
||||
public:
|
||||
///
|
||||
ControlListings(Dialog &);
|
||||
///
|
||||
virtual bool initialiseParams(std::string const & data);
|
||||
/// clean-up on hide.
|
||||
virtual void clearParams();
|
||||
/// clean-up on hide.
|
||||
virtual void dispatchParams();
|
||||
///
|
||||
virtual bool isBufferDependent() const { return true; }
|
||||
///
|
||||
InsetListingsParams & params() { return params_; }
|
||||
///
|
||||
InsetListingsParams const & params() const { return params_; }
|
||||
///
|
||||
void setParams(InsetListingsParams const &);
|
||||
private:
|
||||
///
|
||||
InsetListingsParams params_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
#endif
|
@ -24,7 +24,6 @@ SOURCEFILES = \
|
||||
ControlFloat.cpp \
|
||||
ControlGraphics.cpp \
|
||||
ControlInclude.cpp \
|
||||
ControlListings.cpp \
|
||||
ControlLog.cpp \
|
||||
ControlViewSource.cpp \
|
||||
ControlMath.cpp \
|
||||
@ -59,7 +58,6 @@ HEADERFILES = \
|
||||
ControlExternal.h \
|
||||
ControlFloat.h \
|
||||
ControlGraphics.h \
|
||||
ControlListings.h \
|
||||
ControlInclude.h \
|
||||
ControlLog.h \
|
||||
ControlViewSource.h \
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "GuiIndex.h"
|
||||
#include "GuiMathMatrix.h"
|
||||
#include "GuiNomencl.h"
|
||||
#include "GuiListings.h"
|
||||
#include "GuiLog.h"
|
||||
#include "GuiParagraph.h"
|
||||
#include "GuiPrefs.h"
|
||||
@ -259,7 +258,7 @@ Dialog * Dialogs::build(string const & name)
|
||||
} else if (name == "wrap") {
|
||||
dialog = createGuiWrap(lyxview_);
|
||||
} else if (name == "listings") {
|
||||
dialog = new GuiListingsDialog(lyxview_);
|
||||
dialog = createGuiListings(lyxview_);
|
||||
}
|
||||
|
||||
return dialog;
|
||||
|
@ -13,8 +13,9 @@
|
||||
|
||||
#include "GuiListings.h"
|
||||
|
||||
#include "ControlListings.h"
|
||||
#include "qt_helpers.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "insets/InsetListings.h"
|
||||
#include "insets/InsetListingsParams.h"
|
||||
#include "debug.h"
|
||||
|
||||
@ -36,12 +37,14 @@ using lyx::support::prefixIs;
|
||||
using lyx::support::suffixIs;
|
||||
using lyx::support::contains;
|
||||
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// GuiListingsDialog
|
||||
// GuiListings
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -162,12 +165,12 @@ char const * font_styles_gui[] =
|
||||
|
||||
|
||||
|
||||
GuiListingsDialog::GuiListingsDialog(LyXView & lv)
|
||||
: GuiDialog(lv, "listings")
|
||||
GuiListings::GuiListings(LyXView & lv)
|
||||
: GuiDialog(lv, "listings"), Controller(this)
|
||||
{
|
||||
setupUi(this);
|
||||
setViewTitle(_("Program Listing Settings"));
|
||||
setController(new ControlListings(*this));
|
||||
setController(this, false);
|
||||
|
||||
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
||||
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
|
||||
@ -181,17 +184,17 @@ GuiListingsDialog::GuiListingsDialog(LyXView & lv)
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(floatCB, SIGNAL(clicked()),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(placementLE, SIGNAL(textChanged(const QString&)),
|
||||
connect(placementLE, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(numberSideCO, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(numberStepLE, SIGNAL(textChanged(const QString&)),
|
||||
connect(numberStepLE, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(numberFontSizeCO, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(firstlineLE, SIGNAL(textChanged(const QString&)),
|
||||
connect(firstlineLE, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(lastlineLE, SIGNAL(textChanged(const QString&)),
|
||||
connect(lastlineLE, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(change_adaptor()));
|
||||
connect(fontsizeCO, SIGNAL(currentIndexChanged(int)),
|
||||
this, SLOT(change_adaptor()));
|
||||
@ -244,32 +247,26 @@ GuiListingsDialog::GuiListingsDialog(LyXView & lv)
|
||||
}
|
||||
|
||||
|
||||
ControlListings & GuiListingsDialog::controller()
|
||||
{
|
||||
return static_cast<ControlListings &>(GuiDialog::controller());
|
||||
}
|
||||
|
||||
|
||||
void GuiListingsDialog::closeEvent(QCloseEvent * e)
|
||||
void GuiListings::closeEvent(QCloseEvent * e)
|
||||
{
|
||||
slotClose();
|
||||
e->accept();
|
||||
}
|
||||
|
||||
|
||||
void GuiListingsDialog::change_adaptor()
|
||||
void GuiListings::change_adaptor()
|
||||
{
|
||||
changed();
|
||||
}
|
||||
|
||||
|
||||
string GuiListingsDialog::construct_params()
|
||||
string GuiListings::construct_params()
|
||||
{
|
||||
string language = languages[languageCO->currentIndex()];
|
||||
string dialect;
|
||||
string const dialect_gui = fromqstr(dialectCO->currentText());
|
||||
if (dialectCO->currentIndex() > 0) {
|
||||
for (size_t i = 0; i < nr_dialects; ++i) {
|
||||
for (size_t i = 0; i != nr_dialects; ++i) {
|
||||
if (dialect_gui == dialects[i].gui
|
||||
&& dialects[i].language == language
|
||||
&& !dialects[i].is_default) {
|
||||
@ -355,12 +352,12 @@ string GuiListingsDialog::construct_params()
|
||||
}
|
||||
|
||||
|
||||
docstring GuiListingsDialog::validate_listings_params()
|
||||
docstring GuiListings::validate_listings_params()
|
||||
{
|
||||
// use a cache here to avoid repeated validation
|
||||
// of the same parameters
|
||||
static string param_cache = string();
|
||||
static docstring msg_cache = docstring();
|
||||
static string param_cache;
|
||||
static docstring msg_cache;
|
||||
|
||||
if (bypassCB->isChecked())
|
||||
return docstring();
|
||||
@ -374,7 +371,7 @@ docstring GuiListingsDialog::validate_listings_params()
|
||||
}
|
||||
|
||||
|
||||
void GuiListingsDialog::set_listings_msg()
|
||||
void GuiListings::set_listings_msg()
|
||||
{
|
||||
static bool isOK = true;
|
||||
docstring msg = validate_listings_params();
|
||||
@ -391,7 +388,7 @@ void GuiListingsDialog::set_listings_msg()
|
||||
}
|
||||
|
||||
|
||||
void GuiListingsDialog::on_floatCB_stateChanged(int state)
|
||||
void GuiListings::on_floatCB_stateChanged(int state)
|
||||
{
|
||||
if (state == Qt::Checked) {
|
||||
inlineCB->setChecked(false);
|
||||
@ -401,7 +398,7 @@ void GuiListingsDialog::on_floatCB_stateChanged(int state)
|
||||
}
|
||||
|
||||
|
||||
void GuiListingsDialog::on_inlineCB_stateChanged(int state)
|
||||
void GuiListings::on_inlineCB_stateChanged(int state)
|
||||
{
|
||||
if (state == Qt::Checked) {
|
||||
floatCB->setChecked(false);
|
||||
@ -410,14 +407,14 @@ void GuiListingsDialog::on_inlineCB_stateChanged(int state)
|
||||
}
|
||||
|
||||
|
||||
void GuiListingsDialog::on_numberSideCO_currentIndexChanged(int index)
|
||||
void GuiListings::on_numberSideCO_currentIndexChanged(int index)
|
||||
{
|
||||
numberStepLE->setEnabled(index > 0);
|
||||
numberFontSizeCO->setEnabled(index > 0);
|
||||
}
|
||||
|
||||
|
||||
void GuiListingsDialog::on_languageCO_currentIndexChanged(int index)
|
||||
void GuiListings::on_languageCO_currentIndexChanged(int index)
|
||||
{
|
||||
dialectCO->clear();
|
||||
// 0 is "no dialect"
|
||||
@ -425,7 +422,7 @@ void GuiListingsDialog::on_languageCO_currentIndexChanged(int index)
|
||||
dialectCO->addItem(qt_("No dialect"));
|
||||
string const language = languages[index];
|
||||
|
||||
for (size_t i = 0; i < nr_dialects; ++i) {
|
||||
for (size_t i = 0; i != nr_dialects; ++i) {
|
||||
if (language == dialects[i].language) {
|
||||
dialectCO->addItem(qt_(dialects[i].gui));
|
||||
if (dialects[i].is_default)
|
||||
@ -438,12 +435,10 @@ void GuiListingsDialog::on_languageCO_currentIndexChanged(int index)
|
||||
}
|
||||
|
||||
|
||||
void GuiListingsDialog::applyView()
|
||||
void GuiListings::applyView()
|
||||
{
|
||||
InsetListingsParams & params = controller().params();
|
||||
params.setInline(inlineCB->isChecked());
|
||||
params.setParams(construct_params());
|
||||
controller().setParams(params);
|
||||
params_.setInline(inlineCB->isChecked());
|
||||
params_.setParams(construct_params());
|
||||
}
|
||||
|
||||
|
||||
@ -456,7 +451,7 @@ static string plainParam(std::string const & par)
|
||||
}
|
||||
|
||||
|
||||
void GuiListingsDialog::updateContents()
|
||||
void GuiListings::updateContents()
|
||||
{
|
||||
// set default values
|
||||
listingsTB->setPlainText(
|
||||
@ -478,14 +473,13 @@ void GuiListingsDialog::updateContents()
|
||||
extendedcharsCB->setChecked(false);
|
||||
|
||||
// set values from param string
|
||||
InsetListingsParams & params = controller().params();
|
||||
inlineCB->setChecked(params.isInline());
|
||||
if (params.isInline()) {
|
||||
inlineCB->setChecked(params_.isInline());
|
||||
if (params_.isInline()) {
|
||||
floatCB->setChecked(false);
|
||||
placementLE->setEnabled(false);
|
||||
}
|
||||
// break other parameters and set values
|
||||
vector<string> pars = getVectorFromString(params.separatedParams(), "\n");
|
||||
vector<string> pars = getVectorFromString(params_.separatedParams(), "\n");
|
||||
// process each of them
|
||||
for (vector<string>::iterator it = pars.begin();
|
||||
it != pars.end(); ++it) {
|
||||
@ -509,7 +503,7 @@ void GuiListingsDialog::updateContents()
|
||||
// on_languageCO_currentIndexChanged should have set dialects
|
||||
if (!dialect.empty()) {
|
||||
string dialect_gui;
|
||||
for (size_t i = 0; i < nr_dialects; ++i) {
|
||||
for (size_t i = 0; i != nr_dialects; ++i) {
|
||||
if (dialect == dialects[i].dialect
|
||||
&& dialects[i].language == language) {
|
||||
dialect_gui = dialects[i].gui;
|
||||
@ -617,12 +611,41 @@ void GuiListingsDialog::updateContents()
|
||||
}
|
||||
|
||||
|
||||
bool GuiListingsDialog::isValid()
|
||||
bool GuiListings::isValid()
|
||||
{
|
||||
return validate_listings_params().empty();
|
||||
}
|
||||
|
||||
|
||||
bool GuiListings::initialiseParams(string const & data)
|
||||
{
|
||||
InsetListingsMailer::string2params(data, params_);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void GuiListings::clearParams()
|
||||
{
|
||||
params_.clear();
|
||||
}
|
||||
|
||||
|
||||
void GuiListings::dispatchParams()
|
||||
{
|
||||
string const lfun = InsetListingsMailer::params2string(params_);
|
||||
dispatch(FuncRequest(getLfun(), lfun));
|
||||
}
|
||||
|
||||
|
||||
void GuiListings::setParams(InsetListingsParams const & params)
|
||||
{
|
||||
params_ = params;
|
||||
}
|
||||
|
||||
|
||||
Dialog * createGuiListings(LyXView & lv) { return new GuiListings(lv); }
|
||||
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
|
@ -13,17 +13,17 @@
|
||||
#define GUILISTINGS_H
|
||||
|
||||
#include "GuiDialog.h"
|
||||
#include "ControlListings.h"
|
||||
#include "ui_ListingsUi.h"
|
||||
#include "insets/InsetListingsParams.h"
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class GuiListingsDialog : public GuiDialog, public Ui::ListingsUi
|
||||
class GuiListings : public GuiDialog, public Ui::ListingsUi, public Controller
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiListingsDialog(LyXView & lv);
|
||||
GuiListings(LyXView & lv);
|
||||
/// get values from all the widgets and form a string
|
||||
std::string construct_params();
|
||||
/// validate listings parameters and return an error message, if any
|
||||
@ -46,13 +46,26 @@ private Q_SLOTS:
|
||||
private:
|
||||
void closeEvent(QCloseEvent * e);
|
||||
/// parent controller
|
||||
ControlListings & controller();
|
||||
Controller & controller() { return *this; }
|
||||
/// return false if validate_listings_params returns error
|
||||
bool isValid();
|
||||
/// Apply changes
|
||||
void applyView();
|
||||
/// update
|
||||
void updateContents();
|
||||
///
|
||||
bool initialiseParams(std::string const & data);
|
||||
/// clean-up on hide.
|
||||
void clearParams();
|
||||
/// clean-up on hide.
|
||||
void dispatchParams();
|
||||
///
|
||||
bool isBufferDependent() const { return true; }
|
||||
///
|
||||
void setParams(InsetListingsParams const &);
|
||||
|
||||
///
|
||||
InsetListingsParams params_;
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
Loading…
Reference in New Issue
Block a user