|
16 | 16 |
|
17 | 17 | #include <QtPlugin>
|
18 | 18 | #include <QFileDialog>
|
| 19 | +#include <QMessageBox> |
| 20 | + |
| 21 | +#include "libGitWrap/Operations/RemoteOperations.hpp" |
19 | 22 |
|
20 | 23 | #include "libMacGitverCore/App/MacGitver.hpp"
|
| 24 | +#include "libMacGitverCore/RepoMan/Repo.hpp" |
21 | 25 |
|
22 | 26 | #include "RemoteCreateEditDlg.h"
|
23 | 27 | #include "RemotesModule.h"
|
@@ -59,14 +63,69 @@ void RemotesModule::onRemoteCreateEdit()
|
59 | 63 | //TODO: dlg.setContext( ctx );
|
60 | 64 | dlg.exec();
|
61 | 65 | }
|
| 66 | + |
| 67 | +void RemotesModule::onRemoteDelete() |
| 68 | +{ |
| 69 | + // TODO: requires the remote context (the remote to delete) |
62 | 70 | }
|
63 | 71 |
|
64 | 72 | /**
|
65 | 73 | * @brief Menu action to fetch all remotes of a repository.
|
66 | 74 | */
|
67 | 75 | void RemotesModule::onRemotesFetchAll()
|
68 | 76 | {
|
69 |
| - // TODO: requires a RepositoryContext (the repo to fetch all remotes from) |
| 77 | + // TODO: requires a repository context (the repo to fetch all remotes from) |
70 | 78 | // A sub-context (i.e. a branch) can further restrict, what is fetched
|
| 79 | + Heaven::Action* action = qobject_cast< Heaven::Action* >( sender() ); |
| 80 | + Q_ASSERT( action ); |
| 81 | + RM::Repo* repo = qobject_cast< RM::Repo* >( action->activatedBy() ); |
| 82 | + if( repo ) { |
| 83 | + Git::Result r; |
| 84 | + Git::Repository gitRepo = repo->gitRepo(); |
| 85 | + const QStringList aliases( gitRepo.allRemoteNames(r) ); |
| 86 | + if ( !r ) { |
| 87 | + QMessageBox::warning( 0, tr("Lookup of remotes failed"), |
| 88 | + tr("Unable to lookup remotes for repository '%1'." |
| 89 | + "\nMessage: %2").arg(repo->displayName()) |
| 90 | + .arg(r.errorText()) |
| 91 | + ); |
| 92 | + return; |
| 93 | + } |
| 94 | + |
| 95 | + if ( aliases.isEmpty() ) { |
| 96 | + QMessageBox::information( 0, tr("No Remotes found"), |
| 97 | + tr("No remotes configured for repository '%1'.") |
| 98 | + .arg(repo->displayName()) |
| 99 | + ); |
| 100 | + return; |
| 101 | + } |
| 102 | + |
| 103 | + foreach (const QString& alias, aliases) { |
| 104 | + Git::FetchOperation* op = new Git::FetchOperation( repo->gitRepo() ); |
| 105 | + op->setRemoteAlias( alias ); |
| 106 | + op->setBackgroundMode( true ); |
| 107 | + connect( op, SIGNAL(finished()), this, SLOT(fetchOperationFinished()) ); |
| 108 | + // TODO: create a central dialog to show progress of parallel operations |
| 109 | + op->execute(); |
| 110 | + } |
| 111 | + } |
| 112 | +} |
| 113 | + |
| 114 | +/** |
| 115 | + * @brief Called, when an non-blocking Git::Operation finished. |
| 116 | + */ |
| 117 | +void RemotesModule::onOperationFinished() |
| 118 | +{ |
| 119 | + Git::BaseOperation* op = qobject_cast<Git::BaseOperation*>( sender() ); |
| 120 | + Q_ASSERT( op ); |
| 121 | + Git::Result r( op->result() ); |
| 122 | + if ( !r ) { |
| 123 | + QMessageBox::warning( 0, tr("Operation failed."), |
| 124 | + tr("Operation failed. Message:\n %1").arg(r.errorText()) |
| 125 | + ); |
| 126 | + } |
| 127 | + |
| 128 | + // delete the operation |
| 129 | + op->deleteLater(); |
71 | 130 | }
|
72 | 131 |
|
0 commit comments