KeyReference.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2007 QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef SV_KEY_REFERENCE_H
17 #define SV_KEY_REFERENCE_H
18 
19 #include <QObject>
20 #include <QString>
21 #include <vector>
22 #include <map>
23 #include <QKeySequence>
24 
25 class QAction;
26 class QTextEdit;
27 class QDialog;
28 class QAbstractButton;
29 
30 class KeyReference : public QObject
31 {
32  Q_OBJECT
33 
34 public:
35  KeyReference();
36  virtual ~KeyReference();
37 
38  void setCategory(QString category);
39 
40  void registerShortcut(QAction *, QString overrideName = "");
41  void registerAlternativeShortcut(QAction *, QString alternative);
42  void registerAlternativeShortcut(QAction *, QKeySequence alternative);
43 
44  void registerShortcut(QString actionName, QString shortcut, QString tipText);
45  void registerAlternativeShortcut(QString actionName, QString alternative);
46  void registerAlternativeShortcut(QString actionName, QKeySequence alternative);
47 
48  void show();
49  void hide();
50 
51 protected slots:
52  void dialogButtonClicked(QAbstractButton *);
53 
54 protected:
55  struct KeyDetails {
56  QString actionName;
57  QString shortcut;
58  QString tip;
59  std::vector<QString> alternatives;
60  };
61 
62  typedef std::vector<KeyDetails> KeyList;
63  typedef std::map<QString, KeyList> CategoryMap;
64  typedef std::vector<QString> CategoryList;
65 
67  CategoryMap m_map;
68  CategoryList m_categoryOrder;
69 
70  QTextEdit *m_text;
71  QDialog *m_dialog;
72 };
73 
74 #endif
std::vector< QString > alternatives
Definition: KeyReference.h:59
QDialog * m_dialog
Definition: KeyReference.h:71
CategoryMap m_map
Definition: KeyReference.h:67
void dialogButtonClicked(QAbstractButton *)
QString m_currentCategory
Definition: KeyReference.h:66
void setCategory(QString category)
CategoryList m_categoryOrder
Definition: KeyReference.h:68
std::vector< QString > CategoryList
Definition: KeyReference.h:64
std::map< QString, KeyList > CategoryMap
Definition: KeyReference.h:63
std::vector< KeyDetails > KeyList
Definition: KeyReference.h:62
void registerAlternativeShortcut(QAction *, QString alternative)
virtual ~KeyReference()
void registerShortcut(QAction *, QString overrideName="")
QTextEdit * m_text
Definition: KeyReference.h:70