#include "GuiBranches.h"
-#include "ControlDocument.h"
+#include "ColorCache.h"
#include "GuiApplication.h"
#include "Validator.h"
#include "qt_helpers.h"
+#include "ui_BranchesUnknownUi.h"
+
+#include "Buffer.h"
#include "BufferParams.h"
#include "support/lstrings.h"
+#include <QListWidget>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QPixmap>
namespace frontend {
-GuiBranches::GuiBranches(QWidget * parent, Qt::WFlags f)
- : QWidget(parent, f)
+GuiBranches::GuiBranches(QWidget * parent)
+ : QWidget(parent)
{
setupUi(this);
branchesTW->setColumnCount(3);
branchesTW->headerItem()->setText(1, qt_("Activated"));
branchesTW->headerItem()->setText(2, qt_("Color"));
branchesTW->setSortingEnabled(true);
+
+ undef_ = new BranchesUnknownDialog(this);
+ undef_bc_.setPolicy(ButtonPolicy::OkCancelPolicy);
+ undef_bc_.setCancel(undef_->cancelPB);
+
+ connect(undef_->branchesLW, SIGNAL(itemSelectionChanged()),
+ this, SLOT(unknownBranchSelChanged()));
+ connect(undef_->addSelectedPB, SIGNAL(clicked()),
+ this, SLOT(addUnknown()));
+ connect(undef_->addAllPB, SIGNAL(clicked()),
+ this, SLOT(addAllUnknown()));
+ connect(undef_->addSelectedPB, SIGNAL(clicked()),
+ undef_, SLOT(accept()));
+ connect(undef_->addAllPB, SIGNAL(clicked()),
+ undef_, SLOT(accept()));
+ connect(undef_->cancelPB, SIGNAL(clicked()),
+ undef_, SLOT(reject()));
}
void GuiBranches::update(BufferParams const & params)
for (; it != end; ++it) {
QTreeWidgetItem * newItem = new QTreeWidgetItem(branchesTW);
- QString const bname = toqstr(it->getBranch());
+ QString const bname = toqstr(it->branch());
newItem->setText(0, bname);
+ newItem->setText(1, it->isSelected() ? qt_("Yes") : qt_("No"));
- QString const sel = it->getSelected() ? qt_("Yes") : qt_("No");
- newItem->setText(1, sel);
-
- QColor const itemcolor = rgb2qcolor(it->getColor());
+ QColor const itemcolor = rgb2qcolor(it->color());
if (itemcolor.isValid()) {
QPixmap coloritem(30, 10);
coloritem.fill(itemcolor);
branchesTW->setItemSelected(newItem, true);
}
}
+ unknownPB->setEnabled(!unknown_branches_.isEmpty());
// emit signal
changed();
}
return;
docstring current_branch = qstring_to_ucs4(sel_branch);
- Branch * branch =
- branchlist_.find(current_branch);
+ Branch * branch = branchlist_.find(current_branch);
if (!branch)
return;
- QColor const initial = rgb2qcolor(branch->getColor());
+ QColor const initial = rgb2qcolor(branch->color());
QColor ncol = QColorDialog::getColor(initial, qApp->focusWidget());
if (!ncol.isValid())
return;
updateView();
}
+
+void GuiBranches::on_unknownPB_pressed()
+{
+ undef_->branchesLW->clear();
+ for (int i = 0; i != unknown_branches_.count(); ++i) {
+ if (branchesTW->findItems(unknown_branches_[i], Qt::MatchExactly, 0).empty())
+ undef_->branchesLW->addItem(unknown_branches_[i]);
+ }
+ unknownBranchSelChanged();
+ undef_->exec();
+}
+
+
+void GuiBranches::addUnknown()
+{
+ QList<QListWidgetItem *> selItems =
+ undef_->branchesLW->selectedItems();
+
+ QList<QListWidgetItem *>::const_iterator it = selItems.begin();
+ for (it ; it != selItems.end() ; ++it) {
+ QListWidgetItem const * new_branch = *it;
+ if (new_branch) {
+ branchlist_.add(qstring_to_ucs4(new_branch->text()));
+ updateView();
+ }
+ }
+}
+
+
+void GuiBranches::addAllUnknown()
+{
+ undef_->branchesLW->selectAll();
+ addUnknown();
+}
+
+
+void GuiBranches::unknownBranchSelChanged()
+{
+ undef_->addSelectedPB->setEnabled(
+ !undef_->branchesLW->selectedItems().isEmpty());
+}
+
+
} // namespace frontend
} // namespace lyx
-#include "GuiBranches_moc.cpp"
+#include "moc_GuiBranches.cpp"