chengxr 1 year ago
parent
commit
6f4060fc8b

+ 2 - 0
QFD/common/QFDIcon.cpp

@@ -7,6 +7,8 @@ QString QFDIcon::iconName(QFDIcon::IconType type)
     switch (type) {
     case Data:
         return "Data";
+    case Detail:
+        return "Detail";
     case Expert:
         return "Expert";
     case Project:

+ 1 - 0
QFD/common/QFDIcon.h

@@ -11,6 +11,7 @@ public:
     enum IconType
     {
         Data,
+        Detail,
         Expert,
         Project,
         User,

+ 2 - 0
QFD/resource.qrc

@@ -362,5 +362,7 @@
         <file>resource/svg/Project_white.svg</file>
         <file>resource/svg/User_black.svg</file>
         <file>resource/svg/User_white.svg</file>
+        <file>resource/svg/Detail_black.svg</file>
+        <file>resource/svg/Detail_white.svg</file>
     </qresource>
 </RCC>

+ 1 - 0
QFD/resource/svg/Detail_black.svg

@@ -0,0 +1 @@
+<svg t="1690249308203" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2587" width="16" height="16"><path d="M756.315353 350.539419h-467.385892c-23.369295 0-42.489627-19.120332-42.489627-42.489626s19.120332-42.489627 42.489627-42.489627h467.385892c23.369295 0 42.489627 19.120332 42.489626 42.489627s-19.120332 42.489627-42.489626 42.489626zM756.315353 786.058091h-467.385892c-23.369295 0-42.489627-19.120332-42.489627-42.489626s19.120332-42.489627 42.489627-42.489627h467.385892c23.369295 0 42.489627 19.120332 42.489626 42.489627s-19.120332 42.489627-42.489626 42.489626z" p-id="2588" fill="#000000"></path><path d="M851.917012 1024H172.082988c-72.232365 0-129.593361-57.360996-129.593361-129.593361v-764.813278C42.489627 57.360996 99.850622 0 172.082988 0h679.834024c72.232365 0 129.593361 57.360996 129.593361 129.593361v764.813278c0 72.232365-57.360996 129.593361-129.593361 129.593361zM172.082988 46.738589C125.344398 46.738589 89.228216 84.979253 89.228216 129.593361v764.813278C89.228216 939.020747 125.344398 977.261411 172.082988 977.261411h679.834024c46.738589 0 82.854772-38.240664 82.854772-82.854772v-764.813278c0-46.738589-38.240664-82.854772-82.854772-82.854772H172.082988z" p-id="2589" fill="#000000"></path><path d="M745.692946 569.360996H278.307054c-23.369295 0-42.489627-19.120332-42.489627-42.489627s19.120332-42.489627 42.489627-42.489626h467.385892c23.369295 0 42.489627 19.120332 42.489627 42.489626s-19.120332 42.489627-42.489627 42.489627z" p-id="2590" fill="#000000"></path></svg>

+ 1 - 0
QFD/resource/svg/Detail_white.svg

@@ -0,0 +1 @@
+<svg t="1690249308203" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2587" width="16" height="16"><path d="M756.315353 350.539419h-467.385892c-23.369295 0-42.489627-19.120332-42.489627-42.489626s19.120332-42.489627 42.489627-42.489627h467.385892c23.369295 0 42.489627 19.120332 42.489626 42.489627s-19.120332 42.489627-42.489626 42.489626zM756.315353 786.058091h-467.385892c-23.369295 0-42.489627-19.120332-42.489627-42.489626s19.120332-42.489627 42.489627-42.489627h467.385892c23.369295 0 42.489627 19.120332 42.489626 42.489627s-19.120332 42.489627-42.489626 42.489626z" p-id="2588" fill="#ffffff"></path><path d="M851.917012 1024H172.082988c-72.232365 0-129.593361-57.360996-129.593361-129.593361v-764.813278C42.489627 57.360996 99.850622 0 172.082988 0h679.834024c72.232365 0 129.593361 57.360996 129.593361 129.593361v764.813278c0 72.232365-57.360996 129.593361-129.593361 129.593361zM172.082988 46.738589C125.344398 46.738589 89.228216 84.979253 89.228216 129.593361v764.813278C89.228216 939.020747 125.344398 977.261411 172.082988 977.261411h679.834024c46.738589 0 82.854772-38.240664 82.854772-82.854772v-764.813278c0-46.738589-38.240664-82.854772-82.854772-82.854772H172.082988z" p-id="2589" fill="#ffffff"></path><path d="M745.692946 569.360996H278.307054c-23.369295 0-42.489627-19.120332-42.489627-42.489627s19.120332-42.489627 42.489627-42.489626h467.385892c23.369295 0 42.489627 19.120332 42.489627 42.489626s-19.120332 42.489627-42.489627 42.489627z" p-id="2590" fill="#ffffff"></path></svg>

+ 53 - 2
QFD/view/ExpertManageView.cpp

@@ -1,10 +1,13 @@
 #include "ExpertManageView.h"
 
+#include "QFDIcon.h"
+
 #include "ExpertInfoWidget.h"
 #include "ExpertListWidget.h"
 
 #include <Widgets/Button.h>
 #include <Widgets/LineEdit.h>
+#include <DialogBox/Dialog.h>
 
 #include <QBoxLayout>
 #include <QLabel>
@@ -31,8 +34,10 @@ void ExpertManageView::initialize()
     m_searchLineEdit->setPlaceholderText("搜索");
     m_searchLineEdit->setMinimumWidth(300);
     m_addExpertPushButton = new PushButton("添加", NEWFLICON(FluentIcon, ADD), this);
+    m_detailPushButton    = new PushButton("查看详情", NEWFLICON(QFDIcon, Detail), this);
+    m_deletePushButton    = new PushButton("删除", NEWFLICON(FluentIcon, DELETE), this);
 
-    m_expertInfoWidget   = new ExpertInfoWidget(this);
+    m_expertInfoWidget = new ExpertInfoWidget(this);
     m_expertListWidget = new ExpertListWidget(this);
 }
 
@@ -42,10 +47,15 @@ void ExpertManageView::initLayout()
     m_vBoxLayout->setContentsMargins(15, 10, 10, 15);
     m_vBoxLayout->addLayout(m_hBoxLayout);
 
+    m_hBoxLayout->setContentsMargins(10, 0, 10, 0);
     m_hBoxLayout->addWidget(m_titleLabel);
     m_hBoxLayout->addSpacing(15);
     m_hBoxLayout->addWidget(m_searchLineEdit, 0, Qt::AlignLeft);
     m_hBoxLayout->addWidget(m_addExpertPushButton, 1, Qt::AlignLeft);
+    m_hBoxLayout->addStretch();
+    m_hBoxLayout->addWidget(m_detailPushButton);
+    m_hBoxLayout->addWidget(m_deletePushButton);
+    setListButtonHidden(true);
 
     m_vBoxLayout->addWidget(m_expertListWidget);
 }
@@ -53,12 +63,53 @@ void ExpertManageView::initLayout()
 void ExpertManageView::connectSignalsAndSlots()
 {
     connect(m_addExpertPushButton, &PushButton::clicked, this, &ExpertManageView::slotAddExpertClicked);
+    connect(m_detailPushButton, &PushButton::clicked, this, &ExpertManageView::slotDetailClicked);
+    connect(m_deletePushButton, &PushButton::clicked, this, &ExpertManageView::slotDeleteClicked);
+    connect(m_expertListWidget, &ExpertListWidget::signalSelectionChanged, this,
+            &ExpertManageView::slotListSelectionChanged);
+    connect(m_expertListWidget, &ExpertListWidget::siganlItemDoubleClicked, this,
+            &ExpertManageView::slotListItemDoubleClicked);
 }
 
-void ExpertManageView::slotAddExpertClicked()
+void ExpertManageView::setListButtonHidden(bool hidden)
+{
+    m_detailPushButton->setHidden(hidden);
+    m_deletePushButton->setHidden(hidden);
+}
+
+void ExpertManageView::showExpertInfo()
 {
     if (m_expertInfoWidget->isVisible() == false) {
         m_expertInfoWidget->clearInputs();
         m_expertInfoWidget->show();
     }
 }
+
+void ExpertManageView::slotAddExpertClicked()
+{
+    m_expertInfoWidget->setMode(ExpertInfoWidget::Add);
+    showExpertInfo();
+}
+
+void ExpertManageView::slotDetailClicked()
+{
+    m_expertInfoWidget->setMode(ExpertInfoWidget::Read);
+    showExpertInfo();
+}
+
+void ExpertManageView::slotDeleteClicked()
+{
+    MessageBox *m = new MessageBox("删除专家信息", "删除后不可恢复,确认删除?", this);
+    m->exec();
+}
+
+void ExpertManageView::slotListSelectionChanged()
+{
+    setListButtonHidden(!m_expertListWidget->isItemSelected());
+}
+
+void ExpertManageView::slotListItemDoubleClicked()
+{
+    m_expertInfoWidget->setMode(ExpertInfoWidget::Read);
+    showExpertInfo();
+}

+ 10 - 0
QFD/view/ExpertManageView.h

@@ -29,8 +29,16 @@ private:
     void initLayout();
     void connectSignalsAndSlots();
 
+    void setListButtonHidden(bool hidden);
+
+    void showExpertInfo();
+
 private slots:
     void slotAddExpertClicked();
+    void slotDetailClicked();
+    void slotDeleteClicked();
+    void slotListSelectionChanged();
+    void slotListItemDoubleClicked();
 
 private:
     QVBoxLayout *m_vBoxLayout         = nullptr;
@@ -38,6 +46,8 @@ private:
     QHBoxLayout *m_hBoxLayout         = nullptr;
     SearchLineEdit *m_searchLineEdit  = nullptr;
     PushButton *m_addExpertPushButton = nullptr;
+    PushButton *m_detailPushButton    = nullptr;
+    PushButton *m_deletePushButton    = nullptr;
 
     ExpertInfoWidget *m_expertInfoWidget = nullptr;
     ExpertListWidget *m_expertListWidget = nullptr;

+ 33 - 12
QFD/widgets/ExpertListWidget.cpp

@@ -1,8 +1,5 @@
 #include "ExpertListWidget.h"
 
-#include "ExpertInfoWidget.h"
-
-#include <Widgets/Button.h>
 #include <Common/Icon.h>
 
 #include <QBoxLayout>
@@ -42,12 +39,14 @@ void ExpertListWidget::refreshList()
         QLabel *name = new QLabel(QString("专家%1").arg(i));
         hBox->addWidget(name);
         hBox->addStretch();
-
-        PushButton *deleteButton = new PushButton("删除", NEWFLICON(FluentIcon, DELETE), this);
-        hBox->addWidget(deleteButton, 0, Qt::AlignLeft);
     }
 }
 
+bool ExpertListWidget::isItemSelected() const
+{
+    return m_expertListWidget->selectedItems().count() > 0;
+}
+
 void ExpertListWidget::initialize()
 {
     m_vBoxLayout       = new QVBoxLayout(this);
@@ -55,8 +54,6 @@ void ExpertListWidget::initialize()
     m_expertListWidget->setAlternatingRowColors(true);
     m_expertListWidget->setStyleSheet("QListWidget {border: 1px solid rgba(0, 0, 0, 0.073);background: rgb(255, 255, "
                                       "255);alternate-background-color: rgb(244, 244, 255);}");
-    m_expertInfoWidget = new ExpertInfoWidget(this);
-    m_expertInfoWidget->setMode(ExpertInfoWidget::Read);
 }
 
 void ExpertListWidget::initLayout()
@@ -66,11 +63,35 @@ void ExpertListWidget::initLayout()
 
 void ExpertListWidget::connectSignalsAndSlots()
 {
-    connect(m_expertListWidget, &QListWidget::itemDoubleClicked, this, &ExpertListWidget::slotListItemClicked);
+    connect(m_expertListWidget, &QListWidget::itemDoubleClicked, this, &ExpertListWidget::slotItemDoubleClicked);
+    connect(m_expertListWidget, &QListWidget::itemClicked, this, &ExpertListWidget::slotItemClicked);
+    connect(m_expertListWidget, &QListWidget::currentItemChanged, this, &ExpertListWidget::slotCurrentItemChanged);
+    connect(m_expertListWidget, &QListWidget::currentRowChanged, this, &ExpertListWidget::slotCurrentRowChanged);
+    connect(m_expertListWidget, &QListWidget::itemSelectionChanged, this, &ExpertListWidget::slotItemSelectionChanged);
+}
+
+void ExpertListWidget::slotItemDoubleClicked(QListWidgetItem *)
+{
+    emit siganlItemDoubleClicked();
+}
+
+void ExpertListWidget::slotItemClicked(QListWidgetItem *)
+{
+    qDebug() << __FUNCTION__ << __LINE__;
+}
+
+void ExpertListWidget::slotCurrentItemChanged(QListWidgetItem *current, QListWidgetItem *previous)
+{
+    qDebug() << __FUNCTION__ << __LINE__ << current << previous;
+}
+
+void ExpertListWidget::slotCurrentRowChanged(int currentRow)
+{
+    qDebug() << __FUNCTION__ << __LINE__ << currentRow;
 }
 
-void ExpertListWidget::slotListItemClicked(QListWidgetItem *item)
+void ExpertListWidget::slotItemSelectionChanged()
 {
-    qDebug() << __FUNCTION__ << __LINE__ << item->text();
-    m_expertInfoWidget->show();
+    qDebug() << __FUNCTION__ << __LINE__ << m_expertListWidget->selectedItems();
+    emit signalSelectionChanged();
 }

+ 10 - 5
QFD/widgets/ExpertListWidget.h

@@ -3,8 +3,6 @@
 
 #include <QWidget>
 
-class ExpertInfoWidget;
-
 class QVBoxLayout;
 class QListWidget;
 class QListWidgetItem;
@@ -20,7 +18,11 @@ public:
 
     void refreshList();
 
+    bool isItemSelected() const;
+
 signals:
+    void signalSelectionChanged();
+    void siganlItemDoubleClicked();
 
 private:
     void initialize();
@@ -28,13 +30,16 @@ private:
     void connectSignalsAndSlots();
 
 private slots:
-    void slotListItemClicked(QListWidgetItem *item);
+    void slotItemDoubleClicked(QListWidgetItem *item);
+    void slotItemClicked(QListWidgetItem *item);
+
+    void slotCurrentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
+    void slotCurrentRowChanged(int currentRow);
+    void slotItemSelectionChanged();
 
 private:
     QVBoxLayout *m_vBoxLayout       = nullptr;
     QListWidget *m_expertListWidget = nullptr;
-
-    ExpertInfoWidget *m_expertInfoWidget = nullptr;
 };
 
 #endif  // EXPERTLISTWIDGET_H