indexCO->clear();
indexCO->addItem(qt_("Default"), QString("default"));
- for (vector<string>::const_iterator it = lyxrc.index_alternatives.begin();
+ for (set<string>::const_iterator it = lyxrc.index_alternatives.begin();
it != lyxrc.index_alternatives.end(); ++it) {
QString const command = toqstr(*it).left(toqstr(*it).indexOf(" "));
indexCO->addItem(command, command);
indicesTW->setItemSelected(newItem, true);
}
}
+ indicesTW->resizeColumnToContents(0);
+ bool const have_sel =
+ !indicesTW->selectedItems().isEmpty();
+ removePB->setEnabled(have_sel);
+ renamePB->setEnabled(have_sel);
+ colorPB->setEnabled(have_sel);
// emit signal
changed();
}
string const index_command =
fromqstr(indexCO->itemData(
indexCO->currentIndex()).toString());
- if (index_command == "default")
+ string const index_options = fromqstr(indexOptionsED->text());
+ if (index_command == "default" || index_options.empty())
params.index_command = index_command;
else
- params.index_command = index_command + " "
- + fromqstr(indexOptionsED->text());
+ params.index_command = index_command + " " + index_options;
}
sel_index = selItem->text(0);
if (!sel_index.isEmpty()) {
docstring newname;
+ docstring const oldname = qstring_to_ucs4(sel_index);
bool success = false;
- if (Alert::askForText(newname, _("Enter new index name"))) {
+ if (Alert::askForText(newname, _("Enter new index name"), oldname)) {
+ if (newname.empty() || oldname == newname)
+ return;
success = indiceslist_.rename(qstring_to_ucs4(sel_index), newname);
newIndexLE->clear();
updateView();
+ if (!success)
+ Alert::error(_("Renaming failed"),
+ _("The index could not be renamed. "
+ "Check if the new name already exists."));
}
- if (!success)
- Alert::error(_("Renaming failed"),
- _("The index could not be renamed. "
- "Check if the new name already exists."));
}
}
}
+void GuiIndices::on_indicesTW_itemSelectionChanged()
+{
+ bool const have_sel =
+ !indicesTW->selectedItems().isEmpty();
+ removePB->setEnabled(have_sel);
+ renamePB->setEnabled(have_sel);
+ colorPB->setEnabled(have_sel);
+}
+
+
void GuiIndices::on_colorPB_clicked()
{
toggleColor(indicesTW->currentItem());
void GuiIndices::on_multipleIndicesCB_toggled(bool const state)
{
+ bool const have_sel =
+ !indicesTW->selectedItems().isEmpty();
indicesTW->setEnabled(state);
newIndexLE->setEnabled(state);
newIndexLA->setEnabled(state);
addIndexPB->setEnabled(state);
availableLA->setEnabled(state);
- removePB->setEnabled(state);
- colorPB->setEnabled(state);
+ removePB->setEnabled(state && have_sel);
+ colorPB->setEnabled(state && have_sel);
+ renamePB->setEnabled(state && have_sel);
// emit signal
changed();
}