File indexing completed on 2024-04-28 05:52:07

0001 /*
0002     SPDX-FileCopyrightText: 2007-2009 Stefan Böhmann <kde@hilefoks.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 #ifndef TEALISTMODEL_H
0007 #define TEALISTMODEL_H
0008 
0009 #include <QAbstractTableModel>
0010 
0011 class Tea;
0012 
0013 
0014 /**
0015  * @short provides an model used by SettingsDialog
0016  *
0017  * @author Stefan Böhmann <kde@hilefoks.org>
0018  */
0019 class TeaListModel : public QAbstractTableModel
0020 {
0021 
0022     public:
0023         /**
0024          * Constructs an TeaListModel with the given list of Teas and for the given parent.
0025          * @param teas the initial list of teas to manage.
0026          * @param parent the parent object.
0027          */
0028         explicit TeaListModel(const QList<Tea> &teas, QObject *parent = nullptr);
0029 
0030         /**
0031          * Returns the index of the item in the model specified by the given row, column and parent index.
0032          * @param row the row.
0033          * @param column the column.
0034          * @param parent will be ignored by this model.
0035          *
0036          * @return @ref QModelIndex with the index of the item.
0037          */
0038         QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const override;
0039 
0040         /**
0041          * Returns the number of rows.
0042          * @param parent will be ignored by this model.
0043          *
0044          * @return the number of rows.
0045          */
0046         int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0047 
0048         /**
0049          * Returns the number of columns.
0050          * @param parent will be ignored by this model.
0051          *
0052          * @return the number of columns.
0053          */
0054         int columnCount(const QModelIndex &parent = QModelIndex()) const override;
0055 
0056         /**
0057          * Returns the data stored under the given role for the item referred to by the index.
0058          * @param index the index of the item.
0059          * @param role the role
0060          *
0061          * @return the specified data.
0062          */
0063         QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0064 
0065         /**
0066          * Sets the role data for the item at index to value.
0067          * @param index the index of the item.
0068          * @param value the new value for the item.
0069          * @param role the role.
0070          *
0071          * @return if successful true, otherwise false.
0072          */
0073         bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
0074 
0075         /**
0076          * Returns the data for the given role and section in the header with the specified orientation.
0077          * @param section the section.
0078          * @param orientation the orientation.
0079          * @param role the role.
0080          *
0081          * @return the specified data.
0082          */
0083         QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
0084 
0085         /**
0086          * inserts rows into the model before the given one.
0087          *
0088          * @param row the row - if 0 the new rows will be insert before any exists rows.
0089          * @param count number of rows to add.
0090          * @param parent will be ignored by this model.
0091          *
0092          * @return true if the rows were successfully inserted, otherwise false.
0093          */
0094         bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
0095 
0096         /**
0097          * removes rows from the model, starting with the given row.
0098          * @param row the first row to remove.
0099          * @param count number of rows to remove.
0100          * @param parent will be ignored by this model.
0101          *
0102          * @return true if the rows were successfully removed, otherwise false.
0103          */
0104         bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
0105 
0106         /**
0107          * Returns the whole list of teas.
0108          *
0109          * @return list of teas.
0110          */
0111         const QList<Tea> getTeaList() const;
0112 
0113     private:
0114         QList<Tea> m_tealist;
0115 };
0116 
0117 #endif
0118 
0119 // kate: word-wrap off; encoding utf-8; indent-width 4; tab-width 4; line-numbers on; mixed-indent off; remove-trailing-space-save on; replace-tabs-save on; replace-tabs on; space-indent on;
0120 // vim:set spell et sw=4 ts=4 nowrap cino=l1,cs,U1: