diff --git a/src/frontends/qt4/GuiBibtex.cpp b/src/frontends/qt4/GuiBibtex.cpp index 5635660836..643469f8f3 100644 --- a/src/frontends/qt4/GuiBibtex.cpp +++ b/src/frontends/qt4/GuiBibtex.cpp @@ -60,6 +60,10 @@ GuiBibtex::GuiBibtex(GuiView & lv) 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 @@ GuiBibtex::GuiBibtex(GuiView & lv) 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::addDatabase() 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); } diff --git a/src/frontends/qt4/GuiBibtex.h b/src/frontends/qt4/GuiBibtex.h index b015cb91b7..c2df10317b 100644 --- a/src/frontends/qt4/GuiBibtex.h +++ b/src/frontends/qt4/GuiBibtex.h @@ -53,6 +53,8 @@ private Q_SLOTS: void addPressed(); void addDatabase(); void deletePressed(); + void upPressed(); + void downPressed(); void databaseChanged(); void availableChanged(); void bibEDChanged(); diff --git a/src/frontends/qt4/ui/BibtexUi.ui b/src/frontends/qt4/ui/BibtexUi.ui index 84b09ade22..7af0e605e2 100644 --- a/src/frontends/qt4/ui/BibtexUi.ui +++ b/src/frontends/qt4/ui/BibtexUi.ui @@ -25,10 +25,10 @@ 6 - + - + Add bibliography to the table of contents @@ -38,7 +38,7 @@ - + @@ -59,7 +59,7 @@ - + This bibliography section contains... @@ -81,7 +81,7 @@ - + Qt::Vertical @@ -97,7 +97,7 @@ - + Choose a style file @@ -110,7 +110,7 @@ - + Choose a style file @@ -126,7 +126,7 @@ - + Qt::Vertical @@ -186,7 +186,7 @@ - + 0 @@ -235,7 +235,7 @@ - + @@ -256,6 +256,26 @@ + + + + Move the selected database upwards in the list + + + &Up + + + + + + + Move the selected database downwards in the list + + + Do&wn + + +