File indexing completed on 2025-03-16 05:18:27
0001 /* 0002 * Copyright 2018 by Marco Martin <mart@kde.org> 0003 * 0004 * Licensed under the Apache License, Version 2.0 (the "License"); 0005 * you may not use this file except in compliance with the License. 0006 * You may obtain a copy of the License at 0007 * 0008 * http://www.apache.org/licenses/LICENSE-2.0 0009 * 0010 * Unless required by applicable law or agreed to in writing, software 0011 * distributed under the License is distributed on an "AS IS" BASIS, 0012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0013 * See the License for the specific language governing permissions and 0014 * limitations under the License. 0015 * 0016 */ 0017 0018 #pragma once 0019 0020 #include <QAbstractListModel> 0021 0022 class AbstractDelegate; 0023 class DelegatesModel; 0024 0025 class SessionDataModel : public QAbstractListModel 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 0031 explicit SessionDataModel(QObject *parent = nullptr); 0032 virtual ~SessionDataModel(); 0033 0034 /** 0035 * Insert new data in the model, at a given position 0036 */ 0037 void insertData(int position, const QList<QVariantMap> &dataList); 0038 0039 /** 0040 * update the value of items from position to dataList.count() 0041 * for each key contained in dataList. 0042 * keys not present will not be updated 0043 */ 0044 void updateData(int position, const QList<QVariantMap> &dataList); 0045 0046 /** 0047 * clears the whole model 0048 */ 0049 void clear(); 0050 0051 //REIMPLEMENTED 0052 bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override; 0053 bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; 0054 int rowCount(const QModelIndex &parent = QModelIndex()) const override; 0055 QVariant data(const QModelIndex &index, int role = Qt::UserRole + 1) const override; 0056 QHash<int, QByteArray> roleNames() const override; 0057 0058 private: 0059 QHash<int, QByteArray> m_roles; 0060 QList<QVariantMap> m_data; 0061 }; 0062 0063