diff options
author | hjk <hjk121@nokiamail.com> | 2014-07-29 09:49:14 +0200 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2014-07-29 15:55:32 +0200 |
commit | 3e830a781f7f5e86aa4c275b608f064dcb1a2481 (patch) | |
tree | 4f49ad6525cf9c36596990a77eef69ef89a09a2f | |
parent | a93cc37e419ae6c6158975df67322040299daf55 (diff) | |
download | qt-creator-3e830a781f7f5e86aa4c275b608f064dcb1a2481.tar.gz |
Git: Simplify action callback handling
Change-Id: I5fbf0c3c89ee66b8d4339ee9100f63b53aae41f4
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
-rw-r--r-- | src/plugins/git/gitplugin.cpp | 34 | ||||
-rw-r--r-- | src/plugins/git/gitplugin.h | 1 |
2 files changed, 5 insertions, 30 deletions
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 3584f50ecc..86eca7b04a 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -88,7 +88,6 @@ #include <QTest> #endif -Q_DECLARE_METATYPE(Git::Internal::GitClientMemberFunc) Q_DECLARE_METATYPE(Git::Internal::FileStates) using namespace Core; @@ -147,8 +146,6 @@ GitPlugin::GitPlugin() : m_submitActionTriggered(false) { m_instance = this; - const int mid = qRegisterMetaType<GitClientMemberFunc>(); - Q_UNUSED(mid) m_fileActions.reserve(10); m_projectActions.reserve(10); m_repositoryActions.reserve(50); @@ -259,7 +256,7 @@ QAction *GitPlugin::createRepositoryAction(ActionContainer *ac, } // Action to act on the repository forwarded to a git client member function -// taking the directory. Store the member function as data on the action. +// taking the directory. QAction *GitPlugin::createRepositoryAction(ActionContainer *ac, const QString &text, Id id, const Context &context, bool addToLocator, @@ -267,8 +264,10 @@ QAction *GitPlugin::createRepositoryAction(ActionContainer *ac, { // Set the member func as data and connect to generic slot QAction *action = createRepositoryAction(ac, text, id, context, addToLocator, keys); - action->setData(qVariantFromValue(func)); - connect(action, SIGNAL(triggered()), this, SLOT(gitClientMemberFuncRepositoryAction())); + connect(action, &QAction::triggered, [this, func]() -> void { + QTC_ASSERT(currentState().hasTopLevel(), return); + (m_gitClient->*func)(currentState().topLevel()); + }); return action; } @@ -1155,29 +1154,6 @@ void GitPlugin::continueOrAbortCommand() updateContinueAndAbortCommands(); } -// Retrieve member function of git client stored as user data of action -static inline GitClientMemberFunc memberFunctionFromAction(const QObject *o) -{ - if (o) { - if (const QAction *action = qobject_cast<const QAction *>(o)) { - const QVariant v = action->data(); - if (v.canConvert<GitClientMemberFunc>()) - return qvariant_cast<GitClientMemberFunc>(v); - } - } - return 0; -} - -void GitPlugin::gitClientMemberFuncRepositoryAction() -{ - const VcsBasePluginState state = currentState(); - QTC_ASSERT(state.hasTopLevel(), return); - // Retrieve member function and invoke on repository - GitClientMemberFunc func = memberFunctionFromAction(sender()); - QTC_ASSERT(func, return); - (m_gitClient->*func)(state.topLevel()); -} - void GitPlugin::cleanProject() { const VcsBasePluginState state = currentState(); diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h index 7b9c2b3b81..3f15e15051 100644 --- a/src/plugins/git/gitplugin.h +++ b/src/plugins/git/gitplugin.h @@ -121,7 +121,6 @@ private slots: void updateSubmodules(); void applyCurrentFilePatch(); void promptApplyPatch(); - void gitClientMemberFuncRepositoryAction(); void startAmendCommit(); void startFixupCommit(); |