File indexing completed on 2024-12-08 04:34:10
0001 /* 0002 SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 #include "room.h" 0009 #include <QTreeView> 0010 0011 #include "libruqolawidgets_private_export.h" 0012 0013 class RoomFilterProxyModel; 0014 class RoomListHeadingsProxyModel; 0015 class ChannelListDelegate; 0016 class RocketChatAccount; 0017 0018 class LIBRUQOLAWIDGETS_TESTS_EXPORT ChannelListView : public QTreeView 0019 { 0020 Q_OBJECT 0021 public: 0022 struct ChannelSelectedInfo { 0023 QString roomId; 0024 QString roomName; 0025 Room::RoomType roomType; 0026 Utils::AvatarInfo avatarInfo; 0027 }; 0028 0029 explicit ChannelListView(QWidget *parent = nullptr); 0030 ~ChannelListView() override; 0031 0032 [[nodiscard]] RoomFilterProxyModel *filterModel() const; 0033 0034 void selectChannelRequested(const QString &channelId, const QString &messageId); 0035 void selectNextUnreadChannel(); 0036 0037 enum class Direction { 0038 Up, 0039 Down, 0040 }; 0041 void selectNextChannel(Direction direction = Direction::Down, bool switchToNextUnreadChannel = false); 0042 0043 [[nodiscard]] bool selectChannelByRoomNameRequested(const QString &selectedRoomName); 0044 0045 void channelSelected(const QModelIndex &index); 0046 0047 void setCurrentRocketChatAccount(RocketChatAccount *currentRocketChatAccount); 0048 [[nodiscard]] bool selectChannelByRoomIdRequested(const QString &identifier); 0049 0050 Q_SIGNALS: 0051 void roomSelected(const ChannelListView::ChannelSelectedInfo &roomInfo); 0052 void roomPressed(const QString &roomId); 0053 void selectMessageIdRequested(const QString &messageId); 0054 0055 protected: 0056 void contextMenuEvent(QContextMenuEvent *event) override; 0057 0058 private: 0059 LIBRUQOLAWIDGETS_NO_EXPORT void slotClicked(const QModelIndex &index); 0060 LIBRUQOLAWIDGETS_NO_EXPORT void slotHideChannel(const QModelIndex &index, Room::RoomType roomType); 0061 LIBRUQOLAWIDGETS_NO_EXPORT void slotLeaveChannel(const QModelIndex &index, Room::RoomType roomType); 0062 LIBRUQOLAWIDGETS_NO_EXPORT void slotChangeFavorite(const QModelIndex &index, bool isFavorite); 0063 LIBRUQOLAWIDGETS_NO_EXPORT void slotMarkAsChannel(const QModelIndex &index, bool markAsRead); 0064 LIBRUQOLAWIDGETS_NO_EXPORT void slotConvertToTeam(const QModelIndex &index, Room::RoomType roomType); 0065 LIBRUQOLAWIDGETS_NO_EXPORT void slotChannelConvertToTeamDone(const QJsonObject &obj); 0066 LIBRUQOLAWIDGETS_NO_EXPORT void slotGroupConvertToTeamDone(const QJsonObject &obj); 0067 LIBRUQOLAWIDGETS_NO_EXPORT void slotMoveToTeam(const QModelIndex &index); 0068 LIBRUQOLAWIDGETS_NO_EXPORT void slotConvertToChannel(const QModelIndex &index); 0069 LIBRUQOLAWIDGETS_NO_EXPORT void slotConfigureNotification(Room *room); 0070 [[nodiscard]] LIBRUQOLAWIDGETS_NO_EXPORT bool selectChannelByRoomIdOrRoomName(const QString &id, bool roomId); 0071 LIBRUQOLAWIDGETS_NO_EXPORT void slotRoomRemoved(const QString &roomId); 0072 LIBRUQOLAWIDGETS_NO_EXPORT void slotPressed(const QModelIndex &index); 0073 0074 ChannelListDelegate *const mChannelListDelegate; 0075 RoomListHeadingsProxyModel *const mRoomListHeadingsProxyModel; 0076 RoomFilterProxyModel *const mRoomFilterProxyModel; 0077 QPointer<RocketChatAccount> mCurrentRocketChatAccount; 0078 QMetaObject::Connection mUpdateChannelViewConnect; 0079 }; 0080 Q_DECLARE_TYPEINFO(ChannelListView::ChannelSelectedInfo, Q_RELOCATABLE_TYPE);