123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- #ifndef MAINWINDOW_H
- #define MAINWINDOW_H
- #include <include/ui/argdialog.h>
- #include <include/ui/messagedialog.hpp>
- #include <QList>
- #include <QListView>
- #include <QListWidgetItem>
- #include <QMainWindow>
- #include <QStandardItem>
- #include <QStandardItemModel>
- #include <QString>
- #include <QTableView>
- #include <QTimer>
- #include <headers/kiq_types.hpp>
- #include <include/client/client.hpp>
- namespace ProcessState {
- static constexpr int READY = 1;
- static constexpr int PENDING = 2;
- static constexpr int SUCCEEDED = 3;
- static constexpr int FAILED = 4;
- }
- struct KListViewsStates {
- bool eventViewBottom;
- bool processViewBottom;
- bool historyViewBottom;
- };
- const QString ProcessNames[4] = { "READY", "PENDING", "SUCCEEDED", "FAILED" };
- struct Process {
- QString name;
- int state;
- QString start;
- QString end;
- QString id;
- QString result = "";
- QString error = "";
- bool operator==(const Process &other) const {
- return name == other.name && state == other.state;
- }
- };
- // struct Event {};
- namespace Ui {
- class MainWindow;
- }
- class MainWindow : public QMainWindow
- {
- Q_OBJECT
- public:
- explicit MainWindow(int argc = 0, char** argv = nullptr, QWidget* parent = nullptr);
- ~MainWindow();
- class MessageParser {
- public:
- void init(MainWindow* window);
- void handleCommands(StringVec commands, QString default_app);
- void handleMessage(QString message, StringVec v);
- QString handleEventMessage(QString message, StringVec v);
- private:
- QString parseMessage(const QString& s, StringVec v);
- void updateProcessResult(QString id, QString result, bool error);
- MainWindow* window;
- };
- /** UI & Messages */
- void connectUi();
- void setConnectScreen(bool visible = true);
- QString parseTaskInfo(StringVec v);
- /** Process arguments */
- int cli_argc;
- char** cli_argv;
- /** UI Members */
- MessageParser message_parser;
- Ui::MainWindow* ui;
- ArgDialog* arg_ui;
- MessageDialog message_ui;
- /** Client member */
- Client* q_client;
- /** Models */
- std::vector<Process> m_processes;
- QList<QString> m_events;
- QStandardItemModel* m_process_model;
- QStandardItemModel* m_event_model;
- KListViewsStates m_view_states;
- /** Misc */
- QJsonObject m_config;
- uint16_t m_consecutive_events;
- private slots:
- /** Receivers */
- void connectClient();
- void onMessageReceived(int t, const QString& s, StringVec v);
- };
- #endif // MAINWINDOW_H
|