2020-09-03 09:24:49 -04:00
|
|
|
/*!
|
2020-08-03 13:27:42 -04:00
|
|
|
* Copyright (C) 2020 by Savoir-faire Linux
|
|
|
|
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "lrcinstance.h"
|
|
|
|
#include "qmladapterbase.h"
|
|
|
|
#include "smartlistmodel.h"
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
|
2020-09-03 09:24:49 -04:00
|
|
|
class ConversationsAdapter final : public QmlAdapterBase
|
2020-08-03 13:27:42 -04:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-09-04 17:53:24 -04:00
|
|
|
explicit ConversationsAdapter(QObject* parent = nullptr);
|
2020-09-03 09:24:49 -04:00
|
|
|
~ConversationsAdapter() = default;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void safeInit() override;
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-03 09:24:49 -04:00
|
|
|
public:
|
2020-09-01 14:41:53 -04:00
|
|
|
Q_INVOKABLE bool connectConversationModel(bool updateFilter = true);
|
|
|
|
Q_INVOKABLE void disconnectConversationModel();
|
2020-09-04 17:53:24 -04:00
|
|
|
Q_INVOKABLE void selectConversation(const QString& accountId,
|
|
|
|
const QString& convUid,
|
2020-08-03 13:27:42 -04:00
|
|
|
bool preventSendingSignal = true);
|
2020-09-04 17:53:24 -04:00
|
|
|
Q_INVOKABLE void selectConversation(const QString& uid);
|
2020-08-03 13:27:42 -04:00
|
|
|
Q_INVOKABLE void deselectConversation();
|
2020-09-01 14:41:53 -04:00
|
|
|
Q_INVOKABLE void refill();
|
2020-08-03 13:27:42 -04:00
|
|
|
Q_INVOKABLE void updateConversationsFilterWidget();
|
2020-09-04 17:53:24 -04:00
|
|
|
Q_INVOKABLE void setConversationFilter(const QString& type);
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
signals:
|
2020-09-04 17:53:24 -04:00
|
|
|
void showChatView(const QString& accountId, const QString& convUid);
|
2020-08-03 13:27:42 -04:00
|
|
|
void showConversationTabs(bool visible);
|
2020-09-04 17:53:24 -04:00
|
|
|
void showSearchStatus(const QString& status);
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-03 09:24:49 -04:00
|
|
|
void modelChanged(const QVariant& model);
|
|
|
|
void modelSorted(const QVariant& uri);
|
|
|
|
void updateListViewRequested();
|
|
|
|
void navigateToWelcomePageRequested();
|
|
|
|
|
2020-09-04 17:53:24 -04:00
|
|
|
private slots:
|
|
|
|
void onCurrentAccountIdChanged();
|
|
|
|
|
2020-08-03 13:27:42 -04:00
|
|
|
private:
|
|
|
|
void setConversationFilter(lrc::api::profile::Type filter);
|
|
|
|
void backToWelcomePage();
|
2020-09-04 17:53:24 -04:00
|
|
|
bool selectConversation(const lrc::api::conversation::Info& item,
|
2020-08-03 13:27:42 -04:00
|
|
|
bool preventSendingSignal = true);
|
2020-09-04 17:53:24 -04:00
|
|
|
void updateConversationForNewContact(const QString& convUid);
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-04 17:53:24 -04:00
|
|
|
SmartListModel* conversationSmartListModel_;
|
2020-08-03 13:27:42 -04:00
|
|
|
|
2020-09-04 17:53:24 -04:00
|
|
|
lrc::api::profile::Type currentTypeFilter_ {};
|
2020-08-03 13:27:42 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Connections.
|
|
|
|
*/
|
|
|
|
QMetaObject::Connection modelSortedConnection_;
|
|
|
|
QMetaObject::Connection modelUpdatedConnection_;
|
|
|
|
QMetaObject::Connection filterChangedConnection_;
|
|
|
|
QMetaObject::Connection newConversationConnection_;
|
|
|
|
QMetaObject::Connection conversationRemovedConnection_;
|
|
|
|
QMetaObject::Connection conversationClearedConnection;
|
|
|
|
QMetaObject::Connection selectedCallChanged_;
|
|
|
|
QMetaObject::Connection smartlistSelectionConnection_;
|
|
|
|
QMetaObject::Connection interactionRemovedConnection_;
|
2020-08-18 17:21:28 +02:00
|
|
|
QMetaObject::Connection searchStatusChangedConnection_;
|
|
|
|
QMetaObject::Connection searchResultUpdatedConnection_;
|
2020-08-03 13:27:42 -04:00
|
|
|
};
|