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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ INCLUDE_DIRECTORIES(
${libMacGitverCore_includes}
)

ADD_SUBDIRECTORY( CustomCommands )
ADD_SUBDIRECTORY( History )
ADD_SUBDIRECTORY( GitConfig )
ADD_SUBDIRECTORY( RefsViews )
Expand Down
53 changes: 53 additions & 0 deletions CustomCommands/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

PROJECT( MGV_MOD_CUSTOM_COMMANDS )

QT_PREPARE( Core Gui Widgets Xml )

INCLUDE_DIRECTORIES(
${MGV_MOD_CUSTOM_COMMANDS_SOURCE_DIR}
${MGV_MOD_CUSTOM_COMMANDS_BINARY_DIR}
)

SET( SRC_FILES

CustomCommandsModule.cpp
CustomCommandListCfgPage.cpp
EditCustomCommandDlg.cpp
CustomCommandDef.cpp
)

SET( HDR_FILES

CustomCommandsModule.hpp
CustomCommandListCfgPage.hpp
EditCustomCommandDlg.hpp
CustomCommandDef.hpp
)

SET( UI_FILES

EditCustomCommandDlg.ui
CustomCommandListCfgPage.ui
)

SET( HID_FILES
CustomCommandActions.hid
)


HIC( HIC_FILES ${HID_FILES} )
QT_UIC( UIC_FILES ${UI_FILES} )
QT_MOC( MOC_FILES ${HDR_FILES} )

ADD_MGV_MODULE(
CustomCommands

${SRC_FILES}
${HDR_FILES}
${MOC_FILES}
${UIC_FILES} ${UI_FILES}
${HIC_FILES} ${HID_FILES}
)

MSVC_SPLIT_SOURCES( ModCustomCommands )

44 changes: 44 additions & 0 deletions CustomCommands/CustomCommandActions.hid
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* MacGitver
* Copyright (C) 2012-2013 The MacGitver-Developers <dev@macgitver.org>
*
* (C) Sascha Cunz <sascha@macgitver.org>
*
* 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 <http://www.gnu.org/licenses/>.
*
*/

Ui CustomCommandActions {

Container CustComRepoAC {
DynamicActionMerger ExecOnBranch
{
Merger onMergeExecuteOnBranch;
};
};

/* This container lands at the bottom part of the 'tools' menu */
Container CustComAC {

Menu ExecuteOnRepo {
Text "R&epository";
Container CustComRepoAC;
};

Separator;
DynamicActionMerger ExecGlobally
{
Merger onMergeExecuteGlobally;
};

};

};
178 changes: 178 additions & 0 deletions CustomCommands/CustomCommandDef.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
/*
* MacGitver
* Copyright (C) 2012-2013 The MacGitver-Developers <dev@macgitver.org>
*
* (C) Sascha Cunz <sascha@macgitver.org>
*
* 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 <http://www.gnu.org/licenses/>.
*
*/

#include <QUuid>
#include <QDomElement>

#include "CustomCommandDef.hpp"

CustomCommandDef::CustomCommandDef()
{
newId();
}

CustomCommandDef::CustomCommandDef( const QDomElement& elSelf )
{
mId = elSelf.attribute( QLatin1String( "Id" ), QUuid::createUuid().toString() );

mName = elSelf.attribute( QLatin1String( "Name" ) );
mRunModal = elSelf.attribute( QLatin1String( "RunModal" ), QLatin1String( "0" ) )
== QLatin1String( "1" );

mRefresh = RefreshType( elSelf.attribute( QLatin1String( "RefreshType" ),
QLatin1String( "0" ) ).toInt() );

mExecute = ExecuteOn( elSelf.attribute( QLatin1String( "ExecuteOn" ),
QLatin1String( "0" ) ).toInt() );

mWorkDir = elSelf.attribute( QLatin1String( "WD" ) );
mCustomWorkDir = elSelf.attribute( QLatin1String( "UseWD" ), QLatin1String( "0" ) )
== QLatin1String( "1" );

QDomNode child = elSelf.firstChild();
if( child.isCDATASection() )
{
QDomCDATASection cds = child.toCDATASection();
mCommand = cds.data();
}
else if( child.isText() )
{
QDomText txt = child.toText();
mCommand = txt.data();
}
}

CustomCommandDef::CustomCommandDef( const CustomCommandDef& other )
{
mId = other.mId;
mName = other.mName;
mCommand = other.mCommand;
mExecute = other.mExecute;
mRunModal = other.mRunModal;
mRefresh = other.mRefresh;
mCustomWorkDir = other.mCustomWorkDir;
mWorkDir = other.mWorkDir;
}

CustomCommandDef::~CustomCommandDef()
{
}

void CustomCommandDef::newId()
{
mId = QUuid::createUuid().toString();
}

QString CustomCommandDef::id() const
{
return mId;
}

QString CustomCommandDef::name() const
{
return mName;
}

QString CustomCommandDef::command() const
{
return mCommand;
}

CustomCommandDef::ExecuteOn CustomCommandDef::executeOn() const
{
return mExecute;
}

bool CustomCommandDef::runModal() const
{
return mRunModal;
}

CustomCommandDef::RefreshType CustomCommandDef::refreshType() const
{
return mRefresh;
}

bool CustomCommandDef::useCustomWorkingDir() const
{
return mCustomWorkDir;
}

QString CustomCommandDef::customWorkingDir() const
{
return mWorkDir;
}

void CustomCommandDef::setId( const QString& id )
{
mId = id;
}

void CustomCommandDef::setName( const QString& name )
{
mName = name;
}

void CustomCommandDef::setCommand( const QString& command )
{
mCommand = command;
}

void CustomCommandDef::setExecuteOn( CustomCommandDef::ExecuteOn execOn )
{
mExecute = execOn;
}

void CustomCommandDef::setRunModal( bool runModal )
{
mRunModal = runModal;
}

void CustomCommandDef::setRefreshType( CustomCommandDef::RefreshType type )
{
mRefresh = type;
}

void CustomCommandDef::setUseCustomWorkingDir( bool useCustomWorkingDir )
{
mCustomWorkDir = useCustomWorkingDir;
}

void CustomCommandDef::setCustomWorkingDir( const QString& dir )
{
mWorkDir = dir;
}

void CustomCommandDef::saveTo( QDomElement& elParent )
{
QDomDocument doc = elParent.ownerDocument();
QDomElement el = doc.createElement( QLatin1String( "Command" ) );

el.setAttribute( QLatin1String( "Name" ), mName );
el.setAttribute( QLatin1String( "RunModal" ), mRunModal ? 1 : 0 );
el.setAttribute( QLatin1String( "RefreshType" ), int( mRefresh ) );
el.setAttribute( QLatin1String( "ExecuteOn" ), int( mExecute ) );
el.setAttribute( QLatin1String( "UseWD" ), mCustomWorkDir ? 1 : 0 );
el.setAttribute( QLatin1String( "WD" ), mWorkDir );
el.setAttribute( QLatin1String( "Id" ), mId );

elParent.appendChild( el );

QDomCDATASection cmd = doc.createCDATASection( mCommand );
el.appendChild( cmd );
}
95 changes: 95 additions & 0 deletions CustomCommands/CustomCommandDef.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* MacGitver
* Copyright (C) 2012-2013 The MacGitver-Developers <dev@macgitver.org>
*
* (C) Sascha Cunz <sascha@macgitver.org>
*
* 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 <http://www.gnu.org/licenses/>.
*
*/

#ifndef MGV_CUSTOM_COMMANDS_DEF_HPP
#define MGV_CUSTOM_COMMANDS_DEF_HPP

#include <QSharedData>
#include <QString>
#include <QList>

class QDomElement;

class CustomCommandDef : public QSharedData
{
public:
enum ExecuteOn
{
ExecRootRepo = 1,
ExecSubRepo = 2,
ExecRootOrSubRepo = 3,
ExecBranch = 4,
ExecForEachSubmodule = 5,
ExecForEachSubmoduleDeep = 6,
ExecInWorkingTree = 7,
ExecGlobally = 8
};

enum RefreshType
{
RefreshNever,
RefreshSuccess,
RefreshFailure,
RefreshAlways
};

public:
typedef QExplicitlySharedDataPointer< CustomCommandDef > Ptr;
typedef QList< Ptr > List;

public:
CustomCommandDef();
CustomCommandDef( const QDomElement& elSelf );
CustomCommandDef( const CustomCommandDef& other );
~CustomCommandDef();

public:
QString id() const;
QString name() const;
QString command() const;
ExecuteOn executeOn() const;
bool runModal() const;
RefreshType refreshType() const;
bool useCustomWorkingDir() const;
QString customWorkingDir() const;

void newId();
void setId( const QString& id );
void setName( const QString& name );
void setCommand( const QString& command );
void setExecuteOn( ExecuteOn execOn );
void setRunModal( bool runModal );
void setRefreshType( RefreshType type );
void setUseCustomWorkingDir( bool useCustomWorkingDir );
void setCustomWorkingDir( const QString& dir );

public:
void saveTo( QDomElement& elParent );

private:
QString mId;
QString mName;
QString mCommand;
ExecuteOn mExecute;
bool mRunModal;
RefreshType mRefresh;
bool mCustomWorkDir;
QString mWorkDir;
};

#endif
Loading