QFDAlert.cpp 2.5 KB

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