From: Jürgen Spitzmüller Date: Sat, 11 Jul 2009 06:29:57 +0000 (+0000) Subject: * GuiBranches.cpp: X-Git-Tag: 2.0.0~6105 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=eab8801afe8059d3315305bf0ce7f430a9173099;p=lyx.git * GuiBranches.cpp: * GuiIndices.{cpp,h}: more UI polishment. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30462 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/GuiBranches.cpp b/src/frontends/qt4/GuiBranches.cpp index 08bca16984..9f73cd4c7c 100644 --- a/src/frontends/qt4/GuiBranches.cpp +++ b/src/frontends/qt4/GuiBranches.cpp @@ -112,6 +112,8 @@ void GuiBranches::updateView() !branchesTW->selectedItems().isEmpty(); removePB->setEnabled(have_sel); renamePB->setEnabled(have_sel); + colorPB->setEnabled(have_sel); + activatePB->setEnabled(have_sel); // emit signal changed(); } @@ -205,6 +207,8 @@ void GuiBranches::on_branchesTW_itemSelectionChanged() !branchesTW->selectedItems().isEmpty(); removePB->setEnabled(have_sel); renamePB->setEnabled(have_sel); + colorPB->setEnabled(have_sel); + activatePB->setEnabled(have_sel); } diff --git a/src/frontends/qt4/GuiIndices.cpp b/src/frontends/qt4/GuiIndices.cpp index 5e8c1b3d91..5ab141c70c 100644 --- a/src/frontends/qt4/GuiIndices.cpp +++ b/src/frontends/qt4/GuiIndices.cpp @@ -123,6 +123,11 @@ void GuiIndices::updateView() indicesTW->setItemSelected(newItem, true); } } + bool const have_sel = + !indicesTW->selectedItems().isEmpty(); + removePB->setEnabled(have_sel); + renamePB->setEnabled(have_sel); + colorPB->setEnabled(have_sel); // emit signal changed(); } @@ -196,8 +201,11 @@ void GuiIndices::on_renamePB_clicked() 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(); @@ -216,6 +224,16 @@ void GuiIndices::on_indicesTW_itemDoubleClicked(QTreeWidgetItem * item, int /*co } +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()); @@ -224,13 +242,16 @@ void GuiIndices::on_colorPB_clicked() 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(); } diff --git a/src/frontends/qt4/GuiIndices.h b/src/frontends/qt4/GuiIndices.h index 66cea923ef..bd318ff72f 100644 --- a/src/frontends/qt4/GuiIndices.h +++ b/src/frontends/qt4/GuiIndices.h @@ -50,6 +50,7 @@ protected Q_SLOTS: void on_renamePB_clicked(); void on_removePB_pressed(); void on_indicesTW_itemDoubleClicked(QTreeWidgetItem *, int); + void on_indicesTW_itemSelectionChanged(); void on_colorPB_clicked(); void on_multipleIndicesCB_toggled(bool);