On Sat, 12 Jan 2008, Jürgen Spitzmüller wrote: > Please send a patch for branch. The patch looks straightforward enough, and > the feature you're implementing is something I have been missing myself as > well.
Please have a look at the attached patch (against lyx-1.5 r22509). The main difference to -devel is that I don't add deletePB/upPB/downPB to the BCView's readOnly list anymore. This is because the enabled state of these buttons depends on more than just the underlying buffer's read only state, and is handled in QBibtexDialog::databaseChanged() with these additional conditions. The -devel patch probably should be adapted, too. Does this sound correct to you? Kind regards, Horst -- PGP-Key 0xD40E0E7A
Index: src/frontends/qt4/QBibtex.h =================================================================== --- src/frontends/qt4/QBibtex.h (revision 22509) +++ src/frontends/qt4/QBibtex.h (working copy) @@ -55,6 +55,8 @@ virtual void addPressed(); virtual void addDatabase(); virtual void deletePressed(); + virtual void upPressed(); + virtual void downPressed(); virtual void databaseChanged(); virtual void availableChanged(); void bibEDChanged(); Index: src/frontends/qt4/QBibtex.cpp =================================================================== --- src/frontends/qt4/QBibtex.cpp (revision 22509) +++ src/frontends/qt4/QBibtex.cpp (working copy) @@ -71,6 +71,10 @@ this, SLOT( browsePressed())); connect(deletePB, SIGNAL(clicked()), this, SLOT( deletePressed())); + connect(upPB, SIGNAL(clicked()), + this, SLOT( upPressed())); + connect(downPB, SIGNAL(clicked()), + this, SLOT( downPressed())); connect(styleCB, SIGNAL(editTextChanged (const QString &)), this, SLOT( change_adaptor())); connect(databaseLW, SIGNAL(itemSelectionChanged()), @@ -110,6 +114,8 @@ connect(add_->closePB, SIGNAL(clicked()), add_, SLOT(reject())); + // Make sure the delete/up/down buttons are disabled if necessary. + databaseChanged(); } @@ -221,15 +227,39 @@ void QBibtexDialog::deletePressed() { - databaseLW->takeItem(databaseLW->currentRow()); + QListWidgetItem *cur = databaseLW->takeItem(databaseLW->currentRow()); + if (cur) { + delete cur; + form_->changed(); + } +} + + +void QBibtexDialog::upPressed() +{ + int row = databaseLW->currentRow(); + QListWidgetItem *cur; + databaseLW->insertItem(row - 1, cur = databaseLW->takeItem(row)); + databaseLW->setCurrentItem(cur); form_->changed(); } +void QBibtexDialog::downPressed() +{ + int row = databaseLW->currentRow(); + QListWidgetItem *cur; + databaseLW->insertItem(row + 1, cur = databaseLW->takeItem(row)); + databaseLW->setCurrentItem(cur); + form_->changed(); +} + void QBibtexDialog::databaseChanged() { deletePB->setEnabled(!form_->readOnly() && databaseLW->currentRow() != -1); + upPB->setEnabled(!form_->readOnly() && databaseLW->count() > 1 && databaseLW->currentRow() > 0); + downPB->setEnabled(!form_->readOnly() && databaseLW->count() > 1 && databaseLW->currentRow() < databaseLW->count() - 1); } @@ -272,7 +302,9 @@ bcview().addReadOnly(dialog_->styleCB); bcview().addReadOnly(dialog_->bibtocCB); bcview().addReadOnly(dialog_->addBibPB); - bcview().addReadOnly(dialog_->deletePB); + + // Delete/Up/Down are handled with more conditions in + // QBibtexDialog::databaseChanged(). } Index: src/frontends/qt4/ui/BibtexUi.ui =================================================================== --- src/frontends/qt4/ui/BibtexUi.ui (revision 22509) +++ src/frontends/qt4/ui/BibtexUi.ui (working copy) @@ -25,10 +25,10 @@ <property name="spacing" > <number>6</number> </property> - <item rowspan="3" row="1" column="0" colspan="2" > + <item rowspan="5" row="1" column="0" colspan="2" > <widget class="QListWidget" name="databaseLW" /> </item> - <item row="7" column="0" colspan="2" > + <item row="9" column="0" colspan="2" > <widget class="QCheckBox" name="bibtocCB" > <property name="toolTip" > <string>Add bibliography to the table of contents</string> @@ -38,7 +38,7 @@ </property> </widget> </item> - <item row="6" column="0" > + <item row="8" column="0" > <widget class="QLabel" name="btPrintLA" > <property name="sizePolicy" > <sizepolicy> @@ -59,7 +59,7 @@ </property> </widget> </item> - <item row="6" column="1" > + <item row="8" column="1" > <widget class="QComboBox" name="btPrintCO" > <property name="toolTip" > <string>This bibliography section contains...</string> @@ -81,7 +81,7 @@ </item> </widget> </item> - <item rowspan="2" row="6" column="2" > + <item rowspan="2" row="8" column="2" > <spacer> <property name="orientation" > <enum>Qt::Vertical</enum> @@ -97,7 +97,7 @@ </property> </spacer> </item> - <item row="5" column="2" > + <item row="7" column="2" > <widget class="QPushButton" name="stylePB" > <property name="toolTip" > <string>Choose a style file</string> @@ -110,7 +110,7 @@ </property> </widget> </item> - <item row="5" column="0" colspan="2" > + <item row="7" column="0" colspan="2" > <widget class="QComboBox" name="styleCB" > <property name="toolTip" > <string>Choose a style file</string> @@ -126,7 +126,7 @@ </property> </widget> </item> - <item rowspan="2" row="3" column="2" > + <item rowspan="2" row="5" column="2" > <spacer> <property name="orientation" > <enum>Qt::Vertical</enum> @@ -186,7 +186,7 @@ </property> </widget> </item> - <item row="8" column="0" colspan="3" > + <item row="10" column="0" colspan="3" > <layout class="QHBoxLayout" > <property name="margin" > <number>0</number> @@ -235,7 +235,7 @@ </item> </layout> </item> - <item row="4" column="0" colspan="2" > + <item row="6" column="0" colspan="2" > <widget class="QLabel" name="styleLA" > <property name="sizePolicy" > <sizepolicy> @@ -256,6 +256,26 @@ </property> </widget> </item> + <item row="3" column="2" > + <widget class="QPushButton" name="upPB" > + <property name="toolTip" > + <string>Move the selected database upwards in the list</string> + </property> + <property name="text" > + <string>&Up</string> + </property> + </widget> + </item> + <item row="4" column="2" > + <widget class="QPushButton" name="downPB" > + <property name="toolTip" > + <string>Move the selected database downwards in the list</string> + </property> + <property name="text" > + <string>Do&wn</string> + </property> + </widget> + </item> </layout> </widget> <pixmapfunction></pixmapfunction>