Style cleanup and tex code display bug correction.

* bigleft, bigright: move empty item from last to first to synchronize it with GUI representation
* fix_name(): add FIXME for Enrico
* updateTeXCode():
  - move C-style string declaration.
  - simplify empty string  logic.





git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17848 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-04-18 09:44:24 +00:00
parent 3f3f7c234f
commit 7a3600ac0a

View File

@ -36,16 +36,18 @@ namespace frontend {
namespace { namespace {
QString const bigleft[] = {"bigl", "Bigl", "biggl", "Biggl", ""}; QString const bigleft[] = {"", "bigl", "Bigl", "biggl", "Biggl"};
QString const bigright[] = {"bigr", "Bigr", "biggr", "Biggr", ""}; QString const bigright[] = {"", "bigr", "Bigr", "biggr", "Biggr"};
char const * const biggui[] = {N_("big[[delimiter size]]"), N_("Big[[delimiter size]]"), char const * const biggui[] = {N_("big[[delimiter size]]"), N_("Big[[delimiter size]]"),
N_("bigg[[delimiter size]]"), N_("Bigg[[delimiter size]]"), ""}; N_("bigg[[delimiter size]]"), N_("Bigg[[delimiter size]]"), ""};
// FIXME: It might be better to fix the big delim LFUN to not require
// additional '\' prefix.
QString fix_name(QString const & str, bool big) QString fix_name(QString const & str, bool big)
{ {
if (str.isEmpty()) if (str.isEmpty())
@ -134,53 +136,42 @@ QDelimiterDialog::QDelimiterDialog(QMathDelimiter * form)
void QDelimiterDialog::updateTeXCode(int size) void QDelimiterDialog::updateTeXCode(int size)
{ {
QString left_str; bool const bigsize = size != 0;
QString right_str;
QString bigl;
QString bigr;
QString code_str;
bool bigsize = size != 0;
left_str = fix_name(leftLW->currentItem()->toolTip(), bigsize); QString left_str = fix_name(leftLW->currentItem()->toolTip(), bigsize);
right_str = fix_name(rightLW->currentItem()->toolTip(), bigsize); QString right_str = fix_name(rightLW->currentItem()->toolTip(), bigsize);
if (!bigsize) if (!bigsize)
tex_code_ = left_str + ' ' + right_str; tex_code_ = left_str + ' ' + right_str;
else { else {
tex_code_ = bigleft[size - 1] + ' ' tex_code_ = bigleft[size] + ' '
+ left_str + ' ' + left_str + ' '
+ bigright[size - 1] + ' ' + bigright[size] + ' '
+ right_str; + right_str;
} }
// generate TeX-code // Generate TeX-code for GUI display.
// FIXME: Instead of reconstructing the TeX code it would be nice to
// FIXME: retrieve the LateX code directly from mathed.
// In all cases, we want the '\' prefix if needed, so we pass 'true'
// to fix_name.
left_str = fix_name(leftLW->currentItem()->toolTip(), true); left_str = fix_name(leftLW->currentItem()->toolTip(), true);
right_str = fix_name(rightLW->currentItem()->toolTip(), true); right_str = fix_name(rightLW->currentItem()->toolTip(), true);
if (bigsize == true) { QString code_str;
bigl = "\\" + bigleft[size];
bigr = "\\" + bigright[size];
}
if (!bigsize) if (!bigsize)
code_str = "TeX-Code: \\left" + left_str + ' ' + "\\right" + right_str; code_str = "\\left" + left_str + " \\right" + right_str;
else { else {
// There is nothing in the TeX-code when the delimiter is "None" // There should be nothing in the TeX-code when the delimiter is "None".
if (left_str == ".") { if (left_str != ".")
left_str = ""; code_str = "\\" + bigleft[size] + left_str + ' ';
bigl = ""; if (right_str != ".")
} code_str += "\\" + bigright[size] + right_str;
if (right_str == ".") {
right_str = "";
bigr = "";
}
code_str = "TeX-Code: " + bigl
+ left_str + ' '
+ bigr
+ right_str;
} }
texCodeL->setText(code_str); texCodeL->setText("TeX-Code: " + code_str);
} }
void QDelimiterDialog::on_insertPB_clicked() void QDelimiterDialog::on_insertPB_clicked()
{ {
if (sizeCO->currentIndex() == 0) if (sizeCO->currentIndex() == 0)
@ -235,6 +226,8 @@ void QDelimiterDialog::on_matchCB_stateChanged(int state)
{ {
if (state == Qt::Checked) if (state == Qt::Checked)
on_leftLW_currentRowChanged(leftLW->currentRow()); on_leftLW_currentRowChanged(leftLW->currentRow());
updateTeXCode(sizeCO->currentIndex());
} }