Browse Source

Merge branch 'master' of http://101.43.129.26:10880/chengxr/QFD2

zsf 1 year ago
parent
commit
d84f35e070
4 changed files with 52 additions and 10 deletions
  1. 1 1
      QFD/common/ProjectManager.cpp
  2. 35 6
      QFD/view/HomeView.cpp
  3. 15 3
      QFD/view/HomeView.h
  4. 1 0
      QFD/widgets/ProjectListWidget.cpp

+ 1 - 1
QFD/common/ProjectManager.cpp

@@ -143,6 +143,6 @@ int ProjectManager::updateProject(ProjectInfo &proj)
 int ProjectManager::deleteProject(int id)
 {
     bool ret = ProjectService().DeleteById(id);
-    qDebug() << __FUNCTION__ << __LINE__ << "ret:" << ret;
+    qDebug() << __FUNCTION__ << __LINE__ << "id:" << id << "ret:" << ret;
     return ret ? QF_CODE_SUCCEEDED : QF_CODE_PROJ_DELETE_FALIED;
 }

+ 35 - 6
QFD/view/HomeView.cpp

@@ -56,12 +56,19 @@ void HomeView::initWidgets()
     m_search->setPlaceholderText("输入项目名搜索");
     m_search->setMinimumWidth(300);
 
-    m_filter = new PushButton("筛选", NEWFLICON(QFDIcon, Filter), this);
-    m_filter->setToolTip("筛选项目");
+    m_filter = new PushButton("搜索 / 刷新", NEWFLICON(QFDIcon, Filter), this);
+    m_filter->setToolTip("搜索 / 刷新项目列表");
 
     m_projListWidget = new ProjectListWidget(this);
 
     m_createProjWidget = new CreateProjWidget(this);
+
+    m_totalLab = new QLabel("共123条, 每页20条", this);
+    m_pageLab  = new QLabel("第1/12页", this);
+    m_previous = new PushButton("上一页", this);
+    m_next     = new PushButton("下一页", this);
+    m_first    = new PushButton("首页", this);
+    m_final    = new PushButton("末页", this);
 }
 
 void HomeView::initLayout()
@@ -73,6 +80,8 @@ void HomeView::initLayout()
     m_topLayout = new QHBoxLayout();
     m_layout->addLayout(m_topLayout);
     m_layout->addWidget(m_projListWidget);
+    m_pageLayout = new QHBoxLayout();
+    m_layout->addLayout(m_pageLayout);
 
     // 顶部布局
     m_topLayout->addWidget(m_title);
@@ -82,12 +91,22 @@ void HomeView::initLayout()
     m_topLayout->addWidget(m_search, 0, Qt::AlignLeft);
     m_topLayout->addStretch();
     m_topLayout->addWidget(m_filter);
+
+    m_pageLayout->addWidget(m_totalLab);
+    m_pageLayout->addStretch();
+    m_pageLayout->addWidget(m_first);
+    m_pageLayout->addWidget(m_previous);
+    m_pageLayout->addWidget(m_pageLab);
+    m_pageLayout->addWidget(m_next);
+    m_pageLayout->addWidget(m_final);
+    m_pageLayout->addStretch();
 }
 
 void HomeView::connectSignalsAndSlots()
 {
     connect(m_create, &PushButton::clicked, this, &HomeView::slotCreateProjClicked);
     connect(m_search, &LineEdit::textChanged, this, &HomeView::slotSearchTextChanged);
+    connect(m_filter, &PushButton::clicked, this, &HomeView::slotFilterClicked);
     connect(m_createProjWidget, &CreateProjWidget::signalConfirm, this, &HomeView::slotProjInfoConfirmed);
     connect(m_projListWidget, &ProjectListWidget::sigOpen, this, &HomeView::slotOpenProject);
     connect(m_projListWidget, &ProjectListWidget::sigInfo, this, &HomeView::slotProjectInfo);
@@ -105,14 +124,19 @@ void HomeView::loadProjects()
         return;
     }
 
-    m_projListWidget->setProjects(searchResult());
+    m_projListWidget->setProjects(filterResult());
 }
 
-QList<ProjectInfo *> HomeView::searchResult() const
+QList<ProjectInfo *> HomeView::filterResult() const
 {
     QList<ProjectInfo *> list;
     for (ProjectInfo *proj : m_projList) {
-        if (proj->projectName.contains(m_search->text())) {
+        bool search                           = proj->projectName.contains(m_search->text());
+        QList<ProjectManager::EvalType> types = ProjectManager::evalTypeList(*proj);
+        bool typeValid                        = types.contains(ProjectManager::Requirements)
+                | types.contains(ProjectManager::SchemeOptimization)
+                | types.contains(ProjectManager::OverallEfficiency);
+        if (search && typeValid) {
             list.append(proj);
         }
     }
@@ -130,7 +154,12 @@ void HomeView::slotCreateProjClicked()
 
 void HomeView::slotSearchTextChanged()
 {
-    m_projListWidget->setProjects(searchResult());
+    m_projListWidget->setProjects(filterResult());
+}
+
+void HomeView::slotFilterClicked()
+{
+    qDebug() << __FUNCTION__ << __LINE__ << endl;
 }
 
 /// @todo 修改或者新建项目后, 列表移到该条目

+ 15 - 3
QFD/view/HomeView.h

@@ -37,11 +37,12 @@ private:
 
     void loadProjects();
 
-    QList<ProjectInfo *> searchResult() const;
+    QList<ProjectInfo *> filterResult() const;
 
 private slots:
     void slotCreateProjClicked();
     void slotSearchTextChanged();
+    void slotFilterClicked();
     void slotProjInfoConfirmed();
     void slotProjectInfo(ProjectInfo *proj);
     void slotOpenProject(ProjectInfo *proj);
@@ -50,19 +51,30 @@ private slots:
 private:
     bool m_initilized = false;
 
-    QVBoxLayout *m_layout    = nullptr;
-    QHBoxLayout *m_topLayout = nullptr;
+    QVBoxLayout *m_layout     = nullptr;
+    QHBoxLayout *m_topLayout  = nullptr;
+    QHBoxLayout *m_pageLayout = nullptr;
 
     QLabel *m_title      = nullptr;
     PushButton *m_create = nullptr;
     LineEdit *m_search   = nullptr;
     PushButton *m_filter = nullptr;
 
+    QLabel *m_totalLab     = nullptr;  // 共 123 条, 每页 20 条
+    QLabel *m_pageLab      = nullptr;  // 第 1/5 页
+    PushButton *m_previous = nullptr;  // 上一页
+    PushButton *m_next     = nullptr;  // 下一页
+    PushButton *m_first    = nullptr;  // 首页
+    PushButton *m_final    = nullptr;  // 末页
+
     ProjectListWidget *m_projListWidget = nullptr;
 
     CreateProjWidget *m_createProjWidget = nullptr;
 
     QList<ProjectInfo *> m_projList;
+    int m_page  = 0;   // 页码
+    int m_step  = 20;  // 每页条数
+    int m_total = 0;   // 总数
 };
 
 #endif  // HOMEVIEW_H

+ 1 - 0
QFD/widgets/ProjectListWidget.cpp

@@ -178,6 +178,7 @@ void ProjectListWidget::addProject(ProjectInfo *proj)
 void ProjectListWidget::removeProject(ProjectInfo *proj)
 {
     int index = m_projList.indexOf(proj);
+    qDebug() << __FUNCTION__ << __LINE__ << "index:" << index << endl;
     m_listWidget->takeItem(index);
 }