Added Featured List Pages
This commit is contained in:
@@ -120,6 +120,7 @@ public:
|
||||
* @brief resultsPerPage
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]]
|
||||
auto resultsPerPage() const -> qsizetype
|
||||
{
|
||||
return m_resultsPerPage;
|
||||
@@ -204,6 +205,7 @@ public:
|
||||
* @brief data
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]]
|
||||
auto data() const -> const QList<T>
|
||||
{
|
||||
if(boundaryCheck(m_resultsPerPage))
|
||||
@@ -219,6 +221,7 @@ public:
|
||||
* @brief count
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]]
|
||||
auto count() const -> qsizetype
|
||||
{
|
||||
if(m_offset == nullsize)
|
||||
@@ -240,6 +243,7 @@ public:
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]]
|
||||
auto at(qsizetype index) const -> const T&
|
||||
{
|
||||
return m_cacheController.at(m_offset + index);
|
||||
@@ -251,6 +255,7 @@ public:
|
||||
* The total number of results as reported by the controller
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]]
|
||||
auto totalResults() const -> qsizetype
|
||||
{
|
||||
return m_cacheController.totalCount();
|
||||
@@ -261,6 +266,7 @@ public:
|
||||
* Calculates the current page
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]]
|
||||
auto page() const -> qsizetype
|
||||
{
|
||||
return std::floor(
|
||||
@@ -273,6 +279,7 @@ public:
|
||||
* Calculates the total number of pages available
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]]
|
||||
auto totalPages() const -> qsizetype
|
||||
{
|
||||
return std::ceil(
|
||||
@@ -280,6 +287,22 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief setWindowSize
|
||||
* Sets the controller window size
|
||||
* @return
|
||||
*/
|
||||
auto setWindowSize(qsizetype size) -> void
|
||||
{
|
||||
m_cacheController.setWindowSize(size);
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
auto windowSize() const -> qsizetype
|
||||
{
|
||||
return m_cacheController.windowSize();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
auto queryable() const -> bool
|
||||
|
||||
@@ -337,6 +337,13 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
qsizetype windowSize = this->windowSize();
|
||||
|
||||
if(windowSize == 0)
|
||||
{
|
||||
windowSize = SLIDING_CACHE_WINDOW_SIZE;
|
||||
}
|
||||
|
||||
while (index >= m_windowOffset + (SLIDING_CACHE_WINDOW_SIZE - SLIDING_CACHE_PREFETCH_THRESHOLD))
|
||||
{
|
||||
if(!slideForward())
|
||||
|
||||
@@ -245,7 +245,6 @@ auto FeaturedImagesModel::resultsPerPage() const -> qsizetype
|
||||
|
||||
auto FeaturedImagesModel::setResultsPerPage(qsizetype resultsPerPage) -> void
|
||||
{
|
||||
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run
|
||||
|
||||
@@ -248,7 +248,6 @@ signals:
|
||||
auto stateChanged() -> void;
|
||||
auto errorStringChanged() -> void;
|
||||
auto resultsPerPageChanged() -> void;
|
||||
|
||||
auto pageChanged() -> void;
|
||||
auto totalResultsChanged() -> void;
|
||||
auto totalPagesChanged() -> void;
|
||||
|
||||
@@ -205,6 +205,24 @@ auto FeaturedVideosModel::itemModel() const -> VideoItemModel*
|
||||
return m_itemModel;
|
||||
}
|
||||
|
||||
auto FeaturedVideosModel::windowSize() const -> qsizetype
|
||||
{
|
||||
if(m_paginator == nullptr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return m_paginator->windowSize();
|
||||
}
|
||||
|
||||
auto FeaturedVideosModel::setWindowSize(qsizetype size) -> void
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
m_paginator->setWindowSize(size);
|
||||
}
|
||||
}
|
||||
|
||||
auto FeaturedVideosModel::roleNames() const -> QHash<int, QByteArray>
|
||||
{
|
||||
return m_dataRoles;
|
||||
|
||||
@@ -217,6 +217,20 @@ public:
|
||||
|
||||
VideoItemModel *itemModel() const;
|
||||
|
||||
/**
|
||||
* @brief windowSize
|
||||
* Paginator cache size
|
||||
* @return
|
||||
*/
|
||||
auto windowSize() const -> qsizetype;
|
||||
|
||||
/**
|
||||
* @brief setWindowSize
|
||||
* Set the paginator cache size
|
||||
* @param size
|
||||
*/
|
||||
auto setWindowSize(qsizetype size) -> void;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief setErrorString
|
||||
@@ -243,7 +257,7 @@ signals:
|
||||
auto stateChanged() -> void;
|
||||
auto errorStringChanged() -> void;
|
||||
auto resultsPerPageChanged() -> void;
|
||||
|
||||
auto windowSizeChanged() -> void;
|
||||
auto pageChanged() -> void;
|
||||
auto totalResultsChanged() -> void;
|
||||
auto totalPagesChanged() -> void;
|
||||
@@ -314,6 +328,7 @@ private:
|
||||
Q_PROPERTY(qsizetype totalPages READ totalPages NOTIFY totalPagesChanged FINAL)
|
||||
Q_PROPERTY(qsizetype page READ page NOTIFY pageChanged FINAL)
|
||||
Q_PROPERTY(VideoItemModel *itemModel READ itemModel CONSTANT FINAL)
|
||||
Q_PROPERTY(qsizetype windowSize READ windowSize WRITE setWindowSize NOTIFY windowSizeChanged FINAL)
|
||||
};
|
||||
Q_DECLARE_METATYPE(FeaturedVideosModel)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user