mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-07 02:28:35 +00:00
implement converters
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5651 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
10de2511df
commit
0c89888e25
@ -1,3 +1,8 @@
|
||||
2002-11-17 John Levon <levon@movementarian.org>
|
||||
|
||||
* QPrefsDialog.h:
|
||||
* QPrefsDialog.C: implement converters
|
||||
|
||||
2002-11-17 John Levon <levon@movementarian.org>
|
||||
|
||||
* QPrefsDialog.C:
|
||||
|
@ -244,8 +244,6 @@ void QPrefs::apply()
|
||||
controller().updateScreenFonts();
|
||||
}
|
||||
|
||||
// FIXME: here we read new converters/ formats
|
||||
|
||||
controller().setConverters(converters_);
|
||||
controller().setFormats(formats_);
|
||||
|
||||
|
@ -157,6 +157,11 @@ QPrefsDialog::QPrefsDialog(QPrefs * form)
|
||||
connect(fileformatsModule->formatRemovePB, SIGNAL(clicked()), this, SLOT(remove_format()));
|
||||
connect(fileformatsModule->formatModifyPB, SIGNAL(clicked()), this, SLOT(modify_format()));
|
||||
connect(fileformatsModule->formatsLB, SIGNAL(highlighted(int)), this, SLOT(switch_format(int)));
|
||||
|
||||
connect(convertersModule->converterNewPB, SIGNAL(clicked()), this, SLOT(new_converter()));
|
||||
connect(convertersModule->converterRemovePB, SIGNAL(clicked()), this, SLOT(remove_converter()));
|
||||
connect(convertersModule->converterModifyPB, SIGNAL(clicked()), this, SLOT(modify_converter()));
|
||||
connect(convertersModule->convertersLB, SIGNAL(highlighted(int)), this, SLOT(switch_converter(int)));
|
||||
|
||||
// Qt really sucks. This is as ugly as it looks, but the alternative
|
||||
// means having to derive every module == bloat
|
||||
@ -275,6 +280,16 @@ void QPrefsDialog::updateConverters()
|
||||
{
|
||||
QPrefConvertersModule * convertmod(convertersModule);
|
||||
|
||||
convertmod->converterFromCO->clear();
|
||||
convertmod->converterToCO->clear();
|
||||
|
||||
Formats::const_iterator cit = form_->formats_.begin();
|
||||
Formats::const_iterator end = form_->formats_.end();
|
||||
for (; cit != end; ++cit) {
|
||||
convertmod->converterFromCO->insertItem(cit->prettyname().c_str());
|
||||
convertmod->converterToCO->insertItem(cit->prettyname().c_str());
|
||||
}
|
||||
|
||||
convertmod->convertersLB->clear();
|
||||
|
||||
Converters::const_iterator ccit = form_->converters_.begin();
|
||||
@ -287,6 +302,57 @@ void QPrefsDialog::updateConverters()
|
||||
}
|
||||
|
||||
|
||||
void QPrefsDialog::switch_converter(int nr)
|
||||
{
|
||||
Converter const & c(form_->converters_.get(nr));
|
||||
convertersModule->converterFromCO->setCurrentItem(form_->formats_.getNumber(c.from));
|
||||
convertersModule->converterToCO->setCurrentItem(form_->formats_.getNumber(c.to));
|
||||
convertersModule->converterED->setText(c.command.c_str());
|
||||
convertersModule->converterFlagED->setText(c.flags.c_str());
|
||||
}
|
||||
|
||||
|
||||
// FIXME: we would like to highlight the new entry ... also user must
|
||||
// specify unique from/to or it doesn't appear. This is really bad UI
|
||||
void QPrefsDialog::new_converter()
|
||||
{
|
||||
Format const & from(form_->formats_.get(convertersModule->converterFromCO->currentItem()));
|
||||
Format const & to(form_->formats_.get(convertersModule->converterToCO->currentItem()));
|
||||
|
||||
Converter const * old = form_->converters_.getConverter(from.name(), to.name());
|
||||
form_->converters_.add(from.name(), to.name(), "", "");
|
||||
if (!old) {
|
||||
form_->converters_.updateLast(form_->formats_);
|
||||
}
|
||||
updateConverters();
|
||||
}
|
||||
|
||||
|
||||
void QPrefsDialog::modify_converter()
|
||||
{
|
||||
Format const & from(form_->formats_.get(convertersModule->converterFromCO->currentItem()));
|
||||
Format const & to(form_->formats_.get(convertersModule->converterToCO->currentItem()));
|
||||
string flags(convertersModule->converterFlagED->text().latin1());
|
||||
string name(convertersModule->converterED->text().latin1());
|
||||
|
||||
Converter const * old = form_->converters_.getConverter(from.name(), to.name());
|
||||
form_->converters_.add(from.name(), to.name(), name, flags);
|
||||
if (!old) {
|
||||
form_->converters_.updateLast(form_->formats_);
|
||||
}
|
||||
updateConverters();
|
||||
}
|
||||
|
||||
|
||||
void QPrefsDialog::remove_converter()
|
||||
{
|
||||
Format const & from(form_->formats_.get(convertersModule->converterFromCO->currentItem()));
|
||||
Format const & to(form_->formats_.get(convertersModule->converterToCO->currentItem()));
|
||||
form_->converters_.erase(from.name(), to.name());
|
||||
updateConverters();
|
||||
}
|
||||
|
||||
|
||||
void QPrefsDialog::updateFormats()
|
||||
{
|
||||
QPrefFileformatsModule * formatmod(fileformatsModule);
|
||||
|
@ -60,6 +60,11 @@ public slots:
|
||||
void modify_format();
|
||||
void remove_format();
|
||||
|
||||
void switch_converter(int);
|
||||
void new_converter();
|
||||
void modify_converter();
|
||||
void remove_converter();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent * e);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user