2012-06-26 09:10:41 -05:00
|
|
|
//##################################################################################################
|
|
|
|
//
|
|
|
|
// Custom Visualization Core library
|
2013-09-20 08:22:29 -05:00
|
|
|
// Copyright (C) 2011-2013 Ceetron AS
|
|
|
|
//
|
|
|
|
// This library may be used under the terms of either the GNU General Public License or
|
|
|
|
// the GNU Lesser General Public License as follows:
|
|
|
|
//
|
|
|
|
// GNU General Public License Usage
|
|
|
|
// This library is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library 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 at <<http://www.gnu.org/licenses/gpl.html>>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
// GNU Lesser General Public License Usage
|
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2.1 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
|
|
|
// for more details.
|
2012-06-26 09:10:41 -05:00
|
|
|
//
|
|
|
|
//##################################################################################################
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2013-01-24 07:08:56 -06:00
|
|
|
#include <cstddef>
|
|
|
|
|
2024-08-14 09:54:41 -05:00
|
|
|
#include <atomic>
|
|
|
|
|
2012-06-26 09:10:41 -05:00
|
|
|
class QString;
|
|
|
|
|
2020-06-19 00:53:59 -05:00
|
|
|
namespace caf
|
|
|
|
{
|
2019-03-12 05:01:49 -05:00
|
|
|
class ProgressInfo;
|
|
|
|
|
|
|
|
class ProgressTask
|
|
|
|
{
|
|
|
|
public:
|
2020-06-19 00:53:59 -05:00
|
|
|
ProgressTask( ProgressInfo& parentTask );
|
2019-03-12 05:01:49 -05:00
|
|
|
~ProgressTask();
|
2020-06-19 00:53:59 -05:00
|
|
|
|
2019-03-12 05:01:49 -05:00
|
|
|
private:
|
|
|
|
ProgressInfo& m_parentTask;
|
|
|
|
};
|
|
|
|
|
2012-06-26 09:10:41 -05:00
|
|
|
class ProgressInfo
|
|
|
|
{
|
|
|
|
public:
|
2024-09-10 01:18:37 -05:00
|
|
|
ProgressInfo( size_t maxProgressValue, const QString& title, bool delayShowingProgress = true, bool allowCancel = false );
|
2012-06-26 09:10:41 -05:00
|
|
|
|
|
|
|
~ProgressInfo();
|
2020-06-19 00:53:59 -05:00
|
|
|
void setProgressDescription( const QString& description );
|
|
|
|
void setProgress( size_t progressValue );
|
2012-09-11 02:22:36 -05:00
|
|
|
void incrementProgress();
|
2020-06-19 00:53:59 -05:00
|
|
|
void setNextProgressIncrement( size_t nextStepSize );
|
2024-08-14 09:54:41 -05:00
|
|
|
void cancel();
|
|
|
|
bool isCancelled() const;
|
2012-09-11 02:22:36 -05:00
|
|
|
|
2020-06-19 00:53:59 -05:00
|
|
|
ProgressTask task( const QString& description, int stepSize = 1 );
|
2024-08-14 09:54:41 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::atomic<bool> m_isCancelled;
|
2012-06-26 09:10:41 -05:00
|
|
|
};
|
|
|
|
|
2024-09-11 04:01:25 -05:00
|
|
|
// This class is used to block the processing of events while a progress info dialog is shown. This is required when the
|
|
|
|
// progress info dialog is shown from a non-GUI thread.
|
|
|
|
class ProgressInfoEventProcessingBlocker
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ProgressInfoEventProcessingBlocker();
|
|
|
|
~ProgressInfoEventProcessingBlocker();
|
|
|
|
};
|
|
|
|
|
2019-03-22 07:16:42 -05:00
|
|
|
class ProgressInfoBlocker
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ProgressInfoBlocker();
|
|
|
|
~ProgressInfoBlocker();
|
|
|
|
};
|
2012-06-26 09:10:41 -05:00
|
|
|
|
2020-06-19 00:53:59 -05:00
|
|
|
class ProgressInfoStatic
|
2012-06-26 09:10:41 -05:00
|
|
|
{
|
|
|
|
public:
|
2024-08-14 09:54:41 -05:00
|
|
|
static void start( ProgressInfo& progressInfo,
|
|
|
|
size_t maxProgressValue,
|
|
|
|
const QString& title,
|
|
|
|
bool delayShowingProgress,
|
2024-09-11 04:01:25 -05:00
|
|
|
bool allowCancel );
|
2012-06-26 09:10:41 -05:00
|
|
|
|
2020-06-19 00:53:59 -05:00
|
|
|
static void setProgressDescription( const QString& description );
|
|
|
|
static void setProgress( size_t progressValue );
|
2012-09-11 02:22:36 -05:00
|
|
|
static void incrementProgress();
|
2020-06-19 00:53:59 -05:00
|
|
|
static void setNextProgressIncrement( size_t nextStepSize );
|
2019-05-20 06:21:02 -05:00
|
|
|
static bool isRunning();
|
2012-06-26 09:10:41 -05:00
|
|
|
static void finished();
|
2020-06-19 00:53:59 -05:00
|
|
|
static void setEnabled( bool enable );
|
2019-03-22 07:16:42 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
static bool isUpdatePossible();
|
2020-06-19 00:53:59 -05:00
|
|
|
|
2019-03-22 07:16:42 -05:00
|
|
|
private:
|
|
|
|
friend class ProgressInfoBlocker;
|
2024-09-11 04:01:25 -05:00
|
|
|
friend class ProgressInfoEventProcessingBlocker;
|
2019-05-20 06:21:02 -05:00
|
|
|
static bool s_running;
|
2019-03-22 07:16:42 -05:00
|
|
|
static bool s_disabled;
|
2024-08-14 09:54:41 -05:00
|
|
|
static bool s_isButtonConnected;
|
2024-09-11 04:01:25 -05:00
|
|
|
static bool s_shouldProcessEvents;
|
2012-06-26 09:10:41 -05:00
|
|
|
};
|
|
|
|
|
2020-06-19 00:53:59 -05:00
|
|
|
} // namespace caf
|