X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiBranches.cpp;h=c79a42def221ba4cc45b4d27325ff88ee1b8dad6;hb=59e0cb8f85f0d2f985b31532dd3308315659c662;hp=b3af3ed2936cb9f9ca0d979e7d1da38dd94b4684;hpb=1704c727de05dcb5eb6acba1c2cda85b5991f458;p=lyx.git diff --git a/src/frontends/qt4/GuiBranches.cpp b/src/frontends/qt4/GuiBranches.cpp index b3af3ed293..c79a42def2 100644 --- a/src/frontends/qt4/GuiBranches.cpp +++ b/src/frontends/qt4/GuiBranches.cpp @@ -49,7 +49,10 @@ GuiBranches::GuiBranches(QWidget * parent) branchesTW->headerItem()->setText(0, qt_("Branch")); branchesTW->headerItem()->setText(1, qt_("Activated")); branchesTW->headerItem()->setText(2, qt_("Color")); + branchesTW->headerItem()->setText(3, qt_("Filename Suffix")); branchesTW->setSortingEnabled(true); + branchesTW->resizeColumnToContents(1); + branchesTW->resizeColumnToContents(2); undef_ = new BranchesUnknownDialog(this); undef_bc_.setPolicy(ButtonPolicy::OkCancelPolicy); @@ -67,6 +70,8 @@ GuiBranches::GuiBranches(QWidget * parent) undef_, SLOT(accept())); connect(undef_->cancelPB, SIGNAL(clicked()), undef_, SLOT(reject())); + + newBranchLE->setValidator(new NoNewLineValidator(newBranchLE)); } void GuiBranches::update(BufferParams const & params) @@ -101,6 +106,7 @@ void GuiBranches::updateView() coloritem.fill(itemcolor); newItem->setIcon(2, QIcon(coloritem)); } + newItem->setText(3, it->hasFileNameSuffix() ? qt_("Yes") : qt_("No")); // restore selected branch if (bname == sel_branch) { branchesTW->setCurrentItem(newItem); @@ -114,6 +120,7 @@ void GuiBranches::updateView() renamePB->setEnabled(have_sel); colorPB->setEnabled(have_sel); activatePB->setEnabled(have_sel); + suffixPB->setEnabled(have_sel); // emit signal changed(); } @@ -193,12 +200,20 @@ void GuiBranches::on_activatePB_pressed() } +void GuiBranches::on_suffixPB_pressed() +{ + toggleSuffix(branchesTW->currentItem()); +} + + void GuiBranches::on_branchesTW_itemDoubleClicked(QTreeWidgetItem * item, int col) { if (col < 2) toggleBranch(item); - else + else if (col == 2) toggleColor(item); + else if (col == 3) + toggleSuffix(item); } @@ -210,6 +225,7 @@ void GuiBranches::on_branchesTW_itemSelectionChanged() renamePB->setEnabled(have_sel); colorPB->setEnabled(have_sel); activatePB->setEnabled(have_sel); + suffixPB->setEnabled(have_sel); } @@ -222,9 +238,8 @@ void GuiBranches::toggleBranch(QTreeWidgetItem * item) if (sel_branch.isEmpty()) return; - bool const selected = (item->text(1) == qt_("Yes")); Branch * branch = branchlist_.find(qstring_to_ucs4(sel_branch)); - if (branch && branch->setSelected(!selected)) { + if (branch && branch->setSelected(!branch->isSelected())) { newBranchLE->clear(); updateView(); } @@ -263,6 +278,24 @@ void GuiBranches::toggleColor(QTreeWidgetItem * item) } +void GuiBranches::toggleSuffix(QTreeWidgetItem * item) +{ + if (item == 0) + return; + + QString sel_branch = item->text(0); + if (sel_branch.isEmpty()) + return; + + Branch * branch = branchlist_.find(qstring_to_ucs4(sel_branch)); + if (branch) { + branch->setFileNameSuffix(!branch->hasFileNameSuffix()); + newBranchLE->clear(); + updateView(); + } +} + + void GuiBranches::on_unknownPB_pressed() { undef_->branchesLW->clear();