Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Centralized progress dialog #35

Open
wants to merge 75 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
3391236
Remove useless RepoMan tests
scunz May 10, 2015
4cb1466
Remove signals from RM::Repo
scunz Mar 22, 2015
66ff7eb
Remove 'open' logic'
scunz May 10, 2015
359c33d
Make the RM::Repo's Git::Repository member private
scunz Mar 22, 2015
2a84e82
Keep instance pointer to RepoMan inside itself
scunz May 9, 2015
f57c961
Move AutoRefresher out of RM-namespace
scunz May 10, 2015
1af99a0
Make AutoRefresher internal
scunz Mar 22, 2015
e722ebe
Move refresher instance into MacGitver
scunz Apr 17, 2015
1ad1e9c
Change RepoMan's "Set" to "List" everywhere
scunz Mar 22, 2015
77517e6
Move RepoMan Config Page to Config-Area
scunz May 10, 2015
97a29e7
Move some RepoMan code around
scunz Mar 21, 2015
9ff3da1
Turn RM::ObjType into an Enum Class
scunz May 11, 2015
d16922c
Move BasePrivate to own .cpp file
scunz May 11, 2015
fa24fc0
Be explicit about namespace of Dumper class
scunz May 12, 2015
eff4d8d
Move Branch & Head Private's to own cpp
scunz May 12, 2015
b1022f3
Temporary code
scunz Apr 21, 2015
43dc7ea
Fixup to "Temporary Code" :(
scunz May 10, 2015
9a902ce
Adjustments
scunz May 11, 2015
4a4afc4
Split off RepoMan & make everything compile at least
scunz Apr 11, 2015
87d4364
Repoman Events
scunz Apr 19, 2015
f9d4801
Fix some Compat-Event compile issues
scunz Apr 19, 2015
6ecc29c
Logging Channel for Git
scunz Apr 21, 2015
c635fcc
Add Service Runner into the backend
scunz May 9, 2015
b6fb03a
Add: OpenRepository Service
scunz May 9, 2015
0fa9c3e
Invoke OpenRepository service
scunz May 10, 2015
63d17bc
Add: RefreshRepository Service
scunz May 9, 2015
da0ed09
Add: refresh() method to RepoMan
scunz May 10, 2015
bf7ceff
Core files for libActivities
scunz Apr 26, 2015
431e98b
Snapshot of a mostly complete Activities interface
scunz May 8, 2015
33f1e00
Should fix Linux build
scunz May 9, 2015
226c351
Fixup: Remove unused code
scunz May 10, 2015
6aa8e7c
Step creation
scunz May 10, 2015
e2dd1ed
Fixup: Remove deadlock
scunz May 10, 2015
c3ef9d8
Actually implement state getters in Activity
scunz May 10, 2015
3a7d25f
Fixup: "return {}" to avoid naming the constructor
scunz May 10, 2015
5bf8aee
Public method to request opening of Progress Dialog
scunz May 10, 2015
9ded4fd
Fixup: Inline comment (Manager Priv.hpp)
scunz May 10, 2015
948f8e9
Activities: use Q_ASSERT instead of assert (fix build on linux)
antis81 May 12, 2015
ee2797c
RepoMan: use Q_ASSERT instead of assert (fix build on linux)
antis81 May 12, 2015
bf08429
RepoMan: fix include pathes for case sensitive file systems
antis81 May 12, 2015
892d60b
RepoMan: fix missing include
antis81 May 12, 2015
6c64958
copied progress dialog from "Repository" module (ProgressDlg) to libM…
antis81 Apr 25, 2015
02ec756
add ProgressWdgt, preparing for unified progress dialog
antis81 Apr 21, 2015
6825854
redesign ProgressDlg to visualize the progress of multiple activities
antis81 Apr 25, 2015
a5dd49a
use assignment operator instead of copy c'tor
antis81 Apr 25, 2015
76c2e16
restart timer when active while changing the interval
antis81 Apr 25, 2015
c10097c
set text according to state of progress (running/finished)
antis81 Apr 25, 2015
44a8364
removed obsolete method ProgressDlg::remoteMessage
antis81 Apr 25, 2015
008c9a0
minor cleanup in ProgressDlg
antis81 Apr 27, 2015
6065717
ProgressDlg: moved initializers back to c'tor
antis81 Apr 27, 2015
5d3995f
ProgressDlg: removed customized palette for log view
antis81 Apr 27, 2015
2152781
ProgressDlg: minor cleanup
antis81 Apr 27, 2015
5a1bc44
ProgressDlg: add methods isDone() and setCanClose()
antis81 Apr 27, 2015
b026b9e
ProgressDlg: move asserts
antis81 Apr 27, 2015
0aed968
ProgressDlg: remove invalid activities from progress updating
antis81 Apr 27, 2015
d6a6c8f
add ProgressDlg::setError()
antis81 Apr 27, 2015
294c2f2
ProgressDlg: prevent accept() or reject() before activities are finished
antis81 Apr 27, 2015
2627e42
PrgressDlg: frequently update close buttons
antis81 Apr 27, 2015
dc05e54
ProgressDlg: set step percentage to 100% when finished
antis81 Apr 27, 2015
eb6eac1
ProgressDlg: mark finished and error state of an activity by coloring…
antis81 Apr 27, 2015
825d4e8
ProgressDlg: fixed erase activities
antis81 Apr 27, 2015
c865406
ProgressDlg: make internal progress widgets use the cells background …
antis81 May 1, 2015
444f107
ProgressDlg: a progress widget has no "running" state; an "active" fl…
antis81 May 1, 2015
7ab5ac7
ProgressDlg: refine the appearance of progress bars by using the acti…
antis81 May 1, 2015
df89eb2
ProgressDlg: add an assert, because currently the activity widget *mu…
antis81 May 7, 2015
7e13dfb
ProgressDlg: inline the info text in the progress bar
antis81 May 8, 2015
26cc7fa
ProgressDlg: use C++11 enum class
antis81 May 8, 2015
a996865
ProgressDlg: remove "running" and "finished" text
antis81 May 8, 2015
6aea9a2
ProgressDlg: add a more descriptive "failed" text
antis81 May 8, 2015
75433fe
ProgressDlg: only the activity has a finished slot
antis81 May 8, 2015
2676269
Activities-Gui: add libActivitiesGui static library with copied Progr…
antis81 May 21, 2015
70cc3c0
Activities-Gui: draft implementation of ProgressItem classes
antis81 May 23, 2015
9e5fcaa
ProgressDlg: added data fields to the ProgressItem
antis81 May 28, 2015
6790840
ProgressDlg: add parent for each ProgressItem
antis81 May 28, 2015
243398d
ProgressDlg: add item delegate to draw the items
antis81 May 28, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions Libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ INCLUDE_DIRECTORIES( BEFORE
${MACGITVER_LIBS_SOURCE_DIR}
)

ADD_SUBDIRECTORY(libActivitiesGui)
ADD_SUBDIRECTORY(libLogger)
ADD_SUBDIRECTORY(libActivities)
ADD_SUBDIRECTORY(libDiffViews)
ADD_SUBDIRECTORY(libRepoMan)
ADD_SUBDIRECTORY(libMacGitverCore)

259 changes: 259 additions & 0 deletions Libs/libActivities/Activity.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
/*
* MacGitver
* Copyright (C) 2012-2015 The MacGitver-Developers <[email protected]>
*
* (C) Sascha Cunz <[email protected]>
* (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 <http://www.gnu.org/licenses/>.
*
*/

#include "libActivities/Activity.hpp"
#include "libActivities/ActivityPrivate.hpp"
#include "libActivities/StepPrivate.hpp"
#include "libActivities/ManagerPrivate.hpp"

namespace Activities
{

namespace
{
void countTypes(const std::vector<StepData::Ptr>& 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<StepData::Ptr>& 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;
}

Q_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<std::mutex> ActivityData::uniqueLock() const
{
return std::unique_lock<std::mutex>(mMtx);
}

bool ActivityData::isDefunct() const
{
std::lock_guard<std::mutex> _(mMtx);
return mIsDefunct;
}

void ActivityData::updated(const StepData::Ptr& step, std::unique_lock<std::mutex>& lock)
{
mTotalCurProgress = mCurProgress;
mTotalMaxProgress = mMaxProgress;

for (StepData::Ptr step : mSteps) {

}
}

void ActivityData::stepStarted(const StepData::Ptr& step, std::unique_lock<std::mutex> &lock)
{
State newState = activityState(mSteps);
}

void ActivityData::stepFinished(const StepData::Ptr& step, bool failed, std::unique_lock<std::mutex> &lock)
{
State newState = activityState(mSteps);
}

void ActivityData::logUpdated(const LogData::Ptr &log, std::unique_lock<std::mutex> &lock)
{

}

bool ActivityData::isModalityRequired() const
{
return mForceModalDialog;
}

// -----

Step::Vector Activity::steps() const
{
Step::Vector r;
if (d) {
std::lock_guard<std::mutex> _(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<std::mutex> _(d->mMtx);
return {d->mLog};
}
return {};
}

State Activity::state() const
{
if (d) {
std::lock_guard<std::mutex> _(d->mMtx);
return d->mState;
}

return State::Unknown;
}

QString Activity::display() const
{
if (d) {
std::lock_guard<std::mutex> _(d->mMtx);
return d->mDisplay;
}

return {};
}

int Activity::curProgress() const
{
if (d) {
std::lock_guard<std::mutex> _(d->mMtx);
return d->mTotalCurProgress;
}

return 0;
}

int Activity::maxProgress() const
{
if (d) {
std::lock_guard<std::mutex> _(d->mMtx);
return d->mTotalMaxProgress;
}

return 0;
}

int Activity::curOwnProgress() const
{
if (d) {
std::lock_guard<std::mutex> _(d->mMtx);
return d->mCurProgress;
}

return 0;
}

int Activity::maxOwnProgress() const
{
if (d) {
std::lock_guard<std::mutex> _(d->mMtx);
return d->mMaxProgress;
}

return 0;
}

Step Activity::createStep(const QString& displayName)
{
if (d) {
std::lock_guard<std::mutex> _(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 {};
}

}
68 changes: 68 additions & 0 deletions Libs/libActivities/Activity.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* MacGitver
* Copyright (C) 2012-2015 The MacGitver-Developers <[email protected]>
*
* (C) Sascha Cunz <[email protected]>
* (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 <http://www.gnu.org/licenses/>.
*
*/

#pragma once

#include "libActivities/Step.hpp"
#include "libActivities/Log.hpp"

namespace Activities
{

class ActivityData;

class ACTIVITIES_API Activity
{
public:
using Vector = std::vector<Activity>;

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<ActivityData>& o) : d(o) {}
Activity(std::shared_ptr<ActivityData>&& o) : d(std::move(o)) {}

public:
Step::Vector steps() const;
Step createStep(const QString& displayName);

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<ActivityData> d;
};

}
Loading