~ubuntu-branches/ubuntu/wily/kid3/wily

« back to all changes in this revision

Viewing changes to src/gui/widgets/shortcutsdelegate.h

  • Committer: Package Import Robot
  • Author(s): Mark Purcell, Patrick Matthäi, Mark Purcell
  • Date: 2013-11-30 15:44:59 UTC
  • mfrom: (1.1.16) (2.1.18 sid)
  • Revision ID: package-import@ubuntu.com-20131130154459-s6lpalx8yy2zq7gx
Tags: 3.0.2-1
* New upstream release 

[ Patrick Matthäi ]
* New upstream release.
  - Add new libreadline-dev build dependency.
* Don't explicitly request xz compression - dpkg 1.17 does this by default.
* Bump Standards-Version to 3.9.5 (no changes needed).
* Fix Vcs-Browser control field.

[ Mark Purcell ]
* Switch to dh - reduce debian/rules bloat
* kid3 Replaces kid3-qt - low popcon, reduce archive bloat
* Fix vcs-field-not-canonical
* debian/compat -> 9
* Update Description:

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * \file shortcutsdelegate.h
3
 
 * Keyboard shortcuts item delegate.
4
 
 *
5
 
 * \b Project: Kid3
6
 
 * \author Urs Fleisch
7
 
 * \date 29 Dec 2011
8
 
 *
9
 
 * Copyright (C) 2011  Urs Fleisch
10
 
 *
11
 
 * This file is part of Kid3.
12
 
 *
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.
17
 
 *
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.
22
 
 *
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/>.
25
 
 */
26
 
 
27
 
#ifndef SHORTCUTSDELEGATE_H
28
 
#define SHORTCUTSDELEGATE_H
29
 
 
30
 
#include <QItemDelegate>
31
 
#include "config.h"
32
 
 
33
 
/**
34
 
 * Item delegate to edit and reset keyboard shortcuts.
35
 
 */
36
 
class ShortcutsDelegate : public QItemDelegate {
37
 
  Q_OBJECT
38
 
#ifndef CONFIG_USE_KDE
39
 
public:
40
 
  /**
41
 
   * Constructor.
42
 
   * @param parent parent object
43
 
   */
44
 
  explicit ShortcutsDelegate(QObject* parent = 0);
45
 
 
46
 
  /**
47
 
   * Destructor.
48
 
   */
49
 
  virtual ~ShortcutsDelegate();
50
 
 
51
 
  /**
52
 
   * Create an editor to edit the cells contents.
53
 
   * @param parent parent widget
54
 
   * @param option style
55
 
   * @param index  index of item
56
 
   * @return editor widget
57
 
   */
58
 
  virtual QWidget* createEditor(
59
 
    QWidget* parent, const QStyleOptionViewItem& option,
60
 
    const QModelIndex& index) const;
61
 
 
62
 
  /**
63
 
   * Set data to be edited by the editor.
64
 
   * @param editor editor widget
65
 
   * @param index  index of item
66
 
   */
67
 
  virtual void setEditorData(QWidget* editor, const QModelIndex& index) const;
68
 
 
69
 
  /**
70
 
   * Set model data supplied by editor.
71
 
   * @param editor editor widget
72
 
   * @param model  model
73
 
   * @param index  index of item
74
 
   */
75
 
  virtual void setModelData(
76
 
    QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const;
77
 
 
78
 
  /**
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
82
 
   * @param option style
83
 
   * @param index  index of item
84
 
   */
85
 
  virtual void updateEditorGeometry(
86
 
    QWidget* editor, const QStyleOptionViewItem& option,
87
 
      const QModelIndex& index) const;
88
 
 
89
 
private slots:
90
 
  void clearAndCloseEditor();
91
 
  void resetToDefault();
92
 
  void commitAndCloseEditor();
93
 
 
94
 
private:
95
 
  mutable bool m_resetFlag;
96
 
};
97
 
 
98
 
/**
99
 
 * Editor widget for delegate with buttons to clear and reset the value.
100
 
 *
101
 
 * The editor consists of a line edit to edit the value and buttons to clear and
102
 
 * reset the value to the default.
103
 
 */
104
 
class ShortcutsDelegateEditor : public QFrame {
105
 
  Q_OBJECT
106
 
public:
107
 
  /**
108
 
   * Constructor.
109
 
   *
110
 
   * @param lineEdit widget used to edit value
111
 
   * @param parent parent widget
112
 
   */
113
 
  explicit ShortcutsDelegateEditor(QLineEdit* lineEdit,
114
 
                                   QWidget* parent = 0);
115
 
 
116
 
  /**
117
 
   * Destructor.
118
 
   */
119
 
  virtual ~ShortcutsDelegateEditor();
120
 
 
121
 
  /*!
122
 
   * Get edit widget.
123
 
   * @return line edit widget
124
 
   */
125
 
  QLineEdit* getLineEdit() { return m_lineEdit; }
126
 
 
127
 
  /**
128
 
   * Filters events if this object has been installed as an event filter for
129
 
   * the @a watched object.
130
 
   * @param watched watched object
131
 
   * @param ev event
132
 
   * @return true to stop further event handling
133
 
   */
134
 
  virtual bool eventFilter(QObject* watched, QEvent* ev);
135
 
 
136
 
signals:
137
 
  /**
138
 
   * Emitted when a shortcut has been entered.
139
 
   */
140
 
  void valueEntered();
141
 
 
142
 
  /**
143
 
   * Emitted when the clear button is clicked.
144
 
   */
145
 
  void clearClicked();
146
 
 
147
 
  /**
148
 
   * Emitted when the reset button is clicked.
149
 
   */
150
 
  void resetClicked();
151
 
 
152
 
protected:
153
 
  /**
154
 
   * Receive events.
155
 
   * @param ev event
156
 
   * @return true if event was recognized and processed
157
 
   */
158
 
  virtual bool event(QEvent* ev);
159
 
 
160
 
private:
161
 
  QLineEdit* m_lineEdit;
162
 
#endif // !CONFIG_USE_KDE
163
 
};
164
 
 
165
 
#endif // SHORTCUTSDELEGATE_H