mainwindow.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 <include/argdialog.h>
  12. #include <include/consoledialog.h>
  13. #include <QTableView>
  14. #include <QTimer>
  15. namespace ProcessState {
  16. static constexpr int READY = 1;
  17. static constexpr int PENDING = 2;
  18. static constexpr int SUCCEEDED = 3;
  19. static constexpr int FAILED = 4;
  20. }
  21. const QString ProcessNames[4] = { "READY", "PENDING", "SUCCEEDED", "FAILED" };
  22. struct Process {
  23. QString name;
  24. int state;
  25. QString start;
  26. QString end;
  27. QString id;
  28. QString result;
  29. bool operator==(const Process &other) const {
  30. return name == other.name && state == other.state;
  31. }
  32. };
  33. struct Event {};
  34. namespace Ui {
  35. class MainWindow;
  36. }
  37. class MainWindow : public QMainWindow
  38. {
  39. Q_OBJECT
  40. public:
  41. explicit MainWindow(int argc = 0, char** argv = nullptr, QWidget* parent = nullptr);
  42. virtual void keyPressEvent(QKeyEvent* e);
  43. ~MainWindow();
  44. private:
  45. /** Process arguments */
  46. int cli_argc;
  47. char** cli_argv;
  48. /** UI & Messages */
  49. void connectUi();
  50. void setConnectScreen(bool visible = true);
  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. /** Misc */
  65. ConfigJson m_config;
  66. uint16_t m_consecutive_events;
  67. private slots:
  68. /** Receivers */
  69. void connectClient();
  70. void updateMessages(int t, const QString& s, StringVec v);
  71. void handleKey();
  72. };
  73. #endif // MAINWINDOW_H