Sébastien Blin | 1f91576 | 2020-08-03 13:27:42 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 by Savoir-faire Linux |
| 3 | * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #pragma once |
| 20 | |
| 21 | #include "lrcinstance.h" |
| 22 | #include "qmladapterbase.h" |
| 23 | #include "smartlistmodel.h" |
| 24 | |
| 25 | #include <QObject> |
| 26 | #include <QString> |
| 27 | |
| 28 | class ConversationsAdapter : public QmlAdapterBase |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | |
| 32 | public: |
| 33 | explicit ConversationsAdapter(QObject *parent = nullptr); |
| 34 | ~ConversationsAdapter(); |
| 35 | |
| 36 | Q_INVOKABLE bool connectConversationModel(); |
| 37 | Q_INVOKABLE void selectConversation(const QString &accountId, |
| 38 | const QString &convUid, |
| 39 | bool preventSendingSignal = true); |
| 40 | Q_INVOKABLE void selectConversation(int index); |
| 41 | Q_INVOKABLE void deselectConversation(); |
| 42 | Q_INVOKABLE void accountChangedSetUp(const QString &accountId); |
| 43 | Q_INVOKABLE void updateConversationsFilterWidget(); |
| 44 | Q_INVOKABLE void setConversationFilter(const QString &type); |
| 45 | |
| 46 | signals: |
| 47 | void showChatView(const QString &accountId, const QString &convUid); |
| 48 | void showConversationTabs(bool visible); |
| 49 | |
| 50 | private: |
| 51 | void initQmlObject() override; |
| 52 | void setConversationFilter(lrc::api::profile::Type filter); |
| 53 | void backToWelcomePage(); |
| 54 | bool selectConversation(const lrc::api::conversation::Info &item, |
| 55 | bool preventSendingSignal = true); |
| 56 | void updateConversationForNewContact(const QString &convUid); |
| 57 | |
| 58 | SmartListModel *conversationSmartListModel_; |
| 59 | |
| 60 | lrc::api::profile::Type currentTypeFilter_{}; |
| 61 | |
| 62 | /* |
| 63 | * Connections. |
| 64 | */ |
| 65 | QMetaObject::Connection modelSortedConnection_; |
| 66 | QMetaObject::Connection modelUpdatedConnection_; |
| 67 | QMetaObject::Connection filterChangedConnection_; |
| 68 | QMetaObject::Connection newConversationConnection_; |
| 69 | QMetaObject::Connection conversationRemovedConnection_; |
| 70 | QMetaObject::Connection newInteractionConnection_; |
| 71 | QMetaObject::Connection conversationClearedConnection; |
| 72 | QMetaObject::Connection selectedCallChanged_; |
| 73 | QMetaObject::Connection smartlistSelectionConnection_; |
| 74 | QMetaObject::Connection interactionRemovedConnection_; |
| 75 | }; |