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"
25 #include <QtCore/QAbstractItemModel>
30 class KHotkeysModel
: public QAbstractItemModel
37 Other
//!< Some unknown action type
38 ,ActionDataGroup
//!< A shortcut group
53 KHotkeysModel( QObject
*parent
= 0 );
58 virtual ~KHotkeysModel();
61 * Standard methods required by Qt model/view framework
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;
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;
84 ,Qt::DropAction action
87 ,const QModelIndex
&parent
);
88 QMimeData
*mimeData(const QModelIndexList
&indexes
) const;
89 QStringList
mimeTypes() const;
92 * Get the KHotKeys::ActionDataBase behind the index.
94 KHotKeys::ActionDataBase
*indexToActionDataBase( const QModelIndex
&index
) const;
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
102 KHotKeys::ActionDataGroup
*indexToActionDataGroup( const QModelIndex
&index
) const;
105 * Load the settings from the file
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.
119 KHotKeys::ActionDataBase
*element
120 ,KHotKeys::ActionDataGroup
*newGroup
123 * Save the settings to the file
127 void emitChanged( KHotKeys::ActionDataBase
*item
);
132 KHotKeys::Settings _settings
;
133 KHotKeys::ActionDataGroup
*_actions
;
136 #endif /* #ifndef KHOTKEYSMODEL_HPP */