Browse Source

fixing event list
added process list update behaviour

logicp 5 years ago
parent
commit
46bf40b5b4
5 changed files with 33 additions and 7 deletions
  1. 2 0
      client.cpp
  2. 1 0
      client.hpp
  3. 26 4
      mainwindow.cpp
  4. 1 0
      mainwindow.h
  5. 3 3
      mainwindow.ui

+ 2 - 0
client.cpp

@@ -294,6 +294,8 @@ void Client::execute() {
     if (!selected_commands.empty()) {
         executing = true;
         for (const auto& command : selected_commands) {
+            auto message = getAppName(command) + " pending";
+            emit Client::messageReceived(PROCESS_REQUEST_TYPE, message, {});
             std::string execute_operation = createOperation("Execute", {std::to_string(command)});
             sendEncoded(execute_operation);
         }

+ 1 - 0
client.hpp

@@ -19,6 +19,7 @@
 static constexpr int MESSAGE_UPDATE_TYPE = 1;
 static constexpr int COMMANDS_UPDATE_TYPE = 2;
 static constexpr int EVENT_UPDATE_TYPE = 3;
+static constexpr int PROCESS_REQUEST_TYPE = 4;
 
 typedef std::map<int, std::string> CommandMap;
 typedef std::map<int, std::vector<std::string>> CommandArgMap;

+ 26 - 4
mainwindow.cpp

@@ -109,6 +109,8 @@ void MainWindow::connectClient() {
         }
     });
 
+    ui->processList->addItem("Processes results displayed here");
+
     // TODO: Handle enter key
     //    QObject::connect(send_message_box, &QTextEdit::keyReleaseEvent, this, [q_client, send_message_box]() {
     //        q_client->sendMessage(send_message_box->toPlainText());
@@ -133,13 +135,24 @@ void MainWindow::updateMessages(int t, const QString& message, StringVec v) {
         }
         //TODO: We do this because a CommandLinkButton turns transparent by default, except when hovered or checked
         ui->connect->setChecked(true);
-    } else if(t == EVENT_UPDATE_TYPE) {
-        QString event_message{};
+    } else if (t == PROCESS_REQUEST_TYPE) {
+        qDebug() << "Updating process list";
+        ui->processList->addItem(message);
+
+        //TODO: We do this because a CommandLinkButton turns transparent by default, except when hovered or checked
+        ui->connect->setChecked(true);
+    } else if (t == EVENT_UPDATE_TYPE) {
+        QString event_message{QDateTime::currentDateTime().toString("hh:mm:ss") + " - "};
         if (!v.empty()) {
-            auto mask = v.at(0);
-            auto event_message = q_client->getAppName(std::stoi(mask.toUtf8().constData()));
+            auto mask = std::stoi(v.at(0).toUtf8().constData());
+            event_message += message;
+            event_message += "\n";
+            event_message += q_client->getAppName(mask);
             event_message += ": ";
             event_message += v.at(1);
+            if (message == "Process Result") {
+                updateProcessResult(mask);
+            }
         } else {
             event_message += message;
         }
@@ -153,3 +166,12 @@ void MainWindow::updateMessages(int t, const QString& message, StringVec v) {
     }
 }
 
+void MainWindow::updateProcessResult(int mask) {
+    auto app_name = q_client->getAppName(mask);
+    for (int i = ui->processList->count() - 1; i >= 0; i--) {
+        if (ui->processList->item(i)->text().contains(app_name)) {
+            ui->processList->item(i)->setText(app_name + " completed");
+            return;
+        }
+    }
+}

+ 1 - 0
mainwindow.h

@@ -26,6 +26,7 @@ private:
     ArgDialog *arg_ui;
     void connectUi();
     void runApp();
+    void updateProcessResult(int mask);
     int cli_argc;
     char** cli_argv;
     Client* q_client;

+ 3 - 3
mainwindow.ui

@@ -176,10 +176,10 @@ color: rgb(5, 5, 5);
 font: 87 10pt &quot;Noto Sans&quot;;</string>
            </property>
            <property name="alternatingRowColors">
-            <bool>true</bool>
+            <bool>false</bool>
            </property>
            <property name="isWrapping" stdset="0">
-            <bool>true</bool>
+            <bool>false</bool>
            </property>
           </widget>
          </item>
@@ -209,7 +209,7 @@ font: 87 10pt &quot;Noto Sans&quot;;</string>
         </layout>
        </item>
        <item row="0" column="1">
-        <layout class="QGridLayout" name="gridLayout" rowstretch="1,0,0,0,0,0,0,0,0,0,0,0"/>
+        <layout class="QGridLayout" name="gridLayout" rowstretch="1"/>
        </item>
       </layout>
      </item>