mirror of
https://github.com/YACReader/yacreader
synced 2025-09-12 16:24:56 -04:00
added comic vine pagination and sorting volumes by column
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
#include <QDebug>
|
||||
|
||||
ResponseParser::ResponseParser(QObject *parent) :
|
||||
QObject(parent),error(false),numResults(-1)
|
||||
QObject(parent),error(false),numResults(-1),currentPage(-1),totalPages(-1)
|
||||
{
|
||||
}
|
||||
|
||||
@ -18,6 +18,16 @@ qint32 ResponseParser::getNumResults()
|
||||
return numResults;
|
||||
}
|
||||
|
||||
qint32 ResponseParser::getCurrentPage()
|
||||
{
|
||||
return currentPage;
|
||||
}
|
||||
|
||||
qint32 ResponseParser::getTotalPages()
|
||||
{
|
||||
return totalPages;
|
||||
}
|
||||
|
||||
void ResponseParser::loadJSONResponse(const QString &response)
|
||||
{
|
||||
QScriptEngine engine;
|
||||
@ -36,5 +46,16 @@ void ResponseParser::loadJSONResponse(const QString &response)
|
||||
numResults = sc.property("number_of_total_results").toString().toInt();// sc.property("number_of_total_results").toInt32();
|
||||
else
|
||||
qDebug() << sc.property("oops").toString();
|
||||
|
||||
int limit = sc.property("limit").toInt32();
|
||||
int offset = sc.property("offset").toInt32();
|
||||
int total = sc.property("number_of_total_results").toInt32();
|
||||
if(limit > 0)
|
||||
{
|
||||
totalPages = (total / limit) + (total%limit>0?1:0);
|
||||
currentPage = (offset / limit) + 1;
|
||||
}
|
||||
else
|
||||
totalPages = currentPage = 1;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ public:
|
||||
explicit ResponseParser(QObject *parent = 0);
|
||||
bool responseError();
|
||||
qint32 getNumResults();
|
||||
qint32 getCurrentPage();
|
||||
qint32 getTotalPages();
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
@ -18,6 +20,8 @@ public slots:
|
||||
protected:
|
||||
bool error;
|
||||
qint32 numResults;
|
||||
qint32 currentPage;
|
||||
qint32 totalPages;
|
||||
};
|
||||
|
||||
#endif // RESPONSE_PARSER_H
|
||||
|
Reference in New Issue
Block a user