Пример #1
0
void RecentChatService::update(Chat chat) const
{
    if (isRecent(chat) && !isAlreadyInRepository(chat))
        m_recentChatRepository->addRecentChat(chat);
    if (!isRecent(chat))
        remove(chat);
}
Пример #2
0
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);
}
Пример #3
0
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);
}
Пример #4
0
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_);
}