task: massively simplified task system
Made various changes and fixes to the task system: - Tasks are built around QtConcurrent rather than QThread. Reduces code complexity significantly. - Task error reporting is now streamlined in both TaskManager and TaskDialog. - Moved ProjectImport/Save/LoadManager to the app/task folder
This commit is contained in:
+32
-5
@@ -30,23 +30,50 @@ class TaskDialog : public ProgressDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief TaskDialog Constructor
|
||||
*
|
||||
* Creates a TaskDialog. The TaskDialog takes ownership of the Task and will destroy it on close.
|
||||
* Connect to the Task::Succeeded() if you want to retrieve information from the task before it
|
||||
* gets destroyed.
|
||||
*/
|
||||
TaskDialog(Task *task, const QString &title, QWidget* parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Set whether TaskDialog should destroy itself (and the task) when it's closed
|
||||
*
|
||||
* This is TRUE by default.
|
||||
*/
|
||||
void SetDestroyOnClose(bool e)
|
||||
{
|
||||
destroy_on_close_ = e;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns this dialog's task
|
||||
*/
|
||||
Task* GetTask() const
|
||||
{
|
||||
return task_;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent* e) override;
|
||||
|
||||
virtual void closeEvent(QCloseEvent* e) override;
|
||||
|
||||
signals:
|
||||
void TaskSucceeded(Task* task);
|
||||
|
||||
void TaskFailed(Task* task);
|
||||
|
||||
private:
|
||||
Task* task_;
|
||||
|
||||
QThread* thread_;
|
||||
|
||||
bool task_failed_;
|
||||
QString task_error_;
|
||||
bool destroy_on_close_;
|
||||
|
||||
private slots:
|
||||
void TaskFailed(const QString& s);
|
||||
void TaskFinished();
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user