Procházet zdrojové kódy

V0.6.4
1、基本完成了,等待设备调试

Apple před 1 měsícem
rodič
revize
aad6b2fe1d

+ 2 - 0
EyeMap/CMakeLists.txt

@@ -17,6 +17,7 @@ file(GLOB LOCAL_SRC
     ${CMAKE_CURRENT_SOURCE_DIR}/SettingNum/*.ui
     ${CMAKE_CURRENT_SOURCE_DIR}/SettingNum/OneItem/*.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/SettingNum/OneItem/*.ui
+    ${CMAKE_CURRENT_SOURCE_DIR}/SettingNum/ListItem/*.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/ParameterConfig/*.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/ParameterConfig/*.ui
     ${CMAKE_CURRENT_SOURCE_DIR}/ParameterConfig/OneParamItem/*.cpp
@@ -60,6 +61,7 @@ target_include_directories(${execName1} PRIVATE
     ${CMAKE_CURRENT_SOURCE_DIR}/EyeMapWidget
     ${CMAKE_CURRENT_SOURCE_DIR}/SettingNum
     ${CMAKE_CURRENT_SOURCE_DIR}/SettingNum/OneItem
+    ${CMAKE_CURRENT_SOURCE_DIR}/SettingNum/ListItem
     ${CMAKE_CURRENT_SOURCE_DIR}/ParameterConfig
     ${CMAKE_CURRENT_SOURCE_DIR}/ParameterConfig/OneParamItem
 

+ 4 - 4
EyeMap/EyeMapWidget/eyemapwidget.cpp

@@ -120,14 +120,14 @@ void EyeMapWidget::do_pBtnSettingNum()
     // }
     /* 这里不能设置父指针 */
     // settingNum->setParent(this);
-    /* 设置模态窗口 */
-    settingNum->setModal(true);
+
     /* 设置眼图显示的个数 */
     settingNum->setRowAndColumn(m_row, m_column);
     /* 设置每个项的信息 */
     settingNum->setEveryEyeMapInfo(GEyeMapInfo.getEyeMapInfo());
     /* 设置可选的通道信息 */
     settingNum->setChannelList(GEyeMapInfo.getChannelInfo());
+
     settingNum->exec();
     /* 判断是否点击的是ok,是则重新布局 */
     if(!settingNum->isOk)
@@ -136,8 +136,8 @@ void EyeMapWidget::do_pBtnSettingNum()
     }
     /* 先暂停所有的采集 */
     GOscDataInfo.stopAllCapture();
-    m_row = settingNum->row;
-    m_column = settingNum->column;
+    m_row = settingNum->m_row;
+    m_column = settingNum->m_column;
     eyeMapLayout();
     /* 重置眼图数据矩阵 */
     resetMatrix();

+ 29 - 12
EyeMap/GlobalInfo/EyeMapInfo.cpp

@@ -110,16 +110,16 @@ void AllEyeMapInfo::createSaveFile(const QString& fileName)
     listInitEyeMapInfo.clear();
     for(int i = 0; i < 8; i++)
     {
-        OneEyeMapInfo info;
-        info.uid = static_cast<EyeMapUID>(i + 1);
-        info.num = i + 1;
-        info.title = "通道" + QString::number(i + 1);
-        info.titleBarColor = QColor("#2D2D31");
-        info.isShow = false;
-        info.channelInfo.channel = static_cast<OscChnNum>(i + 1);
-        info.channelInfo.channelName = getChannelName(static_cast<OscChnNum>(i + 1));
-        info.voltageRange = OscVoltageRange::CR_2V5;
-        info.tGridValue = OscTimeGridValue::TGV_200NS;
+        OneEyeMapInfo info = getInitEyeMapInfo(i + 1);
+        // info.uid = static_cast<EyeMapUID>(i + 1);
+        // info.num = i + 1;
+        // info.title = "通道" + QString::number(i + 1);
+        // info.titleBarColor = QColor("#2D2D31");
+        // info.isShow = false;
+        // info.channelInfo.channel = static_cast<OscChnNum>(i + 1);
+        // info.channelInfo.channelName = getChannelName(static_cast<OscChnNum>(i + 1));
+        // info.voltageRange = OscVoltageRange::CR_2V5;
+        // info.tGridValue = OscTimeGridValue::TGV_200NS;
         listInitEyeMapInfo.append(info);
     }
     row = 4;
@@ -263,7 +263,7 @@ void AllEyeMapInfo::updateSettingNum(OneEyeMapInfo& info)
 {
     for(auto& it : listEyeMapPtr)
     {
-        if(it->getNum() == info.num)
+        if(it->getUID() == info.uid)
         {
             it->updateSettingNum(info);
             break;
@@ -276,7 +276,7 @@ void AllEyeMapInfo::updateVoltageAndTimeGardInfo(const OneEyeMapInfo& info)
 {
     for(auto& it : listEyeMapPtr)
     {
-        if(it->getNum() == info.num)
+        if(it->getUID() == info.uid)
         {
             it->setVoltageRange(info.voltageRange);
             it->setTimeGridValue(info.tGridValue);
@@ -359,6 +359,23 @@ void AllEyeMapInfo::setEyeMapOscOpen(int oscNum, bool isOpen)
     }
 }
 
+/* 获取一项初始化数据 */
+OneEyeMapInfo AllEyeMapInfo::getInitEyeMapInfo(int num)
+{
+    OneEyeMapInfo info;
+    info.uid = static_cast<EyeMapUID>(num);
+    info.num = num;
+    info.title = "通道" + QString::number(num);
+    info.titleBarColor = QColor("#2D2D31");
+    info.isShow = false;
+    info.channelInfo.channel = static_cast<OscChnNum>(num);
+    info.channelInfo.channelName = getChannelName(static_cast<OscChnNum>(num));
+    info.voltageRange = OscVoltageRange::CR_2V5;
+    info.tGridValue = OscTimeGridValue::TGV_200NS;
+    return info;
+    
+}
+
 
 
 

+ 3 - 0
EyeMap/GlobalInfo/EyeMapInfo.h

@@ -116,6 +116,9 @@ public:
     /* 根据示波器编号设置眼图状态 */
     void setEyeMapOscOpen(int oscNum, bool isOpen);
 
+    /* 获取初始化数据 */
+    OneEyeMapInfo getInitEyeMapInfo(int num);
+
 public:
     QList<OneEyeMap*> listEyeMapPtr;                    /* 保存8个眼图的指针 */
     QList<OneChannelInfo> listChannelInfo;              /* 可用的通道号 */

+ 12 - 9
EyeMap/OneEyeMap/OneEyeMap.cpp

@@ -62,6 +62,7 @@ OneEyeMap::OneEyeMap(QWidget *parent) :
     m_rectEyeMap.setHeight(m_rectScaleValue.height() - m_topMargin - m_bottomMargin);
 
     /* 设置“暂无设备”、“设备离线”图片 */
+    m_rectNoDevice.setRect(0, 0, 280, 160);
     m_pixmapNoDevice = new QPixmap(":/image/Resource/image/dev_none.png");
     m_pixmapDeviceOffline  = new QPixmap(":/image/Resource/image/dev_outline.png");
     
@@ -148,6 +149,7 @@ void OneEyeMap::updateInfo(const OneEyeMapInfo &info)
 /* 只更新设置个数页面的信息 */
 void OneEyeMap::updateSettingNum(const OneEyeMapInfo &info)
 {
+    setNum(info.num);
     setTitle(info.title);
     setTitleBarColor(info.titleBarColor);
     setChannelInfo(info.channelInfo);
@@ -177,12 +179,12 @@ void OneEyeMap::paintEvent(QPaintEvent *event)
     drawBackground(painter);
 
     /* 判断设备是否打开,没打开就显示“暂无设备”图片 */
-    if(!m_isOpen)
-    {
-        ui->widget_title->hide();
-        drawNoDevice(painter);
-        return;
-    }
+    // if(!m_isOpen)
+    // {
+    //     ui->widget_title->hide();
+    //     drawNoDevice(painter);
+    //     return;
+    // }
     ui->widget_title->show();
 
     m_eyeMapMatrix->mutexEyeData.lock();
@@ -419,9 +421,10 @@ void OneEyeMap::drawEyeMap(QPainter &painter)
 /* 绘制“暂无设备” */
 void OneEyeMap::drawNoDevice(QPainter &painter)
 {
-    int x = (this->width() - m_pixmapNoDevice->width()) / 2;
-    int y = (this->height() - m_pixmapNoDevice->height()) / 2;
-    painter.drawPixmap(x, y, *m_pixmapNoDevice);
+    int x = (this->width() - m_rectNoDevice.width()) / 2;
+    int y = (this->height() - m_rectNoDevice.height()) / 2;
+    m_rectNoDevice.moveTo(x, y);
+    painter.drawPixmap(m_rectNoDevice, *m_pixmapNoDevice);
 }
 
 /* 获取一个格子的电压值 */

+ 4 - 1
EyeMap/OneEyeMap/OneEyeMap.h

@@ -28,6 +28,8 @@ public:
 
     /* 设置对应的示波器是否已经打开 */
     void setOpen(bool isOpen) { m_isOpen = isOpen; }
+    /* 获取UID */
+    EyeMapUID getUID() { return m_info.uid; }
     /* 设置序号 */
     void setNum(int num) { m_info.num = num; }
     /* 获取序号 */
@@ -85,7 +87,7 @@ private:
     /* 绘制眼图区域 */
     void drawEyeMap(QPainter &painter);
     /* 绘制暂无设备 */
-    void drawNoDevice(QPainter &painter);
+    inline void drawNoDevice(QPainter &painter);
 
     /* 获取一个格子的电压值 */
     inline QString getVScaleValue(int index);
@@ -107,6 +109,7 @@ private:
     QRect m_rectScaleValue;             /* 刻度值区域,除了标题栏之外的其他区域,包括下面的眼图区域 */
     QRect m_rectEyeMap;                 /* 眼图区域 */
     QRect m_rectRefColor;               /* 参考颜色区域 */
+    QRect m_rectNoDevice;               /* 暂无设备区域 */
     int m_leftMargin = 0;               /* 眼图距离刻度区域的左边距 */
     int m_topMargin = 0;                /* 眼图距离刻度区域的上边距 */
     int m_rightMargin = 0;              /* 眼图距离刻度区域的右边距 */

+ 1 - 4
EyeMap/ParameterConfig/paramconfig.h

@@ -5,8 +5,7 @@
 #include "spdlog/spdlog.h"
 #include "EyeMapInfo.h"
 
-// #include <QStandardItemModel>
-// #include <QTableView>
+
 
 struct OneEyeMapInfo;
 class OneParamItem;
@@ -61,8 +60,6 @@ private:
 
     QList<OneParamItem*> m_listItem;
 
-    // QStandardItemModel *m_model = nullptr;
-    // QTableView *m_tableView = nullptr;
 };
 
 #endif // PARAMCONFIG_H

+ 0 - 0
EyeMap/SettingNum/Delegate/DelegateComboBox.cpp


+ 0 - 0
EyeMap/SettingNum/Delegate/DelegateComboBox.h


+ 23 - 0
EyeMap/SettingNum/ListItem/ListItem.cpp

@@ -0,0 +1,23 @@
+#include "listitem.h"
+
+
+
+ListItem::ListItem(QWidget *parent)
+    : QListWidget(parent)
+{
+
+}
+
+ListItem::~ListItem()
+{
+
+}
+
+
+void ListItem::dropEvent(QDropEvent *event)
+{
+    QListWidget::dropEvent(event);
+    emit signal_dropComplete();
+}
+
+

+ 26 - 0
EyeMap/SettingNum/ListItem/ListItem.h

@@ -0,0 +1,26 @@
+#ifndef _LISTITEM_H_
+#define _LISTITEM_H_
+
+#include <QListWidget>
+
+class ListItem : public QListWidget
+{
+    Q_OBJECT
+public:
+    ListItem(QWidget *parent = nullptr);
+    ~ListItem();
+
+signals:
+    void signal_dropComplete();
+
+protected:
+    // void dragEnterEvent(QDragEnterEvent *event) override;
+    void dropEvent(QDropEvent *event) override;
+    // void dragMoveEvent(QDragMoveEvent *event) override;
+    // void mousePressEvent(QMouseEvent *event) override;
+
+
+};
+
+
+#endif /* _LISTITEM_H_ */

+ 37 - 0
EyeMap/SettingNum/SettingNum.qss

@@ -196,3 +196,40 @@ QComboBox QAbstractItemView::item:selected
 }
 
 
+/*****************  QTableView ****************/
+QTableView
+{
+    background: #2E2D31;
+    border: 0px;
+    font-weight: 400;
+    font-size: 14px;
+    color: #D2D2D2;
+}
+/* 设置表头 */
+QHeaderView::section
+{
+    background: #2E2D31;
+    /* border: 0px; */
+    font-weight: 400;
+    font-size: 14px;
+    color: #D2D2D2;
+    padding-left: 12px;
+}
+
+QTableView::item
+{
+    padding-left: 12px;
+}
+
+/*****************  QListWidget ****************/
+QListWidget
+{
+    background: #2E2D31;
+    border: 0px;
+    font-weight: 400;
+    font-size: 14px;
+    color: #D2D2D2;
+}
+
+
+

+ 230 - 0
EyeMap/SettingNum/back/settingnum.cpp_

@@ -0,0 +1,230 @@
+#include "settingnum.h"
+#include "ui_settingnum.h"
+
+#include <QDebug>
+#include <QFile>
+#include <QPainter>
+
+#include "customcombobox.h"
+#include "onesettingitem.h"
+#include "oneshadow.h"
+
+SettingNum::SettingNum(QDialog *parent) :
+    QDialog(parent),
+    ui(new Ui::SettingNum)
+{
+    ui->setupUi(this);
+
+    m_logger = spdlog::get("EyeMap");
+    if(m_logger == nullptr)
+    {
+        qDebug() << "获取 EyeMap logger 失败";
+        return;
+    }
+    /* 注册事件过滤,主要是消除滚轮对comboBox的影响 */
+    ui->comboBox_rowNum->installEventFilter(this);
+    ui->comboBox_columnNum->installEventFilter(this);
+
+    /* 设置无边框和背景透明 */
+    this->setWindowFlags(Qt::FramelessWindowHint);
+    this->setAttribute(Qt::WA_TranslucentBackground);
+    /* 加载QSS */
+    QFile fileQss(":/qss/SettingNum/SettingNum.qss");
+    if(fileQss.open(QFile::ReadOnly))
+    {
+        QString qss = fileQss.readAll();
+        this->setStyleSheet(qss);
+        fileQss.close();
+    } else
+    {
+        SPDLOG_LOGGER_ERROR(m_logger, "加载QSS文件失败");
+    }
+    /* 设置阴影 */
+    m_shadow = new OneShadow(ui->widget->size(), 16);
+    ui->verticalLayout->setMargin(16);
+
+    /* 初始化变量 */
+    for(auto item : m_listItem)
+    {
+        item = nullptr;
+    }
+
+    // ui->pBtn_close->move(ui->widget_top->width() - 40, 13);
+
+    /* 设置下拉框可选个数 */
+    QStringList listRow;
+    listRow << "1" << "2" << "3" << "4";
+    ui->comboBox_rowNum->addItems(listRow);
+    ui->comboBox_columnNum->addItem("1");
+    ui->comboBox_columnNum->addItem("2");
+    ui->comboBox_rowNum->setCurrentIndex(1);
+    ui->comboBox_columnNum->setCurrentIndex(1);
+
+
+    connect(ui->pBtn_close, &QPushButton::clicked, this, &SettingNum::do_pBtn_close);
+    connect(ui->pBtn_ok, &QPushButton::clicked, this, &SettingNum::do_pBtn_ok);
+    connect(ui->pBtn_cancel, &QPushButton::clicked, this, &SettingNum::do_pBtn_cancel);
+
+    connect(ui->comboBox_rowNum, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SettingNum::do_selectRowAndColumn);
+    connect(ui->comboBox_columnNum, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SettingNum::do_selectRowAndColumn);
+
+}
+
+SettingNum::~SettingNum()
+{
+    for(auto item : m_listItem)
+    {
+        if(item == nullptr)
+        {
+            continue;
+        }
+        delete item;
+        item = nullptr;
+    }
+    if(m_shadow != nullptr)
+    {
+        delete m_shadow;
+        m_shadow = nullptr;
+    }
+    delete ui;
+}
+
+/* 设置行数和列数 */
+void SettingNum::setRowAndColumn(int row, int column)
+{
+    ui->comboBox_rowNum->setCurrentIndex(row - 1);
+    ui->comboBox_columnNum->setCurrentIndex(column - 1);
+    /* 根据 行 x 列 总数计算需要显示的个数 */
+    int num = row * column;
+    for(int i = 0; i < 8; i++)
+    {
+        OneSettingItem *item = new OneSettingItem(ui->widget_list);
+        item->setNum(i + 1);
+        connect(item, &OneSettingItem::signal_select_channel, this, &SettingNum::do_selectChannel);
+        m_listItem.append(item);
+    }
+    /* 移动item的位置 */
+    layoutItem(num);
+}
+
+/* 设置每个项的信息 */
+void SettingNum::setEveryEyeMapInfo(const QList<OneEyeMapInfo> &listInfo)
+{
+    for(auto &item : m_listItem)
+    {
+        for(auto &info : listInfo)
+        {
+            if(item->getNum() == info.num)
+            {
+                item->setItemInfo(info);
+                break;
+            }
+        }
+    }
+}
+
+/* 设置可用的通道信息 */
+void SettingNum::setChannelList(const QList<OneChannelInfo> &listChannelInfo)
+{
+    for(auto &item : m_listItem)
+    {
+        item->setChannelList(listChannelInfo);
+    }
+}
+
+/* 绘制阴影 */
+void SettingNum::paintEvent(QPaintEvent *event)
+{
+    // QPainter painter(this);
+    // painter.setRenderHint(QPainter::Antialiasing);
+    // painter.drawImage(QPoint(0,0),m_shadow->image());
+}
+
+/* 事件过滤器 */
+bool SettingNum::eventFilter(QObject *watched, QEvent *event)
+{
+    if(watched == ui->comboBox_rowNum || watched == ui->comboBox_columnNum)
+    {
+        if(event->type() == QEvent::Wheel)
+        {
+            return true;
+        }
+    }
+    return QWidget::eventFilter(watched, event);
+}
+
+/* 关闭按钮槽函数 */
+void SettingNum::do_pBtn_close()
+{
+    this->close();
+}
+
+/* 点击了OK按钮 */
+void SettingNum::do_pBtn_ok()
+{
+    isOk = true;
+    row = ui->comboBox_rowNum->currentText().toInt();
+    column = ui->comboBox_columnNum->currentText().toInt();
+
+    /* 更新全局信息 */
+    for(auto &item : m_listItem)
+    {
+        GEyeMapInfo.updateSettingNum(item->getEyeMapInfo());
+    }
+
+    this->close();
+}
+
+/* 点击了取消按钮 */
+void SettingNum::do_pBtn_cancel()
+{
+    isOk = false;
+    this->close();
+}
+
+/* 选择行和列槽函数 */
+void SettingNum::do_selectRowAndColumn(int index)
+{
+    row = ui->comboBox_rowNum->currentText().toInt();
+    column = ui->comboBox_columnNum->currentText().toInt();
+    int num = row * column;
+    layoutItem(num);
+}
+
+/* 通道选择槽函数,选择了一个通道,取消其他项可能已经选择的相同通道 */
+void SettingNum::do_selectChannel(const OscChnNum channel, const QString &channelName)
+{
+    auto sender = qobject_cast<OneSettingItem*>(QObject::sender());
+    for(auto item : m_listItem)
+    {
+        if((item->getCurrentChannel().channel == channel) && (item != sender))
+        {
+            item->setCurrentChannel(GEyeMapInfo.getChannelName(OscChnNum::Osc_None));
+        }
+    }
+}
+
+
+/**
+ * @brief 布局item
+ * 
+ * @param num 需要显示的几个item
+ */
+void SettingNum::layoutItem(int num)
+{
+    for(auto item : m_listItem)
+    {
+        auto dy = (item->getNum() - 1) * 48;
+        item->move(0, dy);
+        if(item->getNum() > num)
+        {
+            item->hide();
+        } else
+        {
+            item->show();
+        }
+    }
+    
+}
+
+

+ 299 - 0
EyeMap/SettingNum/back/settingnum.cpp__

@@ -0,0 +1,299 @@
+#include "settingnum.h"
+#include "ui_settingnum.h"
+
+#include <QDebug>
+#include <QFile>
+#include <QPainter>
+#include <QVBoxLayout>
+#include <QHeaderView>
+
+#include "customcombobox.h"
+#include "onesettingitem.h"
+#include "oneshadow.h"
+
+SettingNum::SettingNum(QDialog *parent) :
+    QDialog(parent),
+    ui(new Ui::SettingNum)
+{
+    ui->setupUi(this);
+
+    m_logger = spdlog::get("EyeMap");
+    if(m_logger == nullptr)
+    {
+        qDebug() << "获取 EyeMap logger 失败";
+        return;
+    }
+    /* 注册事件过滤,主要是消除滚轮对comboBox的影响 */
+    ui->comboBox_rowNum->installEventFilter(this);
+    ui->comboBox_columnNum->installEventFilter(this);
+
+    /* 设置无边框和背景透明 */
+    this->setWindowFlags(Qt::FramelessWindowHint);
+    this->setAttribute(Qt::WA_TranslucentBackground);
+    /* 加载QSS */
+    QFile fileQss(":/qss/SettingNum/SettingNum.qss");
+    if(fileQss.open(QFile::ReadOnly))
+    {
+        QString qss = fileQss.readAll();
+        this->setStyleSheet(qss);
+        fileQss.close();
+    } else
+    {
+        SPDLOG_LOGGER_ERROR(m_logger, "加载QSS文件失败");
+    }
+    /* 设置阴影 */
+    m_shadow = new OneShadow(ui->widget->size(), 16);
+    ui->verticalLayout->setMargin(16);
+
+    /* 初始化变量 */
+    for(auto item : m_listItem)
+    {
+        item = nullptr;
+    }
+
+    // ui->pBtn_close->move(ui->widget_top->width() - 40, 13);
+
+    /* 设置下拉框可选个数 */
+    QStringList listRow;
+    listRow << "1" << "2" << "3" << "4";
+    ui->comboBox_rowNum->addItems(listRow);
+    ui->comboBox_columnNum->addItem("1");
+    ui->comboBox_columnNum->addItem("2");
+    ui->comboBox_rowNum->setCurrentIndex(1);
+    ui->comboBox_columnNum->setCurrentIndex(1);
+
+    /* 初始化表格列表 */
+    initTableList();
+
+
+    connect(ui->pBtn_close, &QPushButton::clicked, this, &SettingNum::do_pBtn_close);
+    connect(ui->pBtn_ok, &QPushButton::clicked, this, &SettingNum::do_pBtn_ok);
+    connect(ui->pBtn_cancel, &QPushButton::clicked, this, &SettingNum::do_pBtn_cancel);
+
+    connect(ui->comboBox_rowNum, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SettingNum::do_selectRowAndColumn);
+    connect(ui->comboBox_columnNum, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SettingNum::do_selectRowAndColumn);
+
+}
+
+SettingNum::~SettingNum()
+{
+    for(auto item : m_listItem)
+    {
+        if(item == nullptr)
+        {
+            continue;
+        }
+        delete item;
+        item = nullptr;
+    }
+    if(m_shadow != nullptr)
+    {
+        delete m_shadow;
+        m_shadow = nullptr;
+    }
+    delete ui;
+}
+
+/* 设置行数和列数 */
+void SettingNum::setRowAndColumn(int row, int column)
+{
+    ui->comboBox_rowNum->setCurrentIndex(row - 1);
+    ui->comboBox_columnNum->setCurrentIndex(column - 1);
+    /* 根据 行 x 列 总数计算需要显示的个数 */
+    int num = row * column;
+    // for(int i = 0; i < 8; i++)
+    // {
+    //     OneSettingItem *item = new OneSettingItem(ui->widget_list);
+    //     item->setNum(i + 1);
+    //     connect(item, &OneSettingItem::signal_select_channel, this, &SettingNum::do_selectChannel);
+    //     m_listItem.append(item);
+    // }
+    /* 移动item的位置 */
+    // layoutItem(num);
+}
+
+/* 设置每个项的信息 */
+void SettingNum::setEveryEyeMapInfo(const QList<OneEyeMapInfo> &listInfo)
+{
+    // for(auto &item : m_listItem)
+    // {
+    //     for(auto &info : listInfo)
+    //     {
+    //         if(item->getNum() == info.num)
+    //         {
+    //             item->setItemInfo(info);
+    //             break;
+    //         }
+    //     }
+    // }
+}
+
+/* 设置可用的通道信息 */
+void SettingNum::setChannelList(const QList<OneChannelInfo> &listChannelInfo)
+{
+    // for(auto &item : m_listItem)
+    // {
+    //     item->setChannelList(listChannelInfo);
+    // }
+}
+
+/* 绘制阴影 */
+// void SettingNum::paintEvent(QPaintEvent *event)
+// {
+//     // QPainter painter(this);
+//     // painter.setRenderHint(QPainter::Antialiasing);
+//     // painter.drawImage(QPoint(0,0),m_shadow->image());
+// }
+
+/* 事件过滤器 */
+bool SettingNum::eventFilter(QObject *watched, QEvent *event)
+{
+    if(watched == ui->comboBox_rowNum || watched == ui->comboBox_columnNum)
+    {
+        if(event->type() == QEvent::Wheel)
+        {
+            return true;
+        }
+    }
+    return QWidget::eventFilter(watched, event);
+}
+
+/* 关闭按钮槽函数 */
+void SettingNum::do_pBtn_close()
+{
+    this->close();
+}
+
+/* 点击了OK按钮 */
+void SettingNum::do_pBtn_ok()
+{
+    isOk = true;
+    row = ui->comboBox_rowNum->currentText().toInt();
+    column = ui->comboBox_columnNum->currentText().toInt();
+
+    /* 更新全局信息 */
+    for(auto &item : m_listItem)
+    {
+        GEyeMapInfo.updateSettingNum(item->getEyeMapInfo());
+    }
+
+    this->close();
+}
+
+/* 点击了取消按钮 */
+void SettingNum::do_pBtn_cancel()
+{
+    isOk = false;
+    this->close();
+}
+
+/* 选择行和列槽函数 */
+void SettingNum::do_selectRowAndColumn(int index)
+{
+    row = ui->comboBox_rowNum->currentText().toInt();
+    column = ui->comboBox_columnNum->currentText().toInt();
+    int num = row * column;
+    layoutItem(num);
+}
+
+/* 通道选择槽函数,选择了一个通道,取消其他项可能已经选择的相同通道 */
+void SettingNum::do_selectChannel(const OscChnNum channel, const QString &channelName)
+{
+    auto sender = qobject_cast<OneSettingItem*>(QObject::sender());
+    for(auto item : m_listItem)
+    {
+        if((item->getCurrentChannel().channel == channel) && (item != sender))
+        {
+            item->setCurrentChannel(GEyeMapInfo.getChannelName(OscChnNum::Osc_None));
+        }
+    }
+}
+
+
+/**
+ * @brief 布局item
+ * 
+ * @param num 需要显示的几个item
+ */
+void SettingNum::layoutItem(int num)
+{
+    for(auto item : m_listItem)
+    {
+        auto dy = (item->getNum() - 1) * 48;
+        item->move(0, dy);
+        if(item->getNum() > num)
+        {
+            item->hide();
+        } else
+        {
+            item->show();
+        }
+    }
+    
+}
+
+/* 初始化表格列表 */
+void SettingNum::initTableList()
+{
+    /* 设置一个布局 */
+    QVBoxLayout *layout = new QVBoxLayout(ui->widget_list);
+    layout->setMargin(0);
+    layout->setSpacing(0);
+    ui->widget_list->setLayout(layout);
+
+    /* 设置模型和视图 */
+    m_tableView = new QTableView(ui->widget_list);
+    m_model = new QStandardItemModel(this);
+    m_tableView->setModel(m_model);
+    layout->addWidget(m_tableView);
+
+    /****** 设置表格属性 ******/
+    /* 设置列数和标题 */
+    m_model->setColumnCount(4);
+    m_model->setHeaderData(0, Qt::Horizontal, "序号");
+    m_model->setHeaderData(1, Qt::Horizontal, "通道");
+    m_model->setHeaderData(2, Qt::Horizontal, "通道展示名称");
+    m_model->setHeaderData(3, Qt::Horizontal, "底色");
+
+    /* 设置标题栏属性 */
+    m_tableView->horizontalHeader()->setFixedHeight(48);
+    /* 禁止点击标题选择一列 */
+    m_tableView->horizontalHeader()->setSectionsClickable(false);
+    /* 设置标题栏文字间距等都在样式表中设置 */
+    m_tableView->horizontalHeader()->setDefaultAlignment(Qt::AlignVCenter | Qt::AlignLeft);
+    
+    /* 设置列宽,各减少1个像素点给分割线 */
+    m_tableView->setColumnWidth(0, 67);
+    m_tableView->setColumnWidth(1, 296);
+    m_tableView->setColumnWidth(2, 296);
+    m_tableView->setColumnWidth(3, 64);
+
+    /* 设置行高 */
+    m_tableView->verticalHeader()->setDefaultSectionSize(48);
+    /* 去掉列序号 */
+    m_tableView->verticalHeader()->hide();
+    /* 设置第一列内容文字左间距为12px */
+    // m_tableView->setStyleSheet("QTableView::item{padding-left: 12px;}");
+
+    /* 添加8列,展示效果用的 */
+    for(int i = 0; i < 8; i++)
+    {
+        m_model->setRowCount(i + 1);
+        m_model->setData(m_model->index(i, 0), i + 1);
+        m_model->setData(m_model->index(i, 1), "通道" + QString::number(i + 1));
+        m_model->setData(m_model->index(i, 2), "通道" + QString::number(i + 1));
+        m_model->setData(m_model->index(i, 3), QColor(255, 255, 255));
+    }
+    
+    /* 设置QCombobox */
+    m_tableView->setIndexWidget(m_model->index(0, 1), new CustomComboBox(m_tableView));
+    m_tableView->setIndexWidget(m_model->index(1, 1), new CustomComboBox(m_tableView));
+    m_tableView->setIndexWidget(m_model->index(2, 1), new CustomComboBox(m_tableView));
+    m_tableView->setIndexWidget(m_model->index(3, 1), new CustomComboBox(m_tableView));
+    // m_tableView->setItemDelegateForColumn(1, new CustomComboBoxDelegate(m_tableView));
+
+    
+
+}
+
+

+ 64 - 0
EyeMap/SettingNum/back/settingnum.h_

@@ -0,0 +1,64 @@
+#ifndef SETTINGNUM_H
+#define SETTINGNUM_H
+
+#include <QDialog>
+
+#include "spdlog/spdlog.h"
+#include "EyeMapInfo.h"
+
+class OneShadow;
+class OneSettingItem;
+
+namespace Ui {
+class SettingNum;
+}
+
+class SettingNum : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit SettingNum(QDialog *parent = nullptr);
+    ~SettingNum();
+
+    /* 设置行数和列数 */
+    void setRowAndColumn(int row, int column);
+    /* 设置每个项的信息 */
+    void setEveryEyeMapInfo(const QList<OneEyeMapInfo> &listInfo);
+    /* 设置可用的通道信息 */
+    void setChannelList(const QList<OneChannelInfo> &listChannelInfo);
+
+protected:
+    void paintEvent(QPaintEvent *event) override;
+    /* 事件过滤器 */
+    bool eventFilter(QObject *watched, QEvent *event) override;
+
+private slots:
+    /* 关闭按钮槽函数 */
+    void do_pBtn_close();
+    /* 点击了OK按钮 */
+    void do_pBtn_ok();
+    /* 点击了取消按钮 */
+    void do_pBtn_cancel();
+    /* 选择行和列槽函数 */
+    void do_selectRowAndColumn(int index);
+    /* 通道选择槽函数,选择了一个通道,取消其他项可能已经选择的相同通道 */
+    void do_selectChannel(const OscChnNum channel, const QString &channelName);
+
+private:
+    /* 布局item */
+    void layoutItem(int num);
+
+public:
+    int row = 0;            /* 行 */
+    int column = 0;         /* 列 */
+    bool isOk = false;      /* 是否点击了OK按钮 */
+private:
+    Ui::SettingNum *ui;
+    std::shared_ptr<spdlog::logger> m_logger = nullptr;
+    OneShadow *m_shadow = nullptr;
+
+    QList<OneSettingItem*> m_listItem;
+};
+
+#endif // SETTINGNUM_H

+ 72 - 0
EyeMap/SettingNum/back/settingnum.h__

@@ -0,0 +1,72 @@
+#ifndef SETTINGNUM_H
+#define SETTINGNUM_H
+
+#include <QDialog>
+
+#include "spdlog/spdlog.h"
+#include "EyeMapInfo.h"
+
+#include <QStandardItemModel>
+#include <QTableView>
+
+class OneShadow;
+class OneSettingItem;
+
+namespace Ui {
+class SettingNum;
+}
+
+class SettingNum : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit SettingNum(QDialog *parent = nullptr);
+    ~SettingNum();
+
+    /* 设置行数和列数 */
+    void setRowAndColumn(int row, int column);
+    /* 设置每个项的信息 */
+    void setEveryEyeMapInfo(const QList<OneEyeMapInfo> &listInfo);
+    /* 设置可用的通道信息 */
+    void setChannelList(const QList<OneChannelInfo> &listChannelInfo);
+
+protected:
+    // void paintEvent(QPaintEvent *event) override;
+    /* 事件过滤器 */
+    bool eventFilter(QObject *watched, QEvent *event) override;
+
+private slots:
+    /* 关闭按钮槽函数 */
+    void do_pBtn_close();
+    /* 点击了OK按钮 */
+    void do_pBtn_ok();
+    /* 点击了取消按钮 */
+    void do_pBtn_cancel();
+    /* 选择行和列槽函数 */
+    void do_selectRowAndColumn(int index);
+    /* 通道选择槽函数,选择了一个通道,取消其他项可能已经选择的相同通道 */
+    void do_selectChannel(const OscChnNum channel, const QString &channelName);
+
+private:
+    /* 布局item */
+    void layoutItem(int num);
+    /* 初始化表格列表 */
+    void initTableList();
+
+public:
+    int row = 0;            /* 行 */
+    int column = 0;         /* 列 */
+    bool isOk = false;      /* 是否点击了OK按钮 */
+private:
+    Ui::SettingNum *ui;
+    std::shared_ptr<spdlog::logger> m_logger = nullptr;
+    OneShadow *m_shadow = nullptr;
+
+    QList<OneSettingItem*> m_listItem;
+
+    QStandardItemModel *m_model = nullptr;
+    QTableView *m_tableView = nullptr;
+};
+
+#endif // SETTINGNUM_H

+ 267 - 0
EyeMap/SettingNum/back/settingnum.ui_

@@ -0,0 +1,267 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SettingNum</class>
+ <widget class="QDialog" name="SettingNum">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>810</width>
+    <height>705</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QWidget" name="widget" native="true">
+     <widget class="QWidget" name="widget_top" native="true">
+      <property name="geometry">
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>788</width>
+        <height>50</height>
+       </rect>
+      </property>
+      <widget class="QLabel" name="label_settingName">
+       <property name="geometry">
+        <rect>
+         <x>32</x>
+         <y>16</y>
+         <width>80</width>
+         <height>18</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>组屏配置</string>
+       </property>
+      </widget>
+      <widget class="QPushButton" name="pBtn_close">
+       <property name="geometry">
+        <rect>
+         <x>738</x>
+         <y>13</y>
+         <width>24</width>
+         <height>24</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+      </widget>
+     </widget>
+     <widget class="QLabel" name="label_x1">
+      <property name="geometry">
+       <rect>
+        <x>32</x>
+        <y>89</y>
+        <width>7</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>*</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_nc1">
+      <property name="geometry">
+       <rect>
+        <x>40</x>
+        <y>89</y>
+        <width>70</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>通道行数:</string>
+      </property>
+     </widget>
+     <widget class="CustomComboBox" name="comboBox_rowNum">
+      <property name="geometry">
+       <rect>
+        <x>110</x>
+        <y>80</y>
+        <width>82</width>
+        <height>32</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_nc2">
+      <property name="geometry">
+       <rect>
+        <x>240</x>
+        <y>89</y>
+        <width>70</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>通道列数:</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_x2">
+      <property name="geometry">
+       <rect>
+        <x>232</x>
+        <y>89</y>
+        <width>7</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>*</string>
+      </property>
+     </widget>
+     <widget class="CustomComboBox" name="comboBox_columnNum">
+      <property name="geometry">
+       <rect>
+        <x>310</x>
+        <y>80</y>
+        <width>82</width>
+        <height>32</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_line1">
+      <property name="geometry">
+       <rect>
+        <x>32</x>
+        <y>142</y>
+        <width>724</width>
+        <height>1</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string/>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_line2">
+      <property name="geometry">
+       <rect>
+        <x>32</x>
+        <y>190</y>
+        <width>724</width>
+        <height>1</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string/>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_nc3">
+      <property name="geometry">
+       <rect>
+        <x>44</x>
+        <y>160</y>
+        <width>40</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>序号</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_nc4">
+      <property name="geometry">
+       <rect>
+        <x>100</x>
+        <y>160</y>
+        <width>40</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>通道</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_nc5">
+      <property name="geometry">
+       <rect>
+        <x>396</x>
+        <y>160</y>
+        <width>280</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>通道展示名称</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_nc6">
+      <property name="geometry">
+       <rect>
+        <x>692</x>
+        <y>160</y>
+        <width>40</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>底色</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_line3">
+      <property name="geometry">
+       <rect>
+        <x>32</x>
+        <y>575</y>
+        <width>724</width>
+        <height>1</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string/>
+      </property>
+     </widget>
+     <widget class="QWidget" name="widget_list" native="true">
+      <property name="geometry">
+       <rect>
+        <x>32</x>
+        <y>191</y>
+        <width>724</width>
+        <height>384</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="pBtn_ok">
+      <property name="geometry">
+       <rect>
+        <x>560</x>
+        <y>606</y>
+        <width>90</width>
+        <height>40</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>保存</string>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="pBtn_cancel">
+      <property name="geometry">
+       <rect>
+        <x>666</x>
+        <y>606</y>
+        <width>90</width>
+        <height>40</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>取消</string>
+      </property>
+     </widget>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>CustomComboBox</class>
+   <extends>QComboBox</extends>
+   <header location="global">customcombobox.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>

+ 176 - 0
EyeMap/SettingNum/back/settingnum.ui__

@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SettingNum</class>
+ <widget class="QDialog" name="SettingNum">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>810</width>
+    <height>705</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QWidget" name="widget" native="true">
+     <widget class="QWidget" name="widget_top" native="true">
+      <property name="geometry">
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>788</width>
+        <height>50</height>
+       </rect>
+      </property>
+      <widget class="QLabel" name="label_settingName">
+       <property name="geometry">
+        <rect>
+         <x>32</x>
+         <y>16</y>
+         <width>80</width>
+         <height>18</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>组屏配置</string>
+       </property>
+      </widget>
+      <widget class="QPushButton" name="pBtn_close">
+       <property name="geometry">
+        <rect>
+         <x>738</x>
+         <y>13</y>
+         <width>24</width>
+         <height>24</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string/>
+       </property>
+      </widget>
+     </widget>
+     <widget class="QLabel" name="label_x1">
+      <property name="geometry">
+       <rect>
+        <x>32</x>
+        <y>89</y>
+        <width>7</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>*</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_nc1">
+      <property name="geometry">
+       <rect>
+        <x>40</x>
+        <y>89</y>
+        <width>70</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>通道行数:</string>
+      </property>
+     </widget>
+     <widget class="CustomComboBox" name="comboBox_rowNum">
+      <property name="geometry">
+       <rect>
+        <x>110</x>
+        <y>80</y>
+        <width>82</width>
+        <height>32</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_nc2">
+      <property name="geometry">
+       <rect>
+        <x>240</x>
+        <y>89</y>
+        <width>70</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>通道列数:</string>
+      </property>
+     </widget>
+     <widget class="QLabel" name="label_x2">
+      <property name="geometry">
+       <rect>
+        <x>232</x>
+        <y>89</y>
+        <width>7</width>
+        <height>14</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>*</string>
+      </property>
+     </widget>
+     <widget class="CustomComboBox" name="comboBox_columnNum">
+      <property name="geometry">
+       <rect>
+        <x>310</x>
+        <y>80</y>
+        <width>82</width>
+        <height>32</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QWidget" name="widget_list" native="true">
+      <property name="geometry">
+       <rect>
+        <x>32</x>
+        <y>143</y>
+        <width>724</width>
+        <height>432</height>
+       </rect>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="pBtn_ok">
+      <property name="geometry">
+       <rect>
+        <x>560</x>
+        <y>606</y>
+        <width>90</width>
+        <height>40</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>保存</string>
+      </property>
+     </widget>
+     <widget class="QPushButton" name="pBtn_cancel">
+      <property name="geometry">
+       <rect>
+        <x>666</x>
+        <y>606</y>
+        <width>90</width>
+        <height>40</height>
+       </rect>
+      </property>
+      <property name="text">
+       <string>取消</string>
+      </property>
+     </widget>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>CustomComboBox</class>
+   <extends>QComboBox</extends>
+   <header location="global">customcombobox.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>

+ 130 - 17
EyeMap/SettingNum/settingnum.cpp

@@ -8,6 +8,7 @@
 #include "customcombobox.h"
 #include "onesettingitem.h"
 #include "oneshadow.h"
+#include "ListItem.h"
 
 SettingNum::SettingNum(QDialog *parent) :
     QDialog(parent),
@@ -43,6 +44,15 @@ SettingNum::SettingNum(QDialog *parent) :
     m_shadow = new OneShadow(ui->widget->size(), 16);
     ui->verticalLayout->setMargin(16);
 
+    /* 设置QListWidget拖拽 */
+    ui->listWidget->setDragDropMode(QAbstractItemView::InternalMove);
+    ui->listWidget->setDragEnabled(true);
+    ui->listWidget->setDropIndicatorShown(true);
+    ui->listWidget->setAcceptDrops(true);
+    ui->listWidget->setSelectionMode(QAbstractItemView::SingleSelection);
+    /* 注册事件过滤器,拦截拖拽事件 */
+    // ui->listWidget->installEventFilter(this);
+
     /* 初始化变量 */
     for(auto item : m_listItem)
     {
@@ -68,6 +78,8 @@ SettingNum::SettingNum(QDialog *parent) :
     connect(ui->comboBox_rowNum, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SettingNum::do_selectRowAndColumn);
     connect(ui->comboBox_columnNum, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SettingNum::do_selectRowAndColumn);
 
+    connect(this, &SettingNum::signal_exec, this, &SettingNum::do_layoutItem);
+    connect(ui->listWidget, &ListItem::signal_dropComplete, this, &SettingNum::do_setItemNum);
 }
 
 SettingNum::~SettingNum()
@@ -95,16 +107,27 @@ void SettingNum::setRowAndColumn(int row, int column)
     ui->comboBox_rowNum->setCurrentIndex(row - 1);
     ui->comboBox_columnNum->setCurrentIndex(column - 1);
     /* 根据 行 x 列 总数计算需要显示的个数 */
+    m_row = row;
+    m_column = column;
     int num = row * column;
-    for(int i = 0; i < 8; i++)
+    ui->listWidget->clear();
+    m_listItem.clear();
+    
+    for(int i = 0; i < num; i++)
     {
-        OneSettingItem *item = new OneSettingItem(ui->widget_list);
+        OneSettingItem *item = new OneSettingItem(ui->listWidget);
         item->setNum(i + 1);
         connect(item, &OneSettingItem::signal_select_channel, this, &SettingNum::do_selectChannel);
         m_listItem.append(item);
+        /* 创建QListWidget的项和项高度 */
+        QListWidgetItem *listWidgetItem = new QListWidgetItem(ui->listWidget);
+        listWidgetItem->setSizeHint(QSize(0, 48));
+        ui->listWidget->setItemWidget(listWidgetItem, item);
     }
+
     /* 移动item的位置 */
-    layoutItem(num);
+    // layoutItem(num);
+
 }
 
 /* 设置每个项的信息 */
@@ -130,16 +153,16 @@ void SettingNum::setChannelList(const QList<OneChannelInfo> &listChannelInfo)
     {
         item->setChannelList(listChannelInfo);
     }
+    m_listChannelInfo = listChannelInfo;
 }
 
-/* 绘制阴影 */
-void SettingNum::paintEvent(QPaintEvent *event)
+/* 刷新布局 */
+void SettingNum::refreshLayout()
 {
-    // QPainter painter(this);
-    // painter.setRenderHint(QPainter::Antialiasing);
-    // painter.drawImage(QPoint(0,0),m_shadow->image());
+    layoutItem(m_row * m_column);
 }
 
+
 /* 事件过滤器 */
 bool SettingNum::eventFilter(QObject *watched, QEvent *event)
 {
@@ -150,9 +173,46 @@ bool SettingNum::eventFilter(QObject *watched, QEvent *event)
             return true;
         }
     }
+    // if(watched == ui->listWidget)
+    // {
+    //     SPDLOG_LOGGER_DEBUG(m_logger, "ui->listWidget事件");
+    //     if(event->type() == QEvent::DragEnter)
+    //     {
+    //         QDragEnterEvent *dragEnterEvent = static_cast<QDragEnterEvent*>(event);
+    //         dragEnterEvent->acceptProposedAction();
+    //         emit signal_dragComplete();
+    //         SPDLOG_LOGGER_DEBUG(m_logger, "拖拽进入");
+    //         return true;
+    //     }
+    //     else if(event->type() == QEvent::Drop)
+    //     {
+    //         QDropEvent *dropEvent = static_cast<QDropEvent*>(event);
+    //         dropEvent->acceptProposedAction();
+    //         SPDLOG_LOGGER_DEBUG(m_logger, "拖拽完成");
+    //         return true;
+    //     }
+    //     else if (event->type() == QEvent::DragMove)
+    //     {
+    //         QDragMoveEvent *dragMoveEvent = static_cast<QDragMoveEvent*>(event);
+    //         dragMoveEvent->accept();
+    //         SPDLOG_LOGGER_DEBUG(m_logger, "拖拽移动");
+    //         return true;
+        
+    //     }else {
+    //         qDebug() << "其他事件:" << event->type();
+    //     }
+    // }
     return QWidget::eventFilter(watched, event);
 }
 
+/* 显示事件 */
+void SettingNum::showEvent(QShowEvent *event)
+{
+    QDialog::showEvent(event);
+    /* 在这个页面显示出来后再设置一次项隐藏才可以 */
+    emit signal_exec();
+}
+
 /* 关闭按钮槽函数 */
 void SettingNum::do_pBtn_close()
 {
@@ -163,8 +223,8 @@ void SettingNum::do_pBtn_close()
 void SettingNum::do_pBtn_ok()
 {
     isOk = true;
-    row = ui->comboBox_rowNum->currentText().toInt();
-    column = ui->comboBox_columnNum->currentText().toInt();
+    m_row = ui->comboBox_rowNum->currentText().toInt();
+    m_column = ui->comboBox_columnNum->currentText().toInt();
 
     /* 更新全局信息 */
     for(auto &item : m_listItem)
@@ -185,10 +245,11 @@ void SettingNum::do_pBtn_cancel()
 /* 选择行和列槽函数 */
 void SettingNum::do_selectRowAndColumn(int index)
 {
-    row = ui->comboBox_rowNum->currentText().toInt();
-    column = ui->comboBox_columnNum->currentText().toInt();
-    int num = row * column;
-    layoutItem(num);
+    m_row = ui->comboBox_rowNum->currentText().toInt();
+    m_column = ui->comboBox_columnNum->currentText().toInt();
+    int num = m_row * m_column;
+    // layoutItem(num);
+    addOrDelItem(num);
 }
 
 /* 通道选择槽函数,选择了一个通道,取消其他项可能已经选择的相同通道 */
@@ -204,6 +265,19 @@ void SettingNum::do_selectChannel(const OscChnNum channel, const QString &channe
     }
 }
 
+/* 刷新listWidget */
+void SettingNum::do_layoutItem()
+{
+    layoutItem(m_row * m_column);
+}
+
+/* 重新设置序号并刷新显示 */
+void SettingNum::do_setItemNum()
+{
+    // SPDLOG_LOGGER_DEBUG(m_logger, "重新设置序号");
+    resetItemNum();
+}
+
 
 /**
  * @brief 布局item
@@ -214,8 +288,8 @@ void SettingNum::layoutItem(int num)
 {
     for(auto item : m_listItem)
     {
-        auto dy = (item->getNum() - 1) * 48;
-        item->move(0, dy);
+        // auto dy = (item->getNum() - 1) * 48;
+        // item->move(0, dy);
         if(item->getNum() > num)
         {
             item->hide();
@@ -224,7 +298,46 @@ void SettingNum::layoutItem(int num)
             item->show();
         }
     }
-    
 }
 
+/* 重新设置Item序号 */
+void SettingNum::resetItemNum()
+{
+    for(int i = 0; i < ui->listWidget->count(); i++)
+    {
+        auto item = qobject_cast<OneSettingItem*>(ui->listWidget->itemWidget(ui->listWidget->item(i)));
+        item->setNum(i + 1);
+    }
+}
+
+/* 添加或删除项 */
+void SettingNum::addOrDelItem(int num)
+{
+    if(num > m_listItem.size())
+    {
+        for(int i = m_listItem.size(); i < num; i++)
+        {
+            OneSettingItem *item = new OneSettingItem(ui->listWidget);
+            item->setNum(i + 1);
+            /* 设置可选通道列表 */
+            item->setChannelList(m_listChannelInfo);
+            /* 设置默认选项 */
+            item->setItemInfo(GEyeMapInfo.getInitEyeMapInfo(i + 1));
+            connect(item, &OneSettingItem::signal_select_channel, this, &SettingNum::do_selectChannel);
+            m_listItem.append(item);
+            /* 创建QListWidget的项和项高度 */
+            QListWidgetItem *listWidgetItem = new QListWidgetItem(ui->listWidget);
+            listWidgetItem->setSizeHint(QSize(0, 48));
+            ui->listWidget->setItemWidget(listWidgetItem, item);
+        }
+    } else
+    {
+        for(int i = m_listItem.size() - 1; i >= num; i--)
+        {
+            delete m_listItem.at(i);
+            m_listItem.removeAt(i);
+            ui->listWidget->takeItem(i);
+        }
+    }
+}
 

+ 19 - 3
EyeMap/SettingNum/settingnum.h

@@ -27,11 +27,18 @@ public:
     void setEveryEyeMapInfo(const QList<OneEyeMapInfo> &listInfo);
     /* 设置可用的通道信息 */
     void setChannelList(const QList<OneChannelInfo> &listChannelInfo);
+    /* 刷新布局 */
+    void refreshLayout();
+
+signals:
+    /* 执行了exec信号 */
+    void signal_exec();
 
 protected:
-    void paintEvent(QPaintEvent *event) override;
     /* 事件过滤器 */
     bool eventFilter(QObject *watched, QEvent *event) override;
+    /* 显示事件 */
+    void showEvent(QShowEvent *event) override;    
 
 private slots:
     /* 关闭按钮槽函数 */
@@ -44,14 +51,22 @@ private slots:
     void do_selectRowAndColumn(int index);
     /* 通道选择槽函数,选择了一个通道,取消其他项可能已经选择的相同通道 */
     void do_selectChannel(const OscChnNum channel, const QString &channelName);
+    /* 刷新listWidget */
+    void do_layoutItem();
+    /* 重新设置序号并刷新显示 */
+    void do_setItemNum();
 
 private:
     /* 布局item */
     void layoutItem(int num);
+    /* 重新设置Item序号 */
+    void resetItemNum();
+    /* 添加或删除项 */
+    void addOrDelItem(int num);
 
 public:
-    int row = 0;            /* 行 */
-    int column = 0;         /* 列 */
+    int m_row = 0;          /* 行 */
+    int m_column = 0;       /* 列 */
     bool isOk = false;      /* 是否点击了OK按钮 */
 private:
     Ui::SettingNum *ui;
@@ -59,6 +74,7 @@ private:
     OneShadow *m_shadow = nullptr;
 
     QList<OneSettingItem*> m_listItem;
+    QList<OneChannelInfo> m_listChannelInfo;    /* 可用的通道信息 */
 };
 
 #endif // SETTINGNUM_H

+ 15 - 10
EyeMap/SettingNum/settingnum.ui

@@ -215,16 +215,6 @@
        <string/>
       </property>
      </widget>
-     <widget class="QWidget" name="widget_list" native="true">
-      <property name="geometry">
-       <rect>
-        <x>32</x>
-        <y>191</y>
-        <width>724</width>
-        <height>384</height>
-       </rect>
-      </property>
-     </widget>
      <widget class="QPushButton" name="pBtn_ok">
       <property name="geometry">
        <rect>
@@ -251,6 +241,16 @@
        <string>取消</string>
       </property>
      </widget>
+     <widget class="ListItem" name="listWidget">
+      <property name="geometry">
+       <rect>
+        <x>32</x>
+        <y>191</y>
+        <width>724</width>
+        <height>384</height>
+       </rect>
+      </property>
+     </widget>
     </widget>
    </item>
   </layout>
@@ -261,6 +261,11 @@
    <extends>QComboBox</extends>
    <header location="global">customcombobox.h</header>
   </customwidget>
+  <customwidget>
+   <class>ListItem</class>
+   <extends>QListWidget</extends>
+   <header location="global">listitem.h</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>