소스 검색

1.3.3
1、基本完成了制作计划的功能

Apple 6 달 전
부모
커밋
18c93a7d8a

+ 84 - 41
SwitchOnOff.sql

@@ -20,36 +20,31 @@ WHERE PTTypeCode = :PTTypeCode;
 #===============================================
 
 
-#删除表格
-DROP TABLE IF EXISTS "EQM_CESHI"."tExecPlanTemplate";
-
-#创建模版表格
-CREATE TABLE IF NOT EXISTS "EQM_CESHI"."tExecPlanTemplate"
-(
-    "TemplateName" VARCHAR(255),
-    "TemplateType" INT,
-    "ExecDate" VARCHAR(255),
-    "ExecTime" VARCHAR(255),
-    "DeviceName" VARCHAR(255),
-    "ActionName" VARCHAR(255),
-    "ActionID" INT
-)
-
-
 #查询模版
 SELECT *
 FROM tExecPlanTemplate;
 
+
 #获取模板名称和模版类型,去掉重复的
-SELECT EP."TemplateName", EP."TemplateType"
+SELECT EP."TemplateName", EP.ChannelID
 FROM tExecPlanTemplate AS EP
-GROUP BY EP."TemplateName", EP."TemplateType";
+GROUP BY EP."TemplateName", EP."ChannelID";
+
 
 #通过模板名称获取模板数据
 SELECT *
 FROM tExecPlanTemplate
 WHERE "TemplateName" = :templateName;
 
+#插入数据
+INSERT INTO "tExecPlanTemplate" ("TemplateName", "ChannelID", "OnWeekDay", "OnDate", "OnTime", "OffWeekDay", "OffDate", "OffTime")
+VALUES ('模版1', '2', '1', '2025-02-09', '09:00:00', '1', '2025-02-09', '09:00:01');
+
+#插入数据,使用参数
+INSERT INTO "tExecPlanTemplate" ("TemplateName", "ChannelID", "OnWeekDay", "OnDate", "OnTime", "OffWeekDay", "OffDate", "OffTime")
+VALUES (:templateName, :channelID, :onWeekDay, :onDate, :onTime, :offWeekDay, :offDate, :offTime);
+
+
 #删除表格中的所有数据
 DELETE
 FROM tExecPlanTemplate;
@@ -57,15 +52,6 @@ FROM tExecPlanTemplate;
 SELECT *
 FROM TMONITORPIN;
 
-
-#插入数据
-INSERT INTO tExecPlanTemplate (TemplateName, TemplateType, ExecDate, ExecTime, DeviceName, ActionName, ActionID)
-VALUES ('模版1', '0', '2025-02-09', '09:00:00', '发射机1', '开机', 1);
-#插入数据,使用参数
-INSERT INTO tExecPlanTemplate ("TemplateName", "TemplateType", "ExecDate", "ExecTime", "DeviceName", "ActionName", "ActionID")
-VALUES (:templateName, :templateType, :execDate, :execTime, :deviceName, :actionName, :actionID);
-
-
 #删除模版
 DELETE 
 FROM tExecPlanTemplate
@@ -76,38 +62,74 @@ FROM tExecPlanTemplate
 WHERE TemplateName = :templateName;
 
 
+#创建模版表格
+CREATE TABLE IF NOT EXISTS "EQM_CESHI"."tExecPlanTemplate"
+(
+    "TemplateName" VARCHAR(255),
+    "TemplateType" INT,
+    "ExecDate" VARCHAR(255),
+    "ExecTime" VARCHAR(255),
+    "DeviceName" VARCHAR(255),
+    "ActionName" VARCHAR(255),
+    "ActionID" INT
+)
+
+#创建执行计划模版,新的UI
+CREATE TABLE IF NOT EXISTS "EQM_CESHI"."tExecPlanTemplate"
+(
+    "TemplateName" VARCHAR(255) NOT NULL,
+    "ChannelID" INT NOT NULL,
+    "OnWeekDay" INT NOT NULL,
+    "OnDate" VARCHAR(255) NOT NULL,
+    "OnTime" VARCHAR(255) NOT NULL,
+    "OffWeekDay" INT NOT NULL,
+    "OffDate" VARCHAR(255) NOT NULL,
+    "OffTime" VARCHAR(255) NOT NULL,
+
+    "DeviceName" VARCHAR(255),
+    "ActionName" VARCHAR(255),
+    "ActionID" INT
+)
+
+
+#删除表格
+DROP TABLE IF EXISTS "EQM_CESHI"."tExecPlanTemplate";
+
+
 #===============================================
 # 发射机计划表格-tExecPlan
 #===============================================
 
-
+#获取所有计划
 SELECT *
 FROM tExecPlan;
 
+#获取指定频率的计划
+SELECT *
+FROM tExecPlan
+WHERE ChannelID = :ChannelID;
+
 #插入一行到发射机计划表格
 INSERT INTO "tExecPlan" ("ExecType", "WeekDay", "Date", "ExecTime", "DID", "MPID", "DeviceName", "PTTypeCode", "ActionID", "ActionName", "ChannelID")
 VALUES (:ExecType, :WeekDay, :Date, :ExecTime, :DID, :MPID, :DeviceName, :PTTypeCode, :ActionID, :ActionName, :ChannelID);
 
 
-#获取设备信息
-SELECT Dev.CHNID, Dev.DID, Dev.DTID, Dev.DNAME, Dev.DClass, Chn.CHNNAME, MP.MADDRESS, MP.MNAME, MP.MType, PT.PTTYPECODE, MP.MPID
-FROM "tDevice" AS Dev
-LEFT JOIN "tDeviceType" AS DT ON "Dev"."DTID" = "DT"."DTID"
-LEFT JOIN "tChannel" AS Chn ON "Dev"."CHNID" = "Chn"."CHNID"
-LEFT JOIN "tMonitorPin" AS MP ON "MP"."MPID" IN (
-    SELECT "MPID"
-    FROM "tDevicePin" AS DevPin
-    WHERE "DevPin"."DID" = "Dev"."DID"
-)
-LEFT JOIN "tPinType" AS PT ON "MP"."MType" = "PT"."PTID";
+#插入一行到发射机计划表格,使用参数,新版本
+INSERT INTO "tExecPlan" ("ChannelID", "ChannelName", "OnWeekDay", "OnDate", "OnTime", "OffWeekDay", "OffDate", "OffTime")
+VALUES (:channelID, :channelName, :onWeekDay, :onDate, :onTime, :offWeekDay, :offDate, :offTime);
 
 
+#删除一个频率的计划
+DELETE
+FROM "tExecPlan"
+WHERE ChannelID = :channelID;
+
 #创建表格
 CREATE TABLE IF NOT EXISTS "EQM_CESHI"."tExecPlan" (
     "IncKey" INT PRIMARY KEY AUTO_INCREMENT,
     "ExecType" INT NOT NULL,
-    "WeekDay" INT,
-    "Date" VARCHAR(64),
+    "WeekDay" INT NOT NULL,
+    "Date" VARCHAR(64) NOT NULL,
     "ExecTime" VARCHAR(64) NOT NULL,
     "DID" INT,
     "MPID" INT,
@@ -118,6 +140,25 @@ CREATE TABLE IF NOT EXISTS "EQM_CESHI"."tExecPlan" (
     "ChannelID" INT
 )
 
+#创建表格,全新UI
+CREATE TABLE IF NOT EXISTS "EQM_CESHI"."tExecPlan" (
+    "IncKey" INT PRIMARY KEY AUTO_INCREMENT,
+    "ChannelID" INT NOT NULL,
+    "ChannelName" VARCHAR(64),
+    "OnWeekDay" INT NOT NULL,
+    "OnDate" VARCHAR(64) NOT NULL,
+    "OnTime" VARCHAR(64) NOT NULL,
+    "OffWeekDay" INT NOT NULL,
+    "OffDate" VARCHAR(64) NOT NULL,
+    "OffTime" VARCHAR(64) NOT NULL,
+    "DID" INT,
+    "MPID" INT,
+    "DeviceName" VARCHAR(64),
+    "PTTypeCode" INT,
+    "ActionID" INT,
+    "ActionName" VARCHAR(64)
+);
+
 
 
 #根据PTTypeCode删除发射机计划
@@ -182,6 +223,8 @@ WHERE KeyWord = :keyWord;
 # 获取设备信息
 #================================================================
 
+
+#获取设备信息
 SELECT Dev.CHNID, Dev.DID, Dev.DTID, Dev.DNAME, Dev.DClass, Chn.CHNNAME, MP.MADDRESS, MP.MNAME, MP.MType, PT.PTTYPECODE, MP.MPID
 FROM "tDevice" AS Dev
 LEFT JOIN "tDeviceType" AS DT ON "Dev"."DTID" = "DT"."DTID"

+ 54 - 0
TransmitterSwitch/ExecPlanData/PlanData.cpp

@@ -1,5 +1,6 @@
 #include "PlanData.h"
 
+#include "LHQLogAPI.h"
 
 PlanData::PlanData()
 {
@@ -19,6 +20,7 @@ PlanCard* PlanData::createOneCard(const ChannelInfo& chnInfo)
     }
     pCard = new PlanCard();
     pCard->setChannelInfo(chnInfo);
+    connect(pCard, &PlanCard::signal_clickedCard, this, &PlanData::do_clickedCard);
 
     m_mapPlanCard.insert(chnInfo.ChannelID, pCard);
     return pCard;
@@ -35,6 +37,18 @@ void PlanData::deleteOneCard(int channelID)
     }
 }
 
+/* 清空一个卡片的计划 */
+void PlanData::clearOnePlanItem(int channelID)
+{
+    auto pCard = findPlanCard(channelID);
+    if(pCard != nullptr)
+    {
+        pCard->clearPlanItem();
+    }else {
+        LH_WRITE_ERROR(QString("没有找到频率ID为%1的卡片").arg(channelID));
+    }
+}
+
 /* 查找卡片 */
 PlanCard* PlanData::findPlanCard(int channelID)
 {
@@ -44,3 +58,43 @@ PlanCard* PlanData::findPlanCard(int channelID)
     }
     return nullptr;
 }
+
+/* 新增一个计划 */
+void PlanData::addPlanItem(int channelID, const PlanInfo& info)
+{
+    auto pCard = findPlanCard(channelID);
+    if(pCard != nullptr)
+    {
+        pCard->addPlanItem(info);
+    }else {
+        LH_WRITE_ERROR(QString("没有找到频率ID为%1的卡片").arg(channelID));
+    }
+}
+
+/* 设置每个卡片的大小 */
+void PlanData::setCardSize(int width, int height)
+{
+    for(auto& it : m_mapPlanCard)
+    {
+        it->setFixedSize(width, height);
+    }
+    // LH_WRITE_LOG_DEBUG(QString("卡片的实际大小:%1*%2").arg(m_mapPlanCard.first()->width()).arg(m_mapPlanCard.first()->height()));
+}
+
+/* 点击了一个卡片 */
+void PlanData::do_clickedCard(int channelID)
+{
+    // LH_WRITE_LOG_DEBUG(QString("点击了频率ID为%1的卡片").arg(channelID));
+    /* 先取消所有的选中效果 */
+    for(auto& it : m_mapPlanCard)
+    {
+        it->setSelected(false);
+    }
+    /* 设置选中效果 */
+    m_currentFrequencyID = channelID;
+    auto pCard = findPlanCard(channelID);
+    if(pCard != nullptr)
+    {
+        pCard->setSelected(true);
+    }
+}

+ 19 - 1
TransmitterSwitch/ExecPlanData/PlanData.h

@@ -6,8 +6,10 @@
 
 #define PData PlanData::getInstance()
 
-class PlanData
+class PlanData : public QObject
 {
+    Q_OBJECT
+    
     PlanData();
     PlanData(const PlanData& data) = delete;
     PlanData& operator=(const PlanData& data) = delete;
@@ -23,13 +25,29 @@ public:
     PlanCard* createOneCard(const ChannelInfo& chnInfo);
     /* 删除一个卡片 */
     void deleteOneCard(int channelID);
+    /* 清空一个卡片的计划 */
+    void clearOnePlanItem(int channelID);
 
     /* 查找卡片 */
     PlanCard* findPlanCard(int channelID);
+    /* 获取当前选中的卡片 */
+    PlanCard* getCurrentPlanCard() { return findPlanCard(m_currentFrequencyID); }
     
+    /* 新增一个计划 */
+    void addPlanItem(int channelID, const PlanInfo& info);
+
+    /* 设置每个卡片的大小 */
+    void setCardSize(int width, int height);
+
+
+private slots:
+    /* 点击了一个卡片 */
+    void do_clickedCard(int channelID);
 
 private:
     QMap<int, PlanCard*> m_mapPlanCard;    /* 计划卡片 */
+
+    int m_currentFrequencyID = 0;          /* 当前频率ID */
 };
 
 

+ 359 - 68
TransmitterSwitch/ExecPlanData/plancard.cpp

@@ -2,11 +2,53 @@
 #include "ui_plancard.h"
 
 #include <QPainter>
+#include <QEventLoop>
 
 #include "UIStyleManager.h"
 #include "LHQLogAPI.h"
 
 
+PlanInfo::PlanInfo()
+{
+    onWeekDay = enum_WeekDay::WeekDay_Mon;
+    onTime = QDateTime::fromString("1970-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
+
+    offWeekDay = enum_WeekDay::WeekDay_Mon;
+    offTime = QDateTime::fromString("1970-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
+}
+
+PlanInfo::PlanInfo(const PlanInfo& info)
+{
+    onWeekDay = info.onWeekDay;
+    onTime = info.onTime;
+
+    offWeekDay = info.offWeekDay;
+    offTime = info.offTime;
+}
+PlanInfo& PlanInfo::operator=(const PlanInfo& info)
+{
+    if(this != &info)
+    {
+        onWeekDay = info.onWeekDay;
+        onTime = info.onTime;
+
+        offWeekDay = info.offWeekDay;
+        offTime = info.offTime;
+    }
+    return *this;
+}
+
+bool PlanInfo::operator==(const PlanInfo& info) const
+{
+    if(onWeekDay == info.onWeekDay && onTime == info.onTime &&
+       offWeekDay == info.offWeekDay && offTime == info.offTime)
+    {
+        return true;
+    }
+    return false;
+}
+
+
 
 /* 重载比较函数 */
 bool CSortModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
@@ -37,38 +79,48 @@ bool CSortModel::lessThan(const QModelIndex &left, const QModelIndex &right) con
 
 
 
-
-
 PlanCard::PlanCard(QWidget *parent) :
     QWidget(parent),
     ui(new Ui::PlanCard)
 {
     ui->setupUi(this);
 
+    /* 设置最小宽度 */
+    this->setMinimumWidth(300);
+
     /* 初始化视图模型 */
     m_model = new QStandardItemModel(this);
     m_model->setColumnCount(2);  /* 两列 */
+    m_model->clear();
     m_sortModel = new CSortModel(this);
     m_sortModel->setSourceModel(m_model);
     m_sortModel->sort(0, Qt::AscendingOrder); /* 默认升序 */
     /* 设置排序数据 */
     m_sortModel->setSortRole(QtUserRole::UserRole_Time); /* 设置排序角色 */
     ui->tableView->setModel(m_sortModel);
+    
     /* 设置每列的高度 */
-    ui->tableView->verticalHeader()->setMinimumHeight(34);
-    ui->tableView->verticalHeader()->setMaximumHeight(34);
     ui->tableView->verticalHeader()->setDefaultSectionSize(34);
-    /* 设置两列一样宽 */
-    auto horWidth = ui->tableView->width();
-    ui->tableView->horizontalHeader()->setDefaultSectionSize(horWidth / 2);
+    
     /* 设置去掉标题 */
     ui->tableView->horizontalHeader()->setVisible(false);
+    /* 去掉列标题 */
+    ui->tableView->verticalHeader()->setVisible(false);
+    /* 去掉网格线 */
+    ui->tableView->setShowGrid(false);
+    /* 设置单元格不可编辑 */
+    ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
 
     /* 设置空白图片和文字的位置 */
     setSpaceImageAndTextRect();
+
+    /* 注册事件过滤器 */
+    // ui->tableView->installEventFilter(this);
+    ui->tableView->viewport()->installEventFilter(this);
     
     /* 连接信号和槽 */
     connect(&EPUIStyle, &UIStyleManager::signal_qssChanged, this, &PlanCard::do_setUIStyle);
+    connect(ui->tableView, &QTableView::clicked, this, &PlanCard::do_tableView_clicked);
     /* 设置默认的皮肤 */
     do_setUIStyle();
 }
@@ -88,57 +140,29 @@ void PlanCard::setChannelInfo(const ChannelInfo& info)
 }
 
 /* 添加一项 */
-void PlanCard::addPlanItem(const enum_WeekDay weekDay, const QDateTime& time, const enum_OnOff onOff)
+void PlanCard::addPlanItem(const PlanInfo& info)
 {
-    QString strTime;
-    switch(weekDay)
-    {
-        case enum_WeekDay::WeekDay_Mon:
-        strTime = QString("星期一 %1").arg(time.toString("hh:mm:ss"));
-            break;
-        case enum_WeekDay::WeekDay_Tue:
-        strTime = QString("星期二 %1").arg(time.toString("hh:mm:ss"));
-            break;
-        case enum_WeekDay::WeekDay_Wed:
-        strTime = QString("星期三 %1").arg(time.toString("hh:mm:ss"));
-            break;
-        case enum_WeekDay::WeekDay_Thu:
-        strTime = QString("星期四 %1").arg(time.toString("hh:mm:ss"));
-            break;
-        case enum_WeekDay::WeekDay_Fri:
-        strTime = QString("星期五 %1").arg(time.toString("hh:mm:ss"));
-            break;
-        case enum_WeekDay::WeekDay_Sat:
-        strTime = QString("星期六 %1").arg(time.toString("hh:mm:ss"));
-            break;
-        case enum_WeekDay::WeekDay_Sun:
-        strTime = QString("星期天 %1").arg(time.toString("hh:mm:ss"));
-            break;
-        case enum_WeekDay::WeekDay_Special:
-        strTime = QString("%1").arg(time.toString("yy-MM-dd hh:mm:ss"));
-            break;
-        default:
-            strTime = QString("未知 %1").arg(time.toString("hh:mm:ss"));
-            break;
-    }
+    auto strStart = getDateString(info.onWeekDay, info.onTime);
+    auto strEnd = getDateString(info.offWeekDay, info.offTime);
 
     /* 创建一个item */
-    QStandardItem* item = new QStandardItem();
-    item->setText(strTime);
-    item->setData(static_cast<int>(weekDay), UserRole_WeekDay);   /* 设置周几 */
-    item->setData(time, UserRole_Time);                           /* 设置时间 */
-    item->setData(static_cast<int>(onOff), UserRole_OnOff);                         /* 设置开关状态 */
+    QStandardItem* itemStart = new QStandardItem();
+    itemStart->setText(strStart);
+    itemStart->setData(static_cast<int>(info.onWeekDay), UserRole_WeekDay);   /* 设置周几 */
+    itemStart->setData(info.onTime, UserRole_Time);                           /* 设置时间 */
+
+    QStandardItem* itemEnd = new QStandardItem();
+    itemEnd->setText(strEnd);
+    itemEnd->setData(static_cast<int>(info.offWeekDay), UserRole_WeekDay);       /* 设置周几 */
+    itemEnd->setData(info.offTime, UserRole_Time);                               /* 设置时间 */
 
     /* 添加一个项 */
-    m_model->setRowCount(m_model->rowCount() + 1); /* 添加一行 */
-    if(onOff == enum_OnOff::On)
-    {
-        m_model->setItem(m_model->rowCount(), 0, item);
-    }else {
-        m_model->setItem(m_model->rowCount(), 1, item);
-    }
+    m_model->appendRow(QList<QStandardItem*>{itemStart, itemEnd});
 
     m_isSpace = false; /* 有数据了 */
+
+    // LH_WRITE_LOG(QString("计划数目: %1").arg(m_model->rowCount()));
+    // LH_WRITE_LOG(QString("UI: %1:%2").arg(ui->tableView->width()).arg(ui->tableView->height()));
 }
 
 /* 删除一项 */
@@ -162,41 +186,214 @@ void PlanCard::deletePlanItem(const enum_WeekDay weekDay, const QDateTime& time,
     }
 }
 
-/* 取出所有的计划信息 */
-void PlanCard::getAllPlanInfo(QList<ExecPlanItemInfo>& list)
+/* 删除一项,传入行号 */
+PlanInfo PlanCard::deletePlanItem(const int row)
+{
+    if(row < 0 || row >= m_model->rowCount())
+    {
+        return PlanInfo(); /* 没有选中行 */
+    }
+    /* 获取原始模型的行号 */
+    auto sourceRow = m_sortModel->mapToSource(m_sortModel->index(row, 0)).row();
+    /* 获取该行计划 */
+    auto item1 = m_model->item(sourceRow, 0);
+    auto item2 = m_model->item(sourceRow, 1);
+    PlanInfo info;
+    info.onWeekDay = static_cast<enum_WeekDay>(item1->data(UserRole_WeekDay).toInt());
+    info.onTime = item1->data(UserRole_Time).toDateTime();
+    info.offWeekDay = static_cast<enum_WeekDay>(item2->data(UserRole_WeekDay).toInt());
+    info.offTime = item2->data(UserRole_Time).toDateTime();
+
+    /* 删除该行 */
+    m_model->removeRow(sourceRow);
+
+    /* 判断数据有没有空 */
+    if(m_model->rowCount() == 0)
+    {
+        m_isSpace = true; /* 没有数据了 */
+    }
+
+    return info; /* 返回删除的计划 */
+}
+
+/* 修改一项 */
+PlanInfo PlanCard::modifyPlanItem(const int row, const PlanInfo& info)
+{
+    if(row < 0 || row >= m_model->rowCount())
+    {
+        return PlanInfo(); /* 没有选中行 */
+    }
+    /* 获取原始模型的行号 */
+    auto sourceRow = m_sortModel->mapToSource(m_sortModel->index(row, 0)).row();
+    /* 获取该行计划 */
+    auto item1 = m_model->item(sourceRow, 0);
+    auto item2 = m_model->item(sourceRow, 1);
+
+    PlanInfo oldInfo;
+    oldInfo.onWeekDay = static_cast<enum_WeekDay>(item1->data(UserRole_WeekDay).toInt());
+    oldInfo.onTime = item1->data(UserRole_Time).toDateTime();
+    oldInfo.offWeekDay = static_cast<enum_WeekDay>(item2->data(UserRole_WeekDay).toInt());
+    oldInfo.offTime = item2->data(UserRole_Time).toDateTime();
+
+    // LH_WRITE_LOG(QString("修改前的行: %1").arg(item1->row()));
+    /* 修改该行 */
+    item1->setText(getDateString(info.onWeekDay, info.onTime));
+    item1->setData(static_cast<int>(info.onWeekDay), UserRole_WeekDay);   /* 设置周几 */
+    item1->setData(info.onTime, UserRole_Time);                           /* 设置时间 */
+
+    item2->setText(getDateString(info.offWeekDay, info.offTime));
+    item2->setData(static_cast<int>(info.offWeekDay), UserRole_WeekDay);       /* 设置周几 */
+    item2->setData(info.offTime, UserRole_Time);                               /* 设置时间 */
+    
+    // LH_WRITE_LOG(QString("修改后的行: %1").arg(item1->row()));
+    /* 依旧选中修改完成后的行 */
+    // ui->tableView->selectRow(item1->row());
+
+    return oldInfo; /* 返回修改前的计划 */
+}
+
+/* 清空列表 */
+void PlanCard::clearPlanItem()
+{
+    for(auto& it : m_model->findItems(QString(), Qt::MatchContains, 0))
+    {
+        m_model->removeRow(it->row());
+    }
+
+    /* 判断数据有没有空 */
+    if(m_model->rowCount() == 0)
+    {
+        m_isSpace = true; /* 没有数据了 */
+    }
+}
+
+/* 取出所有的计划信息,用于给WebAPI发送数据 */
+void PlanCard::getAllPlanInfo(QList<OnePlanItemInfo>& list)
 {
     int rowCount = m_model->rowCount();
     for(int i = 0; i < rowCount; i++)
     {
         auto item1 = m_model->item(i, 0);
         auto item2 = m_model->item(i, 1);
-        ExecPlanItemInfo info1;
+        if(item1 == nullptr || item2 == nullptr)
+        {
+            continue;
+        }
+        OnePlanItemInfo info1;
         info1.ChannelID = m_channelInfo.ChannelID;
-        info1.WeekDay = static_cast<enum_WeekDay>(item1->data(UserRole_WeekDay).toInt());
-        info1.dateTime = item1->data(UserRole_Time).toDateTime();
-        info1.actionID = item1->data(UserRole_OnOff).toInt();
-        info1.actionName = g_ActionName.value(info1.actionID);
-        list.append(info1);
+        info1.ChannelName = m_channelInfo.ChannelName;
+        info1.onWeekDay = static_cast<enum_WeekDay>(item1->data(UserRole_WeekDay).toInt());
+        info1.onDateTime = item1->data(UserRole_Time).toDateTime();
+        info1.offWeekDay = static_cast<enum_WeekDay>(item2->data(UserRole_WeekDay).toInt());
+        info1.offDateTime = item2->data(UserRole_Time).toDateTime();
 
-        ExecPlanItemInfo info2;
-        info2.ChannelID = m_channelInfo.ChannelID;
-        info2.WeekDay = static_cast<enum_WeekDay>(item2->data(UserRole_WeekDay).toInt());
-        info2.dateTime = item2->data(UserRole_Time).toDateTime();
-        info2.actionID = item2->data(UserRole_OnOff).toInt();
-        info2.actionName = g_ActionName.value(info2.actionID);
-        list.append(info2);
+        list.append(info1);
     }
 }
 
 /* 设置计划列表 */
-void PlanCard::setPlanList(const QList<ExecPlanItemInfo>& list)
+void PlanCard::setPlanList(const QList<OnePlanItemInfo>& list)
 {
+    /* 清空当前的计划列表 */
+    clearPlanItem();
     for(const auto& it : list)
     {
-        addPlanItem(it.WeekDay, it.dateTime, static_cast<enum_OnOff>(it.actionID));
+        if(it.ChannelID != m_channelInfo.ChannelID)
+        {
+            /* 不是当前频率的计划 */
+            LH_WRITE_ERROR(QString("频率ID不匹配,当前频率ID:%1, 计划频率ID:%2").arg(m_channelInfo.ChannelID).arg(it.ChannelID));
+            continue; 
+        }
+        /* 添加计划 */
+        PlanInfo info;
+        info.onWeekDay = it.onWeekDay;
+        info.onTime = it.onDateTime;
+        info.offWeekDay = it.offWeekDay;
+        info.offTime = it.offDateTime;
+        addPlanItem(info);
     }
 }
 
+/* 获取计划列表,适用于PlanCard之间传输数据 */
+void PlanCard::getPlanList(QList<PlanInfo>& list)
+{
+    for(int i = 0; i < m_model->rowCount(); i++)
+    {
+        auto item1 = m_model->item(i, 0);
+        auto item2 = m_model->item(i, 1);
+        PlanInfo info;
+        info.onWeekDay = static_cast<enum_WeekDay>(item1->data(UserRole_WeekDay).toInt());
+        info.onTime = item1->data(UserRole_Time).toDateTime();
+        // info.startOnOff = static_cast<enum_OnOff>(item1->data(UserRole_OnOff).toInt());
+
+        info.offWeekDay = static_cast<enum_WeekDay>(item2->data(UserRole_WeekDay).toInt());
+        info.offTime = item2->data(UserRole_Time).toDateTime();
+        // info.endOnOff = static_cast<enum_OnOff>(item2->data(UserRole_OnOff).toInt());
+
+        list.append(info);
+    }
+}
+
+/* 设置计划列表,适用于PlanCard之间传输数据 */
+void PlanCard::setPlanList(const QList<PlanInfo>& list)
+{
+    /* 清空列表 */
+    clearPlanItem();
+    for(const auto& it : list)
+    {
+        addPlanItem(it);
+    }
+}
+
+
+/**
+ * @brief 获取选中的行
+ * 
+ * @return int 
+ */
+int PlanCard::getSelectedRow() const
+{
+    return ui->tableView->currentIndex().row();
+}
+
+PlanInfo PlanCard::getSelectedPlan()
+{
+    auto index = ui->tableView->currentIndex();
+    if(!index.isValid())
+    {
+        return PlanInfo(); /* 没有选中行 */
+    }
+    auto item1 = m_model->item(index.row(), 0);
+    auto item2 = m_model->item(index.row(), 1);
+
+    PlanInfo info;
+    info.onWeekDay = static_cast<enum_WeekDay>(item1->data(UserRole_WeekDay).toInt());
+    info.onTime = item1->data(UserRole_Time).toDateTime();
+    info.offWeekDay = static_cast<enum_WeekDay>(item2->data(UserRole_WeekDay).toInt());
+    info.offTime = item2->data(UserRole_Time).toDateTime();
+    return info;
+
+}
+
+/* 设置自身被选中 */
+void PlanCard::setSelected(bool isSelected)
+{
+    if(isSelected)
+    {
+        ui->widget->setProperty("Selected", true);
+    }else {
+        ui->widget->setProperty("Selected", false);
+    }
+    ui->widget->style()->unpolish(ui->widget);
+    ui->widget->style()->polish(ui->widget);
+}
+
+/* 自身被点击了,给外部调用,发送点击信号 */
+void PlanCard::clickedCard()
+{
+    emit signal_clickedCard(m_channelInfo.ChannelID);
+}
+
 /* 更改UI外观 */
 void PlanCard::do_setUIStyle()
 {
@@ -210,6 +407,27 @@ void PlanCard::do_setUIStyle()
     }
 }
 
+/* 点击了一个单元格,设置高亮一行 */
+void PlanCard::do_tableView_clicked(const QModelIndex& index)
+{
+    if(index.isValid())
+    {
+        /* 设置高亮一行 */
+        ui->tableView->selectRow(index.row());
+    }
+    /* 发送信号 */
+    auto item1 = m_model->item(index.row(), 0);
+    auto item2 = m_model->item(index.row(), 1);
+    PlanInfo info;
+    info.onWeekDay = static_cast<enum_WeekDay>(item1->data(UserRole_WeekDay).toInt());
+    info.onTime = item1->data(UserRole_Time).toDateTime();
+    info.offWeekDay = static_cast<enum_WeekDay>(item2->data(UserRole_WeekDay).toInt());
+    info.offTime = item2->data(UserRole_Time).toDateTime();
+    emit signal_clickedItem(info); /* 发送信号 */
+    // emit signal_clickedCard(m_channelInfo.ChannelID);
+}
+
+
 /* 设置空白图片和文字的位置 */
 void PlanCard::setSpaceImageAndTextRect()
 {
@@ -230,6 +448,55 @@ void PlanCard::setSpaceImageAndTextRect()
 
 }
 
+/* 根据日期获取字符串 */
+QString PlanCard::getDateString(const enum_WeekDay weekDay, const QDateTime& time)
+{
+    QString strTime;
+    switch(weekDay)
+    {
+        case enum_WeekDay::WeekDay_Mon:
+        strTime = QString("星期一 %1").arg(time.toString("hh:mm:ss"));
+            break;
+        case enum_WeekDay::WeekDay_Tue:
+        strTime = QString("星期二 %1").arg(time.toString("hh:mm:ss"));
+            break;
+        case enum_WeekDay::WeekDay_Wed:
+        strTime = QString("星期三 %1").arg(time.toString("hh:mm:ss"));
+            break;
+        case enum_WeekDay::WeekDay_Thu:
+        strTime = QString("星期四 %1").arg(time.toString("hh:mm:ss"));
+            break;
+        case enum_WeekDay::WeekDay_Fri:
+        strTime = QString("星期五 %1").arg(time.toString("hh:mm:ss"));
+            break;
+        case enum_WeekDay::WeekDay_Sat:
+        strTime = QString("星期六 %1").arg(time.toString("hh:mm:ss"));
+            break;
+        case enum_WeekDay::WeekDay_Sun:
+        strTime = QString("星期天 %1").arg(time.toString("hh:mm:ss"));
+            break;
+        case enum_WeekDay::WeekDay_Special:
+        strTime = QString("%1").arg(time.toString("yy-MM-dd hh:mm:ss"));
+            break;
+        default:
+            strTime = QString("未知 %1").arg(time.toString("hh:mm:ss"));
+            break;
+    }
+
+    return strTime;
+}
+
+/* 设置表格大小 */
+void PlanCard::setTableViewSize()
+{
+    /* 设置两列一样宽 */
+    auto horWidth = ui->tableView->width();
+    ui->tableView->horizontalHeader()->setDefaultSectionSize(horWidth / 2);
+
+    // LH_WRITE_LOG(QString("表格大小: %1:%2").arg(ui->tableView->width()).arg(ui->tableView->height()));
+    // LH_WRITE_LOG(QString("标题宽度: %1").arg(ui->widget_tableHeader->width()));
+}
+
 
 /* 绘制事件 */
 void PlanCard::paintEvent(QPaintEvent *event)
@@ -254,6 +521,7 @@ void PlanCard::resizeEvent(QResizeEvent *event)
     QWidget::resizeEvent(event);
     /* 设置空白图片和文字的位置 */
     setSpaceImageAndTextRect();
+    setTableViewSize();
 }
 
 /* 显示事件,这里获取到的控件大小信息是正确的 */
@@ -262,4 +530,27 @@ void PlanCard::showEvent(QShowEvent *event)
     QWidget::showEvent(event);
     /* 设置空白图片和文字的位置 */
     setSpaceImageAndTextRect();
+    setTableViewSize();
+}
+
+/* 鼠标点击事件 */
+void PlanCard::mousePressEvent(QMouseEvent *event)
+{
+    QWidget::mousePressEvent(event);
+    /* 发送信号 */
+    emit signal_clickedCard(m_channelInfo.ChannelID);
+}
+
+/* 事件过滤器 */
+bool PlanCard::eventFilter(QObject *watched, QEvent *event)
+{
+    if(watched == ui->tableView->viewport())
+    {
+        if(event->type() == QEvent::MouseButtonPress)
+        {
+            emit signal_clickedCard(m_channelInfo.ChannelID);
+        }
+    }
+
+    return QWidget::eventFilter(watched, event);
 }

+ 63 - 5
TransmitterSwitch/ExecPlanData/plancard.h

@@ -22,6 +22,26 @@ enum QtUserRole
     UserRole_OnOff                          /* 开关机 */
 };
 
+
+/**
+ * @brief 计划信息结构体
+ * 
+ */
+struct PlanInfo
+{
+    enum_WeekDay onWeekDay;                     /* 周几 */
+    QDateTime onTime;                           /* 时间 */
+
+    enum_WeekDay offWeekDay;                    /* 周几 */
+    QDateTime offTime;                          /* 时间 */
+
+    PlanInfo();
+    PlanInfo(const PlanInfo& info);
+    PlanInfo& operator=(const PlanInfo& info);
+    bool operator==(const PlanInfo& info) const;
+};
+
+
 /**
  * @brief 自定义排序类
  * 
@@ -54,23 +74,56 @@ public:
     ChannelInfo& getChannelInfo() { return m_channelInfo; }
 
     /* 添加一项,这里的一项是开机和关机单独的一个时间 */
-    void addPlanItem(const enum_WeekDay weekDay, const QDateTime& time, const enum_OnOff onOff);
+    void addPlanItem(const PlanInfo& info);
     /* 删除一项 */
     void deletePlanItem(const enum_WeekDay weekDay, const QDateTime& time, const enum_OnOff onOff);
-
-    /* 取出所有的计划信息 */
-    void getAllPlanInfo(QList<ExecPlanItemInfo>& list);
+    /* 删除一项,传入行号 */
+    PlanInfo deletePlanItem(const int row);
+    /* 修改一项 */
+    PlanInfo modifyPlanItem(const int row, const PlanInfo& info);
+    /* 清空列表 */
+    void clearPlanItem();
+
+    /* 取出所有的计划信息,用于给WebAPI发送数据 */
+    void getAllPlanInfo(QList<OnePlanItemInfo>& list);
     /* 设置计划列表 */
-    void setPlanList(const QList<ExecPlanItemInfo>& list);
+    void setPlanList(const QList<OnePlanItemInfo>& list);
+
+    /* 获取计划列表,适用于PlanCard之间传输数据 */
+    void getPlanList(QList<PlanInfo>& list);
+    /* 设置计划列表,适用于PlanCard之间传输数据 */
+    void setPlanList(const QList<PlanInfo>& list);
+
+    /* 获取选中的行 */
+    int getSelectedRow() const;
+    PlanInfo getSelectedPlan();
+
+    /* 设置自身被选中 */
+    void setSelected(bool isSelected);
+    /* 自身被点击了,给外部调用,发送点击信号 */
+    void clickedCard();
+
+signals:
+    /* 点击了一个单元格 */
+    void signal_clickedItem(PlanInfo& info);
+    /* Card被点击了 */
+    void signal_clickedCard(int channelID);
 
 private slots:
     /* 更改UI外观 */
     void do_setUIStyle();
+    /* 点击了一个单元格,设置高亮一行 */
+    void do_tableView_clicked(const QModelIndex& index);
 
 private:
     /* 设置空白图片和文字的位置 */
     void setSpaceImageAndTextRect();
 
+    /* 根据日期获取字符串 */
+    QString getDateString(const enum_WeekDay weekDay, const QDateTime& time);
+    /* 设置表格大小 */
+    void setTableViewSize();
+
 protected:
     /* 绘制事件 */
     void paintEvent(QPaintEvent *event) override;
@@ -79,6 +132,11 @@ protected:
     /* 显示事件 */
     void showEvent(QShowEvent *event) override;
 
+    /* 鼠标点击事件 */
+    void mousePressEvent(QMouseEvent *event) override;
+    /* 事件过滤器 */
+    bool eventFilter(QObject *watched, QEvent *event) override;
+
 private:
     Ui::PlanCard *ui;
 

+ 26 - 7
TransmitterSwitch/ExecPlanData/plancard.ui

@@ -32,14 +32,17 @@
    <item>
     <widget class="QWidget" name="widget" native="true">
      <layout class="QVBoxLayout" name="verticalLayout_2">
-      <property name="leftMargin">
+      <property name="spacing">
        <number>0</number>
       </property>
+      <property name="leftMargin">
+       <number>1</number>
+      </property>
       <property name="topMargin">
        <number>12</number>
       </property>
       <property name="rightMargin">
-       <number>0</number>
+       <number>1</number>
       </property>
       <property name="bottomMargin">
        <number>12</number>
@@ -63,6 +66,22 @@
         </property>
        </widget>
       </item>
+      <item>
+       <spacer name="verticalSpacer">
+        <property name="orientation">
+         <enum>Qt::Vertical</enum>
+        </property>
+        <property name="sizeType">
+         <enum>QSizePolicy::Fixed</enum>
+        </property>
+        <property name="sizeHint" stdset="0">
+         <size>
+          <width>20</width>
+          <height>12</height>
+         </size>
+        </property>
+       </spacer>
+      </item>
       <item>
        <widget class="QWidget" name="widget_tableHeader" native="true">
         <property name="sizePolicy">
@@ -83,7 +102,7 @@
           <height>32</height>
          </size>
         </property>
-        <layout class="QHBoxLayout" name="horizontalLayout">
+        <layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1">
          <property name="spacing">
           <number>0</number>
          </property>
@@ -100,7 +119,7 @@
           <number>0</number>
          </property>
          <item>
-          <widget class="QLabel" name="label_offTime">
+          <widget class="QLabel" name="label_onTime">
            <property name="sizePolicy">
             <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
              <horstretch>0</horstretch>
@@ -120,12 +139,12 @@
             </size>
            </property>
            <property name="text">
-            <string>机时间</string>
+            <string>机时间</string>
            </property>
           </widget>
          </item>
          <item>
-          <widget class="QLabel" name="label_onTime">
+          <widget class="QLabel" name="label_offTime">
            <property name="sizePolicy">
             <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
              <horstretch>0</horstretch>
@@ -145,7 +164,7 @@
             </size>
            </property>
            <property name="text">
-            <string>机时间</string>
+            <string>机时间</string>
            </property>
           </widget>
          </item>

+ 546 - 1
TransmitterSwitch/ManagerPlan/managerplan.cpp

@@ -6,6 +6,11 @@
 #include <QDesktopWidget>
 #include "UIStyleManager.h"
 #include "OneShadowEffect.h"
+#include "TransmitterSwitchInfo.h"
+#include "warning.h"
+#include "tipwidget.h"
+#include "LHQLogAPI.h"
+
 
 ManagerPlan::ManagerPlan(QDialog *parent) :
     QDialog(parent),
@@ -25,6 +30,13 @@ ManagerPlan::ManagerPlan(QDialog *parent) :
     /* 获取屏幕大小 */
     auto screenRect = QApplication::desktop()->availableGeometry();
     this->resize(screenRect.width(), screenRect.height());
+    /* 设置设置区域居中显示 */
+    ui->widget_background->move(screenRect.width() / 2 - ui->widget_background->width() / 2,
+        screenRect.height() / 2 - ui->widget_background->height() / 2);
+
+    /* 设置Card最小宽度 */
+    ui->pCard->setMinimumWidth(300);
+    ui->pCard->setFixedWidth(300);
 
     /* 注册事件过滤器 */
     ui->cBox_selectChn->installEventFilter(this);
@@ -57,14 +69,28 @@ ManagerPlan::ManagerPlan(QDialog *parent) :
     ui->timeEdit_specialStart->SetMainWindow(this);
     ui->timeEdit_specialEnd->SetMainWindow(this);
 
+    /* 需要设置这个属性,qss设置的图标才会生效 */
+    ui->dateEdit_specialStart->setCalendarPopup(true);
+    ui->dateEdit_specialEnd->setCalendarPopup(true);
+
+    /* 设置可选择的频率 */
+    setSelectFrequency();
+
     /* 设置可选择的周几 */
     setWeekDay();
 
     /* 连接信号和槽 */
     connect(ui->pBtn_cancel, &QPushButton::clicked, this, &ManagerPlan::close);
     connect(ui->pBtn_close, &QPushButton::clicked, this, &ManagerPlan::close);
-
+    connect(ui->cBox_selectChn, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ManagerPlan::do_selectFrequency);
     connect(&EPUIStyle, &UIStyleManager::signal_qssChanged, this, &ManagerPlan::do_setUIStyle);
+    connect(ui->pBtn_addPlan, &QPushButton::clicked, this, &ManagerPlan::do_addPlanItem);
+    connect(ui->pBtn_editPlan, &QPushButton::clicked, this, &ManagerPlan::do_modifyPlanItem);
+    connect(ui->pBtn_deletePlan, &QPushButton::clicked, this, &ManagerPlan::do_deletePlanItem);
+    connect(ui->pBtn_ok, &QPushButton::clicked, this, &ManagerPlan::do_pBtn_ok);
+    connect(ui->pCard, &PlanCard::signal_clickedItem, this, &ManagerPlan::do_tableView_clicked);
+
+    /* 设置皮肤样式 */
     do_setUIStyle();
 
     /* 设置下拉框阴影 */
@@ -72,6 +98,11 @@ ManagerPlan::ManagerPlan(QDialog *parent) :
     ui->cBox_selectWeekStart->setViewShadowEffect();
     ui->cBox_selectWeekEnd->setViewShadowEffect();
 
+    /* 注册事件过滤器 */
+    ui->cBox_selectChn->installEventFilter(this);
+    ui->cBox_selectWeekStart->installEventFilter(this);
+    ui->cBox_selectWeekEnd->installEventFilter(this);
+
     /* 默认显示周计划 */
     ui->tabWidget->setCurrentIndex(0);
 }
@@ -81,6 +112,55 @@ ManagerPlan::~ManagerPlan()
     delete ui;
 }
 
+/* 设置显示模式,需要在执行exec()之前调用 */
+void ManagerPlan::setMode(Enum_Mode mode)
+{
+    if(mode == Enum_Mode::Mode_Modify)
+    {
+        ui->widget_addPlan->setVisible(false); /* 隐藏添加计划区域 */
+        ui->label_title->setText("编辑"); /* 修改标题 */
+        ui->widget_background->resize(this->width(), 600); /* 修改窗口大小 */
+    }else {
+        ui->label_title->setText("新增"); /* 修改标题 */
+        ui->widget_background->resize(this->width(), 740); /* 修改窗口大小 */
+    }
+
+}
+
+/* 设置频率信息 */
+void ManagerPlan::setFrequencyID(ChannelInfo& info)
+{
+    m_channelInfo = info;
+    /* 设置当前频率选项 */
+    if(ui->cBox_selectChn->count() > 0)
+    {
+        for(int i = 0; i < ui->cBox_selectChn->count(); i++)
+        {
+            if(ui->cBox_selectChn->itemData(i).toInt() == info.ChannelID)
+            {
+                ui->cBox_selectChn->setCurrentIndex(i);
+                break;
+            }
+        }
+    }
+    /* 设置当前频率的计划列表 */
+    ui->pCard->setChannelInfo(info);
+    /* 设置当前频率的计划列表 */
+    auto list = findPlanList(info.ChannelID);
+    /* 设置计划列表 */  
+    ui->pCard->setPlanList(list);
+
+    if(list.isEmpty())
+    {
+        /* 没有计划,隐藏按钮 */
+        setButtonVisible(false);
+    }else
+    {
+        /* 有计划,显示按钮 */
+        setButtonVisible(true);
+    }
+}
+
 /* 修改UI样式 */
 void ManagerPlan::do_setUIStyle()
 {
@@ -131,6 +211,450 @@ void ManagerPlan::setWeekDay()
     ui->cBox_selectWeekEnd->addItem("星期天", static_cast<int>(enum_WeekDay::WeekDay_Sun));
 }
 
+/* 设置可选频率 */
+void ManagerPlan::setSelectFrequency()
+{
+    for(const auto& chnInfo : ChnContainer.getMapChannel())
+    {
+        ui->cBox_selectChn->addItem(chnInfo.ChannelName, chnInfo.ChannelID);
+    }
+    /* 设置默认的频率 */
+    if(ui->cBox_selectChn->count() > 0)
+    {
+        ui->cBox_selectChn->setCurrentIndex(0);
+        do_selectFrequency(0);
+    }
+    
+}
+
+/* 查找本地计划列表,这个频率不存在则添加 */
+QList<PlanInfo>& ManagerPlan::findPlanList(const int chnID)
+{
+    auto list = m_mapPlanInfo.find(chnID);
+    /* 如果没有这个频率的计划列表,则创建一个新的列表 */
+    if(list == m_mapPlanInfo.end())
+    {
+        QList<PlanInfo> listPlan;
+        /* 将PData的计划拷贝过来 */
+        auto pCard = PData.findPlanCard(chnID);
+        if(pCard != nullptr)
+        {
+            pCard->getPlanList(listPlan);
+        }
+        m_mapPlanInfo.insert(chnID, listPlan);
+    }
+    /* 再次查找这个频率的列表 */
+    list = m_mapPlanInfo.find(chnID);
+    return *list;
+}
+
+
+/* 添加计划,同时添加ui的卡片计划和计划列表 */
+void ManagerPlan::addPlanItem(const int chnID, const PlanInfo& info)
+{
+    /*  添加到UI*/
+    ui->pCard->addPlanItem(info);
+    /* 添加到计划列表 */
+    QList<PlanInfo>& list = findPlanList(chnID);
+    list.append(info);
+}
+
+/* 修改容器中的计划 */
+void ManagerPlan::modifyPlanItem(const int chnID, const PlanInfo& nowInfo, const PlanInfo& newInfo)
+{
+    auto& list = findPlanList(chnID);
+    for(int i = 0; i < list.count(); i++)
+    {
+        if(list.at(i) == nowInfo)
+        {
+            list.replace(i, newInfo);
+            break;
+        }
+    }
+}
+
+
+/**
+ * @brief 判断开机和关机时间是否冲突
+ * 
+ * @param info 
+ * @return true 冲突
+ * @return false 不冲突
+ */
+bool ManagerPlan::checkOnAndOffTime(const PlanInfo& info)
+{
+    if(info.onWeekDay != enum_WeekDay::WeekDay_Special)
+    {
+        /* 正常日判断 */
+        if(info.onWeekDay > info.offWeekDay)
+        {
+            /* 开机时间大于关机时间,冲突 */
+            return true;
+        }
+        else if(info.onWeekDay == info.offWeekDay)
+        {
+            /* 开机和关机在同一天 */
+            if(info.onTime.time() >= info.offTime.time())
+            {
+                /* 开机时间大于等于关机时间,冲突 */
+                return true;
+            }else
+            {
+                /* 开机时间小于关机时间,不冲突 */
+                return false;
+            }
+        }
+        return false;
+    } 
+    else
+    {
+        /* 特殊日判断 */ 
+        /* 开机和关机在不同天 */
+        if(info.onTime.date() > info.offTime.date())
+        {
+            /* 开机时间大于关机时间,冲突 */
+            return true;
+        }
+        else if(info.onTime.date() == info.offTime.date())
+        {
+            /* 开机和关机在同一天 */
+            if(info.onTime.time() >= info.offTime.time())
+            {
+                /* 开机时间大于等于关机时间,冲突 */
+                return true;
+            }else
+            {
+                /* 开机时间小于关机时间,不冲突 */
+                return false;
+            }
+        }
+        return false; 
+    }
+}
+
+/**
+ * @brief 比较两个时间点的大小,正常日和特殊日都可以比较
+ * 
+ * @param info1 
+ * @param info2 
+ * @return true info1 > info2
+ * @return false info1 < info2
+ */
+bool ManagerPlan::timeIsGerater(const enum_WeekDay weekDay1, const QDateTime& time1,
+    const enum_WeekDay weekDay2, const QDateTime& time2)
+{
+    /* 正常日 */
+    if(weekDay1 != enum_WeekDay::WeekDay_Special)
+    {
+        /* 先比较日期 */
+        if(weekDay1 > weekDay2)
+        {
+            return true;
+        }
+        else if(weekDay1 == weekDay2)
+        {
+            /* 日期相同,比较时间 */
+            if(time1.time() > time2.time())
+            {
+                return true;
+            }else
+            {
+                return false;
+            }
+        }
+        return false;
+    } 
+    else /* 特殊日 */
+    {
+        /* 先比较日期 */
+        if(time1.date() > time2.date())
+        {
+            return true;
+        }
+        else if(time1.date() == time2.date())
+        {
+            /* 日期相同,比较时间 */
+            if(time1.time() > time2.time())
+            {
+                return true;
+            }else
+            {
+                return false;
+            }
+        }
+        return false;
+    }
+}
+
+/**
+ * @brief 判断计划时间和列表中的时间是否冲突
+ *        判断规则是只要时间段不和任何一个时间段重合就不冲突
+ * 
+ * @param chnID 
+ * @param info 
+ * @return true 时间冲突
+ * @return false 时间不冲突
+ */
+bool ManagerPlan::checkPlanTimeConflict(const int chnID, const PlanInfo& info)
+{
+    QList<PlanInfo>& list = findPlanList(chnID);
+
+    bool isConflict = false;
+    int weekDayStart = static_cast<int>(info.onWeekDay);
+    int weekDayEnd = static_cast<int>(info.offWeekDay);
+    for(const auto& it : list)
+    {
+        /* info结束时间小于开始时间,或者info开始时间大于结束时间,就不冲突 */
+        bool isLess = timeIsGerater(it.onWeekDay, it.onTime, info.offWeekDay, info.offTime);
+        bool isGreater = timeIsGerater(info.onWeekDay, info.onTime, it.offWeekDay, it.offTime);
+        if(isLess || isGreater)
+        {
+            /* 时间不冲突 */
+            continue;
+        }
+        isConflict = true; /* 时间冲突 */
+        break;
+    }
+
+    return isConflict;
+}
+
+
+/* 判断计划时间和列表中的时间是否冲突,添加排除的计划,用于比较修改的计划 */
+bool ManagerPlan::checkPlanTimeConflict(const int chnID, const PlanInfo& newInfo, const PlanInfo& exInfo)
+{
+    /* 这里采用拷贝的方式获取,后续不需要再把排出的项放回去 */
+    QList<PlanInfo> list = findPlanList(chnID);
+    /* 先去掉需要排除的项 */
+    list.removeOne(exInfo);
+
+    bool isConflict = false;
+    int weekDayStart = static_cast<int>(newInfo.onWeekDay);
+    int weekDayEnd = static_cast<int>(newInfo.offWeekDay);
+    for(const auto& it : list)
+    {
+        /* info结束时间小于开始时间,或者info开始时间大于结束时间,就不冲突 */
+        bool isLess = timeIsGerater(it.onWeekDay, it.onTime, newInfo.offWeekDay, newInfo.offTime);
+        bool isGreater = timeIsGerater(newInfo.onWeekDay, newInfo.onTime, it.offWeekDay, it.offTime);
+        if(isLess || isGreater)
+        {
+            /* 时间不冲突 */
+            continue;
+        }
+        isConflict = true; /* 时间冲突 */
+        break;
+    }
+
+    return isConflict;
+}
+
+
+/* 设置按钮显示或隐藏 */
+void ManagerPlan::setButtonVisible(bool isVisible)
+{
+    if(isVisible)
+    {
+        ui->pBtn_editPlan->show();
+        ui->pBtn_deletePlan->show();
+    }else
+    {
+        ui->pBtn_editPlan->hide();
+        ui->pBtn_deletePlan->hide();
+    }
+}
+
+
+/* 选择了一个频率 */
+void ManagerPlan::do_selectFrequency(int index)
+{
+    auto chnID = ui->cBox_selectChn->itemData(index).toInt();
+    m_channelInfo = ChnContainer.getChannel(chnID);
+    
+    QList<PlanInfo>& list = findPlanList(chnID);
+    /* 设置频率信息 */
+    ui->pCard->setChannelInfo(ChnContainer.getChannel(chnID));
+    /* 设置计划列表 */
+    ui->pCard->setPlanList(list);
+    
+    if(list.isEmpty())
+    {
+        /* 没有计划,隐藏按钮 */
+        setButtonVisible(false);
+    }else
+    {
+        /* 有计划,显示按钮 */
+        setButtonVisible(true);
+    }
+}
+
+/* 点击了添加按钮 */
+void ManagerPlan::do_addPlanItem()
+{
+    int chnID = ui->pCard->getChannelInfo().ChannelID;
+    PlanInfo one;
+    /* 判断是正常日还是特殊日 */
+    if(ui->tabWidget->currentIndex() == 0)
+    {
+        /* 正常日 */
+        one.onWeekDay = static_cast<enum_WeekDay>(ui->cBox_selectWeekStart->itemData(ui->cBox_selectWeekStart->currentIndex()).toInt());
+        one.onTime.setTime(ui->timeEdit_weekStart->getTime());
+
+        one.offWeekDay = static_cast<enum_WeekDay>(ui->cBox_selectWeekEnd->itemData(ui->cBox_selectWeekEnd->currentIndex()).toInt());
+        one.offTime.setTime(ui->timeEdit_weekEnd->getTime());
+    }else {
+        /* 特殊日 */
+        one.onWeekDay = enum_WeekDay::WeekDay_Special;
+        one.onTime.setDate(ui->dateEdit_specialStart->date());
+        one.onTime.setTime(ui->timeEdit_specialStart->getTime());
+
+        one.offWeekDay = enum_WeekDay::WeekDay_Special;
+        one.offTime.setDate(ui->dateEdit_specialEnd->date());
+        one.offTime.setTime(ui->timeEdit_specialEnd->getTime());
+    }
+    
+
+    /* 先判断开机时间和关机时间是否冲突 */
+    if(checkOnAndOffTime(one))
+    {
+        /* 开始和结束时间冲突 */
+        TipWidget::display(TipWidget::OPERATOR_WARN, "开机时间早于或等于关机时间!", this);
+        return;
+    }
+
+    /* 判断时间段是否和历史时间段冲突 */
+    if(checkPlanTimeConflict(chnID, one))
+    {
+        /* 时间段冲突 */
+        TipWidget::display(TipWidget::OPERATOR_WARN, "时间段冲突!", this);
+        return;
+    }
+
+    /* 添加计划 */
+    addPlanItem(chnID, one);
+
+    setButtonVisible(true); /* 显示按钮 */
+
+}
+
+/* 点击修改按钮 */
+void ManagerPlan::do_modifyPlanItem()
+{
+    int chnID = ui->pCard->getChannelInfo().ChannelID;
+    auto& list = findPlanList(chnID);
+
+    /* 获取选中的行 */
+    auto index = ui->pCard->getSelectedRow();
+    if(index < 0 || index >= list.size())
+    {
+        /* 没有选中行 */
+        TipWidget::display(TipWidget::OPERATOR_WARN, "没有选中行!", this);
+        return;
+    }
+    // LH_WRITE_LOG_DEBUG(QString("修改行: %1").arg(index));
+
+    /* 获取修改后的日期 */
+    PlanInfo one;
+    if(ui->tabWidget->currentIndex() == 0)
+    {
+        /* 正常日 */
+        one.onWeekDay = static_cast<enum_WeekDay>(ui->cBox_selectWeekStart->itemData(ui->cBox_selectWeekStart->currentIndex()).toInt());
+        one.onTime.setTime(ui->timeEdit_weekStart->getTime());
+        one.offWeekDay = static_cast<enum_WeekDay>(ui->cBox_selectWeekEnd->itemData(ui->cBox_selectWeekEnd->currentIndex()).toInt());
+        one.offTime.setTime(ui->timeEdit_weekEnd->getTime());
+    }else {
+        /* 特殊日 */
+        one.onWeekDay = enum_WeekDay::WeekDay_Special;
+        one.onTime.setDate(ui->dateEdit_specialStart->date());
+        one.onTime.setTime(ui->timeEdit_specialStart->getTime());
+        one.offWeekDay = enum_WeekDay::WeekDay_Special;
+        one.offTime.setDate(ui->dateEdit_specialEnd->date());
+        one.offTime.setTime(ui->timeEdit_specialEnd->getTime());
+    }
+    /* 先判断设置的时间是否和当前选中的行的时间相同 */
+    auto nowPlan = ui->pCard->getSelectedPlan();
+    if(nowPlan == one)
+    {
+        return;
+    }
+    /* 先判断开机时间和关机时间是否冲突 */
+    if(checkOnAndOffTime(one))
+    {
+        /* 开始和结束时间冲突 */
+        TipWidget::display(TipWidget::OPERATOR_WARN, "开机时间早于或等于关机时间!", this);
+        return;
+    }
+    auto exPlan = ui->pCard->getSelectedPlan();
+    /* 判断时间段是否和历史时间段冲突 */
+    if(checkPlanTimeConflict(chnID, one, exPlan))
+    {
+        /* 时间段冲突 */
+        TipWidget::display(TipWidget::OPERATOR_WARN, "时间段冲突!", this);
+        return;
+    }
+
+    /* 修改选中的行 */
+    auto oldPlan = ui->pCard->modifyPlanItem(index, one);    
+    /* 修改数据容器中的计划 */
+    modifyPlanItem(chnID, oldPlan, one);
+}
+
+/* 点击了删除按钮 */
+void ManagerPlan::do_deletePlanItem()
+{
+    int chnID = ui->pCard->getChannelInfo().ChannelID;
+    auto& list = findPlanList(chnID);
+
+    /* 获取选中的行 */
+    auto index = ui->pCard->getSelectedRow();
+    if(index < 0 || index >= list.size())
+    {
+        /* 没有选中行 */
+        TipWidget::display(TipWidget::OPERATOR_WARN, "没有选中行!", this);
+        return;
+    }
+    LH_WRITE_LOG_DEBUG(QString("删除行: %1").arg(index));
+    /* 删除选中的行 */
+    auto plan = ui->pCard->deletePlanItem(index);
+    /* 删除UI的计划 */
+    list.removeOne(plan);
+
+    /* 判断删除后是否还有计划,没有就隐藏修改和删除按钮 */
+    if(list.isEmpty())
+    {
+        /* 没有计划,隐藏按钮 */
+        setButtonVisible(false);
+    }
+}
+
+/* 点击了OK按钮 */
+void ManagerPlan::do_pBtn_ok()
+{
+    m_isOK = true;
+    this->close();
+}
+
+/* 选中了一项,回显到编辑页面 */
+void ManagerPlan::do_tableView_clicked(PlanInfo& info)
+{
+    /* 设置时间和日期 */
+    if(info.onWeekDay != enum_WeekDay::WeekDay_Special)
+    {
+        /* 正常日 */
+        ui->cBox_selectWeekStart->setCurrentIndex(static_cast<int>(info.onWeekDay) - 1);
+        ui->timeEdit_weekStart->setTime(info.onTime.time());
+        ui->cBox_selectWeekEnd->setCurrentIndex(static_cast<int>(info.offWeekDay) - 1);
+        ui->timeEdit_weekEnd->setTime(info.offTime.time());
+    }else
+    {
+        /* 特殊日 */
+        ui->dateEdit_specialStart->setDate(info.onTime.date());
+        ui->timeEdit_specialStart->setTime(info.onTime.time());
+        ui->dateEdit_specialEnd->setDate(info.offTime.date());
+        ui->timeEdit_specialEnd->setTime(info.offTime.time());
+    }
+}
+
+
 
 /* 鼠标点击事件 */
 void ManagerPlan::mousePressEvent(QMouseEvent *event)
@@ -174,6 +698,27 @@ bool ManagerPlan::eventFilter(QObject *watched, QEvent *event)
             return true;
         }
     }
+    else if(watched == ui->cBox_selectChn)
+    {
+        if(event->type() == QEvent::Wheel)
+        {
+            return true;
+        }
+    }
+    else if(watched == ui->cBox_selectWeekStart)
+    {
+        if(event->type() == QEvent::Wheel)
+        {
+            return true;
+        }
+    }
+    else if(watched == ui->cBox_selectWeekEnd)
+    {
+        if(event->type() == QEvent::Wheel)
+        {
+            return true;
+        }
+    }
     else if(watched == ui->pBtn_close)
     {
         if(event->type() == QEvent::Enter)

+ 71 - 1
TransmitterSwitch/ManagerPlan/managerplan.h

@@ -3,10 +3,24 @@
 
 #include <QDialog>
 
+#include "PlanData.h"
+
 namespace Ui {
 class ManagerPlan;
 }
 
+
+
+enum class Enum_Mode
+{
+    Mode_Add = 0,               /* 添加模式 */
+    Mode_Modify = 1             /* 修改模式 */
+};
+
+/**
+ * @brief 管理计划页面
+ * 
+ */
 class ManagerPlan : public QDialog
 {
     Q_OBJECT
@@ -15,6 +29,16 @@ public:
     explicit ManagerPlan(QDialog *parent = nullptr);
     ~ManagerPlan();
 
+    /* 获取是否点击了OK */
+    bool isOK() const { return m_isOK; }
+    /* 获取计划信息 */
+    QMap<int, QList<PlanInfo>>& getPlanInfo() { return m_mapPlanInfo; }
+
+    /* 设置显示模式,需要在执行exec()之前调用 */
+    void setMode(Enum_Mode mode);
+    /* 设置频率信息 */
+    void setFrequencyID(ChannelInfo& info);
+
 public slots:
     /* 修改UI样式 */
     void do_setUIStyle();
@@ -25,6 +49,46 @@ private:
     /* 设置可选择的周几 */
     void setWeekDay();
 
+    /* 设置可选频率 */
+    void setSelectFrequency();
+
+    /* 查找本地计划列表,这个频率不存在则添加 */
+    QList<PlanInfo>& findPlanList(const int chnID);
+    /* 添加计划,同时添加ui的卡片计划和计划列表 */
+    void addPlanItem(const int chnID, const PlanInfo& info);
+    /* 修改容器中的计划 */
+    void modifyPlanItem(const int chnID, const PlanInfo& nowInfo, const PlanInfo& newInfo);
+
+    /* 判断开机和关机时间是否冲突 */
+    inline bool checkOnAndOffTime(const PlanInfo& info);
+    /* 比较两个时间点的大小 */
+    inline bool timeIsGerater(const enum_WeekDay weekDay1, const QDateTime& time1,
+                            const enum_WeekDay weekDay2, const QDateTime& time2);
+    /* 判断计划时间和列表中的时间是否冲突 */
+    bool checkPlanTimeConflict(const int chnID, const PlanInfo& info);
+    /* 判断计划时间和列表中的时间是否冲突,添加排除的计划,用于比较修改的计划 */
+    bool checkPlanTimeConflict(const int chnID, const PlanInfo& newInfo, const PlanInfo& exInfo);
+
+    /* 设置按钮显示或隐藏 */
+    inline void setButtonVisible(bool isVisible);
+
+private slots:
+    /* 选择了一个频率 */
+    void do_selectFrequency(int index);
+
+    /* 点击了添加按钮 */
+    void do_addPlanItem();
+    /* 点击修改按钮 */
+    void do_modifyPlanItem();
+    /* 点击了删除按钮 */
+    void do_deletePlanItem();
+
+    /* 点击了OK按钮 */
+    void do_pBtn_ok();
+
+    /* 选中了一项,回显到编辑页面 */
+    void do_tableView_clicked(PlanInfo& info);
+
 protected:
     /* 鼠标点击事件 */
     void mousePressEvent(QMouseEvent *event) override;
@@ -39,7 +103,13 @@ protected:
 private:
     Ui::ManagerPlan *ui;
 
-    QPoint m_lastPos;                       /* 鼠标点击的位置 */
+    QPoint m_lastPos;                           /* 鼠标点击的位置 */
+
+    bool m_isOK = false;                        /* 是否点击了OK按钮 */
+    ChannelInfo m_channelInfo;                  /* 频率信息 */
+
+    /* 存储计划信息,修改过的频率计划,存储的是这个频率完整的计划 */
+    QMap<int, QList<PlanInfo>> m_mapPlanInfo;
 };
 
 #endif // MANAGERPLAN_H

+ 910 - 864
TransmitterSwitch/ManagerPlan/managerplan.ui

@@ -37,152 +37,323 @@
    </property>
    <item>
     <widget class="QWidget" name="widget" native="true">
-     <layout class="QGridLayout" name="gridLayout">
-      <item row="0" column="0">
-       <widget class="QWidget" name="widget_background" native="true">
-        <property name="sizePolicy">
-         <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
-          <horstretch>0</horstretch>
-          <verstretch>0</verstretch>
-         </sizepolicy>
-        </property>
-        <property name="minimumSize">
-         <size>
-          <width>682</width>
-          <height>732</height>
-         </size>
-        </property>
-        <property name="maximumSize">
-         <size>
-          <width>682</width>
-          <height>732</height>
-         </size>
-        </property>
-        <layout class="QVBoxLayout" name="verticalLayout_2">
-         <property name="spacing">
-          <number>0</number>
+     <widget class="QWidget" name="widget_background" native="true">
+      <property name="geometry">
+       <rect>
+        <x>199</x>
+        <y>121</y>
+        <width>730</width>
+        <height>732</height>
+       </rect>
+      </property>
+      <property name="sizePolicy">
+       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+        <horstretch>0</horstretch>
+        <verstretch>0</verstretch>
+       </sizepolicy>
+      </property>
+      <property name="minimumSize">
+       <size>
+        <width>730</width>
+        <height>600</height>
+       </size>
+      </property>
+      <property name="maximumSize">
+       <size>
+        <width>730</width>
+        <height>800</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_top" native="true">
+         <property name="sizePolicy">
+          <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+           <horstretch>0</horstretch>
+           <verstretch>0</verstretch>
+          </sizepolicy>
          </property>
-         <property name="leftMargin">
-          <number>0</number>
+         <property name="minimumSize">
+          <size>
+           <width>0</width>
+           <height>63</height>
+          </size>
          </property>
-         <property name="topMargin">
-          <number>0</number>
+         <property name="maximumSize">
+          <size>
+           <width>16777215</width>
+           <height>63</height>
+          </size>
          </property>
-         <property name="rightMargin">
-          <number>0</number>
-         </property>
-         <property name="bottomMargin">
-          <number>0</number>
-         </property>
-         <item>
-          <widget class="QWidget" name="widget_top" 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>63</height>
-            </size>
-           </property>
-           <property name="maximumSize">
-            <size>
-             <width>16777215</width>
-             <height>63</height>
-            </size>
-           </property>
+         <layout class="QHBoxLayout" name="horizontalLayout_8">
+          <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="geometry">
-             <rect>
-              <x>32</x>
-              <y>19</y>
-              <width>72</width>
+            <property name="minimumSize">
+             <size>
+              <width>36</width>
               <height>24</height>
-             </rect>
+             </size>
+            </property>
+            <property name="maximumSize">
+             <size>
+              <width>16777215</width>
+              <height>16777215</height>
+             </size>
             </property>
             <property name="text">
              <string>新增</string>
             </property>
            </widget>
+          </item>
+          <item>
+           <spacer name="horizontalSpacer_6">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
+            </property>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>611</width>
+              <height>20</height>
+             </size>
+            </property>
+           </spacer>
+          </item>
+          <item>
            <widget class="QPushButton" name="pBtn_close">
-            <property name="geometry">
-             <rect>
-              <x>634</x>
-              <y>15</y>
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="minimumSize">
+             <size>
               <width>32</width>
               <height>32</height>
-             </rect>
+             </size>
+            </property>
+            <property name="maximumSize">
+             <size>
+              <width>32</width>
+              <height>32</height>
+             </size>
             </property>
             <property name="text">
              <string/>
             </property>
            </widget>
-          </widget>
-         </item>
-         <item>
-          <spacer name="verticalSpacer">
-           <property name="orientation">
-            <enum>Qt::Vertical</enum>
-           </property>
-           <property name="sizeType">
-            <enum>QSizePolicy::Fixed</enum>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item>
+        <spacer name="verticalSpacer">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeType">
+          <enum>QSizePolicy::Fixed</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>32</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
+        <widget class="QWidget" name="widget_addPlan" 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>140</height>
+          </size>
+         </property>
+         <property name="maximumSize">
+          <size>
+           <width>16777215</width>
+           <height>140</height>
+          </size>
+         </property>
+         <widget class="QLabel" name="label_selectChn">
+          <property name="geometry">
+           <rect>
+            <x>32</x>
+            <y>0</y>
+            <width>72</width>
+            <height>24</height>
+           </rect>
+          </property>
+          <property name="text">
+           <string>选择频率</string>
+          </property>
+         </widget>
+         <widget class="QWidget" name="widget_2" native="true">
+          <property name="geometry">
+           <rect>
+            <x>32</x>
+            <y>38</y>
+            <width>618</width>
+            <height>32</height>
+           </rect>
+          </property>
+          <layout class="QHBoxLayout" name="horizontalLayout">
+           <property name="spacing">
+            <number>0</number>
            </property>
-           <property name="sizeHint" stdset="0">
-            <size>
-             <width>20</width>
-             <height>32</height>
-            </size>
+           <property name="leftMargin">
+            <number>0</number>
            </property>
-          </spacer>
-         </item>
-         <item>
-          <widget class="QWidget" name="widget_addPlan" native="true">
-           <property name="sizePolicy">
-            <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
-             <horstretch>0</horstretch>
-             <verstretch>0</verstretch>
-            </sizepolicy>
+           <property name="topMargin">
+            <number>0</number>
            </property>
-           <property name="minimumSize">
-            <size>
-             <width>0</width>
-             <height>140</height>
-            </size>
+           <property name="rightMargin">
+            <number>0</number>
            </property>
-           <property name="maximumSize">
-            <size>
-             <width>16777215</width>
-             <height>140</height>
-            </size>
+           <property name="bottomMargin">
+            <number>0</number>
            </property>
-           <widget class="QLabel" name="label_selectChn">
-            <property name="geometry">
-             <rect>
-              <x>32</x>
-              <y>0</y>
-              <width>72</width>
-              <height>24</height>
-             </rect>
-            </property>
-            <property name="text">
-             <string>选择频率</string>
+           <item>
+            <widget class="QLabel" name="label_x1">
+             <property name="minimumSize">
+              <size>
+               <width>10</width>
+               <height>10</height>
+              </size>
+             </property>
+             <property name="maximumSize">
+              <size>
+               <width>10</width>
+               <height>10</height>
+              </size>
+             </property>
+             <property name="text">
+              <string>*</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QLabel" name="label_2">
+             <property name="minimumSize">
+              <size>
+               <width>70</width>
+               <height>14</height>
+              </size>
+             </property>
+             <property name="maximumSize">
+              <size>
+               <width>70</width>
+               <height>16777215</height>
+              </size>
+             </property>
+             <property name="text">
+              <string>频率名称:</string>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="CustomComboBox" name="cBox_selectChn">
+             <property name="minimumSize">
+              <size>
+               <width>0</width>
+               <height>32</height>
+              </size>
+             </property>
+             <property name="maximumSize">
+              <size>
+               <width>538</width>
+               <height>32</height>
+              </size>
+             </property>
+            </widget>
+           </item>
+          </layout>
+         </widget>
+         <widget class="QLabel" name="label_selectChn_2">
+          <property name="geometry">
+           <rect>
+            <x>32</x>
+            <y>102</y>
+            <width>72</width>
+            <height>24</height>
+           </rect>
+          </property>
+          <property name="text">
+           <string>添加计划</string>
+          </property>
+         </widget>
+        </widget>
+       </item>
+       <item>
+        <widget class="QWidget" name="widget_editPlan" native="true">
+         <layout class="QHBoxLayout" name="horizontalLayout_4">
+          <property name="spacing">
+           <number>20</number>
+          </property>
+          <property name="leftMargin">
+           <number>32</number>
+          </property>
+          <property name="topMargin">
+           <number>0</number>
+          </property>
+          <property name="rightMargin">
+           <number>32</number>
+          </property>
+          <property name="bottomMargin">
+           <number>0</number>
+          </property>
+          <item>
+           <widget class="PlanCard" name="pCard" native="true">
+            <property name="minimumSize">
+             <size>
+              <width>262</width>
+              <height>0</height>
+             </size>
             </property>
            </widget>
-           <widget class="QWidget" name="widget_2" native="true">
-            <property name="geometry">
-             <rect>
-              <x>32</x>
-              <y>38</y>
-              <width>618</width>
-              <height>32</height>
-             </rect>
+          </item>
+          <item>
+           <widget class="QWidget" name="widget_edit" native="true">
+            <property name="sizePolicy">
+             <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
             </property>
-            <layout class="QHBoxLayout" name="horizontalLayout">
+            <layout class="QVBoxLayout" name="verticalLayout_3">
              <property name="spacing">
-              <number>0</number>
+              <number>10</number>
              </property>
              <property name="leftMargin">
               <number>0</number>
@@ -197,796 +368,671 @@
               <number>0</number>
              </property>
              <item>
-              <widget class="QLabel" name="label_x1">
-               <property name="minimumSize">
-                <size>
-                 <width>10</width>
-                 <height>10</height>
-                </size>
-               </property>
-               <property name="maximumSize">
-                <size>
-                 <width>10</width>
-                 <height>10</height>
-                </size>
-               </property>
-               <property name="text">
-                <string>*</string>
+              <widget class="QTabWidget" name="tabWidget">
+               <property name="sizePolicy">
+                <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+                 <horstretch>0</horstretch>
+                 <verstretch>0</verstretch>
+                </sizepolicy>
                </property>
-              </widget>
-             </item>
-             <item>
-              <widget class="QLabel" name="label_2">
-               <property name="minimumSize">
-                <size>
-                 <width>70</width>
-                 <height>14</height>
-                </size>
-               </property>
-               <property name="maximumSize">
-                <size>
-                 <width>70</width>
-                 <height>16777215</height>
-                </size>
-               </property>
-               <property name="text">
-                <string>频率名称:</string>
-               </property>
-              </widget>
-             </item>
-             <item>
-              <widget class="CustomComboBox" name="cBox_selectChn">
                <property name="minimumSize">
                 <size>
                  <width>0</width>
-                 <height>32</height>
+                 <height>176</height>
                 </size>
                </property>
                <property name="maximumSize">
                 <size>
-                 <width>538</width>
-                 <height>32</height>
+                 <width>16777215</width>
+                 <height>16777215</height>
                 </size>
                </property>
-              </widget>
-             </item>
-            </layout>
-           </widget>
-           <widget class="QLabel" name="label_selectChn_2">
-            <property name="geometry">
-             <rect>
-              <x>32</x>
-              <y>102</y>
-              <width>72</width>
-              <height>24</height>
-             </rect>
-            </property>
-            <property name="text">
-             <string>添加计划</string>
-            </property>
-           </widget>
-          </widget>
-         </item>
-         <item>
-          <widget class="QWidget" name="widget_editPlan" native="true">
-           <layout class="QHBoxLayout" name="horizontalLayout_4">
-            <property name="spacing">
-             <number>20</number>
-            </property>
-            <property name="leftMargin">
-             <number>32</number>
-            </property>
-            <property name="topMargin">
-             <number>0</number>
-            </property>
-            <property name="rightMargin">
-             <number>32</number>
-            </property>
-            <property name="bottomMargin">
-             <number>0</number>
-            </property>
-            <item>
-             <widget class="PlanCard" name="widget_planCard" native="true">
-              <property name="minimumSize">
-               <size>
-                <width>262</width>
-                <height>0</height>
-               </size>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QWidget" name="widget_edit" native="true">
-              <property name="sizePolicy">
-               <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
-                <horstretch>0</horstretch>
-                <verstretch>0</verstretch>
-               </sizepolicy>
-              </property>
-              <layout class="QVBoxLayout" name="verticalLayout_3">
-               <property name="spacing">
-                <number>10</number>
-               </property>
-               <property name="leftMargin">
-                <number>0</number>
-               </property>
-               <property name="topMargin">
-                <number>0</number>
-               </property>
-               <property name="rightMargin">
-                <number>0</number>
+               <property name="currentIndex">
+                <number>1</number>
                </property>
-               <property name="bottomMargin">
-                <number>0</number>
-               </property>
-               <item>
-                <widget class="QTabWidget" name="tabWidget">
-                 <property name="sizePolicy">
-                  <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
-                   <horstretch>0</horstretch>
-                   <verstretch>0</verstretch>
-                  </sizepolicy>
+               <widget class="QWidget" name="tab_week">
+                <attribute name="title">
+                 <string>周计划</string>
+                </attribute>
+                <widget class="QWidget" name="widget_weekStart" native="true">
+                 <property name="geometry">
+                  <rect>
+                   <x>0</x>
+                   <y>24</y>
+                   <width>330</width>
+                   <height>32</height>
+                  </rect>
                  </property>
                  <property name="minimumSize">
                   <size>
                    <width>0</width>
-                   <height>176</height>
+                   <height>32</height>
                   </size>
                  </property>
                  <property name="maximumSize">
                   <size>
                    <width>16777215</width>
-                   <height>16777215</height>
+                   <height>32</height>
                   </size>
                  </property>
-                 <property name="currentIndex">
-                  <number>1</number>
-                 </property>
-                 <widget class="QWidget" name="tab_week">
-                  <attribute name="title">
-                   <string>周计划</string>
-                  </attribute>
-                  <widget class="QWidget" name="widget_weekStart" native="true">
-                   <property name="geometry">
-                    <rect>
-                     <x>0</x>
-                     <y>24</y>
-                     <width>330</width>
-                     <height>32</height>
-                    </rect>
-                   </property>
-                   <property name="minimumSize">
-                    <size>
-                     <width>0</width>
-                     <height>32</height>
-                    </size>
-                   </property>
-                   <property name="maximumSize">
-                    <size>
-                     <width>16777215</width>
-                     <height>32</height>
-                    </size>
-                   </property>
-                   <layout class="QHBoxLayout" name="horizontalLayout_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="QLabel" name="label_x2">
-                      <property name="minimumSize">
-                       <size>
-                        <width>10</width>
-                        <height>10</height>
-                       </size>
-                      </property>
-                      <property name="maximumSize">
-                       <size>
-                        <width>10</width>
-                        <height>10</height>
-                       </size>
-                      </property>
-                      <property name="text">
-                       <string>*</string>
-                      </property>
-                     </widget>
-                    </item>
-                    <item>
-                     <widget class="QLabel" name="label_3">
-                      <property name="minimumSize">
-                       <size>
-                        <width>70</width>
-                        <height>14</height>
-                       </size>
-                      </property>
-                      <property name="maximumSize">
-                       <size>
-                        <width>70</width>
-                        <height>16777215</height>
-                       </size>
-                      </property>
-                      <property name="text">
-                       <string>开机时间:</string>
-                      </property>
-                     </widget>
-                    </item>
-                    <item>
-                     <widget class="CustomComboBox" name="cBox_selectWeekStart">
-                      <property name="minimumSize">
-                       <size>
-                        <width>124</width>
-                        <height>32</height>
-                       </size>
-                      </property>
-                      <property name="maximumSize">
-                       <size>
-                        <width>538</width>
-                        <height>32</height>
-                       </size>
-                      </property>
-                     </widget>
-                    </item>
-                    <item>
-                     <spacer name="horizontalSpacer_2">
-                      <property name="orientation">
-                       <enum>Qt::Horizontal</enum>
-                      </property>
-                      <property name="sizeHint" stdset="0">
-                       <size>
-                        <width>40</width>
-                        <height>20</height>
-                       </size>
-                      </property>
-                     </spacer>
-                    </item>
-                    <item>
-                     <widget class="TimeWidget" name="timeEdit_weekStart">
-                      <property name="minimumSize">
-                       <size>
-                        <width>124</width>
-                        <height>32</height>
-                       </size>
-                      </property>
-                      <property name="maximumSize">
-                       <size>
-                        <width>16777215</width>
-                        <height>32</height>
-                       </size>
-                      </property>
-                     </widget>
-                    </item>
-                   </layout>
-                  </widget>
-                  <widget class="QWidget" name="widget_weekEnd" native="true">
-                   <property name="geometry">
-                    <rect>
-                     <x>0</x>
-                     <y>80</y>
-                     <width>330</width>
-                     <height>32</height>
-                    </rect>
-                   </property>
-                   <property name="minimumSize">
-                    <size>
-                     <width>0</width>
-                     <height>32</height>
-                    </size>
-                   </property>
-                   <property name="maximumSize">
-                    <size>
-                     <width>16777215</width>
-                     <height>32</height>
-                    </size>
-                   </property>
-                   <layout class="QHBoxLayout" name="horizontalLayout_3">
-                    <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="QLabel" name="label_x3">
-                      <property name="minimumSize">
-                       <size>
-                        <width>10</width>
-                        <height>10</height>
-                       </size>
-                      </property>
-                      <property name="maximumSize">
-                       <size>
-                        <width>10</width>
-                        <height>10</height>
-                       </size>
-                      </property>
-                      <property name="text">
-                       <string>*</string>
-                      </property>
-                     </widget>
-                    </item>
-                    <item>
-                     <widget class="QLabel" name="label_4">
-                      <property name="minimumSize">
-                       <size>
-                        <width>70</width>
-                        <height>14</height>
-                       </size>
-                      </property>
-                      <property name="maximumSize">
-                       <size>
-                        <width>70</width>
-                        <height>16777215</height>
-                       </size>
-                      </property>
-                      <property name="text">
-                       <string>关机时间:</string>
-                      </property>
-                     </widget>
-                    </item>
-                    <item>
-                     <widget class="CustomComboBox" name="cBox_selectWeekEnd">
-                      <property name="minimumSize">
-                       <size>
-                        <width>124</width>
-                        <height>32</height>
-                       </size>
-                      </property>
-                      <property name="maximumSize">
-                       <size>
-                        <width>538</width>
-                        <height>32</height>
-                       </size>
-                      </property>
-                     </widget>
-                    </item>
-                    <item>
-                     <spacer name="horizontalSpacer_3">
-                      <property name="orientation">
-                       <enum>Qt::Horizontal</enum>
-                      </property>
-                      <property name="sizeHint" stdset="0">
-                       <size>
-                        <width>40</width>
-                        <height>20</height>
-                       </size>
-                      </property>
-                     </spacer>
-                    </item>
-                    <item>
-                     <widget class="TimeWidget" name="timeEdit_weekEnd">
-                      <property name="minimumSize">
-                       <size>
-                        <width>124</width>
-                        <height>32</height>
-                       </size>
-                      </property>
-                      <property name="maximumSize">
-                       <size>
-                        <width>16777215</width>
-                        <height>32</height>
-                       </size>
-                      </property>
-                     </widget>
-                    </item>
-                   </layout>
-                  </widget>
-                 </widget>
-                 <widget class="QWidget" name="tab_special">
-                  <attribute name="title">
-                   <string>特殊日</string>
-                  </attribute>
-                  <widget class="QWidget" name="widget_specialStart" native="true">
-                   <property name="geometry">
-                    <rect>
-                     <x>0</x>
-                     <y>24</y>
-                     <width>330</width>
-                     <height>32</height>
-                    </rect>
-                   </property>
-                   <property name="minimumSize">
-                    <size>
-                     <width>0</width>
-                     <height>32</height>
-                    </size>
-                   </property>
-                   <property name="maximumSize">
-                    <size>
-                     <width>16777215</width>
-                     <height>32</height>
-                    </size>
-                   </property>
-                   <layout class="QHBoxLayout" name="horizontalLayout_6">
-                    <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="QLabel" name="label_x4">
-                      <property name="minimumSize">
-                       <size>
-                        <width>10</width>
-                        <height>10</height>
-                       </size>
-                      </property>
-                      <property name="maximumSize">
-                       <size>
-                        <width>10</width>
-                        <height>10</height>
-                       </size>
-                      </property>
-                      <property name="text">
-                       <string>*</string>
-                      </property>
-                     </widget>
-                    </item>
-                    <item>
-                     <widget class="QLabel" name="label_5">
-                      <property name="minimumSize">
-                       <size>
-                        <width>70</width>
-                        <height>14</height>
-                       </size>
-                      </property>
-                      <property name="maximumSize">
-                       <size>
-                        <width>70</width>
-                        <height>16777215</height>
-                       </size>
-                      </property>
-                      <property name="text">
-                       <string>开机时间:</string>
-                      </property>
-                     </widget>
-                    </item>
-                    <item>
-                     <widget class="CalendarDTEdit" name="dateEdit_specialStart">
-                      <property name="minimumSize">
-                       <size>
-                        <width>124</width>
-                        <height>32</height>
-                       </size>
-                      </property>
-                     </widget>
-                    </item>
-                    <item>
-                     <spacer name="horizontalSpacer_4">
-                      <property name="orientation">
-                       <enum>Qt::Horizontal</enum>
-                      </property>
-                      <property name="sizeHint" stdset="0">
-                       <size>
-                        <width>40</width>
-                        <height>20</height>
-                       </size>
-                      </property>
-                     </spacer>
-                    </item>
-                    <item>
-                     <widget class="TimeWidget" name="timeEdit_specialStart">
-                      <property name="minimumSize">
-                       <size>
-                        <width>124</width>
-                        <height>32</height>
-                       </size>
-                      </property>
-                      <property name="maximumSize">
-                       <size>
-                        <width>16777215</width>
-                        <height>32</height>
-                       </size>
-                      </property>
-                     </widget>
-                    </item>
-                   </layout>
-                  </widget>
-                  <widget class="QWidget" name="widget_specialEnd" native="true">
-                   <property name="geometry">
-                    <rect>
-                     <x>0</x>
-                     <y>80</y>
-                     <width>330</width>
-                     <height>32</height>
-                    </rect>
-                   </property>
-                   <property name="minimumSize">
-                    <size>
-                     <width>0</width>
-                     <height>32</height>
-                    </size>
-                   </property>
-                   <property name="maximumSize">
-                    <size>
-                     <width>16777215</width>
-                     <height>32</height>
-                    </size>
-                   </property>
-                   <layout class="QHBoxLayout" name="horizontalLayout_7">
-                    <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="QLabel" name="label_x5">
-                      <property name="minimumSize">
-                       <size>
-                        <width>10</width>
-                        <height>10</height>
-                       </size>
-                      </property>
-                      <property name="maximumSize">
-                       <size>
-                        <width>10</width>
-                        <height>10</height>
-                       </size>
-                      </property>
-                      <property name="text">
-                       <string>*</string>
-                      </property>
-                     </widget>
-                    </item>
-                    <item>
-                     <widget class="QLabel" name="label_6">
-                      <property name="minimumSize">
-                       <size>
-                        <width>70</width>
-                        <height>14</height>
-                       </size>
-                      </property>
-                      <property name="maximumSize">
-                       <size>
-                        <width>70</width>
-                        <height>16777215</height>
-                       </size>
-                      </property>
-                      <property name="text">
-                       <string>关机时间:</string>
-                      </property>
-                     </widget>
-                    </item>
-                    <item>
-                     <widget class="CalendarDTEdit" name="dateEdit_specialEnd">
-                      <property name="minimumSize">
-                       <size>
-                        <width>124</width>
-                        <height>32</height>
-                       </size>
-                      </property>
-                     </widget>
-                    </item>
-                    <item>
-                     <spacer name="horizontalSpacer_5">
-                      <property name="orientation">
-                       <enum>Qt::Horizontal</enum>
-                      </property>
-                      <property name="sizeHint" stdset="0">
-                       <size>
-                        <width>40</width>
-                        <height>20</height>
-                       </size>
-                      </property>
-                     </spacer>
-                    </item>
-                    <item>
-                     <widget class="TimeWidget" name="timeEdit_specialEnd">
-                      <property name="minimumSize">
-                       <size>
-                        <width>124</width>
-                        <height>32</height>
-                       </size>
-                      </property>
-                      <property name="maximumSize">
-                       <size>
-                        <width>16777215</width>
-                        <height>32</height>
-                       </size>
-                      </property>
-                     </widget>
-                    </item>
-                   </layout>
-                  </widget>
-                 </widget>
+                 <layout class="QHBoxLayout" name="horizontalLayout_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="QLabel" name="label_x2">
+                    <property name="minimumSize">
+                     <size>
+                      <width>10</width>
+                      <height>10</height>
+                     </size>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>10</width>
+                      <height>10</height>
+                     </size>
+                    </property>
+                    <property name="text">
+                     <string>*</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <widget class="QLabel" name="label_3">
+                    <property name="minimumSize">
+                     <size>
+                      <width>70</width>
+                      <height>14</height>
+                     </size>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>70</width>
+                      <height>16777215</height>
+                     </size>
+                    </property>
+                    <property name="text">
+                     <string>开机时间:</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <widget class="CustomComboBox" name="cBox_selectWeekStart">
+                    <property name="minimumSize">
+                     <size>
+                      <width>124</width>
+                      <height>32</height>
+                     </size>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>538</width>
+                      <height>32</height>
+                     </size>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <spacer name="horizontalSpacer_2">
+                    <property name="orientation">
+                     <enum>Qt::Horizontal</enum>
+                    </property>
+                    <property name="sizeHint" stdset="0">
+                     <size>
+                      <width>40</width>
+                      <height>20</height>
+                     </size>
+                    </property>
+                   </spacer>
+                  </item>
+                  <item>
+                   <widget class="TimeWidget" name="timeEdit_weekStart">
+                    <property name="minimumSize">
+                     <size>
+                      <width>124</width>
+                      <height>32</height>
+                     </size>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>16777215</width>
+                      <height>32</height>
+                     </size>
+                    </property>
+                   </widget>
+                  </item>
+                 </layout>
                 </widget>
-               </item>
-               <item>
-                <widget class="QWidget" name="widget_pBtn" native="true">
+                <widget class="QWidget" name="widget_weekEnd" native="true">
+                 <property name="geometry">
+                  <rect>
+                   <x>0</x>
+                   <y>80</y>
+                   <width>330</width>
+                   <height>32</height>
+                  </rect>
+                 </property>
                  <property name="minimumSize">
                   <size>
                    <width>0</width>
                    <height>32</height>
                   </size>
                  </property>
-                 <widget class="QPushButton" name="pBtn_addPlan">
-                  <property name="geometry">
-                   <rect>
-                    <x>0</x>
-                    <y>0</y>
-                    <width>68</width>
-                    <height>32</height>
-                   </rect>
+                 <property name="maximumSize">
+                  <size>
+                   <width>16777215</width>
+                   <height>32</height>
+                  </size>
+                 </property>
+                 <layout class="QHBoxLayout" name="horizontalLayout_3">
+                  <property name="spacing">
+                   <number>0</number>
                   </property>
-                  <property name="text">
-                   <string>添加</string>
+                  <property name="leftMargin">
+                   <number>0</number>
                   </property>
-                 </widget>
-                 <widget class="QPushButton" name="pBtn_editPlan">
-                  <property name="geometry">
-                   <rect>
-                    <x>76</x>
-                    <y>0</y>
-                    <width>68</width>
-                    <height>32</height>
-                   </rect>
+                  <property name="topMargin">
+                   <number>0</number>
                   </property>
-                  <property name="text">
-                   <string>修改</string>
+                  <property name="rightMargin">
+                   <number>0</number>
                   </property>
-                 </widget>
-                 <widget class="QPushButton" name="pBtn_deletePlan">
-                  <property name="geometry">
-                   <rect>
-                    <x>152</x>
-                    <y>0</y>
-                    <width>68</width>
-                    <height>32</height>
-                   </rect>
+                  <property name="bottomMargin">
+                   <number>0</number>
                   </property>
-                  <property name="text">
-                   <string>删除</string>
+                  <item>
+                   <widget class="QLabel" name="label_x3">
+                    <property name="minimumSize">
+                     <size>
+                      <width>10</width>
+                      <height>10</height>
+                     </size>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>10</width>
+                      <height>10</height>
+                     </size>
+                    </property>
+                    <property name="text">
+                     <string>*</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <widget class="QLabel" name="label_4">
+                    <property name="minimumSize">
+                     <size>
+                      <width>70</width>
+                      <height>14</height>
+                     </size>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>70</width>
+                      <height>16777215</height>
+                     </size>
+                    </property>
+                    <property name="text">
+                     <string>关机时间:</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <widget class="CustomComboBox" name="cBox_selectWeekEnd">
+                    <property name="minimumSize">
+                     <size>
+                      <width>124</width>
+                      <height>32</height>
+                     </size>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>538</width>
+                      <height>32</height>
+                     </size>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <spacer name="horizontalSpacer_3">
+                    <property name="orientation">
+                     <enum>Qt::Horizontal</enum>
+                    </property>
+                    <property name="sizeHint" stdset="0">
+                     <size>
+                      <width>40</width>
+                      <height>20</height>
+                     </size>
+                    </property>
+                   </spacer>
+                  </item>
+                  <item>
+                   <widget class="TimeWidget" name="timeEdit_weekEnd">
+                    <property name="minimumSize">
+                     <size>
+                      <width>124</width>
+                      <height>32</height>
+                     </size>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>16777215</width>
+                      <height>32</height>
+                     </size>
+                    </property>
+                   </widget>
+                  </item>
+                 </layout>
+                </widget>
+               </widget>
+               <widget class="QWidget" name="tab_special">
+                <attribute name="title">
+                 <string>特殊日</string>
+                </attribute>
+                <widget class="QWidget" name="widget_specialStart" native="true">
+                 <property name="geometry">
+                  <rect>
+                   <x>0</x>
+                   <y>24</y>
+                   <width>330</width>
+                   <height>32</height>
+                  </rect>
+                 </property>
+                 <property name="minimumSize">
+                  <size>
+                   <width>0</width>
+                   <height>32</height>
+                  </size>
+                 </property>
+                 <property name="maximumSize">
+                  <size>
+                   <width>16777215</width>
+                   <height>32</height>
+                  </size>
+                 </property>
+                 <layout class="QHBoxLayout" name="horizontalLayout_6">
+                  <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>
-                 </widget>
+                  <property name="bottomMargin">
+                   <number>0</number>
+                  </property>
+                  <item>
+                   <widget class="QLabel" name="label_x4">
+                    <property name="minimumSize">
+                     <size>
+                      <width>10</width>
+                      <height>10</height>
+                     </size>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>10</width>
+                      <height>10</height>
+                     </size>
+                    </property>
+                    <property name="text">
+                     <string>*</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <widget class="QLabel" name="label_5">
+                    <property name="minimumSize">
+                     <size>
+                      <width>70</width>
+                      <height>14</height>
+                     </size>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>70</width>
+                      <height>16777215</height>
+                     </size>
+                    </property>
+                    <property name="text">
+                     <string>开机时间:</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <widget class="CalendarDTEdit" name="dateEdit_specialStart">
+                    <property name="minimumSize">
+                     <size>
+                      <width>124</width>
+                      <height>32</height>
+                     </size>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <spacer name="horizontalSpacer_4">
+                    <property name="orientation">
+                     <enum>Qt::Horizontal</enum>
+                    </property>
+                    <property name="sizeHint" stdset="0">
+                     <size>
+                      <width>40</width>
+                      <height>20</height>
+                     </size>
+                    </property>
+                   </spacer>
+                  </item>
+                  <item>
+                   <widget class="TimeWidget" name="timeEdit_specialStart">
+                    <property name="minimumSize">
+                     <size>
+                      <width>124</width>
+                      <height>32</height>
+                     </size>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>16777215</width>
+                      <height>32</height>
+                     </size>
+                    </property>
+                   </widget>
+                  </item>
+                 </layout>
                 </widget>
-               </item>
-               <item>
-                <spacer name="verticalSpacer_2">
-                 <property name="orientation">
-                  <enum>Qt::Vertical</enum>
+                <widget class="QWidget" name="widget_specialEnd" native="true">
+                 <property name="geometry">
+                  <rect>
+                   <x>0</x>
+                   <y>80</y>
+                   <width>330</width>
+                   <height>32</height>
+                  </rect>
                  </property>
-                 <property name="sizeHint" stdset="0">
+                 <property name="minimumSize">
                   <size>
-                   <width>20</width>
-                   <height>182</height>
+                   <width>0</width>
+                   <height>32</height>
                   </size>
                  </property>
-                </spacer>
-               </item>
-              </layout>
-             </widget>
-            </item>
-           </layout>
-          </widget>
-         </item>
-         <item>
-          <widget class="QWidget" name="widget_bottom" native="true">
-           <property name="minimumSize">
-            <size>
-             <width>0</width>
-             <height>96</height>
-            </size>
-           </property>
-           <property name="maximumSize">
-            <size>
-             <width>16777215</width>
-             <height>96</height>
-            </size>
-           </property>
-           <layout class="QHBoxLayout" name="horizontalLayout_5">
-            <property name="spacing">
-             <number>8</number>
+                 <property name="maximumSize">
+                  <size>
+                   <width>16777215</width>
+                   <height>32</height>
+                  </size>
+                 </property>
+                 <layout class="QHBoxLayout" name="horizontalLayout_7">
+                  <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="QLabel" name="label_x5">
+                    <property name="minimumSize">
+                     <size>
+                      <width>10</width>
+                      <height>10</height>
+                     </size>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>10</width>
+                      <height>10</height>
+                     </size>
+                    </property>
+                    <property name="text">
+                     <string>*</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <widget class="QLabel" name="label_6">
+                    <property name="minimumSize">
+                     <size>
+                      <width>70</width>
+                      <height>14</height>
+                     </size>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>70</width>
+                      <height>16777215</height>
+                     </size>
+                    </property>
+                    <property name="text">
+                     <string>关机时间:</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <widget class="CalendarDTEdit" name="dateEdit_specialEnd">
+                    <property name="minimumSize">
+                     <size>
+                      <width>124</width>
+                      <height>32</height>
+                     </size>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <spacer name="horizontalSpacer_5">
+                    <property name="orientation">
+                     <enum>Qt::Horizontal</enum>
+                    </property>
+                    <property name="sizeHint" stdset="0">
+                     <size>
+                      <width>40</width>
+                      <height>20</height>
+                     </size>
+                    </property>
+                   </spacer>
+                  </item>
+                  <item>
+                   <widget class="TimeWidget" name="timeEdit_specialEnd">
+                    <property name="minimumSize">
+                     <size>
+                      <width>124</width>
+                      <height>32</height>
+                     </size>
+                    </property>
+                    <property name="maximumSize">
+                     <size>
+                      <width>16777215</width>
+                      <height>32</height>
+                     </size>
+                    </property>
+                   </widget>
+                  </item>
+                 </layout>
+                </widget>
+               </widget>
+              </widget>
+             </item>
+             <item>
+              <widget class="QWidget" name="widget_pBtn" native="true">
+               <property name="minimumSize">
+                <size>
+                 <width>0</width>
+                 <height>32</height>
+                </size>
+               </property>
+               <widget class="QPushButton" name="pBtn_addPlan">
+                <property name="geometry">
+                 <rect>
+                  <x>0</x>
+                  <y>0</y>
+                  <width>68</width>
+                  <height>32</height>
+                 </rect>
+                </property>
+                <property name="text">
+                 <string>添加</string>
+                </property>
+               </widget>
+               <widget class="QPushButton" name="pBtn_editPlan">
+                <property name="geometry">
+                 <rect>
+                  <x>76</x>
+                  <y>0</y>
+                  <width>68</width>
+                  <height>32</height>
+                 </rect>
+                </property>
+                <property name="text">
+                 <string>修改</string>
+                </property>
+               </widget>
+               <widget class="QPushButton" name="pBtn_deletePlan">
+                <property name="geometry">
+                 <rect>
+                  <x>152</x>
+                  <y>0</y>
+                  <width>68</width>
+                  <height>32</height>
+                 </rect>
+                </property>
+                <property name="text">
+                 <string>删除</string>
+                </property>
+               </widget>
+              </widget>
+             </item>
+             <item>
+              <spacer name="verticalSpacer_2">
+               <property name="orientation">
+                <enum>Qt::Vertical</enum>
+               </property>
+               <property name="sizeHint" stdset="0">
+                <size>
+                 <width>20</width>
+                 <height>182</height>
+                </size>
+               </property>
+              </spacer>
+             </item>
+            </layout>
+           </widget>
+          </item>
+         </layout>
+        </widget>
+       </item>
+       <item>
+        <widget class="QWidget" name="widget_bottom" native="true">
+         <property name="minimumSize">
+          <size>
+           <width>0</width>
+           <height>96</height>
+          </size>
+         </property>
+         <property name="maximumSize">
+          <size>
+           <width>16777215</width>
+           <height>96</height>
+          </size>
+         </property>
+         <layout class="QHBoxLayout" name="horizontalLayout_5">
+          <property name="spacing">
+           <number>8</number>
+          </property>
+          <property name="leftMargin">
+           <number>32</number>
+          </property>
+          <property name="topMargin">
+           <number>0</number>
+          </property>
+          <property name="rightMargin">
+           <number>32</number>
+          </property>
+          <property name="bottomMargin">
+           <number>0</number>
+          </property>
+          <item>
+           <widget class="QPushButton" name="pBtn_saveTotemplate">
+            <property name="minimumSize">
+             <size>
+              <width>110</width>
+              <height>32</height>
+             </size>
             </property>
-            <property name="leftMargin">
-             <number>32</number>
+            <property name="text">
+             <string>保存为模版</string>
             </property>
-            <property name="topMargin">
-             <number>0</number>
+           </widget>
+          </item>
+          <item>
+           <spacer name="horizontalSpacer">
+            <property name="orientation">
+             <enum>Qt::Horizontal</enum>
             </property>
-            <property name="rightMargin">
-             <number>32</number>
+            <property name="sizeHint" stdset="0">
+             <size>
+              <width>295</width>
+              <height>20</height>
+             </size>
             </property>
-            <property name="bottomMargin">
-             <number>0</number>
+           </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>
-            <item>
-             <widget class="QPushButton" name="pBtn_saveTotemplate">
-              <property name="minimumSize">
-               <size>
-                <width>110</width>
-                <height>32</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>295</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>
+          </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>
     </widget>
    </item>
   </layout>

+ 34 - 28
TransmitterSwitch/Resource/QSS/dark/importtemplate.qss

@@ -1,10 +1,7 @@
 QWidget
 {
     background: transparent;
-    border-radius: 8px;
 
-    /* font-family: 思源黑体R; */
-    /* font-weight: 400; */
     font-size: 14px;
     color: #D2D2D2;
     line-height: 21px;
@@ -14,33 +11,32 @@ QWidget
 
 QWidget#widget
 {
-    background-color: #313539;
+    background: #464649;
+    border-radius: 8px 8px 8px 8px;
 }
 
 QWidget#widget_Top
 {
-    background: rgba(108,105,124,0.2);
-    border-top-left-radius: 10px;
-    border-top-right-radius: 10px;
+    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: normal; */
+    font-weight: 500;
     font-size: 18px;
     color: #D2D2D2;
-    line-height: 27px;
+    line-height: 24px;
     text-align: left;
     font-style: normal;
-    text-transform: uppercase;
+    text-transform: none;
 }
 
-QLabel#label_warning
-{
-    color:red;
-}
 
 QPushButton#pBtn_close
 {
@@ -105,32 +101,42 @@ QPushButton#pBtn_ok:hover
 }
 
 /* ==========================================================
- *  QTabelWidget
+ *  QTableWidget
  * ========================================================== */
-/* 标题栏 */
-QLabel#label_NC2, #label_NC3, #label_NC4
+
+QTableWidget
 {
-    /* font-weight: 400; */
-    font-size: 14px;
-    color: #D2D2D2;
-    line-height: 21px;
+    background: green;
+    padding-left: 16px;
+    border: 0px solid #E6E9F4;
     text-align: left;
-    font-style: normal;
 }
 
-QLabel#label_line2, #label_line3
+QHeaderView
 {
-    background: #E6E9F4;
+    background: red;
 }
 
-QTableWidget
-{
+/* 标题栏 */
+QHeaderView::section {
     background: transparent;
-    padding-left: 0px;
-    border: 0px solid #E6E9F4;
+
+    font-weight: 500;
+    font-size: 14px;
+    color: #D2D2D2;
+    line-height: 22px;
     text-align: left;
+    font-style: normal;
+
+    padding-left: 16px;
+    
+    border: 0px solid #E6E9F4;
+    border-top: 1px solid rgba(255,255,255,0.15);
+    border-bottom: 1px solid rgba(255,255,255,0.15);
 }
 
+
+
 QTableWidget::item
 {
     padding-left: 12px;

+ 12 - 3
TransmitterSwitch/Resource/QSS/dark/managerplan.qss

@@ -44,6 +44,17 @@ QLabel#label_title
     text-transform: uppercase;
 }
 
+QLabel#label_selectChn
+{
+    font-weight: 500;
+    font-size: 16px;
+    color: #D2D2D2;
+    line-height: 22px;
+    text-align: left;
+    font-style: normal;
+    text-transform: none;
+}
+
 QLabel#label_x1, #label_x2, #label_x3, #label_x4, #label_x5, #label_x6
 {
     background: transparent;
@@ -338,7 +349,6 @@ CalendarDTEdit
 
 CalendarDTEdit:hover
 {
-	background: transparent;
     border-radius: 4px;
     padding-left:12px;
     border: 1px solid #438EFF;
@@ -346,7 +356,6 @@ CalendarDTEdit:hover
 
 CalendarDTEdit[Warn=true]
 {
-	background: transparent;
     border-radius: 4px;
     padding-left:12px;
     border: 1px solid #D21F21;
@@ -360,7 +369,7 @@ CalendarDTEdit:!enabled/* 或者disable */
 
 CalendarDTEdit::drop-down
 {
- 	padding-right:8px;
+ 	padding-right: 8px;
 	width: 16px;
     image: url(:/ICON/ICON/date_dark.png);
 }

+ 49 - 5
TransmitterSwitch/Resource/QSS/dark/plancard.qss

@@ -9,7 +9,7 @@ QWidget#widget
     border: 1px solid rgba(255,255,255,0.15);
 }
 
-QWidget#widget[isSelected = "true"]
+QWidget#widget[Selected = "true"]
 {
     border-radius: 4px 4px 4px 4px;
     border: 1px solid #438EFF;
@@ -39,8 +39,9 @@ QLabel#label_title
 /* 表格标题 */
 QWidget#widget_tableHeader
 {
-    background: #313539;
-    border-radius: 0px 0px 0px 0px;
+    background-color: rgba(255, 255, 255, 0.1);
+    border-radius: 0px 0px 0px 0px; 
+    border: none;
 }
 
 QLabel#label_onTime, #label_offTime
@@ -56,7 +57,7 @@ QLabel#label_onTime, #label_offTime
     padding-left: 12px;
 }
 
-QTableView#tableView
+QTableView
 {
     font-weight: 400;
     font-size: 14px;
@@ -66,6 +67,49 @@ QTableView#tableView
     font-style: normal;
     text-transform: none;
 
+    /* background: #438EFF; */
+    border: 0px solid rgba(255, 255, 255, 0.1);
+    outline: none;
+}
+
+QTableView::item
+{
+    font-weight: 400;
+    font-size: 14px;
+    color: #B1B3B4;
+    background: transparent;
+
+    border: none;
     padding-left: 12px;
-    border: 0px;
+    outline: none;
+}
+
+QTableView::item:selected
+{
+    color: #FFFFFF;
+    background: #438EFF;
+    border-radius: 0px 0px 0px 0px;
+    outline: none;
 }
+
+
+/*
+QTableWidget::item
+{
+    padding-left: 12px;
+    padding-right: 0px;
+    padding-top: 0px;
+    padding-bottom: 0px;
+
+    margin: 0px;
+
+    text-align: left;
+
+    border: 0px solid #E6E9F4;
+}
+
+QTableWidget::item:selected
+{
+    color: #EBEBEB;
+    background: #558bda;
+} */

+ 7 - 3
TransmitterSwitch/Resource/QSS/dark/transmitterswitch.qss

@@ -93,14 +93,15 @@ QLabel#label_TipText
     border: 1px solid rgba(255,255,255,0.15);
 }
 
-QPushButton#pBtn_editPlan, #pBtn_clearPlan, #pBtn_importPlan, #pBtn_exportPlan, #pBtn_deletePlan, #pBtn_cloneToOther, #pBtn_refresh
+QPushButton#pBtn_editPlan, #pBtn_clearPlan, #pBtn_importPlan, #pBtn_exportPlan, #pBtn_deletePlan, #pBtn_cloneToOther, #pBtn_refresh,
+#pBtn_templateManager
 {
     background: rgba(255,255,255,0.08);
     border-radius: 2px 2px 2px 2px;
 }
 
 QPushButton#pBtn_editPlan:hover, #pBtn_clearPlan:hover, #pBtn_importPlan:hover, #pBtn_exportPlan:hover, #pBtn_deletePlan:hover, 
-#pBtn_cloneToOther:hover, #pBtn_refresh:hover
+#pBtn_cloneToOther:hover, #pBtn_refresh:hover, #pBtn_templateManager:hover
 {
     background: #1a69b8;
     border-radius: 2px 2px 2px 2px;
@@ -160,7 +161,10 @@ QWidget#widget_items
     border: 0px solid rgba(255,255,255,0.15);
 } */
 
-/*QScrollBar*/
+
+/*===============================================================
+ * QScrollBar 滚动条
+ ================================================================*/
 QScrollArea
 {
 	background:transparent;

+ 5 - 3
TransmitterSwitch/Resource/QSS/dark/warning.qss

@@ -1,7 +1,6 @@
 QWidget
 {
     background: transparent;
-    border-radius: 8px;
     /* font-family: 思源黑体R; */
     /* font-weight: 400; */
     font-size: 18px;
@@ -13,16 +12,19 @@ QWidget
 
 QWidget#widget
 {
-    background-color: #313539;
+    background: #464649;
+    border-radius: 8px 8px 8px 8px;
 }
 
 QWidget#widget_Top
 {
-    background: rgba(108,105,124,0.2);
+    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

+ 49 - 48
TransmitterSwitch/Template/importtemplate.cpp

@@ -9,13 +9,12 @@
 #include <QMouseEvent>
 
 #include "warning/warning.h"
-// #include "lhstylemanager.h"
 #include "LHQLogAPI.h"
 #include "OneShadowEffect.h"
 #include "TransmitterSwitchInfo.h"
 #include "UIStyleManager.h"
 
-ImportTemplate::ImportTemplate(QMap<QString, int> tabList, int type, QWidget *parent) :
+ImportTemplate::ImportTemplate(QWidget *parent) :
     QDialog(parent),
     ui(new Ui::ImportTemplate)
 {
@@ -25,35 +24,36 @@ ImportTemplate::ImportTemplate(QMap<QString, int> tabList, int type, QWidget *pa
     this->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);
     /* 设置底层样式表 */
     this->setAttribute(Qt::WA_TranslucentBackground);
-    /* 加载QSS文件 */
-    // QFile file(":/QSS/QSS/importtemplate_light.qss");
-    // if(file.open(QFile::ReadOnly))
-    // {
-    //     QString styleSheet = file.readAll();
-    //     this->setStyleSheet(styleSheet);
-    //     file.close();
-    // }
     /* 创建阴影 */
     QSize size = this->size();
-    size.setWidth(size.width() - 32);
-    size.setHeight(size.height() - 32);
+    size.setWidth(size.width() - 40);
+    size.setHeight(size.height() - 40);
 
-    // m_shadow = new OneShadow(size, 16);
     auto pShadow = new OneShadowEffect(this);
     this->setGraphicsEffect(pShadow);
 
     m_templateName.clear();
 
-    /* 设置列数,列宽、列高、不可编辑、选择一行 */
+    /* 设置列数 */
+    ui->tableWidget->horizontalHeader()->setVisible(true);
     ui->tableWidget->setColumnCount(3);
+    /* 设置列表头 */
+    QStringList headerList;
+    headerList << "频率名称" << "模版名称" << "选择";
+    ui->tableWidget->setHorizontalHeaderLabels(headerList);
+    /* 设置列表头高度 */
+    ui->tableWidget->horizontalHeader()->setDefaultSectionSize(40);
+    /* 设置列宽间距 */
+    ui->tableWidget->setColumnWidth(0, 274);
+    ui->tableWidget->setColumnWidth(1, 274);
+    ui->tableWidget->setColumnWidth(2, 88);
+    /* 设置列宽度固定 */
+    ui->tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Fixed);
+    ui->tableWidget->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Fixed);
+    ui->tableWidget->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Fixed);
+
     //设置行高
     ui->tableWidget->verticalHeader()->setDefaultSectionSize(48);
-    /* 设置最小列宽 */
-    ui->tableWidget->horizontalHeader()->setMinimumSectionSize(10);
-    /* 设置列宽间距 */
-    ui->tableWidget->setColumnWidth(0,46);
-    ui->tableWidget->setColumnWidth(1,272);
-    ui->tableWidget->setColumnWidth(2,60);
     
     //设置不可编辑
     ui->tableWidget->setEditTriggers(QTableWidget::NoEditTriggers);
@@ -62,50 +62,50 @@ ImportTemplate::ImportTemplate(QMap<QString, int> tabList, int type, QWidget *pa
     //设置只能选中一行
     ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
     //隐藏竖滚动条
-    ui->tableWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+    // ui->tableWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     //隐藏横滚动条
     ui->tableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     //隐藏网格线
     ui->tableWidget->setShowGrid(false);
     //隐藏行号
     ui->tableWidget->verticalHeader()->setVisible(false);
-    //隐藏列表头
-    ui->tableWidget->horizontalHeader()->setVisible(false);
     //设置不显示选中后的虚线
     ui->tableWidget->setFocusPolicy(Qt::NoFocus);
+
     //开启排序功能
 //    ui->tableWidget->setSortingEnabled(true);
 
-    ui->label_warning->hide();
 
     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->tableWidget,SIGNAL(cellClicked(int,int)),this,SLOT(do_seletctRow(int,int)));
+    connect(&EPUIStyle, &UIStyleManager::signal_qssChanged, this, &ImportTemplate::do_setUIStyle);
 
 
-    m_type = type;
     /* 取出当前可用的模版,主要是区分正常日和特殊日 */
-    QStringList list;
-    for(auto begin = tabList.begin(); begin != tabList.end(); begin++)
-    {
-        // LH_WRITE_LOG_DEBUG(QString("模版名称:%1, 类型:%2").arg(begin.key()).arg(begin.value()));
-        if(begin.value() != m_type)
-        {
-            continue;
-        }
-        list.append(begin.key());
-    }
-    /* 先设置表格的行数 */
-    ui->tableWidget->setRowCount(list.count());
-    for(int i = 0;i < list.count();i++)
-    {
-        createRow(i, i + 1, list.at(i));
-    }
+    // QStringList list;
+    // for(auto begin = tabList.begin(); begin != tabList.end(); begin++)
+    // {
+    //     // LH_WRITE_LOG_DEBUG(QString("模版名称:%1, 类型:%2").arg(begin.key()).arg(begin.value()));
+    //     if(begin.value() != m_type)
+    //     {
+    //         continue;
+    //     }
+    //     list.append(begin.key());
+    // }
+    // /* 先设置表格的行数 */
+    // ui->tableWidget->setRowCount(list.count());
+    // for(int i = 0;i < list.count();i++)
+    // {
+    //     createRow(i, i + 1, list.at(i));
+    // }
 
     /* 注册事件过滤器 */
     ui->pBtn_close->installEventFilter(this);
 
+    /* 设置默认的皮肤 */
+    do_setUIStyle();
 }
 
 ImportTemplate::~ImportTemplate()
@@ -115,13 +115,7 @@ ImportTemplate::~ImportTemplate()
 
 void ImportTemplate::do_ok()
 {
-    ui->label_warning->hide();
-    if(m_templateName.isEmpty())
-    {
-        ui->label_warning->setText("请选择模版");
-        ui->label_warning->show();
-        return;
-    }
+    
     m_isOk = true;
     emit signal_templateName(m_templateName);
     this->close();
@@ -163,6 +157,13 @@ void ImportTemplate::do_seletctRow(int row, int col)
     }
 }
 
+/* 设置样式表 */
+void ImportTemplate::do_setUIStyle()
+{
+    setQSSPath(EPUIStyle.getQSSPath());
+}
+
+
 /* 创建一行数据 */
 void ImportTemplate::createRow(int row,int num,const QString &text)
 {

+ 3 - 1
TransmitterSwitch/Template/importtemplate.h

@@ -15,7 +15,7 @@ class ImportTemplate : public QDialog
     Q_OBJECT
 
 public:
-    explicit ImportTemplate(QMap<QString, int> tabList, int type, QWidget *parent = nullptr);
+    explicit ImportTemplate(QWidget *parent = nullptr);
     ~ImportTemplate();
 
     void createRow(int row,int num,const QString& text);                    /* 创建一行数据 */
@@ -38,6 +38,8 @@ private slots:
     void do_ok();
     /* 选中一行 */
     void do_seletctRow(int row,int col);
+    /* 设置样式表 */
+    void do_setUIStyle();
 
 protected:
     /* 绘画事件 */

+ 191 - 156
TransmitterSwitch/Template/importtemplate.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>476</width>
-    <height>650</height>
+    <width>740</width>
+    <height>680</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -23,172 +23,207 @@ background:transparent;
     <number>0</number>
    </property>
    <property name="leftMargin">
-    <number>16</number>
+    <number>20</number>
    </property>
    <property name="topMargin">
-    <number>16</number>
+    <number>20</number>
    </property>
    <property name="rightMargin">
-    <number>16</number>
+    <number>20</number>
    </property>
    <property name="bottomMargin">
-    <number>16</number>
+    <number>20</number>
    </property>
    <item>
     <widget class="QWidget" name="widget" native="true">
      <property name="styleSheet">
       <string notr="true"/>
      </property>
-     <widget class="QLabel" name="label_line2">
-      <property name="geometry">
-       <rect>
-        <x>32</x>
-        <y>89</y>
-        <width>380</width>
-        <height>1</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string/>
-      </property>
-     </widget>
-     <widget class="QLabel" name="label_line3">
-      <property name="geometry">
-       <rect>
-        <x>32</x>
-        <y>137</y>
-        <width>380</width>
-        <height>1</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string/>
-      </property>
-     </widget>
-     <widget class="QLabel" name="label_NC2">
-      <property name="geometry">
-       <rect>
-        <x>44</x>
-        <y>107</y>
-        <width>32</width>
-        <height>14</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>序号</string>
-      </property>
-     </widget>
-     <widget class="QLabel" name="label_NC3">
-      <property name="geometry">
-       <rect>
-        <x>92</x>
-        <y>107</y>
-        <width>56</width>
-        <height>14</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>模板名称</string>
-      </property>
-     </widget>
-     <widget class="QLabel" name="label_NC4">
-      <property name="geometry">
-       <rect>
-        <x>364</x>
-        <y>107</y>
-        <width>28</width>
-        <height>14</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>操作</string>
-      </property>
-     </widget>
-     <widget class="QPushButton" name="pBtn_cancel">
-      <property name="geometry">
-       <rect>
-        <x>276</x>
-        <y>554</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>352</x>
-        <y>554</y>
-        <width>60</width>
-        <height>32</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>确定</string>
-      </property>
-     </widget>
-     <widget class="QTableWidget" name="tableWidget">
-      <property name="geometry">
-       <rect>
-        <x>32</x>
-        <y>140</y>
-        <width>380</width>
-        <height>384</height>
-       </rect>
-      </property>
-     </widget>
-     <widget class="QLabel" name="label_warning">
-      <property name="geometry">
-       <rect>
-        <x>50</x>
-        <y>65</y>
-        <width>351</width>
-        <height>21</height>
-       </rect>
-      </property>
-      <property name="text">
-       <string>TextLabel</string>
-      </property>
-     </widget>
-     <widget class="QWidget" name="widget_Top" native="true">
-      <property name="geometry">
-       <rect>
-        <x>0</x>
-        <y>0</y>
-        <width>444</width>
-        <height>56</height>
-       </rect>
-      </property>
-      <widget class="QPushButton" name="pBtn_close">
-       <property name="geometry">
-        <rect>
-         <x>396</x>
-         <y>12</y>
-         <width>32</width>
-         <height>32</height>
-        </rect>
-       </property>
-       <property name="text">
-        <string/>
-       </property>
-      </widget>
-      <widget class="QLabel" name="label_title">
-       <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>
+     <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>72</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="QTableWidget" name="tableWidget"/>
+         </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>

+ 33 - 21
TransmitterSwitch/TransmitterSwitchInfo.cpp

@@ -68,39 +68,36 @@ void ConfigDataContainer::deleteConfigData(int key)
 
 
 
-ExecPlanItemInfo::ExecPlanItemInfo()
+OnePlanItemInfo::OnePlanItemInfo()
 {
     ChannelID = -1;
-    ExecType = -1;
-    WeekDay = enum_WeekDay::WeekDay_Mon;
-    dateTime = QDateTime::fromString("1970-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
-    devName = "未定义";
-    actionID = 0;
-    actionName = "未定义";
+    ChannelName = "";
+    onWeekDay = enum_WeekDay::WeekDay_Mon;
+    onDateTime = QDateTime::fromString("1970-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
+    offWeekDay = enum_WeekDay::WeekDay_Mon;
+    offDateTime = QDateTime::fromString("1970-01-01 00:00:00", "yyyy-MM-dd hh:mm:ss");
 }
 
-ExecPlanItemInfo::ExecPlanItemInfo(const ExecPlanItemInfo& item)
+OnePlanItemInfo::OnePlanItemInfo(const OnePlanItemInfo& item)
 {
     ChannelID = item.ChannelID;
-    ExecType = item.ExecType;
-    WeekDay = item.WeekDay;
-    dateTime = item.dateTime;
-    actionID = item.actionID;
-    devName = item.devName;
-    actionName = item.actionName;
+    ChannelName = item.ChannelName;
+    onWeekDay = item.onWeekDay;
+    onDateTime = item.onDateTime;
+    offWeekDay = item.offWeekDay;
+    offDateTime = item.offDateTime;
 }
 
-ExecPlanItemInfo& ExecPlanItemInfo::operator=(const ExecPlanItemInfo& item)
+OnePlanItemInfo& OnePlanItemInfo::operator=(const OnePlanItemInfo& item)
 {
     if(this == &item)
         return *this;
     ChannelID = item.ChannelID;
-    ExecType = item.ExecType;
-    WeekDay = item.WeekDay;
-    dateTime = item.dateTime;
-    devName = item.devName;
-    actionID = item.actionID;
-    actionName = item.actionName;
+    ChannelName = item.ChannelName;
+    onWeekDay = item.onWeekDay;
+    onDateTime = item.onDateTime;
+    offWeekDay = item.offWeekDay;
+    offDateTime = item.offDateTime;
     return *this;
 }
 
@@ -273,3 +270,18 @@ void MapDevice::deleteDevice(const QString& devName)
     }
 }
 
+TemplateInfo::TemplateInfo(const TemplateInfo& info)
+{
+    channelInfo = info.channelInfo;
+    templateName = info.templateName;
+}
+
+TemplateInfo& TemplateInfo::operator=(const TemplateInfo& info)
+{
+    if(this == &info)
+        return *this;
+    channelInfo = info.channelInfo;
+    templateName = info.templateName;
+    return *this;
+}
+

+ 26 - 13
TransmitterSwitch/TransmitterSwitchInfo.h

@@ -53,7 +53,7 @@ enum class enum_Action : int
  */
 enum class enum_ExecPlanConfig : int
 {
-    DefaultPlan = 1,            /* 执行计划 */
+    OpenPlan = 1,               /* 执行计划 */
     ExecMode = 2,               /* 执行模式 */
     IsChanged = 3               /* 是否修改 */
 };
@@ -147,7 +147,7 @@ private:
 public:
     /* 配置的键值对的说明 */
     const QMap<int, QString> KeyNotes = {
-        {static_cast<int>(enum_ExecPlanConfig::DefaultPlan), "默认执行计划开关,0关,1开"},
+        {static_cast<int>(enum_ExecPlanConfig::OpenPlan), "默认执行计划开关,0关,1开"},
         {static_cast<int>(enum_ExecPlanConfig::ExecMode), "执行模式,0按时刻,1按天"},
         {static_cast<int>(enum_ExecPlanConfig::IsChanged), "是否更新,0未修改,1修改"}
     };
@@ -182,19 +182,18 @@ private:
  * @brief 执行计划条目信息
  * 
  */
-struct ExecPlanItemInfo
+struct OnePlanItemInfo
 {
     int ChannelID;                                  /* 频率ID */
-    int ExecType;                                   /* 执行类型,0按时刻,1按天 */
-    enum_WeekDay WeekDay;                           /* 周几,数据库里是1-7一周,周8是特殊日 */
-    QDateTime dateTime;                             /* 时间和日期 */
-    QString devName;                                /* 设备名称 */
-    int actionID;                                   /* 动作ID */
-    QString actionName;                             /* 执行的动作 */
-
-    ExecPlanItemInfo();
-    ExecPlanItemInfo(const ExecPlanItemInfo& item);
-    ExecPlanItemInfo& operator=(const ExecPlanItemInfo& item);
+    QString ChannelName;                            /* 频率名称 */
+    enum_WeekDay onWeekDay;                         /* 周几,数据库里是1-7一周,周8是特殊日 */
+    QDateTime onDateTime;                           /* 时间和日期 */
+    enum_WeekDay offWeekDay;                        /* 周几,数据库里是1-7一周,周8是特殊日 */
+    QDateTime offDateTime;                          /* 时间和日期 */
+
+    OnePlanItemInfo();
+    OnePlanItemInfo(const OnePlanItemInfo& item);
+    OnePlanItemInfo& operator=(const OnePlanItemInfo& item);
 };
 
 
@@ -345,6 +344,20 @@ private:
 
 
 
+/**
+ * @brief 模版结构体
+ * 
+ */
+struct TemplateInfo
+{
+    ChannelInfo channelInfo;                /* 频率信息 */
+    QString templateName;                   /* 模版名称 */
+
+    TemplateInfo() : channelInfo(), templateName("") {}
+    TemplateInfo(const TemplateInfo& info);
+    TemplateInfo& operator=(const TemplateInfo& info);
+};
+
 
 
 

+ 1 - 0
TransmitterSwitch/UIStyle/UIStyleManager.cpp

@@ -95,6 +95,7 @@ void UIStyleManager::readQSSFile()
     }else {
         LH_WRITE_ERROR(QString("打开样式表失败: %1").arg(qssPath));
     }
+
 }
 
 

+ 123 - 148
TransmitterSwitch/WebAPI/FromWebAPI.cpp

@@ -246,13 +246,14 @@ bool FromWebAPI::getChannelInfo(QMap<int, ChannelInfo>& mapFreq)
 
 
 /**
- * @brief 将数据写入EQM数据库,这里不需要模版编号和名称,编号都设置成0
+ * @brief 将数据写入EQM数据库
  * 
+ * @param chnID 频率ID
  * @param list 
  * @return true 
  * @return false 
  */
-bool FromWebAPI::insertData(QList<ExecPlanItemInfo>& list)
+bool FromWebAPI::insertData(int chnID, QList<OnePlanItemInfo>& list)
 {
     if(m_httpApi == nullptr)
     {
@@ -260,7 +261,7 @@ bool FromWebAPI::insertData(QList<ExecPlanItemInfo>& list)
         return false;
     }
     /* 先删除表格中的数据 */
-    deleteAllTransmitterPlan();
+    deleteOneChnPlan(chnID);
 
     QDate zeroDate(1970,1,1);
     /* 写入数据 */
@@ -272,25 +273,14 @@ bool FromWebAPI::insertData(QList<ExecPlanItemInfo>& list)
             json1["opName"] = "ESM8C_InsertDataToExecPlan";
             json1["Key"] = QUuid::createUuid().toString().toStdString();
             nJson json2;
-            json2["ExecType"] = it.ExecType;
-            json2["WeekDay"] = it.WeekDay;
-            json2["Date"] = it.dateTime.date().toString("yyyy-MM-dd").toStdString();
-            json2["ExecTime"] = it.dateTime.time().toString("hh:mm:ss").toStdString();
-            json2["DeviceName"] = it.devName.toStdString();
-            json2["ActionName"] = it.actionName.toStdString();
-            json2["ActionID"] = static_cast<int>(it.actionID);
-            /* 根据设备名称找到设备信息 */
-            auto devInfo = DeviceContainer.getDevice(it.devName);
-            if(devInfo.PTTypeCode < 0)
-            {
-                LH_WRITE_ERROR(QString("未找到设备:%1").arg(it.devName));
-                continue;
-            }
-            json2["PTTypeCode"] = devInfo.PTTypeCode;
-            json2["DID"] = devInfo.DID;
-            json2["MPID"] = devInfo.MPID;
-            json2["ChannelID"] = devInfo.ChannelID;
-
+            json2["channelID"] = it.ChannelID;
+            json2["channelName"] = it.ChannelName.toStdString();
+            json2["onWeekDay"] = it.onWeekDay;
+            json2["onDate"] = it.onDateTime.date().toString("yyyy-MM-dd").toStdString();
+            json2["onTime"] = it.onDateTime.time().toString("hh:mm:ss").toStdString();
+            json2["offWeekDay"] = it.offWeekDay;
+            json2["offDate"] = it.offDateTime.date().toString("yyyy-MM-dd").toStdString();
+            json2["offTime"] = it.offDateTime.time().toString("hh:mm:ss").toStdString();
 
             json1["paramList"] = json2;
 
@@ -337,7 +327,7 @@ bool FromWebAPI::insertData(QList<ExecPlanItemInfo>& list)
         LH_WRITE_ERROR(QString("写入EQM数据库失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
         return false;
     }
-    LH_WRITE_LOG(QString("计划写入EQM数据库成功, 计划数目:%1").arg(QString::number(list.size())));
+    // LH_WRITE_LOG(QString("计划写入EQM数据库成功, 计划数目:%1").arg(QString::number(list.size())));
 
     return true;
 }
@@ -345,11 +335,12 @@ bool FromWebAPI::insertData(QList<ExecPlanItemInfo>& list)
 /**
  * @brief 获取tExecPlan表格数据,获取到的数据会根据设备名查找对应的设备信息,如果没有查找到,就抛弃这个计划
  * 
- * @param list 
+ * @param chnID 频率ID
+ * @param mapPlan 
  * @return true 
  * @return false 
  */
-bool FromWebAPI::getExecPlanData(QList<ExecPlanItemInfo>& list)
+bool FromWebAPI::getExecPlanData(int chnID, QList<OnePlanItemInfo>& list)
 {
     if(m_httpApi == nullptr)
     {
@@ -358,7 +349,10 @@ bool FromWebAPI::getExecPlanData(QList<ExecPlanItemInfo>& list)
     }
 
     nJson json0;
-    json0["opName"] = "ESM8C_GetExecPlan";
+    json0["opName"] = "ESM8C_GetOneChnPlan";
+    nJson json1;
+    json1["channelID"] = chnID;
+    json0["paramList"] = json1;
     QString strCmd = QString::fromStdString(json0.dump());
     QString strRet;
     auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Select, strCmd, strRet, true);
@@ -371,59 +365,107 @@ bool FromWebAPI::getExecPlanData(QList<ExecPlanItemInfo>& list)
     // SPDLOG_LOGGER_DEBUG(m_logger,"获取执行计划:\n{}",strRet.toStdString());
     try 
     {
-        nJson json1 = nJson::parse(strRet.toStdString());
-        int retCode = json1["code"].get<int>();
+        nJson json2 = nJson::parse(strRet.toStdString());
+        int retCode = json2["code"].get<int>();
         if(retCode != 0)
         {
             LH_WRITE_ERROR("获取tExecPlan表格数据失败");
             return false;
         }
-        nJson result = json1["result"];
+        nJson result = json2["result"];
         for(auto& it : result)
         {
-            ExecPlanItemInfo info;
-            info.devName = QString::fromStdString(it["deviceName"].get<std::string>());
-            if(!DeviceContainer.findDevice(info.devName))
-            {
-                LH_WRITE_LOG(QString("未找到设备:%1").arg(info.devName));
-                continue;
-            }
-
-            info.ExecType = it["execType"].get<int>();
-            info.WeekDay = static_cast<enum_WeekDay>(it["weekDay"].get<int>());
-            auto tmpDate = it["date"].is_null() ? "" : it["date"].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>();
+            OnePlanItemInfo info;
+            info.ChannelID = chnID;
+            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);
         }
 
     } catch (const nJson::parse_error& e) {
-        LH_WRITE_ERROR(QString("解析tExecPlan表格数据失败:%1").arg(e.what()));
+        LH_WRITE_ERROR(QString("解析 tExecPlan 表格数据失败:%1").arg(e.what()));
         return false;
     }
     catch (const nJson::exception& e)
     {
-        LH_WRITE_ERROR(QString("解析tExecPlan表格数据失败:%1").arg(e.what()));
+        LH_WRITE_ERROR(QString("解析 tExecPlan 表格数据失败:%1").arg(e.what()));
         return false;
     }
     catch(...)
     {
-        LH_WRITE_ERROR("解析tExecPlan表格数据失败");
+        LH_WRITE_ERROR("解析 tExecPlan 表格数据失败");
         return false;
     }
 
-    LH_WRITE_LOG_DEBUG(QString("从EQM.tExecPlan表格获取数据成功,计划数目:%1").arg(list.size()));
+    // LH_WRITE_LOG_DEBUG(QString("从 EQM.tExecPlan 表格获取数据成功,计划数目:%1").arg(list.size()));
+
+    return true;
+}
 
 
+/* 删除所有行 */
+bool FromWebAPI::deleteAllRow()
+{
+    if(m_httpApi == nullptr)
+    {
+        LH_WRITE_ERROR("WebAPI is nullptr");
+        return false;
+    }
+    nJson json0;
+    json0["opName"] = "ESM8C_DeleteAllRow";
+    QString strCmd = QString::fromStdString(json0.dump());
+    QString strRet;
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Delete, strCmd, strRet, true);
+    if(ret != 0)
+    {
+        LH_WRITE_ERROR(QString("删除所有行失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
+        return false;
+    }
+    
     return true;
 }
 
+
+/* 删除一个发射机计划 */
+bool FromWebAPI::deleteOneChnPlan(int chnID)
+{
+    if(m_httpApi == nullptr)
+    {
+        LH_WRITE_ERROR("WebAPI is nullptr");
+        return false;
+    }
+    /* 查找出有多少发射机类型 */
+    QList<int> listPttypeCodeID;
+    for(auto& it : DevTypeContainer.getMapDevType())
+    {
+        listPttypeCodeID.append(it.PTTypeCode);
+    }
+    nJson json0;
+    json0["opName"] = "ESM8C_DeleteOneChnPlan";
+
+    json0["paramList"].clear();
+    nJson json1;
+    json1["channelID"] = chnID;
+    json0["paramList"].push_back(json1);
+    QString strCmd = QString::fromStdString(json0.dump());
+    QString strRet;
+    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Delete, strCmd, strRet, true);
+    if(ret != 0)
+    {
+        LH_WRITE_ERROR(QString("删除频率: %3 计划失败: %1, 错误信息: %2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)).arg(chnID));
+    }else {
+        // LH_WRITE_LOG(QString("删除频率: %1 计划成功!").arg(chnID));
+    }
+    return true;
+}
+
+
 /**
  * @brief 将页面的配置写入数据库,主要是默认计划和执行模式
  * 
@@ -480,7 +522,7 @@ bool FromWebAPI::insertConfigData(QMap<int, ConfigData>& list)
         LH_WRITE_ERROR(QString("写入tExecPlanConfig失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
         return false;
     }
-    LH_WRITE_LOG(QString("页面配置写入tExecPlanConfig成功, 数目:%1").arg(QString::number(list.size())));
+    LH_WRITE_LOG_DEBUG(QString("页面配置写入tExecPlanConfig成功, 数目:%1").arg(QString::number(list.size())));
 
     return true;
 }
@@ -730,67 +772,8 @@ bool FromWebAPI::getEQMTemplateID(QList<int>& listId)
 }
 
 
-/* 删除所有行 */
-bool FromWebAPI::deleteAllRow()
-{
-    if(m_httpApi == nullptr)
-    {
-        LH_WRITE_ERROR("WebAPI is nullptr");
-        return false;
-    }
-    nJson json0;
-    json0["opName"] = "ESM8C_DeleteAllRow";
-    QString strCmd = QString::fromStdString(json0.dump());
-    QString strRet;
-    auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Delete, strCmd, strRet, true);
-    if(ret != 0)
-    {
-        LH_WRITE_ERROR(QString("删除所有行失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)));
-        return false;
-    }
-    
-    return true;
-}
-
-
-/* 删除所有的发射机计划 */
-bool FromWebAPI::deleteAllTransmitterPlan()
-{
-    if(m_httpApi == nullptr)
-    {
-        LH_WRITE_ERROR("WebAPI is nullptr");
-        return false;
-    }
-    /* 查找出有多少发射机类型 */
-    QList<int> listPttypeCodeID;
-    for(auto& it : DevTypeContainer.getMapDevType())
-    {
-        listPttypeCodeID.append(it.PTTypeCode);
-    }
-    nJson json0;
-    json0["opName"] = "ESM8C_DeleteRowBasePTTypeCode";
-    for(const auto& it : listPttypeCodeID)
-    {
-        json0["paramList"].clear();
-        nJson json1;
-        json1["PTTypeCode"] = it;
-        json0["paramList"].push_back(json1);
-        QString strCmd = QString::fromStdString(json0.dump());
-        QString strRet;
-        auto ret = m_httpApi->DBDoInterface(enDBOperatorType::EDBOT_Delete, strCmd, strRet, true);
-        if(ret != 0)
-        {
-            LH_WRITE_ERROR(QString("删除发射机(%3)计划失败:%1, 错误信息:%2").arg(ret).arg(m_httpApi->DoGetLastError(&ret)).arg(it));
-        }else {
-            LH_WRITE_LOG(QString("删除发射机(%1)计划成功!").arg(it));
-        }
-    }
-    return true;
-}
-
-
 /* 保存到模板 */
-bool FromWebAPI::saveTemplate(const QString& templateName, const int type, QList<ExecPlanItemInfo>& list)
+bool FromWebAPI::saveTemplate(const QString& templateName, const int type, QList<OnePlanItemInfo>& list)
 {
     if(m_httpApi == nullptr)
     {
@@ -806,13 +789,13 @@ bool FromWebAPI::saveTemplate(const QString& templateName, const int type, QList
         json1["Key"] = QUuid::createUuid().toString().toStdString();
         nJson json2;
 
-        json2["templateName"] = templateName.toStdString();
-        json2["templateType"] = type;
-        json2["execDate"] = it.dateTime.date().toString("yyyy-MM-dd").toStdString();
-        json2["execTime"] = it.dateTime.time().toString("hh:mm:ss").toStdString();
-        json2["deviceName"] = it.devName.toStdString();
-        json2["actionName"] = it.actionName.toStdString();
-        json2["actionID"] = static_cast<int>(it.actionID);
+        // json2["templateName"] = templateName.toStdString();
+        // json2["templateType"] = type;
+        // json2["execDate"] = it.dateTime.date().toString("yyyy-MM-dd").toStdString();
+        // json2["execTime"] = it.dateTime.time().toString("hh:mm:ss").toStdString();
+        // json2["deviceName"] = it.devName.toStdString();
+        // json2["actionName"] = it.actionName.toStdString();
+        // json2["actionID"] = static_cast<int>(it.actionID);
 
         json1["paramList"] = json2;
         json0.push_back(json1);
@@ -840,7 +823,7 @@ bool FromWebAPI::saveTemplate(const QString& templateName, const int type, QList
 }
 
 /* 获取模板内容 */
-bool FromWebAPI::getTemplate(QString templateName, QList<ExecPlanItemInfo>& list)
+bool FromWebAPI::getTemplate(QString templateName, QList<OnePlanItemInfo>& list)
 {
     if(m_httpApi == nullptr)
     {
@@ -873,21 +856,21 @@ bool FromWebAPI::getTemplate(QString templateName, QList<ExecPlanItemInfo>& list
         nJson result = json2["result"];
         for(auto& it : result)
         {
-            ExecPlanItemInfo 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>();
+            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>();
 
             list.append(info);
         }
@@ -914,7 +897,7 @@ bool FromWebAPI::getTemplate(QString templateName, QList<ExecPlanItemInfo>& list
 }
 
 /* 获取模板列表 */
-bool FromWebAPI::getTemplateList(QMap<QString, int>& list)
+bool FromWebAPI::getTemplateList(QMultiMap<int, TemplateInfo>& mapTemplate)
 {
     if(m_httpApi == nullptr)
     {
@@ -946,18 +929,10 @@ bool FromWebAPI::getTemplateList(QMap<QString, int>& list)
         nJson result = json1["result"];
         for(auto& it : result)
         {
-            if(it["templateName"].is_null())
-            {
-                LH_WRITE_ERROR("模板名称为空");
-                continue;
-            }
-            auto name = QString::fromStdString(it["templateName"].get<std::string>());
-            int type = it["templateType"].is_null() ? -1 : it["templateType"].get<int>();
-            if(list.contains(name))
-            {
-                continue;
-            }
-            list.insert(name, type);
+            TemplateInfo info;
+            info.channelInfo.ChannelID = it["channelID"].get<int>();
+            info.templateName = QString::fromStdString(it["templateName"].get<std::string>());
+            mapTemplate.insert(info.channelInfo.ChannelID, info);
         }
 
     } catch (const nJson::parse_error& e) {

+ 11 - 10
TransmitterSwitch/WebAPI/FromWebAPI.h

@@ -4,7 +4,7 @@
 #include "lhhttpapi.h"
 #include "TransmitterSwitchInfo.h"
 
-struct ExecPlanItemInfo;
+struct OnePlanItemInfo;
 
 class FromWebAPI
 {
@@ -21,9 +21,13 @@ public:
     bool getChannelInfo(QMap<int, ChannelInfo>& mapFreq);
 
     /* 将数据写入EQM数据库 */
-    bool insertData(QList<ExecPlanItemInfo>& list);
+    bool insertData(int chnID, QList<OnePlanItemInfo>& list);
     /* 获取tExecPlan表格数据 */
-    bool getExecPlanData(QList<ExecPlanItemInfo>& list);
+    bool getExecPlanData(int chnID, QList<OnePlanItemInfo>& list);
+    /* 删除所有行 */
+    bool deleteAllRow();
+    /* 删除一个发射机计划 */
+    bool deleteOneChnPlan(int chnID);
 
     /* 将页面的配置写入数据库 */
     bool insertConfigData(QMap<int, ConfigData>& list);
@@ -36,17 +40,14 @@ public:
 
     /* 获取EQM数据库中的模版编号 */
     bool getEQMTemplateID(QList<int>& listId);
-    /* 删除所有行 */
-    bool deleteAllRow();
-    /* 删除所有的发射机计划 */
-    bool deleteAllTransmitterPlan();
+    
 
     /* 保存到模板 */
-    bool saveTemplate(const QString& templateName, const int type, QList<ExecPlanItemInfo>& list);
+    bool saveTemplate(const QString& templateName, const int type, QList<OnePlanItemInfo>& list);
     /* 获取模板内容 */
-    bool getTemplate(QString templateName, QList<ExecPlanItemInfo>& list);
+    bool getTemplate(QString templateName, QList<OnePlanItemInfo>& list);
     /* 获取模板列表 */
-    bool getTemplateList(QMap<QString, int>& list);
+    bool getTemplateList(QMultiMap<int, TemplateInfo>& mapTemplate);
     /* 删除一个模板 */
     bool deleteTemplate(const QString& name);
 

+ 5 - 0
TransmitterSwitch/common/date/calendardtedit.h

@@ -4,6 +4,11 @@
 #include <QWidget>
 #include <QDateTimeEdit>
 
+
+/* 需要设置这个属性,qss设置的图标才会生效
+ * setCalendarPopup(true);
+ */
+
 class CalendarDTEdit : public QDateTimeEdit
 {
     Q_OBJECT

+ 284 - 70
TransmitterSwitch/transmitterswitch.cpp

@@ -1,5 +1,4 @@
 #include "transmitterswitch.h"
-#include "importtemplate.h"
 #include "ui_transmitterswitch.h"
 
 
@@ -7,7 +6,7 @@
 #include <QList>
 #include <memory>
 #include <QLayout>
-
+#include <QScrollBar>
 
 #include "LHQLogAPI.h"
 #include "pBtnUserData2.h"
@@ -24,6 +23,8 @@
 #include "PlanCard.h"
 #include "flowlayout.h"
 #include "managerplan.h"
+#include "importtemplate.h"
+
 
 
 TransmitterSwitch::TransmitterSwitch(QWidget *parent) :
@@ -40,7 +41,7 @@ TransmitterSwitch::TransmitterSwitch(QWidget *parent) :
     layout->addWidget(this);
 
     /* 创建一个流式布局,存放卡片 */
-    m_flowlayout = new FlowLayout(ui->scrollAreaContents_Card, 0, m_cardHorSpacing, 12);
+    m_flowlayout = new FlowLayout(ui->scrollAreaContents_Card, 0, m_cardHorSpacing, m_cardVerSpacing);
     // m_flowlayout->setContentsMargins(0, 0, 0, 0);
     // m_flowlayout->setSpacing(200);
     
@@ -75,7 +76,13 @@ TransmitterSwitch::TransmitterSwitch(QWidget *parent) :
     connect(ui->pBtn_addPlan, &QPushButton::clicked, this, &TransmitterSwitch::do_pBtnAddExecPlan);
     connect(ui->pBtn_importPlan, &QPushButton::clicked, this, &TransmitterSwitch::do_importData);
     connect(ui->pBtn_exportPlan, &QPushButton::clicked, this, &TransmitterSwitch::do_exportData);
-    connect(ui->pBtn_clearPlan, &QPushButton::clicked, this, &TransmitterSwitch::do_clearCurrentPage);
+    connect(ui->pBtn_editPlan, &QPushButton::clicked, this, &TransmitterSwitch::do_pBtnModifyExecPlan);
+    connect(ui->pBtn_refresh, &QPushButton::clicked, this, &TransmitterSwitch::do_pBtnRefresh);
+    connect(ui->pBtn_defaultPlan, &QPushButton::clicked, this, &TransmitterSwitch::do_pBtnIsOpenPlan);
+    connect(ui->rBtn_moment, &QPushButton::clicked, this, &TransmitterSwitch::do_pBtnExecMode);
+    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);
 
     /* 设置QSS */
     connect(&EPUIStyle, &UIStyleManager::signal_qssChanged, this, &TransmitterSwitch::do_setUIStyle);
@@ -148,12 +155,12 @@ void TransmitterSwitch::setWebAPIInfo(const InitData& data)
     setWebAPIInfo(data.url, data.serverID, data.serverKey);
 }
 
-/* 获取EQM数据库计划 */
+/**
+ * @brief 获取EQM数据库计划,包括所有的配置信息
+ * 
+ */
 void TransmitterSwitch::getExecPlanFromEQM()
 {
-    /* 清空本地的计划数据 */
-
-
     /* 获取页面的配置信息 */
     if(m_fromWebAPI->getConfigData(CfgData.getMapConfigData()))
     {
@@ -166,7 +173,7 @@ void TransmitterSwitch::getExecPlanFromEQM()
     auto& mapConfig = CfgData.getMapConfigData();
     for(auto begin = mapConfig.begin(), end = mapConfig.end(); begin != end; begin++)
     {
-        if(begin->key == static_cast<int>(enum_ExecPlanConfig::DefaultPlan))
+        if(begin->key == static_cast<int>(enum_ExecPlanConfig::OpenPlan))
         {
             ui->pBtn_defaultPlan->setChecked(begin->value == 1 ? true : false);
         }
@@ -181,29 +188,32 @@ void TransmitterSwitch::getExecPlanFromEQM()
         }
     }
 
-    /* 获取计划 */
-    QList<ExecPlanItemInfo> list;
-    if(m_fromWebAPI->getExecPlanData(list))
-    {
-        TipWidget::display(TipWidget::OPERATOR_OK, "获取计划成功", this);
-    }else {
-        TipWidget::display(TipWidget::OPERATOR_FAIL, "获取计划失败", this);
-        return;
-    }
-
-    /* 添加计划项 */
-    for(const auto& it : list)
+    /* 获取所有频率的计划 */
+    bool isSuccess = true;
+    for(const auto& chn : ChnContainer.getMapChannel())
     {
-        
+        /* 获取计划 */
+        QList<OnePlanItemInfo> list;
+        if(m_fromWebAPI->getExecPlanData(chn.ChannelID, list))
+        {
+            auto pCard = PData.findPlanCard(chn.ChannelID);
+            if(pCard != nullptr)
+            {
+                pCard->setPlanList(list);
+            }
+        }else {
+            TipWidget::display(TipWidget::OPERATOR_FAIL, QString("获取频率<%1>计划失败").arg(chn.ChannelName), this);
+            isSuccess = false;
+            LH_WRITE_ERROR(QString("获取频率“%1”计划失败").arg(chn.ChannelName));
+        }
+        /* 先显示已获取到的数据,避免等待时间太久,卡顿 */
+        QEventLoop loop;
+        loop.processEvents();
     }
-    /* 排序 */
-    for(int i = 0; i < 8; ++i)
+    if(isSuccess)
     {
-        
+        TipWidget::display(TipWidget::OPERATOR_OK, "获取计划成功", this);
     }
-    /* 获取数据插入到全局变量中,会将更新标志位置true,这里需要手动置为false */
-
-    
     /* 调用回调函数 */
     if(m_trackCB != nullptr)
     {
@@ -214,7 +224,7 @@ void TransmitterSwitch::getExecPlanFromEQM()
 /* 将计划保存到EQM数据库 */
 void TransmitterSwitch::saveExecPlanToEQM()
 {
-    QList<ExecPlanItemInfo> list;
+    QList<OnePlanItemInfo> list;
     /* 获取当前计划的执行模式 */
     int execType = 0;
     if(ui->rBtn_moment->isChecked())
@@ -228,7 +238,7 @@ void TransmitterSwitch::saveExecPlanToEQM()
     // {
     //     for(const auto& it1 : *it)
     //     {
-    //         ExecPlanItemInfo info;
+    //         OnePlanItemInfo info;
     //         info.ExecType = execType;
     //         info.devName = it1->getDevName();
     //         info.actionID = it1->getActionNum();
@@ -240,16 +250,16 @@ void TransmitterSwitch::saveExecPlanToEQM()
     //     }
     // }
     /* 写入数据库 */
-    if(m_fromWebAPI->insertData(list))
-    {
-        TipWidget::display(TipWidget::OPERATOR_OK, "保存计划成功", this);
-    }else {
-        TipWidget::display(TipWidget::OPERATOR_FAIL, "保存计划失败", this);
-    }
+    // if(m_fromWebAPI->insertData(list))
+    // {
+    //     TipWidget::display(TipWidget::OPERATOR_OK, "保存计划成功", this);
+    // }else {
+    //     TipWidget::display(TipWidget::OPERATOR_FAIL, "保存计划失败", this);
+    // }
 
     /* 保存“默认计划”和“执行模式” */
     ConfigData config1;
-    config1.key = static_cast<int>(enum_ExecPlanConfig::DefaultPlan);
+    config1.key = static_cast<int>(enum_ExecPlanConfig::OpenPlan);
     config1.value = ui->pBtn_defaultPlan->isChecked() ? 1 : 0;
     config1.updateTime = QDateTime::currentDateTime();
     CfgData.updateConfigData(config1);
@@ -317,17 +327,215 @@ void TransmitterSwitch::do_pBtnAddExecPlan()
     /* 创建新增窗口 */
     std::shared_ptr<ManagerPlan> mp = std::make_shared<ManagerPlan>();
 
+    /* 获取当前选中的窗口 */
+    auto pCard = PData.getCurrentPlanCard();
+    ChannelInfo chnInfo;
+    if(pCard == nullptr)
+    {
+        LH_WRITE_LOG_DEBUG("没有选中频率卡片");
+    }else {
+        mp->setFrequencyID(pCard->getChannelInfo());
+    }
+
     mp->exec();
+
+    /* 判断是否点击了OK */
+    if(!mp->isOK())
+    {
+        return;
+    }
+    /* 获取计划信息 */
+    auto& mapPlanInfo = mp->getPlanInfo();
+    /* 遍历所有的频率 */
+    bool isSuccess = true;
+    for(auto begin = mapPlanInfo.begin(), end = mapPlanInfo.end(); begin != end; begin++)
+    {
+        /* 获取频率ID */
+        int chnID = begin.key();
+        /* 获取计划列表 */
+        auto& list = begin.value();
+        /* 查找这个频率的Card */   
+        auto pCard = PData.findPlanCard(chnID);
+        if(pCard == nullptr)
+        {
+            LH_WRITE_ERROR(QString("没有找到频率ID为%1的卡片").arg(chnID));
+            continue;
+        }
+        /* 设置计划列表 */
+        pCard->setPlanList(list);
+        /* 写入数据库 */
+        QList<OnePlanItemInfo> listPlan;
+        pCard->getAllPlanInfo(listPlan);
+        if(!m_fromWebAPI->insertData(chnID, listPlan))
+        {
+            LH_WRITE_ERROR(QString("频率ID为%1的计划写入数据库失败").arg(chnID));
+            isSuccess = false;
+            TipWidget::display(TipWidget::OPERATOR_FAIL, QString("频率<%1>计划写入数据库失败").arg(pCard->getChannelInfo().ChannelName), this);
+        }
+    }
+    if(isSuccess)
+    {
+        TipWidget::display(TipWidget::OPERATOR_OK, "添加计划成功", this);
+    }
+}
+
+/* 点击了修改按钮 */
+void TransmitterSwitch::do_pBtnModifyExecPlan()
+{
+    /* 创建新增窗口 */
+    std::shared_ptr<ManagerPlan> mp = std::make_shared<ManagerPlan>();
+    mp->setMode(Enum_Mode::Mode_Modify);
+    auto pCard = PData.getCurrentPlanCard();
+    if(pCard == nullptr)
+    {
+        LH_WRITE_ERROR("没有选中频率卡片");
+        return;
+    }
+    /* 设置频率信息 */
+    mp->setFrequencyID(pCard->getChannelInfo());
+    mp->exec();
+
+    /* 判断是否点击了OK */
+    if(!mp->isOK())
+    {
+        return;
+    }
+    /* 获取计划信息 */
+    auto& mapPlanInfo = mp->getPlanInfo();
+    auto list = mapPlanInfo.find(pCard->getChannelInfo().ChannelID);
+    pCard->setPlanList(*list);
+
+    int chnID = pCard->getChannelInfo().ChannelID;
+    QList<OnePlanItemInfo> listPlan;
+    pCard->getAllPlanInfo(listPlan);
+    if(!m_fromWebAPI->insertData(chnID, listPlan))
+    {
+        LH_WRITE_ERROR(QString("频率ID为%1的计划写入数据库失败").arg(chnID));
+        TipWidget::display(TipWidget::OPERATOR_FAIL, QString("频率<%1>计划写入数据库失败").arg(pCard->getChannelInfo().ChannelName), this);
+    }
+    TipWidget::display(TipWidget::OPERATOR_OK, "修改计划成功", this);
+    /* 调用回调函数 */
+    if(m_trackCB != nullptr)
+    {
+        m_trackCB(1, g_mapTrack.value(1));
+    }
+}
+
+
+/* 点击了刷新按钮 */
+void TransmitterSwitch::do_pBtnRefresh()
+{
+    getExecPlanFromEQM();
+}
+
+/* 点击了“是否开启计划”按钮 */
+void TransmitterSwitch::do_pBtnIsOpenPlan()
+{
+    /* 保存“默认计划”和“执行模式” */
+    ConfigData config1;
+    config1.key = static_cast<int>(enum_ExecPlanConfig::OpenPlan);
+    config1.value = ui->pBtn_defaultPlan->isChecked() ? 1 : 0;
+    config1.updateTime = QDateTime::currentDateTime();
+    CfgData.updateConfigData(config1);
+
+    /* 更新“计划是否更新”标志位,在更新前需要先获取数据库的标志位,如果依旧为1,那么本地是否更改都设置为1 */
+    ConfigData config3;
+    if(!m_fromWebAPI->getConfigData(static_cast<int>(enum_ExecPlanConfig::IsChanged), config3))
+    {
+        config3.key = static_cast<int>(enum_ExecPlanConfig::IsChanged);
+    }
+    /* 只要数据库和本地更新标志位有一个为true,说明还未被读走,则设置标志位为true */
+    config3.value = 1;
+    config3.updateTime = QDateTime::currentDateTime();
+    CfgData.updateConfigData(config3);
+
+    /* 将配置写入数据库 */
+    m_fromWebAPI->insertConfigData(CfgData.getMapConfigData());
 }
 
+/* 点击了“执行模式”按钮 */
+void TransmitterSwitch::do_pBtnExecMode()
+{
+    /* 保存“默认计划”和“执行模式” */
+    ConfigData config1;
+    config1.key = static_cast<int>(enum_ExecPlanConfig::ExecMode);
+    config1.value = ui->rBtn_moment->isChecked() ? 0 : 1;
+    config1.updateTime = QDateTime::currentDateTime();
+    CfgData.updateConfigData(config1);
 
+    /* 更新“计划是否更新”标志位,在更新前需要先获取数据库的标志位,如果依旧为1,那么本地是否更改都设置为1 */
+    ConfigData config3;
+    if(!m_fromWebAPI->getConfigData(static_cast<int>(enum_ExecPlanConfig::IsChanged), config3))
+    {
+        config3.key = static_cast<int>(enum_ExecPlanConfig::IsChanged);
+    }
+    /* 只要数据库和本地更新标志位有一个为true,说明还未被读走,则设置标志位为true */
+    config3.value = 1;
+    config3.updateTime = QDateTime::currentDateTime();
+    CfgData.updateConfigData(config3);
 
+    /* 将配置写入数据库 */
+    m_fromWebAPI->insertConfigData(CfgData.getMapConfigData());
+}
+
+/* 点击了清空计划按钮 */
+void TransmitterSwitch::do_pBtnClearPlan()
+{
+    /* 先判断有没有选中的频率卡片 */
+    if(PData.getCurrentPlanCard() == nullptr)
+    {
+        TipWidget::display(TipWidget::OPERATOR_FAIL, "没有选中频率卡片", this);
+        return;
+    }
+    /* 跳出弹窗警告 */
+    Warning w(this);
+    w.setQSS(EPUIStyle.getQSSPath());
+    w.setText("确定删除对应频率开关机计划?");
+    bool flag = false;
+    connect(&w,&Warning::signal_ok,this,[&](){
+        flag = true;
+    });
+    w.exec();
+    if(!flag)
+    {
+        return;
+    }
+    /* 获取选中的卡片 */
+    auto pCard = PData.getCurrentPlanCard();
+    if(pCard == nullptr)
+    {
+        LH_WRITE_ERROR("没有选中频率卡片");
+        return;
+    }
+    /* 清空计划 */
+    pCard->clearPlanItem();
+    /* 删除数据库中的计划 */
+    if(!m_fromWebAPI->deleteOneChnPlan(pCard->getChannelInfo().ChannelID))
+    {
+        LH_WRITE_ERROR(QString("频率ID为%1的计划删除失败").arg(pCard->getChannelInfo().ChannelID));
+        TipWidget::display(TipWidget::OPERATOR_FAIL, QString("频率<%1>计划删除失败").arg(pCard->getChannelInfo().ChannelName), this);
+    }else {
+        TipWidget::display(TipWidget::OPERATOR_OK, "清空计划成功", this);
+    }
+}
 
 
 /* 导入数据 */
 void TransmitterSwitch::do_importData()
 {
+    /* 获取模版列表 */
+    QMultiMap<int, TemplateInfo> tabList;
+    if(!m_fromWebAPI->getTemplateList(tabList))
+    {
+        TipWidget::display(TipWidget::OPERATOR_FAIL, "获取模版列表失败", this);
+        return;
+    }
+    /* 将模板列表添加频率信息 */
     
+
+    std::shared_ptr<ImportTemplate> it = std::make_shared<ImportTemplate>();
+
+    it->exec();
 }
 
 /* 导出数据 */
@@ -384,28 +592,6 @@ void TransmitterSwitch::do_exportData()
     // }
 }
 
-/* 清空当前页计划 */
-void TransmitterSwitch::do_clearCurrentPage()
-{
-    /* 跳出弹窗警告 */
-    Warning w(this);
-    w.setQSS(EPUIStyle.getQSSPath());
-    w.setText("是否清空当前页计划?");
-    bool flag = false;
-    connect(&w,&Warning::signal_ok,this,[&](){
-        flag = true;
-    });
-    w.exec();
-    if(!flag)
-    {
-        return;
-    }
-    // int weekDay = ui->stackedWidget_items->currentIndex();
-    // IData.clearOneDay(weekDay);
-    // sortLayout(weekDay);
-    // LH_WRITE_LOG_DEBUG(QString("计划剩余数目:%1").arg(IData.getOneDay(weekDay)->size()));
-}
-
 /* 删除一个模板 */
 void TransmitterSwitch::do_deleteTemplate(QString name)
 {
@@ -478,8 +664,14 @@ void TransmitterSwitch::do_selectFrequencyBtn()
             it->setChecked(false);
         }
     }
-    /* 设置当前按钮的选择状态 */
-    btn->setChecked(true);
+    if(btn != ui->pBtn_allFrequency)
+    {
+        /* 设置当前按钮的选择状态 */
+        btn->setChecked(true);
+        /* 设置该按钮对应的卡片状态 */
+        auto pCard = static_cast<PBtnUserData2*>(btn->userData(m_userData_Btn))->getCard();
+        pCard->clickedCard();
+    }
 
     /* 显示当前按钮对应的卡片,隐藏其他卡片 */
     showOneCard(btn);
@@ -488,7 +680,6 @@ void TransmitterSwitch::do_selectFrequencyBtn()
 
 
 
-
 /* 添加一个频率,包括左侧按钮和右侧卡片 */
 void TransmitterSwitch::createOneCard(const ChannelInfo& chnInfo)
 {
@@ -607,6 +798,26 @@ void TransmitterSwitch::showOneCard(QPushButton *btn)
     ui->scrollAreaContents_Card->updateGeometry();
 }
 
+/* 计算并设置设置卡片大小 */
+void TransmitterSwitch::setCardSize()
+{
+    /* 获取滚动条的区域 */
+    int vsb = 0;
+    if(ui->scrollArea->verticalScrollBar()->isVisible())
+    {
+        vsb = ui->scrollArea->verticalScrollBar()->width();
+    }
+    /* 去掉滚动条的宽度和阴影的宽度,再减去一个横向间距,和滚动条有些距离,不挨着太紧 */
+    int saWidth = ui->scrollArea->width() - vsb - m_cardHorSpacing - 2; 
+    int saHeight = ui->scrollArea->height();
+    int cardWidth = ( saWidth - (m_cardHorNumber - 1) * m_cardHorSpacing ) / m_cardHorNumber;
+    int cardHeight = ( saHeight - (m_cardVerNumber - 1) * m_cardVerSpacing ) / m_cardVerNumber;
+    /* 设置卡片大小 */
+    PData.setCardSize(cardWidth, cardHeight);
+
+    // LH_WRITE_LOG_DEBUG(QString("卡片大小:%1*%2").arg(cardWidth).arg(cardHeight));
+}
+
 /* 事件过滤器 */
 bool TransmitterSwitch::eventFilter(QObject *watched, QEvent *event)
 {
@@ -634,17 +845,20 @@ void TransmitterSwitch::resizeEvent(QResizeEvent *event)
     //     QPoint pos = ui->label_Tip->mapTo(this, ui->label_Tip->pos());
     //     m_tipText->move(pos.x() + 2, pos.y() + 2 );
     // }
-    
-    /* 设置scrollArea的大小 */
-    int saWidth = ui->scrollArea->width() - 20 * 3;
-    int saHeight = ui->scrollArea->height() - 20;
-    ui->scrollArea->resize(saWidth, saHeight);
-    ui->scrollAreaContents_Card->resize(saWidth, saHeight);
-    ui->scrollAreaContents_Card->updateGeometry();
 
-    // LH_WRITE_LOG(QString("scrollArea的大小:%1,%2").arg(saWidth).arg(saHeight));
+    setCardSize();
 
     QWidget::resizeEvent(event);
 }
 
+/* 显示事件 */
+void TransmitterSwitch::showEvent(QShowEvent *event)
+{
+    /* 设置提示文本的位置 */
+
+    setCardSize();
+
+    QWidget::showEvent(event);
+}
+
 

+ 17 - 3
TransmitterSwitch/transmitterswitch.h

@@ -47,13 +47,21 @@ private slots:
 
     /* 点击了添加计划按钮 */
     void do_pBtnAddExecPlan();
+    /* 点击了修改按钮 */
+    void do_pBtnModifyExecPlan();
+    /* 点击了刷新按钮 */
+    void do_pBtnRefresh();
+    /* 点击了“是否开启计划”按钮 */
+    void do_pBtnIsOpenPlan();
+    /* 点击了“执行模式”按钮 */
+    void do_pBtnExecMode();
+    /* 点击了清空计划按钮 */
+    void do_pBtnClearPlan();
 
     /* 导入模板 */
     void do_importData();
     /* 保存为模板 */
     void do_exportData();
-    /* 清空当前页计划 */
-    void do_clearCurrentPage();
     /* 删除一个模板 */
     void do_deleteTemplate(QString name);
 
@@ -78,12 +86,16 @@ private:
     void createAllCard();
     /* 显示某个卡片,隐藏其他卡片 */
     void showOneCard(QPushButton *btn);
+    /* 计算并设置设置卡片大小 */
+    void setCardSize();
 
 protected:
     /* 事件过滤器 */
     bool eventFilter(QObject *watched, QEvent *event) override;
     /* 窗口缩放事件 */
     void resizeEvent(QResizeEvent *event) override;
+    /* 显示事件 */
+    void showEvent(QShowEvent *event) override;
 
 private:
     Ui::TransmitterSwitch *ui;
@@ -100,7 +112,9 @@ private:
 
     const quint32 m_userData_Btn = 1;       /* 按钮的用户数据 */
     const int m_cardHorSpacing = 12;        /* 卡片间的横向间距 */
-    
+    const int m_cardVerSpacing = 12;        /* 卡片间的纵向间距 */
+    const int m_cardHorNumber = 4;          /* 卡片的横向数量 */
+    const int m_cardVerNumber = 2;          /* 卡片的纵向数量 */
 };
 
 #endif // TRANSMITTERSWITCH_H

+ 19 - 0
TransmitterSwitch/transmitterswitch.ui

@@ -231,6 +231,25 @@
               </property>
              </widget>
             </item>
+            <item>
+             <widget class="QPushButton" name="pBtn_templateManager">
+              <property name="minimumSize">
+               <size>
+                <width>88</width>
+                <height>32</height>
+               </size>
+              </property>
+              <property name="maximumSize">
+               <size>
+                <width>88</width>
+                <height>32</height>
+               </size>
+              </property>
+              <property name="text">
+               <string>模板管理</string>
+              </property>
+             </widget>
+            </item>
             <item>
              <widget class="QPushButton" name="pBtn_refresh">
               <property name="minimumSize">