VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/globals/UIProgressObject.h

Last change on this file was 98103, checked in by vboxsync, 17 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
RevLine 
[55401]1/* $Id: UIProgressObject.h 98103 2023-01-17 14:15:46Z vboxsync $ */
[25178]2/** @file
[86772]3 * VBox Qt GUI - UIProgressObject class declaration.
[25178]4 */
5
6/*
[98103]7 * Copyright (C) 2009-2023 Oracle and/or its affiliates.
[25178]8 *
[96407]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
[25178]26 */
27
[86772]28#ifndef FEQT_INCLUDED_SRC_globals_UIProgressObject_h
29#define FEQT_INCLUDED_SRC_globals_UIProgressObject_h
[76532]30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
[25178]33
[86772]34/* Qt includes: */
35#include <QEventLoop>
36#include <QObject>
37#include <QPointer>
38
[43857]39/* GUI includes: */
[71630]40#include "UILibraryDefs.h"
[25178]41
[41587]42/* Forward declarations: */
[69006]43class UIProgressEventHandler;
[41587]44class CProgress;
[25178]45
[55277]46/** QObject reimplementation allowing to effectively track the CProgress object completion
47 * (w/o using CProgress::waitForCompletion() and w/o blocking the calling thread in any other way for too long).
48 * @note The CProgress instance is passed as a non-const reference to the constructor
49 * (to memorize COM errors if they happen), and therefore must not be destroyed
[86772]50 * before the created UIProgressObject instance is destroyed. */
51class SHARED_LIBRARY_STUFF UIProgressObject : public QObject
[55277]52{
53 Q_OBJECT;
54
55signals:
56
57 /** Notifies listeners about wrapped CProgress change.
[68998]58 * @param iOperations Brings the number of operations CProgress have.
59 * @param strOperation Brings the description of the current CProgress operation.
60 * @param iOperation Brings the index of the current CProgress operation.
61 * @param iPercent Brings the percentage of the current CProgress operation. */
[55277]62 void sigProgressChange(ulong iOperations, QString strOperation,
63 ulong iOperation, ulong iPercent);
64
[55305]65 /** Notifies listeners about particular COM error.
66 * @param strErrorInfo holds the details of the error happened. */
67 void sigProgressError(QString strErrorInfo);
68
[86206]69 /** Notifies listeners about wrapped CProgress complete. */
70 void sigProgressComplete();
71
[86325]72 /** Notifies listeners about CProgress event handling finished. */
73 void sigProgressEventHandlingFinished();
74
[55277]75public:
76
[86772]77 /** Constructs progress-object passing @a pParent to the base-class.
[69000]78 * @param comProgress Brings the progress reference. */
[86772]79 UIProgressObject(CProgress &comProgress, QObject *pParent = 0);
[86161]80 /** Destructs progress handler. */
[93990]81 virtual ~UIProgressObject() RT_OVERRIDE;
[55277]82
[90253]83 /** Returns whether progress is cancelable. */
84 bool isCancelable() const { return m_fCancelable; }
85
[86205]86 /** Executes the progress within local event-loop. */
87 void exec();
[86206]88 /** Cancels the progress within local event-loop. */
89 void cancel();
[55277]90
[86161]91private slots:
92
93 /** Handles percentage changed event for progress with @a uProgressId to @a iPercent. */
94 void sltHandleProgressPercentageChange(const QUuid &uProgressId, const int iPercent);
95 /** Handles task completed event for progress with @a uProgressId. */
96 void sltHandleProgressTaskComplete(const QUuid &uProgressId);
97
[55277]98private:
99
[86161]100 /** Prepares all. */
101 void prepare();
102 /** Cleanups all. */
103 void cleanup();
[55277]104
[68998]105 /** Holds the progress reference. */
[68999]106 CProgress &m_comProgress;
[55277]107
[90253]108 /** Holds whether progress is cancelable. */
109 bool m_fCancelable;
110
[86161]111 /** Holds the progress event handler instance. */
112 UIProgressEventHandler *m_pEventHandler;
113
[86205]114 /** Holds the exec event-loop instance. */
115 QPointer<QEventLoop> m_pEventLoopExec;
[86206]116 /** Holds the cancel event-loop instance. */
117 QPointer<QEventLoop> m_pEventLoopCancel;
[55277]118};
119
[86772]120#endif /* !FEQT_INCLUDED_SRC_globals_UIProgressObject_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use