File indexing completed on 2024-04-28 08:27:01
0001 /*************************************************************************** 0002 * Copyright 2007 Niko Sams <niko.sams@gmail.com> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify * 0005 * it under the terms of the GNU General Public License as published by * 0006 * the Free Software Foundation; either version 2 of the License, or * 0007 * (at your option) any later version. * 0008 * * 0009 ***************************************************************************/ 0010 0011 #ifndef ALLPROFILESMODEL_H 0012 #define ALLPROFILESMODEL_H 0013 0014 #include <QAbstractListModel> 0015 #include <QList> 0016 0017 namespace KDevelop { 0018 class IProject; 0019 } 0020 class UploadProfileModel; 0021 class UploadProfileItem; 0022 class UploadPlugin; 0023 0024 /** 0025 * Model that lists upload-profiles of all open projects. 0026 * 0027 * Signals from the individual UploadProfileModels are translated 0028 * to the new index and emitted (reset, dataChange, rowInsert*, rowRemove*). 0029 * This translation works only for single-row models - like UploadProfileModels. 0030 */ 0031 class AllProfilesModel : public QAbstractListModel 0032 { 0033 Q_OBJECT 0034 0035 public: 0036 AllProfilesModel(UploadPlugin* plugin, QObject *parent = nullptr); 0037 ~AllProfilesModel() override; 0038 0039 QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override; 0040 int rowCount(const QModelIndex & parent = QModelIndex()) const override; 0041 0042 /** 0043 * Returns a UploadProfileItem for a ModelIndex. 0044 */ 0045 UploadProfileItem* uploadItem(const QModelIndex& index) const; 0046 0047 /** 0048 * Returns a UploadProfileItem for a row 0049 */ 0050 UploadProfileItem* uploadItem(int row, int column = 0) const; 0051 0052 /** 0053 * Adds a UploadProfileModel, usually called when a project was opened 0054 */ 0055 void addModel(UploadProfileModel* m); 0056 0057 /** 0058 * Removes a UploadProfileModel, usually called when a project was closed 0059 */ 0060 void removeModel(UploadProfileModel* m); 0061 0062 private Q_SLOTS: 0063 //translate signals from sourceModels: 0064 void sourceReset(); 0065 void sourceDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); 0066 void sourceRowsAboutToBeInserted(const QModelIndex& parent, int start, int end); 0067 void sourceRowsInserted(); 0068 void sourceRowsAboutToBeRemoved(const QModelIndex& parent, int start, int end); 0069 void sourceRowsRemoved(); 0070 0071 private: 0072 QList<UploadProfileModel*> m_sourceModels; 0073 UploadPlugin* m_plugin; 0074 }; 0075 0076 0077 #endif 0078 // kate: space-indent on; indent-width 4; tab-width 4; replace-tabs on