Warning, file /rolisteam/rolisteam/src/libraries/core/include/network/characterdatamodel.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /*************************************************************************** 0002 * Copyright (C) 2020 by Renaud Guezennec * 0003 * http://www.rolisteam.org/contact * 0004 * * 0005 * This software is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 #ifndef CHARACTERDATAMODEL_H 0021 #define CHARACTERDATAMODEL_H 0022 0023 #include "network/network_type.h" 0024 #include "network_global.h" 0025 #include <QAbstractTableModel> 0026 #include <QPointer> 0027 0028 class ConnectionProfile; 0029 class NETWORK_EXPORT CharacterDataModel : public QAbstractListModel 0030 { 0031 Q_OBJECT 0032 0033 public: 0034 enum Role 0035 { 0036 None= Qt::UserRole + 1, 0037 Avatar, 0038 Color, 0039 AvatarData, 0040 Name 0041 }; 0042 explicit CharacterDataModel(QObject* parent= nullptr); 0043 0044 // Basic functionality: 0045 int rowCount(const QModelIndex& parent= QModelIndex()) const override; 0046 QVariant data(const QModelIndex& index, int role= Qt::DisplayRole) const override; 0047 Qt::ItemFlags flags(const QModelIndex& index) const override; 0048 0049 // Add data 0050 connection::CharacterData character(int i) const; 0051 0052 QHash<int, QByteArray> roleNames() const override; 0053 0054 public slots: 0055 bool insertCharacter(); 0056 void setProfile(ConnectionProfile* profile); 0057 bool addCharacter(const connection::CharacterData& data); 0058 bool removeCharacter(int index); 0059 0060 void setAvatar(int i, const QByteArray& img); 0061 void setName(int i, const QString& string); 0062 void setColor(int i, const QColor& color); 0063 0064 private: 0065 QPointer<ConnectionProfile> m_profile; 0066 }; 0067 0068 #endif // CHARACTERDATAMODEL_H