// // Created by Krad on 2021/11/10. // #ifndef GUI_ACCOUNTFORMDIALOG_H #define GUI_ACCOUNTFORMDIALOG_H class QLabel; class QLineEdit; class QToolButton; class QSqlTableModel; #include #include "GUIFormBaseDialog.h" enum AccountEditMode{ Self, Admin, New }; class AccountFormDialog:public GUIFormBaseDialog{ Q_OBJECT public: explicit AccountFormDialog(QWidget *parent = nullptr,AccountEditMode mode = Self,Qt::WindowFlags f = Qt::WindowFlags()); ~AccountFormDialog() override = default; void setAccountInformation(const QMap& values); void setReferenceModel(QSqlTableModel* model){ mRefModel = model; } protected: bool updateReferenceData() override; void warn(const QString& msg); void hideWarn(); private: void addEndLine(QVBoxLayout *layout); void addNewModeUI(QVBoxLayout *layout); void addSelfModeUI(QHBoxLayout *layout); void addTitleLabel(QVBoxLayout *layout); void initUserCodeUI(QVBoxLayout *layout); void initUserNameUI(QVBoxLayout *layout); void addCommentLabel(QVBoxLayout *layout); void addWarnLabel(QVBoxLayout *layout); void addButtonPwd(QHBoxLayout *layout); void changeSelfPassword(); void resetUserPassword(); QString mUserID; QString mUserPwd; QString mRoleID; QString mNewUserName; bool mUserNameChanged; bool mCommentChanged; bool mRoleChanged; AccountEditMode mMode; QLineEdit* mLeUserCode; QLineEdit* mLeUserName; QLineEdit* mLeComment; QLineEdit* mLePwd; QToolButton* mBtnPwd; QLabel* mLblError; QSqlTableModel* mRefModel; }; #endif //GUI_ACCOUNTFORMDIALOG_H