# # # add_file "src/view/dialogs/DialogManager.cpp" # content [5f33d99686663af84f232e6c7b1cf831cec6b988] # # add_file "src/view/dialogs/DialogManager.h" # content [cc548e839bedf3395db24df608a7a6ef0822fb3f] # ============================================================ --- src/view/dialogs/DialogManager.cpp 5f33d99686663af84f232e6c7b1cf831cec6b988 +++ src/view/dialogs/DialogManager.cpp 5f33d99686663af84f232e6c7b1cf831cec6b988 @@ -0,0 +1,279 @@ +/*************************************************************************** + * Copyright (C) 2007 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 2 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, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "DialogManager.h" +#include "Guitone.h" + +DialogManager::DialogManager(QWidget * parentWidget) : QObject(parentWidget) +{ + about = 0; + changesetBrowser = 0; + checkoutRevision = 0; + commitRevision = 0; + fileDiff = 0; + fileHistory = 0; + generateKeypair = 0; + keyManagement = 0; + preferences = 0; + revisionDiff = 0; + revisionManifest = 0; + selectRevision = 0; + unaccountedRenames = 0; + updateWorkspace = 0; +} + +DialogManager::~DialogManager() +{ + delete about; + delete changesetBrowser; + delete checkoutRevision; + delete commitRevision; + delete fileDiff; + delete fileHistory; + delete generateKeypair; + delete keyManagement; + delete preferences; + delete revisionDiff; + delete revisionManifest; + delete selectRevision; + delete unaccountedRenames; + delete updateWorkspace; +} + +void DialogManager::initWithDatabase(const DatabaseFile & db) +{ + databaseFile = db; + + QWidget * parent = reinterpret_cast(parent); + + about = new About(parent); + changesetBrowser = new ChangesetBrowser(parent, databaseFile); + checkoutRevision = new CheckoutRevision(parent, databaseFile); + fileDiff = new FileDiff(parent); + fileHistory = new FileHistory(parent, databaseFile); + generateKeypair = new GenerateKeypair(parent, databaseFile); + keyManagement = new KeyManagement(parent, databaseFile); + preferences = new Preferences(parent); + revisionDiff = new RevisionDiff(parent); + revisionManifest = new RevisionManifest(parent, databaseFile); + selectRevision = new SelectRevision(parent, databaseFile); + unaccountedRenames = new UnaccountedRenames(parent); + + connect( + changesetBrowser, SIGNAL(revisionManifest(const QString &)), + this, SLOT(showRevisionManifest(const QString &)) + ); + + connect( + fileHistory, SIGNAL(fileDiff(const QString &, const QString &, const QString &)), + this, SLOT(showFileDiff(const QString &, const QString &, const QString &)) + ); + + connect( + selectRevision, SIGNAL(revisionDiff(const QString &, const QString &, const QString &)), + this, SLOT(showRevisionDiff(const QString &, const QString &, const QString &)) + ); + + connect( + selectRevision, SIGNAL(revisionManifest(const QString &)), + this, SLOT(showRevisionManifest(const QString &)) + ); + + connect( + selectRevision, SIGNAL(revisionSelected(const QString &)), + this, SLOT(revisionSelected(const QString &)) + ); + + connect( + revisionManifest, SIGNAL(fileHistory(const QString &, const QString &)), + this, SLOT(showFileHistory(const QString &, const QString &)) + ); + + connect( + checkoutRevision, SIGNAL(selectRevisionFromSelector(const QString &)), + this, SLOT(showSelectRevision(const QString &)) + ); + + connect( + selectRevision, SIGNAL(revisionSelected(const QString &)), + checkoutRevision, SLOT(setSelectedRevision(const QString &)) + ); + + connect( + fileHistory, SIGNAL(fileDiff(const QString &, const QString &, const QString &)), + this, SLOT(showFileDiff(const QString &, const QString &, const QString &)) + ); + + // directly reload the keys dialog if a new key has been created + connect( + generateKeypair, SIGNAL(keypairGenerated()), + keyManagement, SLOT(readKeys()) + ); + + // delegate this further + connect( + checkoutRevision, SIGNAL(revisionCheckedOut(const QString &)), + this, SIGNAL(revisionCheckedOut(const QString &)) + ); + +} + +void DialogManager::initWithWorkspace(const WorkspacePath & ws) +{ + workspacePath = ws; + + QWidget * parent = reinterpret_cast(parent); + + commitRevision = new CommitRevision(parent, workspacePath); + updateWorkspace = new UpdateWorkspace(parent, workspacePath); + + connect( + updateWorkspace, SIGNAL(selectRevisionFromSelector(const QString &)), + this, SLOT(showSelectRevision(const QString &)) + ); + + connect( + selectRevision, SIGNAL(revisionSelected(const QString &)), + updateWorkspace, SLOT(setSelectedRevision(const QString &)) + ); + + // delegate this further + connect( + commitRevision, SIGNAL(revisionCommitted(const QString &)), + this, SIGNAL(revisionCommitted(const QString &)) + ); + + initWithDatabase(APP->manager()->getDatabaseFilePath(ws)); +} + +void DialogManager::showAbout() +{ + I(about); + about->execDocumentModal(); +} + +void DialogManager::showChangesetBrowser() +{ + I(changesetBrowser); + changesetBrowser->execDocumentModal(); +} + +void DialogManager::showCheckoutRevision() +{ + I(checkoutRevision); + checkoutRevision->execDocumentModal(); +} + +void DialogManager::showCommitRevision() +{ + I(commitRevision); + commitRevision->execDocumentModal(); +} + +void DialogManager::showFileDiff(const QString & file, const QString & base, const QString & target) +{ + I(fileDiff); + + if (!workspacePath.isEmpty()) + { + fileDiff->forWorkspace(workspacePath, file); + } + else + { + fileDiff->forDatabase(databaseFile, file, base, target); + } + + fileDiff->execDocumentModal(); +} + +void DialogManager::showFileHistory(const QString & file, const QString & startRevision) +{ + I(fileHistory); + + fileHistory->readHistory(file, startRevision); + fileHistory->execDocumentModal(); +} + +void DialogManager::showGenerateKeypair() +{ + I(generateKeypair); + generateKeypair->execDocumentModal(); +} + +void DialogManager::showKeyManagement() +{ + I(keyManagement); + keyManagement->readKeys(); + keyManagement->execDocumentModal(); +} + +void DialogManager::showPreferences() +{ + I(preferences); + preferences->execDocumentModal(); +} + +void DialogManager::showRevisionDiff(const QString & file, const QString & base, const QString & target) +{ + I(revisionDiff); + + if (!workspacePath.isEmpty()) + { + revisionDiff->forWorkspace(workspacePath, file); + } + else + { + revisionDiff->forDatabase(databaseFile, file, base, target); + } + + revisionDiff->execDocumentModal(); +} + +void DialogManager::showRevisionManifest(const QString & revision) +{ + I(revisionManifest); + + revisionManifest->readManifest(revision); + revisionManifest->execDocumentModal(); +} + +void DialogManager::showSelectRevision(const QString & selector) +{ + I(selectRevision); + + if (selector.size() > 0) + { + selectRevision->queryRevisions(selector); + } + selectRevision->execDocumentModal(); +} + +void DialogManager::showUnaccountedRenames(const QMap & renames) +{ + I(unaccountedRenames); + unaccountedRenames->showUnaccountedRenames(renames); +} + +void DialogManager::showUpdateWorkspace() +{ + I(updateWorkspace); + checkoutRevision->execDocumentModal(); +} + ============================================================ --- src/view/dialogs/DialogManager.h cc548e839bedf3395db24df608a7a6ef0822fb3f +++ src/view/dialogs/DialogManager.h cc548e839bedf3395db24df608a7a6ef0822fb3f @@ -0,0 +1,95 @@ +/*************************************************************************** + * Copyright (C) 2007 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 2 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, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef DIALOGMANAGER_H +#define DIALOGMANAGER_H + +#include "About.h" +#include "ChangesetBrowser.h" +#include "CheckoutRevision.h" +#include "CommitRevision.h" +#include "FileDiff.h" +#include "FileHistory.h" +#include "GenerateKeypair.h" +#include "KeyManagement.h" +#include "Preferences.h" +#include "RevisionDiff.h" +#include "RevisionManifest.h" +#include "SelectRevision.h" +#include "UnaccountedRenames.h" +#include "UpdateWorkspace.h" + +#include +#include + +class DialogManager : public QObject +{ + Q_OBJECT +public: + DialogManager(QWidget *); + ~DialogManager(); + + void initWithDatabase(const DatabaseFile &); + void initWithWorkspace(const WorkspacePath &); + + //! delegated signals +signals: + void revisionCheckedOut(const QString &); + void revisionCommitted(const QString &); + +public slots: + void showAbout(); + void showChangesetBrowser(); + void showCheckoutRevision(); + void showCommitRevision(); + void showFileDiff(const QString &, const QString &, const QString &); + void showFileHistory(const QString &, const QString &); + void showGenerateKeypair(); + void showKeyManagement(); + void showPreferences(); + void showRevisionDiff(const QString &, const QString &, const QString &); + void showRevisionManifest(const QString &); + void showSelectRevision(const QString &); + void showUnaccountedRenames(const QMap &); + void showUpdateWorkspace(); + +private: + About * about; + ChangesetBrowser * changesetBrowser; + CheckoutRevision * checkoutRevision; + CommitRevision * commitRevision; + FileDiff * fileDiff; + FileHistory * fileHistory; + GenerateKeypair * generateKeypair; + KeyManagement * keyManagement; + Preferences * preferences; + RevisionDiff * revisionDiff; + RevisionManifest * revisionManifest; + SelectRevision * selectRevision; + UnaccountedRenames * unaccountedRenames; + UpdateWorkspace * updateWorkspace; + + DatabaseFile databaseFile; + WorkspacePath workspacePath; + + QMap > dialogMapping; +}; + +#endif