mainwindow.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3. #include <include/argdialog.h>
  4. #include <include/consoledialog.h>
  5. #include <QList>
  6. #include <QListView>
  7. #include <QListWidgetItem>
  8. #include <QMainWindow>
  9. #include <QStandardItem>
  10. #include <QStandardItemModel>
  11. #include <QString>
  12. #include <QTableView>
  13. #include <QTimer>
  14. #include <headers/kiq_types.hpp>
  15. #include <include/client.hpp>
  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. void setConnectScreen(bool visible = true);
  52. QString parseMessage(const QString& s, StringVec v);
  53. QString parseTaskInfo(StringVec v);
  54. void updateProcessResult(QString request_id, QString result);
  55. /** UI Members */
  56. Ui::MainWindow *ui;
  57. ArgDialog *arg_ui;
  58. ConsoleDialog console_ui;
  59. /** Client member */
  60. Client* q_client;
  61. /** Models */
  62. std::vector<Process> m_processes;
  63. QList<QString> m_events;
  64. QStandardItemModel* m_process_model;
  65. QStandardItemModel* m_event_model;
  66. /** Misc */
  67. ConfigJson m_config;
  68. uint16_t m_consecutive_events;
  69. private slots:
  70. /** Receivers */
  71. void connectClient();
  72. void updateMessages(int t, const QString& s, StringVec v);
  73. void handleKey();
  74. };
  75. #endif // MAINWINDOW_H