123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- #include "ConfigSchemeDataWidget.h"
- #include "ProjectManager.h"
- #include <dbService/SchemeInfoService.h>
- #include <Widgets/Button.h>
- #include <Common/Icon.h>
- #include <QLabel>
- #include <QListWidget>
- #include <QBoxLayout>
- #include <QImageReader>
- #include <QDebug>
- ConfigSchemeDataWidget::ConfigSchemeDataWidget(QWidget *parent) : QWidget(parent)
- {
- initWidget();
- initLayout();
- connectSignalsAndSlots();
- }
- void ConfigSchemeDataWidget::setProcess(SchemePlanManager::SchemeProcessInfo process)
- {
- m_process = process;
- loadData();
- }
- void ConfigSchemeDataWidget::loadData()
- {
- m_schemeList.clear();
- m_pic->clear();
- if (m_process.type == SchemePlanManager::ImportEvalData) {
- if (m_process.indexType == ProjectManager::EfficiencyIndex) {
- SchemeInfoService().QuerySchemeInfoByEngineerId(&m_schemeList, m_process.projectId, 1);
- }
- if (m_process.indexType == ProjectManager::OptimalIndex) {
- SchemeInfoService().QuerySchemeInfoByEngineerId(&m_schemeList, m_process.projectId, 0);
- }
- }
- refreshList();
- }
- QList<SchemaEval *> ConfigSchemeDataWidget::schemeList() const
- {
- return m_schemeList;
- }
- void ConfigSchemeDataWidget::initWidget()
- {
- m_titleLabel = new QLabel("添加方案数据", this);
- m_titleLabel->setObjectName("titleLabel");
- m_titleLabel->setFixedHeight(50);
- m_titleLabel->setContentsMargins(10, 0, 0, 0);
- m_listTitleLabel = new QLabel("方案列表", this);
- m_listTitleLabel->setObjectName("listTitleLabel");
- m_tipsLabel = new QLabel("已导入的数据将会显示在这里", this);
- m_tipsLabel->setObjectName("tipsLabel");
- m_tipsLabel->setHidden(true);
- m_addButton = new QPushButton(NEWFLICON(FluentIcon, ADD)->icon(), "", this);
- m_addButton->setToolTip("添加方案");
- m_listWidget = new QListWidget(this);
- m_pic = new QLabel(this);
- m_pic->setFixedHeight(160);
- setStyleSheet("#titleLabel {color:#333333; font-size:16px}"
- "#listTitleLabel {color:#333333; font-size:12px}"
- "QPushButton {border: 0;background-color: qlineargradient(x1: 0, y1: 0, x2: "
- "0, y2: 1,stop: 0 #f8f8f8, stop: 1 #f8f8f8);}"
- "QPushButton::hover {border: 1px solid rgba(0, 0, 0, 0.073);}"
- "QPushButton::pressed {background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #dadbde, "
- "stop: 1 #f6f7fa);}"
- "QListWidget {border: 1px solid rgba(0, 0, 0, 0.073);}"
- "QListView::item {height:44;}");
- }
- void ConfigSchemeDataWidget::initLayout()
- {
- m_layout = new QVBoxLayout(this);
- m_layout->setMargin(0);
- m_layout->setSpacing(0);
- m_layout->addWidget(m_titleLabel);
- m_headerLayout = new QHBoxLayout();
- m_layout->addLayout(m_headerLayout);
- m_layout->addSpacing(10);
- m_layout->addWidget(m_tipsLabel);
- m_layout->addWidget(m_listWidget);
- m_layout->addWidget(m_pic);
- m_headerLayout->addWidget(m_listTitleLabel);
- m_headerLayout->addStretch();
- m_headerLayout->addWidget(m_addButton);
- }
- void ConfigSchemeDataWidget::connectSignalsAndSlots()
- {
- connect(m_addButton, &PushButton::clicked, this, &ConfigSchemeDataWidget::slotAddDataClicked);
- connect(m_listWidget, &QListWidget::currentRowChanged, this, &ConfigSchemeDataWidget::slotSelectedChanged);
- }
- void ConfigSchemeDataWidget::refreshList()
- {
- m_listWidget->clear();
- for (SchemaEval *eval : m_schemeList) {
- QListWidgetItem *item = new QListWidgetItem(eval->name);
- m_listWidget->addItem(item);
- }
- }
- void ConfigSchemeDataWidget::slotAddDataClicked()
- {
- qDebug() << __FUNCTION__ << __LINE__ << endl;
- emit sigAddScheme();
- }
- void ConfigSchemeDataWidget::slotSelectedChanged(int row)
- {
- if (m_schemeList.size() <= row || row < 0) {
- return;
- }
- SchemaEval *scheme = m_schemeList[row];
- QImage image = QImage(scheme->filePath);
- m_pic->setPixmap(QPixmap::fromImage(image));
- }
|