/
erhoof
/
telegraf
Обзор
Документация
Войти
/
erhoof
/
telegraf
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/data/chatfoldersmodel.h
51 строка
2 KB
mbarashkov
Выводим в меню чатов два счётчика
06 авг 2025, 17:40
06 авг 2025, 17:40
fb2af42
Код
Авторство
О чём код?
#pragma once #include <QObject> #include "../tdlib/tdlibresponsehandler.h" #include "chatfoldermodel.h" #include "chatfolderid.h" Q_DECLARE_METATYPE(QList<ChatFolderModel*>) Q_DECLARE_METATYPE(ChatFolderModel*) class ChatFoldersModel: public QObject { Q_OBJECT Q_PROPERTY(QList<QObject*> chatFolders READ getChatFolders NOTIFY chatFoldersChanged) Q_PROPERTY(QObject* selectedChatFolder READ getSelectedChatFolder NOTIFY selectedChatFolderChanged) public: explicit ChatFoldersModel(QObject *parent = Q_NULLPTR); static QObject* createSingleton(QQmlEngine*, QJSEngine*) { return instance; } static ChatFoldersModel* getInstance() { return instance; }; ChatFolderModel* getSelectedChatFolder() const { return findFolder(selectedChatFolderId); } ChatFolderModel* findFolder(ChatFolderId* chatFolderId) const; Q_INVOKABLE void selectChatFolder(ChatFolderId::Type type, qlonglong id) { selectedChatFolderId = new ChatFolderId(type, id, this); emit selectedChatFolderChanged(findFolder(selectedChatFolderId)); } signals: void chatFoldersChanged(const QList<QObject*> &chatFolders); void chatFolderChanged(ChatFolderModel *chatFolder); void selectedChatFolderChanged(ChatFolderModel *selectedChatFolder); void selectedChatUnreadCountChanged(int unreadCount); void selectedChatUnreadUnmutedCountChanged(int unreadCount); private slots: void handleChatFolders(const QVariantList &foldersInformation, qlonglong mainAllChatFolderPosition); void handleChatFolderInformation(const QVariantMap &chatFolderInformation); void handleUnreadChatCountUpdated(const QVariantMap &messageCountInformation); private: ChatFolderModel* findFolder(QString name) const; QList<QObject*> chatFolders; QList<QObject*> getChatFolders() const { return chatFolders; }; ChatFolderId* selectedChatFolderId; static ChatFoldersModel* instance; };