File indexing completed on 2024-05-12 05:39:51
0001 /*************************************************************************** 0002 * Copyright (C) 2019 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 CONNECTIONPROFILEMODEL_H 0021 #define CONNECTIONPROFILEMODEL_H 0022 0023 #include <QAbstractListModel> 0024 #include <QObject> 0025 #include <core_global.h> 0026 #include <memory> 0027 class ConnectionProfile; 0028 class CORE_EXPORT ProfileModel : public QAbstractListModel 0029 { 0030 Q_OBJECT 0031 public: 0032 enum CustomRole 0033 { 0034 NameRole= Qt::UserRole + 1, 0035 IndexRole 0036 }; 0037 Q_ENUM(CustomRole) 0038 /** 0039 * @brief ProfileModel 0040 */ 0041 ProfileModel(); 0042 /** 0043 * @brief ~ProfileModel 0044 */ 0045 virtual ~ProfileModel(); 0046 /** 0047 * @brief rowCount 0048 * @param parent 0049 * @return 0050 */ 0051 virtual int rowCount(const QModelIndex& parent= QModelIndex()) const override; 0052 /** 0053 * @brief data 0054 * @param index 0055 * @param role 0056 * @return 0057 */ 0058 virtual QVariant data(const QModelIndex& index, int role) const override; 0059 /** 0060 * @brief headerData 0061 * @param section 0062 * @param orientation 0063 * @param role 0064 * @return 0065 */ 0066 QVariant headerData(int section, Qt::Orientation orientation, int role= Qt::DisplayRole) const override; 0067 0068 Qt::ItemFlags flags(const QModelIndex& index) const override; 0069 void removeProfile(int idx); 0070 0071 ConnectionProfile* getProfile(const QModelIndex&); 0072 0073 int cloneProfile(int index); 0074 0075 int indexOf(ConnectionProfile* tmp); 0076 ConnectionProfile* getProfile(int index); 0077 0078 QHash<int, QByteArray> roleNames() const override; 0079 public slots: 0080 /** 0081 * @brief ProfileModel::appendProfile 0082 */ 0083 void appendProfile(); 0084 /** 0085 * @brief append profile with param 0086 * @param profile 0087 */ 0088 void appendProfile(ConnectionProfile* profile); 0089 0090 signals: 0091 void profileAdded(ConnectionProfile* prof); 0092 0093 private: 0094 std::vector<std::unique_ptr<ConnectionProfile>> m_connectionProfileList; 0095 }; 0096 0097 #endif // CONNECTIONPROFILEMODEL_H