Warning, file /rolisteam/rolisteam/src/libraries/core/include/network/channelmodel.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #ifndef CHANNELMODEL_H
0002 #define CHANNELMODEL_H
0003 
0004 #include <QAbstractItemModel>
0005 #include <QMimeData>
0006 #include <QObject>
0007 
0008 #include "network/channel.h"
0009 #include "network/networkmessagereader.h"
0010 #include "network/networkmessagewriter.h"
0011 #include "network/serverconnection.h"
0012 #include "network_global.h"
0013 
0014 class NETWORK_EXPORT ClientMimeData : public QMimeData
0015 {
0016     Q_OBJECT
0017 public:
0018     ClientMimeData();
0019     void addClient(ServerConnection* m, const QModelIndex);
0020     const QMap<QModelIndex, ServerConnection*>& getList() const;
0021     virtual bool hasFormat(const QString& mimeType) const;
0022 
0023 private:
0024     QMap<QModelIndex, ServerConnection*> m_clientList;
0025 };
0026 /**
0027  * @brief The ChannelModel class
0028  */
0029 class NETWORK_EXPORT ChannelModel : public QAbstractItemModel
0030 {
0031     Q_OBJECT
0032 public:
0033     ChannelModel();
0034     ~ChannelModel();
0035 
0036     virtual int rowCount(const QModelIndex& parent) const;
0037     QModelIndex index(int row, int column, const QModelIndex& parent) const;
0038     virtual QModelIndex parent(const QModelIndex& child) const;
0039     virtual int columnCount(const QModelIndex& parent) const;
0040     QVariant data(const QModelIndex& index, int role) const;
0041 
0042     bool setData(const QModelIndex& index, const QVariant& value, int role);
0043 
0044     QString addChannel(QString name, QByteArray password);
0045     bool addConnectionToChannel(QString chanId, ServerConnection* client);
0046 
0047     void readSettings();
0048     void writeSettings();
0049 
0050     bool addConnectionToDefaultChannel(ServerConnection* client);
0051     Qt::ItemFlags flags(const QModelIndex& index) const;
0052     bool hasChildren(const QModelIndex& parent) const;
0053 
0054     void kick(const QString&, bool isAdmin, const QString& senderId);
0055 
0056     TreeItem* getItemById(QString id) const;
0057     ServerConnection* getServerConnectionById(QString id) const;
0058 
0059     bool isAdmin(const QString& id) const;
0060     bool isGM(const QString& id, const QString& chanId) const;
0061 
0062     QModelIndex addChannelToIndex(Channel* channel, const QModelIndex& parent);
0063     bool addChannelToChannel(Channel* child, Channel* parent);
0064     QModelIndex channelToIndex(Channel* channel);
0065 
0066     void setLocalPlayerId(const QString& id);
0067 
0068     void removeChild(QString id);
0069     QStringList mimeTypes() const;
0070     Qt::DropActions supportedDropActions() const;
0071     QMimeData* mimeData(const QModelIndexList& indexes) const;
0072     bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
0073 
0074     void cleanUp();
0075     void emptyChannelMemory();
0076     void renameChannel(const QString& senderId, const QString& id, const QString& value);
0077     bool moveClient(Channel* origin, const QString& id, Channel* dest);
0078 
0079     const QList<TreeItem*>& modelData();
0080     void resetData(QList<TreeItem*> data);
0081 signals:
0082     void totalSizeChanged(quint64);
0083     void localPlayerGMChanged(QString id);
0084     void modelChanged();
0085     void channelNameChanged(QString id, QString name);
0086 
0087 public slots:
0088     void setChannelMemorySize(Channel* chan, quint64);
0089 
0090 protected:
0091     bool moveMediaItem(QList<ServerConnection*> items, const QModelIndex& parentToBe, int row,
0092                        QList<QModelIndex>& formerPosition);
0093 
0094     void appendChannel(Channel* channel);
0095     bool localIsGM() const;
0096 
0097 private:
0098     std::pair<quint64, QString> convert(quint64 size) const;
0099 
0100 private:
0101     QList<TreeItem*> m_root;
0102     std::map<Channel*, quint64> m_sizeMap;
0103     QString m_defaultChannel;
0104     QString m_localPlayerId;
0105     bool m_admin= false;
0106     bool m_shield= false;
0107 };
0108 
0109 #endif // CHANNELMODEL_H