File indexing completed on 2024-05-19 04:55:53
0001 /** 0002 * \file batchimportsourcesmodel.h 0003 * Context menu commands configuration table model. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 2 Jan 2013 0008 * 0009 * Copyright (C) 2013-2024 Urs Fleisch 0010 * 0011 * This file is part of Kid3. 0012 * 0013 * Kid3 is free software; you can redistribute it and/or modify 0014 * it under the terms of the GNU General Public License as published by 0015 * the Free Software Foundation; either version 2 of the License, or 0016 * (at your option) any later version. 0017 * 0018 * Kid3 is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * You should have received a copy of the GNU General Public License 0024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0025 */ 0026 0027 #pragma once 0028 0029 #include <QAbstractTableModel> 0030 #include "batchimportprofile.h" 0031 #include "kid3api.h" 0032 0033 /** 0034 * Context menu commands configuration table model. 0035 */ 0036 class KID3_CORE_EXPORT BatchImportSourcesModel : public QAbstractTableModel { 0037 Q_OBJECT 0038 public: 0039 /** 0040 * Constructor. 0041 * @param parent parent widget 0042 */ 0043 explicit BatchImportSourcesModel(QObject* parent = nullptr); 0044 0045 /** 0046 * Destructor. 0047 */ 0048 ~BatchImportSourcesModel() override = default; 0049 0050 /** 0051 * Get item flags for index. 0052 * @param index model index 0053 * @return item flags 0054 */ 0055 Qt::ItemFlags flags(const QModelIndex& index) const override; 0056 0057 /** 0058 * Get data for a given role. 0059 * @param index model index 0060 * @param role item data role 0061 * @return data for role 0062 */ 0063 QVariant data(const QModelIndex& index, 0064 int role = Qt::DisplayRole) const override; 0065 0066 /** 0067 * Set data for a given role. 0068 * @param index model index 0069 * @param value data value 0070 * @param role item data role 0071 * @return true if successful 0072 */ 0073 bool setData(const QModelIndex& index, const QVariant& value, 0074 int role = Qt::EditRole) override; 0075 0076 /** 0077 * Get data for header section. 0078 * @param section column or row 0079 * @param orientation horizontal or vertical 0080 * @param role item data role 0081 * @return header data for role 0082 */ 0083 QVariant headerData(int section, Qt::Orientation orientation, 0084 int role = Qt::DisplayRole) const override; 0085 0086 /** 0087 * Set data for header section. 0088 * Not supported. 0089 * @return false 0090 */ 0091 bool setHeaderData(int, Qt::Orientation, const QVariant&, 0092 int = Qt::EditRole) override { return false; } 0093 0094 /** 0095 * Get number of rows. 0096 * @param parent parent model index, invalid for table models 0097 * @return number of rows, 0098 * if parent is valid number of children (0 for table models) 0099 */ 0100 int rowCount(const QModelIndex& parent = QModelIndex()) const override; 0101 0102 /** 0103 * Get number of columns. 0104 * @param parent parent model index, invalid for table models 0105 * @return number of columns, 0106 * if parent is valid number of children (0 for table models) 0107 */ 0108 int columnCount(const QModelIndex& parent = QModelIndex()) const override; 0109 0110 /** 0111 * Insert rows. 0112 * @param row rows are inserted before this row, if 0 at the begin, 0113 * if rowCount() at the end 0114 * @param count number of rows to insert 0115 * @param parent parent model index, invalid for table models 0116 * @return true if successful 0117 */ 0118 bool insertRows(int row, int count, 0119 const QModelIndex& parent = QModelIndex()) override; 0120 0121 /** 0122 * Remove rows. 0123 * @param row rows are removed starting with this row 0124 * @param count number of rows to remove 0125 * @param parent parent model index, invalid for table models 0126 * @return true if successful 0127 */ 0128 bool removeRows(int row, int count, 0129 const QModelIndex& parent = QModelIndex()) override; 0130 0131 /** 0132 * Set batch import source of a given @a row. 0133 * @param row number of row to set 0134 * @param source batch import source 0135 */ 0136 void setBatchImportSource(int row, const BatchImportProfile::Source& source); 0137 0138 /** 0139 * Get batch import source of a given @a row. 0140 * @param row number of row to get 0141 * @param source the batch import source is returned here 0142 */ 0143 void getBatchImportSource(int row, BatchImportProfile::Source& source) const; 0144 0145 /** 0146 * Set the model from the import sources. 0147 * @param sources batch import sources 0148 */ 0149 void setBatchImportSources(const QList<BatchImportProfile::Source>& sources); 0150 0151 /** 0152 * Get the import sources from the model. 0153 * @return batch import sources. 0154 */ 0155 QList<BatchImportProfile::Source> getBatchImportSources() const; 0156 0157 private: 0158 QList<BatchImportProfile::Source> m_sources; 0159 };