Learn Environment
subtask_item.hpp
Go to the documentation of this file.
1 #ifndef SUBTASK_ITEM_HPP
2 #define SUBTASK_ITEM_HPP
3 
4 #include "common/task.hpp"
6 #include "ui/execute_frame.hpp"
7 #include "ui/toast.hpp"
8 
9 #include <QWidget>
10 #include <QPushButton>
11 #include <QToolButton>
12 #include <QLabel>
13 #include <QHBoxLayout>
14 #include <QVBoxLayout>
15 
25 class SubtaskItem : public QWidget {
26  Q_OBJECT
27 
28 public:
34  SubtaskItem(QWidget *parent, Subtask *subtask);
35 
39  void updateUI(bool constructorCall = false);
40 
45  void setTaskManager(TaskManager *manager);
46 
47 Q_SIGNALS:
52  void subtaskStartStopRequested(const Subtask &subtask);
53 
54 private Q_SLOTS:
58  void handleStartButtonClick();
59  void handleHelpButtonClick();
60  void handleStartOwnScript();
61  void handleStartSolution();
62  void handleToggleSolution();
63  void handleResetNotebook();
64 
65 protected:
66  void resizeEvent(QResizeEvent* event) override;
67 
68 private:
75  void setupItemUI(const QString &headerText, const QString &linkText, const QString &bodyText);
76  void initializeHelpMenu();
77  void initializeStartMenu();
78  void setExecutionFrame(const QString& imagePath, const QString& text);
79  void showToast(const QString &message);
80 
81  TaskManager *taskManager;
82  Subtask *subtask;
83  QString headerText;
84  QString linkText;
85  QString bodyText;
86  QToolButton *startButton;
87  QToolButton *helpButton;
88  QVBoxLayout *baseLayout;
89  ExecuteFrame *executeSubtaskFrame;
90 
91  QPushButton *menuStartOwnBtn;
92  QPushButton *menuStartSolutionBtn;
93 
94  QPushButton *menuToggleSolutionBtn;
95  QPushButton *menuResetNotebookBtn;
96 
97  QMenu *startMenu;
98  QMenu *helpMenu;
99 
100  Toast *toast;
101 };
102 
103 #endif // SUBTASK_ITEM_HPP
NotebookConverter
A class for converting Jupyter notebooks to Python scripts and processing task pools.
Definition: notebook_converter.hpp:23
task.hpp
SubtaskItem::resizeEvent
void resizeEvent(QResizeEvent *event) override
Definition: subtask_item.cpp:80
TaskManager
Manages tasks and their execution within the application.
Definition: task_manager.hpp:20
Subtask::status
SubtaskStatus status
The status of the subtask.
Definition: task.hpp:46
SubtaskStatus::Queued
@ Queued
The subtask is queued for execution.
NotebookConverter::hasSolutionCells
static bool hasSolutionCells(const QString &notebookPath)
Checks if the notebook contains any solution cells.
Definition: notebook_converter.cpp:428
Subtask::lastExecutionError
QString lastExecutionError
The error message from the last execution of the subtask.
Definition: task.hpp:50
SubtaskStatus::Running
@ Running
The subtask is currently being executed.
toast.hpp
Subtask::solutionFilePath
QString solutionFilePath
The file path to the solution of the subtask.
Definition: task.hpp:36
subtask_item.hpp
QWidget
SubtaskItem::SubtaskItem
SubtaskItem(QWidget *parent, Subtask *subtask)
Constructs a SubtaskItem object.
Definition: subtask_item.cpp:62
SubtaskStatus::Inactive
@ Inactive
The subtask is inactive (state where it can't be executed).
execute_frame.hpp
TaskManager::toggleSolution
void toggleSolution(Subtask &subtask)
Show or hide the solution of a subtask.
Definition: task_manager.cpp:74
notebook_converter.hpp
Subtask::filePath
QString filePath
The file path of the subtask.
Definition: task.hpp:35
ExecuteFrame::setImage
void setImage(const QString &path)
Sets the image to be displayed.
Definition: execute_frame.cpp:52
SubtaskItem
Represents a UI item for a subtask.
Definition: subtask_item.hpp:25
Toast::showToast
void showToast(const QString &message)
Definition: toast.cpp:27
SubtaskItem::subtaskStartStopRequested
void subtaskStartStopRequested(const Subtask &subtask)
Signal emitted when a start/stop request is made for the subtask.
Subtask::hasBeenExecuted
bool hasBeenExecuted
Whether the subtask has been executed at least once.
Definition: task.hpp:48
ExecuteFrame::setText
void setText(const QString &text)
Sets the text to be displayed.
Definition: execute_frame.cpp:84
TaskManager::startStopSubtask
void startStopSubtask(Subtask &subtask, bool startSolution=false)
Starts or stops a subtask.
Definition: task_manager.cpp:45
SubtaskStatus::Ready
@ Ready
The subtask is ready to be executed.
Toast
Definition: toast.hpp:8
task_manager.hpp
NotebookConverter::resetNotebook
void resetNotebook(const QString &notebookPath, const QString &notebookSolutionPath)
Removes solution code from a Jupyter notebook.
Definition: notebook_converter.cpp:104
SubtaskItem::updateUI
void updateUI(bool constructorCall=false)
Updates the UI elements based on the subtask's status.
Definition: subtask_item.cpp:88
Subtask
Represents a subtask within a task.
Definition: task.hpp:31
ExecuteFrame
A custom QFrame that displays an image and text. For logging and task execution.
Definition: execute_frame.hpp:13
SubtaskItem::setTaskManager
void setTaskManager(TaskManager *manager)
Sets the TaskManager object.
Definition: subtask_item.cpp:151