diff --git a/Remotes/RemoteCreateEditDlg.ui b/Remotes/RemoteCreateEditDlg.ui
index 05f0b41..29f4053 100644
--- a/Remotes/RemoteCreateEditDlg.ui
+++ b/Remotes/RemoteCreateEditDlg.ui
@@ -6,75 +6,58 @@
0
0
- 428
- 307
+ 438
+ 340
-
- -
-
-
- Remote Server
+
+
-
+
+
+ URL
+
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+ txtUrl
-
-
-
-
-
- Url
-
-
- txtUrl
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- Name
-
-
- txtName
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- Push Url
-
-
-
- -
-
-
- false
-
-
- true
-
-
-
-
- -
+
-
+
+
+ Enter the full URI to the remote repository
+
+
+ true
+
+
+
+ -
+
+
+ false
+
+
+ true
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+ -
- Custom refspec for Fetch
+ Custom refspecs for Fetch
true
@@ -139,13 +122,36 @@
- -
-
-
- Qt::Horizontal
+
-
+
+
+ Alias
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
+
+
+ txtName
+
+
+
+ -
+
+
+
+
+
+ Enter an alias for the Git Remote ...
+
+
+ true
+
+
+
+ -
+
+
+ Push URL
@@ -159,10 +165,6 @@
- txtName
- txtUrl
- chkPushUrl
- txtPushUrl
chkRefSpecs
treeRefSpecs
txtEditRefSpec
diff --git a/Remotes/RemotesModule.cpp b/Remotes/RemotesModule.cpp
index dd002e6..c490c06 100644
--- a/Remotes/RemotesModule.cpp
+++ b/Remotes/RemotesModule.cpp
@@ -16,8 +16,12 @@
#include
#include
+#include
+
+#include "libGitWrap/Operations/RemoteOperations.hpp"
#include "libMacGitverCore/App/MacGitver.hpp"
+#include "libMacGitverCore/RepoMan/Repo.hpp"
#include "RemoteCreateEditDlg.h"
#include "RemotesModule.h"
@@ -35,7 +39,9 @@ BlueSky::View* RemotesModule::createRemotesView()
void RemotesModule::initialize()
{
setupActions( this );
- acRemotesAC->mergeInto( "RemotesMP" );
+
+ acRemotesAC->mergeInto( "RemotesMP" );
+ acRemotesFetchAC->mergeInto( "RemotesFetchMP" );
MacGitver::self().registerView( "Remotes", tr( "Remotes" ),
&RemotesModule::createRemotesView );
@@ -46,9 +52,81 @@ void RemotesModule::deinitialize()
MacGitver::self().unregisterView( "Remotes" );
}
-void RemotesModule::onRemoteCreate()
+/**
+ * @brief Menu action to create a remote and add it to a repository.
+ */
+void RemotesModule::onRemoteCreateEdit()
{
- RemoteCreateEditDlg().exec();
+ // TODO: requires a repository context (the repo to add the remote to)
+ // To edit an existing remote, the remote context is required
+ RemoteCreateEditDlg dlg;
+ //TODO: dlg.setContext( ctx );
+ dlg.exec();
+}
+
+void RemotesModule::onRemoteDelete()
+{
+ // TODO: requires the remote context (the remote to delete)
+}
+
+/**
+ * @brief Menu action to fetch all remotes of a repository.
+ */
+void RemotesModule::onRemotesFetchAll()
+{
+ // TODO: requires a repository context (the repo to fetch all remotes from)
+ // A sub-context (i.e. a branch) can further restrict, what is fetched
+ Heaven::Action* action = qobject_cast< Heaven::Action* >( sender() );
+ Q_ASSERT( action );
+ RM::Repo* repo = qobject_cast< RM::Repo* >( action->activatedBy() );
+ if( repo ) {
+ Git::Result r;
+ Git::Repository gitRepo = repo->gitRepo();
+ const QStringList aliases( gitRepo.allRemoteNames(r) );
+ if ( !r ) {
+ QMessageBox::warning( 0, tr("Lookup of remotes failed"),
+ tr("Unable to lookup remotes for repository '%1'."
+ "\nMessage: %2").arg(repo->displayName())
+ .arg(r.errorText())
+ );
+ return;
+ }
+
+ if ( aliases.isEmpty() ) {
+ QMessageBox::information( 0, tr("No Remotes found"),
+ tr("No remotes configured for repository '%1'.")
+ .arg(repo->displayName())
+ );
+ return;
+ }
+
+ foreach (const QString& alias, aliases) {
+ Git::FetchOperation* op = new Git::FetchOperation( repo->gitRepo() );
+ op->setRemoteAlias( alias );
+ op->setBackgroundMode( true );
+ connect( op, SIGNAL(finished()), this, SLOT(fetchOperationFinished()) );
+ // TODO: create a central dialog to show progress of parallel operations
+ op->execute();
+ }
+ }
+}
+
+/**
+ * @brief Called, when an non-blocking Git::Operation finished.
+ */
+void RemotesModule::onOperationFinished()
+{
+ Git::BaseOperation* op = qobject_cast( sender() );
+ Q_ASSERT( op );
+ Git::Result r( op->result() );
+ if ( !r ) {
+ QMessageBox::warning( 0, tr("Operation failed."),
+ tr("Operation failed. Message:\n %1").arg(r.errorText())
+ );
+ }
+
+ // delete the operation
+ op->deleteLater();
}
#if QT_VERSION < 0x050000
diff --git a/Remotes/RemotesModule.h b/Remotes/RemotesModule.h
index fd72b52..9ddf949 100644
--- a/Remotes/RemotesModule.h
+++ b/Remotes/RemotesModule.h
@@ -38,7 +38,16 @@ class RemotesModule : public Module, public RemotesModuleActions
static BlueSky::View* createRemotesView();
private slots:
- void onRemoteCreate();
+ // RemotesAC
+ void onRemoteCreateEdit();
+ void onRemoteDelete();
+
+private slots:
+ // RemotesFetchAC
+ void onRemotesFetchAll();
+
+private slots:
+ void onOperationFinished();
};
#endif
diff --git a/Remotes/RemotesModuleActions.hid b/Remotes/RemotesModuleActions.hid
index 4f7ffe4..3157f63 100644
--- a/Remotes/RemotesModuleActions.hid
+++ b/Remotes/RemotesModuleActions.hid
@@ -18,23 +18,28 @@ Ui RemotesModuleActions {
Container RemotesAC {
- Menu Remotes {
+ Menu MnuRemotes {
+ Text "Remotes";
- Text "R&emotes";
-
- Action RemotesCreate {
- Text "&Create...";
- _ConnectTo onRemoteCreate();
+ Action RemoteAdd {
+ Text "Add Remote ...";
+ _ConnectTo onRemoteCreateEdit();
};
- Action RemotesFetch {
- Text "&Fetch";
- };
- Action RemotesPush {
- Text "P&ush...";
- };
+ };
+ };
+
+ Container RemotesFetchAC {
+ Menu MnuFetch {
+ Text "Fetch";
+
+ Action RemotesFetchAll {
+ Text "All Remotes";
+ _ConnectTo onRemotesFetchAll();
+ };
+ Separator;
};
};
diff --git a/Repository/RepoTreeViewCtxMenu.hid b/Repository/RepoTreeViewCtxMenu.hid
index cbedc14..7016414 100644
--- a/Repository/RepoTreeViewCtxMenu.hid
+++ b/Repository/RepoTreeViewCtxMenu.hid
@@ -16,8 +16,6 @@
Ui RepoTreeViewCtxMenu {
-
-
Action Activate {
Text "&Activate";
StatusToolTip "Make this repository the active one.";
@@ -34,6 +32,9 @@ Ui RepoTreeViewCtxMenu {
Action Activate;
Separator;
+ MergePlace RemotesMP;
+ MergePlace RemotesFetchMP;
+ Separator;
Action Close;
};