File indexing completed on 2024-05-12 15:27:03
0001 /*************************************************************************** 0002 File : MatrixModel.h 0003 Project : LabPlot 0004 Description : Matrix data model 0005 -------------------------------------------------------------------- 0006 Copyright : (C) 2015 Alexander Semke (alexander.semke@web.de) 0007 Copyright : (C) 2008-2009 Tilman Benkert (thzs@gmx.net) 0008 0009 ***************************************************************************/ 0010 0011 /*************************************************************************** 0012 * * 0013 * This program 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 * This program 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, write to the Free Software * 0025 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 0026 * Boston, MA 02110-1301 USA * 0027 * * 0028 ***************************************************************************/ 0029 0030 #ifndef MATRIXMODEL_H 0031 #define MATRIXMODEL_H 0032 0033 #include <QAbstractItemModel> 0034 0035 class Matrix; 0036 0037 class MatrixModel : public QAbstractItemModel { 0038 Q_OBJECT 0039 0040 public: 0041 explicit MatrixModel(Matrix*); 0042 0043 //! \name Overloaded functions from QAbstractItemModel 0044 //@{ 0045 Qt::ItemFlags flags(const QModelIndex&) const override; 0046 QVariant data(const QModelIndex& index, int role) const override; 0047 QVariant headerData(int section, Qt::Orientation orientation,int role = Qt::DisplayRole) const override; 0048 int rowCount(const QModelIndex& parent = QModelIndex()) const override; 0049 int columnCount(const QModelIndex& parent = QModelIndex()) const override; 0050 bool setData(const QModelIndex& index, const QVariant& value, int role) override; 0051 QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; 0052 QModelIndex parent(const QModelIndex& child) const override; 0053 //@} 0054 0055 void updateHeader(); 0056 void setSuppressDataChangedSignal(bool); 0057 void setChanged(); 0058 0059 private slots: 0060 void handleColumnsAboutToBeInserted(int before, int count); 0061 void handleColumnsInserted(int first, int count); 0062 void handleColumnsAboutToBeRemoved(int first, int count); 0063 void handleColumnsRemoved(int first, int count); 0064 void handleRowsAboutToBeInserted(int before, int count); 0065 void handleRowsInserted(int first, int count); 0066 void handleRowsAboutToBeRemoved(int first, int count); 0067 void handleRowsRemoved(int first, int count); 0068 void handleDataChanged(int top, int left, int bottom, int right); 0069 void handleCoordinatesChanged(); 0070 void handleFormatChanged(); 0071 0072 private: 0073 Matrix* m_matrix; 0074 bool m_suppressDataChangedSignal{false}; 0075 0076 signals: 0077 void changed(); 0078 }; 0079 0080 #endif