labplot  2.8.2
About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.
  Fossies Dox: labplot-2.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

SpreadsheetCommentsHeaderModel.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  File : SpreadsheetCommentsHeaderModel.cpp
3  Project : LabPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2007 by Tilman Benkert (thzs@gmx.net)
6 
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  * This program is distributed in the hope that it will be useful, *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19  * GNU General Public License for more details. *
20  * *
21  * You should have received a copy of the GNU General Public License *
22  * along with this program; if not, write to the Free Software *
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
24  * Boston, MA 02110-1301 USA *
25  * *
26  ***************************************************************************/
27 
29 
30  /*!
31  \class SpreadsheetCommentsHeaderModel
32  \brief Model class wrapping a SpreadsheetModel to display column comments in a SpreadsheetCommentsHeaderView
33 
34  \ingroup commonfrontend
35  */
36 
38  : QAbstractTableModel(parent), m_spreadsheet_model(spreadsheet_model) {
39 
40  connect(m_spreadsheet_model, &SpreadsheetModel::headerDataChanged,
41  this, &SpreadsheetCommentsHeaderModel::headerDataChanged);
42  connect(m_spreadsheet_model, &SpreadsheetModel::headerDataChanged,
43  this, &SpreadsheetCommentsHeaderModel::headerDataChanged);
44  connect(m_spreadsheet_model, &SpreadsheetModel::columnsAboutToBeInserted,
45  this, &SpreadsheetCommentsHeaderModel::columnsAboutToBeInserted);
46  connect(m_spreadsheet_model, &SpreadsheetModel::columnsAboutToBeRemoved,
47  this, &SpreadsheetCommentsHeaderModel::columnsAboutToBeRemoved);
48  connect(m_spreadsheet_model, &SpreadsheetModel::columnsInserted,
49  this, &SpreadsheetCommentsHeaderModel::columnsInserted);
50  connect(m_spreadsheet_model, &SpreadsheetModel::columnsRemoved,
51  this, &SpreadsheetCommentsHeaderModel::columnsRemoved);
52 }
53 
54 Qt::ItemFlags SpreadsheetCommentsHeaderModel::flags(const QModelIndex& index ) const {
55  if (index.isValid())
56  return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
57  else
58  return Qt::ItemIsEnabled;
59 }
60 
61 QVariant SpreadsheetCommentsHeaderModel::data(const QModelIndex& index, int role) const {
62  Q_UNUSED(index);
63  Q_UNUSED(role);
64  return QVariant();
65 }
66 
67 QVariant SpreadsheetCommentsHeaderModel::headerData(int section, Qt::Orientation orientation, int role) const {
68  if (orientation != Qt::Horizontal || role != Qt::DisplayRole || section < 0 || section >= columnCount())
69  return QVariant();
70 
71  return QVariant(m_spreadsheet_model->headerData(section, Qt::Horizontal, static_cast<int>(SpreadsheetModel::CustomDataRole::CommentRole)));
72 }
73 
74 int SpreadsheetCommentsHeaderModel::rowCount(const QModelIndex& parent) const{
75  Q_UNUSED(parent)
76  return m_spreadsheet_model->rowCount();
77 }
78 
79 int SpreadsheetCommentsHeaderModel::columnCount(const QModelIndex& parent) const{
80  Q_UNUSED(parent)
82 }
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role) const override
SpreadsheetCommentsHeaderModel(SpreadsheetModel *, QObject *parent=nullptr)
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Qt::ItemFlags flags(const QModelIndex &) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Model for the access to a Spreadsheet.
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
@ CommentRole
the column comment (for headerData())
int rowCount(const QModelIndex &parent=QModelIndex()) const override
int columnCount(const QModelIndex &parent=QModelIndex()) const override