123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #include "AlgorithmManageView.h"
- #include <QLabel>
- #include <QBoxLayout>
- #include <QListWidget>
- #include <QStringList>
- AlgorithmManageView::AlgorithmManageView(QWidget *parent) : QWidget(parent)
- {
- initWidgets();
- initLayouts();
- m_algList = { SchemePlanManager::PrincipalComponents,
- SchemePlanManager::Entropy,
- SchemePlanManager::AHP,
- SchemePlanManager::HWM,
- SchemePlanManager::SPA,
- SchemePlanManager::MEA,
- SchemePlanManager::GCE,
- SchemePlanManager::WeightedSum };
- showAlgs();
- }
- /*
- QVBoxLayout *m_vBoxLayout = nullptr;
- QLabel *m_titleLabel = nullptr;
- QHBoxLayout *m_hBoxLayout = nullptr;
- QListWidget *m_listWidget = nullptr;
- */
- void AlgorithmManageView::initWidgets()
- {
- m_titleLabel = new QLabel(this);
- m_titleLabel->setText("算法列表");
- QFont ft("Microsoft YaHei", 12);
- m_titleLabel->setFont(ft);
- m_listWidget = new QListWidget(this);
- m_listWidget->setAlternatingRowColors(true);
- m_listWidget->setStyleSheet("QListWidget {border: 1px solid rgba(0, 0, 0, 0.073);background: rgb(255, 255, "
- "255);alternate-background-color: rgb(244, 244, 255);}");
- }
- void AlgorithmManageView::initLayouts()
- {
- m_layout = new QVBoxLayout(this);
- m_layout->setMargin(20);
- m_topLayout = new QHBoxLayout();
- m_layout->addLayout(m_topLayout);
- m_layout->addWidget(m_listWidget);
- m_topLayout->addWidget(m_titleLabel);
- }
- void AlgorithmManageView::showAlgs()
- {
- m_listWidget->clear();
- for (int i = 0; i < m_algList.count(); i++) {
- QListWidgetItem *item = new QListWidgetItem;
- item->setSizeHint(QSize(200, 60));
- m_listWidget->addItem(item);
- QWidget *w = new QWidget();
- m_listWidget->setItemWidget(item, w);
- QHBoxLayout *hBox = new QHBoxLayout(w);
- hBox->setSpacing(0);
- hBox->setMargin(10);
- QLabel *idx = new QLabel(QString::number(i + 1));
- idx->setFixedWidth(20);
- hBox->addWidget(idx);
- hBox->addSpacing(10);
- SchemePlanManager::Algorithm alg = m_algList[i];
- QString algStr = SchemePlanManager::nameOfAlgorithm(alg);
- QLabel *name = new QLabel(algStr);
- hBox->addWidget(name);
- hBox->addStretch();
- }
- }
|