ItemData.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef ITEMDATA_H
  2. #define ITEMDATA_H
  3. #include "oneitem.h"
  4. #define IData ItemData::getInstance()
  5. /**
  6. * @brief 存储创建的Item
  7. *
  8. */
  9. class ItemData
  10. {
  11. ItemData();
  12. ItemData(const ItemData&) = delete;
  13. ItemData& operator=(const ItemData&) = delete;
  14. public:
  15. ~ItemData();
  16. static ItemData& getInstance()
  17. {
  18. static ItemData instance;
  19. return instance;
  20. }
  21. /* 添加一项计划 */
  22. void addOneItem(int week, OneItem* item);
  23. /* 删除一项计划 */
  24. void deleteOneItem(int week, int num);
  25. /* 清空一天的计划 */
  26. void clearOneDay(int week);
  27. /* 清空所有的计划数据 */
  28. void clearAllItem();
  29. /* 查找有没有这个项 */
  30. bool findItem(OneItem* item);
  31. bool findItem(int week, OneItem* item);
  32. /* 获取整个容器 */
  33. QMap<int, QList<OneItem*>*>& getMapItem() { return m_mapItem; }
  34. /* 获取一天的容器 */
  35. QList<OneItem*>* getOneDay(int week);
  36. /* 获取一天的计划 */
  37. QList<ExecPlanItemInfo> getOneDayExecPlan(int week);
  38. /* 新增判断是否有重复 */
  39. bool judgeTimeRepetitionWithAdd(int weekDay, const QString& devName, const QTime& time);
  40. bool judgeDateTimeRepetitionWithAdd(int weekDay, const QString& devName, const QDate& date, const QTime& time);
  41. /* 判断已有的项修改时间后和其他项是否重复 */
  42. bool judgeTimeRepetitionWithEdit(int weekDay, OneItem* item, const QTime& newTime);
  43. /* 判断特殊日的已有项修改时间后和其他项是否重复 */
  44. bool judgeDateTimeRepetitionWithEdit(int weekDay, OneItem* item, const QDate& newDate, const QTime& newTime);
  45. /* 获取计划是否有更新 */
  46. bool isUpdate() { return m_isUpdate; }
  47. /* 设置计划是否有更新 */
  48. void setUpdate(bool isUpdate) { m_isUpdate = isUpdate; }
  49. private:
  50. bool m_isUpdate = false; /* 是否有更新计划 */
  51. QMap<int, QList<OneItem*>*> m_mapItem; /* int是周几 */
  52. };
  53. #endif // ITEMDATA_H