|
@@ -2,11 +2,14 @@
|
|
|
|
|
|
#include <Widgets/LineEdit.h>
|
|
#include <Widgets/LineEdit.h>
|
|
#include <Widgets/Button.h>
|
|
#include <Widgets/Button.h>
|
|
|
|
+#include <Widgets/SpinBox.h>
|
|
|
|
|
|
#include <QBoxLayout>
|
|
#include <QBoxLayout>
|
|
#include <QGridLayout>
|
|
#include <QGridLayout>
|
|
#include <QLabel>
|
|
#include <QLabel>
|
|
|
|
|
|
|
|
+#include <QDebug>
|
|
|
|
+
|
|
ExpertInfoWidget::ExpertInfoWidget(QWidget *parent) : QWidget(parent)
|
|
ExpertInfoWidget::ExpertInfoWidget(QWidget *parent) : QWidget(parent)
|
|
{
|
|
{
|
|
initWindow();
|
|
initWindow();
|
|
@@ -16,6 +19,17 @@ ExpertInfoWidget::ExpertInfoWidget(QWidget *parent) : QWidget(parent)
|
|
updateState();
|
|
updateState();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void ExpertInfoWidget::showEvent(QShowEvent *event)
|
|
|
|
+{
|
|
|
|
+ QWidget::showEvent(event);
|
|
|
|
+ clearFocus();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ExpertInfoWidget::hideEvent(QHideEvent *event)
|
|
|
|
+{
|
|
|
|
+ QWidget::hideEvent(event);
|
|
|
|
+}
|
|
|
|
+
|
|
void ExpertInfoWidget::setMode(ExpertInfoWidget::Mode mode)
|
|
void ExpertInfoWidget::setMode(ExpertInfoWidget::Mode mode)
|
|
{
|
|
{
|
|
m_mode = mode;
|
|
m_mode = mode;
|
|
@@ -31,60 +45,71 @@ void ExpertInfoWidget::clearInputs()
|
|
m_jobLineEdit->clear();
|
|
m_jobLineEdit->clear();
|
|
m_majorLineEdit->clear();
|
|
m_majorLineEdit->clear();
|
|
m_contactInfoLineEdit->clear();
|
|
m_contactInfoLineEdit->clear();
|
|
|
|
+ m_timeLineEdit->clear();
|
|
m_noteTextEdit->clear();
|
|
m_noteTextEdit->clear();
|
|
- updateState();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void ExpertInfoWidget::initWindow()
|
|
void ExpertInfoWidget::initWindow()
|
|
{
|
|
{
|
|
|
|
+ setMaximumWidth(400);
|
|
setWindowFlags(Qt::Window);
|
|
setWindowFlags(Qt::Window);
|
|
setWindowFlag(Qt::WindowMinMaxButtonsHint, false);
|
|
setWindowFlag(Qt::WindowMinMaxButtonsHint, false);
|
|
- // setModal(true);
|
|
|
|
- // setWindowFlags(Qt::Dialog);
|
|
|
|
- // setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
|
|
|
- resize(400, 450);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void ExpertInfoWidget::initialize()
|
|
void ExpertInfoWidget::initialize()
|
|
{
|
|
{
|
|
- int editWidth = 300;
|
|
|
|
|
|
+ int labelHeight = 35;
|
|
|
|
+ int editWidth = 300;
|
|
|
|
|
|
m_vBoxLayout = new QVBoxLayout(this);
|
|
m_vBoxLayout = new QVBoxLayout(this);
|
|
m_gridLayout = new QGridLayout();
|
|
m_gridLayout = new QGridLayout();
|
|
|
|
|
|
m_idLabel = new QLabel(this);
|
|
m_idLabel = new QLabel(this);
|
|
m_idLabel->setText("账号ID:");
|
|
m_idLabel->setText("账号ID:");
|
|
|
|
+ m_idLabel->setFixedHeight(labelHeight);
|
|
m_idLineEdit = new LineEdit(this);
|
|
m_idLineEdit = new LineEdit(this);
|
|
m_idLineEdit->setFixedWidth(editWidth);
|
|
m_idLineEdit->setFixedWidth(editWidth);
|
|
m_idLineEdit->setPlaceholderText("请输入a-z/A-Z/0-9数字字母组合");
|
|
m_idLineEdit->setPlaceholderText("请输入a-z/A-Z/0-9数字字母组合");
|
|
m_passwordLabel = new QLabel(this);
|
|
m_passwordLabel = new QLabel(this);
|
|
m_passwordLabel->setText("用户密码:");
|
|
m_passwordLabel->setText("用户密码:");
|
|
|
|
+ m_passwordLabel->setFixedHeight(labelHeight);
|
|
m_passwordLineEdit = new PasswordLineEdit(this);
|
|
m_passwordLineEdit = new PasswordLineEdit(this);
|
|
m_passwordLineEdit->setFixedWidth(editWidth);
|
|
m_passwordLineEdit->setFixedWidth(editWidth);
|
|
m_passwordLineEdit->setPlaceholderText("请输入密码");
|
|
m_passwordLineEdit->setPlaceholderText("请输入密码");
|
|
m_nameLabel = new QLabel(this);
|
|
m_nameLabel = new QLabel(this);
|
|
m_nameLabel->setText("专家名:");
|
|
m_nameLabel->setText("专家名:");
|
|
|
|
+ m_nameLabel->setFixedHeight(labelHeight);
|
|
m_nameLineEdit = new LineEdit(this);
|
|
m_nameLineEdit = new LineEdit(this);
|
|
m_nameLineEdit->setFixedWidth(editWidth);
|
|
m_nameLineEdit->setFixedWidth(editWidth);
|
|
m_nameLineEdit->setPlaceholderText("请输入专家名");
|
|
m_nameLineEdit->setPlaceholderText("请输入专家名");
|
|
m_companyLabel = new QLabel(this);
|
|
m_companyLabel = new QLabel(this);
|
|
m_companyLabel->setText("单位:");
|
|
m_companyLabel->setText("单位:");
|
|
|
|
+ m_companyLabel->setFixedHeight(labelHeight);
|
|
m_companyLineEdit = new LineEdit(this);
|
|
m_companyLineEdit = new LineEdit(this);
|
|
m_companyLineEdit->setFixedWidth(editWidth);
|
|
m_companyLineEdit->setFixedWidth(editWidth);
|
|
m_jobLabel = new QLabel(this);
|
|
m_jobLabel = new QLabel(this);
|
|
m_jobLabel->setText("职务:");
|
|
m_jobLabel->setText("职务:");
|
|
|
|
+ m_jobLabel->setFixedHeight(labelHeight);
|
|
m_jobLineEdit = new LineEdit(this);
|
|
m_jobLineEdit = new LineEdit(this);
|
|
m_jobLineEdit->setFixedWidth(editWidth);
|
|
m_jobLineEdit->setFixedWidth(editWidth);
|
|
m_majorLabel = new QLabel(this);
|
|
m_majorLabel = new QLabel(this);
|
|
m_majorLabel->setText("专业:");
|
|
m_majorLabel->setText("专业:");
|
|
|
|
+ m_majorLabel->setFixedHeight(labelHeight);
|
|
m_majorLineEdit = new LineEdit(this);
|
|
m_majorLineEdit = new LineEdit(this);
|
|
m_majorLineEdit->setFixedWidth(editWidth);
|
|
m_majorLineEdit->setFixedWidth(editWidth);
|
|
m_contactInfoLabel = new QLabel(this);
|
|
m_contactInfoLabel = new QLabel(this);
|
|
m_contactInfoLabel->setText("联系方式:");
|
|
m_contactInfoLabel->setText("联系方式:");
|
|
|
|
+ m_contactInfoLabel->setFixedHeight(labelHeight);
|
|
m_contactInfoLineEdit = new LineEdit(this);
|
|
m_contactInfoLineEdit = new LineEdit(this);
|
|
m_contactInfoLineEdit->setFixedWidth(editWidth);
|
|
m_contactInfoLineEdit->setFixedWidth(editWidth);
|
|
|
|
+ m_timeLabel = new QLabel(this);
|
|
|
|
+ m_timeLabel->setText("填写时间:");
|
|
|
|
+ m_timeLabel->setFixedHeight(labelHeight);
|
|
|
|
+ m_timeLineEdit = new DateTimeEdit(this);
|
|
|
|
+ m_timeLineEdit->setFixedWidth(editWidth);
|
|
m_noteLabel = new QLabel(this);
|
|
m_noteLabel = new QLabel(this);
|
|
m_noteLabel->setText("备注:");
|
|
m_noteLabel->setText("备注:");
|
|
|
|
+ m_noteLabel->setFixedHeight(labelHeight);
|
|
m_noteTextEdit = new TextEdit(this);
|
|
m_noteTextEdit = new TextEdit(this);
|
|
m_noteTextEdit->setFixedWidth(editWidth);
|
|
m_noteTextEdit->setFixedWidth(editWidth);
|
|
m_noteTextEdit->setFixedHeight(100);
|
|
m_noteTextEdit->setFixedHeight(100);
|
|
@@ -113,8 +138,10 @@ void ExpertInfoWidget::initLayout()
|
|
m_gridLayout->addWidget(m_majorLineEdit, 5, 1, 1, 1, Qt::AlignLeft);
|
|
m_gridLayout->addWidget(m_majorLineEdit, 5, 1, 1, 1, Qt::AlignLeft);
|
|
m_gridLayout->addWidget(m_contactInfoLabel, 6, 0, 1, 1, Qt::AlignRight);
|
|
m_gridLayout->addWidget(m_contactInfoLabel, 6, 0, 1, 1, Qt::AlignRight);
|
|
m_gridLayout->addWidget(m_contactInfoLineEdit, 6, 1, 1, 1, Qt::AlignLeft);
|
|
m_gridLayout->addWidget(m_contactInfoLineEdit, 6, 1, 1, 1, Qt::AlignLeft);
|
|
- m_gridLayout->addWidget(m_noteLabel, 7, 0, 1, 1, Qt::AlignRight | Qt::AlignTop);
|
|
|
|
- m_gridLayout->addWidget(m_noteTextEdit, 7, 1, 1, 1, Qt::AlignLeft);
|
|
|
|
|
|
+ m_gridLayout->addWidget(m_timeLabel, 7, 0, 1, 1, Qt::AlignRight);
|
|
|
|
+ m_gridLayout->addWidget(m_timeLineEdit, 7, 1, 1, 1, Qt::AlignLeft);
|
|
|
|
+ m_gridLayout->addWidget(m_noteLabel, 8, 0, 1, 1, Qt::AlignRight | Qt::AlignTop);
|
|
|
|
+ m_gridLayout->addWidget(m_noteTextEdit, 8, 1, 1, 1, Qt::AlignLeft);
|
|
|
|
|
|
m_vBoxLayout->addStretch();
|
|
m_vBoxLayout->addStretch();
|
|
m_vBoxLayout->addLayout(m_hBoxLayout);
|
|
m_vBoxLayout->addLayout(m_hBoxLayout);
|
|
@@ -132,31 +159,62 @@ void ExpertInfoWidget::connectSignalsAndSlots()
|
|
|
|
|
|
void ExpertInfoWidget::updateState()
|
|
void ExpertInfoWidget::updateState()
|
|
{
|
|
{
|
|
|
|
+ int h = height();
|
|
|
|
+ QString t = windowTitle();
|
|
switch (m_mode) {
|
|
switch (m_mode) {
|
|
case Add: {
|
|
case Add: {
|
|
- setWindowTitle("添加用户");
|
|
|
|
|
|
+ t = "添加用户";
|
|
|
|
+ h = 300;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
case Update: {
|
|
case Update: {
|
|
- setWindowTitle("修改用户信息");
|
|
|
|
|
|
+ t = "修改用户信息";
|
|
|
|
+ h = 300;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
case Read: {
|
|
case Read: {
|
|
- setWindowTitle("用户信息");
|
|
|
|
|
|
+ t = "用户信息";
|
|
|
|
+ h = 450;
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- bool editEnabled = m_mode != Read;
|
|
|
|
- m_idLineEdit->setEnabled(editEnabled);
|
|
|
|
- m_passwordLineEdit->setEnabled(editEnabled);
|
|
|
|
- m_nameLineEdit->setEnabled(editEnabled);
|
|
|
|
- m_companyLineEdit->setEnabled(editEnabled);
|
|
|
|
- m_jobLineEdit->setEnabled(editEnabled);
|
|
|
|
- m_majorLineEdit->setEnabled(editEnabled);
|
|
|
|
- m_idLineEdit->setEnabled(editEnabled);
|
|
|
|
- m_contactInfoLineEdit->setEnabled(editEnabled);
|
|
|
|
- m_noteTextEdit->setEnabled(editEnabled);
|
|
|
|
- m_confirmButton->setHidden(!editEnabled);
|
|
|
|
- m_cancelButton->setHidden(!editEnabled);
|
|
|
|
|
|
+ setMaximumHeight(h);
|
|
|
|
+ setWindowTitle(t);
|
|
|
|
+
|
|
|
|
+ setEditable(m_mode != Read);
|
|
|
|
+ setDetailsHideen(m_mode == Add);
|
|
|
|
+
|
|
|
|
+ // update();
|
|
|
|
+ repaint();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ExpertInfoWidget::setDetailsHideen(bool hidden)
|
|
|
|
+{
|
|
|
|
+ m_companyLabel->setHidden(hidden);
|
|
|
|
+ m_companyLineEdit->setHidden(hidden);
|
|
|
|
+ m_jobLabel->setHidden(hidden);
|
|
|
|
+ m_jobLineEdit->setHidden(hidden);
|
|
|
|
+ m_majorLabel->setHidden(hidden);
|
|
|
|
+ m_majorLineEdit->setHidden(hidden);
|
|
|
|
+ m_contactInfoLabel->setHidden(hidden);
|
|
|
|
+ m_contactInfoLineEdit->setHidden(hidden);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void ExpertInfoWidget::setEditable(bool editable)
|
|
|
|
+{
|
|
|
|
+ m_idLineEdit->setReadOnly(!editable);
|
|
|
|
+ m_passwordLineEdit->setReadOnly(!editable);
|
|
|
|
+ m_nameLineEdit->setReadOnly(!editable);
|
|
|
|
+ m_companyLineEdit->setReadOnly(!editable);
|
|
|
|
+ m_jobLineEdit->setReadOnly(!editable);
|
|
|
|
+ m_majorLineEdit->setReadOnly(!editable);
|
|
|
|
+ m_idLineEdit->setReadOnly(!editable);
|
|
|
|
+ m_contactInfoLineEdit->setReadOnly(!editable);
|
|
|
|
+ m_timeLineEdit->setReadOnly(!editable);
|
|
|
|
+ m_noteTextEdit->setReadOnly(!editable);
|
|
|
|
+ m_confirmButton->setHidden(!editable);
|
|
|
|
+ m_cancelButton->setHidden(!editable);
|
|
}
|
|
}
|
|
|
|
|
|
void ExpertInfoWidget::slotConfirm()
|
|
void ExpertInfoWidget::slotConfirm()
|