File indexing completed on 2024-05-12 03:47:48

0001 /*
0002     File                 : MatrixModel.h
0003     Project              : LabPlot
0004     Description          : Matrix data model
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2015 Alexander Semke <alexander.semke@web.de>
0007     SPDX-FileCopyrightText: 2008-2009 Tilman Benkert <thzs@gmx.net>
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #ifndef MATRIXMODEL_H
0012 #define MATRIXMODEL_H
0013 
0014 #include <QAbstractItemModel>
0015 
0016 class Matrix;
0017 
0018 class MatrixModel : public QAbstractItemModel {
0019     Q_OBJECT
0020 
0021 public:
0022     explicit MatrixModel(Matrix*);
0023 
0024     //! \name Overloaded functions from QAbstractItemModel
0025     //@{
0026     Qt::ItemFlags flags(const QModelIndex&) const override;
0027     QVariant data(const QModelIndex& index, int role) const override;
0028     QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
0029     int rowCount(const QModelIndex& parent = QModelIndex()) const override;
0030     int columnCount(const QModelIndex& parent = QModelIndex()) const override;
0031     bool setData(const QModelIndex& index, const QVariant& value, int role) override;
0032     QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
0033     QModelIndex parent(const QModelIndex& child) const override;
0034     //@}
0035 
0036     void updateHeader();
0037     void setSuppressDataChangedSignal(bool);
0038     void setChanged();
0039 
0040 private Q_SLOTS:
0041     void handleColumnsAboutToBeInserted(int before, int count);
0042     void handleColumnsInserted(int first, int count);
0043     void handleColumnsAboutToBeRemoved(int first, int count);
0044     void handleColumnsRemoved(int first, int count);
0045     void handleRowsAboutToBeInserted(int before, int count);
0046     void handleRowsInserted(int first, int count);
0047     void handleRowsAboutToBeRemoved(int first, int count);
0048     void handleRowsRemoved(int first, int count);
0049     void handleDataChanged(int top, int left, int bottom, int right);
0050     void handleCoordinatesChanged();
0051     void handleFormatChanged();
0052 
0053 private:
0054     Matrix* m_matrix;
0055     bool m_suppressDataChangedSignal{false};
0056 
0057 Q_SIGNALS:
0058     void changed();
0059 };
0060 
0061 #endif