2
* \file shortcutsdelegate.h
3
* Keyboard shortcuts item delegate.
9
* Copyright (C) 2011 Urs Fleisch
11
* This file is part of Kid3.
13
* Kid3 is free software; you can redistribute it and/or modify
14
* it under the terms of the GNU General Public License as published by
15
* the Free Software Foundation; either version 2 of the License, or
16
* (at your option) any later version.
18
* Kid3 is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
* GNU General Public License for more details.
23
* You should have received a copy of the GNU General Public License
24
* along with this program. If not, see <http://www.gnu.org/licenses/>.
27
#ifndef SHORTCUTSDELEGATE_H
28
#define SHORTCUTSDELEGATE_H
30
#include <QItemDelegate>
34
* Item delegate to edit and reset keyboard shortcuts.
36
class ShortcutsDelegate : public QItemDelegate {
38
#ifndef CONFIG_USE_KDE
42
* @param parent parent object
44
explicit ShortcutsDelegate(QObject* parent = 0);
49
virtual ~ShortcutsDelegate();
52
* Create an editor to edit the cells contents.
53
* @param parent parent widget
55
* @param index index of item
56
* @return editor widget
58
virtual QWidget* createEditor(
59
QWidget* parent, const QStyleOptionViewItem& option,
60
const QModelIndex& index) const;
63
* Set data to be edited by the editor.
64
* @param editor editor widget
65
* @param index index of item
67
virtual void setEditorData(QWidget* editor, const QModelIndex& index) const;
70
* Set model data supplied by editor.
71
* @param editor editor widget
73
* @param index index of item
75
virtual void setModelData(
76
QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
79
* Updates the geometry of the @a editor for the item with the given
80
* @a index, according to the rectangle specified in the @a option.
81
* @param editor editor widget
83
* @param index index of item
85
virtual void updateEditorGeometry(
86
QWidget* editor, const QStyleOptionViewItem& option,
87
const QModelIndex& index) const;
90
void clearAndCloseEditor();
91
void resetToDefault();
92
void commitAndCloseEditor();
95
mutable bool m_resetFlag;
99
* Editor widget for delegate with buttons to clear and reset the value.
101
* The editor consists of a line edit to edit the value and buttons to clear and
102
* reset the value to the default.
104
class ShortcutsDelegateEditor : public QFrame {
110
* @param lineEdit widget used to edit value
111
* @param parent parent widget
113
explicit ShortcutsDelegateEditor(QLineEdit* lineEdit,
114
QWidget* parent = 0);
119
virtual ~ShortcutsDelegateEditor();
123
* @return line edit widget
125
QLineEdit* getLineEdit() { return m_lineEdit; }
128
* Filters events if this object has been installed as an event filter for
129
* the @a watched object.
130
* @param watched watched object
132
* @return true to stop further event handling
134
virtual bool eventFilter(QObject* watched, QEvent* ev);
138
* Emitted when a shortcut has been entered.
143
* Emitted when the clear button is clicked.
148
* Emitted when the reset button is clicked.
156
* @return true if event was recognized and processed
158
virtual bool event(QEvent* ev);
161
QLineEdit* m_lineEdit;
162
#endif // !CONFIG_USE_KDE
165
#endif // SHORTCUTSDELEGATE_H