~ubuntu-branches/ubuntu/saucy/konsole/saucy-proposed

« back to all changes in this revision

Viewing changes to src/KeyboardTranslatorManager.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-06-06 14:29:24 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20120606142924-1rekqv6j25lw2k41
Tags: 4:4.8.80-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This source file is part of Konsole, a terminal emulator.
 
3
 
 
4
    Copyright 2007-2008 by Robert Knight <robertknight@gmail.com>
 
5
 
 
6
    This program is free software; you can redistribute it and/or modify
 
7
    it under the terms of the GNU General Public License as published by
 
8
    the Free Software Foundation; either version 2 of the License, or
 
9
    (at your option) any later version.
 
10
 
 
11
    This program is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
    GNU General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU General Public License
 
17
    along with this program; if not, write to the Free Software
 
18
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
19
    02110-1301  USA.
 
20
*/
 
21
 
 
22
#ifndef KEYBOARDTRANSLATOR_MANAGER_H
 
23
#define KEYBOARDTRANSLATOR_MANAGER_H
 
24
 
 
25
// Qt
 
26
#include <QtCore/QHash>
 
27
#include <QtCore/QStringList>
 
28
 
 
29
// Konsole
 
30
#include "konsole_export.h"
 
31
#include "KeyboardTranslator.h"
 
32
 
 
33
class QIODevice;
 
34
 
 
35
namespace Konsole
 
36
{
 
37
/**
 
38
 * Manages the keyboard translations available for use by terminal sessions,
 
39
 * see KeyboardTranslator.
 
40
 */
 
41
class KeyboardTranslatorManager
 
42
{
 
43
public:
 
44
    /**
 
45
     * Constructs a new KeyboardTranslatorManager and loads the list of
 
46
     * available keyboard translations.
 
47
     *
 
48
     * The keyboard translations themselves are not loaded until they are
 
49
     * first requested via a call to findTranslator()
 
50
     */
 
51
    KeyboardTranslatorManager();
 
52
    ~KeyboardTranslatorManager();
 
53
 
 
54
    /**
 
55
     * Adds a new translator.  If a translator with the same name
 
56
     * already exists, it will be replaced by the new translator.
 
57
     *
 
58
     * TODO: More documentation.
 
59
     */
 
60
    void addTranslator(KeyboardTranslator* translator);
 
61
 
 
62
    /**
 
63
     * Deletes a translator.  Returns true on successful deletion or false otherwise.
 
64
     *
 
65
     * TODO: More documentation
 
66
     */
 
67
    bool deleteTranslator(const QString& name);
 
68
 
 
69
    /** Returns the default translator for Konsole. */
 
70
    const KeyboardTranslator* defaultTranslator();
 
71
 
 
72
    /**
 
73
     * Returns the keyboard translator with the given name or 0 if no translator
 
74
     * with that name exists.
 
75
     *
 
76
     * The first time that a translator with a particular name is requested,
 
77
     * the on-disk .keytab file is loaded and parsed.
 
78
     */
 
79
    const KeyboardTranslator* findTranslator(const QString& name);
 
80
    /**
 
81
     * Returns a list of the names of available keyboard translators.
 
82
     *
 
83
     * The first time this is called, a search for available
 
84
     * translators is started.
 
85
     */
 
86
    QStringList allTranslators();
 
87
 
 
88
    /** Returns the global KeyboardTranslatorManager instance. */
 
89
    static KeyboardTranslatorManager* instance();
 
90
 
 
91
private:
 
92
    void findTranslators(); // locate all available translators
 
93
 
 
94
    // loads the translator with the given name
 
95
    KeyboardTranslator* loadTranslator(const QString& name);
 
96
    KeyboardTranslator* loadTranslator(QIODevice* device, const QString& name);
 
97
 
 
98
    bool saveTranslator(const KeyboardTranslator* translator);
 
99
    QString findTranslatorPath(const QString& name);
 
100
 
 
101
    bool _haveLoadedAll;
 
102
 
 
103
    const KeyboardTranslator* _fallbackTranslator;
 
104
    QHash<QString, KeyboardTranslator*> _translators;
 
105
};
 
106
}
 
107
 
 
108
#endif // KEYBOARDTRANSLATOR_MANAGER_H
 
109