#include "Buffer.h"
#include "BufferParams.h"
-#include "support/debug.h"
#include "ui_BibtexAddUi.h"
#include "qt_helpers.h"
#include "Validator.h"
#include "LyXRC.h"
-#include "support/gettext.h"
#include "ButtonPolicy.h"
+#include "support/debug.h"
+#include "support/FileFilterList.h"
#include "support/filetools.h" // changeExtension
+#include "support/gettext.h"
#include "support/lstrings.h"
-#include "support/FileFilterList.h"
#include <QPushButton>
#include <QListWidget>
#include <QCheckBox>
-#include <QCloseEvent>
#include <QLineEdit>
using namespace std;
GuiBibtex::GuiBibtex(GuiView & lv)
- : GuiCommand(lv, "bibtex")
+ : GuiCommand(lv, "bibtex", qt_("BibTeX Bibliography"))
{
setupUi(this);
- setViewTitle( _("BibTeX Bibliography"));
-
QDialog::setModal(true);
connect(okPB, SIGNAL(clicked()),
this, SLOT(downPressed()));
connect(styleCB, SIGNAL(editTextChanged(QString)),
this, SLOT(change_adaptor()));
- connect(databaseLW, SIGNAL(itemSelectionChanged()),
+ connect(databaseLW, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this, SLOT(databaseChanged()));
connect(bibtocCB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
this, SLOT(addDatabase()));
connect(add_->bibLW, SIGNAL(itemActivated(QListWidgetItem *)),
add_, SLOT(accept()));
- connect(add_->bibLW, SIGNAL(itemSelectionChanged()),
+ connect(add_->bibLW, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this, SLOT(availableChanged()));
connect(add_->browsePB, SIGNAL(clicked()),
this, SLOT(browseBibPressed()));
bc().addReadOnly(styleCB);
bc().addReadOnly(bibtocCB);
bc().addReadOnly(addBibPB);
- bc().addReadOnly(deletePB);
+ // Delete/Up/Down are handled with more conditions in
+ // databaseChanged().
// Make sure the delete/up/down buttons are disabled if necessary.
databaseChanged();
}
}
+ databaseChanged();
changed();
}
QListWidgetItem *cur = databaseLW->takeItem(databaseLW->currentRow());
if (cur) {
delete cur;
+ databaseChanged();
changed();
}
}
void GuiBibtex::upPressed()
{
int row = databaseLW->currentRow();
- QListWidgetItem *cur;
- databaseLW->insertItem(row - 1, cur = databaseLW->takeItem(row));
+ QListWidgetItem *cur = databaseLW->takeItem(row);
+ databaseLW->insertItem(row - 1, cur);
databaseLW->setCurrentItem(cur);
changed();
}
void GuiBibtex::downPressed()
{
int row = databaseLW->currentRow();
- QListWidgetItem *cur;
- databaseLW->insertItem(row + 1, cur = databaseLW->takeItem(row));
+ QListWidgetItem *cur = databaseLW->takeItem(row);
+ databaseLW->insertItem(row + 1, cur);
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);
+ bool readOnly = isBufferReadonly();
+ int count = databaseLW->count();
+ int row = databaseLW->currentRow();
+ deletePB->setEnabled(!readOnly && row != -1);
+ upPB->setEnabled(!readOnly && count > 1 && row > 0);
+ downPB->setEnabled(!readOnly && count > 1 && row < count - 1);
}
}
-void GuiBibtex::closeEvent(QCloseEvent *e)
-{
- slotClose();
- e->accept();
-}
-
-
void GuiBibtex::updateContents()
{
bool bibtopic = usingBibtopic();