#include <QPixmap>
#include <QCheckBox>
-
+#include <QListWidgetItem>
#include <sstream>
namespace {
-char const * delim[] = {
+string const delim[] = {
"(", ")", "{", "}", "[", "]",
"lceil", "rceil", "lfloor", "rfloor", "langle", "rangle",
"uparrow", "Uparrow", "downarrow", "Downarrow",
connect(insertPB, SIGNAL(clicked()), this, SLOT(insertClicked()));
setWindowTitle(qt_("LyX: Delimiters"));
-
- for (size_t i = 0; i != 21; ++i)
- delimiters_.append(toqstr(delim[i]));
+ setFocusProxy(leftLW);
// The last element is the empty one.
- size_t end = delimiters_.size() - 1;
- for (size_t i = 0; i != end; ++i) {
- if (delimiters_[i].size() == 1) {
- leftCO->addItem(delimiters_[i]);
- rightCO->addItem(delimiters_[i]);
+ for (size_t i = 0; !delim[i].empty(); ++i) {
+ QString const left_d = toqstr(delim[i]);
+ QString const right_d = do_match(left_d);
+ if (left_d.size() == 1) {
+ leftLW->addItem(left_d);
+ rightLW->addItem(right_d);
} else {
- QPixmap pm = QPixmap(toqstr(find_xpm(fromqstr(delimiters_[i]))));
- leftCO->addItem(QIcon(pm), delimiters_[i]);
- rightCO->addItem(QIcon(pm), delimiters_[i]);
+ QPixmap left_pm = QPixmap(toqstr(find_xpm(fromqstr(left_d))));
+ leftLW->addItem(new QListWidgetItem(QIcon(left_pm), left_d));
+ QPixmap right_pm = QPixmap(toqstr(find_xpm(fromqstr(right_d))));
+ rightLW->addItem(new QListWidgetItem(QIcon(right_pm), right_d));
}
}
- leftCO->addItem(qt_("(None)"));
- rightCO->addItem(qt_("(None)"));
+ leftLW->addItem(qt_("(None)"));
+ rightLW->addItem(qt_("(None)"));
sizeCO->addItem(qt_("Variable"));
for (int i = 0; *biggui[i]; ++i)
sizeCO->addItem(qt_(biggui[i]));
- on_leftCO_activated(0);
+ on_leftLW_currentRowChanged(0);
}
void QDelimiterDialog::insertClicked()
{
- QString const left_ = delimiters_[leftCO->currentIndex()];
- QString const right_ = delimiters_[rightCO->currentIndex()];
+ QString const left_ = (leftLW->currentRow() < leftLW->count() - 1)?
+ leftLW->currentItem()->text(): QString();
+ QString const right_ = (rightLW->currentRow() < rightLW->count() - 1)?
+ rightLW->currentItem()->text(): QString();
int const size_ = sizeCO->currentIndex();
if (size_ == 0) {
<< fix_name(right_, true) << '"';
form_->controller().dispatchBigDelim(os.str());
}
+}
+
+void QDelimiterDialog::on_leftLW_itemActivated(QListWidgetItem *)
+{
+ if (!matchCB->isChecked())
+ return;
+
+ insertClicked();
+ accept();
}
-void QDelimiterDialog::on_leftCO_activated(int item)
+void QDelimiterDialog::on_leftLW_currentRowChanged(int item)
{
- if (matchCB->isChecked()) {
- QString const match = do_match(delimiters_[item]);
- rightCO->setCurrentIndex(delimiters_.indexOf(match));
- }
+ if (matchCB->isChecked())
+ rightLW->setCurrentRow(item);
}
-void QDelimiterDialog::on_rightCO_activated(int item)
+void QDelimiterDialog::on_rightLW_currentRowChanged(int item)
{
- if (matchCB->isChecked()) {
- QString const match = do_match(delimiters_[item]);
- leftCO->setCurrentIndex(delimiters_.indexOf(match));
- }
+ if (matchCB->isChecked())
+ leftLW->setCurrentRow(item);
}
void QDelimiterDialog::on_matchCB_stateChanged(int state)
{
if (state == Qt::Checked)
- on_leftCO_activated(leftCO->currentIndex());
+ on_leftLW_currentRowChanged(leftLW->currentRow());
}
<rect>
<x>0</x>
<y>0</y>
- <width>206</width>
- <height>153</height>
+ <width>193</width>
+ <height>430</height>
</rect>
</property>
<property name="minimumSize" >
<number>6</number>
</property>
<item>
- <widget class="QComboBox" name="leftCO" >
+ <widget class="QListWidget" name="leftLW" >
<property name="sizePolicy" >
<sizepolicy>
- <hsizetype>4</hsizetype>
- <vsizetype>4</vsizetype>
+ <hsizetype>0</hsizetype>
+ <vsizetype>7</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="minimumSize" >
+ <property name="maximumSize" >
<size>
- <width>42</width>
- <height>42</height>
+ <width>110</width>
+ <height>16777215</height>
</size>
</property>
- <property name="maxVisibleItems" >
- <number>100</number>
- </property>
- <property name="sizeAdjustPolicy" >
- <enum>QComboBox::AdjustToContents</enum>
- </property>
<property name="iconSize" >
<size>
- <width>32</width>
- <height>32</height>
+ <width>16</width>
+ <height>16</height>
</size>
</property>
+ <property name="resizeMode" >
+ <enum>QListView::Adjust</enum>
+ </property>
+ <property name="spacing" >
+ <number>1</number>
+ </property>
+ <property name="currentRow" >
+ <number>-1</number>
+ </property>
</widget>
</item>
<item>
- <widget class="QComboBox" name="rightCO" >
+ <widget class="QListWidget" name="rightLW" >
<property name="sizePolicy" >
<sizepolicy>
- <hsizetype>4</hsizetype>
- <vsizetype>4</vsizetype>
+ <hsizetype>0</hsizetype>
+ <vsizetype>7</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="minimumSize" >
+ <property name="maximumSize" >
<size>
- <width>42</width>
- <height>42</height>
+ <width>110</width>
+ <height>16777215</height>
</size>
</property>
- <property name="maxVisibleItems" >
- <number>100</number>
- </property>
<property name="iconSize" >
<size>
- <width>32</width>
- <height>32</height>
+ <width>16</width>
+ <height>16</height>
</size>
</property>
+ <property name="spacing" >
+ <number>1</number>
+ </property>
</widget>
</item>
</layout>
</layout>
</widget>
<tabstops>
- <tabstop>leftCO</tabstop>
- <tabstop>rightCO</tabstop>
<tabstop>matchCB</tabstop>
<tabstop>sizeCO</tabstop>
<tabstop>insertPB</tabstop>