/
lmaxyz
/
telegraf
Обзор
Документация
Войти
/
lmaxyz
/
telegraf
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/data/chatfoldermodel.cpp
117 строк
3 KB
mbarashkov
Переработана и упрощена система учета непрочитанных в меню чатов
05 авг 2025, 16:58
05 авг 2025, 16:58
1fa07c3
Код
Авторство
О чём код?
#include "chatfoldermodel.h" ChatFolderModel::ChatFolderModel(QObject *parent): QObject(parent), id(ChatFolderId::Type::AllChats, 0), unreadCount(0) { } ChatFolderModel::ChatFolderModel(QMap<QString, QVariant> folder, ChatFolderId::Type type, QObject *parent): QObject(parent), id(type, folder["id"].toLongLong()), name(folder["name"].toMap()["text"].toMap()["text"].toString()), unreadCount(0) { } ChatFolderModel::ChatFolderModel(qlonglong id, QString name, ChatFolderId::Type type, QObject *parent): QObject(parent), id(type, id), name(name), unreadCount(0) { } bool ChatFolderModel::setProperties(QVariantMap properties) { auto updated = false; auto _exclude_archived = properties["exclude_archived"].toBool(); auto _exclude_muted = properties["exclude_muted"].toBool(); auto _exclude_read = properties["exclude_read"].toBool(); auto _include_bots = properties["include_bots"].toBool(); auto _include_contacts = properties["include_contacts"].toBool(); auto _include_channels = properties["include_channels"].toBool(); auto _include_groups = properties["include_groups"].toBool(); auto _include_non_contacts = properties["include_non_contacts"].toBool(); if(options[ExcludeArchived] != _exclude_archived) { options[ExcludeArchived] = _exclude_archived; updated = true; } if(options[ExcludeMuted] != _exclude_muted) { options[ExcludeMuted] = _exclude_muted; updated = true; } if(options[ExcludeRead] != _exclude_read) { options[ExcludeRead] = _exclude_read; updated = true; } if(options[IncludeBots] != _include_bots) { options[IncludeBots] = _include_bots; updated = true; } if(options[IncludeContacts] != _include_contacts) { options[IncludeContacts] = _include_contacts; updated = true; } if(options[IncludeChannels] != _include_channels) { options[IncludeChannels] = _include_channels; updated = true; } if(options[IncludeGroups] != _include_groups) { options[IncludeGroups] = _include_groups; updated = true; } if(options[IncludeNonContacts] != _include_non_contacts) { options[IncludeNonContacts] = _include_non_contacts; updated = true; } auto __includedChatIds = properties["included_chat_ids"].toList(); QList<qlonglong> _includedChatIds; for (const auto &id: __includedChatIds){ _includedChatIds.push_back(id.toLongLong()); } if(includedChatIds != _includedChatIds) { includedChatIds = _includedChatIds; updated = true; } auto __excludedChatIds = properties["excluded_chat_ids"].toList(); QList<qlonglong> _excludedChatIds; for (const auto &id: __excludedChatIds){ _excludedChatIds.push_back(id.toLongLong()); } if(excludedChatIds != _excludedChatIds) { excludedChatIds = _excludedChatIds; updated = true; } auto __pinnedChatIds = properties["pinned_chat_ids"].toList(); QList<qlonglong> _pinned_chat_ids; for (const auto &id: __pinnedChatIds){ _pinned_chat_ids.push_back(id.toLongLong()); } if(pinnedChatIds != _pinned_chat_ids) { pinnedChatIds = _pinned_chat_ids; updated = true; } return updated; } bool ChatFolderModel::getOptionValue(ChatFolderModel::Option option) const { if(!options.contains(option)) { return false; } return options.value(option); }