PageWidget.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef PAGEWIDGET_H
  2. #define PAGEWIDGET_H
  3. #include <QWidget>
  4. #include <QList>
  5. #include <QComboBox>
  6. #include "databasemanager.h"
  7. class QLabel;
  8. class QEvent;
  9. struct HeaderInfo {
  10. QString label;
  11. QString prop;
  12. };
  13. namespace Ui {
  14. class PageWidget;
  15. }
  16. class PageWidget : public QWidget {
  17. Q_OBJECT
  18. public:
  19. explicit PageWidget(int blockSize = 3, QWidget *parent = 0);
  20. ~PageWidget();
  21. /*const 关键字在成员函数声明和定义中的使用,确保了该函数不会修改对象的状态,提高了代码的安全性和可读性。这对于那些只需要读取对象状态而不需要修改对象状态的函数非常有用*/
  22. int getBlockSize() const;
  23. int getMaxPage() const;
  24. int getCurrentPage() const;
  25. // 其他组件只需要调用这两个函数即可
  26. void setMaxPage(int maxPage); // 当总页数改变时调用
  27. void setCurrentPage(int currentPage, bool signalEmitted = false); // 修改当前页时调用
  28. void showLeft();
  29. QComboBox* getComboBox() const;
  30. protected:
  31. virtual bool eventFilter(QObject *watched, QEvent *e);
  32. signals:
  33. void currentPageChanged(int page);
  34. private:
  35. Ui::PageWidget *ui;
  36. int blockSize;
  37. int maxPage; //总页数
  38. int currentPage; //当前页面
  39. QList<QLabel *> *pageLabels;
  40. int PageRecordCount; //每页显示的记录数量
  41. void setBlockSize(int blockSize);
  42. void updatePageLabels();
  43. void initialize();
  44. void setRecordCount();
  45. void initCombo();
  46. };
  47. #endif // PAGEWIDGET_H