# # # patch "src/view/dialogs/ChangesetBrowser.cpp" # from [73f6e9589ed5bd6f45821622d6643e99168e40e1] # to [37b2506331a987c5795e91e653d3309a4cb44215] # # patch "src/view/dialogs/ChangesetBrowser.h" # from [c9b70428a454166913d15724c1b18f1a91f43637] # to [762d08a1a37e466eaa18c31515fed98bee874398] # # patch "src/view/dialogs/FileDiff.cpp" # from [0df18f51a4020c5a2a36495b8da49fc5348c53c5] # to [2cec6c3f482d7bd6c6ae18168205fa306376fd53] # # patch "src/view/dialogs/FileDiff.h" # from [c254fa1cdec0a6fe6545adcf784e5cbcb5ca1573] # to [501d0b5241a6e23fe9f31919fd9906c03a24a142] # ============================================================ --- src/view/dialogs/ChangesetBrowser.cpp 73f6e9589ed5bd6f45821622d6643e99168e40e1 +++ src/view/dialogs/ChangesetBrowser.cpp 37b2506331a987c5795e91e653d3309a4cb44215 @@ -18,12 +18,11 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - #include "ChangesetBrowser.h" #include "Settings.h" -ChangesetBrowser::ChangesetBrowser(QWidget * parent, const QString & database) - : Dialog(parent), databaseFile(database) +ChangesetBrowser::ChangesetBrowser(QWidget * parent, const DatabaseFile & db) + : Dialog(parent), databaseFile(db) { setupUi(this); Dialog::init(); ============================================================ --- src/view/dialogs/ChangesetBrowser.h c9b70428a454166913d15724c1b18f1a91f43637 +++ src/view/dialogs/ChangesetBrowser.h 762d08a1a37e466eaa18c31515fed98bee874398 @@ -31,7 +31,7 @@ public: { Q_OBJECT public: - ChangesetBrowser(QWidget *, const QString &); + ChangesetBrowser(QWidget *, const DatabaseFile &); ~ChangesetBrowser(); signals: @@ -51,7 +51,7 @@ private: void initTreeWidget(); bool tree; - QString databaseFile; + DatabaseFile databaseFile; Branches * branchModel; ChangesetModel * changesetModel; GetRevision * revisionModel; ============================================================ --- src/view/dialogs/FileDiff.cpp 0df18f51a4020c5a2a36495b8da49fc5348c53c5 +++ src/view/dialogs/FileDiff.cpp 2cec6c3f482d7bd6c6ae18168205fa306376fd53 @@ -19,106 +19,119 @@ ***************************************************************************/ #include "FileDiff.h" -#include "Monotone.h" +#include "MonotoneUtil.h" #include "Settings.h" #include #include -FileDiff::FileDiff(QWidget* parent) : Dialog(parent) +FileDiff::FileDiff(QWidget * parent) : Dialog(parent) { setupUi(this); Dialog::init(); -} -FileDiff::FileDiff(QWidget * parent, const QString & fileName, - const QString & base, const QString & target): Dialog(parent) -{ - setupUi(this); - Dialog::init(); - init(fileName, base, target); + // make the line number col a little smaller + diffView->header()->resizeSection(0, 40); + + connect( + firstRevision, SIGNAL(toggled(bool)), + this, SLOT(versionToggled(bool)) + ); + connect( + secondRevision, SIGNAL(toggled(bool)), + this, SLOT(versionToggled()) + ); + connect( + bothRevisions, SIGNAL(toggled(bool)), + this, SLOT(versionToggled(bool)) + ); + + connect( + scrollToNext, SIGNAL(clicked()), + this, SLOT(getNextGroup()) + ); + + connect( + scrollToPrev, SIGNAL(clicked()), + this, SLOT(getPrevGroup()) + ); } -void FileDiff::init( - const QString & fileName, const QString & base, const QString & target -) +void FileDiff::forDatabase(const DatabaseFile & db, const QString & file, + const QString & base, const QString & target) { - file = fileName; + fileName = file; loaded = false; - + QString title = windowTitle(); setWindowTitle(title.arg(fileName)); - - if (base.isNull() || base.isEmpty()) - { - firstRevision->setText(tr("workspace parent")); - } - else - { - firstRevision->setText( - firstRevision->text().arg(base.left(12).append("...")) - ); - } - - if (target.isNull() || target.isEmpty()) - { - secondRevision->setText(tr("workspace revision")); - } - else - { - secondRevision->setText( - secondRevision->text().arg(target.left(12).append("...")) - ); - } - - fileModel = new GetFile(this); - + + firstRevision->setText( + firstRevision->text().arg(base.left(12).append("...")) + ); + + secondRevision->setText( + secondRevision->text().arg(target.left(12).append("...")) + ); + + fileModel = new GetFile(this, db); + fileProxyModel = new GetFileProxyModel(this); fileProxyModel->setSourceModel(fileModel); diffModel = new ContentDiff(this); - + diffView->setModel(fileProxyModel); diffStatusView->setModel(fileProxyModel); - - // make the line number col a little smaller - diffView->header()->resizeSection(0, 40); connect( - firstRevision, SIGNAL(toggled(bool)), - this, SLOT(versionToggled(bool)) + fileModel, SIGNAL(fileRead()), + this, SLOT(applyDiff()) ); + connect( - secondRevision, SIGNAL(toggled(bool)), - this, SLOT(versionToggled(bool)) + diffModel, SIGNAL(diffRead()), + this, SLOT(applyDiff()) ); + + fileModel->readFileByName(fileName, base); + diffModel->readDatabaseDiff(db, fileName, base, target); +} + +void FileDiff::forWorkspace(const WorkspacePath & ws, const QString & file) +{ + fileName = file; + loaded = false; + + QString title = windowTitle(); + setWindowTitle(title.arg(fileName)); + + firstRevision->setText(tr("workspace parent")); + secondRevision->setText(tr("workspace revision")); + + fileModel = new GetFile(this, MonotoneUtil::getDatabaseFile(ws)); + + fileProxyModel = new GetFileProxyModel(this); + fileProxyModel->setSourceModel(fileModel); + + diffModel = new ContentDiff(this); + + diffView->setModel(fileProxyModel); + diffStatusView->setModel(fileProxyModel); + connect( - bothRevisions, SIGNAL(toggled(bool)), - this, SLOT(versionToggled(bool)) - ); - - connect( fileModel, SIGNAL(fileRead()), this, SLOT(applyDiff()) ); - + connect( diffModel, SIGNAL(diffRead()), this, SLOT(applyDiff()) ); - - connect( - scrollToNext, SIGNAL(clicked()), - this, SLOT(getNextGroup()) - ); - - connect( - scrollToPrev, SIGNAL(clicked()), - this, SLOT(getPrevGroup()) - ); - - fileModel->readFileByName(fileName, base); - diffModel->readDiff(fileName, base, target); + + QString baseRev = MonotoneUtil::getBaseWorkspaceRevision(ws); + fileModel->readFileByName(fileName, baseRev); + diffModel->readWorkspaceDiff(ws, fileName, baseRev); } FileDiff::~FileDiff() {} @@ -130,8 +143,8 @@ void FileDiff::applyDiff() loaded = true; return; } - - Diff * diff = diffModel->getDiff(file); + + Diff * diff = diffModel->getDiff(fileName); if (diff == 0) { QMessageBox::information( @@ -143,12 +156,12 @@ void FileDiff::applyDiff() reject(); return; } - + fileModel->applyDiff(diff); diffStatusView->update(); } -void FileDiff::versionToggled(bool dummy) +void FileDiff::versionToggled() { if (firstRevision->isChecked()) fileProxyModel->setFileVersion(GetFileProxyModel::Left); @@ -156,7 +169,7 @@ void FileDiff::versionToggled(bool dummy fileProxyModel->setFileVersion(GetFileProxyModel::Right); if (bothRevisions->isChecked()) fileProxyModel->setFileVersion(GetFileProxyModel::Both); - + diffStatusView->update(); } @@ -164,7 +177,7 @@ void FileDiff::scrollToGroup(bool forwar { if (!currentIndex.isValid()) return; QModelIndex proxyIndex = fileProxyModel->mapFromSource(currentIndex); - + // recursion: if the queried group is not valid in the view because it // has been filtered out, get the next group and try again if (!proxyIndex.isValid()) @@ -177,7 +190,7 @@ void FileDiff::scrollToGroup(bool forwar getPrevGroup(); return; } - + diffView->scrollTo(proxyIndex, QAbstractItemView::PositionAtTop); } ============================================================ --- src/view/dialogs/FileDiff.h c254fa1cdec0a6fe6545adcf784e5cbcb5ca1573 +++ src/view/dialogs/FileDiff.h 501d0b5241a6e23fe9f31919fd9906c03a24a142 @@ -29,28 +29,27 @@ class FileDiff : public Dialog, private class FileDiff : public Dialog, private Ui::FileDiffDialog { - Q_OBJECT - + Q_OBJECT public: FileDiff(QWidget *); - FileDiff(QWidget *, const QString &, const QString & base = QString(), const QString & target = QString()); - void init(const QString &, const QString & base = QString(), const QString & target = QString()); - - ~FileDiff(); + ~FileDiff(); + void forDatabase(const DatabaseFile &, const QString &, const QString &, const QString &); + void forWorkspace(const WorkspacePath &, const QString &); + private slots: void applyDiff(); - void versionToggled(bool); + void versionToggled(); void scrollToGroup(bool); void getPrevGroup(); void getNextGroup(); - + private: ContentDiff * diffModel; GetFile * fileModel; GetFileProxyModel * fileProxyModel; QModelIndex currentIndex; - QString file; + QString fileName; bool loaded; };