2 * Copyright (C) 2007 by Mathias Soeken <msoeken@tzi.de>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the
16 * Free Software Foundation, Inc.
17 * 51 Franklin Street, Fifth Floor
18 * Boston, MA 02110-1301 USA.
22 #ifndef TREEVIEWHEADERCONTEXTMENU_H
23 #define TREEVIEWHEADERCONTEXTMENU_H
36 * ContextMenu for QTreeView::header() to toggle the
37 * visible state of the columns.
39 * It is possible to exclude columns from inserting in the
40 * menu either by the @p excludedColumns parameter in the constructor,
41 * by #addExcludedColumn or #addExcludedColumns.
43 * You can also change the display style of the items in the menu.
45 * @author Mathias Soeken <msoeken@tzi.de>
47 class TreeViewHeaderContextMenu
: public QObject
{
49 Q_PROPERTY(int style READ style
)
50 Q_PROPERTY(KMenu
* menu READ menu
)
53 enum { AlwaysCheckBox
, CheckBoxOnChecked
, ShowHideText
};
56 explicit TreeViewHeaderContextMenu( QObject
*parent
, QTreeView
*widget
, int style
= AlwaysCheckBox
, QVector
<int> excludedColumns
= QVector
<int>() );
57 ~TreeViewHeaderContextMenu();
60 void updateAction( QAction
*action
, int column
);
63 void slotCustomContextMenuRequested( const QPoint
& );
67 void slotTriggered( QAction
* );
68 void slotAboutToShow();
72 QVector
<QAction
*> mActions
;
75 QHash
<QAction
*, int> mActionColumnMapping
;
76 QVector
<int> mExcludedColumns
;
79 int style() const { return mStyle
; }
80 void addExcludedColumn( int column
) { mExcludedColumns
<< column
; updateActions(); }
81 void addExcludedColumns( QVector
<int> columns
) { mExcludedColumns
<< columns
; updateActions(); }
82 KMenu
*menu() const { return mContextMenu
; }
85 void columnToggled( int );