On Sat, 12 Jan 2008, Jürgen Spitzmüller wrote: > Horst Schirmeier wrote: > > The attached patch adds reordering capabilities to the GuiBibtex > > dialog, ie. adds "Up"/"Down" buttons which move bibtex entries up/down > > in the list. > > Looks good (and good idea indeed). Probably also for the 1.5.x branch.
Thanks :-) I'd be happy to see that in 1.5.x, too. The patch does not apply unmodified, though -- if you want a lyx-1.5 version, just contact me. > Could you send the patch as an attachment, not inline? The patch is attached. For future cases -- are attachments generally preferred to inline patches on the lyx-devel ML? Kind regards, Horst -- PGP-Key 0xD40E0E7A
Index: src/frontends/qt4/GuiBibtex.h =================================================================== --- src/frontends/qt4/GuiBibtex.h (revision 22496) +++ src/frontends/qt4/GuiBibtex.h (working copy) @@ -53,6 +53,8 @@ void addPressed(); void addDatabase(); void deletePressed(); + void upPressed(); + void downPressed(); void databaseChanged(); void availableChanged(); void bibEDChanged(); Index: src/frontends/qt4/GuiBibtex.cpp =================================================================== --- src/frontends/qt4/GuiBibtex.cpp (revision 22496) +++ src/frontends/qt4/GuiBibtex.cpp (working copy) @@ -60,6 +60,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(QString)), this, SLOT(change_adaptor())); connect(databaseLW, SIGNAL(itemSelectionChanged()), @@ -103,6 +107,9 @@ bc().addReadOnly(bibtocCB); bc().addReadOnly(addBibPB); bc().addReadOnly(deletePB); + + // Make sure the delete/up/down buttons are disabled if necessary. + databaseChanged(); } @@ -225,15 +232,39 @@ void GuiBibtex::deletePressed() { - databaseLW->takeItem(databaseLW->currentRow()); + QListWidgetItem *cur = databaseLW->takeItem(databaseLW->currentRow()); + if (cur) { + delete cur; + changed(); + } +} + + +void GuiBibtex::upPressed() +{ + int row = databaseLW->currentRow(); + QListWidgetItem *cur; + databaseLW->insertItem(row - 1, cur = databaseLW->takeItem(row)); + databaseLW->setCurrentItem(cur); changed(); } +void GuiBibtex::downPressed() +{ + int row = databaseLW->currentRow(); + QListWidgetItem *cur; + databaseLW->insertItem(row + 1, cur = databaseLW->takeItem(row)); + databaseLW->setCurrentItem(cur); + changed(); +} + void GuiBibtex::databaseChanged() { deletePB->setEnabled(!isBufferReadonly() && databaseLW->currentRow() != -1); + upPB->setEnabled(!isBufferReadonly() && databaseLW->count() > 1 && databaseLW->currentRow() > 0); + downPB->setEnabled(!isBufferReadonly() && databaseLW->count() > 1 && databaseLW->currentRow() < databaseLW->count() - 1); } Index: src/frontends/qt4/ui/BibtexUi.ui =================================================================== --- src/frontends/qt4/ui/BibtexUi.ui (revision 22496) +++ 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>