|
@@ -1,6 +1,7 @@
|
|
|
#include "ConfigMeasureDataWidget.h"
|
|
|
|
|
|
#include "ProjectManager.h"
|
|
|
+#include "common/QFDIcon.h"
|
|
|
|
|
|
#include "dbService/SchemeInfoService.h"
|
|
|
#include "dbService/NodeMatrixService.h"
|
|
@@ -73,12 +74,12 @@ void ConfigMeasureDataWidget::selectLast()
|
|
|
|
|
|
QList<NodeMatrixInfo *> ConfigMeasureDataWidget::selectedData()
|
|
|
{
|
|
|
- if (m_uuidList.size() <= 0) {
|
|
|
+ int row = m_listWidget->currentRow();
|
|
|
+ if (m_uuidList.size() <= 0 || row < 0 || row >= m_uuidList.size()) {
|
|
|
QList<NodeMatrixInfo *> list;
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- int row = m_listWidget->currentRow();
|
|
|
return m_nodeData[m_uuidList[row]];
|
|
|
}
|
|
|
|
|
@@ -152,9 +153,24 @@ void ConfigMeasureDataWidget::refreshList()
|
|
|
m_listWidget->clear();
|
|
|
|
|
|
for (int i = 0; i < m_uuidList.size(); i++) {
|
|
|
+ QLabel *title = new QLabel;
|
|
|
+ title->setText(QString("数据%1").arg(i + 1));
|
|
|
+
|
|
|
+ QPushButton *remove = new QPushButton(NEWFLICON(QFDIcon, Minus)->icon(), "", this);
|
|
|
+ remove->setFixedSize(QSize(25, 25));
|
|
|
+ remove->setIconSize(QSize(10, 10));
|
|
|
+ remove->setToolTip("删除数据");
|
|
|
+ connect(remove, &QPushButton::clicked, [this, i](int) { slotRemoveDataClicked(i); });
|
|
|
+
|
|
|
+ QWidget *w = new QWidget;
|
|
|
+ QHBoxLayout *lay = new QHBoxLayout(w);
|
|
|
+ lay->addWidget(title);
|
|
|
+ lay->addStretch();
|
|
|
+ lay->addWidget(remove);
|
|
|
+
|
|
|
QListWidgetItem *item = new QListWidgetItem;
|
|
|
- item->setText(QString("数据%1").arg(i + 1));
|
|
|
m_listWidget->addItem(item);
|
|
|
+ m_listWidget->setItemWidget(item, w);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -183,6 +199,22 @@ void ConfigMeasureDataWidget::slotAddDataClicked()
|
|
|
emit sigAddData();
|
|
|
}
|
|
|
|
|
|
+void ConfigMeasureDataWidget::slotRemoveDataClicked(int index)
|
|
|
+{
|
|
|
+ QString indexName = ProjectManager::nameOfIndexType((ProjectManager::IndexType)m_process.indexType);
|
|
|
+ QString uuid = m_uuidList[index];
|
|
|
+ bool ret = NodeMatrixService().deleteMeasureData(m_process.projectId, indexName, uuid);
|
|
|
+ if (ret) {
|
|
|
+ m_uuidList.removeOne(uuid);
|
|
|
+ m_nodeData.remove(uuid);
|
|
|
+ refreshList();
|
|
|
+
|
|
|
+ if (m_uuidList.size() > 0) {
|
|
|
+ selectFirst();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void ConfigMeasureDataWidget::slotCurrentRowChanged()
|
|
|
{
|
|
|
emit sigCurrentRowChanged();
|