加入应用列表的翻页功能

This commit is contained in:
RigoLigoRLC
2021-09-06 20:19:52 +08:00
parent 4ede620e71
commit f5649a121f
7 changed files with 148 additions and 28 deletions

View File

@@ -1,8 +1,7 @@
#pragma once
#include <QScrollArea>
#include <QList>
#include <QtWidgets>
#include "spkresource.h"
#include "spkappitem.h"
#include "page/spkpagebase.h"
@@ -19,20 +18,40 @@ namespace SpkUi
void AddApplicationEntry(QString name, QString pkgName, QString description, QString iconUrl,
int appId);
void ClearAll();
void SetPageStatus(int total, int current, int itemCount);
void SetCurrentCategory(int categoryId) { mCategoryId = categoryId; }
private:
void DisablePageSwitchers();
public:
private:
QVBoxLayout *mMainLay;
QHBoxLayout *mPageSwitchLay;
QPushButton *mBtnPgUp, *mBtnPgDown, *mBtnGotoPage;
QLineEdit *mPageInput;
QScrollArea *mAppsArea;
QLabel *mPageIndicator;
QWidget *mAppsWidget, *mPageSwitchWidget;
SpkStretchLayout *mItemLay;
QList<SpkAppItem *> mAppItemList;
QIntValidator *mPageValidator;
int mCategoryId, mCurrentPage;
signals:
void ApplicationClicked(QString name, QString pkgName);
void SwitchListPage(int categoryId, int page);
public slots:
void ResourceAcquisitionFinished(int id, ResourceResult result);
void Activated();
private slots:
void PageUp();
void PageDown();
void GotoPage();
};
}

View File

@@ -1,10 +1,10 @@
#pragma once
#include <QScrollArea>
#include <QtWidgets>
#include <spkresource.h>
class SpkPageBase : public QScrollArea
class SpkPageBase : public QWidget
{
Q_OBJECT
public:

View File

@@ -99,7 +99,7 @@ namespace SpkUi
}
mLastSelectedItem = item;
if(item->data(column, RoleItemIsCategory).toBool())
emit SwitchToCategory(item->data(column, RoleItemCategoryPageId).toInt());
emit SwitchToCategory(item->data(column, RoleItemCategoryPageId).toInt(), 0);
else
emit SwitchToPage(item->data(column, RoleItemCategoryPageId).toInt());
}
@@ -117,7 +117,7 @@ namespace SpkUi
}
signals:
void SwitchToCategory(int aCategoryId);
void SwitchToCategory(int aCategoryId, int aPage);
void SwitchToPage(int aPageId);
};
@@ -179,7 +179,7 @@ class SpkMainWindow : public SpkWindow
void CategoryDataReceived();
void EnterCategoryList(int id);
void EnterCategoryList(int aCategoryId, int aPage);
void CategoryListDataReceived();
private: