1 /* 2 SPDX-FileCopyrightText: 2008 Sebastian Trueg <trueg@k3b.org> 3 SPDX-FileCopyrightText: 2010 Michal Malek <michalm@jabster.pl> 4 SPDX-FileCopyrightText: 1998-2008 Sebastian Trueg <trueg@k3b.org> 5 SPDX-License-Identifier: GPL-2.0-or-later 6 */ 7 8 #ifndef _K3B_VIEW_COLUMN_ADJUSTER_H_ 9 #define _K3B_VIEW_COLUMN_ADJUSTER_H_ 10 11 #include <QList> 12 #include <QObject> 13 14 class QEvent; 15 class QTreeView; 16 17 namespace K3b { 18 class ViewColumnAdjuster : public QObject 19 { 20 Q_OBJECT 21 22 public: 23 explicit ViewColumnAdjuster( QObject* parent = 0 ); 24 explicit ViewColumnAdjuster( QTreeView* parent ); 25 ~ViewColumnAdjuster() override; 26 27 /** 28 * Takes header into account if not hidden. 29 */ 30 int columnSizeHint( int col ) const; 31 32 /** 33 * Sets the view column adjuster operates on. 34 * Call this *after* calling setModel() on view, 35 * otherwise column adjuster won't work. 36 */ 37 void setView( QTreeView* view ); 38 void addFixedColumn( int ); 39 40 void setColumnMargin( int column, int margin ); 41 int columnMargin( int column ) const; 42 43 bool eventFilter( QObject* watched, QEvent* event ) override; 44 45 Q_SIGNALS: 46 /** 47 * If something is connected to this slot, adjustColumns 48 * will not be called automatically. 49 */ 50 void columnsNeedAjusting(); 51 52 public Q_SLOTS: 53 void adjustColumns(); 54 55 private: 56 class Private; 57 Private* const d; 58 59 Q_PRIVATE_SLOT( d, void _k_adjustColumns() ) 60 }; 61 } 62 63 #endif 64