From ca55dfd5a3b28e75629fd4745f538dbe7f60597b Mon Sep 17 00:00:00 2001
From: Giacomo Strangolino <giacomo.strangolino@elettra.eu>
Date: Mon, 14 Mar 2022 11:58:25 +0100
Subject: [PATCH] FixedXXX call FixedX(1) before

---
 src/4uhv.cpp    |  9 +++++++--
 src/channel.cpp | 17 ++++++++++++++++-
 src/channel.h   |  2 ++
 src/channel.ui  | 13 ++++---------
 4 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/src/4uhv.cpp b/src/4uhv.cpp
index cc472fc..f947fc2 100644
--- a/src/4uhv.cpp
+++ b/src/4uhv.cpp
@@ -72,9 +72,14 @@ void FourUHV::onPsListReady(const CuData &da) {
                     const QString& s = w->property("point").toString();
                     if(s.contains("%1")) w->setProperty("source",  QString(s).arg(ch));
                 }
-                if(w->metaObject()->indexOfProperty("target") > -1) {
+                if(w->property("target").isValid() || w->objectName().contains(QRegularExpression("pbFix\\dk"))) {
                     const QString& t = w->property("point").toString();
-                    if(t.contains("%1"))  w->setProperty("target", QString(t).arg(ch));
+                    printf("FourUHV::onPsListReady: %s point is %s \n",
+                           qstoc(w->objectName()), qstoc(t));
+                    if(t.contains("%1")) {
+                        w->setProperty("channel", ch);
+                        w->setProperty("target", QString(t).arg(ch));
+                    }
                 }
             }
             channel->findChild<QGroupBox *>("gbHighTh")->setHidden(true);
diff --git a/src/channel.cpp b/src/channel.cpp
index 5dd4385..22b200a 100644
--- a/src/channel.cpp
+++ b/src/channel.cpp
@@ -1,10 +1,14 @@
 #include "channel.h"
 #include "ui_channel.h"
+#include <quwriter.h>
 
 Channel::Channel(QWidget *parent, CumbiaPool *cu_p, const CuControlsFactoryPool &fp) :
-    QWidget(parent) {
+    QWidget(parent), cu_pool(cu_p), m_ctrl_fpool(fp) {
     ui = new Ui::Channel;
     ui->setupUi(this, cu_p, fp);
+    connect(ui->pbFix3k, SIGNAL(clicked()), this, SLOT(onPbFixClicked()));
+    connect(ui->pbFix5k, SIGNAL(clicked()), this, SLOT(onPbFixClicked()));
+    connect(ui->pbFix7k, SIGNAL(clicked()), this, SLOT(onPbFixClicked()));
 }
 
 Channel::~Channel()
@@ -12,3 +16,14 @@ Channel::~Channel()
     delete ui;
 }
 
+void Channel::onPbFixClicked() {
+    const QString& t0 = QString("$1/Fixed%1(1)").arg(sender()->property("channel").toInt());
+    const QString& t1 = sender()->property("target").toString();
+    foreach(const QString& t, QStringList() << t0 << t1) {
+        QuWriter *w = new QuWriter(this, cu_pool, m_ctrl_fpool);
+        w->setAutoDestroy(true);
+        w->setTarget(t);
+        printf("Channel::onPbFixClicked %s executing target %s\n", qstoc(sender()->objectName()), qstoc(t));
+        w->execute();
+    }
+}
diff --git a/src/channel.h b/src/channel.h
index a514aff..ba0bd60 100644
--- a/src/channel.h
+++ b/src/channel.h
@@ -18,6 +18,8 @@ public:
     explicit Channel(QWidget *parent, CumbiaPool *cu_p, const CuControlsFactoryPool& fp);
     ~Channel();
 
+protected slots:
+    void onPbFixClicked();
 private:
     Ui::Channel *ui;
     CumbiaPool *cu_pool;
diff --git a/src/channel.ui b/src/channel.ui
index 7e0240b..ff16e45 100644
--- a/src/channel.ui
+++ b/src/channel.ui
@@ -166,7 +166,7 @@
         </widget>
        </item>
        <item row="2" column="1">
-        <widget class="QuButton" name="tPushButton_4">
+        <widget class="QPushButton" name="pbFix5k">
          <property name="text">
           <string>Fix5000</string>
          </property>
@@ -186,7 +186,7 @@
         </widget>
        </item>
        <item row="2" column="2">
-        <widget class="QuButton" name="tPushButton_5">
+        <widget class="QPushButton" name="pbFix7k">
          <property name="text">
           <string>Fix7000</string>
          </property>
@@ -295,7 +295,7 @@
         </widget>
        </item>
        <item row="2" column="0">
-        <widget class="QuButton" name="tPushButton_3">
+        <widget class="QPushButton" name="pbFix3k">
          <property name="text">
           <string>Fix3000</string>
          </property>
@@ -318,7 +318,7 @@
   </customwidget>
   <customwidget>
    <class>QuTable</class>
-   <extends>EFlag</extends>
+   <extends>QWidget</extends>
    <header>qutable.h</header>
   </customwidget>
   <customwidget>
@@ -326,11 +326,6 @@
    <extends>QPushButton</extends>
    <header>qubutton.h</header>
   </customwidget>
-  <customwidget>
-   <class>EFlag</class>
-   <extends>QWidget</extends>
-   <header>eflag.h</header>
-  </customwidget>
   <customwidget>
    <class>QuLineEdit</class>
    <extends>QLineEdit</extends>
-- 
GitLab