chengxr 1 năm trước cách đây
mục cha
commit
b46197d88c
5 tập tin đã thay đổi với 174 bổ sung3 xóa
  1. 2 0
      QFD/QFD.pro
  2. 43 0
      QFD/view/ExpertInfoView.cpp
  3. 45 0
      QFD/view/ExpertInfoView.h
  4. 57 1
      QFD/view/ExpertView.cpp
  5. 27 2
      QFD/view/ExpertView.h

+ 2 - 0
QFD/QFD.pro

@@ -64,6 +64,7 @@ SOURCES += \
     view/AboutView.cpp \
     view/CreateProjView.cpp \
     view/DataView.cpp \
+    view/ExpertInfoView.cpp \
     view/ExpertView.cpp \
     view/HomeView.cpp \
     view/LoginView.cpp \
@@ -77,6 +78,7 @@ HEADERS += \
     view/AboutView.h \
     view/CreateProjView.h \
     view/DataView.h \
+    view/ExpertInfoView.h \
     view/ExpertView.h \
     view/HomeView.h \
     view/LoginView.h \

+ 43 - 0
QFD/view/ExpertInfoView.cpp

@@ -0,0 +1,43 @@
+#include "ExpertInfoView.h"
+
+ExpertInfoView::ExpertInfoView(QWidget *parent) : QWidget(parent)
+{
+    initWindow();
+    initialize();
+    initLayout();
+    connectSignalsAndSlots();
+    updateState();
+}
+
+void ExpertInfoView::setMode(ExpertInfoView::Mode mode) { }
+
+void ExpertInfoView::clearInputs() { }
+
+void ExpertInfoView::initWindow()
+{
+    setWindowFlags(Qt::Window);
+    setWindowFlag(Qt::WindowMinMaxButtonsHint, false);
+    resize(400, 600);
+}
+
+void ExpertInfoView::initialize() { }
+
+void ExpertInfoView::initLayout() { }
+
+void ExpertInfoView::connectSignalsAndSlots() { }
+
+void ExpertInfoView::updateState()
+{
+    switch (m_mode) {
+    case Add: {
+        setWindowTitle("添加用户");
+        break;
+    }
+    case Update: {
+        setWindowTitle("专家1");
+    }
+    case Read: {
+        setWindowTitle("专家1");
+    }
+    }
+}

+ 45 - 0
QFD/view/ExpertInfoView.h

@@ -0,0 +1,45 @@
+#ifndef EXPERTINFOVIEW_H
+#define EXPERTINFOVIEW_H
+
+#include <QWidget>
+
+class LineEdit;
+class PasswordLineEdit;
+class PushButton;
+
+class QVBoxLayout;
+class QGridLayout;
+class QLabel;
+
+class ExpertInfoView : public QWidget
+{
+    Q_OBJECT
+
+    enum Mode
+    {
+        Add,     // 新增
+        Update,  // 编辑
+        Read,    // 查看
+    };
+
+public:
+    explicit ExpertInfoView(QWidget *parent = nullptr);
+
+    void setMode(Mode mode);
+
+    void clearInputs();
+
+private:
+    void initWindow();
+    void initialize();
+    void initLayout();
+    void connectSignalsAndSlots();
+    void updateState();
+
+signals:
+
+private:
+    Mode m_mode = Add;
+};
+
+#endif  // EXPERTINFOVIEW_H

+ 57 - 1
QFD/view/ExpertView.cpp

@@ -1,6 +1,62 @@
-#include "ExpertView.h"
+#include "ExpertView.h"
+
+#include "ExpertInfoView.h"
+
+#include <Widgets/Button.h>
+#include <Widgets/LineEdit.h>
+
+#include <QBoxLayout>
+#include <QLabel>
+
+#include <QDebug>
 
 ExpertView::ExpertView(QWidget *parent) : QWidget(parent)
 {
+    initialize();
+    initLayout();
+    connectSignalsAndSlots();
+}
+
+void ExpertView::initialize()
+{
+    m_vBoxLayout = new QVBoxLayout(this);
+
+    m_titleLabel = new QLabel(this);
+    m_titleLabel->setText("用户列表");
+    QFont ft("Microsoft YaHei", 12);
+    m_titleLabel->setFont(ft);
+    m_hBoxLayout     = new QHBoxLayout();
+    m_searchLineEdit = new SearchLineEdit(this);
+    m_searchLineEdit->setPlaceholderText("搜索用户");
+    m_searchLineEdit->setMinimumWidth(300);
+    m_addExpertPushButton = new PushButton("添加用户", NEWFLICON(FluentIcon, ADD), this);
+
+    m_expertInfoView = new ExpertInfoView(this);
+}
 
+void ExpertView::initLayout()
+{
+    m_vBoxLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
+    m_vBoxLayout->setContentsMargins(15, 10, 10, 15);
+    m_vBoxLayout->addLayout(m_hBoxLayout);
+
+    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_vBoxLayout->addSpacing(15);
+}
+
+void ExpertView::connectSignalsAndSlots()
+{
+    connect(m_addExpertPushButton, &PushButton::clicked, this, &ExpertView::slotAddExpertClicked);
+}
+
+void ExpertView::slotAddExpertClicked()
+{
+    if (m_expertInfoView->isVisible() == false) {
+        m_expertInfoView->clearInputs();
+        m_expertInfoView->show();
+    }
 }

+ 27 - 2
QFD/view/ExpertView.h

@@ -1,8 +1,17 @@
-#ifndef EXPERTVIEW_H
+#ifndef EXPERTVIEW_H
 #define EXPERTVIEW_H
 
 #include <QWidget>
 
+class ExpertInfoView;
+
+class PushButton;
+class SearchLineEdit;
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QLabel;
+
 class ExpertView : public QWidget
 {
     Q_OBJECT
@@ -11,6 +20,22 @@ public:
 
 signals:
 
+private:
+    void initialize();
+    void initLayout();
+    void connectSignalsAndSlots();
+
+private slots:
+    void slotAddExpertClicked();
+
+private:
+    QVBoxLayout *m_vBoxLayout         = nullptr;
+    QLabel *m_titleLabel              = nullptr;
+    QHBoxLayout *m_hBoxLayout         = nullptr;
+    SearchLineEdit *m_searchLineEdit  = nullptr;
+    PushButton *m_addExpertPushButton = nullptr;
+
+    ExpertInfoView *m_expertInfoView = nullptr;
 };
 
-#endif // EXPERTVIEW_H
+#endif  // EXPERTVIEW_H