not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / khotkeys / kcm_hotkeys / hotkeys_model.h
blob74d14b339d56d3b64620d576489ec48eec52d1bc
1 /*
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.
19 #ifndef KHOTKEYSMODEL_H
20 #define KHOTKEYSMODEL_H
22 #include "libkhotkeysfwd.h"
23 #include "settings.h"
25 #include <QtCore/QAbstractItemModel>
28 /**
30 class KHotkeysModel : public QAbstractItemModel
32 Q_OBJECT
34 public:
36 enum ItemType {
37 Other //!< Some unknown action type
38 ,ActionDataGroup //!< A shortcut group
39 ,SimpleActionData
42 enum Column {
43 NameColumn = 0,
44 EnabledColumn,
45 IsGroupColumn,
46 TypeColumn };
48 /**
49 * Default constructor
51 * @param
53 KHotkeysModel( QObject *parent = 0 );
55 /**
56 * Destructor
58 virtual ~KHotkeysModel();
60 /**
61 * Standard methods required by Qt model/view framework
63 //@{
64 QModelIndex index( int, int, const QModelIndex &parent = QModelIndex() ) const;
65 QModelIndex parent( const QModelIndex &index ) const;
66 int rowCount( const QModelIndex &index ) const;
67 int columnCount( const QModelIndex &index ) const;
68 QVariant headerData( int section, Qt::Orientation, int role = Qt::DisplayRole ) const;
69 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const;
70 //@}
72 bool removeRows( int row, int count, const QModelIndex &parent );
73 QModelIndex addGroup( const QModelIndex &parent );
74 QModelIndex insertActionData( KHotKeys::ActionDataBase *data, const QModelIndex &parent );
75 bool setData( const QModelIndex &index, const QVariant &value, int role );
77 Qt::ItemFlags flags( const QModelIndex &index ) const;
79 /**
80 * Support dropping
82 bool dropMimeData(
83 const QMimeData *data
84 ,Qt::DropAction action
85 ,int row
86 ,int column
87 ,const QModelIndex &parent);
88 QMimeData *mimeData(const QModelIndexList &indexes) const;
89 QStringList mimeTypes() const;
91 /**
92 * Get the KHotKeys::ActionDataBase behind the index.
94 KHotKeys::ActionDataBase *indexToActionDataBase( const QModelIndex &index ) const;
96 /**
97 * Get the KHotKeys::ActionDataBase behind the index or 0.
99 * Getting 0 doesn't mean the index is invalid. It means you provided a
100 * action object.
102 KHotKeys::ActionDataGroup *indexToActionDataGroup( const QModelIndex &index ) const;
105 * Load the settings from the file
107 void load();
109 /**
110 * Move @p element to @p newGroup at @position.
112 * @param element move this element
113 * @param newGroup to this group
114 * @param position and put it at this position. default is last
116 * @return @c true if moved, @c false if not.
118 bool moveElement(
119 KHotKeys::ActionDataBase *element
120 ,KHotKeys::ActionDataGroup *newGroup
121 ,int position = -1);
123 * Save the settings to the file
125 void save();
127 void emitChanged( KHotKeys::ActionDataBase *item );
129 private:
132 KHotKeys::Settings _settings;
133 KHotKeys::ActionDataGroup *_actions;
136 #endif /* #ifndef KHOTKEYSMODEL_HPP */