HomeView.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. private:
  25. void initWidgets();
  26. void initLayout();
  27. void connectSignalsAndSlots();
  28. void loadProjects();
  29. int firstPage() const; // 首页页码
  30. int finalPage() const; // 末页页码
  31. private slots:
  32. void slotCreateProjClicked();
  33. void slotSearchTextChanged();
  34. void slotFilterClicked();
  35. void slotProjInfoConfirmed();
  36. void slotProjectInfo(ProjectInfo *proj);
  37. void slotOpenProject(ProjectInfo *proj);
  38. void slotDeleteProject(ProjectInfo *proj);
  39. void slotPreviousClicked();
  40. void slotNextClicked();
  41. void slotFirstClicked();
  42. void slotFinalClicked();
  43. private:
  44. bool m_initilized = false;
  45. QVBoxLayout *m_layout = nullptr;
  46. QHBoxLayout *m_topLayout = nullptr;
  47. QHBoxLayout *m_pageLayout = nullptr;
  48. QLabel *m_title = nullptr;
  49. PushButton *m_create = nullptr;
  50. LineEdit *m_search = nullptr;
  51. PushButton *m_filter = nullptr;
  52. QLabel *m_totalLab = nullptr; // 共 123 条, 每页 20 条
  53. QLabel *m_pageLab = nullptr; // 第 1/5 页
  54. PushButton *m_previous = nullptr; // 上一页
  55. PushButton *m_next = nullptr; // 下一页
  56. PushButton *m_first = nullptr; // 首页
  57. PushButton *m_final = nullptr; // 末页
  58. ProjectListWidget *m_projListWidget = nullptr;
  59. CreateProjWidget *m_createProjWidget = nullptr;
  60. QList<ProjectInfo *> m_projList;
  61. int m_page = 1; // 页码
  62. int m_pageSize = 20; // 每页条数
  63. int m_total = 0; // 总数
  64. };
  65. #endif // HOMEVIEW_H