File indexing completed on 2024-05-12 15:27:38
0001 /*************************************************************************** 0002 File : SpreadsheetHeaderView.h 0003 Project : LabPlot 0004 -------------------------------------------------------------------- 0005 Copyright : (C) 2016 Alexander Semke (alexander.semke@web.de) 0006 Copyright : (C) 2007 by Tilman Benkert (thzs@gmx.net) 0007 Description : Horizontal header for SpreadsheetView displaying comments in a second header 0008 0009 ***************************************************************************/ 0010 0011 /*************************************************************************** 0012 * * 0013 * This program is free software; you can redistribute it and/or modify * 0014 * it under the terms of the GNU General Public License as published by * 0015 * the Free Software Foundation; either version 2 of the License, or * 0016 * (at your option) any later version. * 0017 * * 0018 * This program is distributed in the hope that it will be useful, * 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0021 * GNU General Public License for more details. * 0022 * * 0023 * You should have received a copy of the GNU General Public License * 0024 * along with this program; if not, write to the Free Software * 0025 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 0026 * Boston, MA 02110-1301 USA * 0027 * * 0028 ***************************************************************************/ 0029 0030 #ifndef SPREADSHEETHEADERVIEW_H 0031 #define SPREADSHEETHEADERVIEW_H 0032 0033 #include <QHeaderView> 0034 0035 class SpreadsheetCommentsHeaderView : public QHeaderView { 0036 Q_OBJECT 0037 0038 public: 0039 explicit SpreadsheetCommentsHeaderView(QWidget* parent = nullptr); 0040 ~SpreadsheetCommentsHeaderView() override; 0041 0042 void setModel(QAbstractItemModel*) override; 0043 friend class SpreadsheetHeaderView; // access to paintSection (protected) 0044 }; 0045 0046 class SpreadsheetHeaderView : public QHeaderView { 0047 Q_OBJECT 0048 0049 public: 0050 explicit SpreadsheetHeaderView(QWidget* parent = nullptr); 0051 ~SpreadsheetHeaderView() override; 0052 0053 void setModel(QAbstractItemModel*) override; 0054 QSize sizeHint () const override; 0055 0056 void showComments(bool on = true); 0057 bool areCommentsShown() const; 0058 0059 private: 0060 SpreadsheetCommentsHeaderView* m_slave; 0061 bool m_showComments; 0062 0063 private slots: 0064 void refresh(); 0065 void headerDataChanged(Qt::Orientation, int logicalFirst, int logicalLast); 0066 0067 protected: 0068 void paintSection(QPainter*, const QRect&, int logicalIndex) const override; 0069 }; 0070 0071 #endif