void RecentChatService::update(Chat chat) const { if (isRecent(chat) && !isAlreadyInRepository(chat)) m_recentChatRepository->addRecentChat(chat); if (!isRecent(chat)) remove(chat); }
bool RecentChatService::isRecent(Chat chat) const { if (!chat.hasProperty(LAST_MESSAGE_DATE_TIME_PROPERTY)) return false; auto dateTime = chat.property(LAST_MESSAGE_DATE_TIME_PROPERTY, QDateTime{}).toDateTime(); return isRecent(dateTime); }
void RecentChatService::cleanUp() { auto oldChats = std::vector<Chat>{}; for (auto chat : m_recentChatRepository) if (!isRecent(chat)) oldChats.push_back(chat); for (auto chat : oldChats) remove(chat); }
bool EntryData::isWritable() const { Notebook *b = book(); if (!b || b->isReadOnly()) return false; if (isUnlocked()) return true; if (isEmpty()) return true; return isRecent() && App::instance()->cui()->match(cui_); }