~valavanisalex/ubuntu/maverick/scidavis/fix-604811

« back to all changes in this revision

Viewing changes to scidavis/src/future/table/TableCommentsHeaderModel.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ruben Molina
  • Date: 2009-09-06 11:34:04 UTC
  • Revision ID: james.westby@ubuntu.com-20090906113404-4awaey82l3686w4q
Tags: upstream-0.2.3
ImportĀ upstreamĀ versionĀ 0.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
    File                 : TableCommentsHeaderModel.cpp
 
3
    Project              : SciDAVis
 
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
 
9
 
 
10
 ***************************************************************************/
 
11
 
 
12
/***************************************************************************
 
13
 *                                                                         *
 
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.                                    *
 
18
 *                                                                         *
 
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.                           *
 
23
 *                                                                         *
 
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                                           *
 
28
 *                                                                         *
 
29
 ***************************************************************************/
 
30
 
 
31
#include "TableCommentsHeaderModel.h"
 
32
 
 
33
TableCommentsHeaderModel::TableCommentsHeaderModel( TableModel * table_model, QObject * parent )
 
34
        : QAbstractTableModel( parent ), d_table_model(table_model)
 
35
{
 
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)));
 
48
}
 
49
 
 
50
TableCommentsHeaderModel::~TableCommentsHeaderModel()
 
51
{
 
52
}
 
53
 
 
54
Qt::ItemFlags TableCommentsHeaderModel::flags(const QModelIndex & index ) const
 
55
{
 
56
        if (index.isValid())
 
57
                return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
 
58
        else
 
59
                return Qt::ItemIsEnabled;
 
60
}
 
61
 
 
62
 
 
63
QVariant TableCommentsHeaderModel::data(const QModelIndex &index, int role) const
 
64
{
 
65
        Q_UNUSED(index);
 
66
        Q_UNUSED(role);
 
67
        return QVariant();
 
68
}
 
69
 
 
70
QVariant TableCommentsHeaderModel::headerData(int section, Qt::Orientation orientation,
 
71
                int role) const
 
72
{
 
73
        if( orientation != Qt::Horizontal || role != Qt::DisplayRole || section < 0 || section >= columnCount())
 
74
                return QVariant();
 
75
 
 
76
        return QVariant(d_table_model->headerData(section, Qt::Horizontal, TableModel::CommentRole));
 
77
}
 
78
 
 
79
int TableCommentsHeaderModel::rowCount(const QModelIndex &parent) const
 
80
{
 
81
        Q_UNUSED(parent)
 
82
        return d_table_model->rowCount();
 
83
}
 
84
 
 
85
int TableCommentsHeaderModel::columnCount(const QModelIndex & parent) const
 
86
{
 
87
        Q_UNUSED(parent)
 
88
        return d_table_model->columnCount();
 
89
}
 
90