connect(textAfterED, SIGNAL(textChanged(QString)),
this, SLOT(updateStyles()));
connect(textBeforeED, SIGNAL(returnPressed()),
- this, SLOT(on_okPB_clicked()));
+ this, SLOT(on_buttonBox_accepted()));
connect(textAfterED, SIGNAL(returnPressed()),
- this, SLOT(on_okPB_clicked()));
+ this, SLOT(on_buttonBox_accepted()));
selectionManager = new GuiSelectionManager(this, availableLV, selectedLV,
addPB, deletePB, upPB, downPB, &available_model_, &selected_model_, 1);
connect(selectionManager, SIGNAL(updateHook()),
this, SLOT(updateControls()));
connect(selectionManager, SIGNAL(okHook()),
- this, SLOT(on_okPB_clicked()));
+ this, SLOT(on_buttonBox_accepted()));
connect(filter_, SIGNAL(rightButtonClicked()),
this, SLOT(resetFilter()));
selectedLV->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
#endif
+ selectedLV->setToolTip(qt_("Ordered list of all cited references.\n"
+ "You can reorder, add and remove references with the buttons on the left."));
setFocusProxy(filter_);
}
void GuiCitation::showEvent(QShowEvent * e)
{
- filter_->clear();
+ if (!filter_->text().isEmpty())
+ filterPressed();
availableLV->setFocus();
DialogView::showEvent(e);
}
-void GuiCitation::on_okPB_clicked()
+void GuiCitation::on_buttonBox_accepted()
{
applyView();
clearSelection();
}
-void GuiCitation::on_cancelPB_clicked()
+void GuiCitation::on_buttonBox_rejected()
{
clearSelection();
hide();
}
-void GuiCitation::on_applyPB_clicked()
+void GuiCitation::on_buttonBox_clicked(QAbstractButton * button)
{
- applyView();
-}
-
-
-void GuiCitation::on_restorePB_clicked()
-{
- init();
- updateFilterHint();
- filterPressed();
+ switch (buttonBox->standardButton(button)) {
+ case QDialogButtonBox::Apply:
+ applyView();
+ break;
+ case QDialogButtonBox::Reset:
+ init();
+ updateFilterHint();
+ filterPressed();
+ break;
+ default:
+ break;
+ }
}
starredCB->setToolTip(qt_("Always list all authors (rather than using \"et al.\"), "
"if the current citation style supports this."));
}
+ if (availableLV->selectionModel()->selectedIndexes().isEmpty())
+ availableLV->setToolTip(qt_("All references available for citing."));
+ else
+ availableLV->setToolTip(qt_("All references available for citing.\n"
+ "To add the selected one, hit Add, press Enter or double-click.\n"
+ "Hit Ctrl-Enter to add and close the dialog."));
}
void GuiCitation::setButtons()
{
int const srows = selectedLV->model()->rowCount();
- applyPB->setEnabled(srows > 0);
- okPB->setEnabled(srows > 0);
+ buttonBox->button(QDialogButtonBox::Apply)->setEnabled(srows > 0);
+ buttonBox->button(QDialogButtonBox::Ok)->setEnabled(srows > 0);
}
void GuiCitation::updateFilterHint()
{
- QString const hint = instant_->isChecked() ?
+ QString hint = instant_->isChecked() ?
qt_("Enter string to filter the list of available citations") :
qt_("Enter string to filter the list of available citations and press <Enter>");
+ hint += qt_("\nThe down arrow key will get you into the list of filtered citations.");
filter_->setToolTip(hint);
}
for (int i = 0; i != selected_model_.rowCount(); ++i) {
QStandardItem const * key = selected_model_.item(i, 1);
QStandardItem const * post = selected_model_.item(i, 2);
- if (key && post)
+ if (key && post && !key->text().isEmpty() && !post->text().isEmpty())
res.push_back(qstring_to_ucs4(key->text()) + " " + qstring_to_ucs4(post->text()));
}
return res;
} else
availableLV->setFocus();
- applyPB->setEnabled(false);
- okPB->setEnabled(false);
+ buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
+ buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
}