edbee - Qt Editor Library v0.11.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
texteditorkeymap.h
Go to the documentation of this file.
1// edbee - Copyright (c) 2012-2025 by Rick Blommers and contributors
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#include "edbee/exports.h"
7
8#include <QKeySequence>
9#include <QHash>
10#include <QMultiHash>
11#include <QStringList>
12
13namespace edbee {
14
17
18
22public:
23 TextEditorKey( const QKeySequence& seq );
24 TextEditorKey* clone() const;
25
26 const QKeySequence& sequence();
27
28private:
29 QKeySequence sequence_;
30
31};
32
33
34//------------------------------------------------------------
35
36
40public:
41
42 TextEditorKeyMap( TextEditorKeyMap* parentKeyMap=0 );
43 virtual ~TextEditorKeyMap();
44
45 void copyKeysTo( TextEditorKeyMap* keyMap );
46
47 TextEditorKey* get( const QString& name ) const;
48 QKeySequence getSequence( const QString& name ) const;
49 QList<TextEditorKey*> getAll( const QString& name ) const;
50 bool has( const QString& name ) const;
51
52 void add( const QString& command, TextEditorKey *sequence );
53 void add( const QString& command, const QKeySequence& seq );
54 bool add( const QString& command, const QString& seq );
55// void set( const QString& name, const QKeySequence::StandardKey key );
56 void replace(const QString& name, TextEditorKey *sequence );
57
58 QString findBySequence( QKeySequence sequence, QKeySequence::SequenceMatch& match );
59
60 static QKeySequence joinKeySequences( const QKeySequence seq1, const QKeySequence seq2 );
61 static QKeySequence::StandardKey standardKeyFromString( const QString& str );
62
63 QString toString() const;
64
65 TextEditorKeyMap* parentMap() { return parentRef_; }
66
67private:
68
69 TextEditorKeyMap* parentRef_;
70 QMultiHash<QString,TextEditorKey*> keyMap_;
71};
72
73
74//-------------------------------------------------------------------
75
76
81public:
83 virtual ~TextKeyMapManager();
84
85 void loadAllKeyMaps( const QString& path );
86 void loadKeyMap( const QString& file );
87 void loadFactoryKeyMap();
88
89 TextEditorKeyMap* get( const QString& name=QString() );
90 TextEditorKeyMap* findOrCreate( const QString& name );
91
92private:
93
94 QHash<QString,TextEditorKeyMap*> keyMapHash_;
95
96};
97
98
99
100} // edbee
This is the abstract base class for a textcommand.
Definition texteditorcommand.h:50
The texteditor works via the controller. The controller is the central point/mediator which maps/cont...
Definition texteditorcontroller.h:39
A contexted keysequence This contains a keysequence and optionally a given context.
Definition texteditorkeymap.h:21
const QKeySequence & sequence()
returns the keysequence
Definition texteditorkeymap.cpp:35
TextEditorKey(const QKeySequence &seq)
Constructs the texteditor key sequence.
Definition texteditorkeymap.cpp:21
TextEditorKey * clone() const
Clones the text editor key.
Definition texteditorkeymap.cpp:28
A text editor key map This key map, maps key-sequences to action-names.
Definition texteditorkeymap.h:39
void copyKeysTo(TextEditorKeyMap *keyMap)
copies the given keys to the other keymap
Definition texteditorkeymap.cpp:71
TextEditorKey * get(const QString &name) const
Returns the last inserted keysequence for the given command It also tries to search the parent keymap...
Definition texteditorkeymap.cpp:83
QList< TextEditorKey * > getAll(const QString &name) const
Returns a list of all keysequences for the given command This method will also search the parents for...
Definition texteditorkeymap.cpp:105
static QKeySequence::StandardKey standardKeyFromString(const QString &str)
converts a string to a standard key if the standard key isn't found it returns 'QKeySequence::Unknown...
Definition texteditorkeymap.cpp:249
bool has(const QString &name) const
Tests if the keymap has the given action It will also search the parent key map.
Definition texteditorkeymap.cpp:123
TextEditorKeyMap * parentMap()
Definition texteditorkeymap.h:65
QString findBySequence(QKeySequence sequence, QKeySequence::SequenceMatch &match)
Searches for the given command with a keysequence Warning when one keysequence is the prefix of the o...
Definition texteditorkeymap.cpp:201
void replace(const QString &name, TextEditorKey *sequence)
replace the given command with the given key sequence all other keysequences (on this level) are igno...
Definition texteditorkeymap.cpp:187
TextEditorKeyMap(TextEditorKeyMap *parentKeyMap=0)
Definition texteditorkeymap.cpp:45
QString toString() const
returns all added actions
Definition texteditorkeymap.cpp:326
static QKeySequence joinKeySequences(const QKeySequence seq1, const QKeySequence seq2)
This method joins 2 key-sequences to 1 sequence (if possible) if seq1 + se2 length > 4 seq2 is return...
Definition texteditorkeymap.cpp:221
QKeySequence getSequence(const QString &name) const
Returns the key sequence for the given name.
Definition texteditorkeymap.cpp:95
void loadFactoryKeyMap()
This method loads the internal factory keymap.
Definition texteditorkeymap.cpp:390
TextEditorKeyMap * findOrCreate(const QString &name)
finds or creates the given keymap
Definition texteditorkeymap.cpp:404
TextEditorKeyMap * get(const QString &name=QString())
Returns the given text-editor keymap.
Definition texteditorkeymap.cpp:397
void loadAllKeyMaps(const QString &path)
This method loads all keymaps.
Definition texteditorkeymap.cpp:356
TextKeyMapManager()
destructs all keymaps
Definition texteditorkeymap.cpp:341
void loadKeyMap(const QString &file)
This method loads a single keymap.
Definition texteditorkeymap.cpp:367
#define EDBEE_EXPORT
Definition exports.h:15
#define add(key, value)
Definition factorykeymap.cpp:13
QT Acessibility has an issue with reporting blank lines between elements lines. defining 'WINDOWS_EMP...
Definition commentcommand.cpp:20