Ver código fonte

V0.1.2
1、重做了单个item类,解决以前的遗留问题
2、完成了获取数据功能

Apple 3 meses atrás
pai
commit
9fe3632c7c
30 arquivos alterados com 1513 adições e 96 exclusões
  1. 81 47
      TransmitterSwitch/AddItem/addnormalitem.cpp
  2. 26 8
      TransmitterSwitch/AddItem/addnormalitem.h
  3. 2 2
      TransmitterSwitch/AddItem/addnormalitem.ui
  4. 213 0
      TransmitterSwitch/AddItem__/addnormalitem.cpp
  5. 61 0
      TransmitterSwitch/AddItem__/addnormalitem.h
  6. 299 0
      TransmitterSwitch/AddItem__/addnormalitem.ui
  7. 3 0
      TransmitterSwitch/ItemData/ItemData.cpp
  8. 9 0
      TransmitterSwitch/ItemData/ItemData.h
  9. 259 0
      TransmitterSwitch/ItemData/oneitem.cpp
  10. 88 0
      TransmitterSwitch/ItemData/oneitem.h
  11. 306 0
      TransmitterSwitch/ItemData/oneitem.ui
  12. BIN
      TransmitterSwitch/Resource/ICON/Date.png
  13. BIN
      TransmitterSwitch/Resource/ICON/Dialog_close.png
  14. BIN
      TransmitterSwitch/Resource/ICON/Dialog_close2.png
  15. BIN
      TransmitterSwitch/Resource/ICON/DownArrow.png
  16. BIN
      TransmitterSwitch/Resource/ICON/Time.png
  17. 40 14
      TransmitterSwitch/Resource/QSS/AddNormalItem_Light.qss
  18. 0 0
      TransmitterSwitch/Resource/QSS/OneItem_dark.qss
  19. 7 1
      TransmitterSwitch/Resource/TransSwitch.qrc
  20. 18 6
      TransmitterSwitch/TransmitterSwitchInfo.cpp
  21. 7 1
      TransmitterSwitch/TransmitterSwitchInfo.h
  22. 13 9
      TransmitterSwitch/WebAPI/FromWebAPI.cpp
  23. 1 1
      TransmitterSwitch/WebAPI/FromWebAPI.h
  24. 30 5
      TransmitterSwitch/transmitterswitch.cpp
  25. 5 0
      TransmitterSwitch/transmitterswitch.h
  26. 6 2
      show1/CMakeLists.txt
  27. 1 0
      show1/LHLog/LHQLogAPI.cpp
  28. 33 0
      show1/LHLog/LHQLogAPI.h
  29. 2 0
      show1/main.cpp
  30. 3 0
      show1/widget.cpp

+ 81 - 47
TransmitterSwitch/AddItem/addnormalitem.cpp

@@ -8,6 +8,8 @@
 
 #include "common/combobox/customcombobox.h"
 #include "LHQLogAPI.h"
+#include "transmitterswitchinfo.h"
+#include "common/SelectTime/timewidget.h"
 
 AddNormalItem::AddNormalItem(QWidget *parent) :
     QDialog(parent),
@@ -21,7 +23,7 @@ AddNormalItem::AddNormalItem(QWidget *parent) :
     this->setAttribute(Qt::WA_TranslucentBackground);
 
     /* 加载QSS */
-    QFile file(":/QSS/QSS/AddNormalItem.qss");
+    QFile file(":/QSS/QSS/AddNormalItem_Light.qss");
     if(file.open(QIODevice::ReadOnly))
     {
         QString stylesheet = file.readAll();
@@ -40,37 +42,10 @@ AddNormalItem::AddNormalItem(QWidget *parent) :
     // m_p = dynamic_cast<ExecPlan*>(parent);
 
 
-    ui->timeEdit->setTimeAreaWidth(132);
-    ui->timeEdit->SetMainWindow(this);
-
     ui->label_timeWarn->hide();
     ui->label_devWarn->hide();
     ui->label_actionWarn->hide();
 
-    /* 添加设备项 */
-    // ui->comBox_devSelect->clear();
-    // for(const auto& it : DevInfo.cfgDevInfo())
-    // {
-    //     ui->comBox_devSelect->addItem(it->devName);
-    //     for(auto it1 = it->DevType.getDevAction().begin();it1 != it->DevType.getDevAction().end();it1++)
-    //     {
-    //         ui->comBox_actionSelect->addItem(it1.value());
-    //     }
-    // }
-    // ui->comBox_devSelect->setCurrentIndex(0);
-    // m_devName = ui->comBox_devSelect->currentText();
-    // /* 添加动作项 */
-    // ui->comBox_actionSelect->clear();
-    // auto it = DevInfo.cfgDevInfo().value(ui->comBox_devSelect->currentText(),nullptr);
-    // if(it != nullptr )
-    // {
-    //     for(auto it1 = it->DevType.getDevAction().begin();it1 != it->DevType.getDevAction().end();it1++)
-    //     {
-    //         ui->comBox_actionSelect->addItem(it1.value());
-    //     }
-    // }
-
-
     /* 连接信号和槽 */
     connect(ui->pBtn_Close,&QPushButton::clicked,this,&QDialog::close);
     connect(ui->pBtn_cancel,&QPushButton::clicked,this,&QDialog::close);
@@ -78,28 +53,15 @@ AddNormalItem::AddNormalItem(QWidget *parent) :
     connect(ui->pBtn_cancel,&QPushButton::clicked,this,&AddNormalItem::close);
 
     /* 设备选择 */
-    connect(ui->comBox_devSelect,QOverload<const QString&>::of(&QComboBox::currentTextChanged),this,[this](){
-        m_devName = ui->comBox_devSelect->currentText();
-        /* 根据选择的设备,设置该设备的动作 */
-        // ui->comBox_actionSelect->clear();
-        // auto it = DevInfo.cfgDevInfo().value(ui->comBox_devSelect->currentText(),nullptr);
-        // if(it != nullptr )
-        // {
-        //     /* 将该设备支持的动作设置到选项中 */
-        //     for(auto it1 = it->DevType.getDevAction().begin();it1 != it->DevType.getDevAction().end();it1++)
-        //     {
-        //         ui->comBox_actionSelect->addItem(it1.value());
-        //     }
-        // }
-    });
+    connect(ui->comBox_devSelect, QOverload<const QString&>::of(&QComboBox::currentTextChanged), this, &AddNormalItem::do_selectDev);
     /* 动作选择 */
-    connect(ui->comBox_actionSelect,QOverload<const QString&>::of(&QComboBox::currentTextChanged),this,[this](){
-        m_action = ui->comBox_actionSelect->currentText();
-    });
-//    connect(ui->pBtn_selectTime,SIGNAL(clicked()),this,SLOT(do_selectTime()));
-
+    connect(ui->comBox_actionSelect,QOverload<const QString&>::of(&QComboBox::currentTextChanged),this, &AddNormalItem::do_selectAction);
     /* 设置默认时间 */
     ui->timeEdit->setTime("00:00:00");
+
+    /* 注册事件过滤器 */
+    ui->comBox_actionSelect->installEventFilter(this);
+    ui->comBox_devSelect->installEventFilter(this);
 }
 
 AddNormalItem::~AddNormalItem()
@@ -107,6 +69,28 @@ AddNormalItem::~AddNormalItem()
     delete ui;
 }
 
+/* 设置父指针,时间选择器需要使用 */
+void AddNormalItem::setParentPointer(QWidget* p)
+{
+    /* 设置时间选择器 */
+    ui->timeEdit->setTimeAreaWidth(132);
+    ui->timeEdit->SetMainWindow(this);
+}
+
+/* 添加可选设备 */
+void AddNormalItem::setDevice(QMap<QString, DeviceInfo>& mapDev)
+{
+    ui->comBox_devSelect->clear();
+    for(const auto& it : mapDev)
+    {
+        ui->comBox_devSelect->addItem(it.devName);
+    }
+    /* 设置显示第一个设备,并设置可选的动作 */
+    ui->comBox_devSelect->setCurrentIndex(0);
+    m_devName = ui->comBox_devSelect->currentText();
+    setAction(m_devName);
+}
+
 
 /* 进行查重和关闭页面 */
 void AddNormalItem::do_ok()
@@ -159,6 +143,20 @@ void AddNormalItem::do_ok()
     close();
 }
 
+
+/* 选择了设备,设置其对应的动作 */
+void AddNormalItem::do_selectDev()
+{
+    m_devName = ui->comBox_devSelect->currentText();
+    setAction(m_devName);
+}
+
+/* 选择了动作 */
+void AddNormalItem::do_selectAction()
+{
+    m_action = ui->comBox_actionSelect->currentText();
+}
+
 /* 设置选择框报警 */
 void AddNormalItem::setComboBoxWarning(QComboBox* bo, bool flag)
 {
@@ -192,3 +190,39 @@ void AddNormalItem::setTimeEditWarning(bool flag)
     ui->timeEdit->style()->polish(ui->timeEdit);
 }
 
+/* 设置动作 */
+void AddNormalItem::setAction(const QString& devName)
+{
+    QMap<int, QString> devAction;
+    if(!DeviceContainer.getDevAction(devName, devAction))
+    {
+        return;
+    }
+    ui->comBox_actionSelect->clear();
+    for(auto it = devAction.begin();it != devAction.end();it++)
+    {
+        ui->comBox_actionSelect->addItem(it.value(), it.key());
+    }
+}
+
+
+/* 事件过滤器 */
+bool AddNormalItem::eventFilter(QObject *watched, QEvent *event)
+{
+    if(watched == ui->comBox_devSelect)
+    {
+        if(event->type() == QEvent::Wheel)
+        {
+            return true;
+        }
+    }
+    else if(watched == ui->comBox_actionSelect)
+    {
+        if(event->type() == QEvent::Wheel)
+        {
+            return true;
+        }
+    }
+    return QDialog::eventFilter(watched,event);
+}
+

+ 26 - 8
TransmitterSwitch/AddItem/addnormalitem.h

@@ -5,9 +5,8 @@
 #include <QTime>
 #include <QComboBox>
 
-
-class ExecPlan;
 class TimeWidget;
+class DeviceInfo;
 
 namespace Ui {
 class AddNormalItem;
@@ -21,20 +20,39 @@ public:
     explicit AddNormalItem(QWidget *parent = nullptr);
     ~AddNormalItem();
 
+    /* 设置父指针,时间选择器需要使用 */
+    void setParentPointer(QWidget* p);
+    /* 添加可选设备 */
+    void setDevice(QMap<QString, DeviceInfo>& mapDev);
+
 signals:
-    void signal_addNormalItem(QString dev,QString action,QTime time);/* 添加正常日期的项 */
+    /* 添加正常日期的项 */
+    void signal_addNormalItem(QString dev,QString action,QTime time);
 
 private slots:
 //    void do_selectTime();                           /* 选择时间 */
-    void do_ok();                                   /* 进行查重和关闭页面 */
+    /* 进行查重和关闭页面 */
+    void do_ok();
+    /* 选择了设备,设置其对应的动作 */
+    void do_selectDev();
+    /* 选择了动作 */
+    void do_selectAction();
 
 private:
-    void setComboBoxWarning(QComboBox* bo,bool flag);/* 设置选择框报警 */
-    void setTimeEditWarning(bool flag);             /* 设置时间报警 */
-
+    /* 设置选择框报警 */
+    void setComboBoxWarning(QComboBox* bo,bool flag);
+    /* 设置时间报警 */
+    void setTimeEditWarning(bool flag);
+    void setAction(const QString& devName);
+
+protected:
+    /* 事件过滤器 */
+    bool eventFilter(QObject *watched, QEvent *event);
+    
 private:
     Ui::AddNormalItem *ui;
-    ExecPlan* m_p = nullptr;                        /* 设置父类指针 */
+
+    // ExecPlan* m_p = nullptr;                        /* 设置父类指针 */
     QString m_devName;                              /* 选择的设备 */
     QString m_action;                               /* 选择的动作 */
     QTime m_time;                                   /* 执行的时间 */

+ 2 - 2
TransmitterSwitch/AddItem/addnormalitem.ui

@@ -125,7 +125,7 @@
        <string>确定</string>
       </property>
      </widget>
-     <widget class="QLabel" name="label_NC5">
+     <widget class="QLabel" name="label_iconTime">
       <property name="geometry">
        <rect>
         <x>359</x>
@@ -262,7 +262,7 @@
        <string>TextLabel</string>
       </property>
      </widget>
-     <zorder>label_NC5</zorder>
+     <zorder>label_iconTime</zorder>
      <zorder>label_NC1</zorder>
      <zorder>label_NC2_x</zorder>
      <zorder>label_NC3</zorder>

+ 213 - 0
TransmitterSwitch/AddItem__/addnormalitem.cpp

@@ -0,0 +1,213 @@
+#include "addnormalitem.h"
+#include "ui_addnormalitem.h"
+
+#include <memory>
+#include <QDebug>
+#include <QListView>
+#include <QFile>
+
+#include "common/combobox/customcombobox.h"
+#include "LHQLogAPI.h"
+#include "transmitterswitchinfo.h"
+#include "common/SelectTime/timewidget.h"
+
+AddNormalItem::AddNormalItem(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::AddNormalItem)
+{
+    ui->setupUi(this);
+
+    /* 设置无边框 */
+    setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
+    /* 设置底层样式表,让最底层的透明 */
+    this->setAttribute(Qt::WA_TranslucentBackground);
+
+    /* 加载QSS */
+    QFile file(":/QSS/QSS/AddNormalItem_Light.qss");
+    if(file.open(QIODevice::ReadOnly))
+    {
+        QString stylesheet = file.readAll();
+        this->setStyleSheet(stylesheet);
+        file.close();
+    } else
+    {
+        LH_WRITE_ERROR(QString("打开文件失败:%1").arg(file.fileName()));
+    }
+    /* 设置comboBox阴影 */
+    ui->comBox_devSelect->setViewShadowEffect();
+    ui->comBox_actionSelect->setViewShadowEffect();
+
+
+    /* 获取父指针 */
+    // m_p = dynamic_cast<ExecPlan*>(parent);
+
+
+    ui->label_timeWarn->hide();
+    ui->label_devWarn->hide();
+    ui->label_actionWarn->hide();
+
+    /* 连接信号和槽 */
+    connect(ui->pBtn_Close, &QPushButton::clicked, this, &QDialog::close);
+    connect(ui->pBtn_cancel, &QPushButton::clicked, this, &QDialog::close);
+    connect(ui->pBtn_ok, &QPushButton::clicked, this, &AddNormalItem::do_ok);
+    connect(ui->pBtn_cancel, &QPushButton::clicked, this, &AddNormalItem::close);
+
+    /* 设备选择 */
+    connect(ui->comBox_devSelect, QOverload<const QString&>::of(&QComboBox::currentTextChanged), this, &AddNormalItem::do_selectDev);
+    /* 动作选择 */
+    connect(ui->comBox_actionSelect,QOverload<const QString&>::of(&QComboBox::currentTextChanged),this, &AddNormalItem::do_selectAction);
+    /* 打开时间选择器 */
+    connect(ui->pBtn_selectTime, &QPushButton::clicked, this, &AddNormalItem::do_selectTime);
+    /* 设置默认时间 */
+    m_time.setHMS(0, 0, 0);
+}
+
+AddNormalItem::~AddNormalItem()
+{
+    delete ui;
+}
+
+/* 设置父指针,时间选择器需要使用 */
+void AddNormalItem::setParentPointer(QWidget* p)
+{
+    /* 设置时间选择器 */
+
+}
+
+/* 添加可选设备 */
+void AddNormalItem::setDevice(QMap<QString, DeviceInfo>& mapDev)
+{
+    ui->comBox_devSelect->clear();
+    for(const auto& it : mapDev)
+    {
+        ui->comBox_devSelect->addItem(it.devName);
+    }
+    /* 设置显示第一个设备,并设置可选的动作 */
+    ui->comBox_devSelect->setCurrentIndex(0);
+    m_devName = ui->comBox_devSelect->currentText();
+    setAction(m_devName);
+}
+
+
+/* 进行查重和关闭页面 */
+void AddNormalItem::do_ok()
+{
+    ui->label_timeWarn->hide();
+    ui->label_devWarn->hide();
+    ui->label_actionWarn->hide();
+    setComboBoxWarning(ui->comBox_devSelect,false);
+    setComboBoxWarning(ui->comBox_actionSelect, false);
+    setTimeEditWarning(false);
+
+    /* 检查设备是否为空 */
+    if(ui->comBox_devSelect->currentText().isEmpty())
+    {
+        ui->label_devWarn->setText("不能为空!");
+        ui->label_devWarn->show();
+        setComboBoxWarning(ui->comBox_devSelect, true);
+        return;
+    }
+    /* 检查动作是否为空 */
+    if(ui->comBox_actionSelect->currentText().isEmpty())
+    {
+        ui->label_actionWarn->setText("不能为空!");
+        ui->label_actionWarn->show();
+        setComboBoxWarning(ui->comBox_actionSelect, true);
+    }
+
+    /* 时间赋值 */
+    
+    /* 检查时间是否为空 */
+    if(m_time.isNull())
+    {
+        ui->label_timeWarn->setText("不能为空!");
+        ui->label_timeWarn->show();
+        setTimeEditWarning(true);
+        return;
+    }
+    /* 进行设备查重 */
+    // bool ret = m_p->judgeTimeRepetition(*m_p->m_vecItem[m_p->m_stack->currentIndex()],m_devName,m_time);
+    // if(ret)
+    // {
+    //     ui->label_timeWarn->setText("一个时间点,单个设备仅能执行一个操作!");
+    //     ui->label_timeWarn->show();
+    //     setTimeEditWarning(true);
+    //     return;
+    // }
+
+    /* 发送信号 */
+    emit signal_addNormalItem(m_devName,m_action,m_time);
+    close();
+}
+
+
+/* 选择了设备,设置其对应的动作 */
+void AddNormalItem::do_selectDev()
+{
+    m_devName = ui->comBox_devSelect->currentText();
+    setAction(m_devName);
+}
+
+/* 选择了动作 */
+void AddNormalItem::do_selectAction()
+{
+    m_action = ui->comBox_actionSelect->currentText();
+}
+
+/* 点击了时间选择按钮,打开时间选择器 */
+void AddNormalItem::do_selectTime()
+{
+    LH_WRITE_LOG_DEBUG("选择时间");
+    std::shared_ptr<TimeWidget> tw = std::make_shared<TimeWidget>(this, TimeWidget::ShowType::Dialog);
+
+    tw->showTimeEditArea();
+}
+
+/* 设置选择框报警 */
+void AddNormalItem::setComboBoxWarning(QComboBox* bo, bool flag)
+{
+    if(flag)
+    {
+        bo->setProperty("Warn", true);
+    }
+    else
+    {
+        bo->setProperty("Warn", false);
+    }
+
+    bo->style()->unpolish(bo);
+    bo->style()->polish(bo);
+    
+}
+
+/* 设置时间报警 */
+void AddNormalItem::setTimeEditWarning(bool flag)
+{
+    if(flag)
+    {
+        ui->pBtn_selectTime->setProperty("Warn", true);
+    }
+    else
+    {
+        ui->pBtn_selectTime->setProperty("Warn", false);
+    }
+
+    ui->pBtn_selectTime->style()->unpolish(ui->pBtn_selectTime);
+    ui->pBtn_selectTime->style()->polish(ui->pBtn_selectTime);
+}
+
+/* 设置动作 */
+void AddNormalItem::setAction(const QString& devName)
+{
+    QMap<int, QString> devAction;
+    if(!DeviceContainer.getDevAction(devName, devAction))
+    {
+        return;
+    }
+    ui->comBox_actionSelect->clear();
+    for(auto it = devAction.begin();it != devAction.end();it++)
+    {
+        ui->comBox_actionSelect->addItem(it.value(), it.key());
+    }
+}
+

+ 61 - 0
TransmitterSwitch/AddItem__/addnormalitem.h

@@ -0,0 +1,61 @@
+#ifndef ADDNORMALITEM_H
+#define ADDNORMALITEM_H
+
+#include <QDialog>
+#include <QTime>
+#include <QComboBox>
+
+class TimeWidget;
+class DeviceInfo;
+
+namespace Ui {
+class AddNormalItem;
+}
+
+class AddNormalItem : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit AddNormalItem(QWidget *parent = nullptr);
+    ~AddNormalItem();
+
+    /* 设置父指针,时间选择器需要使用 */
+    void setParentPointer(QWidget* p);
+    /* 添加可选设备 */
+    void setDevice(QMap<QString, DeviceInfo>& mapDev);
+
+signals:
+    /* 添加正常日期的项 */
+    void signal_addNormalItem(QString dev,QString action,QTime time);
+
+private slots:
+//    void do_selectTime();                           /* 选择时间 */
+    /* 进行查重和关闭页面 */
+    void do_ok();
+    /* 选择了设备,设置其对应的动作 */
+    void do_selectDev();
+    /* 选择了动作 */
+    void do_selectAction();
+    /* 点击了时间选择按钮,打开时间选择器 */
+    void do_selectTime();
+
+private:
+    /* 设置选择框报警 */
+    void setComboBoxWarning(QComboBox* bo,bool flag);
+    /* 设置时间报警 */
+    void setTimeEditWarning(bool flag);
+    void setAction(const QString& devName);
+    
+private:
+    Ui::AddNormalItem *ui;
+
+    // ExecPlan* m_p = nullptr;                        /* 设置父类指针 */
+    QString m_devName;                              /* 选择的设备 */
+    QString m_action;                               /* 选择的动作 */
+    QTime m_time;                                   /* 执行的时间 */
+
+    TimeWidget* m_timeWidget = nullptr;             /* 时间选择器 */
+};
+
+#endif // ADDNORMALITEM_H

+ 299 - 0
TransmitterSwitch/AddItem__/addnormalitem.ui

@@ -0,0 +1,299 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>AddNormalItem</class>
+ <widget class="QDialog" name="AddNormalItem">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>436</width>
+    <height>349</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <property name="spacing">
+    <number>0</number>
+   </property>
+   <property name="leftMargin">
+    <number>10</number>
+   </property>
+   <property name="topMargin">
+    <number>10</number>
+   </property>
+   <property name="rightMargin">
+    <number>10</number>
+   </property>
+   <property name="bottomMargin">
+    <number>10</number>
+   </property>
+   <item>
+    <widget class="QWidget" name="widget_background" native="true">
+     <property name="styleSheet">
+      <string notr="true"/>
+     </property>
+     <widget class="QLabel" name="label_NC1">
+      <property name="geometry">
+       <rect>
+        <x>32</x>
+        <y>18</y>
+        <width>80</width>
+        <height>18</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>添加计划</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_NC2_x">
+      <property name="geometry">
+       <rect>
+        <x>32</x>
+        <y>154</y>
+        <width>7</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#ff0000;&quot;&gt;*&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_NC3">
+      <property name="geometry">
+       <rect>
+        <x>40</x>
+        <y>154</y>
+        <width>70</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>时间选择:</string>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="pBtn_Close">
+      <property name="geometry">
+       <rect>
+        <x>368</x>
+        <y>12</y>
+        <width>32</width>
+        <height>32</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string/>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_NC4">
+      <property name="geometry">
+       <rect>
+        <x>0</x>
+        <y>56</y>
+        <width>416</width>
+        <height>1</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string/>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="pBtn_cancel">
+      <property name="geometry">
+       <rect>
+        <x>248</x>
+        <y>265</y>
+        <width>60</width>
+        <height>32</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>取消</string>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="pBtn_ok">
+      <property name="geometry">
+       <rect>
+        <x>324</x>
+        <y>265</y>
+        <width>60</width>
+        <height>32</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>确定</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_iconTime">
+      <property name="geometry">
+       <rect>
+        <x>359</x>
+        <y>153</y>
+        <width>16</width>
+        <height>16</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string/>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_timeWarn">
+      <property name="geometry">
+       <rect>
+        <x>110</x>
+        <y>180</y>
+        <width>250</width>
+        <height>18</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>TextLabel</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_NC8_x">
+      <property name="geometry">
+       <rect>
+        <x>32</x>
+        <y>98</y>
+        <width>7</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#ff0000;&quot;&gt;*&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_NC9">
+      <property name="geometry">
+       <rect>
+        <x>40</x>
+        <y>98</y>
+        <width>70</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>设备选择:</string>
+      </property>
+     </widget>
+     <widget class="CustomComboBox" name="comBox_devSelect">
+      <property name="geometry">
+       <rect>
+        <x>110</x>
+        <y>89</y>
+        <width>274</width>
+        <height>32</height>
+       </rect>
+      </property>
+      <property name="currentText">
+       <string/>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_NC8_x_2">
+      <property name="geometry">
+       <rect>
+        <x>32</x>
+        <y>210</y>
+        <width>7</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:#ff0000;&quot;&gt;*&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+      </property>
+     </widget>
+     <widget class="CustomComboBox" name="comBox_actionSelect">
+      <property name="geometry">
+       <rect>
+        <x>110</x>
+        <y>201</y>
+        <width>274</width>
+        <height>32</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_NC9_2">
+      <property name="geometry">
+       <rect>
+        <x>40</x>
+        <y>210</y>
+        <width>70</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>动作选择:</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_devWarn">
+      <property name="geometry">
+       <rect>
+        <x>110</x>
+        <y>126</y>
+        <width>250</width>
+        <height>18</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>TextLabel</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_actionWarn">
+      <property name="geometry">
+       <rect>
+        <x>110</x>
+        <y>238</y>
+        <width>250</width>
+        <height>18</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>TextLabel</string>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="pBtn_selectTime">
+      <property name="geometry">
+       <rect>
+        <x>110</x>
+        <y>145</y>
+        <width>274</width>
+        <height>32</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>00:00:00</string>
+      </property>
+     </widget>
+     <zorder>label_iconTime</zorder>
+     <zorder>label_NC1</zorder>
+     <zorder>label_NC2_x</zorder>
+     <zorder>label_NC3</zorder>
+     <zorder>pBtn_Close</zorder>
+     <zorder>label_NC4</zorder>
+     <zorder>pBtn_cancel</zorder>
+     <zorder>pBtn_ok</zorder>
+     <zorder>label_timeWarn</zorder>
+     <zorder>label_NC8_x</zorder>
+     <zorder>label_NC9</zorder>
+     <zorder>comBox_devSelect</zorder>
+     <zorder>label_NC8_x_2</zorder>
+     <zorder>comBox_actionSelect</zorder>
+     <zorder>label_NC9_2</zorder>
+     <zorder>label_devWarn</zorder>
+     <zorder>label_actionWarn</zorder>
+     <zorder>pBtn_selectTime</zorder>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>CustomComboBox</class>
+   <extends>QComboBox</extends>
+   <header location="global">customcombobox.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>

+ 3 - 0
TransmitterSwitch/ItemData/ItemData.cpp

@@ -0,0 +1,3 @@
+#include "ItemData/ItemData.h"
+
+

+ 9 - 0
TransmitterSwitch/ItemData/ItemData.h

@@ -0,0 +1,9 @@
+#ifndef ITEMDATA_H
+#define ITEMDATA_H
+
+
+
+
+
+
+#endif // ITEMDATA_H

+ 259 - 0
TransmitterSwitch/ItemData/oneitem.cpp

@@ -0,0 +1,259 @@
+#include "oneitem.h"
+#include "ui_oneitem.h"
+
+#include <QFile>
+
+#include "LHQLogAPI.h"
+
+
+OneItem::OneItem(QWidget *parent, bool isSpecial) :
+    QWidget(parent), m_isSpecial(isSpecial),
+    ui(new Ui::OneItem)
+{
+    ui->setupUi(this);
+
+    /* 加载QSS */
+    QFile file(":/QSS/QSS/OneItem_dark.qss");
+    if(file.open(QIODevice::ReadOnly))
+    {
+        QString stylesheet = file.readAll();
+        this->setStyleSheet(stylesheet);
+        file.close();
+    } else
+    {
+        LH_WRITE_ERROR(QString("打开文件失败:%1").arg(file.fileName()));
+    }
+
+    /* 设置定时器 */
+    m_warnTimer.setTimerType(Qt::PreciseTimer);
+    m_warnTimer.setSingleShot(true);
+    connect(&m_warnTimer,&QTimer::timeout,this,[this](){
+        ui->label_warnning->hide();
+    });
+
+    /* 根据是否是特殊日移动位置 */
+    layoutInit();
+
+    /* 注册事件过滤器 */
+    ui->comboBox_devName->installEventFilter(this);
+    ui->comboBox_action->installEventFilter(this);
+
+    /* 连接信号和槽 */
+    connect(ui->comboBox_devName,QOverload<const QString&>::of(&QComboBox::currentTextChanged),this,&OneItem::do_devChanged);
+    connect(ui->comboBox_action,QOverload<const QString&>::of(&QComboBox::currentTextChanged),this,&OneItem::do_actionChanged);
+    connect(ui->pBtn_execTime,&QPushButton::clicked,this,&OneItem::do_pBtn_execTime_clicked);
+    connect(ui->pBtn_execDate,&QPushButton::clicked,this,&OneItem::do_pBtn_execDate_clicked);
+}
+
+OneItem::~OneItem()
+{
+    delete ui;
+}
+
+
+/* 设置序号 */
+void OneItem::setNum(int num)
+{
+    ui->label_num->setText(QString::number(num));
+}
+
+/* 获取序号 */
+int OneItem::getNum()
+{
+    return ui->label_num->text().toInt();
+}
+
+/* 设置日期 */
+void OneItem::setDate(const QDate& date)
+{
+    ui->pBtn_execDate->setText(date.toString("yyyy-MM-dd"));
+}
+
+/* 获取日期 */
+QDate OneItem::getDate()
+{
+    return QDate::fromString(ui->pBtn_execDate->text(),"yyyy-MM-dd");
+}
+
+/* 设置执行时间 */
+void OneItem::setExecTime(const QTime& time)
+{
+    ui->pBtn_execTime->setText(time.toString("hh:mm:ss"));
+}
+
+/* 获取执行时间 */
+QTime OneItem::getExecTime()
+{
+    return QTime::fromString(ui->pBtn_execTime->text(),"hh:mm:ss");
+}
+
+/* 设置设备名称 */
+void OneItem::setDevName(const QString& dev)
+{
+    ui->comboBox_devName->setCurrentText(dev);
+}
+
+/* 获取设备名称 */
+QString OneItem::getDevName()
+{
+    return ui->comboBox_devName->currentText();
+}
+
+/* 通过动作名称设置动作 */
+void OneItem::setActionName(const QString &action)
+{
+    ui->comboBox_action->setCurrentText(action);
+}
+
+/* 获取动作名称 */
+QString OneItem::getActionName()
+{
+    return ui->comboBox_action->currentText();
+}
+
+/* 获取动作类型 */
+int OneItem::getActionNum()
+{
+    return ui->comboBox_action->currentIndex();
+}
+
+/* 添加设备 */
+void OneItem::addDevice(const QMap<QString, DeviceInfo>& mapDev)
+{
+    ui->comboBox_devName->clear();
+    for(const auto& it : mapDev)
+    {
+        ui->comboBox_devName->addItem(it.devName);
+    }
+    /* 设置显示第一个设备,并设置可选的动作 */
+    ui->comboBox_devName->setCurrentIndex(0);
+    setActionName(ui->comboBox_devName->currentText());
+}
+
+/* 获取日期类型 */
+bool OneItem::getDateType()
+{
+    return m_isSpecial;
+}
+
+/* 设置警告 */
+void OneItem::setWarningText(QString str, int ms)
+{
+    ui->label_warnning->setText(str);
+    ui->label_warnning->show();
+    if(ms > 0)
+    {
+        m_warnTimer.start(ms);
+    }
+}
+
+/* 隐藏警告 */
+void OneItem::hideWarn()
+{
+    ui->label_warnning->hide();
+}
+
+/* 设备改变了 */
+void OneItem::do_devChanged(QString devName)
+{
+    /* 根据选择的设备,设置该设备的动作 */
+    ui->comboBox_action->clear();
+    auto it = DeviceContainer.getDevice(devName);
+    if(it.PTTypeCode > 0)
+    {
+        m_devInfo = it;
+        for(auto it1 = m_devInfo.DevType.devAction.begin();it1 != m_devInfo.DevType.devAction.end();it1++)
+        {
+            ui->comboBox_action->addItem(it1.value(), it1.key());
+        }
+    }else
+    {
+        LH_WRITE_ERROR(QString("没有这个设备:%1").arg(devName));
+        return;
+    }
+    emit signal_devChanged();
+}
+
+/* 动作改变了 */
+void OneItem::do_actionChanged(QString action)
+{
+
+}
+
+/* 执行时间被点击了 */
+void OneItem::do_pBtn_execTime_clicked()
+{
+    emit signal_execTimeClicked(getExecTime());
+}
+
+/* 执行日期被点击了 */
+void OneItem::do_pBtn_execDate_clicked()
+{
+    emit signal_dateClicked(getDate());
+}
+
+
+/* 根据日期类型布局 */
+void OneItem::layoutInit()
+{
+    /* 正常日,日期隐藏 */
+    if(!m_isSpecial)
+    {
+        ui->pBtn_execDate->hide();
+        ui->pBtn_iconDate->hide();
+        /* 序号 */
+        ui->label_num->move(18, 0);
+        /* 设备名称 */
+        ui->comboBox_devName->move(114, 0);
+        /* 执行时间 */
+        ui->pBtn_execTime->move(390, 40);
+        /* 执行时间图标 */
+        ui->pBtn_iconTime->move(498, 8);
+        /* 动作 */
+        ui->comboBox_action->move(538, 0);
+        /* 关闭 */
+        ui->pBtn_close->move(814, 0);
+    }else 
+    {
+        ui->pBtn_execDate->show();
+        ui->pBtn_iconDate->show();
+        /* 序号 */
+        ui->label_num->move(18, 0);
+        /* 设备名称 */
+        ui->comboBox_devName->move(114, 0);
+        /* 执行日期 */
+        ui->pBtn_execDate->move(390, 0);
+        /* 执行日期图标 */
+        ui->pBtn_iconDate->move(498, 8);
+        /* 执行时间 */
+        ui->pBtn_execTime->move(539, 40);
+        /* 执行时间图标 */
+        ui->pBtn_iconTime->move(646, 8);
+        /* 动作 */
+        ui->comboBox_action->move(686, 0);
+        /* 关闭 */
+        ui->pBtn_close->move(962, 0);
+    }
+}
+
+
+/* 事件过滤器 */
+bool OneItem::eventFilter(QObject *watched, QEvent *event)
+{
+    if(watched == ui->comboBox_action)
+    {
+        if(event->type() == QEvent::Wheel)
+        {
+            return true;
+        }
+    }
+    else if(watched == ui->comboBox_devName)
+    {
+        if(event->type() == QEvent::Wheel)
+        {
+            return true;
+        }
+    }
+    return QWidget::eventFilter(watched,event);
+}
+

+ 88 - 0
TransmitterSwitch/ItemData/oneitem.h

@@ -0,0 +1,88 @@
+#ifndef ONEITEM_H
+#define ONEITEM_H
+
+#include <QWidget>
+#include <QTimer>
+#include "TransmitterSwitchInfo.h"
+
+namespace Ui {
+class OneItem;
+}
+
+class OneItem : public QWidget
+{
+    Q_OBJECT
+
+public:
+    explicit OneItem(QWidget *parent = nullptr, bool isSpecial = false);
+    ~OneItem();
+
+    /* 设置序号 */
+    void setNum(int num);
+    /* 获取序号 */
+    int getNum();
+    /* 设置日期 */
+    void setDate(const QDate& date);
+    /* 获取日期 */
+    QDate getDate();
+    /* 设置执行时间 */
+    void setExecTime(const QTime& time);
+    /* 获取执行时间 */
+    QTime getExecTime();
+    /* 设置设备名称 */
+    void setDevName(const QString& dev);
+    /* 获取设备名称 */
+    QString getDevName();
+    /* 通过动作名称设置动作 */
+    void setActionName(const QString &action);
+    /* 获取动作名称 */
+    QString getActionName();
+    /* 获取动作类型 */
+    int getActionNum();
+    /* 添加设备 */
+    void addDevice(const QMap<QString, DeviceInfo>& mapDev);
+
+    /* 获取日期类型 */
+    bool getDateType();
+    /* 设置警告 */
+    void setWarningText(QString str,int ms = 3000);
+    /* 隐藏警告 */
+    void hideWarn();
+
+signals:
+    /* 一个OneItem被删除了 */
+    void signal_OneItemDelete(int num);
+    /* 日期被点击了 */
+    void signal_dateClicked(QDate date);
+    /* 执行时间被点击了 */
+    void signal_execTimeClicked(QTime time);
+    /* 设备改变了 */
+    void signal_devChanged();
+
+private slots:
+    /* 设备改变了 */
+    void do_devChanged(QString devName);
+    /* 动作改变了 */
+    void do_actionChanged(QString action);
+    /* 执行时间被点击了 */
+    void do_pBtn_execTime_clicked();
+    /* 执行日期被点击了 */
+    void do_pBtn_execDate_clicked();
+
+private:
+    /* 根据日期类型布局 */
+    void layoutInit();
+
+protected:
+    /* 事件过滤器 */
+    bool eventFilter(QObject *watched, QEvent *event);
+
+private:
+    Ui::OneItem *ui;
+
+    bool m_isSpecial = false;
+    QTimer m_warnTimer;
+    DeviceInfo m_devInfo;
+};
+
+#endif // ONEITEM_H

+ 306 - 0
TransmitterSwitch/ItemData/oneitem.ui

@@ -0,0 +1,306 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>OneItem</class>
+ <widget class="QWidget" name="OneItem">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>1220</width>
+    <height>48</height>
+   </rect>
+  </property>
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+    <horstretch>0</horstretch>
+    <verstretch>0</verstretch>
+   </sizepolicy>
+  </property>
+  <property name="minimumSize">
+   <size>
+    <width>0</width>
+    <height>48</height>
+   </size>
+  </property>
+  <property name="maximumSize">
+   <size>
+    <width>16777215</width>
+    <height>48</height>
+   </size>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <property name="spacing">
+    <number>0</number>
+   </property>
+   <property name="leftMargin">
+    <number>0</number>
+   </property>
+   <property name="topMargin">
+    <number>0</number>
+   </property>
+   <property name="rightMargin">
+    <number>0</number>
+   </property>
+   <property name="bottomMargin">
+    <number>0</number>
+   </property>
+   <item>
+    <widget class="QWidget" name="widget" native="true">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="minimumSize">
+      <size>
+       <width>0</width>
+       <height>48</height>
+      </size>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout_2">
+      <property name="spacing">
+       <number>0</number>
+      </property>
+      <property name="leftMargin">
+       <number>0</number>
+      </property>
+      <property name="topMargin">
+       <number>0</number>
+      </property>
+      <property name="rightMargin">
+       <number>0</number>
+      </property>
+      <property name="bottomMargin">
+       <number>0</number>
+      </property>
+      <item>
+       <widget class="QWidget" name="widget_content" native="true">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="minimumSize">
+         <size>
+          <width>0</width>
+          <height>32</height>
+         </size>
+        </property>
+        <widget class="QLabel" name="label_num">
+         <property name="geometry">
+          <rect>
+           <x>18</x>
+           <y>0</y>
+           <width>80</width>
+           <height>32</height>
+          </rect>
+         </property>
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="minimumSize">
+          <size>
+           <width>80</width>
+           <height>32</height>
+          </size>
+         </property>
+         <property name="text">
+          <string>序号</string>
+         </property>
+        </widget>
+        <widget class="QComboBox" name="comboBox_devName">
+         <property name="geometry">
+          <rect>
+           <x>114</x>
+           <y>0</y>
+           <width>260</width>
+           <height>32</height>
+          </rect>
+         </property>
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="minimumSize">
+          <size>
+           <width>260</width>
+           <height>32</height>
+          </size>
+         </property>
+         <property name="maximumSize">
+          <size>
+           <width>260</width>
+           <height>16777215</height>
+          </size>
+         </property>
+        </widget>
+        <widget class="QPushButton" name="pBtn_close">
+         <property name="geometry">
+          <rect>
+           <x>962</x>
+           <y>0</y>
+           <width>32</width>
+           <height>32</height>
+          </rect>
+         </property>
+         <property name="minimumSize">
+          <size>
+           <width>32</width>
+           <height>32</height>
+          </size>
+         </property>
+         <property name="maximumSize">
+          <size>
+           <width>32</width>
+           <height>32</height>
+          </size>
+         </property>
+         <property name="text">
+          <string/>
+         </property>
+        </widget>
+        <widget class="QComboBox" name="comboBox_action">
+         <property name="geometry">
+          <rect>
+           <x>686</x>
+           <y>0</y>
+           <width>260</width>
+           <height>32</height>
+          </rect>
+         </property>
+         <property name="minimumSize">
+          <size>
+           <width>260</width>
+           <height>32</height>
+          </size>
+         </property>
+         <property name="maximumSize">
+          <size>
+           <width>260</width>
+           <height>32</height>
+          </size>
+         </property>
+        </widget>
+        <widget class="QPushButton" name="pBtn_execDate">
+         <property name="geometry">
+          <rect>
+           <x>390</x>
+           <y>0</y>
+           <width>132</width>
+           <height>32</height>
+          </rect>
+         </property>
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="minimumSize">
+          <size>
+           <width>132</width>
+           <height>32</height>
+          </size>
+         </property>
+         <property name="maximumSize">
+          <size>
+           <width>132</width>
+           <height>32</height>
+          </size>
+         </property>
+         <property name="text">
+          <string>2025-01-16</string>
+         </property>
+        </widget>
+        <widget class="QPushButton" name="pBtn_execTime">
+         <property name="geometry">
+          <rect>
+           <x>538</x>
+           <y>0</y>
+           <width>132</width>
+           <height>32</height>
+          </rect>
+         </property>
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
+         </property>
+         <property name="minimumSize">
+          <size>
+           <width>132</width>
+           <height>32</height>
+          </size>
+         </property>
+         <property name="maximumSize">
+          <size>
+           <width>132</width>
+           <height>32</height>
+          </size>
+         </property>
+         <property name="text">
+          <string>00:00:00</string>
+         </property>
+        </widget>
+        <widget class="QPushButton" name="pBtn_iconDate">
+         <property name="geometry">
+          <rect>
+           <x>500</x>
+           <y>10</y>
+           <width>16</width>
+           <height>16</height>
+          </rect>
+         </property>
+         <property name="text">
+          <string/>
+         </property>
+        </widget>
+        <widget class="QPushButton" name="pBtn_iconTime">
+         <property name="geometry">
+          <rect>
+           <x>640</x>
+           <y>10</y>
+           <width>16</width>
+           <height>16</height>
+          </rect>
+         </property>
+         <property name="text">
+          <string/>
+         </property>
+        </widget>
+        <zorder>label_num</zorder>
+        <zorder>comboBox_devName</zorder>
+        <zorder>pBtn_close</zorder>
+        <zorder>comboBox_action</zorder>
+        <zorder>pBtn_execDate</zorder>
+        <zorder>pBtn_execTime</zorder>
+        <zorder>pBtn_iconTime</zorder>
+        <zorder>pBtn_iconDate</zorder>
+       </widget>
+      </item>
+      <item>
+       <widget class="QLabel" name="label_warnning">
+        <property name="text">
+         <string/>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

BIN
TransmitterSwitch/Resource/ICON/Date.png


BIN
TransmitterSwitch/Resource/ICON/Dialog_close.png


BIN
TransmitterSwitch/Resource/ICON/Dialog_close2.png


BIN
TransmitterSwitch/Resource/ICON/DownArrow.png


BIN
TransmitterSwitch/Resource/ICON/Time.png


+ 40 - 14
TransmitterSwitch/Resource/QSS/AddNormalItem.qss → TransmitterSwitch/Resource/QSS/AddNormalItem_Light.qss

@@ -30,16 +30,6 @@ QLabel#label_NC4
     background: #E6E9F4;
 }
 
-QLabel#label_NC5
-{
-	border-image: url(:/ESM-8C_ICON/Time.png);
-}
-/* QLabel#label_NC11
-{
-	border-image: url(:/ESM-8C_ICON/Date.png);
-} */
-
-
 QPushButton
 {
 	text-align: center;
@@ -47,11 +37,11 @@ QPushButton
 }
 
 QPushButton#pBtn_Close{
-	image: url(:/ESM-8C_ICON/Dialog_close.png);
+	image: url(:/ICON/ICON/Dialog_close.png);
 }
 QPushButton#pBtn_Close:hover
 {
-	image: url(:/ESM-8C_ICON/Dialog_close2.png);
+	image: url(:/ICON/ICON/Dialog_close2.png);
 }
 
 /********* 普通方框按钮三种状态效果 *********/
@@ -140,7 +130,7 @@ QComboBox::drop-down
 /* 下拉箭头图标 */
 QComboBox::down-arrow
 {
-    image: url(:/ESM-8C_ICON/DownArrow.png);
+    image: url(:/ICON/ICON/DownArrow.png);
     height:16px;
     width:16px;
 }
@@ -207,6 +197,10 @@ QComboBox QScrollBar::sub-line::vertical{/*下箭头*/
  *  时间报警红框
  * ========================================================== */
 
+QLabel#label_iconTime
+{
+	border-image: url(:/ICON/ICON/Time.png);
+}
 
 TimeWidget
 {
@@ -224,9 +218,41 @@ TimeWidget[Warn=true]
     border: 1px solid #D21F21;
 }
 
-TimeWidget:!enabled/* 或者disable */
+TimeWidget:!enabled
 {
     background: rgba(0,0,0,0.04);
     border: 1px solid #E6E9F4;
 }
 
+/* QPushButton#pBtn_selectTime
+{
+    background: transparent;
+    border: 1px solid #E6E9F4;
+    border-radius: 4px;
+    font-size: 14px;
+    font-weight: 400;
+    color: #3A3F63;
+    padding-left: 12px;
+    text-align: left;
+}
+
+QPushButton#pBtn_selectTime:hover
+{
+    background: transparent;
+    border: 1px solid #4458FE;
+    border-radius: 4px;
+    font-size: 14px;
+    font-weight: 400;
+    color: #4458FE;
+    padding-left: 12px;
+    text-align: left;
+}
+/* 报警红框 */
+QPushButton#pBtn_selectTime[Warn=true]
+{
+	background: transparent;
+    border-radius: 4px;
+    padding-left:12px;
+    border: 1px solid #D21F21;
+} */
+

+ 0 - 0
TransmitterSwitch/Resource/QSS/OneItem_dark.qss


+ 7 - 1
TransmitterSwitch/Resource/TransSwitch.qrc

@@ -1,7 +1,8 @@
 <RCC>
     <qresource prefix="/QSS">
         <file>QSS/TransmitterSwitch_dark.qss</file>
-        <file>QSS/AddNormalItem.qss</file>
+        <file>QSS/AddNormalItem_Light.qss</file>
+        <file>QSS/OneItem_dark.qss</file>
     </qresource>
     <qresource prefix="/ICON">
         <file>Tip/Complete2x.png</file>
@@ -17,6 +18,11 @@
         <file>ICON/rBtn_Unchaecked.png</file>
         <file>ICON/Tip_Light.png</file>
         <file>ICON/Tip_Dark.png</file>
+        <file>ICON/Dialog_close.png</file>
+        <file>ICON/Dialog_close2.png</file>
+        <file>ICON/Date.png</file>
+        <file>ICON/Time.png</file>
+        <file>ICON/DownArrow.png</file>
     </qresource>
     <qresource prefix="/Font">
         <file>font/SiYuanBlack_ttf/SiYuanBlack_Bold.ttf</file>

+ 18 - 6
TransmitterSwitch/TransmitterSwitchInfo.cpp

@@ -12,22 +12,17 @@ ExecPlanItemInfo::ExecPlanItemInfo()
     devName = "未定义";
     actionID = 0;
     actionName = "未定义";
-    // dateType = DateType::NormalDate;
-    // cfgDev = nullptr;
 }
 
 ExecPlanItemInfo::ExecPlanItemInfo(const ExecPlanItemInfo& item)
 {
     ExecType = item.ExecType;
     WeekDay = item.WeekDay;
-    // num = item.num;
     date = item.date;
     execTime = item.execTime;
     actionID = item.actionID;
     devName = item.devName;
     actionName = item.actionName;
-    // dateType = item.dateType;
-    // cfgDev = item.cfgDev;
 }
 
 ExecPlanItemInfo& ExecPlanItemInfo::operator=(const ExecPlanItemInfo& item)
@@ -103,7 +98,7 @@ DevTypeInfo MapDevType::getDevType(int PTTypeCode)
 DeviceInfo::DeviceInfo()
 {
     devName = "未定义";
-    PTTypeCode = 0;
+    PTTypeCode = -1;
     DevType = DevTypeInfo();
     DTID = 0;
     DID = 0;
@@ -158,6 +153,23 @@ DeviceInfo MapDevice::getDevice(const QString& devName)
     return DeviceInfo();
 }
 
+/* 查找一个设备 */
+bool MapDevice::findDevice(const QString& devName)
+{
+    return m_mapDevice.contains(devName);
+}
+
+/* 根据设备名称获取设备动作 */
+bool MapDevice::getDevAction(const QString& devName, QMap<int, QString>& devAction)
+{
+    if(m_mapDevice.contains(devName))
+    {
+        devAction = m_mapDevice[devName].DevType.devAction;
+        return true;
+    }
+    return false;
+}
+
 /* 删除一个设备 */
 void MapDevice::deleteDevice(const QString& devName)
 {

+ 7 - 1
TransmitterSwitch/TransmitterSwitchInfo.h

@@ -142,15 +142,21 @@ public:
     void addDevice(const DeviceInfo& devInfo);
     /* 获取一个设备 */
     DeviceInfo getDevice(const QString& devName);
+    /* 查找一个设备 */
+    bool findDevice(const QString& devName);
+    /* 根据设备名称获取设备动作 */
+    bool getDevAction(const QString& devName, QMap<int, QString>& devAction);
     /* 删除一个设备 */
     void deleteDevice(const QString& devName);
+    /* 获取容器 */
+    QMap<QString, DeviceInfo>& getMapDevice() { return m_mapDevice; }
 
 private:
     QMap<QString, DeviceInfo> m_mapDevice;          /* 设备信息,key是设备名称 */
 
 };
 
-
+#define DeviceContainer MapDevice::getInstance()
 
 
 #endif /* TRANSMITTERSWITCHINFO_H */

+ 13 - 9
TransmitterSwitch/WebAPI/FromWebAPI.cpp

@@ -65,7 +65,7 @@ bool FromWebAPI::initWebApi(const QString& url, const QString& serverID, const Q
 }
 
 /* 获取设备信息 */
-bool FromWebAPI::getDeviceInfo(QMap<int, DeviceInfo>& mapDevice)
+bool FromWebAPI::getDeviceInfo(QMap<QString, DeviceInfo>& mapDevice)
 {
     if(m_httpApi == nullptr)
     {
@@ -84,7 +84,8 @@ bool FromWebAPI::getDeviceInfo(QMap<int, DeviceInfo>& mapDevice)
         return false;
     }
     /* 解析获取到的JSON数据 */
-    // SPDLOG_LOGGER_DEBUG(m_logger,"\n{}",strRet.toStdString());
+    LH_WRITE_LOG_DEBUG(strRet);
+
     try 
     {
         nJson json1 = nJson::parse(strRet.toStdString());
@@ -126,9 +127,11 @@ bool FromWebAPI::getDeviceInfo(QMap<int, DeviceInfo>& mapDevice)
                 LH_WRITE_ERROR(QString("设备类型:%1《主/备》 类型为空").arg(DevInfo.DevType.PTTypeCode));
                 continue;
             }
-            mapDevice.insert(DevInfo.PTTypeCode, DevInfo);
+            mapDevice.insert(DevInfo.devName, DevInfo);
         }
 
+        LH_WRITE_LOG(QString("获取设备数据成功,设备数目:%1").arg(mapDevice.size()));
+
     } catch (const nJson::parse_error& e) {
         LH_WRITE_ERROR("解析ESM-8C设备数据失败");
         return false;
@@ -272,12 +275,11 @@ bool FromWebAPI::getExecPlanData(QList<ExecPlanItemInfo>& list)
         {
             ExecPlanItemInfo info;
             info.devName = QString::fromStdString(it["deviceName"].get<std::string>());
-            // info.cfgDev = DevInfo.findCfgDev(info.devName);
-            // if(info.cfgDev == nullptr)
-            // {
-            //     SPDLOG_LOGGER_WARN(m_logger,"未找到设备:{}", info.devName.toStdString());
-            //     continue;
-            // }
+            if(!DeviceContainer.findDevice(info.devName))
+            {
+                LH_WRITE_LOG(QString("未找到设备:%1").arg(info.devName));
+                continue;
+            }
 
             info.ExecType = it["execType"].get<int>();
             info.WeekDay = it["weekDay"].get<int>() - 1;
@@ -293,6 +295,8 @@ bool FromWebAPI::getExecPlanData(QList<ExecPlanItemInfo>& list)
             list.append(info);
         }
 
+        LH_WRITE_LOG(QString("获取tExecPlan表格数据成功,数据数目:%1").arg(list.size()));
+
     } catch (const nJson::parse_error& e) {
         LH_WRITE_ERROR(QString("解析tExecPlan表格数据失败:%1").arg(e.what()));
         return false;

+ 1 - 1
TransmitterSwitch/WebAPI/FromWebAPI.h

@@ -16,7 +16,7 @@ public:
     bool initWebApi(const QString& url,const QString& serverID,const QString& serverKey);
     
     /* 获取设备信息 */
-    bool getDeviceInfo(QMap<int, DeviceInfo>& mapDevice);
+    bool getDeviceInfo(QMap<QString, DeviceInfo>& mapDevice);
 
     /* 将数据写入EQM数据库 */
     bool insertData(QList<ExecPlanItemInfo>& list);

+ 30 - 5
TransmitterSwitch/transmitterswitch.cpp

@@ -2,12 +2,15 @@
 #include "ui_transmitterswitch.h"
 
 #include <QFile>
+#include <QList>
 #include <memory>
 
 #include "LHQLogAPI.h"
 #include "widgetitems.h"
 #include "UserData/pBtnUserData.h"
 #include "AddItem/addnormalitem.h"
+#include "WebAPI/FromWebAPI.h"
+#include "transmitterswitchinfo.h"
 
 TransmitterSwitch::TransmitterSwitch(QWidget *parent) :
     QWidget(parent),
@@ -15,6 +18,8 @@ TransmitterSwitch::TransmitterSwitch(QWidget *parent) :
 {
     ui->setupUi(this);
 
+    /* 创建WebAPI实例 */
+    m_fromWebAPI = new FromWebAPI;
 
     /* 设置“默认计划”按钮可点击 */
     ui->pBtn_defaultPlan->setCheckable(true);
@@ -39,8 +44,8 @@ TransmitterSwitch::TransmitterSwitch(QWidget *parent) :
     m_vecWeeks[day]->setChecked(true);
 
     /* 连接信号和槽 */
-    connect(ui->pBtn_addPlan,&QPushButton::clicked,this,&TransmitterSwitch::do_pBtnAddExecPlan);
-
+    connect(ui->pBtn_addPlan, &QPushButton::clicked, this, &TransmitterSwitch::do_pBtnAddExecPlan);
+    connect(ui->pBtn_importPlan, &QPushButton::clicked, this, &TransmitterSwitch::do_importData);
 }
 
 TransmitterSwitch::~TransmitterSwitch()
@@ -81,7 +86,18 @@ void TransmitterSwitch::setQSS(const QString &qssPath)
  */
 void TransmitterSwitch::setWebAPIInfo(const QString &url, const QString &serverID, const QString &serverKey)
 {
-    
+    if(m_fromWebAPI == nullptr)
+    {
+        m_fromWebAPI = new FromWebAPI;
+    }
+    if(url.isEmpty() || serverID.isEmpty() || serverKey.isEmpty())
+    {
+        LH_WRITE_ERROR("WebAPI info is empty");
+        return;
+    }
+    m_fromWebAPI->initWebApi(url,serverID,serverKey);
+    /* 获取支持的设备 */
+    m_fromWebAPI->getDeviceInfo(DeviceContainer.getMapDevice());
 }
 
 
@@ -116,10 +132,12 @@ void TransmitterSwitch::do_pBtnAddExecPlan()
     if(ui->stackedWidget_items->currentIndex() < 7)
     {
         std::shared_ptr<AddNormalItem> atf = std::make_shared<AddNormalItem>(this);
+        atf->setParentPointer(this);
         connect(atf.get(),SIGNAL(signal_addNormalItem(QString,QString,QTime)),this,SLOT(do_addNormalOneItem(QString,QString,QTime)));
-
+        /* 设置可选项 */
+        atf->setDevice(DeviceContainer.getMapDevice());
         atf->exec();
-        atf->setAttribute(Qt::WA_DeleteOnClose,true);
+        // atf->setAttribute(Qt::WA_DeleteOnClose,true);
     }
     else        /* 特殊日 */
     {
@@ -137,6 +155,13 @@ void TransmitterSwitch::do_addNormalOneItem(QString devName, QString action, QTi
 
 }
 
+/* 导入数据 */
+void TransmitterSwitch::do_importData()
+{
+    QList<ExecPlanItemInfo> list;
+    m_fromWebAPI->getExecPlanData(list);
+}
+
 
 /* 创建一周8天的item页面 */
 void TransmitterSwitch::createWeekWidget()

+ 5 - 0
TransmitterSwitch/transmitterswitch.h

@@ -7,6 +7,7 @@
 #include <QLabel>
 
 class WidgetItems;
+class FromWebAPI;
 
 namespace Ui {
 class TransmitterSwitch;
@@ -33,6 +34,8 @@ private slots:
 
     /* 添加一项正常日计划 */
     void do_addNormalOneItem(QString devName, QString action, QTime execTime);
+    /* 导入数据 */
+    void do_importData();
 
 private:
     /* 创建一周8天的item页面 */
@@ -51,6 +54,8 @@ private:
     QVector<QPushButton*> m_vecWeeks;       /* 存储一周8天的按钮指针,方便后续操作 */
     QVector<WidgetItems*> m_vecWidgetItems; /* 存储每周8天的item页面 */
     QVector<QLayout*> m_vecLayouts;         /* 存储每周8天的layout,item都添加到这里面 */
+
+    FromWebAPI* m_fromWebAPI = nullptr;     /* WebAPI操作类 */
     
 };
 

+ 6 - 2
show1/CMakeLists.txt

@@ -16,13 +16,14 @@ file(GLOB LOCAL_SRC
     ${CMAKE_SOURCE_DIR}/TransmitterSwitch/WidgetItems/*.cpp
     ${CMAKE_SOURCE_DIR}/TransmitterSwitch/UserData/*.cpp
     ${CMAKE_SOURCE_DIR}/TransmitterSwitch/AddItem/*.cpp
+    ${CMAKE_SOURCE_DIR}/TransmitterSwitch/ItemData/*.cpp
 
     ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/Shadow/*.cpp
     ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/ImageBlur/*.cpp
     ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/combobox/*.cpp
     ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/SelectTime/*.cpp
 
-    ${LHQLog_SOURCE_DIRS}/*.cpp
+    # ${LHQLog_SOURCE_DIRS}/*.cpp
     ${LHHTTPAPI_SOURCE_DIRS}/*.cpp
 )
 
@@ -36,6 +37,7 @@ add_executable(${execName1} ${LOCAL_SRC})
 #添加头文件
 target_include_directories(${execName1} PRIVATE
     ${CMAKE_CURRENT_SOURCE_DIR}
+    ${CMAKE_CURRENT_SOURCE_DIR}/LHLog
 
     ${CMAKE_SOURCE_DIR}/External/common/Thread
 
@@ -44,6 +46,7 @@ target_include_directories(${execName1} PRIVATE
     ${CMAKE_SOURCE_DIR}/TransmitterSwitch/WidgetItems
     ${CMAKE_SOURCE_DIR}/TransmitterSwitch/UserData
     ${CMAKE_SOURCE_DIR}/TransmitterSwitch/AddItem
+    ${CMAKE_SOURCE_DIR}/TransmitterSwitch/ItemData
 
     ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common
     ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/nlohmann
@@ -52,7 +55,8 @@ target_include_directories(${execName1} PRIVATE
     ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/combobox
     ${CMAKE_SOURCE_DIR}/TransmitterSwitch/common/SelectTime
 
-    ${LHQLog_INCLUDE_DIRS}
+
+    # ${LHQLog_INCLUDE_DIRS}
     ${LHHTTPAPI_INCLUDE_DIRS}
     ${spdlog_INCLUDE_DIR}
 )

+ 1 - 0
show1/LHLog/LHQLogAPI.cpp

@@ -0,0 +1 @@
+

+ 33 - 0
show1/LHLog/LHQLogAPI.h

@@ -0,0 +1,33 @@
+#pragma once
+
+#include <QString>
+#include "spdlog/spdlog.h"
+
+/** ====================================================================================================
+ * ***************************************  对外API **************************************************
+ * ====================================================================================================*/
+
+/**
+ * @brief 兼容LHQLogAPI的输出方式
+ * 
+ */
+#define LH_WRITE_LOG_DEBUG(_log_msg) \
+    do {                                                                        \
+        QString _log_str = _log_msg;                                            \
+        SPDLOG_DEBUG(_log_str.toStdString());                                   \
+    } while(0)
+
+#define LH_WRITE_LOG(_log_msg)       \
+    do {                                                                        \
+        QString _log_str = _log_msg;                                            \
+        SPDLOG_INFO(_log_str.toStdString());                                    \
+    } while (0)
+
+#define LH_WRITE_ERROR(_log_msg)    \
+    do {                                                                        \
+        QString _log_str = _log_msg;                                            \
+        SPDLOG_ERROR(_log_str.toStdString());                                   \
+    } while (0)
+
+
+

+ 2 - 0
show1/main.cpp

@@ -15,6 +15,8 @@ int main(int argc, char *argv[])
     QApplication a(argc, argv);
     addFont();
 
+    /* 设置日志输出等级 */
+    spdlog::set_level(spdlog::level::debug);
 
     Widget w;
     w.show();

+ 3 - 0
show1/widget.cpp

@@ -21,6 +21,9 @@ Widget::Widget(QWidget *parent) :
     /* 设置参数 */
     m_tSwitch->setQSS(":/QSS/QSS/TransmitterSwitch_dark.qss");
 
+    /* 初始化WebAPI */
+    m_tSwitch->setWebAPIInfo("http://192.1.3.133:31000/v6/", "2e36b53ccd2a433b9a803b98d683ed91", "TMS");
+
 }
 
 Widget::~Widget()