diff --git a/Libs/libMacGitverCore/App/MgvPrimaryWindowActions.hid b/Libs/libMacGitverCore/App/MgvPrimaryWindowActions.hid index 11a375b5..cf66420b 100644 --- a/Libs/libMacGitverCore/App/MgvPrimaryWindowActions.hid +++ b/Libs/libMacGitverCore/App/MgvPrimaryWindowActions.hid @@ -48,7 +48,6 @@ Ui MgvPrimaryWindowActions { MergePlace ViewsListMP; }; - MergePlace RemotesMP; MergePlace WorkingTreeMP; Menu ToolsMenu { diff --git a/Modules/Remotes/CMakeLists.txt b/Modules/Remotes/CMakeLists.txt index f76cf72a..7a5604bd 100644 --- a/Modules/Remotes/CMakeLists.txt +++ b/Modules/Remotes/CMakeLists.txt @@ -11,22 +11,19 @@ INCLUDE_DIRECTORIES( BEFORE SET( SRC_FILES RemotesModule.cpp - RemotesView.cpp - RemotesViewContext.cpp - RemoteCreateEditDlg.cpp + RemotesDlg.cpp ) SET( HDR_FILES RemotesModule.h - RemotesView.h - RemotesViewContext.h - RemoteCreateEditDlg.h + RemotesDlg.h ) SET( UI_FILES - RemoteCreateEditDlg.ui + RemotesOptionsWdgt.ui + RemotesWdgt.ui ) SET( HID_FILES diff --git a/Modules/Remotes/RemoteCreateEditDlg.cpp b/Modules/Remotes/RemoteCreateEditDlg.cpp deleted file mode 100644 index eb1b152a..00000000 --- a/Modules/Remotes/RemoteCreateEditDlg.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012 Sascha Cunz - * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU General Public License (Version 2) as published by the Free Software Foundation. - * - * 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, see . - * - */ - -#include "RemoteCreateEditDlg.h" - -RemoteCreateEditDlg::RemoteCreateEditDlg() -{ - setupUi( this ); - setWindowTitle( trUtf8( "Create remote" ) ); - init(); -} - -RemoteCreateEditDlg::RemoteCreateEditDlg( Git::Remote remote ) -{ - setupUi( this ); - setWindowTitle( trUtf8( "Edit remote" ) ); - init(); - - mRemote = remote; - txtName->setText( mRemote.name() ); - txtUrl->setText( mRemote.url() ); -} - -void RemoteCreateEditDlg::init() -{ - connect( txtName, SIGNAL(textChanged(QString)), this, SLOT(onNameChanged(QString)) ); - connect( txtUrl, SIGNAL(textChanged(QString)), this, SLOT(onUrlChanged(QString)) ); - connect( txtPushUrl, SIGNAL(textChanged(QString)), this, SLOT(checkValid()) ); -} - -void RemoteCreateEditDlg::onNameChanged( const QString& newName ) -{ - if( !chkRefSpecs->isChecked() ) - { - // ... - } - checkValid(); -} - -void RemoteCreateEditDlg::onUrlChanged( const QString& newUrl ) -{ - if( !chkPushUrl->isChecked() ) - { - txtPushUrl->setText( newUrl ); - } - checkValid(); -} - -void RemoteCreateEditDlg::checkValid() -{ - bool okay = - !txtName->text().isEmpty() && - !txtUrl->text().isEmpty() && - ( !chkPushUrl->isChecked() || - ( chkPushUrl->isChecked() && !txtPushUrl->text().isEmpty() ) ); - - buttonBox->button( QDialogButtonBox::Ok )->setEnabled( okay ); -} - -void RemoteCreateEditDlg::accept() -{ -} diff --git a/Modules/Remotes/RemoteCreateEditDlg.h b/Modules/Remotes/RemoteCreateEditDlg.h deleted file mode 100644 index 1f55dbc2..00000000 --- a/Modules/Remotes/RemoteCreateEditDlg.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012 Sascha Cunz - * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU General Public License (Version 2) as published by the Free Software Foundation. - * - * 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, see . - * - */ - -#ifndef MGV_REMOTE_CREATE_EDIT_DLG_H -#define MGV_REMOTE_CREATE_EDIT_DLG_H - -#include "ui_RemoteCreateEditDlg.h" - -#include "libGitWrap/Remote.hpp" - -class RemoteCreateEditDlg : public QDialog, private Ui::RemoteCreateEditDlg -{ - Q_OBJECT -public: - RemoteCreateEditDlg(); - RemoteCreateEditDlg( Git::Remote remote ); - -private: - void init(); - -private: - void accept(); - -private slots: - void onNameChanged( const QString& newName ); - void onUrlChanged( const QString& newUrl ); - - void checkValid(); - -private: - Git::Remote mRemote; -}; - -#endif diff --git a/Modules/Remotes/RemoteCreateEditDlg.ui b/Modules/Remotes/RemoteCreateEditDlg.ui deleted file mode 100644 index 05f0b419..00000000 --- a/Modules/Remotes/RemoteCreateEditDlg.ui +++ /dev/null @@ -1,225 +0,0 @@ - - - RemoteCreateEditDlg - - - - 0 - 0 - 428 - 307 - - - - - - - Remote Server - - - - - - Url - - - txtUrl - - - - - - - true - - - - - - - Name - - - txtName - - - - - - - true - - - - - - - Push Url - - - - - - - false - - - true - - - - - - - - - - Custom refspec for Fetch - - - true - - - false - - - - - - Add - - - - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - - - - - Remove - - - - - - - Update - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - LineEdit - QLineEdit -
libMacGitverCore/Widgets/LineEdit.h
-
-
- - txtName - txtUrl - chkPushUrl - txtPushUrl - chkRefSpecs - treeRefSpecs - txtEditRefSpec - btnAddRefSpec - btnUpdateRefSpec - btnRemoveRefSpec - buttonBox - - - - - buttonBox - accepted() - RemoteCreateEditDlg - accept() - - - 252 - 302 - - - 157 - 274 - - - - - buttonBox - rejected() - RemoteCreateEditDlg - reject() - - - 320 - 302 - - - 286 - 274 - - - - - chkPushUrl - toggled(bool) - txtPushUrl - setEnabled(bool) - - - 61 - 103 - - - 106 - 99 - - - - -
diff --git a/Modules/Remotes/RemotesDlg.cpp b/Modules/Remotes/RemotesDlg.cpp new file mode 100644 index 00000000..209bcd27 --- /dev/null +++ b/Modules/Remotes/RemotesDlg.cpp @@ -0,0 +1,247 @@ +/* + * MacGitver + * Copyright (C) 2012 Sascha Cunz + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License (Version 2) as published by the Free Software Foundation. + * + * 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, see . + * + */ + +#include "RemotesDlg.h" + +#include "libMacGitverCore/RepoMan/Remote.hpp" +#include "libMacGitverCore/RepoMan/Repo.hpp" + +#include + +RemotesOptionsWdgt::RemotesOptionsWdgt() +{ + setupUi(this); +} + + +RemotesWdgt::RemotesWdgt() +{ + setupUi(this); +} + + +RemotesDlg::RemotesDlg(RM::Repo* repo) +{ + setDialogWidgets(mRemotesWdgt, mRemotesOptsWdgt); + + connect(mRemotesWdgt->btnAddRemote, &QAbstractButton::clicked, + this, &RemotesDlg::onAddRemote); + connect(mRemotesWdgt->btnDeleteRemote, &QAbstractButton::clicked, + this, &RemotesDlg::onDeleteRemote); + connect(mRemotesWdgt->txtUrl, &QLineEdit::textChanged, + this, &RemotesDlg::onUrlChanged); + + connect( mRemotesOptsWdgt->txtPushUrl, &QLineEdit::textChanged, + this, &RemotesDlg::checkValid ); + + if (!repo) { + // TODO: this should never happen and we should assert out here. + setEnabled(false); + setWindowTitle( tr("Error: Needs a repository context!") ); + return; + } + + setWindowTitle( tr("Remotes in \"%1\"").arg(repo->displayName()) ); + + mRemotesWdgt->txtRemotes->installEventFilter(this); +} + +void RemotesDlg::updateValues(const QString& remoteAlias) +{ + // TODO: implement dialog update + //RM::Remote* remote = mRepoContext->remotes(remoteName); + //txtUrl->setText( remote ? remote->url() : QString() ); + //txtPushUrl->setText( remote ? remote->pushUrl() : QString() ); + //treeRefSpecs->model()->setRemote(remote); +} + +/** + * @internal + * @brief Clear the fields for the current selected Remote. + */ +void RemotesDlg::clear() +{ + mRemotesWdgt->txtUrl->clear(); + + mRemotesOptsWdgt->txtEditRefSpec->clear(); + mRemotesOptsWdgt->txtPushUrl->clear(); + mRemotesOptsWdgt->treeRefSpecs->setModel(nullptr); +} + +bool RemotesDlg::modeCanEnter(RemotesDlg::EditMode mode) const +{ + if (mode == EditMode::Rename) { + return mRemotesWdgt->txtRemotes->currentIndex() > -1; + } + + return true; +} + +void RemotesDlg::modeEnter(EditMode mode) +{ + Q_ASSERT(mMode == EditMode::Edit); + if (!modeCanEnter(mode)) { + return; + } + + mMode = mode; + + mRemotesWdgt->btnAddRemote->setEnabled(false); + mRemotesWdgt->btnDeleteRemote->setEnabled(false); + mRemotesWdgt->txtRemotes->setEditable(true); + + switch (mMode) { + case EditMode::Create: + + mRemotesWdgt->txtRemotes->lineEdit()->setPlaceholderText(tr("Enter a name ...")); + //txtRemotes->lineEdit()->clear(); + mRemotesWdgt->txtUrl->setPlaceholderText(tr("Enter a URL for the new Remote ...")); + clear(); + + break; + + case EditMode::Rename: + mRemotesWdgt->txtRemotes->lineEdit()->setText(mRemotesWdgt->txtRemotes->currentText()); + mRemotesWdgt->txtRemotes->lineEdit()->selectAll(); + + break; + + case EditMode::Edit: + default: + break; + } + + mRemotesWdgt->txtRemotes->setFocus(); +} + +void RemotesDlg::modeLeave(bool accept) +{ + if (accept) { + switch (mMode) { + case EditMode::Create: + { + QString remoteAlias = mRemotesWdgt->txtRemotes->lineEdit()->text(); + // TODO: implementation to create an RM::Remote + qCritical("Not implemented yet: Create a Remote via RepoMan."); + break; + } + + case EditMode::Rename: + { + QString oldRemoteAlias = mRemotesWdgt->txtRemotes->currentText(); + QString newRemoteAlias = mRemotesWdgt->txtRemotes->lineEdit()->text(); + // TODO: implementation to rename an RM::Remote + qCritical("Not implemented yet: Rename a Remote via RepoMan."); + break; + } + + case EditMode::Edit: + default: + break; + } + } + + mRemotesWdgt->txtUrl->setPlaceholderText(QString()); + mRemotesWdgt->btnAddRemote->setEnabled(true); + mRemotesWdgt->btnDeleteRemote->setEnabled(true); + mRemotesWdgt->txtRemotes->setEditable(false); + mRemotesWdgt->txtRemotes->update(); + + // switch to default mode + mMode = EditMode::Edit; +} + +void RemotesDlg::checkValid() +{ + bool okay = !mRemotesWdgt->txtRemotes->currentText().isEmpty(); + okay &= !mRemotesWdgt->txtUrl->text().isEmpty(); + + setAcceptable(okay); +} + +void RemotesDlg::accept() +{ + if (mMode == EditMode::Edit) { + QDialog::accept(); + } + else { + modeLeave(true); + } +} + +void RemotesDlg::onAddRemote() +{ + modeEnter(EditMode::Create); +} + +void RemotesDlg::onDeleteRemote() +{ + int r = QMessageBox::question(this, tr("Delete selected Remote?"), + tr("Delete the Remote \"%1\" from the " + "repository \"%2\"?") + .arg(mRemotesWdgt->txtRemotes->currentText()) + .arg(mRepoContext->displayName())); + if (r == QMessageBox::Yes) { + // TODO: implement deletion of selected Remote + } +} + +void RemotesDlg::onCurrentRemoteChanged(const QString &alias) +{ + mRemotesWdgt->btnDeleteRemote->setEnabled(mRemotesWdgt->txtRemotes->currentIndex() > -1); + updateValues(alias); +} + +void RemotesDlg::onUrlChanged(const QString& newUrl) +{ + if( !mRemotesOptsWdgt->chkPushUrl->isChecked() ) { + mRemotesOptsWdgt->txtPushUrl->setText( newUrl ); + } + checkValid(); +} + +void RemotesDlg::reject() +{ + if (mMode != EditMode::Edit) { + modeLeave(false); + } + else { + QDialog::reject(); + } +} + +/** + * @internal + * + * @brief Handles the double-click for the remotes combo box. + * + * @param o the event sender + * + * @param e the event + * + * @return + */ +bool RemotesDlg::eventFilter(QObject* o, QEvent* e) +{ + if (Q_LIKELY(o == mRemotesWdgt->txtRemotes)) { + if (e->type() == QEvent::MouseButtonDblClick) { + modeEnter(EditMode::Rename); + return true; + } + } + + return QObject::eventFilter(o, e); +} diff --git a/Modules/Remotes/RemotesDlg.h b/Modules/Remotes/RemotesDlg.h new file mode 100644 index 00000000..104c0794 --- /dev/null +++ b/Modules/Remotes/RemotesDlg.h @@ -0,0 +1,99 @@ +/* + * MacGitver + * Copyright (C) 2012 Sascha Cunz + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License (Version 2) as published by the Free Software Foundation. + * + * 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, see . + * + */ + +#pragma once + +#include "libMacGitverCore/Widgets/ExpandableDlg.hpp" + +#include "ui_RemotesOptionsWdgt.h" +#include "ui_RemotesWdgt.h" + +#include + +namespace RM +{ + class Repo; +} + +class RemotesOptionsWdgt : public QWidget, Ui::RemotesOptionsWdgt +{ + Q_OBJECT + + friend class RemotesDlg; + +public: + RemotesOptionsWdgt(); +}; + +class RemotesWdgt : public QWidget, Ui::RemotesWdgt +{ + Q_OBJECT + + friend class RemotesDlg; + +public: + RemotesWdgt(); +}; + +class RemotesDlg : public ExpandableDlg +{ + Q_OBJECT + +public: + enum EditMode + { + Edit = 0, + Create, + Rename + }; + +public: + RemotesDlg(RM::Repo* repo); + +private: + void init(); + +private: + // virtual slots + void accept(); + void reject(); + +private: + bool eventFilter(QObject* o, QEvent* e); + + void updateValues(const QString &remoteAlias); + void clear(); + + bool modeCanEnter(EditMode mode) const; + void modeEnter(EditMode mode); + void modeLeave(bool accept); + +private slots: + void checkValid(); + + void onAddRemote(); + void onDeleteRemote(); + void onCurrentRemoteChanged(const QString& alias); + void onUrlChanged(const QString& newUrl); + +private: + QPointer mRemotesOptsWdgt = new RemotesOptionsWdgt; + QPointer mRemotesWdgt = new RemotesWdgt; + +private: + RM::Repo* mRepoContext = nullptr; + EditMode mMode = EditMode::Edit; +}; diff --git a/Modules/Remotes/RemotesModule.cpp b/Modules/Remotes/RemotesModule.cpp index 05e7d295..d4f627cf 100644 --- a/Modules/Remotes/RemotesModule.cpp +++ b/Modules/Remotes/RemotesModule.cpp @@ -14,31 +14,30 @@ * */ -#include -#include +#include "libGitWrap/Operations/RemoteOperations.hpp" #include "libMacGitverCore/App/MacGitver.hpp" +#include "libMacGitverCore/RepoMan/RepoMan.hpp" -#include "RemoteCreateEditDlg.h" +#include "RemotesDlg.h" #include "RemotesModule.h" -#include "RemotesView.h" -RemotesModule::RemotesModule() -{ -} +#include +#include +#include -BlueSky::View* RemotesModule::createRemotesView() +RemotesModule::RemotesModule() { - return new RemotesView; } void RemotesModule::initialize() { setupActions( this ); - acRemotesAC->mergeInto( "RemotesMP" ); - MacGitver::self().registerView( "Remotes", tr( "Remotes" ), - &RemotesModule::createRemotesView ); + acFetchAC->mergeInto( "FetchMP" ); + acFetchThisAC->mergeInto( "FetchThisMP" ); + acRemotesAC->mergeInto( "RemotesMP" ); + acPushAC->mergeInto( "PushMP" ); } void RemotesModule::deinitialize() @@ -46,7 +45,91 @@ 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::onManageRemotes() { - RemoteCreateEditDlg().exec(); + Heaven::Action* a = qobject_cast( sender() ); + Q_ASSERT(a); + + // TODO: reliably determine the repository context + QObject* actionCtx = a->activatedBy(); + RM::Repo* repoCtx = actionCtx ? static_cast( actionCtx ) + : MacGitver::repoMan().activeRepository(); + + RemotesDlg( repoCtx ).exec(); } + +/** + * @brief Menu action to fetch all remotes of a repository. + */ +void RemotesModule::onFetchAllRemotes() +{ + // 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, &Git::FetchOperation::finished, + this, &RemotesModule::onOperationFinished ); + // TODO: create a central dialog to show progress of parallel operations + op->execute(); + } + } +} + +void RemotesModule::onFetchThis() +{ + // TODO: implementation + // Requires a "remote" or "remote branch" context. +} + +void RemotesModule::onPushToAllRemotes() +{ + // TODO: implementation +} + +/** + * @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(); +} + diff --git a/Modules/Remotes/RemotesModule.h b/Modules/Remotes/RemotesModule.h index fd72b521..e1979bae 100644 --- a/Modules/Remotes/RemotesModule.h +++ b/Modules/Remotes/RemotesModule.h @@ -14,8 +14,7 @@ * */ -#ifndef MGV_MODULE_REMOTES_H -#define MGV_MODULE_REMOTES_H +#pragma once #include "libMacGitverCore/MacGitver/Module.h" @@ -34,11 +33,21 @@ class RemotesModule : public Module, public RemotesModuleActions void initialize(); void deinitialize(); -private: - static BlueSky::View* createRemotesView(); +private slots: + // RemotesAC + void onManageRemotes(); private slots: - void onRemoteCreate(); -}; + // FetchAC + void onFetchAllRemotes(); -#endif + // FetchThisAC + void onFetchThis(); + +private slots: + // PushAC + void onPushToAllRemotes(); + +private slots: + void onOperationFinished(); +}; diff --git a/Modules/Remotes/RemotesModuleActions.hid b/Modules/Remotes/RemotesModuleActions.hid index 4f7ffe4a..2c07f6e9 100644 --- a/Modules/Remotes/RemotesModuleActions.hid +++ b/Modules/Remotes/RemotesModuleActions.hid @@ -18,23 +18,52 @@ Ui RemotesModuleActions { Container RemotesAC { - Menu Remotes { + Action ManageRemotes { + Text "Remotes ..."; + _ConnectTo onManageRemotes(); + }; - Text "R&emotes"; + }; - Action RemotesCreate { - Text "&Create..."; - _ConnectTo onRemoteCreate(); - }; + Container FetchAC { - Action RemotesFetch { - Text "&Fetch"; + Menu MnuFetch { + Text "Fetch"; + + Action FetchAll { + Text "Fetch All Remotes"; + _ConnectTo onFetchAllRemotes(); }; - Action RemotesPush { - Text "P&ush..."; + Separator; + + // TODO: Add DAM to fetch a single Remote + }; + + }; + + Container FetchThisAC { + + Action FetchThis { + Text "Fetch This"; + _ConnectTo onFetchThis(); + }; + + }; + + Container PushAC { + + Menu MnuPush { + Text "Push"; + + Action PushToAll { + Text "Push To All Remotes"; + _ConnectTo onPushToAllRemotes(); }; + Separator; + + // TODO: Add DAM to push to a single Remote }; }; diff --git a/Modules/Remotes/RemotesOptionsWdgt.ui b/Modules/Remotes/RemotesOptionsWdgt.ui new file mode 100644 index 00000000..3273203b --- /dev/null +++ b/Modules/Remotes/RemotesOptionsWdgt.ui @@ -0,0 +1,106 @@ + + + RemotesOptionsWdgt + + + + 0 + 0 + 371 + 205 + + + + Form + + + + + + + 0 + 0 + + + + Push URL + + + + + + + false + + + true + + + + + + + Custom refspecs for Fetch + + + true + + + false + + + + + + + + + Update + + + + + + + Remove + + + + + + + Add + + + + + + + + 0 + 0 + + + + + 0 + 50 + + + + + + + + + + + + LineEdit + QLineEdit +
libMacGitverCore/Widgets/LineEdit.h
+
+
+ + +
diff --git a/Modules/Remotes/RemotesView.cpp b/Modules/Remotes/RemotesView.cpp deleted file mode 100644 index b7f56836..00000000 --- a/Modules/Remotes/RemotesView.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012 Sascha Cunz - * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU General Public License (Version 2) as published by the Free Software Foundation. - * - * 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, see . - * - */ - -#include - -#include "RemotesView.h" -#include "RemotesViewContext.h" - -RemotesView::RemotesView() - : View( "Remotes" ) - , mCtx( NULL ) -{ - mTreeView = new QTreeView(); - mTreeView->setFrameShape( QFrame::NoFrame ); - - setWidget( mTreeView ); - - setViewName( trUtf8( "Remotes" ) ); -} - -/* -Heaven::ViewContext* RemotesView::createContext() -{ - return new RemotesViewContext; -} - -void RemotesView::setContext( Heaven::ViewContext* context ) -{ - //GlobalView::setContext( context ); - mCtx = qobject_cast< RemotesViewContext* >( context ); - Q_ASSERT( mCtx ); - - mTreeView->setModel( mCtx->model() ); -} -*/ diff --git a/Modules/Remotes/RemotesView.h b/Modules/Remotes/RemotesView.h deleted file mode 100644 index f42b9656..00000000 --- a/Modules/Remotes/RemotesView.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012 Sascha Cunz - * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU General Public License (Version 2) as published by the Free Software Foundation. - * - * 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, see . - * - */ - -#pragma once - -#include "libBlueSky/Views.hpp" - -class QTreeView; - -class RemotesViewContext; - -class RemotesView : public BlueSky::View -{ - Q_OBJECT -public: - RemotesView(); - -protected: - //Heaven::ViewContext* createContext(); - //void setContext( Heaven::ViewContext* context ); - -private: - RemotesViewContext* mCtx; - QTreeView* mTreeView; -}; diff --git a/Modules/Remotes/RemotesViewContext.cpp b/Modules/Remotes/RemotesViewContext.cpp deleted file mode 100644 index 734d060c..00000000 --- a/Modules/Remotes/RemotesViewContext.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012 Sascha Cunz - * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU General Public License (Version 2) as published by the Free Software Foundation. - * - * 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, see . - * - */ - -#include - -#include "libMacGitverCore/App/MacGitver.hpp" - -#include "RemotesViewContext.h" - -RemotesViewContext::RemotesViewContext() - : ViewContext() - , mModel( NULL ) -{ - connect( &MacGitver::self(), SIGNAL(repositoryChanged(Git::Repository)), - this, SLOT(repositoryChanged(Git::Repository)) ); - - mModel = new QStandardItemModel( 0, 1, this ); -} - -QAbstractItemModel* RemotesViewContext::model() -{ - return mModel; -} diff --git a/Modules/Remotes/RemotesViewContext.h b/Modules/Remotes/RemotesViewContext.h deleted file mode 100644 index 83e30155..00000000 --- a/Modules/Remotes/RemotesViewContext.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012 Sascha Cunz - * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU General Public License (Version 2) as published by the Free Software Foundation. - * - * 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, see . - * - */ - -#ifndef MGV_REMOTES_VIEW_CONTEXT_H -#define MGV_REMOTES_VIEW_CONTEXT_H - -#include "libBlueSky/Contexts.hpp" - -class QAbstractItemModel; -class QStandardItem; -class QStandardItemModel; - -class RemotesViewContext : public BlueSky::ViewContext -{ - Q_OBJECT -public: - RemotesViewContext(); - -public: - QAbstractItemModel* model(); - -private: - QStandardItemModel* mModel; -}; - -#endif diff --git a/Modules/Remotes/RemotesWdgt.ui b/Modules/Remotes/RemotesWdgt.ui new file mode 100644 index 00000000..ca3ec5b7 --- /dev/null +++ b/Modules/Remotes/RemotesWdgt.ui @@ -0,0 +1,99 @@ + + + RemotesWdgt + + + + 0 + 0 + 328 + 81 + + + + + + + + 0 + 0 + + + + Git Remote + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + <p>Select the Git Remote, you like to edit.<br/></p> +<p>Tip: Double-Click to rename a selected Remote.</b> + + + + + + + + Add a new Remote. + + + + + + + + + + + false + + + Delete this Remote. + + + - + + + + + + + + 0 + 0 + + + + URL + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + txtUrl + + + + + + + true + + + + + + + + LineEdit + QLineEdit +
libMacGitverCore/Widgets/LineEdit.h
+
+
+ + +
diff --git a/Modules/Repository/RepoTreeViewCtxMenu.hid b/Modules/Repository/RepoTreeViewCtxMenu.hid index cbedc14f..b2324935 100644 --- a/Modules/Repository/RepoTreeViewCtxMenu.hid +++ b/Modules/Repository/RepoTreeViewCtxMenu.hid @@ -16,8 +16,6 @@ Ui RepoTreeViewCtxMenu { - - Action Activate { Text "&Activate"; StatusToolTip "Make this repository the active one."; @@ -34,6 +32,11 @@ Ui RepoTreeViewCtxMenu { Action Activate; Separator; + + MergePlace RemotesMP; + MergePlace FetchMP; + Separator; + Action Close; }; @@ -41,7 +44,11 @@ Ui RepoTreeViewCtxMenu { Menu CtxMenuSMRepo { Action Activate; + Separator; + MergePlace RemotesMP; + MergePlace FetchMP; + Separator; }; }; diff --git a/Modules/Repository/RepositoryModule.hid b/Modules/Repository/RepositoryModule.hid index 96b7a472..9e9fc17b 100644 --- a/Modules/Repository/RepositoryModule.hid +++ b/Modules/Repository/RepositoryModule.hid @@ -43,14 +43,27 @@ Ui RepositoryActions { }; + Menu MnuActiveRepo { + Text "Active repository"; + + MergePlace RemotesMP; + Separator; + + MergePlace FetchMP; + MergePlace PushMP; + }; + Container RepositoryMenuAC { Action RepositoryOpen; Menu RepoOpenRecent; Separator; + Action RepositoryCreate; Action RepositoryClone; + Separator; + Menu MnuActiveRepo; }; };