Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 74 additions & 72 deletions Remotes/RemoteCreateEditDlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,75 +6,58 @@
<rect>
<x>0</x>
<y>0</y>
<width>428</width>
<height>307</height>
<width>438</width>
<height>340</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Remote Server</string>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>URL</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>txtUrl</cstring>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Url</string>
</property>
<property name="buddy">
<cstring>txtUrl</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="LineEdit" name="txtUrl">
<property name="mandatory" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name</string>
</property>
<property name="buddy">
<cstring>txtName</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="LineEdit" name="txtName">
<property name="mandatory" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="chkPushUrl">
<property name="text">
<string>Push Url</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="LineEdit" name="txtPushUrl">
<property name="enabled">
<bool>false</bool>
</property>
<property name="mandatory" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<item row="1" column="1">
<widget class="LineEdit" name="txtUrl">
<property name="placeholderText">
<string>Enter the full URI to the remote repository</string>
</property>
<property name="mandatory" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="LineEdit" name="txtPushUrl">
<property name="enabled">
<bool>false</bool>
</property>
<property name="mandatory" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QGroupBox" name="chkRefSpecs">
<property name="title">
<string>Custom refspec for Fetch</string>
<string>Custom refspecs for Fetch</string>
</property>
<property name="checkable">
<bool>true</bool>
Expand Down Expand Up @@ -139,13 +122,36 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Alias</string>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>txtName</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="LineEdit" name="txtName">
<property name="toolTip">
<string/>
</property>
<property name="placeholderText">
<string>Enter an alias for the Git Remote ...</string>
</property>
<property name="mandatory" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="chkPushUrl">
<property name="text">
<string>Push URL</string>
</property>
</widget>
</item>
Expand All @@ -159,10 +165,6 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>txtName</tabstop>
<tabstop>txtUrl</tabstop>
<tabstop>chkPushUrl</tabstop>
<tabstop>txtPushUrl</tabstop>
<tabstop>chkRefSpecs</tabstop>
<tabstop>treeRefSpecs</tabstop>
<tabstop>txtEditRefSpec</tabstop>
Expand Down
84 changes: 81 additions & 3 deletions Remotes/RemotesModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@

#include <QtPlugin>
#include <QFileDialog>
#include <QMessageBox>

#include "libGitWrap/Operations/RemoteOperations.hpp"

#include "libMacGitverCore/App/MacGitver.hpp"
#include "libMacGitverCore/RepoMan/Repo.hpp"

#include "RemoteCreateEditDlg.h"
#include "RemotesModule.h"
Expand All @@ -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 );
Expand All @@ -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<Git::BaseOperation*>( 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
Expand Down
11 changes: 10 additions & 1 deletion Remotes/RemotesModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
29 changes: 17 additions & 12 deletions Remotes/RemotesModuleActions.hid
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

};
Expand Down
5 changes: 3 additions & 2 deletions Repository/RepoTreeViewCtxMenu.hid
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

Ui RepoTreeViewCtxMenu {



Action Activate {
Text "&Activate";
StatusToolTip "Make this repository the active one.";
Expand All @@ -34,6 +32,9 @@ Ui RepoTreeViewCtxMenu {

Action Activate;
Separator;
MergePlace RemotesMP;
MergePlace RemotesFetchMP;
Separator;
Action Close;

};
Expand Down