SciDAVis  1.D4
TableDoubleHeaderView.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : TableDoubleHeaderView.h
3  Project : SciDAVis
4  --------------------------------------------------------------------
5  Copyright : (C) 2007 by Tilman Benkert,
6  Email (use @ for *) : thzs*gmx.net
7  Description : Horizontal header for TableView displaying comments in a second header
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 
30 #ifndef TABLEDOUBLEHEADERVIEW_H
31 #define TABLEDOUBLEHEADERVIEW_H
32 
33 #include <QHeaderView>
34 #include "TableModel.h"
35 
37 
46 class TableCommentsHeaderView : public QHeaderView
47 {
48  Q_OBJECT
49 
50  public:
51  TableCommentsHeaderView(QWidget *parent = 0);
52  virtual ~TableCommentsHeaderView();
53 
54  virtual void setModel(QAbstractItemModel * model);
55 
56  friend class TableDoubleHeaderView; // access to paintSection (protected)
57 };
58 
60 /*
61  * This class is only to be used by TableView.
62  * It allows for displaying two horizontal headers.
63  * A TableDoubleHeaderView displays the column name, plot designation, and
64  * type icon in a normal QHeaderView and below that a second header
65  * which displays the column comments.
66  *
67  * \sa TableCommentsHeaderView
68  * \sa QHeaderView
69  */
70 class TableDoubleHeaderView : public QHeaderView
71 {
72  Q_OBJECT
73 
74  private:
76 
77  public:
78  TableDoubleHeaderView(QWidget * parent = 0);
80 
81  virtual void setModel(QAbstractItemModel * model);
82  virtual QSize sizeHint () const;
84  void showComments(bool on = true);
86  bool areCommentsShown() const;
87 
88  public slots:
89  // adjust geometry and repaint header
90  void refresh();
91  // React to a header data change
92  void headerDataChanged(Qt::Orientation orientation, int logicalFirst, int logicalLast);
93 
94  protected slots:
95  void sectionsInserted(const QModelIndex & parent, int logicalFirst, int logicalLast);
96 
97  protected:
98  virtual void paintSection(QPainter * painter, const QRect & rect, int logicalIndex) const;
99 
102 };
103 
104 
105 
106 
107 #endif // #ifndef TABLEDOUBLEHEADERVIEW_H