QFDAlert.cpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include "QFDAlert.h"
  2. #include <dbService/ClassSet.h>
  3. #include <Widgets/InfoBar.h>
  4. void QFDAlert::showAlertWithCode(int code, QWidget *w)
  5. {
  6. if (code == QF_CODE_SUCCEEDED) {
  7. return;
  8. }
  9. QString msg;
  10. QFDAlertType type = Alert;
  11. if (code == QF_CODE_EMPTY_ACCOUNT) {
  12. msg = "账号不能为空";
  13. } else if (code == QF_CODE_EMPTY_PASSWORD) {
  14. msg = "密码不能为空";
  15. } else if (code == QF_CODE_USER_NOT_EXISTS) {
  16. msg = "用户不存在";
  17. } else if (code == QF_CODE_WRONG_PASSWORD) {
  18. msg = "密码错误";
  19. } else if (code == QF_CODE_PASSWORD_NOT_SAME) {
  20. msg = "两次输入密码不一致,请修改后重试";
  21. } else if (code == QF_CODE_PASSWORD_UNCHANGED) {
  22. msg = "不能与旧密码相同,请修改后重试";
  23. } else if (code == QF_CODE_DATA_ERROR) {
  24. msg = "数据异常";
  25. } else if (code == QF_CODE_EMPTY_USERNAME) {
  26. msg = "专家名不能为空";
  27. } else if (code == QF_CODE_ACCOUNT_OCCUPIED) {
  28. msg = "用户名已存在或者数据库存储异常!";
  29. } else if (code == QF_CODE_ADD_USER_SUCCEEDED) {
  30. msg = "已添加";
  31. type = Success;
  32. } else if (code == QF_CODE_DELETE_USER_FAILED) {
  33. msg = "删除用户失败";
  34. } else if (code == QF_CODE_NEED_PROJ_SUMMARY) {
  35. msg = "请补全项目概要信息";
  36. } else if (code == QF_CODE_NEED_PROJ_NAME) {
  37. msg = "请填写项目名称";
  38. } else if (code == QF_CODE_NEED_PROJ_TYPE) {
  39. msg = "请选额评估类型";
  40. } else if (code == QF_CODE_PROJ_CREATE_FALIED) {
  41. msg = "创建失败";
  42. } else if (code == QF_CODE_PROJ_NOT_EDITABLE) {
  43. msg = "该类型项目不支持修改";
  44. } else if (code == QF_CODE_PROJ_UPDATE_FALIED) {
  45. msg = "更新失败";
  46. } else if (code == QF_CODE_PROJ_DELETE_FALIED) {
  47. msg = "删除失败";
  48. } else if (code == QF_CODE_EVAL_NOT_SUPPORTED) {
  49. msg = "不支持的评估类型";
  50. } else if (code == QF_CODE_WEIGHTSUM_ERROR) {
  51. msg = "已配置专家的权重和不等于1";
  52. }
  53. if (!msg.isEmpty()) {
  54. switch (type) {
  55. case None:
  56. break;
  57. case Info:
  58. InfoBar::info("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
  59. break;
  60. case Success:
  61. InfoBar::success("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
  62. break;
  63. case Alert:
  64. InfoBar::warning("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
  65. break;
  66. case Error:
  67. InfoBar::error("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
  68. break;
  69. }
  70. }
  71. }