From 3391236e27938ab1aa973e6f1623ad70a8f18a9b Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 10 May 2015 16:46:46 +0100 Subject: [PATCH 01/75] Remove useless RepoMan tests These tests actually didn't test very much, are in the wrong library and no longer compatible with how the RepoMan will work. We need to investigate further in how to do actually useful testing of the RepoMan. --- testMacGitverCore/CMakeLists.txt | 24 -- testMacGitverCore/Infra/EventCatcher.cpp | 268 ----------------------- testMacGitverCore/Infra/EventCatcher.hpp | 151 ------------- testMacGitverCore/Infra/TempRepo.cpp | 48 ---- testMacGitverCore/Infra/TempRepo.hpp | 77 ------- testMacGitverCore/Test_Branch.cpp | 25 --- testMacGitverCore/Test_Branch.hpp | 27 --- testMacGitverCore/Test_Namespace.cpp | 25 --- testMacGitverCore/Test_Namespace.hpp | 27 --- testMacGitverCore/Test_Ref.cpp | 25 --- testMacGitverCore/Test_Ref.hpp | 27 --- testMacGitverCore/Test_RefLog.cpp | 25 --- testMacGitverCore/Test_RefLog.hpp | 27 --- testMacGitverCore/Test_RefTreeNode.cpp | 25 --- testMacGitverCore/Test_RefTreeNode.hpp | 27 --- testMacGitverCore/Test_Remote.cpp | 25 --- testMacGitverCore/Test_Remote.hpp | 27 --- testMacGitverCore/Test_Repo.cpp | 52 ----- testMacGitverCore/Test_Repo.hpp | 27 --- testMacGitverCore/Test_RepoMan.cpp | 64 ------ testMacGitverCore/Test_RepoMan.hpp | 43 ---- testMacGitverCore/Test_Submodule.cpp | 25 --- testMacGitverCore/Test_Submodule.hpp | 27 --- testMacGitverCore/Test_Tag.cpp | 25 --- testMacGitverCore/Test_Tag.hpp | 27 --- 25 files changed, 1170 deletions(-) delete mode 100644 testMacGitverCore/Infra/EventCatcher.cpp delete mode 100644 testMacGitverCore/Infra/EventCatcher.hpp delete mode 100644 testMacGitverCore/Infra/TempRepo.cpp delete mode 100644 testMacGitverCore/Infra/TempRepo.hpp delete mode 100644 testMacGitverCore/Test_Branch.cpp delete mode 100644 testMacGitverCore/Test_Branch.hpp delete mode 100644 testMacGitverCore/Test_Namespace.cpp delete mode 100644 testMacGitverCore/Test_Namespace.hpp delete mode 100644 testMacGitverCore/Test_Ref.cpp delete mode 100644 testMacGitverCore/Test_Ref.hpp delete mode 100644 testMacGitverCore/Test_RefLog.cpp delete mode 100644 testMacGitverCore/Test_RefLog.hpp delete mode 100644 testMacGitverCore/Test_RefTreeNode.cpp delete mode 100644 testMacGitverCore/Test_RefTreeNode.hpp delete mode 100644 testMacGitverCore/Test_Remote.cpp delete mode 100644 testMacGitverCore/Test_Remote.hpp delete mode 100644 testMacGitverCore/Test_Repo.cpp delete mode 100644 testMacGitverCore/Test_Repo.hpp delete mode 100644 testMacGitverCore/Test_RepoMan.cpp delete mode 100644 testMacGitverCore/Test_RepoMan.hpp delete mode 100644 testMacGitverCore/Test_Submodule.cpp delete mode 100644 testMacGitverCore/Test_Submodule.hpp delete mode 100644 testMacGitverCore/Test_Tag.cpp delete mode 100644 testMacGitverCore/Test_Tag.hpp diff --git a/testMacGitverCore/CMakeLists.txt b/testMacGitverCore/CMakeLists.txt index 721b4d8e..c215b0ba 100644 --- a/testMacGitverCore/CMakeLists.txt +++ b/testMacGitverCore/CMakeLists.txt @@ -21,18 +21,6 @@ SET(SRC_FILES Infra/main.cpp Infra/Fixture.cpp Infra/TempDirProvider.cpp - Infra/TempRepo.cpp - Infra/EventCatcher.cpp - - Test_RepoMan.cpp - Test_Repo.cpp - Test_Tag.cpp - Test_Submodule.cpp - Test_Branch.cpp - Test_Remote.cpp - Test_Namespace.cpp - Test_RefTreeNode.cpp - Test_RefLog.cpp Test_SHMParser.cpp ) @@ -41,18 +29,6 @@ SET(HDR_FILES Infra/Fixture.hpp Infra/TempDirProvider.hpp - Infra/TempRepo.hpp - Infra/EventCatcher.hpp - - Test_RepoMan.hpp - Test_Repo.hpp - Test_Submodule.hpp - Test_Tag.hpp - Test_Branch.hpp - Test_Remote.hpp - Test_Namespace.hpp - Test_RefTreeNode.hpp - Test_RefLog.hpp Test_SHMParser.hpp ) diff --git a/testMacGitverCore/Infra/EventCatcher.cpp b/testMacGitverCore/Infra/EventCatcher.cpp deleted file mode 100644 index 1616bfd7..00000000 --- a/testMacGitverCore/Infra/EventCatcher.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "libMacGitverCore/RepoMan/Repo.hpp" -#include "libMacGitverCore/RepoMan/Remote.hpp" -#include "libMacGitverCore/RepoMan/Ref.hpp" -#include "libMacGitverCore/RepoMan/RepoMan.hpp" -#include "libMacGitverCore/RepoMan/Tag.hpp" -#include "libMacGitverCore/RepoMan/Branch.hpp" -#include "libMacGitverCore/RepoMan/RefLog.hpp" -#include "libMacGitverCore/RepoMan/Submodule.hpp" -#include "libMacGitverCore/RepoMan/Namespace.hpp" -#include "libMacGitverCore/RepoMan/RefTreeNode.hpp" - -#include "Infra/EventCatcher.hpp" - -EventCatcher::EventCatcher() -{ - RM::Events::addReceiver(this); -} - -EventCatcher::~EventCatcher() -{ - RM::Events::delReceiver(this); -} - -void EventCatcher::clear() -{ - entries.clear(); -} - -EventCatcher::EventLogEntries EventCatcher::allEvents() const -{ - return entries; -} - -int EventCatcher::eventCount() const -{ - return entries.count(); -} - -int EventCatcher::eventCount(EventTypes type) -{ - int count = 0; - - foreach (const EventLogEntry& ele, entries) { - if (ele.type == type) { - count++; - } - } - - return count; -} - -int EventCatcher::eventCount(EventTypes type, RM::Base* p1) const -{ - int count = 0; - - foreach (const EventLogEntry& ele, entries) { - if (ele.type == type && ele.params.count() == 1 && ele.params[0] == p1) { - count++; - } - } - - return count; -} - -int EventCatcher::eventCount(EventTypes type, RM::Base* p1, RM::Base* p2) const -{ - int count = 0; - - foreach (const EventLogEntry& ele, entries) { - if (ele.type == type && ele.params.count() == 2 && ele.params[0] == p1 && - ele.params[1] == p2) { - count++; - } - } - - return count; -} - -void EventCatcher::recordEvent(EventTypes type, RM::Base* p1) -{ - EventLogEntry ele; - ele.type = type; - ele.params << p1; - entries << ele; -} - -void EventCatcher::recordEvent(EventTypes type, RM::Base* p1, RM::Base* p2) -{ - EventLogEntry ele; - ele.type = type; - ele.params << p1 << p2; - entries << ele; -} - -void EventCatcher::repositoryOpened(RM::Repo* repo) -{ - recordEvent(ecRepoOpened, repo); -} - -void EventCatcher::repositoryAboutToClose(RM::Repo* repo) -{ - recordEvent(ecRepoAboutToClose, repo); -} - -void EventCatcher::repositoryActivated(RM::Repo* repo) -{ - recordEvent(ecRepoActivated, repo); -} - -void EventCatcher::repositoryDeactivated(RM::Repo* repo) -{ - recordEvent(ecRepoDeactivated, repo); -} - -void EventCatcher::refTreeNodeCreated(RM::Repo* repo, RM::RefTreeNode* node) -{ - recordEvent(ecRefTreeNodeCreated, repo, node); -} - -void EventCatcher::refTreeNodeAboutToBeDeleted(RM::Repo* repo, RM::RefTreeNode* node) -{ - recordEvent(ecRefTreeNodeAboutToBeRemoved, repo, node); -} - -void EventCatcher::refCreated(RM::Repo* repo, RM::Ref* ref) -{ - recordEvent(ecRefCreated, repo, ref); -} - -void EventCatcher::refAboutToBeDeleted(RM::Repo* repo, RM::Ref* ref) -{ - recordEvent(ecRefAboutToBeRemoved, repo, ref); -} - -void EventCatcher::refMoved(RM::Repo* repo, RM::Ref* ref) -{ - recordEvent(ecRefMoved, repo, ref); -} - -void EventCatcher::refHeadDetached(RM::Repo* repo, RM::Ref* ref) -{ - recordEvent(ecRefHeadDetached, repo, ref); -} - -void EventCatcher::tagCreated(RM::Repo* repo, RM::Tag* tag) -{ - recordEvent(ecTagCreated, repo, tag); -} - -void EventCatcher::tagAboutToBeDeleted(RM::Repo* repo, RM::Tag* tag) -{ - recordEvent(ecTagAboutToBeDeleted, repo, tag); -} - -void EventCatcher::branchCreated(RM::Repo* repo, RM::Branch* branch) -{ - recordEvent(ecBranchCreated, repo, branch); -} - -void EventCatcher::branchAboutToBeDeleted(RM::Repo* repo, RM::Branch* branch) -{ - recordEvent(ecBranchAboutToBeDeleted, repo, branch); -} - -void EventCatcher::branchMoved(RM::Repo* repo, RM::Branch* branch) -{ - recordEvent(ecBranchMoved, repo, branch); -} - -void EventCatcher::branchUpstreamChanged(RM::Repo* repo, RM::Branch* branch) -{ - recordEvent(ecBranchUpstreamChanged, repo, branch); -} - -void EventCatcher::namespaceCreated(RM::Repo* repo, RM::Namespace* nameSpace) -{ - recordEvent(ecNamespaceCreated, repo, nameSpace); -} - -void EventCatcher::namespaceAboutToBeDeleted(RM::Repo* repo, RM::Namespace* nameSpace) -{ - recordEvent(ecNamespaceAboutToBeRemoved, repo, nameSpace); -} - -void EventCatcher::refLogChanged(RM::Repo* repo, RM::RefLog* reflog) -{ - recordEvent(ecRefLogChanged, repo, reflog); -} - -void EventCatcher::refLogNewEntry(RM::Repo* repo, RM::RefLog* reflog) -{ - recordEvent(ecRefLogNewEntry, repo, reflog); -} - -void EventCatcher::stageCreated(RM::Repo* repo, RM::Ref* ref) -{ - recordEvent(ecStageCreated, repo, ref); -} - -void EventCatcher::stageAboutToBeDeleted(RM::Repo* repo, RM::Ref* ref) -{ - recordEvent(ecStageAboutToBeRemoved, repo, ref); -} - -void EventCatcher::remoteCreated(RM::Repo* repo, RM::Remote* remote) -{ - recordEvent(ecRemoteCreated, repo, remote); -} - -void EventCatcher::remoteAboutToBeDeleted(RM::Repo* repo, RM::Remote* remote) -{ - recordEvent(ecRemoteAboutToBeRemoved, repo, remote); -} - -void EventCatcher::remoteModified(RM::Repo* repo, RM::Remote* remote) -{ - recordEvent(ecRemoteModified, repo, remote); -} - -void EventCatcher::submoduleCreated(RM::Repo* repo, RM::Submodule* submodule) -{ - recordEvent(ecSubmoduleCreated, repo, submodule); -} - -void EventCatcher::submoduleAboutToBeDeleted(RM::Repo* repo, RM::Submodule* submodule) -{ - recordEvent(ecSubmoduleAboutToBeDeleted, repo, submodule); -} - -void EventCatcher::submoduleMoved(RM::Repo* repo, RM::Submodule* submodule) -{ - recordEvent(ecSubmoduleMoved, repo, submodule); -} - -void EventCatcher::repositoryStateChanged(RM::Repo* repo) -{ - recordEvent(ecRepoStateChanged, repo); -} - -void EventCatcher::indexUpdated(RM::Repo* repo) -{ - recordEvent(ecIndexUpdated, repo); -} - -void EventCatcher::workTreeUpdated(RM::Repo* repo) -{ - recordEvent(ecWorkTreeUpdated, repo); -} - diff --git a/testMacGitverCore/Infra/EventCatcher.hpp b/testMacGitverCore/Infra/EventCatcher.hpp deleted file mode 100644 index a472e293..00000000 --- a/testMacGitverCore/Infra/EventCatcher.hpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 TEST_MGV_CORE_EVENT_CATCHER_HPP -#define TEST_MGV_CORE_EVENT_CATCHER_HPP - -#include "libMacGitverCore/RepoMan/Base.hpp" -#include "libMacGitverCore/RepoMan/Events.hpp" - -namespace RM -{ - class Repo; -} - -enum EventTypes { - // These are administrative for RepoMan - ecRepoOpened, - ecRepoAboutToClose, - ecRepoActivated, - ecRepoDeactivated, - - // These are more or less virtual events. They are artificially constructed in RepoMan - ecRefTreeNodeCreated, - ecRefTreeNodeAboutToBeRemoved, - - // The following list represent events that actually may occur inside a git repository - ecRefCreated, - ecRefAboutToBeRemoved, - ecRefMoved, - ecRefLinkChanged, // => SymLink target changed (i.e. in HEAD) - ecRefOrphaned, // Additional to ecRefLinkChanged - ecRefHeadDetached, // Additional to ecRefLinkChanged - - ecTagCreated, // Additional to ecRefCreated - ecTagAboutToBeDeleted, // Additional to ecRefDeleted - - ecBranchCreated, // Additional to ecRefCreated - ecBranchAboutToBeDeleted, // Additional to ecRefDeleted - ecBranchMoved, // Additional to ecRefMoved - - ecBranchUpstreamChanged, - - ecNamespaceCreated, - ecNamespaceAboutToBeRemoved, - - ecRefLogChanged, - ecRefLogNewEntry, - - ecStageCreated, // Additional to ecRefLogNewEntry and ecRefLogChanged - ecStageAboutToBeRemoved, // Additional to ecRefLogChanged - - ecRemoteCreated, - ecRemoteAboutToBeRemoved, - ecRemoteModified, - - ecSubmoduleCreated, - ecSubmoduleAboutToBeDeleted, - ecSubmoduleMoved, - - - // These will be very hard to implement: - ecRepoStateChanged, // Normal / Rebasing / Merging etc. - - ecIndexUpdated, // Any modification to the index should trigger this event - ecWorkTreeUpdated, // This cannot be determined relyable everywhere(But I got some idea...) - - ecLast // => to not warn for the ',' in C++98 -}; - -class EventCatcher : public RM::EventsInterface -{ -public: - struct EventLogEntry - { - EventTypes type; - RM::Base::List params; - }; - - typedef QVector EventLogEntries; - -public: - EventCatcher(); - ~EventCatcher(); - -public: - void clear(); - EventLogEntries allEvents() const; - - int eventCount() const; - int eventCount(EventTypes type); - int eventCount(EventTypes type, RM::Base* p1) const; - int eventCount(EventTypes type, RM::Base* p1, RM::Base* p2) const; - -private: - void recordEvent(EventTypes type, RM::Base* p1); - void recordEvent(EventTypes type, RM::Base* p1, RM::Base* p2); - -protected: - void repositoryOpened(RM::Repo* repo); - void repositoryAboutToClose(RM::Repo* repo); - void repositoryActivated(RM::Repo* repo); - void repositoryDeactivated(RM::Repo* repo); - void refTreeNodeCreated(RM::Repo* repo, RM::RefTreeNode* node); - void refTreeNodeAboutToBeDeleted(RM::Repo* repo, RM::RefTreeNode* node); - void refCreated(RM::Repo* repo, RM::Ref* ref); - void refAboutToBeDeleted(RM::Repo* repo, RM::Ref* ref); - void refMoved(RM::Repo* repo, RM::Ref* ref); - void refHeadDetached(RM::Repo* repo, RM::Ref* ref); - void tagCreated(RM::Repo* repo, RM::Tag* tag); - void tagAboutToBeDeleted(RM::Repo* repo, RM::Tag* tag); - void branchCreated(RM::Repo* repo, RM::Branch* branch); - void branchAboutToBeDeleted(RM::Repo* repo, RM::Branch* branch); - void branchMoved(RM::Repo* repo, RM::Branch* branch); - void branchUpstreamChanged(RM::Repo* repo, RM::Branch* branch); - void namespaceCreated(RM::Repo* repo, RM::Namespace* nameSpace); - void namespaceAboutToBeDeleted(RM::Repo* repo, RM::Namespace* nameSpace); - void refLogChanged(RM::Repo* repo, RM::RefLog* reflog); - void refLogNewEntry(RM::Repo* repo, RM::RefLog* reflog); - void stageCreated(RM::Repo* repo, RM::Ref* ref); - void stageAboutToBeDeleted(RM::Repo* repo, RM::Ref* ref); - void remoteCreated(RM::Repo* repo, RM::Remote* remote); - void remoteAboutToBeDeleted(RM::Repo* repo, RM::Remote* remote); - void remoteModified(RM::Repo* repo, RM::Remote* remote); - void submoduleCreated(RM::Repo* repo, RM::Submodule* submodule); - void submoduleAboutToBeDeleted(RM::Repo* repo, RM::Submodule* submodule); - void submoduleMoved(RM::Repo* repo, RM::Submodule* submodule); - void repositoryStateChanged(RM::Repo* repo); - void indexUpdated(RM::Repo* repo); - void workTreeUpdated(RM::Repo* repo); - -private: - EventLogEntries entries; -}; - -#endif diff --git a/testMacGitverCore/Infra/TempRepo.cpp b/testMacGitverCore/Infra/TempRepo.cpp deleted file mode 100644 index 544d51ac..00000000 --- a/testMacGitverCore/Infra/TempRepo.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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/RepoMan/Repo.hpp" -#include "libMacGitverCore/RepoMan/RepoMan.hpp" - -#include "Infra/Fixture.hpp" -#include "Infra/TempDirProvider.hpp" -#include "Infra/TempRepo.hpp" - -TempRepo::TempRepo(Fixture* fixture, const char* name) -{ - mTempRepoDir = fixture->prepareRepo(name); -} - -TempRepo::~TempRepo() -{ - QDir(mTempRepoDir).rmpath(QStringLiteral(".")); -} - -TempRepoOpener::TempRepoOpener(Fixture* fixture, const char* name) - : mTempRepo(fixture, name) -{ - mRepo = MacGitver::repoMan().open(mTempRepo); -} - -TempRepoOpener::~TempRepoOpener() -{ - mRepo->close(); -} diff --git a/testMacGitverCore/Infra/TempRepo.hpp b/testMacGitverCore/Infra/TempRepo.hpp deleted file mode 100644 index 21a69900..00000000 --- a/testMacGitverCore/Infra/TempRepo.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 TEST_MGV_TEMP_REPO_HPP -#define TEST_MGV_TEMP_REPO_HPP - -#include - -class Fixture; - -namespace RM -{ - class Repo; -} - -/** - * @brief Copy a Test-Repository and remove it after usage - */ -class TempRepo -{ -public: - TempRepo(Fixture* fixture, const char* name); - ~TempRepo(); - -public: - operator QString() const - { - return mTempRepoDir; - } - -private: - QString mTempRepoDir; -}; - -/** - * @brief Copy a Test-Repo, remove it after use and keep it opened in RepoMan as long - * as it is in use. - */ -class TempRepoOpener -{ -public: - TempRepoOpener(Fixture* fixture, const char* name); - ~TempRepoOpener(); - -public: - operator RM::Repo*() const - { - return mRepo; - } - - RM::Repo* operator->() const - { - return mRepo; - } - -private: - TempRepo mTempRepo; - RM::Repo* mRepo; -}; - -#endif diff --git a/testMacGitverCore/Test_Branch.cpp b/testMacGitverCore/Test_Branch.cpp deleted file mode 100644 index 45df3185..00000000 --- a/testMacGitverCore/Test_Branch.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "Test_Branch.hpp" - -TEST_F(Branch_Fixture, Trivial) -{ - -} diff --git a/testMacGitverCore/Test_Branch.hpp b/testMacGitverCore/Test_Branch.hpp deleted file mode 100644 index b64e07a2..00000000 --- a/testMacGitverCore/Test_Branch.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 TEST_MGVCORE_BRANCH_HPP -#define TEST_MGVCORE_BRANCH_HPP - -#include "Infra/Fixture.hpp" - -typedef Fixture Branch_Fixture; - -#endif diff --git a/testMacGitverCore/Test_Namespace.cpp b/testMacGitverCore/Test_Namespace.cpp deleted file mode 100644 index 8c7967c5..00000000 --- a/testMacGitverCore/Test_Namespace.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "Test_Namespace.hpp" - -TEST_F(Namespace_Fixture, Trivial) -{ - -} diff --git a/testMacGitverCore/Test_Namespace.hpp b/testMacGitverCore/Test_Namespace.hpp deleted file mode 100644 index 50d65041..00000000 --- a/testMacGitverCore/Test_Namespace.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 TEST_MGVCORE_NAMESPACE_HPP -#define TEST_MGVCORE_NAMESPACE_HPP - -#include "Infra/Fixture.hpp" - -typedef Fixture Namespace_Fixture; - -#endif diff --git a/testMacGitverCore/Test_Ref.cpp b/testMacGitverCore/Test_Ref.cpp deleted file mode 100644 index 1086b1ea..00000000 --- a/testMacGitverCore/Test_Ref.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "Test_Tag.hpp" - -TEST_F(Tag_Fixture, Trivial) -{ - -} diff --git a/testMacGitverCore/Test_Ref.hpp b/testMacGitverCore/Test_Ref.hpp deleted file mode 100644 index c6c96fcb..00000000 --- a/testMacGitverCore/Test_Ref.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 TEST_MGVCORE_REPO_MAN_HPP -#define TEST_MGVCORE_REPO_MAN_HPP - -#include "Fixture.hpp" - -typedef Fixture Repo_Fixture; - -#endif diff --git a/testMacGitverCore/Test_RefLog.cpp b/testMacGitverCore/Test_RefLog.cpp deleted file mode 100644 index 4205b4c5..00000000 --- a/testMacGitverCore/Test_RefLog.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "Test_RefLog.hpp" - -TEST_F(RefLog_Fixture, Trivial) -{ - -} diff --git a/testMacGitverCore/Test_RefLog.hpp b/testMacGitverCore/Test_RefLog.hpp deleted file mode 100644 index 9eada47e..00000000 --- a/testMacGitverCore/Test_RefLog.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 TEST_MGVCORE_REFLOG_HPP -#define TEST_MGVCORE_REFLOG_HPP - -#include "Infra/Fixture.hpp" - -typedef Fixture RefLog_Fixture; - -#endif diff --git a/testMacGitverCore/Test_RefTreeNode.cpp b/testMacGitverCore/Test_RefTreeNode.cpp deleted file mode 100644 index 21597337..00000000 --- a/testMacGitverCore/Test_RefTreeNode.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "Test_RefTreeNode.hpp" - -TEST_F(RefTreeNode_Fixture, Trivial) -{ - -} diff --git a/testMacGitverCore/Test_RefTreeNode.hpp b/testMacGitverCore/Test_RefTreeNode.hpp deleted file mode 100644 index 2bf7112d..00000000 --- a/testMacGitverCore/Test_RefTreeNode.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 TEST_MGVCORE_REF_TREE_NODE_HPP -#define TEST_MGVCORE_REF_TREE_NODE_HPP - -#include "Infra/Fixture.hpp" - -typedef Fixture RefTreeNode_Fixture; - -#endif diff --git a/testMacGitverCore/Test_Remote.cpp b/testMacGitverCore/Test_Remote.cpp deleted file mode 100644 index 1e445529..00000000 --- a/testMacGitverCore/Test_Remote.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "Test_Remote.hpp" - -TEST_F(Remote_Fixture, Trivial) -{ - -} diff --git a/testMacGitverCore/Test_Remote.hpp b/testMacGitverCore/Test_Remote.hpp deleted file mode 100644 index ee057139..00000000 --- a/testMacGitverCore/Test_Remote.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 TEST_MGVCORE_REMOTE_HPP -#define TEST_MGVCORE_REMOTE_HPP - -#include "Infra/Fixture.hpp" - -typedef Fixture Remote_Fixture; - -#endif diff --git a/testMacGitverCore/Test_Repo.cpp b/testMacGitverCore/Test_Repo.cpp deleted file mode 100644 index 509b49a3..00000000 --- a/testMacGitverCore/Test_Repo.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "libMacGitverCore/RepoMan/RepoMan.hpp" -#include "libMacGitverCore/RepoMan/Repo.hpp" - -#include "Infra/TempRepo.hpp" - -#include "Test_Repo.hpp" - -#define RMAN() MacGitver::repoMan() - -TEST_F(Repo_Fixture, CanOpenRepo) -{ - TempRepo tempRepo(this, "SimpleRepo1"); - - RM::Repo* repo = RMAN().open(tempRepo); - ASSERT_TRUE(repo != NULL); - - repo->close(); - ASSERT_EQ(0, RMAN().repositories().count()); -} - -TEST_F(Repo_Fixture, Trivial) -{ - TempRepoOpener repo(this, "SimpleRepo1"); - - ASSERT_TRUE(repo->isA()); - - ASSERT_TRUE(repo->isActive()); - ASSERT_TRUE(repo->isLoaded()); - ASSERT_FALSE(repo->isSubModule()); - ASSERT_FALSE(repo->isBare()); - - qDebug("%s", qPrintable(RMAN().dump())); -} diff --git a/testMacGitverCore/Test_Repo.hpp b/testMacGitverCore/Test_Repo.hpp deleted file mode 100644 index d0e48fd0..00000000 --- a/testMacGitverCore/Test_Repo.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 TEST_MGVCORE_REPO_HPP -#define TEST_MGVCORE_REPO_HPP - -#include "Infra/Fixture.hpp" - -typedef Fixture Repo_Fixture; - -#endif diff --git a/testMacGitverCore/Test_RepoMan.cpp b/testMacGitverCore/Test_RepoMan.cpp deleted file mode 100644 index b5cb6238..00000000 --- a/testMacGitverCore/Test_RepoMan.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "Test_RepoMan.hpp" - -#include "libMacGitverCore/RepoMan/RepoMan.hpp" - -void RepoManFixture::expectSignal(QObject* sender, const char * const signature) -{ - connect(sender, signature, this, SLOT(expectedSignal())); - - expectedSender = sender; - expectedSignature = signature; - gotSignal = false; -} - -bool RepoManFixture::receivedSignal() -{ - bool got = gotSignal; - - disconnect(expectedSender, expectedSignature, this, SLOT(expectedSignal())); - expectedSender = NULL; - expectedSignature = NULL; - - return got; -} - -void RepoManFixture::expectedSignal() -{ - if (sender() == expectedSender) - { - gotSignal = true; - } -} - - -TEST_F(RepoManFixture, Trivial) -{ -#if 0 - // This test is stupid. If RepoMan was implemented correctly, there would be no signal for - // opening an "invalid" repository... - RM::RepoMan* rm = &MacGitver::repoMan(); - expectSignal(rm, SIGNAL(firstRepositoryOpened())); - rm->open(Git::Repository()); - ASSERT_TRUE(receivedSignal()); -#endif -} - diff --git a/testMacGitverCore/Test_RepoMan.hpp b/testMacGitverCore/Test_RepoMan.hpp deleted file mode 100644 index 4c98fe40..00000000 --- a/testMacGitverCore/Test_RepoMan.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 TEST_MGVCORE_REPO_MAN_HPP -#define TEST_MGVCORE_REPO_MAN_HPP - -#include "Infra/Fixture.hpp" - -class RepoManFixture : public Fixture -{ - Q_OBJECT -public: - -protected: - void expectSignal(QObject* sender, const char* const signature); - bool receivedSignal(); - -private slots: - void expectedSignal(); - -protected: - const char* expectedSignature; - QObject* expectedSender; - bool gotSignal; -}; - -#endif diff --git a/testMacGitverCore/Test_Submodule.cpp b/testMacGitverCore/Test_Submodule.cpp deleted file mode 100644 index 47da8cb6..00000000 --- a/testMacGitverCore/Test_Submodule.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "Test_Submodule.hpp" - -TEST_F(Submodule_Fixture, Trivial) -{ - -} diff --git a/testMacGitverCore/Test_Submodule.hpp b/testMacGitverCore/Test_Submodule.hpp deleted file mode 100644 index 1f37473a..00000000 --- a/testMacGitverCore/Test_Submodule.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 TEST_MGVCORE_SUBMODULE_HPP -#define TEST_MGVCORE_SUBMODULE_HPP - -#include "Infra/Fixture.hpp" - -typedef Fixture Submodule_Fixture; - -#endif diff --git a/testMacGitverCore/Test_Tag.cpp b/testMacGitverCore/Test_Tag.cpp deleted file mode 100644 index 1086b1ea..00000000 --- a/testMacGitverCore/Test_Tag.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "Test_Tag.hpp" - -TEST_F(Tag_Fixture, Trivial) -{ - -} diff --git a/testMacGitverCore/Test_Tag.hpp b/testMacGitverCore/Test_Tag.hpp deleted file mode 100644 index 9976af6d..00000000 --- a/testMacGitverCore/Test_Tag.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 TEST_MGVCORE_TAG_HPP -#define TEST_MGVCORE_TAG_HPP - -#include "Infra/Fixture.hpp" - -typedef Fixture Tag_Fixture; - -#endif From 4cb1466ae5155db3650221b479128d64c32fd627 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 22 Mar 2015 06:35:02 +0000 Subject: [PATCH 02/75] Remove signals from RM::Repo --- Libs/libMacGitverCore/RepoMan/Repo.cpp | 14 ++++---------- Libs/libMacGitverCore/RepoMan/Repo.hpp | 8 -------- Modules/Repository/RepoInfoModel.cpp | 6 ++++-- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/Libs/libMacGitverCore/RepoMan/Repo.cpp b/Libs/libMacGitverCore/RepoMan/Repo.cpp index d41233fb..0ccdbaed 100644 --- a/Libs/libMacGitverCore/RepoMan/Repo.cpp +++ b/Libs/libMacGitverCore/RepoMan/Repo.cpp @@ -198,7 +198,8 @@ namespace RM if (d->mDisplayAlias != alias) { d->mDisplayAlias = alias; - emit aliasChanged(alias); + // ###REPOMAN Create new Event "RepoAliasChanged" + // emit aliasChanged(alias); } } @@ -217,7 +218,6 @@ namespace RM } Events::self()->repositoryAboutToClose(this); - emit aboutToClose(this); foreach (Repo* child, submodules()) { child->close(); @@ -420,13 +420,10 @@ namespace RM mUnloadTimer = NULL; } - Repo* r = pub(); - emit r->aboutToUnload(r); - + // ####REPOMAN Do we really need to send out events for Unload/Load? If yes, create + // real events for that! mIsLoaded = false; mRepo = Git::Repository(); - - emit r->unloaded(r); } @@ -473,10 +470,7 @@ namespace RM subInfo = repoByPath(path, true); if (!subInfo) { - subInfo = new Submodule(subRepo, p); - emit p->childAdded(p, subInfo); - } else { oldSubmodules.remove(subInfo); diff --git a/Libs/libMacGitverCore/RepoMan/Repo.hpp b/Libs/libMacGitverCore/RepoMan/Repo.hpp index 9a68f7b1..6d6e7bef 100644 --- a/Libs/libMacGitverCore/RepoMan/Repo.hpp +++ b/Libs/libMacGitverCore/RepoMan/Repo.hpp @@ -97,14 +97,6 @@ namespace RM private slots: void unloadTimer(); - - signals: - void aboutToClose (RM::Repo* repo); - void aboutToUnload (RM::Repo* repo); - void unloaded (RM::Repo* repo); - void loaded (RM::Repo* repo); - void childAdded (RM::Repo* parent, RM::Repo* child); - void aliasChanged (const QString& newAlias); }; } diff --git a/Modules/Repository/RepoInfoModel.cpp b/Modules/Repository/RepoInfoModel.cpp index bcbee721..c9886c7e 100644 --- a/Modules/Repository/RepoInfoModel.cpp +++ b/Modules/Repository/RepoInfoModel.cpp @@ -204,11 +204,13 @@ void RepoInfoModel::repositoryOpened(RM::Repo *info) return; } + // ###REPOMAN Instead of this, listen to SubmoduleCreated events + // This connection is wrong. There could be any children added below the repository (i.e. // HEAD, SubModule, CollectionNode). But the slot will unconditionally reserve a new space // for a submodule... - connect(info, &RM::Repo::childAdded, - this, &RepoInfoModel::repositoryChildAdded); + //connect(info, &RM::Repo::childAdded, + // this, &RepoInfoModel::repositoryChildAdded); // we add a row just at the end of the root. This is stupid. But that's the way it works when // a model actually isn't a model... From 66ff7eb675b3f57ac06b90491fec79626f5cd943 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 10 May 2015 04:39:41 +0100 Subject: [PATCH 03/75] Remove 'open' logic' --- Libs/libMacGitverCore/RepoMan/RepoMan.cpp | 76 +++-------------------- Libs/libMacGitverCore/RepoMan/RepoMan.hpp | 9 ++- 2 files changed, 11 insertions(+), 74 deletions(-) diff --git a/Libs/libMacGitverCore/RepoMan/RepoMan.cpp b/Libs/libMacGitverCore/RepoMan/RepoMan.cpp index 3c5c1132..4fa77d15 100644 --- a/Libs/libMacGitverCore/RepoMan/RepoMan.cpp +++ b/Libs/libMacGitverCore/RepoMan/RepoMan.cpp @@ -29,6 +29,8 @@ #include "libBlueSky/Application.hpp" +#include + namespace RM { @@ -69,81 +71,17 @@ namespace RM } /** - * @brief Open a repository (By it's path) + * @brief Open a repository * - * Opens a Git::Repository at the @a path and if this is valid, call open() to setup a RepoMan - * repository for it. + * Opens the Repository at @a path * * @param[in] path The path where to look for the repository to open. * - * @return A pointer to a Repo object that represents the repositorty. An existing one will - * be returned if such a Repo object can be found. - * `NULL` will be returned, if the repository cannot be opened. - * - */ - Repo* RepoMan::open(const QString& path) - { - Git::Result result; - Git::Repository repo = Git::Repository::open( result, path ); - if( !result || !repo.isValid() ) - { - return NULL; - } - - return open( repo ); - } - - /** - * @brief Setup a Repo object for a Git::Repository - * - * If there is no Repo object for the git repository at that place in the file system, a new one - * will be created and registered with the repo-manager and the core. - * - * @param[in] gitRepo The Git::Repository object - * - * @return Returns either an existing Repo object or a newly created one. - * */ - Repo* RepoMan::open(const Git::Repository& gitRepo) - { - RM_D(RepoMan); - - Repo* repo = repoByPath(gitRepo.workTreePath(), false); - - if(!repo) { - repo = new Repo(gitRepo, this); - d->repos.append(repo); - - Events::self()->repositoryOpened(repo); - - if (d->repos.count() == 1) { - emit firstRepositoryOpened(); - } - } - - activate( repo ); - return repo; - } - - Repo* RepoMan::repoByPath( const QString& basePath, bool searchSubmodules ) + void RepoMan::open(const QString& path) { - RM_D(RepoMan); - - foreach (Repo* repo, d->repos) { - if (repo->path() == basePath) { - return repo; - } - - if (searchSubmodules) { - if (RepoPrivate* subPriv = Private::dataOf(repo)) { - if (Repo* subSubRepo = subPriv->repoByPath(basePath, true)) { - return subSubRepo; - } - } - } - } - - return NULL; + // ### REPOMAN TODO + qDebug() << "RepoMan::Open is currently not implemented."; } /** diff --git a/Libs/libMacGitverCore/RepoMan/RepoMan.hpp b/Libs/libMacGitverCore/RepoMan/RepoMan.hpp index 602298b3..f9f4f980 100644 --- a/Libs/libMacGitverCore/RepoMan/RepoMan.hpp +++ b/Libs/libMacGitverCore/RepoMan/RepoMan.hpp @@ -49,7 +49,7 @@ namespace RM ~RepoMan(); public: - Repo* open(const QString& path); + void open(const QString& path); void closeAll(); @@ -58,12 +58,11 @@ namespace RM Repo::List repositories() const; - Repo* repoByPath(const QString& basePath, bool searchSubmodules); - void internalClosedRepo(Repo* repository); - private: - Repo* open(const Git::Repository& repo); + public: + static RepoMan& instance(); + void terminate(); private slots: void reactivateWorkaround(); From 359c33d457dcbf01006227663627750537ddae83 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 22 Mar 2015 18:43:03 +0000 Subject: [PATCH 04/75] Make the RM::Repo's Git::Repository member private --- .../RepoMan/Private/RepoPrivate.hpp | 8 +++- Libs/libMacGitverCore/RepoMan/Repo.cpp | 40 +++++++++---------- Libs/libMacGitverCore/RepoMan/Repo.hpp | 2 +- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Libs/libMacGitverCore/RepoMan/Private/RepoPrivate.hpp b/Libs/libMacGitverCore/RepoMan/Private/RepoPrivate.hpp index 296229e4..2b16deab 100644 --- a/Libs/libMacGitverCore/RepoMan/Private/RepoPrivate.hpp +++ b/Libs/libMacGitverCore/RepoMan/Private/RepoPrivate.hpp @@ -62,13 +62,14 @@ namespace RM public: void load(); void unload(); - bool ensureIsLoaded(); void findAlias(); void scanSubmodules(); Repo* repoByPath(const QString& basePath, bool searchSubmodules); public: - Git::Repository mRepo; //!< GitWrap-Repo, if loaded + Git::Repository gitRepo(bool doLoad = false); + + public: QString mPath; //!< Full, absolute path to this repository QString mDisplayAlias; //!< An alias for display (Default to last path comp.) bool mIsSubModule : 1; //!< This is a submodule of another repo @@ -78,6 +79,9 @@ namespace RM bool mIsInitializing : 1; //!< True, while this repository is initializing QTimer* mUnloadTimer; //!< NULL or a timer to unload this repository Head* mHead; //!< The HEAD + + private: + Git::Repository mRepo; //!< GitWrap-Repo, if loaded }; } diff --git a/Libs/libMacGitverCore/RepoMan/Repo.cpp b/Libs/libMacGitverCore/RepoMan/Repo.cpp index 0ccdbaed..6a62258a 100644 --- a/Libs/libMacGitverCore/RepoMan/Repo.cpp +++ b/Libs/libMacGitverCore/RepoMan/Repo.cpp @@ -71,19 +71,13 @@ namespace RM Git::Repository Repo::gitRepo() { RM_D(Repo); - - if (d->ensureIsLoaded()) { - return d->mRepo; - } - - return Git::Repository(); + return d->gitRepo(true); } - Git::Repository Repo::gitLoadedRepo() const + Git::Repository Repo::gitLoadedRepo() { - RM_CD(Repo); - - return d->mIsLoaded ? d->mRepo : Git::Repository(); + RM_D(Repo); + return d->gitRepo(); } QString Repo::path() const @@ -391,15 +385,6 @@ namespace RM MacGitver::repoMan().internalClosedRepo(p); } - bool RepoPrivate::ensureIsLoaded() - { - if (!mIsLoaded) { - load(); - } - - return mIsLoaded; - } - void RepoPrivate::load() { // ### Unimplemented: RepoPrivate::load() @@ -441,12 +426,13 @@ namespace RM { RM_P(Repo); - if (!ensureIsLoaded()) { + Git::Repository repo = gitRepo(true); + if (!repo.isValid()) { return; } Git::Result r; - Git::Submodule::List subs = mRepo.submodules( r ); + Git::Submodule::List subs = repo.submodules( r ); if (!r) { return; } @@ -542,7 +528,7 @@ namespace RM { dumper.addLine(QString(QStringLiteral("Repository 0x%1 - %02")) .arg(quintptr(mPub),0,16) - .arg(mIsLoaded ? pub()->gitLoadedRepo().name() + .arg(mIsLoaded ? mRepo.name() : QStringLiteral(""))); } @@ -759,4 +745,14 @@ namespace RM { return static_cast(mPub); } + + Git::Repository RepoPrivate::gitRepo(bool doLoad) + { + if (!mIsLoaded && doLoad) { + load(); + } + + return mRepo; + } + } diff --git a/Libs/libMacGitverCore/RepoMan/Repo.hpp b/Libs/libMacGitverCore/RepoMan/Repo.hpp index 6d6e7bef..68789b34 100644 --- a/Libs/libMacGitverCore/RepoMan/Repo.hpp +++ b/Libs/libMacGitverCore/RepoMan/Repo.hpp @@ -58,7 +58,7 @@ namespace RM public: GW_DEPRECATED Git::Repository gitRepo(); - GW_DEPRECATED Git::Repository gitLoadedRepo() const; + GW_DEPRECATED Git::Repository gitLoadedRepo(); bool isSubModule() const; bool isBare() const; From 2a84e82e822dd2443dd06bc79b3eaf9096b3c640 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sat, 9 May 2015 22:23:22 +0100 Subject: [PATCH 05/75] Keep instance pointer to RepoMan inside itself --- Libs/libMacGitverCore/App/MacGitver.cpp | 10 ++++------ Libs/libMacGitverCore/App/MacGitver.hpp | 1 + Libs/libMacGitverCore/App/MacGitverPrivate.hpp | 1 - Libs/libMacGitverCore/App/MgvPrimaryWindow.cpp | 6 +++--- Libs/libMacGitverCore/RepoMan/AutoRefresher.cpp | 2 +- .../RepoMan/Config/RepoManConfigPage.cpp | 3 ++- Libs/libMacGitverCore/RepoMan/RepoMan.cpp | 14 ++++++++++++++ Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp | 2 +- Modules/Logging/LoggingMode.cpp | 2 +- Modules/Repository/CreateRepositoryDlg.cpp | 2 +- Modules/Repository/RepoTreeView.cpp | 8 ++++---- 11 files changed, 32 insertions(+), 19 deletions(-) diff --git a/Libs/libMacGitverCore/App/MacGitver.cpp b/Libs/libMacGitverCore/App/MacGitver.cpp index da9a3405..b8974e17 100644 --- a/Libs/libMacGitverCore/App/MacGitver.cpp +++ b/Libs/libMacGitverCore/App/MacGitver.cpp @@ -73,7 +73,7 @@ void MacGitverPrivate::init() QApplication::setApplicationName(QStringLiteral("MacGitver_NonGui")); } - sRepoMan = new RM::RepoMan; + RM::RepoMan::instance(); sModules = new Modules; if (isGui) { @@ -86,7 +86,8 @@ MacGitverPrivate::~MacGitverPrivate() { unregisterGlobalConfigPages(); - delete sRepoMan; sRepoMan = NULL; + RM::RepoMan::instance().terminate(); + delete sModules; sModules = NULL; Log::Manager::release(); @@ -104,7 +105,6 @@ void MacGitverPrivate::bootGui() } MacGitver* MacGitverPrivate::sSelf = NULL; -RM::RepoMan* MacGitverPrivate::sRepoMan = NULL; Modules* MacGitverPrivate::sModules = NULL; MacGitver& MacGitver::self() @@ -117,9 +117,7 @@ MacGitver& MacGitver::self() RM::RepoMan& MacGitver::repoMan() { - Q_ASSERT(MacGitverPrivate::sRepoMan); - - return *MacGitverPrivate::sRepoMan; + return RM::RepoMan::instance(); } MacGitver::MacGitver(bool runGui) diff --git a/Libs/libMacGitverCore/App/MacGitver.hpp b/Libs/libMacGitverCore/App/MacGitver.hpp index 46ba1d41..000e8901 100644 --- a/Libs/libMacGitverCore/App/MacGitver.hpp +++ b/Libs/libMacGitverCore/App/MacGitver.hpp @@ -50,6 +50,7 @@ class MGV_CORE_API MacGitver public: static MacGitver& self(); + GW_DEPRECATED static RM::RepoMan& repoMan(); public: diff --git a/Libs/libMacGitverCore/App/MacGitverPrivate.hpp b/Libs/libMacGitverCore/App/MacGitverPrivate.hpp index 36a1d726..3b891404 100644 --- a/Libs/libMacGitverCore/App/MacGitverPrivate.hpp +++ b/Libs/libMacGitverCore/App/MacGitverPrivate.hpp @@ -64,5 +64,4 @@ private slots: MgvApp bsApp; static MacGitver* sSelf; static Modules* sModules; - static RM::RepoMan* sRepoMan; }; diff --git a/Libs/libMacGitverCore/App/MgvPrimaryWindow.cpp b/Libs/libMacGitverCore/App/MgvPrimaryWindow.cpp index c1c85aae..54b77419 100644 --- a/Libs/libMacGitverCore/App/MgvPrimaryWindow.cpp +++ b/Libs/libMacGitverCore/App/MgvPrimaryWindow.cpp @@ -64,10 +64,10 @@ MgvPrimaryWindow::MgvPrimaryWindow() w->show(); #endif - connect(&MacGitver::repoMan(), &RM::RepoMan::firstRepositoryOpened, + connect(&RM::RepoMan::instance(), &RM::RepoMan::firstRepositoryOpened, this, &MgvPrimaryWindow::activateModeForRepo); - connect(&MacGitver::repoMan(), &RM::RepoMan::lastRepositoryClosed, + connect(&RM::RepoMan::instance(), &RM::RepoMan::lastRepositoryClosed, this, &MgvPrimaryWindow::activateModeForRepo); setupFonts(); @@ -157,7 +157,7 @@ void MgvPrimaryWindow::moveToCenter() void MgvPrimaryWindow::activateModeForRepo() { - if (MacGitver::repoMan().repositories().count() > 0) { + if (RM::RepoMan::instance().repositories().count() > 0) { activateMode(QStringLiteral("HistoryMode")); } else { diff --git a/Libs/libMacGitverCore/RepoMan/AutoRefresher.cpp b/Libs/libMacGitverCore/RepoMan/AutoRefresher.cpp index 14545ed6..cb446fff 100644 --- a/Libs/libMacGitverCore/RepoMan/AutoRefresher.cpp +++ b/Libs/libMacGitverCore/RepoMan/AutoRefresher.cpp @@ -194,7 +194,7 @@ namespace RM void AutoRefresher::onRefreshGit() { Log::Manager().addMessage(trUtf8("Refreshing git repositories...")); - MacGitver::repoMan().refresh(); + RM::RepoMan::instance().refresh(); } void AutoRefresher::onRefreshIndex() diff --git a/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.cpp b/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.cpp index bd2a5409..6a122fcd 100644 --- a/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.cpp +++ b/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.cpp @@ -71,7 +71,8 @@ void RepoManConfigPage::apply() void RepoManConfigPage::init() { - RM::RepoMan* rm = &MacGitver::repoMan(); + RM::RepoMan* rm = &RM::RepoMan::instance(); + RM::Internal::RepoManPrivate* rmp = RM::Internal::BasePrivate::dataOf(rm); refresher = rmp->refresher; diff --git a/Libs/libMacGitverCore/RepoMan/RepoMan.cpp b/Libs/libMacGitverCore/RepoMan/RepoMan.cpp index 4fa77d15..279a9612 100644 --- a/Libs/libMacGitverCore/RepoMan/RepoMan.cpp +++ b/Libs/libMacGitverCore/RepoMan/RepoMan.cpp @@ -70,6 +70,20 @@ namespace RM Events::delReceiver(this); } + RepoMan& RepoMan::instance() + { + static QPointer sSelf; + if (!sSelf) { + sSelf = new RepoMan; + } + return *sSelf; + } + + void RepoMan::terminate() + { + delete this; + } + /** * @brief Open a repository * diff --git a/Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp b/Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp index 063f87a9..4338faec 100644 --- a/Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp +++ b/Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp @@ -36,7 +36,7 @@ RepoStateWidget::RepoStateWidget() repo = NULL; setupUi(); - RM::RepoMan& rm = MacGitver::repoMan(); + RM::RepoMan& rm = RM::RepoMan::instance(); connect(&rm, &RM::RepoMan::refMoved, this, &RepoStateWidget::onUpdateHEAD); diff --git a/Modules/Logging/LoggingMode.cpp b/Modules/Logging/LoggingMode.cpp index cae33c97..55cdab78 100644 --- a/Modules/Logging/LoggingMode.cpp +++ b/Modules/Logging/LoggingMode.cpp @@ -31,7 +31,7 @@ LoggingMode::LoggingMode(QObject *parent) setEnabled(false); setDisplayOrder(100); - connect(&MacGitver::self().repoMan(), + connect(&RM::RepoMan::instance(), &RM::RepoMan::hasActiveRepositoryChanged, this, &LoggingMode::setEnabled); } diff --git a/Modules/Repository/CreateRepositoryDlg.cpp b/Modules/Repository/CreateRepositoryDlg.cpp index d2d55e52..a60ba1db 100644 --- a/Modules/Repository/CreateRepositoryDlg.cpp +++ b/Modules/Repository/CreateRepositoryDlg.cpp @@ -106,7 +106,7 @@ void CreateRepositoryDlg::accept() MacGitver::log(Log::Normal, trUtf8("Created a new repository at %1").arg(fn)); - MacGitver::repoMan().open(fn); + RM::RepoMan::instance().open(fn); QDialog::accept(); } diff --git a/Modules/Repository/RepoTreeView.cpp b/Modules/Repository/RepoTreeView.cpp index 4e22187c..55b44df5 100644 --- a/Modules/Repository/RepoTreeView.cpp +++ b/Modules/Repository/RepoTreeView.cpp @@ -56,11 +56,11 @@ RepoTreeView::RepoTreeView() connect( mRepos, SIGNAL(contextMenu(QModelIndex,QPoint)), this, SLOT(contextMenu(QModelIndex,QPoint)) ); - connect( &MacGitver::repoMan(), &RM::RepoMan::repositoryActivated, - this, &RepoTreeView::onRepoActivated); + connect(&RM::RepoMan::instance(), &RM::RepoMan::repositoryActivated, + this, &RepoTreeView::onRepoActivated); - connect( &MacGitver::repoMan(), &RM::RepoMan::repositoryDeactivated, - this, &RepoTreeView::onRepoDeactivated); + connect(&RM::RepoMan::instance(), &RM::RepoMan::repositoryDeactivated, + this, &RepoTreeView::onRepoDeactivated); } QModelIndex RepoTreeView::deeplyMapToSource( QModelIndex current ) const From f57c961b3d1c949aaa352b4fb294d23057ad87b1 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 10 May 2015 01:54:50 +0100 Subject: [PATCH 06/75] Move AutoRefresher out of RM-namespace --- .../RepoMan/AutoRefresher.cpp | 279 +++++++++--------- .../RepoMan/AutoRefresher.hpp | 74 +++-- .../RepoMan/Config/RepoManConfigPage.hpp | 7 +- 3 files changed, 174 insertions(+), 186 deletions(-) diff --git a/Libs/libMacGitverCore/RepoMan/AutoRefresher.cpp b/Libs/libMacGitverCore/RepoMan/AutoRefresher.cpp index cb446fff..87ee1d77 100644 --- a/Libs/libMacGitverCore/RepoMan/AutoRefresher.cpp +++ b/Libs/libMacGitverCore/RepoMan/AutoRefresher.cpp @@ -26,183 +26,178 @@ #include "AutoRefresherCfg.hpp" -namespace RM +AutoRefresher::AutoRefresher(QObject* parent) + : QObject(parent) + , refreshGitTimer(NULL) + , refreshIndexTimer(NULL) + , refreshWorktreeTimer(NULL) { + new AutoRefresherCfg(this); - AutoRefresher::AutoRefresher(QObject* parent) - : QObject(parent) - , refreshGitTimer(NULL) - , refreshIndexTimer(NULL) - , refreshWorktreeTimer(NULL) - { - new AutoRefresherCfg(this); + forcedUpdate(); +} - forcedUpdate(); - } +AutoRefresher::~AutoRefresher() +{ +} - AutoRefresher::~AutoRefresher() - { - } +bool AutoRefresher::refreshEnabled() const +{ + return AutoRefresherCfg::refreshEnabled(); +} - bool AutoRefresher::refreshEnabled() const - { - return AutoRefresherCfg::refreshEnabled(); - } +bool AutoRefresher::refreshGitEnabled() const +{ + return AutoRefresherCfg::gitInterval() != 0; +} - bool AutoRefresher::refreshGitEnabled() const - { - return AutoRefresherCfg::gitInterval() != 0; - } +bool AutoRefresher::refreshIndexEnabled() const +{ + return AutoRefresherCfg::indexInterval() != 0; +} - bool AutoRefresher::refreshIndexEnabled() const - { - return AutoRefresherCfg::indexInterval() != 0; - } +bool AutoRefresher::refreshWorktreeEnabled() const +{ + return AutoRefresherCfg::worktreeInterval() != 0; +} - bool AutoRefresher::refreshWorktreeEnabled() const - { - return AutoRefresherCfg::worktreeInterval() != 0; - } +void AutoRefresher::setRefreshEnabled(bool enabled) +{ + AutoRefresherCfg::setRefreshEnabled(enabled); + forcedUpdate(); +} - void AutoRefresher::setRefreshEnabled(bool enabled) - { - AutoRefresherCfg::setRefreshEnabled(enabled); - forcedUpdate(); - } +void AutoRefresher::forcedUpdate() +{ + setRefreshGitInterval(AutoRefresherCfg::gitInterval(), true); + setRefreshIndexInterval(AutoRefresherCfg::indexInterval(), true); + setRefreshWorktreeInterval(AutoRefresherCfg::worktreeInterval(), true); +} - void AutoRefresher::forcedUpdate() - { - setRefreshGitInterval(AutoRefresherCfg::gitInterval(), true); - setRefreshIndexInterval(AutoRefresherCfg::indexInterval(), true); - setRefreshWorktreeInterval(AutoRefresherCfg::worktreeInterval(), true); +void AutoRefresher::setRefreshGitInterval(int interval, bool force) +{ + if (interval < 15) { + interval = 0; } - void AutoRefresher::setRefreshGitInterval(int interval, bool force) - { - if (interval < 15) { - interval = 0; - } - - if (interval == AutoRefresherCfg::gitInterval() ) { - if (!force) { - return; - } - } - else { - AutoRefresherCfg::setGitInterval(interval); + if (interval == AutoRefresherCfg::gitInterval() ) { + if (!force) { + return; } + } + else { + AutoRefresherCfg::setGitInterval(interval); + } - if (interval) { - if (!refreshGitTimer) { - refreshGitTimer = new QTimer(this); - connect(refreshGitTimer, SIGNAL(timeout()), - this, SLOT(onRefreshGit())); - } - refreshGitTimer->setInterval(interval * 1000); - refreshGitTimer->start(); + if (interval) { + if (!refreshGitTimer) { + refreshGitTimer = new QTimer(this); + connect(refreshGitTimer, SIGNAL(timeout()), + this, SLOT(onRefreshGit())); } - else { - if (refreshGitTimer) { - refreshGitTimer->stop(); - refreshGitTimer->deleteLater(); - refreshGitTimer = NULL; - } + refreshGitTimer->setInterval(interval * 1000); + refreshGitTimer->start(); + } + else { + if (refreshGitTimer) { + refreshGitTimer->stop(); + refreshGitTimer->deleteLater(); + refreshGitTimer = NULL; } } +} - void AutoRefresher::setRefreshIndexInterval(int interval, bool force) - { - if (interval < 30) { - interval = 0; - } +void AutoRefresher::setRefreshIndexInterval(int interval, bool force) +{ + if (interval < 30) { + interval = 0; + } - if (interval == AutoRefresherCfg::indexInterval() ) { - if (!force) { - return; - } - } - else { - AutoRefresherCfg::setIndexInterval(interval); + if (interval == AutoRefresherCfg::indexInterval() ) { + if (!force) { + return; } + } + else { + AutoRefresherCfg::setIndexInterval(interval); + } - if (interval) { - if (!refreshIndexTimer) { - refreshIndexTimer = new QTimer(this); - connect(refreshIndexTimer, SIGNAL(timeout()), - this, SLOT(onRefreshIndex())); - } - refreshIndexTimer->setInterval(interval * 1000); - refreshIndexTimer->start(); + if (interval) { + if (!refreshIndexTimer) { + refreshIndexTimer = new QTimer(this); + connect(refreshIndexTimer, SIGNAL(timeout()), + this, SLOT(onRefreshIndex())); } - else { - if (refreshIndexTimer) { - refreshIndexTimer->stop(); - refreshIndexTimer->deleteLater(); - refreshIndexTimer = NULL; - } + refreshIndexTimer->setInterval(interval * 1000); + refreshIndexTimer->start(); + } + else { + if (refreshIndexTimer) { + refreshIndexTimer->stop(); + refreshIndexTimer->deleteLater(); + refreshIndexTimer = NULL; } } +} - void AutoRefresher::setRefreshWorktreeInterval(int interval, bool force) - { - if (interval < 120) { - interval = 0; - } +void AutoRefresher::setRefreshWorktreeInterval(int interval, bool force) +{ + if (interval < 120) { + interval = 0; + } - if (interval == AutoRefresherCfg::worktreeInterval() ) { - if (!force) { - return; - } - } - else { - AutoRefresherCfg::setWorktreeInterval(interval); + if (interval == AutoRefresherCfg::worktreeInterval() ) { + if (!force) { + return; } + } + else { + AutoRefresherCfg::setWorktreeInterval(interval); + } - if (interval) { - if (!refreshWorktreeTimer) { - refreshWorktreeTimer = new QTimer(this); - connect(refreshWorktreeTimer, SIGNAL(timeout()), - this, SLOT(onRefreshWorktree())); - } - refreshWorktreeTimer->setInterval(interval * 1000); - refreshWorktreeTimer->start(); + if (interval) { + if (!refreshWorktreeTimer) { + refreshWorktreeTimer = new QTimer(this); + connect(refreshWorktreeTimer, SIGNAL(timeout()), + this, SLOT(onRefreshWorktree())); } - else { - if (refreshWorktreeTimer) { - refreshWorktreeTimer->stop(); - refreshWorktreeTimer->deleteLater(); - refreshWorktreeTimer = NULL; - } + refreshWorktreeTimer->setInterval(interval * 1000); + refreshWorktreeTimer->start(); + } + else { + if (refreshWorktreeTimer) { + refreshWorktreeTimer->stop(); + refreshWorktreeTimer->deleteLater(); + refreshWorktreeTimer = NULL; } } +} - int AutoRefresher::gitRefreshInterval() const - { - return AutoRefresherCfg::gitInterval(); - } - - int AutoRefresher::indexRefreshInterval() const - { - return AutoRefresherCfg::indexInterval(); - } +int AutoRefresher::gitRefreshInterval() const +{ + return AutoRefresherCfg::gitInterval(); +} - int AutoRefresher::worktreeRefreshInterval() const - { - return AutoRefresherCfg::worktreeInterval(); - } +int AutoRefresher::indexRefreshInterval() const +{ + return AutoRefresherCfg::indexInterval(); +} - void AutoRefresher::onRefreshGit() - { - Log::Manager().addMessage(trUtf8("Refreshing git repositories...")); - RM::RepoMan::instance().refresh(); - } +int AutoRefresher::worktreeRefreshInterval() const +{ + return AutoRefresherCfg::worktreeInterval(); +} - void AutoRefresher::onRefreshIndex() - { - } +void AutoRefresher::onRefreshGit() +{ + Log::Manager().addMessage(trUtf8("Refreshing git repositories...")); + RM::RepoMan::instance().refresh(); +} - void AutoRefresher::onRefreshWorktree() - { - } +void AutoRefresher::onRefreshIndex() +{ +} +void AutoRefresher::onRefreshWorktree() +{ } diff --git a/Libs/libMacGitverCore/RepoMan/AutoRefresher.hpp b/Libs/libMacGitverCore/RepoMan/AutoRefresher.hpp index 6d3de627..f5b79868 100644 --- a/Libs/libMacGitverCore/RepoMan/AutoRefresher.hpp +++ b/Libs/libMacGitverCore/RepoMan/AutoRefresher.hpp @@ -25,43 +25,39 @@ class QTimer; #include "libMacGitverCore/Config/ConfigUser.h" -namespace RM +class AutoRefresher + : public QObject { - - class AutoRefresher : public QObject - { - Q_OBJECT - public: - AutoRefresher(QObject* parent); - ~AutoRefresher(); - - public: - bool refreshEnabled() const; - bool refreshGitEnabled() const; - bool refreshIndexEnabled() const; - bool refreshWorktreeEnabled() const; - - int gitRefreshInterval() const; - int indexRefreshInterval() const; - int worktreeRefreshInterval() const; - - void setRefreshEnabled(bool enabled); - void setRefreshGitInterval(int interval, bool force = false); - void setRefreshIndexInterval(int interval, bool force = false); - void setRefreshWorktreeInterval(int interval, bool force = false); - - private slots: - void onRefreshGit(); - void onRefreshIndex(); - void onRefreshWorktree(); - - private: - void forcedUpdate(); - - private: - QTimer* refreshGitTimer; - QTimer* refreshIndexTimer; - QTimer* refreshWorktreeTimer; - }; - -} + Q_OBJECT +public: + AutoRefresher(QObject* parent); + ~AutoRefresher(); + +public: + bool refreshEnabled() const; + bool refreshGitEnabled() const; + bool refreshIndexEnabled() const; + bool refreshWorktreeEnabled() const; + + int gitRefreshInterval() const; + int indexRefreshInterval() const; + int worktreeRefreshInterval() const; + + void setRefreshEnabled(bool enabled); + void setRefreshGitInterval(int interval, bool force = false); + void setRefreshIndexInterval(int interval, bool force = false); + void setRefreshWorktreeInterval(int interval, bool force = false); + +private slots: + void onRefreshGit(); + void onRefreshIndex(); + void onRefreshWorktree(); + +private: + void forcedUpdate(); + +private: + QTimer* refreshGitTimer; + QTimer* refreshIndexTimer; + QTimer* refreshWorktreeTimer; +}; diff --git a/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.hpp b/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.hpp index 979536bf..c3661d9b 100644 --- a/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.hpp +++ b/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.hpp @@ -25,10 +25,7 @@ #include "ui_RepoManConfigPage.h" -namespace RM -{ - class AutoRefresher; -} +class AutoRefresher; class RepoManConfigPage : public ConfigPage @@ -55,5 +52,5 @@ private slots: QWidget* widget(); private: - RM::AutoRefresher* refresher; + AutoRefresher* refresher; }; From 1af99a07cf3856d391cc8d2d6927c99470ae2c63 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 22 Mar 2015 05:18:38 +0000 Subject: [PATCH 07/75] Make AutoRefresher internal --- Libs/libMacGitverCore/CMakeLists.txt | 8 ++++---- .../{RepoMan => MacGitver}/AutoRefresher.cpp | 2 +- .../{RepoMan => MacGitver}/AutoRefresher.hpp | 0 .../{RepoMan => MacGitver}/AutoRefresherCfg.ccfg | 0 .../libMacGitverCore/RepoMan/Config/RepoManConfigPage.cpp | 3 ++- Libs/libMacGitverCore/RepoMan/Private/RepoManPrivate.hpp | 3 ++- 6 files changed, 9 insertions(+), 7 deletions(-) rename Libs/libMacGitverCore/{RepoMan => MacGitver}/AutoRefresher.cpp (98%) rename Libs/libMacGitverCore/{RepoMan => MacGitver}/AutoRefresher.hpp (100%) rename Libs/libMacGitverCore/{RepoMan => MacGitver}/AutoRefresherCfg.ccfg (100%) diff --git a/Libs/libMacGitverCore/CMakeLists.txt b/Libs/libMacGitverCore/CMakeLists.txt index b95cfac2..14aca99c 100644 --- a/Libs/libMacGitverCore/CMakeLists.txt +++ b/Libs/libMacGitverCore/CMakeLists.txt @@ -24,8 +24,8 @@ SET( SRC_FILES MacGitver/Module.cpp MacGitver/Modules.cpp MacGitver/GitPatchConsumer.cpp + MacGitver/AutoRefresher.cpp - RepoMan/AutoRefresher.cpp RepoMan/Base.cpp RepoMan/Ref.cpp RepoMan/Branch.cpp @@ -112,11 +112,11 @@ SET( PRI_HDR_FILES App/MacGitverPrivate.hpp App/MgvPrimaryWindowPrivate.hpp + MacGitver/AutoRefresher.hpp + Config/Ui/ConfigDialog.hpp Config/Ui/GeneralConfigPage.hpp - RepoMan/AutoRefresher.hpp - RepoMan/Private/BasePrivate.hpp RepoMan/Private/BranchPrivate.hpp RepoMan/Private/CollectionNodePrivate.hpp @@ -165,7 +165,7 @@ SET(RCC_FILES SET( HDR_FILES ${PRI_HDR_FILES} ${PUB_HDR_FILES} ) SET(CCFG_FILES - RepoMan/AutoRefresherCfg.ccfg + MacGitver/AutoRefresherCfg.ccfg ) CFGCOMP(CFG_FILES ${CCFG_FILES}) diff --git a/Libs/libMacGitverCore/RepoMan/AutoRefresher.cpp b/Libs/libMacGitverCore/MacGitver/AutoRefresher.cpp similarity index 98% rename from Libs/libMacGitverCore/RepoMan/AutoRefresher.cpp rename to Libs/libMacGitverCore/MacGitver/AutoRefresher.cpp index 87ee1d77..511748d6 100644 --- a/Libs/libMacGitverCore/RepoMan/AutoRefresher.cpp +++ b/Libs/libMacGitverCore/MacGitver/AutoRefresher.cpp @@ -21,9 +21,9 @@ #include "libMacGitverCore/App/MacGitver.hpp" -#include "libMacGitverCore/RepoMan/AutoRefresher.hpp" #include "libMacGitverCore/RepoMan/RepoMan.hpp" +#include "MacGitver/AutoRefresher.hpp" #include "AutoRefresherCfg.hpp" AutoRefresher::AutoRefresher(QObject* parent) diff --git a/Libs/libMacGitverCore/RepoMan/AutoRefresher.hpp b/Libs/libMacGitverCore/MacGitver/AutoRefresher.hpp similarity index 100% rename from Libs/libMacGitverCore/RepoMan/AutoRefresher.hpp rename to Libs/libMacGitverCore/MacGitver/AutoRefresher.hpp diff --git a/Libs/libMacGitverCore/RepoMan/AutoRefresherCfg.ccfg b/Libs/libMacGitverCore/MacGitver/AutoRefresherCfg.ccfg similarity index 100% rename from Libs/libMacGitverCore/RepoMan/AutoRefresherCfg.ccfg rename to Libs/libMacGitverCore/MacGitver/AutoRefresherCfg.ccfg diff --git a/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.cpp b/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.cpp index 6a122fcd..29ae2497 100644 --- a/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.cpp +++ b/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.cpp @@ -18,10 +18,11 @@ */ #include "libMacGitverCore/RepoMan/Config/RepoManConfigPage.hpp" + #include "libMacGitverCore/RepoMan/Private/RepoManPrivate.hpp" -#include "libMacGitverCore/RepoMan/AutoRefresher.hpp" #include "libMacGitverCore/RepoMan/RepoMan.hpp" +#include "libMacGitverCore/MacGitver/AutoRefresher.hpp" #include "libMacGitverCore/App/MacGitver.hpp" IMPLEMENT_NESTED_PAGE_CREATOR(RepoManConfigPage, 210) diff --git a/Libs/libMacGitverCore/RepoMan/Private/RepoManPrivate.hpp b/Libs/libMacGitverCore/RepoMan/Private/RepoManPrivate.hpp index 2095cb9f..e6ef93c2 100644 --- a/Libs/libMacGitverCore/RepoMan/Private/RepoManPrivate.hpp +++ b/Libs/libMacGitverCore/RepoMan/Private/RepoManPrivate.hpp @@ -22,7 +22,8 @@ #include "libMacGitverCore/RepoMan/Private/BasePrivate.hpp" #include "libMacGitverCore/RepoMan/RepoMan.hpp" -#include "libMacGitverCore/RepoMan/AutoRefresher.hpp" + +#include "libMacGitverCore/MacGitver/AutoRefresher.hpp" #include "hic_RepoManActions.h" From e722ebe58c27365ef0559726ab9d1f597699ed11 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Fri, 17 Apr 2015 02:10:33 +0100 Subject: [PATCH 08/75] Move refresher instance into MacGitver --- Libs/libMacGitverCore/App/MacGitver.cpp | 10 ++++++++ Libs/libMacGitverCore/App/MacGitver.hpp | 3 +++ .../libMacGitverCore/App/MacGitverPrivate.hpp | 2 ++ .../MacGitver/AutoRefresher.cpp | 24 +++++++++---------- .../MacGitver/AutoRefresher.hpp | 2 +- .../RepoMan/Config/RepoManConfigPage.cpp | 7 ++---- .../RepoMan/Private/RepoManPrivate.hpp | 1 - Libs/libMacGitverCore/RepoMan/RepoMan.cpp | 8 +------ 8 files changed, 31 insertions(+), 26 deletions(-) diff --git a/Libs/libMacGitverCore/App/MacGitver.cpp b/Libs/libMacGitverCore/App/MacGitver.cpp index b8974e17..3eb12aad 100644 --- a/Libs/libMacGitverCore/App/MacGitver.cpp +++ b/Libs/libMacGitverCore/App/MacGitver.cpp @@ -35,6 +35,7 @@ #include "libMacGitverCore/MacGitver/Modules.h" #include "libMacGitverCore/RepoMan/RepoMan.hpp" #include "libMacGitverCore/RepoMan/Config/RepoManConfigPage.hpp" +#include "libMacGitverCore/MacGitver/AutoRefresher.hpp" /** * @class MacGitver @@ -55,6 +56,7 @@ MacGitverPrivate::MacGitverPrivate(MacGitver* owner, bool runGui) : isGui(runGui) + , refresher(nullptr) { sSelf = owner; } @@ -67,6 +69,9 @@ void MacGitverPrivate::init() QApplication::setOrganizationName(QStringLiteral("MacGitver")); QApplication::setApplicationName(QStringLiteral("MacGitver")); + // only start the auto refresher if we're running a GUI + refresher = new AutoRefresher; + Heaven::IconManager::self().defaultProvider()->addSearchPath(QStringLiteral(":/Images")); } else { QApplication::setOrganizationName(QStringLiteral("MacGitver")); @@ -207,3 +212,8 @@ bool MacGitver::isRunningGui() const { return d->isGui; } + +AutoRefresher* MacGitver::refresher() const +{ + return d->refresher; +} diff --git a/Libs/libMacGitverCore/App/MacGitver.hpp b/Libs/libMacGitverCore/App/MacGitver.hpp index 000e8901..276be1ee 100644 --- a/Libs/libMacGitverCore/App/MacGitver.hpp +++ b/Libs/libMacGitverCore/App/MacGitver.hpp @@ -38,6 +38,7 @@ namespace RM typedef BlueSky::ViewDescriptor::CreatorFunc MgvViewCreator; +class AutoRefresher; class MacGitverPrivate; class MGV_CORE_API MacGitver @@ -67,6 +68,8 @@ class MGV_CORE_API MacGitver MgvViewCreator creator); void unregisterView(const BlueSky::ViewIdentifier& identifier); + AutoRefresher *refresher() const; + static void log(Log::Type type, const QString& logMessage); static void log(Log::Type type, const char* logMessage); static void log(Log::Type type, const Git::Result& r, const char* logMessage = nullptr); diff --git a/Libs/libMacGitverCore/App/MacGitverPrivate.hpp b/Libs/libMacGitverCore/App/MacGitverPrivate.hpp index 3b891404..6516c2e9 100644 --- a/Libs/libMacGitverCore/App/MacGitverPrivate.hpp +++ b/Libs/libMacGitverCore/App/MacGitverPrivate.hpp @@ -27,6 +27,7 @@ class QDir; class Modules; +class AutoRefresher; struct MgvViewInfo { @@ -62,6 +63,7 @@ private slots: Git::GitWrap mGitWrap; bool isGui; MgvApp bsApp; + AutoRefresher* refresher; static MacGitver* sSelf; static Modules* sModules; }; diff --git a/Libs/libMacGitverCore/MacGitver/AutoRefresher.cpp b/Libs/libMacGitverCore/MacGitver/AutoRefresher.cpp index 511748d6..49a89c22 100644 --- a/Libs/libMacGitverCore/MacGitver/AutoRefresher.cpp +++ b/Libs/libMacGitverCore/MacGitver/AutoRefresher.cpp @@ -17,20 +17,19 @@ * */ -#include - -#include "libMacGitverCore/App/MacGitver.hpp" +#include "libMacGitverCore/MacGitver/AutoRefresher.hpp" +#include "AutoRefresherCfg.hpp" #include "libMacGitverCore/RepoMan/RepoMan.hpp" -#include "MacGitver/AutoRefresher.hpp" -#include "AutoRefresherCfg.hpp" +#include +#include -AutoRefresher::AutoRefresher(QObject* parent) - : QObject(parent) - , refreshGitTimer(NULL) - , refreshIndexTimer(NULL) - , refreshWorktreeTimer(NULL) +AutoRefresher::AutoRefresher() + : QObject() + , refreshGitTimer(nullptr) + , refreshIndexTimer(nullptr) + , refreshWorktreeTimer(nullptr) { new AutoRefresherCfg(this); @@ -190,14 +189,15 @@ int AutoRefresher::worktreeRefreshInterval() const void AutoRefresher::onRefreshGit() { - Log::Manager().addMessage(trUtf8("Refreshing git repositories...")); - RM::RepoMan::instance().refresh(); + qDebug() << "Refresh Repository currently not implemented."; } void AutoRefresher::onRefreshIndex() { + qDebug() << "Refresh Index currently not implemented."; } void AutoRefresher::onRefreshWorktree() { + qDebug() << "Refresh Worktree currently not implemented."; } diff --git a/Libs/libMacGitverCore/MacGitver/AutoRefresher.hpp b/Libs/libMacGitverCore/MacGitver/AutoRefresher.hpp index f5b79868..c7d42d9c 100644 --- a/Libs/libMacGitverCore/MacGitver/AutoRefresher.hpp +++ b/Libs/libMacGitverCore/MacGitver/AutoRefresher.hpp @@ -30,7 +30,7 @@ class AutoRefresher { Q_OBJECT public: - AutoRefresher(QObject* parent); + AutoRefresher(); ~AutoRefresher(); public: diff --git a/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.cpp b/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.cpp index 29ae2497..998d7910 100644 --- a/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.cpp +++ b/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.cpp @@ -29,7 +29,7 @@ IMPLEMENT_NESTED_PAGE_CREATOR(RepoManConfigPage, 210) RepoManConfigPage::RepoManConfigPage(ConfigDialog* dlg) : ConfigPage(dlg) - , refresher(NULL) + , refresher(MacGitver::self().refresher()) { setupUi(this); @@ -72,10 +72,7 @@ void RepoManConfigPage::apply() void RepoManConfigPage::init() { - RM::RepoMan* rm = &RM::RepoMan::instance(); - - RM::Internal::RepoManPrivate* rmp = RM::Internal::BasePrivate::dataOf(rm); - refresher = rmp->refresher; + Q_ASSERT(refresher); grpEnableAutoRefresh->setChecked(refresher->refreshEnabled()); diff --git a/Libs/libMacGitverCore/RepoMan/Private/RepoManPrivate.hpp b/Libs/libMacGitverCore/RepoMan/Private/RepoManPrivate.hpp index e6ef93c2..73592c6e 100644 --- a/Libs/libMacGitverCore/RepoMan/Private/RepoManPrivate.hpp +++ b/Libs/libMacGitverCore/RepoMan/Private/RepoManPrivate.hpp @@ -51,7 +51,6 @@ namespace RM public: Repo::List repos; Repo* activeRepo; - AutoRefresher* refresher; }; } diff --git a/Libs/libMacGitverCore/RepoMan/RepoMan.cpp b/Libs/libMacGitverCore/RepoMan/RepoMan.cpp index 279a9612..b4db3d4a 100644 --- a/Libs/libMacGitverCore/RepoMan/RepoMan.cpp +++ b/Libs/libMacGitverCore/RepoMan/RepoMan.cpp @@ -186,14 +186,8 @@ namespace RM RepoManPrivate::RepoManPrivate(RepoMan* _pub) : BasePrivate(_pub) , activeRepo(NULL) - , refresher(NULL) { setupActions(_pub); - - // only start the auto refresher if we're running a GUI - if (MacGitver::self().isRunningGui()) { - refresher = new AutoRefresher(_pub); - } } bool RepoManPrivate::refreshSelf() @@ -257,7 +251,7 @@ namespace RM break; } - return NULL; + return nullptr; } } From 1ad1e9cc015882695681cb1ee62a36206a71cf44 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 22 Mar 2015 18:04:23 +0000 Subject: [PATCH 09/75] Change RepoMan's "Set" to "List" everywhere --- Libs/libMacGitverCore/RepoMan/Base.cpp | 14 +++++------ Libs/libMacGitverCore/RepoMan/Base.hpp | 24 +++++-------------- Libs/libMacGitverCore/RepoMan/Branch.hpp | 1 - .../RepoMan/CollectionNode.hpp | 1 - Libs/libMacGitverCore/RepoMan/Head.hpp | 1 - Libs/libMacGitverCore/RepoMan/Namespace.hpp | 1 - .../RepoMan/Private/BasePrivate.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Ref.hpp | 1 - Libs/libMacGitverCore/RepoMan/RefTreeNode.hpp | 1 - Libs/libMacGitverCore/RepoMan/Remote.hpp | 1 - Libs/libMacGitverCore/RepoMan/Repo.cpp | 6 ++--- Libs/libMacGitverCore/RepoMan/Repo.hpp | 3 +-- Libs/libMacGitverCore/RepoMan/Tag.hpp | 1 - Modules/Repository/RepoInfoModel.cpp | 7 ++---- 14 files changed, 20 insertions(+), 44 deletions(-) diff --git a/Libs/libMacGitverCore/RepoMan/Base.cpp b/Libs/libMacGitverCore/RepoMan/Base.cpp index c8d7e53e..e4d57692 100644 --- a/Libs/libMacGitverCore/RepoMan/Base.cpp +++ b/Libs/libMacGitverCore/RepoMan/Base.cpp @@ -117,7 +117,7 @@ namespace RM * * @return A set of all children of this object (unfiltered). */ - Base::Set Base::childObjects() const + Base::List Base::childObjects() const { RM_CD(Base); @@ -132,15 +132,15 @@ namespace RM * @return A set of children of this object filtered by object type. * */ - Base::Set Base::childObjects(ObjTypes type) const + Base::List Base::childObjects(ObjTypes type) const { RM_CD(Base); - Set children; + List children; foreach(Base* child, d->mChildren) { if (child->objType() == type) { - children.insert(child); + children.append(child); } } @@ -354,7 +354,7 @@ namespace RM { Q_ASSERT(object); Q_ASSERT(!mChildren.contains(object)); - mChildren.insert(object); + mChildren.append(object); } /** @@ -366,7 +366,7 @@ namespace RM void BasePrivate::removeChildObject(Base* object) { Q_ASSERT(mChildren.contains(object)); - mChildren.remove(object); + mChildren.removeOne(object); } /** @@ -597,7 +597,7 @@ namespace RM Base* current = mPub; foreach (QString scope, scopes) { - RefTreeNode::Set nodes = current->childObjects(); + RefTreeNode::List nodes = current->childObjects(); RefTreeNode* next = NULL; foreach(RefTreeNode* child, nodes) { diff --git a/Libs/libMacGitverCore/RepoMan/Base.hpp b/Libs/libMacGitverCore/RepoMan/Base.hpp index 888212b8..206db8c4 100644 --- a/Libs/libMacGitverCore/RepoMan/Base.hpp +++ b/Libs/libMacGitverCore/RepoMan/Base.hpp @@ -89,7 +89,6 @@ namespace RM public: typedef QVector< Base* > List; - typedef QSet< Base* > Set; protected: Base(Internal::BasePrivate& _d); @@ -106,11 +105,11 @@ namespace RM Base* parentObject() const; - Set childObjects() const; - Set childObjects(ObjTypes type) const; + List childObjects() const; + List childObjects(ObjTypes type) const; template< class T > - typename T::Set childObjects() const; + typename T::List childObjects() const; template< class T > bool isA() const; @@ -149,24 +148,13 @@ namespace RM } template< class T > - inline typename T::Set Base::childObjects() const + inline typename T::List Base::childObjects() const { - /* - Set children = childObjects(T::StaticObjType); - typename T::Set typedChildren; - - foreach(Base* child, children) { - typedChildren.insert(static_cast(child)); - } - - return typedChildren; - */ - // Equivalent, but faster: - typename T::Set children; + typename T::List children; foreach(Base* child, childObjects()) { if (child->inheritsRepoManType()) { - children.insert(static_cast(child)); + children.append(static_cast(child)); } } diff --git a/Libs/libMacGitverCore/RepoMan/Branch.hpp b/Libs/libMacGitverCore/RepoMan/Branch.hpp index f511f537..4c768a04 100644 --- a/Libs/libMacGitverCore/RepoMan/Branch.hpp +++ b/Libs/libMacGitverCore/RepoMan/Branch.hpp @@ -29,7 +29,6 @@ namespace RM public: enum { StaticObjectType = BranchObject }; typedef QVector< Branch* > List; - typedef QSet< Branch* > Set; public: Branch(Base* parent, const Git::Reference& ref); diff --git a/Libs/libMacGitverCore/RepoMan/CollectionNode.hpp b/Libs/libMacGitverCore/RepoMan/CollectionNode.hpp index b0ea932d..98ac869a 100644 --- a/Libs/libMacGitverCore/RepoMan/CollectionNode.hpp +++ b/Libs/libMacGitverCore/RepoMan/CollectionNode.hpp @@ -38,7 +38,6 @@ namespace RM public: enum { StaticObjectType = CollectionNodeObject }; typedef Internal::CollectionNodePrivate Private; - typedef QSet< CollectionNode* > Set; typedef QVector< CollectionNode* > List; public: diff --git a/Libs/libMacGitverCore/RepoMan/Head.hpp b/Libs/libMacGitverCore/RepoMan/Head.hpp index 5e26d838..4e6eccc8 100644 --- a/Libs/libMacGitverCore/RepoMan/Head.hpp +++ b/Libs/libMacGitverCore/RepoMan/Head.hpp @@ -36,7 +36,6 @@ namespace RM public: enum { StaticObjectType = HeadObject }; typedef Internal::HeadPrivate Private; - typedef QSet< Head* > Set; typedef QVector< Head* > List; public: diff --git a/Libs/libMacGitverCore/RepoMan/Namespace.hpp b/Libs/libMacGitverCore/RepoMan/Namespace.hpp index 2a0d986e..cacc4060 100644 --- a/Libs/libMacGitverCore/RepoMan/Namespace.hpp +++ b/Libs/libMacGitverCore/RepoMan/Namespace.hpp @@ -35,7 +35,6 @@ namespace RM public: enum { StaticObjectType = NamespaceObject }; typedef Internal::NamespacePrivate Private; - typedef QSet< Namespace* > Set; typedef QVector< Namespace* > List; public: diff --git a/Libs/libMacGitverCore/RepoMan/Private/BasePrivate.hpp b/Libs/libMacGitverCore/RepoMan/Private/BasePrivate.hpp index ea703066..295b52f4 100644 --- a/Libs/libMacGitverCore/RepoMan/Private/BasePrivate.hpp +++ b/Libs/libMacGitverCore/RepoMan/Private/BasePrivate.hpp @@ -53,7 +53,7 @@ namespace RM Base* mPub; Repo* mRepo; BasePrivate* mParentObj; - Base::Set mChildren; + Base::List mChildren; public: template< class T > T* pub() diff --git a/Libs/libMacGitverCore/RepoMan/Ref.hpp b/Libs/libMacGitverCore/RepoMan/Ref.hpp index ada176ce..e5a55c6f 100644 --- a/Libs/libMacGitverCore/RepoMan/Ref.hpp +++ b/Libs/libMacGitverCore/RepoMan/Ref.hpp @@ -42,7 +42,6 @@ namespace RM public: enum { StaticObjectType = RefObject }; - typedef QSet< Ref* > Set; typedef QList< Ref* > List; protected: diff --git a/Libs/libMacGitverCore/RepoMan/RefTreeNode.hpp b/Libs/libMacGitverCore/RepoMan/RefTreeNode.hpp index be0f5455..c49210d4 100644 --- a/Libs/libMacGitverCore/RepoMan/RefTreeNode.hpp +++ b/Libs/libMacGitverCore/RepoMan/RefTreeNode.hpp @@ -36,7 +36,6 @@ namespace RM public: enum { StaticObjectType = RefTreeNodeObject }; typedef Internal::RefTreeNodePrivate Private; - typedef QSet< RefTreeNode* > Set; typedef QList< RefTreeNode* > List; public: diff --git a/Libs/libMacGitverCore/RepoMan/Remote.hpp b/Libs/libMacGitverCore/RepoMan/Remote.hpp index d47d5e6c..2392bb7e 100644 --- a/Libs/libMacGitverCore/RepoMan/Remote.hpp +++ b/Libs/libMacGitverCore/RepoMan/Remote.hpp @@ -36,7 +36,6 @@ namespace RM public: enum { StaticObjectType = RemoteObject }; typedef Internal::RemotePrivate Private; - typedef QSet< Remote* > Set; typedef QVector< Remote* > List; public: diff --git a/Libs/libMacGitverCore/RepoMan/Repo.cpp b/Libs/libMacGitverCore/RepoMan/Repo.cpp index 6a62258a..ea148a0b 100644 --- a/Libs/libMacGitverCore/RepoMan/Repo.cpp +++ b/Libs/libMacGitverCore/RepoMan/Repo.cpp @@ -144,7 +144,7 @@ namespace RM return NULL; } - Repo::Set Repo::submodules() const + Repo::List Repo::submodules() const { return childObjects(); } @@ -437,7 +437,7 @@ namespace RM return; } - Repo::Set oldSubmodules = pub()->submodules(); + Repo::List oldSubmodules = pub()->submodules(); foreach (Git::Submodule sub, subs) { Git::Result child; @@ -459,7 +459,7 @@ namespace RM subInfo = new Submodule(subRepo, p); } else { - oldSubmodules.remove(subInfo); + oldSubmodules.removeOne(subInfo); } } diff --git a/Libs/libMacGitverCore/RepoMan/Repo.hpp b/Libs/libMacGitverCore/RepoMan/Repo.hpp index 68789b34..203be87b 100644 --- a/Libs/libMacGitverCore/RepoMan/Repo.hpp +++ b/Libs/libMacGitverCore/RepoMan/Repo.hpp @@ -46,7 +46,6 @@ namespace RM public: enum { StaticObjectType = RepoObject }; typedef Internal::RepoPrivate Private; - typedef QSet< Repo* > Set; typedef QVector< Repo* > List; protected: @@ -67,7 +66,7 @@ namespace RM bool isInitializing() const; Repo* parentRepository(); - Set submodules() const; + List submodules() const; QString path() const; diff --git a/Libs/libMacGitverCore/RepoMan/Tag.hpp b/Libs/libMacGitverCore/RepoMan/Tag.hpp index e40064d8..f5d57e10 100644 --- a/Libs/libMacGitverCore/RepoMan/Tag.hpp +++ b/Libs/libMacGitverCore/RepoMan/Tag.hpp @@ -29,7 +29,6 @@ namespace RM public: enum { StaticObjectType = TagObject }; typedef QVector< Tag* > List; - typedef QSet< Tag* > Set; public: Tag(Base* _parent, const Git::Reference& _ref); diff --git a/Modules/Repository/RepoInfoModel.cpp b/Modules/Repository/RepoInfoModel.cpp index c9886c7e..eb512740 100644 --- a/Modules/Repository/RepoInfoModel.cpp +++ b/Modules/Repository/RepoInfoModel.cpp @@ -170,11 +170,8 @@ QModelIndex RepoInfoModel::info2Index(RM::Repo* info) const if( info->parentRepository() ) { - RM::Repo::Set sms = info->parentRepository()->submodules(); - RM::Repo::List list; - foreach (RM::Repo* r, sms) { - list.append(r); - } + RM::Repo::List list = info->parentRepository()->submodules(); + // ###REPOMAN Shouldn't this be sorted? row = list.indexOf(info); } else From 77517e65300f88b074c6509c731b6e1ae06d3ced Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 10 May 2015 19:42:33 +0100 Subject: [PATCH 10/75] Move RepoMan Config Page to Config-Area --- Libs/libMacGitverCore/App/MacGitver.cpp | 2 +- Libs/libMacGitverCore/CMakeLists.txt | 9 +++------ .../{RepoMan/Config => Config/Ui}/RepoManConfigPage.cpp | 5 +---- .../{RepoMan/Config => Config/Ui}/RepoManConfigPage.hpp | 0 .../{RepoMan/Config => Config/Ui}/RepoManConfigPage.ui | 0 5 files changed, 5 insertions(+), 11 deletions(-) rename Libs/libMacGitverCore/{RepoMan/Config => Config/Ui}/RepoManConfigPage.cpp (95%) rename Libs/libMacGitverCore/{RepoMan/Config => Config/Ui}/RepoManConfigPage.hpp (100%) rename Libs/libMacGitverCore/{RepoMan/Config => Config/Ui}/RepoManConfigPage.ui (100%) diff --git a/Libs/libMacGitverCore/App/MacGitver.cpp b/Libs/libMacGitverCore/App/MacGitver.cpp index 3eb12aad..cbbc8594 100644 --- a/Libs/libMacGitverCore/App/MacGitver.cpp +++ b/Libs/libMacGitverCore/App/MacGitver.cpp @@ -32,9 +32,9 @@ #include "libMacGitverCore/App/MgvPrimaryWindow.hpp" #include "libMacGitverCore/Config/Config.h" #include "libMacGitverCore/Config/Ui/GeneralConfigPage.hpp" +#include "libMacGitverCore/Config/Ui//RepoManConfigPage.hpp" #include "libMacGitverCore/MacGitver/Modules.h" #include "libMacGitverCore/RepoMan/RepoMan.hpp" -#include "libMacGitverCore/RepoMan/Config/RepoManConfigPage.hpp" #include "libMacGitverCore/MacGitver/AutoRefresher.hpp" /** diff --git a/Libs/libMacGitverCore/CMakeLists.txt b/Libs/libMacGitverCore/CMakeLists.txt index 14aca99c..ba431836 100644 --- a/Libs/libMacGitverCore/CMakeLists.txt +++ b/Libs/libMacGitverCore/CMakeLists.txt @@ -20,6 +20,7 @@ SET( SRC_FILES Config/Ui/ConfigPage.cpp Config/Ui/GeneralConfigPage.cpp Config/Ui/ConfigPageProvider.cpp + Config/Ui/RepoManConfigPage.cpp MacGitver/Module.cpp MacGitver/Modules.cpp @@ -43,8 +44,6 @@ SET( SRC_FILES RepoMan/Private/Dumper.cpp - RepoMan/Config/RepoManConfigPage.cpp - SHMParser/ShellExpand.cpp Widgets/ExpandableDlg.cpp @@ -116,6 +115,7 @@ SET( PRI_HDR_FILES Config/Ui/ConfigDialog.hpp Config/Ui/GeneralConfigPage.hpp + Config/Ui/RepoManConfigPage.hpp RepoMan/Private/BasePrivate.hpp RepoMan/Private/BranchPrivate.hpp @@ -132,8 +132,6 @@ SET( PRI_HDR_FILES RepoMan/Private/Dumper.hpp RepoMan/Private/HeadPrivate.hpp - RepoMan/Config/RepoManConfigPage.hpp - Widgets/StringSelectorWidgetPrivate.h Widgets/FlatTreeModelPrivate.h Widgets/RepoStateWidget.hpp @@ -145,8 +143,7 @@ SET( UI_FILES Config/Ui/ConfigDialog.ui Config/Ui/GeneralConfigPage.ui - - RepoMan/Config/RepoManConfigPage.ui + Config/Ui/RepoManConfigPage.ui Widgets/ExpandableDlg.ui ) diff --git a/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.cpp b/Libs/libMacGitverCore/Config/Ui/RepoManConfigPage.cpp similarity index 95% rename from Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.cpp rename to Libs/libMacGitverCore/Config/Ui/RepoManConfigPage.cpp index 998d7910..e3a82093 100644 --- a/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.cpp +++ b/Libs/libMacGitverCore/Config/Ui/RepoManConfigPage.cpp @@ -17,10 +17,7 @@ * */ -#include "libMacGitverCore/RepoMan/Config/RepoManConfigPage.hpp" - -#include "libMacGitverCore/RepoMan/Private/RepoManPrivate.hpp" -#include "libMacGitverCore/RepoMan/RepoMan.hpp" +#include "libMacGitverCore/Config/Ui/RepoManConfigPage.hpp" #include "libMacGitverCore/MacGitver/AutoRefresher.hpp" #include "libMacGitverCore/App/MacGitver.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.hpp b/Libs/libMacGitverCore/Config/Ui/RepoManConfigPage.hpp similarity index 100% rename from Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.hpp rename to Libs/libMacGitverCore/Config/Ui/RepoManConfigPage.hpp diff --git a/Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.ui b/Libs/libMacGitverCore/Config/Ui/RepoManConfigPage.ui similarity index 100% rename from Libs/libMacGitverCore/RepoMan/Config/RepoManConfigPage.ui rename to Libs/libMacGitverCore/Config/Ui/RepoManConfigPage.ui From 97a29e79f494058ad0cf7f8064450ba1aab59fc6 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sat, 21 Mar 2015 20:32:11 +0000 Subject: [PATCH 11/75] Move some RepoMan code around --- Libs/libMacGitverCore/CMakeLists.txt | 53 ++++++++++--------- .../BasePrivate.hpp => Data/BaseData.hpp} | 0 .../BranchPrivate.hpp => Data/BranchData.hpp} | 2 +- .../CollectionNodeData.hpp} | 2 +- .../HeadPrivate.hpp => Data/HeadData.hpp} | 2 +- .../NamespaceData.hpp} | 2 +- .../RefPrivate.hpp => Data/RefData.hpp} | 2 +- .../RefLogPrivate.hpp => Data/RefLogData.hpp} | 2 +- .../RefTreeNodeData.hpp} | 2 +- .../RemotePrivate.hpp => Data/RemoteData.hpp} | 2 +- .../RepoPrivate.hpp => Data/RepoData.hpp} | 2 +- .../RepoManData.hpp} | 2 +- .../SubmoduleData.hpp} | 2 +- .../TagPrivate.hpp => Data/TagData.hpp} | 2 +- .../RepoMan/{ => Frontend}/Base.cpp | 21 ++++---- .../RepoMan/{ => Frontend}/Branch.cpp | 3 +- .../RepoMan/{ => Frontend}/CollectionNode.cpp | 6 +-- .../RepoMan/{ => Frontend}/Head.cpp | 9 ++-- .../RepoMan/{ => Frontend}/Namespace.cpp | 7 +-- .../RepoMan/{ => Frontend}/Ref.cpp | 11 ++-- .../RepoMan/{ => Frontend}/RefLog.cpp | 4 +- .../RepoMan/{ => Frontend}/RefTreeNode.cpp | 9 ++-- .../RepoMan/{ => Frontend}/Remote.cpp | 12 +++-- .../RepoMan/{ => Frontend}/Repo.cpp | 7 +-- .../RepoMan/{ => Frontend}/Submodule.cpp | 7 +-- .../RepoMan/{ => Frontend}/Tag.cpp | 8 +-- Libs/libMacGitverCore/RepoMan/RepoMan.cpp | 5 +- 27 files changed, 103 insertions(+), 83 deletions(-) rename Libs/libMacGitverCore/RepoMan/{Private/BasePrivate.hpp => Data/BaseData.hpp} (100%) rename Libs/libMacGitverCore/RepoMan/{Private/BranchPrivate.hpp => Data/BranchData.hpp} (97%) rename Libs/libMacGitverCore/RepoMan/{Private/CollectionNodePrivate.hpp => Data/CollectionNodeData.hpp} (97%) rename Libs/libMacGitverCore/RepoMan/{Private/HeadPrivate.hpp => Data/HeadData.hpp} (97%) rename Libs/libMacGitverCore/RepoMan/{Private/NamespacePrivate.hpp => Data/NamespaceData.hpp} (96%) rename Libs/libMacGitverCore/RepoMan/{Private/RefPrivate.hpp => Data/RefData.hpp} (97%) rename Libs/libMacGitverCore/RepoMan/{Private/RefLogPrivate.hpp => Data/RefLogData.hpp} (96%) rename Libs/libMacGitverCore/RepoMan/{Private/RefTreeNodePrivate.hpp => Data/RefTreeNodeData.hpp} (97%) rename Libs/libMacGitverCore/RepoMan/{Private/RemotePrivate.hpp => Data/RemoteData.hpp} (97%) rename Libs/libMacGitverCore/RepoMan/{Private/RepoPrivate.hpp => Data/RepoData.hpp} (98%) rename Libs/libMacGitverCore/RepoMan/{Private/RepoManPrivate.hpp => Data/RepoManData.hpp} (96%) rename Libs/libMacGitverCore/RepoMan/{Private/SubmodulePrivate.hpp => Data/SubmoduleData.hpp} (96%) rename Libs/libMacGitverCore/RepoMan/{Private/TagPrivate.hpp => Data/TagData.hpp} (96%) rename Libs/libMacGitverCore/RepoMan/{ => Frontend}/Base.cpp (98%) rename Libs/libMacGitverCore/RepoMan/{ => Frontend}/Branch.cpp (98%) rename Libs/libMacGitverCore/RepoMan/{ => Frontend}/CollectionNode.cpp (96%) rename Libs/libMacGitverCore/RepoMan/{ => Frontend}/Head.cpp (97%) rename Libs/libMacGitverCore/RepoMan/{ => Frontend}/Namespace.cpp (96%) rename Libs/libMacGitverCore/RepoMan/{ => Frontend}/Ref.cpp (96%) rename Libs/libMacGitverCore/RepoMan/{ => Frontend}/RefLog.cpp (96%) rename Libs/libMacGitverCore/RepoMan/{ => Frontend}/RefTreeNode.cpp (96%) rename Libs/libMacGitverCore/RepoMan/{ => Frontend}/Remote.cpp (94%) rename Libs/libMacGitverCore/RepoMan/{ => Frontend}/Repo.cpp (99%) rename Libs/libMacGitverCore/RepoMan/{ => Frontend}/Submodule.cpp (95%) rename Libs/libMacGitverCore/RepoMan/{ => Frontend}/Tag.cpp (95%) diff --git a/Libs/libMacGitverCore/CMakeLists.txt b/Libs/libMacGitverCore/CMakeLists.txt index ba431836..10fdfaa9 100644 --- a/Libs/libMacGitverCore/CMakeLists.txt +++ b/Libs/libMacGitverCore/CMakeLists.txt @@ -27,20 +27,21 @@ SET( SRC_FILES MacGitver/GitPatchConsumer.cpp MacGitver/AutoRefresher.cpp - RepoMan/Base.cpp - RepoMan/Ref.cpp - RepoMan/Branch.cpp - RepoMan/CollectionNode.cpp RepoMan/Events.cpp - RepoMan/Repo.cpp RepoMan/RepoMan.cpp - RepoMan/Remote.cpp - RepoMan/Tag.cpp - RepoMan/RefLog.cpp - RepoMan/Submodule.cpp - RepoMan/RefTreeNode.cpp - RepoMan/Namespace.cpp - RepoMan/Head.cpp + + RepoMan/Frontend/Base.cpp + RepoMan/Frontend/Branch.cpp + RepoMan/Frontend/CollectionNode.cpp + RepoMan/Frontend/Namespace.cpp + RepoMan/Frontend/Ref.cpp + RepoMan/Frontend/RefLog.cpp + RepoMan/Frontend/RefTreeNode.cpp + RepoMan/Frontend/Remote.cpp + RepoMan/Frontend/Repo.cpp + RepoMan/Frontend/Submodule.cpp + RepoMan/Frontend/Tag.cpp + RepoMan/Frontend/Head.cpp RepoMan/Private/Dumper.cpp @@ -117,20 +118,22 @@ SET( PRI_HDR_FILES Config/Ui/GeneralConfigPage.hpp Config/Ui/RepoManConfigPage.hpp - RepoMan/Private/BasePrivate.hpp - RepoMan/Private/BranchPrivate.hpp - RepoMan/Private/CollectionNodePrivate.hpp - RepoMan/Private/NamespacePrivate.hpp - RepoMan/Private/RefPrivate.hpp - RepoMan/Private/RefLogPrivate.hpp - RepoMan/Private/RefTreeNodePrivate.hpp - RepoMan/Private/RemotePrivate.hpp - RepoMan/Private/RepoPrivate.hpp - RepoMan/Private/RepoManPrivate.hpp - RepoMan/Private/SubmodulePrivate.hpp - RepoMan/Private/TagPrivate.hpp RepoMan/Private/Dumper.hpp - RepoMan/Private/HeadPrivate.hpp + + RepoMan/Data/BaseData.hpp + RepoMan/Data/BranchData.hpp + RepoMan/Data/CollectionNodeData.hpp + RepoMan/Data/NamespaceData.hpp + RepoMan/Data/RefData.hpp + RepoMan/Data/RefLogData.hpp + RepoMan/Data/RefTreeNodeData.hpp + RepoMan/Data/RemoteData.hpp + RepoMan/Data/RepoData.hpp + RepoMan/Data/RepoManData.hpp + RepoMan/Data/SubmoduleData.hpp + RepoMan/Data/TagData.hpp + RepoMan/Data/HeadData.hpp + Widgets/StringSelectorWidgetPrivate.h Widgets/FlatTreeModelPrivate.h diff --git a/Libs/libMacGitverCore/RepoMan/Private/BasePrivate.hpp b/Libs/libMacGitverCore/RepoMan/Data/BaseData.hpp similarity index 100% rename from Libs/libMacGitverCore/RepoMan/Private/BasePrivate.hpp rename to Libs/libMacGitverCore/RepoMan/Data/BaseData.hpp diff --git a/Libs/libMacGitverCore/RepoMan/Private/BranchPrivate.hpp b/Libs/libMacGitverCore/RepoMan/Data/BranchData.hpp similarity index 97% rename from Libs/libMacGitverCore/RepoMan/Private/BranchPrivate.hpp rename to Libs/libMacGitverCore/RepoMan/Data/BranchData.hpp index ad7f54bb..ae677d80 100644 --- a/Libs/libMacGitverCore/RepoMan/Private/BranchPrivate.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/BranchData.hpp @@ -19,7 +19,7 @@ #pragma once -#include "RepoMan/Private/RefPrivate.hpp" +#include "RepoMan/Data/RefData.hpp" #include "RepoMan/Branch.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Private/CollectionNodePrivate.hpp b/Libs/libMacGitverCore/RepoMan/Data/CollectionNodeData.hpp similarity index 97% rename from Libs/libMacGitverCore/RepoMan/Private/CollectionNodePrivate.hpp rename to Libs/libMacGitverCore/RepoMan/Data/CollectionNodeData.hpp index ca4fd49d..da4ba2c2 100644 --- a/Libs/libMacGitverCore/RepoMan/Private/CollectionNodePrivate.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/CollectionNodeData.hpp @@ -19,7 +19,7 @@ #pragma once -#include "RepoMan/Private/BasePrivate.hpp" +#include "RepoMan/Data/BaseData.hpp" #include "RepoMan/CollectionNode.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Private/HeadPrivate.hpp b/Libs/libMacGitverCore/RepoMan/Data/HeadData.hpp similarity index 97% rename from Libs/libMacGitverCore/RepoMan/Private/HeadPrivate.hpp rename to Libs/libMacGitverCore/RepoMan/Data/HeadData.hpp index 2b67f393..6845675a 100644 --- a/Libs/libMacGitverCore/RepoMan/Private/HeadPrivate.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/HeadData.hpp @@ -19,7 +19,7 @@ #pragma once -#include "RepoMan/Private/BasePrivate.hpp" +#include "RepoMan/Data/BaseData.hpp" #include "RepoMan/Head.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Private/NamespacePrivate.hpp b/Libs/libMacGitverCore/RepoMan/Data/NamespaceData.hpp similarity index 96% rename from Libs/libMacGitverCore/RepoMan/Private/NamespacePrivate.hpp rename to Libs/libMacGitverCore/RepoMan/Data/NamespaceData.hpp index 8af0ae3b..607612fc 100644 --- a/Libs/libMacGitverCore/RepoMan/Private/NamespacePrivate.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/NamespaceData.hpp @@ -19,7 +19,7 @@ #pragma once -#include "RepoMan/Private/BasePrivate.hpp" +#include "RepoMan/Data/BaseData.hpp" #include "RepoMan/Namespace.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Private/RefPrivate.hpp b/Libs/libMacGitverCore/RepoMan/Data/RefData.hpp similarity index 97% rename from Libs/libMacGitverCore/RepoMan/Private/RefPrivate.hpp rename to Libs/libMacGitverCore/RepoMan/Data/RefData.hpp index 377b79d5..1a67eb16 100644 --- a/Libs/libMacGitverCore/RepoMan/Private/RefPrivate.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/RefData.hpp @@ -19,7 +19,7 @@ #pragma once -#include "RepoMan/Private/BasePrivate.hpp" +#include "RepoMan/Data/BaseData.hpp" #include "RepoMan/Ref.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Private/RefLogPrivate.hpp b/Libs/libMacGitverCore/RepoMan/Data/RefLogData.hpp similarity index 96% rename from Libs/libMacGitverCore/RepoMan/Private/RefLogPrivate.hpp rename to Libs/libMacGitverCore/RepoMan/Data/RefLogData.hpp index f5945d2a..ac51e052 100644 --- a/Libs/libMacGitverCore/RepoMan/Private/RefLogPrivate.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/RefLogData.hpp @@ -19,7 +19,7 @@ #pragma once -#include "RepoMan/Private/BasePrivate.hpp" +#include "RepoMan/Data/BaseData.hpp" #include "RepoMan/RefLog.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Private/RefTreeNodePrivate.hpp b/Libs/libMacGitverCore/RepoMan/Data/RefTreeNodeData.hpp similarity index 97% rename from Libs/libMacGitverCore/RepoMan/Private/RefTreeNodePrivate.hpp rename to Libs/libMacGitverCore/RepoMan/Data/RefTreeNodeData.hpp index fa60c315..65283eba 100644 --- a/Libs/libMacGitverCore/RepoMan/Private/RefTreeNodePrivate.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/RefTreeNodeData.hpp @@ -19,7 +19,7 @@ #pragma once -#include "RepoMan/Private/BasePrivate.hpp" +#include "RepoMan/Data/BaseData.hpp" #include "RepoMan/RefTreeNode.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Private/RemotePrivate.hpp b/Libs/libMacGitverCore/RepoMan/Data/RemoteData.hpp similarity index 97% rename from Libs/libMacGitverCore/RepoMan/Private/RemotePrivate.hpp rename to Libs/libMacGitverCore/RepoMan/Data/RemoteData.hpp index 0c8b2fec..a50bcd00 100644 --- a/Libs/libMacGitverCore/RepoMan/Private/RemotePrivate.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/RemoteData.hpp @@ -19,7 +19,7 @@ #pragma once -#include "RepoMan/Private/BasePrivate.hpp" +#include "RepoMan/Data/BaseData.hpp" #include "RepoMan/Remote.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Private/RepoPrivate.hpp b/Libs/libMacGitverCore/RepoMan/Data/RepoData.hpp similarity index 98% rename from Libs/libMacGitverCore/RepoMan/Private/RepoPrivate.hpp rename to Libs/libMacGitverCore/RepoMan/Data/RepoData.hpp index 2b16deab..f1f28a6c 100644 --- a/Libs/libMacGitverCore/RepoMan/Private/RepoPrivate.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/RepoData.hpp @@ -19,7 +19,7 @@ #pragma once -#include "RepoMan/Private/BasePrivate.hpp" +#include "RepoMan/Data/BaseData.hpp" #include "RepoMan/Repo.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Private/RepoManPrivate.hpp b/Libs/libMacGitverCore/RepoMan/Data/RepoManData.hpp similarity index 96% rename from Libs/libMacGitverCore/RepoMan/Private/RepoManPrivate.hpp rename to Libs/libMacGitverCore/RepoMan/Data/RepoManData.hpp index 73592c6e..1561edb7 100644 --- a/Libs/libMacGitverCore/RepoMan/Private/RepoManPrivate.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/RepoManData.hpp @@ -19,7 +19,7 @@ #pragma once -#include "libMacGitverCore/RepoMan/Private/BasePrivate.hpp" +#include "libMacGitverCore/RepoMan/Data/BaseData.hpp" #include "libMacGitverCore/RepoMan/RepoMan.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Private/SubmodulePrivate.hpp b/Libs/libMacGitverCore/RepoMan/Data/SubmoduleData.hpp similarity index 96% rename from Libs/libMacGitverCore/RepoMan/Private/SubmodulePrivate.hpp rename to Libs/libMacGitverCore/RepoMan/Data/SubmoduleData.hpp index 38bb9e65..40937119 100644 --- a/Libs/libMacGitverCore/RepoMan/Private/SubmodulePrivate.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/SubmoduleData.hpp @@ -19,7 +19,7 @@ #pragma once -#include "RepoMan/Private/RepoPrivate.hpp" +#include "RepoMan/Data/RepoData.hpp" #include "RepoMan/Submodule.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Private/TagPrivate.hpp b/Libs/libMacGitverCore/RepoMan/Data/TagData.hpp similarity index 96% rename from Libs/libMacGitverCore/RepoMan/Private/TagPrivate.hpp rename to Libs/libMacGitverCore/RepoMan/Data/TagData.hpp index 896da3b1..c371206e 100644 --- a/Libs/libMacGitverCore/RepoMan/Private/TagPrivate.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/TagData.hpp @@ -19,7 +19,7 @@ #pragma once -#include "RepoMan/Private/RefPrivate.hpp" +#include "RepoMan/Data/RefData.hpp" #include "RepoMan/Tag.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Base.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Base.cpp similarity index 98% rename from Libs/libMacGitverCore/RepoMan/Base.cpp rename to Libs/libMacGitverCore/RepoMan/Frontend/Base.cpp index e4d57692..24f8ad11 100644 --- a/Libs/libMacGitverCore/RepoMan/Base.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Base.cpp @@ -24,16 +24,17 @@ #include "App/MacGitver.hpp" -#include "Base.hpp" -#include "Repo.hpp" -#include "RepoMan.hpp" -#include "RefTreeNode.hpp" -#include "CollectionNode.hpp" -#include "Events.hpp" - -#include "Private/RepoManPrivate.hpp" -#include "Private/Dumper.hpp" -#include "Private/BasePrivate.hpp" +#include "RepoMan/Base.hpp" +#include "RepoMan/Repo.hpp" +#include "RepoMan/RepoMan.hpp" +#include "RepoMan/RefTreeNode.hpp" +#include "RepoMan/CollectionNode.hpp" +#include "RepoMan/Events.hpp" + +#include "RepoMan/Data/RepoManData.hpp" +#include "RepoMan/Data/BaseData.hpp" + +#include "RepoMan/Private/Dumper.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Branch.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp similarity index 98% rename from Libs/libMacGitverCore/RepoMan/Branch.cpp rename to Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp index dd0115ae..8008f907 100644 --- a/Libs/libMacGitverCore/RepoMan/Branch.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp @@ -23,7 +23,8 @@ #include "RepoMan/Head.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Private/BranchPrivate.hpp" + +#include "RepoMan/Data/BranchData.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/CollectionNode.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/CollectionNode.cpp similarity index 96% rename from Libs/libMacGitverCore/RepoMan/CollectionNode.cpp rename to Libs/libMacGitverCore/RepoMan/Frontend/CollectionNode.cpp index 8f703ffb..bede7079 100644 --- a/Libs/libMacGitverCore/RepoMan/CollectionNode.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/CollectionNode.cpp @@ -21,10 +21,10 @@ #include "libHeavenIcons/IconRef.hpp" -#include "CollectionNode.hpp" +#include "RepoMan/CollectionNode.hpp" -#include "Private/Dumper.hpp" -#include "Private/CollectionNodePrivate.hpp" +#include "RepoMan/Private/Dumper.hpp" +#include "RepoMan/Data/CollectionNodeData.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Head.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp similarity index 97% rename from Libs/libMacGitverCore/RepoMan/Head.cpp rename to Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp index 0a312cda..2f45f196 100644 --- a/Libs/libMacGitverCore/RepoMan/Head.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp @@ -17,11 +17,14 @@ * */ -#include "Head.hpp" -#include "Events.hpp" +#include "RepoMan/Events.hpp" + +#include "RepoMan/Head.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Private/HeadPrivate.hpp" + +#include "RepoMan/Data/HeadData.hpp" + #include "RepoMan/Branch.hpp" #include "RepoMan/Repo.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Namespace.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Namespace.cpp similarity index 96% rename from Libs/libMacGitverCore/RepoMan/Namespace.cpp rename to Libs/libMacGitverCore/RepoMan/Frontend/Namespace.cpp index 19ba0b7e..e32bf40c 100644 --- a/Libs/libMacGitverCore/RepoMan/Namespace.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Namespace.cpp @@ -17,11 +17,12 @@ * */ -#include "Namespace.hpp" -#include "Events.hpp" +#include "RepoMan/Events.hpp" + +#include "RepoMan/Namespace.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Private/NamespacePrivate.hpp" +#include "RepoMan/Data/NamespaceData.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Ref.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Ref.cpp similarity index 96% rename from Libs/libMacGitverCore/RepoMan/Ref.cpp rename to Libs/libMacGitverCore/RepoMan/Frontend/Ref.cpp index 4bcdd5dd..22708601 100644 --- a/Libs/libMacGitverCore/RepoMan/Ref.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Ref.cpp @@ -21,12 +21,13 @@ #include "libGitWrap/Reference.hpp" #include "libGitWrap/RefName.hpp" -#include "Ref.hpp" -#include "Repo.hpp" -#include "Events.hpp" +#include "RepoMan/Events.hpp" -#include "Private/Dumper.hpp" -#include "Private/RefPrivate.hpp" +#include "RepoMan/Ref.hpp" +#include "RepoMan/Repo.hpp" + +#include "RepoMan/Private/Dumper.hpp" +#include "RepoMan/Data/RefData.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/RefLog.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/RefLog.cpp similarity index 96% rename from Libs/libMacGitverCore/RepoMan/RefLog.cpp rename to Libs/libMacGitverCore/RepoMan/Frontend/RefLog.cpp index 443fbc5e..86f4ef9c 100644 --- a/Libs/libMacGitverCore/RepoMan/RefLog.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/RefLog.cpp @@ -17,10 +17,10 @@ * */ -#include "RefLog.hpp" +#include "RepoMan/RefLog.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Private/RefLogPrivate.hpp" +#include "RepoMan/Data/RefLogData.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/RefTreeNode.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.cpp similarity index 96% rename from Libs/libMacGitverCore/RepoMan/RefTreeNode.cpp rename to Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.cpp index 4fae6a5a..85ea00fb 100644 --- a/Libs/libMacGitverCore/RepoMan/RefTreeNode.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.cpp @@ -17,10 +17,13 @@ * */ -#include "RefTreeNode.hpp" -#include "Events.hpp" +#include "RepoMan/Events.hpp" + +#include "RepoMan/RefTreeNode.hpp" + #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Private/RefTreeNodePrivate.hpp" + +#include "RepoMan/Data/RefTreeNodeData.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Remote.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Remote.cpp similarity index 94% rename from Libs/libMacGitverCore/RepoMan/Remote.cpp rename to Libs/libMacGitverCore/RepoMan/Frontend/Remote.cpp index 7a402400..4835f8c0 100644 --- a/Libs/libMacGitverCore/RepoMan/Remote.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Remote.cpp @@ -19,13 +19,15 @@ #include "libGitWrap/Result.hpp" -#include "Repo.hpp" -#include "Remote.hpp" -#include "Events.hpp" -#include "CollectionNode.hpp" +#include "RepoMan/Events.hpp" + +#include "RepoMan/Repo.hpp" +#include "RepoMan/Remote.hpp" +#include "RepoMan/CollectionNode.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Private/RemotePrivate.hpp" + +#include "RepoMan/Data/RemoteData.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Repo.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Repo.cpp similarity index 99% rename from Libs/libMacGitverCore/RepoMan/Repo.cpp rename to Libs/libMacGitverCore/RepoMan/Frontend/Repo.cpp index ea148a0b..978e00d8 100644 --- a/Libs/libMacGitverCore/RepoMan/Repo.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Repo.cpp @@ -39,9 +39,10 @@ #include "RepoMan/Submodule.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Private/RepoPrivate.hpp" -#include "RepoMan/Private/RemotePrivate.hpp" -#include "RepoMan/Private/CollectionNodePrivate.hpp" + +#include "RepoMan/Data/RepoData.hpp" +#include "RepoMan/Data/RemoteData.hpp" +#include "RepoMan/Data/CollectionNodeData.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Submodule.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Submodule.cpp similarity index 95% rename from Libs/libMacGitverCore/RepoMan/Submodule.cpp rename to Libs/libMacGitverCore/RepoMan/Frontend/Submodule.cpp index 4f5e148e..0874f04b 100644 --- a/Libs/libMacGitverCore/RepoMan/Submodule.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Submodule.cpp @@ -17,11 +17,12 @@ * */ -#include "Submodule.hpp" -#include "Events.hpp" +#include "RepoMan/Events.hpp" + +#include "RepoMan/Submodule.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Private/SubmodulePrivate.hpp" +#include "RepoMan/Data/SubmoduleData.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Tag.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Tag.cpp similarity index 95% rename from Libs/libMacGitverCore/RepoMan/Tag.cpp rename to Libs/libMacGitverCore/RepoMan/Frontend/Tag.cpp index a530ef13..c04c4072 100644 --- a/Libs/libMacGitverCore/RepoMan/Tag.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Tag.cpp @@ -17,11 +17,13 @@ * */ -#include "Tag.hpp" -#include "Events.hpp" +#include "RepoMan/Events.hpp" + +#include "RepoMan/Tag.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Private/TagPrivate.hpp" + +#include "RepoMan/Data/TagData.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/RepoMan.cpp b/Libs/libMacGitverCore/RepoMan/RepoMan.cpp index b4db3d4a..a01b6393 100644 --- a/Libs/libMacGitverCore/RepoMan/RepoMan.cpp +++ b/Libs/libMacGitverCore/RepoMan/RepoMan.cpp @@ -24,8 +24,9 @@ #include "RepoMan/Events.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Private/RepoManPrivate.hpp" -#include "RepoMan/Private/RepoPrivate.hpp" + +#include "RepoMan/Data/RepoManData.hpp" +#include "RepoMan/Data/RepoData.hpp" #include "libBlueSky/Application.hpp" From 9ff3da1339f647f7eca1c8ad92e42af50eb03732 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Mon, 11 May 2015 02:26:29 +0100 Subject: [PATCH 12/75] Turn RM::ObjType into an Enum Class --- Libs/libMacGitverCore/CMakeLists.txt | 1 + Libs/libMacGitverCore/RepoMan/Base.hpp | 36 +---------- Libs/libMacGitverCore/RepoMan/Branch.hpp | 2 +- .../RepoMan/CollectionNode.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Core.hpp | 61 +++++++++++++++++++ .../RepoMan/Data/BaseData.hpp | 11 +++- .../RepoMan/Frontend/Branch.cpp | 4 +- .../RepoMan/Frontend/CollectionNode.cpp | 4 +- .../RepoMan/Frontend/Head.cpp | 4 +- .../RepoMan/Frontend/Namespace.cpp | 4 +- .../libMacGitverCore/RepoMan/Frontend/Ref.cpp | 4 +- .../RepoMan/Frontend/RefLog.cpp | 4 +- .../RepoMan/Frontend/RefTreeNode.cpp | 4 +- .../RepoMan/Frontend/Remote.cpp | 4 +- .../RepoMan/Frontend/Repo.cpp | 8 +-- .../RepoMan/Frontend/Submodule.cpp | 4 +- .../libMacGitverCore/RepoMan/Frontend/Tag.cpp | 4 +- Libs/libMacGitverCore/RepoMan/Head.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Namespace.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Ref.hpp | 2 +- Libs/libMacGitverCore/RepoMan/RefLog.hpp | 2 +- Libs/libMacGitverCore/RepoMan/RefTreeNode.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Remote.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Repo.hpp | 2 +- Libs/libMacGitverCore/RepoMan/RepoMan.cpp | 22 +++---- Libs/libMacGitverCore/RepoMan/RepoMan.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Submodule.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Tag.hpp | 2 +- Modules/RefsViews/Branches/BranchesModel.cpp | 14 ++--- 29 files changed, 127 insertions(+), 90 deletions(-) create mode 100644 Libs/libMacGitverCore/RepoMan/Core.hpp diff --git a/Libs/libMacGitverCore/CMakeLists.txt b/Libs/libMacGitverCore/CMakeLists.txt index 10fdfaa9..5f18241a 100644 --- a/Libs/libMacGitverCore/CMakeLists.txt +++ b/Libs/libMacGitverCore/CMakeLists.txt @@ -77,6 +77,7 @@ SET( PUB_HDR_FILES MacGitver/GitPatchConsumer.hpp MacGitver/IRepositoryContext.hpp + RepoMan/Core.hpp RepoMan/Base.hpp RepoMan/Events.hpp RepoMan/CollectionNode.hpp diff --git a/Libs/libMacGitverCore/RepoMan/Base.hpp b/Libs/libMacGitverCore/RepoMan/Base.hpp index 206db8c4..8bdfd4a9 100644 --- a/Libs/libMacGitverCore/RepoMan/Base.hpp +++ b/Libs/libMacGitverCore/RepoMan/Base.hpp @@ -19,45 +19,11 @@ #pragma once -#include -#include -#include - -#include "libMacGitverCore/MacGitverApi.hpp" - -namespace Heaven { - - class Menu; - class IconRef; - -} +#include "libMacGitverCore/RepoMan/Core.hpp" namespace RM { - enum ObjTypes - { - InvalidObject, - - CollectionNodeObject, - NamespaceObject, - RepoManagerObject, - - // repositories - RepoObject, - RemoteObject, - SubmoduleObject, - HeadObject, - - // references - BranchObject, - RefObject, - RefTreeNodeObject, - TagObject, - - RefLogObject - }; - enum CollectionTypes { ctBranches, diff --git a/Libs/libMacGitverCore/RepoMan/Branch.hpp b/Libs/libMacGitverCore/RepoMan/Branch.hpp index 4c768a04..7452299f 100644 --- a/Libs/libMacGitverCore/RepoMan/Branch.hpp +++ b/Libs/libMacGitverCore/RepoMan/Branch.hpp @@ -27,7 +27,7 @@ namespace RM class MGV_CORE_API Branch : public Ref { public: - enum { StaticObjectType = BranchObject }; + static const ObjTypes StaticObjectType = ObjTypes::Branch; typedef QVector< Branch* > List; public: diff --git a/Libs/libMacGitverCore/RepoMan/CollectionNode.hpp b/Libs/libMacGitverCore/RepoMan/CollectionNode.hpp index 98ac869a..6b30e134 100644 --- a/Libs/libMacGitverCore/RepoMan/CollectionNode.hpp +++ b/Libs/libMacGitverCore/RepoMan/CollectionNode.hpp @@ -36,7 +36,7 @@ namespace RM Q_DECLARE_TR_FUNCTIONS(RM_CollectionNode) public: - enum { StaticObjectType = CollectionNodeObject }; + static const ObjTypes StaticObjectType = ObjTypes::CollectionNode; typedef Internal::CollectionNodePrivate Private; typedef QVector< CollectionNode* > List; diff --git a/Libs/libMacGitverCore/RepoMan/Core.hpp b/Libs/libMacGitverCore/RepoMan/Core.hpp new file mode 100644 index 00000000..f4bdc384 --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Core.hpp @@ -0,0 +1,61 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 +#include +#include + +#include "libMacGitverCore/MacGitverApi.hpp" + +namespace Heaven { + + class Menu; + class IconRef; + +} + +namespace RM +{ + + enum class ObjTypes + { + Invalid, + + CollectionNode, + Namespace, + RepoManager, + + // repositories + Repo, + Remote, + Submodule, + Head, + + // references + Branch, + Reference, + RefTreeNode, + Tag, + + RefLog + }; + +} diff --git a/Libs/libMacGitverCore/RepoMan/Data/BaseData.hpp b/Libs/libMacGitverCore/RepoMan/Data/BaseData.hpp index 295b52f4..962958f1 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/BaseData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/BaseData.hpp @@ -33,13 +33,22 @@ #define RM_CP(CLASS) const CLASS* p = \ static_cast(mPub) +#ifdef _MSVC +#define const_or_constexpr const +#else +#define const_or_constexpr constexpr +#endif + namespace RM { namespace Internal { - class Dumper; + } + + namespace Internal + { class BasePrivate { diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp index 8008f907..02a3909a 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp @@ -86,7 +86,7 @@ namespace RM ObjTypes BranchPrivate::objType() const { - return BranchObject; + return ObjTypes::Branch; } void BranchPrivate::postCreation() @@ -135,7 +135,7 @@ namespace RM bool BranchPrivate::inherits(ObjTypes type) const { - return type == BranchObject || RefPrivate::inherits(type); + return type == ObjTypes::Branch || RefPrivate::inherits(type); } } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/CollectionNode.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/CollectionNode.cpp index bede7079..e35ed1b0 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/CollectionNode.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/CollectionNode.cpp @@ -68,7 +68,7 @@ namespace RM ObjTypes CollectionNodePrivate::objType() const { - return CollectionNodeObject; + return ObjTypes::CollectionNode; } QString CollectionNodePrivate::displayName() const @@ -121,7 +121,7 @@ namespace RM bool CollectionNodePrivate::inherits(ObjTypes type) const { - return type == CollectionNodeObject || BasePrivate::inherits(type); + return type == ObjTypes::CollectionNode || BasePrivate::inherits(type); } } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp index 2f45f196..b956460b 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp @@ -57,7 +57,7 @@ namespace RM ObjTypes HeadPrivate::objType() const { - return HeadObject; + return ObjTypes::Head; } void HeadPrivate::dumpSelf(Internal::Dumper& dumper) const @@ -96,7 +96,7 @@ namespace RM bool HeadPrivate::inherits(ObjTypes type) const { - return type == HeadObject || BasePrivate::inherits(type); + return type == ObjTypes::Head || BasePrivate::inherits(type); } } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Namespace.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Namespace.cpp index e32bf40c..2428b8e8 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Namespace.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Namespace.cpp @@ -80,7 +80,7 @@ namespace RM ObjTypes NamespacePrivate::objType() const { - return NamespaceObject; + return ObjTypes::Namespace; } void NamespacePrivate::dumpSelf(Internal::Dumper& dumper) const @@ -125,7 +125,7 @@ namespace RM bool NamespacePrivate::inherits(ObjTypes type) const { - return type == NamespaceObject || BasePrivate::inherits(type); + return type == ObjTypes::Namespace || BasePrivate::inherits(type); } } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Ref.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Ref.cpp index 22708601..708d8966 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Ref.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Ref.cpp @@ -109,7 +109,7 @@ namespace RM ObjTypes RefPrivate::objType() const { - return RefObject; + return ObjTypes::Reference; } QString RefPrivate::displayName() const @@ -124,7 +124,7 @@ namespace RM bool RefPrivate::inherits(ObjTypes type) const { - return type == RefObject || BasePrivate::inherits(type); + return type == ObjTypes::Reference || BasePrivate::inherits(type); } void RefPrivate::postCreation() diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/RefLog.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/RefLog.cpp index 86f4ef9c..e5c6b79f 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/RefLog.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/RefLog.cpp @@ -43,7 +43,7 @@ namespace RM ObjTypes RefLogPrivate::objType() const { - return RefLogObject; + return ObjTypes::RefLog; } void RefLogPrivate::dumpSelf(Internal::Dumper& dumper) const @@ -75,7 +75,7 @@ namespace RM bool RefLogPrivate::inherits(ObjTypes type) const { - return type == RefLogObject || BasePrivate::inherits(type); + return type == ObjTypes::RefLog || BasePrivate::inherits(type); } } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.cpp index 85ea00fb..5171f49d 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.cpp @@ -54,7 +54,7 @@ namespace RM ObjTypes RefTreeNodePrivate::objType() const { - return RefTreeNodeObject; + return ObjTypes::RefTreeNode; } void RefTreeNodePrivate::dumpSelf(Dumper& dumper) const @@ -105,7 +105,7 @@ namespace RM bool RefTreeNodePrivate::inherits(ObjTypes type) const { - return type == RefTreeNodeObject || BasePrivate::inherits(type); + return type == ObjTypes::RefTreeNode || BasePrivate::inherits(type); } } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Remote.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Remote.cpp index 4835f8c0..a4f108ed 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Remote.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Remote.cpp @@ -74,7 +74,7 @@ namespace RM ObjTypes RemotePrivate::objType() const { - return RemoteObject; + return ObjTypes::Remote; } void RemotePrivate::dumpSelf(Internal::Dumper& dumper) const @@ -120,7 +120,7 @@ namespace RM bool RemotePrivate::inherits(ObjTypes type) const { - return type == RemoteObject || BasePrivate::inherits(type); + return type == ObjTypes::Remote || BasePrivate::inherits(type); } } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Repo.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Repo.cpp index 978e00d8..45e7cd55 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Repo.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Repo.cpp @@ -138,7 +138,7 @@ namespace RM return NULL; } - if (p->inheritsRepoManType(RepoObject)) { + if (p->inheritsRepoManType(ObjTypes::Repo)) { return static_cast(p); } @@ -517,12 +517,12 @@ namespace RM /** * @brief Get this object's type * - * @return always RepoObject. + * @return always ObjTypes::Repo. * */ ObjTypes RepoPrivate::objType() const { - return RepoObject; + return ObjTypes::Repo; } void RepoPrivate::dumpSelf(Internal::Dumper& dumper) const @@ -739,7 +739,7 @@ namespace RM bool RepoPrivate::inherits(ObjTypes type) const { - return type == RepoObject || BasePrivate::inherits(type); + return type == ObjTypes::Repo || BasePrivate::inherits(type); } Repo* RepoPrivate::searchRepository() diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Submodule.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Submodule.cpp index 0874f04b..e8969375 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Submodule.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Submodule.cpp @@ -52,7 +52,7 @@ namespace RM ObjTypes SubmodulePrivate::objType() const { - return SubmoduleObject; + return ObjTypes::Submodule; } void SubmodulePrivate::dumpSelf(Dumper& dumper) const @@ -86,7 +86,7 @@ namespace RM bool SubmodulePrivate::inherits(ObjTypes type) const { - return type == SubmoduleObject || RepoPrivate::inherits(type); + return type == ObjTypes::Submodule || RepoPrivate::inherits(type); } } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Tag.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Tag.cpp index c04c4072..f98e4ce2 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Tag.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Tag.cpp @@ -46,7 +46,7 @@ namespace RM ObjTypes TagPrivate::objType() const { - return TagObject; + return ObjTypes::Tag; } void TagPrivate::postCreation() @@ -81,7 +81,7 @@ namespace RM bool TagPrivate::inherits(ObjTypes type) const { - return type == TagObject || RefPrivate::inherits(type); + return type == ObjTypes::Tag || RefPrivate::inherits(type); } } diff --git a/Libs/libMacGitverCore/RepoMan/Head.hpp b/Libs/libMacGitverCore/RepoMan/Head.hpp index 4e6eccc8..6f8990ca 100644 --- a/Libs/libMacGitverCore/RepoMan/Head.hpp +++ b/Libs/libMacGitverCore/RepoMan/Head.hpp @@ -34,7 +34,7 @@ namespace RM class MGV_CORE_API Head : public Base { public: - enum { StaticObjectType = HeadObject }; + static const ObjTypes StaticObjectType = ObjTypes::Head; typedef Internal::HeadPrivate Private; typedef QVector< Head* > List; diff --git a/Libs/libMacGitverCore/RepoMan/Namespace.hpp b/Libs/libMacGitverCore/RepoMan/Namespace.hpp index cacc4060..7049fc39 100644 --- a/Libs/libMacGitverCore/RepoMan/Namespace.hpp +++ b/Libs/libMacGitverCore/RepoMan/Namespace.hpp @@ -33,7 +33,7 @@ namespace RM class MGV_CORE_API Namespace : public Base { public: - enum { StaticObjectType = NamespaceObject }; + static const ObjTypes StaticObjectType = ObjTypes::Namespace; typedef Internal::NamespacePrivate Private; typedef QVector< Namespace* > List; diff --git a/Libs/libMacGitverCore/RepoMan/Ref.hpp b/Libs/libMacGitverCore/RepoMan/Ref.hpp index e5a55c6f..1970a4ef 100644 --- a/Libs/libMacGitverCore/RepoMan/Ref.hpp +++ b/Libs/libMacGitverCore/RepoMan/Ref.hpp @@ -40,7 +40,7 @@ namespace RM class MGV_CORE_API Ref : public Base { public: - enum { StaticObjectType = RefObject }; + static const ObjTypes StaticObjectType = ObjTypes::Reference; typedef QList< Ref* > List; diff --git a/Libs/libMacGitverCore/RepoMan/RefLog.hpp b/Libs/libMacGitverCore/RepoMan/RefLog.hpp index 45bcab0f..0879a024 100644 --- a/Libs/libMacGitverCore/RepoMan/RefLog.hpp +++ b/Libs/libMacGitverCore/RepoMan/RefLog.hpp @@ -32,7 +32,7 @@ namespace RM class MGV_CORE_API RefLog : public Base { public: - enum { StaticObjectType = RefLogObject }; + static const ObjTypes StaticObjectType = ObjTypes::RefLog; typedef Internal::RefLogPrivate Private; public: diff --git a/Libs/libMacGitverCore/RepoMan/RefTreeNode.hpp b/Libs/libMacGitverCore/RepoMan/RefTreeNode.hpp index c49210d4..1084fc7f 100644 --- a/Libs/libMacGitverCore/RepoMan/RefTreeNode.hpp +++ b/Libs/libMacGitverCore/RepoMan/RefTreeNode.hpp @@ -34,7 +34,7 @@ namespace RM class MGV_CORE_API RefTreeNode : public Base { public: - enum { StaticObjectType = RefTreeNodeObject }; + static const ObjTypes StaticObjectType = ObjTypes::RefTreeNode; typedef Internal::RefTreeNodePrivate Private; typedef QList< RefTreeNode* > List; diff --git a/Libs/libMacGitverCore/RepoMan/Remote.hpp b/Libs/libMacGitverCore/RepoMan/Remote.hpp index 2392bb7e..d4cd1756 100644 --- a/Libs/libMacGitverCore/RepoMan/Remote.hpp +++ b/Libs/libMacGitverCore/RepoMan/Remote.hpp @@ -34,7 +34,7 @@ namespace RM class MGV_CORE_API Remote : public Base { public: - enum { StaticObjectType = RemoteObject }; + static const ObjTypes StaticObjectType = ObjTypes::Remote; typedef Internal::RemotePrivate Private; typedef QVector< Remote* > List; diff --git a/Libs/libMacGitverCore/RepoMan/Repo.hpp b/Libs/libMacGitverCore/RepoMan/Repo.hpp index 203be87b..6463167c 100644 --- a/Libs/libMacGitverCore/RepoMan/Repo.hpp +++ b/Libs/libMacGitverCore/RepoMan/Repo.hpp @@ -44,7 +44,7 @@ namespace RM Q_OBJECT public: - enum { StaticObjectType = RepoObject }; + static const ObjTypes StaticObjectType = ObjTypes::Repo; typedef Internal::RepoPrivate Private; typedef QVector< Repo* > List; diff --git a/Libs/libMacGitverCore/RepoMan/RepoMan.cpp b/Libs/libMacGitverCore/RepoMan/RepoMan.cpp index a01b6393..62d47515 100644 --- a/Libs/libMacGitverCore/RepoMan/RepoMan.cpp +++ b/Libs/libMacGitverCore/RepoMan/RepoMan.cpp @@ -198,7 +198,7 @@ namespace RM ObjTypes RepoManPrivate::objType() const { - return RepoManagerObject; + return ObjTypes::RepoManager; } void RepoManPrivate::dumpSelf(Internal::Dumper& dumper) const @@ -225,18 +225,18 @@ namespace RM { switch (object->objType()) { - case BranchObject: return menuCtxBranch; - case TagObject: return menuCtxTag; - case RepoObject: return menuCtxRepo; - case SubmoduleObject: return menuCtxSubmodule; - case NamespaceObject: return menuCtxNamespace; - case RefLogObject: return menuCtxRefLog; - case RemoteObject: return menuCtxRemote; + case ObjTypes::Branch: return menuCtxBranch; + case ObjTypes::Tag: return menuCtxTag; + case ObjTypes::Repo: return menuCtxRepo; + case ObjTypes::Submodule: return menuCtxSubmodule; + case ObjTypes::Namespace: return menuCtxNamespace; + case ObjTypes::RefLog: return menuCtxRefLog; + case ObjTypes::Remote: return menuCtxRemote; - //case RefObject: return menuCtxRef; - //case RefTreeNodeObject: return menuCtxRefTreeNode; + //case ObjTypes::Reference: return menuCtxRef; + //case ObjTypes::RefTreeNode: return menuCtxRefTreeNode; - case CollectionNodeObject: + case ObjTypes::CollectionNode: switch (static_cast(object)->collectionType()) { case ctBranches: return menuCtxBranches; diff --git a/Libs/libMacGitverCore/RepoMan/RepoMan.hpp b/Libs/libMacGitverCore/RepoMan/RepoMan.hpp index f9f4f980..2b214ae7 100644 --- a/Libs/libMacGitverCore/RepoMan/RepoMan.hpp +++ b/Libs/libMacGitverCore/RepoMan/RepoMan.hpp @@ -41,7 +41,7 @@ namespace RM { Q_OBJECT public: - enum { StaticObjectType = RepoManagerObject }; + static const ObjTypes StaticObjectType = ObjTypes::RepoManager; typedef Internal::RepoManPrivate Private; public: diff --git a/Libs/libMacGitverCore/RepoMan/Submodule.hpp b/Libs/libMacGitverCore/RepoMan/Submodule.hpp index 2d366d7d..4c26cd6d 100644 --- a/Libs/libMacGitverCore/RepoMan/Submodule.hpp +++ b/Libs/libMacGitverCore/RepoMan/Submodule.hpp @@ -27,7 +27,7 @@ namespace RM class MGV_CORE_API Submodule : public Repo { public: - enum { StaticObjectType = SubmoduleObject }; + static const ObjTypes StaticObjectType = ObjTypes::Submodule; public: Submodule(const Git::Repository& repo, Repo* parent); diff --git a/Libs/libMacGitverCore/RepoMan/Tag.hpp b/Libs/libMacGitverCore/RepoMan/Tag.hpp index f5d57e10..951b71a3 100644 --- a/Libs/libMacGitverCore/RepoMan/Tag.hpp +++ b/Libs/libMacGitverCore/RepoMan/Tag.hpp @@ -27,7 +27,7 @@ namespace RM class MGV_CORE_API Tag : public Ref { public: - enum { StaticObjectType = TagObject }; + static const ObjTypes StaticObjectType = ObjTypes::Tag; typedef QVector< Tag* > List; public: diff --git a/Modules/RefsViews/Branches/BranchesModel.cpp b/Modules/RefsViews/Branches/BranchesModel.cpp index c94576e1..8cd44d53 100644 --- a/Modules/RefsViews/Branches/BranchesModel.cpp +++ b/Modules/RefsViews/Branches/BranchesModel.cpp @@ -184,7 +184,7 @@ RefItem* BranchesModel::createBranchItem(bool notify, RefItem* parent, RM::Branc return NULL; } - if (!parent && obj->parentObject()->objType() != RM::CollectionNodeObject) { + if (!parent && obj->parentObject()->objType() != RM::ObjTypes::CollectionNode) { parent = insertObject(notify, obj->parentObject()); return NULL; } @@ -198,7 +198,7 @@ RefItem* BranchesModel::createBranchItem(bool notify, RefItem* parent, RM::Branc RefItem* BranchesModel::createTagItem(bool notify, RefItem* parent, RM::Tag* obj) { - if (!parent && obj->parentObject()->objType() != RM::CollectionNodeObject) { + if (!parent && obj->parentObject()->objType() != RM::ObjTypes::CollectionNode) { parent = insertObject(notify, obj->parentObject()); return NULL; } @@ -215,7 +215,7 @@ RefItem* BranchesModel::createScopeItem(bool notify, RefItem* parent, RM::RefTre if (!parent) { RM::Base* parObj = obj->parentObject(); - if (parObj->objType() != RM::CollectionNodeObject) { + if (parObj->objType() != RM::ObjTypes::CollectionNode) { parent = insertObject(notify, parObj); return NULL; } @@ -262,20 +262,20 @@ RefItem* BranchesModel::insertObject(bool notify, RM::Base* obj) if (!it) { switch (obj->objType()) { - case RM::BranchObject: + case RM::ObjTypes::Branch: it = createBranchItem(notify, parent, static_cast(obj)); break; - case RM::TagObject: + case RM::ObjTypes::Tag: it = createTagItem(notify, parent, static_cast(obj)); break; - case RM::RefTreeNodeObject: + case RM::ObjTypes::RefTreeNode: it = createScopeItem(notify, parent, static_cast(obj)); doChildren = true; break; - case RM::RemoteObject: + case RM::ObjTypes::Remote: it = createRemoteItem(notify, parent, static_cast(obj)); doChildren = true; break; From d16922c97dfdc752a800644351cbda6ad13ae9da Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Mon, 11 May 2015 18:43:04 +0100 Subject: [PATCH 13/75] Move BasePrivate to own .cpp file --- Libs/libMacGitverCore/CMakeLists.txt | 2 + Libs/libMacGitverCore/RepoMan/Core.hpp | 1 + Libs/libMacGitverCore/RepoMan/Data/Base.cpp | 413 ++++++++++++++++++ .../RepoMan/Frontend/Base.cpp | 407 +---------------- 4 files changed, 432 insertions(+), 391 deletions(-) create mode 100644 Libs/libMacGitverCore/RepoMan/Data/Base.cpp diff --git a/Libs/libMacGitverCore/CMakeLists.txt b/Libs/libMacGitverCore/CMakeLists.txt index 5f18241a..8a2066bf 100644 --- a/Libs/libMacGitverCore/CMakeLists.txt +++ b/Libs/libMacGitverCore/CMakeLists.txt @@ -43,6 +43,8 @@ SET( SRC_FILES RepoMan/Frontend/Tag.cpp RepoMan/Frontend/Head.cpp + RepoMan/Data/Base.cpp + RepoMan/Private/Dumper.cpp SHMParser/ShellExpand.cpp diff --git a/Libs/libMacGitverCore/RepoMan/Core.hpp b/Libs/libMacGitverCore/RepoMan/Core.hpp index f4bdc384..b9629814 100644 --- a/Libs/libMacGitverCore/RepoMan/Core.hpp +++ b/Libs/libMacGitverCore/RepoMan/Core.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "libMacGitverCore/MacGitverApi.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Data/Base.cpp b/Libs/libMacGitverCore/RepoMan/Data/Base.cpp new file mode 100644 index 00000000..a5655074 --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Data/Base.cpp @@ -0,0 +1,413 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "RepoMan/Data/BaseData.hpp" +#include "RepoMan/Data/RefTreeNodeData.hpp" +#include "RepoMan/Data/CollectionNodeData.hpp" + +#include "RepoMan/Base.hpp" +#include "RepoMan/Repo.hpp" + +#include "RepoMan/Events.hpp" +#include "RepoMan/Private/Dumper.hpp" + +#include "libHeavenIcons/IconRef.hpp" + +namespace RM +{ + + namespace Internal + { + + BasePrivate::BasePrivate(Base* pub) + : mPub(pub) + , mRepo(NULL) + , mParentObj(NULL) + { + Q_ASSERT(mPub); + } + + BasePrivate::~BasePrivate() + { + // THIS _IS_ IMPORTANT + // We forbid by definition that any RM::* object may be destroyed _before_ it is unlinked + // from its parent. Otherwise, events cannot be triggered correctly. + Q_ASSERT(mChildren.count() == 0); + Q_ASSERT(mParentObj == NULL); + Q_ASSERT(mRepo == NULL); + } + + /** + * @brief Child-part of linking into the tree + * + * @param[in] parent The parent to link into + * + * This method is called directly from the constructor. It establishes a relationship with the + * parent object. This relationship can never be altered. + * + */ + void BasePrivate::linkToParent(Base* parent) + { + if (parent) { + mParentObj = parent->mData; + mParentObj->addChildObject(mPub); + mRepo = searchRepository(); + refreshSelf(); + postCreation(); + } + } + + /** + * @internal + * @brief Child-Part of unlinking from the tree + * + * Invokes the parent part on the parent side and then cleans up the reference to the parent. + */ + void BasePrivate::unlinkFromParent() + { + if (mParentObj) { + mParentObj->removeChildObject(mPub); + mParentObj = NULL; + mRepo = NULL; + } + } + + /** + * @internal + * @brief Parent-part of linking a new child + * + * We cannot do any special processing, since the child object is not yet fully constructed. We + * just fill the internal structure. + * + * @param[in] object The new child object that shall be linked in. + */ + void BasePrivate::addChildObject(Base* object) + { + Q_ASSERT(object); + Q_ASSERT(!mChildren.contains(object)); + mChildren.append(object); + } + + /** + * @internal + * @brief Parent-part of unlinking a child from the parent + * + * @param[in] object The child that is to be removed from the parent + */ + void BasePrivate::removeChildObject(Base* object) + { + Q_ASSERT(mChildren.contains(object)); + mChildren.removeOne(object); + } + + /** + * @internal + * @brief Recursively dump this object into a dumper + * + * All children will be dumped recursively. + * + * @param[in] dumper The dumper to output to + * + */ + void BasePrivate::dumpRecursive(Dumper& dumper) const + { + dumpSelf(dumper); + + dumper.indent(); + foreach(Base* child, mChildren) { + child->mData->dumpRecursive(dumper); + } + dumper.dedent(); + } + + QString BasePrivate::displayName() const + { + return QStringLiteral(""); + } + + /** + * @brief Refresh this object + * + * Refreshes this object and all its children. First calls to refreshSelf() expecting it to + * update this object and send out events. If refreshSelf() returns `false`, this object is + * removed from the tree. In this case all children should already have been removed from the + * tree. + * + * If refreshSelf() returned `true`, preRefreshChildren() is called. It should remove children + * that are no longer part of the tree. After that for each child, refresh() is called + * recursively. Finally, postRefreshChildren() is invoked, which should search for new objects + * and link them into the tree. + * + * If preRefreshChildren() is implemented correctly on all objects, refreshSelf() should + * probably never have to return `false`. + * + */ + void BasePrivate::refresh() + { + if (!refreshSelf()) { + // If refresh self returned false, we are no longer valid and will now destroy + // ourselves. We just terminateObject(). + terminateObject(); + return; + } + + postRefresh(); + preRefreshChildren(); + + foreach(Base* child, mChildren) { + child->mData->refresh(); + } + + postRefreshChildren(); + + if (refreshCheckDispensable()) { + terminateObject(); + } + } + + void BasePrivate::postRefresh() + { + } + + /** + * @brief Check if this object is dispensable + * + * @return @c true to dispense this object + * + * During the refresh cycle, this is the last method called for each object. If it returns + * @c true, the object will be terminated. + * + * This can be used for container objects that shall actually get dispensed once they have no + * more children (i.e. RefTreeNode). + * + */ + bool BasePrivate::refreshCheckDispensable() + { + return false; + } + + /** + * @brief First step in refreshing the children + * + * This method is called directly after the object refreshed itself (refreshSelf()) but before + * any of its children are refreshed. + * + * It shall be used to figure out which children do no longer exist. + * + * The base implementation simply does nothing. + * + */ + void BasePrivate::preRefreshChildren() + { + } + + /** + * @brief Last step in refreshing the children + * + * This method is called as last step in the refreshing process. It shall be used to find + * objects and add them to the tree. + * + * The base implementation simply does nothing. + * + */ + void BasePrivate::postRefreshChildren() + { + } + + /** + * @brief Terminates the lifetime of this object + * + * This method MUST be used to destroy an object. Don't just delete an repoman object. + * + * 1. For all children, terminateObject() gets invoked. + * 2. preTerminate() is called, whose objective is to send an event if required. + * 3. the object is unlinkedFromParent() + * 4. finally it deletes itself. Deleting is not defered; the object is gone immediately. + * + */ + void BasePrivate::terminateObject() + { + foreach (Base* child, mChildren) { + child->mData->terminateObject(); + } + + preTerminate(); + unlinkFromParent(); + delete this; + } + + /** + * @brief Are Events blocked for the repository this object belongs to? + * + * @return `true` if any events for this repository shall be suppressed. `false` in normal + * operation. + * + * During the construction of a repository and its initial seeding with objects, no events will + * be send to any listeners. This method must be used to query whether we're currently in that + * phase or not. + * + */ + bool BasePrivate::repoEventsBlocked() + { + Q_ASSERT(mRepo); + return mRepo->isInitializing(); + } + + /** + * @brief Pre-Termination call + * + * This method is called prior to doing the actual object termination. Its objective is to send + * out any required events to listeners, unless this repository is still initializing. + * + * The base implementation will send out a objectAboutToDelete() event. + */ + void BasePrivate::preTerminate() + { + if (!repoEventsBlocked()) { + Events::self()->objectAboutToBeDeleted(repository(), mPub); + } + } + + /** + * @brief Post-Construction call + * + * This method is called just before the last constructor is finished. The call actually will + * come from linkToParent(). + * + * The purpose of this method is to send a creation event. The base implementation will send a + * objectCreated() event. + * + * Note that no events should be sent out, if repoEventsBlocked() returns `true`. + * + */ + void BasePrivate::postCreation() + { + if (!repoEventsBlocked()) { + Events::self()->objectCreated(repository(), mPub); + } + } + + /** + * @brief Find the parent for a Ref. + * + * @param[in] scopes List of scopes to search for or to create. + * + * @param[in] create If `true` and @a path is not empty, a reference tree node will be + * created, if none is found. If `false`, `NULL` will be returned. + * + * @return If @a scopes is empty, `this` is returned. Otherwise findRefTreeNode() is called + * to either find or create a RefTreeNode, which will be returned. + */ + Base* BasePrivate::findRefParent(const QStringList& scopes, bool create) + { + if (scopes.isEmpty()) { + return mPub; + } + return findRefTreeNode(scopes, create); + } + + /** + * @brief Search for or create a ref tree node + * + * Searches for a RefTreeNode for path. + * + * @param[in] scopes List of scopes to search for or to create. Must not be empty. + * + * @param[in] create If `true` and a part of the tree node cannot be found, it will be + * created. If `false`, `NULL` will be returned in that case. + * + * @return If @a create is `true`, a valid RefTreeNode is returned. If @a create is + * `false`, `NULL` will be returned in case the path cannot be found. + */ + RefTreeNode* BasePrivate::findRefTreeNode(const QStringList &scopes, bool create) + { + if (scopes.isEmpty()) { + return NULL; + } + + Base* current = mPub; + + foreach (QString scope, scopes) { + RefTreeNode::List nodes = current->childObjects(); + RefTreeNode* next = NULL; + + foreach(RefTreeNode* child, nodes) { + if (child->name() == scope) { + next = child; + break; + } + } + + if (!next) { + if (create) { + // Note: We don't need to roll this back. Either we go all the way or nowhere. + next = new RefTreeNode(current, scope); + } + else { + return NULL; + } + } + + current = next; + } + + return static_cast< RefTreeNode* >(current); + } + + + CollectionNode* BasePrivate::getOrCreateCollection(CollectionTypes ctype) + { + CollectionNode* cn; + + foreach (cn, mPub->childObjects()) { + if (cn->collectionType() == ctype) { + return cn; + } + } + + return new CollectionNode(ctype, mPub); + } + + Repo* BasePrivate::searchRepository() + { + if (!mRepo) { + if (mParentObj) { + mRepo = mParentObj->repository(); + } + else { + return NULL; + } + } + return mRepo; + } + + Heaven::IconRef BasePrivate::icon(bool small) const + { + QString size = small ? QStringLiteral("@16") : QStringLiteral("@24"); + return Heaven::IconRef::fromString(QChar(L'#') % objectTypeName() % size); + } + + bool BasePrivate::inherits(ObjTypes type) const + { + return false; + } + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Base.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Base.cpp index 24f8ad11..d6848dde 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Base.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Base.cpp @@ -36,27 +36,27 @@ #include "RepoMan/Private/Dumper.hpp" +/** + * @class Base + * @brief Base class for all RepoMan objects + * + * This base class takes care of a unified linking between a parent and its children. Children + * are always created with a pointer to their parent. Children may never be reparented. Only a + * parent is allowed to create children for itself. + * + * Further, the Base class takes care of keeping the strict logic of the refresh process. For + * details on how to implement the refresh logic, see refresh(). + * + * Finally, this base class allows to dump a partial subtree of RepoMan objects into a textual + * hierarchy. See dump() on advanced information. + * + */ + namespace RM { using namespace Internal; - /** - * @class Base - * @brief Base class for all RepoMan objects - * - * This base class takes care of a unified linking between a parent and its children. Children - * are always created with a pointer to their parent. Children may never be reparented. Only a - * parent is allowed to create children for itself. - * - * Further, the Base class takes care of keeping the strict logic of the refresh process. For - * details on how to implement the refresh logic, see refresh(). - * - * Finally, this base class allows to dump a partial subtree of RepoMan objects into a textual - * hierarchy. See dump() on advanced information. - * - */ - /** * @fn bool Base::refreshSelf() * @brief Refresh this object's data and sent events @@ -287,379 +287,4 @@ namespace RM return d->inherits(type); } - //-- BasePrivate ---------------------------------------------------------------------------- >8 - - BasePrivate::BasePrivate(Base* pub) - : mPub(pub) - , mRepo(NULL) - , mParentObj(NULL) - { - Q_ASSERT(mPub); - } - - BasePrivate::~BasePrivate() - { - // THIS _IS_ IMPORTANT - // We forbid by definition that any RM::* object may be destroyed _before_ it is unlinked - // from its parent. Otherwise, events cannot be triggered correctly. - Q_ASSERT(mChildren.count() == 0); - Q_ASSERT(mParentObj == NULL); - Q_ASSERT(mRepo == NULL); - } - - /** - * @brief Child-part of linking into the tree - * - * @param[in] parent The parent to link into - * - * This method is called directly from the constructor. It establishes a relationship with the - * parent object. This relationship can never be altered. - * - */ - void BasePrivate::linkToParent(Base* parent) - { - if (parent) { - mParentObj = parent->mData; - mParentObj->addChildObject(mPub); - mRepo = searchRepository(); - refreshSelf(); - postCreation(); - } - } - - /** - * @internal - * @brief Child-Part of unlinking from the tree - * - * Invokes the parent part on the parent side and then cleans up the reference to the parent. - */ - void BasePrivate::unlinkFromParent() - { - if (mParentObj) { - mParentObj->removeChildObject(mPub); - mParentObj = NULL; - mRepo = NULL; - } - } - - /** - * @internal - * @brief Parent-part of linking a new child - * - * We cannot do any special processing, since the child object is not yet fully constructed. We - * just fill the internal structure. - * - * @param[in] object The new child object that shall be linked in. - */ - void BasePrivate::addChildObject(Base* object) - { - Q_ASSERT(object); - Q_ASSERT(!mChildren.contains(object)); - mChildren.append(object); - } - - /** - * @internal - * @brief Parent-part of unlinking a child from the parent - * - * @param[in] object The child that is to be removed from the parent - */ - void BasePrivate::removeChildObject(Base* object) - { - Q_ASSERT(mChildren.contains(object)); - mChildren.removeOne(object); - } - - /** - * @internal - * @brief Recursively dump this object into a dumper - * - * All children will be dumped recursively. - * - * @param[in] dumper The dumper to output to - * - */ - void BasePrivate::dumpRecursive(Dumper& dumper) const - { - dumpSelf(dumper); - - dumper.indent(); - foreach(Base* child, mChildren) { - child->mData->dumpRecursive(dumper); - } - dumper.dedent(); - } - - QString BasePrivate::displayName() const - { - return QStringLiteral(""); - } - - /** - * @brief Refresh this object - * - * Refreshes this object and all its children. First calls to refreshSelf() expecting it to - * update this object and send out events. If refreshSelf() returns `false`, this object is - * removed from the tree. In this case all children should already have been removed from the - * tree. - * - * If refreshSelf() returned `true`, preRefreshChildren() is called. It should remove children - * that are no longer part of the tree. After that for each child, refresh() is called - * recursively. Finally, postRefreshChildren() is invoked, which should search for new objects - * and link them into the tree. - * - * If preRefreshChildren() is implemented correctly on all objects, refreshSelf() should - * probably never have to return `false`. - * - */ - void BasePrivate::refresh() - { - if (!refreshSelf()) { - // If refresh self returned false, we are no longer valid and will now destroy - // ourselves. We just terminateObject(). - terminateObject(); - return; - } - - postRefresh(); - preRefreshChildren(); - - foreach(Base* child, mChildren) { - child->mData->refresh(); - } - - postRefreshChildren(); - - if (refreshCheckDispensable()) { - terminateObject(); - } - } - - void BasePrivate::postRefresh() - { - } - - /** - * @brief Check if this object is dispensable - * - * @return @c true to dispense this object - * - * During the refresh cycle, this is the last method called for each object. If it returns - * @c true, the object will be terminated. - * - * This can be used for container objects that shall actually get dispensed once they have no - * more children (i.e. RefTreeNode). - * - */ - bool BasePrivate::refreshCheckDispensable() - { - return false; - } - - /** - * @brief First step in refreshing the children - * - * This method is called directly after the object refreshed itself (refreshSelf()) but before - * any of its children are refreshed. - * - * It shall be used to figure out which children do no longer exist. - * - * The base implementation simply does nothing. - * - */ - void BasePrivate::preRefreshChildren() - { - } - - /** - * @brief Last step in refreshing the children - * - * This method is called as last step in the refreshing process. It shall be used to find - * objects and add them to the tree. - * - * The base implementation simply does nothing. - * - */ - void BasePrivate::postRefreshChildren() - { - } - - /** - * @brief Terminates the lifetime of this object - * - * This method MUST be used to destroy an object. Don't just delete an repoman object. - * - * 1. For all children, terminateObject() gets invoked. - * 2. preTerminate() is called, whose objective is to send an event if required. - * 3. the object is unlinkedFromParent() - * 4. finally it deletes itself. Deleting is not defered; the object is gone immediately. - * - */ - void BasePrivate::terminateObject() - { - foreach (Base* child, mChildren) { - child->mData->terminateObject(); - } - - preTerminate(); - unlinkFromParent(); - delete this; - } - - /** - * @brief Are Events blocked for the repository this object belongs to? - * - * @return `true` if any events for this repository shall be suppressed. `false` in normal - * operation. - * - * During the construction of a repository and its initial seeding with objects, no events will - * be send to any listeners. This method must be used to query whether we're currently in that - * phase or not. - * - */ - bool BasePrivate::repoEventsBlocked() - { - Q_ASSERT(mRepo); - return mRepo->isInitializing(); - } - - /** - * @brief Pre-Termination call - * - * This method is called prior to doing the actual object termination. Its objective is to send - * out any required events to listeners, unless this repository is still initializing. - * - * The base implementation will send out a objectAboutToDelete() event. - */ - void BasePrivate::preTerminate() - { - if (!repoEventsBlocked()) { - Events::self()->objectAboutToBeDeleted(repository(), mPub); - } - } - - /** - * @brief Post-Construction call - * - * This method is called just before the last constructor is finished. The call actually will - * come from linkToParent(). - * - * The purpose of this method is to send a creation event. The base implementation will send a - * objectCreated() event. - * - * Note that no events should be sent out, if repoEventsBlocked() returns `true`. - * - */ - void BasePrivate::postCreation() - { - if (!repoEventsBlocked()) { - Events::self()->objectCreated(repository(), mPub); - } - } - - /** - * @brief Find the parent for a Ref. - * - * @param[in] scopes List of scopes to search for or to create. - * - * @param[in] create If `true` and @a path is not empty, a reference tree node will be - * created, if none is found. If `false`, `NULL` will be returned. - * - * @return If @a scopes is empty, `this` is returned. Otherwise findRefTreeNode() is called - * to either find or create a RefTreeNode, which will be returned. - */ - Base* BasePrivate::findRefParent(const QStringList& scopes, bool create) - { - if (scopes.isEmpty()) { - return mPub; - } - return findRefTreeNode(scopes, create); - } - - /** - * @brief Search for or create a ref tree node - * - * Searches for a RefTreeNode for path. - * - * @param[in] scopes List of scopes to search for or to create. Must not be empty. - * - * @param[in] create If `true` and a part of the tree node cannot be found, it will be - * created. If `false`, `NULL` will be returned in that case. - * - * @return If @a create is `true`, a valid RefTreeNode is returned. If @a create is - * `false`, `NULL` will be returned in case the path cannot be found. - */ - RefTreeNode* BasePrivate::findRefTreeNode(const QStringList &scopes, bool create) - { - if (scopes.isEmpty()) { - return NULL; - } - - Base* current = mPub; - - foreach (QString scope, scopes) { - RefTreeNode::List nodes = current->childObjects(); - RefTreeNode* next = NULL; - - foreach(RefTreeNode* child, nodes) { - if (child->name() == scope) { - next = child; - break; - } - } - - if (!next) { - if (create) { - // Note: We don't need to roll this back. Either we go all the way or nowhere. - next = new RefTreeNode(current, scope); - } - else { - return NULL; - } - } - - current = next; - } - - return static_cast< RefTreeNode* >(current); - } - - - CollectionNode* BasePrivate::getOrCreateCollection(CollectionTypes ctype) - { - CollectionNode* cn; - - foreach (cn, mPub->childObjects()) { - if (cn->collectionType() == ctype) { - return cn; - } - } - - return new CollectionNode(ctype, mPub); - } - - Repo* BasePrivate::searchRepository() - { - if (!mRepo) { - if (mParentObj) { - mRepo = mParentObj->repository(); - } - else { - return NULL; - } - } - return mRepo; - } - - Heaven::IconRef BasePrivate::icon(bool small) const - { - QString size = small ? QStringLiteral("@16") : QStringLiteral("@24"); - return Heaven::IconRef::fromString(QChar(L'#') % objectTypeName() % size); - } - - bool BasePrivate::inherits(ObjTypes type) const - { - return false; - } - } From fa24fc07319bead0906d10d2f222a26ed9dad44f Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Tue, 12 May 2015 07:23:59 +0100 Subject: [PATCH 14/75] Be explicit about namespace of Dumper class When we'll move most of Internal to Data, the Dumper class resides where it is. So this'll make things easier later on --- Libs/libMacGitverCore/RepoMan/Data/BaseData.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Data/BranchData.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Data/HeadData.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Data/NamespaceData.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Data/RefData.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Data/RefLogData.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Data/RefTreeNodeData.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Data/RemoteData.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Data/RepoData.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Data/RepoManData.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Data/SubmoduleData.hpp | 2 +- Libs/libMacGitverCore/RepoMan/Data/TagData.hpp | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Libs/libMacGitverCore/RepoMan/Data/BaseData.hpp b/Libs/libMacGitverCore/RepoMan/Data/BaseData.hpp index 962958f1..eb01ad73 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/BaseData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/BaseData.hpp @@ -117,7 +117,7 @@ namespace RM virtual bool refreshCheckDispensable(); virtual bool inherits(ObjTypes type) const; virtual ObjTypes objType() const = 0; - virtual void dumpSelf(Dumper& dumper) const = 0; + virtual void dumpSelf(Internal::Dumper& dumper) const = 0; }; inline Repo* BasePrivate::repository() diff --git a/Libs/libMacGitverCore/RepoMan/Data/BranchData.hpp b/Libs/libMacGitverCore/RepoMan/Data/BranchData.hpp index ae677d80..97dda34e 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/BranchData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/BranchData.hpp @@ -40,7 +40,7 @@ namespace RM void preTerminate(); bool refreshDetails(const Git::Reference& ref); void emitMoved(); - void dumpSelf(Dumper& dumper) const; + void dumpSelf(Internal::Dumper& dumper) const; QString objectTypeName() const; bool inherits(ObjTypes type) const; diff --git a/Libs/libMacGitverCore/RepoMan/Data/HeadData.hpp b/Libs/libMacGitverCore/RepoMan/Data/HeadData.hpp index 6845675a..92f09ddb 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/HeadData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/HeadData.hpp @@ -38,7 +38,7 @@ namespace RM ObjTypes objType() const; bool refreshSelf(); QString displayName() const; - void dumpSelf(Dumper& dumper) const; + void dumpSelf(Internal::Dumper& dumper) const; QString objectTypeName() const; bool inherits(ObjTypes type) const; diff --git a/Libs/libMacGitverCore/RepoMan/Data/NamespaceData.hpp b/Libs/libMacGitverCore/RepoMan/Data/NamespaceData.hpp index 607612fc..d7b77fb2 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/NamespaceData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/NamespaceData.hpp @@ -40,7 +40,7 @@ namespace RM void postCreation(); void preTerminate(); QString displayName() const; - void dumpSelf(Dumper& dumper) const; + void dumpSelf(Internal::Dumper& dumper) const; QString objectTypeName() const; bool inherits(ObjTypes type) const; diff --git a/Libs/libMacGitverCore/RepoMan/Data/RefData.hpp b/Libs/libMacGitverCore/RepoMan/Data/RefData.hpp index 1a67eb16..62afb6b0 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/RefData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/RefData.hpp @@ -42,7 +42,7 @@ namespace RM void preTerminate(); virtual bool refreshDetails(const Git::Reference& ref); virtual void emitMoved(); - void dumpSelf(Dumper& dumper) const; + void dumpSelf(Internal::Dumper& dumper) const; QString objectTypeName() const; bool inherits(ObjTypes type) const; diff --git a/Libs/libMacGitverCore/RepoMan/Data/RefLogData.hpp b/Libs/libMacGitverCore/RepoMan/Data/RefLogData.hpp index ac51e052..7724c619 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/RefLogData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/RefLogData.hpp @@ -39,7 +39,7 @@ namespace RM bool refreshSelf(); void postCreation(); void preTerminate(); - void dumpSelf(Dumper& dumper) const; + void dumpSelf(Internal::Dumper& dumper) const; QString objectTypeName() const; bool inherits(ObjTypes type) const; }; diff --git a/Libs/libMacGitverCore/RepoMan/Data/RefTreeNodeData.hpp b/Libs/libMacGitverCore/RepoMan/Data/RefTreeNodeData.hpp index 65283eba..d4eef6bd 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/RefTreeNodeData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/RefTreeNodeData.hpp @@ -41,7 +41,7 @@ namespace RM void preTerminate(); bool refreshCheckDispensable(); QString displayName() const; - void dumpSelf(Dumper& dumper) const; + void dumpSelf(Internal::Dumper& dumper) const; QString objectTypeName() const; bool inherits(ObjTypes type) const; diff --git a/Libs/libMacGitverCore/RepoMan/Data/RemoteData.hpp b/Libs/libMacGitverCore/RepoMan/Data/RemoteData.hpp index a50bcd00..54c55b17 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/RemoteData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/RemoteData.hpp @@ -42,7 +42,7 @@ namespace RM void postCreation(); void preTerminate(); QString displayName() const; - void dumpSelf(Dumper& dumper) const; + void dumpSelf(Internal::Dumper& dumper) const; QString objectTypeName() const; bool inherits(ObjTypes type) const; diff --git a/Libs/libMacGitverCore/RepoMan/Data/RepoData.hpp b/Libs/libMacGitverCore/RepoMan/Data/RepoData.hpp index f1f28a6c..9fb42eeb 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/RepoData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/RepoData.hpp @@ -43,7 +43,7 @@ namespace RM void preTerminate(); void postRefreshChildren(); QString displayName() const; - void dumpSelf(Dumper& dumper) const; + void dumpSelf(Internal::Dumper& dumper) const; QString objectTypeName() const; bool inherits(ObjTypes type) const; Repo* searchRepository(); diff --git a/Libs/libMacGitverCore/RepoMan/Data/RepoManData.hpp b/Libs/libMacGitverCore/RepoMan/Data/RepoManData.hpp index 1561edb7..5c637c27 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/RepoManData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/RepoManData.hpp @@ -43,7 +43,7 @@ namespace RM bool refreshSelf(); void preTerminate(); QString displayName() const; - void dumpSelf(Dumper& dumper) const; + void dumpSelf(Internal::Dumper& dumper) const; QString objectTypeName() const; Heaven::Menu* contextMenuFor(Base* object); diff --git a/Libs/libMacGitverCore/RepoMan/Data/SubmoduleData.hpp b/Libs/libMacGitverCore/RepoMan/Data/SubmoduleData.hpp index 40937119..2f454210 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/SubmoduleData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/SubmoduleData.hpp @@ -38,7 +38,7 @@ namespace RM ObjTypes objType() const; void postCreation(); void preTerminate(); - void dumpSelf(Dumper& dumper) const; + void dumpSelf(Internal::Dumper& dumper) const; QString objectTypeName() const; bool inherits(ObjTypes type) const; }; diff --git a/Libs/libMacGitverCore/RepoMan/Data/TagData.hpp b/Libs/libMacGitverCore/RepoMan/Data/TagData.hpp index c371206e..8bb62db9 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/TagData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/TagData.hpp @@ -38,7 +38,7 @@ namespace RM ObjTypes objType() const; void postCreation(); void preTerminate(); - void dumpSelf(Dumper& dumper) const; + void dumpSelf(Internal::Dumper& dumper) const; QString objectTypeName() const; bool inherits(ObjTypes type) const; }; From eff4d8d1b1ec3523ea33820adc1e4cf626601297 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Tue, 12 May 2015 07:25:13 +0100 Subject: [PATCH 15/75] Move Branch & Head Private's to own cpp --- Libs/libMacGitverCore/CMakeLists.txt | 2 + Libs/libMacGitverCore/RepoMan/Data/Branch.cpp | 95 ++++++++++++++++ Libs/libMacGitverCore/RepoMan/Data/Head.cpp | 102 ++++++++++++++++++ .../RepoMan/Frontend/Branch.cpp | 64 ----------- .../RepoMan/Frontend/Head.cpp | 76 +------------ 5 files changed, 201 insertions(+), 138 deletions(-) create mode 100644 Libs/libMacGitverCore/RepoMan/Data/Branch.cpp create mode 100644 Libs/libMacGitverCore/RepoMan/Data/Head.cpp diff --git a/Libs/libMacGitverCore/CMakeLists.txt b/Libs/libMacGitverCore/CMakeLists.txt index 8a2066bf..9d17f912 100644 --- a/Libs/libMacGitverCore/CMakeLists.txt +++ b/Libs/libMacGitverCore/CMakeLists.txt @@ -44,6 +44,8 @@ SET( SRC_FILES RepoMan/Frontend/Head.cpp RepoMan/Data/Base.cpp + RepoMan/Data/Branch.cpp + RepoMan/Data/Head.cpp RepoMan/Private/Dumper.cpp diff --git a/Libs/libMacGitverCore/RepoMan/Data/Branch.cpp b/Libs/libMacGitverCore/RepoMan/Data/Branch.cpp new file mode 100644 index 00000000..3b59faac --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Data/Branch.cpp @@ -0,0 +1,95 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "RepoMan/Data/BranchData.hpp" +#include "RepoMan/Events.hpp" + +#include "RepoMan/Private/Dumper.hpp" + +namespace RM +{ + + namespace Internal + { + + BranchPrivate::BranchPrivate(Branch* pub, const Git::Reference& ref) + : RefPrivate(pub, BranchType, ref) + , mHasUpstream(false) + , mAheadCount(0) + , mBehindCount(0) + { + } + + ObjTypes BranchPrivate::objType() const + { + return ObjTypes::Branch; + } + + void BranchPrivate::postCreation() + { + if (!repoEventsBlocked()) { + Events::self()->branchCreated(repository(), pub()); + } + + RefPrivate::postCreation(); + } + + void BranchPrivate::preTerminate() + { + if (!repoEventsBlocked()) { + Events::self()->branchAboutToBeDeleted(repository(), pub()); + } + + RefPrivate::preTerminate(); + } + + void BranchPrivate::dumpSelf(Internal::Dumper& dumper) const + { + dumper.addLine(QString(QStringLiteral("Branch 0x%1 - %2")) + .arg(quintptr(mPub),0,16) + .arg(mName)); + } + + QString BranchPrivate::objectTypeName() const + { + return QStringLiteral("Branch"); + } + + void BranchPrivate::emitMoved() + { + if (!repoEventsBlocked()) { + Events::self()->refMoved(mRepo, pub()); + Events::self()->branchMoved(mRepo, pub()); + } + } + + bool BranchPrivate::refreshDetails(const Git::Reference& ref) + { + + return RefPrivate::refreshDetails(ref); + } + + bool BranchPrivate::inherits(ObjTypes type) const + { + return type == ObjTypes::Branch || RefPrivate::inherits(type); + } + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Data/Head.cpp b/Libs/libMacGitverCore/RepoMan/Data/Head.cpp new file mode 100644 index 00000000..fa1a354b --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Data/Head.cpp @@ -0,0 +1,102 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "RepoMan/Events.hpp" + +#include "RepoMan/Head.hpp" + +#include "RepoMan/Private/Dumper.hpp" + +#include "RepoMan/Data/HeadData.hpp" + +#include "RepoMan/Branch.hpp" +#include "RepoMan/Repo.hpp" + +#include "libGitWrap/Repository.hpp" +#include "libGitWrap/BranchRef.hpp" + +namespace RM +{ + + namespace Internal + { + + HeadPrivate::HeadPrivate(Head* _pub, const Git::Repository& repo) + : BasePrivate(_pub) + , symbolicName() + , isDetached(repo.isHeadDetached()) + , isUnborn(repo.isHeadUnborn()) + { + Git::Result r; + + if (isDetached) { + detachedId = repo.HEAD(r).objectId(); + } + else { + symbolicName = repo.headBranchName(r); + } + } + + ObjTypes HeadPrivate::objType() const + { + return ObjTypes::Head; + } + + void HeadPrivate::dumpSelf(Internal::Dumper& dumper) const + { + dumper.addLine(QString(QStringLiteral("Head 0x%1 - %2")) + .arg(quintptr(mPub),0,16) + .arg(symbolicName)); + } + + bool HeadPrivate::refreshSelf() + { + Git::Repository repo = repository()->gitLoadedRepo(); + Git::Result r; + + isUnborn = repo.isHeadUnborn(); + isDetached = repo.isHeadDetached(); + + if (isDetached) { + detachedId = repo.HEAD(r).objectId(); + } + else { + symbolicName = repo.headBranchName(r); + } + return true; + } + + QString HeadPrivate::displayName() const + { + return symbolicName; + } + + QString HeadPrivate::objectTypeName() const + { + return QStringLiteral("Head"); + } + + bool HeadPrivate::inherits(ObjTypes type) const + { + return type == ObjTypes::Head || BasePrivate::inherits(type); + } + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp index 02a3909a..2da6af24 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp @@ -74,68 +74,4 @@ namespace RM return h && h->is(this); } - //-- BranchPrivate ----------------------------------------------------------------------------- - - BranchPrivate::BranchPrivate(Branch* pub, const Git::Reference& ref) - : RefPrivate(pub, BranchType, ref) - , mHasUpstream(false) - , mAheadCount(0) - , mBehindCount(0) - { - } - - ObjTypes BranchPrivate::objType() const - { - return ObjTypes::Branch; - } - - void BranchPrivate::postCreation() - { - if (!repoEventsBlocked()) { - Events::self()->branchCreated(repository(), pub()); - } - - RefPrivate::postCreation(); - } - - void BranchPrivate::preTerminate() - { - if (!repoEventsBlocked()) { - Events::self()->branchAboutToBeDeleted(repository(), pub()); - } - - RefPrivate::preTerminate(); - } - - void BranchPrivate::dumpSelf(Internal::Dumper& dumper) const - { - dumper.addLine(QString(QStringLiteral("Branch 0x%1 - %2")) - .arg(quintptr(mPub),0,16) - .arg(mName)); - } - - QString BranchPrivate::objectTypeName() const - { - return QStringLiteral("Branch"); - } - - void BranchPrivate::emitMoved() - { - if (!repoEventsBlocked()) { - Events::self()->refMoved(mRepo, pub()); - Events::self()->branchMoved(mRepo, pub()); - } - } - - bool BranchPrivate::refreshDetails(const Git::Reference& ref) - { - - return RefPrivate::refreshDetails(ref); - } - - bool BranchPrivate::inherits(ObjTypes type) const - { - return type == ObjTypes::Branch || RefPrivate::inherits(type); - } - } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp index b956460b..baeaef74 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp @@ -21,90 +21,18 @@ #include "RepoMan/Head.hpp" -#include "RepoMan/Private/Dumper.hpp" - #include "RepoMan/Data/HeadData.hpp" #include "RepoMan/Branch.hpp" #include "RepoMan/Repo.hpp" #include "libGitWrap/Repository.hpp" -#include "libGitWrap/BranchRef.hpp" namespace RM { - namespace Internal - { - - // -- HeadPrivate ----------------------------------------------------------------------- >8 - - HeadPrivate::HeadPrivate(Head* _pub, const Git::Repository& repo) - : BasePrivate(_pub) - , symbolicName() - , isDetached(repo.isHeadDetached()) - , isUnborn(repo.isHeadUnborn()) - { - Git::Result r; - - if (isDetached) { - detachedId = repo.HEAD(r).objectId(); - } - else { - symbolicName = repo.headBranchName(r); - } - } - - ObjTypes HeadPrivate::objType() const - { - return ObjTypes::Head; - } - - void HeadPrivate::dumpSelf(Internal::Dumper& dumper) const - { - dumper.addLine(QString(QStringLiteral("Head 0x%1 - %2")) - .arg(quintptr(mPub),0,16) - .arg(symbolicName)); - } - - bool HeadPrivate::refreshSelf() - { - Git::Repository repo = repository()->gitLoadedRepo(); - Git::Result r; - - isUnborn = repo.isHeadUnborn(); - isDetached = repo.isHeadDetached(); - - if (isDetached) { - detachedId = repo.HEAD(r).objectId(); - } - else { - symbolicName = repo.headBranchName(r); - } - return true; - } - - QString HeadPrivate::displayName() const - { - return symbolicName; - } - - QString HeadPrivate::objectTypeName() const - { - return QStringLiteral("Head"); - } - - bool HeadPrivate::inherits(ObjTypes type) const - { - return type == ObjTypes::Head || BasePrivate::inherits(type); - } - - } - - // -- Head ---------------------------------------------------------------------------------- >8 - - Head::Head(const Git::Repository& ref, Base* parent) - : Base(*new Internal::HeadPrivate(this, ref)) + Head::Head(const Git::Repository& repo, Base* parent) + : Base(*new Internal::HeadPrivate(this, repo)) { RM_D(Head); d->linkToParent(parent); From b1022f39b1033908a690f2da3993841ba358f849 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Tue, 21 Apr 2015 23:55:59 +0100 Subject: [PATCH 16/75] Temporary code --- Libs/libMacGitverCore/CMakeLists.txt | 68 +- .../RepoMan/Backend/RepoLocker.hpp | 57 + .../RepoMan/Backend/RepoMan.cpp | 59 + .../RepoMan/Backend/RepoMan.hpp | 55 + Libs/libMacGitverCore/RepoMan/Base.hpp | 130 -- Libs/libMacGitverCore/RepoMan/Branch.hpp | 45 - .../RepoMan/CollectionNode.hpp | 51 - Libs/libMacGitverCore/RepoMan/Core.hpp | 19 +- Libs/libMacGitverCore/RepoMan/Data/Base.cpp | 177 +-- Libs/libMacGitverCore/RepoMan/Data/Base.hpp | 142 +++ .../RepoMan/Data/BaseData.hpp | 130 -- Libs/libMacGitverCore/RepoMan/Data/Branch.cpp | 34 +- .../Data/{BranchData.hpp => Branch.hpp} | 13 +- Libs/libMacGitverCore/RepoMan/Data/Head.cpp | 31 +- Libs/libMacGitverCore/RepoMan/Data/Head.hpp | 84 ++ .../RepoMan/Data/Namespace.cpp | 0 .../RepoMan/Data/Namespace.hpp | 57 + Libs/libMacGitverCore/RepoMan/Data/RefLog.cpp | 0 .../Data/{NamespaceData.hpp => RefLog.hpp} | 18 +- .../RepoMan/Data/RefTreeNode.cpp | 0 .../{RefTreeNodeData.hpp => RefTreeNode.hpp} | 14 +- .../RepoMan/Data/Reference.cpp | 0 .../Data/{RefData.hpp => Reference.hpp} | 17 +- Libs/libMacGitverCore/RepoMan/Data/Remote.cpp | 0 .../Data/{RemoteData.hpp => Remote.hpp} | 18 +- Libs/libMacGitverCore/RepoMan/Data/Repo.cpp | 69 ++ .../RepoMan/Data/{RepoData.hpp => Repo.hpp} | 74 +- .../Data/{RepoManData.hpp => RepoMan.hpp} | 20 +- .../RepoMan/Data/Submodule.cpp | 0 .../Data/{RefLogData.hpp => Submodule.hpp} | 15 +- Libs/libMacGitverCore/RepoMan/Data/Tag.cpp | 0 .../Data/{SubmoduleData.hpp => Tag.hpp} | 14 +- Libs/libMacGitverCore/RepoMan/Events.cpp | 66 +- Libs/libMacGitverCore/RepoMan/Events.hpp | 161 +-- .../RepoMan/Frontend/Base.cpp | 400 +++--- .../RepoMan/Frontend/Base.hpp | 110 ++ .../RepoMan/Frontend/BaseInternal.hpp | 121 ++ .../RepoMan/Frontend/Branch.cpp | 85 +- .../RepoMan/Frontend/Branch.hpp | 50 + .../RepoMan/Frontend/CollectionNode.cpp | 127 -- .../RepoMan/Frontend/Head.cpp | 84 +- .../RepoMan/Frontend/Head.hpp | 56 + .../RepoMan/Frontend/Namespace.cpp | 74 +- .../HeadData.hpp => Frontend/Namespace.hpp} | 38 +- .../RepoMan/Frontend/RefLog.cpp | 96 +- .../RepoMan/{ => Frontend}/RefLog.hpp | 26 +- .../RepoMan/Frontend/RefTreeNode.cpp | 129 +- .../RepoMan/{ => Frontend}/RefTreeNode.hpp | 30 +- .../Frontend/{Ref.cpp => Reference.cpp} | 137 ++- .../RepoMan/Frontend/Reference.hpp | 82 ++ .../RepoMan/Frontend/Remote.cpp | 147 +-- .../Remote.hpp} | 34 +- .../RepoMan/Frontend/Repo.cpp | 1070 ++++++++--------- .../RepoMan/Frontend/Repo.hpp | 116 ++ .../RepoMan/Frontend/Submodule.cpp | 97 +- .../TagData.hpp => Frontend/Submodule.hpp} | 18 +- .../libMacGitverCore/RepoMan/Frontend/Tag.cpp | 93 +- .../libMacGitverCore/RepoMan/Frontend/Tag.hpp | 51 + Libs/libMacGitverCore/RepoMan/Head.hpp | 54 - Libs/libMacGitverCore/RepoMan/Namespace.hpp | 53 - Libs/libMacGitverCore/RepoMan/Ref.hpp | 64 - Libs/libMacGitverCore/RepoMan/Remote.hpp | 51 - Libs/libMacGitverCore/RepoMan/Repo.hpp | 101 -- Libs/libMacGitverCore/RepoMan/RepoMan.cpp | 68 +- Libs/libMacGitverCore/RepoMan/RepoMan.hpp | 94 +- Libs/libMacGitverCore/RepoMan/Submodule.hpp | 45 - Libs/libMacGitverCore/RepoMan/Tag.hpp | 46 - .../Widgets/RepoStateWidget.cpp | 32 +- .../Widgets/RepoStateWidget.hpp | 22 +- 69 files changed, 2861 insertions(+), 2678 deletions(-) create mode 100644 Libs/libMacGitverCore/RepoMan/Backend/RepoLocker.hpp create mode 100644 Libs/libMacGitverCore/RepoMan/Backend/RepoMan.cpp create mode 100644 Libs/libMacGitverCore/RepoMan/Backend/RepoMan.hpp delete mode 100644 Libs/libMacGitverCore/RepoMan/Base.hpp delete mode 100644 Libs/libMacGitverCore/RepoMan/Branch.hpp delete mode 100644 Libs/libMacGitverCore/RepoMan/CollectionNode.hpp create mode 100644 Libs/libMacGitverCore/RepoMan/Data/Base.hpp delete mode 100644 Libs/libMacGitverCore/RepoMan/Data/BaseData.hpp rename Libs/libMacGitverCore/RepoMan/Data/{BranchData.hpp => Branch.hpp} (80%) create mode 100644 Libs/libMacGitverCore/RepoMan/Data/Head.hpp create mode 100644 Libs/libMacGitverCore/RepoMan/Data/Namespace.cpp create mode 100644 Libs/libMacGitverCore/RepoMan/Data/Namespace.hpp create mode 100644 Libs/libMacGitverCore/RepoMan/Data/RefLog.cpp rename Libs/libMacGitverCore/RepoMan/Data/{NamespaceData.hpp => RefLog.hpp} (80%) create mode 100644 Libs/libMacGitverCore/RepoMan/Data/RefTreeNode.cpp rename Libs/libMacGitverCore/RepoMan/Data/{RefTreeNodeData.hpp => RefTreeNode.hpp} (79%) create mode 100644 Libs/libMacGitverCore/RepoMan/Data/Reference.cpp rename Libs/libMacGitverCore/RepoMan/Data/{RefData.hpp => Reference.hpp} (78%) create mode 100644 Libs/libMacGitverCore/RepoMan/Data/Remote.cpp rename Libs/libMacGitverCore/RepoMan/Data/{RemoteData.hpp => Remote.hpp} (79%) create mode 100644 Libs/libMacGitverCore/RepoMan/Data/Repo.cpp rename Libs/libMacGitverCore/RepoMan/Data/{RepoData.hpp => Repo.hpp} (60%) rename Libs/libMacGitverCore/RepoMan/Data/{RepoManData.hpp => RepoMan.hpp} (70%) create mode 100644 Libs/libMacGitverCore/RepoMan/Data/Submodule.cpp rename Libs/libMacGitverCore/RepoMan/Data/{RefLogData.hpp => Submodule.hpp} (77%) create mode 100644 Libs/libMacGitverCore/RepoMan/Data/Tag.cpp rename Libs/libMacGitverCore/RepoMan/Data/{SubmoduleData.hpp => Tag.hpp} (78%) create mode 100644 Libs/libMacGitverCore/RepoMan/Frontend/Base.hpp create mode 100644 Libs/libMacGitverCore/RepoMan/Frontend/BaseInternal.hpp create mode 100644 Libs/libMacGitverCore/RepoMan/Frontend/Branch.hpp delete mode 100644 Libs/libMacGitverCore/RepoMan/Frontend/CollectionNode.cpp create mode 100644 Libs/libMacGitverCore/RepoMan/Frontend/Head.hpp rename Libs/libMacGitverCore/RepoMan/{Data/HeadData.hpp => Frontend/Namespace.hpp} (56%) rename Libs/libMacGitverCore/RepoMan/{ => Frontend}/RefLog.hpp (66%) rename Libs/libMacGitverCore/RepoMan/{ => Frontend}/RefTreeNode.hpp (63%) rename Libs/libMacGitverCore/RepoMan/Frontend/{Ref.cpp => Reference.cpp} (55%) create mode 100644 Libs/libMacGitverCore/RepoMan/Frontend/Reference.hpp rename Libs/libMacGitverCore/RepoMan/{Data/CollectionNodeData.hpp => Frontend/Remote.hpp} (57%) create mode 100644 Libs/libMacGitverCore/RepoMan/Frontend/Repo.hpp rename Libs/libMacGitverCore/RepoMan/{Data/TagData.hpp => Frontend/Submodule.hpp} (75%) create mode 100644 Libs/libMacGitverCore/RepoMan/Frontend/Tag.hpp delete mode 100644 Libs/libMacGitverCore/RepoMan/Head.hpp delete mode 100644 Libs/libMacGitverCore/RepoMan/Namespace.hpp delete mode 100644 Libs/libMacGitverCore/RepoMan/Ref.hpp delete mode 100644 Libs/libMacGitverCore/RepoMan/Remote.hpp delete mode 100644 Libs/libMacGitverCore/RepoMan/Repo.hpp delete mode 100644 Libs/libMacGitverCore/RepoMan/Submodule.hpp delete mode 100644 Libs/libMacGitverCore/RepoMan/Tag.hpp diff --git a/Libs/libMacGitverCore/CMakeLists.txt b/Libs/libMacGitverCore/CMakeLists.txt index 9d17f912..01c0bb4f 100644 --- a/Libs/libMacGitverCore/CMakeLists.txt +++ b/Libs/libMacGitverCore/CMakeLists.txt @@ -32,9 +32,8 @@ SET( SRC_FILES RepoMan/Frontend/Base.cpp RepoMan/Frontend/Branch.cpp - RepoMan/Frontend/CollectionNode.cpp RepoMan/Frontend/Namespace.cpp - RepoMan/Frontend/Ref.cpp + RepoMan/Frontend/Reference.cpp RepoMan/Frontend/RefLog.cpp RepoMan/Frontend/RefTreeNode.cpp RepoMan/Frontend/Remote.cpp @@ -46,9 +45,19 @@ SET( SRC_FILES RepoMan/Data/Base.cpp RepoMan/Data/Branch.cpp RepoMan/Data/Head.cpp + RepoMan/Data/Namespace.cpp + RepoMan/Data/Reference.cpp + RepoMan/Data/RefLog.cpp + RepoMan/Data/RefTreeNode.cpp + RepoMan/Data/Remote.cpp + RepoMan/Data/Repo.cpp + RepoMan/Data/Submodule.cpp + RepoMan/Data/Tag.cpp RepoMan/Private/Dumper.cpp + RepoMan/Backend/RepoMan.cpp + SHMParser/ShellExpand.cpp Widgets/ExpandableDlg.cpp @@ -82,20 +91,20 @@ SET( PUB_HDR_FILES MacGitver/IRepositoryContext.hpp RepoMan/Core.hpp - RepoMan/Base.hpp RepoMan/Events.hpp - RepoMan/CollectionNode.hpp - RepoMan/Ref.hpp - RepoMan/Repo.hpp RepoMan/RepoMan.hpp - RepoMan/Remote.hpp - RepoMan/Tag.hpp - RepoMan/Branch.hpp - RepoMan/RefLog.hpp - RepoMan/Submodule.hpp - RepoMan/RefTreeNode.hpp - RepoMan/Namespace.hpp - RepoMan/Head.hpp + + RepoMan/Frontend/Base.hpp + RepoMan/Frontend/Reference.hpp + RepoMan/Frontend/Repo.hpp + RepoMan/Frontend/Remote.hpp + RepoMan/Frontend/Tag.hpp + RepoMan/Frontend/Branch.hpp + RepoMan/Frontend/RefLog.hpp + RepoMan/Frontend/Submodule.hpp + RepoMan/Frontend/RefTreeNode.hpp + RepoMan/Frontend/Namespace.hpp + RepoMan/Frontend/Head.hpp SHMParser/ShellExpand.hpp @@ -125,20 +134,23 @@ SET( PRI_HDR_FILES RepoMan/Private/Dumper.hpp - RepoMan/Data/BaseData.hpp - RepoMan/Data/BranchData.hpp - RepoMan/Data/CollectionNodeData.hpp - RepoMan/Data/NamespaceData.hpp - RepoMan/Data/RefData.hpp - RepoMan/Data/RefLogData.hpp - RepoMan/Data/RefTreeNodeData.hpp - RepoMan/Data/RemoteData.hpp - RepoMan/Data/RepoData.hpp - RepoMan/Data/RepoManData.hpp - RepoMan/Data/SubmoduleData.hpp - RepoMan/Data/TagData.hpp - RepoMan/Data/HeadData.hpp - + RepoMan/Data/Base.hpp + RepoMan/Data/Branch.hpp + RepoMan/Data/Namespace.hpp + RepoMan/Data/Reference.hpp + RepoMan/Data/RefLog.hpp + RepoMan/Data/RefTreeNode.hpp + RepoMan/Data/Remote.hpp + RepoMan/Data/Repo.hpp + RepoMan/Data/RepoMan.hpp + RepoMan/Data/Submodule.hpp + RepoMan/Data/Tag.hpp + RepoMan/Data/Head.hpp + + RepoMan/Frontend/BaseInternal.hpp + + RepoMan/Backend/RepoMan.hpp + RepoMan/Backend/RepoLocker.hpp Widgets/StringSelectorWidgetPrivate.h Widgets/FlatTreeModelPrivate.h diff --git a/Libs/libMacGitverCore/RepoMan/Backend/RepoLocker.hpp b/Libs/libMacGitverCore/RepoMan/Backend/RepoLocker.hpp new file mode 100644 index 00000000..86f41a11 --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Backend/RepoLocker.hpp @@ -0,0 +1,57 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "RepoMan/Data/Repo.hpp" + +namespace RM +{ + + namespace Backend + { + + class RepoLocker + { + public: + RepoLocker() = delete; + RepoLocker(const RepoLocker&) = delete; + + inline RepoLocker(const Data::Repo::SPtr& p) + : d(p) + { + if (d) { + d->mutex().lock(); + } + } + + inline ~RepoLocker() + { + if (d) { + d->mutex().unlock(); + } + } + + private: + Data::Repo::SPtr d; + }; + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Backend/RepoMan.cpp b/Libs/libMacGitverCore/RepoMan/Backend/RepoMan.cpp new file mode 100644 index 00000000..a0855451 --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Backend/RepoMan.cpp @@ -0,0 +1,59 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "RepoMan/Backend/RepoMan.hpp" + +#include +#include + +namespace RM +{ + + namespace Backend + { + + static RepoMan* repoMan() + { + static QPointer< RepoMan > sInstance; + if (sInstance.isNull()) { + sInstance = new RepoMan; + } + return sInstance; + } + + RepoMan::RepoMan() + : mWorkerThread(new QThread) + { + moveToThread(mWorkerThread); + mWorkerThread->start(); + } + + RepoMan& RepoMan::instance() + { + return *repoMan(); + } + + QThread* RepoMan::workerThread() + { + return repoMan()->mWorkerThread; + } + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Backend/RepoMan.hpp b/Libs/libMacGitverCore/RepoMan/Backend/RepoMan.hpp new file mode 100644 index 00000000..81e4b5d6 --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Backend/RepoMan.hpp @@ -0,0 +1,55 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "RepoMan/Data/Repo.hpp" + +#include +#include + +namespace RM +{ + + namespace Backend + { + + class RepoMan + : public QObject + { + Q_OBJECT + public: + RepoMan(); + + public: + static RepoMan& instance(); + static QThread* workerThread(); + + public: + Data::Repo::SPtr findRepo(const QString& workTreePath) const; + + private: + QThread* mWorkerThread; + mutable QMutex mRepoMan; + Data::Repo::SList mRepos; + }; + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Base.hpp b/Libs/libMacGitverCore/RepoMan/Base.hpp deleted file mode 100644 index 8bdfd4a9..00000000 --- a/Libs/libMacGitverCore/RepoMan/Base.hpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2015 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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/RepoMan/Core.hpp" - -namespace RM -{ - - enum CollectionTypes - { - ctBranches, - ctNamespaces, - ctNotes, - ctTags - }; - - class Repo; - class RefTreeNode; - class CollectionNode; - class Namespace; - class Ref; - class Remote; - class RefLog; - class Submodule; - class Tag; - - namespace Internal - { - class Dumper; - class BasePrivate; - } - - class MGV_CORE_API Base - { - friend class Repo; - friend class Internal::BasePrivate; - - public: - typedef QVector< Base* > List; - - protected: - Base(Internal::BasePrivate& _d); - virtual ~Base(); - - public: - ObjTypes objType() const; - - public: - void refresh(); - - const Repo* repository() const; - Repo* repository(); - - Base* parentObject() const; - - List childObjects() const; - List childObjects(ObjTypes type) const; - - template< class T > - typename T::List childObjects() const; - - template< class T > - bool isA() const; - - template< class T > - bool inheritsRepoManType() const; - - bool inheritsRepoManType(ObjTypes type) const; - - Heaven::IconRef icon(bool small = false) const; - - QString typeName() const; - QString displayName() const; - QString dump() const; - - Heaven::Menu* contextMenu(); - - protected: - Internal::BasePrivate* mData; - - private: - Base(const Base& other); - Base& operator=(const Base& other); - }; - - template< class T > - inline bool Base::isA() const - { - return objType() == ObjTypes(T::StaticObjectType); - } - - template< class T > - inline bool Base::inheritsRepoManType() const - { - return inheritsRepoManType(ObjTypes(T::StaticObjectType)); - } - - template< class T > - inline typename T::List Base::childObjects() const - { - typename T::List children; - - foreach(Base* child, childObjects()) { - if (child->inheritsRepoManType()) { - children.append(static_cast(child)); - } - } - - return children; - } - -} diff --git a/Libs/libMacGitverCore/RepoMan/Branch.hpp b/Libs/libMacGitverCore/RepoMan/Branch.hpp deleted file mode 100644 index 7452299f..00000000 --- a/Libs/libMacGitverCore/RepoMan/Branch.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2015 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "Ref.hpp" - -namespace RM -{ - - class MGV_CORE_API Branch : public Ref - { - public: - static const ObjTypes StaticObjectType = ObjTypes::Branch; - typedef QVector< Branch* > List; - - public: - Branch(Base* parent, const Git::Reference& ref); - - public: - bool hasUpstream() const; - QString upstreamRefName() const; - Ref* upstream(); - int aheadCount() const; - int behindCount() const; - bool isHead() const; - }; - -} diff --git a/Libs/libMacGitverCore/RepoMan/CollectionNode.hpp b/Libs/libMacGitverCore/RepoMan/CollectionNode.hpp deleted file mode 100644 index 6b30e134..00000000 --- a/Libs/libMacGitverCore/RepoMan/CollectionNode.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2015 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 - -#include "Base.hpp" - -namespace RM -{ - - namespace Internal - { - class CollectionNodePrivate; - } - - class MGV_CORE_API CollectionNode : public Base - { - Q_DECLARE_TR_FUNCTIONS(RM_CollectionNode) - - public: - static const ObjTypes StaticObjectType = ObjTypes::CollectionNode; - typedef Internal::CollectionNodePrivate Private; - typedef QVector< CollectionNode* > List; - - public: - CollectionNode(CollectionTypes _ctype, Base* parent); - - public: - CollectionTypes collectionType() const; - QString collectionTypeName() const; - }; - -} diff --git a/Libs/libMacGitverCore/RepoMan/Core.hpp b/Libs/libMacGitverCore/RepoMan/Core.hpp index b9629814..575d0115 100644 --- a/Libs/libMacGitverCore/RepoMan/Core.hpp +++ b/Libs/libMacGitverCore/RepoMan/Core.hpp @@ -40,23 +40,28 @@ namespace RM { Invalid, - CollectionNode, Namespace, - RepoManager, - - // repositories Repo, Remote, Submodule, Head, - - // references Branch, Reference, RefTreeNode, Tag, - RefLog }; + namespace Frontend + { + class Repo; + class RefTreeNode; + class Namespace; + class Reference; + class Remote; + class RefLog; + class Submodule; + class Tag; + } + } diff --git a/Libs/libMacGitverCore/RepoMan/Data/Base.cpp b/Libs/libMacGitverCore/RepoMan/Data/Base.cpp index a5655074..ebdb735f 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/Base.cpp +++ b/Libs/libMacGitverCore/RepoMan/Data/Base.cpp @@ -17,14 +17,11 @@ * */ -#include "RepoMan/Data/BaseData.hpp" -#include "RepoMan/Data/RefTreeNodeData.hpp" -#include "RepoMan/Data/CollectionNodeData.hpp" +#include "RepoMan/Data/Base.hpp" -#include "RepoMan/Base.hpp" -#include "RepoMan/Repo.hpp" +#include "RepoMan/Frontend/Base.hpp" +#include "RepoMan/Frontend/Repo.hpp" -#include "RepoMan/Events.hpp" #include "RepoMan/Private/Dumper.hpp" #include "libHeavenIcons/IconRef.hpp" @@ -32,88 +29,17 @@ namespace RM { - namespace Internal + namespace Data { - BasePrivate::BasePrivate(Base* pub) - : mPub(pub) - , mRepo(NULL) - , mParentObj(NULL) + Base::Base() + : mRepo() + , mParent() { - Q_ASSERT(mPub); } - BasePrivate::~BasePrivate() + Base::~Base() { - // THIS _IS_ IMPORTANT - // We forbid by definition that any RM::* object may be destroyed _before_ it is unlinked - // from its parent. Otherwise, events cannot be triggered correctly. - Q_ASSERT(mChildren.count() == 0); - Q_ASSERT(mParentObj == NULL); - Q_ASSERT(mRepo == NULL); - } - - /** - * @brief Child-part of linking into the tree - * - * @param[in] parent The parent to link into - * - * This method is called directly from the constructor. It establishes a relationship with the - * parent object. This relationship can never be altered. - * - */ - void BasePrivate::linkToParent(Base* parent) - { - if (parent) { - mParentObj = parent->mData; - mParentObj->addChildObject(mPub); - mRepo = searchRepository(); - refreshSelf(); - postCreation(); - } - } - - /** - * @internal - * @brief Child-Part of unlinking from the tree - * - * Invokes the parent part on the parent side and then cleans up the reference to the parent. - */ - void BasePrivate::unlinkFromParent() - { - if (mParentObj) { - mParentObj->removeChildObject(mPub); - mParentObj = NULL; - mRepo = NULL; - } - } - - /** - * @internal - * @brief Parent-part of linking a new child - * - * We cannot do any special processing, since the child object is not yet fully constructed. We - * just fill the internal structure. - * - * @param[in] object The new child object that shall be linked in. - */ - void BasePrivate::addChildObject(Base* object) - { - Q_ASSERT(object); - Q_ASSERT(!mChildren.contains(object)); - mChildren.append(object); - } - - /** - * @internal - * @brief Parent-part of unlinking a child from the parent - * - * @param[in] object The child that is to be removed from the parent - */ - void BasePrivate::removeChildObject(Base* object) - { - Q_ASSERT(mChildren.contains(object)); - mChildren.removeOne(object); } /** @@ -125,22 +51,27 @@ namespace RM * @param[in] dumper The dumper to output to * */ - void BasePrivate::dumpRecursive(Dumper& dumper) const + void Base::dumpRecursive(Internal::Dumper& dumper) const { dumpSelf(dumper); dumper.indent(); - foreach(Base* child, mChildren) { - child->mData->dumpRecursive(dumper); - } + dumpChildren(dumper); dumper.dedent(); } - QString BasePrivate::displayName() const + void Base::dumpChildren(Internal::Dumper& dumper) const + { + Q_UNUSED(dumper); + /* Nothinng to do for base class */ + } + + QString Base::displayName() const { return QStringLiteral(""); } + #if 0 // ###REPOMAN /** * @brief Refresh this object * @@ -158,7 +89,7 @@ namespace RM * probably never have to return `false`. * */ - void BasePrivate::refresh() + void Base::refresh() { if (!refreshSelf()) { // If refresh self returned false, we are no longer valid and will now destroy @@ -181,7 +112,7 @@ namespace RM } } - void BasePrivate::postRefresh() + void Base::postRefresh() { } @@ -197,7 +128,7 @@ namespace RM * more children (i.e. RefTreeNode). * */ - bool BasePrivate::refreshCheckDispensable() + bool Base::refreshCheckDispensable() { return false; } @@ -213,7 +144,7 @@ namespace RM * The base implementation simply does nothing. * */ - void BasePrivate::preRefreshChildren() + void Base::preRefreshChildren() { } @@ -226,7 +157,7 @@ namespace RM * The base implementation simply does nothing. * */ - void BasePrivate::postRefreshChildren() + void Base::postRefreshChildren() { } @@ -241,7 +172,7 @@ namespace RM * 4. finally it deletes itself. Deleting is not defered; the object is gone immediately. * */ - void BasePrivate::terminateObject() + void Base::terminateObject() { foreach (Base* child, mChildren) { child->mData->terminateObject(); @@ -263,7 +194,7 @@ namespace RM * phase or not. * */ - bool BasePrivate::repoEventsBlocked() + bool Base::repoEventsBlocked() { Q_ASSERT(mRepo); return mRepo->isInitializing(); @@ -277,7 +208,7 @@ namespace RM * * The base implementation will send out a objectAboutToDelete() event. */ - void BasePrivate::preTerminate() + void Base::preTerminate() { if (!repoEventsBlocked()) { Events::self()->objectAboutToBeDeleted(repository(), mPub); @@ -296,25 +227,27 @@ namespace RM * Note that no events should be sent out, if repoEventsBlocked() returns `true`. * */ - void BasePrivate::postCreation() + void Base::postCreation() { if (!repoEventsBlocked()) { Events::self()->objectCreated(repository(), mPub); } } + #endif + #if 0 // ###REPOMAN move to RefreshService /** * @brief Find the parent for a Ref. * * @param[in] scopes List of scopes to search for or to create. * * @param[in] create If `true` and @a path is not empty, a reference tree node will be - * created, if none is found. If `false`, `NULL` will be returned. + * created, if none is found. If `false`, `nullptr` will be returned. * * @return If @a scopes is empty, `this` is returned. Otherwise findRefTreeNode() is called * to either find or create a RefTreeNode, which will be returned. */ - Base* BasePrivate::findRefParent(const QStringList& scopes, bool create) + Base* Base::findRefParent(const QStringList& scopes, bool create) { if (scopes.isEmpty()) { return mPub; @@ -330,22 +263,22 @@ namespace RM * @param[in] scopes List of scopes to search for or to create. Must not be empty. * * @param[in] create If `true` and a part of the tree node cannot be found, it will be - * created. If `false`, `NULL` will be returned in that case. + * created. If `false`, `nullptr` will be returned in that case. * * @return If @a create is `true`, a valid RefTreeNode is returned. If @a create is - * `false`, `NULL` will be returned in case the path cannot be found. + * `false`, `nullptr` will be returned in case the path cannot be found. */ - RefTreeNode* BasePrivate::findRefTreeNode(const QStringList &scopes, bool create) + RefTreeNode* Base::findRefTreeNode(const QStringList &scopes, bool create) { if (scopes.isEmpty()) { - return NULL; + return nullptr; } Base* current = mPub; foreach (QString scope, scopes) { RefTreeNode::List nodes = current->childObjects(); - RefTreeNode* next = NULL; + RefTreeNode* next = nullptr; foreach(RefTreeNode* child, nodes) { if (child->name() == scope) { @@ -360,7 +293,7 @@ namespace RM next = new RefTreeNode(current, scope); } else { - return NULL; + return nullptr; } } @@ -370,8 +303,7 @@ namespace RM return static_cast< RefTreeNode* >(current); } - - CollectionNode* BasePrivate::getOrCreateCollection(CollectionTypes ctype) + CollectionNode* Base::getOrCreateCollection(CollectionTypes ctype) { CollectionNode* cn; @@ -383,31 +315,34 @@ namespace RM return new CollectionNode(ctype, mPub); } + #endif - Repo* BasePrivate::searchRepository() - { - if (!mRepo) { - if (mParentObj) { - mRepo = mParentObj->repository(); - } - else { - return NULL; - } - } - return mRepo; - } - - Heaven::IconRef BasePrivate::icon(bool small) const + Heaven::IconRef Base::icon(bool small) const { QString size = small ? QStringLiteral("@16") : QStringLiteral("@24"); return Heaven::IconRef::fromString(QChar(L'#') % objectTypeName() % size); } - bool BasePrivate::inherits(ObjTypes type) const + bool Base::inherits(ObjTypes type) const { return false; } + Base::WList Base::children() const + { + return Base::WList(); + } + + std::weak_ptr Base::repository() const + { + return mRepo; + } + + std::shared_ptr Base::parent() const + { + return mParent.lock(); + } + } } diff --git a/Libs/libMacGitverCore/RepoMan/Data/Base.hpp b/Libs/libMacGitverCore/RepoMan/Data/Base.hpp new file mode 100644 index 00000000..c7506e5b --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Data/Base.hpp @@ -0,0 +1,142 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "RepoMan/Core.hpp" + +#include +#include +#include + +#ifdef _MSVC +#define const_or_constexpr const +#else +#define const_or_constexpr constexpr +#endif + +namespace RM +{ + + namespace Internal + { + class Dumper; + } + + namespace Frontend + { + class Base; + } + + namespace Data + { + + class Repo; + + class Base + : public std::enable_shared_from_this + { + public: + using FrontendT = Frontend::Base; + using SPtr = std::shared_ptr; + using WPtr = std::weak_ptr; + using SList = std::vector; + using WList = std::vector; + + private: + Base(const Base&) = delete; + Base& operator=(const Base&) = delete; + + protected: + Base(); + + public: + virtual ~Base(); + + public: + void dumpRecursive(Internal::Dumper& dumper) const; + + std::weak_ptr repository() const; + SPtr parent() const; + + public: + virtual QString displayName() const; + virtual QString objectTypeName() const = 0; + virtual Heaven::IconRef icon(bool small) const; + virtual bool inherits(ObjTypes type) const; + virtual ObjTypes objType() const = 0; + virtual void dumpSelf(Internal::Dumper& dumper) const = 0; + void dumpChildren(Internal::Dumper& dumper) const; + + virtual WList children() const; + + template + std::shared_ptr as() const; + + template + std::shared_ptr as(); + + private: + std::weak_ptr mRepo; + std::weak_ptr mParent; + }; + + template + inline std::shared_ptr Base::as() const + { + if (inherits(T::StaticObjectType)) { + return std::shared_ptr(static_cast(this)); + } + return std::shared_ptr(); + } + + template + inline std::shared_ptr Base::as() + { + if (inherits(T::StaticObjectType)) { + return std::shared_ptr(static_cast(this)); + } + return std::shared_ptr(); + } + + template + typename T::SList sharedFromWeakList(const typename T::WList& wlist) + { + typename T::SList slist; + for (const typename T::WPtr& wptr : wlist) { + if (auto sptr = wptr.lock()) { + slist.push_back(sptr); + } + } + return slist; + } + + template + typename T::WList weakFromSharedList(const typename T::SList& slist) + { + typename T::WList wlist; + for (const typename T::SPtr& sptr : slist) { + wlist.push_back(sptr); + } + return wlist; + } + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Data/BaseData.hpp b/Libs/libMacGitverCore/RepoMan/Data/BaseData.hpp deleted file mode 100644 index eb01ad73..00000000 --- a/Libs/libMacGitverCore/RepoMan/Data/BaseData.hpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2015 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "RepoMan/Base.hpp" - -#define RM_D(CLASS) Internal::CLASS##Private* d = \ - static_cast(mData) - -#define RM_CD(CLASS) const Internal::CLASS##Private* d = \ - static_cast(mData) - -#define RM_P(CLASS) CLASS* p = \ - static_cast(mPub) - -#define RM_CP(CLASS) const CLASS* p = \ - static_cast(mPub) - -#ifdef _MSVC -#define const_or_constexpr const -#else -#define const_or_constexpr constexpr -#endif - -namespace RM -{ - - namespace Internal - { - class Dumper; - } - - namespace Internal - { - - class BasePrivate - { - protected: - BasePrivate(Base* pub); - - public: - virtual ~BasePrivate(); - - public: - Base* mPub; - Repo* mRepo; - BasePrivate* mParentObj; - Base::List mChildren; - - public: - template< class T > T* pub() - { - return static_cast(mPub); - } - - template< class T > const T* pub() const - { - return static_cast(mPub); - } - - public: - void dumpRecursive(Dumper& dumper) const; - - void terminateObject(); - void linkToParent(Base* parent); - void unlinkFromParent(); - void addChildObject(Base *object); - void removeChildObject(Base* object); - Repo* repository(); - - virtual Repo* searchRepository(); - - void refresh(); - bool repoEventsBlocked(); - - Base* findRefParent(const QStringList& scopes, bool create); - RefTreeNode* findRefTreeNode(const QStringList& scopes, bool create); - - CollectionNode* getOrCreateCollection(CollectionTypes ctype); - - template< class T > static typename T::Private* dataOf(Base* b) - { - BasePrivate* p = b->mData; - if (p->objType() != ObjTypes(T::StaticObjectType)) { - return NULL; - } - return static_cast(p); - } - - public: - virtual QString displayName() const; - virtual QString objectTypeName() const = 0; - virtual Heaven::IconRef icon(bool small) const; - virtual bool refreshSelf() = 0; - virtual void postRefresh(); - virtual void preRefreshChildren(); - virtual void postRefreshChildren(); - virtual void postCreation(); - virtual void preTerminate(); - virtual bool refreshCheckDispensable(); - virtual bool inherits(ObjTypes type) const; - virtual ObjTypes objType() const = 0; - virtual void dumpSelf(Internal::Dumper& dumper) const = 0; - }; - - inline Repo* BasePrivate::repository() - { - return mRepo; - } - - } - -} diff --git a/Libs/libMacGitverCore/RepoMan/Data/Branch.cpp b/Libs/libMacGitverCore/RepoMan/Data/Branch.cpp index 3b59faac..f159fdc6 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/Branch.cpp +++ b/Libs/libMacGitverCore/RepoMan/Data/Branch.cpp @@ -17,40 +17,42 @@ * */ -#include "RepoMan/Data/BranchData.hpp" #include "RepoMan/Events.hpp" +#include "RepoMan/Data/Branch.hpp" + #include "RepoMan/Private/Dumper.hpp" namespace RM { - namespace Internal + namespace Data { - BranchPrivate::BranchPrivate(Branch* pub, const Git::Reference& ref) - : RefPrivate(pub, BranchType, ref) + Branch::Branch(Frontend::Branch* pub, const Git::Reference& ref) + : Reference(pub, BranchType, ref) , mHasUpstream(false) , mAheadCount(0) , mBehindCount(0) { } - ObjTypes BranchPrivate::objType() const + ObjTypes Branch::objType() const { return ObjTypes::Branch; } - void BranchPrivate::postCreation() + #if 0 // ###DEAD + void Branch::postCreation() { - if (!repoEventsBlocked()) { + jif (!repoEventsBlocked()) { Events::self()->branchCreated(repository(), pub()); } RefPrivate::postCreation(); } - void BranchPrivate::preTerminate() + void Branch::preTerminate() { if (!repoEventsBlocked()) { Events::self()->branchAboutToBeDeleted(repository(), pub()); @@ -59,35 +61,35 @@ namespace RM RefPrivate::preTerminate(); } - void BranchPrivate::dumpSelf(Internal::Dumper& dumper) const + void Branch::dumpSelf(Internal::Dumper& dumper) const { dumper.addLine(QString(QStringLiteral("Branch 0x%1 - %2")) .arg(quintptr(mPub),0,16) .arg(mName)); } - QString BranchPrivate::objectTypeName() const + QString Branch::objectTypeName() const { return QStringLiteral("Branch"); } - void BranchPrivate::emitMoved() + void Branch::emitMoved() { if (!repoEventsBlocked()) { Events::self()->refMoved(mRepo, pub()); Events::self()->branchMoved(mRepo, pub()); } } + #endif - bool BranchPrivate::refreshDetails(const Git::Reference& ref) + bool Branch::refreshDetails(const Git::Reference& ref) { - - return RefPrivate::refreshDetails(ref); + return Reference::refreshDetails(ref); } - bool BranchPrivate::inherits(ObjTypes type) const + bool Branch::inherits(ObjTypes type) const { - return type == ObjTypes::Branch || RefPrivate::inherits(type); + return type == ObjTypes::Branch || Reference::inherits(type); } } diff --git a/Libs/libMacGitverCore/RepoMan/Data/BranchData.hpp b/Libs/libMacGitverCore/RepoMan/Data/Branch.hpp similarity index 80% rename from Libs/libMacGitverCore/RepoMan/Data/BranchData.hpp rename to Libs/libMacGitverCore/RepoMan/Data/Branch.hpp index 97dda34e..5435afcf 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/BranchData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/Branch.hpp @@ -19,20 +19,23 @@ #pragma once -#include "RepoMan/Data/RefData.hpp" +#include "RepoMan/Data/Reference.hpp" -#include "RepoMan/Branch.hpp" +#include "RepoMan/Frontend/Branch.hpp" namespace RM { - namespace Internal + namespace Data { - class BranchPrivate : public RefPrivate + class Branch + : public Reference { public: - BranchPrivate(Branch* pub, const Git::Reference& ref); + static const_or_constexpr ObjTypes StaticObjectType = ObjTypes::Branch; + public: + Branch(Frontend::Branch* pub, const Git::Reference& ref); public: ObjTypes objType() const; diff --git a/Libs/libMacGitverCore/RepoMan/Data/Head.cpp b/Libs/libMacGitverCore/RepoMan/Data/Head.cpp index fa1a354b..a446c4d4 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/Head.cpp +++ b/Libs/libMacGitverCore/RepoMan/Data/Head.cpp @@ -19,26 +19,22 @@ #include "RepoMan/Events.hpp" -#include "RepoMan/Head.hpp" +#include "RepoMan/Data/Head.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/HeadData.hpp" - -#include "RepoMan/Branch.hpp" -#include "RepoMan/Repo.hpp" - #include "libGitWrap/Repository.hpp" #include "libGitWrap/BranchRef.hpp" namespace RM { - namespace Internal + namespace Data { - HeadPrivate::HeadPrivate(Head* _pub, const Git::Repository& repo) - : BasePrivate(_pub) + #if 0 + Head::Head(Frontend::Head* _pub, const Git::Repository& repo) + : Base(_pub) , symbolicName() , isDetached(repo.isHeadDetached()) , isUnborn(repo.isHeadUnborn()) @@ -53,19 +49,19 @@ namespace RM } } - ObjTypes HeadPrivate::objType() const + ObjTypes Head::objType() const { return ObjTypes::Head; } - void HeadPrivate::dumpSelf(Internal::Dumper& dumper) const + void Head::dumpSelf(Internal::Dumper& dumper) const { dumper.addLine(QString(QStringLiteral("Head 0x%1 - %2")) .arg(quintptr(mPub),0,16) .arg(symbolicName)); } - bool HeadPrivate::refreshSelf() + bool Head::refreshSelf() { Git::Repository repo = repository()->gitLoadedRepo(); Git::Result r; @@ -81,20 +77,21 @@ namespace RM } return true; } + #endif - QString HeadPrivate::displayName() const + QString Head::displayName() const { - return symbolicName; + return mSymbolicName; } - QString HeadPrivate::objectTypeName() const + QString Head::objectTypeName() const { return QStringLiteral("Head"); } - bool HeadPrivate::inherits(ObjTypes type) const + bool Head::inherits(ObjTypes type) const { - return type == ObjTypes::Head || BasePrivate::inherits(type); + return type == ObjTypes::Head || Base::inherits(type); } } diff --git a/Libs/libMacGitverCore/RepoMan/Data/Head.hpp b/Libs/libMacGitverCore/RepoMan/Data/Head.hpp new file mode 100644 index 00000000..e4fcf189 --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Data/Head.hpp @@ -0,0 +1,84 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "RepoMan/Data/Base.hpp" + +#include "RepoMan/Frontend/Head.hpp" + +namespace RM +{ + + namespace Data + { + + class Head + : public Base + { + public: + static const_or_constexpr ObjTypes StaticObjectType = ObjTypes::Head; + + public: + Head(Frontend::Head* pub, const Git::Repository& ref); + + public: + ObjTypes objType() const; + bool refreshSelf(); + QString displayName() const; + void dumpSelf(Internal::Dumper& dumper) const; + QString objectTypeName() const; + bool inherits(ObjTypes type) const; + + public: + bool isDetached() const; + bool isUnborn() const; + Git::ObjectId detachedId() const; + QString symbolicName() const; + + private: + QString mSymbolicName; + Git::ObjectId mDetachedId; + bool mIsDetached : 1; + bool mIsUnborn : 1; + }; + + inline bool Head::isDetached() const + { + return mIsDetached; + } + + inline bool Head::isUnborn() const + { + return mIsUnborn; + } + + inline Git::ObjectId Head::detachedId() const + { + return mDetachedId; + } + + inline QString Head::symbolicName() const + { + return mSymbolicName; + } + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Data/Namespace.cpp b/Libs/libMacGitverCore/RepoMan/Data/Namespace.cpp new file mode 100644 index 00000000..e69de29b diff --git a/Libs/libMacGitverCore/RepoMan/Data/Namespace.hpp b/Libs/libMacGitverCore/RepoMan/Data/Namespace.hpp new file mode 100644 index 00000000..6db03dfc --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Data/Namespace.hpp @@ -0,0 +1,57 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "RepoMan/Data/Base.hpp" + +#include "RepoMan/Frontend/Namespace.hpp" + +namespace RM +{ + + namespace Data + { + + class Namespace + : public Base + { + public: + static const_or_constexpr ObjTypes StaticObjectType = ObjTypes::Namespace; + + public: + Namespace(Namespace* _pub, const QString& _name); + + public: + ObjTypes objType() const; + bool refreshSelf(); + void postCreation(); + void preTerminate(); + QString displayName() const; + void dumpSelf(Internal::Dumper& dumper) const; + QString objectTypeName() const; + bool inherits(ObjTypes type) const; + + public: + QString name; + }; + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Data/RefLog.cpp b/Libs/libMacGitverCore/RepoMan/Data/RefLog.cpp new file mode 100644 index 00000000..e69de29b diff --git a/Libs/libMacGitverCore/RepoMan/Data/NamespaceData.hpp b/Libs/libMacGitverCore/RepoMan/Data/RefLog.hpp similarity index 80% rename from Libs/libMacGitverCore/RepoMan/Data/NamespaceData.hpp rename to Libs/libMacGitverCore/RepoMan/Data/RefLog.hpp index d7b77fb2..322fc62a 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/NamespaceData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/RefLog.hpp @@ -19,33 +19,33 @@ #pragma once -#include "RepoMan/Data/BaseData.hpp" +#include "RepoMan/Data/Base.hpp" -#include "RepoMan/Namespace.hpp" +#include "RepoMan/Frontend/RefLog.hpp" namespace RM { - namespace Internal + namespace Data { - class NamespacePrivate : public BasePrivate + class RefLog + : public Base { public: - NamespacePrivate(Namespace* _pub, const QString& _name); + static const_or_constexpr ObjTypes StaticObjectType = ObjTypes::RefLog; + + public: + RefLog(RefLog* _pub); public: ObjTypes objType() const; bool refreshSelf(); void postCreation(); void preTerminate(); - QString displayName() const; void dumpSelf(Internal::Dumper& dumper) const; QString objectTypeName() const; bool inherits(ObjTypes type) const; - - public: - QString name; }; } diff --git a/Libs/libMacGitverCore/RepoMan/Data/RefTreeNode.cpp b/Libs/libMacGitverCore/RepoMan/Data/RefTreeNode.cpp new file mode 100644 index 00000000..e69de29b diff --git a/Libs/libMacGitverCore/RepoMan/Data/RefTreeNodeData.hpp b/Libs/libMacGitverCore/RepoMan/Data/RefTreeNode.hpp similarity index 79% rename from Libs/libMacGitverCore/RepoMan/Data/RefTreeNodeData.hpp rename to Libs/libMacGitverCore/RepoMan/Data/RefTreeNode.hpp index d4eef6bd..759e4eac 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/RefTreeNodeData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/RefTreeNode.hpp @@ -19,20 +19,24 @@ #pragma once -#include "RepoMan/Data/BaseData.hpp" +#include "RepoMan/Data/Base.hpp" -#include "RepoMan/RefTreeNode.hpp" +#include "RepoMan/Frontend/RefTreeNode.hpp" namespace RM { - namespace Internal + namespace Data { - class RefTreeNodePrivate : public BasePrivate + class RefTreeNode + : public Base { public: - RefTreeNodePrivate(RefTreeNode* _pub, const QString& _name); + static const_or_constexpr ObjTypes StaticObjectType = ObjTypes::RefTreeNode; + + public: + RefTreeNode(RefTreeNode* _pub, const QString& _name); public: ObjTypes objType() const; diff --git a/Libs/libMacGitverCore/RepoMan/Data/Reference.cpp b/Libs/libMacGitverCore/RepoMan/Data/Reference.cpp new file mode 100644 index 00000000..e69de29b diff --git a/Libs/libMacGitverCore/RepoMan/Data/RefData.hpp b/Libs/libMacGitverCore/RepoMan/Data/Reference.hpp similarity index 78% rename from Libs/libMacGitverCore/RepoMan/Data/RefData.hpp rename to Libs/libMacGitverCore/RepoMan/Data/Reference.hpp index 62afb6b0..8e1dac3d 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/RefData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/Reference.hpp @@ -19,20 +19,24 @@ #pragma once -#include "RepoMan/Data/BaseData.hpp" +#include "RepoMan/Data/Base.hpp" -#include "RepoMan/Ref.hpp" +#include "RepoMan/Frontend/Reference.hpp" namespace RM { - namespace Internal + namespace Data { - class RefPrivate : public BasePrivate + class Reference + : public Base { public: - RefPrivate(Ref* pub, RefTypes type, const Git::Reference& ref); + static const_or_constexpr ObjTypes StaticObjectType = ObjTypes::Reference; + + public: + Reference(Frontend::Reference* pub, RefTypes type, const Git::Reference& ref); public: ObjTypes objType() const; @@ -53,6 +57,9 @@ namespace RM Git::ObjectId mId; }; + GW_DEPRECATED + typedef Reference Ref; + } } diff --git a/Libs/libMacGitverCore/RepoMan/Data/Remote.cpp b/Libs/libMacGitverCore/RepoMan/Data/Remote.cpp new file mode 100644 index 00000000..e69de29b diff --git a/Libs/libMacGitverCore/RepoMan/Data/RemoteData.hpp b/Libs/libMacGitverCore/RepoMan/Data/Remote.hpp similarity index 79% rename from Libs/libMacGitverCore/RepoMan/Data/RemoteData.hpp rename to Libs/libMacGitverCore/RepoMan/Data/Remote.hpp index 54c55b17..78f96b95 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/RemoteData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/Remote.hpp @@ -19,22 +19,26 @@ #pragma once -#include "RepoMan/Data/BaseData.hpp" +#include "RepoMan/Data/Base.hpp" -#include "RepoMan/Remote.hpp" +#include "RepoMan/Frontend/Remote.hpp" namespace RM { - class Head; - - namespace Internal + namespace Data { - class RemotePrivate : public BasePrivate + class Head; + + class Remote + : public Base { public: - RemotePrivate(Remote* _pub, const Git::Remote& _obj); + static const_or_constexpr ObjTypes StaticObjectType = ObjTypes::Remote; + + public: + Remote(Remote* _pub, const Git::Remote& _obj); public: ObjTypes objType() const; diff --git a/Libs/libMacGitverCore/RepoMan/Data/Repo.cpp b/Libs/libMacGitverCore/RepoMan/Data/Repo.cpp new file mode 100644 index 00000000..69d31b36 --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Data/Repo.cpp @@ -0,0 +1,69 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "RepoMan/Data/Repo.hpp" + +#include + +namespace RM +{ + + namespace Data + { + + Repo::Repo(const Git::Repository& repo) + : mHead(nullptr) + , mRepo(repo) + { + } + + Repo::~Repo() + { + } + + Git::Repository Repo::gitRepo(bool doLoad) + { + if (!mRepo && doLoad) { + assert(false); // ###REPOMAN - Not sure if we still want to support this... + } + + return mRepo; + } + + Repo::SPtr Repo::repoByPath(const QString& basePath, bool searchSubmodules) + { + for (const Repo::SPtr& subRepo : mSubmodules) { + if (subRepo->path() == basePath) { + return subRepo; + } + + if (searchSubmodules) { + Repo::SPtr found = subRepo->repoByPath(basePath, true); + if (found) { + return found; + } + } + } + + return Repo::SPtr(); + } + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Data/RepoData.hpp b/Libs/libMacGitverCore/RepoMan/Data/Repo.hpp similarity index 60% rename from Libs/libMacGitverCore/RepoMan/Data/RepoData.hpp rename to Libs/libMacGitverCore/RepoMan/Data/Repo.hpp index 9fb42eeb..3d0152ba 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/RepoData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/Repo.hpp @@ -19,23 +19,39 @@ #pragma once -#include "RepoMan/Data/BaseData.hpp" +#include "RepoMan/Data/Base.hpp" -#include "RepoMan/Repo.hpp" +#include "RepoMan/Frontend/Repo.hpp" + +class QTimer; namespace RM { - class Head; - - namespace Internal + namespace Data { - class RepoPrivate : public BasePrivate + class Reference; + class Remote; + class Namespace; + class Head; + + class Repo + : public Base { public: - RepoPrivate(Repo* pub, const Git::Repository& repo); - ~RepoPrivate(); + static const_or_constexpr ObjTypes StaticObjectType = ObjTypes::Repo; + + public: + using FrontendT = Frontend::Repo; + using SPtr = std::shared_ptr; + using WPtr = std::weak_ptr; + using SList = std::vector; + using WList = std::vector; + + public: + Repo(const Git::Repository& repo); + ~Repo(); public: ObjTypes objType() const; @@ -46,44 +62,60 @@ namespace RM void dumpSelf(Internal::Dumper& dumper) const; QString objectTypeName() const; bool inherits(ObjTypes type) const; - Repo* searchRepository(); public: - Ref* findReference( const Git::Reference& ref, bool create = false); - Ref* findReference( const QString& fqrn, bool create = false); - Remote* findRemote( const Git::Remote& remote, bool create = false); + Reference* findReference( const QString& fqrn, bool create = false); + Remote* findRemote( const QString& remoteName, bool create = false); + Namespace* findNamespace( const QStringList& _namespaces, bool create = false); Namespace* findNamespace( const QString& nsFullName, bool create = false); private: - Ref* findReference(Git::RefName &rn, Git::Reference ref, bool create); + GW_DEPRECATED + Reference* findReference(Git::RefName &rn, Git::Reference ref, bool create); public: - void load(); - void unload(); - void findAlias(); - void scanSubmodules(); - Repo* repoByPath(const QString& basePath, bool searchSubmodules); + SPtr repoByPath(const QString& basePath, bool searchSubmodules); + WList submodules() const; public: + QMutex& mutex() const; + QString path() const; Git::Repository gitRepo(bool doLoad = false); public: - QString mPath; //!< Full, absolute path to this repository QString mDisplayAlias; //!< An alias for display (Default to last path comp.) bool mIsSubModule : 1; //!< This is a submodule of another repo bool mIsBare : 1; //!< This is a bare repo bool mIsLoaded : 1; //!< This repo is currently loaded (by gitWrap) bool mIsActive : 1; //!< This is MGV's current active repo? - bool mIsInitializing : 1; //!< True, while this repository is initializing - QTimer* mUnloadTimer; //!< NULL or a timer to unload this repository + //bool mIsInitializing : 1; //!< True, while this repository is initializing + //QTimer* mUnloadTimer; //!< NULL or a timer to unload this repository Head* mHead; //!< The HEAD private: Git::Repository mRepo; //!< GitWrap-Repo, if loaded + QString mPath; //!< Full, absolute path to this repository + mutable QMutex mMutex; //!< One mutex to protect them all (inside this Repo) + SList mSubmodules; }; + inline QMutex& Repo::mutex() const + { + return mMutex; + } + + inline Repo::WList Repo::submodules() const + { + return weakFromSharedList(mSubmodules); + } + + inline QString Repo::path() const + { + return mPath; + } + } } diff --git a/Libs/libMacGitverCore/RepoMan/Data/RepoManData.hpp b/Libs/libMacGitverCore/RepoMan/Data/RepoMan.hpp similarity index 70% rename from Libs/libMacGitverCore/RepoMan/Data/RepoManData.hpp rename to Libs/libMacGitverCore/RepoMan/Data/RepoMan.hpp index 5c637c27..f3c0cc1e 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/RepoManData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/RepoMan.hpp @@ -19,7 +19,7 @@ #pragma once -#include "libMacGitverCore/RepoMan/Data/BaseData.hpp" +#include "libMacGitverCore/RepoMan/Data/Base.hpp" #include "libMacGitverCore/RepoMan/RepoMan.hpp" @@ -27,25 +27,18 @@ #include "hic_RepoManActions.h" +#if 0 // ###DEAD namespace RM { - namespace Internal + namespace Data { - class RepoManPrivate : public BasePrivate, private RepoManActions + class RepoMan : private RepoManActions { public: - RepoManPrivate(RepoMan* _pub); - - public: - ObjTypes objType() const; - bool refreshSelf(); - void preTerminate(); - QString displayName() const; - void dumpSelf(Internal::Dumper& dumper) const; - QString objectTypeName() const; - + RepoMan(RepoMan* _pub); + Heaven::Menu* contextMenuFor(Base* object); public: @@ -56,3 +49,4 @@ namespace RM } } +#endif diff --git a/Libs/libMacGitverCore/RepoMan/Data/Submodule.cpp b/Libs/libMacGitverCore/RepoMan/Data/Submodule.cpp new file mode 100644 index 00000000..e69de29b diff --git a/Libs/libMacGitverCore/RepoMan/Data/RefLogData.hpp b/Libs/libMacGitverCore/RepoMan/Data/Submodule.hpp similarity index 77% rename from Libs/libMacGitverCore/RepoMan/Data/RefLogData.hpp rename to Libs/libMacGitverCore/RepoMan/Data/Submodule.hpp index 7724c619..d89f30ef 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/RefLogData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/Submodule.hpp @@ -19,24 +19,27 @@ #pragma once -#include "RepoMan/Data/BaseData.hpp" +#include "RepoMan/Data/Repo.hpp" -#include "RepoMan/RefLog.hpp" +#include "RepoMan/Frontend/Submodule.hpp" namespace RM { - namespace Internal + namespace Data { - class RefLogPrivate : public BasePrivate + class Submodule + : public Repo { public: - RefLogPrivate(RefLog* _pub); + static const_or_constexpr ObjTypes StaticObjectType = ObjTypes::Submodule; + + public: + Submodule(Submodule* pub, const Git::Repository& repo); public: ObjTypes objType() const; - bool refreshSelf(); void postCreation(); void preTerminate(); void dumpSelf(Internal::Dumper& dumper) const; diff --git a/Libs/libMacGitverCore/RepoMan/Data/Tag.cpp b/Libs/libMacGitverCore/RepoMan/Data/Tag.cpp new file mode 100644 index 00000000..e69de29b diff --git a/Libs/libMacGitverCore/RepoMan/Data/SubmoduleData.hpp b/Libs/libMacGitverCore/RepoMan/Data/Tag.hpp similarity index 78% rename from Libs/libMacGitverCore/RepoMan/Data/SubmoduleData.hpp rename to Libs/libMacGitverCore/RepoMan/Data/Tag.hpp index 2f454210..3f4b367e 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/SubmoduleData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Data/Tag.hpp @@ -19,20 +19,24 @@ #pragma once -#include "RepoMan/Data/RepoData.hpp" +#include "RepoMan/Data/Reference.hpp" -#include "RepoMan/Submodule.hpp" +#include "RepoMan/Frontend/Tag.hpp" namespace RM { - namespace Internal + namespace Data { - class SubmodulePrivate : public RepoPrivate + class Tag + : public Reference { public: - SubmodulePrivate(Submodule* pub, const Git::Repository& repo); + static const_or_constexpr ObjTypes StaticObjectType = ObjTypes::Tag; + + public: + Tag(Tag* pub, const Git::Reference& _ref); public: ObjTypes objType() const; diff --git a/Libs/libMacGitverCore/RepoMan/Events.cpp b/Libs/libMacGitverCore/RepoMan/Events.cpp index 9a96bb03..f208fd68 100644 --- a/Libs/libMacGitverCore/RepoMan/Events.cpp +++ b/Libs/libMacGitverCore/RepoMan/Events.cpp @@ -156,231 +156,231 @@ namespace RM self()->mEvents.remove(ev); } - void Events::repositoryOpened(Repo* repo) + void Events::repositoryOpened(const RM::Frontend::Repo& repo) { foreach (EventsInterface* ei, mEvents) { ei->repositoryOpened(repo); } } - void Events::repositoryAboutToClose(Repo* repo) + void Events::repositoryAboutToClose(const RM::Frontend::Repo& repo) { foreach (EventsInterface* ei, mEvents) { ei->repositoryAboutToClose(repo); } } - void Events::repositoryActivated(Repo* repo) + void Events::repositoryActivated(const RM::Frontend::Repo& repo) { foreach (EventsInterface* ei, mEvents) { ei->repositoryActivated(repo); } } - void Events::repositoryDeactivated(Repo* repo) + void Events::repositoryDeactivated(const RM::Frontend::Repo& repo) { foreach (EventsInterface* ei, mEvents) { ei->repositoryDeactivated(repo); } } - void Events::objectCreated(Repo* repo, Base* object) + void Events::objectCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object) { foreach (EventsInterface* ei, mEvents) { ei->objectCreated(repo, object); } } - void Events::objectAboutToBeDeleted(Repo* repo, Base* object) + void Events::objectAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object) { foreach (EventsInterface* ei, mEvents) { ei->objectAboutToBeDeleted(repo, object); } } - void Events::refTreeNodeCreated(Repo* repo, RefTreeNode* node) + void Events::refTreeNodeCreated(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node) { foreach (EventsInterface* ei, mEvents) { ei->refTreeNodeCreated(repo, node); } } - void Events::refTreeNodeAboutToBeDeleted(Repo* repo, RefTreeNode* node) + void Events::refTreeNodeAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node) { foreach (EventsInterface* ei, mEvents) { ei->refTreeNodeAboutToBeDeleted(repo, node); } } - void Events::refCreated(Repo* repo, Ref* ref) + void Events::refCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) { foreach (EventsInterface* ei, mEvents) { ei->refCreated(repo, ref); } } - void Events::refAboutToBeDeleted(Repo* repo, Ref* ref) + void Events::refAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) { foreach (EventsInterface* ei, mEvents) { ei->refAboutToBeDeleted(repo, ref); } } - void Events::refMoved(Repo* repo, Ref* ref) + void Events::refMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) { foreach (EventsInterface* ei, mEvents) { ei->refMoved(repo, ref); } } - void Events::refHeadDetached(Repo* repo, Ref* ref) + void Events::refHeadDetached(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) { foreach (EventsInterface* ei, mEvents) { ei->refHeadDetached(repo, ref); } } - void Events::tagCreated(Repo* repo, Tag* tag) + void Events::tagCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag) { foreach (EventsInterface* ei, mEvents) { ei->tagCreated(repo, tag); } } - void Events::tagAboutToBeDeleted(Repo* repo, Tag* tag) + void Events::tagAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag) { foreach (EventsInterface* ei, mEvents) { ei->tagAboutToBeDeleted(repo, tag); } } - void Events::branchCreated(Repo* repo, Branch* branch) + void Events::branchCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) { foreach (EventsInterface* ei, mEvents) { ei->branchCreated(repo, branch); } } - void Events::branchAboutToBeDeleted(Repo* repo, Branch* branch) + void Events::branchAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) { foreach (EventsInterface* ei, mEvents) { ei->branchAboutToBeDeleted(repo, branch); } } - void Events::branchMoved(Repo* repo, Branch* branch) + void Events::branchMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) { foreach (EventsInterface* ei, mEvents) { ei->branchMoved(repo, branch); } } - void Events::branchUpstreamChanged(Repo* repo, Branch* branch) + void Events::branchUpstreamChanged(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) { foreach (EventsInterface* ei, mEvents) { ei->branchUpstreamChanged(repo, branch); } } - void Events::namespaceCreated(Repo* repo, Namespace* nameSpace) + void Events::namespaceCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace) { foreach (EventsInterface* ei, mEvents) { ei->namespaceCreated(repo, nameSpace); } } - void Events::namespaceAboutToBeDeleted(Repo* repo, Namespace* nameSpace) + void Events::namespaceAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace) { foreach (EventsInterface* ei, mEvents) { ei->namespaceAboutToBeDeleted(repo, nameSpace); } } - void Events::refLogChanged(Repo* repo, RefLog* reflog) + void Events::refLogChanged(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog) { foreach (EventsInterface* ei, mEvents) { ei->refLogChanged(repo, reflog); } } - void Events::refLogNewEntry(Repo* repo, RefLog* reflog) + void Events::refLogNewEntry(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog) { foreach (EventsInterface* ei, mEvents) { ei->refLogNewEntry(repo, reflog); } } - void Events::stageCreated(Repo* repo, Ref* ref) + void Events::stageCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) { foreach (EventsInterface* ei, mEvents) { ei->stageCreated(repo, ref); } } - void Events::stageAboutToBeDeleted(Repo* repo, Ref* ref) + void Events::stageAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) { foreach (EventsInterface* ei, mEvents) { ei->stageAboutToBeDeleted(repo, ref); } } - void Events::remoteCreated(Repo* repo, Remote* remote) + void Events::remoteCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) { foreach (EventsInterface* ei, mEvents) { ei->remoteCreated(repo, remote); } } - void Events::remoteAboutToBeDeleted(Repo* repo, Remote* remote) + void Events::remoteAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) { foreach (EventsInterface* ei, mEvents) { ei->remoteAboutToBeDeleted(repo, remote); } } - void Events::remoteModified(Repo* repo, Remote* remote) + void Events::remoteModified(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) { foreach (EventsInterface* ei, mEvents) { ei->remoteModified(repo, remote); } } - void Events::submoduleCreated(Repo* repo, Submodule* submodule) + void Events::submoduleCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) { foreach (EventsInterface* ei, mEvents) { ei->submoduleCreated(repo, submodule); } } - void Events::submoduleAboutToBeDeleted(Repo* repo, Submodule* submodule) + void Events::submoduleAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) { foreach (EventsInterface* ei, mEvents) { ei->submoduleAboutToBeDeleted(repo, submodule); } } - void Events::submoduleMoved(Repo* repo, Submodule* submodule) + void Events::submoduleMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) { foreach (EventsInterface* ei, mEvents) { ei->submoduleMoved(repo, submodule); } } - void Events::repositoryStateChanged(Repo* repo) + void Events::repositoryStateChanged(const RM::Frontend::Repo& repo) { foreach (EventsInterface* ei, mEvents) { ei->repositoryStateChanged(repo); } } - void Events::indexUpdated(Repo* repo) + void Events::indexUpdated(const RM::Frontend::Repo& repo) { foreach (EventsInterface* ei, mEvents) { ei->indexUpdated(repo); } } - void Events::workTreeUpdated(Repo* repo) + void Events::workTreeUpdated(const RM::Frontend::Repo& repo) { foreach (EventsInterface* ei, mEvents) { ei->workTreeUpdated(repo); diff --git a/Libs/libMacGitverCore/RepoMan/Events.hpp b/Libs/libMacGitverCore/RepoMan/Events.hpp index 5f30ee04..738a6f66 100644 --- a/Libs/libMacGitverCore/RepoMan/Events.hpp +++ b/Libs/libMacGitverCore/RepoMan/Events.hpp @@ -19,23 +19,26 @@ #pragma once -#include +#include "libMacGitverCore/RepoMan/Core.hpp" -#include "libMacGitverCore/MacGitverApi.hpp" +#include namespace RM { - class Base; - class Namespace; - class Repo; - class Ref; - class Remote; - class Submodule; - class RefTreeNode; - class RefLog; - class Branch; - class Tag; + namespace Frontend + { + class Base; + class Namespace; + class Repo; + class Reference; + class Remote; + class Submodule; + class RefTreeNode; + class RefLog; + class Branch; + class Tag; + } class MGV_CORE_API EventsInterface { @@ -43,50 +46,50 @@ namespace RM virtual ~EventsInterface() {} public: - virtual void repositoryOpened(Repo* repo) = 0; - virtual void repositoryAboutToClose(Repo* repo) = 0; - virtual void repositoryActivated(Repo* repo) = 0; - virtual void repositoryDeactivated(Repo* repo) = 0; + virtual void repositoryOpened(const RM::Frontend::Repo& repo) = 0; + virtual void repositoryAboutToClose(const RM::Frontend::Repo& repo) = 0; + virtual void repositoryActivated(const RM::Frontend::Repo& repo) = 0; + virtual void repositoryDeactivated(const RM::Frontend::Repo& repo) = 0; - virtual void objectCreated(Repo* repo, Base* object) = 0; - virtual void objectAboutToBeDeleted(Repo* repo, Base* object) = 0; + virtual void objectCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object) = 0; + virtual void objectAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object) = 0; - virtual void refTreeNodeCreated(Repo* repo, RefTreeNode* node) = 0; - virtual void refTreeNodeAboutToBeDeleted(Repo* repo, RefTreeNode* node) = 0; + virtual void refTreeNodeCreated(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node) = 0; + virtual void refTreeNodeAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node) = 0; - virtual void refCreated(Repo* repo, Ref* ref) = 0; - virtual void refAboutToBeDeleted(Repo* repo, Ref* ref) = 0; - virtual void refMoved(Repo* repo, Ref* ref) = 0; - virtual void refHeadDetached(Repo* repo, Ref* ref) = 0; + virtual void refCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) = 0; + virtual void refAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) = 0; + virtual void refMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) = 0; + virtual void refHeadDetached(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) = 0; - virtual void tagCreated(Repo* repo, Tag* tag) = 0; - virtual void tagAboutToBeDeleted(Repo* repo, Tag* tag) = 0; + virtual void tagCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag) = 0; + virtual void tagAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag) = 0; - virtual void branchCreated(Repo* repo, Branch* branch) = 0; - virtual void branchAboutToBeDeleted(Repo* repo, Branch* branch) = 0; - virtual void branchMoved(Repo* repo, Branch* branch) = 0; - virtual void branchUpstreamChanged(Repo* repo, Branch* branch) = 0; + virtual void branchCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) = 0; + virtual void branchAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) = 0; + virtual void branchMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) = 0; + virtual void branchUpstreamChanged(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) = 0; - virtual void namespaceCreated(Repo* repo, Namespace* nameSpace) = 0; - virtual void namespaceAboutToBeDeleted(Repo* repo, Namespace* nameSpace) = 0; + virtual void namespaceCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace) = 0; + virtual void namespaceAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace) = 0; - virtual void refLogChanged(Repo* repo, RefLog* reflog) = 0; - virtual void refLogNewEntry(Repo* repo, RefLog* reflog) = 0; + virtual void refLogChanged(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog) = 0; + virtual void refLogNewEntry(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog) = 0; - virtual void stageCreated(Repo* repo, Ref* ref) = 0; - virtual void stageAboutToBeDeleted(Repo* repo, Ref* ref) = 0; + virtual void stageCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) = 0; + virtual void stageAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) = 0; - virtual void remoteCreated(Repo* repo, Remote* remote) = 0; - virtual void remoteAboutToBeDeleted(Repo* repo, Remote* remote) = 0; - virtual void remoteModified(Repo* repo, Remote* remote) = 0; + virtual void remoteCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) = 0; + virtual void remoteAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) = 0; + virtual void remoteModified(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) = 0; - virtual void submoduleCreated(Repo* repo, Submodule* submodule) = 0; - virtual void submoduleAboutToBeDeleted(Repo* repo, Submodule* submodule) = 0; - virtual void submoduleMoved(Repo* repo, Submodule* submodule) = 0; + virtual void submoduleCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) = 0; + virtual void submoduleAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) = 0; + virtual void submoduleMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) = 0; - virtual void repositoryStateChanged(Repo* repo) = 0; - virtual void indexUpdated(Repo* repo) = 0; - virtual void workTreeUpdated(Repo* repo) = 0; + virtual void repositoryStateChanged(const RM::Frontend::Repo& repo) = 0; + virtual void indexUpdated(const RM::Frontend::Repo& repo) = 0; + virtual void workTreeUpdated(const RM::Frontend::Repo& repo) = 0; }; class MGV_CORE_API Events // : public EventsInterface @@ -100,43 +103,43 @@ namespace RM static void delReceiver(EventsInterface* ev); private: - QSet< EventsInterface* > mEvents; + QSet mEvents; static Events* sSelf; public: - void repositoryOpened(Repo* repo); - void repositoryAboutToClose(Repo* repo); - void repositoryActivated(Repo* repo); - void repositoryDeactivated(Repo* repo); - void objectCreated(Repo* repo, Base* object); - void objectAboutToBeDeleted(Repo* repo, Base* object); - void refTreeNodeCreated(Repo* repo, RefTreeNode* node); - void refTreeNodeAboutToBeDeleted(Repo* repo, RefTreeNode* node); - void refCreated(Repo* repo, Ref* ref); - void refAboutToBeDeleted(Repo* repo, Ref* ref); - void refMoved(Repo* repo, Ref* ref); - void refHeadDetached(Repo* repo, Ref* ref); - void tagCreated(Repo* repo, Tag* tag); - void tagAboutToBeDeleted(Repo* repo, Tag* tag); - void branchCreated(Repo* repo, Branch* branch); - void branchAboutToBeDeleted(Repo* repo, Branch* branch); - void branchMoved(Repo* repo, Branch* branch); - void branchUpstreamChanged(Repo* repo, Branch* branch); - void namespaceCreated(Repo* repo, Namespace* nameSpace); - void namespaceAboutToBeDeleted(Repo* repo, Namespace* nameSpace); - void refLogChanged(Repo* repo, RefLog* reflog); - void refLogNewEntry(Repo* repo, RefLog* reflog); - void stageCreated(Repo* repo, Ref* ref); - void stageAboutToBeDeleted(Repo* repo, Ref* ref); - void remoteCreated(Repo* repo, Remote* remote); - void remoteAboutToBeDeleted(Repo* repo, Remote* remote); - void remoteModified(Repo* repo, Remote* remote); - void submoduleCreated(Repo* repo, Submodule* submodule); - void submoduleAboutToBeDeleted(Repo* repo, Submodule* submodule); - void submoduleMoved(Repo* repo, Submodule* submodule); - void repositoryStateChanged(Repo* repo); - void indexUpdated(Repo* repo); - void workTreeUpdated(Repo* repo); + void repositoryOpened(const RM::Frontend::Repo& repo); + void repositoryAboutToClose(const RM::Frontend::Repo& repo); + void repositoryActivated(const RM::Frontend::Repo& repo); + void repositoryDeactivated(const RM::Frontend::Repo& repo); + void objectCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object); + void objectAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object); + void refTreeNodeCreated(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node); + void refTreeNodeAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node); + void refCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void refAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void refMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void refHeadDetached(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void tagCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag); + void tagAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag); + void branchCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); + void branchAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); + void branchMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); + void branchUpstreamChanged(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); + void namespaceCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace); + void namespaceAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace); + void refLogChanged(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog); + void refLogNewEntry(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog); + void stageCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void stageAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void remoteCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); + void remoteAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); + void remoteModified(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); + void submoduleCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); + void submoduleAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); + void submoduleMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); + void repositoryStateChanged(const RM::Frontend::Repo& repo); + void indexUpdated(const RM::Frontend::Repo& repo); + void workTreeUpdated(const RM::Frontend::Repo& repo); }; } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Base.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Base.cpp index d6848dde..fba0cfb0 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Base.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Base.cpp @@ -17,27 +17,26 @@ * */ -#include -#include - -#include "libHeavenIcons/IconRef.hpp" - #include "App/MacGitver.hpp" -#include "RepoMan/Base.hpp" -#include "RepoMan/Repo.hpp" +#include "RepoMan/Frontend/BaseInternal.hpp" +#include "RepoMan/Frontend/Repo.hpp" #include "RepoMan/RepoMan.hpp" -#include "RepoMan/RefTreeNode.hpp" -#include "RepoMan/CollectionNode.hpp" +#include "RepoMan/Frontend/RefTreeNode.hpp" + #include "RepoMan/Events.hpp" -#include "RepoMan/Data/RepoManData.hpp" -#include "RepoMan/Data/BaseData.hpp" +#include "RepoMan/Data/Base.hpp" #include "RepoMan/Private/Dumper.hpp" +#include "libHeavenIcons/IconRef.hpp" + +#include +#include + /** - * @class Base + * @class RM::Frontend::Base * @brief Base class for all RepoMan objects * * This base class takes care of a unified linking between a parent and its children. Children @@ -55,236 +54,197 @@ namespace RM { - using namespace Internal; - - /** - * @fn bool Base::refreshSelf() - * @brief Refresh this object's data and sent events - * - * This method is called during the refreshing mechanism. It is the first step and can determine - * that the object itself does no longer exist. However, if this happens, the child refreshing - * logic of the parent is most probably broken. - * - * Implementations should _only_ refresh the object itself and not the children. See refresh() - * for details on how exactly the refreshing process works. - */ - - /** - * @fn bool Base::isA() - * @brief Check this object's type - * - * @tparam T Type to check against - * - * @return `true`, if this is an object of type @a T. `false` otherwise. - */ - - /*-* // Keep this comment away from doxygen: https://bugzilla.gnome.org/show_bug.cgi?id=709052 - * @fn T::Set Base::childObjects() const - * @brief Find (existing) children filtered by a given type - * - * @tparam T Type to check the children against - * - * @return A set of children of type @a T. - */ - - /** - * @brief Constructor - * - * Creates a new RepoMan object and links it into the parent. Because at this point the new - * child is not yet fully constructed, no further action is taken. - * - * @param[in] parent The parent to whom we shall link this new child to. - * - */ - Base::Base(BasePrivate& _d) - : mData(&_d) + namespace Frontend { - } - /** - * @brief Destructor - * - * At the point where the destructor is called, all children should have been unlinked from the - * tree and this object has to be unlinked too. - * - */ - Base::~Base() - { - delete mData; - } + /** + * @brief Constructor + * + * Creates a new RepoMan object and links it into the parent. Because at this point the new + * child is not yet fully constructed, no further action is taken. + * + * @param[in] parent The parent to whom we shall link this new child to. + * + */ + Base::Base(const std::shared_ptr& o) + : mData(o) + { + } - /** - * @brief Find (existing) children - * - * @return A set of all children of this object (unfiltered). - */ - Base::List Base::childObjects() const - { - RM_CD(Base); + Base::Base(std::shared_ptr&& o) + : mData(std::move(o)) + { + } - return d->mChildren; - } + Base::Base() + {} - /** - * @brief Find (existing) children of a specific type - * - * @param[in] type The object type of the children to find. - * - * @return A set of children of this object filtered by object type. - * - */ - Base::List Base::childObjects(ObjTypes type) const - { - RM_CD(Base); + Base::Base(const Base& other) + : mData(other.mData) + { + } - List children; + Base::Base(Base&& other) + : mData(std::move(other.mData)) + { + } - foreach(Base* child, d->mChildren) { - if (child->objType() == type) { - children.append(child); - } + Base& Base::operator=(Base&& other) + { + std::swap(mData, other.mData); + return * this; } - return children; - } + bool Base::operator==(const Base& other) const + { + return mData == other.mData; + } - /** - * @brief Get the direct parent object - * - * The direct parent object is specified during construction and can never be changed. - * - * @return The direct parent object. - * - */ - Base* Base::parentObject() const - { - RM_CD(Base); + Base::operator bool() const + { + return !!mData; + } + /** + * @brief Destructor + * + * At the point where the destructor is called, all children should have been unlinked from the + * tree and this object has to be unlinked too. + * + */ + Base::~Base() + { + } - return d->mParentObj->mPub; - } + Base& Base::operator=(const Base& other) + { + mData = other.mData; + return * this; + } - /** - * @brief Refresh this object - * - * Refreshs this object and all its children. - * - */ - void Base::refresh() - { - RM_D(Base); - d->refresh(); - } + /** + * @brief Get the direct parent object + * + * The direct parent object is specified during construction and can never be changed. + * + * @return The direct parent object. + * + */ + Base Base::parent() const + { + return mData->parent(); + } - /** - * @brief Find the repository for this object - * - * @return The first repository in hierarchy (Repo or Submodule) - * - */ - const Repo* Base::repository() const - { - RM_CD(Base); - return d->mRepo; - } + /** + * @brief Find the repository for this object + * + * @return The first repository in hierarchy (Repo or Submodule) + * + */ + Repo Base::repository() const + { + if (mData) { + return mData->repository().lock(); + } + return Repo(); + } - /** - * @brief find the repository for this object - * - * Walks up the hierarchy of objects to find the repository. Since objects can never be - * reparented, the result of this method never changes. - * - * @return The first repository in hierarchy that is found - * - */ - Repo* Base::repository() - { - RM_D(Base); - return d->mRepo; - } + bool Base::inherits(ObjTypes type) const + { + return mData->inherits(type); + } - /** - * @brief Get a string that can be used to display this object - * - * @return Always ``. Reimplementations should return something more meaningful. - * - */ - QString Base::displayName() const - { - RM_CD(Base); - return d->displayName(); - } + /** + * @brief Get the type of this object + * + * This method must be implemented by all derivats of Base. They must simply return the correct + * value from the ObjTypes enum. + * + * @return Type of this object + * + */ + ObjTypes Base::objType() const + { + return mData->objType(); + } - /** - * @brief Get the type of this object - * - * This method must be implemented by all derivats of Base. They must simply return the correct - * value from the ObjTypes enum. - * - * @return Type of this object - * - */ - ObjTypes Base::objType() const - { - RM_CD(Base); - return d->objType(); - } + /** + * @brief Creates a textual dump of this object and its children + * + * @return Textual dump. + * + */ + QString Base::dump() const + { + Internal::Dumper dumper; + mData->dumpRecursive(dumper); + return dumper.output(); + } - /** - * @brief Creates a textual dump of this object and its children - * - * @return Textual dump. - * - */ - QString Base::dump() const - { - RM_CD(Base); + /** + * @brief Get the name of this object type + * + * @return The name + * + */ + QString Base::typeName() const + { + return mData->objectTypeName(); + } - Dumper dumper; - d->dumpRecursive(dumper); - return dumper.output(); - } + std::shared_ptr Base::data() const + { + return mData; + } - /** - * @brief Get the name of this object type - * - * @return The name - * - */ - QString Base::typeName() const - { - RM_CD(Base); - return d->objectTypeName(); - } + Base::List Base::children() const + { + // ###REPOMAN Do we need to lock here? + if (mData) { + //return mData->children(); + } - /** - * @brief Get a context menu for this object - * - * @return A Heaven::Menu that can be used as context menu for this object. - * - */ - Heaven::Menu* Base::contextMenu() - { - RepoMan* rm = &MacGitver::repoMan(); - RepoMan::Private* rmp = BasePrivate::dataOf(rm); - return rmp->contextMenuFor(this); - } + return List(); + } - /** - * @brief Get an icon for this object - * - * @return A iconRef for this object - * - */ - Heaven::IconRef Base::icon(bool small) const - { - RM_D(Base); - return d->icon(small); - } + /** + * @brief Get a string that can be used to display this object + * + * @return Always ``. Reimplementations should return something more meaningful. + * + */ + QString Base::displayName() const + { + DPtrT d(this); + return d->displayName(); + } + + #if 0 // ###DEAD + /** + * @brief Get a context menu for this object + * + * @return A Heaven::Menu that can be used as context menu for this object. + * + */ + Heaven::Menu* Base::contextMenu() + { + RepoMan* rm = &MacGitver::repoMan(); + RepoMan::Private* rmp = BasePrivate::dataOf(rm); + return rmp->contextMenuFor(this); + } + #endif + + /** + * @brief Get an icon for this object + * + * @return A iconRef for this object + * + */ + Heaven::IconRef Base::icon(bool small) const + { + DPtrT d(this); + return d->icon(small); + } - bool Base::inheritsRepoManType(ObjTypes type) const - { - RM_CD(Base); - return d->inherits(type); } } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Base.hpp b/Libs/libMacGitverCore/RepoMan/Frontend/Base.hpp new file mode 100644 index 00000000..c2a3a586 --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Base.hpp @@ -0,0 +1,110 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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/RepoMan/Core.hpp" + +namespace RM +{ + + namespace Internal + { + class Dumper; + } + + namespace Data + { + class Base; + } + + namespace Frontend + { + + class MGV_CORE_API Base + { + public: + using List = std::vector; + using DPtrType = Data::Base; + + public: + Base(const std::shared_ptr& _d); + Base(std::shared_ptr&& _d); + virtual ~Base(); + Base(); + + public: + Base(const Base& other); + Base(Base&& other); + Base& operator=(const Base& other); + Base& operator=(Base&& other); + + bool operator==(const Base& other) const; + + operator bool() const; + + public: + ObjTypes objType() const; + bool inherits(ObjTypes type) const; + + public: + Repo repository() const; + Base parent() const; + + Heaven::IconRef icon(bool small = false) const; + + QString typeName() const; + QString displayName() const; + QString dump() const; + + Heaven::Menu* contextMenu(); + + std::shared_ptr data() const; + + template + T as() const; + + List children() const; + + protected: + std::shared_ptr mData; + + protected: + enum LockingMechanism { Locked, NotLocked }; + + private: + template + struct Locker; + + protected: + template + class DPtrT; + }; + + template + inline T Base::as() const + { + using Dest = typename T::DPtrType; + const Dest* p = std::static_pointer_cast(mData); + return T(p); + } + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/BaseInternal.hpp b/Libs/libMacGitverCore/RepoMan/Frontend/BaseInternal.hpp new file mode 100644 index 00000000..6e94ed4b --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Frontend/BaseInternal.hpp @@ -0,0 +1,121 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "RepoMan/Frontend/Base.hpp" +#include "RepoMan/Backend/RepoLocker.hpp" + +namespace RM +{ + namespace Frontend + { + + template + struct Base::Locker + { + /* constexpr */ Locker(const std::shared_ptr&) + {} + }; + + template<> + struct Base::Locker + : private Backend::RepoLocker + { + public: + Locker(const std::shared_ptr& t) + : Backend::RepoLocker(std::const_pointer_cast(t)) + {} + }; + + template + class Base::DPtrT + { + public: + using DPtrType = typename T::DPtrType; + + public: + DPtrT(T* that); + + public: + const DPtrType* operator->() const { return d.get(); } + DPtrType* operator->() { return d.get(); } + operator const DPtrType*() const { return d.get(); } + operator DPtrType*() { return d.get(); } + + private: + std::shared_ptr d; + Base::Locker l; + }; + + template + inline Base::DPtrT::DPtrT(T* that) + : d(std::static_pointer_cast(that->mData)) + , l(d->repository().lock()) + { + } + + template + class Base::DPtrT + { + public: + using DPtrType = typename T::DPtrType; + + public: + DPtrT(const T* that); + + public: + const DPtrType* operator->() const { return d.get(); } + operator const DPtrType*() const { return d.get(); } + + private: + std::shared_ptr d; + Base::Locker l; + }; + + template + inline Base::DPtrT::DPtrT(const T* that) + : d(std::static_pointer_cast(that->mData)) + , l(d->repository().lock()) + { + } + + template + inline typename T::List toFrontend(const typename T::DPtrType::SList& slist) + { + typename T::List frontendlist; + for (const typename T::DPtrType::SPtr& s : slist) { + frontendlist.push_back(T(s)); + } + return frontendlist; + } + + template + inline typename T::List toFrontend(const typename T::DPtrType::WList& wlist) + { + typename T::List frontendlist; + for (const typename T::DPtrType::WPtr& w : wlist) { + frontendlist.push_back(T(w.lock())); + } + return frontendlist; + } + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp index 2da6af24..032eb75d 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp @@ -17,61 +17,66 @@ * */ -#include "RepoMan/Branch.hpp" -#include "RepoMan/Repo.hpp" +#include "RepoMan/Frontend/Branch.hpp" +#include "RepoMan/Frontend/Repo.hpp" +#include "RepoMan/Frontend/Head.hpp" + #include "RepoMan/Events.hpp" -#include "RepoMan/Head.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/BranchData.hpp" +#include "RepoMan/Data/Branch.hpp" namespace RM { - using namespace Internal; - - Branch::Branch(Base* parent, const Git::Reference &ref) - : Ref( *new BranchPrivate(this, ref) ) + namespace Frontend { - RM_D(Branch); - d->linkToParent( parent ); - } - QString Branch::upstreamRefName() const - { - RM_CD(Branch); - return d->mUpstreamRefName; - } + #if 0 + Branch::Branch(Base* parent, const Git::Reference &ref) + : Reference( *new Data::Branch(this, ref) ) + { + RM_D(Branch); + d->linkToParent( parent ); + } - Ref* Branch::upstream() - { - return repository()->findReference(upstreamRefName()); - } + QString Branch::upstreamRefName() const + { + RM_CD(Branch); + return d->mUpstreamRefName; + } - bool Branch::hasUpstream() const - { - RM_CD(Branch); - return d->mHasUpstream; - } + Reference Branch::upstream() + { + return repository().findReference(upstreamRefName()); + } - int Branch::aheadCount() const - { - RM_CD(Branch); - return d->mAheadCount; - } + bool Branch::hasUpstream() const + { + RM_CD(Branch); + return d->mHasUpstream; + } - int Branch::behindCount() const - { - RM_CD(Branch); - return d->mBehindCount; - } + int Branch::aheadCount() const + { + RM_CD(Branch); + return d->mAheadCount; + } - bool Branch::isHead() const - { - const Repo* r = repository(); - const Head* h = r ? r->head() : NULL; - return h && h->is(this); + int Branch::behindCount() const + { + RM_CD(Branch); + return d->mBehindCount; + } + + bool Branch::isHead() const + { + const Repo* r = repository(); + const Head* h = r ? r->head() : NULL; + return h && h->is(this); + } + #endif } } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Branch.hpp b/Libs/libMacGitverCore/RepoMan/Frontend/Branch.hpp new file mode 100644 index 00000000..0e6c8f69 --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Branch.hpp @@ -0,0 +1,50 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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/RepoMan/Frontend/Reference.hpp" + +namespace RM +{ + + namespace Frontend + { + + class MGV_CORE_API Branch : public Reference + { + public: + static const ObjTypes StaticObjectType = ObjTypes::Branch; + typedef QVector List; + + public: + Branch(Base* parent, const Git::Reference& ref); + + public: + bool hasUpstream() const; + QString upstreamRefName() const; + Reference upstream(); + int aheadCount() const; + int behindCount() const; + bool isHead() const; + }; + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/CollectionNode.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/CollectionNode.cpp deleted file mode 100644 index e35ed1b0..00000000 --- a/Libs/libMacGitverCore/RepoMan/Frontend/CollectionNode.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2015 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "libHeavenIcons/IconRef.hpp" - -#include "RepoMan/CollectionNode.hpp" - -#include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/CollectionNodeData.hpp" - -namespace RM -{ - - using namespace Internal; - - CollectionNode::CollectionNode(CollectionTypes _ctype, Base* _parent) - : Base(*new CollectionNodePrivate(this, _ctype)) - { - RM_D(CollectionNode); - d->linkToParent(_parent); - } - - - CollectionTypes CollectionNode::collectionType() const - { - RM_CD(CollectionNode); - return d->ctype; - } - - QString CollectionNode::collectionTypeName() const - { - RM_CD(CollectionNode); - - switch (d->ctype) { - case ctBranches: return tr("Branches"); - case ctTags: return tr("Tags"); - case ctNamespaces: return tr("Namespaces"); - case ctNotes: return tr("Notes"); - default: return QString(); - } - } - - //-- CollectionNodePrivate --------------------------------------------------------------------- - - CollectionNodePrivate::CollectionNodePrivate(CollectionNode* _pub, CollectionTypes _ctype) - : BasePrivate(_pub) - , ctype(_ctype) - { - } - - ObjTypes CollectionNodePrivate::objType() const - { - return ObjTypes::CollectionNode; - } - - QString CollectionNodePrivate::displayName() const - { - return pub()->collectionTypeName(); - } - - void CollectionNodePrivate::dumpSelf(Internal::Dumper& dumper) const - { - dumper.addLine(QString(QStringLiteral("Collection '%2' 0x%1")) - .arg(quintptr(mPub),0,16) - .arg(displayName())); - } - - bool CollectionNodePrivate::refreshSelf() - { - return true; - } - - void CollectionNodePrivate::postCreation() - { - BasePrivate::postCreation(); - } - - void CollectionNodePrivate::preTerminate() - { - BasePrivate::preTerminate(); - } - - QString CollectionNodePrivate::objectTypeName() const - { - return QStringLiteral("CollectionNode"); - } - - Heaven::IconRef CollectionNodePrivate::icon(bool small) const - { - QString size = small ? QStringLiteral("@16") : QStringLiteral("@24"); - QString s; - - switch (ctype) { - case ctBranches: s = QStringLiteral("Branches"); break; - case ctTags: s = QStringLiteral("Tags"); break; - case ctNotes: s = QStringLiteral("Notes"); break; - case ctNamespaces: s = QStringLiteral("Namespaces"); break; - default: return Heaven::IconRef(); - } - - return Heaven::IconRef::fromString(QChar(L'#') % s % size); - } - - bool CollectionNodePrivate::inherits(ObjTypes type) const - { - return type == ObjTypes::CollectionNode || BasePrivate::inherits(type); - } - -} diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp index baeaef74..151ca34f 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp @@ -19,62 +19,70 @@ #include "RepoMan/Events.hpp" -#include "RepoMan/Head.hpp" +#include "RepoMan/Frontend/Head.hpp" +#include "RepoMan/Frontend/Repo.hpp" -#include "RepoMan/Data/HeadData.hpp" +#include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Branch.hpp" -#include "RepoMan/Repo.hpp" +#include "RepoMan/Data/Head.hpp" #include "libGitWrap/Repository.hpp" namespace RM { - Head::Head(const Git::Repository& repo, Base* parent) - : Base(*new Internal::HeadPrivate(this, repo)) + namespace Frontend { - RM_D(Head); - d->linkToParent(parent); - } - QString Head::symbolicName() const - { - RM_CD(Head); - if (d->isDetached) { - return QString(); + #if 0 + Head::Head(const Git::Repository& repo, Base* parent) + : Base(*new Internal::HeadPrivate(this, repo)) + { + RM_D(Head); + d->linkToParent(parent); } - return d->symbolicName; - } - bool Head::isDetached() const - { - RM_CD(Head); - return d->isDetached; - } + QString Head::symbolicName() const + { + RM_CD(Head); + if (d->isDetached) { + return QString(); + } + return d->symbolicName; + } - bool Head::isUnborn() const - { - RM_CD(Head); - return d->isUnborn; - } + bool Head::isDetached() const + { + RM_CD(Head); + return d->isDetached; + } - Git::ObjectId Head::detachedId() const - { - RM_CD(Head); - return d->detachedId; - } + bool Head::isUnborn() const + { + RM_CD(Head); + return d->isUnborn; + } - bool Head::is(const Branch* ref) const - { - RM_CD(Head); + Git::ObjectId Head::detachedId() const + { + RM_CD(Head); + return d->detachedId; + } + + bool Head::is(const Branch* ref) const + { + RM_CD(Head); - if (d->isDetached || d->isUnborn) { - /* If it's unborn, it cannot match an existing branch anyway */ - return false; + if (d->isDetached || d->isUnborn) { + /* If it's unborn, it cannot match an existing branch anyway */ + return false; + } + + return ref && d->symbolicName == ref->fullName(); } - return ref && d->symbolicName == ref->fullName(); + #endif + } } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Head.hpp b/Libs/libMacGitverCore/RepoMan/Frontend/Head.hpp new file mode 100644 index 00000000..b966521f --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Head.hpp @@ -0,0 +1,56 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "RepoMan/Frontend/Branch.hpp" + +namespace RM +{ + + namespace Data + { + class Head; + } + + namespace Frontend + { + class MGV_CORE_API Head : public Base + { + public: + static const ObjTypes StaticObjectType = ObjTypes::Head; + typedef Data::Head Private; + typedef QVector List; + + public: + Head(const Git::Repository& repo, Base* parent); + + public: + bool isDetached() const; + bool isUnborn() const; + Git::ObjectId detachedId() const; + QString symbolicName() const; + + public: + bool is(const Branch* ref) const; + }; + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Namespace.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Namespace.cpp index 2428b8e8..824051a6 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Namespace.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Namespace.cpp @@ -19,57 +19,63 @@ #include "RepoMan/Events.hpp" -#include "RepoMan/Namespace.hpp" +#include "RepoMan/Frontend/Namespace.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/NamespaceData.hpp" +#include "RepoMan/Data/Namespace.hpp" namespace RM { - using namespace Internal; - - Namespace::Namespace(Base* _parent, const QString& _name) - : Base(*new NamespacePrivate(this, _name)) + namespace Frontend { - RM_D(Namespace); - d->linkToParent(_parent); - } - CollectionNode* Namespace::branches() - { - RM_D(Namespace); + #if 0 + Namespace::Namespace(Base* _parent, const QString& _name) + : Base(*new NamespacePrivate(this, _name)) + { + RM_D(Namespace); + d->linkToParent(_parent); + } - return d->getOrCreateCollection( ctBranches ); - } + CollectionNode* Namespace::branches() + { + RM_D(Namespace); - CollectionNode* Namespace::tags() - { - RM_D(Namespace); - return d->getOrCreateCollection( ctTags ); - } + return d->getOrCreateCollection( ctBranches ); + } - CollectionNode* Namespace::namespaces() - { - RM_D(Namespace); + CollectionNode* Namespace::tags() + { + RM_D(Namespace); + return d->getOrCreateCollection( ctTags ); + } - return d->getOrCreateCollection( ctNamespaces ); - } + CollectionNode* Namespace::namespaces() + { + RM_D(Namespace); - CollectionNode* Namespace::notes() - { - RM_D(Namespace); + return d->getOrCreateCollection( ctNamespaces ); + } - return d->getOrCreateCollection( ctNotes ); - } + CollectionNode* Namespace::notes() + { + RM_D(Namespace); - QString Namespace::name() const - { - RM_D(Namespace); + return d->getOrCreateCollection( ctNotes ); + } + + QString Namespace::name() const + { + RM_D(Namespace); + + return d->name; + } + #endif - return d->name; } +#if 0 //-- NamespacePrivate -------------------------------------------------------------------------- NamespacePrivate::NamespacePrivate(Namespace* _pub, const QString& _name) @@ -128,4 +134,6 @@ namespace RM return type == ObjTypes::Namespace || BasePrivate::inherits(type); } + #endif + } diff --git a/Libs/libMacGitverCore/RepoMan/Data/HeadData.hpp b/Libs/libMacGitverCore/RepoMan/Frontend/Namespace.hpp similarity index 56% rename from Libs/libMacGitverCore/RepoMan/Data/HeadData.hpp rename to Libs/libMacGitverCore/RepoMan/Frontend/Namespace.hpp index 92f09ddb..7390c86a 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/HeadData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Namespace.hpp @@ -19,36 +19,40 @@ #pragma once -#include "RepoMan/Data/BaseData.hpp" - -#include "RepoMan/Head.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Base.hpp" namespace RM { - namespace Internal + namespace Data + { + class Namespace; + } + + namespace Frontend { - class HeadPrivate : public BasePrivate + class MGV_CORE_API Namespace : public Base { public: - HeadPrivate(Head* pub, const Git::Repository& ref); + static const ObjTypes StaticObjectType = ObjTypes::Namespace; + typedef Data::Namespace Private; + typedef QVector List; public: - ObjTypes objType() const; - bool refreshSelf(); - QString displayName() const; - void dumpSelf(Internal::Dumper& dumper) const; - QString objectTypeName() const; - bool inherits(ObjTypes type) const; + Namespace(Base* parent, const QString& _name); public: - QString symbolicName; - Git::ObjectId detachedId; - bool isDetached : 1; - bool isUnborn : 1; - }; + QString name() const; + #if 0 // ###DEAD + public: + CollectionNode* branches(); + CollectionNode* namespaces(); + CollectionNode* notes(); + CollectionNode* tags(); + #endif + }; } } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/RefLog.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/RefLog.cpp index e5c6b79f..e952d18c 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/RefLog.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/RefLog.cpp @@ -17,65 +17,79 @@ * */ -#include "RepoMan/RefLog.hpp" +#include "RepoMan/Frontend/RefLog.hpp" + +#include "RepoMan/Data/RefLog.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/RefLogData.hpp" namespace RM { - using namespace Internal; - - RefLog::RefLog(Base* _parent) - : Base(*new RefLogPrivate(this)) + namespace Frontend { - RM_D(RefLog); - d->linkToParent(_parent); - } - //-- RefLogPrivate ----------------------------------------------------------------------------- + #if 0 - RefLogPrivate::RefLogPrivate(RefLog* _pub) - : BasePrivate(_pub) - { - } + RefLog::RefLog(Base* _parent) + : Base(*new RefLogPrivate(this)) + { + RM_D(RefLog); + d->linkToParent(_parent); + } - ObjTypes RefLogPrivate::objType() const - { - return ObjTypes::RefLog; - } + #endif - void RefLogPrivate::dumpSelf(Internal::Dumper& dumper) const - { - dumper.addLine(QString(QStringLiteral("RefLog 0x%1")) - .arg(quintptr(mPub),0,16)); } - void RefLogPrivate::postCreation() + namespace Data { - BasePrivate::postCreation(); - } - void RefLogPrivate::preTerminate() - { - // What to do? We don't send Ref-Log-Deleted events - BasePrivate::preTerminate(); - } + #if 0 - bool RefLogPrivate::refreshSelf() - { - return true; - } + RefLogPrivate::RefLogPrivate(RefLog* _pub) + : BasePrivate(_pub) + { + } - QString RefLogPrivate::objectTypeName() const - { - return QStringLiteral("RefLog"); - } + ObjTypes RefLogPrivate::objType() const + { + return RefLogObject; + } - bool RefLogPrivate::inherits(ObjTypes type) const - { - return type == ObjTypes::RefLog || BasePrivate::inherits(type); + void RefLogPrivate::dumpSelf(Internal::Dumper& dumper) const + { + dumper.addLine(QString(QLatin1String("RefLog 0x%1")) + .arg(quintptr(mPub),0,16)); + } + + void RefLogPrivate::postCreation() + { + BasePrivate::postCreation(); + } + + void RefLogPrivate::preTerminate() + { + // What to do? We don't send Ref-Log-Deleted events + BasePrivate::preTerminate(); + } + + bool RefLogPrivate::refreshSelf() + { + return true; + } + + QString RefLogPrivate::objectTypeName() const + { + return QLatin1String("RefLog"); + } + + bool RefLogPrivate::inherits(ObjTypes type) const + { + return type == RefLogObject || BasePrivate::inherits(type); + } + + #endif } } diff --git a/Libs/libMacGitverCore/RepoMan/RefLog.hpp b/Libs/libMacGitverCore/RepoMan/Frontend/RefLog.hpp similarity index 66% rename from Libs/libMacGitverCore/RepoMan/RefLog.hpp rename to Libs/libMacGitverCore/RepoMan/Frontend/RefLog.hpp index 0879a024..231d56d6 100644 --- a/Libs/libMacGitverCore/RepoMan/RefLog.hpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/RefLog.hpp @@ -19,24 +19,30 @@ #pragma once -#include "Base.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Base.hpp" namespace RM { - namespace Internal + namespace Data { - class RefLogPrivate; + class RefLog; } - class MGV_CORE_API RefLog : public Base + namespace Frontend { - public: - static const ObjTypes StaticObjectType = ObjTypes::RefLog; - typedef Internal::RefLogPrivate Private; - public: - RefLog(Base* _parent); - }; + class MGV_CORE_API RefLog + : public Base + { + public: + static const ObjTypes StaticObjectType = ObjTypes::RefLog; + typedef Data::RefLog Private; + + public: + RefLog(Base* _parent); + }; + + } } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.cpp index 5171f49d..5a3b115c 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.cpp @@ -19,93 +19,102 @@ #include "RepoMan/Events.hpp" -#include "RepoMan/RefTreeNode.hpp" +#include "RepoMan/Frontend/RefTreeNode.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/RefTreeNodeData.hpp" +#include "RepoMan/Data/RefTreeNode.hpp" namespace RM { - using namespace Internal; - - RefTreeNode::RefTreeNode(Base* _parent, const QString& _name) - : Base(*new RefTreeNodePrivate(this, _name)) + namespace Frontend { - RM_D(RefTreeNode); - d->linkToParent(_parent); - } - QString RefTreeNode::name() const - { - RM_D(RefTreeNode); + #if 0 + RefTreeNode::RefTreeNode(Base* _parent, const QString& _name) + : Base(*new RefTreeNodePrivate(this, _name)) + { + RM_D(RefTreeNode); + d->linkToParent(_parent); + } - return d->name; - } + QString RefTreeNode::name() const + { + RM_D(RefTreeNode); - //-- RefTreeNodePrivate ------------------------------------------------------------------------ + return d->name; + } + #endif - RefTreeNodePrivate::RefTreeNodePrivate(RefTreeNode* _pub, const QString& _name) - : BasePrivate(_pub) - , name(_name) - { } - ObjTypes RefTreeNodePrivate::objType() const + namespace Data { - return ObjTypes::RefTreeNode; - } + #if 0 + RefTreeNodePrivate::RefTreeNodePrivate(RefTreeNode* _pub, const QString& _name) + : BasePrivate(_pub) + , name(_name) + { + } - void RefTreeNodePrivate::dumpSelf(Dumper& dumper) const - { - dumper.addLine(QString(QStringLiteral("RefTreeNode 0x%1 [%2]")) - .arg(quintptr(mPub),0,16) - .arg(name)); - } + ObjTypes RefTreeNodePrivate::objType() const + { + return RefTreeNodeObject; + } - void RefTreeNodePrivate::postCreation() - { - if (!repoEventsBlocked()) { - Events::self()->refTreeNodeCreated(repository(), pub()); + void RefTreeNodePrivate::dumpSelf(Dumper& dumper) const + { + dumper.addLine(QString(QLatin1String("RefTreeNode 0x%1 [%2]")) + .arg(quintptr(mPub),0,16) + .arg(name)); } - BasePrivate::postCreation(); - } + void RefTreeNodePrivate::postCreation() + { + if (!repoEventsBlocked()) { + Events::self()->refTreeNodeCreated(repository(), pub()); + } - void RefTreeNodePrivate::preTerminate() - { - if (!repoEventsBlocked()) { - Events::self()->refTreeNodeAboutToBeDeleted(repository(), pub()); + BasePrivate::postCreation(); } - BasePrivate::preTerminate(); - } + void RefTreeNodePrivate::preTerminate() + { + if (!repoEventsBlocked()) { + Events::self()->refTreeNodeAboutToBeDeleted(repository(), pub()); + } - QString RefTreeNodePrivate::displayName() const - { - return name; - } + BasePrivate::preTerminate(); + } - bool RefTreeNodePrivate::refreshSelf() - { - // We don't have anything to refresh - we're purely virutual - return true; - } + QString RefTreeNodePrivate::displayName() const + { + return name; + } - bool RefTreeNodePrivate::refreshCheckDispensable() - { - return mChildren.isEmpty(); - } + bool RefTreeNodePrivate::refreshSelf() + { + // We don't have anything to refresh - we're purely virutual + return true; + } - QString RefTreeNodePrivate::objectTypeName() const - { - return QStringLiteral("RefTreeNode"); - } + bool RefTreeNodePrivate::refreshCheckDispensable() + { + return mChildren.isEmpty(); + } + + QString RefTreeNodePrivate::objectTypeName() const + { + return QLatin1String("RefTreeNode"); + } + + bool RefTreeNodePrivate::inherits(ObjTypes type) const + { + return type == RefTreeNodeObject || BasePrivate::inherits(type); + } + #endif - bool RefTreeNodePrivate::inherits(ObjTypes type) const - { - return type == ObjTypes::RefTreeNode || BasePrivate::inherits(type); } } diff --git a/Libs/libMacGitverCore/RepoMan/RefTreeNode.hpp b/Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.hpp similarity index 63% rename from Libs/libMacGitverCore/RepoMan/RefTreeNode.hpp rename to Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.hpp index 1084fc7f..9a8935f9 100644 --- a/Libs/libMacGitverCore/RepoMan/RefTreeNode.hpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.hpp @@ -19,9 +19,9 @@ #pragma once -#include +#include "libMacGitverCore/RepoMan/Frontend/Base.hpp" -#include "Base.hpp" +#include namespace RM { @@ -31,18 +31,24 @@ namespace RM class RefTreeNodePrivate; } - class MGV_CORE_API RefTreeNode : public Base + namespace Frontend { - public: - static const ObjTypes StaticObjectType = ObjTypes::RefTreeNode; - typedef Internal::RefTreeNodePrivate Private; - typedef QList< RefTreeNode* > List; - public: - RefTreeNode(Base* _parent, const QString& _name); + class MGV_CORE_API RefTreeNode + : public Base + { + public: + static const ObjTypes StaticObjectType = ObjTypes::RefTreeNode; + typedef Internal::RefTreeNodePrivate Private; + typedef QList< RefTreeNode* > List; + + public: + RefTreeNode(Base* _parent, const QString& _name); - public: - QString name() const; - }; + public: + QString name() const; + }; + + } } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Ref.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Reference.cpp similarity index 55% rename from Libs/libMacGitverCore/RepoMan/Frontend/Ref.cpp rename to Libs/libMacGitverCore/RepoMan/Frontend/Reference.cpp index 708d8966..926a6e30 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Ref.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Reference.cpp @@ -23,75 +23,90 @@ #include "RepoMan/Events.hpp" -#include "RepoMan/Ref.hpp" -#include "RepoMan/Repo.hpp" +#include "RepoMan/Frontend/BaseInternal.hpp" +#include "RepoMan/Frontend/Reference.hpp" +#include "RepoMan/Frontend/Repo.hpp" + +#include "RepoMan/Data/Reference.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/RefData.hpp" namespace RM { - //-- Ref --8> - - Ref::Ref(Internal::RefPrivate& data) - : Base( data ) + namespace Frontend { - } - Ref::Ref(Base* parent, RefTypes type, const Git::Reference& ref) - : Base( *new Internal::RefPrivate( this, type, ref ) ) - { - RM_D( Ref ); - d->linkToParent( parent ); - } + #if 0 - RefTypes Ref::type() const - { - RM_CD(Ref); - return d->mType; - } + Reference::Reference(Data::Reference* data) + : Base(data) + { + } - QString Ref::name() const - { - RM_CD(Ref); - return d->mName; - } + Reference::Reference(Base* parent, RefTypes type, const Git::Reference& ref) + : Base( *new Internal::RefPrivate( this, type, ref ) ) + { + RM_D(Reference); + d->linkToParent( parent ); + } + #endif - QString Ref::fullName() const - { - RM_CD(Ref); - return d->mFullQualifiedName; - } + RefTypes Reference::type() const + { + DPtrT d(this); + return d->mType; + } - Git::ObjectId Ref::id() const - { - RM_CD(Ref); - return d->mId; - } + QString Reference::name() const + { + DPtrT d(this); + return d->mName; + } - QString Ref::displaySha1() const - { - return id().toString(8); - } + QString Reference::fullName() const + { + DPtrT d(this); + return d->mFullQualifiedName; + } - Git::Reference Ref::load(Git::Result& r) - { - RM_D(Ref); - Git::Reference gitRef; + Git::ObjectId Reference::id() const + { + DPtrT d(this); + return d->mId; + } + + QString Reference::displaySha1() const + { + return id().toString(8); + } + + #if 0 + + Git::Reference Reference::load(Git::Result& r) + { + RM_D(Ref); + Git::Reference gitRef; + + if (r) { + Git::Repository repo = repository()->gitRepo(); + gitRef = repo.reference(r, d->mFullQualifiedName); + } - if (r) { - Git::Repository repo = repository()->gitRepo(); - gitRef = repo.reference(r, d->mFullQualifiedName); + return gitRef; } - return gitRef; + #endif + } - namespace Internal + + namespace Data { - RefPrivate::RefPrivate(Ref* pub, RefTypes type, const Git::Reference& ref) + #if 0 + + ReferencePrivate::ReferencePrivate(Reference* pub, RefTypes type, const Git::Reference& ref) : BasePrivate( pub ) , mType( type ) , mFullQualifiedName( ref.name() ) @@ -100,36 +115,36 @@ namespace RM { } - void RefPrivate::dumpSelf(Internal::Dumper& dumper) const + void ReferencePrivate::dumpSelf(Internal::Dumper& dumper) const { dumper.addLine(QString(QStringLiteral("Ref 0x%1 [%2]")) .arg(quintptr(mPub),0,16) .arg(mName)); } - ObjTypes RefPrivate::objType() const + ObjTypes ReferencePrivate::objType() const { return ObjTypes::Reference; } - QString RefPrivate::displayName() const + QString ReferencePrivate::displayName() const { return mName; } - QString RefPrivate::objectTypeName() const + QString ReferencePrivate::objectTypeName() const { return QStringLiteral("Ref"); } - bool RefPrivate::inherits(ObjTypes type) const + bool ReferencePrivate::inherits(ObjTypes type) const { return type == ObjTypes::Reference || BasePrivate::inherits(type); } - void RefPrivate::postCreation() + void ReferencePrivate::postCreation() { - RM_P(Ref); + RM_P(Reference); if (!repoEventsBlocked()) { Events::self()->refCreated(repository(), p); @@ -138,9 +153,9 @@ namespace RM BasePrivate::postCreation(); } - void RefPrivate::preTerminate() + void ReferencePrivate::preTerminate() { - RM_P(Ref); + RM_P(Reference); if ( !repoEventsBlocked() ) { Events::self()->refAboutToBeDeleted(repository(), p); @@ -149,14 +164,14 @@ namespace RM BasePrivate::preTerminate(); } - void RefPrivate::emitMoved() + void ReferencePrivate::emitMoved() { if (!repoEventsBlocked()) { Events::self()->refMoved(repository(), pub()); } } - bool RefPrivate::refreshDetails(const Git::Reference& ref) + bool ReferencePrivate::refreshDetails(const Git::Reference& ref) { Git::ObjectId id = ref.objectId(); @@ -170,7 +185,7 @@ namespace RM return true; } - bool RefPrivate::refreshSelf() + bool ReferencePrivate::refreshSelf() { Git::Result r; Repo* repo = repository(); Q_ASSERT( repo ); @@ -188,6 +203,8 @@ namespace RM return true; } + #endif + } } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Reference.hpp b/Libs/libMacGitverCore/RepoMan/Frontend/Reference.hpp new file mode 100644 index 00000000..959eb445 --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Reference.hpp @@ -0,0 +1,82 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libGitWrap/ObjectId.hpp" + +#include "Base.hpp" + +namespace RM +{ + + namespace Data + { + class Reference; + } + + enum RefTypes + { + BranchType, + TagType + }; + + namespace Frontend + { + + class MGV_CORE_API Reference + : public Base + { + public: + static const ObjTypes StaticObjectType = ObjTypes::Reference; + using DPtrType = Data::Reference; + using List = QList; + + protected: + Reference(Data::Reference* data); + + public: + Reference(); + + public: + GW_DEPRECATED + Reference(Base* parent, RefTypes type, const Git::Reference& ref); + + GW_DEPRECATED + Git::Reference load(Git::Result& r); + + public: + RefTypes type() const; + QString name() const; + QString fullName() const; + Git::ObjectId id() const; + QString displaySha1() const; + }; + + inline Reference::Reference() + : Base() + { + } + + GW_DEPRECATED + typedef Reference Ref; + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Remote.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Remote.cpp index a4f108ed..705bbc4a 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Remote.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Remote.cpp @@ -21,106 +21,117 @@ #include "RepoMan/Events.hpp" -#include "RepoMan/Repo.hpp" -#include "RepoMan/Remote.hpp" -#include "RepoMan/CollectionNode.hpp" +#include "RepoMan/Frontend/Repo.hpp" +#include "RepoMan/Frontend/Remote.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/RemoteData.hpp" +#include "RepoMan/Data/Remote.hpp" namespace RM { - using namespace Internal; - - Remote::Remote(const Git::Remote& gitObj, Base* _parent) - : Base(*new RemotePrivate(this, gitObj)) + namespace Frontend { - RM_D(Remote); - d->linkToParent(_parent); - } + #if 0 - Git::Remote Remote::gitObject() - { - Git::Result r; - return repository()->gitRepo().remote(r, name()); - } + Remote::Remote(const Git::Remote& gitObj, Base* _parent) + : Base(*new RemotePrivate(this, gitObj)) + { + RM_D(Remote); - QString Remote::name() const - { - RM_D(Remote); + d->linkToParent(_parent); + } - return d->name; - } + Git::Remote Remote::gitObject() + { + Git::Result r; + return repository()->gitRepo().remote(r, name()); + } - CollectionNode* Remote::branches() - { - RM_D(Remote); + QString Remote::name() const + { + RM_D(Remote); + + return d->name; + } + CollectionNode* Remote::branches() + { + RM_D(Remote); - // ### We don't use this when filling up the branches, yet. - return d->getOrCreateCollection(ctBranches); - } - //-- RemotePrivate ----------------------------------------------------------------------------- + // ### We don't use this when filling up the branches, yet. + return d->getOrCreateCollection(ctBranches); + } - RemotePrivate::RemotePrivate(Remote* _pub, const Git::Remote& _obj) - : BasePrivate(_pub) - { - name = _obj.name(); - } + #endif - ObjTypes RemotePrivate::objType() const - { - return ObjTypes::Remote; } - void RemotePrivate::dumpSelf(Internal::Dumper& dumper) const + namespace Data { - dumper.addLine(QString(QStringLiteral("Remote %2 0x%1")) - .arg(quintptr(mPub),0,16) - .arg(name)); - } - void RemotePrivate::postCreation() - { - if (!repoEventsBlocked()) { - Events::self()->remoteCreated(repository(), pub()); + #if 0 + + RemotePrivate::RemotePrivate(Remote* _pub, const Git::Remote& _obj) + : BasePrivate(_pub) + { + name = _obj.name(); } - BasePrivate::postCreation(); - } + ObjTypes RemotePrivate::objType() const + { + return RemoteObject; + } - void RemotePrivate::preTerminate() - { - if (!repoEventsBlocked()) { - Events::self()->remoteAboutToBeDeleted(repository(), pub()); + void RemotePrivate::dumpSelf(Internal::Dumper& dumper) const + { + dumper.addLine(QString(QLatin1String("Remote %2 0x%1")) + .arg(quintptr(mPub),0,16) + .arg(name)); } - BasePrivate::preTerminate(); - } + void RemotePrivate::postCreation() + { + if (!repoEventsBlocked()) { + Events::self()->remoteCreated(repository(), pub()); + } - QString RemotePrivate::displayName() const - { - return name; - } + BasePrivate::postCreation(); + } + void RemotePrivate::preTerminate() + { + if (!repoEventsBlocked()) { + Events::self()->remoteAboutToBeDeleted(repository(), pub()); + } - bool RemotePrivate::refreshSelf() - { - return true; - } + BasePrivate::preTerminate(); + } - QString RemotePrivate::objectTypeName() const - { - return QStringLiteral("Remote"); - } + QString RemotePrivate::displayName() const + { + return name; + } - bool RemotePrivate::inherits(ObjTypes type) const - { - return type == ObjTypes::Remote || BasePrivate::inherits(type); + bool RemotePrivate::refreshSelf() + { + return true; + } + + QString RemotePrivate::objectTypeName() const + { + return QLatin1String("Remote"); + } + + bool RemotePrivate::inherits(ObjTypes type) const + { + return type == RemoteObject || BasePrivate::inherits(type); + } + + #endif } } diff --git a/Libs/libMacGitverCore/RepoMan/Data/CollectionNodeData.hpp b/Libs/libMacGitverCore/RepoMan/Frontend/Remote.hpp similarity index 57% rename from Libs/libMacGitverCore/RepoMan/Data/CollectionNodeData.hpp rename to Libs/libMacGitverCore/RepoMan/Frontend/Remote.hpp index da4ba2c2..106a03e9 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/CollectionNodeData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Remote.hpp @@ -19,34 +19,38 @@ #pragma once -#include "RepoMan/Data/BaseData.hpp" +#include "libGitWrap/Remote.hpp" -#include "RepoMan/CollectionNode.hpp" +#include "libMacGitverCore/Repoman/Frontend/Base.hpp" namespace RM { - namespace Internal + namespace Data + { + class Remote; + } + + namespace Frontend { - class CollectionNodePrivate : public BasePrivate + class MGV_CORE_API Remote : public Base { public: - CollectionNodePrivate(CollectionNode* _pub, CollectionTypes _ctype); + static const ObjTypes StaticObjectType = ObjTypes::Remote; + typedef Data::Remote Private; + typedef QVector List; public: - ObjTypes objType() const; - bool refreshSelf(); - void postCreation(); - void preTerminate(); - QString displayName() const; - void dumpSelf(Dumper& dumper) const; - QString objectTypeName() const; - Heaven::IconRef icon(bool small) const; - bool inherits(ObjTypes type) const; + Remote(const Git::Remote& gitObj, Base* parent); public: - CollectionTypes ctype; + GW_DEPRECATED + Git::Remote gitObject(); + QString name() const; + #if 0 // ###DEAD + CollectionNode* branches(); + #endif }; } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Repo.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Repo.cpp index 45e7cd55..3025b83f 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Repo.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Repo.cpp @@ -17,9 +17,6 @@ * */ -#include -#include - #include "libGitWrap/Reference.hpp" #include "libGitWrap/ObjectId.hpp" #include "libGitWrap/RefName.hpp" @@ -28,732 +25,659 @@ #include "libMacGitverCore/App/MacGitver.hpp" #include "RepoMan/Events.hpp" -#include "RepoMan/Repo.hpp" #include "RepoMan/RepoMan.hpp" -#include "RepoMan/Head.hpp" -#include "RepoMan/Remote.hpp" -#include "RepoMan/Namespace.hpp" -#include "RepoMan/Ref.hpp" -#include "RepoMan/Tag.hpp" -#include "RepoMan/Branch.hpp" -#include "RepoMan/Submodule.hpp" + +#include "RepoMan/Frontend/BaseInternal.hpp" +#include "RepoMan/Frontend/Repo.hpp" +#include "RepoMan/Frontend/Head.hpp" +#include "RepoMan/Frontend/Remote.hpp" +#include "RepoMan/Frontend/Namespace.hpp" +#include "RepoMan/Frontend/Reference.hpp" +#include "RepoMan/Frontend/Tag.hpp" +#include "RepoMan/Frontend/Branch.hpp" +#include "RepoMan/Frontend/Submodule.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/RepoData.hpp" -#include "RepoMan/Data/RemoteData.hpp" -#include "RepoMan/Data/CollectionNodeData.hpp" +#include "RepoMan/Data/Repo.hpp" +#include "RepoMan/Data/Head.hpp" +#include "RepoMan/Data/Remote.hpp" + +#include namespace RM { - using namespace Internal; - - Repo::Repo(RepoPrivate& _d) - : Base(_d) - { - } - - Repo::Repo(const Git::Repository& repo, Base* parent) - : Base( *new RepoPrivate(this, repo) ) - { - RM_D(Repo); - - d->linkToParent(parent); - d->refresh(); - - d->mIsInitializing = false; - } - - Repo::~Repo() - { - } - - Git::Repository Repo::gitRepo() - { - RM_D(Repo); - return d->gitRepo(true); - } - - Git::Repository Repo::gitLoadedRepo() - { - RM_D(Repo); - return d->gitRepo(); - } - - QString Repo::path() const - { - RM_CD(Repo); - - return d->mPath; - } - - bool Repo::isSubModule() const + namespace Frontend { - RM_CD(Repo); - return d->mIsSubModule; - } - - bool Repo::isBare() const - { - RM_CD(Repo); - - return d->mIsBare; - } + Repo::Repo(const std::shared_ptr& o) + : Base(std::move(std::shared_ptr(o))) + { + } - bool Repo::isLoaded() const - { - RM_CD(Repo); + Repo::Repo(std::shared_ptr&& o) + : Base(std::shared_ptr(std::move(o))) + { + } - return d->mIsLoaded; - } +#if 0 + Git::Repository Repo::gitRepo() + { + RM_D(Repo); + return d->gitRepo(true); + } - bool Repo::isActive() const - { - RM_CD(Repo); + Git::Repository Repo::gitLoadedRepo() + { + RM_D(Repo); + return d->gitRepo(); + } +#endif - return d->mIsActive; - } + QString Repo::path() const + { + DPtrT d(this); + return d->path(); + } - /** - * @brief Are we in initialization phase? - * - * @return `true` if we're still doing an initial seed with repository objects. In this - * case no events for new or changed objects shall be sent out to any listeners. - * - */ - bool Repo::isInitializing() const - { - RM_CD(Repo); + bool Repo::isSubModule() const + { + DPtrT d(this); + return d->mIsSubModule; + } - return d->mIsInitializing; - } + bool Repo::isBare() const + { + DPtrT d(this); + return d->mIsBare; + } - Repo* Repo::parentRepository() - { - Base* p = parentObject(); + bool Repo::isLoaded() const + { + DPtrT d(this); + return d->mIsLoaded; + } - if (!p) { - return NULL; + bool Repo::isActive() const + { + DPtrT d(this); + return d && d->mIsActive; } - if (p->inheritsRepoManType(ObjTypes::Repo)) { - return static_cast(p); + Repo Repo::parentRepository() + { + DPtrT d(this); + return d->parent()->as(); } - return NULL; - } + Repo::List Repo::submodules() const + { + DPtrT d(this); + return toFrontend(d->submodules()); + } - Repo::List Repo::submodules() const - { - return childObjects(); - } + void Repo::activated() + { + DPtrT d(this); - void Repo::activated() - { - // ### Should be very private - RM_D(Repo); - Q_ASSERT(!d->mIsActive); + Q_ASSERT(!d->mIsActive); - if (d->mUnloadTimer) { - d->mUnloadTimer->stop(); - d->mUnloadTimer->deleteLater(); - d->mUnloadTimer = NULL; +#if 0 + if (d->mUnloadTimer) { + d->mUnloadTimer->stop(); + d->mUnloadTimer->deleteLater(); + d->mUnloadTimer = NULL; + } +#endif + d->mIsActive = true; } - d->mIsActive = true; - } + void Repo::deactivated() + { + DPtrT d(this); - void Repo::deactivated() - { - // ### Should be very private - RM_D(Repo); - Q_ASSERT(d->mIsActive); + Q_ASSERT(d->mIsActive); +#if 0 + Q_ASSERT(!d->mUnloadTimer); - Q_ASSERT(!d->mUnloadTimer); - d->mUnloadTimer = new QTimer(this); - connect(d->mUnloadTimer, SIGNAL(timeout()), this, SLOT(unloadTimer())); - d->mUnloadTimer->setInterval(15 * 60 * 1000); // quarter of an hour - d->mUnloadTimer->start(); + d->mUnloadTimer = new QTimer(this); + connect(d->mUnloadTimer, SIGNAL(timeout()), this, SLOT(unloadTimer())); + d->mUnloadTimer->setInterval(15 * 60 * 1000); // quarter of an hour + d->mUnloadTimer->start(); +#endif - d->mIsActive = false; - } - - QString Repo::displayAlias() const - { - RM_CD(Repo); + d->mIsActive = false; + } - return d->mDisplayAlias; - } + QString Repo::displayAlias() const + { + DPtrT d(this); + return d->mDisplayAlias; + } - void Repo::setDisplayAlias(const QString& alias) - { - RM_D(Repo); + void Repo::setDisplayAlias(const QString& alias) + { +#if 0 + RM_D(Repo); - if (d->mDisplayAlias != alias) { - d->mDisplayAlias = alias; - // ###REPOMAN Create new Event "RepoAliasChanged" - // emit aliasChanged(alias); + if (d->mDisplayAlias != alias) { + d->mDisplayAlias = alias; + // ###REPOMAN Create new Event "RepoAliasChanged" + // emit aliasChanged(alias); + } +#endif } - } +#if 0 + void Repo::unloadTimer() + { + RM_D(Repo); + d->unload(); + } +#endif - void Repo::unloadTimer() - { - RM_D(Repo); - d->unload(); - } + void Repo::close() + { + #if 0 + RM_D(Repo); - void Repo::close() - { - RM_D(Repo); + if (d->mIsActive) { + MacGitver::repoMan().activate(NULL); + } - if (d->mIsActive) { - MacGitver::repoMan().activate(NULL); - } + Events::self()->repositoryAboutToClose(this); - Events::self()->repositoryAboutToClose(this); + foreach (Repo* child, submodules()) { + child->close(); + } - foreach (Repo* child, submodules()) { - child->close(); + d->terminateObject(); + #endif } - d->terminateObject(); - } + QString Repo::branchDisplay() const + { + // TODO: This method is totally wrong placed here + DPtrT d(this); - QString Repo::branchDisplay() const - { - // TODO: This method is totally wrong placed here - RM_D(Repo); + if (d->mIsLoaded && d->mHead) { - if (d->mIsLoaded && d->mHead) { + if (d->mHead->isDetached()) { + return QObject::tr("detached at %1" ).arg(d->mHead->detachedId().toString()); + } - if (d->mHead->isDetached()) { - return tr("detached at %1" ).arg(d->mHead->detachedId().toString()); - } + if (d->mHead->isUnborn()) { + return QObject::tr("Branch yet to be born"); + } - if (d->mHead->isUnborn()) { - return tr("Branch yet to be born"); + return QObject::tr("%1" ).arg(d->mHead->symbolicName().mid(11)); } + return QObject::tr("<unknown>"); + } - return tr("%1" ).arg(d->mHead->symbolicName().mid(11)); +#if 0 + Ref* Repo::findReference(const Git::Reference& ref) + { + RM_D(Repo); + return d->findReference(ref, false); } - return tr("<unknown>"); - } - Ref* Repo::findReference(const Git::Reference& ref) - { - RM_D(Repo); - return d->findReference(ref, false); - } + Ref* Repo::findReference(const QString &fqrn) + { + RM_D(Repo); + return d->findReference(fqrn, false); + } - Ref* Repo::findReference(const QString &fqrn) - { - RM_D(Repo); - return d->findReference(fqrn, false); - } + Remote* Repo::findRemote(const Git::Remote& remote) + { + RM_D(Repo); + return d->findRemote(remote, false); + } - Remote* Repo::findRemote(const Git::Remote& remote) - { - RM_D(Repo); - return d->findRemote(remote, false); - } + Remote* Repo::findRemote(const QString& remoteName) + { + RM_D(Repo); + return d->findRemote(remoteName, false); + } - Remote* Repo::findRemote(const QString& remoteName) - { - RM_D(Repo); - return d->findRemote(remoteName, false); - } + Namespace* Repo::findNamespace(const QStringList& namespaces) + { + RM_D( Repo ); + return d->findNamespace(namespaces); + } - Namespace* Repo::findNamespace(const QStringList& namespaces) - { - RM_D( Repo ); - return d->findNamespace(namespaces); - } + Namespace* Repo::findNamespace(const QString& nsFullName) + { + RM_D( Repo ); + return d->findNamespace(nsFullName); + } - Namespace* Repo::findNamespace(const QString& nsFullName) - { - RM_D( Repo ); - return d->findNamespace(nsFullName); - } + Head* Repo::head() const + { + RM_CD(Repo); + return d->mHead; + } - Head* Repo::head() const - { - RM_CD(Repo); - return d->mHead; - } + #endif - /** - * @brief Get this repository's collection of branches - * - * @return A CollectionNode whose children are the branches included in this repository. - * - * Branches are references matching the regular expression `^refs/heads/.*$`. Branches may be - * scoped in which case they are subdivided into RefTreeNode objects. - * - */ - CollectionNode* Repo::branches() - { - RM_D( Repo ); - return d->getOrCreateCollection( ctBranches ); - } + #if 0 // ###DEAD - /** - * @brief Get this repository's collection of tags - * - * @return A CollectionNode whose children are the tags included in this repository. - * - * Tags are references matching the regular expression `^refs/tags/.*$`. Tags may be scoped in - * which case they are subdivided into RefTreeNode objects. - * - */ - CollectionNode* Repo::tags() - { - RM_D( Repo ); - return d->getOrCreateCollection( ctTags ); - } + /** + * @brief Get this repository's collection of branches + * + * @return A CollectionNode whose children are the branches included in this repository. + * + * Branches are references matching the regular expression `^refs/heads/.*$`. Branches may be + * scoped in which case they are subdivided into RefTreeNode objects. + * + */ + CollectionNode* Repo::branches() + { + RM_D( Repo ); + return d->getOrCreateCollection( ctBranches ); + } - /** - * @brief Get this repository's collection of namespaces - * - * @return A CollectionNode whose children are the 1st level namespaces included in this - * repository. - * - */ - CollectionNode* Repo::namespaces() - { - RM_D(Repo); - return d->getOrCreateCollection(ctNamespaces); - } + /** + * @brief Get this repository's collection of tags + * + * @return A CollectionNode whose children are the tags included in this repository. + * + * Tags are references matching the regular expression `^refs/tags/.*$`. Tags may be scoped in + * which case they are subdivided into RefTreeNode objects. + * + */ + CollectionNode* Repo::tags() + { + RM_D( Repo ); + return d->getOrCreateCollection( ctTags ); + } - /** - * @brief Get this repository's collection of notes - * - * @return A CollectionNode object whose children are the notes included in this repository. - * - * Notes are refs matching the regular expression `^refs/notes/.*$`. Notes may be scoped, in - * which case they are subdivided into RefTreeNode objects. - * - */ - CollectionNode* Repo::notes() - { - RM_D(Repo); - return d->getOrCreateCollection(ctNotes); - } + /** + * @brief Get this repository's collection of namespaces + * + * @return A CollectionNode whose children are the 1st level namespaces included in this + * repository. + * + */ + CollectionNode* Repo::namespaces() + { + RM_D(Repo); + return d->getOrCreateCollection(ctNamespaces); + } - //-- RepoPrivate ------------------------------------------------------------------------------- + /** + * @brief Get this repository's collection of notes + * + * @return A CollectionNode object whose children are the notes included in this repository. + * + * Notes are refs matching the regular expression `^refs/notes/.*$`. Notes may be scoped, in + * which case they are subdivided into RefTreeNode objects. + * + */ + CollectionNode* Repo::notes() + { + RM_D(Repo); + return d->getOrCreateCollection(ctNotes); + } + + #endif + + } + + namespace Data + { + + #if 0 + RepoPrivate::RepoPrivate(Repo* pub, const Git::Repository& repo) + : BasePrivate( pub ) + { + mRepo = repo; + mHead = NULL; + mPath = mRepo.basePath(); + mIsLoaded = mRepo.isValid(); + mIsActive = false; + mIsBare = mRepo.isValid() && mRepo.isBare(); + mIsSubModule = false; + mIsInitializing = true; + mDisplayAlias = QString(); + mUnloadTimer = NULL; - RepoPrivate::RepoPrivate(Repo* pub, const Git::Repository& repo) - : BasePrivate( pub ) - { - mRepo = repo; - mHead = NULL; - mPath = mRepo.workTreePath(); - mIsLoaded = mRepo.isValid(); - mIsActive = false; - mIsBare = mRepo.isValid() && mRepo.isBare(); - mIsSubModule = false; - mIsInitializing = true; - mDisplayAlias = QString(); - mUnloadTimer = NULL; - - if (mPath.endsWith(L'/')) { - mPath = mPath.left(mPath.length() - 1); - } - - findAlias(); - - if (mDisplayAlias.isEmpty()) { - if (mPath.isEmpty()) { - mDisplayAlias = Repo::tr("Unknown Repository"); - } - else { - QStringList sl = mPath.split(QChar(L'/'), QString::SkipEmptyParts); - mDisplayAlias = sl.last(); + if (mPath.endsWith(L'/')) { + mPath = mPath.left(mPath.length() - 1); } - } - } - RepoPrivate::~RepoPrivate() - { - RM_P(Repo); + findAlias(); - if (mIsLoaded) { - unload(); + if (mDisplayAlias.isEmpty()) { + if (mPath.isEmpty()) { + mDisplayAlias = Repo::tr("Unknown Repository"); + } + else { + QStringList sl = mPath.split(QChar(L'/'), QString::SkipEmptyParts); + mDisplayAlias = sl.last(); + } + } } - MacGitver::repoMan().internalClosedRepo(p); - } + RepoPrivate::~RepoPrivate() + { + RM_P(Repo); - void RepoPrivate::load() - { - // ### Unimplemented: RepoPrivate::load() - Q_ASSERT(!mIsLoaded); - } + if (mIsLoaded) { + unload(); + } - void RepoPrivate::unload() - { - if (mIsActive) { - qDebug() << "Unloading active RepoInfo. Will deactivate it first."; - MacGitver::repoMan().activate(NULL); + MacGitver::repoMan().internalClosedRepo(p); } - Q_ASSERT(!mIsActive); - if (mUnloadTimer) { - mUnloadTimer->stop(); - mUnloadTimer->deleteLater(); - mUnloadTimer = NULL; + void RepoPrivate::load() + { + // ### Unimplemented: RepoPrivate::load() + Q_ASSERT(!mIsLoaded); } - // ####REPOMAN Do we really need to send out events for Unload/Load? If yes, create - // real events for that! - mIsLoaded = false; - mRepo = Git::Repository(); - } + void RepoPrivate::unload() + { + if (mIsActive) { + qDebug() << "Unloading active RepoInfo. Will deactivate it first."; + MacGitver::repoMan().activate(NULL); + } + Q_ASSERT(!mIsActive); + if (mUnloadTimer) { + mUnloadTimer->stop(); + mUnloadTimer->deleteLater(); + mUnloadTimer = NULL; + } - QString RepoPrivate::displayName() const - { - return mDisplayAlias; - } + // ####REPOMAN Do we really need to send out events for Unload/Load? If yes, create + // real events for that! + mIsLoaded = false; + mRepo = Git::Repository(); + } - void RepoPrivate::preTerminate() - { - // Do we need to do smth? - } - void RepoPrivate::scanSubmodules() - { - RM_P(Repo); + QString RepoPrivate::displayName() const + { + return mDisplayAlias; + } - Git::Repository repo = gitRepo(true); - if (!repo.isValid()) { - return; + void RepoPrivate::preTerminate() + { + // Do we need to do smth? } - Git::Result r; - Git::Submodule::List subs = repo.submodules( r ); - if (!r) { - return; + void RepoPrivate::findAlias() + { + // ### Unimplemented: RepoPrivate::findAlias() } - Repo::List oldSubmodules = pub()->submodules(); + bool RepoPrivate::refreshSelf() + { + if (!mIsLoaded) { + // In case we're not loaded, just return and do nothing. + return true; + } - foreach (Git::Submodule sub, subs) { - Git::Result child; - Git::Repository subRepo = sub.subRepository(child); - if (!child) { - continue; + if (!mHead) { + RM_P(Repo); + mHead = new Head(mRepo, p); } - Q_ASSERT(subRepo.isValid()); - Repo* subInfo = NULL; - QString path = subRepo.workTreePath(); + return true; + } - if (path.endsWith(L'/')) { - path = path.left(path.length() - 1); + void RepoPrivate::postRefreshChildren() + { + if (!mIsLoaded) { + // In case we're not loaded, just return and do nothing. + return; } - subInfo = repoByPath(path, true); - if (!subInfo) { - subInfo = new Submodule(subRepo, p); + Git::Result r; + Git::Remote::List remotes = mRepo.allRemotes(r); + if (r) { + foreach (const Git::Remote& remote, remotes) { + findRemote(remote, true); + } } - else { - oldSubmodules.removeOne(subInfo); + + Git::ReferenceList refs = mRepo.allReferences(r); + if (r) { + foreach (Git::Reference ref, refs) { + findReference(ref, true); + } } - } - foreach(Repo* repo, oldSubmodules) { - dataOf(repo)->terminateObject(); + scanSubmodules(); } - } - - void RepoPrivate::findAlias() - { - // ### Unimplemented: RepoPrivate::findAlias() - } - bool RepoPrivate::refreshSelf() - { - if (!mIsLoaded) { - // In case we're not loaded, just return and do nothing. - return true; + /** + * @brief Get this object's type + * + * @return always RepoObject. + * + */ + ObjTypes RepoPrivate::objType() const + { + return RepoObject; } - if (!mHead) { - RM_P(Repo); - mHead = new Head(mRepo, p); + void RepoPrivate::dumpSelf(Internal::Dumper& dumper) const + { + dumper.addLine(QString(QLatin1String("Repository 0x%1 - %02")) + .arg(quintptr(mPub),0,16) + .arg(mIsLoaded ? mRepo.name() + : QLatin1String(""))); } - return true; - } - void RepoPrivate::postRefreshChildren() - { - if (!mIsLoaded) { - // In case we're not loaded, just return and do nothing. - return; + Ref* RepoPrivate::findReference(const Git::Reference& ref, bool create) + { + Git::RefName rn = ref.nameAnalyzer(); + return findReference(rn, ref, create); } - Git::Result r; - Git::Remote::List remotes = mRepo.allRemotes(r); - if (r) { - foreach (const Git::Remote& remote, remotes) { - findRemote(remote, true); - } + Ref* RepoPrivate::findReference(const QString& fqrn, bool create) + { + Git::RefName rn(fqrn); + return findReference(rn, Git::Reference(), create); } - Git::ReferenceList refs = mRepo.allReferences(r); - if (r) { - foreach (Git::Reference ref, refs) { - findReference(ref, true); - } - } + Ref* RepoPrivate::findReference(Git::RefName& rn, Git::Reference ref, bool create) + { + Base* parent = NULL; + CollectionNode* cn = NULL; - scanSubmodules(); - } + if (rn.isRemote() && rn.isBranch()) { + Remote* rm = findRemote(rn.remote(), create); - /** - * @brief Get this object's type - * - * @return always ObjTypes::Repo. - * - */ - ObjTypes RepoPrivate::objType() const - { - return ObjTypes::Repo; - } - - void RepoPrivate::dumpSelf(Internal::Dumper& dumper) const - { - dumper.addLine(QString(QStringLiteral("Repository 0x%1 - %02")) - .arg(quintptr(mPub),0,16) - .arg(mIsLoaded ? mRepo.name() - : QStringLiteral(""))); - } - - - Ref* RepoPrivate::findReference(const Git::Reference& ref, bool create) - { - Git::RefName rn = ref.nameAnalyzer(); - return findReference(rn, ref, create); - } - - Ref* RepoPrivate::findReference(const QString& fqrn, bool create) - { - Git::RefName rn(fqrn); - return findReference(rn, Git::Reference(), create); - } - - Ref* RepoPrivate::findReference(Git::RefName& rn, Git::Reference ref, bool create) - { - Base* parent = NULL; - CollectionNode* cn = NULL; + if (!rm) { + return NULL; + } - if (rn.isRemote() && rn.isBranch()) { - Remote* rm = findRemote(rn.remote(), create); + RemotePrivate* rmp = dataOf(rm); + if (!rmp) { + return NULL; + } - if (!rm) { - return NULL; + parent = rmp->findRefParent(rn.scopes(), create); } + else if (rn.isNamespaced()) { + Namespace* ns = findNamespace(rn.namespaces(), create); - RemotePrivate* rmp = dataOf(rm); - if (!rmp) { - return NULL; - } + if (!ns) { + return NULL; + } - parent = rmp->findRefParent(rn.scopes(), create); - } - else if (rn.isNamespaced()) { - Namespace* ns = findNamespace(rn.namespaces(), create); + if (rn.isBranch()) { + cn = ns->branches(); + } + else if (rn.isTag()) { + cn = ns->tags(); + } + else { + return NULL; + } - if (!ns) { - return NULL; - } + CollectionNodePrivate* cnp = dataOf(cn); + if (!cnp) { + return NULL; + } - if (rn.isBranch()) { - cn = ns->branches(); - } - else if (rn.isTag()) { - cn = ns->tags(); + parent = cnp->findRefParent(rn.scopes(), create); } else { - return NULL; - } + if (rn.isBranch()) { + cn = getOrCreateCollection(ctBranches); + } + else if (rn.isTag()) { + cn = getOrCreateCollection(ctTags); + } + else { + return NULL; + } - CollectionNodePrivate* cnp = dataOf(cn); - if (!cnp) { - return NULL; - } + CollectionNodePrivate* cnp = dataOf(cn); + if (!cnp) { + return NULL; + } - parent = cnp->findRefParent(rn.scopes(), create); - } - else { - if (rn.isBranch()) { - cn = getOrCreateCollection(ctBranches); - } - else if (rn.isTag()) { - cn = getOrCreateCollection(ctTags); - } - else { - return NULL; + parent = cnp->findRefParent(rn.scopes(), create); } - CollectionNodePrivate* cnp = dataOf(cn); - if (!cnp) { - return NULL; + foreach (Ref* rmRef, parent->childObjects()) { + if (rmRef->fullName() == rn.fullName()) { + return rmRef; + } } - parent = cnp->findRefParent(rn.scopes(), create); - } - - foreach (Ref* rmRef, parent->childObjects()) { - if (rmRef->fullName() == rn.fullName()) { - return rmRef; + if (create) { + if ( rn.isBranch() ) { + return new Branch( parent, ref ); + } + else if( rn.isTag() ) { + return new Tag( parent, ref ); + } + else { + qDebug() << "Do not know how to deal with reference:" << rn.fullName(); + return NULL; + } } - } - if (create) { - if ( rn.isBranch() ) { - return new Branch( parent, ref ); - } - else if( rn.isTag() ) { - return new Tag( parent, ref ); - } - else { - qDebug() << "Do not know how to deal with reference:" << rn.fullName(); - return NULL; - } + return NULL; } - return NULL; - } - - Remote* RepoPrivate::findRemote(const QString &remoteName, bool create) - { - RM_P(Repo); + Remote* RepoPrivate::findRemote(const QString &remoteName, bool create) + { + RM_P(Repo); - foreach (Remote* remote, p->childObjects()) { - if (remote->name() == remoteName) { - return remote; + foreach (Remote* remote, p->childObjects()) { + if (remote->name() == remoteName) { + return remote; + } } - } - if (create) { - Git::Result r; - Git::Remote gr = p->gitRepo().remote(r, remoteName); + if (create) { + Git::Result r; + Git::Remote gr = p->gitRepo().remote(r, remoteName); - if (r && gr.isValid()) { - Remote* remote = new Remote(gr, p); - return remote; + if (r && gr.isValid()) { + Remote* remote = new Remote(gr, p); + return remote; + } } + + return NULL; } - return NULL; - } + Remote* RepoPrivate::findRemote(const Git::Remote &remote, bool create) + { + RM_P( Repo ); - Remote* RepoPrivate::findRemote(const Git::Remote &remote, bool create) - { - RM_P( Repo ); + if (!remote.isValid()) { + return NULL; + } - if (!remote.isValid()) { - return NULL; - } + QString remoteName = remote.name(); + foreach (Remote* rmRemote, p->childObjects()) { + if (rmRemote->name() == remoteName) { + return rmRemote; + } + } - QString remoteName = remote.name(); - foreach (Remote* rmRemote, p->childObjects()) { - if (rmRemote->name() == remoteName) { + if (create) { + Remote* rmRemote = new Remote(remote, p); return rmRemote; } - } - if (create) { - Remote* rmRemote = new Remote(remote, p); - return rmRemote; + return NULL; } - return NULL; - } - - Namespace* RepoPrivate::findNamespace(const QStringList& _namespaces, bool create) { + Namespace* RepoPrivate::findNamespace(const QStringList& _namespaces, bool create) { - Base* par = getOrCreateCollection(ctNamespaces); - Namespace* child = NULL; + Base* par = getOrCreateCollection(ctNamespaces); + Namespace* child = NULL; - foreach (QString nsName, _namespaces) { - child = NULL; + foreach (QString nsName, _namespaces) { + child = NULL; - foreach (Namespace* ns, par->childObjects()) { - if (ns->name() == nsName) { - child = ns; - break; + foreach (Namespace* ns, par->childObjects()) { + if (ns->name() == nsName) { + child = ns; + break; + } } - } - if (!child) { - if (create) { - child = new Namespace(par, nsName); - } - else { - return NULL; + if (!child) { + if (create) { + child = new Namespace(par, nsName); + } + else { + return NULL; + } } + + par = child; } - par = child; + return child; } - return child; - } - - Namespace* RepoPrivate::findNamespace(const QString& nsFullName, bool create) { - - QStringList nsNames = nsFullName.split(QChar(L'/')); - return findNamespace(nsNames, create); - } - - Repo* RepoPrivate::repoByPath(const QString& basePath, bool searchSubmodules) - { - foreach (Repo* subRepo, mPub->childObjects()) { - - if (subRepo->path() == basePath) { - return subRepo; - } + Namespace* RepoPrivate::findNamespace(const QString& nsFullName, bool create) { - if (searchSubmodules) { - if (RepoPrivate* subRepoPriv = dataOf(subRepo)) { - if (Repo* subsubRepo = subRepoPriv->repoByPath(basePath, true)) { - return subsubRepo; - } - } - } + QStringList nsNames = nsFullName.split(QChar(L'/')); + return findNamespace(nsNames, create); } - return NULL; - } + QString RepoPrivate::objectTypeName() const + { + return QLatin1String("Repo"); + } - QString RepoPrivate::objectTypeName() const - { - return QStringLiteral("Repo"); - } + bool RepoPrivate::inherits(ObjTypes type) const + { + return type == RepoObject || BasePrivate::inherits(type); + } - bool RepoPrivate::inherits(ObjTypes type) const - { - return type == ObjTypes::Repo || BasePrivate::inherits(type); - } + Repo* RepoPrivate::searchRepository() + { + return static_cast(mPub); + } - Repo* RepoPrivate::searchRepository() - { - return static_cast(mPub); - } + Git::Repository RepoPrivate::gitRepo(bool doLoad) + { + if (!mIsLoaded && doLoad) { + load(); + } - Git::Repository RepoPrivate::gitRepo(bool doLoad) - { - if (!mIsLoaded && doLoad) { - load(); + return mRepo; } - return mRepo; + #endif + } } + diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Repo.hpp b/Libs/libMacGitverCore/RepoMan/Frontend/Repo.hpp new file mode 100644 index 00000000..132d0a1c --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Repo.hpp @@ -0,0 +1,116 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libGitWrap/Repository.hpp" + +#include "libMacGitverCore/RepoMan/Frontend/Base.hpp" + +namespace RM +{ + + class RepoMan; + class Head; + + namespace Data + { + class Repo; + } + + namespace Frontend + { + + class MGV_CORE_API Repo + : public Base + { + friend class RepoMan; + public: + static const ObjTypes StaticObjectType = ObjTypes::Repo; + typedef Data::Repo DPtrType; + typedef QVector List; + + public: + Repo() = default; + Repo(const std::shared_ptr& o); + Repo(std::shared_ptr&& o); + ~Repo() = default; + + bool operator==(const Repo& other) const; + + public: + GW_DEPRECATED Git::Repository gitRepo(); + GW_DEPRECATED Git::Repository gitLoadedRepo(); + + bool isSubModule() const; + bool isBare() const; + bool isLoaded() const; + bool isActive() const; + bool isInitializing() const; + + Repo parentRepository(); + List submodules() const; + + QString path() const; + + QString displayAlias() const; + void setDisplayAlias( const QString& alias ); + + QString branchDisplay() const; + + void close(); + + GW_DEPRECATED + Reference findReference( const Git::Reference& ref); + Reference findReference( const QString& fqrn); + + GW_DEPRECATED + Remote findRemote( const Git::Remote& remote); + Remote findRemote( const QString& remoteName); + + Namespace findNamespace( const QStringList& namespaces); + Namespace findNamespace( const QString& nsFullName); + + #if 0 // ###DEAD + CollectionNode* branches(); + CollectionNode* namespaces(); + CollectionNode* notes(); + CollectionNode* tags(); + Head* head() const; + #endif + + private: + void activated(); + void deactivated(); + + #if 0 // ###DEAD + private slots: + void unloadTimer(); + #endif + }; + + + inline bool Repo::operator==(const Repo& other) const + { + return Base::operator==(other); + } + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Submodule.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Submodule.cpp index e8969375..54aceefc 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Submodule.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Submodule.cpp @@ -19,74 +19,85 @@ #include "RepoMan/Events.hpp" -#include "RepoMan/Submodule.hpp" +#include "RepoMan/Data/Submodule.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/SubmoduleData.hpp" namespace RM { - using namespace Internal; - Submodule::Submodule(const Git::Repository& repo, Repo* parent) - : Repo( *new SubmodulePrivate( this, repo ) ) + namespace Frontend { - RM_D(Submodule); - d->mIsSubModule = true; + #if 0 + Submodule::Submodule(const Git::Repository& repo, Repo* parent) + : Repo( *new RM::Data::Submodule( this, repo ) ) + { + RM_D(Submodule); - setDisplayAlias( repo.name() ); + d->mIsSubModule = true; - d->linkToParent( parent ); - d->refresh(); + setDisplayAlias( repo.name() ); - d->mIsInitializing = false; - } + d->linkToParent( parent ); + d->refresh(); - //-- SubmodulePrivate -------------------------------------------------------------------------- + d->mIsInitializing = false; + } + #endif - SubmodulePrivate::SubmodulePrivate(Submodule* pub, const Git::Repository& repo) - : RepoPrivate( pub, repo ) - { } - ObjTypes SubmodulePrivate::objType() const + namespace Data { - return ObjTypes::Submodule; - } + #if 0 - void SubmodulePrivate::dumpSelf(Dumper& dumper) const - { - dumper.addLine(QString(QStringLiteral("Submodule 0x%1")) - .arg(quintptr(mPub),0,16)); - } + SubmodulePrivate::SubmodulePrivate(Submodule* pub, const Git::Repository& repo) + : RepoPrivate( pub, repo ) + { + } - void SubmodulePrivate::postCreation() - { - if (!repoEventsBlocked()) { - Events::self()->submoduleCreated(repository(), pub()); + ObjTypes SubmodulePrivate::objType() const + { + return SubmoduleObject; } - RepoPrivate::postCreation(); - } + void SubmodulePrivate::dumpSelf(Dumper& dumper) const + { + dumper.addLine(QString(QLatin1String("Submodule 0x%1")) + .arg(quintptr(mPub),0,16)); + } - void SubmodulePrivate::preTerminate() - { - if (!repoEventsBlocked()) { - Events::self()->submoduleAboutToBeDeleted(repository(), pub()); + void SubmodulePrivate::postCreation() + { + if (!repoEventsBlocked()) { + Events::self()->submoduleCreated(repository(), pub()); + } + + RepoPrivate::postCreation(); } - RepoPrivate::preTerminate(); - } + void SubmodulePrivate::preTerminate() + { + if (!repoEventsBlocked()) { + Events::self()->submoduleAboutToBeDeleted(repository(), pub()); + } - QString SubmodulePrivate::objectTypeName() const - { - return QStringLiteral("Submodule"); - } + RepoPrivate::preTerminate(); + } + + QString SubmodulePrivate::objectTypeName() const + { + return QLatin1String("Submodule"); + } + + bool SubmodulePrivate::inherits(ObjTypes type) const + { + return type == SubmoduleObject || RepoPrivate::inherits(type); + } + + #endif - bool SubmodulePrivate::inherits(ObjTypes type) const - { - return type == ObjTypes::Submodule || RepoPrivate::inherits(type); } } diff --git a/Libs/libMacGitverCore/RepoMan/Data/TagData.hpp b/Libs/libMacGitverCore/RepoMan/Frontend/Submodule.hpp similarity index 75% rename from Libs/libMacGitverCore/RepoMan/Data/TagData.hpp rename to Libs/libMacGitverCore/RepoMan/Frontend/Submodule.hpp index 8bb62db9..a53acb73 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/TagData.hpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Submodule.hpp @@ -19,28 +19,28 @@ #pragma once -#include "RepoMan/Data/RefData.hpp" - -#include "RepoMan/Tag.hpp" +#include "libMacGitverCore/Repoman/Frontend/Repo.hpp" namespace RM { - namespace Internal + namespace Frontend { - class TagPrivate : public RefPrivate + class MGV_CORE_API Submodule : public Repo { public: - TagPrivate(Tag* pub, const Git::Reference& _ref); + static const ObjTypes StaticObjectType = ObjTypes::Submodule; + + public: + Submodule(const Git::Repository& repo, Repo* parent); public: + + private: ObjTypes objType() const; - void postCreation(); void preTerminate(); void dumpSelf(Internal::Dumper& dumper) const; - QString objectTypeName() const; - bool inherits(ObjTypes type) const; }; } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Tag.cpp b/Libs/libMacGitverCore/RepoMan/Frontend/Tag.cpp index f98e4ce2..476c6438 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Tag.cpp +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Tag.cpp @@ -19,69 +19,80 @@ #include "RepoMan/Events.hpp" -#include "RepoMan/Tag.hpp" +#include "RepoMan/Frontend/Tag.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/TagData.hpp" +#include "RepoMan/Data/Tag.hpp" namespace RM { - using namespace Internal; - - Tag::Tag(Base* _parent, const Git::Reference& _ref) - : Ref(*new TagPrivate(this, _ref)) + namespace Frontend { - RM_D(Tag); - d->linkToParent(_parent); - } - //-- TagPrivate -------------------------------------------------------------------------------- + #if 0 + Tag::Tag(Base* _parent, const Git::Reference& _ref) + : Ref(*new TagPrivate(this, _ref)) + { + RM_D(Tag); + d->linkToParent(_parent); + } - TagPrivate::TagPrivate(Tag* _pub, const Git::Reference& _ref) - : RefPrivate(_pub, TagType, _ref) - { - } + #endif - ObjTypes TagPrivate::objType() const - { - return ObjTypes::Tag; } - void TagPrivate::postCreation() + namespace Data { - if (!repoEventsBlocked()) { - Events::self()->tagCreated(repository(), pub()); + + #if 0 + + TagPrivate::TagPrivate(Tag* _pub, const Git::Reference& _ref) + : RefPrivate(_pub, TagType, _ref) + { } - RefPrivate::postCreation(); - } + ObjTypes TagPrivate::objType() const + { + return TagObject; + } - void TagPrivate::preTerminate() - { - if (!repoEventsBlocked()) { - Events::self()->tagAboutToBeDeleted(repository(), pub()); + void TagPrivate::postCreation() + { + if (!repoEventsBlocked()) { + Events::self()->tagCreated(repository(), pub()); + } + + RefPrivate::postCreation(); } - RefPrivate::preTerminate(); - } + void TagPrivate::preTerminate() + { + if (!repoEventsBlocked()) { + Events::self()->tagAboutToBeDeleted(repository(), pub()); + } + RefPrivate::preTerminate(); + } - void TagPrivate::dumpSelf(Internal::Dumper& dumper) const - { - dumper.addLine(QString(QStringLiteral("Tag 0x%1 - %2")) - .arg(quintptr(mPub),0,16) - .arg(mName)); - } + void TagPrivate::dumpSelf(Internal::Dumper& dumper) const + { + dumper.addLine(QString(QLatin1String("Tag 0x%1 - %2")) + .arg(quintptr(mPub),0,16) + .arg(mName)); + } - QString TagPrivate::objectTypeName() const - { - return QStringLiteral("Tag"); - } + QString TagPrivate::objectTypeName() const + { + return QLatin1String("Tag"); + } + + bool TagPrivate::inherits(ObjTypes type) const + { + return type == TagObject || RefPrivate::inherits(type); + } + #endif - bool TagPrivate::inherits(ObjTypes type) const - { - return type == ObjTypes::Tag || RefPrivate::inherits(type); } } diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Tag.hpp b/Libs/libMacGitverCore/RepoMan/Frontend/Tag.hpp new file mode 100644 index 00000000..6149bcc8 --- /dev/null +++ b/Libs/libMacGitverCore/RepoMan/Frontend/Tag.hpp @@ -0,0 +1,51 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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/RepoMan/Frontend/Reference.hpp" + +namespace RM +{ + + namespace Frontend + { + + class MGV_CORE_API Tag : public Reference + { + public: + static const ObjTypes StaticObjectType = ObjTypes::Tag; + typedef QVector List; + + public: + Tag(Base* _parent, const Git::Reference& _ref); + + public: + + private: + ObjTypes objType() const; + void preTerminate(); + void dumpSelf(Internal::Dumper& dumper) const; + + private: + }; + + } + +} diff --git a/Libs/libMacGitverCore/RepoMan/Head.hpp b/Libs/libMacGitverCore/RepoMan/Head.hpp deleted file mode 100644 index 6f8990ca..00000000 --- a/Libs/libMacGitverCore/RepoMan/Head.hpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2015 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "RepoMan/Base.hpp" -#include "RepoMan/CollectionNode.hpp" -#include "RepoMan/Branch.hpp" - -namespace RM -{ - - namespace Internal - { - class HeadPrivate; - } - - class MGV_CORE_API Head : public Base - { - public: - static const ObjTypes StaticObjectType = ObjTypes::Head; - typedef Internal::HeadPrivate Private; - typedef QVector< Head* > List; - - public: - Head(const Git::Repository& repo, Base* parent); - - public: - bool isDetached() const; - bool isUnborn() const; - Git::ObjectId detachedId() const; - QString symbolicName() const; - - public: - bool is(const Branch* ref) const; - }; - -} diff --git a/Libs/libMacGitverCore/RepoMan/Namespace.hpp b/Libs/libMacGitverCore/RepoMan/Namespace.hpp deleted file mode 100644 index 7049fc39..00000000 --- a/Libs/libMacGitverCore/RepoMan/Namespace.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2015 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "Base.hpp" -#include "CollectionNode.hpp" - -namespace RM -{ - - namespace Internal - { - class NamespacePrivate; - } - - class MGV_CORE_API Namespace : public Base - { - public: - static const ObjTypes StaticObjectType = ObjTypes::Namespace; - typedef Internal::NamespacePrivate Private; - typedef QVector< Namespace* > List; - - public: - Namespace(Base* parent, const QString& _name); - - public: - QString name() const; - - public: - CollectionNode* branches(); - CollectionNode* namespaces(); - CollectionNode* notes(); - CollectionNode* tags(); - }; - -} diff --git a/Libs/libMacGitverCore/RepoMan/Ref.hpp b/Libs/libMacGitverCore/RepoMan/Ref.hpp deleted file mode 100644 index 1970a4ef..00000000 --- a/Libs/libMacGitverCore/RepoMan/Ref.hpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2015 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "libGitWrap/ObjectId.hpp" - -#include "Base.hpp" - -namespace RM -{ - - namespace Internal - { - class RefPrivate; - } - - enum RefTypes - { - BranchType, - TagType - }; - - class MGV_CORE_API Ref : public Base - { - public: - static const ObjTypes StaticObjectType = ObjTypes::Reference; - - typedef QList< Ref* > List; - - protected: - Ref(Internal::RefPrivate& data); - - public: - Ref(Base* parent, RefTypes type, const Git::Reference& ref); - - GW_DEPRECATED - Git::Reference load(Git::Result& r); - - public: - RefTypes type() const; - QString name() const; - QString fullName() const; - Git::ObjectId id() const; - QString displaySha1() const; - }; - -} diff --git a/Libs/libMacGitverCore/RepoMan/Remote.hpp b/Libs/libMacGitverCore/RepoMan/Remote.hpp deleted file mode 100644 index d4cd1756..00000000 --- a/Libs/libMacGitverCore/RepoMan/Remote.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2015 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "libGitWrap/Remote.hpp" - -#include "Base.hpp" - -namespace RM -{ - - namespace Internal - { - class RemotePrivate; - } - - class MGV_CORE_API Remote : public Base - { - public: - static const ObjTypes StaticObjectType = ObjTypes::Remote; - typedef Internal::RemotePrivate Private; - typedef QVector< Remote* > List; - - public: - Remote(const Git::Remote& gitObj, Base* parent); - - public: - GW_DEPRECATED - Git::Remote gitObject(); - QString name() const; - CollectionNode* branches(); - }; - -} diff --git a/Libs/libMacGitverCore/RepoMan/Repo.hpp b/Libs/libMacGitverCore/RepoMan/Repo.hpp deleted file mode 100644 index 6463167c..00000000 --- a/Libs/libMacGitverCore/RepoMan/Repo.hpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2015 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 - -class QTimer; - -#include "libGitWrap/Repository.hpp" - -#include "libMacGitverCore/RepoMan/Base.hpp" - -namespace RM -{ - - class RepoMan; - class Head; - - namespace Internal - { - class RepoPrivate; - } - - class MGV_CORE_API Repo : public QObject, public Base - { - friend class RepoMan; - - Q_OBJECT - public: - static const ObjTypes StaticObjectType = ObjTypes::Repo; - typedef Internal::RepoPrivate Private; - typedef QVector< Repo* > List; - - protected: - Repo(Internal::RepoPrivate& _d); - - public: - Repo(const Git::Repository& repo, Base* parent); - ~Repo(); - - public: - GW_DEPRECATED Git::Repository gitRepo(); - GW_DEPRECATED Git::Repository gitLoadedRepo(); - - bool isSubModule() const; - bool isBare() const; - bool isLoaded() const; - bool isActive() const; - bool isInitializing() const; - - Repo* parentRepository(); - List submodules() const; - - QString path() const; - - QString displayAlias() const; - void setDisplayAlias( const QString& alias ); - - QString branchDisplay() const; - - void close(); - - Ref* findReference( const Git::Reference& ref); - Ref* findReference( const QString& fqrn); - Remote* findRemote( const Git::Remote& remote); - Remote* findRemote( const QString& remoteName); - Namespace* findNamespace( const QStringList& namespaces); - Namespace* findNamespace( const QString& nsFullName); - - CollectionNode* branches(); - CollectionNode* namespaces(); - CollectionNode* notes(); - CollectionNode* tags(); - Head* head() const; - - private: - void activated(); - void deactivated(); - - private slots: - void unloadTimer(); - }; - -} diff --git a/Libs/libMacGitverCore/RepoMan/RepoMan.cpp b/Libs/libMacGitverCore/RepoMan/RepoMan.cpp index 62d47515..33d5939d 100644 --- a/Libs/libMacGitverCore/RepoMan/RepoMan.cpp +++ b/Libs/libMacGitverCore/RepoMan/RepoMan.cpp @@ -20,13 +20,12 @@ #include "libMacGitverCore/App/MacGitver.hpp" #include "RepoMan/RepoMan.hpp" -#include "RepoMan/CollectionNode.hpp" #include "RepoMan/Events.hpp" #include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/RepoManData.hpp" -#include "RepoMan/Data/RepoData.hpp" +#include "RepoMan/Data/RepoMan.hpp" +#include "RepoMan/Data/Repo.hpp" #include "libBlueSky/Application.hpp" @@ -35,8 +34,6 @@ namespace RM { - using namespace Internal; - /** * @class RepoMan * @brief Manages the open / active repositories @@ -49,14 +46,13 @@ namespace RM * */ RepoMan::RepoMan() - : Base(*new RepoManPrivate(this)) { Events::addReceiver(this); connect(BlueSky::Application::instance(), - SIGNAL(activeModeChanged(BlueSky::Mode*)), + &BlueSky::Application::activeModeChanged, this, - SLOT(reactivateWorkaround())); + &RepoMan::reactivateWorkaround); } /** @@ -105,24 +101,29 @@ namespace RM */ void RepoMan::closeAll() { + #if 0 // ###DEAD RM_D(RepoMan); foreach(Repo* repo, d->repos) { repo->close(); } + #endif } void RepoMan::reactivateWorkaround() { + #if 0 // ###DEAD RM_D(RepoMan); if (d->activeRepo) { Events::self()->repositoryDeactivated(d->activeRepo); Events::self()->repositoryActivated(d->activeRepo); } + #endif } - void RepoMan::activate(Repo* repository) + void RepoMan::activate(const Frontend::Repo& repository) { + #if 0 // ###DEAD RM_D(RepoMan); if(repository != d->activeRepo) { @@ -145,8 +146,10 @@ namespace RM emit hasActiveRepositoryChanged(d->activeRepo != NULL); } } + #endif } + #if 0 // ###DEAD void RepoMan::internalClosedRepo(Repo* repository) { RM_D(RepoMan); @@ -169,19 +172,29 @@ namespace RM } } } + #endif - Repo* RepoMan::activeRepository() + Frontend::Repo RepoMan::activeRepository() { + #if 0 // ###DEAD RM_D(RepoMan); return d->activeRepo; + #else + return Frontend::Repo(); + #endif } - Repo::List RepoMan::repositories() const + Frontend::Repo::List RepoMan::repositories() const { + #if 0 // ###DEAD RM_CD(RepoMan); return d->repos; + #else + return Frontend::Repo::List(); + #endif } + #if 0 // ###DEAD //-- RepoManPrivate ---------------------------------------------------------------------------- RepoManPrivate::RepoManPrivate(RepoMan* _pub) @@ -211,20 +224,9 @@ namespace RM // Do we need to do smth? } - QString RepoManPrivate::displayName() const - { - return QStringLiteral("RepoMan"); - } - - QString RepoManPrivate::objectTypeName() const - { - return QStringLiteral("RepoMan"); - } - Heaven::Menu* RepoManPrivate::contextMenuFor(Base* object) { switch (object->objType()) { - case ObjTypes::Branch: return menuCtxBranch; case ObjTypes::Tag: return menuCtxTag; case ObjTypes::Repo: return menuCtxRepo; @@ -232,27 +234,9 @@ namespace RM case ObjTypes::Namespace: return menuCtxNamespace; case ObjTypes::RefLog: return menuCtxRefLog; case ObjTypes::Remote: return menuCtxRemote; - - //case ObjTypes::Reference: return menuCtxRef; - //case ObjTypes::RefTreeNode: return menuCtxRefTreeNode; - - case ObjTypes::CollectionNode: - switch (static_cast(object)->collectionType()) { - - case ctBranches: return menuCtxBranches; - case ctTags: return menuCtxTags; - case ctNotes: return menuCtxNotes; - case ctNamespaces: return menuCtxNamespaces; - - default: break; - } - break; - - default: - break; + default: return nullptr; } - - return nullptr; } + #endif } diff --git a/Libs/libMacGitverCore/RepoMan/RepoMan.hpp b/Libs/libMacGitverCore/RepoMan/RepoMan.hpp index 2b214ae7..a2152649 100644 --- a/Libs/libMacGitverCore/RepoMan/RepoMan.hpp +++ b/Libs/libMacGitverCore/RepoMan/RepoMan.hpp @@ -19,33 +19,23 @@ #pragma once -#include - -#include "libGitWrap/Repository.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" -#include "libMacGitverCore/RepoMan/Repo.hpp" #include "libMacGitverCore/RepoMan/Events.hpp" +#include + namespace RM { - namespace Internal - { - class RepoManPrivate; - } - class MGV_CORE_API RepoMan : public QObject - , public Base , private EventsInterface { Q_OBJECT - public: - static const ObjTypes StaticObjectType = ObjTypes::RepoManager; - typedef Internal::RepoManPrivate Private; - - public: + private: RepoMan(); + public: ~RepoMan(); public: @@ -53,12 +43,10 @@ namespace RM void closeAll(); - Repo* activeRepository(); - void activate(Repo* repository); - - Repo::List repositories() const; + Frontend::Repo activeRepository(); + void activate(const Frontend::Repo& repository); - void internalClosedRepo(Repo* repository); + Frontend::Repo::List repositories() const; public: static RepoMan& instance(); @@ -74,39 +62,39 @@ namespace RM void hasActiveRepositoryChanged(bool hasActiveRepo); signals: - void repositoryOpened(RM::Repo* repo); - void repositoryAboutToClose(RM::Repo* repo); - void repositoryActivated(RM::Repo* repo); - void repositoryDeactivated(RM::Repo* repo); - void objectCreated(RM::Repo* repo, RM::Base* object); - void objectAboutToBeDeleted(RM::Repo* repo, RM::Base* object); - void refTreeNodeCreated(RM::Repo* repo, RM::RefTreeNode* node); - void refTreeNodeAboutToBeDeleted(RM::Repo* repo, RM::RefTreeNode* node); - void refCreated(RM::Repo* repo, RM::Ref* ref); - void refAboutToBeDeleted(RM::Repo* repo, RM::Ref* ref); - void refMoved(RM::Repo* repo, RM::Ref* ref); - void refHeadDetached(RM::Repo* repo, RM::Ref* ref); - void tagCreated(RM::Repo* repo, RM::Tag* tag); - void tagAboutToBeDeleted(RM::Repo* repo, RM::Tag* tag); - void branchCreated(RM::Repo* repo, RM::Branch* branch); - void branchAboutToBeDeleted(RM::Repo* repo, RM::Branch* branch); - void branchMoved(RM::Repo* repo, RM::Branch* branch); - void branchUpstreamChanged(RM::Repo* repo, RM::Branch* branch); - void namespaceCreated(RM::Repo* repo, RM::Namespace* nameSpace); - void namespaceAboutToBeDeleted(RM::Repo* repo, RM::Namespace* nameSpace); - void refLogChanged(RM::Repo* repo, RM::RefLog* reflog); - void refLogNewEntry(RM::Repo* repo, RM::RefLog* reflog); - void stageCreated(RM::Repo* repo, RM::Ref* ref); - void stageAboutToBeDeleted(RM::Repo* repo, RM::Ref* ref); - void remoteCreated(RM::Repo* repo, RM::Remote* remote); - void remoteAboutToBeDeleted(RM::Repo* repo, RM::Remote* remote); - void remoteModified(RM::Repo* repo, RM::Remote* remote); - void submoduleCreated(RM::Repo* repo, RM::Submodule* submodule); - void submoduleAboutToBeDeleted(RM::Repo* repo, RM::Submodule* submodule); - void submoduleMoved(RM::Repo* repo, RM::Submodule* submodule); - void repositoryStateChanged(RM::Repo* repo); - void indexUpdated(RM::Repo* repo); - void workTreeUpdated(RM::Repo* repo); + void repositoryOpened(const RM::Frontend::Repo& repo); + void repositoryAboutToClose(const RM::Frontend::Repo& repo); + void repositoryActivated(const RM::Frontend::Repo& repo); + void repositoryDeactivated(const RM::Frontend::Repo& repo); + void objectCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object); + void objectAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object); + void refTreeNodeCreated(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node); + void refTreeNodeAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node); + void refCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void refAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void refMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void refHeadDetached(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void tagCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag); + void tagAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag); + void branchCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); + void branchAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); + void branchMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); + void branchUpstreamChanged(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); + void namespaceCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace); + void namespaceAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace); + void refLogChanged(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog); + void refLogNewEntry(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog); + void stageCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void stageAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void remoteCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); + void remoteAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); + void remoteModified(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); + void submoduleCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); + void submoduleAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); + void submoduleMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); + void repositoryStateChanged(const RM::Frontend::Repo& repo); + void indexUpdated(const RM::Frontend::Repo& repo); + void workTreeUpdated(const RM::Frontend::Repo& repo); }; } diff --git a/Libs/libMacGitverCore/RepoMan/Submodule.hpp b/Libs/libMacGitverCore/RepoMan/Submodule.hpp deleted file mode 100644 index 4c26cd6d..00000000 --- a/Libs/libMacGitverCore/RepoMan/Submodule.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2015 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "Repo.hpp" - -namespace RM -{ - - class MGV_CORE_API Submodule : public Repo - { - public: - static const ObjTypes StaticObjectType = ObjTypes::Submodule; - - public: - Submodule(const Git::Repository& repo, Repo* parent); - - public: - - private: - ObjTypes objType() const; - void preTerminate(); - void dumpSelf(Internal::Dumper& dumper) const; - - private: - }; - -} diff --git a/Libs/libMacGitverCore/RepoMan/Tag.hpp b/Libs/libMacGitverCore/RepoMan/Tag.hpp deleted file mode 100644 index 951b71a3..00000000 --- a/Libs/libMacGitverCore/RepoMan/Tag.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2015 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "Ref.hpp" - -namespace RM -{ - - class MGV_CORE_API Tag : public Ref - { - public: - static const ObjTypes StaticObjectType = ObjTypes::Tag; - typedef QVector< Tag* > List; - - public: - Tag(Base* _parent, const Git::Reference& _ref); - - public: - - private: - ObjTypes objType() const; - void preTerminate(); - void dumpSelf(Internal::Dumper& dumper) const; - - private: - }; - -} diff --git a/Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp b/Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp index 4338faec..8aa4e6f0 100644 --- a/Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp +++ b/Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp @@ -25,15 +25,15 @@ #include "libHeavenIcons/IconRef.hpp" #include "libHeavenIcons/Icon.hpp" -#include "RepoMan/Ref.hpp" +#include "RepoMan/Frontend/Reference.hpp" +#include "RepoMan/Frontend/Repo.hpp" + #include "RepoMan/RepoMan.hpp" -#include "RepoMan/Repo.hpp" #include "RepoStateWidget.hpp" RepoStateWidget::RepoStateWidget() { - repo = NULL; setupUi(); RM::RepoMan& rm = RM::RepoMan::instance(); @@ -48,20 +48,18 @@ RepoStateWidget::RepoStateWidget() this, &RepoStateWidget::repositoryDeactivated); } -void RepoStateWidget::repositoryActivated(RM::Repo* info) +void RepoStateWidget::repositoryActivated(const RM::Frontend::Repo& info) { - if( repo != info ) - { + if (repo != info) { repo = info; setRepoState(); } } -void RepoStateWidget::repositoryDeactivated(RM::Repo* info) +void RepoStateWidget::repositoryDeactivated(const RM::Frontend::Repo& info) { - if( repo == info ) - { - repo = NULL; + if (repo == info) { + repo = RM::Frontend::Repo(); setRepoState(); } } @@ -70,22 +68,24 @@ void RepoStateWidget::setRepoState() { txtState->hide(); - txtRepo->setText( repo ? repo->displayAlias() : QString() ); - onUpdateHEAD( repo, NULL ); + txtRepo->setText(repo ? repo.displayAlias() : QString()); + onUpdateHEAD(repo, RM::Frontend::Reference()); } -void RepoStateWidget::onUpdateHEAD(RM::Repo* ownerRepo, RM::Ref* ref) +void RepoStateWidget::onUpdateHEAD( + const RM::Frontend::Repo& ownerRepo, + const RM::Frontend::Reference& ref) { - if ( ownerRepo != repo ) { + if (ownerRepo != repo) { return; } - if ( ref && ref->name() != QStringLiteral("HEAD") ) { + if (ref && ref.name() != QStringLiteral("HEAD")) { return; } // TODO: implement a HTML formatter to highlight HEAD - txtBranch->setText( repo ? repo->branchDisplay() : QString() ); + txtBranch->setText(repo ? repo.branchDisplay() : QString()); } static inline QLabel* pixmapLabel(const char* name) diff --git a/Libs/libMacGitverCore/Widgets/RepoStateWidget.hpp b/Libs/libMacGitverCore/Widgets/RepoStateWidget.hpp index 2fa038c0..d65ab3d2 100644 --- a/Libs/libMacGitverCore/Widgets/RepoStateWidget.hpp +++ b/Libs/libMacGitverCore/Widgets/RepoStateWidget.hpp @@ -19,16 +19,12 @@ #pragma once +#include "RepoMan/Frontend/Repo.hpp" + class QLabel; #include -namespace RM -{ - class Ref; - class Repo; -} - class RepoStateWidget : public QWidget { Q_OBJECT @@ -36,19 +32,19 @@ class RepoStateWidget : public QWidget RepoStateWidget(); private slots: - void repositoryActivated(RM::Repo* info); - void repositoryDeactivated(RM::Repo* info); + void repositoryActivated(const RM::Frontend::Repo& repo); + void repositoryDeactivated(const RM::Frontend::Repo& repo); private: void setupUi(); void setRepoState(); public slots: - void onUpdateHEAD(RM::Repo* ownerRepo, RM::Ref* ref); + void onUpdateHEAD(const RM::Frontend::Repo& ownerRepo, const RM::Frontend::Reference& ref); private: - RM::Repo* repo; - QLabel* txtRepo; - QLabel* txtState; - QLabel* txtBranch; + RM::Frontend::Repo repo; + QLabel* txtRepo; + QLabel* txtState; + QLabel* txtBranch; }; From 43dc7ea67d195cebabecfec4d7737587beb24d43 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Mon, 11 May 2015 00:48:57 +0100 Subject: [PATCH 17/75] Fixup to "Temporary Code" :( --- Libs/libMacGitverCore/MacGitver/IRepositoryContext.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Libs/libMacGitverCore/MacGitver/IRepositoryContext.hpp b/Libs/libMacGitverCore/MacGitver/IRepositoryContext.hpp index 3ad14874..ff11181b 100644 --- a/Libs/libMacGitverCore/MacGitver/IRepositoryContext.hpp +++ b/Libs/libMacGitverCore/MacGitver/IRepositoryContext.hpp @@ -23,13 +23,16 @@ namespace RM { - class Repo; + namespace Frontend + { + class Repo; + } } class IRepositoryContext { public: - virtual RM::Repo* repository() const = 0; + virtual RM::Frontend::Repo repository() const = 0; }; Q_DECLARE_INTERFACE( IRepositoryContext, From 9a902ce7f88405c0c3671092b251c5536b146896 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Mon, 11 May 2015 03:52:34 +0100 Subject: [PATCH 18/75] Adjustments --- Modules/CMakeLists.txt | 8 +- Modules/GitConfig/GitConfigModule.cpp | 7 +- Modules/History/HistoryList.cpp | 12 +- Modules/History/HistoryModel.cpp | 16 +- Modules/History/HistoryModel.h | 13 +- Modules/History/HistoryView.cpp | 8 +- Modules/History/HistoryView.h | 9 +- Modules/RefsViews/Branches/BranchesModel.cpp | 107 ++++++------- Modules/RefsViews/Branches/BranchesModel.hpp | 50 +++--- Modules/RefsViews/Branches/RefItem.cpp | 8 +- Modules/RefsViews/Branches/RefItem.hpp | 51 +++--- Modules/RefsViews/RefRenameDialog.cpp | 10 +- Modules/RefsViews/RefRenameDialog.hpp | 10 +- Modules/RepoManLogger/Listener.cpp | 96 ++++++------ Modules/RepoManLogger/Listener.hpp | 66 ++++---- Modules/Repository/RepoInfoModel.cpp | 156 +++++++++++-------- Modules/Repository/RepoInfoModel.hpp | 43 ++--- Modules/Repository/RepoTreeView.cpp | 21 ++- Modules/Repository/RepoTreeView.hpp | 16 +- Modules/Repository/RepositoryModule.cpp | 23 +-- Modules/Repository/RepositoryModule.h | 6 +- 21 files changed, 388 insertions(+), 348 deletions(-) diff --git a/Modules/CMakeLists.txt b/Modules/CMakeLists.txt index 7d30339a..e3308327 100644 --- a/Modules/CMakeLists.txt +++ b/Modules/CMakeLists.txt @@ -7,12 +7,12 @@ INCLUDE_DIRECTORIES( ${HEAVEN_INCLUDE_DIRS} ) -ADD_SUBDIRECTORY(History) +#ADD_SUBDIRECTORY(History) ADD_SUBDIRECTORY(GitConfig) -ADD_SUBDIRECTORY(RefsViews) +#ADD_SUBDIRECTORY(RefsViews) ADD_SUBDIRECTORY(Repository) -ADD_SUBDIRECTORY(Remotes) +#ADD_SUBDIRECTORY(Remotes) ADD_SUBDIRECTORY(Welcome) -ADD_SUBDIRECTORY(WorkingTree) +#ADD_SUBDIRECTORY(WorkingTree) ADD_SUBDIRECTORY(Logging) ADD_SUBDIRECTORY(RepoManLogger) diff --git a/Modules/GitConfig/GitConfigModule.cpp b/Modules/GitConfig/GitConfigModule.cpp index 3b4edb6a..d4812d9f 100644 --- a/Modules/GitConfig/GitConfigModule.cpp +++ b/Modules/GitConfig/GitConfigModule.cpp @@ -19,7 +19,7 @@ #include "libMacGitverCore/App/MacGitver.hpp" #include "libMacGitverCore/RepoMan/RepoMan.hpp" -#include "libMacGitverCore/RepoMan/Repo.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" #include "GitConfigModule.h" #include "GitConfigDialog.h" @@ -40,10 +40,13 @@ void GitConfigModule::deinitialize() void GitConfigModule::onToolsGitConfig() { + RM::Frontend::Repo repo(RM::RepoMan::instance().activeRepository()); + + #if 0 // ###REPOMAN Git::Repository gitRepo; - RM::Repo* repo = MacGitver::repoMan().activeRepository(); if (repo) { gitRepo = repo->gitRepo(); } GitConfigDialog( gitRepo ).exec(); + #endif } diff --git a/Modules/History/HistoryList.cpp b/Modules/History/HistoryList.cpp index 82152e44..0b7f712a 100644 --- a/Modules/History/HistoryList.cpp +++ b/Modules/History/HistoryList.cpp @@ -16,7 +16,7 @@ #include "libMacGitverCore/App/MacGitver.hpp" #include "libMacGitverCore/RepoMan/RepoMan.hpp" -#include "libMacGitverCore/RepoMan/Repo.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" #include "libMacGitverCore/Widgets/HeaderView.h" #include "CreateBranchDialog.h" @@ -128,6 +128,7 @@ QModelIndex HistoryList::deeplyMapToSource( QModelIndex current ) const void HistoryList::onCheckout() { + #if 0 // ### REPOMAN Heaven::Action* action = qobject_cast< Heaven::Action* >( sender() ); if ( !action ) return; @@ -162,10 +163,12 @@ void HistoryList::onCheckout() trUtf8("Checkout of commit failed. Git message:\n%1").arg(r.errorText())); return; } + #endif } void HistoryList::checkout(Git::Result& result, const Git::Reference& ref) { + #if 0 // ### REPOMAN GW_CHECK_RESULT(result, void()); Git::CheckoutReferenceOperation* op = new Git::CheckoutReferenceOperation( ref ); @@ -181,10 +184,12 @@ void HistoryList::checkout(Git::Result& result, const Git::Reference& ref) .arg( ref.shorthand() ) .arg( result.errorText() ) ); } + #endif } void HistoryList::onCreateBranch() { + #if 0 // ### REPOMAN Heaven::Action* action = qobject_cast< Heaven::Action* >( sender() ); if ( !action ) return; @@ -220,10 +225,12 @@ void HistoryList::onCreateBranch() { checkout( r, branch ); } + #endif } void HistoryList::onCreateTag() { + #if 0 // ### REPOMAN Heaven::Action* action = qobject_cast< Heaven::Action* >( sender() ); if ( !action ) return; @@ -253,10 +260,12 @@ void HistoryList::onCreateTag() trUtf8("Failed to create tag. Git message:\n%1").arg(r.errorText()) ); return; } + #endif } void HistoryList::onShowHEAD() { + #if 0 // ### REPOMAN Git::Result r; Git::Repository repo = MacGitver::repoMan().activeRepository()->gitRepo(); @@ -280,5 +289,6 @@ void HistoryList::onShowHEAD() "Important Note: This is a feature preview!\n\n" "Please make sure the HEAD commit is at least once visible!" ) ); } + #endif } diff --git a/Modules/History/HistoryModel.cpp b/Modules/History/HistoryModel.cpp index 5c964087..a655d851 100644 --- a/Modules/History/HistoryModel.cpp +++ b/Modules/History/HistoryModel.cpp @@ -22,7 +22,7 @@ #include "libMacGitverCore/App/MacGitver.hpp" #include "libMacGitverCore/RepoMan/RepoMan.hpp" -#include "libMacGitverCore/RepoMan/Ref.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Reference.hpp" #include "libGitWrap/Reference.hpp" @@ -40,7 +40,7 @@ HistoryModel::HistoryModel( const Git::Repository& repo, QObject* parent ) mDisplays = 0; - RM::RepoMan &rm = MacGitver::repoMan(); + RM::RepoMan &rm = RM::RepoMan::instance(); connect(&rm, &RM::RepoMan::refCreated, this, &HistoryModel::onRefCreated); connect(&rm, &RM::RepoMan::refAboutToBeDeleted, this, &HistoryModel::onRefDestroyed); connect(&rm, &RM::RepoMan::refMoved, this, &HistoryModel::onRefMoved); @@ -229,35 +229,41 @@ void HistoryModel::afterAppend() endInsertRows(); } -void HistoryModel::onRefCreated(RM::Repo* repo, RM::Ref* ref) +void HistoryModel::onRefCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) { Q_UNUSED( ref ) + #if 0 // ###REPOMAN if ( !repo || (repo->gitLoadedRepo() != mRepo) ) { return; } + #endif scanInlineReferences(); } -void HistoryModel::onRefDestroyed(RM::Repo* repo, RM::Ref* ref) +void HistoryModel::onRefDestroyed(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) { Q_UNUSED( ref ) + #if 0 // ###REPOMAN if ( !repo || (repo->gitLoadedRepo() != mRepo) ) { return; } + #endif scanInlineReferences(); } -void HistoryModel::onRefMoved(RM::Repo* repo, RM::Ref* ref) +void HistoryModel::onRefMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) { Q_UNUSED( ref ); + #if 0 // ###REPOMAN if ( !repo || (repo->gitLoadedRepo() != mRepo) ) { return; } + #endif scanInlineReferences(); } diff --git a/Modules/History/HistoryModel.h b/Modules/History/HistoryModel.h index 39e4875d..606f1ae8 100644 --- a/Modules/History/HistoryModel.h +++ b/Modules/History/HistoryModel.h @@ -30,8 +30,11 @@ namespace RM { - class Ref; - class Repo; + namespace Frontend + { + class Reference; + class Repo; + } } class HistoryModel : public QAbstractTableModel @@ -114,9 +117,9 @@ private slots: void beforeAppend(); void afterAppend(); - void onRefCreated(RM::Repo* repo, RM::Ref* ref); - void onRefDestroyed(RM::Repo* repo, RM::Ref* ref); - void onRefMoved(RM::Repo*repo, RM::Ref*ref); + void onRefCreated (const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void onRefDestroyed(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void onRefMoved (const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); private: InlineRefDisplays mDisplays; diff --git a/Modules/History/HistoryView.cpp b/Modules/History/HistoryView.cpp index cd656611..fdd981fe 100644 --- a/Modules/History/HistoryView.cpp +++ b/Modules/History/HistoryView.cpp @@ -31,7 +31,7 @@ #include "libMacGitverCore/App/MacGitver.hpp" #include "libMacGitverCore/RepoMan/RepoMan.hpp" -#include "libMacGitverCore/RepoMan/Repo.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" #include "HistoryView.h" #include "HistoryEntry.h" @@ -73,13 +73,14 @@ HistoryView::HistoryView() this, &HistoryView::repoActivated); } -void HistoryView::repoActivated(RM::Repo* repo) +void HistoryView::repoActivated(const RM::Frontend::Repo& repo) { if (mRepo != repo) { mRepo = repo; - Git::Repository repo = mRepo->gitRepo(); + #if 0 // ###REPOMAN + Git::Repository repo = mRepo.gitRepo(); if (mModel) { mList->setModel(NULL); @@ -104,6 +105,7 @@ void HistoryView::repoActivated(RM::Repo* repo) mModel->buildHistory(); mList->setModel(mModel); } + #endif } } diff --git a/Modules/History/HistoryView.h b/Modules/History/HistoryView.h index 10c64071..efd0239f 100644 --- a/Modules/History/HistoryView.h +++ b/Modules/History/HistoryView.h @@ -33,10 +33,7 @@ class QToolBar; #include "HistoryModel.h" -namespace RM -{ - class Repo; -} +#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" class HistoryDetails; class HistoryList; @@ -53,7 +50,7 @@ class HistoryView : public BlueSky::View, HistoryView(); private slots: - void repoActivated(RM::Repo* repo); + void repoActivated(const RM::Frontend::Repo& repo); void currentCommitChanged(const Git::ObjectId& sha1); void onChangeShowLocalBranches(bool checked); @@ -78,7 +75,7 @@ private slots: HistoryList* mList; HistoryDetails* mDetails; HistoryDiff* mDiff; - RM::Repo* mRepo; + RM::Frontend::Repo mRepo; }; #endif diff --git a/Modules/RefsViews/Branches/BranchesModel.cpp b/Modules/RefsViews/Branches/BranchesModel.cpp index 8cd44d53..f6af1f42 100644 --- a/Modules/RefsViews/Branches/BranchesModel.cpp +++ b/Modules/RefsViews/Branches/BranchesModel.cpp @@ -16,21 +16,19 @@ * */ -#include -#include +#include "BranchesModel.hpp" #include "libMacGitverCore/App/MacGitver.hpp" #include "libMacGitverCore/RepoMan/RepoMan.hpp" -#include "libMacGitverCore/RepoMan/Ref.hpp" -#include "libMacGitverCore/RepoMan/RefTreeNode.hpp" -#include "libMacGitverCore/RepoMan/Branch.hpp" -#include "libMacGitverCore/RepoMan/Remote.hpp" -#include "libMacGitverCore/RepoMan/CollectionNode.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Reference.hpp" +#include "libMacGitverCore/RepoMan/Frontend/RefTreeNode.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Branch.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Remote.hpp" #include "libGitWrap/Result.hpp" -#include "BranchesModel.hpp" - +#include +#include BranchesModel::BranchesModel( BranchesViewData* parent ) : QAbstractItemModel( parent ) @@ -40,7 +38,7 @@ BranchesModel::BranchesModel( BranchesViewData* parent ) , mHeaderRemote( NULL ) , mHeaderTags( NULL ) { - RM::RepoMan& rm = MacGitver::repoMan(); + RM::RepoMan& rm = RM::RepoMan::instance(); connect(&rm, &RM::RepoMan::refCreated, this, &BranchesModel::onRefCreated); @@ -76,15 +74,14 @@ QModelIndex BranchesModel::itemToIndex(RefItem* item) const return createIndex( row, 0, item ); } -QModelIndex BranchesModel::objectToIndex(RM::Base* obj) const +QModelIndex BranchesModel::objectToIndex(const RM::Frontend::Base& obj) const { return itemToIndex(mObjToItems.value(obj, NULL)); } -int BranchesModel::rowCount( const QModelIndex& parent ) const +int BranchesModel::rowCount(const QModelIndex& parent) const { - if( parent.column() > 0 ) - { + if (parent.column() > 0) { return 0; } @@ -92,17 +89,19 @@ int BranchesModel::rowCount( const QModelIndex& parent ) const return parentItem->children.count(); } -int BranchesModel::columnCount( const QModelIndex& parent ) const +int BranchesModel::columnCount(const QModelIndex& parent) const { return 1; } -QVariant BranchesModel::data( const QModelIndex& index, int role ) const +QVariant BranchesModel::data(const QModelIndex& index, int role) const { RefItem* item = indexToItem(index); + if (index.column() != 0) { return QVariant(); } + return item ? item->data(role) : QVariant(); } @@ -178,15 +177,15 @@ RefItem* BranchesModel::link(bool notify, RefItem* it) return it; } -RefItem* BranchesModel::createBranchItem(bool notify, RefItem* parent, RM::Branch* obj) +RefItem* BranchesModel::createBranchItem(bool notify, RefItem* parent, const RM::Frontend::Branch& obj) { - if (obj->name() == QStringLiteral("HEAD")) { - return NULL; + if (obj.name() == QStringLiteral("HEAD")) { + return nullptr; } - if (!parent && obj->parentObject()->objType() != RM::ObjTypes::CollectionNode) { - parent = insertObject(notify, obj->parentObject()); - return NULL; + if (!parent /* && obj.parent().objType() != RM::ObjTypes::CollectionNode */) { // ###REPOMAN + parent = insertObject(notify, obj.parent()); + return nullptr; } if (!parent) { @@ -196,10 +195,10 @@ RefItem* BranchesModel::createBranchItem(bool notify, RefItem* parent, RM::Branc return link(notify, new RefBranch(parent, obj)); } -RefItem* BranchesModel::createTagItem(bool notify, RefItem* parent, RM::Tag* obj) +RefItem* BranchesModel::createTagItem(bool notify, RefItem* parent, const RM::Frontend::Tag& obj) { - if (!parent && obj->parentObject()->objType() != RM::ObjTypes::CollectionNode) { - parent = insertObject(notify, obj->parentObject()); + if (!parent /* && obj->parentObject()->objType() != RM::ObjTypes::CollectionNode */) { // ###REPOMAN + parent = insertObject(notify, obj.parent()); return NULL; } @@ -210,23 +209,25 @@ RefItem* BranchesModel::createTagItem(bool notify, RefItem* parent, RM::Tag* obj return link(notify, new RefTag(parent, obj)); } -RefItem* BranchesModel::createScopeItem(bool notify, RefItem* parent, RM::RefTreeNode* obj) +RefItem* BranchesModel::createScopeItem(bool notify, RefItem* parent, const RM::Frontend::RefTreeNode& obj) { if (!parent) { - RM::Base* parObj = obj->parentObject(); + RM::Frontend::Base parObj = obj.parent(); + + #if 0 // ###REPOMAN if (parObj->objType() != RM::ObjTypes::CollectionNode) { parent = insertObject(notify, parObj); - return NULL; + return nullptr; } - RM::CollectionNode* cn = static_cast(parObj); + RM::Frontend::CollectionNode* cn = static_cast(parObj); switch (cn->collectionType()) { - case RM::ctTags: + case RM::Frontend::ctTags: parent = mHeaderTags; break; - case RM::ctBranches: + case RM::Frontend::ctBranches: parent = mHeaderLocal; break; @@ -234,12 +235,13 @@ RefItem* BranchesModel::createScopeItem(bool notify, RefItem* parent, RM::RefTre // Should we assert here? return NULL; } + #endif } return link(notify, new RefScope(parent, obj)); } -RefItem* BranchesModel::createRemoteItem(bool notify, RefItem* parent, RM::Remote* obj) +RefItem* BranchesModel::createRemoteItem(bool notify, RefItem* parent, const RM::Frontend::Remote& obj) { if (!parent) { parent = mHeaderRemote; @@ -248,35 +250,36 @@ RefItem* BranchesModel::createRemoteItem(bool notify, RefItem* parent, RM::Remot return link(notify, new RefRemote(parent, obj)); } -RefItem* BranchesModel::insertObject(bool notify, RM::Base* obj) +RefItem* BranchesModel::insertObject(bool notify, const RM::Frontend::Base& obj) { if (!obj) { return NULL; } - qDebug() << obj->displayName(); + qDebug() << obj.displayName(); bool doChildren = false; - RefItem* parent = mObjToItems.value(obj->parentObject(), NULL); + RefItem* parent = mObjToItems.value(obj.parent(), NULL); RefItem* it = mObjToItems.value(obj, NULL); if (!it) { - switch (obj->objType()) { + + switch (obj.objType()) { case RM::ObjTypes::Branch: - it = createBranchItem(notify, parent, static_cast(obj)); + it = createBranchItem(notify, parent, obj.as()); break; case RM::ObjTypes::Tag: - it = createTagItem(notify, parent, static_cast(obj)); + it = createTagItem(notify, parent, obj.as()); break; case RM::ObjTypes::RefTreeNode: - it = createScopeItem(notify, parent, static_cast(obj)); + it = createScopeItem(notify, parent, obj.as()); doChildren = true; break; case RM::ObjTypes::Remote: - it = createRemoteItem(notify, parent, static_cast(obj)); + it = createRemoteItem(notify, parent, obj.as()); doChildren = true; break; @@ -290,7 +293,7 @@ RefItem* BranchesModel::insertObject(bool notify, RM::Base* obj) mItemToObjs.insert(it, obj); if (doChildren) { - foreach(RM::Base* child, obj->childObjects()) { + foreach(RM::Frontend::Base child, obj.children()) { insertObject(notify, child); } } @@ -299,14 +302,14 @@ RefItem* BranchesModel::insertObject(bool notify, RM::Base* obj) return it; } -void BranchesModel::insertCollection(RM::CollectionNode* coll) +void BranchesModel::insertCollection(RM::Frontend::CollectionNode* coll) { - foreach(RM::Base* obj, coll->childObjects()) { + foreach(RM::Frontend::Base* obj, coll->childObjects()) { insertObject(false, obj); } } -void BranchesModel::updatedObject(RM::Base* obj) +void BranchesModel::updatedObject(RM::Frontend::Base* obj) { RefItem* it = mObjToItems.value(obj, NULL); if (!it) { @@ -334,7 +337,7 @@ void BranchesModel::deleteItem(RefItem* it) beginRemoveRows(itemToIndex(parent), pos, pos); - RM::Base* obj = it->object(); + RM::Frontend::Base* obj = it->object(); if (obj) { mObjToItems.remove(obj); mItemToObjs.remove(it); @@ -345,12 +348,12 @@ void BranchesModel::deleteItem(RefItem* it) endRemoveRows(); } -void BranchesModel::deletedObject(RM::Base* obj) +void BranchesModel::deletedObject(RM::Frontend::Base* obj) { deleteItem(mObjToItems.value(obj, NULL)); } -void BranchesModel::setRepository(RM::Repo* repo) +void BranchesModel::setRepository(RM::Frontend::Repo* repo) { if (mRepo == repo) { return; @@ -374,14 +377,14 @@ void BranchesModel::setRepository(RM::Repo* repo) insertCollection(mRepo->branches()); insertCollection(mRepo->tags()); - foreach (RM::Remote* rmRemote, repo->childObjects()) { + foreach (RM::Frontend::Remote* rmRemote, repo->childObjects()) { insertObject(false, rmRemote); } endResetModel(); } -void BranchesModel::onRefCreated(RM::Repo* repo, RM::Ref* ref) +void BranchesModel::onRefCreated(RM::Frontend::Repo* repo, RM::Frontend::Ref* ref) { if (repo != mRepo) { return; @@ -390,7 +393,7 @@ void BranchesModel::onRefCreated(RM::Repo* repo, RM::Ref* ref) insertObject(true, ref); } -void BranchesModel::onRefDestroyed(RM::Repo* repo, RM::Ref* ref) +void BranchesModel::onRefDestroyed(RM::Frontend::Repo* repo, RM::Frontend::Ref* ref) { if (repo != mRepo) { return; @@ -399,7 +402,7 @@ void BranchesModel::onRefDestroyed(RM::Repo* repo, RM::Ref* ref) deletedObject(ref); } -void BranchesModel::onRefTreeNodeAboutToBeDeleted(RM::Repo* repo, RM::RefTreeNode* obj) +void BranchesModel::onRefTreeNodeAboutToBeDeleted(RM::Frontend::Repo* repo, RM::Frontend::RefTreeNode* obj) { if (repo != mRepo) { return; @@ -408,7 +411,7 @@ void BranchesModel::onRefTreeNodeAboutToBeDeleted(RM::Repo* repo, RM::RefTreeNod deletedObject(obj); } -void BranchesModel::onRefMoved(RM::Repo* repo, RM::Ref* ref) +void BranchesModel::onRefMoved(RM::Frontend::Repo* repo, RM::Frontend::Ref* ref) { if (repo != mRepo) { return; diff --git a/Modules/RefsViews/Branches/BranchesModel.hpp b/Modules/RefsViews/Branches/BranchesModel.hpp index 87956ba8..895fef79 100644 --- a/Modules/RefsViews/Branches/BranchesModel.hpp +++ b/Modules/RefsViews/Branches/BranchesModel.hpp @@ -19,20 +19,16 @@ #ifndef MGV_BRANCHES_MODEL_HPP #define MGV_BRANCHES_MODEL_HPP -#include +#include "Branches/BranchesViewData.hpp" +#include "RefItem.hpp" + +#include "libMacGitverCore/RepoMan/Frontend/Branch.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" #include "libGitWrap/Reference.hpp" #include "libGitWrap/Repository.hpp" -#include "Branches/BranchesViewData.hpp" -#include "RefItem.hpp" - -namespace RM -{ - class Ref; - class Repo; - class CollectionNode; -} +#include class RefItem; class RefScope; @@ -61,37 +57,37 @@ class BranchesModel : public QAbstractItemModel void gitError( const Git::Result& error ); private slots: - void onRefCreated(RM::Repo* repo, RM::Ref* ref); - void onRefDestroyed(RM::Repo* repo, RM::Ref* ref); - void onRefMoved(RM::Repo* repo, RM::Ref* ref); - void onRefTreeNodeAboutToBeDeleted(RM::Repo* repo, RM::RefTreeNode* obj); + void onRefCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void onRefDestroyed(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void onRefMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void onRefTreeNodeAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& obj); private: QModelIndex itemToIndex(RefItem* item) const; - QModelIndex objectToIndex(RM::Base* obj) const; + QModelIndex objectToIndex(const RM::Frontend::Base& obj) const; RefItem* link(bool notify, RefItem* it); - void insertCollection(RM::CollectionNode* coll); - RefItem* insertObject(bool notify, RM::Base* obj); - RefItem* createBranchItem(bool notify, RefItem* parent, RM::Branch* obj); - RefItem* createTagItem(bool notify, RefItem* parent, RM::Tag* obj); - RefItem* createScopeItem(bool notify, RefItem* parent, RM::RefTreeNode* obj); - RefItem* createRemoteItem(bool notify, RefItem* parent, RM::Remote* obj); - - void updatedObject(RM::Base* obj); - void deletedObject(RM::Base* obj); + //void insertCollection(RM::CollectionNode* coll); + RefItem* insertObject(bool notify, const RM::Frontend::Base& obj); + RefItem* createBranchItem(bool notify, RefItem* parent, const RM::Frontend::Branch& obj); + RefItem* createTagItem(bool notify, RefItem* parent, const RM::Frontend::Tag& obj); + RefItem* createScopeItem(bool notify, RefItem* parent, const RM::Frontend::RefTreeNode& obj); + RefItem* createRemoteItem(bool notify, RefItem* parent, const RM::Frontend::Remote& obj); + + void updatedObject(const RM::Frontend::Base& obj); + void deletedObject(const RM::Frontend::Base& obj); void deleteItem(RefItem* it); private: - RM::Repo* mRepo; + RM::Frontend::Repo mRepo; RefRoot* mRoot; RefHeadline* mHeaderLocal; RefHeadline* mHeaderRemote; RefHeadline* mHeaderTags; - QHash mObjToItems; - QHash mItemToObjs; + QHash mObjToItems; + QHash mItemToObjs; }; #endif diff --git a/Modules/RefsViews/Branches/RefItem.cpp b/Modules/RefsViews/Branches/RefItem.cpp index dda9f28e..3c607cc3 100644 --- a/Modules/RefsViews/Branches/RefItem.cpp +++ b/Modules/RefsViews/Branches/RefItem.cpp @@ -47,9 +47,9 @@ RefItem::~RefItem() qDeleteAll( children ); } -RM::Base* RefItem::object() +RM::Frontend::Base RefItem::object() { - return NULL; + return nullptr; } int RefItem::itemPosition() @@ -140,7 +140,7 @@ QVariant RefBranch::data(int role) const switch (role) { case Qt::FontRole: - if (object()->isHead()) { + if (object().isHead()) { QFont f; f.setBold( true ); return f; @@ -175,7 +175,7 @@ QVariant RefTag::data(int role) const switch (role) { case Qt::EditRole: - return object()->name(); + return object().name(); } return RefItemObject::data(role); diff --git a/Modules/RefsViews/Branches/RefItem.hpp b/Modules/RefsViews/Branches/RefItem.hpp index 8ce32359..0ebb5bdb 100644 --- a/Modules/RefsViews/Branches/RefItem.hpp +++ b/Modules/RefsViews/Branches/RefItem.hpp @@ -22,25 +22,16 @@ #include "libHeavenIcons/Icon.hpp" -#include "libMacGitverCore/RepoMan/RefTreeNode.hpp" -#include "libMacGitverCore/RepoMan/Ref.hpp" -#include "libMacGitverCore/RepoMan/Branch.hpp" -#include "libMacGitverCore/RepoMan/Tag.hpp" -#include "libMacGitverCore/RepoMan/Remote.hpp" +#include "libMacGitverCore/RepoMan/Frontend/RefTreeNode.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Reference.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Branch.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Tag.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Remote.hpp" #include #include #include -namespace RM -{ - class Base; - class Ref; - class Branch; - class RefTreeNode; - class Namespace; -} - class BranchesModel; class RefItem @@ -74,7 +65,7 @@ class RefItem public: int itemPosition(); virtual ItemType type() const = 0; - virtual RM::Base* object(); + virtual RM::Frontend::Base object(); public: RefItem* parent; @@ -118,28 +109,30 @@ template class RefItemObject : public RefItem { protected: - RefItemObject(RefItem* parent, T* object) + RefItemObject(RefItem* parent, const T& object) : RefItem(parent) , mObject(object) {} public: - const T* object() const { + const T& object() const { return mObject; } - T* object() { + #if 0 // ###REPOMAN got unsafe now, right? + T& object() { return mObject; } + #endif QVariant data(int role) const { if (mObject) { switch (role) { case Qt::DisplayRole: - return mObject->displayName(); + return mObject.displayName(); case Qt::DecorationRole: - Heaven::IconRef iref = mObject->icon(true); + Heaven::IconRef iref = mObject.icon(true); Heaven::Icon icon = iref.icon(); return icon.pixmap(); } @@ -148,16 +141,16 @@ class RefItemObject : public RefItem } protected: - T* mObject; + T mObject; }; -class RefScope : public RefItemObject +class RefScope : public RefItemObject { public: enum { StaticType = Scope }; public: - RefScope(RefItem* parent, RM::RefTreeNode* obj) + RefScope(RefItem* parent, const RM::Frontend::RefTreeNode& obj) : RefItemObject(parent, obj) {} @@ -176,13 +169,13 @@ class RefNameSpace : public RefScope ItemType type() const; }; -class RefRemote : public RefItemObject +class RefRemote : public RefItemObject { public: enum { StaticType = Remote }; public: - RefRemote(RefItem* parent, RM::Remote* remote) + RefRemote(RefItem* parent, const RM::Frontend::Remote& remote) : RefItemObject(parent, remote) { } @@ -191,13 +184,13 @@ class RefRemote : public RefItemObject ItemType type() const; }; -class RefBranch : public RefItemObject +class RefBranch : public RefItemObject { public: enum { StaticType = Branch }; public: - RefBranch(RefItem* parent, RM::Branch* branch) + RefBranch(RefItem* parent, const RM::Frontend::Branch& branch) : RefItemObject(parent, branch) { } @@ -208,13 +201,13 @@ class RefBranch : public RefItemObject }; -class RefTag : public RefItemObject +class RefTag : public RefItemObject { public: enum { StaticType = Tag }; public: - RefTag(RefItem* parent, RM::Tag* tag) + RefTag(RefItem* parent, const RM::Frontend::Tag& tag) : RefItemObject(parent, tag) { } diff --git a/Modules/RefsViews/RefRenameDialog.cpp b/Modules/RefsViews/RefRenameDialog.cpp index cd111d29..0b5f7688 100644 --- a/Modules/RefsViews/RefRenameDialog.cpp +++ b/Modules/RefsViews/RefRenameDialog.cpp @@ -24,10 +24,10 @@ #include "libGitWrap/RefName.hpp" -#include "libMacGitverCore/RepoMan/Branch.hpp" -#include "libMacGitverCore/RepoMan/Repo.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Branch.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" -RefRenameDialog::RefRenameDialog(const Git::Reference &ref, RM::Repo* repo) +RefRenameDialog::RefRenameDialog(const Git::Reference &ref, const RM::Frontend::Repo& repo) : BlueSky::Dialog() , mRef(ref) , mRepo(repo) @@ -64,7 +64,9 @@ void RefRenameDialog::accept() mRef.rename(mGitResult, newRefName); if (mGitResult) { - mRepo->refresh(); + // ###REPOMAN When making this a service, we need to refresh (but all services need to + // do that). + //mRepo->refresh(); QDialog::accept(); return; } diff --git a/Modules/RefsViews/RefRenameDialog.hpp b/Modules/RefsViews/RefRenameDialog.hpp index 79e554e5..08d08136 100644 --- a/Modules/RefsViews/RefRenameDialog.hpp +++ b/Modules/RefsViews/RefRenameDialog.hpp @@ -23,7 +23,7 @@ #include "libGitWrap/Result.hpp" #include "libGitWrap/Reference.hpp" -#include "libMacGitverCore/RepoMan/Repo.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" #include "ui_RefRenameDialog.h" @@ -33,7 +33,7 @@ class RefRenameDialog { Q_OBJECT public: - RefRenameDialog(const Git::Reference& ref, RM::Repo* repo); + RefRenameDialog(const Git::Reference& ref, const RM::Frontend::Repo& repo); const Git::Result &gitResult() const; @@ -41,7 +41,7 @@ private slots: void accept(); private: - Git::Result mGitResult; - Git::Reference mRef; - RM::Repo* mRepo; + Git::Result mGitResult; + Git::Reference mRef; + RM::Frontend::Repo mRepo; }; diff --git a/Modules/RepoManLogger/Listener.cpp b/Modules/RepoManLogger/Listener.cpp index 5c223b55..2542f219 100644 --- a/Modules/RepoManLogger/Listener.cpp +++ b/Modules/RepoManLogger/Listener.cpp @@ -17,10 +17,10 @@ * */ -#include "libMacGitverCore/RepoMan/Repo.hpp" -#include "libMacGitverCore/RepoMan/Tag.hpp" -#include "libMacGitverCore/RepoMan/Branch.hpp" -#include "libMacGitverCore/RepoMan/Submodule.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Tag.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Branch.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Submodule.hpp" #include "Listener.hpp" #include "TemplateNames.hpp" @@ -36,180 +36,180 @@ Listener::~Listener() RM::Events::delReceiver(this); } -void Listener::repositoryOpened(RM::Repo* repo) +void Listener::repositoryOpened(const RM::Frontend::Repo& repo) { Log::Event e = Log::Event::create(TMPL_REPO_ACTIVITY); Q_ASSERT(e); e.setParam(QStringLiteral("Action"), tr("opened")); - e.setParam(QStringLiteral("RepoName"), repo->displayAlias()); + e.setParam(QStringLiteral("RepoName"), repo.displayAlias()); repoManChannel.addEvent(e); } -void Listener::repositoryAboutToClose(RM::Repo* repo) +void Listener::repositoryAboutToClose(const RM::Frontend::Repo& repo) { Log::Event e = Log::Event::create(TMPL_REPO_ACTIVITY); Q_ASSERT(e); e.setParam(QStringLiteral("Action"), tr("closed")); - e.setParam(QStringLiteral("RepoName"), repo->displayAlias()); + e.setParam(QStringLiteral("RepoName"), repo.displayAlias()); repoManChannel.addEvent(e); } -void Listener::repositoryActivated(RM::Repo* repo) +void Listener::repositoryActivated(const RM::Frontend::Repo& repo) { Log::Event e = Log::Event::create(TMPL_REPO_ACTIVITY); Q_ASSERT(e); e.setParam(QStringLiteral("Action"), tr("activated")); - e.setParam(QStringLiteral("RepoName"), repo->displayAlias()); + e.setParam(QStringLiteral("RepoName"), repo.displayAlias()); repoManChannel.addEvent(e); } -void Listener::repositoryDeactivated(RM::Repo* repo) +void Listener::repositoryDeactivated(const RM::Frontend::Repo& repo) { // We don't want to report deactivation } -void Listener::objectCreated(RM::Repo* repo, RM::Base* object) +void Listener::objectCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object) { } -void Listener::objectAboutToBeDeleted(RM::Repo* repo, RM::Base* object) +void Listener::objectAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object) { } -void Listener::refTreeNodeCreated(RM::Repo* repo, RM::RefTreeNode* node) +void Listener::refTreeNodeCreated(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node) { } -void Listener::refTreeNodeAboutToBeDeleted(RM::Repo* repo, RM::RefTreeNode* node) +void Listener::refTreeNodeAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node) { } -void Listener::refCreated(RM::Repo* repo, RM::Ref* ref) +void Listener::refCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) { } -void Listener::refAboutToBeDeleted(RM::Repo* repo, RM::Ref* ref) +void Listener::refAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) { } -void Listener::refMoved(RM::Repo* repo, RM::Ref* ref) +void Listener::refMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) { } -void Listener::refHeadDetached(RM::Repo* repo, RM::Ref* ref) +void Listener::refHeadDetached(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) { } -void Listener::tagCreated(RM::Repo* repo, RM::Tag* tag) +void Listener::tagCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag) { Log::Event e = Log::Event::create(TMPL_FOUND_NEW_REF); Q_ASSERT(e); e.setParam(QStringLiteral("Type"), tr("tag")); - e.setParam(QStringLiteral("ObjName"), tag->displayName()); - e.setParam(QStringLiteral("SHA"), tag->displaySha1()); - e.setParam(QStringLiteral("RepoName"), repo->displayAlias()); + e.setParam(QStringLiteral("ObjName"), tag.displayName()); + e.setParam(QStringLiteral("SHA"), tag.displaySha1()); + e.setParam(QStringLiteral("RepoName"), repo.displayAlias()); repoManChannel.addEvent(e); } -void Listener::tagAboutToBeDeleted(RM::Repo* repo, RM::Tag* tag) +void Listener::tagAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag) { } -void Listener::branchCreated(RM::Repo* repo, RM::Branch* branch) +void Listener::branchCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) { } -void Listener::branchAboutToBeDeleted(RM::Repo* repo, RM::Branch* branch) +void Listener::branchAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) { } -void Listener::branchMoved(RM::Repo* repo, RM::Branch* branch) +void Listener::branchMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) { Log::Event e = Log::Event::create(TMPL_BRANCH_MOVED); Q_ASSERT(e); - e.setParam(QStringLiteral("ObjName"), branch->displayName()); - e.setParam(QStringLiteral("SHA"), branch->displaySha1()); - e.setParam(QStringLiteral("RepoName"), repo->displayAlias()); + e.setParam(QStringLiteral("ObjName"), branch.displayName()); + e.setParam(QStringLiteral("SHA"), branch.displaySha1()); + e.setParam(QStringLiteral("RepoName"), repo.displayAlias()); repoManChannel.addEvent(e); } -void Listener::branchUpstreamChanged(RM::Repo* repo, RM::Branch* branch) +void Listener::branchUpstreamChanged(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) { } -void Listener::namespaceCreated(RM::Repo* repo, RM::Namespace* nameSpace) +void Listener::namespaceCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace) { } -void Listener::namespaceAboutToBeDeleted(RM::Repo* repo, RM::Namespace* nameSpace) +void Listener::namespaceAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace) { } -void Listener::refLogChanged(RM::Repo* repo, RM::RefLog* reflog) +void Listener::refLogChanged(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog) { } -void Listener::refLogNewEntry(RM::Repo* repo, RM::RefLog* reflog) +void Listener::refLogNewEntry(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog) { } -void Listener::stageCreated(RM::Repo* repo, RM::Ref* ref) +void Listener::stageCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) { } -void Listener::stageAboutToBeDeleted(RM::Repo* repo, RM::Ref* ref) +void Listener::stageAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) { } -void Listener::remoteCreated(RM::Repo* repo, RM::Remote* remote) +void Listener::remoteCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) { } -void Listener::remoteAboutToBeDeleted(RM::Repo* repo, RM::Remote* remote) +void Listener::remoteAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) { } -void Listener::remoteModified(RM::Repo* repo, RM::Remote* remote) +void Listener::remoteModified(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) { } -void Listener::submoduleCreated(RM::Repo* repo, RM::Submodule* submodule) +void Listener::submoduleCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) { Log::Event e = Log::Event::create(TMPL_FOUND_NEW_SM); Q_ASSERT(e); - e.setParam(QStringLiteral("ObjName"), submodule->displayName()); - e.setParam(QStringLiteral("RepoName"), repo->displayAlias()); + e.setParam(QStringLiteral("ObjName"), submodule.displayName()); + e.setParam(QStringLiteral("RepoName"), repo.displayAlias()); repoManChannel.addEvent(e); } -void Listener::submoduleAboutToBeDeleted(RM::Repo* repo, RM::Submodule* submodule) +void Listener::submoduleAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) { } -void Listener::submoduleMoved(RM::Repo* repo, RM::Submodule* submodule) +void Listener::submoduleMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) { } -void Listener::repositoryStateChanged(RM::Repo* repo) +void Listener::repositoryStateChanged(const RM::Frontend::Repo& repo) { } -void Listener::indexUpdated(RM::Repo* repo) +void Listener::indexUpdated(const RM::Frontend::Repo& repo) { } -void Listener::workTreeUpdated(RM::Repo* repo) +void Listener::workTreeUpdated(const RM::Frontend::Repo& repo) { } diff --git a/Modules/RepoManLogger/Listener.hpp b/Modules/RepoManLogger/Listener.hpp index 2652dac4..6648d41d 100644 --- a/Modules/RepoManLogger/Listener.hpp +++ b/Modules/RepoManLogger/Listener.hpp @@ -35,39 +35,39 @@ class Listener : public RM::EventsInterface ~Listener(); public: - void repositoryOpened(RM::Repo* repo); - void repositoryAboutToClose(RM::Repo* repo); - void repositoryActivated(RM::Repo* repo); - void repositoryDeactivated(RM::Repo* repo); - void objectCreated(RM::Repo* repo, RM::Base* object); - void objectAboutToBeDeleted(RM::Repo* repo, RM::Base* object); - void refTreeNodeCreated(RM::Repo* repo, RM::RefTreeNode* node); - void refTreeNodeAboutToBeDeleted(RM::Repo* repo, RM::RefTreeNode* node); - void refCreated(RM::Repo* repo, RM::Ref* ref); - void refAboutToBeDeleted(RM::Repo* repo, RM::Ref* ref); - void refMoved(RM::Repo* repo, RM::Ref* ref); - void refHeadDetached(RM::Repo* repo, RM::Ref* ref); - void tagCreated(RM::Repo* repo, RM::Tag* tag); - void tagAboutToBeDeleted(RM::Repo* repo, RM::Tag* tag); - void branchCreated(RM::Repo* repo, RM::Branch* branch); - void branchAboutToBeDeleted(RM::Repo* repo, RM::Branch* branch); - void branchMoved(RM::Repo* repo, RM::Branch* branch); - void branchUpstreamChanged(RM::Repo* repo, RM::Branch* branch); - void namespaceCreated(RM::Repo* repo, RM::Namespace* nameSpace); - void namespaceAboutToBeDeleted(RM::Repo* repo, RM::Namespace* nameSpace); - void refLogChanged(RM::Repo* repo, RM::RefLog* reflog); - void refLogNewEntry(RM::Repo* repo, RM::RefLog* reflog); - void stageCreated(RM::Repo* repo, RM::Ref* ref); - void stageAboutToBeDeleted(RM::Repo* repo, RM::Ref* ref); - void remoteCreated(RM::Repo* repo, RM::Remote* remote); - void remoteAboutToBeDeleted(RM::Repo* repo, RM::Remote* remote); - void remoteModified(RM::Repo* repo, RM::Remote* remote); - void submoduleCreated(RM::Repo* repo, RM::Submodule* submodule); - void submoduleAboutToBeDeleted(RM::Repo* repo, RM::Submodule* submodule); - void submoduleMoved(RM::Repo* repo, RM::Submodule* submodule); - void repositoryStateChanged(RM::Repo* repo); - void indexUpdated(RM::Repo* repo); - void workTreeUpdated(RM::Repo* repo); + void repositoryOpened(const RM::Frontend::Repo& repo); + void repositoryAboutToClose(const RM::Frontend::Repo& repo); + void repositoryActivated(const RM::Frontend::Repo& repo); + void repositoryDeactivated(const RM::Frontend::Repo& repo); + void objectCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object); + void objectAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object); + void refTreeNodeCreated(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node); + void refTreeNodeAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node); + void refCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void refAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void refMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void refHeadDetached(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void tagCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag); + void tagAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag); + void branchCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); + void branchAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); + void branchMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); + void branchUpstreamChanged(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); + void namespaceCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace); + void namespaceAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace); + void refLogChanged(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog); + void refLogNewEntry(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog); + void stageCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void stageAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); + void remoteCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); + void remoteAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); + void remoteModified(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); + void submoduleCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); + void submoduleAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); + void submoduleMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); + void repositoryStateChanged(const RM::Frontend::Repo& repo); + void indexUpdated(const RM::Frontend::Repo& repo); + void workTreeUpdated(const RM::Frontend::Repo& repo); private: Log::Channel repoManChannel; diff --git a/Modules/Repository/RepoInfoModel.cpp b/Modules/Repository/RepoInfoModel.cpp index eb512740..8c87e1c5 100644 --- a/Modules/Repository/RepoInfoModel.cpp +++ b/Modules/Repository/RepoInfoModel.cpp @@ -14,6 +14,8 @@ * */ +#include "RepoInfoModel.hpp" + #include "libMacGitverCore/App/MacGitver.hpp" #include "libMacGitverCore/Config/Config.h" #include "libMacGitverCore/RepoMan/RepoMan.hpp" @@ -21,54 +23,72 @@ #include "libHeavenIcons/IconRef.hpp" #include "libHeavenIcons/Icon.hpp" -#include "RepoInfoModel.hpp" +struct RepoInfoModel::RepoInfo +{ + RepoInfo(RM::Frontend::Repo&& r) + : mRepo(std::move(r)) + {} + + ~RepoInfo() + { + qDeleteAll(mChildren); + } + + RM::Frontend::Repo mRepo; + RepoInfoModel::RepoInfos mChildren; +}; RepoInfoModel::RepoInfoModel() { - mRepoMan = &MacGitver::repoMan(); + RM::RepoMan& rm = RM::RepoMan::instance(); - connect( mRepoMan, &RM::RepoMan::repositoryDeactivated, - this, &RepoInfoModel::invalidateRepository); + connect( &rm, &RM::RepoMan::repositoryDeactivated, + this, &RepoInfoModel::invalidateRepository); - connect( mRepoMan, &RM::RepoMan::repositoryActivated, - this, &RepoInfoModel::invalidateRepository); + connect( &rm, &RM::RepoMan::repositoryActivated, + this, &RepoInfoModel::invalidateRepository); - connect( mRepoMan, &RM::RepoMan::repositoryOpened, - this, &RepoInfoModel::invalidateRepository); + connect( &rm, &RM::RepoMan::repositoryOpened, + this, &RepoInfoModel::invalidateRepository); +} + +RepoInfoModel::~RepoInfoModel() +{ + qDeleteAll(mRoots); } int RepoInfoModel::rowCount( const QModelIndex& parent ) const { - if( parent.isValid() ) - { - RM::Repo* info = index2Info( parent ); - return info ? info->submodules().count() : 0; + if (parent.isValid()) { + RM::Frontend::Repo info = index2Repo( parent ); + return info ? info.submodules().count() : 0; } - else - { - return mRepoMan->repositories().count(); + else { + return RM::RepoMan::instance().repositories().count(); } } -int RepoInfoModel::columnCount( const QModelIndex& parent ) const +int RepoInfoModel::columnCount(const QModelIndex& parent) const { return 1; } -QVariant RepoInfoModel::data( const QModelIndex& index, int role ) const +QVariant RepoInfoModel::data(const QModelIndex& index, int role) const { - if( !index.isValid() ) return QVariant(); + if (!index.isValid()) { + return QVariant(); + } - RM::Repo* info = index2Info( index ); - if( info ) - { - switch(role) { + RM::Frontend::Repo info = index2Repo(index); + if (info) { + + switch (role) { case Qt::DisplayRole: - return info->displayAlias(); + return info.displayAlias(); case Qt::DecorationRole: { - Heaven::IconRef icon = info->icon().clone(); + Heaven::IconRef icon = info.icon().clone(); QFont f; int size = (f.pixelSize() <= 0) ? f.pointSize() : f.pixelSize(); icon.setSize( qMax(size + 2, 16) ); @@ -79,11 +99,11 @@ QVariant RepoInfoModel::data( const QModelIndex& index, int role ) const { QFont f1, f2; f2.setBold( true ); - return info->isActive() ? f2 : f1; + return info.isActive() ? f2 : f1; } case IsActive: - return info->isActive(); + return info.isActive(); case Qt::ToolTipRole: return trUtf8( @@ -100,75 +120,71 @@ QVariant RepoInfoModel::data( const QModelIndex& index, int role ) const "
Branch: %2
" "" "") - .arg(info->displayName()) - .arg(info->branchDisplay()); + .arg(info.displayName()) + .arg(info.branchDisplay()); } } return QVariant(); } -QModelIndex RepoInfoModel::index( int row, int column, const QModelIndex& parent ) const +QModelIndex RepoInfoModel::index(int row, int column, const QModelIndex& parent) const { Q_UNUSED(column); - RM::Repo::List list; + RM::Frontend::Repo::List list; - if( parent.isValid() ) - { - RM::Repo* infoParent = index2Info( parent ); - if( !infoParent ) - { + if (parent.isValid()) { + + RM::Frontend::Repo repoParent = index2Repo(parent); + + if (!repoParent) { return QModelIndex(); } - foreach (RM::Repo* r, infoParent->submodules()) { - list.append(r); - } + list = repoParent.submodules(); } - else - { - list = mRepoMan->repositories(); + else { + list = RM::RepoMan::instance().repositories(); } - if( row >= list.count() || row < 0 ) - { + if (row >= list.count() || row < 0) { return QModelIndex(); } - return info2Index( list.at( row ) ); + return repo2Index(list.at(row)); } -QModelIndex RepoInfoModel::parent( const QModelIndex& child ) const +QModelIndex RepoInfoModel::parent(const QModelIndex& child) const { - if( !child.isValid() ) - { + if (!child.isValid()) { return QModelIndex(); } - RM::Repo* info = index2Info( child ); - if( !info || !info->parentRepository() ) - { + RM::Frontend::Repo info = index2Repo(child); + + if (!info || !info.parentRepository()) { return QModelIndex(); } - return info2Index( info->parentRepository() ); + return repo2Index(info.parentRepository()); } -RM::Repo* RepoInfoModel::index2Info( const QModelIndex& index ) const +RM::Frontend::Repo RepoInfoModel::index2Repo(const QModelIndex& index) const { - return static_cast< RM::Repo* >( index.internalPointer() ); + RepoInfo* ri = index2info(index); + return ri ? ri->mRepo : RM::Frontend::Repo(); } -QModelIndex RepoInfoModel::info2Index(RM::Repo* info) const +QModelIndex RepoInfoModel::repo2Index(const RM::Frontend::Repo& repo) const { int row = 0; - if( !info ) - { + if (!repo) { return QModelIndex(); } - if( info->parentRepository() ) +#if 0 + if (info->parentRepository()) { RM::Repo::List list = info->parentRepository()->submodules(); // ###REPOMAN Shouldn't this be sorted? @@ -185,18 +201,27 @@ QModelIndex RepoInfoModel::info2Index(RM::Repo* info) const } return createIndex( row, 0, info ); +#endif } -void RepoInfoModel::invalidateRepository(RM::Repo *info) +void RepoInfoModel::invalidateRepository(const RM::Frontend::Repo& info) { - if ( !info ) return; + if (!info) { + return; + } + + QModelIndex index = repo2Index(info); + emit dataChanged(index, index); +} - QModelIndex index = info2Index( info ); - emit dataChanged( index, index ); +RepoInfoModel::RepoInfo* RepoInfoModel::index2info(const QModelIndex& index) const +{ + return nullptr; } -void RepoInfoModel::repositoryOpened(RM::Repo *info) +void RepoInfoModel::repositoryOpened(const RM::Frontend::Repo& info) { +#if 0 if (!info || info->parentRepository()) { return; } @@ -215,11 +240,13 @@ void RepoInfoModel::repositoryOpened(RM::Repo *info) int row = mRepoMan->repositories().count() - 1; emit beginInsertRows(QModelIndex(), row, row); emit endInsertRows(); +#endif } -void RepoInfoModel::repositoryChildAdded(RM::Repo* parent, RM::Repo* child) +void RepoInfoModel::repositoryChildAdded(const RM::Frontend::Repo& parent, const RM::Frontend::Repo& child) { - QModelIndex parentIndex = info2Index(parent); +#if 0 + QModelIndex parentIndex = repo2Index(parent); // we add a row just at the end of the root. This is stupid. But that's the way it works when // a model actually isn't a model... @@ -227,4 +254,5 @@ void RepoInfoModel::repositoryChildAdded(RM::Repo* parent, RM::Repo* child) int row = parent->submodules().count() - 1; emit beginInsertRows(parentIndex, row, row); emit endInsertRows(); +#endif } diff --git a/Modules/Repository/RepoInfoModel.hpp b/Modules/Repository/RepoInfoModel.hpp index 31e261f8..28e71df8 100644 --- a/Modules/Repository/RepoInfoModel.hpp +++ b/Modules/Repository/RepoInfoModel.hpp @@ -14,22 +14,18 @@ * */ -#ifndef MGV_REPO_INFO_MODEL_HPP -#define MGV_REPO_INFO_MODEL_HPP +#pragma once #include -namespace RM -{ - class Repo; - class RepoMan; -} +#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" class RepoInfoModel : public QAbstractItemModel { Q_OBJECT public: RepoInfoModel(); + ~RepoInfoModel(); enum ExtraRoles { @@ -37,23 +33,28 @@ class RepoInfoModel : public QAbstractItemModel }; public: - int rowCount( const QModelIndex& parent = QModelIndex() ) const; - int columnCount( const QModelIndex& parent = QModelIndex() ) const; - QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const; - QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const; - QModelIndex parent( const QModelIndex& child ) const; + int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; + QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex& child) const; public: - RM::Repo* index2Info( const QModelIndex& index ) const; - QModelIndex info2Index( RM::Repo* info ) const; + RM::Frontend::Repo index2Repo(const QModelIndex& index) const; + QModelIndex repo2Index(const RM::Frontend::Repo& repo) const; -public slots: - void invalidateRepository(RM::Repo* info); - void repositoryOpened(RM::Repo* info); - void repositoryChildAdded(RM::Repo* parent, RM::Repo* child); +private: + struct RepoInfo; + using RepoInfos = QVector; private: - RM::RepoMan* mRepoMan; -}; + RepoInfo* index2info(const QModelIndex& index) const; -#endif +private slots: + void invalidateRepository(const RM::Frontend::Repo& repo); + void repositoryOpened(const RM::Frontend::Repo& repo); + void repositoryChildAdded(const RM::Frontend::Repo& parent, const RM::Frontend::Repo& child); + +private: + RepoInfos mRoots; +}; diff --git a/Modules/Repository/RepoTreeView.cpp b/Modules/Repository/RepoTreeView.cpp index 55b44df5..7d28bc3b 100644 --- a/Modules/Repository/RepoTreeView.cpp +++ b/Modules/Repository/RepoTreeView.cpp @@ -21,7 +21,7 @@ #include "libMacGitverCore/App/MacGitver.hpp" #include "libMacGitverCore/RepoMan/RepoMan.hpp" -#include "libMacGitverCore/RepoMan/Repo.hpp" +#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" #include "RepoTreeView.hpp" #include "RepoInfoModel.hpp" @@ -79,7 +79,8 @@ QModelIndex RepoTreeView::deeplyMapToSource( QModelIndex current ) const void RepoTreeView::contextMenu( const QModelIndex& index, const QPoint& globalPos ) { - RM::Repo* info = mModel->index2Info(deeplyMapToSource(index)); +#if 0 + RM::Repo* info = mModel->index2Repo(deeplyMapToSource(index)); if (info) { Heaven::Menu* menu = info->isSubModule() ? menuCtxMenuSMRepo : menuCtxMenuRepo; @@ -88,23 +89,26 @@ void RepoTreeView::contextMenu( const QModelIndex& index, const QPoint& globalPo menu->showPopup( globalPos ); } +#endif } void RepoTreeView::onCtxActivate() { +#if 0 Heaven::Action* action = qobject_cast< Heaven::Action* >( sender() ); - if( action ) - { + if (action) { RM::Repo* info = qobject_cast< RM::Repo* >( action->activatedBy() ); if( info ) { MacGitver::repoMan().activate( info ); } } +#endif } void RepoTreeView::onCtxClose() { +#if 0 Heaven::Action* action = qobject_cast< Heaven::Action* >( sender() ); if( action ) { @@ -114,10 +118,12 @@ void RepoTreeView::onCtxClose() info->close(); } } +#endif } -void RepoTreeView::onRepoActivated(RM::Repo* repo) +void RepoTreeView::onRepoActivated(const RM::Frontend::Repo& repo) { +#if 0 BlueSky::ContextKeys keys = mkKeys(); keys.set("RepoName", repo->path()); @@ -132,15 +138,18 @@ void RepoTreeView::onRepoActivated(RM::Repo* repo) } setCurrentContext(ctx); +#endif } -void RepoTreeView::onRepoDeactivated(RM::Repo* repo) +void RepoTreeView::onRepoDeactivated(const RM::Frontend::Repo& repo) { +#if 0 RepositoryContext* ctx = qobject_cast< RepositoryContext* >(currentContext()); if (ctx && ctx->repository() == repo) { setCurrentContext( NULL ); } +#endif } BlueSky::ViewContext* RepoTreeView::createContextObject() const diff --git a/Modules/Repository/RepoTreeView.hpp b/Modules/Repository/RepoTreeView.hpp index 5904fdbd..0c9ba394 100644 --- a/Modules/Repository/RepoTreeView.hpp +++ b/Modules/Repository/RepoTreeView.hpp @@ -14,8 +14,7 @@ * */ -#ifndef MGV_REPO_TREE_VIEW_HPP -#define MGV_REPO_TREE_VIEW_HPP +#pragma once #include "libBlueSky/Contexts.hpp" @@ -23,14 +22,11 @@ class QModelIndex; -namespace RM -{ - class Repo; -} - class RepoInfoModel; class TreeViewCtxMenu; +#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" + class RepoTreeView : public BlueSky::ContextView , private RepoTreeViewCtxMenu @@ -50,8 +46,8 @@ private slots: // from mRepos void contextMenu( const QModelIndex& index, const QPoint& globalPos ); private slots: // for MacGitver::repoMan() - void onRepoActivated(RM::Repo* repo); - void onRepoDeactivated(RM::Repo* repo); + void onRepoActivated(const RM::Frontend::Repo& repo); + void onRepoDeactivated(const RM::Frontend::Repo& repo); private: QModelIndex deeplyMapToSource( QModelIndex current ) const; @@ -61,5 +57,3 @@ private slots: // for MacGitver::repoMan() RepoInfoModel* mModel; TreeViewCtxMenu* mRepos; }; - -#endif diff --git a/Modules/Repository/RepositoryModule.cpp b/Modules/Repository/RepositoryModule.cpp index 38a9558f..9b42f664 100644 --- a/Modules/Repository/RepositoryModule.cpp +++ b/Modules/Repository/RepositoryModule.cpp @@ -54,8 +54,8 @@ void RepositoryModule::initialize() mMostRecentlyUsed = configGet( "MRU", QStringList() ); - connect(&MacGitver::repoMan(), SIGNAL(repositoryOpened(RM::Repo*)), - this, SLOT(onCoreRepoOpen(RM::Repo*))); + connect(&RM::RepoMan::instance(), &RM::RepoMan::repositoryOpened, + this, &RepositoryModule::onCoreRepoOpen); updateMostRecentlyUsedMenu(); @@ -117,17 +117,8 @@ void RepositoryModule::onRepositoryOpenHelper() return; } - MacGitver::repoMan().open(repoDir); - - // ###REPOMAN This should move to an eventlistener, which is invoked by RepoMan for every - // opened repository. This will then also boost the priority in the LRU menu for - // repositories opened through it. - - // If we successfully loaded the repository at that directory, - // we store the repository's work dir as "lastUsedDir". - // If it is a bare repository, we store the repository's directory. + RM::RepoMan::instance().open(repoDir); Config::self().set("Repository/lastUsedDir", repoDir); - // repo.isBare() ? repoDir : repo.basePath() ); } void RepositoryModule::onRepositoryClone() @@ -138,17 +129,17 @@ void RepositoryModule::onRepositoryClone() void RepositoryModule::onRecentRepositoryOpen( const QVariant& path ) { QString repoPath = path.toString(); - MacGitver::repoMan().open( repoPath ); + RM::RepoMan::instance().open( repoPath ); } -void RepositoryModule::onCoreRepoOpen(RM::Repo* repo) +void RepositoryModule::onCoreRepoOpen(const RM::Frontend::Repo& repo) { - if( repo->isSubModule() ) + if( repo.isSubModule() ) { return; } - QString path = repo->path(); + QString path = repo.path(); mMostRecentlyUsed.removeAll( path ); mMostRecentlyUsed.prepend( path ); diff --git a/Modules/Repository/RepositoryModule.h b/Modules/Repository/RepositoryModule.h index ac7086b2..b46f3b88 100644 --- a/Modules/Repository/RepositoryModule.h +++ b/Modules/Repository/RepositoryModule.h @@ -26,7 +26,9 @@ namespace RM { - class Repo; + namespace Frontend { + class Repo; + } } class RepositoryModule @@ -63,7 +65,7 @@ private slots: private slots: void onRepositoryOpenHelper(); - void onCoreRepoOpen(RM::Repo* repo); + void onCoreRepoOpen(const RM::Frontend::Repo& repo); private: void updateMostRecentlyUsedMenu(); From 4a4afc4717a1c386468a44bb2e798954e8908206 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sat, 11 Apr 2015 02:09:39 +0100 Subject: [PATCH 19/75] Split off RepoMan & make everything compile at least --- CMakeLists.txt | 1 + Libs/CMakeLists.txt | 2 + Libs/libMacGitverCore/App/MacGitver.cpp | 5 +- .../libMacGitverCore/App/MgvPrimaryWindow.cpp | 4 +- Libs/libMacGitverCore/CMakeLists.txt | 71 +--------- .../MacGitver/AutoRefresher.cpp | 2 +- .../Widgets/RepoStateWidget.cpp | 6 +- .../Widgets/RepoStateWidget.hpp | 2 +- .../Backend/RepoLocker.hpp | 2 +- .../Backend/RepoMan.cpp | 2 +- .../Backend/RepoMan.hpp | 2 +- Libs/libRepoMan/CMakeLists.txt | 130 ++++++++++++++++++ .../RepoMan => libRepoMan}/Core.hpp | 8 +- .../RepoMan => libRepoMan}/Data/Base.cpp | 7 +- .../RepoMan => libRepoMan}/Data/Base.hpp | 2 +- .../RepoMan => libRepoMan}/Data/Branch.cpp | 6 +- .../RepoMan => libRepoMan}/Data/Branch.hpp | 4 +- .../RepoMan => libRepoMan}/Data/Head.cpp | 6 +- .../RepoMan => libRepoMan}/Data/Head.hpp | 4 +- .../RepoMan => libRepoMan}/Data/Namespace.cpp | 0 .../RepoMan => libRepoMan}/Data/Namespace.hpp | 4 +- .../RepoMan => libRepoMan}/Data/RefLog.cpp | 0 .../RepoMan => libRepoMan}/Data/RefLog.hpp | 4 +- .../Data/RefTreeNode.cpp | 0 .../Data/RefTreeNode.hpp | 4 +- .../RepoMan => libRepoMan}/Data/Reference.cpp | 0 .../RepoMan => libRepoMan}/Data/Reference.hpp | 4 +- .../RepoMan => libRepoMan}/Data/Remote.cpp | 0 .../RepoMan => libRepoMan}/Data/Remote.hpp | 4 +- .../RepoMan => libRepoMan}/Data/Repo.cpp | 25 +++- .../RepoMan => libRepoMan}/Data/Repo.hpp | 7 +- .../RepoMan => libRepoMan}/Data/RepoMan.hpp | 6 +- .../RepoMan => libRepoMan}/Data/Submodule.cpp | 0 .../RepoMan => libRepoMan}/Data/Submodule.hpp | 4 +- .../RepoMan => libRepoMan}/Data/Tag.cpp | 0 .../RepoMan => libRepoMan}/Data/Tag.hpp | 4 +- .../RepoMan => libRepoMan}/Events.cpp | 2 +- .../RepoMan => libRepoMan}/Events.hpp | 6 +- .../RepoMan => libRepoMan}/Frontend/Base.cpp | 16 +-- .../RepoMan => libRepoMan}/Frontend/Base.hpp | 4 +- .../Frontend/BaseInternal.hpp | 4 +- .../Frontend/Branch.cpp | 12 +- .../Frontend/Branch.hpp | 4 +- .../RepoMan => libRepoMan}/Frontend/Head.cpp | 10 +- .../RepoMan => libRepoMan}/Frontend/Head.hpp | 4 +- .../Frontend/Namespace.cpp | 8 +- .../Frontend/Namespace.hpp | 4 +- .../Frontend/RefLog.cpp | 6 +- .../Frontend/RefLog.hpp | 4 +- .../Frontend/RefTreeNode.cpp | 8 +- .../Frontend/RefTreeNode.hpp | 4 +- .../Frontend/Reference.cpp | 12 +- .../Frontend/Reference.hpp | 2 +- .../Frontend/Remote.cpp | 10 +- .../Frontend/Remote.hpp | 4 +- .../RepoMan => libRepoMan}/Frontend/Repo.cpp | 38 +++-- .../RepoMan => libRepoMan}/Frontend/Repo.hpp | 4 +- .../Frontend/Submodule.cpp | 6 +- .../Frontend/Submodule.hpp | 4 +- .../RepoMan => libRepoMan}/Frontend/Tag.cpp | 8 +- .../RepoMan => libRepoMan}/Frontend/Tag.hpp | 5 +- .../RepoMan => libRepoMan}/Private/Dumper.cpp | 0 .../RepoMan => libRepoMan}/Private/Dumper.hpp | 0 .../Private/RepoManActions.hid | 0 .../RepoMan => libRepoMan}/RepoMan.cpp | 13 +- .../RepoMan => libRepoMan}/RepoMan.hpp | 6 +- Modules/GitConfig/GitConfigModule.cpp | 3 +- Modules/Logging/LoggingMode.cpp | 3 +- Modules/RepoManLogger/Listener.cpp | 8 +- Modules/RepoManLogger/Listener.hpp | 2 +- Modules/Repository/CreateRepositoryDlg.cpp | 3 +- Modules/Repository/RepoInfoModel.cpp | 3 +- Modules/Repository/RepoInfoModel.hpp | 2 +- Modules/Repository/RepoTreeView.cpp | 3 +- Modules/Repository/RepoTreeView.hpp | 2 +- Modules/Repository/RepositoryModule.cpp | 3 +- 76 files changed, 329 insertions(+), 243 deletions(-) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Backend/RepoLocker.hpp (97%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Backend/RepoMan.cpp (97%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Backend/RepoMan.hpp (97%) create mode 100644 Libs/libRepoMan/CMakeLists.txt rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Core.hpp (91%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Base.cpp (98%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Base.hpp (99%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Branch.cpp (95%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Branch.hpp (95%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Head.cpp (95%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Head.hpp (96%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Namespace.cpp (100%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Namespace.hpp (94%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/RefLog.cpp (100%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/RefLog.hpp (94%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/RefTreeNode.cpp (100%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/RefTreeNode.hpp (94%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Reference.cpp (100%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Reference.hpp (95%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Remote.cpp (100%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Remote.hpp (95%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Repo.cpp (77%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Repo.hpp (95%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/RepoMan.hpp (92%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Submodule.cpp (100%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Submodule.hpp (94%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Tag.cpp (100%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Data/Tag.hpp (94%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Events.cpp (99%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Events.hpp (98%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Base.cpp (95%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Base.hpp (97%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/BaseInternal.hpp (97%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Branch.cpp (88%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Branch.hpp (91%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Head.cpp (91%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Head.hpp (94%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Namespace.cpp (95%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Namespace.hpp (93%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/RefLog.cpp (94%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/RefLog.hpp (92%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/RefTreeNode.cpp (94%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/RefTreeNode.hpp (93%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Reference.cpp (95%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Reference.hpp (98%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Remote.cpp (94%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Remote.hpp (93%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Repo.cpp (96%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Repo.hpp (97%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Submodule.cpp (95%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Submodule.hpp (91%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Tag.cpp (93%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Frontend/Tag.hpp (91%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Private/Dumper.cpp (100%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Private/Dumper.hpp (100%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/Private/RepoManActions.hid (100%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/RepoMan.cpp (96%) rename Libs/{libMacGitverCore/RepoMan => libRepoMan}/RepoMan.hpp (97%) diff --git a/CMakeLists.txt b/CMakeLists.txt index fbed2818..e7e99317 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ ENABLE_TESTING() SET(UTILS_APP_NAME MacGitver) RAD_DEFINE_VERSION(MACGITVER_CORE 0 0 1) +RAD_DEFINE_VERSION(REPOMAN 0 0 1) ADD_SUBDIRECTORY(CfgComp) diff --git a/Libs/CMakeLists.txt b/Libs/CMakeLists.txt index 26912da6..b80fdabd 100644 --- a/Libs/CMakeLists.txt +++ b/Libs/CMakeLists.txt @@ -12,4 +12,6 @@ INCLUDE_DIRECTORIES( BEFORE ADD_SUBDIRECTORY(libLogger) ADD_SUBDIRECTORY(libDiffViews) +ADD_SUBDIRECTORY(libRepoMan) ADD_SUBDIRECTORY(libMacGitverCore) + diff --git a/Libs/libMacGitverCore/App/MacGitver.cpp b/Libs/libMacGitverCore/App/MacGitver.cpp index cbbc8594..f282d30b 100644 --- a/Libs/libMacGitverCore/App/MacGitver.cpp +++ b/Libs/libMacGitverCore/App/MacGitver.cpp @@ -32,11 +32,12 @@ #include "libMacGitverCore/App/MgvPrimaryWindow.hpp" #include "libMacGitverCore/Config/Config.h" #include "libMacGitverCore/Config/Ui/GeneralConfigPage.hpp" -#include "libMacGitverCore/Config/Ui//RepoManConfigPage.hpp" +#include "libMacGitverCore/Config/Ui/RepoManConfigPage.hpp" #include "libMacGitverCore/MacGitver/Modules.h" -#include "libMacGitverCore/RepoMan/RepoMan.hpp" #include "libMacGitverCore/MacGitver/AutoRefresher.hpp" +#include "libRepoMan/RepoMan.hpp" + /** * @class MacGitver * @brief Central core of the MacGitver application diff --git a/Libs/libMacGitverCore/App/MgvPrimaryWindow.cpp b/Libs/libMacGitverCore/App/MgvPrimaryWindow.cpp index 54b77419..bbba0f90 100644 --- a/Libs/libMacGitverCore/App/MgvPrimaryWindow.cpp +++ b/Libs/libMacGitverCore/App/MgvPrimaryWindow.cpp @@ -22,12 +22,12 @@ #include "libMacGitverCore/App/MgvPrimaryWindowPrivate.hpp" #include "libMacGitverCore/MacGitver/Modules.h" -#include "libMacGitverCore/RepoMan/RepoMan.hpp" - #include "libMacGitverCore/Config/Config.h" #include "libMacGitverCore/Config/Ui/ConfigDialog.hpp" #include "libMacGitverCore/Widgets/RepoStateWidget.hpp" +#include "libRepoMan/RepoMan.hpp" + #include "libBlueSky/Application.hpp" #include "libBlueSky/FooterWidget.hpp" diff --git a/Libs/libMacGitverCore/CMakeLists.txt b/Libs/libMacGitverCore/CMakeLists.txt index 01c0bb4f..9ed93c6a 100644 --- a/Libs/libMacGitverCore/CMakeLists.txt +++ b/Libs/libMacGitverCore/CMakeLists.txt @@ -27,37 +27,6 @@ SET( SRC_FILES MacGitver/GitPatchConsumer.cpp MacGitver/AutoRefresher.cpp - RepoMan/Events.cpp - RepoMan/RepoMan.cpp - - RepoMan/Frontend/Base.cpp - RepoMan/Frontend/Branch.cpp - RepoMan/Frontend/Namespace.cpp - RepoMan/Frontend/Reference.cpp - RepoMan/Frontend/RefLog.cpp - RepoMan/Frontend/RefTreeNode.cpp - RepoMan/Frontend/Remote.cpp - RepoMan/Frontend/Repo.cpp - RepoMan/Frontend/Submodule.cpp - RepoMan/Frontend/Tag.cpp - RepoMan/Frontend/Head.cpp - - RepoMan/Data/Base.cpp - RepoMan/Data/Branch.cpp - RepoMan/Data/Head.cpp - RepoMan/Data/Namespace.cpp - RepoMan/Data/Reference.cpp - RepoMan/Data/RefLog.cpp - RepoMan/Data/RefTreeNode.cpp - RepoMan/Data/Remote.cpp - RepoMan/Data/Repo.cpp - RepoMan/Data/Submodule.cpp - RepoMan/Data/Tag.cpp - - RepoMan/Private/Dumper.cpp - - RepoMan/Backend/RepoMan.cpp - SHMParser/ShellExpand.cpp Widgets/ExpandableDlg.cpp @@ -90,22 +59,6 @@ SET( PUB_HDR_FILES MacGitver/GitPatchConsumer.hpp MacGitver/IRepositoryContext.hpp - RepoMan/Core.hpp - RepoMan/Events.hpp - RepoMan/RepoMan.hpp - - RepoMan/Frontend/Base.hpp - RepoMan/Frontend/Reference.hpp - RepoMan/Frontend/Repo.hpp - RepoMan/Frontend/Remote.hpp - RepoMan/Frontend/Tag.hpp - RepoMan/Frontend/Branch.hpp - RepoMan/Frontend/RefLog.hpp - RepoMan/Frontend/Submodule.hpp - RepoMan/Frontend/RefTreeNode.hpp - RepoMan/Frontend/Namespace.hpp - RepoMan/Frontend/Head.hpp - SHMParser/ShellExpand.hpp Widgets/ExpandableDlg.hpp @@ -132,29 +85,11 @@ SET( PRI_HDR_FILES Config/Ui/GeneralConfigPage.hpp Config/Ui/RepoManConfigPage.hpp - RepoMan/Private/Dumper.hpp - - RepoMan/Data/Base.hpp - RepoMan/Data/Branch.hpp - RepoMan/Data/Namespace.hpp - RepoMan/Data/Reference.hpp - RepoMan/Data/RefLog.hpp - RepoMan/Data/RefTreeNode.hpp - RepoMan/Data/Remote.hpp - RepoMan/Data/Repo.hpp - RepoMan/Data/RepoMan.hpp - RepoMan/Data/Submodule.hpp - RepoMan/Data/Tag.hpp - RepoMan/Data/Head.hpp - - RepoMan/Frontend/BaseInternal.hpp - - RepoMan/Backend/RepoMan.hpp - RepoMan/Backend/RepoLocker.hpp - Widgets/StringSelectorWidgetPrivate.h Widgets/FlatTreeModelPrivate.h Widgets/RepoStateWidget.hpp + + MacGitver/AutoRefresher.hpp ) SET( UI_FILES @@ -171,7 +106,6 @@ SET( UI_FILES SET( HID_FILES App/MgvPrimaryWindowActions.hid - RepoMan/Private/RepoManActions.hid ) @@ -212,6 +146,7 @@ TARGET_LINK_LIBRARIES( HeavenIcons BlueSky Logger + RepoMan LINK_PRIVATE GitWrap diff --git a/Libs/libMacGitverCore/MacGitver/AutoRefresher.cpp b/Libs/libMacGitverCore/MacGitver/AutoRefresher.cpp index 49a89c22..311a4628 100644 --- a/Libs/libMacGitverCore/MacGitver/AutoRefresher.cpp +++ b/Libs/libMacGitverCore/MacGitver/AutoRefresher.cpp @@ -20,7 +20,7 @@ #include "libMacGitverCore/MacGitver/AutoRefresher.hpp" #include "AutoRefresherCfg.hpp" -#include "libMacGitverCore/RepoMan/RepoMan.hpp" +#include "libRepoMan/RepoMan.hpp" #include #include diff --git a/Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp b/Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp index 8aa4e6f0..bd26c3d2 100644 --- a/Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp +++ b/Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp @@ -25,10 +25,10 @@ #include "libHeavenIcons/IconRef.hpp" #include "libHeavenIcons/Icon.hpp" -#include "RepoMan/Frontend/Reference.hpp" -#include "RepoMan/Frontend/Repo.hpp" +#include "libRepoMan/Frontend/Reference.hpp" +#include "libRepoMan/Frontend/Repo.hpp" -#include "RepoMan/RepoMan.hpp" +#include "libRepoMan/RepoMan.hpp" #include "RepoStateWidget.hpp" diff --git a/Libs/libMacGitverCore/Widgets/RepoStateWidget.hpp b/Libs/libMacGitverCore/Widgets/RepoStateWidget.hpp index d65ab3d2..4d6a5bd3 100644 --- a/Libs/libMacGitverCore/Widgets/RepoStateWidget.hpp +++ b/Libs/libMacGitverCore/Widgets/RepoStateWidget.hpp @@ -19,7 +19,7 @@ #pragma once -#include "RepoMan/Frontend/Repo.hpp" +#include "libRepoMan/Frontend/Repo.hpp" class QLabel; diff --git a/Libs/libMacGitverCore/RepoMan/Backend/RepoLocker.hpp b/Libs/libRepoMan/Backend/RepoLocker.hpp similarity index 97% rename from Libs/libMacGitverCore/RepoMan/Backend/RepoLocker.hpp rename to Libs/libRepoMan/Backend/RepoLocker.hpp index 86f41a11..72438e92 100644 --- a/Libs/libMacGitverCore/RepoMan/Backend/RepoLocker.hpp +++ b/Libs/libRepoMan/Backend/RepoLocker.hpp @@ -19,7 +19,7 @@ #pragma once -#include "RepoMan/Data/Repo.hpp" +#include "libRepoMan/Data/Repo.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Backend/RepoMan.cpp b/Libs/libRepoMan/Backend/RepoMan.cpp similarity index 97% rename from Libs/libMacGitverCore/RepoMan/Backend/RepoMan.cpp rename to Libs/libRepoMan/Backend/RepoMan.cpp index a0855451..4687491c 100644 --- a/Libs/libMacGitverCore/RepoMan/Backend/RepoMan.cpp +++ b/Libs/libRepoMan/Backend/RepoMan.cpp @@ -17,7 +17,7 @@ * */ -#include "RepoMan/Backend/RepoMan.hpp" +#include "libRepoMan/Backend/RepoMan.hpp" #include #include diff --git a/Libs/libMacGitverCore/RepoMan/Backend/RepoMan.hpp b/Libs/libRepoMan/Backend/RepoMan.hpp similarity index 97% rename from Libs/libMacGitverCore/RepoMan/Backend/RepoMan.hpp rename to Libs/libRepoMan/Backend/RepoMan.hpp index 81e4b5d6..e93f3791 100644 --- a/Libs/libMacGitverCore/RepoMan/Backend/RepoMan.hpp +++ b/Libs/libRepoMan/Backend/RepoMan.hpp @@ -19,7 +19,7 @@ #pragma once -#include "RepoMan/Data/Repo.hpp" +#include "libRepoMan/Data/Repo.hpp" #include #include diff --git a/Libs/libRepoMan/CMakeLists.txt b/Libs/libRepoMan/CMakeLists.txt new file mode 100644 index 00000000..0a39f195 --- /dev/null +++ b/Libs/libRepoMan/CMakeLists.txt @@ -0,0 +1,130 @@ + +PROJECT(REPOMAN) + +QT_PREPARE(Core Gui Widgets) + +INCLUDE_DIRECTORIES( BEFORE + ${REPOMAN_SOURCE_DIR} + ${REPOMAN_BINARY_DIR} +) + +SET( SRC_FILES + + Events.cpp + RepoMan.cpp + + Frontend/Base.cpp + Frontend/Branch.cpp + Frontend/Namespace.cpp + Frontend/Reference.cpp + Frontend/RefLog.cpp + Frontend/RefTreeNode.cpp + Frontend/Remote.cpp + Frontend/Repo.cpp + Frontend/Submodule.cpp + Frontend/Tag.cpp + Frontend/Head.cpp + + Data/Base.cpp + Data/Branch.cpp + Data/Namespace.cpp + Data/Reference.cpp + Data/RefLog.cpp + Data/RefTreeNode.cpp + Data/Remote.cpp + Data/Repo.cpp + Data/Submodule.cpp + Data/Tag.cpp + Data/Head.cpp + + Private/Dumper.cpp + + Backend/RepoMan.cpp +) + +SET( PUB_HDR_FILES + + Core.hpp + Events.hpp + RepoMan.hpp + + Frontend/Base.hpp + Frontend/Reference.hpp + Frontend/Repo.hpp + Frontend/Remote.hpp + Frontend/Tag.hpp + Frontend/Branch.hpp + Frontend/RefLog.hpp + Frontend/Submodule.hpp + Frontend/RefTreeNode.hpp + Frontend/Namespace.hpp + Frontend/Head.hpp +) + +SET( PRI_HDR_FILES + + Private/Dumper.hpp + + Data/Base.hpp + Data/Branch.hpp + Data/Namespace.hpp + Data/Reference.hpp + Data/RefLog.hpp + Data/RefTreeNode.hpp + Data/Remote.hpp + Data/Repo.hpp + Data/RepoMan.hpp + Data/Submodule.hpp + Data/Tag.hpp + Data/Head.hpp + + Frontend/BaseInternal.hpp + + Backend/RepoMan.hpp + Backend/RepoLocker.hpp +) + +SET( HID_FILES + + Private/RepoManActions.hid +) + +SET( HDR_FILES ${PRI_HDR_FILES} ${PUB_HDR_FILES} ) + +QT_MOC( MOC_FILES ${HDR_FILES} ) +HIC( HIC_FILES ${HID_FILES} ) + +ADD_QT_LIBRARY( + RepoMan SHARED + + ${SRC_FILES} + ${HDR_FILES} + ${MOC_FILES} + ${HIC_FILES} ${HID_FILES} +) + +TARGET_LINK_LIBRARIES( + RepoMan + + LINK_PUBLIC + HeavenActions + HeavenIcons + BlueSky + + LINK_PRIVATE + GitWrap +) + +IF(UNIX AND NOT APPLE) + SET_TARGET_PROPERTIES( + RepoMan + PROPERTIES INSTALL_RPATH + "\$ORIGIN" + ) +ENDIF() + +RAD_DEFINE_VERSION(REPOMAN 0 0 1) +RAD_SET_TARGET_VERSION( RepoMan REPOMAN ) +RAD_INSTALL_LIBRARY( RepoMan RepoMan ) +RAD_INSTALL_HEADERS( libRepoMan ${PUB_HDR_FILES} ) +RAD_SPLIT_SOURCE_TREE( RepoMan ) diff --git a/Libs/libMacGitverCore/RepoMan/Core.hpp b/Libs/libRepoMan/Core.hpp similarity index 91% rename from Libs/libMacGitverCore/RepoMan/Core.hpp rename to Libs/libRepoMan/Core.hpp index 575d0115..a907ecf2 100644 --- a/Libs/libMacGitverCore/RepoMan/Core.hpp +++ b/Libs/libRepoMan/Core.hpp @@ -24,7 +24,13 @@ #include #include -#include "libMacGitverCore/MacGitverApi.hpp" +#include + +#ifdef RepoMan_EXPORTS +# define REPOMAN_API Q_DECL_EXPORT +#else +# define REPOMAN_API Q_DECL_IMPORT +#endif namespace Heaven { diff --git a/Libs/libMacGitverCore/RepoMan/Data/Base.cpp b/Libs/libRepoMan/Data/Base.cpp similarity index 98% rename from Libs/libMacGitverCore/RepoMan/Data/Base.cpp rename to Libs/libRepoMan/Data/Base.cpp index ebdb735f..c7333e11 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/Base.cpp +++ b/Libs/libRepoMan/Data/Base.cpp @@ -17,12 +17,11 @@ * */ -#include "RepoMan/Data/Base.hpp" +#include "libRepoMan/Data/Base.hpp" -#include "RepoMan/Frontend/Base.hpp" -#include "RepoMan/Frontend/Repo.hpp" +#include "libRepoMan/Frontend/Repo.hpp" -#include "RepoMan/Private/Dumper.hpp" +#include "libRepoMan/Private/Dumper.hpp" #include "libHeavenIcons/IconRef.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Data/Base.hpp b/Libs/libRepoMan/Data/Base.hpp similarity index 99% rename from Libs/libMacGitverCore/RepoMan/Data/Base.hpp rename to Libs/libRepoMan/Data/Base.hpp index c7506e5b..458cad74 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/Base.hpp +++ b/Libs/libRepoMan/Data/Base.hpp @@ -19,7 +19,7 @@ #pragma once -#include "RepoMan/Core.hpp" +#include "libRepoMan/Core.hpp" #include #include diff --git a/Libs/libMacGitverCore/RepoMan/Data/Branch.cpp b/Libs/libRepoMan/Data/Branch.cpp similarity index 95% rename from Libs/libMacGitverCore/RepoMan/Data/Branch.cpp rename to Libs/libRepoMan/Data/Branch.cpp index f159fdc6..bbf93812 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/Branch.cpp +++ b/Libs/libRepoMan/Data/Branch.cpp @@ -17,11 +17,11 @@ * */ -#include "RepoMan/Events.hpp" +#include "libRepoMan/Events.hpp" -#include "RepoMan/Data/Branch.hpp" +#include "libRepoMan/Data/Branch.hpp" -#include "RepoMan/Private/Dumper.hpp" +#include "libRepoMan/Private/Dumper.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Data/Branch.hpp b/Libs/libRepoMan/Data/Branch.hpp similarity index 95% rename from Libs/libMacGitverCore/RepoMan/Data/Branch.hpp rename to Libs/libRepoMan/Data/Branch.hpp index 5435afcf..23cdd606 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/Branch.hpp +++ b/Libs/libRepoMan/Data/Branch.hpp @@ -19,9 +19,9 @@ #pragma once -#include "RepoMan/Data/Reference.hpp" +#include "libRepoMan/Data/Reference.hpp" -#include "RepoMan/Frontend/Branch.hpp" +#include "libRepoMan/Frontend/Branch.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Data/Head.cpp b/Libs/libRepoMan/Data/Head.cpp similarity index 95% rename from Libs/libMacGitverCore/RepoMan/Data/Head.cpp rename to Libs/libRepoMan/Data/Head.cpp index a446c4d4..cf1f391d 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/Head.cpp +++ b/Libs/libRepoMan/Data/Head.cpp @@ -17,11 +17,11 @@ * */ -#include "RepoMan/Events.hpp" +#include "libRepoMan/Events.hpp" -#include "RepoMan/Data/Head.hpp" +#include "libRepoMan/Data/Head.hpp" -#include "RepoMan/Private/Dumper.hpp" +#include "libRepoMan/Private/Dumper.hpp" #include "libGitWrap/Repository.hpp" #include "libGitWrap/BranchRef.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Data/Head.hpp b/Libs/libRepoMan/Data/Head.hpp similarity index 96% rename from Libs/libMacGitverCore/RepoMan/Data/Head.hpp rename to Libs/libRepoMan/Data/Head.hpp index e4fcf189..0e31ae13 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/Head.hpp +++ b/Libs/libRepoMan/Data/Head.hpp @@ -19,9 +19,9 @@ #pragma once -#include "RepoMan/Data/Base.hpp" +#include "libRepoMan/Data/Base.hpp" -#include "RepoMan/Frontend/Head.hpp" +#include "libRepoMan/Frontend/Head.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Data/Namespace.cpp b/Libs/libRepoMan/Data/Namespace.cpp similarity index 100% rename from Libs/libMacGitverCore/RepoMan/Data/Namespace.cpp rename to Libs/libRepoMan/Data/Namespace.cpp diff --git a/Libs/libMacGitverCore/RepoMan/Data/Namespace.hpp b/Libs/libRepoMan/Data/Namespace.hpp similarity index 94% rename from Libs/libMacGitverCore/RepoMan/Data/Namespace.hpp rename to Libs/libRepoMan/Data/Namespace.hpp index 6db03dfc..76c6804f 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/Namespace.hpp +++ b/Libs/libRepoMan/Data/Namespace.hpp @@ -19,9 +19,9 @@ #pragma once -#include "RepoMan/Data/Base.hpp" +#include "libRepoMan/Data/Base.hpp" -#include "RepoMan/Frontend/Namespace.hpp" +#include "libRepoMan/Frontend/Namespace.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Data/RefLog.cpp b/Libs/libRepoMan/Data/RefLog.cpp similarity index 100% rename from Libs/libMacGitverCore/RepoMan/Data/RefLog.cpp rename to Libs/libRepoMan/Data/RefLog.cpp diff --git a/Libs/libMacGitverCore/RepoMan/Data/RefLog.hpp b/Libs/libRepoMan/Data/RefLog.hpp similarity index 94% rename from Libs/libMacGitverCore/RepoMan/Data/RefLog.hpp rename to Libs/libRepoMan/Data/RefLog.hpp index 322fc62a..1f697948 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/RefLog.hpp +++ b/Libs/libRepoMan/Data/RefLog.hpp @@ -19,9 +19,9 @@ #pragma once -#include "RepoMan/Data/Base.hpp" +#include "libRepoMan/Data/Base.hpp" -#include "RepoMan/Frontend/RefLog.hpp" +#include "libRepoMan/Frontend/RefLog.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Data/RefTreeNode.cpp b/Libs/libRepoMan/Data/RefTreeNode.cpp similarity index 100% rename from Libs/libMacGitverCore/RepoMan/Data/RefTreeNode.cpp rename to Libs/libRepoMan/Data/RefTreeNode.cpp diff --git a/Libs/libMacGitverCore/RepoMan/Data/RefTreeNode.hpp b/Libs/libRepoMan/Data/RefTreeNode.hpp similarity index 94% rename from Libs/libMacGitverCore/RepoMan/Data/RefTreeNode.hpp rename to Libs/libRepoMan/Data/RefTreeNode.hpp index 759e4eac..ff6989b2 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/RefTreeNode.hpp +++ b/Libs/libRepoMan/Data/RefTreeNode.hpp @@ -19,9 +19,9 @@ #pragma once -#include "RepoMan/Data/Base.hpp" +#include "libRepoMan/Data/Base.hpp" -#include "RepoMan/Frontend/RefTreeNode.hpp" +#include "libRepoMan/Frontend/RefTreeNode.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Data/Reference.cpp b/Libs/libRepoMan/Data/Reference.cpp similarity index 100% rename from Libs/libMacGitverCore/RepoMan/Data/Reference.cpp rename to Libs/libRepoMan/Data/Reference.cpp diff --git a/Libs/libMacGitverCore/RepoMan/Data/Reference.hpp b/Libs/libRepoMan/Data/Reference.hpp similarity index 95% rename from Libs/libMacGitverCore/RepoMan/Data/Reference.hpp rename to Libs/libRepoMan/Data/Reference.hpp index 8e1dac3d..e07c5ef6 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/Reference.hpp +++ b/Libs/libRepoMan/Data/Reference.hpp @@ -19,9 +19,9 @@ #pragma once -#include "RepoMan/Data/Base.hpp" +#include "libRepoMan/Data/Base.hpp" -#include "RepoMan/Frontend/Reference.hpp" +#include "libRepoMan/Frontend/Reference.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Data/Remote.cpp b/Libs/libRepoMan/Data/Remote.cpp similarity index 100% rename from Libs/libMacGitverCore/RepoMan/Data/Remote.cpp rename to Libs/libRepoMan/Data/Remote.cpp diff --git a/Libs/libMacGitverCore/RepoMan/Data/Remote.hpp b/Libs/libRepoMan/Data/Remote.hpp similarity index 95% rename from Libs/libMacGitverCore/RepoMan/Data/Remote.hpp rename to Libs/libRepoMan/Data/Remote.hpp index 78f96b95..3d8f8b44 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/Remote.hpp +++ b/Libs/libRepoMan/Data/Remote.hpp @@ -19,9 +19,9 @@ #pragma once -#include "RepoMan/Data/Base.hpp" +#include "libRepoMan/Data/Base.hpp" -#include "RepoMan/Frontend/Remote.hpp" +#include "libRepoMan/Frontend/Remote.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Data/Repo.cpp b/Libs/libRepoMan/Data/Repo.cpp similarity index 77% rename from Libs/libMacGitverCore/RepoMan/Data/Repo.cpp rename to Libs/libRepoMan/Data/Repo.cpp index 69d31b36..b634e732 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/Repo.cpp +++ b/Libs/libRepoMan/Data/Repo.cpp @@ -17,7 +17,7 @@ * */ -#include "RepoMan/Data/Repo.hpp" +#include "libRepoMan/Data/Repo.hpp" #include @@ -64,6 +64,29 @@ namespace RM return Repo::SPtr(); } + ObjTypes Repo::objType() const + { + return ObjTypes::Repo; + } + + QString Repo::displayName() const + { + return QStringLiteral("Repo"); + } + + void Repo::dumpSelf(Internal::Dumper& dumper) const + { + } + + QString Repo::objectTypeName() const + { + } + + bool Repo::inherits(ObjTypes type) const + { + return type == ObjTypes::Repo || Base::inherits(type); + } + } } diff --git a/Libs/libMacGitverCore/RepoMan/Data/Repo.hpp b/Libs/libRepoMan/Data/Repo.hpp similarity index 95% rename from Libs/libMacGitverCore/RepoMan/Data/Repo.hpp rename to Libs/libRepoMan/Data/Repo.hpp index 3d0152ba..9632b313 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/Repo.hpp +++ b/Libs/libRepoMan/Data/Repo.hpp @@ -19,9 +19,9 @@ #pragma once -#include "RepoMan/Data/Base.hpp" +#include "libRepoMan/Data/Base.hpp" -#include "RepoMan/Frontend/Repo.hpp" +#include "libRepoMan/Frontend/Repo.hpp" class QTimer; @@ -55,9 +55,6 @@ namespace RM public: ObjTypes objType() const; - bool refreshSelf(); - void preTerminate(); - void postRefreshChildren(); QString displayName() const; void dumpSelf(Internal::Dumper& dumper) const; QString objectTypeName() const; diff --git a/Libs/libMacGitverCore/RepoMan/Data/RepoMan.hpp b/Libs/libRepoMan/Data/RepoMan.hpp similarity index 92% rename from Libs/libMacGitverCore/RepoMan/Data/RepoMan.hpp rename to Libs/libRepoMan/Data/RepoMan.hpp index f3c0cc1e..0b1c25f9 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/RepoMan.hpp +++ b/Libs/libRepoMan/Data/RepoMan.hpp @@ -19,9 +19,9 @@ #pragma once -#include "libMacGitverCore/RepoMan/Data/Base.hpp" +#include "libRepoMan/Data/Base.hpp" -#include "libMacGitverCore/RepoMan/RepoMan.hpp" +#include "libRepoMan/RepoMan.hpp" #include "libMacGitverCore/MacGitver/AutoRefresher.hpp" @@ -38,7 +38,7 @@ namespace RM { public: RepoMan(RepoMan* _pub); - + Heaven::Menu* contextMenuFor(Base* object); public: diff --git a/Libs/libMacGitverCore/RepoMan/Data/Submodule.cpp b/Libs/libRepoMan/Data/Submodule.cpp similarity index 100% rename from Libs/libMacGitverCore/RepoMan/Data/Submodule.cpp rename to Libs/libRepoMan/Data/Submodule.cpp diff --git a/Libs/libMacGitverCore/RepoMan/Data/Submodule.hpp b/Libs/libRepoMan/Data/Submodule.hpp similarity index 94% rename from Libs/libMacGitverCore/RepoMan/Data/Submodule.hpp rename to Libs/libRepoMan/Data/Submodule.hpp index d89f30ef..8cb02afd 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/Submodule.hpp +++ b/Libs/libRepoMan/Data/Submodule.hpp @@ -19,9 +19,9 @@ #pragma once -#include "RepoMan/Data/Repo.hpp" +#include "libRepoMan/Data/Repo.hpp" -#include "RepoMan/Frontend/Submodule.hpp" +#include "libRepoMan/Frontend/Submodule.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Data/Tag.cpp b/Libs/libRepoMan/Data/Tag.cpp similarity index 100% rename from Libs/libMacGitverCore/RepoMan/Data/Tag.cpp rename to Libs/libRepoMan/Data/Tag.cpp diff --git a/Libs/libMacGitverCore/RepoMan/Data/Tag.hpp b/Libs/libRepoMan/Data/Tag.hpp similarity index 94% rename from Libs/libMacGitverCore/RepoMan/Data/Tag.hpp rename to Libs/libRepoMan/Data/Tag.hpp index 3f4b367e..6064587c 100644 --- a/Libs/libMacGitverCore/RepoMan/Data/Tag.hpp +++ b/Libs/libRepoMan/Data/Tag.hpp @@ -19,9 +19,9 @@ #pragma once -#include "RepoMan/Data/Reference.hpp" +#include "libRepoMan/Data/Reference.hpp" -#include "RepoMan/Frontend/Tag.hpp" +#include "libRepoMan/Frontend/Tag.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Events.cpp b/Libs/libRepoMan/Events.cpp similarity index 99% rename from Libs/libMacGitverCore/RepoMan/Events.cpp rename to Libs/libRepoMan/Events.cpp index f208fd68..45db5a75 100644 --- a/Libs/libMacGitverCore/RepoMan/Events.cpp +++ b/Libs/libRepoMan/Events.cpp @@ -17,7 +17,7 @@ * */ -#include "RepoMan/Events.hpp" +#include "libRepoMan/Events.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Events.hpp b/Libs/libRepoMan/Events.hpp similarity index 98% rename from Libs/libMacGitverCore/RepoMan/Events.hpp rename to Libs/libRepoMan/Events.hpp index 738a6f66..6bb6fe7c 100644 --- a/Libs/libMacGitverCore/RepoMan/Events.hpp +++ b/Libs/libRepoMan/Events.hpp @@ -19,7 +19,7 @@ #pragma once -#include "libMacGitverCore/RepoMan/Core.hpp" +#include "libRepoMan/Core.hpp" #include @@ -40,7 +40,7 @@ namespace RM class Tag; } - class MGV_CORE_API EventsInterface + class REPOMAN_API EventsInterface { public: virtual ~EventsInterface() {} @@ -92,7 +92,7 @@ namespace RM virtual void workTreeUpdated(const RM::Frontend::Repo& repo) = 0; }; - class MGV_CORE_API Events // : public EventsInterface + class REPOMAN_API Events // : public EventsInterface { private: Events(); diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Base.cpp b/Libs/libRepoMan/Frontend/Base.cpp similarity index 95% rename from Libs/libMacGitverCore/RepoMan/Frontend/Base.cpp rename to Libs/libRepoMan/Frontend/Base.cpp index fba0cfb0..dbda6a98 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Base.cpp +++ b/Libs/libRepoMan/Frontend/Base.cpp @@ -17,18 +17,18 @@ * */ -#include "App/MacGitver.hpp" +//#include "App/MacGitver.hpp" -#include "RepoMan/Frontend/BaseInternal.hpp" -#include "RepoMan/Frontend/Repo.hpp" -#include "RepoMan/RepoMan.hpp" -#include "RepoMan/Frontend/RefTreeNode.hpp" +#include "libRepoMan/Frontend/BaseInternal.hpp" +#include "libRepoMan/Frontend/Repo.hpp" +#include "libRepoMan/RepoMan.hpp" +#include "libRepoMan/Frontend/RefTreeNode.hpp" -#include "RepoMan/Events.hpp" +#include "libRepoMan/Events.hpp" -#include "RepoMan/Data/Base.hpp" +#include "libRepoMan/Data/Base.hpp" -#include "RepoMan/Private/Dumper.hpp" +#include "libRepoMan/Private/Dumper.hpp" #include "libHeavenIcons/IconRef.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Base.hpp b/Libs/libRepoMan/Frontend/Base.hpp similarity index 97% rename from Libs/libMacGitverCore/RepoMan/Frontend/Base.hpp rename to Libs/libRepoMan/Frontend/Base.hpp index c2a3a586..0eac9406 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Base.hpp +++ b/Libs/libRepoMan/Frontend/Base.hpp @@ -19,7 +19,7 @@ #pragma once -#include "libMacGitverCore/RepoMan/Core.hpp" +#include "libRepoMan/Core.hpp" namespace RM { @@ -37,7 +37,7 @@ namespace RM namespace Frontend { - class MGV_CORE_API Base + class REPOMAN_API Base { public: using List = std::vector; diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/BaseInternal.hpp b/Libs/libRepoMan/Frontend/BaseInternal.hpp similarity index 97% rename from Libs/libMacGitverCore/RepoMan/Frontend/BaseInternal.hpp rename to Libs/libRepoMan/Frontend/BaseInternal.hpp index 6e94ed4b..78a1446b 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/BaseInternal.hpp +++ b/Libs/libRepoMan/Frontend/BaseInternal.hpp @@ -19,8 +19,8 @@ #pragma once -#include "RepoMan/Frontend/Base.hpp" -#include "RepoMan/Backend/RepoLocker.hpp" +#include "libRepoMan/Frontend/Base.hpp" +#include "libRepoMan/Backend/RepoLocker.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp b/Libs/libRepoMan/Frontend/Branch.cpp similarity index 88% rename from Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp rename to Libs/libRepoMan/Frontend/Branch.cpp index 032eb75d..3671759c 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Branch.cpp +++ b/Libs/libRepoMan/Frontend/Branch.cpp @@ -17,15 +17,15 @@ * */ -#include "RepoMan/Frontend/Branch.hpp" -#include "RepoMan/Frontend/Repo.hpp" -#include "RepoMan/Frontend/Head.hpp" +#include "libRepoMan/Frontend/Branch.hpp" +#include "libRepoMan/Frontend/Repo.hpp" +#include "libRepoMan/Frontend/Head.hpp" -#include "RepoMan/Events.hpp" +#include "libRepoMan/Events.hpp" -#include "RepoMan/Private/Dumper.hpp" +#include "libRepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/Branch.hpp" +#include "libRepoMan/Data/Branch.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Branch.hpp b/Libs/libRepoMan/Frontend/Branch.hpp similarity index 91% rename from Libs/libMacGitverCore/RepoMan/Frontend/Branch.hpp rename to Libs/libRepoMan/Frontend/Branch.hpp index 0e6c8f69..38abdabe 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Branch.hpp +++ b/Libs/libRepoMan/Frontend/Branch.hpp @@ -19,7 +19,7 @@ #pragma once -#include "libMacGitverCore/RepoMan/Frontend/Reference.hpp" +#include "libRepoMan/Frontend/Reference.hpp" namespace RM { @@ -27,7 +27,7 @@ namespace RM namespace Frontend { - class MGV_CORE_API Branch : public Reference + class REPOMAN_API Branch : public Reference { public: static const ObjTypes StaticObjectType = ObjTypes::Branch; diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp b/Libs/libRepoMan/Frontend/Head.cpp similarity index 91% rename from Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp rename to Libs/libRepoMan/Frontend/Head.cpp index 151ca34f..39190171 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Head.cpp +++ b/Libs/libRepoMan/Frontend/Head.cpp @@ -17,14 +17,14 @@ * */ -#include "RepoMan/Events.hpp" +#include "libRepoMan/Events.hpp" -#include "RepoMan/Frontend/Head.hpp" -#include "RepoMan/Frontend/Repo.hpp" +#include "libRepoMan/Private/Dumper.hpp" -#include "RepoMan/Private/Dumper.hpp" +#include "libRepoMan/Data/Head.hpp" -#include "RepoMan/Data/Head.hpp" +#include "libRepoMan/Frontend/Branch.hpp" +#include "libRepoMan/Frontend/Repo.hpp" #include "libGitWrap/Repository.hpp" diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Head.hpp b/Libs/libRepoMan/Frontend/Head.hpp similarity index 94% rename from Libs/libMacGitverCore/RepoMan/Frontend/Head.hpp rename to Libs/libRepoMan/Frontend/Head.hpp index b966521f..6478e4b9 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Head.hpp +++ b/Libs/libRepoMan/Frontend/Head.hpp @@ -19,7 +19,7 @@ #pragma once -#include "RepoMan/Frontend/Branch.hpp" +#include "libRepoMan/Frontend/Branch.hpp" namespace RM { @@ -31,7 +31,7 @@ namespace RM namespace Frontend { - class MGV_CORE_API Head : public Base + class REPOMAN_API Head : public Base { public: static const ObjTypes StaticObjectType = ObjTypes::Head; diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Namespace.cpp b/Libs/libRepoMan/Frontend/Namespace.cpp similarity index 95% rename from Libs/libMacGitverCore/RepoMan/Frontend/Namespace.cpp rename to Libs/libRepoMan/Frontend/Namespace.cpp index 824051a6..e1d15803 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Namespace.cpp +++ b/Libs/libRepoMan/Frontend/Namespace.cpp @@ -17,12 +17,12 @@ * */ -#include "RepoMan/Events.hpp" +#include "libRepoMan/Events.hpp" -#include "RepoMan/Frontend/Namespace.hpp" +#include "libRepoMan/Frontend/Namespace.hpp" -#include "RepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/Namespace.hpp" +#include "libRepoMan/Private/Dumper.hpp" +#include "libRepoMan/Data/Namespace.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Namespace.hpp b/Libs/libRepoMan/Frontend/Namespace.hpp similarity index 93% rename from Libs/libMacGitverCore/RepoMan/Frontend/Namespace.hpp rename to Libs/libRepoMan/Frontend/Namespace.hpp index 7390c86a..39c02ddf 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Namespace.hpp +++ b/Libs/libRepoMan/Frontend/Namespace.hpp @@ -19,7 +19,7 @@ #pragma once -#include "libMacGitverCore/RepoMan/Frontend/Base.hpp" +#include "libRepoMan/Frontend/Base.hpp" namespace RM { @@ -32,7 +32,7 @@ namespace RM namespace Frontend { - class MGV_CORE_API Namespace : public Base + class REPOMAN_API Namespace : public Base { public: static const ObjTypes StaticObjectType = ObjTypes::Namespace; diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/RefLog.cpp b/Libs/libRepoMan/Frontend/RefLog.cpp similarity index 94% rename from Libs/libMacGitverCore/RepoMan/Frontend/RefLog.cpp rename to Libs/libRepoMan/Frontend/RefLog.cpp index e952d18c..bcacc3ac 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/RefLog.cpp +++ b/Libs/libRepoMan/Frontend/RefLog.cpp @@ -17,11 +17,11 @@ * */ -#include "RepoMan/Frontend/RefLog.hpp" +#include "libRepoMan/Frontend/RefLog.hpp" -#include "RepoMan/Data/RefLog.hpp" +#include "libRepoMan/Data/RefLog.hpp" -#include "RepoMan/Private/Dumper.hpp" +#include "libRepoMan/Private/Dumper.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/RefLog.hpp b/Libs/libRepoMan/Frontend/RefLog.hpp similarity index 92% rename from Libs/libMacGitverCore/RepoMan/Frontend/RefLog.hpp rename to Libs/libRepoMan/Frontend/RefLog.hpp index 231d56d6..8d375456 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/RefLog.hpp +++ b/Libs/libRepoMan/Frontend/RefLog.hpp @@ -19,7 +19,7 @@ #pragma once -#include "libMacGitverCore/RepoMan/Frontend/Base.hpp" +#include "libRepoMan/Frontend/Base.hpp" namespace RM { @@ -32,7 +32,7 @@ namespace RM namespace Frontend { - class MGV_CORE_API RefLog + class REPOMAN_API RefLog : public Base { public: diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.cpp b/Libs/libRepoMan/Frontend/RefTreeNode.cpp similarity index 94% rename from Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.cpp rename to Libs/libRepoMan/Frontend/RefTreeNode.cpp index 5a3b115c..110ce0c1 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.cpp +++ b/Libs/libRepoMan/Frontend/RefTreeNode.cpp @@ -17,13 +17,13 @@ * */ -#include "RepoMan/Events.hpp" +#include "libRepoMan/Events.hpp" -#include "RepoMan/Frontend/RefTreeNode.hpp" +#include "libRepoMan/Frontend/RefTreeNode.hpp" -#include "RepoMan/Private/Dumper.hpp" +#include "libRepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/RefTreeNode.hpp" +#include "libRepoMan/Data/RefTreeNode.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.hpp b/Libs/libRepoMan/Frontend/RefTreeNode.hpp similarity index 93% rename from Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.hpp rename to Libs/libRepoMan/Frontend/RefTreeNode.hpp index 9a8935f9..4e08c9c4 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/RefTreeNode.hpp +++ b/Libs/libRepoMan/Frontend/RefTreeNode.hpp @@ -19,7 +19,7 @@ #pragma once -#include "libMacGitverCore/RepoMan/Frontend/Base.hpp" +#include "libRepoMan/Frontend/Base.hpp" #include @@ -34,7 +34,7 @@ namespace RM namespace Frontend { - class MGV_CORE_API RefTreeNode + class REPOMAN_API RefTreeNode : public Base { public: diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Reference.cpp b/Libs/libRepoMan/Frontend/Reference.cpp similarity index 95% rename from Libs/libMacGitverCore/RepoMan/Frontend/Reference.cpp rename to Libs/libRepoMan/Frontend/Reference.cpp index 926a6e30..0f44c30d 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Reference.cpp +++ b/Libs/libRepoMan/Frontend/Reference.cpp @@ -21,15 +21,15 @@ #include "libGitWrap/Reference.hpp" #include "libGitWrap/RefName.hpp" -#include "RepoMan/Events.hpp" +#include "libRepoMan/Events.hpp" -#include "RepoMan/Frontend/BaseInternal.hpp" -#include "RepoMan/Frontend/Reference.hpp" -#include "RepoMan/Frontend/Repo.hpp" +#include "libRepoMan/Frontend/BaseInternal.hpp" +#include "libRepoMan/Frontend/Reference.hpp" +#include "libRepoMan/Frontend/Repo.hpp" -#include "RepoMan/Data/Reference.hpp" +#include "libRepoMan/Data/Reference.hpp" -#include "RepoMan/Private/Dumper.hpp" +#include "libRepoMan/Private/Dumper.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Reference.hpp b/Libs/libRepoMan/Frontend/Reference.hpp similarity index 98% rename from Libs/libMacGitverCore/RepoMan/Frontend/Reference.hpp rename to Libs/libRepoMan/Frontend/Reference.hpp index 959eb445..9e445cee 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Reference.hpp +++ b/Libs/libRepoMan/Frontend/Reference.hpp @@ -40,7 +40,7 @@ namespace RM namespace Frontend { - class MGV_CORE_API Reference + class REPOMAN_API Reference : public Base { public: diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Remote.cpp b/Libs/libRepoMan/Frontend/Remote.cpp similarity index 94% rename from Libs/libMacGitverCore/RepoMan/Frontend/Remote.cpp rename to Libs/libRepoMan/Frontend/Remote.cpp index 705bbc4a..b590eddf 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Remote.cpp +++ b/Libs/libRepoMan/Frontend/Remote.cpp @@ -19,14 +19,14 @@ #include "libGitWrap/Result.hpp" -#include "RepoMan/Events.hpp" +#include "libRepoMan/Events.hpp" -#include "RepoMan/Frontend/Repo.hpp" -#include "RepoMan/Frontend/Remote.hpp" +#include "libRepoMan/Frontend/Repo.hpp" +#include "libRepoMan/Frontend/Remote.hpp" -#include "RepoMan/Private/Dumper.hpp" +#include "libRepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/Remote.hpp" +#include "libRepoMan/Data/Remote.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Remote.hpp b/Libs/libRepoMan/Frontend/Remote.hpp similarity index 93% rename from Libs/libMacGitverCore/RepoMan/Frontend/Remote.hpp rename to Libs/libRepoMan/Frontend/Remote.hpp index 106a03e9..58e6bdbd 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Remote.hpp +++ b/Libs/libRepoMan/Frontend/Remote.hpp @@ -21,7 +21,7 @@ #include "libGitWrap/Remote.hpp" -#include "libMacGitverCore/Repoman/Frontend/Base.hpp" +#include "libRepoman/Frontend/Base.hpp" namespace RM { @@ -34,7 +34,7 @@ namespace RM namespace Frontend { - class MGV_CORE_API Remote : public Base + class REPOMAN_API Remote : public Base { public: static const ObjTypes StaticObjectType = ObjTypes::Remote; diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Repo.cpp b/Libs/libRepoMan/Frontend/Repo.cpp similarity index 96% rename from Libs/libMacGitverCore/RepoMan/Frontend/Repo.cpp rename to Libs/libRepoMan/Frontend/Repo.cpp index 3025b83f..ea626a42 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Repo.cpp +++ b/Libs/libRepoMan/Frontend/Repo.cpp @@ -22,26 +22,24 @@ #include "libGitWrap/RefName.hpp" #include "libGitWrap/Submodule.hpp" -#include "libMacGitverCore/App/MacGitver.hpp" - -#include "RepoMan/Events.hpp" -#include "RepoMan/RepoMan.hpp" - -#include "RepoMan/Frontend/BaseInternal.hpp" -#include "RepoMan/Frontend/Repo.hpp" -#include "RepoMan/Frontend/Head.hpp" -#include "RepoMan/Frontend/Remote.hpp" -#include "RepoMan/Frontend/Namespace.hpp" -#include "RepoMan/Frontend/Reference.hpp" -#include "RepoMan/Frontend/Tag.hpp" -#include "RepoMan/Frontend/Branch.hpp" -#include "RepoMan/Frontend/Submodule.hpp" - -#include "RepoMan/Private/Dumper.hpp" - -#include "RepoMan/Data/Repo.hpp" -#include "RepoMan/Data/Head.hpp" -#include "RepoMan/Data/Remote.hpp" +#include "libRepoMan/Events.hpp" +#include "libRepoMan/RepoMan.hpp" + +#include "libRepoMan/Frontend/BaseInternal.hpp" +#include "libRepoMan/Frontend/Repo.hpp" +#include "libRepoMan/Frontend/Head.hpp" +#include "libRepoMan/Frontend/Remote.hpp" +#include "libRepoMan/Frontend/Namespace.hpp" +#include "libRepoMan/Frontend/Reference.hpp" +#include "libRepoMan/Frontend/Tag.hpp" +#include "libRepoMan/Frontend/Branch.hpp" +#include "libRepoMan/Frontend/Submodule.hpp" + +#include "libRepoMan/Private/Dumper.hpp" + +#include "libRepoMan/Data/Repo.hpp" +#include "libRepoMan/Data/Head.hpp" +#include "libRepoMan/Data/Remote.hpp" #include diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Repo.hpp b/Libs/libRepoMan/Frontend/Repo.hpp similarity index 97% rename from Libs/libMacGitverCore/RepoMan/Frontend/Repo.hpp rename to Libs/libRepoMan/Frontend/Repo.hpp index 132d0a1c..07629104 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Repo.hpp +++ b/Libs/libRepoMan/Frontend/Repo.hpp @@ -21,7 +21,7 @@ #include "libGitWrap/Repository.hpp" -#include "libMacGitverCore/RepoMan/Frontend/Base.hpp" +#include "libRepoMan/Frontend/Base.hpp" namespace RM { @@ -37,7 +37,7 @@ namespace RM namespace Frontend { - class MGV_CORE_API Repo + class REPOMAN_API Repo : public Base { friend class RepoMan; diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Submodule.cpp b/Libs/libRepoMan/Frontend/Submodule.cpp similarity index 95% rename from Libs/libMacGitverCore/RepoMan/Frontend/Submodule.cpp rename to Libs/libRepoMan/Frontend/Submodule.cpp index 54aceefc..584026bf 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Submodule.cpp +++ b/Libs/libRepoMan/Frontend/Submodule.cpp @@ -17,11 +17,11 @@ * */ -#include "RepoMan/Events.hpp" +#include "libRepoMan/Events.hpp" -#include "RepoMan/Data/Submodule.hpp" +#include "libRepoMan/Data/Submodule.hpp" -#include "RepoMan/Private/Dumper.hpp" +#include "libRepoMan/Private/Dumper.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Submodule.hpp b/Libs/libRepoMan/Frontend/Submodule.hpp similarity index 91% rename from Libs/libMacGitverCore/RepoMan/Frontend/Submodule.hpp rename to Libs/libRepoMan/Frontend/Submodule.hpp index a53acb73..af9026b7 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Submodule.hpp +++ b/Libs/libRepoMan/Frontend/Submodule.hpp @@ -19,7 +19,7 @@ #pragma once -#include "libMacGitverCore/Repoman/Frontend/Repo.hpp" +#include "libRepoman/Frontend/Repo.hpp" namespace RM { @@ -27,7 +27,7 @@ namespace RM namespace Frontend { - class MGV_CORE_API Submodule : public Repo + class REPOMAN_API Submodule : public Repo { public: static const ObjTypes StaticObjectType = ObjTypes::Submodule; diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Tag.cpp b/Libs/libRepoMan/Frontend/Tag.cpp similarity index 93% rename from Libs/libMacGitverCore/RepoMan/Frontend/Tag.cpp rename to Libs/libRepoMan/Frontend/Tag.cpp index 476c6438..340b8c2a 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Tag.cpp +++ b/Libs/libRepoMan/Frontend/Tag.cpp @@ -17,13 +17,13 @@ * */ -#include "RepoMan/Events.hpp" +#include "libRepoMan/Events.hpp" -#include "RepoMan/Frontend/Tag.hpp" +#include "libRepoMan/Frontend/Tag.hpp" -#include "RepoMan/Private/Dumper.hpp" +#include "libRepoMan/Private/Dumper.hpp" -#include "RepoMan/Data/Tag.hpp" +#include "libRepoMan/Data/Tag.hpp" namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/Frontend/Tag.hpp b/Libs/libRepoMan/Frontend/Tag.hpp similarity index 91% rename from Libs/libMacGitverCore/RepoMan/Frontend/Tag.hpp rename to Libs/libRepoMan/Frontend/Tag.hpp index 6149bcc8..ae0a85d5 100644 --- a/Libs/libMacGitverCore/RepoMan/Frontend/Tag.hpp +++ b/Libs/libRepoMan/Frontend/Tag.hpp @@ -19,7 +19,7 @@ #pragma once -#include "libMacGitverCore/RepoMan/Frontend/Reference.hpp" +#include "libRepoMan/Frontend/Reference.hpp" namespace RM { @@ -27,7 +27,8 @@ namespace RM namespace Frontend { - class MGV_CORE_API Tag : public Reference + class REPOMAN_API Tag + : public Reference { public: static const ObjTypes StaticObjectType = ObjTypes::Tag; diff --git a/Libs/libMacGitverCore/RepoMan/Private/Dumper.cpp b/Libs/libRepoMan/Private/Dumper.cpp similarity index 100% rename from Libs/libMacGitverCore/RepoMan/Private/Dumper.cpp rename to Libs/libRepoMan/Private/Dumper.cpp diff --git a/Libs/libMacGitverCore/RepoMan/Private/Dumper.hpp b/Libs/libRepoMan/Private/Dumper.hpp similarity index 100% rename from Libs/libMacGitverCore/RepoMan/Private/Dumper.hpp rename to Libs/libRepoMan/Private/Dumper.hpp diff --git a/Libs/libMacGitverCore/RepoMan/Private/RepoManActions.hid b/Libs/libRepoMan/Private/RepoManActions.hid similarity index 100% rename from Libs/libMacGitverCore/RepoMan/Private/RepoManActions.hid rename to Libs/libRepoMan/Private/RepoManActions.hid diff --git a/Libs/libMacGitverCore/RepoMan/RepoMan.cpp b/Libs/libRepoMan/RepoMan.cpp similarity index 96% rename from Libs/libMacGitverCore/RepoMan/RepoMan.cpp rename to Libs/libRepoMan/RepoMan.cpp index 33d5939d..d943df1f 100644 --- a/Libs/libMacGitverCore/RepoMan/RepoMan.cpp +++ b/Libs/libRepoMan/RepoMan.cpp @@ -17,19 +17,18 @@ * */ -#include "libMacGitverCore/App/MacGitver.hpp" +#include "libRepoMan/RepoMan.hpp" +#include "libRepoMan/Events.hpp" -#include "RepoMan/RepoMan.hpp" -#include "RepoMan/Events.hpp" +#include "libRepoMan/Private/Dumper.hpp" -#include "RepoMan/Private/Dumper.hpp" - -#include "RepoMan/Data/RepoMan.hpp" -#include "RepoMan/Data/Repo.hpp" +#include "libRepoMan/Data/RepoMan.hpp" +#include "libRepoMan/Data/Repo.hpp" #include "libBlueSky/Application.hpp" #include +#include namespace RM { diff --git a/Libs/libMacGitverCore/RepoMan/RepoMan.hpp b/Libs/libRepoMan/RepoMan.hpp similarity index 97% rename from Libs/libMacGitverCore/RepoMan/RepoMan.hpp rename to Libs/libRepoMan/RepoMan.hpp index a2152649..33f0bbf3 100644 --- a/Libs/libMacGitverCore/RepoMan/RepoMan.hpp +++ b/Libs/libRepoMan/RepoMan.hpp @@ -19,16 +19,16 @@ #pragma once -#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" +#include "libRepoMan/Frontend/Repo.hpp" -#include "libMacGitverCore/RepoMan/Events.hpp" +#include "libRepoMan/Events.hpp" #include namespace RM { - class MGV_CORE_API RepoMan + class REPOMAN_API RepoMan : public QObject , private EventsInterface { diff --git a/Modules/GitConfig/GitConfigModule.cpp b/Modules/GitConfig/GitConfigModule.cpp index d4812d9f..1afcf167 100644 --- a/Modules/GitConfig/GitConfigModule.cpp +++ b/Modules/GitConfig/GitConfigModule.cpp @@ -18,8 +18,7 @@ #include #include "libMacGitverCore/App/MacGitver.hpp" -#include "libMacGitverCore/RepoMan/RepoMan.hpp" -#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" +#include "libRepoMan/RepoMan.hpp" #include "GitConfigModule.h" #include "GitConfigDialog.h" diff --git a/Modules/Logging/LoggingMode.cpp b/Modules/Logging/LoggingMode.cpp index 55cdab78..e00499fa 100644 --- a/Modules/Logging/LoggingMode.cpp +++ b/Modules/Logging/LoggingMode.cpp @@ -20,8 +20,7 @@ #include #include "libMacGitverCore/App/MacGitver.hpp" -#include "libMacGitverCore/RepoMan/RepoMan.hpp" - +#include "libRepoMan/RepoMan.hpp" #include "LoggingMode.hpp" LoggingMode::LoggingMode(QObject *parent) diff --git a/Modules/RepoManLogger/Listener.cpp b/Modules/RepoManLogger/Listener.cpp index 2542f219..003df9ff 100644 --- a/Modules/RepoManLogger/Listener.cpp +++ b/Modules/RepoManLogger/Listener.cpp @@ -17,10 +17,10 @@ * */ -#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" -#include "libMacGitverCore/RepoMan/Frontend/Tag.hpp" -#include "libMacGitverCore/RepoMan/Frontend/Branch.hpp" -#include "libMacGitverCore/RepoMan/Frontend/Submodule.hpp" +#include "libRepoMan/RepoMan.hpp" +#include "libRepoMan/Frontend/Tag.hpp" +#include "libRepoMan/Frontend/Branch.hpp" +#include "libRepoMan/Frontend/Submodule.hpp" #include "Listener.hpp" #include "TemplateNames.hpp" diff --git a/Modules/RepoManLogger/Listener.hpp b/Modules/RepoManLogger/Listener.hpp index 6648d41d..3ded666c 100644 --- a/Modules/RepoManLogger/Listener.hpp +++ b/Modules/RepoManLogger/Listener.hpp @@ -21,7 +21,7 @@ #include -#include "libMacGitverCore/RepoMan/Events.hpp" +#include "libRepoMan/Events.hpp" #include "libLogger/Channel.hpp" #include "libLogger/Event.hpp" diff --git a/Modules/Repository/CreateRepositoryDlg.cpp b/Modules/Repository/CreateRepositoryDlg.cpp index a60ba1db..c62330d2 100644 --- a/Modules/Repository/CreateRepositoryDlg.cpp +++ b/Modules/Repository/CreateRepositoryDlg.cpp @@ -20,8 +20,7 @@ #include "libMacGitverCore/Config/Config.h" #include "libMacGitverCore/App/MacGitver.hpp" -#include "libMacGitverCore/RepoMan/RepoMan.hpp" - +#include "libRepoMan/RepoMan.hpp" #include "CreateRepositoryDlg.h" CreateRepositoryDlg::CreateRepositoryDlg() diff --git a/Modules/Repository/RepoInfoModel.cpp b/Modules/Repository/RepoInfoModel.cpp index 8c87e1c5..968c9b85 100644 --- a/Modules/Repository/RepoInfoModel.cpp +++ b/Modules/Repository/RepoInfoModel.cpp @@ -18,8 +18,7 @@ #include "libMacGitverCore/App/MacGitver.hpp" #include "libMacGitverCore/Config/Config.h" -#include "libMacGitverCore/RepoMan/RepoMan.hpp" - +#include "libRepoMan/RepoMan.hpp" #include "libHeavenIcons/IconRef.hpp" #include "libHeavenIcons/Icon.hpp" diff --git a/Modules/Repository/RepoInfoModel.hpp b/Modules/Repository/RepoInfoModel.hpp index 28e71df8..599d54cb 100644 --- a/Modules/Repository/RepoInfoModel.hpp +++ b/Modules/Repository/RepoInfoModel.hpp @@ -18,7 +18,7 @@ #include -#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" +#include "libRepoMan/RepoMan.hpp" class RepoInfoModel : public QAbstractItemModel { diff --git a/Modules/Repository/RepoTreeView.cpp b/Modules/Repository/RepoTreeView.cpp index 7d28bc3b..3b7e7189 100644 --- a/Modules/Repository/RepoTreeView.cpp +++ b/Modules/Repository/RepoTreeView.cpp @@ -20,8 +20,7 @@ #include "libMacGitverCore/Widgets/TreeViewCtxMenu.hpp" #include "libMacGitverCore/App/MacGitver.hpp" -#include "libMacGitverCore/RepoMan/RepoMan.hpp" -#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" +#include "libRepoMan/RepoMan.hpp" #include "RepoTreeView.hpp" #include "RepoInfoModel.hpp" diff --git a/Modules/Repository/RepoTreeView.hpp b/Modules/Repository/RepoTreeView.hpp index 0c9ba394..94259191 100644 --- a/Modules/Repository/RepoTreeView.hpp +++ b/Modules/Repository/RepoTreeView.hpp @@ -25,7 +25,7 @@ class QModelIndex; class RepoInfoModel; class TreeViewCtxMenu; -#include "libMacGitverCore/RepoMan/Frontend/Repo.hpp" +#include "libRepoMan/RepoMan.hpp" class RepoTreeView : public BlueSky::ContextView diff --git a/Modules/Repository/RepositoryModule.cpp b/Modules/Repository/RepositoryModule.cpp index 9b42f664..7197406f 100644 --- a/Modules/Repository/RepositoryModule.cpp +++ b/Modules/Repository/RepositoryModule.cpp @@ -24,8 +24,7 @@ #include "libMacGitverCore/Config/Config.h" #include "libMacGitverCore/App/MacGitver.hpp" -#include "libMacGitverCore/RepoMan/RepoMan.hpp" - +#include "libRepoMan/Frontend/Repo.hpp" #include "RepositoryModule.h" #include "RepoTreeView.hpp" #include "CloneRepositoryDlg.h" From 87d436430f263aa00892ee2ea637a1944808c845 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 19 Apr 2015 02:50:22 +0100 Subject: [PATCH 20/75] Repoman Events --- Libs/libRepoMan/CMakeLists.txt | 13 +- Libs/libRepoMan/Core.hpp | 2 + Libs/libRepoMan/Data/Base.cpp | 9 + Libs/libRepoMan/Data/Base.hpp | 12 +- Libs/libRepoMan/Events.cpp | 391 ------------------ Libs/libRepoMan/Events.hpp | 145 ------- Libs/libRepoMan/Events/Compat.cpp | 384 +++++++++++++++++ Libs/libRepoMan/Events/Compat.hpp | 123 ++++++ Libs/libRepoMan/Events/Event.cpp | 93 +++++ Libs/libRepoMan/Events/Event.hpp | 74 ++++ Libs/libRepoMan/Events/EventData.cpp | 49 +++ Libs/libRepoMan/Events/EventData.hpp | 55 +++ Libs/libRepoMan/Events/Manager.cpp | 71 ++++ Libs/libRepoMan/Events/Manager.hpp | 62 +++ Libs/libRepoMan/Frontend/Base.cpp | 10 +- Libs/libRepoMan/Frontend/Base.hpp | 4 +- Libs/libRepoMan/Frontend/Branch.cpp | 2 - Libs/libRepoMan/Frontend/Head.cpp | 2 - Libs/libRepoMan/Frontend/Namespace.cpp | 2 - Libs/libRepoMan/Frontend/RefTreeNode.cpp | 2 - Libs/libRepoMan/Frontend/Reference.cpp | 2 - Libs/libRepoMan/Frontend/Remote.cpp | 2 - Libs/libRepoMan/Frontend/Repo.cpp | 1 - Libs/libRepoMan/Frontend/Submodule.cpp | 2 - Libs/libRepoMan/Frontend/Tag.cpp | 2 - Libs/libRepoMan/RepoMan.cpp | 4 - Libs/libRepoMan/RepoMan.hpp | 8 +- Modules/RepoManLogger/Listener.cpp | 66 +-- Modules/RepoManLogger/Listener.hpp | 64 +-- Modules/RepoManLogger/RepoManLoggerModule.cpp | 4 +- 30 files changed, 1022 insertions(+), 638 deletions(-) delete mode 100644 Libs/libRepoMan/Events.cpp delete mode 100644 Libs/libRepoMan/Events.hpp create mode 100644 Libs/libRepoMan/Events/Compat.cpp create mode 100644 Libs/libRepoMan/Events/Compat.hpp create mode 100644 Libs/libRepoMan/Events/Event.cpp create mode 100644 Libs/libRepoMan/Events/Event.hpp create mode 100644 Libs/libRepoMan/Events/EventData.cpp create mode 100644 Libs/libRepoMan/Events/EventData.hpp create mode 100644 Libs/libRepoMan/Events/Manager.cpp create mode 100644 Libs/libRepoMan/Events/Manager.hpp diff --git a/Libs/libRepoMan/CMakeLists.txt b/Libs/libRepoMan/CMakeLists.txt index 0a39f195..bb1d46b5 100644 --- a/Libs/libRepoMan/CMakeLists.txt +++ b/Libs/libRepoMan/CMakeLists.txt @@ -10,9 +10,13 @@ INCLUDE_DIRECTORIES( BEFORE SET( SRC_FILES - Events.cpp RepoMan.cpp + Events/Event.cpp + Events/EventData.cpp + Events/Manager.cpp + Events/Compat.cpp + Frontend/Base.cpp Frontend/Branch.cpp Frontend/Namespace.cpp @@ -45,9 +49,12 @@ SET( SRC_FILES SET( PUB_HDR_FILES Core.hpp - Events.hpp RepoMan.hpp + Events/Event.hpp + Events/Manager.hpp + Events/Compat.hpp + Frontend/Base.hpp Frontend/Reference.hpp Frontend/Repo.hpp @@ -65,6 +72,8 @@ SET( PRI_HDR_FILES Private/Dumper.hpp + Events/EventData.hpp + Data/Base.hpp Data/Branch.hpp Data/Namespace.hpp diff --git a/Libs/libRepoMan/Core.hpp b/Libs/libRepoMan/Core.hpp index a907ecf2..36f5bbf4 100644 --- a/Libs/libRepoMan/Core.hpp +++ b/Libs/libRepoMan/Core.hpp @@ -60,6 +60,7 @@ namespace RM namespace Frontend { + class Base; class Repo; class RefTreeNode; class Namespace; @@ -68,6 +69,7 @@ namespace RM class RefLog; class Submodule; class Tag; + class Branch; } } diff --git a/Libs/libRepoMan/Data/Base.cpp b/Libs/libRepoMan/Data/Base.cpp index c7333e11..05443c3e 100644 --- a/Libs/libRepoMan/Data/Base.cpp +++ b/Libs/libRepoMan/Data/Base.cpp @@ -19,6 +19,9 @@ #include "libRepoMan/Data/Base.hpp" +#include "libRepoMan/Events/Manager.hpp" +#include "libRepoMan/Events/EventData.hpp" + #include "libRepoMan/Frontend/Repo.hpp" #include "libRepoMan/Private/Dumper.hpp" @@ -70,6 +73,12 @@ namespace RM return QStringLiteral(""); } + void Base::emitEvent(EventType type) + { + Event ev(Internal::EventData::create(type, this)); + EventManager::self().sendEvent(ev); + } + #if 0 // ###REPOMAN /** * @brief Refresh this object diff --git a/Libs/libRepoMan/Data/Base.hpp b/Libs/libRepoMan/Data/Base.hpp index 458cad74..d28974d2 100644 --- a/Libs/libRepoMan/Data/Base.hpp +++ b/Libs/libRepoMan/Data/Base.hpp @@ -19,7 +19,7 @@ #pragma once -#include "libRepoMan/Core.hpp" +#include "libRepoMan/Events/Event.hpp" #include #include @@ -75,6 +75,9 @@ namespace RM std::weak_ptr repository() const; SPtr parent() const; + public: + SPtr getPtr() { return shared_from_this(); } + public: virtual QString displayName() const; virtual QString objectTypeName() const = 0; @@ -92,6 +95,9 @@ namespace RM template std::shared_ptr as(); + protected: + void emitEvent(EventType type); + private: std::weak_ptr mRepo; std::weak_ptr mParent; @@ -101,7 +107,7 @@ namespace RM inline std::shared_ptr Base::as() const { if (inherits(T::StaticObjectType)) { - return std::shared_ptr(static_cast(this)); + return std::static_pointer_cast(shared_from_this()); } return std::shared_ptr(); } @@ -110,7 +116,7 @@ namespace RM inline std::shared_ptr Base::as() { if (inherits(T::StaticObjectType)) { - return std::shared_ptr(static_cast(this)); + return std::static_pointer_cast(shared_from_this()); } return std::shared_ptr(); } diff --git a/Libs/libRepoMan/Events.cpp b/Libs/libRepoMan/Events.cpp deleted file mode 100644 index 45db5a75..00000000 --- a/Libs/libRepoMan/Events.cpp +++ /dev/null @@ -1,391 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2015 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "libRepoMan/Events.hpp" - -namespace RM -{ - - /** - * @class EventsInterface - * @brief Interface that receives all RepoMan events - * - * All pure virtual methods in this interface represent events from the RepoMan. - * - * Each of these events can be connected to individually via Qt's SIGNAL/SLOT mechanism on the - * MacGitver::repoMan() singleton. - * - * You can also write an implementation of the whole interface and register it through the - * Events singleton. We're doing that in the unit tests - and probably will do it in a - * Heaven::View in order to display the repository events. - * - * @fn EventsInterface::repositoryOpened(Repo* repo) - * @brief Sent after a repository is opened - * - * This is an administrative event. It implies no actual change to the underlying repository. - * - * @param[in] repo The repository that was opened - * - * - * @fn EventsInterface::repositoryAboutToClose(Repo* repo) - * @brief Sent before a repository will be closed - * - * This is an administrative event. It implies no actual change to the underlying repository. - * - * @param[in] repo The repository that is about to be closed - * - * - * @fn EventsInterface::repositoryActivated(Repo* repo) - * @brief Sent after a repository was activated - * - * This is an administrative event. It implies no actual change to the underlying repository. - * - * @param[in] repo The repository that became the active one - * - * - * @fn EventsInterface::repositoryDeactivated(Repo* repo) - * @brief Sent after a repository was deactivated - * - * This is an administrative event. It implies no actual change to the underlying repository. - * - * @param[in] repo The repository that was activated - * - * - * @fn EventsInterface::repositoryStateChanged(Repo* repo) - * @brief Sent after a change in a repository's state was detected - * - * Transitions between "normal", "rebasing", "merging" etc. are detected. - * - * @param[in] repo The repository whose state changed - * - * @fn EventsInterface::refTreeNodeCreated(Repo* repo, RefTreeNode* node) - * @brief Sent when a new tree node in a ref tree was created - * - * This is a virtual event. It is artificially created. - * - * @param[in] repo The repository for which a ref tree node was created - * @param[in] node The node that was created - * - * - * @fn EventsInterface::refTreeNodeAboutToBeRemoved(Repo* repo, RefTreeNode* node) - * @brief Sent before a tree node in a ref tree will be removed - * - * This is a virtual event. It is artificially created. - * - * @param[in] repo The repository for which a ref tree node will be removed - * @param[in] node The node that will be removed - * - * - * @fn EventsInterface::refCreated(Repo* repo, Ref* ref) - * @brief Sent after a reference was created - * - * @param[in] repo The affected repository - * @param[in] ref The newly created reference - * - * @fn EventsInterface::refAboutToBeRemoved(Repo* repo, Ref* ref) - * @brief Sent before a reference is about to be removed - * - * The reference is most probably already physically removed. This event is sent before it is - * removed from RepoMan's data model. - * - * @param[in] repo The affected repository - * @param[in] ref The reference that will be removed - * - * - * @fn EventsInterface::refMoved(Repo* repo, Ref* ref) - * @brief Sent when either the target id or the symbolic target of a reference changed. - * - * The reference is most probably already physically moved. This event is sent when the change - * is discovered by the RepoMan. - * - * @param[in] repo The affected repository - * @param[in] ref The reference that will move - * - * - * @fn EventsInterface::refHeadDetached(Repo* repo, Ref* ref) - * @brief Sent after the HEAD reference got into a detached state - * - * This event will be sent when RepoMan detected that the HEAD reference has been set to a - * detached state. - * - * This will happen constantly during a rebase action and also happens after checking out a - * given SHA1 or a tag. - * - * @param[in] repo The affected repository - * @param[in] ref The HEAD reference that got detached - * - */ - - Events::Events() - { - } - - Events* Events::sSelf = NULL; - - Events* Events::self() - { - if (sSelf == NULL) { - sSelf = new Events; - } - return sSelf; - } - - void Events::addReceiver(EventsInterface* ev) - { - self()->mEvents.insert(ev); - } - - void Events::delReceiver(EventsInterface* ev) - { - self()->mEvents.remove(ev); - } - - void Events::repositoryOpened(const RM::Frontend::Repo& repo) - { - foreach (EventsInterface* ei, mEvents) { - ei->repositoryOpened(repo); - } - } - - void Events::repositoryAboutToClose(const RM::Frontend::Repo& repo) - { - foreach (EventsInterface* ei, mEvents) { - ei->repositoryAboutToClose(repo); - } - } - - void Events::repositoryActivated(const RM::Frontend::Repo& repo) - { - foreach (EventsInterface* ei, mEvents) { - ei->repositoryActivated(repo); - } - } - - void Events::repositoryDeactivated(const RM::Frontend::Repo& repo) - { - foreach (EventsInterface* ei, mEvents) { - ei->repositoryDeactivated(repo); - } - } - - void Events::objectCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object) - { - foreach (EventsInterface* ei, mEvents) { - ei->objectCreated(repo, object); - } - } - - void Events::objectAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object) - { - foreach (EventsInterface* ei, mEvents) { - ei->objectAboutToBeDeleted(repo, object); - } - } - - void Events::refTreeNodeCreated(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node) - { - foreach (EventsInterface* ei, mEvents) { - ei->refTreeNodeCreated(repo, node); - } - } - - void Events::refTreeNodeAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node) - { - foreach (EventsInterface* ei, mEvents) { - ei->refTreeNodeAboutToBeDeleted(repo, node); - } - } - - void Events::refCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) - { - foreach (EventsInterface* ei, mEvents) { - ei->refCreated(repo, ref); - } - } - - void Events::refAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) - { - foreach (EventsInterface* ei, mEvents) { - ei->refAboutToBeDeleted(repo, ref); - } - } - - void Events::refMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) - { - foreach (EventsInterface* ei, mEvents) { - ei->refMoved(repo, ref); - } - } - - void Events::refHeadDetached(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) - { - foreach (EventsInterface* ei, mEvents) { - ei->refHeadDetached(repo, ref); - } - } - - void Events::tagCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag) - { - foreach (EventsInterface* ei, mEvents) { - ei->tagCreated(repo, tag); - } - } - - void Events::tagAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag) - { - foreach (EventsInterface* ei, mEvents) { - ei->tagAboutToBeDeleted(repo, tag); - } - } - - void Events::branchCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) - { - foreach (EventsInterface* ei, mEvents) { - ei->branchCreated(repo, branch); - } - } - - void Events::branchAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) - { - foreach (EventsInterface* ei, mEvents) { - ei->branchAboutToBeDeleted(repo, branch); - } - } - - void Events::branchMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) - { - foreach (EventsInterface* ei, mEvents) { - ei->branchMoved(repo, branch); - } - } - - void Events::branchUpstreamChanged(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) - { - foreach (EventsInterface* ei, mEvents) { - ei->branchUpstreamChanged(repo, branch); - } - } - - void Events::namespaceCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace) - { - foreach (EventsInterface* ei, mEvents) { - ei->namespaceCreated(repo, nameSpace); - } - } - - void Events::namespaceAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace) - { - foreach (EventsInterface* ei, mEvents) { - ei->namespaceAboutToBeDeleted(repo, nameSpace); - } - } - - void Events::refLogChanged(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog) - { - foreach (EventsInterface* ei, mEvents) { - ei->refLogChanged(repo, reflog); - } - } - - void Events::refLogNewEntry(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog) - { - foreach (EventsInterface* ei, mEvents) { - ei->refLogNewEntry(repo, reflog); - } - } - - void Events::stageCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) - { - foreach (EventsInterface* ei, mEvents) { - ei->stageCreated(repo, ref); - } - } - - void Events::stageAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) - { - foreach (EventsInterface* ei, mEvents) { - ei->stageAboutToBeDeleted(repo, ref); - } - } - - void Events::remoteCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) - { - foreach (EventsInterface* ei, mEvents) { - ei->remoteCreated(repo, remote); - } - } - - void Events::remoteAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) - { - foreach (EventsInterface* ei, mEvents) { - ei->remoteAboutToBeDeleted(repo, remote); - } - } - - void Events::remoteModified(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) - { - foreach (EventsInterface* ei, mEvents) { - ei->remoteModified(repo, remote); - } - } - - void Events::submoduleCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) - { - foreach (EventsInterface* ei, mEvents) { - ei->submoduleCreated(repo, submodule); - } - } - - void Events::submoduleAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) - { - foreach (EventsInterface* ei, mEvents) { - ei->submoduleAboutToBeDeleted(repo, submodule); - } - } - - void Events::submoduleMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) - { - foreach (EventsInterface* ei, mEvents) { - ei->submoduleMoved(repo, submodule); - } - } - - void Events::repositoryStateChanged(const RM::Frontend::Repo& repo) - { - foreach (EventsInterface* ei, mEvents) { - ei->repositoryStateChanged(repo); - } - } - - void Events::indexUpdated(const RM::Frontend::Repo& repo) - { - foreach (EventsInterface* ei, mEvents) { - ei->indexUpdated(repo); - } - } - - void Events::workTreeUpdated(const RM::Frontend::Repo& repo) - { - foreach (EventsInterface* ei, mEvents) { - ei->workTreeUpdated(repo); - } - } - - -} diff --git a/Libs/libRepoMan/Events.hpp b/Libs/libRepoMan/Events.hpp deleted file mode 100644 index 6bb6fe7c..00000000 --- a/Libs/libRepoMan/Events.hpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2015 The MacGitver-Developers - * - * (C) Sascha Cunz - * (C) Cunz RaD Ltd. - * - * 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 "libRepoMan/Core.hpp" - -#include - -namespace RM -{ - - namespace Frontend - { - class Base; - class Namespace; - class Repo; - class Reference; - class Remote; - class Submodule; - class RefTreeNode; - class RefLog; - class Branch; - class Tag; - } - - class REPOMAN_API EventsInterface - { - public: - virtual ~EventsInterface() {} - - public: - virtual void repositoryOpened(const RM::Frontend::Repo& repo) = 0; - virtual void repositoryAboutToClose(const RM::Frontend::Repo& repo) = 0; - virtual void repositoryActivated(const RM::Frontend::Repo& repo) = 0; - virtual void repositoryDeactivated(const RM::Frontend::Repo& repo) = 0; - - virtual void objectCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object) = 0; - virtual void objectAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object) = 0; - - virtual void refTreeNodeCreated(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node) = 0; - virtual void refTreeNodeAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node) = 0; - - virtual void refCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) = 0; - virtual void refAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) = 0; - virtual void refMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) = 0; - virtual void refHeadDetached(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) = 0; - - virtual void tagCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag) = 0; - virtual void tagAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag) = 0; - - virtual void branchCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) = 0; - virtual void branchAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) = 0; - virtual void branchMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) = 0; - virtual void branchUpstreamChanged(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) = 0; - - virtual void namespaceCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace) = 0; - virtual void namespaceAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace) = 0; - - virtual void refLogChanged(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog) = 0; - virtual void refLogNewEntry(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog) = 0; - - virtual void stageCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) = 0; - virtual void stageAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) = 0; - - virtual void remoteCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) = 0; - virtual void remoteAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) = 0; - virtual void remoteModified(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) = 0; - - virtual void submoduleCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) = 0; - virtual void submoduleAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) = 0; - virtual void submoduleMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) = 0; - - virtual void repositoryStateChanged(const RM::Frontend::Repo& repo) = 0; - virtual void indexUpdated(const RM::Frontend::Repo& repo) = 0; - virtual void workTreeUpdated(const RM::Frontend::Repo& repo) = 0; - }; - - class REPOMAN_API Events // : public EventsInterface - { - private: - Events(); - - public: - static Events* self(); - static void addReceiver(EventsInterface* ev); - static void delReceiver(EventsInterface* ev); - - private: - QSet mEvents; - static Events* sSelf; - - public: - void repositoryOpened(const RM::Frontend::Repo& repo); - void repositoryAboutToClose(const RM::Frontend::Repo& repo); - void repositoryActivated(const RM::Frontend::Repo& repo); - void repositoryDeactivated(const RM::Frontend::Repo& repo); - void objectCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object); - void objectAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object); - void refTreeNodeCreated(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node); - void refTreeNodeAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node); - void refCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void refAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void refMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void refHeadDetached(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void tagCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag); - void tagAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag); - void branchCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); - void branchAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); - void branchMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); - void branchUpstreamChanged(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); - void namespaceCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace); - void namespaceAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace); - void refLogChanged(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog); - void refLogNewEntry(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog); - void stageCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void stageAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void remoteCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); - void remoteAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); - void remoteModified(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); - void submoduleCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); - void submoduleAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); - void submoduleMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); - void repositoryStateChanged(const RM::Frontend::Repo& repo); - void indexUpdated(const RM::Frontend::Repo& repo); - void workTreeUpdated(const RM::Frontend::Repo& repo); - }; - -} diff --git a/Libs/libRepoMan/Events/Compat.cpp b/Libs/libRepoMan/Events/Compat.cpp new file mode 100644 index 00000000..c6d704dc --- /dev/null +++ b/Libs/libRepoMan/Events/Compat.cpp @@ -0,0 +1,384 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libRepoMan/Events/Event.hpp" +#include "libRepoMan/Events/Compat.hpp" + +namespace RM +{ + + /** + * @class CompatEventsInterface + * @brief Interface that receives all RepoMan events + * + * All pure virtual methods in this interface represent events from the RepoMan. + * + * Each of these events can be connected to individually via Qt's SIGNAL/SLOT mechanism on the + * MacGitver::repoMan() singleton. + * + * You can also write an implementation of the whole interface and register it through the + * CompatEvents singleton. We're doing that in the unit tests - and probably will do it in a + * Heaven::View in order to display the repository events. + * + * @fn CompatEventsInterface::repositoryOpened(Repo* repo) + * @brief Sent after a repository is opened + * + * This is an administrative event. It implies no actual change to the underlying repository. + * + * @param[in] repo The repository that was opened + * + * + * @fn CompatEventsInterface::repositoryAboutToClose(Repo* repo) + * @brief Sent before a repository will be closed + * + * This is an administrative event. It implies no actual change to the underlying repository. + * + * @param[in] repo The repository that is about to be closed + * + * + * @fn CompatEventsInterface::repositoryActivated(Repo* repo) + * @brief Sent after a repository was activated + * + * This is an administrative event. It implies no actual change to the underlying repository. + * + * @param[in] repo The repository that became the active one + * + * + * @fn CompatEventsInterface::repositoryDeactivated(Repo* repo) + * @brief Sent after a repository was deactivated + * + * This is an administrative event. It implies no actual change to the underlying repository. + * + * @param[in] repo The repository that was activated + * + * + * @fn CompatEventsInterface::repositoryStateChanged(Repo* repo) + * @brief Sent after a change in a repository's state was detected + * + * Transitions between "normal", "rebasing", "merging" etc. are detected. + * + * @param[in] repo The repository whose state changed + * + * @fn CompatEventsInterface::refTreeNodeCreated(Repo* repo, RefTreeNode* node) + * @brief Sent when a new tree node in a ref tree was created + * + * This is a virtual event. It is artificially created. + * + * @param[in] repo The repository for which a ref tree node was created + * @param[in] node The node that was created + * + * + * @fn CompatEventsInterface::refTreeNodeAboutToBeRemoved(Repo* repo, RefTreeNode* node) + * @brief Sent before a tree node in a ref tree will be removed + * + * This is a virtual event. It is artificially created. + * + * @param[in] repo The repository for which a ref tree node will be removed + * @param[in] node The node that will be removed + * + * + * @fn CompatEventsInterface::refCreated(Repo* repo, Ref* ref) + * @brief Sent after a reference was created + * + * @param[in] repo The affected repository + * @param[in] ref The newly created reference + * + * @fn CompatEventsInterface::refAboutToBeRemoved(Repo* repo, Ref* ref) + * @brief Sent before a reference is about to be removed + * + * The reference is most probably already physically removed. This event is sent before it is + * removed from RepoMan's data model. + * + * @param[in] repo The affected repository + * @param[in] ref The reference that will be removed + * + * + * @fn CompatEventsInterface::refMoved(Repo* repo, Ref* ref) + * @brief Sent when either the target id or the symbolic target of a reference changed. + * + * The reference is most probably already physically moved. This event is sent when the change + * is discovered by the RepoMan. + * + * @param[in] repo The affected repository + * @param[in] ref The reference that will move + * + * + * @fn CompatEventsInterface::refHeadDetached(Repo* repo, Ref* ref) + * @brief Sent after the HEAD reference got into a detached state + * + * This event will be sent when RepoMan detected that the HEAD reference has been set to a + * detached state. + * + * This will happen constantly during a rebase action and also happens after checking out a + * given SHA1 or a tag. + * + * @param[in] repo The affected repository + * @param[in] ref The HEAD reference that got detached + * + */ + + std::vector CompatEvents::mEvents; + + void CompatEvents::addReceiver(CompatEventsInterface* ev) + { + mEvents.push_back(ev); + } + + void CompatEvents::delReceiver(CompatEventsInterface* ev) + { + for (auto it = mEvents.begin(); it != mEvents.end(); ++it) { + if (*it == ev) { + mEvents.erase(it); + return; + } + } + } + + void CompatEvents::repositoryOpened(const RM::Frontend::Repo& repo) + { + for (CompatEventsInterface* ei : mEvents) { + ei->repositoryOpened(repo); + } + } + + void CompatEvents::repositoryAboutToClose(const RM::Frontend::Repo& repo) + { + for (CompatEventsInterface* ei : mEvents) { + ei->repositoryAboutToClose(repo); + } + } + + void CompatEvents::repositoryActivated(const RM::Frontend::Repo& repo) + { + for (CompatEventsInterface* ei : mEvents) { + ei->repositoryActivated(repo); + } + } + + void CompatEvents::repositoryDeactivated(const RM::Frontend::Repo& repo) + { + for (CompatEventsInterface* ei : mEvents) { + ei->repositoryDeactivated(repo); + } + } + + void CompatEvents::objectCreated(const RM::Frontend::Base& object) + { + for (CompatEventsInterface* ei : mEvents) { + ei->objectCreated(object); + } + } + + void CompatEvents::objectAboutToBeDeleted(const RM::Frontend::Base& object) + { + for (CompatEventsInterface* ei : mEvents) { + ei->objectAboutToBeDeleted(object); + } + } + + void CompatEvents::refTreeNodeCreated(const RM::Frontend::RefTreeNode& node) + { + for (CompatEventsInterface* ei : mEvents) { + ei->refTreeNodeCreated(node); + } + } + + void CompatEvents::refTreeNodeAboutToBeDeleted(const RM::Frontend::RefTreeNode& node) + { + for (CompatEventsInterface* ei : mEvents) { + ei->refTreeNodeAboutToBeDeleted(node); + } + } + + void CompatEvents::refCreated(const RM::Frontend::Reference& ref) + { + for (CompatEventsInterface* ei : mEvents) { + ei->refCreated(ref); + } + } + + void CompatEvents::refAboutToBeDeleted(const RM::Frontend::Reference& ref) + { + for (CompatEventsInterface* ei : mEvents) { + ei->refAboutToBeDeleted(ref); + } + } + + void CompatEvents::refMoved(const RM::Frontend::Reference& ref) + { + for (CompatEventsInterface* ei : mEvents) { + ei->refMoved(ref); + } + } + + void CompatEvents::refHeadDetached(const RM::Frontend::Reference& ref) + { + for (CompatEventsInterface* ei : mEvents) { + ei->refHeadDetached(ref); + } + } + + void CompatEvents::tagCreated(const RM::Frontend::Tag& tag) + { + for (CompatEventsInterface* ei : mEvents) { + ei->tagCreated(tag); + } + } + + void CompatEvents::tagAboutToBeDeleted(const RM::Frontend::Tag& tag) + { + for (CompatEventsInterface* ei : mEvents) { + ei->tagAboutToBeDeleted(tag); + } + } + + void CompatEvents::branchCreated(const RM::Frontend::Branch& branch) + { + for (CompatEventsInterface* ei : mEvents) { + ei->branchCreated(branch); + } + } + + void CompatEvents::branchAboutToBeDeleted(const RM::Frontend::Branch& branch) + { + for (CompatEventsInterface* ei : mEvents) { + ei->branchAboutToBeDeleted(branch); + } + } + + void CompatEvents::branchMoved(const RM::Frontend::Branch& branch) + { + for (CompatEventsInterface* ei : mEvents) { + ei->branchMoved(branch); + } + } + + void CompatEvents::branchUpstreamChanged(const RM::Frontend::Branch& branch) + { + for (CompatEventsInterface* ei : mEvents) { + ei->branchUpstreamChanged(branch); + } + } + + void CompatEvents::namespaceCreated(const RM::Frontend::Namespace& nameSpace) + { + for (CompatEventsInterface* ei : mEvents) { + ei->namespaceCreated(nameSpace); + } + } + + void CompatEvents::namespaceAboutToBeDeleted(const RM::Frontend::Namespace& nameSpace) + { + for (CompatEventsInterface* ei : mEvents) { + ei->namespaceAboutToBeDeleted(nameSpace); + } + } + + void CompatEvents::refLogChanged(const RM::Frontend::RefLog& reflog) + { + for (CompatEventsInterface* ei : mEvents) { + ei->refLogChanged(reflog); + } + } + + void CompatEvents::refLogNewEntry(const RM::Frontend::RefLog& reflog) + { + for (CompatEventsInterface* ei : mEvents) { + ei->refLogNewEntry(reflog); + } + } + + void CompatEvents::stageCreated(const RM::Frontend::Reference& ref) + { + for (CompatEventsInterface* ei : mEvents) { + ei->stageCreated(ref); + } + } + + void CompatEvents::stageAboutToBeDeleted(const RM::Frontend::Reference& ref) + { + for (CompatEventsInterface* ei : mEvents) { + ei->stageAboutToBeDeleted(ref); + } + } + + void CompatEvents::remoteCreated(const RM::Frontend::Remote& remote) + { + for (CompatEventsInterface* ei : mEvents) { + ei->remoteCreated(remote); + } + } + + void CompatEvents::remoteAboutToBeDeleted(const RM::Frontend::Remote& remote) + { + for (CompatEventsInterface* ei : mEvents) { + ei->remoteAboutToBeDeleted(remote); + } + } + + void CompatEvents::remoteModified(const RM::Frontend::Remote& remote) + { + for (CompatEventsInterface* ei : mEvents) { + ei->remoteModified(remote); + } + } + + void CompatEvents::submoduleCreated(const RM::Frontend::Submodule& submodule) + { + for (CompatEventsInterface* ei : mEvents) { + ei->submoduleCreated(submodule); + } + } + + void CompatEvents::submoduleAboutToBeDeleted(const RM::Frontend::Submodule& submodule) + { + for (CompatEventsInterface* ei : mEvents) { + ei->submoduleAboutToBeDeleted(submodule); + } + } + + void CompatEvents::submoduleMoved(const RM::Frontend::Submodule& submodule) + { + for (CompatEventsInterface* ei : mEvents) { + ei->submoduleMoved(submodule); + } + } + + void CompatEvents::repositoryStateChanged(const RM::Frontend::Repo& repo) + { + for (CompatEventsInterface* ei : mEvents) { + ei->repositoryStateChanged(repo); + } + } + + void CompatEvents::indexUpdated() + { + for (CompatEventsInterface* ei : mEvents) { + ei->indexUpdated(); + } + } + + void CompatEvents::workTreeUpdated() + { + for (CompatEventsInterface* ei : mEvents) { + ei->workTreeUpdated(); + } + } + +} diff --git a/Libs/libRepoMan/Events/Compat.hpp b/Libs/libRepoMan/Events/Compat.hpp new file mode 100644 index 00000000..41a0dc40 --- /dev/null +++ b/Libs/libRepoMan/Events/Compat.hpp @@ -0,0 +1,123 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libRepoMan/Frontend/Base.hpp" + +namespace RM +{ + + class REPOMAN_API CompatEventsInterface + { + public: + virtual ~CompatEventsInterface() {} + + public: + virtual void repositoryOpened(const RM::Frontend::Repo& repo) = 0; + virtual void repositoryAboutToClose(const RM::Frontend::Repo& repo) = 0; + virtual void repositoryActivated(const RM::Frontend::Repo& repo) = 0; + virtual void repositoryDeactivated(const RM::Frontend::Repo& repo) = 0; + + virtual void objectCreated(const RM::Frontend::Base& object) = 0; + virtual void objectAboutToBeDeleted(const RM::Frontend::Base& object) = 0; + + virtual void refTreeNodeCreated(const RM::Frontend::RefTreeNode& node) = 0; + virtual void refTreeNodeAboutToBeDeleted(const RM::Frontend::RefTreeNode& node) = 0; + + virtual void refCreated(const RM::Frontend::Reference& ref) = 0; + virtual void refAboutToBeDeleted(const RM::Frontend::Reference& ref) = 0; + virtual void refMoved(const RM::Frontend::Reference& ref) = 0; + virtual void refHeadDetached(const RM::Frontend::Reference& ref) = 0; + + virtual void tagCreated(const RM::Frontend::Tag& tag) = 0; + virtual void tagAboutToBeDeleted(const RM::Frontend::Tag& tag) = 0; + + virtual void branchCreated(const RM::Frontend::Branch& branch) = 0; + virtual void branchAboutToBeDeleted(const RM::Frontend::Branch& branch) = 0; + virtual void branchMoved(const RM::Frontend::Branch& branch) = 0; + virtual void branchUpstreamChanged(const RM::Frontend::Branch& branch) = 0; + + virtual void namespaceCreated(const RM::Frontend::Namespace& nameSpace) = 0; + virtual void namespaceAboutToBeDeleted(const RM::Frontend::Namespace& nameSpace) = 0; + + virtual void refLogChanged(const RM::Frontend::RefLog& reflog) = 0; + virtual void refLogNewEntry(const RM::Frontend::RefLog& reflog) = 0; + + virtual void stageCreated(const RM::Frontend::Reference& ref) = 0; + virtual void stageAboutToBeDeleted(const RM::Frontend::Reference& ref) = 0; + + virtual void remoteCreated(const RM::Frontend::Remote& remote) = 0; + virtual void remoteAboutToBeDeleted(const RM::Frontend::Remote& remote) = 0; + virtual void remoteModified(const RM::Frontend::Remote& remote) = 0; + + virtual void submoduleCreated(const RM::Frontend::Submodule& submodule) = 0; + virtual void submoduleAboutToBeDeleted(const RM::Frontend::Submodule& submodule) = 0; + virtual void submoduleMoved(const RM::Frontend::Submodule& submodule) = 0; + + virtual void repositoryStateChanged(const RM::Frontend::Repo& repo) = 0; + virtual void indexUpdated() = 0; + virtual void workTreeUpdated() = 0; + }; + + class REPOMAN_API CompatEvents + { + static std::vector mEvents; + + public: + static void addReceiver(CompatEventsInterface* ei); + static void delReceiver(CompatEventsInterface* ei); + + public: + static void repositoryOpened(const RM::Frontend::Repo& repo); + static void repositoryAboutToClose(const RM::Frontend::Repo& repo); + static void repositoryActivated(const RM::Frontend::Repo& repo); + static void repositoryDeactivated(const RM::Frontend::Repo& repo); + static void objectCreated(const RM::Frontend::Base& object); + static void objectAboutToBeDeleted(const RM::Frontend::Base& object); + static void refTreeNodeCreated(const RM::Frontend::RefTreeNode& node); + static void refTreeNodeAboutToBeDeleted(const RM::Frontend::RefTreeNode& node); + static void refCreated(const RM::Frontend::Reference& ref); + static void refAboutToBeDeleted(const RM::Frontend::Reference& ref); + static void refMoved(const RM::Frontend::Reference& ref); + static void refHeadDetached(const RM::Frontend::Reference& ref); + static void tagCreated(const RM::Frontend::Tag& tag); + static void tagAboutToBeDeleted(const RM::Frontend::Tag& tag); + static void branchCreated(const RM::Frontend::Branch& branch); + static void branchAboutToBeDeleted(const RM::Frontend::Branch& branch); + static void branchMoved(const RM::Frontend::Branch& branch); + static void branchUpstreamChanged(const RM::Frontend::Branch& branch); + static void namespaceCreated(const RM::Frontend::Namespace& nameSpace); + static void namespaceAboutToBeDeleted(const RM::Frontend::Namespace& nameSpace); + static void refLogChanged(const RM::Frontend::RefLog& reflog); + static void refLogNewEntry(const RM::Frontend::RefLog& reflog); + static void stageCreated(const RM::Frontend::Reference& ref); + static void stageAboutToBeDeleted(const RM::Frontend::Reference& ref); + static void remoteCreated(const RM::Frontend::Remote& remote); + static void remoteAboutToBeDeleted(const RM::Frontend::Remote& remote); + static void remoteModified(const RM::Frontend::Remote& remote); + static void submoduleCreated(const RM::Frontend::Submodule& submodule); + static void submoduleAboutToBeDeleted(const RM::Frontend::Submodule& submodule); + static void submoduleMoved(const RM::Frontend::Submodule& submodule); + static void repositoryStateChanged(const RM::Frontend::Repo& repo); + static void indexUpdated(); + static void workTreeUpdated(); + }; + +} diff --git a/Libs/libRepoMan/Events/Event.cpp b/Libs/libRepoMan/Events/Event.cpp new file mode 100644 index 00000000..3d5b0fdd --- /dev/null +++ b/Libs/libRepoMan/Events/Event.cpp @@ -0,0 +1,93 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libRepoMan/Events/Event.hpp" +#include "libRepoMan/Events/EventData.hpp" + +#include "libRepoMan/Frontend/Repo.hpp" + +namespace RM +{ + + + Event::Event() + { + } + + Event::~Event() + { + } + + Event::Event(const Event& o) + : d(o.d) + { + } + + Event::Event(Event&& o) + : d(std::move(o.d)) + { + } + + Event::Event(const std::shared_ptr& o) + : d(o) + { + } + + Event::Event(std::shared_ptr&& o) + : d(std::move(o)) + { + } + + Event& Event::operator =(const Event& o) + { + d = o.d; + return *this; + } + + Event& Event::operator =(Event&& o) + { + d = std::move(o.d); + return *this; + } + + EventType Event::type() const + { + if (!d) { + return EventType::None; + } + return d->type(); + } + + Frontend::Repo Event::repo() const + { + if (!d) { + return Frontend::Repo(); + } + return d->repo().lock(); + } + + Frontend::Base Event::baseContext() const + { + if (!d) { + return Frontend::Base(); + } + return d->context(); + } + +} diff --git a/Libs/libRepoMan/Events/Event.hpp b/Libs/libRepoMan/Events/Event.hpp new file mode 100644 index 00000000..3c2d2dad --- /dev/null +++ b/Libs/libRepoMan/Events/Event.hpp @@ -0,0 +1,74 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libRepoMan/Frontend/Base.hpp" + +#include + +namespace RM +{ + + namespace Internal + { + class EventData; + } + + enum class EventType + { + None, + + RepoOpened, + RepoAboutToClose, + RepoActivated, + RepoDeactivated, + }; + + class REPOMAN_API Event + { + public: + Event(); + Event(std::shared_ptr&& d); + Event(const std::shared_ptr& d); + Event(const Event& o); + Event(Event&& o); + + Event& operator=(const Event& o); + Event& operator=(Event&& o); + + ~Event(); + + public: + EventType type() const; + Frontend::Repo repo() const; + + Frontend::Base baseContext() const; + + template + T context() const + { + return baseContext().as(); + } + + private: + std::shared_ptr d; + }; + +} diff --git a/Libs/libRepoMan/Events/EventData.cpp b/Libs/libRepoMan/Events/EventData.cpp new file mode 100644 index 00000000..298767cc --- /dev/null +++ b/Libs/libRepoMan/Events/EventData.cpp @@ -0,0 +1,49 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libRepoMan/Events/EventData.hpp" + +namespace RM +{ + + namespace Internal + { + + EventData::EventData(EventType type, Data::Base* context) + : mType(type) + , mContext(context ? context->getPtr() : Data::Base::SPtr()) + { + } + + std::shared_ptr EventData::create(EventType type, Data::Base* context) + { + return std::make_shared(type, context); + } + + Data::Repo::WPtr EventData::repo() const + { + if (!mContext) { + return Data::Repo::WPtr(); + } + return mContext->repository(); + } + + } + +} diff --git a/Libs/libRepoMan/Events/EventData.hpp b/Libs/libRepoMan/Events/EventData.hpp new file mode 100644 index 00000000..4539d8a4 --- /dev/null +++ b/Libs/libRepoMan/Events/EventData.hpp @@ -0,0 +1,55 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libRepoMan/Events/Event.hpp" +#include "libRepoMan/Data/Base.hpp" +#include "libRepoMan/Data/Repo.hpp" + +namespace RM +{ + + namespace Internal + { + + class EventData + { + public: + EventData() = delete; + EventData(const EventData&) = delete; + EventData(EventType type, Data::Base* context); + + public: + static std::shared_ptr create(EventType type, Data::Base* context); + + public: + Data::Repo::WPtr repo() const; + const Data::Base::SPtr& context() const { return mContext; } + EventType type() const { return mType; } + + private: + EventType mType; + Data::Base::SPtr mContext; + }; + + + } + +} diff --git a/Libs/libRepoMan/Events/Manager.cpp b/Libs/libRepoMan/Events/Manager.cpp new file mode 100644 index 00000000..1b7ab1c9 --- /dev/null +++ b/Libs/libRepoMan/Events/Manager.cpp @@ -0,0 +1,71 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libRepoMan/Events/Manager.hpp" + +#include +#include +#include +#include + +namespace RM +{ + + namespace Internal + { + + void ThreadMover::sendMovedEvent(const Event& e) + { + Q_ASSERT(QThread::currentThread() == thread()); + EventManager::self().sendEvent(e); + } + + } + + EventManager::EventManager() + { + if(thread() != qApp->thread()) { + qDebug() << "Moving EventManager to main thread"; + moveToThread(qApp->thread()); + } + + mMover = new Internal::ThreadMover(this); + } + + void EventManager::sendEvent(const Event& ev) + { + if (QThread::currentThread() != thread()) { + QMetaObject::invokeMethod(mMover, "sendMovedEvent", Qt::QueuedConnection, + Q_ARG(RM::Event, ev)); + return; + } + emit repoEvent(ev); + } + + EventManager& EventManager::self() + { + static QPointer s; + if (!s) { + s = new EventManager; + } + return *s; + } + +} + diff --git a/Libs/libRepoMan/Events/Manager.hpp b/Libs/libRepoMan/Events/Manager.hpp new file mode 100644 index 00000000..83d3fdc0 --- /dev/null +++ b/Libs/libRepoMan/Events/Manager.hpp @@ -0,0 +1,62 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libRepoMan/Events/Event.hpp" + +namespace RM +{ + + namespace Internal + { + + class ThreadMover : public QObject + { + Q_OBJECT + public: + using QObject::QObject; + + public slots: + void sendMovedEvent(const RM::Event& e); + }; + + } + + class REPOMAN_API EventManager + : public QObject + { + Q_OBJECT + public: + static EventManager& self(); + + private: + EventManager(); + + public: + void sendEvent(const Event& ev); + + signals: + void repoEvent(const Event& ev); + + private: + Internal::ThreadMover* mMover; + }; + +} diff --git a/Libs/libRepoMan/Frontend/Base.cpp b/Libs/libRepoMan/Frontend/Base.cpp index dbda6a98..bbe40354 100644 --- a/Libs/libRepoMan/Frontend/Base.cpp +++ b/Libs/libRepoMan/Frontend/Base.cpp @@ -24,7 +24,7 @@ #include "libRepoMan/RepoMan.hpp" #include "libRepoMan/Frontend/RefTreeNode.hpp" -#include "libRepoMan/Events.hpp" +#include "libRepoMan/Events/Event.hpp" #include "libRepoMan/Data/Base.hpp" @@ -66,13 +66,13 @@ namespace RM * @param[in] parent The parent to whom we shall link this new child to. * */ - Base::Base(const std::shared_ptr& o) - : mData(o) + Base::Base(const std::shared_ptr& d) + : mData(d) { } - Base::Base(std::shared_ptr&& o) - : mData(std::move(o)) + Base::Base(std::shared_ptr&& d) + : mData(std::move(d)) { } diff --git a/Libs/libRepoMan/Frontend/Base.hpp b/Libs/libRepoMan/Frontend/Base.hpp index 0eac9406..2029dbe0 100644 --- a/Libs/libRepoMan/Frontend/Base.hpp +++ b/Libs/libRepoMan/Frontend/Base.hpp @@ -44,8 +44,8 @@ namespace RM using DPtrType = Data::Base; public: - Base(const std::shared_ptr& _d); - Base(std::shared_ptr&& _d); + Base(const std::shared_ptr& d); + Base(std::shared_ptr&& d); virtual ~Base(); Base(); diff --git a/Libs/libRepoMan/Frontend/Branch.cpp b/Libs/libRepoMan/Frontend/Branch.cpp index 3671759c..5db6a411 100644 --- a/Libs/libRepoMan/Frontend/Branch.cpp +++ b/Libs/libRepoMan/Frontend/Branch.cpp @@ -21,8 +21,6 @@ #include "libRepoMan/Frontend/Repo.hpp" #include "libRepoMan/Frontend/Head.hpp" -#include "libRepoMan/Events.hpp" - #include "libRepoMan/Private/Dumper.hpp" #include "libRepoMan/Data/Branch.hpp" diff --git a/Libs/libRepoMan/Frontend/Head.cpp b/Libs/libRepoMan/Frontend/Head.cpp index 39190171..c59079ff 100644 --- a/Libs/libRepoMan/Frontend/Head.cpp +++ b/Libs/libRepoMan/Frontend/Head.cpp @@ -17,8 +17,6 @@ * */ -#include "libRepoMan/Events.hpp" - #include "libRepoMan/Private/Dumper.hpp" #include "libRepoMan/Data/Head.hpp" diff --git a/Libs/libRepoMan/Frontend/Namespace.cpp b/Libs/libRepoMan/Frontend/Namespace.cpp index e1d15803..ae2251bd 100644 --- a/Libs/libRepoMan/Frontend/Namespace.cpp +++ b/Libs/libRepoMan/Frontend/Namespace.cpp @@ -17,8 +17,6 @@ * */ -#include "libRepoMan/Events.hpp" - #include "libRepoMan/Frontend/Namespace.hpp" #include "libRepoMan/Private/Dumper.hpp" diff --git a/Libs/libRepoMan/Frontend/RefTreeNode.cpp b/Libs/libRepoMan/Frontend/RefTreeNode.cpp index 110ce0c1..140da7e8 100644 --- a/Libs/libRepoMan/Frontend/RefTreeNode.cpp +++ b/Libs/libRepoMan/Frontend/RefTreeNode.cpp @@ -17,8 +17,6 @@ * */ -#include "libRepoMan/Events.hpp" - #include "libRepoMan/Frontend/RefTreeNode.hpp" #include "libRepoMan/Private/Dumper.hpp" diff --git a/Libs/libRepoMan/Frontend/Reference.cpp b/Libs/libRepoMan/Frontend/Reference.cpp index 0f44c30d..831c2988 100644 --- a/Libs/libRepoMan/Frontend/Reference.cpp +++ b/Libs/libRepoMan/Frontend/Reference.cpp @@ -21,8 +21,6 @@ #include "libGitWrap/Reference.hpp" #include "libGitWrap/RefName.hpp" -#include "libRepoMan/Events.hpp" - #include "libRepoMan/Frontend/BaseInternal.hpp" #include "libRepoMan/Frontend/Reference.hpp" #include "libRepoMan/Frontend/Repo.hpp" diff --git a/Libs/libRepoMan/Frontend/Remote.cpp b/Libs/libRepoMan/Frontend/Remote.cpp index b590eddf..997ad188 100644 --- a/Libs/libRepoMan/Frontend/Remote.cpp +++ b/Libs/libRepoMan/Frontend/Remote.cpp @@ -19,8 +19,6 @@ #include "libGitWrap/Result.hpp" -#include "libRepoMan/Events.hpp" - #include "libRepoMan/Frontend/Repo.hpp" #include "libRepoMan/Frontend/Remote.hpp" diff --git a/Libs/libRepoMan/Frontend/Repo.cpp b/Libs/libRepoMan/Frontend/Repo.cpp index ea626a42..8dab44e6 100644 --- a/Libs/libRepoMan/Frontend/Repo.cpp +++ b/Libs/libRepoMan/Frontend/Repo.cpp @@ -22,7 +22,6 @@ #include "libGitWrap/RefName.hpp" #include "libGitWrap/Submodule.hpp" -#include "libRepoMan/Events.hpp" #include "libRepoMan/RepoMan.hpp" #include "libRepoMan/Frontend/BaseInternal.hpp" diff --git a/Libs/libRepoMan/Frontend/Submodule.cpp b/Libs/libRepoMan/Frontend/Submodule.cpp index 584026bf..bdabdab1 100644 --- a/Libs/libRepoMan/Frontend/Submodule.cpp +++ b/Libs/libRepoMan/Frontend/Submodule.cpp @@ -17,8 +17,6 @@ * */ -#include "libRepoMan/Events.hpp" - #include "libRepoMan/Data/Submodule.hpp" #include "libRepoMan/Private/Dumper.hpp" diff --git a/Libs/libRepoMan/Frontend/Tag.cpp b/Libs/libRepoMan/Frontend/Tag.cpp index 340b8c2a..d977d77e 100644 --- a/Libs/libRepoMan/Frontend/Tag.cpp +++ b/Libs/libRepoMan/Frontend/Tag.cpp @@ -17,8 +17,6 @@ * */ -#include "libRepoMan/Events.hpp" - #include "libRepoMan/Frontend/Tag.hpp" #include "libRepoMan/Private/Dumper.hpp" diff --git a/Libs/libRepoMan/RepoMan.cpp b/Libs/libRepoMan/RepoMan.cpp index d943df1f..0688e190 100644 --- a/Libs/libRepoMan/RepoMan.cpp +++ b/Libs/libRepoMan/RepoMan.cpp @@ -18,7 +18,6 @@ */ #include "libRepoMan/RepoMan.hpp" -#include "libRepoMan/Events.hpp" #include "libRepoMan/Private/Dumper.hpp" @@ -46,8 +45,6 @@ namespace RM */ RepoMan::RepoMan() { - Events::addReceiver(this); - connect(BlueSky::Application::instance(), &BlueSky::Application::activeModeChanged, this, @@ -63,7 +60,6 @@ namespace RM RepoMan::~RepoMan() { closeAll(); - Events::delReceiver(this); } RepoMan& RepoMan::instance() diff --git a/Libs/libRepoMan/RepoMan.hpp b/Libs/libRepoMan/RepoMan.hpp index 33f0bbf3..298b0dde 100644 --- a/Libs/libRepoMan/RepoMan.hpp +++ b/Libs/libRepoMan/RepoMan.hpp @@ -21,16 +21,18 @@ #include "libRepoMan/Frontend/Repo.hpp" -#include "libRepoMan/Events.hpp" +#include "libRepoMan/Events/Event.hpp" #include namespace RM { + namespace Frontend { class Branch; } + class REPOMAN_API RepoMan : public QObject - , private EventsInterface + //, private EventsInterface { Q_OBJECT private: @@ -61,6 +63,7 @@ namespace RM void repositoryClosed(); void hasActiveRepositoryChanged(bool hasActiveRepo); + #ifndef REPOMAN_NO_COMPAT signals: void repositoryOpened(const RM::Frontend::Repo& repo); void repositoryAboutToClose(const RM::Frontend::Repo& repo); @@ -95,6 +98,7 @@ namespace RM void repositoryStateChanged(const RM::Frontend::Repo& repo); void indexUpdated(const RM::Frontend::Repo& repo); void workTreeUpdated(const RM::Frontend::Repo& repo); + #endif }; } diff --git a/Modules/RepoManLogger/Listener.cpp b/Modules/RepoManLogger/Listener.cpp index 003df9ff..ae3c0bf5 100644 --- a/Modules/RepoManLogger/Listener.cpp +++ b/Modules/RepoManLogger/Listener.cpp @@ -28,12 +28,12 @@ Listener::Listener(Log::Channel channel) : repoManChannel(channel) { - RM::Events::addReceiver(this); + RM::CompatEvents::addReceiver(this); } Listener::~Listener() { - RM::Events::delReceiver(this); + RM::CompatEvents::delReceiver(this); } void Listener::repositoryOpened(const RM::Frontend::Repo& repo) @@ -74,39 +74,39 @@ void Listener::repositoryDeactivated(const RM::Frontend::Repo& repo) // We don't want to report deactivation } -void Listener::objectCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object) +void Listener::objectCreated(const RM::Frontend::Base& object) { } -void Listener::objectAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object) +void Listener::objectAboutToBeDeleted(const RM::Frontend::Base& object) { } -void Listener::refTreeNodeCreated(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node) +void Listener::refTreeNodeCreated(const RM::Frontend::RefTreeNode& node) { } -void Listener::refTreeNodeAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node) +void Listener::refTreeNodeAboutToBeDeleted(const RM::Frontend::RefTreeNode& node) { } -void Listener::refCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) +void Listener::refCreated(const RM::Frontend::Reference& ref) { } -void Listener::refAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) +void Listener::refAboutToBeDeleted(const RM::Frontend::Reference& ref) { } -void Listener::refMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) +void Listener::refMoved(const RM::Frontend::Reference& ref) { } -void Listener::refHeadDetached(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) +void Listener::refHeadDetached(const RM::Frontend::Reference& ref) { } -void Listener::tagCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag) +void Listener::tagCreated(const RM::Frontend::Tag& tag) { Log::Event e = Log::Event::create(TMPL_FOUND_NEW_REF); Q_ASSERT(e); @@ -114,91 +114,91 @@ void Listener::tagCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Ta e.setParam(QStringLiteral("Type"), tr("tag")); e.setParam(QStringLiteral("ObjName"), tag.displayName()); e.setParam(QStringLiteral("SHA"), tag.displaySha1()); - e.setParam(QStringLiteral("RepoName"), repo.displayAlias()); + e.setParam(QStringLiteral("RepoName"), tag.repository().displayAlias()); repoManChannel.addEvent(e); } -void Listener::tagAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag) +void Listener::tagAboutToBeDeleted(const RM::Frontend::Tag& tag) { } -void Listener::branchCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) +void Listener::branchCreated(const RM::Frontend::Branch& branch) { } -void Listener::branchAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) +void Listener::branchAboutToBeDeleted(const RM::Frontend::Branch& branch) { } -void Listener::branchMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) +void Listener::branchMoved(const RM::Frontend::Branch& branch) { Log::Event e = Log::Event::create(TMPL_BRANCH_MOVED); Q_ASSERT(e); e.setParam(QStringLiteral("ObjName"), branch.displayName()); e.setParam(QStringLiteral("SHA"), branch.displaySha1()); - e.setParam(QStringLiteral("RepoName"), repo.displayAlias()); + e.setParam(QStringLiteral("RepoName"), branch.repository().displayAlias()); repoManChannel.addEvent(e); } -void Listener::branchUpstreamChanged(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch) +void Listener::branchUpstreamChanged(const RM::Frontend::Branch& branch) { } -void Listener::namespaceCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace) +void Listener::namespaceCreated(const RM::Frontend::Namespace& nameSpace) { } -void Listener::namespaceAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace) +void Listener::namespaceAboutToBeDeleted(const RM::Frontend::Namespace& nameSpace) { } -void Listener::refLogChanged(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog) +void Listener::refLogChanged(const RM::Frontend::RefLog& reflog) { } -void Listener::refLogNewEntry(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog) +void Listener::refLogNewEntry(const RM::Frontend::RefLog& reflog) { } -void Listener::stageCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) +void Listener::stageCreated(const RM::Frontend::Reference& ref) { } -void Listener::stageAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref) +void Listener::stageAboutToBeDeleted(const RM::Frontend::Reference& ref) { } -void Listener::remoteCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) +void Listener::remoteCreated(const RM::Frontend::Remote& remote) { } -void Listener::remoteAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) +void Listener::remoteAboutToBeDeleted(const RM::Frontend::Remote& remote) { } -void Listener::remoteModified(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote) +void Listener::remoteModified(const RM::Frontend::Remote& remote) { } -void Listener::submoduleCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) +void Listener::submoduleCreated(const RM::Frontend::Submodule& submodule) { Log::Event e = Log::Event::create(TMPL_FOUND_NEW_SM); Q_ASSERT(e); e.setParam(QStringLiteral("ObjName"), submodule.displayName()); - e.setParam(QStringLiteral("RepoName"), repo.displayAlias()); + e.setParam(QStringLiteral("RepoName"), submodule.repository().displayAlias()); repoManChannel.addEvent(e); } -void Listener::submoduleAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) +void Listener::submoduleAboutToBeDeleted(const RM::Frontend::Submodule& submodule) { } -void Listener::submoduleMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule) +void Listener::submoduleMoved(const RM::Frontend::Submodule& submodule) { } @@ -206,10 +206,10 @@ void Listener::repositoryStateChanged(const RM::Frontend::Repo& repo) { } -void Listener::indexUpdated(const RM::Frontend::Repo& repo) +void Listener::indexUpdated() { } -void Listener::workTreeUpdated(const RM::Frontend::Repo& repo) +void Listener::workTreeUpdated() { } diff --git a/Modules/RepoManLogger/Listener.hpp b/Modules/RepoManLogger/Listener.hpp index 3ded666c..8fd867e3 100644 --- a/Modules/RepoManLogger/Listener.hpp +++ b/Modules/RepoManLogger/Listener.hpp @@ -19,14 +19,14 @@ #pragma once -#include - -#include "libRepoMan/Events.hpp" +#include "libRepoMan/Events/Compat.hpp" #include "libLogger/Channel.hpp" #include "libLogger/Event.hpp" -class Listener : public RM::EventsInterface +#include + +class Listener : public RM::CompatEventsInterface { Q_DECLARE_TR_FUNCTIONS(RepoManLogger) @@ -39,35 +39,35 @@ class Listener : public RM::EventsInterface void repositoryAboutToClose(const RM::Frontend::Repo& repo); void repositoryActivated(const RM::Frontend::Repo& repo); void repositoryDeactivated(const RM::Frontend::Repo& repo); - void objectCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object); - void objectAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object); - void refTreeNodeCreated(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node); - void refTreeNodeAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node); - void refCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void refAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void refMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void refHeadDetached(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void tagCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag); - void tagAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag); - void branchCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); - void branchAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); - void branchMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); - void branchUpstreamChanged(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); - void namespaceCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace); - void namespaceAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace); - void refLogChanged(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog); - void refLogNewEntry(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog); - void stageCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void stageAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void remoteCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); - void remoteAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); - void remoteModified(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); - void submoduleCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); - void submoduleAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); - void submoduleMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); + void objectCreated(const RM::Frontend::Base& object); + void objectAboutToBeDeleted(const RM::Frontend::Base& object); + void refTreeNodeCreated(const RM::Frontend::RefTreeNode& node); + void refTreeNodeAboutToBeDeleted(const RM::Frontend::RefTreeNode& node); + void refCreated(const RM::Frontend::Reference& ref); + void refAboutToBeDeleted(const RM::Frontend::Reference& ref); + void refMoved(const RM::Frontend::Reference& ref); + void refHeadDetached(const RM::Frontend::Reference& ref); + void tagCreated(const RM::Frontend::Tag& tag); + void tagAboutToBeDeleted(const RM::Frontend::Tag& tag); + void branchCreated(const RM::Frontend::Branch& branch); + void branchAboutToBeDeleted(const RM::Frontend::Branch& branch); + void branchMoved(const RM::Frontend::Branch& branch); + void branchUpstreamChanged(const RM::Frontend::Branch& branch); + void namespaceCreated(const RM::Frontend::Namespace& nameSpace); + void namespaceAboutToBeDeleted(const RM::Frontend::Namespace& nameSpace); + void refLogChanged(const RM::Frontend::RefLog& reflog); + void refLogNewEntry(const RM::Frontend::RefLog& reflog); + void stageCreated(const RM::Frontend::Reference& ref); + void stageAboutToBeDeleted(const RM::Frontend::Reference& ref); + void remoteCreated(const RM::Frontend::Remote& remote); + void remoteAboutToBeDeleted(const RM::Frontend::Remote& remote); + void remoteModified(const RM::Frontend::Remote& remote); + void submoduleCreated(const RM::Frontend::Submodule& submodule); + void submoduleAboutToBeDeleted(const RM::Frontend::Submodule& submodule); + void submoduleMoved(const RM::Frontend::Submodule& submodule); void repositoryStateChanged(const RM::Frontend::Repo& repo); - void indexUpdated(const RM::Frontend::Repo& repo); - void workTreeUpdated(const RM::Frontend::Repo& repo); + void indexUpdated(); + void workTreeUpdated(); private: Log::Channel repoManChannel; diff --git a/Modules/RepoManLogger/RepoManLoggerModule.cpp b/Modules/RepoManLogger/RepoManLoggerModule.cpp index 7b8ec21b..6c51d615 100644 --- a/Modules/RepoManLogger/RepoManLoggerModule.cpp +++ b/Modules/RepoManLogger/RepoManLoggerModule.cpp @@ -25,7 +25,7 @@ #include "TemplateNames.hpp" RepoManLoggerModule::RepoManLoggerModule() - : listener(NULL) + : listener(nullptr) { } @@ -49,7 +49,7 @@ void RepoManLoggerModule::deinitialize() // Channel should also be kept registered // But listener has to be destroyed... delete listener; - listener = NULL; + listener = nullptr; } void RepoManLoggerModule::setupTemplates() From f9d48016a39ad1c5850ce3041e4db12a26104651 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Mon, 20 Apr 2015 00:56:04 +0100 Subject: [PATCH 21/75] Fix some Compat-Event compile issues --- .../Widgets/RepoStateWidget.cpp | 21 ++++--- .../Widgets/RepoStateWidget.hpp | 4 +- Libs/libRepoMan/RepoMan.hpp | 61 +++++++++---------- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp b/Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp index bd26c3d2..c0d4f884 100644 --- a/Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp +++ b/Libs/libMacGitverCore/Widgets/RepoStateWidget.cpp @@ -48,18 +48,18 @@ RepoStateWidget::RepoStateWidget() this, &RepoStateWidget::repositoryDeactivated); } -void RepoStateWidget::repositoryActivated(const RM::Frontend::Repo& info) +void RepoStateWidget::repositoryActivated(const RM::Frontend::Repo& repo) { - if (repo != info) { - repo = info; + if (mRepo != repo) { + mRepo = repo; setRepoState(); } } -void RepoStateWidget::repositoryDeactivated(const RM::Frontend::Repo& info) +void RepoStateWidget::repositoryDeactivated(const RM::Frontend::Repo& repo) { - if (repo == info) { - repo = RM::Frontend::Repo(); + if (mRepo == repo) { + mRepo = RM::Frontend::Repo(); setRepoState(); } } @@ -68,15 +68,16 @@ void RepoStateWidget::setRepoState() { txtState->hide(); - txtRepo->setText(repo ? repo.displayAlias() : QString()); - onUpdateHEAD(repo, RM::Frontend::Reference()); + txtRepo->setText(mRepo ? mRepo.displayAlias() : QString()); + onUpdateHEAD(RM::Frontend::Reference()); } void RepoStateWidget::onUpdateHEAD( - const RM::Frontend::Repo& ownerRepo, const RM::Frontend::Reference& ref) { - if (ownerRepo != repo) { + RM::Frontend::Repo repo = ref.repository(); + + if (repo != mRepo) { return; } diff --git a/Libs/libMacGitverCore/Widgets/RepoStateWidget.hpp b/Libs/libMacGitverCore/Widgets/RepoStateWidget.hpp index 4d6a5bd3..773f3ad3 100644 --- a/Libs/libMacGitverCore/Widgets/RepoStateWidget.hpp +++ b/Libs/libMacGitverCore/Widgets/RepoStateWidget.hpp @@ -40,10 +40,10 @@ private slots: void setRepoState(); public slots: - void onUpdateHEAD(const RM::Frontend::Repo& ownerRepo, const RM::Frontend::Reference& ref); + void onUpdateHEAD(const RM::Frontend::Reference& ref); private: - RM::Frontend::Repo repo; + RM::Frontend::Repo mRepo; QLabel* txtRepo; QLabel* txtState; QLabel* txtBranch; diff --git a/Libs/libRepoMan/RepoMan.hpp b/Libs/libRepoMan/RepoMan.hpp index 298b0dde..fc37bbbb 100644 --- a/Libs/libRepoMan/RepoMan.hpp +++ b/Libs/libRepoMan/RepoMan.hpp @@ -22,6 +22,7 @@ #include "libRepoMan/Frontend/Repo.hpp" #include "libRepoMan/Events/Event.hpp" +#include "libRepoMan/Events/Compat.hpp" #include @@ -32,7 +33,7 @@ namespace RM class REPOMAN_API RepoMan : public QObject - //, private EventsInterface + , private CompatEventsInterface { Q_OBJECT private: @@ -63,42 +64,40 @@ namespace RM void repositoryClosed(); void hasActiveRepositoryChanged(bool hasActiveRepo); - #ifndef REPOMAN_NO_COMPAT signals: void repositoryOpened(const RM::Frontend::Repo& repo); void repositoryAboutToClose(const RM::Frontend::Repo& repo); void repositoryActivated(const RM::Frontend::Repo& repo); void repositoryDeactivated(const RM::Frontend::Repo& repo); - void objectCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object); - void objectAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Base& object); - void refTreeNodeCreated(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node); - void refTreeNodeAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::RefTreeNode& node); - void refCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void refAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void refMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void refHeadDetached(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void tagCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag); - void tagAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Tag& tag); - void branchCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); - void branchAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); - void branchMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); - void branchUpstreamChanged(const RM::Frontend::Repo& repo, const RM::Frontend::Branch& branch); - void namespaceCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace); - void namespaceAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Namespace& nameSpace); - void refLogChanged(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog); - void refLogNewEntry(const RM::Frontend::Repo& repo, const RM::Frontend::RefLog& reflog); - void stageCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void stageAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Reference& ref); - void remoteCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); - void remoteAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); - void remoteModified(const RM::Frontend::Repo& repo, const RM::Frontend::Remote& remote); - void submoduleCreated(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); - void submoduleAboutToBeDeleted(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); - void submoduleMoved(const RM::Frontend::Repo& repo, const RM::Frontend::Submodule& submodule); + void objectCreated(const RM::Frontend::Base& object); + void objectAboutToBeDeleted(const RM::Frontend::Base& object); + void refTreeNodeCreated(const RM::Frontend::RefTreeNode& node); + void refTreeNodeAboutToBeDeleted(const RM::Frontend::RefTreeNode& node); + void refCreated(const RM::Frontend::Reference& ref); + void refAboutToBeDeleted(const RM::Frontend::Reference& ref); + void refMoved(const RM::Frontend::Reference& ref); + void refHeadDetached(const RM::Frontend::Reference& ref); + void tagCreated(const RM::Frontend::Tag& tag); + void tagAboutToBeDeleted(const RM::Frontend::Tag& tag); + void branchCreated(const RM::Frontend::Branch& branch); + void branchAboutToBeDeleted(const RM::Frontend::Branch& branch); + void branchMoved(const RM::Frontend::Branch& branch); + void branchUpstreamChanged(const RM::Frontend::Branch& branch); + void namespaceCreated(const RM::Frontend::Namespace& nameSpace); + void namespaceAboutToBeDeleted(const RM::Frontend::Namespace& nameSpace); + void refLogChanged(const RM::Frontend::RefLog& reflog); + void refLogNewEntry(const RM::Frontend::RefLog& reflog); + void stageCreated(const RM::Frontend::Reference& ref); + void stageAboutToBeDeleted(const RM::Frontend::Reference& ref); + void remoteCreated(const RM::Frontend::Remote& remote); + void remoteAboutToBeDeleted(const RM::Frontend::Remote& remote); + void remoteModified(const RM::Frontend::Remote& remote); + void submoduleCreated(const RM::Frontend::Submodule& submodule); + void submoduleAboutToBeDeleted(const RM::Frontend::Submodule& submodule); + void submoduleMoved(const RM::Frontend::Submodule& submodule); void repositoryStateChanged(const RM::Frontend::Repo& repo); - void indexUpdated(const RM::Frontend::Repo& repo); - void workTreeUpdated(const RM::Frontend::Repo& repo); - #endif + void indexUpdated(); + void workTreeUpdated(); }; } From 6ecc29ca85c878b4ecc5f578c076c9c392cfbbdd Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Tue, 21 Apr 2015 22:38:06 +0100 Subject: [PATCH 22/75] Logging Channel for Git --- Libs/libRepoMan/Backend/RepoMan.cpp | 25 +++++++++++++++++++++++++ Libs/libRepoMan/Backend/RepoMan.hpp | 12 ++++++++++++ Libs/libRepoMan/CMakeLists.txt | 1 + 3 files changed, 38 insertions(+) diff --git a/Libs/libRepoMan/Backend/RepoMan.cpp b/Libs/libRepoMan/Backend/RepoMan.cpp index 4687491c..e10ab95a 100644 --- a/Libs/libRepoMan/Backend/RepoMan.cpp +++ b/Libs/libRepoMan/Backend/RepoMan.cpp @@ -19,6 +19,8 @@ #include "libRepoMan/Backend/RepoMan.hpp" +#include "libLogger/Manager.hpp" + #include #include @@ -42,6 +44,8 @@ namespace RM { moveToThread(mWorkerThread); mWorkerThread->start(); + + setupLogging(); } RepoMan& RepoMan::instance() @@ -54,6 +58,27 @@ namespace RM return repoMan()->mWorkerThread; } + void RepoMan::setupLogging() + { + mGitErrorChannel = Log::Channel::create(tr("Git Errors")); + + Log::Manager().addChannel(mGitErrorChannel); + + mGitErrorTemplate = Log::Template::create(tr("Git Errors")); + mGitErrorTemplate.setTransformation(tr("$$ caused a git error: $gwerror$")); + Log::Manager().addTemplate(mGitErrorTemplate); + } + + Log::Channel RepoMan::gitErrorChannel() const + { + return mGitErrorChannel; + } + + Log::Template RepoMan::gitErrorTemplate() const + { + return mGitErrorTemplate; + } + } } diff --git a/Libs/libRepoMan/Backend/RepoMan.hpp b/Libs/libRepoMan/Backend/RepoMan.hpp index e93f3791..8a6284b6 100644 --- a/Libs/libRepoMan/Backend/RepoMan.hpp +++ b/Libs/libRepoMan/Backend/RepoMan.hpp @@ -21,6 +21,9 @@ #include "libRepoMan/Data/Repo.hpp" +#include "libLogger/Channel.hpp" +#include "libLogger/Template.hpp" + #include #include @@ -44,10 +47,19 @@ namespace RM public: Data::Repo::SPtr findRepo(const QString& workTreePath) const; + public: + Log::Channel gitErrorChannel() const; + Log::Template gitErrorTemplate() const; + + private: + void setupLogging(); + private: QThread* mWorkerThread; mutable QMutex mRepoMan; Data::Repo::SList mRepos; + Log::Channel mGitErrorChannel; + Log::Template mGitErrorTemplate; }; } diff --git a/Libs/libRepoMan/CMakeLists.txt b/Libs/libRepoMan/CMakeLists.txt index bb1d46b5..97cf8c7a 100644 --- a/Libs/libRepoMan/CMakeLists.txt +++ b/Libs/libRepoMan/CMakeLists.txt @@ -121,6 +121,7 @@ TARGET_LINK_LIBRARIES( BlueSky LINK_PRIVATE + Logger GitWrap ) From c635fcc33b63b333d7376b9aa78151120c7fcccf Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sat, 9 May 2015 21:36:29 +0100 Subject: [PATCH 23/75] Add Service Runner into the backend --- Libs/libRepoMan/Backend/AbstractService.cpp | 61 ++++++++++ Libs/libRepoMan/Backend/AbstractService.hpp | 49 ++++++++ Libs/libRepoMan/Backend/ServiceRunner.cpp | 122 ++++++++++++++++++++ Libs/libRepoMan/Backend/ServiceRunner.hpp | 69 +++++++++++ Libs/libRepoMan/CMakeLists.txt | 4 + 5 files changed, 305 insertions(+) create mode 100644 Libs/libRepoMan/Backend/AbstractService.cpp create mode 100644 Libs/libRepoMan/Backend/AbstractService.hpp create mode 100644 Libs/libRepoMan/Backend/ServiceRunner.cpp create mode 100644 Libs/libRepoMan/Backend/ServiceRunner.hpp diff --git a/Libs/libRepoMan/Backend/AbstractService.cpp b/Libs/libRepoMan/Backend/AbstractService.cpp new file mode 100644 index 00000000..8d8e996c --- /dev/null +++ b/Libs/libRepoMan/Backend/AbstractService.cpp @@ -0,0 +1,61 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libLogger/Manager.hpp" +#include "libLogger/Event.hpp" + +#include "libRepoMan/Backend/AbstractService.hpp" +#include "libRepoMan/Backend/RepoMan.hpp" + +#include + +namespace RM { namespace Backend { + +AbstractService::AbstractService() +{ +} + +void AbstractService::execute() +{ + if (thread() != RepoMan::workerThread()) { + qDebug() << "Running a Service outside of the RepoMan Thread."; + Q_ASSERT(false); + return; + } + + emit started(); + + run(); + + emit finished(); +} + +void AbstractService::logGitError(const Git::Result& r, const char* msg) +{ + Log::Channel ch = RepoMan::instance().gitErrorChannel(); + Log::Template tpl = RepoMan::instance().gitErrorTemplate(); + Log::Event ev = Log::Event::create(tpl); + + ev.setParam(QStringLiteral("gwerror"), r.errorText()); + ev.setText(QString::fromUtf8(msg)); + + Log::Manager().addEvent(ch, ev); +} + +} } diff --git a/Libs/libRepoMan/Backend/AbstractService.hpp b/Libs/libRepoMan/Backend/AbstractService.hpp new file mode 100644 index 00000000..edf77744 --- /dev/null +++ b/Libs/libRepoMan/Backend/AbstractService.hpp @@ -0,0 +1,49 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libGitWrap/Result.hpp" + +#include + +namespace RM { namespace Backend { + +class AbstractService + : public QObject +{ + Q_OBJECT +public: + AbstractService(); + +signals: + void started(); + void finished(); + +public: + void execute(); + +protected: + virtual void run() = 0; + +protected: + void logGitError(const Git::Result& r, const char* msg = nullptr); +}; + +} } diff --git a/Libs/libRepoMan/Backend/ServiceRunner.cpp b/Libs/libRepoMan/Backend/ServiceRunner.cpp new file mode 100644 index 00000000..00bd096d --- /dev/null +++ b/Libs/libRepoMan/Backend/ServiceRunner.cpp @@ -0,0 +1,122 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libRepoMan/Backend/ServiceRunner.hpp" +#include "libRepoMan/Backend/AbstractService.hpp" +#include "libRepoMan/Backend/RepoMan.hpp" + +#include +#include +#include +#include + +namespace RM { namespace Backend { + +typedef QQueue< QPointer > ServiceQueue; + +class ServiceRunner::Data +{ +public: + QMutex mMtx; + +public: + ServiceQueue& queueFor(RunnerPriority priority); + AbstractService* dequeueNext(); + +private: + ServiceQueue mLowQueue, mDefaultQueue, mUrgentQueue, mImmediateQueue; +}; + +ServiceQueue& ServiceRunner::Data::queueFor(RunnerPriority priority) +{ + switch (priority) { + case RunnerPriority::Low: return mLowQueue; + case RunnerPriority::Default: return mDefaultQueue; + case RunnerPriority::Urgent: return mUrgentQueue; + case RunnerPriority::Immediate: return mImmediateQueue; + default: Q_ASSERT(false); + } +} + +AbstractService* ServiceRunner::Data::dequeueNext() +{ + QMutexLocker _(&mMtx); + + if (!mImmediateQueue.empty()) { + return mImmediateQueue.dequeue(); + } + else if (!mUrgentQueue.empty()) { + return mUrgentQueue.dequeue(); + } + else if (!mDefaultQueue.empty()) { + return mDefaultQueue.dequeue(); + } + else if (!mLowQueue.empty()) { + return mLowQueue.dequeue(); + } + + return NULL; +} + +void ServiceRunner::processNext() +{ + AbstractService* next = d->dequeueNext(); + + if (next) { + next->execute(); + } +} + +ServiceRunner::ServiceRunner() + : d(new Data) +{ + connect(this, &ServiceRunner::processNextService, + this, &ServiceRunner::processNext, + Qt::QueuedConnection); +} + +ServiceRunner::~ServiceRunner() +{ + delete d; +} + +void ServiceRunner::enqueue(Backend::AbstractService* svc, RunnerPriority priority) +{ + QMutexLocker(&d->mMtx); + + ServiceQueue& queue(d->queueFor(priority)); + svc->moveToThread(Backend::RepoMan::workerThread()); + queue.enqueue(svc); + + emit processNextService(); +} + +ServiceRunner& ServiceRunner::instance() +{ + QPointer< ServiceRunner > sSelf; + + if (sSelf.isNull()) { + sSelf = new ServiceRunner; + sSelf->moveToThread(Backend::RepoMan::workerThread()); + } + + return *sSelf; +} + +} } diff --git a/Libs/libRepoMan/Backend/ServiceRunner.hpp b/Libs/libRepoMan/Backend/ServiceRunner.hpp new file mode 100644 index 00000000..046f2eed --- /dev/null +++ b/Libs/libRepoMan/Backend/ServiceRunner.hpp @@ -0,0 +1,69 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 + +namespace RM { namespace Backend { + +class AbstractService; + +enum class RunnerPriority +{ + Low, + Default, + Urgent, + Immediate, +}; + +class ServiceRunner + : public QObject +{ + Q_OBJECT +private: + ServiceRunner(); +public: + ~ServiceRunner(); + +public: + static ServiceRunner& instance(); + +public: + void enqueue(Backend::AbstractService* svc, RunnerPriority priority); + +signals: + void processNextService(); + +private: + void processNext(); + +private: + class Data; + Data* d; +}; + +static inline void perform( + Backend::AbstractService* svc, + RunnerPriority priority = RunnerPriority::Default) +{ + ServiceRunner::instance().enqueue(svc, priority); +} + +} } diff --git a/Libs/libRepoMan/CMakeLists.txt b/Libs/libRepoMan/CMakeLists.txt index 97cf8c7a..cc1318a0 100644 --- a/Libs/libRepoMan/CMakeLists.txt +++ b/Libs/libRepoMan/CMakeLists.txt @@ -43,6 +43,8 @@ SET( SRC_FILES Private/Dumper.cpp + Backend/AbstractService.cpp + Backend/ServiceRunner.cpp Backend/RepoMan.cpp ) @@ -89,6 +91,8 @@ SET( PRI_HDR_FILES Frontend/BaseInternal.hpp + Backend/AbstractService.hpp + Backend/ServiceRunner.hpp Backend/RepoMan.hpp Backend/RepoLocker.hpp ) From b6fb03a32334f99bf60421c2534ad330e6e98622 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 10 May 2015 00:35:14 +0100 Subject: [PATCH 24/75] Add: OpenRepository Service --- Libs/libRepoMan/CMakeLists.txt | 4 ++ Libs/libRepoMan/Services/OpenRepository.cpp | 44 +++++++++++++++++++++ Libs/libRepoMan/Services/OpenRepository.hpp | 40 +++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 Libs/libRepoMan/Services/OpenRepository.cpp create mode 100644 Libs/libRepoMan/Services/OpenRepository.hpp diff --git a/Libs/libRepoMan/CMakeLists.txt b/Libs/libRepoMan/CMakeLists.txt index cc1318a0..96d6d75a 100644 --- a/Libs/libRepoMan/CMakeLists.txt +++ b/Libs/libRepoMan/CMakeLists.txt @@ -46,6 +46,8 @@ SET( SRC_FILES Backend/AbstractService.cpp Backend/ServiceRunner.cpp Backend/RepoMan.cpp + + Services/OpenRepository.cpp ) SET( PUB_HDR_FILES @@ -95,6 +97,8 @@ SET( PRI_HDR_FILES Backend/ServiceRunner.hpp Backend/RepoMan.hpp Backend/RepoLocker.hpp + + Services/OpenRepository.hpp ) SET( HID_FILES diff --git a/Libs/libRepoMan/Services/OpenRepository.cpp b/Libs/libRepoMan/Services/OpenRepository.cpp new file mode 100644 index 00000000..b163a6b1 --- /dev/null +++ b/Libs/libRepoMan/Services/OpenRepository.cpp @@ -0,0 +1,44 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libRepoMan/Data/Repo.hpp" +#include "libRepoMan/Services/OpenRepository.hpp" + +#include "libGitWrap/Repository.hpp" + +namespace RM { namespace Services { + +OpenRepository::OpenRepository(const QString& path) + : mPath(path) +{ +} + +void OpenRepository::run() +{ + Git::Result res; + Git::Repository gitRepo = Git::Repository::open(res, mPath); + if (!res) { + logGitError(res); + } + + Data::Repo::SPtr repoData; + repoData.make_shared(gitRepo); +} + +} } diff --git a/Libs/libRepoMan/Services/OpenRepository.hpp b/Libs/libRepoMan/Services/OpenRepository.hpp new file mode 100644 index 00000000..85b44f6d --- /dev/null +++ b/Libs/libRepoMan/Services/OpenRepository.hpp @@ -0,0 +1,40 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libRepoMan/Backend/AbstractService.hpp" + +namespace RM { namespace Services { + +class OpenRepository + : public Backend::AbstractService +{ + Q_OBJECT +public: + OpenRepository(const QString& path); + +private: + void run(); + +private: + QString mPath; +}; + +} } From 0fa9c3ef95465e4662f579065ddc00205e253c54 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 10 May 2015 16:54:29 +0100 Subject: [PATCH 25/75] Invoke OpenRepository service --- Libs/libRepoMan/RepoMan.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Libs/libRepoMan/RepoMan.cpp b/Libs/libRepoMan/RepoMan.cpp index 0688e190..d1ae2093 100644 --- a/Libs/libRepoMan/RepoMan.cpp +++ b/Libs/libRepoMan/RepoMan.cpp @@ -21,6 +21,10 @@ #include "libRepoMan/Private/Dumper.hpp" +#include "libRepoMan/Backend/ServiceRunner.hpp" + +#include "libRepoMan/Services/OpenRepository.hpp" + #include "libRepoMan/Data/RepoMan.hpp" #include "libRepoMan/Data/Repo.hpp" @@ -86,8 +90,7 @@ namespace RM */ void RepoMan::open(const QString& path) { - // ### REPOMAN TODO - qDebug() << "RepoMan::Open is currently not implemented."; + Backend::perform(new Services::OpenRepository(path)); } /** From 63d17bc5ccdb9c8fb9cf0cadd703d5c6a7a708d3 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 10 May 2015 00:36:30 +0100 Subject: [PATCH 26/75] Add: RefreshRepository Service --- Libs/libRepoMan/CMakeLists.txt | 2 + .../libRepoMan/Services/RefreshRepository.cpp | 100 ++++++++++++++++++ .../libRepoMan/Services/RefreshRepository.hpp | 46 ++++++++ 3 files changed, 148 insertions(+) create mode 100644 Libs/libRepoMan/Services/RefreshRepository.cpp create mode 100644 Libs/libRepoMan/Services/RefreshRepository.hpp diff --git a/Libs/libRepoMan/CMakeLists.txt b/Libs/libRepoMan/CMakeLists.txt index 96d6d75a..f500985d 100644 --- a/Libs/libRepoMan/CMakeLists.txt +++ b/Libs/libRepoMan/CMakeLists.txt @@ -48,6 +48,7 @@ SET( SRC_FILES Backend/RepoMan.cpp Services/OpenRepository.cpp + Services/RefreshRepository.cpp ) SET( PUB_HDR_FILES @@ -99,6 +100,7 @@ SET( PRI_HDR_FILES Backend/RepoLocker.hpp Services/OpenRepository.hpp + Services/RefreshRepository.hpp ) SET( HID_FILES diff --git a/Libs/libRepoMan/Services/RefreshRepository.cpp b/Libs/libRepoMan/Services/RefreshRepository.cpp new file mode 100644 index 00000000..1c6708ca --- /dev/null +++ b/Libs/libRepoMan/Services/RefreshRepository.cpp @@ -0,0 +1,100 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libRepoMan/Backend/RepoMan.hpp" + +#include "libRepoMan/Backend/RepoLocker.hpp" +#include "libRepoMan/Services/RefreshRepository.hpp" + +#include "libGitWrap/Submodule.hpp" + +#include + +namespace RM { namespace Services { + +RefreshRepository::RefreshRepository(const Frontend::Repo& repo) + : mRepo() +{ + +} + +RefreshRepository::RefreshRepository(const Data::Repo::SPtr& repo) + : mRepo(repo) +{ +} + +void RefreshRepository::run() +{ + Backend::RepoLocker lock(mRepo); + + mGitRepo = mRepo->gitRepo(false); + if (!mGitRepo.isValid()) { + return; + } + + scanSubmodules(); +} + + +void RefreshRepository::scanSubmodules() +{ + Git::Result r; + Git::Submodule::List subs = mGitRepo.submodules(r); + if (!r) { + return; + } + + Data::Repo::SList oldSubmodules = Data::sharedFromWeakList(mRepo->submodules()); + + foreach (Git::Submodule sub, subs) { + Git::Result child; + + Git::Repository subRepo = sub.subRepository(child); + if (!child) { + // If we cannot load the repository, keep it in list of submodules to remove. + continue; + } + Q_ASSERT(subRepo.isValid()); + + QString path = subRepo.workTreePath(); + + if (path.endsWith(L'/')) { + path = path.left(path.length() - 1); + } + + auto it = std::find(oldSubmodules.begin(), oldSubmodules.end(), + mRepo->repoByPath(path, true)); + if (it != oldSubmodules.end()) { + oldSubmodules.erase(it); + } + else { + // ###REPOMAN + qDebug() << "Existing Submodule does not exist in data structure"; + // subInfo = new Submodule(subRepo, p); + } + } + + foreach (Data::Repo::WPtr repo, oldSubmodules) { + // ###REPOMAN + Q_UNUSED(repo); + // dataOf(repo)->terminateObject(); + } +} + +} } diff --git a/Libs/libRepoMan/Services/RefreshRepository.hpp b/Libs/libRepoMan/Services/RefreshRepository.hpp new file mode 100644 index 00000000..c2495fd6 --- /dev/null +++ b/Libs/libRepoMan/Services/RefreshRepository.hpp @@ -0,0 +1,46 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libRepoMan/Backend/AbstractService.hpp" +#include "libRepoMan/Data/Repo.hpp" + +namespace RM { namespace Services { + +class RefreshRepository + : public Backend::AbstractService +{ + Q_OBJECT +public: + RefreshRepository(const Frontend::Repo& repo); + RefreshRepository(const Data::Repo::SPtr& repo); + +private: + void run(); + +private: + void scanSubmodules(); + +private: + Data::Repo::SPtr mRepo; + Git::Repository mGitRepo; +}; + +} } From da0ed09ba410bbbdb3ea1f78b7286ad0db257d41 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 10 May 2015 16:57:48 +0100 Subject: [PATCH 27/75] Add: refresh() method to RepoMan --- Libs/libRepoMan/RepoMan.cpp | 9 +++++++++ Libs/libRepoMan/RepoMan.hpp | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/Libs/libRepoMan/RepoMan.cpp b/Libs/libRepoMan/RepoMan.cpp index d1ae2093..479c0e65 100644 --- a/Libs/libRepoMan/RepoMan.cpp +++ b/Libs/libRepoMan/RepoMan.cpp @@ -24,10 +24,13 @@ #include "libRepoMan/Backend/ServiceRunner.hpp" #include "libRepoMan/Services/OpenRepository.hpp" +#include "libRepoMan/Services/RefreshRepository.hpp" #include "libRepoMan/Data/RepoMan.hpp" #include "libRepoMan/Data/Repo.hpp" +#include "libLogger/Manager.hpp" + #include "libBlueSky/Application.hpp" #include @@ -192,6 +195,12 @@ namespace RM #endif } + void RepoMan::refresh(RefreshTypes what) + { + Log::Manager().addMessage(trUtf8("Refreshing git repositories...")); + Backend::perform(new Services::RefreshRepository(activeRepository())); + } + #if 0 // ###DEAD //-- RepoManPrivate ---------------------------------------------------------------------------- diff --git a/Libs/libRepoMan/RepoMan.hpp b/Libs/libRepoMan/RepoMan.hpp index fc37bbbb..9b9ce51d 100644 --- a/Libs/libRepoMan/RepoMan.hpp +++ b/Libs/libRepoMan/RepoMan.hpp @@ -29,6 +29,13 @@ namespace RM { + enum class RefreshTypes + { + Repositories, + Indicies, + Worktrees + }; + namespace Frontend { class Branch; } class REPOMAN_API RepoMan @@ -42,6 +49,7 @@ namespace RM ~RepoMan(); public: + void refresh(RefreshTypes what); void open(const QString& path); void closeAll(); From bf7ceff2996945682c5e0a74c0f0d30c142ba483 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 26 Apr 2015 21:33:04 +0100 Subject: [PATCH 28/75] Core files for libActivities --- Libs/CMakeLists.txt | 1 + Libs/libActivities/Api.hpp | 28 ++++++++++++++++++ Libs/libActivities/CMakeLists.txt | 48 +++++++++++++++++++++++++++++++ Libs/libActivities/Manager.cpp | 33 +++++++++++++++++++++ Libs/libActivities/Manager.hpp | 37 ++++++++++++++++++++++++ 5 files changed, 147 insertions(+) create mode 100644 Libs/libActivities/Api.hpp create mode 100644 Libs/libActivities/CMakeLists.txt create mode 100644 Libs/libActivities/Manager.cpp create mode 100644 Libs/libActivities/Manager.hpp diff --git a/Libs/CMakeLists.txt b/Libs/CMakeLists.txt index b80fdabd..215a80c8 100644 --- a/Libs/CMakeLists.txt +++ b/Libs/CMakeLists.txt @@ -11,6 +11,7 @@ INCLUDE_DIRECTORIES( BEFORE ) ADD_SUBDIRECTORY(libLogger) +ADD_SUBDIRECTORY(libActivities) ADD_SUBDIRECTORY(libDiffViews) ADD_SUBDIRECTORY(libRepoMan) ADD_SUBDIRECTORY(libMacGitverCore) diff --git a/Libs/libActivities/Api.hpp b/Libs/libActivities/Api.hpp new file mode 100644 index 00000000..b1f583ba --- /dev/null +++ b/Libs/libActivities/Api.hpp @@ -0,0 +1,28 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 + +#ifdef Activities_EXPORTS +# define ACTIVITIES_API Q_DECL_EXPORT +#else +# define ACTIVITIES_API Q_DECL_IMPORT +#endif diff --git a/Libs/libActivities/CMakeLists.txt b/Libs/libActivities/CMakeLists.txt new file mode 100644 index 00000000..e92a5325 --- /dev/null +++ b/Libs/libActivities/CMakeLists.txt @@ -0,0 +1,48 @@ + +PROJECT(ACTIVITIES) + +QT_PREPARE(Core) + +SET( SRC_FILES + + Manager.cpp +) + +SET( PUB_HDR_FILES + + Api.hpp + Manager.hpp +) + +SET( PRI_HDR_FILES +) + +SET( HDR_FILES ${PRI_HDR_FILES} ${PUB_HDR_FILES} ) + +QT_MOC( MOC_FILES ${HDR_FILES} ) + +ADD_QT_LIBRARY( + Activities SHARED + + ${SRC_FILES} + ${HDR_FILES} + ${MOC_FILES} +) + +TARGET_LINK_LIBRARIES( + Activities +) + +IF(UNIX AND NOT APPLE) + SET_TARGET_PROPERTIES( + Activities + PROPERTIES INSTALL_RPATH + "\$ORIGIN" + ) +ENDIF() + +RAD_DEFINE_VERSION(ACTIVITIES 0 0 1) +RAD_SET_TARGET_VERSION(Activities ACTIVITIES) +RAD_INSTALL_LIBRARY (Activities Activities) +RAD_INSTALL_HEADERS (libActivities ${PUB_HDR_FILES}) +RAD_SPLIT_SOURCE_TREE (libActivities) diff --git a/Libs/libActivities/Manager.cpp b/Libs/libActivities/Manager.cpp new file mode 100644 index 00000000..74b520e8 --- /dev/null +++ b/Libs/libActivities/Manager.cpp @@ -0,0 +1,33 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libActivities/Manager.hpp" + +namespace Activities +{ + + Manager::Manager() + { + } + + Manager::~Manager() + { + } + +} diff --git a/Libs/libActivities/Manager.hpp b/Libs/libActivities/Manager.hpp new file mode 100644 index 00000000..bc536f40 --- /dev/null +++ b/Libs/libActivities/Manager.hpp @@ -0,0 +1,37 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libActivities/Api.hpp" + +namespace Activities +{ + + class ACTIVITIES_API Manager + { + public: + Manager(); + ~Manager(); + + private: + + }; + +} From 431e98b550e4e1f41f58a5e74c4b129fee29d200 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Fri, 8 May 2015 20:39:47 +0100 Subject: [PATCH 29/75] Snapshot of a mostly complete Activities interface Still lacking lots of implementation and a good testcase. --- Libs/libActivities/Activity.cpp | 195 ++++++++++++++++ Libs/libActivities/Activity.hpp | 67 ++++++ Libs/libActivities/ActivityPrivate.hpp | 69 ++++++ Libs/libActivities/CMakeLists.txt | 10 + Libs/libActivities/Log.cpp | 140 +++++++++++ Libs/libActivities/Log.hpp | 55 +++++ Libs/libActivities/LogPrivate.hpp | 61 +++++ Libs/libActivities/Manager.cpp | 309 ++++++++++++++++++++++++- Libs/libActivities/Manager.hpp | 49 +++- Libs/libActivities/ManagerPrivate.hpp | 138 +++++++++++ Libs/libActivities/Step.cpp | 264 +++++++++++++++++++++ Libs/libActivities/Step.hpp | 80 +++++++ Libs/libActivities/StepPrivate.hpp | 97 ++++++++ 13 files changed, 1528 insertions(+), 6 deletions(-) create mode 100644 Libs/libActivities/Activity.cpp create mode 100644 Libs/libActivities/Activity.hpp create mode 100644 Libs/libActivities/ActivityPrivate.hpp create mode 100644 Libs/libActivities/Log.cpp create mode 100644 Libs/libActivities/Log.hpp create mode 100644 Libs/libActivities/LogPrivate.hpp create mode 100644 Libs/libActivities/ManagerPrivate.hpp create mode 100644 Libs/libActivities/Step.cpp create mode 100644 Libs/libActivities/Step.hpp create mode 100644 Libs/libActivities/StepPrivate.hpp diff --git a/Libs/libActivities/Activity.cpp b/Libs/libActivities/Activity.cpp new file mode 100644 index 00000000..b02114cc --- /dev/null +++ b/Libs/libActivities/Activity.cpp @@ -0,0 +1,195 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libActivities/Activity.hpp" +#include "libActivities/ActivityPrivate.hpp" +#include "libActivities/StepPrivate.hpp" +#include "libActivities/ManagerPrivate.hpp" + +namespace Activities +{ + + namespace + { + void countTypes(const std::vector& steps, int& pending, int& running, + int& success, int& error) + { + for (auto step : steps) { + switch (step->mState) { + case State::Unknown: + case State::PartiallyFinishedWithErrors: + break; + + case State::Pending: + pending++; + break; + + case State::InProgress: + running++; + break; + + case State::Finished: + success++; + break; + + case State::FinishedWithErrors: + error++; + break; + } + } + } + + State activityState(const std::vector& steps) + { + int pending = 0, running = 0, success = 0, error = 0, total = steps.size(); + countTypes(steps, pending, running, success, error); + + if (total == 0 || pending == total) { + return State::Pending; + } + + if (success == total) { + return State::Finished; + } + + if (error == total) { + return State::FinishedWithErrors; + } + + if (error > 0) { + return State::PartiallyFinishedWithErrors; + } + + assert(running + success > 0); + return State::InProgress; + } + } + + ActivityData::ActivityData(const QString &display) + : mGeneration(ManagerData::nextGeneration()) + , mState(State::Pending) + , mIsDefunct(false) + , mDisplay(display) + , mCurProgress(0) + , mMaxProgress(0) + , mTotalCurProgress(0) + , mTotalMaxProgress(0) + { + } + + ActivityData::~ActivityData() + { + } + + quint32 ActivityData::generation() const + { + return mGeneration; + } + + ActivityData::Ptr ActivityData::getptr() + { + return shared_from_this(); + } + + std::unique_lock ActivityData::uniqueLock() const + { + return std::unique_lock(mMtx); + } + + bool ActivityData::isDefunct() const + { + std::lock_guard _(mMtx); + return mIsDefunct; + } + + void ActivityData::updated(const StepData::Ptr& step, std::unique_lock& lock) + { + mTotalCurProgress = mCurProgress; + mTotalMaxProgress = mMaxProgress; + + for (StepData::Ptr step : mSteps) { + + } + } + + void ActivityData::stepStarted(const StepData::Ptr& step, std::unique_lock &lock) + { + State newState = activityState(mSteps); + } + + void ActivityData::stepFinished(const StepData::Ptr& step, bool failed, std::unique_lock &lock) + { + State newState = activityState(mSteps); + } + + void ActivityData::logUpdated(const LogData::Ptr &log, std::unique_lock &lock) + { + + } + + bool ActivityData::isModalityRequired() const + { + return mForceModalDialog; + } + + // ----- + + Step::Vector Activity::steps() const + { + Step::Vector r; + if (d) { + std::lock_guard _(d->mMtx); + for (const StepData::Ptr& step : d->mSteps) { + r.push_back(step); + } + } + return r; + } + + bool Activity::isDefunct() const + { + if (d) { + return d->isDefunct(); + } + + return true; + } + + Log Activity::log() const + { + if (d) { + std::lock_guard _(d->mMtx); + return {d->mLog}; + } + return Log(); + } + +#if 0 + void Activity::addStep(const Step::Ptr& step) + { + std::lock_guard _(mMtx); + std::shared_ptr _step = std::static_pointer_cast(step); + + _step->setActivity(getptr()); + mSteps.push_back(step); + } + +#endif + +} diff --git a/Libs/libActivities/Activity.hpp b/Libs/libActivities/Activity.hpp new file mode 100644 index 00000000..3d65c5b2 --- /dev/null +++ b/Libs/libActivities/Activity.hpp @@ -0,0 +1,67 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libActivities/Step.hpp" +#include "libActivities/Log.hpp" + +namespace Activities +{ + + class ActivityData; + + class ACTIVITIES_API Activity + { + public: + using Vector = std::vector; + + public: + Activity() = default; + ~Activity() = default; + Activity(const Activity& o) : Activity(o.d) {} + Activity(Activity&& o) : Activity(std::move(o.d)) {} + Activity(const std::shared_ptr& o) : d(o) {} + Activity(std::shared_ptr&& o) : d(std::move(o)) {} + + public: + Step::Vector steps() const; + + public: + State state() const; + QString display() const; + int curProgress() const; + int maxProgress() const; + int curOwnProgress() const; + int maxOwnProgress() const; + Log log() const; + + public: + void setState(State newState); + void setDisplay(const QString& display); + void setProgress(int cur, int max); + + public: + bool isDefunct() const; + + private: + std::shared_ptr d; + }; + +} diff --git a/Libs/libActivities/ActivityPrivate.hpp b/Libs/libActivities/ActivityPrivate.hpp new file mode 100644 index 00000000..bc856168 --- /dev/null +++ b/Libs/libActivities/ActivityPrivate.hpp @@ -0,0 +1,69 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libActivities/StepPrivate.hpp" +#include "libActivities/LogPrivate.hpp" + +namespace Activities +{ + + class ActivityData + : public std::enable_shared_from_this + { + public: + using Steps = std::vector; + using Ptr = std::shared_ptr; + using Vector = std::vector; + + public: + ActivityData(const QString& display); + ~ActivityData(); + + public: + quint32 generation() const; + Ptr getptr(); + std::unique_lock uniqueLock() const; + + void updated(const StepData::Ptr& step, std::unique_lock &lock); + void stepStarted(const StepData::Ptr& step, std::unique_lock &lock); + void stepFinished(const StepData::Ptr& step, bool failed, std::unique_lock &lock); + void logUpdated(const LogData::Ptr& log, std::unique_lock& lock); + + public: + bool isModalityRequired() const; + bool isDefunct() const; + + public: + mutable std::mutex mMtx; + quint32 mGeneration; + State mState; + bool mIsDefunct; + Steps mSteps; + LogData::Ptr mLog; + QString mDisplay; + int mCurProgress; + int mMaxProgress; + int mTotalCurProgress; + int mTotalMaxProgress; + bool mForceModalDialog; + }; + +} diff --git a/Libs/libActivities/CMakeLists.txt b/Libs/libActivities/CMakeLists.txt index e92a5325..2d64923c 100644 --- a/Libs/libActivities/CMakeLists.txt +++ b/Libs/libActivities/CMakeLists.txt @@ -6,15 +6,25 @@ QT_PREPARE(Core) SET( SRC_FILES Manager.cpp + Activity.cpp + Step.cpp + Log.cpp ) SET( PUB_HDR_FILES Api.hpp Manager.hpp + Activity.hpp + Step.hpp + Log.hpp ) SET( PRI_HDR_FILES + ManagerPrivate.hpp + ActivityPrivate.hpp + StepPrivate.hpp + LogPrivate.hpp ) SET( HDR_FILES ${PRI_HDR_FILES} ${PUB_HDR_FILES} ) diff --git a/Libs/libActivities/Log.cpp b/Libs/libActivities/Log.cpp new file mode 100644 index 00000000..813ba221 --- /dev/null +++ b/Libs/libActivities/Log.cpp @@ -0,0 +1,140 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libActivities/LogPrivate.hpp" +#include "libActivities/ActivityPrivate.hpp" + +namespace Activities +{ + + LogData::LogData() + { + } + + LogData::~LogData() + { + } + + LogData::Ptr LogData::getptr() + { + return shared_from_this(); + } + + LogData::Ptr LogData::create() + { + return std::make_shared(); + } + + void LogData::setActivity(ActivityData* activity) + { + mActivity = activity->getptr(); + } + + void LogData::flush() + { + if (mRecoverableLine.isEmpty()) { + return; + } + + mLines << mRecoverableLine; + mRecoverableLine = QString(); + } + + // ---- + + void Log::setRecoverable(const QString& text, bool flush) + { + if (d) { + std::unique_lock lock; + ActivityData::Ptr a = d->mActivity.lock(); + if (a) { + lock = a->uniqueLock(); + } + + if (flush) { + d->flush(); + } + d->mRecoverableLine = text; + + if (a) { + a->logUpdated(d->getptr(), lock); + } + } + } + + void Log::addLine(const QString& text, bool flush) + { + if (d) { + std::unique_lock lock; + ActivityData::Ptr a = d->mActivity.lock(); + if (a) { + lock = a->uniqueLock(); + } + + if (flush) { + d->flush(); + } + + d->mLines << text; + + if (a) { + a->logUpdated(d->getptr(), lock); + } + } + } + + QStringList Log::lines() const + { + QStringList sl; + + if (d) { + std::unique_lock lock; + ActivityData::Ptr a = d->mActivity.lock(); + if (a) { + lock = a->uniqueLock(); + } + + sl = d->mLines; + + if (d->mRecoverableLine.isEmpty()) { + // we definitely want to detach here, since we don't want to return a pointer into + // the mutex-protected string list. + sl.detach(); + } + else { + sl << d->mRecoverableLine; + } + } + + return sl; + } + + bool Log::isDefunct() const + { + if (d) { + ActivityData::Ptr a = d->mActivity.lock(); + if (a) { + return a->isDefunct(); + } + } + + return true; + } + +} diff --git a/Libs/libActivities/Log.hpp b/Libs/libActivities/Log.hpp new file mode 100644 index 00000000..44023198 --- /dev/null +++ b/Libs/libActivities/Log.hpp @@ -0,0 +1,55 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libActivities/Step.hpp" + +#include + +namespace Activities +{ + + class LogData; + + class ACTIVITIES_API Log + { + public: + Log() = default; + ~Log() = default; + Log(const Log& o) : Log(o.d) {} + Log(Log&& o) : Log(std::move(o.d)) {} + Log(const std::shared_ptr& o) : d(o) {} + Log(std::shared_ptr&& o) : d(std::move(o)) {} + + public: + void setRecoverable(const QString& text, bool flush = false); + void addLine(const QString& text, bool flush = true); + + public: + QStringList lines() const; + + public: + bool isDefunct() const; + + private: + std::shared_ptr d; + }; + +} diff --git a/Libs/libActivities/LogPrivate.hpp b/Libs/libActivities/LogPrivate.hpp new file mode 100644 index 00000000..e1ab6eaf --- /dev/null +++ b/Libs/libActivities/LogPrivate.hpp @@ -0,0 +1,61 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libActivities/Log.hpp" + +#include + +#include + +namespace Activities +{ + + class ActivityData; + + class LogData + : public std::enable_shared_from_this + { + public: + using Ptr = std::shared_ptr; + + public: + LogData(); + ~LogData(); + + public: + static Ptr create(); + + public: + Ptr getptr(); + + public: + void setActivity(ActivityData* activity); + + public: + void flush(); + + public: + std::weak_ptr mActivity; + QString mRecoverableLine; + QStringList mLines; + }; + +} diff --git a/Libs/libActivities/Manager.cpp b/Libs/libActivities/Manager.cpp index 74b520e8..332146f8 100644 --- a/Libs/libActivities/Manager.cpp +++ b/Libs/libActivities/Manager.cpp @@ -17,17 +17,322 @@ * */ -#include "libActivities/Manager.hpp" +#include "libActivities/ManagerPrivate.hpp" + +#include +#include +#include namespace Activities { + constexpr int ALLOWED_EMPTY_TIMERS = 8; // 8 * 750ms = 6 seconds before we stop "timing" + constexpr int TIMER_INTERVAL = 750; + constexpr int SHOW_DIALOG_AFTER = 5000; + constexpr int HIDE_DIALOG_AFTER = 30000; + + bool EventInfo::operator==(const EventInfo& o) const + { + if (type != o.type) { + return false; + } + + switch (type) { + case EventTypes::StepAdded: + case EventTypes::StepRemoved: + case EventTypes::StepUpdated: + if (step != o.step) { + return false; + } + // fall through + case EventTypes::LogUpdated: + case EventTypes::ActivityAdded: + case EventTypes::ActivityRemoved: + case EventTypes::ActivityUpdated: + if (activity != o.activity) { + return false; + } + // fall through + case EventTypes::GlobalState: + break; + } + + return true; + } + + std::unique_lock ManagerData::getLock() + { + static std::mutex sMutex; + return std::unique_lock(sMutex); + } + + ManagerData::ManagerData() + : mOwner(nullptr) + , mUpdateTimer(nullptr) + , mAllowedEmptyTimers(ALLOWED_EMPTY_TIMERS) + { + if (QThread::currentThread() != qApp->thread()) { + // However we got created, force ourselves into the main thread... + moveToThread(qApp->thread()); + } + + setParent(qApp); + + qRegisterMetaType(); + } + + ManagerData::~ManagerData() + { + std::unique_lock l(getLock()); + sSelf = nullptr; + } + + ManagerData* ManagerData::sSelf = nullptr; + + quint32 ManagerData::nextGeneration() + { + static quint32 ng = 0; + return ++ng; + } + + ManagerData* ManagerData::instance() + { + if (!sSelf) { + std::unique_lock l(getLock()); + if (!sSelf) { + sSelf = new ManagerData; + } + } + + return sSelf; + } + + Activity ManagerData::newActivity(const QString& display) + { + ActivityData::Ptr ad { std::make_shared(display) }; + + mCurActivities.push_back(ad); + enqueue(EventTypes::ActivityAdded, ad); + + return {ad}; + } + + void ManagerData::enqueue(EventInfo&& ei) + { + std::unique_lock lock { getLock() }; + + for (const EventInfo& temp : mEvents) { + if (temp == ei) { + return; + } + } + + mEvents.push_back(std::move(ei)); + + if (maybeStartEventSending() || ei.type == EventTypes::GlobalState) { + updateGlobalState(); + } + } + + bool ManagerData::maybeStartEventSending() + { + if (mUpdateTimer && mUpdateTimer->isActive()) { + return false; + } + + if (!mUpdateTimer) { + mUpdateTimer = new QTimer; + + if (QThread::currentThread() != thread()) { // Likely + mUpdateTimer->moveToThread(thread()); + } + + mUpdateTimer->setParent(this); + + qDebug() << "Created update timer"; + + connect(mUpdateTimer, &QTimer::timeout, this, &ManagerData::sendEvents); + } + + mAllowedEmptyTimers = ALLOWED_EMPTY_TIMERS; + mUpdateTimer->start(TIMER_INTERVAL); + + qDebug() << "Started the update timer"; + + return true; + } + + void ManagerData::sendEvents() + { + EventInfo::Vector events; + + if (QThread::currentThread() != qApp->thread()) { + // This should actually not happen, since the timer ought to deliver events to the + // right thread in the first place. + qDebug() << "Activities::ManagerData::sendEvents() was called in non-gui-thread!"; + QMetaObject::invokeMethod(this, "sendEvents", Qt::QueuedConnection); + return; + } + + { + // We're keeping the mutex lock as small as possible, so we don't bother the worker + // thread to wait for us to send out events... + std::unique_lock lock { getLock() }; + events.swap(mEvents); + + if (events.empty()) { + if (!--mAllowedEmptyTimers) { + qDebug() << "No events for " << ALLOWED_EMPTY_TIMERS * TIMER_INTERVAL << "ms. " + "Stopping the update timer."; + mUpdateTimer->stop(); + } + return; + } + else { + mAllowedEmptyTimers = ALLOWED_EMPTY_TIMERS; + } + } + + + std::sort(events.begin(), events.end(), [](const EventInfo& a, const EventInfo& b) -> bool { + + if (a.type < b.type) { + return true; + } + + if (b.type < a.type) { + return false; + } + + assert(a.activity && b.activity); + + if (a.activity->generation() < b.activity->generation()) { + return true; + } + if (b.activity->generation() < a.activity->generation()) { + return false; + } + + if (a.type == EventTypes::StepAdded || + a.type == EventTypes::StepRemoved || + a.type == EventTypes::StepUpdated) { + + assert(a.step && b.step); + + if (a.step->generation() < b.step->generation()) { + return true; + } + if (b.step->generation() < a.step->generation()) { + return false; + } + } + + // If we're still here, then we're the same type and neither one of the activity nor + // step generation number is either less or greater -> We're equal! But we want to be + // unique, so equality is impossible... + assert(false); + Q_UNREACHABLE(); + }); + + for (EventInfo& ei : events) { + switch (ei.type) { + case EventTypes::ActivityAdded: + mOwner->activityCreated({ei.activity}); + break; + + case EventTypes::ActivityRemoved: + mOwner->activityRemoved({ei.activity}); + break; + + case EventTypes::ActivityUpdated: + mOwner->activityUpdated({ei.activity}); + break; + + case EventTypes::LogUpdated: + mOwner->logUpdated({ei.activity}); + break; + + case EventTypes::StepAdded: + mOwner->stepCreated({ei.activity}, {ei.step}); + break; + + case EventTypes::StepRemoved: + mOwner->stepRemoved({ei.activity}, {ei.step}); + break; + + case EventTypes::StepUpdated: + mOwner->stepUpdated({ei.activity}, {ei.step}); + break; + + case EventTypes::GlobalState: + { + std::unique_lock lock(getLock()); + mOwner->updateGlobalActivity(mCurrentGlobalState); + } + break; + } + } + } + + bool ManagerData::isModalityRequired() const + { + bool required = false; + + for (const ActivityData::Ptr& a : mCurActivities) { + if (a->isModalityRequired()) { + required = true; + break; + } + } + + return required; + } + + void ManagerData::updateGlobalState() + { + + } + + // ----- + Manager::Manager() { + if (QThread::currentThread() != qApp->thread()) { + // However we got created, force ourselves into the main thread... + moveToThread(qApp->thread()); + } + + setParent(qApp); + } + + Manager& Manager::instance() + { + ManagerData* d = ManagerData::instance(); + Q_ASSERT(d); + if (!d->mOwner) { + d->mOwner = new Manager; + } + return *d->mOwner; } - Manager::~Manager() + Activity Manager::createActivity(const QString& display) { + ManagerData* d = ManagerData::instance(); + std::unique_lock lock(ManagerData::getLock()); + return d->newActivity(display); + } + + Activity::Vector Manager::activities() const + { + ManagerData* d = ManagerData::instance(); + std::unique_lock lock(ManagerData::getLock()); + + Activity::Vector result; + for (auto a : d->mCurActivities) { + result.push_back({a}); + } + + return result; } } diff --git a/Libs/libActivities/Manager.hpp b/Libs/libActivities/Manager.hpp index bc536f40..0b130e0a 100644 --- a/Libs/libActivities/Manager.hpp +++ b/Libs/libActivities/Manager.hpp @@ -19,19 +19,60 @@ #pragma once -#include "libActivities/Api.hpp" +#include "libActivities/Activity.hpp" + +#include namespace Activities { + struct GlobalSnapShot + { + int mNumActivities; + int mRunningActivities; + int mDoneActivities; + int mFailedActivities; + + int mCurProgress; + int mMaxProgress; + + QString mUpfrontName; // The name of the first registered activity. This is really + // arbitrary as we obviously cannot display all of them in + // the global snap shot. + }; + class ACTIVITIES_API Manager + : public QObject { - public: + Q_OBJECT + private: Manager(); - ~Manager(); + public: + ~Manager() = default; - private: + static Manager& instance(); + + public: + Activity createActivity(const QString& display); + public: + Activity::Vector activities() const; + + signals: + void activityCreated(Activities::Activity); + void activityUpdated(Activities::Activity); + void activityRemoved(Activities::Activity); + void stepCreated(Activities::Activity, Activities::Step); + void stepUpdated(Activities::Activity, Activities::Step); + void stepRemoved(Activities::Activity, Activities::Step); + void logUpdated(Activities::Activity); + + signals: + void updateGlobalActivity(Activities::GlobalSnapShot); + void showProgressDialog(bool modal); + void hideProgressDialog(); }; } + +Q_DECLARE_METATYPE(Activities::GlobalSnapShot) diff --git a/Libs/libActivities/ManagerPrivate.hpp b/Libs/libActivities/ManagerPrivate.hpp new file mode 100644 index 00000000..080e25b9 --- /dev/null +++ b/Libs/libActivities/ManagerPrivate.hpp @@ -0,0 +1,138 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libActivities/Manager.hpp" +#include "libActivities/ActivityPrivate.hpp" + +class QTimer; + +namespace Activities +{ + + enum class EventTypes + { + ActivityAdded, + ActivityUpdated, + ActivityRemoved, + + StepAdded, + StepUpdated, + StepRemoved, + + LogUpdated, + + GlobalState + }; + + #if defined(__cpp_constexpr) && (__cpp_constexpr >= 201304L) + constexpr + #else + static inline + #endif + int eventGroup(EventTypes et) + { + switch (et) { + case EventTypes::ActivityAdded: return 1; + case EventTypes::StepAdded: return 2; + case EventTypes::ActivityUpdated: return 3; + case EventTypes::StepUpdated: return 4; + case EventTypes::LogUpdated: return 5; + case EventTypes::StepRemoved: return 6; + case EventTypes::ActivityRemoved: return 7; + case EventTypes::GlobalState: return 8; + } + } + + #if defined(__cpp_constexpr) && (__cpp_constexpr >= 201304L) + constexpr + #else + static inline + #endif + bool operator<(EventTypes a, EventTypes b) + { + int l1 = eventGroup(a), l2 = eventGroup(b); + return l1 < l2; + } + + struct EventInfo + { + using Vector = std::vector; + + EventTypes type; + ActivityData::Ptr activity; + StepData::Ptr step; + + bool operator==(const EventInfo& o) const; + EventInfo(EventTypes t, ActivityData::Ptr a, StepData::Ptr s = {}) + : type(t), activity(a), step(s) + {} + }; + + class Manager; + + class ManagerData + : public QObject + { + Q_OBJECT + private: + ManagerData(); + public: + ~ManagerData(); + + public: + static ManagerData* instance(); + static std::unique_lock getLock(); + static quint32 nextGeneration(); + + public: + Activity newActivity(const QString &display); + + public: + void enqueue(EventInfo&& ei); + + template + void enqueue(T&& ... t) + { + EventInfo ei(std::forward(t)...); + enqueue(std::move(ei)); + } + + private slots: + void sendEvents(); + + private: + bool maybeStartEventSending(); + void updateGlobalState(); + bool isModalityRequired() const; + + public: + Manager* mOwner; + ActivityData::Vector mCurActivities; + QTimer* mUpdateTimer; + int mAllowedEmptyTimers; + EventInfo::Vector mEvents; + GlobalSnapShot mCurrentGlobalState; + + private: + static ManagerData* sSelf; + }; + +} diff --git a/Libs/libActivities/Step.cpp b/Libs/libActivities/Step.cpp new file mode 100644 index 00000000..ae52fbe7 --- /dev/null +++ b/Libs/libActivities/Step.cpp @@ -0,0 +1,264 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libActivities/StepPrivate.hpp" +#include "libActivities/ActivityPrivate.hpp" +#include "libActivities/ManagerPrivate.hpp" + +namespace Activities +{ + + StepData::StepData() + : mGeneration(ManagerData::nextGeneration()) + , mState(State::Pending) + { + } + + StepData::~StepData() + { + } + + StepData::Ptr StepData::getptr() + { + return shared_from_this(); + } + + quint32 StepData::generation() const + { + return mGeneration; + } + + StepData::Ptr StepData::create() + { + return std::make_shared(); + } + + void StepData::setActivity(ActivityData* activity) + { + mActivity = activity->getptr(); + } + + void StepData::changeState(State newState, std::unique_lock& lock) + { + ActivityData::Ptr a; + + if (mState == newState) { + return; + } + + if (newState == State::PartiallyFinishedWithErrors || + newState == State::Unknown) { + qDebug() << "Invalid new state" << newState << "for Activities::Step"; + return; + } + + switch (mState) { + case State::Unknown: + case State::PartiallyFinishedWithErrors: + qDebug() << "Invalid current state" << newState << "for Activities::Step"; + return; + + case State::Pending: + if (newState == State::InProgress) { + mState = newState; + if ((a = mActivity.lock())) { + a->stepStarted(getptr(), lock); + } + } + // Fall through + + case State::InProgress: + if (newState == State::Finished || newState == State::FinishedWithErrors) { + mState = newState; + if ((a = mActivity.lock())) { + a->stepFinished(getptr(), newState == State::FinishedWithErrors, lock); + } + } + break; + + case State::Finished: + case State::FinishedWithErrors: + // No change allowed + qDebug() << "Invalid Activities::Step state transition:" + << mState << "to" << newState; + + newState = mState; + break; + } + } + + State Step::state() const + { + State s { State::Unknown }; + + if (d) { + std::unique_lock lock; + ActivityData::Ptr a = d->mActivity.lock(); + if (a) { + lock = a->uniqueLock(); + } + + s = d->mState; + } + + return s; + } + + QString Step::displayName() const + { + QString r; + + if (d) { + std::unique_lock lock; + ActivityData::Ptr a = d->mActivity.lock(); + if (a) { + lock = a->uniqueLock(); + } + + r = d->mDisplayName; + } + return r; + } + + QString Step::statusText() const + { + QString r; + + if (d) { + std::unique_lock lock; + ActivityData::Ptr a = d->mActivity.lock(); + if (a) { + lock = a->uniqueLock(); + } + + r = d->mStatusText; + } + return r; + } + + int Step::curProgress() const + { + int r = 0; + + if (d) { + std::unique_lock lock; + ActivityData::Ptr a = d->mActivity.lock(); + if (a) { + lock = a->uniqueLock(); + } + + r = d->mCurProgress; + } + return r; + } + + int Step::maxProgress() const + { + int r = 0; + + if (d) { + std::unique_lock lock; + ActivityData::Ptr a = d->mActivity.lock(); + if (a) { + lock = a->uniqueLock(); + } + + r = d->mMaxProgress; + } + return r; + } + + void Step::setState(State newState) + { + if (d) { + std::unique_lock lock; + ActivityData::Ptr a = d->mActivity.lock(); + if (a) { + lock = a->uniqueLock(); + } + + d->changeState(newState, lock); + } + } + + void Step::setDisplayName(const QString& name) + { + if (d) { + std::unique_lock lock; + ActivityData::Ptr a = d->mActivity.lock(); + if (a) { + lock = a->uniqueLock(); + } + + d->mDisplayName = name; + + if (a) { + a->updated(d, lock); + } + } + } + + void Step::setStatusText(const QString& text) + { + if (d) { + std::unique_lock lock; + ActivityData::Ptr a = d->mActivity.lock(); + if (a) { + lock = a->uniqueLock(); + } + + d->mStatusText = text; + + if (a) { + a->updated(d, lock); + } + } + } + + void Step::setProgress(int cur, int max) + { + if (d) { + std::unique_lock lock; + ActivityData::Ptr a = d->mActivity.lock(); + if (a) { + lock = a->uniqueLock(); + } + + d->mCurProgress = cur; + d->mMaxProgress = max; + + if (a) { + a->updated(d, lock); + } + } + } + + bool Step::isDefunct() const + { + if (d) { + ActivityData::Ptr a = d->mActivity.lock(); + if (a) { + return a->isDefunct(); + } + } + + return true; + } + +} diff --git a/Libs/libActivities/Step.hpp b/Libs/libActivities/Step.hpp new file mode 100644 index 00000000..2df90744 --- /dev/null +++ b/Libs/libActivities/Step.hpp @@ -0,0 +1,80 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libActivities/Api.hpp" + +#include +#include + +class QString; + +namespace Activities +{ + + class Activity; + class StepData; + + enum class State + { + Unknown, + + Pending, + InProgress, + Finished, + FinishedWithErrors, + + PartiallyFinishedWithErrors + }; + + class ACTIVITIES_API Step + { + public: + using Vector = std::vector; + + public: + Step() = default; + ~Step() = default; + Step(const Step& o) : Step(o.d) {} + Step(Step&& o) : Step(std::move(o.d)) {} + Step(const std::shared_ptr& o) : d(o) {} + Step(std::shared_ptr&& o) : d(std::move(o)) {} + + public: + State state() const; + QString displayName() const; + QString statusText() const; + int curProgress() const; + int maxProgress() const; + + public: + void setState(State newState); + void setDisplayName(const QString& name); + void setStatusText(const QString& text); + void setProgress(int cur, int max); + + public: + bool isDefunct() const; + + private: + std::shared_ptr d; + }; + +} diff --git a/Libs/libActivities/StepPrivate.hpp b/Libs/libActivities/StepPrivate.hpp new file mode 100644 index 00000000..e875835d --- /dev/null +++ b/Libs/libActivities/StepPrivate.hpp @@ -0,0 +1,97 @@ +/* + * MacGitver + * Copyright (C) 2012-2015 The MacGitver-Developers + * + * (C) Sascha Cunz + * (C) Cunz RaD Ltd. + * + * 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 "libActivities/Step.hpp" + +#include +#include + +#include + +namespace Activities +{ + + class ActivityData; + + class StepData + : public std::enable_shared_from_this + { + public: + using Ptr = std::shared_ptr; + using Vector = std::vector; + + public: + StepData(); + ~StepData(); + + public: + static Ptr create(); + + public: + quint32 generation() const; + Ptr getptr(); + + public: + void setActivity(ActivityData* activity); + + public: + QString displayName() const; + QString statusText() const; + int curProgress() const; + int maxProgress() const; + + public: + void changeState(State newState, std::unique_lock &lock); + void setDisplayName(const QString& name); + void setStatusText(const QString& text); + void setProgress(int cur, int max); + + public: + std::weak_ptr mActivity; + quint32 mGeneration; + State mState; + QString mStatusText; + QString mDisplayName; + int mCurProgress; + int mMaxProgress; + }; + +} + +static inline +QDebug operator<<(QDebug dbg, Activities::State state) +{ + switch (state) { + case Activities::State::Unknown: + return dbg << "State::Unknown"; + case Activities::State::Pending: + return dbg << "State::Pending"; + case Activities::State::Finished: + return dbg << "State::Finished"; + case Activities::State::FinishedWithErrors: + return dbg << "State::FinishedWithErrors"; + case Activities::State::InProgress: + return dbg << "State::InProgress"; + case Activities::State::PartiallyFinishedWithErrors: + return dbg << "State::PartiallyFinishedWithErrors"; + } + Q_UNREACHABLE(); +} From 33f1e00c1195bae890b843cb30f1836c10333dcc Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sat, 9 May 2015 13:36:27 +0100 Subject: [PATCH 30/75] Should fix Linux build --- Libs/libActivities/Activity.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Libs/libActivities/Activity.cpp b/Libs/libActivities/Activity.cpp index b02114cc..32018a7c 100644 --- a/Libs/libActivities/Activity.cpp +++ b/Libs/libActivities/Activity.cpp @@ -22,6 +22,8 @@ #include "libActivities/StepPrivate.hpp" #include "libActivities/ManagerPrivate.hpp" +#include + namespace Activities { From 226c351d3cfe65ad7ce45c5a07ca01f75b65df8a Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 10 May 2015 22:35:39 +0100 Subject: [PATCH 31/75] Fixup: Remove unused code --- Libs/libActivities/Activity.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Libs/libActivities/Activity.cpp b/Libs/libActivities/Activity.cpp index 32018a7c..c9335201 100644 --- a/Libs/libActivities/Activity.cpp +++ b/Libs/libActivities/Activity.cpp @@ -182,16 +182,4 @@ namespace Activities return Log(); } -#if 0 - void Activity::addStep(const Step::Ptr& step) - { - std::lock_guard _(mMtx); - std::shared_ptr _step = std::static_pointer_cast(step); - - _step->setActivity(getptr()); - mSteps.push_back(step); - } - -#endif - } From 6aa8e7cd7d5463a3fdbfbeb97b492d52b1912963 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 10 May 2015 22:38:05 +0100 Subject: [PATCH 32/75] Step creation --- Libs/libActivities/Activity.cpp | 16 ++++++++++++++++ Libs/libActivities/Activity.hpp | 1 + Libs/libActivities/Step.cpp | 17 ++++++++--------- Libs/libActivities/StepPrivate.hpp | 7 ++----- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Libs/libActivities/Activity.cpp b/Libs/libActivities/Activity.cpp index c9335201..f125b5a1 100644 --- a/Libs/libActivities/Activity.cpp +++ b/Libs/libActivities/Activity.cpp @@ -182,4 +182,20 @@ namespace Activities return Log(); } + Step Activity::createStep(const QString& displayName) + { + if (d) { + std::lock_guard _(d->mMtx); + + StepData::Ptr sd = StepData::create(d->getptr(), displayName); + d->mSteps.push_back(sd); + + ManagerData::instance()->enqueue(EventTypes::StepAdded, d->getptr(), sd); + + return {sd}; + } + + return {}; + } + } diff --git a/Libs/libActivities/Activity.hpp b/Libs/libActivities/Activity.hpp index 3d65c5b2..c3dbd68c 100644 --- a/Libs/libActivities/Activity.hpp +++ b/Libs/libActivities/Activity.hpp @@ -42,6 +42,7 @@ namespace Activities public: Step::Vector steps() const; + Step createStep(const QString& displayName); public: State state() const; diff --git a/Libs/libActivities/Step.cpp b/Libs/libActivities/Step.cpp index ae52fbe7..37986eed 100644 --- a/Libs/libActivities/Step.cpp +++ b/Libs/libActivities/Step.cpp @@ -24,9 +24,13 @@ namespace Activities { - StepData::StepData() - : mGeneration(ManagerData::nextGeneration()) + StepData::StepData(const ActivityData::Ptr& activity, const QString& display) + : mActivity(activity) + , mGeneration(ManagerData::nextGeneration()) , mState(State::Pending) + , mDisplayName(display) + , mCurProgress(0) + , mMaxProgress(0) { } @@ -44,14 +48,9 @@ namespace Activities return mGeneration; } - StepData::Ptr StepData::create() + StepData::Ptr StepData::create(const ActivityData::Ptr& activity, const QString& display) { - return std::make_shared(); - } - - void StepData::setActivity(ActivityData* activity) - { - mActivity = activity->getptr(); + return std::make_shared(activity, display); } void StepData::changeState(State newState, std::unique_lock& lock) diff --git a/Libs/libActivities/StepPrivate.hpp b/Libs/libActivities/StepPrivate.hpp index e875835d..2f55c2b1 100644 --- a/Libs/libActivities/StepPrivate.hpp +++ b/Libs/libActivities/StepPrivate.hpp @@ -39,19 +39,16 @@ namespace Activities using Vector = std::vector; public: - StepData(); + StepData(const std::shared_ptr& activity, const QString& display); ~StepData(); public: - static Ptr create(); + static Ptr create(const std::shared_ptr& activity, const QString& display); public: quint32 generation() const; Ptr getptr(); - public: - void setActivity(ActivityData* activity); - public: QString displayName() const; QString statusText() const; From e2dd1ed4d4edd2aeacd8a950a40f9c31ee802e85 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 10 May 2015 22:38:22 +0100 Subject: [PATCH 33/75] Fixup: Remove deadlock --- Libs/libActivities/Manager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Libs/libActivities/Manager.cpp b/Libs/libActivities/Manager.cpp index 332146f8..bf2665ac 100644 --- a/Libs/libActivities/Manager.cpp +++ b/Libs/libActivities/Manager.cpp @@ -109,9 +109,12 @@ namespace Activities Activity ManagerData::newActivity(const QString& display) { + std::unique_lock lock(ManagerData::getLock()); ActivityData::Ptr ad { std::make_shared(display) }; mCurActivities.push_back(ad); + + lock.unlock(); enqueue(EventTypes::ActivityAdded, ad); return {ad}; @@ -318,7 +321,6 @@ namespace Activities Activity Manager::createActivity(const QString& display) { ManagerData* d = ManagerData::instance(); - std::unique_lock lock(ManagerData::getLock()); return d->newActivity(display); } From c3ef9d832550cd80e0eadb5c8808d5c9b1aa1670 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 10 May 2015 22:39:04 +0100 Subject: [PATCH 34/75] Actually implement state getters in Activity --- Libs/libActivities/Activity.cpp | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/Libs/libActivities/Activity.cpp b/Libs/libActivities/Activity.cpp index f125b5a1..395c3bc9 100644 --- a/Libs/libActivities/Activity.cpp +++ b/Libs/libActivities/Activity.cpp @@ -182,6 +182,66 @@ namespace Activities return Log(); } + State Activity::state() const + { + if (d) { + std::lock_guard _(d->mMtx); + return d->mState; + } + + return State::Unknown; + } + + QString Activity::display() const + { + if (d) { + std::lock_guard _(d->mMtx); + return d->mDisplay; + } + + return {}; + } + + int Activity::curProgress() const + { + if (d) { + std::lock_guard _(d->mMtx); + return d->mTotalCurProgress; + } + + return 0; + } + + int Activity::maxProgress() const + { + if (d) { + std::lock_guard _(d->mMtx); + return d->mTotalMaxProgress; + } + + return 0; + } + + int Activity::curOwnProgress() const + { + if (d) { + std::lock_guard _(d->mMtx); + return d->mCurProgress; + } + + return 0; + } + + int Activity::maxOwnProgress() const + { + if (d) { + std::lock_guard _(d->mMtx); + return d->mMaxProgress; + } + + return 0; + } + Step Activity::createStep(const QString& displayName) { if (d) { From 3a7d25f0fd87b60e91a7068c82cbdb3f800c305e Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 10 May 2015 22:39:30 +0100 Subject: [PATCH 35/75] Fixup: "return {}" to avoid naming the constructor --- Libs/libActivities/Activity.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libs/libActivities/Activity.cpp b/Libs/libActivities/Activity.cpp index 395c3bc9..61eb32e4 100644 --- a/Libs/libActivities/Activity.cpp +++ b/Libs/libActivities/Activity.cpp @@ -179,7 +179,7 @@ namespace Activities std::lock_guard _(d->mMtx); return {d->mLog}; } - return Log(); + return {}; } State Activity::state() const From 5bf8aeeb833d685283f14b38a6350d09c425e552 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 10 May 2015 22:40:30 +0100 Subject: [PATCH 36/75] Public method to request opening of Progress Dialog --- Libs/libActivities/Manager.cpp | 16 ++++++++++++++++ Libs/libActivities/Manager.hpp | 1 + Libs/libActivities/ManagerPrivate.hpp | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Libs/libActivities/Manager.cpp b/Libs/libActivities/Manager.cpp index bf2665ac..cda03425 100644 --- a/Libs/libActivities/Manager.cpp +++ b/Libs/libActivities/Manager.cpp @@ -337,4 +337,20 @@ namespace Activities return result; } + void Manager::requestProgressDialog() + { + bool requireModal; + + { + std::unique_lock lock(ManagerData::getLock()); + ManagerData* d = ManagerData::instance(); + + // this ought to be false, if this method is used correctly. But timing could interfere + // here. + requireModal = d->isModalityRequired(); + } + + emit showProgressDialog(requireModal); + } + } diff --git a/Libs/libActivities/Manager.hpp b/Libs/libActivities/Manager.hpp index 0b130e0a..3bd1576c 100644 --- a/Libs/libActivities/Manager.hpp +++ b/Libs/libActivities/Manager.hpp @@ -56,6 +56,7 @@ namespace Activities Activity createActivity(const QString& display); public: + void requestProgressDialog(); Activity::Vector activities() const; signals: diff --git a/Libs/libActivities/ManagerPrivate.hpp b/Libs/libActivities/ManagerPrivate.hpp index 080e25b9..1ce303a9 100644 --- a/Libs/libActivities/ManagerPrivate.hpp +++ b/Libs/libActivities/ManagerPrivate.hpp @@ -103,6 +103,7 @@ namespace Activities static quint32 nextGeneration(); public: + bool isModalityRequired() const; Activity newActivity(const QString &display); public: @@ -121,7 +122,6 @@ namespace Activities private: bool maybeStartEventSending(); void updateGlobalState(); - bool isModalityRequired() const; public: Manager* mOwner; From 9ded4fddbaa68959b86dc38adf31fd5ffca60dc5 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 10 May 2015 22:40:55 +0100 Subject: [PATCH 37/75] Fixup: Inline comment (Manager Priv.hpp) --- Libs/libActivities/ManagerPrivate.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Libs/libActivities/ManagerPrivate.hpp b/Libs/libActivities/ManagerPrivate.hpp index 1ce303a9..355164b8 100644 --- a/Libs/libActivities/ManagerPrivate.hpp +++ b/Libs/libActivities/ManagerPrivate.hpp @@ -112,6 +112,8 @@ namespace Activities template void enqueue(T&& ... t) { + // Since we can't bind a brace-initialised object to an xvalue, this method can be used + // instead, like: enqueue(EventType::Foo, bar); EventInfo ei(std::forward(t)...); enqueue(std::move(ei)); } From 948f8e9168930344a8a389e362a11b110719cb03 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Tue, 12 May 2015 08:18:47 +0200 Subject: [PATCH 38/75] Activities: use Q_ASSERT instead of assert (fix build on linux) --- Libs/libActivities/Activity.cpp | 4 +--- Libs/libActivities/Manager.cpp | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Libs/libActivities/Activity.cpp b/Libs/libActivities/Activity.cpp index 61eb32e4..13e3d818 100644 --- a/Libs/libActivities/Activity.cpp +++ b/Libs/libActivities/Activity.cpp @@ -22,8 +22,6 @@ #include "libActivities/StepPrivate.hpp" #include "libActivities/ManagerPrivate.hpp" -#include - namespace Activities { @@ -78,7 +76,7 @@ namespace Activities return State::PartiallyFinishedWithErrors; } - assert(running + success > 0); + Q_ASSERT(running + success > 0); return State::InProgress; } } diff --git a/Libs/libActivities/Manager.cpp b/Libs/libActivities/Manager.cpp index cda03425..28898d45 100644 --- a/Libs/libActivities/Manager.cpp +++ b/Libs/libActivities/Manager.cpp @@ -207,7 +207,7 @@ namespace Activities return false; } - assert(a.activity && b.activity); + Q_ASSERT(a.activity && b.activity); if (a.activity->generation() < b.activity->generation()) { return true; @@ -220,7 +220,7 @@ namespace Activities a.type == EventTypes::StepRemoved || a.type == EventTypes::StepUpdated) { - assert(a.step && b.step); + Q_ASSERT(a.step && b.step); if (a.step->generation() < b.step->generation()) { return true; @@ -233,7 +233,7 @@ namespace Activities // If we're still here, then we're the same type and neither one of the activity nor // step generation number is either less or greater -> We're equal! But we want to be // unique, so equality is impossible... - assert(false); + Q_ASSERT(false); Q_UNREACHABLE(); }); From ee2797c72c45c1dae7262f8412ad7dc1e90ee51d Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Tue, 12 May 2015 08:19:22 +0200 Subject: [PATCH 39/75] RepoMan: use Q_ASSERT instead of assert (fix build on linux) --- Libs/libRepoMan/Data/Repo.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Libs/libRepoMan/Data/Repo.cpp b/Libs/libRepoMan/Data/Repo.cpp index b634e732..60d90bed 100644 --- a/Libs/libRepoMan/Data/Repo.cpp +++ b/Libs/libRepoMan/Data/Repo.cpp @@ -19,8 +19,6 @@ #include "libRepoMan/Data/Repo.hpp" -#include - namespace RM { @@ -40,7 +38,7 @@ namespace RM Git::Repository Repo::gitRepo(bool doLoad) { if (!mRepo && doLoad) { - assert(false); // ###REPOMAN - Not sure if we still want to support this... + Q_ASSERT(false); // ###REPOMAN - Not sure if we still want to support this... } return mRepo; From bf0842992774baecbee883ea8c3db1d7c6e1ca56 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Tue, 12 May 2015 08:20:31 +0200 Subject: [PATCH 40/75] RepoMan: fix include pathes for case sensitive file systems --- Libs/libRepoMan/Frontend/Remote.hpp | 2 +- Libs/libRepoMan/Frontend/Submodule.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Libs/libRepoMan/Frontend/Remote.hpp b/Libs/libRepoMan/Frontend/Remote.hpp index 58e6bdbd..430d17b4 100644 --- a/Libs/libRepoMan/Frontend/Remote.hpp +++ b/Libs/libRepoMan/Frontend/Remote.hpp @@ -21,7 +21,7 @@ #include "libGitWrap/Remote.hpp" -#include "libRepoman/Frontend/Base.hpp" +#include "libRepoMan/Frontend/Base.hpp" namespace RM { diff --git a/Libs/libRepoMan/Frontend/Submodule.hpp b/Libs/libRepoMan/Frontend/Submodule.hpp index af9026b7..ef3ee8cd 100644 --- a/Libs/libRepoMan/Frontend/Submodule.hpp +++ b/Libs/libRepoMan/Frontend/Submodule.hpp @@ -19,7 +19,7 @@ #pragma once -#include "libRepoman/Frontend/Repo.hpp" +#include "libRepoMan/Frontend/Repo.hpp" namespace RM { From 892d60b7528087eb11bc4746799aae4408beff44 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Tue, 12 May 2015 08:26:19 +0200 Subject: [PATCH 41/75] RepoMan: fix missing include --- Libs/libRepoMan/Data/Repo.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Libs/libRepoMan/Data/Repo.hpp b/Libs/libRepoMan/Data/Repo.hpp index 9632b313..9d240545 100644 --- a/Libs/libRepoMan/Data/Repo.hpp +++ b/Libs/libRepoMan/Data/Repo.hpp @@ -23,6 +23,8 @@ #include "libRepoMan/Frontend/Repo.hpp" +#include + class QTimer; namespace RM From 6c64958abbb489f3c5745364d5d0013b300cebd2 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Sat, 25 Apr 2015 17:09:52 +0200 Subject: [PATCH 42/75] copied progress dialog from "Repository" module (ProgressDlg) to libMacGitverCore with required minor changes --- Libs/libMacGitverCore/CMakeLists.txt | 3 + Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 163 ++++++++++++++++++ Libs/libMacGitverCore/Widgets/ProgressDlg.hpp | 45 +++++ Libs/libMacGitverCore/Widgets/ProgressDlg.ui | 157 +++++++++++++++++ 4 files changed, 368 insertions(+) create mode 100644 Libs/libMacGitverCore/Widgets/ProgressDlg.cpp create mode 100644 Libs/libMacGitverCore/Widgets/ProgressDlg.hpp create mode 100644 Libs/libMacGitverCore/Widgets/ProgressDlg.ui diff --git a/Libs/libMacGitverCore/CMakeLists.txt b/Libs/libMacGitverCore/CMakeLists.txt index 9ed93c6a..1179ce2e 100644 --- a/Libs/libMacGitverCore/CMakeLists.txt +++ b/Libs/libMacGitverCore/CMakeLists.txt @@ -37,6 +37,7 @@ SET( SRC_FILES Widgets/FlatTreeComboBox.cpp Widgets/FlatTreeModel.cpp Widgets/FlatTreeDelegate.cpp + Widgets/ProgressDlg.cpp Widgets/SHA1Input.cpp Widgets/ShortCommitModel.cpp Widgets/RepoStateWidget.cpp @@ -69,6 +70,7 @@ SET( PUB_HDR_FILES Widgets/FlatTreeComboBox.h Widgets/FlatTreeModel.h Widgets/FlatTreeDelegate.h + Widgets/ProgressDlg.hpp Widgets/SHA1Input.h Widgets/ShortCommitModel.h Widgets/TreeViewCtxMenu.hpp @@ -101,6 +103,7 @@ SET( UI_FILES Config/Ui/RepoManConfigPage.ui Widgets/ExpandableDlg.ui + Widgets/ProgressDlg.ui ) SET( HID_FILES diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp new file mode 100644 index 00000000..3bbeb34e --- /dev/null +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -0,0 +1,163 @@ + +#include "ProgressDlg.hpp" +#include "ui_ProgressDlg.h" + +#include +#include +#include +#include +#include + + +ProgressDlg::ProgressDlg() + : BlueSky::Dialog() + , ui( new Ui::ProgressDlg ) + , mDone( false ) +{ + ui->setupUi( this ); + + QPushButton* close = ui->buttonBox->button( QDialogButtonBox::Close ); + close->setEnabled( false ); + connect( close, &QPushButton::clicked, this, &ProgressDlg::close ); + + QPalette p; + p.setColor( QPalette::Base, p.color( QPalette::Window ) ); + p.setColor( QPalette::Text, p.color( QPalette::WindowText ) ); + ui->txtLog->setPalette( p ); +} + +ProgressDlg::~ProgressDlg() +{ + delete ui; +} + +void ProgressDlg::setAction( const QString& action, + const QStringList& open, + const QStringList& current, + const QStringList& done ) +{ + QString act = action; + + foreach( QString s, done ) + { + act += QStringLiteral( " (" ) % s % QStringLiteral( ")" ); + } + + foreach( QString s, current ) + { + act += QStringLiteral( " (" ) % s % QStringLiteral( ")" ); + } + + foreach( QString s, open ) + { + act += QStringLiteral( " (" ) % s % QStringLiteral( ")" ); + } + + ui->lblAction->setText( act ); +} + +void ProgressDlg::setCurrent(QObject* current) +{ + mCurrent = current; + + connect( mCurrent, SIGNAL(remoteMessage(QString)), + this, SLOT(remoteMessage(QString)) ); + connect( mCurrent, SIGNAL(transportProgress(quint32, quint32, quint32, quint64)), + this, SLOT(transportProgress(quint32, quint32, quint32, quint64)) ); +} + +void ProgressDlg::closeEvent( QCloseEvent* ev ) +{ + if( !mDone ) + { + ev->ignore(); + return; + } + + QDialog::closeEvent( ev ); +} + +void ProgressDlg::transportProgress( quint32 totalObjects, + quint32 indexedObjects, + quint32 receivedObjects, + quint64 receivedBytes ) +{ + QString recv; + if( receivedBytes > 1024 * 1024 * 950 ) /* 950 is so we get 0.9 gb */ + { + recv = QString::number( receivedBytes / (1024*1024*1024.0), 'f', 2 ) % QStringLiteral( " Gb" ); + } + else if( receivedBytes > 1024 * 950 ) + { + recv = QString::number( receivedBytes / (1024*1024.0), 'f', 2 ) % QStringLiteral( " Mb" ); + } + else if( receivedBytes > 950 ) + { + recv = QString::number( receivedBytes / 1024.0, 'f', 2 ) % QStringLiteral( " Kb" ); + } + else + { + recv = QString::number( receivedBytes ); + } + ui->lblTransferSize->setText( recv ); + + ui->progressBar->setRange( 0, totalObjects * 2 ); + ui->progressBar->setValue( indexedObjects + receivedObjects ); +} + +void ProgressDlg::remoteMessage( const QString& msg ) +{ + mRawRemoteMessage += msg; + + QString output; + QChar outputBuffer[ 256 ]; + int outBufPos = 0, outBufLen = 0; + + for( int i = 0; i < mRawRemoteMessage.length(); ++i ) + { + if( mRawRemoteMessage[ i ] == QChar( L'\r' ) ) + { + outBufPos = 0; + } + else if( mRawRemoteMessage[ i ] == QChar( L'\n' ) ) + { + if( outBufLen ) + output += QString( outputBuffer, outBufLen ); + output += QChar( L'\n' ); + outBufPos = outBufLen = 0; + } + else + { + outputBuffer[ outBufPos++] = mRawRemoteMessage[ i ]; + outBufLen = qMax( outBufLen, outBufPos ); + } + } + + if( outBufLen ) + output += QString( outputBuffer, outBufLen ); + + QString log = mBaseLog % QStringLiteral( "
" ) % + output.replace( QChar( L'\n' ), QLatin1String("
") ).simplified(); + + ui->txtLog->setHtml( log ); +} + +void ProgressDlg::beginStep( const QString& step ) +{ + mBaseLog += tr( "%1
" ).arg( step ); + ui->txtLog->setHtml( mBaseLog ); +} + +void ProgressDlg::finalizeStep() +{ + mBaseLog = ui->txtLog->toHtml() % QStringLiteral( "
" ); + mRawRemoteMessage = QString(); + + ui->txtLog->setHtml( mBaseLog ); +} + +void ProgressDlg::setDone() +{ + mDone = true; + ui->buttonBox->button( QDialogButtonBox::Close )->setEnabled( true ); +} diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp new file mode 100644 index 00000000..12354d9e --- /dev/null +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp @@ -0,0 +1,45 @@ + +#pragma once + +#include "libMacGitverCore/MacGitverApi.hpp" +#include "libBlueSky/Dialog.hpp" + +namespace Ui +{ + class ProgressDlg; +}; + +class MGV_CORE_API ProgressDlg : public BlueSky::Dialog +{ + Q_OBJECT +public: + ProgressDlg(); + ~ProgressDlg(); + +public: + void setAction( const QString& action, const QStringList& open, + const QStringList& current, const QStringList& done ); + void setCurrent(QObject* current); + +private slots: + void transportProgress( quint32 totalObjects, quint32 indexedObjects, + quint32 receivedObjects, quint64 receivedBytes ); + void remoteMessage( const QString& msg ); + +public: + void setDone(); + void beginStep( const QString& step ); + void finalizeStep(); + +protected: + void closeEvent( QCloseEvent* ev ); + +private: + Ui::ProgressDlg* ui; + +private: + bool mDone; + QString mBaseLog; + QObject* mCurrent; + QString mRawRemoteMessage; +}; diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.ui b/Libs/libMacGitverCore/Widgets/ProgressDlg.ui new file mode 100644 index 00000000..19bf883d --- /dev/null +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.ui @@ -0,0 +1,157 @@ + + + ProgressDlg + + + Qt::ApplicationModal + + + + 0 + 0 + 484 + 291 + + + + + 0 + 0 + + + + Progress + + + true + + + + + + QDialogButtonBox::Close + + + + + + + + 0 + 0 + + + + + 0 + 60 + + + + Log + + + + QLayout::SetDefaultConstraint + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + + + + + + + + Current operation + + + + 3 + + + 3 + + + 3 + + + 3 + + + 6 + + + 2 + + + + + + 0 + 0 + + + + + + + + + + + + + + + <b>Progress</(b> + + + + + + + <b>Action</b> + + + + + + + + + + + + + + + + + + From 02ec756af7046a99df5b42a972e2624b3e500702 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Tue, 21 Apr 2015 14:41:48 +0200 Subject: [PATCH 43/75] add ProgressWdgt, preparing for unified progress dialog The ProgressWdgt is going to be used internally by ProgressDlg to represent a single activity or step. --- Libs/libMacGitverCore/CMakeLists.txt | 2 + Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 29 ++++++++++++++ Libs/libMacGitverCore/Widgets/ProgressDlg.hpp | 12 ++++++ Libs/libMacGitverCore/Widgets/ProgressWdgt.ui | 38 +++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 Libs/libMacGitverCore/Widgets/ProgressWdgt.ui diff --git a/Libs/libMacGitverCore/CMakeLists.txt b/Libs/libMacGitverCore/CMakeLists.txt index 1179ce2e..053d145d 100644 --- a/Libs/libMacGitverCore/CMakeLists.txt +++ b/Libs/libMacGitverCore/CMakeLists.txt @@ -104,6 +104,8 @@ SET( UI_FILES Widgets/ExpandableDlg.ui Widgets/ProgressDlg.ui + + Widgets/ProgressWdgt.ui ) SET( HID_FILES diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 3bbeb34e..2539d18d 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -1,6 +1,7 @@ #include "ProgressDlg.hpp" #include "ui_ProgressDlg.h" +#include "ui_ProgressWdgt.h" #include #include @@ -8,6 +9,34 @@ #include #include +namespace Private +{ + + class ProgressWdgt : public QWidget, public Ui::ProgressWdgt + { + public: + typedef QMap< QString, QPointer > Steps; + + enum Status { Running = 0, Stopped }; + + public: + ProgressWdgt(const QString& description) + { + setupUi(this); + progressBar->setMinimum(0); + progressBar->setMaximum(100); + txtHeader->setText( description ); + } + + public: + Steps mSteps; + Status mStatus = Running; + + qreal mPercentage = 0.; + }; + +} + ProgressDlg::ProgressDlg() : BlueSky::Dialog() diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp index 12354d9e..b1e02a2e 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp @@ -4,6 +4,14 @@ #include "libMacGitverCore/MacGitverApi.hpp" #include "libBlueSky/Dialog.hpp" +#include +#include + +namespace Private +{ + class ProgressWdgt; +}; + namespace Ui { class ProgressDlg; @@ -12,6 +20,10 @@ namespace Ui class MGV_CORE_API ProgressDlg : public BlueSky::Dialog { Q_OBJECT + +public: + typedef QMap< QPointer, QPointer > Activities; + public: ProgressDlg(); ~ProgressDlg(); diff --git a/Libs/libMacGitverCore/Widgets/ProgressWdgt.ui b/Libs/libMacGitverCore/Widgets/ProgressWdgt.ui new file mode 100644 index 00000000..3b780075 --- /dev/null +++ b/Libs/libMacGitverCore/Widgets/ProgressWdgt.ui @@ -0,0 +1,38 @@ + + + ProgressWdgt + + + + 0 + 0 + 448 + 83 + + + + Progress + + + + + + Progress: + + + + + + + + + + Not started... + + + + + + + + From 6825854540fe03784dc1f9f5801c158d7d498012 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Sat, 25 Apr 2015 17:15:32 +0200 Subject: [PATCH 44/75] redesign ProgressDlg to visualize the progress of multiple activities An activity must contain at least one step to be processed. Note: There's no logging available yet. --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 144 +++++++------ Libs/libMacGitverCore/Widgets/ProgressDlg.hpp | 41 ++-- Libs/libMacGitverCore/Widgets/ProgressDlg.ui | 201 +++++++----------- 3 files changed, 188 insertions(+), 198 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 2539d18d..e6679df8 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -5,9 +5,7 @@ #include #include -#include #include -#include namespace Private { @@ -53,6 +51,9 @@ ProgressDlg::ProgressDlg() p.setColor( QPalette::Base, p.color( QPalette::Window ) ); p.setColor( QPalette::Text, p.color( QPalette::WindowText ) ); ui->txtLog->setPalette( p ); + + connect(&mUpdater, &QTimer::timeout, this, &ProgressDlg::updateActivities); + mUpdater.start(250); } ProgressDlg::~ProgressDlg() @@ -60,39 +61,54 @@ ProgressDlg::~ProgressDlg() delete ui; } -void ProgressDlg::setAction( const QString& action, - const QStringList& open, - const QStringList& current, - const QStringList& done ) +int ProgressDlg::updateInterval() const { - QString act = action; + return mUpdater.interval(); +} - foreach( QString s, done ) - { - act += QStringLiteral( " (" ) % s % QStringLiteral( ")" ); - } +void ProgressDlg::setUpdateInterval(int msec) +{ + mUpdater.setInterval(msec); +} - foreach( QString s, current ) - { - act += QStringLiteral( " (" ) % s % QStringLiteral( ")" ); - } +void ProgressDlg::addActivity(const QString& description, QObject* activity, + const StepInfo::List& steps) +{ + Q_ASSERT(activity); - foreach( QString s, open ) - { - act += QStringLiteral( " (" ) % s % QStringLiteral( ")" ); + Private::ProgressWdgt* a( new Private::ProgressWdgt(description) ); + mActivities[activity] = a; + + QTreeWidgetItem* activityItem(new QTreeWidgetItem); + ui->treeProgress->addTopLevelItem(activityItem); + ui->treeProgress->setItemWidget(activityItem, 0, a); + + foreach (const StepInfo& sir, steps) { + Private::ProgressWdgt* s = new Private::ProgressWdgt(sir.desc); + a->mSteps[sir.name] = s; + + QTreeWidgetItem* stepItem(new QTreeWidgetItem); + activityItem->addChild(stepItem); + ui->treeProgress->setItemWidget(stepItem, 0, s); } +} + +void ProgressDlg::setStatusInfo(QObject* activity, const QString& step, + const QString& text) +{ + Q_ASSERT(activity && !step.isEmpty()); - ui->lblAction->setText( act ); + Private::ProgressWdgt* s = findStep(activity, step); + s->txtStatusInfo->setText(text); } -void ProgressDlg::setCurrent(QObject* current) +void ProgressDlg::setPercentage(QObject* activity, const QString& step, + qreal percent) { - mCurrent = current; + Q_ASSERT(activity && !step.isEmpty()); - connect( mCurrent, SIGNAL(remoteMessage(QString)), - this, SLOT(remoteMessage(QString)) ); - connect( mCurrent, SIGNAL(transportProgress(quint32, quint32, quint32, quint64)), - this, SLOT(transportProgress(quint32, quint32, quint32, quint64)) ); + Private::ProgressWdgt* s = findStep(activity, step); + s->mPercentage = qMin( qMax(percent, 0.), 1. ) * 100.; } void ProgressDlg::closeEvent( QCloseEvent* ev ) @@ -106,35 +122,7 @@ void ProgressDlg::closeEvent( QCloseEvent* ev ) QDialog::closeEvent( ev ); } -void ProgressDlg::transportProgress( quint32 totalObjects, - quint32 indexedObjects, - quint32 receivedObjects, - quint64 receivedBytes ) -{ - QString recv; - if( receivedBytes > 1024 * 1024 * 950 ) /* 950 is so we get 0.9 gb */ - { - recv = QString::number( receivedBytes / (1024*1024*1024.0), 'f', 2 ) % QStringLiteral( " Gb" ); - } - else if( receivedBytes > 1024 * 950 ) - { - recv = QString::number( receivedBytes / (1024*1024.0), 'f', 2 ) % QStringLiteral( " Mb" ); - } - else if( receivedBytes > 950 ) - { - recv = QString::number( receivedBytes / 1024.0, 'f', 2 ) % QStringLiteral( " Kb" ); - } - else - { - recv = QString::number( receivedBytes ); - } - ui->lblTransferSize->setText( recv ); - - ui->progressBar->setRange( 0, totalObjects * 2 ); - ui->progressBar->setValue( indexedObjects + receivedObjects ); -} - -void ProgressDlg::remoteMessage( const QString& msg ) +void ProgressDlg::remoteMessage(const QString& msg) { mRawRemoteMessage += msg; @@ -166,27 +154,53 @@ void ProgressDlg::remoteMessage( const QString& msg ) output += QString( outputBuffer, outBufLen ); QString log = mBaseLog % QStringLiteral( "
" ) % - output.replace( QChar( L'\n' ), QLatin1String("
") ).simplified(); + output.replace( QChar( L'\n' ), QStringLiteral("
") ).simplified(); ui->txtLog->setHtml( log ); } -void ProgressDlg::beginStep( const QString& step ) +void ProgressDlg::finished(QObject* activity) { - mBaseLog += tr( "%1
" ).arg( step ); - ui->txtLog->setHtml( mBaseLog ); + mActivities[activity]->mStatus = Private::ProgressWdgt::Stopped; + + bool done = true; + foreach (Private::ProgressWdgt* a, mActivities) { + done &= (a->mStatus == Private::ProgressWdgt::Stopped); + if (!done) { + break; + } + } + + if (done) { + mDone = true; + ui->buttonBox->button( QDialogButtonBox::Close )->setEnabled( true ); + } } -void ProgressDlg::finalizeStep() +void ProgressDlg::finished(QObject* activity, const QString& step) { - mBaseLog = ui->txtLog->toHtml() % QStringLiteral( "
" ); - mRawRemoteMessage = QString(); + Q_ASSERT(activity && !step.isEmpty()); + + Private::ProgressWdgt* a = mActivities[activity]; + a->mSteps[step]->mStatus = Private::ProgressWdgt::Stopped; +} - ui->txtLog->setHtml( mBaseLog ); +void ProgressDlg::updateActivities() +{ + foreach(Private::ProgressWdgt* a, mActivities) { + a->mPercentage = 0; + foreach (Private::ProgressWdgt* s, a->mSteps) { + s->progressBar->setValue(qRound(s->mPercentage)); + qreal stepPercent = s->mPercentage / a->mSteps.size(); + a->mPercentage += qMin( qMax(stepPercent, 0.), 100.); + } + + a->progressBar->setValue(qRound(a->mPercentage)); + } } -void ProgressDlg::setDone() +Private::ProgressWdgt* ProgressDlg::findStep(QObject* activity, const QString& step) const { - mDone = true; - ui->buttonBox->button( QDialogButtonBox::Close )->setEnabled( true ); + Private::ProgressWdgt* a = mActivities[activity]; + return step.isEmpty() || !a ? nullptr : a->mSteps[step]; } diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp index b1e02a2e..c1d458a0 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp @@ -6,6 +6,7 @@ #include #include +#include namespace Private { @@ -22,6 +23,14 @@ class MGV_CORE_API ProgressDlg : public BlueSky::Dialog Q_OBJECT public: + struct StepInfo + { + typedef QVector List; + + QString name; + QString desc; + }; + typedef QMap< QPointer, QPointer > Activities; public: @@ -29,29 +38,37 @@ class MGV_CORE_API ProgressDlg : public BlueSky::Dialog ~ProgressDlg(); public: - void setAction( const QString& action, const QStringList& open, - const QStringList& current, const QStringList& done ); - void setCurrent(QObject* current); + int updateInterval() const; + void setUpdateInterval(int msec); -private slots: - void transportProgress( quint32 totalObjects, quint32 indexedObjects, - quint32 receivedObjects, quint64 receivedBytes ); - void remoteMessage( const QString& msg ); + void addActivity(const QString& description, QObject* activity, + const StepInfo::List& steps); -public: - void setDone(); - void beginStep( const QString& step ); - void finalizeStep(); + void setStatusInfo(QObject* activity, const QString& step, + const QString& text); + void setPercentage(QObject* activity, const QString& step, qreal percent); + void remoteMessage(const QString& msg); + + void finished(QObject* activity); + void finished(QObject* activity, const QString& step); + +private slots: + void updateActivities(); protected: void closeEvent( QCloseEvent* ev ); +private: + Private::ProgressWdgt* findStep(QObject* activity, const QString& step) const; + private: Ui::ProgressDlg* ui; private: bool mDone; QString mBaseLog; - QObject* mCurrent; QString mRawRemoteMessage; + Activities mActivities; + + QTimer mUpdater; }; diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.ui b/Libs/libMacGitverCore/Widgets/ProgressDlg.ui index 19bf883d..f5cce393 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.ui +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.ui @@ -9,16 +9,10 @@ 0 0 - 484 - 291 + 603 + 332 - - - 0 - 0 - - Progress @@ -26,128 +20,93 @@ true - - - - QDialogButtonBox::Close - - - - - - - - 0 - 0 - - - - - 0 - 60 - + + + + Qt::Vertical - - Log - - - - QLayout::SetDefaultConstraint + + + + 0 + 2 + + + + QAbstractItemView::ScrollPerPixel - - 0 + + true - - 0 + + true - - 0 + + false + + + + 1 + + + + + + + 0 + 1 + - - 0 + + + 0 + 60 + - - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - - + + Details: + + + + QLayout::SetDefaultConstraint + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + + + - - - - Current operation + + + + QDialogButtonBox::Close - - - 3 - - - 3 - - - 3 - - - 3 - - - 6 - - - 2 - - - - - - 0 - 0 - - - - - - - - - - - - - - - <b>Progress</(b> - - - - - - - <b>Action</b> - - - - - - - - - - - From a5dd49a484d91c84fc8f919a22d664e5748ccbbb Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Sat, 25 Apr 2015 19:58:42 +0200 Subject: [PATCH 45/75] use assignment operator instead of copy c'tor --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index e6679df8..7dd97b93 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -76,7 +76,7 @@ void ProgressDlg::addActivity(const QString& description, QObject* activity, { Q_ASSERT(activity); - Private::ProgressWdgt* a( new Private::ProgressWdgt(description) ); + Private::ProgressWdgt* a = new Private::ProgressWdgt(description); mActivities[activity] = a; QTreeWidgetItem* activityItem(new QTreeWidgetItem); From 76c2e16541cda09b404ac17b77af95a33990308f Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Sat, 25 Apr 2015 19:59:36 +0200 Subject: [PATCH 46/75] restart timer when active while changing the interval --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 7dd97b93..cd3ad3e2 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -68,7 +68,13 @@ int ProgressDlg::updateInterval() const void ProgressDlg::setUpdateInterval(int msec) { - mUpdater.setInterval(msec); + if (mUpdater.isActive()) { + // restart timer with the new interval + mUpdater.start(msec); + } + else { + mUpdater.setInterval(msec); + } } void ProgressDlg::addActivity(const QString& description, QObject* activity, From c10097c15f2cd7abc7abe2dcc448090da81070dc Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Sat, 25 Apr 2015 20:03:38 +0200 Subject: [PATCH 47/75] set text according to state of progress (running/finished) TODO: error state is missing --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index cd3ad3e2..85785044 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -97,6 +97,8 @@ void ProgressDlg::addActivity(const QString& description, QObject* activity, activityItem->addChild(stepItem); ui->treeProgress->setItemWidget(stepItem, 0, s); } + + a->txtStatusInfo->setText(tr("Running...")); } void ProgressDlg::setStatusInfo(QObject* activity, const QString& step, @@ -167,7 +169,9 @@ void ProgressDlg::remoteMessage(const QString& msg) void ProgressDlg::finished(QObject* activity) { - mActivities[activity]->mStatus = Private::ProgressWdgt::Stopped; + Private::ProgressWdgt* a = mActivities[activity]; + a->mStatus = Private::ProgressWdgt::Stopped; + a->txtStatusInfo->setText(tr("Finished!")); bool done = true; foreach (Private::ProgressWdgt* a, mActivities) { From 44a8364154f6de6f04fef0348bc8261508af331f Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Sat, 25 Apr 2015 20:22:30 +0200 Subject: [PATCH 48/75] removed obsolete method ProgressDlg::remoteMessage --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 37 ------------------- Libs/libMacGitverCore/Widgets/ProgressDlg.hpp | 1 - 2 files changed, 38 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 85785044..e9af0a8e 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -130,43 +130,6 @@ void ProgressDlg::closeEvent( QCloseEvent* ev ) QDialog::closeEvent( ev ); } -void ProgressDlg::remoteMessage(const QString& msg) -{ - mRawRemoteMessage += msg; - - QString output; - QChar outputBuffer[ 256 ]; - int outBufPos = 0, outBufLen = 0; - - for( int i = 0; i < mRawRemoteMessage.length(); ++i ) - { - if( mRawRemoteMessage[ i ] == QChar( L'\r' ) ) - { - outBufPos = 0; - } - else if( mRawRemoteMessage[ i ] == QChar( L'\n' ) ) - { - if( outBufLen ) - output += QString( outputBuffer, outBufLen ); - output += QChar( L'\n' ); - outBufPos = outBufLen = 0; - } - else - { - outputBuffer[ outBufPos++] = mRawRemoteMessage[ i ]; - outBufLen = qMax( outBufLen, outBufPos ); - } - } - - if( outBufLen ) - output += QString( outputBuffer, outBufLen ); - - QString log = mBaseLog % QStringLiteral( "
" ) % - output.replace( QChar( L'\n' ), QStringLiteral("
") ).simplified(); - - ui->txtLog->setHtml( log ); -} - void ProgressDlg::finished(QObject* activity) { Private::ProgressWdgt* a = mActivities[activity]; diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp index c1d458a0..feb0a34f 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp @@ -47,7 +47,6 @@ class MGV_CORE_API ProgressDlg : public BlueSky::Dialog void setStatusInfo(QObject* activity, const QString& step, const QString& text); void setPercentage(QObject* activity, const QString& step, qreal percent); - void remoteMessage(const QString& msg); void finished(QObject* activity); void finished(QObject* activity, const QString& step); From 008c9a0af2c8832c41d22fd2bbd841b5e9801dc7 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Mon, 27 Apr 2015 13:05:41 +0200 Subject: [PATCH 49/75] minor cleanup in ProgressDlg --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index e9af0a8e..2d196a65 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -3,9 +3,9 @@ #include "ui_ProgressDlg.h" #include "ui_ProgressWdgt.h" -#include #include #include +#include namespace Private { @@ -13,10 +13,10 @@ namespace Private class ProgressWdgt : public QWidget, public Ui::ProgressWdgt { public: - typedef QMap< QString, QPointer > Steps; - enum Status { Running = 0, Stopped }; + typedef QMap< QString, QPointer > Steps; + public: ProgressWdgt(const QString& description) { From 6065717ba48c68af7ee8557fa79835f0346a6155 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Mon, 27 Apr 2015 13:17:21 +0200 Subject: [PATCH 50/75] ProgressDlg: moved initializers back to c'tor --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 2d196a65..47834833 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -19,6 +19,8 @@ namespace Private public: ProgressWdgt(const QString& description) + : mStatus(Running) + , mPercentage(0.) { setupUi(this); progressBar->setMinimum(0); @@ -28,9 +30,9 @@ namespace Private public: Steps mSteps; - Status mStatus = Running; + Status mStatus; - qreal mPercentage = 0.; + qreal mPercentage; }; } From 5d3995ff549cefdc36e4aa8452f615f5eb2d246b Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Mon, 27 Apr 2015 13:19:13 +0200 Subject: [PATCH 51/75] ProgressDlg: removed customized palette for log view --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 47834833..e14fd407 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -49,10 +49,6 @@ ProgressDlg::ProgressDlg() close->setEnabled( false ); connect( close, &QPushButton::clicked, this, &ProgressDlg::close ); - QPalette p; - p.setColor( QPalette::Base, p.color( QPalette::Window ) ); - p.setColor( QPalette::Text, p.color( QPalette::WindowText ) ); - ui->txtLog->setPalette( p ); connect(&mUpdater, &QTimer::timeout, this, &ProgressDlg::updateActivities); mUpdater.start(250); From 215278146a93108e09c12c782f942221b238e509 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Mon, 27 Apr 2015 13:20:11 +0200 Subject: [PATCH 52/75] ProgressDlg: minor cleanup --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index e14fd407..38070119 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -45,10 +45,9 @@ ProgressDlg::ProgressDlg() { ui->setupUi( this ); - QPushButton* close = ui->buttonBox->button( QDialogButtonBox::Close ); + QPushButton* close = ui->buttonBox->button(QDialogButtonBox::Close); close->setEnabled( false ); - connect( close, &QPushButton::clicked, this, &ProgressDlg::close ); - + connect(close, &QPushButton::clicked, this, &ProgressDlg::close); connect(&mUpdater, &QTimer::timeout, this, &ProgressDlg::updateActivities); mUpdater.start(250); From 5a1bc443582502530fdef6d18583771ba1d6aa27 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Mon, 27 Apr 2015 13:25:24 +0200 Subject: [PATCH 53/75] ProgressDlg: add methods isDone() and setCanClose() --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 10 ++++++++++ Libs/libMacGitverCore/Widgets/ProgressDlg.hpp | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 38070119..1b31d3f1 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -174,3 +174,13 @@ Private::ProgressWdgt* ProgressDlg::findStep(QObject* activity, const QString& s Private::ProgressWdgt* a = mActivities[activity]; return step.isEmpty() || !a ? nullptr : a->mSteps[step]; } + +void ProgressDlg::setCanClose() +{ + const bool wasDone = mDone; + mDone = isDone(); + + if (mDone != wasDone) { + ui->buttonBox->button( QDialogButtonBox::Close )->setEnabled( mDone ); + } +} diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp index feb0a34f..cd6ff44e 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp @@ -60,6 +60,9 @@ private slots: private: Private::ProgressWdgt* findStep(QObject* activity, const QString& step) const; + bool isDone() const; + void setCanClose(); + private: Ui::ProgressDlg* ui; @@ -71,3 +74,8 @@ private slots: QTimer mUpdater; }; + +inline bool ProgressDlg::isDone() const +{ + return mActivities.isEmpty(); +} From b026b9e41ccc438fc3249c00bba1ffaac82e19eb Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Mon, 27 Apr 2015 13:28:34 +0200 Subject: [PATCH 54/75] ProgressDlg: move asserts --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 1b31d3f1..c70f6beb 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -101,18 +101,18 @@ void ProgressDlg::addActivity(const QString& description, QObject* activity, void ProgressDlg::setStatusInfo(QObject* activity, const QString& step, const QString& text) { - Q_ASSERT(activity && !step.isEmpty()); - Private::ProgressWdgt* s = findStep(activity, step); + Q_ASSERT(s); + s->txtStatusInfo->setText(text); } void ProgressDlg::setPercentage(QObject* activity, const QString& step, qreal percent) { - Q_ASSERT(activity && !step.isEmpty()); - Private::ProgressWdgt* s = findStep(activity, step); + Q_ASSERT(s); + s->mPercentage = qMin( qMax(percent, 0.), 1. ) * 100.; } @@ -130,6 +130,8 @@ void ProgressDlg::closeEvent( QCloseEvent* ev ) void ProgressDlg::finished(QObject* activity) { Private::ProgressWdgt* a = mActivities[activity]; + Q_ASSERT(a); + a->mStatus = Private::ProgressWdgt::Stopped; a->txtStatusInfo->setText(tr("Finished!")); From 0aed9681ff1f4174035d257b9f513e2c9582de0f Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Mon, 27 Apr 2015 13:34:45 +0200 Subject: [PATCH 55/75] ProgressDlg: remove invalid activities from progress updating Activities become invalid, when they where deleted (pointer == nullptr). --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index c70f6beb..317c2854 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -159,15 +159,27 @@ void ProgressDlg::finished(QObject* activity, const QString& step) void ProgressDlg::updateActivities() { - foreach(Private::ProgressWdgt* a, mActivities) { - a->mPercentage = 0; - foreach (Private::ProgressWdgt* s, a->mSteps) { - s->progressBar->setValue(qRound(s->mPercentage)); - qreal stepPercent = s->mPercentage / a->mSteps.size(); - a->mPercentage += qMin( qMax(stepPercent, 0.), 100.); + Activities::Iterator it = mActivities.begin(); + while ( it != mActivities.end() ) { + if (!it.key()) { + // remove invalid activities + it = mActivities.erase(it); + } + else { + Private::ProgressWdgt* a = *it; + a->mPercentage = 0.; + + foreach (Private::ProgressWdgt* s, a->mSteps) { + s->progressBar->setValue(qRound(s->mPercentage)); + qreal stepPercent = s->mPercentage / a->mSteps.size(); + a->mPercentage += qMin( qMax(stepPercent, 0.), 100.); + } + + a->progressBar->setValue(qRound(a->mPercentage)); + + ++it; } - a->progressBar->setValue(qRound(a->mPercentage)); } } From d6a6c8f672f76586af6d2c01dc37b465920640fe Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Mon, 27 Apr 2015 13:39:02 +0200 Subject: [PATCH 56/75] add ProgressDlg::setError() --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 13 +++++++++++-- Libs/libMacGitverCore/Widgets/ProgressDlg.hpp | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 317c2854..72611926 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -151,10 +151,19 @@ void ProgressDlg::finished(QObject* activity) void ProgressDlg::finished(QObject* activity, const QString& step) { - Q_ASSERT(activity && !step.isEmpty()); + Private::ProgressWdgt* s = findStep(activity, step); + Q_ASSERT(s); + + s->mStatus = Private::ProgressWdgt::Stopped; +} +void ProgressDlg::setError(QObject* activity, const QString& message) +{ Private::ProgressWdgt* a = mActivities[activity]; - a->mSteps[step]->mStatus = Private::ProgressWdgt::Stopped; + Q_ASSERT(a); + a->setToolTip(tr("Activity failed!
%1").arg(message)); + a->txtStatusInfo->setText(tr("Failed!")); + a->mStatus = Private::ProgressWdgt::Stopped; } void ProgressDlg::updateActivities() diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp index cd6ff44e..750b3de9 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp @@ -51,6 +51,8 @@ class MGV_CORE_API ProgressDlg : public BlueSky::Dialog void finished(QObject* activity); void finished(QObject* activity, const QString& step); + void setError(QObject* activity, const QString& message); + private slots: void updateActivities(); From 294c2f2f0a4d173f66ff5839d7ba88e790fe4c11 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Mon, 27 Apr 2015 13:41:40 +0200 Subject: [PATCH 57/75] ProgressDlg: prevent accept() or reject() before activities are finished --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 13 +++++++++++++ Libs/libMacGitverCore/Widgets/ProgressDlg.hpp | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 72611926..9827eb96 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -188,7 +188,20 @@ void ProgressDlg::updateActivities() ++it; } + } +} +void ProgressDlg::accept() +{ + if (isDone()) { + BlueSky::Dialog::accept(); + } +} + +void ProgressDlg::reject() +{ + if (isDone()) { + BlueSky::Dialog::reject(); } } diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp index 750b3de9..12d3c9f0 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp @@ -53,6 +53,11 @@ class MGV_CORE_API ProgressDlg : public BlueSky::Dialog void setError(QObject* activity, const QString& message); +public: + // virtual slots + void accept(); + void reject(); + private slots: void updateActivities(); From 2627e428bf878ddff9feb8253752b9fa28c872a4 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Mon, 27 Apr 2015 13:45:11 +0200 Subject: [PATCH 58/75] PrgressDlg: frequently update close buttons --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 9827eb96..9784dc2c 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -135,18 +135,6 @@ void ProgressDlg::finished(QObject* activity) a->mStatus = Private::ProgressWdgt::Stopped; a->txtStatusInfo->setText(tr("Finished!")); - bool done = true; - foreach (Private::ProgressWdgt* a, mActivities) { - done &= (a->mStatus == Private::ProgressWdgt::Stopped); - if (!done) { - break; - } - } - - if (done) { - mDone = true; - ui->buttonBox->button( QDialogButtonBox::Close )->setEnabled( true ); - } } void ProgressDlg::finished(QObject* activity, const QString& step) @@ -189,6 +177,8 @@ void ProgressDlg::updateActivities() ++it; } } + + setCanClose(); } void ProgressDlg::accept() From dc05e54a87eb8aa47a90396e3d59e091260943fb Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Mon, 27 Apr 2015 13:46:35 +0200 Subject: [PATCH 59/75] ProgressDlg: set step percentage to 100% when finished --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 9784dc2c..3791a44a 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -143,6 +143,7 @@ void ProgressDlg::finished(QObject* activity, const QString& step) Q_ASSERT(s); s->mStatus = Private::ProgressWdgt::Stopped; + s->mPercentage = 100.; } void ProgressDlg::setError(QObject* activity, const QString& message) From eb6eac173a66252c355ddcad35ce04d9aa8e6d74 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Mon, 27 Apr 2015 13:47:59 +0200 Subject: [PATCH 60/75] ProgressDlg: mark finished and error state of an activity by coloring the progress bar --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 3791a44a..d583ac35 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -134,6 +134,7 @@ void ProgressDlg::finished(QObject* activity) a->mStatus = Private::ProgressWdgt::Stopped; a->txtStatusInfo->setText(tr("Finished!")); + a->setStyleSheet(QStringLiteral("QProgressBar::chunk{background-color: #55FF55;}")); } @@ -144,6 +145,7 @@ void ProgressDlg::finished(QObject* activity, const QString& step) s->mStatus = Private::ProgressWdgt::Stopped; s->mPercentage = 100.; + s->setStyleSheet(QStringLiteral("QProgressBar::chunk{background-color: #55FF55;}")); } void ProgressDlg::setError(QObject* activity, const QString& message) @@ -153,6 +155,7 @@ void ProgressDlg::setError(QObject* activity, const QString& message) a->setToolTip(tr("Activity failed!
%1").arg(message)); a->txtStatusInfo->setText(tr("Failed!")); a->mStatus = Private::ProgressWdgt::Stopped; + a->setStyleSheet(QStringLiteral("QProgressBar{background-color: #FF5555;} QProgressBar::chunk{background-color: red;}")); } void ProgressDlg::updateActivities() From 825d4e8d2f788abbd6b3dc8ef6c81b70b9823f4c Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Mon, 27 Apr 2015 14:04:40 +0200 Subject: [PATCH 61/75] ProgressDlg: fixed erase activities --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index d583ac35..df91906b 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -162,22 +162,22 @@ void ProgressDlg::updateActivities() { Activities::Iterator it = mActivities.begin(); while ( it != mActivities.end() ) { + Private::ProgressWdgt* a = *it; + a->mPercentage = 0.; + + foreach (Private::ProgressWdgt* s, a->mSteps) { + s->progressBar->setValue(qRound(s->mPercentage)); + qreal stepPercent = s->mPercentage / a->mSteps.size(); + a->mPercentage += qMin( qMax(stepPercent, 0.), 100.); + } + + a->progressBar->setValue(qRound(a->mPercentage)); + + // remove invalid activities after updating if (!it.key()) { - // remove invalid activities it = mActivities.erase(it); } else { - Private::ProgressWdgt* a = *it; - a->mPercentage = 0.; - - foreach (Private::ProgressWdgt* s, a->mSteps) { - s->progressBar->setValue(qRound(s->mPercentage)); - qreal stepPercent = s->mPercentage / a->mSteps.size(); - a->mPercentage += qMin( qMax(stepPercent, 0.), 100.); - } - - a->progressBar->setValue(qRound(a->mPercentage)); - ++it; } } From c86540602be16182d53e38c9c975c48d3430e394 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Fri, 1 May 2015 12:47:47 +0200 Subject: [PATCH 62/75] ProgressDlg: make internal progress widgets use the cells background on painting --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index df91906b..4f560ac1 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -23,6 +23,7 @@ namespace Private , mPercentage(0.) { setupUi(this); + setAttribute(Qt::WA_NoSystemBackground); progressBar->setMinimum(0); progressBar->setMaximum(100); txtHeader->setText( description ); From 444f107d3a0edd10d008a6a0cec55d6f09d2670c Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Fri, 1 May 2015 12:52:49 +0200 Subject: [PATCH 63/75] ProgressDlg: a progress widget has no "running" state; an "active" flag better reflects what I mean here --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 4f560ac1..e8d749dc 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -13,13 +13,12 @@ namespace Private class ProgressWdgt : public QWidget, public Ui::ProgressWdgt { public: - enum Status { Running = 0, Stopped }; typedef QMap< QString, QPointer > Steps; public: ProgressWdgt(const QString& description) - : mStatus(Running) + : mActive(true) , mPercentage(0.) { setupUi(this); @@ -31,8 +30,8 @@ namespace Private public: Steps mSteps; - Status mStatus; + bool mActive; qreal mPercentage; }; @@ -133,7 +132,7 @@ void ProgressDlg::finished(QObject* activity) Private::ProgressWdgt* a = mActivities[activity]; Q_ASSERT(a); - a->mStatus = Private::ProgressWdgt::Stopped; + a->mActive = false; a->txtStatusInfo->setText(tr("Finished!")); a->setStyleSheet(QStringLiteral("QProgressBar::chunk{background-color: #55FF55;}")); @@ -144,7 +143,7 @@ void ProgressDlg::finished(QObject* activity, const QString& step) Private::ProgressWdgt* s = findStep(activity, step); Q_ASSERT(s); - s->mStatus = Private::ProgressWdgt::Stopped; + s->mActive = false; s->mPercentage = 100.; s->setStyleSheet(QStringLiteral("QProgressBar::chunk{background-color: #55FF55;}")); } @@ -153,9 +152,9 @@ void ProgressDlg::setError(QObject* activity, const QString& message) { Private::ProgressWdgt* a = mActivities[activity]; Q_ASSERT(a); + a->mActive = false; a->setToolTip(tr("Activity failed!
%1").arg(message)); a->txtStatusInfo->setText(tr("Failed!")); - a->mStatus = Private::ProgressWdgt::Stopped; a->setStyleSheet(QStringLiteral("QProgressBar{background-color: #FF5555;} QProgressBar::chunk{background-color: red;}")); } From 7ab5ac73f516f1e59cad19cb95d53386b8895e9e Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Fri, 1 May 2015 12:57:50 +0200 Subject: [PATCH 64/75] ProgressDlg: refine the appearance of progress bars by using the activiy's result and minor cleanup --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 57 +++++++++++++++++-- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index e8d749dc..2de3a7f3 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -13,6 +13,7 @@ namespace Private class ProgressWdgt : public QWidget, public Ui::ProgressWdgt { public: + enum Result { Undefined = 0, Ok, Error }; typedef QMap< QString, QPointer > Steps; @@ -23,16 +24,61 @@ namespace Private { setupUi(this); setAttribute(Qt::WA_NoSystemBackground); + resultChanged(Result::Undefined); progressBar->setMinimum(0); progressBar->setMaximum(100); txtHeader->setText( description ); } public: - Steps mSteps; + void resultChanged(Result result) + { + QColor barColor; + + switch (result) { + case Result::Ok: + barColor = QColor(0x55, 0xFF, 0x55); + break; + + case Result::Error: + barColor = QColor(0xFF, 0x55, 0x55); + break; + + case Result::Undefined: + default: + barColor = QColor(0x99, 0x99, 0x99); + break; + } + + progressBar->setStyleSheet( + QStringLiteral( + "QProgressBar{" + "text-align: center;" + "border: 2px solid silver;" + "border-radius: 5px;" + "background: QLinearGradient(" + "x1: 0, y1: 0, x2: 0, y2: 1," + "stop: 0 %1," + "stop: 1 %2);" + "}") + .arg(barColor.darker(150).name()).arg(barColor.name()) % + + QStringLiteral( + "QProgressBar::chunk{" + "background: QLinearGradient(" + "x1: 0, y1: 0, x2: 0, y2: 1," + "stop: 0 %1," + "stop: 1 %2);" + "}") + .arg(barColor.lighter(150).name()).arg(barColor.name()) + ); + } + public: bool mActive; qreal mPercentage; + + Steps mSteps; }; } @@ -134,8 +180,7 @@ void ProgressDlg::finished(QObject* activity) a->mActive = false; a->txtStatusInfo->setText(tr("Finished!")); - a->setStyleSheet(QStringLiteral("QProgressBar::chunk{background-color: #55FF55;}")); - + a->resultChanged(Private::ProgressWdgt::Result::Ok); } void ProgressDlg::finished(QObject* activity, const QString& step) @@ -145,7 +190,7 @@ void ProgressDlg::finished(QObject* activity, const QString& step) s->mActive = false; s->mPercentage = 100.; - s->setStyleSheet(QStringLiteral("QProgressBar::chunk{background-color: #55FF55;}")); + s->resultChanged(Private::ProgressWdgt::Result::Ok); } void ProgressDlg::setError(QObject* activity, const QString& message) @@ -153,9 +198,9 @@ void ProgressDlg::setError(QObject* activity, const QString& message) Private::ProgressWdgt* a = mActivities[activity]; Q_ASSERT(a); a->mActive = false; - a->setToolTip(tr("Activity failed!
%1").arg(message)); a->txtStatusInfo->setText(tr("Failed!")); - a->setStyleSheet(QStringLiteral("QProgressBar{background-color: #FF5555;} QProgressBar::chunk{background-color: red;}")); + a->setToolTip(tr("Activity failed!
%1").arg(message)); + a->resultChanged(Private::ProgressWdgt::Result::Error); } void ProgressDlg::updateActivities() From df89eb2bbcd24e2ee2b76f5650c3e863f35cdcbf Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Thu, 7 May 2015 08:27:47 +0200 Subject: [PATCH 65/75] ProgressDlg: add an assert, because currently the activity widget *must* be valid --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 2de3a7f3..93a3f9e2 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -208,6 +208,8 @@ void ProgressDlg::updateActivities() Activities::Iterator it = mActivities.begin(); while ( it != mActivities.end() ) { Private::ProgressWdgt* a = *it; + Q_ASSERT(a); + a->mPercentage = 0.; foreach (Private::ProgressWdgt* s, a->mSteps) { From 7e13dfb9e4ff5d5675d78f41a3e761f467a288e4 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Fri, 8 May 2015 08:12:56 +0200 Subject: [PATCH 66/75] ProgressDlg: inline the info text in the progress bar --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 8 ++++---- Libs/libMacGitverCore/Widgets/ProgressWdgt.ui | 11 ++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 93a3f9e2..799e7693 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -141,7 +141,7 @@ void ProgressDlg::addActivity(const QString& description, QObject* activity, ui->treeProgress->setItemWidget(stepItem, 0, s); } - a->txtStatusInfo->setText(tr("Running...")); + a->progressBar->setFormat(tr("Running...")); } void ProgressDlg::setStatusInfo(QObject* activity, const QString& step, @@ -150,7 +150,7 @@ void ProgressDlg::setStatusInfo(QObject* activity, const QString& step, Private::ProgressWdgt* s = findStep(activity, step); Q_ASSERT(s); - s->txtStatusInfo->setText(text); + s->progressBar->setFormat(text); } void ProgressDlg::setPercentage(QObject* activity, const QString& step, @@ -179,7 +179,7 @@ void ProgressDlg::finished(QObject* activity) Q_ASSERT(a); a->mActive = false; - a->txtStatusInfo->setText(tr("Finished!")); + a->progressBar->setFormat(tr("Finished!")); a->resultChanged(Private::ProgressWdgt::Result::Ok); } @@ -198,7 +198,7 @@ void ProgressDlg::setError(QObject* activity, const QString& message) Private::ProgressWdgt* a = mActivities[activity]; Q_ASSERT(a); a->mActive = false; - a->txtStatusInfo->setText(tr("Failed!")); + a->progressBar->setFormat(tr("Failed!")); a->setToolTip(tr("Activity failed!
%1").arg(message)); a->resultChanged(Private::ProgressWdgt::Result::Error); } diff --git a/Libs/libMacGitverCore/Widgets/ProgressWdgt.ui b/Libs/libMacGitverCore/Widgets/ProgressWdgt.ui index 3b780075..a997fc8a 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressWdgt.ui +++ b/Libs/libMacGitverCore/Widgets/ProgressWdgt.ui @@ -7,7 +7,7 @@ 0 0 448 - 83 + 62 @@ -22,12 +22,9 @@ - - - - - - Not started... + + + From 26cc7fa959bdfcb5d11d36287efa88b10e2ed73b Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Fri, 8 May 2015 09:07:11 +0200 Subject: [PATCH 67/75] ProgressDlg: use C++11 enum class --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 799e7693..fcd85046 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -13,7 +13,7 @@ namespace Private class ProgressWdgt : public QWidget, public Ui::ProgressWdgt { public: - enum Result { Undefined = 0, Ok, Error }; + enum class Result { Undefined = 0, Ok, Error }; typedef QMap< QString, QPointer > Steps; From a996865e9d0aacf4f8650ccd4b26681145bcf59a Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Fri, 8 May 2015 09:54:51 +0200 Subject: [PATCH 68/75] ProgressDlg: remove "running" and "finished" text --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index fcd85046..42e1534c 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -140,8 +140,6 @@ void ProgressDlg::addActivity(const QString& description, QObject* activity, activityItem->addChild(stepItem); ui->treeProgress->setItemWidget(stepItem, 0, s); } - - a->progressBar->setFormat(tr("Running...")); } void ProgressDlg::setStatusInfo(QObject* activity, const QString& step, @@ -179,7 +177,6 @@ void ProgressDlg::finished(QObject* activity) Q_ASSERT(a); a->mActive = false; - a->progressBar->setFormat(tr("Finished!")); a->resultChanged(Private::ProgressWdgt::Result::Ok); } From 6aea9a287f9a2282d280174b01eeb1b1b1059031 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Fri, 8 May 2015 09:56:15 +0200 Subject: [PATCH 69/75] ProgressDlg: add a more descriptive "failed" text --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 42e1534c..0b75f898 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -195,8 +195,8 @@ void ProgressDlg::setError(QObject* activity, const QString& message) Private::ProgressWdgt* a = mActivities[activity]; Q_ASSERT(a); a->mActive = false; - a->progressBar->setFormat(tr("Failed!")); - a->setToolTip(tr("Activity failed!
%1").arg(message)); + a->progressBar->setFormat(tr("Failed. See tool tip for details.")); + a->setToolTip(tr("Activity failed.
%1").arg(message)); a->resultChanged(Private::ProgressWdgt::Result::Error); } From 75433fe7af2f85a7f8064b131ae788e7249d4683 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Fri, 8 May 2015 10:00:08 +0200 Subject: [PATCH 70/75] ProgressDlg: only the activity has a finished slot When a step progress reaches 100%, the progress bar changes to a green background. --- Libs/libMacGitverCore/Widgets/ProgressDlg.cpp | 14 ++++---------- Libs/libMacGitverCore/Widgets/ProgressDlg.hpp | 1 - 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp index 0b75f898..7b064e47 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.cpp @@ -158,6 +158,10 @@ void ProgressDlg::setPercentage(QObject* activity, const QString& step, Q_ASSERT(s); s->mPercentage = qMin( qMax(percent, 0.), 1. ) * 100.; + + if (s->mPercentage >= 100.) { + s->resultChanged(Private::ProgressWdgt::Result::Ok); + } } void ProgressDlg::closeEvent( QCloseEvent* ev ) @@ -180,16 +184,6 @@ void ProgressDlg::finished(QObject* activity) a->resultChanged(Private::ProgressWdgt::Result::Ok); } -void ProgressDlg::finished(QObject* activity, const QString& step) -{ - Private::ProgressWdgt* s = findStep(activity, step); - Q_ASSERT(s); - - s->mActive = false; - s->mPercentage = 100.; - s->resultChanged(Private::ProgressWdgt::Result::Ok); -} - void ProgressDlg::setError(QObject* activity, const QString& message) { Private::ProgressWdgt* a = mActivities[activity]; diff --git a/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp b/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp index 12d3c9f0..ab672960 100644 --- a/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp +++ b/Libs/libMacGitverCore/Widgets/ProgressDlg.hpp @@ -49,7 +49,6 @@ class MGV_CORE_API ProgressDlg : public BlueSky::Dialog void setPercentage(QObject* activity, const QString& step, qreal percent); void finished(QObject* activity); - void finished(QObject* activity, const QString& step); void setError(QObject* activity, const QString& message); From 26762695eaa3cb01977638abb8b2127c8891fc9f Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Thu, 21 May 2015 09:35:08 +0200 Subject: [PATCH 71/75] Activities-Gui: add libActivitiesGui static library with copied ProgressDlg files --- Libs/CMakeLists.txt | 1 + Libs/libActivitiesGui/CMakeLists.txt | 56 ++++++ Libs/libActivitiesGui/ProgressDlg.cpp | 254 ++++++++++++++++++++++++++ Libs/libActivitiesGui/ProgressDlg.hpp | 87 +++++++++ Libs/libActivitiesGui/ProgressDlg.ui | 116 ++++++++++++ Libs/libActivitiesGui/ProgressWdgt.ui | 35 ++++ 6 files changed, 549 insertions(+) create mode 100644 Libs/libActivitiesGui/CMakeLists.txt create mode 100644 Libs/libActivitiesGui/ProgressDlg.cpp create mode 100644 Libs/libActivitiesGui/ProgressDlg.hpp create mode 100644 Libs/libActivitiesGui/ProgressDlg.ui create mode 100644 Libs/libActivitiesGui/ProgressWdgt.ui diff --git a/Libs/CMakeLists.txt b/Libs/CMakeLists.txt index 215a80c8..5c9202b9 100644 --- a/Libs/CMakeLists.txt +++ b/Libs/CMakeLists.txt @@ -10,6 +10,7 @@ INCLUDE_DIRECTORIES( BEFORE ${MACGITVER_LIBS_SOURCE_DIR} ) +ADD_SUBDIRECTORY(libActivitiesGui) ADD_SUBDIRECTORY(libLogger) ADD_SUBDIRECTORY(libActivities) ADD_SUBDIRECTORY(libDiffViews) diff --git a/Libs/libActivitiesGui/CMakeLists.txt b/Libs/libActivitiesGui/CMakeLists.txt new file mode 100644 index 00000000..5954c2ac --- /dev/null +++ b/Libs/libActivitiesGui/CMakeLists.txt @@ -0,0 +1,56 @@ + +PROJECT(ACTIVITIES_GUI) + +QT_PREPARE(Core Widgets) + +INCLUDE_DIRECTORIES( + ${ACTIVITIES_GUI_BINARY_DIR} +) + +SET( SRC_FILES + ProgressDlg.cpp +) + +SET( PUB_HDR_FILES + ProgressDlg.hpp +) + +SET( PRI_HDR_FILES +) + +SET( UI_FILES + ProgressDlg.ui + ProgressWdgt.ui +) + +SET( HDR_FILES ${PRI_HDR_FILES} ${PUB_HDR_FILES} ) + +QT_UIC( UIC_FILES ${UI_FILES} ) +QT_MOC( MOC_FILES ${HDR_FILES} ) + +ADD_QT_LIBRARY( + ActivitiesGui SHARED + + ${SRC_FILES} + ${HDR_FILES} + ${UIC_FILES} + ${MOC_FILES} +) + +TARGET_LINK_LIBRARIES( + ActivitiesGui +) + +IF(UNIX AND NOT APPLE) + SET_TARGET_PROPERTIES( + ActivitiesGui + PROPERTIES INSTALL_RPATH + "\$ORIGIN" + ) +ENDIF() + +RAD_DEFINE_VERSION(ACTIVITIES_GUI 0 0 1) +RAD_SET_TARGET_VERSION(ActivitiesGui ACTIVITIES_GUI) +RAD_INSTALL_LIBRARY (ActivitiesGui ActivitiesGui) +RAD_INSTALL_HEADERS (libActivitiesGui ${PUB_HDR_FILES}) +RAD_SPLIT_SOURCE_TREE (libActivitiesGui) diff --git a/Libs/libActivitiesGui/ProgressDlg.cpp b/Libs/libActivitiesGui/ProgressDlg.cpp new file mode 100644 index 00000000..7b064e47 --- /dev/null +++ b/Libs/libActivitiesGui/ProgressDlg.cpp @@ -0,0 +1,254 @@ + +#include "ProgressDlg.hpp" +#include "ui_ProgressDlg.h" +#include "ui_ProgressWdgt.h" + +#include +#include +#include + +namespace Private +{ + + class ProgressWdgt : public QWidget, public Ui::ProgressWdgt + { + public: + enum class Result { Undefined = 0, Ok, Error }; + + typedef QMap< QString, QPointer > Steps; + + public: + ProgressWdgt(const QString& description) + : mActive(true) + , mPercentage(0.) + { + setupUi(this); + setAttribute(Qt::WA_NoSystemBackground); + resultChanged(Result::Undefined); + progressBar->setMinimum(0); + progressBar->setMaximum(100); + txtHeader->setText( description ); + } + + public: + void resultChanged(Result result) + { + QColor barColor; + + switch (result) { + case Result::Ok: + barColor = QColor(0x55, 0xFF, 0x55); + break; + + case Result::Error: + barColor = QColor(0xFF, 0x55, 0x55); + break; + + case Result::Undefined: + default: + barColor = QColor(0x99, 0x99, 0x99); + break; + } + + progressBar->setStyleSheet( + QStringLiteral( + "QProgressBar{" + "text-align: center;" + "border: 2px solid silver;" + "border-radius: 5px;" + "background: QLinearGradient(" + "x1: 0, y1: 0, x2: 0, y2: 1," + "stop: 0 %1," + "stop: 1 %2);" + "}") + .arg(barColor.darker(150).name()).arg(barColor.name()) % + + QStringLiteral( + "QProgressBar::chunk{" + "background: QLinearGradient(" + "x1: 0, y1: 0, x2: 0, y2: 1," + "stop: 0 %1," + "stop: 1 %2);" + "}") + .arg(barColor.lighter(150).name()).arg(barColor.name()) + ); + } + + public: + bool mActive; + qreal mPercentage; + + Steps mSteps; + }; + +} + + +ProgressDlg::ProgressDlg() + : BlueSky::Dialog() + , ui( new Ui::ProgressDlg ) + , mDone( false ) +{ + ui->setupUi( this ); + + QPushButton* close = ui->buttonBox->button(QDialogButtonBox::Close); + close->setEnabled( false ); + connect(close, &QPushButton::clicked, this, &ProgressDlg::close); + + connect(&mUpdater, &QTimer::timeout, this, &ProgressDlg::updateActivities); + mUpdater.start(250); +} + +ProgressDlg::~ProgressDlg() +{ + delete ui; +} + +int ProgressDlg::updateInterval() const +{ + return mUpdater.interval(); +} + +void ProgressDlg::setUpdateInterval(int msec) +{ + if (mUpdater.isActive()) { + // restart timer with the new interval + mUpdater.start(msec); + } + else { + mUpdater.setInterval(msec); + } +} + +void ProgressDlg::addActivity(const QString& description, QObject* activity, + const StepInfo::List& steps) +{ + Q_ASSERT(activity); + + Private::ProgressWdgt* a = new Private::ProgressWdgt(description); + mActivities[activity] = a; + + QTreeWidgetItem* activityItem(new QTreeWidgetItem); + ui->treeProgress->addTopLevelItem(activityItem); + ui->treeProgress->setItemWidget(activityItem, 0, a); + + foreach (const StepInfo& sir, steps) { + Private::ProgressWdgt* s = new Private::ProgressWdgt(sir.desc); + a->mSteps[sir.name] = s; + + QTreeWidgetItem* stepItem(new QTreeWidgetItem); + activityItem->addChild(stepItem); + ui->treeProgress->setItemWidget(stepItem, 0, s); + } +} + +void ProgressDlg::setStatusInfo(QObject* activity, const QString& step, + const QString& text) +{ + Private::ProgressWdgt* s = findStep(activity, step); + Q_ASSERT(s); + + s->progressBar->setFormat(text); +} + +void ProgressDlg::setPercentage(QObject* activity, const QString& step, + qreal percent) +{ + Private::ProgressWdgt* s = findStep(activity, step); + Q_ASSERT(s); + + s->mPercentage = qMin( qMax(percent, 0.), 1. ) * 100.; + + if (s->mPercentage >= 100.) { + s->resultChanged(Private::ProgressWdgt::Result::Ok); + } +} + +void ProgressDlg::closeEvent( QCloseEvent* ev ) +{ + if( !mDone ) + { + ev->ignore(); + return; + } + + QDialog::closeEvent( ev ); +} + +void ProgressDlg::finished(QObject* activity) +{ + Private::ProgressWdgt* a = mActivities[activity]; + Q_ASSERT(a); + + a->mActive = false; + a->resultChanged(Private::ProgressWdgt::Result::Ok); +} + +void ProgressDlg::setError(QObject* activity, const QString& message) +{ + Private::ProgressWdgt* a = mActivities[activity]; + Q_ASSERT(a); + a->mActive = false; + a->progressBar->setFormat(tr("Failed. See tool tip for details.")); + a->setToolTip(tr("Activity failed.
%1").arg(message)); + a->resultChanged(Private::ProgressWdgt::Result::Error); +} + +void ProgressDlg::updateActivities() +{ + Activities::Iterator it = mActivities.begin(); + while ( it != mActivities.end() ) { + Private::ProgressWdgt* a = *it; + Q_ASSERT(a); + + a->mPercentage = 0.; + + foreach (Private::ProgressWdgt* s, a->mSteps) { + s->progressBar->setValue(qRound(s->mPercentage)); + qreal stepPercent = s->mPercentage / a->mSteps.size(); + a->mPercentage += qMin( qMax(stepPercent, 0.), 100.); + } + + a->progressBar->setValue(qRound(a->mPercentage)); + + // remove invalid activities after updating + if (!it.key()) { + it = mActivities.erase(it); + } + else { + ++it; + } + } + + setCanClose(); +} + +void ProgressDlg::accept() +{ + if (isDone()) { + BlueSky::Dialog::accept(); + } +} + +void ProgressDlg::reject() +{ + if (isDone()) { + BlueSky::Dialog::reject(); + } +} + +Private::ProgressWdgt* ProgressDlg::findStep(QObject* activity, const QString& step) const +{ + Private::ProgressWdgt* a = mActivities[activity]; + return step.isEmpty() || !a ? nullptr : a->mSteps[step]; +} + +void ProgressDlg::setCanClose() +{ + const bool wasDone = mDone; + mDone = isDone(); + + if (mDone != wasDone) { + ui->buttonBox->button( QDialogButtonBox::Close )->setEnabled( mDone ); + } +} diff --git a/Libs/libActivitiesGui/ProgressDlg.hpp b/Libs/libActivitiesGui/ProgressDlg.hpp new file mode 100644 index 00000000..ab672960 --- /dev/null +++ b/Libs/libActivitiesGui/ProgressDlg.hpp @@ -0,0 +1,87 @@ + +#pragma once + +#include "libMacGitverCore/MacGitverApi.hpp" +#include "libBlueSky/Dialog.hpp" + +#include +#include +#include + +namespace Private +{ + class ProgressWdgt; +}; + +namespace Ui +{ + class ProgressDlg; +}; + +class MGV_CORE_API ProgressDlg : public BlueSky::Dialog +{ + Q_OBJECT + +public: + struct StepInfo + { + typedef QVector List; + + QString name; + QString desc; + }; + + typedef QMap< QPointer, QPointer > Activities; + +public: + ProgressDlg(); + ~ProgressDlg(); + +public: + int updateInterval() const; + void setUpdateInterval(int msec); + + void addActivity(const QString& description, QObject* activity, + const StepInfo::List& steps); + + void setStatusInfo(QObject* activity, const QString& step, + const QString& text); + void setPercentage(QObject* activity, const QString& step, qreal percent); + + void finished(QObject* activity); + + void setError(QObject* activity, const QString& message); + +public: + // virtual slots + void accept(); + void reject(); + +private slots: + void updateActivities(); + +protected: + void closeEvent( QCloseEvent* ev ); + +private: + Private::ProgressWdgt* findStep(QObject* activity, const QString& step) const; + + bool isDone() const; + void setCanClose(); + +private: + Ui::ProgressDlg* ui; + +private: + bool mDone; + QString mBaseLog; + QString mRawRemoteMessage; + Activities mActivities; + + QTimer mUpdater; +}; + +inline bool ProgressDlg::isDone() const +{ + return mActivities.isEmpty(); +} diff --git a/Libs/libActivitiesGui/ProgressDlg.ui b/Libs/libActivitiesGui/ProgressDlg.ui new file mode 100644 index 00000000..f5cce393 --- /dev/null +++ b/Libs/libActivitiesGui/ProgressDlg.ui @@ -0,0 +1,116 @@ + + + ProgressDlg + + + Qt::ApplicationModal + + + + 0 + 0 + 603 + 332 + + + + Progress + + + true + + + + + + Qt::Vertical + + + + + 0 + 2 + + + + QAbstractItemView::ScrollPerPixel + + + true + + + true + + + false + + + + 1 + + + + + + + 0 + 1 + + + + + 0 + 60 + + + + Details: + + + + QLayout::SetDefaultConstraint + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + + + + + + + + + QDialogButtonBox::Close + + + + + + + + diff --git a/Libs/libActivitiesGui/ProgressWdgt.ui b/Libs/libActivitiesGui/ProgressWdgt.ui new file mode 100644 index 00000000..a997fc8a --- /dev/null +++ b/Libs/libActivitiesGui/ProgressWdgt.ui @@ -0,0 +1,35 @@ + + + ProgressWdgt + + + + 0 + 0 + 448 + 62 + + + + Progress + + + + + + Progress: + + + + + + + + + + + + + + + From 70cc3c04de14bdfa0f39456e67927901817706ad Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Sat, 23 May 2015 12:34:14 +0200 Subject: [PATCH 72/75] Activities-Gui: draft implementation of ProgressItem classes --- Libs/libActivitiesGui/CMakeLists.txt | 2 + Libs/libActivitiesGui/ProgressItems.cpp | 39 ++++++++++ Libs/libActivitiesGui/ProgressItems.hpp | 95 +++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 Libs/libActivitiesGui/ProgressItems.cpp create mode 100644 Libs/libActivitiesGui/ProgressItems.hpp diff --git a/Libs/libActivitiesGui/CMakeLists.txt b/Libs/libActivitiesGui/CMakeLists.txt index 5954c2ac..e62fb61d 100644 --- a/Libs/libActivitiesGui/CMakeLists.txt +++ b/Libs/libActivitiesGui/CMakeLists.txt @@ -9,10 +9,12 @@ INCLUDE_DIRECTORIES( SET( SRC_FILES ProgressDlg.cpp + ProgressItems.cpp ) SET( PUB_HDR_FILES ProgressDlg.hpp + ProgressItems.hpp ) SET( PRI_HDR_FILES diff --git a/Libs/libActivitiesGui/ProgressItems.cpp b/Libs/libActivitiesGui/ProgressItems.cpp new file mode 100644 index 00000000..7d458264 --- /dev/null +++ b/Libs/libActivitiesGui/ProgressItems.cpp @@ -0,0 +1,39 @@ +#include "ProgressItems.hpp" + + +ProgressItem::ProgressItem(ProgressItem* parent) +{ +} + +int ProgressItem::type() const +{ + return static_cast(StaticType); +} + +QVariant ProgressItem::data(int role) const +{ + Q_UNUSED(role); + return QVariant(); +} + + +//ProgressItemService::ProgressItemService(ProgressItem* parent, +// Activities::Service* service) +// : ProgressItemObject(parent, object) +//{ + +//} + + +//ProgressItemActivity::ProgressItemActivity(ProgressItem* parent, +// Activities::Activity* activity) +// : ProgressItemObject(parent, activity) +//{ + +//} + + +//ProgressItemStep::ProgressItemStep(ProgressItem* parent, Activities::Step* step) +//{ + +//} diff --git a/Libs/libActivitiesGui/ProgressItems.hpp b/Libs/libActivitiesGui/ProgressItems.hpp new file mode 100644 index 00000000..b33044de --- /dev/null +++ b/Libs/libActivitiesGui/ProgressItems.hpp @@ -0,0 +1,95 @@ + +#pragma once + +//#include +//#include +//#include + +#include + +class ProgressItem +{ +public: + enum class Type { Base = 0, Service, Activity, Step }; + +public: + static const Type StaticType = Type::Base; + +public: + ProgressItem(ProgressItem* parent); + +public: + virtual int type() const; + + virtual QVariant data(int role) const; +}; + +template +class ProgressItemObject : public ProgressItem +{ +protected: + ProgressItemObject(ProgressItem* parent, T* object) + : ProgressItem(parent) + , mObject(object) + {} + +public: + const T* object() const { + return mObject; + } + + T* object() { + return mObject; + } + + QVariant data(int role) const { +// TODO: return the requested data fields +// if (mObject) { +// switch (role) { +// case Qt::DisplayRole: +// return mObject->description(); + +// case Qt::DecorationRole: +// Heaven::IconRef iref = mObject->icon(true); +// Heaven::Icon icon = iref.icon(); +// return icon.pixmap(); +// } +// } + + return ProgressItem::data(role); + } + +protected: + T* mObject; +}; + +//class ProgressItemService +// : public ProgressItemObject +//{ +//public: +// static const ProgressItem::Type StaticType = ProgressItem::Type::Service; + +//public: +// ProgressItemService(ProgressItem* parent, Activities::Service* service); +//}; + + +//class ProgressItemActivity +// : public ProgressItemObject +//{ +//public: +// static const ProgressItem::Type StaticType = ProgressItem::Type::Activity; + +//public: +// ProgressItemActivity(ProgressItem* parent, Activities::Activity* activity); +//}; + +//class ProgressItemStep +// : public ProgressItemObject +//{ +//public: +// static const ProgressItem::Type StaticType = ProgressItem::Type::Step; + +//public: +// ProgressItemStep(ProgressItem* parent, Activities::Step* step); +//}; From 9e5fcaa8c66002b5a0147a71deb035021fbe2763 Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Thu, 28 May 2015 13:17:38 +0200 Subject: [PATCH 73/75] ProgressDlg: added data fields to the ProgressItem --- Libs/libActivitiesGui/ProgressItems.hpp | 33 +++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/Libs/libActivitiesGui/ProgressItems.hpp b/Libs/libActivitiesGui/ProgressItems.hpp index b33044de..765524f2 100644 --- a/Libs/libActivitiesGui/ProgressItems.hpp +++ b/Libs/libActivitiesGui/ProgressItems.hpp @@ -11,6 +11,7 @@ class ProgressItem { public: enum class Type { Base = 0, Service, Activity, Step }; + enum class DisplayRole { Progress = Qt::UserRole, ProgressInfo }; public: static const Type StaticType = Type::Base; @@ -47,20 +48,48 @@ class ProgressItemObject : public ProgressItem // if (mObject) { // switch (role) { // case Qt::DisplayRole: -// return mObject->description(); +// return mObject->display(); // case Qt::DecorationRole: // Heaven::IconRef iref = mObject->icon(true); // Heaven::Icon icon = iref.icon(); // return icon.pixmap(); // } -// } + +// case ProgressItem::Progress: +// return percent(); + +// case ProgressItem::ProgressInfo: +// return percent(); + +// case Qt::ToolTipRole: +// return mObject->isDefunct() ? mObject->errorText() +// : mObject->description(); +// } return ProgressItem::data(role); } protected: T* mObject; + +private: + quint8 percent() const + { + int max = mObject->maxProgress(); + int cur = mObject->curProgress(); + + if (mObject->minProgress() < 0) { + // substract a negative minimum + max += mObject->minProgress(); + cur += mObject->minProgress(); + } + + int percent = max ? (cur / max) * 100 : 0; + Q_ASSERT(percent >= 0); + + return static_cast(percent); + } }; //class ProgressItemService From 6790840e51993f39ca6df2837e424fb5383e6fce Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Thu, 28 May 2015 13:22:22 +0200 Subject: [PATCH 74/75] ProgressDlg: add parent for each ProgressItem --- Libs/libActivitiesGui/ProgressItems.cpp | 1 + Libs/libActivitiesGui/ProgressItems.hpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Libs/libActivitiesGui/ProgressItems.cpp b/Libs/libActivitiesGui/ProgressItems.cpp index 7d458264..94cf375b 100644 --- a/Libs/libActivitiesGui/ProgressItems.cpp +++ b/Libs/libActivitiesGui/ProgressItems.cpp @@ -2,6 +2,7 @@ ProgressItem::ProgressItem(ProgressItem* parent) + : mParent(parent) { } diff --git a/Libs/libActivitiesGui/ProgressItems.hpp b/Libs/libActivitiesGui/ProgressItems.hpp index 765524f2..a2d3a255 100644 --- a/Libs/libActivitiesGui/ProgressItems.hpp +++ b/Libs/libActivitiesGui/ProgressItems.hpp @@ -23,6 +23,9 @@ class ProgressItem virtual int type() const; virtual QVariant data(int role) const; + +private: + ProgressItem* mParent; }; template From 243398d5ae1c7a5d25dfa1e2296185c5109eb50b Mon Sep 17 00:00:00 2001 From: Nils Fenner Date: Thu, 28 May 2015 13:28:11 +0200 Subject: [PATCH 75/75] ProgressDlg: add item delegate to draw the items The delegate is just a template and not done right yet. --- Libs/libActivitiesGui/ProgressDlg.cpp | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Libs/libActivitiesGui/ProgressDlg.cpp b/Libs/libActivitiesGui/ProgressDlg.cpp index 7b064e47..212610bf 100644 --- a/Libs/libActivitiesGui/ProgressDlg.cpp +++ b/Libs/libActivitiesGui/ProgressDlg.cpp @@ -3,12 +3,43 @@ #include "ui_ProgressDlg.h" #include "ui_ProgressWdgt.h" +#include "ProgressItems.hpp" + #include +#include #include #include +#include namespace Private { + class ProgressDelegate : public QStyledItemDelegate + { + public: + ProgressDelegate(QObject* parent = 0) + : QStyledItemDelegate(parent) + { + } + + void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index) const + { + // draw header text + QTextOption txtOpts; + txtOpts.setAlignment(Qt::AlignLeading); + painter->drawText(option.rect, index.data().toString(), txtOpts); + + // draw progress bar + QRect progressRect = option.rect.adjusted(10, 10, -10, -10); + painter->drawRoundedRect(progressRect, 5., 5.); + + // draw description text + QTextOption descOpts; + descOpts.setAlignment(Qt::AlignCenter); + painter->drawText(progressRect, + index.data(static_cast(ProgressItem::DisplayRole::ProgressInfo)).toString()); + } + }; class ProgressWdgt : public QWidget, public Ui::ProgressWdgt { @@ -91,6 +122,8 @@ ProgressDlg::ProgressDlg() { ui->setupUi( this ); + ui->treeProgress->setItemDelegate(new Private::ProgressDelegate); + QPushButton* close = ui->buttonBox->button(QDialogButtonBox::Close); close->setEnabled( false ); connect(close, &QPushButton::clicked, this, &ProgressDlg::close);