فهرست منبع

V1.3.7
1、完成了复制计划的页面
2、完成了导入计划的页面

apple 2 هفته پیش
والد
کامیت
f49767a922

+ 2 - 2
TransmitterSwitch/CMakeLists.txt

@@ -15,11 +15,11 @@ file(GLOB LOCAL_SRC
     ${CMAKE_CURRENT_SOURCE_DIR}/Resource/*.qrc
     ${CMAKE_CURRENT_SOURCE_DIR}/UserData/*.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/ExecPlanData/*.cpp
-    # ${CMAKE_CURRENT_SOURCE_DIR}/ItemData/*.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/Template/*.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/warnning/*.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/UIStyle/*.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/ManagerPlan/*.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/CopyToOther/*.cpp
 
     ${CMAKE_CURRENT_SOURCE_DIR}/common/Thread/*.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/common/Shadow/*.cpp
@@ -57,11 +57,11 @@ target_include_directories(${lib_name} PRIVATE
     ${CMAKE_CURRENT_SOURCE_DIR}/WebAPI
     ${CMAKE_CURRENT_SOURCE_DIR}/UserData
     ${CMAKE_CURRENT_SOURCE_DIR}/ExecPlanData
-    # ${CMAKE_CURRENT_SOURCE_DIR}/ItemData
     ${CMAKE_CURRENT_SOURCE_DIR}/Template
     ${CMAKE_CURRENT_SOURCE_DIR}/warnning
     ${CMAKE_CURRENT_SOURCE_DIR}/UIStyle
     ${CMAKE_CURRENT_SOURCE_DIR}/ManagerPlan
+    ${CMAKE_CURRENT_SOURCE_DIR}/CopyToOther
 
     ${CMAKE_CURRENT_SOURCE_DIR}/common
     ${CMAKE_CURRENT_SOURCE_DIR}/common/Thread

+ 233 - 0
TransmitterSwitch/CopyToOther/copytoother.cpp

@@ -0,0 +1,233 @@
+#include "copytoother.h"
+#include "ui_copytoother.h"
+
+#include <QDebug>
+#include <QPoint>
+#include <QTableWidgetItem>
+#include <QFile>
+#include <QPainter>
+#include <QMouseEvent>
+#include <QCheckBox>
+#include <QVBoxLayout>
+#include <qcheckbox.h>
+
+#include "warning/warning.h"
+#include "LHQLogAPI.h"
+#include "OneShadowEffect.h"
+#include "TransmitterSwitchInfo.h"
+#include "UIStyleManager.h"
+#include "template.h"
+
+CopyToOther::CopyToOther(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::CopyToOther)
+{
+    ui->setupUi(this);
+
+    /* 设置隐藏边框 */
+    this->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
+    /* 设置底层样式表 */
+    this->setAttribute(Qt::WA_TranslucentBackground);
+    /* 创建阴影 */
+    QSize size = this->size();
+    size.setWidth(size.width() - 40);
+    size.setHeight(size.height() - 40);
+
+    auto pShadow = new OneShadowEffect(this);
+    this->setGraphicsEffect(pShadow);
+
+    /* 给滚动区域添加一个布局 */
+    m_layout = new QVBoxLayout(ui->scrollAreaWidgetContents);
+    m_layout->setContentsMargins(0, 0, 0, 0);
+    m_layout->setSpacing(0);
+    ui->scrollAreaWidgetContents->setLayout(m_layout);
+    /* 添加一个竖直弹簧 */
+    auto pSpacerItem = new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding);
+    m_layout->addItem(pSpacerItem);
+
+
+    connect(ui->pBtn_close,SIGNAL(clicked()),this,SLOT(close()));
+    connect(ui->pBtn_cancel,SIGNAL(clicked()),this,SLOT(close()));
+    connect(ui->pBtn_ok,SIGNAL(clicked()),this,SLOT(do_ok()));
+
+    connect(ui->checkBox_list, &QCheckBox::stateChanged, this, &CopyToOther::do_checkBox_stateChanged);
+
+    /* 注册事件过滤器 */
+    ui->pBtn_close->installEventFilter(this);
+
+}
+
+CopyToOther::~CopyToOther()
+{
+    delete ui;
+}
+
+/**
+ * @brief 设置频率列表,并去掉当前的频率
+ * 
+ * @param currChn 
+ * @param list 
+ */
+void CopyToOther::setFrequencyList(ChannelInfo& currChn, QMap<int, ChannelInfo>& list)
+{
+    for(auto it : list)
+    {
+        if(it.ChannelID == currChn.ChannelID)
+        {
+            continue; /* 跳过当前频率 */
+        }
+        createRow(it);
+    }
+}
+
+void CopyToOther::do_ok()
+{
+    /* 获取已选中的模版列表 */
+    for(auto it : m_listCheckBox)
+    {
+        if(it->isChecked())
+        {
+            auto chnID = it->property(m_propertyChnID.c_str()).toInt();
+            OneTemplateInfo info;
+            info.channelInfo.ChannelID = chnID;
+            info.channelInfo.ChannelName = it->text();
+            info.templateName = it->text() + QString::number(chnID);
+        }
+    }
+
+
+    m_isOk = true;
+    emit signal_templateName(m_templateName);
+    this->close();
+}
+
+/* 点击了一个checkBox,取消其他同频率的checkBox */
+void CopyToOther::do_checkBox_stateChanged(int state)
+{
+    auto checkBox = qobject_cast<QCheckBox*>(sender());
+    if(checkBox == nullptr)
+    {
+        return;
+    }
+    /* 先判断是不是全选 */
+    if(checkBox == ui->checkBox_list)
+    {
+        /* 判断是全选还是取消全选 */
+        if(state == Qt::Checked)
+        {
+            for(auto it : m_listCheckBox)
+            {
+                it->setChecked(true);
+            }
+        }else {
+            for(auto it : m_listCheckBox)
+            {
+                it->setChecked(false);
+            }
+        }
+        return;
+    }
+
+}
+
+/* 显示事件 */
+void CopyToOther::showEvent(QShowEvent *event)
+{
+
+}
+
+
+/* 设置QSS */
+void CopyToOther::setQSSPath(const QString& qssPath)
+{
+    if(qssPath.isEmpty())
+    {
+        return;
+    }
+    QString qssFile = qssPath + "/copytoother.qss";
+    QFile file(qssFile);
+    if(file.open(QFile::ReadOnly))
+    {
+        QString styleSheet = file.readAll();
+        this->setStyleSheet(styleSheet);
+        file.close();
+    }else 
+    {
+        LH_WRITE_ERROR(QString("Open %1 failed").arg(qssFile));
+    }
+
+}
+
+
+
+/* 添加一行 */
+void CopyToOther::createRow(const ChannelInfo& info)
+{
+    QCheckBox* checkBox = new QCheckBox(this);
+    checkBox->setText(info.ChannelName);
+    checkBox->setProperty(m_propertyChnID.c_str(), info.ChannelID);
+    checkBox->setMinimumHeight(34);
+    connect(checkBox, &QCheckBox::stateChanged, this, &CopyToOther::do_checkBox_stateChanged);
+    /* 插入到最后一个弹簧之前 */
+    m_layout->insertWidget(m_layout->count() - 1, checkBox);
+    /* 添加到列表中 */
+    m_listCheckBox.append(checkBox);
+}
+
+/* 事件过滤器 */
+bool CopyToOther::eventFilter(QObject *watched, QEvent *event)
+{
+    if(watched == ui->pBtn_close)
+    {
+        if(event->type() == QEvent::Enter)
+        {
+            ui->pBtn_close->setProperty("Hover", true);
+            ui->pBtn_close->style()->unpolish(ui->pBtn_close);
+            ui->pBtn_close->style()->polish(ui->pBtn_close);
+
+            return true;
+        }else if(event->type() == QEvent::Leave)
+        {
+            ui->pBtn_close->setProperty("Hover", false);
+            ui->pBtn_close->style()->unpolish(ui->pBtn_close);
+            ui->pBtn_close->style()->polish(ui->pBtn_close);
+
+            return true;
+        }
+    }
+    return QWidget::eventFilter(watched,event);
+}
+
+/* 鼠标点击事件 */
+void CopyToOther::mousePressEvent(QMouseEvent *event)
+{
+    m_lastPos = event->globalPos();
+    event->accept();
+}
+
+/* 鼠标移动事件 */
+void CopyToOther::mouseMoveEvent(QMouseEvent *event)
+{
+    // QRect rect = this->geometry();
+    // rect.setBottom(rect.top()+50);
+    auto point = ui->widget_Top->mapToGlobal(QPoint(0, 0));
+    QRect rect(point, ui->widget_Top->size());
+
+    if(!rect.contains(m_lastPos))
+    {
+        event->accept();
+        return;
+    }
+
+    int dx = event->globalX() - m_lastPos.x();
+    int dy = event->globalY() - m_lastPos.y();
+    move(x()+dx, y()+dy);
+    m_lastPos = event->globalPos();
+    event->accept();
+}
+
+/* 鼠标释放事件 */
+void CopyToOther::mouseReleaseEvent(QMouseEvent *event)
+{
+    event->accept();
+}

+ 76 - 0
TransmitterSwitch/CopyToOther/copytoother.h

@@ -0,0 +1,76 @@
+#ifndef COPYTOOTHER_H
+#define COPYTOOTHER_H
+
+#include "TransmitterSwitchInfo.h"
+#include <QDialog>
+#include <QCheckBox>
+#include <qboxlayout.h>
+#include <qlist.h>
+
+class TemplateItem;
+class OneShadow;
+class OneTemplateInfo;
+class QVBoxLayout;
+
+namespace Ui {
+class CopyToOther;
+}
+
+class CopyToOther : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit CopyToOther(QWidget *parent = nullptr);
+    ~CopyToOther();
+
+    /* 设置频率列表 */
+    void setFrequencyList(ChannelInfo& currChn, QMap<int, ChannelInfo>& list);
+    /* 获取选中的频率列表 */
+    QList<ChannelInfo>& getSelectedFrequencyList() { return m_listChannel; }
+    /* 是否点下了OK */
+    bool isOk() const { return m_isOk; }
+    /* 设置QSS */
+    void setQSSPath(const QString& qssPath);
+    
+signals:
+    /* 选择一个模版 */
+    void signal_templateName(QString name);
+
+private:
+    /* 添加一行 */
+    void createRow(const ChannelInfo& info);
+
+private slots:
+    void do_ok();
+    /* 点击了一个checkBox,取消其他同频率的checkBox */
+    void do_checkBox_stateChanged(int state);
+
+protected:
+    /* 显示事件 */
+    void showEvent(QShowEvent *event) override;
+    /* 事件过滤器 */
+    bool eventFilter(QObject *watched, QEvent *event) override;
+    /* 鼠标点击事件 */
+    void mousePressEvent(QMouseEvent *event) override;
+    /* 鼠标移动事件 */
+    void mouseMoveEvent(QMouseEvent *event) override;
+    /* 鼠标释放事件 */
+    void mouseReleaseEvent(QMouseEvent *event) override;
+
+private:
+    Ui::CopyToOther *ui;
+
+    QVBoxLayout* m_layout = nullptr;                    /* 垂直布局 */
+    bool m_isOk = false;                                /* 是否点下了OK */
+    QString m_templateName;                             /* 模版名称 */
+    int m_type = -1;                                    /* 模版类型 */
+
+    QPoint m_lastPos;                                   /* 鼠标点击的位置 */
+    const std::string m_propertyChnID = "ChannelID";    /* 属性名称 */
+
+    QList<QCheckBox*> m_listCheckBox;                  /* checkBox列表 */
+    QList<ChannelInfo> m_listChannel;                  /* 频率列表 */
+};
+
+#endif // COPYTOOTHER_H

+ 258 - 0
TransmitterSwitch/CopyToOther/copytoother.ui

@@ -0,0 +1,258 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CopyToOther</class>
+ <widget class="QDialog" name="CopyToOther">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>448</width>
+    <height>632</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <property name="styleSheet">
+   <string notr="true"/>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <property name="spacing">
+    <number>0</number>
+   </property>
+   <property name="leftMargin">
+    <number>20</number>
+   </property>
+   <property name="topMargin">
+    <number>20</number>
+   </property>
+   <property name="rightMargin">
+    <number>20</number>
+   </property>
+   <property name="bottomMargin">
+    <number>20</number>
+   </property>
+   <item>
+    <widget class="QWidget" name="widget" native="true">
+     <property name="styleSheet">
+      <string notr="true"/>
+     </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>32</number>
+      </property>
+      <item>
+       <widget class="QWidget" name="widget_Top" native="true">
+        <property name="minimumSize">
+         <size>
+          <width>0</width>
+          <height>63</height>
+         </size>
+        </property>
+        <property name="maximumSize">
+         <size>
+          <width>16777215</width>
+          <height>63</height>
+         </size>
+        </property>
+        <layout class="QHBoxLayout" name="horizontalLayout">
+         <property name="spacing">
+          <number>0</number>
+         </property>
+         <property name="leftMargin">
+          <number>32</number>
+         </property>
+         <property name="rightMargin">
+          <number>16</number>
+         </property>
+         <item>
+          <widget class="QLabel" name="label_title">
+           <property name="minimumSize">
+            <size>
+             <width>140</width>
+             <height>24</height>
+            </size>
+           </property>
+           <property name="text">
+            <string>复制到其他频率</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <spacer name="horizontalSpacer">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>536</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+         <item>
+          <widget class="QPushButton" name="pBtn_close">
+           <property name="minimumSize">
+            <size>
+             <width>32</width>
+             <height>32</height>
+            </size>
+           </property>
+           <property name="text">
+            <string/>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </widget>
+      </item>
+      <item>
+       <widget class="QWidget" name="widget_content" native="true">
+        <property name="minimumSize">
+         <size>
+          <width>0</width>
+          <height>0</height>
+         </size>
+        </property>
+        <layout class="QVBoxLayout" name="verticalLayout_3">
+         <property name="spacing">
+          <number>0</number>
+         </property>
+         <property name="leftMargin">
+          <number>32</number>
+         </property>
+         <property name="topMargin">
+          <number>32</number>
+         </property>
+         <property name="rightMargin">
+          <number>32</number>
+         </property>
+         <property name="bottomMargin">
+          <number>32</number>
+         </property>
+         <item>
+          <widget class="QCheckBox" name="checkBox_list">
+           <property name="minimumSize">
+            <size>
+             <width>0</width>
+             <height>46</height>
+            </size>
+           </property>
+           <property name="text">
+            <string>频率列表</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QScrollArea" name="scrollArea">
+           <property name="widgetResizable">
+            <bool>true</bool>
+           </property>
+           <widget class="QWidget" name="scrollAreaWidgetContents">
+            <property name="geometry">
+             <rect>
+              <x>0</x>
+              <y>0</y>
+              <width>342</width>
+              <height>351</height>
+             </rect>
+            </property>
+           </widget>
+          </widget>
+         </item>
+        </layout>
+       </widget>
+      </item>
+      <item>
+       <widget class="QWidget" name="widget_bottom" native="true">
+        <property name="minimumSize">
+         <size>
+          <width>0</width>
+          <height>34</height>
+         </size>
+        </property>
+        <property name="maximumSize">
+         <size>
+          <width>16777215</width>
+          <height>34</height>
+         </size>
+        </property>
+        <layout class="QHBoxLayout" name="horizontalLayout_2">
+         <property name="spacing">
+          <number>8</number>
+         </property>
+         <property name="leftMargin">
+          <number>0</number>
+         </property>
+         <property name="topMargin">
+          <number>0</number>
+         </property>
+         <property name="rightMargin">
+          <number>32</number>
+         </property>
+         <property name="bottomMargin">
+          <number>0</number>
+         </property>
+         <item>
+          <spacer name="horizontalSpacer_2">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>463</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+         <item>
+          <widget class="QPushButton" name="pBtn_cancel">
+           <property name="minimumSize">
+            <size>
+             <width>68</width>
+             <height>32</height>
+            </size>
+           </property>
+           <property name="text">
+            <string>取消</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QPushButton" name="pBtn_ok">
+           <property name="minimumSize">
+            <size>
+             <width>68</width>
+             <height>32</height>
+            </size>
+           </property>
+           <property name="text">
+            <string>确定</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 194 - 0
TransmitterSwitch/Resource/QSS/dark/copytoother.qss

@@ -0,0 +1,194 @@
+QWidget
+{
+    background: transparent;
+
+    font-size: 14px;
+    color: #D2D2D2;
+    line-height: 21px;
+    text-align: left;
+    font-style: normal;
+}
+
+QWidget#widget
+{
+    background: #464649;
+    border-radius: 8px 8px 8px 8px;
+}
+
+QWidget#widget_Top
+{
+    background: transparent;
+    border-top-left-radius: 8px;
+    border-top-right-radius: 8px;
+    border-bottom-left-radius: 0px;
+    border-bottom-right-radius: 0px;
+
+    border-bottom: 1px solid rgba(255,255,255,0.15);
+}
+
+QLabel#label_title
+{
+    font-weight: 500;
+    font-size: 18px;
+    color: #D2D2D2;
+    line-height: 24px;
+    text-align: left;
+    font-style: normal;
+    text-transform: none;
+}
+
+
+QPushButton#pBtn_close
+{
+	/* border-image: url(:/ICON/ICON/Dialog_close.png); */
+    background: transparent;
+    border-radius: 4px;
+    qproperty-icon: url(:/ICON/ICON/Close_Dark.png);
+    qproperty-iconSize: 20px 20px;
+
+    text-align: center;
+}
+
+QPushButton#pBtn_close[Hover = true]
+{	
+	/* border-image: url(:/ICON/ICON/Dialog_close2.png); */
+    background: transparent;
+    border-radius: 4px;
+    qproperty-icon: url(:/ICON/ICON/Close_pass.png);
+    qproperty-iconSize: 20px 20px;
+    text-align: center;
+    border: 1px solid #438EFF;
+}
+
+
+
+/********* 普通方框按钮三种状态效果 *********/
+QPushButton#pBtn_cancel:enabled
+{
+    text-align: center;
+    color: #EBEBEB;
+    border: 1px solid rgba(255,255,255,0.25);
+    border-radius: 16px;
+    background: transparent;
+}
+QPushButton#pBtn_cancel:hover
+{
+    text-align: center;
+    color: #EBEBEB;
+    border: 1px solid rgba(255,255,255,0.25);
+    border-radius: 16px;
+    background: rgba(0,0,0,0.15);
+}
+
+
+/********* 带有底色按钮三种状态效果 *********/
+QPushButton#pBtn_ok
+{
+	border-radius: 16px;
+	text-align: center;
+    color:white;
+    background: #438EFF;
+    border-radius: 16px;
+}
+
+QPushButton#pBtn_ok:hover
+{
+	border-radius: 16px;
+	text-align: center;
+    color:white;
+    background: #5F9EFF;
+    border-radius: 16px;
+}
+
+/* ==========================================================
+ *  QCheckBox
+ * ========================================================== */
+
+/* 左下角和右下角是直角 */
+QCheckBox#checkBox_list
+{
+    font-weight: 500;
+    font-size: 16px;
+    color: #D2D2D2;
+    text-align: left;
+    font-style: normal;
+    text-transform: none;
+
+    padding-left: 16px;
+
+    border-top-left-radius: 4px;
+    border-top-right-radius: 4px;
+    border-bottom-left-radius: 0px;
+    border-bottom-right-radius: 0px;
+
+    border: 1px solid rgba(255,255,255,0.15);
+}
+
+QCheckBox
+{
+    font-weight: 400;
+    font-size: 14px;
+    color: #B1B3B4;
+    text-align: left;
+    font-style: normal;
+    text-transform: none;
+
+    padding-left: 16px;
+}
+
+/*===============================================================
+ * QScrollBar 滚动条
+ ================================================================*/
+QScrollArea
+{
+	background:transparent;
+	border-top-left-radius: 0px;
+    border-top-right-radius: 0px;
+    border-bottom-left-radius: 4px;
+    border-bottom-right-radius: 4px;
+
+	border-left: 1px solid rgba(255,255,255,0.15);
+    border-right: 1px solid rgba(255,255,255,0.15);
+    border-bottom: 1px solid rgba(255,255,255,0.15);
+}
+QScrollBar:horizontal, QScrollBar:vertical
+{
+    border:none;
+    background-color: rgba(255, 255, 255, 0);
+    margin: 0px 0px 0px 0px;
+}
+QScrollBar:horizontal
+{
+    height: 12px;
+}
+QScrollBar:vertical
+{
+    width: 6px;
+}
+QScrollBar::handle:horizontal,QScrollBar::handle:vertical
+{
+    background: #E2E2E2;
+    border-radius: 3px;
+    min-width: 8px;
+}
+QScrollBar::handle:horizontal
+{
+    min-width: 8px;
+}
+QScrollBar::handle:vertical
+{
+    min-height: 113px;
+}
+QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal,
+QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical
+{
+    background-color: rgba(255, 255, 255, 0);
+    border: none;
+}
+QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal,
+QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical
+{
+    background-color: rgba(255, 255, 255, 0);
+    background: none;
+}
+

+ 1 - 0
TransmitterSwitch/Resource/QSS/dark/plancard.qss

@@ -5,6 +5,7 @@
 
 QWidget#widget
 {
+    background: transparent;
     border-radius: 4px 4px 4px 4px;
     border: 1px solid rgba(255,255,255,0.15);
 }

+ 1 - 1
TransmitterSwitch/Resource/QSS/dark/transmitterswitch.qss

@@ -17,7 +17,7 @@ QWidget
 /* 整体背景 */
 QWidget#widget
 {
-    background: transparent;
+    background: #070709;
 }
 
 QPushButton

+ 1 - 0
TransmitterSwitch/Resource/TransSwitch.qrc

@@ -25,6 +25,7 @@
         <file>QSS/dark/pBtn_frequency.qss</file>
         <file>QSS/dark/plancard.qss</file>
         <file>QSS/dark/managerplan.qss</file>
+        <file>QSS/dark/copytoother.qss</file>
     </qresource>
     <qresource prefix="/ICON">
         <file>Tip/Complete2x.png</file>

+ 103 - 23
TransmitterSwitch/WebAPI/FromWebAPI.cpp

@@ -175,14 +175,13 @@ bool FromWebAPI::getDeviceInfo(QMap<QString, DeviceInfo>& mapDevice)
 bool FromWebAPI::getChannelInfo(QMap<int, ChannelInfo>& mapFreq)
 {
     /* 测试,创建几个频率 */
-    // for(int i = 0; i < 12; i++)
-    // {
-    //     ChannelInfo freqInfo;
-    //     freqInfo.ChannelID = i + 1;
-    //     freqInfo.ChannelName = QString("频率%1").arg(freqInfo.ChannelID);
-    //     mapFreq.insert(freqInfo.ChannelID, freqInfo);
-    // }
-
+    for(int i = 0; i < 12; i++)
+    {
+        ChannelInfo freqInfo;
+        freqInfo.ChannelID = i + 1;
+        freqInfo.ChannelName = QString("频率%1").arg(freqInfo.ChannelID);
+        mapFreq.insert(freqInfo.ChannelID, freqInfo);
+    }
 
 
     if(m_httpApi == nullptr)
@@ -410,6 +409,7 @@ bool FromWebAPI::getExecPlanData(int chnID, QList<OnePlanItemInfo>& list)
 
 bool FromWebAPI::getExecPlanData(QMap<int, QList<OnePlanItemInfo>>& mapPlan)
 {
+
     if(m_httpApi == nullptr)
     {
         LH_WRITE_ERROR("WebAPI is nullptr");
@@ -901,7 +901,7 @@ bool FromWebAPI::saveTemplate(const QString& templateName, QList<OnePlanItemInfo
 }
 
 /* 获取模板内容 */
-bool FromWebAPI::getTemplate(QString templateName, QList<OnePlanItemInfo>& list)
+bool FromWebAPI::getOneTemplateData(QString templateName, QList<OnePlanItemInfo>& list)
 {
     if(m_httpApi == nullptr)
     {
@@ -935,20 +935,15 @@ bool FromWebAPI::getTemplate(QString templateName, QList<OnePlanItemInfo>& list)
         for(auto& it : result)
         {
             OnePlanItemInfo info;
-            // info.devName = QString::fromStdString(it["deviceName"].get<std::string>());
-            // if(!DeviceContainer.findDevice(info.devName))
-            // {
-            //     LH_WRITE_LOG(QString("未找到设备:%1").arg(info.devName));
-            //     continue;
-            // }
-            // auto tmpDate = it["execDate"].is_null() ? "" : it["execDate"].get<std::string>();
-            // if(!tmpDate.empty())
-            // {
-            //     info.dateTime.setDate(QDate::fromString(QString::fromStdString(tmpDate),"yyyy-MM-dd"));
-            // }
-            // info.dateTime.setTime(QTime::fromString(QString::fromStdString(it["execTime"].get<std::string>()),"hh:mm:ss"));
-            // info.actionName = QString::fromStdString(it["actionName"].get<std::string>());
-            // info.actionID = it["actionID"].get<int>();
+            
+            info.ChannelID = it["channelID"].is_null() ? -1 : it["channelID"].get<int>();
+            info.ChannelName = QString::fromStdString(it["channelName"].get<std::string>());
+            info.onWeekDay = static_cast<enum_WeekDay>(it["onWeekDay"].get<int>());
+            info.onDateTime.setDate(QDate::fromString(QString::fromStdString(it["onDate"].get<std::string>()), "yyyy-MM-dd"));
+            info.onDateTime.setTime(QTime::fromString(QString::fromStdString(it["onTime"].get<std::string>()), "hh:mm:ss"));
+            info.offWeekDay = static_cast<enum_WeekDay>(it["offWeekDay"].get<int>());
+            info.offDateTime.setDate(QDate::fromString(QString::fromStdString(it["offDate"].get<std::string>()), "yyyy-MM-dd"));
+            info.offDateTime.setTime(QTime::fromString(QString::fromStdString(it["offTime"].get<std::string>()), "hh:mm:ss"));
 
             list.append(info);
         }
@@ -974,6 +969,91 @@ bool FromWebAPI::getTemplate(QString templateName, QList<OnePlanItemInfo>& list)
     return true;
 }
 
+
+/* 获取多个模板的内容 */
+bool FromWebAPI::getTemplateData(QList<OneTemplateInfo>& listTemplate, QMap<int, QList<OnePlanItemInfo>>& mapPlan)
+{
+    if(m_httpApi == nullptr)
+    {
+        LH_WRITE_ERROR("WebAPI is nullptr");
+        return false;
+    }
+    nJson json0 = nJson::array();
+    for(auto& it : listTemplate)
+    {
+        nJson json1;
+        json1["opName"] = "TMS_GetExecPlanTemplateData";
+        json1["Key"] = QUuid::createUuid().toString().toStdString();
+        json1["templateName"] = it.templateName.toStdString();
+        json0.push_back(json1);
+    }
+
+    QString strCmd = QString::fromStdString(json0.dump());
+    QString strRet;
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_BatchTransAction, strCmd, strRet, true);
+    if(ret != 0)
+    {
+        LH_WRITE_ERROR(QString("获取模板失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
+        return false;
+    }
+    /* 解析获取到的JSON数据 */
+    try
+    {
+        nJson jsonRet = nJson::parse(strRet.toStdString());
+        int retCode = jsonRet["code"].get<int>();
+        if(retCode != 0)
+        {
+            LH_WRITE_ERROR("获取模板失败");
+            return false;
+        }
+        nJson result = jsonRet["result"];
+        for(auto& it : result)
+        {
+            OnePlanItemInfo info;
+            
+            info.ChannelID = it["channelID"].is_null() ? -1 : it["channelID"].get<int>();
+            info.ChannelName = QString::fromStdString(it["channelName"].get<std::string>());
+            info.onWeekDay = static_cast<enum_WeekDay>(it["onWeekDay"].get<int>());
+            info.onDateTime.setDate(QDate::fromString(QString::fromStdString(it["onDate"].get<std::string>()), "yyyy-MM-dd"));
+            info.onDateTime.setTime(QTime::fromString(QString::fromStdString(it["onTime"].get<std::string>()), "hh:mm:ss"));
+            info.offWeekDay = static_cast<enum_WeekDay>(it["offWeekDay"].get<int>());
+            info.offDateTime.setDate(QDate::fromString(QString::fromStdString(it["offDate"].get<std::string>()), "yyyy-MM-dd"));
+            info.offDateTime.setTime(QTime::fromString(QString::fromStdString(it["offTime"].get<std::string>()), "hh:mm:ss"));
+
+            /* 查找该频率所属的列表 */
+            auto list = mapPlan.find(info.ChannelID);
+            if(list == mapPlan.end())
+            {
+                /* 创建一个新的列表 */
+                QList<OnePlanItemInfo> listPlan;
+                listPlan.append(info);
+                mapPlan.insert(info.ChannelID, listPlan);
+            }else {
+                /* 找到对应的列表 */
+                list->append(info);
+            }
+        }
+
+    }
+    catch (const nJson::parse_error& e)
+    {
+        LH_WRITE_ERROR(QString("解析模板失败:%1").arg(e.what()));
+        return false;
+    }
+    catch (const nJson::exception& e)
+    {
+        LH_WRITE_ERROR(QString("解析模板失败:%1").arg(e.what()));
+        return false;
+    }
+    catch(...)
+    {
+        LH_WRITE_ERROR("解析模板失败");
+        return false;
+    }
+
+    return true;
+}
+
 /* 获取模板列表 */
 bool FromWebAPI::getTemplateList(QMultiMap<int, OneTemplateInfo>& mapTemplate)
 {

+ 4 - 1
TransmitterSwitch/WebAPI/FromWebAPI.h

@@ -3,6 +3,7 @@
 
 #include "lhhttpapi.h"
 #include "TransmitterSwitchInfo.h"
+#include <qlist.h>
 
 struct OnePlanItemInfo;
 
@@ -46,7 +47,9 @@ public:
     /* 保存到模板 */
     bool saveTemplate(const QString& templateName, QList<OnePlanItemInfo>& list);
     /* 获取模板内容 */
-    bool getTemplate(QString templateName, QList<OnePlanItemInfo>& list);
+    bool getOneTemplateData(QString templateName, QList<OnePlanItemInfo>& list);
+    /* 获取多个模板的内容 */
+    bool getTemplateData(QList<OneTemplateInfo>& listTemplate, QMap<int, QList<OnePlanItemInfo>>& mapPlan);
     /* 获取模板列表 */
     bool getTemplateList(QMultiMap<int, OneTemplateInfo>& mapTemplate);
     /* 获取某个频率的模版列表 */

+ 2 - 1
TransmitterSwitch/common/TipWidget/tipwidget.cpp

@@ -96,7 +96,8 @@ TipWidget::TipWidget(FormType type, QString& text, QWidget *parent) :
     {
         QFontMetrics fm(ui->label_tipTitle->font());
         auto textWidth = fm.width(text);
-        int width = textWidth + this->width() - ui->label_tipTitle->width();
+        // int width = textWidth + this->width() - ui->label_tipTitle->width();
+        int width = textWidth + this->width() - 60;
         this->setFixedWidth(width);
     }
 }

+ 1 - 0
TransmitterSwitch/common/TipWidget/tipwidget.h

@@ -21,6 +21,7 @@ public:
     };
 public:
     static const int WIDTH = 168;
+    // static const int WIDTH = 256;
     static const int HEIGHT = 56;
     static void display(FormType type, QWidget* parent = Q_NULLPTR, int nTitleHeight = 48);
     static void display(FormType type, QString text, QWidget* parent = Q_NULLPTR, int nTitleHeight = 48);

+ 92 - 3
TransmitterSwitch/transmitterswitch.cpp

@@ -12,8 +12,6 @@
 #include "pBtnUserData2.h"
 #include "WebAPI/FromWebAPI.h"
 #include "TransmitterSwitchInfo.h"
-#include "timewidget.h"
-#include "cdate.h"
 #include "savetotemplate.h"
 #include "importtemplate.h"
 #include "warning.h"
@@ -24,6 +22,7 @@
 #include "flowlayout.h"
 #include "managerplan.h"
 #include "importtemplate.h"
+#include "copytoother.h"
 
 
 
@@ -83,6 +82,7 @@ TransmitterSwitch::TransmitterSwitch(QWidget *parent) :
     connect(ui->rBtn_day, &QPushButton::clicked, this, &TransmitterSwitch::do_pBtnExecMode);
     connect(ui->pBtn_clearPlan, &QPushButton::clicked, this, &TransmitterSwitch::do_pBtnClearPlan);
     connect(ui->pBtn_deletePlan, &QPushButton::clicked, this, &TransmitterSwitch::do_pBtnClearPlan);
+    connect(ui->pBtn_cloneToOther, &QPushButton::clicked, this, &TransmitterSwitch::do_pBtnCopyToOther);
 
     /* 设置QSS */
     connect(&EPUIStyle, &UIStyleManager::signal_qssChanged, this, &TransmitterSwitch::do_setUIStyle);
@@ -386,7 +386,7 @@ void TransmitterSwitch::do_pBtnAddExecPlan()
         {
             LH_WRITE_ERROR(QString("频率ID为%1的计划写入数据库失败").arg(chnID));
             isSuccess = false;
-            TipWidget::display(TipWidget::OPERATOR_FAIL, QString("频率<%1>计划写入数据库失败").arg(pCard->getChannelInfo().ChannelName), this);
+            TipWidget::display(TipWidget::OPERATOR_FAIL, QString("频率:%1 计划写入数据库失败!").arg(pCard->getChannelInfo().ChannelName), this);
         }
     }
     if(isSuccess)
@@ -535,6 +535,64 @@ void TransmitterSwitch::do_pBtnClearPlan()
     }
 }
 
+/* 点击了复制到其他频率按钮 */
+void TransmitterSwitch::do_pBtnCopyToOther()
+{
+    /* 先判断有没有选中的频率卡片 */
+    auto pCard = PData.getCurrentPlanCard();
+    if(pCard == nullptr)
+    {
+        TipWidget::display(TipWidget::OPERATOR_FAIL, "没有选中频率卡片", this);
+        return;
+    }
+    /* 判断卡片有没有计划 */
+    if(pCard->isPlanEmpty())
+    {
+        TipWidget::display(TipWidget::OPERATOR_FAIL, "当前频率没有计划", this);
+        return;
+    }
+
+    std::shared_ptr<CopyToOther> cto = std::make_shared<CopyToOther>(this);
+    cto->setQSSPath(EPUIStyle.getQSSPath());
+    cto->setFrequencyList(pCard->getChannelInfo(), ChnContainer.getMapChannel());
+    cto->exec();
+
+    /* 判断有没有点击OK */
+    if(!cto->isOk())
+    {
+        return;
+    }
+    /* 获取选中的频率列表 */
+    auto list = cto->getSelectedFrequencyList();
+    /* 获取当前频率的计划列表 */
+    QList<OnePlanItemInfo> listPlan;
+    pCard->getAllPlanInfo(listPlan);
+    /* 遍历所有的频率 */
+    bool isSuccess = true;
+    for(auto& it : list)
+    {
+        auto pTmpCard = PData.findPlanCard(it.ChannelID);
+        if(pTmpCard == nullptr)
+        {
+            LH_WRITE_ERROR(QString("没有找到频率ID为%1的卡片").arg(it.ChannelID));
+            continue;
+        }
+        /* 设置计划列表 */
+        pTmpCard->setPlanList(listPlan);
+        /* 写入数据库 */
+        if(!m_fromWebAPI->insertData(it.ChannelID, listPlan))
+        {
+            LH_WRITE_ERROR(QString("频率ID为%1的计划写入数据库失败").arg(it.ChannelID));
+            TipWidget::display(TipWidget::OPERATOR_FAIL, QString("频率<%1>计划写入数据库失败").arg(it.ChannelName), this);
+            isSuccess = false;
+        }
+    }
+    if(isSuccess)
+    {
+        TipWidget::display(TipWidget::OPERATOR_OK, "复制计划成功", this);
+    }
+}
+
 
 /* 导入数据 */
 void TransmitterSwitch::do_importData()
@@ -582,6 +640,37 @@ void TransmitterSwitch::do_importData()
     it->setTemplateList(tabList);
 
     it->exec();
+
+    /* 判断有没有点击OK */
+    if(!it->isOk())
+    {
+        return;
+    }
+
+    /* 获取选中的模版 */
+    auto tmpList = it->getSelectedTemplateList();
+    QMap<int, QList<OnePlanItemInfo>> mapPlan;
+    m_fromWebAPI->getTemplateData(tmpList, mapPlan);
+
+    /* 将所有的模板数据插入到卡片中 */
+    for(auto begin = mapPlan.begin(), end = mapPlan.end(); begin != end; begin++)
+    {
+        auto pCard = PData.findPlanCard(begin.key());
+        if(pCard == nullptr)
+        {
+            LH_WRITE_ERROR(QString("没有找到频率ID为%1的卡片").arg(begin.key()));
+            continue;
+        }
+        /* 设置计划列表 */
+        pCard->setPlanList(begin.value());
+    }
+
+    TipWidget::display(TipWidget::OPERATOR_OK, "导入模版成功", this);
+    /* 调用回调函数 */
+    if(m_trackCB != nullptr)
+    {
+        m_trackCB(3, g_mapTrack.value(3));
+    }
 }
 
 /* 导出数据 */

+ 2 - 0
TransmitterSwitch/transmitterswitch.h

@@ -57,6 +57,8 @@ private slots:
     void do_pBtnExecMode();
     /* 点击了清空计划按钮 */
     void do_pBtnClearPlan();
+    /* 点击了复制到其他频率按钮 */
+    void do_pBtnCopyToOther();
 
     /* 导入模板 */
     void do_importData();