VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIProgressTask.h@ 96430

Last change on this file since 96430 was 96407, checked in by vboxsync, 22 months ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1/* $Id: UIProgressTask.h 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIProgressTask class declaration.
4 */
5
6/*
7 * Copyright (C) 2020-2022 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef FEQT_INCLUDED_SRC_globals_UIProgressTask_h
29#define FEQT_INCLUDED_SRC_globals_UIProgressTask_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35#include <QObject>
36#include <QPointer>
37
38/* GUI includes: */
39#include "UILibraryDefs.h"
40#include "UIProgressObject.h"
41
42/* COM includes: */
43#include "CProgress.h"
44
45/* Forward declarations: */
46class QTimer;
47
48/** QObject-based interface allowing to plan UIProgressObject-based tasks
49 * to be seamlessly and asynchronously scheduled (in time) and executed. */
50class SHARED_LIBRARY_STUFF UIProgressTask : public QObject
51{
52 Q_OBJECT;
53
54signals:
55
56 /** Notifies listeners about progress has started. */
57 void sigProgressStarted();
58 /** Notifies listeners about progress has changed.
59 * @param uPercent Brings the progress percentage. */
60 void sigProgressChange(ulong uPercent);
61 /** Notifies listeners about progress has finished. */
62 void sigProgressFinished();
63
64public:
65
66 /** Creates progress task passing @a pParent to the base-class. */
67 UIProgressTask(QObject *pParent);
68 /** Creates progress task passing @a pParent to the base-class. */
69 virtual ~UIProgressTask() RT_OVERRIDE;
70
71 /** Returns whether task is scheduled. */
72 bool isScheduled() const;
73
74 /** Returns whether task is running. */
75 bool isRunning() const;
76
77 /** Returns whether task is cancelable. */
78 bool isCancelable() const;
79
80public slots:
81
82 /** Schedules task to be executed in @a iMsec. */
83 void schedule(int iMsec);
84
85 /** Starts the task directly.
86 * @note It will also be started automatically if scheduled. */
87 void start();
88 /** Cancels the task directly. */
89 void cancel();
90
91protected:
92
93 /** Creates and returns started progress-wrapper required to init UIProgressObject. */
94 virtual CProgress createProgress() = 0;
95 /** Allows sub-class to handle finished @a comProgress wrapper. */
96 virtual void handleProgressFinished(CProgress &comProgress) = 0;
97
98private slots:
99
100 /** Handles progress change.
101 * @param iOperations Brings the number of operations CProgress have.
102 * @param strOperation Brings the description of the current CProgress operation.
103 * @param iOperation Brings the index of the current CProgress operation.
104 * @param iPercent Brings the percentage of the current CProgress operation. */
105 void sltHandleProgressChange(ulong uOperations, QString strOperation,
106 ulong uOperation, ulong uPercent);
107 /** Handles progress event handling finished signal. */
108 void sltHandleProgressEventHandlingFinished();
109
110private:
111
112 /** Prepares all. */
113 void prepare();
114 /** Cleanups all. */
115 void cleanup();
116
117 /** Holds the schedule timer instance. */
118 QTimer *m_pTimer;
119 /** Holds the progress-wrapper instance. */
120 CProgress m_comProgress;
121 /** Holds the progress-object instance. */
122 QPointer<UIProgressObject> m_pProgressObject;
123};
124
125#endif /* !FEQT_INCLUDED_SRC_globals_UIProgressTask_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use