/
lmaxyz
/
telegraf
Обзор
Документация
Войти
/
lmaxyz
/
telegraf
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/data/chatfoldermodel.h
71 строка
3 KB
mbarashkov
Выводим в меню чатов два счётчика
06 авг 2025, 17:40
06 авг 2025, 17:40
fb2af42
Код
Авторство
О чём код?
#pragma once #include <QObject> #include <QMap> #include <QVariant> #include "chatfolderid.h" #include "../debuglog.h" class ChatFolderModel: public QObject { Q_OBJECT Q_PROPERTY(QString name READ getName NOTIFY nameChanged); Q_PROPERTY(qlonglong id READ getTdLibId NOTIFY idChanged); Q_PROPERTY(qint32 unreadCount READ getUnreadCount WRITE setUnreadCount NOTIFY unreadCountChanged); Q_PROPERTY(qint32 unreadUnmutedCount READ getUnreadUnmutedCount WRITE setUnreadUnmutedCount NOTIFY unreadUnmutedCountChanged); Q_PROPERTY(ChatFolderId::Type type READ getType CONSTANT); public: ChatFolderModel(QObject *parent = Q_NULLPTR); ChatFolderModel(QMap<QString, QVariant> folder, ChatFolderId::Type type, QObject *parent = Q_NULLPTR); ChatFolderModel(qlonglong id, QString name, ChatFolderId::Type type, QObject *parent = Q_NULLPTR); enum Option { ExcludeArchived, ExcludeMuted, ExcludeRead, IncludeBots, IncludeContacts, IncludeChannels, IncludeGroups, IncludeNonContacts }; bool setProperties(QVariantMap properties); bool getOptionValue(ChatFolderModel::Option option) const; bool isIncluded(qlonglong chatId) const { return includedChatIds.contains(chatId); } bool isExcluded(qlonglong chatId) const { return excludedChatIds.contains(chatId); } bool isPinned(qlonglong chatId) const { return pinnedChatIds.contains(chatId); } QString getName() const { return name; } QList<qlonglong> getPinnedChatIds() const { return pinnedChatIds; } qlonglong getTdLibId() const { return id.getTdLibId(); } ChatFolderId::Type getType() const { return id.getType(); } qint32 getUnreadCount() const { return unreadCount; } void setUnreadCount(qint32 unreadCount) { this->unreadCount = unreadCount; emit unreadCountChanged(unreadCount); } qint32 getUnreadUnmutedCount() const { return unreadUnmutedCount; } void setUnreadUnmutedCount(qint32 unreadUnmutedCount) { this->unreadUnmutedCount = unreadUnmutedCount; emit unreadUnmutedCountChanged(unreadUnmutedCount); } signals: void nameChanged(const QString name); void idChanged(const qlonglong id); void unreadCountChanged(const qint32 unreadCount); void unreadUnmutedCountChanged(const qint32 unreadCount); private: ChatFolderId id; QString name; QList<qlonglong> includedChatIds; QList<qlonglong> pinnedChatIds; QList<qlonglong> excludedChatIds; QMap<Option, bool> options; qint32 unreadCount; qint32 unreadUnmutedCount; };