|
@@ -17,7 +17,10 @@
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
-ProjectView::ProjectView(ProjectInfo *proj, QWidget *parent) : QWidget(parent), m_proj(proj) { }
|
|
|
+ProjectView::ProjectView(ProjectInfo *proj, QWidget *parent) : QWidget(parent), m_proj(proj)
|
|
|
+{
|
|
|
+ selectItem(m_tree->topLevelItem(0), 0);
|
|
|
+}
|
|
|
|
|
|
void ProjectView::showEvent(QShowEvent *event)
|
|
|
{
|
|
@@ -54,8 +57,9 @@ void ProjectView::initWidgets()
|
|
|
|
|
|
QList<ProjectManager::EvalType> types = ProjectManager::evalTypeList(*m_proj);
|
|
|
for (int i = 0; i < types.count(); i++) {
|
|
|
- QString projName = ProjectManager::nameOfEvalType(types[i]);
|
|
|
- QTreeWidgetItem *item = new QTreeWidgetItem({ projName });
|
|
|
+ QString typeName = ProjectManager::nameOfEvalType(types[i]);
|
|
|
+ QTreeWidgetItem *item = new QTreeWidgetItem({ typeName });
|
|
|
+ item->setData(0, Qt::BackgroundRole, types[i]);
|
|
|
item->addChildren({ new QTreeWidgetItem({ "指标体系设计" }), new QTreeWidgetItem({ "评估方案规划" }),
|
|
|
new QTreeWidgetItem({ "评估数据采集" }), new QTreeWidgetItem({ "评估数据处理" }) });
|
|
|
m_tree->addTopLevelItem(item);
|
|
@@ -71,7 +75,7 @@ void ProjectView::initWidgets()
|
|
|
QPalette pal(m_contentSeperator->palette());
|
|
|
|
|
|
//设置背景黑色
|
|
|
- pal.setColor(QPalette::Background, Qt::black);
|
|
|
+ pal.setColor(QPalette::Background, QColor("#aaaaaa"));
|
|
|
m_contentSeperator->setAutoFillBackground(true);
|
|
|
m_contentSeperator->setPalette(pal);
|
|
|
}
|
|
@@ -83,7 +87,6 @@ void ProjectView::initLayout()
|
|
|
m_layout->addLayout(m_headerLayout);
|
|
|
m_contentLayout = new QHBoxLayout();
|
|
|
m_layout->addLayout(m_contentLayout);
|
|
|
- // m_layout->addStretch();
|
|
|
|
|
|
m_headerLayout->addWidget(m_title);
|
|
|
m_headerLayout->addStretch();
|
|
@@ -98,4 +101,27 @@ void ProjectView::initLayout()
|
|
|
void ProjectView::connectSigalsAndSlots()
|
|
|
{
|
|
|
connect(m_close, &PushButton::clicked, this, &ProjectView::sigClose);
|
|
|
+ connect(m_tree, &TreeWidget::itemClicked, this, &ProjectView::selectItem);
|
|
|
+}
|
|
|
+
|
|
|
+void ProjectView::selectItem(QTreeWidgetItem *item, int column)
|
|
|
+{
|
|
|
+ Q_UNUSED(column)
|
|
|
+
|
|
|
+ int typeIndex = m_tree->indexOfTopLevelItem(item);
|
|
|
+ int taskIndex = -1;
|
|
|
+ if (typeIndex < 0) {
|
|
|
+ typeIndex = m_tree->indexOfTopLevelItem(item->parent());
|
|
|
+ taskIndex = item->parent()->indexOfChild(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (taskIndex < 0) {
|
|
|
+ item->setSelected(false);
|
|
|
+ item->child(0)->setSelected(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ ProjectManager::EvalType type = ProjectManager::evalTypeList(*m_proj)[typeIndex];
|
|
|
+ QString typeName = ProjectManager::nameOfEvalType(type);
|
|
|
+
|
|
|
+ qDebug() << __FUNCTION__ << __LINE__ << typeIndex << type << typeName << taskIndex << endl;
|
|
|
}
|