chengxr 1 year ago
parent
commit
8cf728a9af

+ 9 - 1
QFD/view/ExpertManageView.cpp

@@ -104,15 +104,16 @@ void ExpertManageView::showExpertInfoWidget(ExpertInfoWidget::Mode mode)
 {
     if (m_expertInfoWidget == nullptr) {
         m_expertInfoWidget = new ExpertInfoWidget(this);
+        connect(m_expertInfoWidget, &ExpertInfoWidget::sigConfirm, this, &ExpertManageView::slotConfirmAddExpert);
     }
 
     if (m_expertInfoWidget->isVisible() == false) {
-        m_expertInfoWidget->clearInputs();
         m_expertInfoWidget->show();
         m_expertInfoWidget->setFocus(Qt::NoFocusReason);
     }
 
     m_expertInfoWidget->setMode(mode);
+    m_expertInfoWidget->clearInputs();
 }
 
 void ExpertManageView::hideExpertInfoWidget()
@@ -141,6 +142,7 @@ void ExpertManageView::refreshList()
 void ExpertManageView::slotAddExpertClicked()
 {
     showExpertInfoWidget(ExpertInfoWidget::Create);
+    m_expertListWidget->clearSelection();
 }
 
 void ExpertManageView::slotDetailClicked()
@@ -173,3 +175,9 @@ void ExpertManageView::slotListItemDoubleClicked(int row)
     QFUser *user = m_userList[row];
     showExpertInfo(user);
 }
+
+void ExpertManageView::slotConfirmAddExpert()
+{
+    QFUser *user = m_expertInfoWidget->user();
+    qDebug() << __FUNCTION__ << __LINE__ << user->id << user->userName;
+}

+ 2 - 0
QFD/view/ExpertManageView.h

@@ -54,6 +54,8 @@ private slots:
     void slotListSelectionChanged();
     void slotListItemDoubleClicked(int row);
 
+    void slotConfirmAddExpert();
+
 private:
     bool m_initilized = false;
 

+ 14 - 2
QFD/widgets/ExpertInfoWidget.cpp

@@ -47,7 +47,7 @@ void ExpertInfoWidget::clearInputs()
     m_jobLineEdit->clear();
     m_majorLineEdit->clear();
     m_contactInfoLineEdit->clear();
-    m_timeLineEdit->clear();
+    m_timeLineEdit->setDateTime(QDateTime::currentDateTime());
     m_noteTextEdit->clear();
 }
 
@@ -73,6 +73,18 @@ void ExpertInfoWidget::setUser(QFUser *user)
     qDebug() << __FUNCTION__ << __LINE__ << user->writeTime << dt << user->remark;
 }
 
+QFUser *ExpertInfoWidget::user() const
+{
+    if (m_mode == Create) {
+        QFUser *user   = new QFUser();
+        user->id       = m_idLineEdit->text().toInt();
+        user->userName = m_nameLineEdit->text();
+        return user;
+    } else {
+        return m_user;
+    }
+}
+
 void ExpertInfoWidget::initWindow()
 {
     setWindowFlags(Qt::Window);
@@ -252,7 +264,7 @@ void ExpertInfoWidget::setEditable(bool editable)
 
 void ExpertInfoWidget::slotConfirm()
 {
-    close();
+    emit sigConfirm();
 }
 
 void ExpertInfoWidget::slotCancel()

+ 5 - 0
QFD/widgets/ExpertInfoWidget.h

@@ -43,6 +43,10 @@ public:
 
     void setUser(QFUser *user);
 
+    /// Create 模式下,构造新的 QFUser
+    /// 其他模式下直接返回 m_user
+    QFUser *user() const;
+
 private:
     void initWindow();
     void initialize();
@@ -58,6 +62,7 @@ private slots:
     void slotCancel();
 
 signals:
+    void sigConfirm();
 
 private:
     Mode m_mode = Create;

+ 5 - 0
QFD/widgets/ExpertListWidget.cpp

@@ -54,6 +54,11 @@ int ExpertListWidget::selectedRow() const
     return m_listWidget->row(item);
 }
 
+void ExpertListWidget::clearSelection()
+{
+    m_listWidget->clearSelection();
+}
+
 void ExpertListWidget::initialize()
 {
     m_vBoxLayout = new QVBoxLayout(this);

+ 2 - 0
QFD/widgets/ExpertListWidget.h

@@ -24,6 +24,8 @@ public:
 
     int selectedRow() const;
 
+    void clearSelection();
+
 signals:
     void signalSelectionChanged();
     void siganlItemDoubleClicked(int row);