1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- #include "QFDAlert.h"
- #include <dbService/ClassSet.h>
- #include <Widgets/InfoBar.h>
- void QFDAlert::showAlertWithCode(int code, QWidget *w)
- {
- if (code == QF_CODE_SUCCEEDED) {
- return;
- }
- QString msg;
- QFDAlertType type = Alert;
- if (code == QF_CODE_EMPTY_ACCOUNT) {
- msg = "账号不能为空";
- } else if (code == QF_CODE_EMPTY_PASSWORD) {
- msg = "密码不能为空";
- } else if (code == QF_CODE_USER_NOT_EXISTS) {
- msg = "用户不存在";
- } else if (code == QF_CODE_WRONG_PASSWORD) {
- msg = "密码错误";
- } else if (code == QF_CODE_PASSWORD_NOT_SAME) {
- msg = "两次输入密码不一致,请修改后重试";
- } else if (code == QF_CODE_PASSWORD_UNCHANGED) {
- msg = "不能与旧密码相同,请修改后重试";
- } else if (code == QF_CODE_DATA_ERROR) {
- msg = "数据异常";
- } else if (code == QF_CODE_EMPTY_USERNAME) {
- msg = "专家名不能为空";
- } else if (code == QF_CODE_ACCOUNT_OCCUPIED) {
- msg = "用户名已存在或者数据库存储异常!";
- } else if (code == QF_CODE_ADD_USER_SUCCEEDED) {
- msg = "已添加";
- type = Success;
- } else if (code == QF_CODE_DELETE_USER_FAILED) {
- msg = "删除用户失败";
- } else if (code == QF_CODE_NEED_PROJ_SUMMARY) {
- msg = "请补全项目概要信息";
- } else if (code == QF_CODE_NEED_PROJ_NAME) {
- msg = "请填写项目名称";
- } else if (code == QF_CODE_NEED_PROJ_TYPE) {
- msg = "请选额评估类型";
- } else if (code == QF_CODE_PROJ_CREATE_FALIED) {
- msg = "创建失败";
- } else if (code == QF_CODE_PROJ_NOT_EDITABLE) {
- msg = "该类型项目不支持修改";
- } else if (code == QF_CODE_PROJ_UPDATE_FALIED) {
- msg = "更新失败";
- } else if (code == QF_CODE_PROJ_DELETE_FALIED) {
- msg = "删除失败";
- } else if (code == QF_CODE_EVAL_NOT_SUPPORTED) {
- msg = "不支持的评估类型";
- } else if (code == QF_CODE_WEIGHTSUM_ERROR) {
- msg = "已配置专家的权重和不等于1";
- }
- if (!msg.isEmpty()) {
- switch (type) {
- case None:
- break;
- case Info:
- InfoBar::info("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
- break;
- case Success:
- InfoBar::success("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
- break;
- case Alert:
- InfoBar::warning("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
- break;
- case Error:
- InfoBar::error("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
- break;
- }
- }
- }
|