1 #pragma once 2 3 #ifndef TASKSVIEWER_H 4 #define TASKSVIEWER_H 5 6 #include <QSplitter> 7 #include <QScrollArea> 8 9 #include "toonzqt/treemodel.h" 10 #include "toonzqt/lineedit.h" 11 #include "toonzqt/checkbox.h" 12 #include "toonz/observer.h" 13 #include "batches.h" 14 15 class TFarmTask; 16 class TaskTreeView; 17 class QListWidgetItem; 18 class QComboBox; 19 20 class TaskTreeModel final : public TreeModel { 21 Q_OBJECT 22 23 // QModelIndex m_selectedIndex; 24 TaskTreeView *m_view; 25 26 public: 27 class Item final : public TreeModel::Item { 28 friend class TaskTreeModel; 29 30 public: 31 Item(const QString &name); 32 Item(TFarmTask *task); 33 //~Item(); getInternalPointer()34 void *getInternalPointer() const override { return m_task; } getTask()35 TFarmTask *getTask() const { return m_task; } setName(QString name)36 void setName(QString name) { m_name = name; } getName()37 QString getName() const { return m_name; } 38 39 private: 40 TFarmTask *m_task; 41 QString m_name; 42 }; // class TaskItem 43 44 TaskTreeModel(TaskTreeView *parent = 0); 45 //~TaskTreeModel(); 46 // void setSelected(const QModelIndex& index) {m_selectedIndex=index;} 47 // void openContextMenu(const QPoint& p); 48 49 void update(); 50 public slots: 51 void start(bool); 52 void stop(bool); 53 void remove(bool); 54 void save(bool); 55 void saveas(bool); 56 void load(bool); 57 void addCleanupTask(bool); 58 void addRenderTask(bool); 59 60 void setupModelData(); 61 62 protected: 63 QVariant data(const QModelIndex &index, int role) const override; 64 65 private: 66 // void setLayout(Item *oldPegs); 67 }; 68 69 //------------------------------------------------------------------------------------------ 70 class TasksViewer; 71 72 class TaskTreeView final : public TreeView { 73 Q_OBJECT 74 75 public: 76 TasksViewer *m_mainViewer; 77 TaskTreeView(TasksViewer *parent, TaskTreeModel *treeModel); 78 getSelectedIndexes()79 QModelIndexList getSelectedIndexes() const { return selectedIndexes(); } 80 81 protected: 82 void onClick(TreeModel::Item *item, const QPoint &pos, 83 QMouseEvent *e) override; 84 void openContextMenu(TreeModel::Item *item, const QPoint &globalPos) override; 85 }; 86 87 //------------------------------------------------------------------------------------------ 88 89 //============================================================================= 90 class QLabel; 91 class QGridLayout; 92 class TFarmTask; 93 class QTextEdit; 94 class QListWidget; 95 96 class TaskSheet final : public QScrollArea { 97 Q_OBJECT 98 99 TasksViewer *m_viewer; 100 101 QFrame *m_boxCleanup; 102 QFrame *m_boxComposer; 103 104 TFarmTask *m_task; 105 DVGui::LineEdit *m_name; 106 DVGui::LineEdit *m_priority; 107 DVGui::LineEdit *m_from; 108 DVGui::LineEdit *m_to; 109 DVGui::LineEdit *m_step; 110 DVGui::LineEdit *m_shrink; 111 DVGui::LineEdit *m_chunkSize; 112 DVGui::LineEdit *m_outputPath; 113 QLabel *m_id; 114 QLabel *m_status; 115 QTextEdit *m_commandLine; 116 QLabel *m_server; 117 QLabel *m_submittedBy; 118 QLabel *m_submittedOn; 119 QLabel *m_submitDate; 120 QLabel *m_startDate; 121 QLabel *m_complDate; 122 QLabel *m_duration; 123 QLabel *m_stepCount; 124 QLabel *m_failedSteps; 125 QLabel *m_succSteps; 126 QListWidget *m_addedBox; 127 QListWidget *m_notAddedBox; 128 DVGui::CheckBox *m_visible; 129 QComboBox *m_overwrite; 130 QComboBox *m_multimedia; 131 QComboBox *m_threadsCombo; 132 QComboBox *m_rasterGranularityCombo; 133 134 protected slots: 135 136 void onAdded(bool); 137 void onRemoved(bool); 138 void onRemovedItemDoubleClicked(QListWidgetItem *item); 139 void onAddedItemDoubleClicked(QListWidgetItem *item); 140 void onFocusIn(); 141 void setName(); 142 void setFrom(); 143 void setTo(); 144 void setShrink(); 145 void setStep(); 146 void setOutput(); 147 void setChunkSize(); 148 void setVisible(int); 149 void setOverwrite(int); 150 void setMultimedia(int); 151 void setThreadsCombo(int); 152 void setGranularityCombo(int); 153 void setPriority(); 154 155 public: 156 TaskSheet(TasksViewer *owner); 157 void update(TFarmTask *task); 158 void updateChunks(TFarmTask *task); getCurrentTask()159 TFarmTask *getCurrentTask() { return m_task; } 160 }; 161 162 //============================================================================= 163 class QToolBar; 164 class TasksViewer final : public QSplitter, public BatchesController::Observer { 165 Q_OBJECT 166 167 public: 168 TaskSheet *m_taskSheet; 169 TaskTreeView *m_treeView; 170 QTimer *m_timer; 171 172 #if QT_VERSION >= 0x050500 173 TasksViewer(QWidget *parent = 0, Qt::WindowFlags flags = 0); 174 #else 175 TasksViewer(QWidget *parent = 0, Qt::WFlags flags = 0); 176 #endif 177 ~TasksViewer(); 178 179 void update() override; 180 181 void setSelected(TFarmTask *task); 182 const std::vector<QAction *> &getActions() const; 183 184 void startTimer(); 185 void stopTimer(); 186 187 public slots: 188 void onTimer(); 189 190 protected: 191 QWidget *createToolBar(); 192 std::vector<QAction *> m_actions; 193 void add(const QString &iconName, QString text, QToolBar *toolBar, 194 const char *slot, QString iconText); 195 196 void showEvent(QShowEvent *) override; 197 void hideEvent(QHideEvent *) override; 198 }; 199 200 //============================================================================= 201 202 #endif // TASKSVIEWER_H 203