edbee - Qt Editor Library
texteditorkeymap.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <QKeySequence>
9 #include <QHash>
10 #include <QStringList>
11 
12 namespace edbee {
13 
14 class TextEditorCommand;
15 class TextEditorController;
16 
17 
21 {
22 public:
23  TextEditorKey( const QKeySequence& seq );
24  TextEditorKey* clone() const;
25 
26  const QKeySequence& sequence();
27 
28 private:
29  QKeySequence sequence_;
30 
31 };
32 
33 
34 //------------------------------------------------------------
35 
36 
40 {
41 public:
42 
43  TextEditorKeyMap( TextEditorKeyMap* parentKeyMap=0 );
44  virtual ~TextEditorKeyMap();
45 
46  void copyKeysTo( TextEditorKeyMap* keyMap );
47 
48  TextEditorKey* get( const QString& name ) const;
49  QKeySequence getSequence( const QString& name ) const;
50  QList<TextEditorKey*> getAll( const QString& name ) const;
51  bool has( const QString& name ) const;
52 
53  void add( const QString& command, TextEditorKey *sequence );
54  void add( const QString& command, const QKeySequence& seq );
55  bool add( const QString& command, const QString& seq );
56 // void set( const QString& name, const QKeySequence::StandardKey key );
57  void replace(const QString& name, TextEditorKey *sequence );
58 
59  QString findBySequence( QKeySequence sequence, QKeySequence::SequenceMatch& match );
60 
61  static QKeySequence joinKeySequences( const QKeySequence seq1, const QKeySequence seq2 );
62  static QKeySequence::StandardKey standardKeyFromString( const QString& str );
63 
64  QString toString() const;
65 
66  TextEditorKeyMap* parentMap() { return parentRef_; }
67 
68 private:
69 
70  TextEditorKeyMap* parentRef_;
71  QHash<QString,TextEditorKey*> keyMap_;
72 };
73 
74 
75 //-------------------------------------------------------------------
76 
77 
82 {
83 public:
85  virtual ~TextKeyMapManager();
86 
87  void loadAllKeyMaps( const QString& path );
88  void loadKeyMap( const QString& file );
89  void loadFactoryKeyMap();
90 
91  TextEditorKeyMap* get( const QString& name="" );
92  TextEditorKeyMap* findOrCreate( const QString& name );
93 
94 private:
95 
96  QHash<QString,TextEditorKeyMap*> keyMapHash_;
97 
98 };
99 
100 
101 
102 } // edbee
There can be different keymaps for different file-types/ The keymap manager manages all the available...
Definition: texteditorkeymap.h:81
TextEditorKey(const QKeySequence &seq)
Constructs the texteditor key sequence.
Definition: texteditorkeymap.cpp:23
Copyright 2011-2013 - Reliable Bits Software by Blommers IT.
Definition: commentcommand.cpp:22
TextEditorKey * clone() const
Clones the text editor key.
Definition: texteditorkeymap.cpp:30
#define add(key, value)
Definition: factorykeymap.cpp:15
A text editor key map This key map, maps key-sequences to action-names.
Definition: texteditorkeymap.h:39
TextEditorKeyMap * parentMap()
Definition: texteditorkeymap.h:66
const QKeySequence & sequence()
returns the keysequence
Definition: texteditorkeymap.cpp:37
A contexted keysequence This contains a keysequence and optionally a given context.
Definition: texteditorkeymap.h:20