Richard Heck wrote:
Leuven, E. wrote:

a second question concerns the copiers. for each file format there can be one copier. so i am planning to simply add a copiers line edit to the file formats panel and get rid of the copiers panel.

I like this idea.

updated patch attached. it gets rid of the copier panel

Index: development/qmake/qt4/qt4.pro
===================================================================
--- development/qmake/qt4/qt4.pro	(revision 20284)
+++ development/qmake/qt4/qt4.pro	(working copy)
@@ -212,7 +212,6 @@
 UI += PreambleUi.ui
 UI += PrefColorsUi.ui
 UI += PrefConvertersUi.ui
-UI += PrefCopiersUi.ui
 UI += PrefCygwinPathUi.ui
 UI += PrefDateUi.ui
 UI += PrefDisplayUi.ui
Index: development/scons/scons_manifest.py
===================================================================
--- development/scons/scons_manifest.py	(revision 20284)
+++ development/scons/scons_manifest.py	(working copy)
@@ -1051,7 +1051,6 @@
     PreambleUi.ui
     PrefColorsUi.ui
     PrefConvertersUi.ui
-    PrefCopiersUi.ui
     PrefCygwinPathUi.ui
     PrefDateUi.ui
     PrefDisplayUi.ui
Index: src/Format.h
===================================================================
--- src/Format.h	(revision 20284)
+++ src/Format.h	(working copy)
@@ -47,45 +47,35 @@
 	/// Name fo the parent format
 	std::string const parentFormat() const;
 	///
-	std::string const & name() const {
-		return name_;
-	}
+	std::string const & name() const { return name_; }
 	///
-	std::string const & extension() const {
-		return extension_;
-	}
+	void setName(std::string const & v) { name_ = v; }
 	///
-	std::string const & prettyname() const {
-		return prettyname_;
-	}
+	std::string const & extension() const { return extension_; }
 	///
-	std::string const & shortcut() const {
-		return shortcut_;
-	}
+	void setExtension(std::string const & v) { extension_ = v; }
 	///
-	std::string const & viewer() const {
-		return viewer_;
-	}
+	std::string const & prettyname() const { return prettyname_; }
 	///
-	void setViewer(std::string const & v) {
-		viewer_ = v;
-	}
+	void setPrettyname(std::string const & v) { prettyname_ = v; }
 	///
-	std::string const & editor() const {
-		return editor_;
-	}
+	std::string const & shortcut() const { return shortcut_; }
 	///
-	void setEditor(std::string const & v) {
-		editor_ = v;
-	}
+	void setShortcut(std::string const & v) { shortcut_ = v; }
 	///
-	bool documentFormat() const {
-		return flags_ & document;
-	}
+	std::string const & viewer() const { return viewer_; }
 	///
-	bool vectorFormat() const {
-		return flags_ & vector;
-	}
+	void setViewer(std::string const & v) { viewer_ = v; }
+	///
+	std::string const & editor() const { return editor_; }
+	///
+	void setEditor(std::string const & v) { editor_ = v; }
+	///
+	bool documentFormat() const { return flags_ & document; }
+	///
+	bool vectorFormat() const { return flags_ & vector; }
+	///
+	void setFlags(int v) { flags_ = v; }
 private:
 	/// Internal name. Needs to be unique.
 	std::string name_;
@@ -121,9 +111,9 @@
 	///
 	typedef FormatList::const_iterator const_iterator;
 	///
-	Format const & get(FormatList::size_type i) const {
-		return formatlist[i];
-	}
+	Format const & get(FormatList::size_type i) const { return formatlist[i]; }
+	///
+	Format & get(FormatList::size_type i) { return formatlist[i]; }
 	/// \returns format named \p name if it exists, otherwise 0
 	Format const * getFormat(std::string const & name) const;
 	/*!
Index: src/frontends/qt4/GuiPrefs.cpp
===================================================================
--- src/frontends/qt4/GuiPrefs.cpp	(revision 20284)
+++ src/frontends/qt4/GuiPrefs.cpp	(working copy)
@@ -42,6 +42,7 @@
 #include <QString>
 #include <QValidator>
 #include <QCloseEvent>
+#include <QMessageBox>
 
 #include <iomanip>
 #include <sstream>
@@ -1106,298 +1107,93 @@
 
 /////////////////////////////////////////////////////////////////////
 //
-// PrefCopiers
+// PrefFileformats
 //
 /////////////////////////////////////////////////////////////////////
-
-PrefCopiers::PrefCopiers(GuiPrefsDialog * form, QWidget * parent)
-	: PrefModule(_("Copiers"), form, parent)
+FormatValidator::FormatValidator(QWidget * parent, Formats const & f) 
+	: QValidator(parent), formats_(f)
 {
-	setupUi(this);
-
-	connect(copierNewPB, SIGNAL(clicked()), this, SLOT(new_copier()));
-	connect(copierRemovePB, SIGNAL(clicked()), this, SLOT(remove_copier()));
-	connect(copierModifyPB, SIGNAL(clicked()), this, SLOT(modify_copier()));
-	connect(AllCopiersLW, SIGNAL(currentRowChanged(int)),
-		this, SLOT(switch_copierLB(int)));
-	connect(copierFormatCO, SIGNAL(activated(int)),
-		this, SLOT(switch_copierCO(int)));
-	connect(copierNewPB, SIGNAL(clicked()),
-		this, SIGNAL(changed()));
-	connect(copierRemovePB, SIGNAL(clicked()),
-		this, SIGNAL(changed()));
-	connect(copierModifyPB, SIGNAL(clicked()),
-		this, SIGNAL(changed()));
-	connect(copierFormatCO, SIGNAL(activated(const QString &)),
-		this, SLOT(copiers_changed()));
-	connect(copierED, SIGNAL(textChanged(const QString &)),
-		this, SLOT(copiers_changed()));
 }
 
 
-void PrefCopiers::apply(LyXRC & /*rc*/) const
+void FormatValidator::fixup(QString & input) const
 {
-}
+	Formats::const_iterator cit = formats_.begin();
+	Formats::const_iterator end = formats_.end();
+	for (; cit != end; ++cit) {
+		string const name = str(cit);
+		if (distance(formats_.begin(), cit) == nr()) {
+			input = toqstr(name);
+			return;
 
-
-void PrefCopiers::update(LyXRC const & /*rc*/)
-{
-	updateView();
-}
-
-
-void PrefCopiers::updateView()
-{
-	// The choice widget
-	// save current selection
-	QString current = copierFormatCO->currentText();
-	copierFormatCO->clear();
-
-	for (Formats::const_iterator it = form_->formats().begin(),
-		     end = form_->formats().end();
-	     it != end; ++it) {
-		copierFormatCO->addItem(toqstr(it->prettyname()));
-	}
-
-	// The browser widget
-	AllCopiersLW->clear();
-
-	for (Movers::const_iterator it = form_->movers().begin(),
-		     end = form_->movers().end();
-	     it != end; ++it) {
-		std::string const & command = it->second.command();
-		if (command.empty())
-			continue;
-		QString const pretty = toqstr(form_->formats().prettyName(it->first));
-		AllCopiersLW->addItem(pretty);
-	}
-	AllCopiersLW->sortItems(Qt::AscendingOrder);
-
-	// restore selection
-	if (!current.isEmpty()) {
-		QList<QListWidgetItem *> item =
-			AllCopiersLW->findItems(current, Qt::MatchExactly);
-		if (item.size()>0)
-			AllCopiersLW->setCurrentItem(item.at(0));
-	}
-	// select first element if restoring failed
-	if (AllCopiersLW->currentRow() == -1)
-		AllCopiersLW->setCurrentRow(0);
-}
-
-
-namespace {
-
-class SamePrettyName {
-public:
-	SamePrettyName(string const & n) : pretty_name_(n) {}
-
-	bool operator()(Format const & fmt) const {
-		return fmt.prettyname() == pretty_name_;
-	}
-
-private:
-	string const pretty_name_;
-};
-
-
-Format const * getFormat(std::string const & prettyname)
-{
-	Formats::const_iterator it = formats.begin();
-	Formats::const_iterator const end = formats.end();
-	it = std::find_if(it, end, SamePrettyName(prettyname));
-	return it == end ? 0 : &*it;
-}
-
-} // namespace anon
-
-
-void PrefCopiers::switch_copierLB(int row)
-{
-	if (row < 0)
-		return;
-
-	// FIXME UNICODE?
-	std::string const browser_text =
-		fromqstr(AllCopiersLW->currentItem()->text());
-	Format const * fmt = getFormat(browser_text);
-	if (fmt == 0)
-		return;
-
-	QString const gui_name = toqstr(fmt->prettyname());
-	QString const command = toqstr(form_->movers().command(fmt->name()));
-
-	copierED->clear();
-	int const combo_size = copierFormatCO->count();
-	for (int i = 0; i < combo_size; ++i) {
-		QString const text = copierFormatCO->itemText(i);
-		if (text == gui_name) {
-			copierFormatCO->setCurrentIndex(i);
-			copierED->setText(command);
-			break;
 		}
 	}
-	updateButtons();
 }
 
 
-void PrefCopiers::switch_copierCO(int row)
+QValidator::State FormatValidator::validate(QString & input, int & pos) const
 {
-	if (row<0)
-		return;
-
-	std::string const combo_text =
-		fromqstr(copierFormatCO->currentText());
-	Format const * fmt = getFormat(combo_text);
-	if (fmt == 0)
-		return;
-
-	QString const command = toqstr(form_->movers().command(fmt->name()));
-	copierED->setText(command);
-
-	QListWidgetItem * const index = AllCopiersLW->currentItem();
-	if (index >= 0)
-		AllCopiersLW->setItemSelected(index, false);
-
-	QString const gui_name = toqstr(fmt->prettyname());
-	int const browser_size = AllCopiersLW->count();
-	for (int i = 0; i < browser_size; ++i) {
-		QString const text = AllCopiersLW->item(i)->text();
-		if (text == gui_name) {
-			QListWidgetItem * item = AllCopiersLW->item(i);
-			AllCopiersLW->setItemSelected(item, true);
-			break;
-		}
+	Formats::const_iterator cit = formats_.begin();
+	Formats::const_iterator end = formats_.end();
+	bool unknown = true;
+	for (; unknown && cit != end; ++cit) {
+		string const name = str(cit);
+		if (distance(formats_.begin(), cit) != nr())
+			unknown = toqstr(name) != input;
 	}
+
+	if (unknown && !input.isEmpty()) 
+		return QValidator::Acceptable;
+	else
+		return QValidator::Intermediate;
 }
 
 
-void PrefCopiers::copiers_changed()
+int FormatValidator::nr() const
 {
-	updateButtons();
+	QComboBox * p = qobject_cast<QComboBox *>(parent());
+	return p->itemData(p->currentIndex()).toInt();
 }
 
 
-void PrefCopiers::updateButtons()
+FormatNameValidator::FormatNameValidator(QWidget * parent, Formats const & f) 
+	: FormatValidator(parent, f)
 {
-	QString selected = copierFormatCO->currentText();
-
-	bool known = false;
-	for (int i = 0; i < AllCopiersLW->count(); ++i) {
-		if (AllCopiersLW->item(i)->text() == selected)
-			known = true;
-	}
-
-	bool const valid = !copierED->text().isEmpty();
-
-	Format const * fmt = getFormat(fromqstr(selected));
-	string const old_command = form_->movers().command(fmt->name());
-	string const new_command(fromqstr(copierED->text()));
-
-	bool modified = (old_command != new_command);
-
-	copierModifyPB->setEnabled(valid && known && modified);
-	copierNewPB->setEnabled(valid && !known);
-	copierRemovePB->setEnabled(known);
 }
 
-
-void PrefCopiers::new_copier()
+std::string FormatNameValidator::str(Formats::const_iterator it) const
 {
-	std::string const combo_text =
-		fromqstr(copierFormatCO->currentText());
-	Format const * fmt = getFormat(combo_text);
-	if (fmt == 0)
-		return;
-
-	string const command = fromqstr(copierED->text());
-	if (command.empty())
-		return;
-
-	form_->movers().set(fmt->name(), command);
-
-	updateView();
-	int const last = AllCopiersLW->count() - 1;
-	AllCopiersLW->setCurrentRow(last);
-
-	updateButtons();
+	return it->name();
 }
 
 
-void PrefCopiers::modify_copier()
+FormatPrettynameValidator::FormatPrettynameValidator(QWidget * parent, Formats const & f) 
+	: FormatValidator(parent, f)
 {
-	std::string const combo_text =
-		fromqstr(copierFormatCO->currentText());
-	Format const * fmt = getFormat(combo_text);
-	if (fmt == 0)
-		return;
-
-	string const command = fromqstr(copierED->text());
-	form_->movers().set(fmt->name(), command);
-
-	updateView();
-	updateButtons();
 }
 
 
-void PrefCopiers::remove_copier()
+std::string FormatPrettynameValidator::str(Formats::const_iterator it) const
 {
-	std::string const combo_text =
-		fromqstr(copierFormatCO->currentText());
-	Format const * fmt = getFormat(combo_text);
-	if (fmt == 0)
-		return;
-
-	string const & fmt_name = fmt->name();
-	form_->movers().set(fmt_name, string());
-
-	updateView();
-	updateButtons();
+	return it->prettyname();
 }
 
 
-
-/////////////////////////////////////////////////////////////////////
-//
-// PrefFileformats
-//
-/////////////////////////////////////////////////////////////////////
-
 PrefFileformats::PrefFileformats(GuiPrefsDialog * form, QWidget * parent)
 	: PrefModule(_("File formats"), form, parent)
 {
 	setupUi(this);
+	formatED->setValidator(new FormatNameValidator(formatsCB, form_->formats()));
+	formatsCB->setValidator(new FormatPrettynameValidator(formatsCB, form_->formats()));
 
-	connect(formatNewPB, SIGNAL(clicked()),
-		this, SLOT(new_format()));
-	connect(formatRemovePB, SIGNAL(clicked()),
-		this, SLOT(remove_format()));
-	connect(formatModifyPB, SIGNAL(clicked()),
-		this, SLOT(modify_format()));
-	connect(formatsLW, SIGNAL(currentRowChanged(int)),
-		this, SLOT(switch_format(int)));
-	connect(formatED, SIGNAL(textChanged(const QString&)),
-		this, SLOT(fileformat_changed()));
-	connect(guiNameED, SIGNAL(textChanged(const QString&)),
-		this, SLOT(fileformat_changed()));
-	connect(shortcutED, SIGNAL(textChanged(const QString&)),
-		this, SLOT(fileformat_changed()));
-	connect(extensionED, SIGNAL(textChanged(const QString&)),
-		this, SLOT(fileformat_changed()));
-	connect(viewerED, SIGNAL(textChanged(const QString&)),
-		this, SLOT(fileformat_changed()));
-	connect(editorED, SIGNAL(textChanged(const QString&)),
-		this, SLOT(fileformat_changed()));
 	connect(documentCB, SIGNAL(clicked()),
-		this, SLOT(fileformat_changed()));
+		this, SLOT(setFlags()));
 	connect(vectorCB, SIGNAL(clicked()),
-		this, SLOT(fileformat_changed()));
-	connect(formatNewPB, SIGNAL(clicked()),
+		this, SLOT(setFlags()));
+	connect(formatsCB->lineEdit(), SIGNAL(editingFinished()),
+		this, SLOT(updatePrettyname()));
+	connect(formatsCB->lineEdit(), SIGNAL(textEdited(const QString &)),
 		this, SIGNAL(changed()));
-	connect(formatRemovePB, SIGNAL(clicked()),
-		this, SIGNAL(changed()));
-	connect(formatModifyPB, SIGNAL(clicked()),
-		this, SIGNAL(changed()));
 }
 
 
@@ -1414,146 +1210,154 @@
 
 void PrefFileformats::updateView()
 {
-	// save current selection
-	QString current = guiNameED->text();
+	QString const current = formatsCB->currentText();
 
-	// update listwidget with formats
-	formatsLW->blockSignals(true);
-	formatsLW->clear();
+	// update combobox with formats
+	formatsCB->blockSignals(true);
+	formatsCB->clear();
+	form_->formats().sort();
 	Formats::const_iterator cit = form_->formats().begin();
 	Formats::const_iterator end = form_->formats().end();
-	for (; cit != end; ++cit) {
-		new QListWidgetItem(toqstr(cit->prettyname()),
-							formatsLW,
-							form_->formats().getNumber(cit->name()) );
-	}
-	formatsLW->sortItems(Qt::AscendingOrder);
-	formatsLW->blockSignals(false);
+	for (; cit != end; ++cit)
+		formatsCB->addItem(toqstr(cit->prettyname()),
+							QVariant(form_->formats().getNumber(cit->name())) );
 
 	// restore selection
-	if (!current.isEmpty()) {
-		QList<QListWidgetItem *>  item = formatsLW->findItems(current, Qt::MatchExactly);
-		if (item.size()>0)
-			formatsLW->setCurrentItem(item.at(0));
-	}
-	// select first element if restoring failed
-	if (formatsLW->currentRow() == -1)
-		formatsLW->setCurrentRow(0);
+	int const item = formatsCB->findText(current, Qt::MatchExactly);
+	formatsCB->setCurrentIndex(item < 0 ? 0 : item);
+	on_formatsCB_currentIndexChanged(item < 0 ? 0 : item);
+	formatsCB->blockSignals(false);
 }
 
 
-void PrefFileformats::switch_format(int nr)
+void PrefFileformats::on_formatsCB_currentIndexChanged(int i)
 {
-	int const ftype = formatsLW->item(nr)->type();
-	Format const f = form_->formats().get(ftype);
+	int const nr = formatsCB->itemData(i).toInt();
+	Format const f = form_->formats().get(nr);
 
 	formatED->setText(toqstr(f.name()));
-	guiNameED->setText(toqstr(f.prettyname()));
+	copierED->setText(toqstr(form_->movers().command(f.name())));
 	extensionED->setText(toqstr(f.extension()));
 	shortcutED->setText(toqstr(f.shortcut()));
 	viewerED->setText(toqstr(f.viewer()));
 	editorED->setText(toqstr(f.editor()));
 	documentCB->setChecked((f.documentFormat()));
 	vectorCB->setChecked((f.vectorFormat()));
+}
 
-	updateButtons();
+
+void PrefFileformats::setFlags()
+{
+	int flags = Format::none;
+	if (documentCB->isChecked())
+		flags |= Format::document;
+	if (vectorCB->isChecked())
+		flags |= Format::vector;
+	currentFormat().setFlags(flags);
+	changed();
 }
 
 
-void PrefFileformats::fileformat_changed()
+void PrefFileformats::on_copierED_textEdited(const QString & s)
 {
-	updateButtons();
+	string const fmt = fromqstr(formatED->text());
+	form_->movers().set(fmt, fromqstr(s));
+	changed();
 }
 
 
-void PrefFileformats::updateButtons()
+void PrefFileformats::on_extensionED_textEdited(const QString & s)
 {
-	QString const format = formatED->text();
-	QString const gui_name = guiNameED->text();
-	int const sel = form_->formats().getNumber(fromqstr(format));
-	bool gui_name_known = false;
-	int where = sel;
-	for (int i = 0; i < formatsLW->count(); ++i) {
-		if (formatsLW->item(i)->text() == gui_name) {
-			gui_name_known = true;
-			where = formatsLW->item(i)->type();
-		}
-	}
+	currentFormat().setExtension(fromqstr(s));
+	changed();
+}
 
-	// assure that a gui name cannot be chosen twice
-	bool const known_otherwise = gui_name_known && (where != sel);
 
-	bool const known = !(sel < 0);
-	bool const valid = (!formatED->text().isEmpty()
-		&& !guiNameED->text().isEmpty());
+void PrefFileformats::on_viewerED_textEdited(const QString & s)
+{
+	currentFormat().setViewer(fromqstr(s));
+	changed();
+}
 
-	int const ftype = formatsLW->currentItem()->type();
-	Format const & f(form_->formats().get(ftype));
-	string const old_pretty(f.prettyname());
-	string const old_shortcut(f.shortcut());
-	string const old_extension(f.extension());
-	string const old_viewer(f.viewer());
-	string const old_editor(f.editor());
-	bool const old_document(f.documentFormat());
-	bool const old_vector(f.vectorFormat());
 
-	string const new_pretty(fromqstr(gui_name));
-	string const new_shortcut(fromqstr(shortcutED->text()));
-	string const new_extension(fromqstr(extensionED->text()));
-	string const new_viewer(fromqstr(viewerED->text()));
-	string const new_editor(fromqstr(editorED->text()));
-	bool const new_document(documentCB->isChecked());
-	bool const new_vector(vectorCB->isChecked());
+void PrefFileformats::on_editorED_textEdited(const QString & s)
+{
+	currentFormat().setEditor(fromqstr(s));
+	changed();
+}
 
-	bool modified = ((old_pretty != new_pretty) || (old_shortcut != new_shortcut)
-		|| (old_extension != new_extension) || (old_viewer != new_viewer)
-		|| old_editor != new_editor || old_document != new_document
-		|| old_vector != new_vector);
 
-	formatModifyPB->setEnabled(valid && known && modified && !known_otherwise);
-	formatNewPB->setEnabled(valid && !known && !gui_name_known);
-	formatRemovePB->setEnabled(known);
+void PrefFileformats::on_shortcutED_textEdited(const QString & s)
+{
+	currentFormat().setShortcut(fromqstr(s));
+	changed();
 }
 
 
-void PrefFileformats::new_format()
+void PrefFileformats::on_formatED_editingFinished()
 {
-	string const name = fromqstr(formatED->text());
-	string const prettyname = fromqstr(guiNameED->text());
-	string const extension = fromqstr(extensionED->text());
-	string const shortcut = fromqstr(shortcutED->text());
-	string const viewer = fromqstr(viewerED->text());
-	string const editor = fromqstr(editorED->text());
-	int flags = Format::none;
-	if (documentCB->isChecked())
-		flags |= Format::document;
-	if (vectorCB->isChecked())
-		flags |= Format::vector;
+	string const newname = fromqstr(formatED->displayText());
+	if (newname == currentFormat().name())
+		return;
 
-	form_->formats().add(name, extension, prettyname, shortcut, viewer,
-			     editor, flags);
-	form_->formats().sort();
-	form_->converters().update(form_->formats());
+	currentFormat().setName(newname);
+	changed();
+}
 
-	updateView();
-	updateButtons();
+
+void PrefFileformats::on_formatED_textChanged(const QString &)
+{
+	QString t = formatED->text();
+	int p = 0;
+	bool valid = formatED->validator()->validate(t, p) == QValidator::Acceptable;
+	setValid(formatLA, valid);
+}
+
+
+void PrefFileformats::on_formatsCB_editTextChanged(const QString &)
+{
+	QString t = formatsCB->currentText();
+	int p = 0;
+	bool valid = formatsCB->validator()->validate(t, p) == QValidator::Acceptable;
+	setValid(formatsLA, valid);
+}
+
+
+void PrefFileformats::updatePrettyname()
+{
+	string const newname = fromqstr(formatsCB->currentText());
+	if (newname == currentFormat().prettyname())
+		return;
+
+	currentFormat().setPrettyname(newname);
+	form_->converters().update(form_->formats());
 	formatsChanged();
+	updateView();
+	changed();
 }
 
 
-void PrefFileformats::modify_format()
+Format & PrefFileformats::currentFormat()
 {
-	int const current_item = formatsLW->currentItem()->type();
-	Format const & oldformat = form_->formats().get(current_item);
-	form_->formats().erase(oldformat.name());
+	int const i = formatsCB->currentIndex();
+	int const nr = formatsCB->itemData(i).toInt();
+	return form_->formats().get(nr);
+}
 
-	new_format();
+
+void PrefFileformats::on_formatNewPB_clicked()
+{
+	form_->formats().add("", "", "", "", "", "", Format::none);
+	updateView();
+	formatsCB->setCurrentIndex(0);
+	formatsCB->setFocus(Qt::OtherFocusReason);
 }
 
 
-void PrefFileformats::remove_format()
+void PrefFileformats::on_formatRemovePB_clicked()
 {
-	int const nr = formatsLW->currentItem()->type();
+	int const i = formatsCB->currentIndex();
+	int const nr = formatsCB->itemData(i).toInt();
 	string const current_text = form_->formats().get(nr).name();
 	if (form_->converters().formatIsUsed(current_text)) {
 		Alert::error(_("Format in use"),
@@ -1564,10 +1368,10 @@
 
 	form_->formats().erase(current_text);
 	form_->converters().update(form_->formats());
-
-	updateView();
-	updateButtons();
 	formatsChanged();
+	updateView();
+	on_formatsCB_editTextChanged(formatsCB->currentText());
+	changed();
 }
 
 
@@ -1945,9 +1749,6 @@
 	add(converters);
 	add(formats);
 
-	add(new PrefCopiers(this));
-
-
 	prefsPS->setCurrentPanel(_("User interface"));
 // FIXME: hack to work around resizing bug in Qt >= 4.2
 // bug verified with Qt 4.2.{0-3} (JSpitzm)
Index: src/frontends/qt4/GuiPrefs.h
===================================================================
--- src/frontends/qt4/GuiPrefs.h	(revision 20284)
+++ src/frontends/qt4/GuiPrefs.h	(working copy)
@@ -16,6 +16,7 @@
 #include "ControlPrefs.h"
 #include "Color.h"
 #include "LyXRC.h"
+#include "Format.h"
 
 #include "ui_PrefsUi.h"
 
@@ -29,7 +30,6 @@
 #include "ui_PrefPathsUi.h"
 #include "ui_PrefSpellcheckerUi.h"
 #include "ui_PrefConvertersUi.h"
-#include "ui_PrefCopiersUi.h"
 #include "ui_PrefFileformatsUi.h"
 #include "ui_PrefLanguageUi.h"
 #include "ui_PrefPrinterUi.h"
@@ -37,6 +37,7 @@
 #include "ui_PrefIdentityUi.h"
 
 #include <QDialog>
+#include <QValidator>
 
 #include <vector>
 
@@ -233,27 +234,33 @@
 };
 
 
-class PrefCopiers : public PrefModule, public Ui::PrefCopiersUi
+class FormatValidator : public QValidator
 {
-	Q_OBJECT
 public:
-	PrefCopiers(GuiPrefsDialog * form, QWidget * parent = 0);
+	FormatValidator(QWidget *, Formats const & f);
+	void fixup(QString & input) const;
+	QValidator::State validate(QString & input, int & pos) const;
+private:
+	virtual std::string str(Formats::const_iterator it) const = 0;
+	int nr() const;
+	Formats const & formats_;
+};
 
-	void apply(LyXRC & rc) const;
-	void update(LyXRC const & rc);
 
-	void updateView();
+class FormatNameValidator : public FormatValidator
+{
+public:
+	FormatNameValidator(QWidget *, Formats const & f);
+private:
+	std::string str(Formats::const_iterator it) const;
+};
 
-private Q_SLOTS:
-	void switch_copierLB(int nr);
-	void switch_copierCO(int nr);
-	void copiers_changed();
-	void new_copier();
-	void modify_copier();
-	void remove_copier();
-
+class FormatPrettynameValidator : public FormatValidator
+{
+public:
+	FormatPrettynameValidator(QWidget *, Formats const & f);
 private:
-	void updateButtons();
+	std::string str(Formats::const_iterator it) const;
 };
 
 
@@ -265,19 +272,28 @@
 
 	void apply(LyXRC & rc) const;
 	void update(LyXRC const & rc);
+	void updateView();
 
-	void updateView();
 Q_SIGNALS:
 	void formatsChanged();
-private:
-	void updateButtons();
 
 private Q_SLOTS:
-	void switch_format(int);
-	void fileformat_changed();
-	void new_format();
-	void modify_format();
-	void remove_format();
+	void on_copierED_textEdited(const QString & s);
+	void on_extensionED_textEdited(const QString &);
+	void on_viewerED_textEdited(const QString &);
+	void on_editorED_textEdited(const QString &);
+	void on_shortcutED_textEdited(const QString &);
+	void on_formatED_editingFinished();
+	void on_formatED_textChanged(const QString &);
+	void on_formatsCB_currentIndexChanged(int);
+	void on_formatsCB_editTextChanged(const QString &);
+	void on_formatNewPB_clicked();
+	void on_formatRemovePB_clicked();
+	void setFlags();
+	void updatePrettyname();
+
+private:
+	Format & currentFormat();
 };
 
 
Index: src/frontends/qt4/Makefile.am
===================================================================
--- src/frontends/qt4/Makefile.am	(revision 20284)
+++ src/frontends/qt4/Makefile.am	(working copy)
@@ -240,7 +240,6 @@
 	PreambleUi.ui \
 	PrefColorsUi.ui \
 	PrefConvertersUi.ui \
-	PrefCopiersUi.ui \
 	PrefDateUi.ui \
 	PrefDisplayUi.ui \
 	PrefFileformatsUi.ui \
Index: src/frontends/qt4/ui/compile_uic.sh
===================================================================
--- src/frontends/qt4/ui/compile_uic.sh	(revision 20284)
+++ src/frontends/qt4/ui/compile_uic.sh	(working copy)
@@ -33,7 +33,6 @@
 uic ParagraphUi.ui -o ParagraphUi.h
 uic PrefColorsUi.ui -o PrefColorsUi.h
 uic PrefConvertersUi.ui -o PrefConvertersUi.h
-uic PrefCopiersUi.ui -o PrefCopiersUi.h
 uic PrefDateUi.ui -o PrefDateUi.h
 uic PrefDisplayUi.ui -o PrefDisplayUi.h
 uic PrefFileformatsUi.ui -o PrefFileformatsUi.h
Index: src/frontends/qt4/ui/PrefCopiersUi.ui
===================================================================
--- src/frontends/qt4/ui/PrefCopiersUi.ui	(revision 20284)
+++ src/frontends/qt4/ui/PrefCopiersUi.ui	(working copy)
@@ -1,133 +0,0 @@
-<ui version="4.0" >
- <class>PrefCopiersUi</class>
- <widget class="QWidget" name="PrefCopiersUi" >
-  <property name="geometry" >
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>396</width>
-    <height>320</height>
-   </rect>
-  </property>
-  <property name="windowTitle" >
-   <string/>
-  </property>
-  <layout class="QGridLayout" >
-   <property name="margin" >
-    <number>9</number>
-   </property>
-   <property name="spacing" >
-    <number>6</number>
-   </property>
-   <item row="2" column="2" >
-    <spacer>
-     <property name="orientation" >
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="sizeHint" >
-      <size>
-       <width>161</width>
-       <height>20</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
-   <item row="2" column="0" >
-    <widget class="QLabel" name="copierFormatLA" >
-     <property name="text" >
-      <string>&amp;Format:</string>
-     </property>
-     <property name="buddy" >
-      <cstring>copierFormatCO</cstring>
-     </property>
-    </widget>
-   </item>
-   <item row="2" column="1" >
-    <widget class="QComboBox" name="copierFormatCO" />
-   </item>
-   <item row="1" column="0" colspan="3" >
-    <widget class="QListWidget" name="AllCopiersLW" />
-   </item>
-   <item row="3" column="1" colspan="2" >
-    <widget class="QLineEdit" name="copierED" />
-   </item>
-   <item row="3" column="0" >
-    <widget class="QLabel" name="copierLA" >
-     <property name="text" >
-      <string>&amp;Copier:</string>
-     </property>
-     <property name="buddy" >
-      <cstring>copierED</cstring>
-     </property>
-    </widget>
-   </item>
-   <item row="0" column="0" colspan="4" >
-    <widget class="QLabel" name="AllCopiersLA" >
-     <property name="text" >
-      <string>C&amp;opiers</string>
-     </property>
-     <property name="buddy" >
-      <cstring>AllCopiersLW</cstring>
-     </property>
-    </widget>
-   </item>
-   <item rowspan="3" row="1" column="3" >
-    <layout class="QVBoxLayout" >
-     <property name="margin" >
-      <number>0</number>
-     </property>
-     <property name="spacing" >
-      <number>6</number>
-     </property>
-     <item>
-      <widget class="QPushButton" name="copierNewPB" >
-       <property name="text" >
-        <string>&amp;Add</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="copierModifyPB" >
-       <property name="text" >
-        <string>&amp;Modify</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="copierRemovePB" >
-       <property name="text" >
-        <string>&amp;Remove</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <spacer>
-       <property name="orientation" >
-        <enum>Qt::Vertical</enum>
-       </property>
-       <property name="sizeHint" >
-        <size>
-         <width>20</width>
-         <height>40</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-    </layout>
-   </item>
-  </layout>
- </widget>
- <tabstops>
-  <tabstop>AllCopiersLW</tabstop>
-  <tabstop>copierFormatCO</tabstop>
-  <tabstop>copierED</tabstop>
-  <tabstop>copierNewPB</tabstop>
-  <tabstop>copierModifyPB</tabstop>
-  <tabstop>copierRemovePB</tabstop>
- </tabstops>
- <includes>
-  <include location="local" >qt_helpers.h</include>
- </includes>
- <resources/>
- <connections/>
-</ui>
Index: src/frontends/qt4/ui/PrefFileformatsUi.ui
===================================================================
--- src/frontends/qt4/ui/PrefFileformatsUi.ui	(revision 20284)
+++ src/frontends/qt4/ui/PrefFileformatsUi.ui	(working copy)
@@ -5,253 +5,184 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>459</width>
-    <height>410</height>
+    <width>414</width>
+    <height>322</height>
    </rect>
   </property>
   <property name="windowTitle" >
    <string/>
   </property>
-  <layout class="QVBoxLayout" >
+  <layout class="QGridLayout" >
    <property name="margin" >
-    <number>0</number>
+    <number>9</number>
    </property>
    <property name="spacing" >
     <number>6</number>
    </property>
-   <item>
+   <item row="8" column="1" colspan="3" >
+    <widget class="QLineEdit" name="copierED" />
+   </item>
+   <item row="6" column="1" >
+    <widget class="QLineEdit" name="editorED" />
+   </item>
+   <item row="0" column="2" >
+    <widget class="QPushButton" name="formatNewPB" >
+     <property name="text" >
+      <string>&amp;New...</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="3" >
+    <widget class="QPushButton" name="formatRemovePB" >
+     <property name="text" >
+      <string>&amp;Remove</string>
+     </property>
+    </widget>
+   </item>
+   <item row="5" column="1" >
+    <widget class="QLineEdit" name="shortcutED" />
+   </item>
+   <item row="3" column="1" >
+    <widget class="QLineEdit" name="formatED" />
+   </item>
+   <item row="3" column="0" >
+    <widget class="QLabel" name="formatLA" >
+     <property name="text" >
+      <string>S&amp;hort Name:</string>
+     </property>
+     <property name="buddy" >
+      <cstring>formatED</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1" >
+    <widget class="QComboBox" name="formatsCB" >
+     <property name="sizePolicy" >
+      <sizepolicy>
+       <hsizetype>7</hsizetype>
+       <vsizetype>0</vsizetype>
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="editable" >
+      <bool>true</bool>
+     </property>
+     <property name="insertPolicy" >
+      <enum>QComboBox::InsertAtCurrent</enum>
+     </property>
+     <property name="minimumContentsLength" >
+      <number>1</number>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="1" colspan="3" >
+    <widget class="QCheckBox" name="vectorCB" >
+     <property name="text" >
+      <string>Vector graphi&amp;cs format</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="0" >
     <widget class="QLabel" name="formatsLA" >
      <property name="text" >
-      <string>&amp;File formats</string>
+      <string>&amp;Format:</string>
      </property>
      <property name="buddy" >
-      <cstring>formatsLW</cstring>
+      <cstring>formatsCB</cstring>
      </property>
     </widget>
    </item>
-   <item>
-    <layout class="QHBoxLayout" >
-     <property name="margin" >
-      <number>0</number>
+   <item row="1" column="1" colspan="3" >
+    <widget class="QCheckBox" name="documentCB" >
+     <property name="text" >
+      <string>&amp;Document format</string>
      </property>
-     <property name="spacing" >
-      <number>6</number>
+    </widget>
+   </item>
+   <item row="7" column="0" >
+    <widget class="QLabel" name="viewerLA" >
+     <property name="text" >
+      <string>&amp;Viewer:</string>
      </property>
-     <item>
-      <widget class="QListWidget" name="formatsLW" />
-     </item>
-     <item>
-      <layout class="QVBoxLayout" >
-       <property name="margin" >
-        <number>0</number>
-       </property>
-       <property name="spacing" >
-        <number>6</number>
-       </property>
-       <item>
-        <widget class="QPushButton" name="formatNewPB" >
-         <property name="text" >
-          <string>&amp;Add</string>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="formatModifyPB" >
-         <property name="text" >
-          <string>&amp;Modify</string>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QPushButton" name="formatRemovePB" >
-         <property name="text" >
-          <string>&amp;Remove</string>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <spacer>
-         <property name="orientation" >
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" >
-          <size>
-           <width>20</width>
-           <height>40</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-      </layout>
-     </item>
-    </layout>
+     <property name="buddy" >
+      <cstring>viewerED</cstring>
+     </property>
+    </widget>
    </item>
-   <item>
-    <layout class="QHBoxLayout" >
-     <property name="margin" >
-      <number>0</number>
+   <item row="7" column="1" >
+    <widget class="QLineEdit" name="viewerED" />
+   </item>
+   <item row="6" column="0" >
+    <widget class="QLabel" name="editorLA" >
+     <property name="text" >
+      <string>Ed&amp;itor:</string>
      </property>
-     <property name="spacing" >
-      <number>6</number>
+     <property name="buddy" >
+      <cstring>editorED</cstring>
      </property>
-     <item>
-      <widget class="QCheckBox" name="documentCB" >
-       <property name="text" >
-        <string>&amp;Document format</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QCheckBox" name="vectorCB" >
-       <property name="text" >
-        <string>Vector graphi&amp;cs format</string>
-       </property>
-      </widget>
-     </item>
-    </layout>
+    </widget>
    </item>
-   <item>
-    <layout class="QHBoxLayout" >
-     <property name="margin" >
-      <number>0</number>
+   <item row="5" column="0" >
+    <widget class="QLabel" name="shortcutLA" >
+     <property name="text" >
+      <string>S&amp;hortcut:</string>
      </property>
-     <property name="spacing" >
-      <number>6</number>
+     <property name="buddy" >
+      <cstring>shortcutED</cstring>
      </property>
-     <item>
-      <layout class="QVBoxLayout" >
-       <property name="margin" >
-        <number>0</number>
-       </property>
-       <property name="spacing" >
-        <number>6</number>
-       </property>
-       <item>
-        <widget class="QLabel" name="formatLA" >
-         <property name="text" >
-          <string>F&amp;ormat:</string>
-         </property>
-         <property name="buddy" >
-          <cstring>formatED</cstring>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QLabel" name="shortcutLA" >
-         <property name="text" >
-          <string>S&amp;hortcut:</string>
-         </property>
-         <property name="buddy" >
-          <cstring>shortcutED</cstring>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QLabel" name="viewerLA" >
-         <property name="text" >
-          <string>&amp;Viewer:</string>
-         </property>
-         <property name="buddy" >
-          <cstring>viewerED</cstring>
-         </property>
-        </widget>
-       </item>
-      </layout>
-     </item>
-     <item>
-      <layout class="QVBoxLayout" >
-       <property name="margin" >
-        <number>0</number>
-       </property>
-       <property name="spacing" >
-        <number>6</number>
-       </property>
-       <item>
-        <widget class="QLineEdit" name="formatED" />
-       </item>
-       <item>
-        <widget class="QLineEdit" name="shortcutED" />
-       </item>
-       <item>
-        <widget class="QLineEdit" name="viewerED" />
-       </item>
-      </layout>
-     </item>
-     <item>
-      <layout class="QVBoxLayout" >
-       <property name="margin" >
-        <number>0</number>
-       </property>
-       <property name="spacing" >
-        <number>6</number>
-       </property>
-       <item>
-        <widget class="QLabel" name="guiNameLA" >
-         <property name="text" >
-          <string>&amp;GUI name:</string>
-         </property>
-         <property name="buddy" >
-          <cstring>guiNameED</cstring>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QLabel" name="extensionLA" >
-         <property name="text" >
-          <string>E&amp;xtension:</string>
-         </property>
-         <property name="buddy" >
-          <cstring>extensionED</cstring>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QLabel" name="editorLA" >
-         <property name="text" >
-          <string>Ed&amp;itor:</string>
-         </property>
-         <property name="buddy" >
-          <cstring>editorED</cstring>
-         </property>
-        </widget>
-       </item>
-      </layout>
-     </item>
-     <item>
-      <layout class="QVBoxLayout" >
-       <property name="margin" >
-        <number>0</number>
-       </property>
-       <property name="spacing" >
-        <number>6</number>
-       </property>
-       <item>
-        <widget class="QLineEdit" name="guiNameED" />
-       </item>
-       <item>
-        <widget class="QLineEdit" name="extensionED" />
-       </item>
-       <item>
-        <widget class="QLineEdit" name="editorED" />
-       </item>
-      </layout>
-     </item>
-    </layout>
+    </widget>
    </item>
+   <item row="4" column="0" >
+    <widget class="QLabel" name="extensionLA" >
+     <property name="text" >
+      <string>E&amp;xtension:</string>
+     </property>
+     <property name="buddy" >
+      <cstring>extensionED</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="1" >
+    <widget class="QLineEdit" name="extensionED" />
+   </item>
+   <item row="9" column="1" >
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" >
+      <size>
+       <width>168</width>
+       <height>21</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="8" column="0" >
+    <widget class="QLabel" name="label" >
+     <property name="text" >
+      <string>Co&amp;pier:</string>
+     </property>
+     <property name="buddy" >
+      <cstring>copierED</cstring>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <tabstops>
-  <tabstop>formatsLW</tabstop>
+  <tabstop>formatsCB</tabstop>
+  <tabstop>formatNewPB</tabstop>
+  <tabstop>formatRemovePB</tabstop>
   <tabstop>documentCB</tabstop>
   <tabstop>vectorCB</tabstop>
   <tabstop>formatED</tabstop>
-  <tabstop>guiNameED</tabstop>
-  <tabstop>shortcutED</tabstop>
   <tabstop>extensionED</tabstop>
-  <tabstop>viewerED</tabstop>
+  <tabstop>shortcutED</tabstop>
   <tabstop>editorED</tabstop>
-  <tabstop>formatNewPB</tabstop>
-  <tabstop>formatModifyPB</tabstop>
+  <tabstop>viewerED</tabstop>
+  <tabstop>copierED</tabstop>
  </tabstops>
  <includes>
   <include location="local" >qt_helpers.h</include>

Reply via email to