mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-07-04 13:17:08 -04:00
Edg 2286 browsing history of conversations (#92)
* WiP on thread view. * Missing db code. * Fixes in sericeDB, working on listView in threads window. * Changes in thread Db message. * Missing responseTo value bug tracking. * Fixed threads DB getter. * Show threads list. * Added missing code in service-db. * Small fixes. * WiP listView swich page. * Code clean-up. * Code formatted. * PR sugestions applied.
This commit is contained in:
65
module-apps/application-messages/widgets/ThreadModel.cpp
Normal file
65
module-apps/application-messages/widgets/ThreadModel.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* ThreadModel.cpp
|
||||
*
|
||||
* Created on: 15 lis 2019
|
||||
* Author: kuba
|
||||
*/
|
||||
|
||||
#include "ThreadModel.hpp"
|
||||
#include "ThreadItem.hpp"
|
||||
|
||||
#include "Application.hpp"
|
||||
|
||||
#include "../MessagesStyle.hpp"
|
||||
|
||||
#include "service-db/api/DBServiceAPI.hpp"
|
||||
ThreadModel::ThreadModel(app::Application *app) :
|
||||
DatabaseModel(app, messages::threads::pageSize) {
|
||||
|
||||
}
|
||||
|
||||
void ThreadModel::requestRecordsCount(void) {
|
||||
recordsCount = DBServiceAPI::ThreadGetCount(application);
|
||||
|
||||
if (recordsCount > 0) {
|
||||
|
||||
DBServiceAPI::ThreadGetLimitOffset(application, 0,
|
||||
messages::threads::pageSize);
|
||||
if (recordsCount >= messages::threads::pageSize) {
|
||||
DBServiceAPI::ThreadGetLimitOffset(application,
|
||||
messages::threads::pageSize, messages::threads::pageSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
bool ThreadModel::updateRecords(
|
||||
std::unique_ptr<std::vector<ThreadRecord>> records,
|
||||
const uint32_t offset, const uint32_t limit, uint32_t count) {
|
||||
DatabaseModel::updateRecords(std::move(records), offset, limit, count);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ThreadModel::requestRecords(uint32_t offset, uint32_t limit) {
|
||||
DBServiceAPI::ThreadGetLimitOffset(application, offset, limit);
|
||||
}
|
||||
|
||||
gui::ListItem* ThreadModel::getItem(int index, int fistElement, int prevElement,
|
||||
uint32_t limit, int remaining, bool topDown) {
|
||||
std::shared_ptr<ThreadRecord> thread = getRecord(index);
|
||||
|
||||
if (thread.get() == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto item = new gui::ThreadItem(this);
|
||||
if (item != nullptr) {
|
||||
item->setThreadItem(thread);
|
||||
item->setID(index);
|
||||
item->activatedCallback = [=](gui::Item &item) {
|
||||
LOG_INFO("ThreadItem ActivatedCallback");
|
||||
return true;
|
||||
};
|
||||
return item;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
Reference in New Issue
Block a user