HomeView.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef HOMEVIEW_H
  2. #define HOMEVIEW_H
  3. #include <QWidget>
  4. class ProjectInfo;
  5. class CreateProjWidget;
  6. class ProjectListWidget;
  7. class PushButton;
  8. class LineEdit;
  9. class QVBoxLayout;
  10. class QHBoxLayout;
  11. class QLabel;
  12. ///
  13. /// \brief The HomeView class
  14. /// 首页
  15. class HomeView : public QWidget
  16. {
  17. Q_OBJECT
  18. public:
  19. explicit HomeView(QWidget *parent = nullptr);
  20. void showEvent(QShowEvent *event) override;
  21. void hideEvent(QHideEvent *event) override;
  22. signals:
  23. void sigOpenProject(ProjectInfo *proj);
  24. void sigDeleteProject(ProjectInfo *proj);
  25. private:
  26. void initWidgets();
  27. void initLayout();
  28. void connectSignalsAndSlots();
  29. void loadProjects();
  30. int firstPage() const; // 首页页码
  31. int finalPage() const; // 末页页码
  32. private slots:
  33. void slotCreateProjClicked();
  34. void slotSearchTextChanged();
  35. void slotFilterClicked();
  36. void slotProjInfoConfirmed();
  37. void slotProjectInfo(ProjectInfo *proj);
  38. void slotOpenProject(ProjectInfo *proj);
  39. void slotDeleteProject(ProjectInfo *proj);
  40. void slotExportProject(ProjectInfo *proj);
  41. void slotPreviousClicked();
  42. void slotNextClicked();
  43. void slotFirstClicked();
  44. void slotFinalClicked();
  45. private:
  46. bool m_initilized = false;
  47. QVBoxLayout *m_layout = nullptr;
  48. QHBoxLayout *m_topLayout = nullptr;
  49. QHBoxLayout *m_pageLayout = nullptr;
  50. QLabel *m_title = nullptr;
  51. PushButton *m_create = nullptr;
  52. LineEdit *m_search = nullptr;
  53. PushButton *m_filter = nullptr;
  54. QLabel *m_totalLab = nullptr; // 共 123 条, 每页 20 条
  55. QLabel *m_pageLab = nullptr; // 第 1/5 页
  56. PushButton *m_previous = nullptr; // 上一页
  57. PushButton *m_next = nullptr; // 下一页
  58. PushButton *m_first = nullptr; // 首页
  59. PushButton *m_final = nullptr; // 末页
  60. ProjectListWidget *m_projListWidget = nullptr;
  61. CreateProjWidget *m_createProjWidget = nullptr;
  62. QList<ProjectInfo *> m_projList;
  63. int m_page = 1; // 页码
  64. int m_pageSize = 20; // 每页条数
  65. int m_total = 0; // 总数
  66. };
  67. #endif // HOMEVIEW_H