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:
itsmattkc
2020-05-19 02:44:32 +10:00
parent c4b0a53174
commit b9cd83eff1
49 changed files with 864 additions and 1332 deletions
+14 -1
View File
@@ -46,7 +46,20 @@ TaskView::TaskView(QWidget* parent) :
void TaskView::AddTask(Task *t)
{
// Create TaskViewItem (UI representation of a Task) and connect it
layout_->insertWidget(layout_->count()-1, new TaskViewItem(t));
TaskViewItem* item = new TaskViewItem(t);
items_.insert(t, item);
layout_->insertWidget(layout_->count()-1, item);
}
void TaskView::TaskFailed(Task *t)
{
items_.value(t)->Failed();
}
void TaskView::RemoveTask(Task *t)
{
items_.value(t)->deleteLater();
items_.remove(t);
}
OLIVE_NAMESPACE_EXIT
+8
View File
@@ -50,9 +50,17 @@ public slots:
*/
void AddTask(Task* t);
void TaskFailed(Task* t);
void RemoveTask(Task* t);
private:
QWidget* central_widget_;
QVBoxLayout* layout_;
QHash<Task*, TaskViewItem*> items_;
};
OLIVE_NAMESPACE_EXIT
+5 -1
View File
@@ -61,8 +61,12 @@ TaskViewItem::TaskViewItem(Task* task, QWidget *parent) :
// Connect to the task
connect(task_, &Task::ProgressChanged, progress_bar_, &QProgressBar::setValue);
connect(task_, &Task::Removed, this, &TaskViewItem::deleteLater);
connect(cancel_btn_, &QPushButton::clicked, task_, &Task::Cancel, Qt::DirectConnection);
}
void TaskViewItem::Failed()
{
task_status_lbl_->setText(task_->GetError());
}
OLIVE_NAMESPACE_EXIT
+2
View File
@@ -45,6 +45,8 @@ class TaskViewItem : public QFrame
public:
TaskViewItem(Task *task, QWidget* parent = nullptr);
void Failed();
private:
QLabel* task_name_lbl_;
QProgressBar* progress_bar_;