Uwe Stöhr wrote:
> Please hold on. I propose instead to display the full TeX code in any
case as discussed in
> bugzilla. I'll work on a patch.
I can't hold it, because this is so simple with the new infrastructure
of my patch, here it is again - with displaying "\right" and "\left".
That won't work with big delimiters. Besides, that's not what I was
talking about, I meant to display the full LFUN argument.
See patch.
Abdel.
Index: QDelimiterDialog.C
===================================================================
--- QDelimiterDialog.C (revision 17814)
+++ QDelimiterDialog.C (working copy)
@@ -36,19 +36,19 @@
namespace {
-char const * const bigleft[] = {"bigl", "Bigl", "biggl", "Biggl", ""};
+QString const bigleft[] = {"bigl", "Bigl", "biggl", "Biggl", ""};
-char const * 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]]"),
N_("bigg[[delimiter size]]"), N_("Bigg[[delimiter size]]"), ""};
-string fix_name(string const & str, bool big)
+QString fix_name(QString const & str, bool big)
{
- if (str.empty())
+ if (str.isEmpty())
return ".";
if (!big || str == "(" || str == ")" || str == "[" || str == "]"
|| str == "|" || str == "/")
@@ -91,7 +91,6 @@
setupUi(this);
connect(closePB, SIGNAL(clicked()), this, SLOT(accept()));
- connect(insertPB, SIGNAL(clicked()), this, SLOT(insertClicked()));
setWindowTitle(qt_("LyX: Delimiters"));
setFocusProxy(leftLW);
@@ -133,41 +132,63 @@
}
-void QDelimiterDialog::insertClicked()
+void QDelimiterDialog::updateTeXCode(int size)
{
- string left_str;
- string right_str;
+ QString left_str;
+ QString right_str;
+ bool bigsize = size != 0;
if (leftLW->currentRow() < leftLW->count() - 1)
- left_str = fromqstr(leftLW->currentItem()->toolTip());
+ left_str = fix_name(leftLW->currentItem()->toolTip(), bigsize);
if (rightLW->currentRow() < rightLW->count() - 1)
- right_str = fromqstr(rightLW->currentItem()->toolTip());
+ right_str = fix_name(rightLW->currentItem()->toolTip(),
bigsize);
- int const size_ = sizeCO->currentIndex();
- if (size_ == 0) {
- form_->controller().dispatchDelim(
- fix_name(left_str, false) + ' ' +
- fix_name(right_str, false));
- } else {
- std::ostringstream os;
- os << '"' << bigleft[size_ - 1] << "\" \""
+ if (!bigsize)
+ tex_code_ = left_str + ' ' + right_str;
+ else {
+ tex_code_ = bigleft[size - 1] + ' '
+ + left_str + ' '
+ + bigright[size - 1] + ' '
+ + right_str;
+ }
+/*
+ os << '"' << bigleft[size_ - 1] << "\" \""
<< fix_name(left_str, true) << "\" \""
<< bigright[size_ - 1] << "\" \""
<< fix_name(right_str, true) << '"';
- form_->controller().dispatchBigDelim(os.str());
+*/
+
+ texCodeL->setText(tex_code_);
+}
+
+
+void QDelimiterDialog::on_insertPB_clicked()
+{
+ if (sizeCO->currentIndex() == 0)
+ form_->controller().dispatchDelim(fromqstr(tex_code_));
+ else {
+ QString command = '"' + tex_code_ + '"';
+ command.replace(' ', "\" \"");
+ form_->controller().dispatchBigDelim(fromqstr(command));
}
}
+void QDelimiterDialog::on_sizeCO_activated(int index)
+{
+ updateTeXCode(index);
+}
+
+
void QDelimiterDialog::on_leftLW_itemActivated(QListWidgetItem *)
{
- insertClicked();
+ on_insertPB_clicked();
accept();
}
void QDelimiterDialog::on_rightLW_itemActivated(QListWidgetItem *)
{
- insertClicked();
+ on_insertPB_clicked();
accept();
}
@@ -177,11 +198,7 @@
if (matchCB->isChecked())
rightLW->setCurrentRow(item);
- // Display the associated TeX name.
- if (leftLW->currentRow() == leftLW->count() - 1)
- texCodeL->clear();
- else
- texCodeL->setText("TeX code: \\" +
leftLW->currentItem()->toolTip());
+ updateTeXCode(sizeCO->currentIndex());
}
@@ -190,11 +207,7 @@
if (matchCB->isChecked())
leftLW->setCurrentRow(item);
- // Display the associated TeX name.
- if (rightLW->currentRow() == leftLW->count() - 1)
- texCodeL->clear();
- else
- texCodeL->setText("TeX code: \\" +
rightLW->currentItem()->toolTip());
+ updateTeXCode(sizeCO->currentIndex());
}
Index: QDelimiterDialog.h
===================================================================
--- QDelimiterDialog.h (revision 17814)
+++ QDelimiterDialog.h (working copy)
@@ -33,12 +33,17 @@
void on_leftLW_currentRowChanged(int);
void on_rightLW_currentRowChanged(int);
void on_matchCB_stateChanged(int);
- void insertClicked();
+ void on_insertPB_clicked();
+ void on_sizeCO_activated(int);
private:
///
char_type doMatch(char_type const symbol) const;
+ ///
+ void updateTeXCode(int size);
/// owning form
QMathDelimiter * form_;
+ /// TeX code that will be inserted.
+ QString tex_code_;
};
} // namespace frontend