# # # add_file "src/model/BranchesProxyModel.cpp" # content [09db4b59b40a256d1bafaffaa2b59c2af8d01ef0] # # add_file "src/model/BranchesProxyModel.h" # content [7be64a24705c84de7df0063d2ee6c62fea02915f] # # add_file "src/view/widgets/BranchView.cpp" # content [62590eb879a129b84bd7c81464c6fba5233a6e5e] # # add_file "src/view/widgets/BranchView.h" # content [9c5e1248688a2729c1e96c6de1463ecbd906fd45] # # patch "guitone.pro" # from [21df76248280eb2b9d4674d5417cbccf327b8cde] # to [37192ca1eb8877c37f917fe5cc1e49a75b13268d] # # patch "res/forms/dialogs/changeset_browser.ui" # from [715176abd5b2dd44f77eb144f2708726635b10af] # to [acec562b32d453228b3fbc2438da26e41002a1fe] # # patch "src/model/Branches.cpp" # from [68640cc21cb8741e349be14703f4b78b101db7d7] # to [67a145d13304dbdd83a59c9db10f33cfa8f56dc5] # # patch "src/model/Branches.h" # from [aac5902d3666e210b470e5e38b242ddb453450b5] # to [f2ddb8c1991b32f53e190ae3f1e05902461196c4] # # patch "src/view/dialogs/ChangesetBrowser.cpp" # from [3a4068f00d16bb40b561f42535231705e2a3397f] # to [b0865decf7393809ac01fb964696001f2a8c90fc] # # patch "src/view/dialogs/ChangesetBrowser.h" # from [e3e968d6eb92455c2397370254a986138f2fbf80] # to [ae5ea7b80db4220b1c4f6dab9814da35a6eae401] # # patch "src/view/dialogs/CheckoutRevision.cpp" # from [4073ede5d48029eb24325788d05025d3734cfaa5] # to [08a5fb3bd73416a58393d9271b0e9f22710805d6] # # patch "src/view/dialogs/DatabaseDialogManager.cpp" # from [ed1529ba7e99b5c50809084dae59b68e567de617] # to [9fd20e3bd733cf36a534882f32eaaa7c1095c225] # # patch "src/view/dialogs/SelectRevision.cpp" # from [0b94e795626ab3b9461e25b2fd0a71867eec11d0] # to [f9db3a6293905582be8c05cf580a0d2bc37e7608] # # patch "src/view/dialogs/UpdateWorkspace.cpp" # from [7840d2b43f9dc33f63ab8af6ffb3a010bf311e9d] # to [9c46b834533239597ee91776ec1abfe9cabb422f] # ============================================================ --- src/model/BranchesProxyModel.cpp 09db4b59b40a256d1bafaffaa2b59c2af8d01ef0 +++ src/model/BranchesProxyModel.cpp 09db4b59b40a256d1bafaffaa2b59c2af8d01ef0 @@ -0,0 +1,85 @@ +/*************************************************************************** + * Copyright (C) 2010 Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + ***************************************************************************/ + +#include "BranchesProxyModel.h" +#include "vocab.h" + +BranchesProxyModel::BranchesProxyModel(QObject * parent) + : QSortFilterProxyModel(parent), showSuspended(false) +{ + // FIXME: maybe this should be configurable? + filter.setCaseSensitivity(Qt::CaseSensitive); + filter.setPatternSyntax(QRegExp::Wildcard); +} + +BranchesProxyModel::~BranchesProxyModel() {} + +bool BranchesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex & sourceParent) const +{ + QModelIndex sourceIndex = sourceModel()->index(sourceRow, 0, sourceParent); + bool acceptRow = true; + acceptRow &= showSuspended || !sourceIndex.data(Qt::UserRole).toBool(); + acceptRow &= filter.isEmpty() || indexMatchesFilter(sourceIndex); + + return acceptRow; +} + +void BranchesProxyModel::showSuspendedBranches(bool show) +{ + if (show == showSuspended) + return; + + showSuspended = show; + invalidate(); +} + +void BranchesProxyModel::filterByName(const QString & pattern) +{ + filter.setPattern(pattern); + invalidate(); +} + +// FIXME: we're basically doing this twice for each proxy model, while +// a single proxy model which does the filtering for both (sub) proxy +// models should be enough. Tweak that some time. +bool BranchesProxyModel::indexMatchesFilter(const QModelIndex & index) const +{ + QString branch = index.data(Qt::ToolTipRole).toString(); + if (filter.indexIn(branch) >= 0) + { + return true; + } + + // we always have to filter _all_ items of the view even if we only + // display a subset of them in a list-alike way, since the parents + // of a specific matched node must match as well in order to keep + // the node in + int childCount = -1; + while (true) + { + QModelIndex child = index.child(++childCount, 0); + if (!child.isValid()) + break; + + if (indexMatchesFilter(child)) + return true; + } + + return false; +} + ============================================================ --- src/model/BranchesProxyModel.h 7be64a24705c84de7df0063d2ee6c62fea02915f +++ src/model/BranchesProxyModel.h 7be64a24705c84de7df0063d2ee6c62fea02915f @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2010 Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + ***************************************************************************/ + +#ifndef BRANCHES_PROXY_MODEL_H +#define BRANCHES_PROXY_MODEL_H + +#include +#include + +class BranchesProxyModel : public QSortFilterProxyModel +{ + Q_OBJECT +public: + BranchesProxyModel(QObject *); + ~BranchesProxyModel(); + + bool filterAcceptsRow(int, const QModelIndex &) const; + +public slots: + void showSuspendedBranches(bool); + void filterByName(const QString &); + +private: + bool indexMatchesFilter(const QModelIndex &) const; + + bool showSuspended; + QRegExp filter; +}; + +#endif ============================================================ --- src/view/widgets/BranchView.cpp 62590eb879a129b84bd7c81464c6fba5233a6e5e +++ src/view/widgets/BranchView.cpp 62590eb879a129b84bd7c81464c6fba5233a6e5e @@ -0,0 +1,70 @@ +/*************************************************************************** + * Copyright (C) 2010 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + ***************************************************************************/ + +#include "BranchView.h" +#include "vocab.h" + +BranchView::BranchView(QWidget * parent) : TreeView(parent) +{ + popupMenu = new QMenu(); + + setRootIsDecorated(false); + setItemsExpandable(true); + + QAction * toggleTree = new QAction(tr("display branches as tree"), this); + toggleTree->setCheckable(true); + toggleTree->setData(toggle_tree); + popupMenu->addAction(toggleTree); + + QAction * toggleSuspended = new QAction(tr("show suspended branches"), this); + toggleSuspended->setCheckable(true); + toggleSuspended->setData(toggle_suspended); + popupMenu->addAction(toggleSuspended); + + connect( + this, SIGNAL(contextMenuRequested(const QModelIndexList &, const QPoint &)), + this, SLOT(slotContextMenuRequested(const QModelIndexList &, const QPoint &)) + ); +} + +BranchView::~BranchView() +{ + delete popupMenu; +} + +void BranchView::slotContextMenuRequested(const QModelIndexList & indexes, + const QPoint & pt) +{ + Q_UNUSED(indexes); + + QAction * act = popupMenu->exec(pt); + + if (act == 0) + return; + + if (act->data().toInt() == toggle_tree) + { + emit displayBranchesAsTree(act->isChecked()); + } + else + if (act->data().toInt() == toggle_suspended) + { + emit showSuspendedBranches(act->isChecked()); + } +} + ============================================================ --- src/view/widgets/BranchView.h 9c5e1248688a2729c1e96c6de1463ecbd906fd45 +++ src/view/widgets/BranchView.h 9c5e1248688a2729c1e96c6de1463ecbd906fd45 @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2010 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + ***************************************************************************/ + +#ifndef BRANCH_VIEW_H +#define BRANCH_VIEW_H + +#include "TreeView.h" +#include + +class BranchView : public TreeView +{ + Q_OBJECT +public: + BranchView(QWidget *); + ~BranchView(); + +signals: + void displayBranchesAsTree(bool); + void showSuspendedBranches(bool); + +private slots: + void slotContextMenuRequested(const QModelIndexList &, const QPoint &); + +private: + QMenu * popupMenu; + enum { toggle_tree, toggle_suspended } action; +}; + +#endif + ============================================================ --- guitone.pro 21df76248280eb2b9d4674d5417cbccf327b8cde +++ guitone.pro 37192ca1eb8877c37f917fe5cc1e49a75b13268d @@ -82,6 +82,7 @@ HEADERS = src/view/widgets/TreeView.h \ src/view/widgets/SearchInput.h \ src/view/widgets/SizeableLabel.h \ src/view/widgets/CertListBrowser.h \ + src/view/widgets/BranchView.h \ src/view/mainwindows/MainWindow.h \ src/view/mainwindows/WorkspaceWindow.h \ src/view/mainwindows/DatabaseWindow.h \ @@ -139,6 +140,7 @@ HEADERS = src/view/widgets/TreeView.h \ src/model/GetFileProxyModel.h \ src/model/Tags.h \ src/model/Branches.h \ + src/model/BranchesProxyModel.h \ src/model/Keys.h \ src/model/Toposort.h \ src/model/Manifest.h \ @@ -178,6 +180,7 @@ SOURCES += src/view/widgets/TreeView.cpp src/view/widgets/SearchInput.cpp \ src/view/widgets/SizeableLabel.cpp \ src/view/widgets/CertListBrowser.cpp \ + src/view/widgets/BranchView.cpp \ src/view/mainwindows/MainWindow.cpp \ src/view/mainwindows/WorkspaceWindow.cpp \ src/view/mainwindows/DatabaseWindow.cpp \ @@ -235,6 +238,7 @@ SOURCES += src/view/widgets/TreeView.cpp src/model/GetFileProxyModel.cpp \ src/model/Tags.cpp \ src/model/Branches.cpp \ + src/model/BranchesProxyModel.cpp \ src/model/Keys.cpp \ src/model/Toposort.cpp \ src/model/Manifest.cpp \ ============================================================ --- res/forms/dialogs/changeset_browser.ui 715176abd5b2dd44f77eb144f2708726635b10af +++ res/forms/dialogs/changeset_browser.ui acec562b32d453228b3fbc2438da26e41002a1fe @@ -23,7 +23,30 @@ Qt::Horizontal - + + + + 0 + + + + + + + Filter branches + + + + + + + + + + + + + Qt::Vertical @@ -33,8 +56,11 @@ 5 + + 0 + - + QAbstractItemView::NoEditTriggers @@ -88,7 +114,7 @@ QPushButton { - background: qlineargradient(x1:0,y1:0,x2:0,y2:1,stop: 0 palette(midlight), stop: 0.3 palette(light), stop: 1 palette(dark)); + background: qlineargradient(x1:0,y1:0,x2:0,y2:1,stop: 0 palette(midlight), stop: 0.3 palette(light), stop: 1 palette(dark)); border: 1px solid palette(dark); border-top-left-radius: 10px; border-bottom-left-radius: 10px; @@ -142,7 +168,7 @@ QPushButton:pressed, QPushButton:checked QPushButton { - background: qlineargradient(x1:0,y1:0,x2:0,y2:1,stop: 0 palette(midlight), stop: 0.3 palette(light), stop: 1 palette(dark)); + background: qlineargradient(x1:0,y1:0,x2:0,y2:1,stop: 0 palette(midlight), stop: 0.3 palette(light), stop: 1 palette(dark)); border: 1px solid palette(dark); border-top-right-radius: 10px; border-bottom-right-radius: 10px; @@ -225,7 +251,7 @@ QPushButton:pressed, QPushButton:checked 0 - -1 + 24636 @@ -323,13 +349,6 @@ QPushButton:pressed, QPushButton:checked - - - display branches as tree - - - - Qt::Horizontal @@ -373,6 +392,16 @@ QPushButton:pressed, QPushButton:checked QTextBrowser
CertListBrowser.h
+ + BranchView + QTreeView +
BranchView.h
+
+ + SearchInput + QLineEdit +
SearchInput.h
+
============================================================ --- src/model/Branches.cpp 68640cc21cb8741e349be14703f4b78b101db7d7 +++ src/model/Branches.cpp 67a145d13304dbdd83a59c9db10f33cfa8f56dc5 @@ -20,10 +20,20 @@ #include "BasicIOParser.h" #include "Settings.h" -Branches::Branches(QObject * parent, const DatabaseFile & db, bool display_tree) +/* + * We use two hacks here: + * 1) we mark suspended branches by setting the data behind Qt::UserRole + * in the specific branch item to true + * 2) we set the full branch name in tree and list mode as data behind + * Qt::ToolTipRole + */ +Branches::Branches(QObject * parent, const DatabaseFile & db) : QStandardItemModel(parent), AutomateCommand(0), - tree(display_tree), builder(0), databaseFile(db) -{} + builder(0), databaseFile(db) +{ + branchesAsTree = false; + suspendedBranches = false; +} Branches::~Branches() { @@ -33,9 +43,8 @@ void Branches::readBranches() void Branches::readBranches() { + branches.clear(); activeHeadsMap.clear(); - branchItemMap.clear(); - clear(); reset(); suspendedBranchesBrush = QBrush(QColor( @@ -61,10 +70,10 @@ void Branches::processTaskResult(const M QString cmd = task->getArguments().at(0); if (cmd == "branches") { - QStringList branchList = task->getDecodedOutput() + branches = task->getDecodedOutput() .split("\n", QString::SkipEmptyParts); - foreach (const QString & branch, branchList) + foreach (const QString & branch, branches) { MonotoneTaskPtr task(new MonotoneTask( QStringList() << "select" << "h:" + branch, @@ -73,35 +82,17 @@ void Branches::processTaskResult(const M AutomateCommand::enqueueDatabaseTask(databaseFile, task); } + displayBranchesAsTree(branchesAsTree); - setHorizontalHeaderItem(0, new QStandardItem(tr("Branches"))); - if (tree) - { - builder = new TreeBuilder(branchItemMap, invisibleRootItem(), this); - builder->addList(branchList); - } - else - { - foreach (const QString & branch, branchList) - { - QStandardItem * item = new QStandardItem(); - item->setData(branch, Qt::DisplayRole); - item->setData(branch, Qt::ToolTipRole); - appendRow(item); - branchItemMap.insert(branch, item); - } - } - - reset(); emit branchesRead(); } else if (cmd == "select") { QString branch = task->getArguments().at(1).mid(2); - QStringList headList = task->getDecodedOutput() + QStringList heads = task->getDecodedOutput() .split("\n", QString::SkipEmptyParts); - foreach (const QString & head, headList) + foreach (const QString & head, heads) { activeHeadsMap[branch].insert(head); @@ -117,24 +108,20 @@ void Branches::processTaskResult(const M BasicIOParser parser(task->getDecodedOutput()); I(parser.parse()); - CertList certList; - certList.revision = head; - certList.fill(parser.getStanzas()); + CertList certs; + certs.revision = head; + certs.fill(parser.getStanzas()); - QStringList suspendedBranches = certList.findByNameValues("suspend"); + QStringList suspendedBranches = certs.findByNameValues("suspend"); foreach (const QString & suspendedBranch, suspendedBranches) { activeHeadsMap[suspendedBranch].remove(head); + } - if (activeHeadsMap[suspendedBranch].size() == 0 && - branchItemMap.contains(suspendedBranch)) - { - QStandardItem * item = branchItemMap.value(suspendedBranch); - item->setData(QVariant(suspendedBranchesBrush), Qt::ForegroundRole); - - QModelIndex index = indexFromItem(item); - emit dataChanged(index, index); - } + if (!hasQueuedCommands()) + { + markSuspendedBranches(invisibleRootItem()); + reset(); } } } @@ -155,3 +142,65 @@ Qt::ItemFlags Branches::flags(const QMod return flags; } +void Branches::displayBranchesAsTree(bool tree) +{ + branchItemMap.clear(); + clear(); + + setHorizontalHeaderItem(0, new QStandardItem(tr("Branches"))); + + if (tree) + { + builder = new TreeBuilder(branchItemMap, invisibleRootItem(), this); + builder->addList(branches); + } + else + { + foreach (const QString & branch, branches) + { + QStandardItem * item = new QStandardItem(); + item->setData(branch, Qt::DisplayRole); + item->setData(branch, Qt::ToolTipRole); + appendRow(item); + branchItemMap.insert(branch, item); + } + } + + branchesAsTree = tree; + + markSuspendedBranches(invisibleRootItem()); + + reset(); +} + +bool Branches::markSuspendedBranches(QStandardItem * item) +{ + bool suspended = false; + if (item->hasChildren()) + { + bool allSuspended = true; + for (int i=0; irowCount(); ++i) + { + allSuspended &= markSuspendedBranches(item->child(i)); + } + suspended = allSuspended; + } + else + { + QString branch = item->data(Qt::ToolTipRole).toString(); + if (activeHeadsMap.contains(branch) && + activeHeadsMap.value(branch).size() == 0) + { + suspended = true; + } + } + + item->setData( + suspended ? suspendedBranchesBrush : QVariant(), + Qt::ForegroundRole + ); + item->setData(suspended, Qt::UserRole); + + return suspended; +} + ============================================================ --- src/model/Branches.h aac5902d3666e210b470e5e38b242ddb453450b5 +++ src/model/Branches.h f2ddb8c1991b32f53e190ae3f1e05902461196c4 @@ -30,26 +30,28 @@ public: { Q_OBJECT public: - Branches(QObject *, const DatabaseFile &, bool); - virtual ~Branches(); + Branches(QObject *, const DatabaseFile &); + ~Branches(); Qt::ItemFlags flags(const QModelIndex & index) const; public slots: void readBranches(); + void displayBranchesAsTree(bool); signals: void branchesRead(void); private: void processTaskResult(const MonotoneTaskPtr &); + bool markSuspendedBranches(QStandardItem *); + bool branchesAsTree, suspendedBranches; + QStringList branches; QMap > activeHeadsMap; QMap branchItemMap; - bool tree; TreeBuilder * builder; - DatabaseFile databaseFile; QBrush suspendedBranchesBrush; }; ============================================================ --- src/view/dialogs/ChangesetBrowser.cpp 3a4068f00d16bb40b561f42535231705e2a3397f +++ src/view/dialogs/ChangesetBrowser.cpp b0865decf7393809ac01fb964696001f2a8c90fc @@ -40,28 +40,43 @@ ChangesetBrowser::ChangesetBrowser(QWidg changesetsSplitter->restoreState(); changeLogSplitter->restoreState(); - tree = Settings::getBool("ChangesetBrowserTree"); - displayBranchesAsTree->setText( - !tree ? tr("display branches as tree") : tr("display branches flat") + branchModel = new Branches(this, databaseFile); + + branchProxyModel = new BranchesProxyModel(this); + branchProxyModel->setSourceModel(branchModel); + + branchView->setModel(branchProxyModel); + + connect( + branchViewFilter, SIGNAL(textChanged(const QString &)), + branchProxyModel, SLOT(filterByName(const QString &)) ); - initTreeWidget(); + connect( + branchView, SIGNAL(displayBranchesAsTree(bool)), + branchModel, SLOT(displayBranchesAsTree(bool)) + ); - changeLog->setKeyMap(MonotoneUtil::getPublicKeyMap(databaseFile)); + connect( + branchView, SIGNAL(showSuspendedBranches(bool)), + branchProxyModel, SLOT(showSuspendedBranches(bool)) + ); connect( - branches, SIGNAL(clicked(const QModelIndex &)), - this, SLOT(branchesClicked(const QModelIndex &)) + branchModel, SIGNAL(modelReset()), + branchView, SLOT(expandAll()) ); connect( - displayBranchesAsTree, SIGNAL(clicked()), - this, SLOT(toggleTree()) + branchView, SIGNAL(clicked(const QModelIndex &)), + this, SLOT(branchViewClicked(const QModelIndex &)) ); + changeLog->setKeyMap(MonotoneUtil::getPublicKeyMap(databaseFile)); + branchLogModel = new GetBranchLog(this, databaseFile); - changesets->setModel(branchLogModel); - changesets->setRootIsDecorated(false); + changesetView->setModel(branchLogModel); + changesetView->setRootIsDecorated(false); connect( branchLogModel, SIGNAL(readingStopped()), @@ -87,8 +102,8 @@ ChangesetBrowser::ChangesetBrowser(QWidg ); connect( - changesets, SIGNAL(clicked(const QModelIndex &)), - this, SLOT(changesetsClicked(const QModelIndex &)) + changesetView, SIGNAL(clicked(const QModelIndex &)), + this, SLOT(changesetViewClicked(const QModelIndex &)) ); connect( @@ -107,13 +122,13 @@ ChangesetBrowser::ChangesetBrowser(QWidg ); connect( - changesets, SIGNAL(doubleClicked(const QModelIndex &)), - this, SLOT(changesetsDoubleClicked(const QModelIndex &)) + changesetView, SIGNAL(doubleClicked(const QModelIndex &)), + this, SLOT(changesetViewDoubleClicked(const QModelIndex &)) ); connect( - changesets, SIGNAL(contextMenuRequested(const QModelIndexList &, const QPoint &)), - this, SLOT(changesetsContextMenuRequested(const QModelIndexList &, const QPoint &)) + changesetView, SIGNAL(contextMenuRequested(const QModelIndexList &, const QPoint &)), + this, SLOT(changesetViewContextMenuRequested(const QModelIndexList &, const QPoint &)) ); connect( @@ -135,10 +150,14 @@ ChangesetBrowser::~ChangesetBrowser() delete branchLogModel; delete revisionModel; - if (branchModel) delete branchModel; - Settings::setBool("ChangesetBrowserTree", tree); + delete branchModel; } +void ChangesetBrowser::init() +{ + branchModel->readBranches(); +} + void ChangesetBrowser::readAll() { progressWidget->setVisible(true); @@ -166,22 +185,13 @@ void ChangesetBrowser::readingStopped() pushAll->setAutoExclusive(true); } -void ChangesetBrowser::toggleTree() +void ChangesetBrowser::branchViewClicked(const QModelIndex & idx) { - tree = !tree; - displayBranchesAsTree->setText( - !tree ? tr("display branches as tree") : tr("display branches flat") - ); - initTreeWidget(); -} - -void ChangesetBrowser::branchesClicked(const QModelIndex & idx) -{ // skip clicks on parent nodes in tree mode - if (branchModel->rowCount(idx) > 0) + if (branchProxyModel->rowCount(idx) > 0) return; - QString branch = branchModel->data(idx, Qt::ToolTipRole).toString(); + QString branch = branchProxyModel->data(idx, Qt::ToolTipRole).toString(); if (branch == branchLogModel->getCurrentBranch()) { @@ -195,7 +205,7 @@ void ChangesetBrowser::branchesClicked(c branchLogModel->readMore(branch); } -void ChangesetBrowser::changesetsClicked(const QModelIndex & idx) +void ChangesetBrowser::changesetViewClicked(const QModelIndex & idx) { QModelIndex revIdx = branchLogModel->index(idx.row(), 3, QModelIndex()); currentRevision = branchLogModel->data(revIdx, Qt::DisplayRole).toString(); @@ -205,35 +215,8 @@ void ChangesetBrowser::changesetsClicked multipleParents->setVisible(false); } -void ChangesetBrowser::initTreeWidget() +void ChangesetBrowser::changesetViewDoubleClicked(const QModelIndex & index) { - if (branchModel) - { - disconnect( - branchModel, SIGNAL(branchesRead(void)), - this, SLOT(branchesRead(void)) - ); - delete branchModel; - } - - branchModel = new Branches(this, databaseFile, tree); - branchModel->readBranches(); - branches->setRootIsDecorated(false); - branches->setModel(branchModel); - - connect( - branchModel, SIGNAL(branchesRead(void)), - this, SLOT(branchesRead(void)) - ); -} - -void ChangesetBrowser::branchesRead() -{ - branches->setExpanded(branchModel->index(0, 0, QModelIndex()), true); -} - -void ChangesetBrowser::changesetsDoubleClicked(const QModelIndex & index) -{ if (!index.isValid()) return; QModelIndex revIdx = branchLogModel->index(index.row(), 3, QModelIndex()); QString rev(revIdx.data().toString()); @@ -249,7 +232,7 @@ void ChangesetBrowser::changesetsDoubleC } } -void ChangesetBrowser::changesetsContextMenuRequested(const QModelIndexList & indexList, const QPoint & pos) +void ChangesetBrowser::changesetViewContextMenuRequested(const QModelIndexList & indexList, const QPoint & pos) { if (indexList.size() == 0) return; ============================================================ --- src/view/dialogs/ChangesetBrowser.h e3e968d6eb92455c2397370254a986138f2fbf80 +++ src/view/dialogs/ChangesetBrowser.h ae5ea7b80db4220b1c4f6dab9814da35a6eae401 @@ -21,6 +21,7 @@ #include "ui_changeset_browser.h" #include "Branches.h" +#include "BranchesProxyModel.h" #include "Dialog.h" #include "GetBranchLog.h" #include "GetRevision.h" @@ -34,6 +35,8 @@ public: ChangesetBrowser(QWidget *, const DatabaseFile &); ~ChangesetBrowser(); + void init(); + signals: void revisionManifest(const QString &); void diffRevision(const QString &, const QString &, const QString &); @@ -48,24 +51,24 @@ private slots: void closeEvent(QCloseEvent *); private slots: - void branchesClicked(const QModelIndex &); - void changesetsClicked(const QModelIndex &); - void branchesRead(); - void toggleTree(); + void branchViewClicked(const QModelIndex &); + void changesetViewClicked(const QModelIndex &); + + void changesetViewDoubleClicked(const QModelIndex &); + void revisionViewDoubleClicked(const QModelIndex &); + + void changesetViewContextMenuRequested(const QModelIndexList &, const QPoint &); + void revisionViewContextMenuRequested(const QModelIndexList &, const QPoint &); + void readAll(); void readMore(); void readingStopped(); - void changesetsDoubleClicked(const QModelIndex &); - void changesetsContextMenuRequested(const QModelIndexList &, const QPoint &); - void revisionViewDoubleClicked(const QModelIndex &); - void revisionViewContextMenuRequested(const QModelIndexList &, const QPoint &); + void updateParentsList(); -private: - void initTreeWidget(); - - bool tree; + private: DatabaseFile databaseFile; + BranchesProxyModel * branchProxyModel; Branches * branchModel; GetBranchLog * branchLogModel; GetRevision * revisionModel; ============================================================ --- src/view/dialogs/CheckoutRevision.cpp 4073ede5d48029eb24325788d05025d3734cfaa5 +++ src/view/dialogs/CheckoutRevision.cpp 08a5fb3bd73416a58393d9271b0e9f22710805d6 @@ -31,7 +31,7 @@ CheckoutRevision::CheckoutRevision(QWidg setupUi(this); Dialog::init(); - branchesModel = new Branches(this, databaseFile, false); + branchesModel = new Branches(this, databaseFile); branchesModel->readBranches(); branchList->setModel(branchesModel); ============================================================ --- src/view/dialogs/DatabaseDialogManager.cpp ed1529ba7e99b5c50809084dae59b68e567de617 +++ src/view/dialogs/DatabaseDialogManager.cpp 9fd20e3bd733cf36a534882f32eaaa7c1095c225 @@ -112,6 +112,8 @@ void DatabaseDialogManager::showChangese ); } + changesetBrowser->init(); + showDialog(changesetBrowser); } ============================================================ --- src/view/dialogs/SelectRevision.cpp 0b94e795626ab3b9461e25b2fd0a71867eec11d0 +++ src/view/dialogs/SelectRevision.cpp f9db3a6293905582be8c05cf580a0d2bc37e7608 @@ -45,7 +45,7 @@ SelectRevision::SelectRevision(QWidget * selectorModel = new Select(this, databaseFile); sortModel = new Toposort(this, databaseFile); certsModel = new Certs(this, databaseFile); - branchesModel = new Branches(this, databaseFile, false); + branchesModel = new Branches(this, databaseFile); tagsModel = new Tags(this, databaseFile); keysModel = new Keys(this, databaseFile); ============================================================ --- src/view/dialogs/UpdateWorkspace.cpp 7840d2b43f9dc33f63ab8af6ffb3a010bf311e9d +++ src/view/dialogs/UpdateWorkspace.cpp 9c46b834533239597ee91776ec1abfe9cabb422f @@ -32,7 +32,7 @@ UpdateWorkspace::UpdateWorkspace(QWidget DatabaseFile db = MonotoneUtil::getDatabaseFile(workspacePath); - branchesModel = new Branches(this, db, false); + branchesModel = new Branches(this, db); branchList->setModel(branchesModel); tagsModel = new Tags(this, db);