QFDAlert.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. }
  51. if (!msg.isEmpty()) {
  52. switch (type) {
  53. case None:
  54. break;
  55. case Info:
  56. InfoBar::info("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
  57. break;
  58. case Success:
  59. InfoBar::success("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
  60. break;
  61. case Alert:
  62. InfoBar::warning("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
  63. break;
  64. case Error:
  65. InfoBar::error("提示", msg, Qt::Horizontal, false, 2000, InfoBarPosition::TOP_RIGHT, w);
  66. break;
  67. }
  68. }
  69. }