mainwindow.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3. #include <QMainWindow>
  4. #include <QString>
  5. #include <QList>
  6. #include <QListView>
  7. #include <QListWidgetItem>
  8. #include <QStandardItemModel>
  9. #include <QStandardItem>
  10. #include <include/client.hpp>
  11. #include <headers/ktextedit.hpp>
  12. #include <include/argdialog.h>
  13. #include <include/consoledialog.h>
  14. #include <QTableView>
  15. #include <QTimer>
  16. namespace ProcessState {
  17. static constexpr int READY = 1;
  18. static constexpr int PENDING = 2;
  19. static constexpr int SUCCEEDED = 3;
  20. static constexpr int FAILED = 4;
  21. }
  22. const QString ProcessNames[4] = { "READY", "PENDING", "SUCCEEDED", "FAILED" };
  23. struct Process {
  24. QString name;
  25. int state;
  26. QString start;
  27. QString end;
  28. QString id;
  29. QString result;
  30. bool operator==(const Process &other) const {
  31. return name == other.name && state == other.state;
  32. }
  33. };
  34. struct Event {};
  35. namespace Ui {
  36. class MainWindow;
  37. }
  38. class MainWindow : public QMainWindow
  39. {
  40. Q_OBJECT
  41. public:
  42. explicit MainWindow(int argc = 0, char** argv = nullptr, QWidget* parent = nullptr);
  43. virtual void keyPressEvent(QKeyEvent* e);
  44. ~MainWindow();
  45. private:
  46. /** Process arguments */
  47. int cli_argc;
  48. char** cli_argv;
  49. /** UI & Messages */
  50. void connectUi();
  51. QString parseMessage(const QString& s, StringVec v);
  52. void updateProcessResult(QString request_id, QString result);
  53. /** UI Members */
  54. Ui::MainWindow *ui;
  55. ArgDialog *arg_ui;
  56. ConsoleDialog console_ui;
  57. /** Client member */
  58. Client* q_client;
  59. /** Models */
  60. std::vector<Process> m_processes;
  61. QList<QString> m_events;
  62. QStandardItemModel* m_process_model;
  63. QStandardItemModel* m_event_model;
  64. private slots:
  65. /** Receivers */
  66. void connectClient();
  67. void updateMessages(int t, const QString& s, StringVec v);
  68. void handleKey();
  69. };
  70. #endif // MAINWINDOW_H