1
/***************************************************************************
2
File : TableCommentsHeaderModel.cpp
4
--------------------------------------------------------------------
5
Copyright : (C) 2007 by Tilman Benkert,
6
Email (use @ for *) : thzs*gmx.net
7
Description : Model wrapping a TableModel to display column
8
comments in a TableCommentsHeaderView
10
***************************************************************************/
12
/***************************************************************************
14
* This program is free software; you can redistribute it and/or modify *
15
* it under the terms of the GNU General Public License as published by *
16
* the Free Software Foundation; either version 2 of the License, or *
17
* (at your option) any later version. *
19
* This program is distributed in the hope that it will be useful, *
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22
* GNU General Public License for more details. *
24
* You should have received a copy of the GNU General Public License *
25
* along with this program; if not, write to the Free Software *
26
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
27
* Boston, MA 02110-1301 USA *
29
***************************************************************************/
31
#include "TableCommentsHeaderModel.h"
33
TableCommentsHeaderModel::TableCommentsHeaderModel( TableModel * table_model, QObject * parent )
34
: QAbstractTableModel( parent ), d_table_model(table_model)
36
connect(d_table_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
37
this, SIGNAL(headerDataChanged(Qt::Orientation,int,int)));
38
connect(d_table_model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
39
this, SIGNAL(headerDataChanged(Qt::Orientation,int,int)));
40
connect(d_table_model, SIGNAL(columnsAboutToBeInserted(const QModelIndex&,int,int)),
41
this, SIGNAL(columnsAboutToBeInserted(const QModelIndex&,int,int)));
42
connect(d_table_model, SIGNAL(columnsAboutToBeRemoved(const QModelIndex&,int,int)),
43
this, SIGNAL(columnsAboutToBeRemoved(const QModelIndex&,int,int)));
44
connect(d_table_model, SIGNAL(columnsInserted(const QModelIndex&,int,int)),
45
this, SIGNAL(columnsInserted(const QModelIndex&,int,int)));
46
connect(d_table_model, SIGNAL(columnsRemoved(const QModelIndex&,int,int)),
47
this, SIGNAL(columnsRemoved(const QModelIndex&,int,int)));
50
TableCommentsHeaderModel::~TableCommentsHeaderModel()
54
Qt::ItemFlags TableCommentsHeaderModel::flags(const QModelIndex & index ) const
57
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
59
return Qt::ItemIsEnabled;
63
QVariant TableCommentsHeaderModel::data(const QModelIndex &index, int role) const
70
QVariant TableCommentsHeaderModel::headerData(int section, Qt::Orientation orientation,
73
if( orientation != Qt::Horizontal || role != Qt::DisplayRole || section < 0 || section >= columnCount())
76
return QVariant(d_table_model->headerData(section, Qt::Horizontal, TableModel::CommentRole));
79
int TableCommentsHeaderModel::rowCount(const QModelIndex &parent) const
82
return d_table_model->rowCount();
85
int TableCommentsHeaderModel::columnCount(const QModelIndex & parent) const
88
return d_table_model->columnCount();