|
@@ -13,6 +13,7 @@
|
|
#include "OneShadowEffect.h"
|
|
#include "OneShadowEffect.h"
|
|
#include "TransmitterSwitchInfo.h"
|
|
#include "TransmitterSwitchInfo.h"
|
|
#include "UIStyleManager.h"
|
|
#include "UIStyleManager.h"
|
|
|
|
+#include "template.h"
|
|
|
|
|
|
ImportTemplate::ImportTemplate(QWidget *parent) :
|
|
ImportTemplate::ImportTemplate(QWidget *parent) :
|
|
QDialog(parent),
|
|
QDialog(parent),
|
|
@@ -41,19 +42,19 @@ ImportTemplate::ImportTemplate(QWidget *parent) :
|
|
QStringList headerList;
|
|
QStringList headerList;
|
|
headerList << "频率名称" << "模版名称" << "选择";
|
|
headerList << "频率名称" << "模版名称" << "选择";
|
|
ui->tableWidget->setHorizontalHeaderLabels(headerList);
|
|
ui->tableWidget->setHorizontalHeaderLabels(headerList);
|
|
|
|
+ ui->tableWidget->horizontalHeader()->setSectionsClickable(false);
|
|
|
|
+ ui->tableWidget->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
|
|
|
+
|
|
/* 设置列表头高度 */
|
|
/* 设置列表头高度 */
|
|
ui->tableWidget->horizontalHeader()->setDefaultSectionSize(40);
|
|
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(0, QHeaderView::Fixed);
|
|
ui->tableWidget->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Fixed);
|
|
ui->tableWidget->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Fixed);
|
|
ui->tableWidget->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Fixed);
|
|
ui->tableWidget->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Fixed);
|
|
|
|
|
|
//设置行高
|
|
//设置行高
|
|
- ui->tableWidget->verticalHeader()->setDefaultSectionSize(48);
|
|
|
|
|
|
+ ui->tableWidget->verticalHeader()->setDefaultSectionSize(40);
|
|
|
|
|
|
//设置不可编辑
|
|
//设置不可编辑
|
|
ui->tableWidget->setEditTriggers(QTableWidget::NoEditTriggers);
|
|
ui->tableWidget->setEditTriggers(QTableWidget::NoEditTriggers);
|
|
@@ -61,8 +62,6 @@ ImportTemplate::ImportTemplate(QWidget *parent) :
|
|
ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
//设置只能选中一行
|
|
//设置只能选中一行
|
|
ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
- //隐藏竖滚动条
|
|
|
|
- // ui->tableWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
//隐藏横滚动条
|
|
//隐藏横滚动条
|
|
ui->tableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
ui->tableWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
//隐藏网格线
|
|
//隐藏网格线
|
|
@@ -79,33 +78,10 @@ ImportTemplate::ImportTemplate(QWidget *parent) :
|
|
connect(ui->pBtn_close,SIGNAL(clicked()),this,SLOT(close()));
|
|
connect(ui->pBtn_close,SIGNAL(clicked()),this,SLOT(close()));
|
|
connect(ui->pBtn_cancel,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->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);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /* 取出当前可用的模版,主要是区分正常日和特殊日 */
|
|
|
|
- // 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);
|
|
ui->pBtn_close->installEventFilter(this);
|
|
|
|
|
|
- /* 设置默认的皮肤 */
|
|
|
|
- do_setUIStyle();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
ImportTemplate::~ImportTemplate()
|
|
ImportTemplate::~ImportTemplate()
|
|
@@ -115,77 +91,73 @@ ImportTemplate::~ImportTemplate()
|
|
|
|
|
|
void ImportTemplate::do_ok()
|
|
void ImportTemplate::do_ok()
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ /* 获取已选中的模版列表 */
|
|
|
|
+ for(auto it : m_listCheckBox)
|
|
|
|
+ {
|
|
|
|
+ if(it->isChecked())
|
|
|
|
+ {
|
|
|
|
+ auto chnID = it->property(m_propertyChnID.c_str()).toInt();
|
|
|
|
+ auto tmpName = it->property(m_propertytmpName.c_str()).toString();
|
|
|
|
+ OneTemplateInfo info;
|
|
|
|
+ info.channelInfo.ChannelID = chnID;
|
|
|
|
+ info.templateName = tmpName;
|
|
|
|
+ m_listTemplate.append(info);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
m_isOk = true;
|
|
m_isOk = true;
|
|
emit signal_templateName(m_templateName);
|
|
emit signal_templateName(m_templateName);
|
|
this->close();
|
|
this->close();
|
|
}
|
|
}
|
|
|
|
|
|
-/* 选中一行 */
|
|
|
|
-void ImportTemplate::do_seletctRow(int row, int col)
|
|
|
|
|
|
+/* 点击了一个checkBox,取消其他同频率的checkBox */
|
|
|
|
+void ImportTemplate::do_checkBox_stateChanged(int state)
|
|
{
|
|
{
|
|
- if(col == 2)
|
|
|
|
|
|
+ if(state != Qt::Checked)
|
|
{
|
|
{
|
|
- /* 弹出框提示确定要删除 */
|
|
|
|
- std::shared_ptr<Warning> w = std::make_shared<Warning>(this);
|
|
|
|
- w->setQSS(EPUIStyle.getQSSPath());
|
|
|
|
- w->setText("是否删除模板?");
|
|
|
|
- bool flag = false;
|
|
|
|
- connect(w.get(), &Warning::signal_ok,this,[&](){
|
|
|
|
- flag = true;
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- w->exec();
|
|
|
|
- if(!flag)
|
|
|
|
- {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- emit signal_deleteTemplate(ui->tableWidget->item(row,1)->text());
|
|
|
|
- /* 删除一行 */
|
|
|
|
- ui->tableWidget->removeRow(row);
|
|
|
|
- // LH_WRITE_LOG_DEBUG(QString("剩余模版个数:%1").arg(ui->tableWidget->rowCount()));
|
|
|
|
- /* 对模版重新编号 */
|
|
|
|
- for(int i = 0 ;i < ui->tableWidget->rowCount();i++)
|
|
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ auto checkBox = qobject_cast<QCheckBox*>(sender());
|
|
|
|
+ if(checkBox == nullptr)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ auto chnID = checkBox->property(m_propertyChnID.c_str()).toInt();
|
|
|
|
+ /* 取消其他同频率的checkBox */
|
|
|
|
+ for(auto it : m_listCheckBox)
|
|
|
|
+ {
|
|
|
|
+ if(it != checkBox && it->property(m_propertyChnID.c_str()).toInt() == chnID)
|
|
{
|
|
{
|
|
- ui->tableWidget->item(i,0)->setData(Qt::DisplayRole, i+1);
|
|
|
|
|
|
+ it->setChecked(false);
|
|
}
|
|
}
|
|
- /* 强制重新绘制表格 */
|
|
|
|
- ui->tableWidget->repaint();
|
|
|
|
- }else
|
|
|
|
- {
|
|
|
|
- m_templateName = ui->tableWidget->item(row,1)->text();
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-/* 设置样式表 */
|
|
|
|
-void ImportTemplate::do_setUIStyle()
|
|
|
|
|
|
+/* 显示事件 */
|
|
|
|
+void ImportTemplate::showEvent(QShowEvent *event)
|
|
{
|
|
{
|
|
- setQSSPath(EPUIStyle.getQSSPath());
|
|
|
|
|
|
+ /* 设置列宽度 */
|
|
|
|
+ int width = (ui->tableWidget->width() - 88) / 2;
|
|
|
|
+ ui->tableWidget->setColumnWidth(0, width);
|
|
|
|
+ ui->tableWidget->setColumnWidth(1, width);
|
|
|
|
+ ui->tableWidget->setColumnWidth(3, 88);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-/* 创建一行数据 */
|
|
|
|
-void ImportTemplate::createRow(int row,int num,const QString &text)
|
|
|
|
|
|
+/* 设置模版列表 */
|
|
|
|
+void ImportTemplate::setTemplateList(const QMultiMap<int, OneTemplateInfo>& mapTemplate)
|
|
{
|
|
{
|
|
- /* 获取亮色还是暗色 */
|
|
|
|
- bool isDark = (EPUIStyle.getUIStyle() == enum_UIStyle::UI_Dark ? true : false);
|
|
|
|
-
|
|
|
|
- QTableWidgetItem* item = new QTableWidgetItem;
|
|
|
|
- item->setData(Qt::DisplayRole,num);
|
|
|
|
- ui->tableWidget->setItem(row,0,item);
|
|
|
|
-
|
|
|
|
- item = new QTableWidgetItem(text);
|
|
|
|
- ui->tableWidget->setItem(row,1,item);
|
|
|
|
-
|
|
|
|
- item = new QTableWidgetItem("删除");
|
|
|
|
- // item->setTextAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
|
|
|
|
- if(isDark)
|
|
|
|
|
|
+ for(auto it = mapTemplate.begin(), end = mapTemplate.end(); it != end; it++)
|
|
{
|
|
{
|
|
- item->setForeground(QColor(95, 158, 255));
|
|
|
|
- }else {
|
|
|
|
- item->setForeground(Qt::blue);
|
|
|
|
|
|
+ createRow(it.value());
|
|
}
|
|
}
|
|
- ui->tableWidget->setItem(row,2,item);
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/* 获取选中的模板列表 */
|
|
|
|
+QList<OneTemplateInfo>& ImportTemplate::getSelectedTemplateList()
|
|
|
|
+{
|
|
|
|
+ return m_listTemplate;
|
|
}
|
|
}
|
|
|
|
|
|
/* 设置QSS */
|
|
/* 设置QSS */
|
|
@@ -205,16 +177,42 @@ void ImportTemplate::setQSSPath(const QString& qssPath)
|
|
}else
|
|
}else
|
|
{
|
|
{
|
|
LH_WRITE_ERROR(QString("Open %1 failed").arg(qssFile));
|
|
LH_WRITE_ERROR(QString("Open %1 failed").arg(qssFile));
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // if(EPUIStyle.getUIStyle() == enum_UIStyle::UI_Dark)
|
|
|
|
+ // {
|
|
|
|
+ // /* 手动设置表头的qss */
|
|
|
|
+ // ui->tableWidget->horizontalHeader()->setStyleSheet(m_qssHeaderView_dark);
|
|
|
|
+ // }else {
|
|
|
|
+ // ui->tableWidget->horizontalHeader()->setStyleSheet(m_qssHeaderView_dark);
|
|
|
|
+ // }
|
|
}
|
|
}
|
|
|
|
|
|
-/* 绘画事件 */
|
|
|
|
-// void ImportTemplate::paintEvent(QPaintEvent *event)
|
|
|
|
-// {
|
|
|
|
-// QPainter painter(this);
|
|
|
|
-// painter.setRenderHint(QPainter::Antialiasing);
|
|
|
|
-// painter.drawImage(QPoint(0, 0), m_shadow->image());
|
|
|
|
-// }
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/* 添加一行 */
|
|
|
|
+void ImportTemplate::createRow(const OneTemplateInfo& info)
|
|
|
|
+{
|
|
|
|
+ /* 设置表格的行数 */
|
|
|
|
+ int row = ui->tableWidget->rowCount();
|
|
|
|
+ ui->tableWidget->setRowCount(row + 1);
|
|
|
|
+ /* 设置行高 */
|
|
|
|
+ ui->tableWidget->setRowHeight(row, 40);
|
|
|
|
+
|
|
|
|
+ QTableWidgetItem* item0 = new QTableWidgetItem(info.channelInfo.ChannelName);
|
|
|
|
+ // item->setData(Qt::DisplayRole, info.channelInfo.ChannelName);
|
|
|
|
+ QTableWidgetItem* item1 = new QTableWidgetItem(info.templateName);
|
|
|
|
+ ui->tableWidget->setItem(row, 0, item0);
|
|
|
|
+ ui->tableWidget->setItem(row, 1, item1);
|
|
|
|
+ auto checkBox = new QCheckBox();
|
|
|
|
+ checkBox->setProperty(m_propertyChnID.c_str(), info.channelInfo.ChannelID);
|
|
|
|
+ checkBox->setProperty(m_propertytmpName.c_str(), info.templateName);
|
|
|
|
+ /* 连接信号和槽 */
|
|
|
|
+ connect(checkBox, &QCheckBox::stateChanged, this, &ImportTemplate::do_checkBox_stateChanged);
|
|
|
|
+ ui->tableWidget->setCellWidget(row, 2, checkBox);
|
|
|
|
+
|
|
|
|
+ m_listCheckBox.append(checkBox);
|
|
|
|
+}
|
|
|
|
|
|
/* 事件过滤器 */
|
|
/* 事件过滤器 */
|
|
bool ImportTemplate::eventFilter(QObject *watched, QEvent *event)
|
|
bool ImportTemplate::eventFilter(QObject *watched, QEvent *event)
|