BALL  1.4.79
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
shortcutRegistry.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_VIEW_KERNEL_SHORTCUTREGISTRY_H
6 #define BALL_VIEW_KERNEL_SHORTCUTREGISTRY_H
7 
8 #ifndef BALL_CONCEPT_EMBEDDABLE_H
10 #endif
11 
12 #include <map>
13 
14 #ifndef BALL_DATATYPE_HASHSET_H
15 # include <BALL/DATATYPE/hashSet.h>
16 #endif
17 
18 #ifndef BALL_VIEW_KERNEL_PREFERENCESENTRY_H
20 #endif
21 
22 #include <QtCore/QObject>
23 
24 class QAction;
25 class QKeySequence;
26 
27 namespace BALL
28 {
29  namespace VIEW
30  {
37  : public QObject,
38  public Embeddable,
40  {
41  Q_OBJECT
42 
43  public:
45 
46 
48 
51  virtual ~ShortcutRegistry();
52 
54  void registerShortcut(String description, QAction* shortcut);
55 
57  void clear();
58 
60  void clearKeySequences();
61 
63  bool readShortcutsFromFile(const String& filename);
64 
66  bool writeShortcutsToFile(const String& filename);
67 
69  bool changeShortcut(QAction* shortcut, const String& new_sequence);
70  bool changeShortcut(int index, const String& new_sequence);
71 
72  size_t size();
73 
74  bool hasDescription(const String& description);
75  bool hasKey(const QString& key_seq);
76  bool hasKey(const QKeySequence& key_seq);
77  bool hasKey(const String& key_seq);
78 
79  std::pair<String, QAction*> operator[](Index i);
80 
81  // needed for storing this classes' preferences
82  virtual bool getValue(String&) const;
83  virtual bool setValue(const String&);
84 
85  signals:
86  void shortcutChanged();
87 
88  protected:
89  static const char* BETWEEN_SC_SEPERATOR;
90  static const char* IN_SC_SEPERATOR;
91 
92  std::pair<String, QAction*> getEntry_(Index pos);
93 
94  std::map<String, QAction*> shortcuts_;
95  std::map<String, String> unknown_shortcuts_;
97  };
98 
99  }// namespace VIEW
100 }// namespace BALL
101 
102 #endif // BALL_VIEW_KERNEL_SHORTCUTREGISTRY_H
103 
static const char * BETWEEN_SC_SEPERATOR
static const char * IN_SC_SEPERATOR
std::map< String, String > unknown_shortcuts_
#define BALL_VIEW_EXPORT
Definition: COMMON/global.h:52
#define BALL_EMBEDDABLE(TYPE, BASE)
Definition: embeddable.h:31
std::map< String, QAction * > shortcuts_
HashSet< String > shortcut_keys_