blob: 9fbcac45910544ce7eab02a76f4f377867216a3c [file] [log] [blame]
Sébastien Blin1f915762020-08-03 13:27:42 -04001/*
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
28class ConversationsAdapter : public QmlAdapterBase
29{
30 Q_OBJECT
31
32public:
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
46signals:
47 void showChatView(const QString &accountId, const QString &convUid);
48 void showConversationTabs(bool visible);
49
Sébastien Blin5f35e192020-08-06 15:24:57 -040050public slots:
51 void slotAccountChanged();
52
Sébastien Blin1f915762020-08-03 13:27:42 -040053private:
54 void initQmlObject() override;
55 void setConversationFilter(lrc::api::profile::Type filter);
56 void backToWelcomePage();
57 bool selectConversation(const lrc::api::conversation::Info &item,
58 bool preventSendingSignal = true);
59 void updateConversationForNewContact(const QString &convUid);
60
61 SmartListModel *conversationSmartListModel_;
62
63 lrc::api::profile::Type currentTypeFilter_{};
64
65 /*
66 * Connections.
67 */
68 QMetaObject::Connection modelSortedConnection_;
69 QMetaObject::Connection modelUpdatedConnection_;
70 QMetaObject::Connection filterChangedConnection_;
71 QMetaObject::Connection newConversationConnection_;
72 QMetaObject::Connection conversationRemovedConnection_;
73 QMetaObject::Connection newInteractionConnection_;
74 QMetaObject::Connection conversationClearedConnection;
75 QMetaObject::Connection selectedCallChanged_;
76 QMetaObject::Connection smartlistSelectionConnection_;
77 QMetaObject::Connection interactionRemovedConnection_;
78};