123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #ifndef PAGEWIDGET_H
- #define PAGEWIDGET_H
- #include <QWidget>
- #include <QList>
- #include <QComboBox>
- #include "databasemanager.h"
- class QLabel;
- class QEvent;
- struct HeaderInfo {
- QString label;
- QString prop;
- };
- namespace Ui {
- class PageWidget;
- }
- class PageWidget : public QWidget {
- Q_OBJECT
- public:
- explicit PageWidget(int blockSize = 3, QWidget *parent = 0);
- ~PageWidget();
- /*const 关键字在成员函数声明和定义中的使用,确保了该函数不会修改对象的状态,提高了代码的安全性和可读性。这对于那些只需要读取对象状态而不需要修改对象状态的函数非常有用*/
- int getBlockSize() const;
- int getMaxPage() const;
- int getCurrentPage() const;
- // 其他组件只需要调用这两个函数即可
- void setMaxPage(int maxPage); // 当总页数改变时调用
- void setCurrentPage(int currentPage, bool signalEmitted = false); // 修改当前页时调用
- void showLeft();
- QComboBox* getComboBox() const;
- protected:
- virtual bool eventFilter(QObject *watched, QEvent *e);
- signals:
- void currentPageChanged(int page);
- private:
- Ui::PageWidget *ui;
- int blockSize;
- int maxPage; //总页数
- int currentPage; //当前页面
- QList<QLabel *> *pageLabels;
- int PageRecordCount; //每页显示的记录数量
- void setBlockSize(int blockSize);
- void updatePageLabels();
- void initialize();
- void setRecordCount();
- void initCombo();
- };
- #endif // PAGEWIDGET_H
|