|
@@ -1,5 +1,9 @@
|
|
|
#include "ProjectListWidget.h"
|
|
|
|
|
|
+#include "QFDIcon.h"
|
|
|
+#include "ProjectManager.h"
|
|
|
+#include "dbService/ClassSet.h"
|
|
|
+
|
|
|
#include <Widgets/LineEdit.h>
|
|
|
#include <Widgets/Button.h>
|
|
|
#include <Widgets/TreeView.h>
|
|
@@ -7,45 +11,136 @@
|
|
|
#include <QBoxLayout>
|
|
|
#include <QListWidget>
|
|
|
#include <QLabel>
|
|
|
+#include <QDateTime>
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
-ProjectListWidget::ProjectListWidget(QWidget *parent) : QWidget(parent)
|
|
|
+ProjectListItemWidget::ProjectListItemWidget(QWidget *parent) : QWidget(parent)
|
|
|
{
|
|
|
- initialize();
|
|
|
+ initWidgets();
|
|
|
initLayout();
|
|
|
- connectSiganlsAndSlots();
|
|
|
- refreshList();
|
|
|
}
|
|
|
|
|
|
-void ProjectListWidget::refreshList()
|
|
|
+void ProjectListItemWidget::initWidgets()
|
|
|
+{
|
|
|
+ m_name = new QLabel(this);
|
|
|
+ m_name->setObjectName("name");
|
|
|
+ m_time = new QLabel(this);
|
|
|
+ m_time->setObjectName("time");
|
|
|
+ m_taskLabel = new QLabel(this);
|
|
|
+ m_taskLabel->setObjectName("taskLabel");
|
|
|
+ m_taskLabel->setText("任务名称:");
|
|
|
+ m_task = new QLabel(this);
|
|
|
+ m_task->setObjectName("task");
|
|
|
+ m_typeLabel = new QLabel(this);
|
|
|
+ m_typeLabel->setObjectName("typeLabel");
|
|
|
+ m_typeLabel->setText("评估类型:");
|
|
|
+ m_type = new QLabel(this);
|
|
|
+ m_type->setObjectName("type");
|
|
|
+ m_open = new PushButton("打开", NEWFLICON(QFDIcon, Open), this);
|
|
|
+ m_open->setObjectName("open");
|
|
|
+ m_edit = new PushButton("编辑", NEWFLICON(FluentIcon, EDIT), this);
|
|
|
+ m_edit->setObjectName("edit");
|
|
|
+
|
|
|
+ setStyleSheet("#name {color:#1196db; font-size:15px; font:bold}"
|
|
|
+ "#time {color:gray}"
|
|
|
+ "#taskLabel {color: gray;}"
|
|
|
+ "#task {color: gray;}"
|
|
|
+ "#typeLabel {color: gray;}"
|
|
|
+ "#type {color: gray;}");
|
|
|
+}
|
|
|
+
|
|
|
+void ProjectListItemWidget::initLayout()
|
|
|
+{
|
|
|
+ // 总体布局
|
|
|
+ m_layout = new QVBoxLayout(this);
|
|
|
+ m_layout->setMargin(10);
|
|
|
+
|
|
|
+ m_nameLayout = new QHBoxLayout();
|
|
|
+ m_layout->addLayout(m_nameLayout);
|
|
|
+ m_layout->addSpacing(5);
|
|
|
+
|
|
|
+ m_taskLayout = new QHBoxLayout();
|
|
|
+ m_layout->addLayout(m_taskLayout);
|
|
|
+
|
|
|
+ m_typeLayout = new QHBoxLayout();
|
|
|
+ m_layout->addLayout(m_typeLayout);
|
|
|
+
|
|
|
+ m_buttonLayout = new QHBoxLayout();
|
|
|
+ m_layout->addLayout(m_buttonLayout);
|
|
|
+
|
|
|
+ // 名称
|
|
|
+ m_nameLayout->addWidget(m_name);
|
|
|
+ m_nameLayout->addStretch();
|
|
|
+ m_nameLayout->addWidget(m_time);
|
|
|
+
|
|
|
+ // 任务
|
|
|
+ m_taskLayout->setContentsMargins(10, 0, 10, 0);
|
|
|
+ m_taskLayout->addWidget(m_taskLabel);
|
|
|
+ m_taskLayout->addSpacing(5);
|
|
|
+ m_taskLayout->addWidget(m_task);
|
|
|
+ m_taskLayout->addStretch();
|
|
|
+
|
|
|
+ // 类型
|
|
|
+ m_typeLayout->setContentsMargins(10, 0, 10, 0);
|
|
|
+ m_typeLayout->addWidget(m_typeLabel);
|
|
|
+ m_typeLayout->addSpacing(5);
|
|
|
+ m_typeLayout->addWidget(m_type);
|
|
|
+ m_typeLayout->addStretch();
|
|
|
+
|
|
|
+ // 按钮
|
|
|
+ m_buttonLayout->addStretch();
|
|
|
+ m_buttonLayout->addWidget(m_open);
|
|
|
+ m_buttonLayout->addWidget(m_edit);
|
|
|
+}
|
|
|
+
|
|
|
+void ProjectListItemWidget::setData(ProjectInfo *info)
|
|
|
{
|
|
|
+ m_info = info;
|
|
|
+ if (info == nullptr) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ m_name->setText(info->projectName);
|
|
|
+
|
|
|
+ QDateTime t = QDateTime::fromTime_t(info->estimateTime.toUInt());
|
|
|
+ m_time->setText(t.toString("yyyy-M-d"));
|
|
|
|
|
|
- for (int i = 1; i <= 20; i++) {
|
|
|
- QTreeWidgetItem *item1 = new QTreeWidgetItem({ QString("工程%1").arg(i) });
|
|
|
- m_treeWidget->addTopLevelItem(item1);
|
|
|
- item1->addChildren({ new QTreeWidgetItem({ "能力需求评估" }), new QTreeWidgetItem({ "技术措施评估" }),
|
|
|
- new QTreeWidgetItem({ "技术方案评估" }) });
|
|
|
+ m_task->setText(info->taskName);
|
|
|
+
|
|
|
+ QString tStr;
|
|
|
+ QList<ProjectManager::EvalType> types = ProjectManager::evalTypeList(*info);
|
|
|
+ for (int i = 0; i < types.count(); i++) {
|
|
|
+ tStr += ProjectManager::nameOfEvalType(types[i]);
|
|
|
+ if (i < types.count() - 1) {
|
|
|
+ tStr += "、";
|
|
|
+ }
|
|
|
}
|
|
|
+ m_type->setText(tStr);
|
|
|
+}
|
|
|
|
|
|
- m_treeWidget->expandAll();
|
|
|
+ProjectListWidget::ProjectListWidget(QWidget *parent) : QWidget(parent)
|
|
|
+{
|
|
|
+ initWidgets();
|
|
|
+ initLayout();
|
|
|
+ connectSiganlsAndSlots();
|
|
|
+}
|
|
|
|
|
|
- return;
|
|
|
- // m_listWidget->clear();
|
|
|
+void ProjectListWidget::showProjects(QList<ProjectInfo *> list)
|
|
|
+{
|
|
|
+ m_listWidget->clear();
|
|
|
|
|
|
- // for (int i = 1; i <= 100; i++) {
|
|
|
- // QListWidgetItem *item = new QListWidgetItem;
|
|
|
- // item->setSizeHint(QSize(200, 80));
|
|
|
- // m_listWidget->addItem(item);
|
|
|
+ for (ProjectInfo *info : list) {
|
|
|
+ ProjectListItemWidget *w = new ProjectListItemWidget(m_listWidget);
|
|
|
+ w->setData(info);
|
|
|
|
|
|
- // ProjectListItemWidget *w = new ProjectListItemWidget();
|
|
|
- // w->setIndex(i);
|
|
|
- // w->setName(QString("工程%1").arg(i));
|
|
|
- // m_listWidget->setItemWidget(item, w);
|
|
|
- // }
|
|
|
+ QListWidgetItem *item = new QListWidgetItem(m_listWidget);
|
|
|
+ item->setSizeHint(QSize(300, 135));
|
|
|
+ m_listWidget->setItemWidget(item, w);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-void ProjectListWidget::initialize()
|
|
|
+void ProjectListWidget::initWidgets()
|
|
|
{
|
|
|
QPalette pal(palette());
|
|
|
pal.setColor(QPalette::Background, QColor("#eeeeee"));
|
|
@@ -54,30 +149,26 @@ void ProjectListWidget::initialize()
|
|
|
|
|
|
m_vBoxLayout = new QVBoxLayout(this);
|
|
|
|
|
|
- // m_listWidget = new QListWidget(this);
|
|
|
+ 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);}");
|
|
|
-
|
|
|
- m_treeWidget = new TreeWidget(this);
|
|
|
- m_treeWidget->setHeaderHidden(true);
|
|
|
+ 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 ProjectListWidget::initLayout()
|
|
|
{
|
|
|
m_vBoxLayout->setMargin(0);
|
|
|
- // m_vBoxLayout->addWidget(m_listWidget);
|
|
|
- m_vBoxLayout->addWidget(m_treeWidget);
|
|
|
+ m_vBoxLayout->addWidget(m_listWidget);
|
|
|
}
|
|
|
|
|
|
void ProjectListWidget::connectSiganlsAndSlots()
|
|
|
{
|
|
|
- // connect(m_listWidget, &QListWidget::itemDoubleClicked, this, &ProjectListWidget::slotItemDoubleClicked);
|
|
|
- // connect(m_listWidget, &QListWidget::itemClicked, this, &ProjectListWidget::slotItemClicked);
|
|
|
- // connect(m_listWidget, &QListWidget::currentItemChanged, this, &ProjectListWidget::slotCurrentItemChanged);
|
|
|
- // connect(m_listWidget, &QListWidget::currentRowChanged, this, &ProjectListWidget::slotCurrentRowChanged);
|
|
|
- // connect(m_listWidget, &QListWidget::itemSelectionChanged, this, &ProjectListWidget::slotItemSelectionChanged);
|
|
|
+ connect(m_listWidget, &QListWidget::itemDoubleClicked, this, &ProjectListWidget::slotItemDoubleClicked);
|
|
|
+ connect(m_listWidget, &QListWidget::itemClicked, this, &ProjectListWidget::slotItemClicked);
|
|
|
+ connect(m_listWidget, &QListWidget::currentItemChanged, this, &ProjectListWidget::slotCurrentItemChanged);
|
|
|
+ connect(m_listWidget, &QListWidget::currentRowChanged, this, &ProjectListWidget::slotCurrentRowChanged);
|
|
|
+ connect(m_listWidget, &QListWidget::itemSelectionChanged, this, &ProjectListWidget::slotItemSelectionChanged);
|
|
|
}
|
|
|
|
|
|
void ProjectListWidget::slotItemDoubleClicked(QListWidgetItem *item)
|
|
@@ -104,68 +195,3 @@ void ProjectListWidget::slotItemSelectionChanged()
|
|
|
{
|
|
|
qDebug() << __FUNCTION__ << __LINE__;
|
|
|
}
|
|
|
-
|
|
|
-ProjectListItemWidget::ProjectListItemWidget(QWidget *parent) : QWidget(parent)
|
|
|
-{
|
|
|
- initialize();
|
|
|
- initLayout();
|
|
|
-}
|
|
|
-
|
|
|
-void ProjectListItemWidget::initialize()
|
|
|
-{
|
|
|
- m_hBoxLayout = new QHBoxLayout(this);
|
|
|
- m_vBoxLayout = new QVBoxLayout();
|
|
|
-
|
|
|
- m_indexLabel = new QLabel(this);
|
|
|
- m_indexLabel->setFixedWidth(20);
|
|
|
- m_indexLabel->setObjectName("indexLabel");
|
|
|
- m_nameLabel = new QLabel(this);
|
|
|
- m_nameLabel->setObjectName("nameLabel");
|
|
|
- m_typeLabel1 = new QLabel(this);
|
|
|
- m_typeLabel1->setObjectName("typeLabel1");
|
|
|
- m_typeLabel1->setContentsMargins(10, 0, 0, 0);
|
|
|
- m_typeLabel2 = new QLabel(this);
|
|
|
- m_typeLabel2->setObjectName("typeLabel2");
|
|
|
- m_typeLabel2->setContentsMargins(10, 0, 0, 0);
|
|
|
-
|
|
|
- m_typeLabel1->setText("能力与技术重要度评估");
|
|
|
- m_typeLabel2->setText("技术方案评估");
|
|
|
-
|
|
|
- setStyleSheet("#indexLabel {font-size:14px}"
|
|
|
- "#nameLabel {color:#1196db; font-size:14px; font:bold}"
|
|
|
- "#typeLabel1 {color: gray;}"
|
|
|
- "#typeLabel2 {color: gray;}");
|
|
|
-}
|
|
|
-
|
|
|
-void ProjectListItemWidget::initLayout()
|
|
|
-{
|
|
|
- m_hBoxLayout->addWidget(m_indexLabel);
|
|
|
- m_hBoxLayout->addLayout(m_vBoxLayout);
|
|
|
- m_hBoxLayout->addStretch();
|
|
|
-
|
|
|
- m_vBoxLayout->addWidget(m_nameLabel);
|
|
|
- m_vBoxLayout->addWidget(m_typeLabel1);
|
|
|
- m_vBoxLayout->addWidget(m_typeLabel2);
|
|
|
-}
|
|
|
-
|
|
|
-void ProjectListItemWidget::setIndex(int index)
|
|
|
-{
|
|
|
- m_index = index;
|
|
|
- m_indexLabel->setText(QString::number(index));
|
|
|
-}
|
|
|
-
|
|
|
-int ProjectListItemWidget::index() const
|
|
|
-{
|
|
|
- return m_index;
|
|
|
-}
|
|
|
-
|
|
|
-void ProjectListItemWidget::setName(const QString name)
|
|
|
-{
|
|
|
- m_name = name;
|
|
|
- m_nameLabel->setText(name);
|
|
|
-}
|
|
|
-
|
|
|
-const QString ProjectListItemWidget::name() const
|
|
|
-{
|
|
|
- return m_name;
|
|
|
-}
|