2
Copyright (C) 2008 Michael Jansen <kde@michael-jansen.biz>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library 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 GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
Boston, MA 02110-1301, USA.
20
#include "hotkeys_tree_view.h"
21
#include "hotkeys_context_menu.h"
23
#include "hotkeys_model.h"
25
#include "actions/actions.h"
26
#include "action_data/action_data_group.h"
27
#include "action_data/simple_action_data.h"
29
#include "KDE/KLocale"
32
#include <QtGui/QContextMenuEvent>
35
HotkeysTreeView::HotkeysTreeView( QWidget *parent )
38
setObjectName("khotkeys treeview");
39
setAllColumnsShowFocus(true);
42
setDropIndicatorShown(true);
46
HotkeysTreeView::~HotkeysTreeView()
51
HotkeysTreeView::contextMenuEvent( QContextMenuEvent *event )
53
QModelIndex index = indexAt(event->pos());
54
// KHotKeys::ActionDataBase *item = model()->indexToActionDataBase(index);
55
HotkeysTreeViewContextMenu menu( index, this );
56
menu.exec(event->globalPos());
61
HotkeysTreeView::modelReset()
63
resizeColumnToContents(KHotkeysModel::NameColumn);
67
KHotkeysModel *HotkeysTreeView::model()
69
return dynamic_cast<KHotkeysModel*>( QTreeView::model() );
74
HotkeysTreeView::setModel( QAbstractItemModel *model )
76
if (!dynamic_cast<KHotkeysModel*>( model ))
78
Q_ASSERT(dynamic_cast<KHotkeysModel*>( model ));
81
QTreeView::setModel(model);
83
setAllColumnsShowFocus(true);
84
setAlternatingRowColors(true);
86
setSelectionBehavior( QAbstractItemView::SelectRows );
87
setSelectionMode( QAbstractItemView::SingleSelection );
90
model, SIGNAL(modelReset()),
91
this, SLOT(modelReset()));
93
resizeColumnToContents(KHotkeysModel::EnabledColumn);
94
resizeColumnToContents(KHotkeysModel::NameColumn);
97
#include "moc_hotkeys_tree_view.cpp"