File indexing completed on 2024-04-28 05:38:03
0001 #ifndef CHANNELLISTPANEL_H 0002 #define CHANNELLISTPANEL_H 0003 0004 #include <QWidget> 0005 #include <memory> 0006 0007 #include "controller/networkcontroller.h" 0008 #include "network/channelmodel.h" 0009 #include "network/networkmessagereader.h" 0010 #include "network/networkmessagewriter.h" 0011 #include "rwidgets_global.h" 0012 0013 namespace Ui 0014 { 0015 class ChannelListPanel; 0016 } 0017 0018 class RWIDGET_EXPORT ChannelListPanel : public QWidget 0019 { 0020 Q_OBJECT 0021 0022 public: 0023 enum Group 0024 { 0025 VIEWER= 0x0, 0026 GAMEMASTER= 0x1, 0027 ADMIN= 0x2 0028 }; 0029 Q_DECLARE_FLAGS(Groups, Group) 0030 0031 explicit ChannelListPanel(NetworkController* ctrl, QWidget* parent= nullptr); 0032 virtual ~ChannelListPanel(); 0033 0034 void processMessage(NetworkMessageReader* msg); 0035 // void sendOffModel(); 0036 0037 ChannelListPanel::Groups currentGroups() const; 0038 void setCurrentGroups(const Groups& currentGroups); 0039 0040 bool isAdmin(); 0041 bool isGM(); 0042 template <typename T> 0043 T indexToPointer(QModelIndex index); 0044 0045 QString serverName() const; 0046 void setServerName(const QString& serverName); 0047 0048 void setLocalPlayerId(const QString& id); 0049 0050 void cleanUp(); 0051 0052 ServerConnection* getClient(QModelIndex index); 0053 Channel* getChannel(QModelIndex index); 0054 signals: 0055 void CurrentChannelGmIdChanged(QString gm); 0056 0057 public slots: 0058 void showCustomMenu(QPoint pos); 0059 void sendOffLoginAdmin(QByteArray str= QByteArray()); 0060 0061 protected: 0062 void moveUserToCurrent(); 0063 protected slots: 0064 void addChannelAsSibbling(); 0065 void lockChannel(); 0066 void kickUser(); 0067 void banUser(); 0068 void addChannel(); 0069 void setPasswordOnChannel(); 0070 void deleteChannel(); 0071 void joinChannel(); 0072 void editChannel(); 0073 void logAsAdmin(); 0074 void resetChannel(); 0075 0076 private: 0077 Ui::ChannelListPanel* ui; 0078 QPointer<NetworkController> m_ctrl; 0079 0080 QAction* m_edit= nullptr; 0081 QAction* m_lock= nullptr; 0082 QAction* m_join= nullptr; 0083 QAction* m_ban= nullptr; 0084 QAction* m_channelPassword= nullptr; 0085 QAction* m_addChannel= nullptr; 0086 QAction* m_addSubchannel= nullptr; 0087 QAction* m_deleteChannel= nullptr; 0088 QAction* m_setDefault= nullptr; 0089 QAction* m_admin= nullptr; 0090 QAction* m_kick= nullptr; 0091 QAction* m_resetChannel= nullptr; 0092 QAction* m_moveUserToCurrentChannel= nullptr; 0093 0094 Groups m_currentGroups; 0095 QModelIndex m_index; 0096 QString m_serverName; 0097 QString m_localPlayerId; 0098 }; 0099 0100 Q_DECLARE_OPERATORS_FOR_FLAGS(ChannelListPanel::Groups) 0101 0102 #endif // CHANNELLISTPANEL_H