mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Remove contentManager pagination.
The pagination was added as a workaround to a too slow display of the content. Now that with commit 4cbf001 we are displaying the icons async, the pagination is no more usefull.
This commit is contained in:
parent
09bfbf1476
commit
67d56f1d03
@ -66,12 +66,6 @@ function init() {
|
|||||||
openBook : function(book) {
|
openBook : function(book) {
|
||||||
contentManager.openBook(book.id, function() {});
|
contentManager.openBook(book.id, function() {});
|
||||||
},
|
},
|
||||||
changePage : function(delta) {
|
|
||||||
var newPage = contentManager.currentPage+delta;
|
|
||||||
if (newPage < 0) newPage = 0;
|
|
||||||
if (newPage > contentManager.nbPages-1) newPage = contentManager.nbPages-1;
|
|
||||||
contentManager.currentPage = newPage;
|
|
||||||
},
|
|
||||||
downloadBook : function(book) {
|
downloadBook : function(book) {
|
||||||
contentManager.downloadBook(book.id, function(did) {
|
contentManager.downloadBook(book.id, function(did) {
|
||||||
book.downloadId = did;
|
book.downloadId = did;
|
||||||
@ -218,13 +212,6 @@ button {
|
|||||||
{{ book.description }}
|
{{ book.description }}
|
||||||
</p>
|
</p>
|
||||||
</details>
|
</details>
|
||||||
<div class="footer">
|
|
||||||
<button v-on:click="contentManager.currentPage = 0">First</button>
|
|
||||||
<button v-on:click="changePage(-1)">Previous</button>
|
|
||||||
{{ contentManager.currentPage+1 }} / {{ contentManager.nbPages }}
|
|
||||||
<button v-on:click="changePage(1)">Next</button>
|
|
||||||
<button v-on:click="contentManager.currentPage = contentManager.nbPages-1">Last</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body></html>
|
</body></html>
|
||||||
|
@ -32,7 +32,6 @@ void ContentManager::setLocal(bool local) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_local = local;
|
m_local = local;
|
||||||
m_currentPage = 0;
|
|
||||||
emit(remoteParamsChanged());
|
emit(remoteParamsChanged());
|
||||||
emit(booksChanged());
|
emit(booksChanged());
|
||||||
}
|
}
|
||||||
@ -218,8 +217,7 @@ void ContentManager::setCurrentLanguage(QString language)
|
|||||||
void ContentManager::updateRemoteLibrary() {
|
void ContentManager::updateRemoteLibrary() {
|
||||||
QUrlQuery query;
|
QUrlQuery query;
|
||||||
query.addQueryItem("lang", m_currentLanguage);
|
query.addQueryItem("lang", m_currentLanguage);
|
||||||
query.addQueryItem("count", QString::number(m_booksPerPage));
|
query.addQueryItem("count", QString::number(0));
|
||||||
query.addQueryItem("start", QString::number(getStartBookIndex()));
|
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setScheme("http");
|
url.setScheme("http");
|
||||||
url.setHost(CATALOG_HOST);
|
url.setHost(CATALOG_HOST);
|
||||||
@ -237,14 +235,14 @@ void ContentManager::updateRemoteLibrary() {
|
|||||||
|
|
||||||
QStringList ContentManager::getBookIds() {
|
QStringList ContentManager::getBookIds() {
|
||||||
if (m_local) {
|
if (m_local) {
|
||||||
return mp_library->getBookIds().mid(getStartBookIndex(), m_booksPerPage);
|
return mp_library->getBookIds();
|
||||||
} else {
|
} else {
|
||||||
auto bookIds = m_remoteLibrary.getBooksIds();
|
auto bookIds = m_remoteLibrary.getBooksIds();
|
||||||
QStringList list;
|
QStringList list;
|
||||||
for(auto i=0; i<m_booksPerPage; i++) {
|
for(auto& bookId:bookIds) {
|
||||||
try{
|
try{
|
||||||
list.append(QString::fromStdString(bookIds.at(getStartBookIndex()+i)));
|
list.append(QString::fromStdString(bookId));
|
||||||
} catch (out_of_range& e) {
|
} catch (out_of_range&) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,6 @@
|
|||||||
class ContentManager : public QObject
|
class ContentManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int booksPerPage MEMBER m_booksPerPage NOTIFY booksChanged)
|
|
||||||
Q_PROPERTY(int nbPages READ getNbPages NOTIFY booksChanged)
|
|
||||||
Q_PROPERTY(int currentPage MEMBER m_currentPage WRITE setCurrentPage NOTIFY booksChanged)
|
|
||||||
Q_PROPERTY(int startBookIndex READ getStartBookIndex NOTIFY booksChanged)
|
|
||||||
Q_PROPERTY(int endBookIndex READ getEndBookIndex NOTIFY booksChanged)
|
|
||||||
Q_PROPERTY(QStringList bookIds READ getBookIds NOTIFY booksChanged)
|
Q_PROPERTY(QStringList bookIds READ getBookIds NOTIFY booksChanged)
|
||||||
Q_PROPERTY(QStringList downloadIds READ getDownloadIds NOTIFY downloadsChanged)
|
Q_PROPERTY(QStringList downloadIds READ getDownloadIds NOTIFY downloadsChanged)
|
||||||
Q_PROPERTY(QString currentLanguage MEMBER m_currentLanguage WRITE setCurrentLanguage NOTIFY currentLangChanged)
|
Q_PROPERTY(QString currentLanguage MEMBER m_currentLanguage WRITE setCurrentLanguage NOTIFY currentLangChanged)
|
||||||
@ -32,15 +27,9 @@ private:
|
|||||||
kiwix::Library m_remoteLibrary;
|
kiwix::Library m_remoteLibrary;
|
||||||
kiwix::Downloader* mp_downloader;
|
kiwix::Downloader* mp_downloader;
|
||||||
ContentManagerView* mp_view;
|
ContentManagerView* mp_view;
|
||||||
int m_booksPerPage = 10;
|
|
||||||
int m_currentPage = 0;
|
|
||||||
int m_totalBooks = 0;
|
int m_totalBooks = 0;
|
||||||
bool m_local = true;
|
bool m_local = true;
|
||||||
QString m_currentLanguage;
|
QString m_currentLanguage;
|
||||||
void setCurrentPage(int currentPage) {
|
|
||||||
m_currentPage = max(0, min(currentPage, getNbPages()-1));
|
|
||||||
emit(booksChanged());
|
|
||||||
}
|
|
||||||
void setCurrentLanguage(QString language);
|
void setCurrentLanguage(QString language);
|
||||||
|
|
||||||
QStringList getBookIds();
|
QStringList getBookIds();
|
||||||
@ -52,16 +41,6 @@ signals:
|
|||||||
void currentLangChanged();
|
void currentLangChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
int getNbPages() {
|
|
||||||
auto nbBooks = m_local ? mp_library->getBookIds().length() : m_totalBooks;
|
|
||||||
return round(float(nbBooks) / m_booksPerPage);
|
|
||||||
}
|
|
||||||
int getStartBookIndex() {
|
|
||||||
return m_currentPage * m_booksPerPage;
|
|
||||||
}
|
|
||||||
int getEndBookIndex() {
|
|
||||||
return min((m_currentPage+1) * m_booksPerPage, mp_library->getBookIds().length());
|
|
||||||
}
|
|
||||||
QStringList getBookInfos(QString id, const QStringList &keys);
|
QStringList getBookInfos(QString id, const QStringList &keys);
|
||||||
void openBook(const QString& id);
|
void openBook(const QString& id);
|
||||||
QStringList updateDownloadInfos(QString id, const QStringList& keys);
|
QStringList updateDownloadInfos(QString id, const QStringList& keys);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user