[EGD-3040] ListItemProvider refactored to abstract class

[EGD-3040] ListView & ListItemProvider cleanups
This commit is contained in:
Przemyslaw Brudny
2020-04-22 21:21:21 +02:00
committed by PrzeBrudny
parent 94c0226c46
commit fb056774f5
18 changed files with 317 additions and 372 deletions

View File

@@ -11,7 +11,7 @@
#include "NotesModel.hpp"
NotesModel::NotesModel(app::Application *app) : DatabaseModel(app, 3)
NotesModel::NotesModel(app::Application *app) : DatabaseModel(app, 4)
{}
NotesModel::~NotesModel()
@@ -27,9 +27,9 @@ void NotesModel::requestRecordsCount()
// request first and second page if possible
if (recordsCount > 0) {
DBServiceAPI::NotesGetLimitOffset(application, 0, pageSize);
if (recordsCount > pageSize) {
DBServiceAPI::NotesGetLimitOffset(application, pageSize, pageSize);
}
// if (recordsCount > pageSize) {
// DBServiceAPI::NotesGetLimitOffset(application, pageSize, pageSize);
// }
}
}
@@ -44,19 +44,20 @@ bool NotesModel::updateRecords(std::unique_ptr<std::vector<NotesRecord>> records
uint32_t count)
{
// LOG_INFO("Offset: %d, Limit: %d Count:%d", offset, limit, count);
// for( uint32_t i=0; i<records.get()->size(); ++i ) {
// LOG_INFO("id: %d, filename: %s", records.get()->operator [](i).ID, records.get()->operator
//[](i).path.c_str());
// }
LOG_INFO("Offset: %d, Limit: %d Count:%d", offset, limit, count);
for( uint32_t i=0; i<records.get()->size(); ++i ) {
LOG_INFO("id: %d, filename: %s", records.get()->operator [](i).ID, records.get()->operator
[](i).path.c_str());
}
listDataAvailable = true;
DatabaseModel::updateRecords(std::move(records), offset, limit, count);
return true;
}
gui::ListItem *NotesModel::getItem(
int index, int firstElement, int prevElement, uint32_t count, int remaining, bool topDown)
gui::ListItem *NotesModel::getItem(int index)
{
std::shared_ptr<NotesRecord> note = getRecord(index);