mainwindow.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. 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. namespace Ui {
  34. class MainWindow;
  35. }
  36. class MainWindow : public QMainWindow
  37. {
  38. Q_OBJECT
  39. public:
  40. explicit MainWindow(int argc = 0, char** argv = nullptr, QWidget* parent = nullptr);
  41. virtual void keyPressEvent(QKeyEvent* e);
  42. ~MainWindow();
  43. private:
  44. /** Process arguments */
  45. int cli_argc;
  46. char** cli_argv;
  47. /** UI & Messages */
  48. void connectUi();
  49. QString parseMessage(const QString& s, StringVec v);
  50. void updateProcessResult(QString request_id, QString result);
  51. /** UI Members */
  52. Ui::MainWindow *ui;
  53. ArgDialog *arg_ui;
  54. ConsoleDialog console_ui;
  55. /** Client member */
  56. Client* q_client;
  57. /** Models */
  58. std::vector<Process> m_processes;
  59. QStandardItemModel* m_process_model;
  60. QList<QString> m_events;
  61. private slots:
  62. /** Receivers */
  63. void connectClient();
  64. void updateMessages(int t, const QString& s, StringVec v);
  65. void handleKey();
  66. };
  67. #endif // MAINWINDOW_H