# # # patch "src/view/dialogs/ChangesetBrowser.cpp" # from [f88765a14b2eef403b8609587b95d7cf58a6a4ae] # to [73f6e9589ed5bd6f45821622d6643e99168e40e1] # # patch "src/view/dialogs/ChangesetBrowser.h" # from [9b78450d35f13ae1a57e9475e69e66f975afbc0f] # to [c9b70428a454166913d15724c1b18f1a91f43637] # ============================================================ --- src/view/dialogs/ChangesetBrowser.cpp f88765a14b2eef403b8609587b95d7cf58a6a4ae +++ src/view/dialogs/ChangesetBrowser.cpp 73f6e9589ed5bd6f45821622d6643e99168e40e1 @@ -21,80 +21,81 @@ #include "ChangesetBrowser.h" #include "Settings.h" -#include "RevisionManifest.h" -ChangesetBrowser::ChangesetBrowser(QWidget *parent) : Dialog(parent) +ChangesetBrowser::ChangesetBrowser(QWidget * parent, const QString & database) + : Dialog(parent), databaseFile(database) { - setupUi(this); + setupUi(this); Dialog::init(); - + // OSX sheet-alike dialog setWindowFlags(Qt::Sheet); - - this->setWindowFlags(this->windowFlags() | Qt::WindowMaximizeButtonHint); - this->setWindowFlags(this->windowFlags() | Qt::WindowMinimizeButtonHint); - innerSplitter->init(); - outerSplitter->init(); - tree = Settings::getBool("ChangesetBrowserTree", false); + this->setWindowFlags(this->windowFlags() | Qt::WindowMaximizeButtonHint); + this->setWindowFlags(this->windowFlags() | Qt::WindowMinimizeButtonHint); + innerSplitter->init(); + outerSplitter->init(); + + tree = Settings::getBool("ChangesetBrowserTree", false); displayBranchesAsTree->setText( !tree ? tr("display branches as tree") : tr("display branches flat") ); - + branchModel = 0; - - initTreeWidget(); - connect( + initTreeWidget(); + + connect( branches, SIGNAL(clicked(const QModelIndex &)), this, SLOT(branchesClicked(const QModelIndex &)) ); - + connect( displayBranchesAsTree, SIGNAL(clicked()), this, SLOT(toggleTree()) ); - changesetModel = new ChangesetModel(this); - changesets->setModel(changesetModel); - changesets->setRootIsDecorated(false); + changesetModel = new ChangesetModel(this, databaseFile); + changesets->setModel(changesetModel); + changesets->setRootIsDecorated(false); - revisionModel = new GetRevision(this); + revisionModel = new GetRevision(this, databaseFile); revisionView->setModel(revisionModel); - + connect( changesets, SIGNAL(clicked(const QModelIndex &)), this, SLOT(changesetsClicked(const QModelIndex &)) ); - - connect( + + connect( pushAll, SIGNAL(clicked()), this, SLOT(receiveAll()) ); - + connect( pushMore, SIGNAL(clicked()), this, SLOT(receiveMore()) ); - + connect( changesets, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(changesetsDoubleClicked(const QModelIndex &)) ); - + connect( changesets, SIGNAL(contextMenuRequested(const QModelIndexList &, const QPoint &)), this, SLOT(contextMenuRequested(const QModelIndexList &, const QPoint &)) ); } + void ChangesetBrowser::receiveAll() { - changesetModel->receiveRevisions(true); + changesetModel->receiveRevisions(true); } void ChangesetBrowser::receiveMore() { - changesetModel->receiveRevisions(false); + changesetModel->receiveRevisions(false); } ChangesetBrowser::~ChangesetBrowser() @@ -102,29 +103,29 @@ ChangesetBrowser::~ChangesetBrowser() delete changesetModel; delete revisionModel; if (branchModel) delete branchModel; - Settings::setBool("ChangesetBrowserTree", tree); + Settings::setBool("ChangesetBrowserTree", tree); } void ChangesetBrowser::toggleTree() { - tree = !tree; + tree = !tree; displayBranchesAsTree->setText( !tree ? tr("display branches as tree") : tr("display branches flat") ); - initTreeWidget(); + initTreeWidget(); } void ChangesetBrowser::branchesClicked(const QModelIndex & idx) { - QString branch = branchModel->data(idx, Qt::ToolTipRole).toString(); - changesetModel->setBranch(branch); + QString branch = branchModel->data(idx, Qt::ToolTipRole).toString(); + changesetModel->setBranch(branch); } void ChangesetBrowser::changesetsClicked(const QModelIndex & idx) { QModelIndex revIdx = changesetModel->index(idx.row(), 3, QModelIndex()); QString revision = changesetModel->data(revIdx, Qt::DisplayRole).toString(); - revisionModel->readRevision(revision); + revisionModel->readRevision(revision); } void ChangesetBrowser::initTreeWidget() @@ -137,56 +138,50 @@ void ChangesetBrowser::initTreeWidget() ); delete branchModel; } - - branchModel = new Branches(this, tree); - branchModel->readBranches(); - branches->setRootIsDecorated(false); - branches->setModel(branchModel); - connect( + branchModel = new Branches(this, databaseFile, tree); + branchModel->readBranches(); + branches->setRootIsDecorated(false); + branches->setModel(branchModel); + + connect( branchModel, SIGNAL(branchesRead(void)), - this, SLOT(branchesRead(void)) + this, SLOT(branchesRead(void)) ); } void ChangesetBrowser::branchesRead() { - branches->setExpanded(branchModel->index(0, 0, QModelIndex()), true); + branches->setExpanded(branchModel->index(0, 0, QModelIndex()), true); } -void ChangesetBrowser::openManifestDialog(const QString & rev) -{ - RevisionManifest dlg(this, rev); - dlg.exec(); -} - void ChangesetBrowser::changesetsDoubleClicked(const QModelIndex & index) { if (!index.isValid()) return; QModelIndex revIdx = changesetModel->index(index.row(), 3, QModelIndex()); - openManifestDialog(revIdx.data().toString()); + emit revisionManifest(revIdx.data().toString()); } void ChangesetBrowser::contextMenuRequested(const QModelIndexList & indexList, const QPoint & pos) { if (indexList.size() == 0) return; - - QModelIndex revIdx = + + QModelIndex revIdx = changesetModel->index(indexList.at(0).row(), 3, QModelIndex()); - + QString rev(revIdx.data().toString()); - + QMenu menu(this); QFont activeFont; activeFont.setBold(true); - + QAction * actOpenManifest = menu.addAction(tr("View files in this revision")); actOpenManifest->setFont(activeFont); - + QAction * act = menu.exec(pos); if (act == actOpenManifest) { - openManifestDialog(rev); + emit revisionManifest(rev); } // TODO: we might want to add more items here, like "Checkout", "Update", // etc. ============================================================ --- src/view/dialogs/ChangesetBrowser.h 9b78450d35f13ae1a57e9475e69e66f975afbc0f +++ src/view/dialogs/ChangesetBrowser.h c9b70428a454166913d15724c1b18f1a91f43637 @@ -22,7 +22,6 @@ #define CHANGESET_BROWSER_H #include "ui_changeset_browser.h" -#include "Monotone.h" #include "Branches.h" #include "Dialog.h" #include "ChangesetModel.h" @@ -30,29 +29,31 @@ class ChangesetBrowser : public Dialog, class ChangesetBrowser : public Dialog, private Ui::ChangesetBrowser { - Q_OBJECT + Q_OBJECT +public: + ChangesetBrowser(QWidget *, const QString &); + ~ChangesetBrowser(); -public: - ChangesetBrowser(QWidget *); - ~ChangesetBrowser(); +signals: + void revisionManifest(const QString &); private slots: - void branchesClicked(const QModelIndex &); + void branchesClicked(const QModelIndex &); void changesetsClicked(const QModelIndex &); - void branchesRead(); - void toggleTree(); - void receiveAll(); - void receiveMore(); + void branchesRead(); + void toggleTree(); + void receiveAll(); + void receiveMore(); void changesetsDoubleClicked(const QModelIndex &); void contextMenuRequested(const QModelIndexList &, const QPoint &); private: void initTreeWidget(); - void openManifestDialog(const QString &); - + bool tree; - Branches * branchModel; - ChangesetModel * changesetModel; + QString databaseFile; + Branches * branchModel; + ChangesetModel * changesetModel; GetRevision * revisionModel; };