GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
KeyboardTranslatorReader Class Reference

Parses the contents of a Keyboard Translator (.keytab) file and returns the entries found in it. More...

#include "KeyboardTranslator.h"

Collaboration diagram for KeyboardTranslatorReader:

Classes

struct  Token
 

Public Member Functions

 KeyboardTranslatorReader (QIODevice *source)
 Constructs a new reader which parses the given source. More...
 
QString description () const
 Returns the description text. More...
 
bool hasNextEntry ()
 Returns true if there is another entry in the source stream. More...
 
KeyboardTranslator::Entry nextEntry ()
 Returns the next entry found in the source stream. More...
 
bool parseError ()
 Returns true if an error occurred whilst parsing the input or false if no error occurred. More...
 

Static Public Member Functions

static KeyboardTranslator::Entry createEntry (const QString &condition, const QString &result)
 Parses a condition and result string for a translator entry and produces a keyboard translator entry. More...
 

Private Member Functions

bool decodeSequence (const QString &, int &keyCode, Qt::KeyboardModifiers &modifiers, Qt::KeyboardModifiers &modifierMask, KeyboardTranslator::States &state, KeyboardTranslator::States &stateFlags)
 
void readNext ()
 
QList< Tokentokenize (const QString &)
 

Static Private Member Functions

static bool parseAsCommand (const QString &text, KeyboardTranslator::Command &command)
 
static bool parseAsKeyCode (const QString &item, int &keyCode)
 
static bool parseAsModifier (const QString &item, Qt::KeyboardModifier &modifier)
 
static bool parseAsStateFlag (const QString &item, KeyboardTranslator::State &state)
 

Private Attributes

QString _description
 
bool _hasNext
 
KeyboardTranslator::Entry _nextEntry
 
QIODevice * _source
 

Detailed Description

Parses the contents of a Keyboard Translator (.keytab) file and returns the entries found in it.

Usage example:

QFile source( "/path/to/keytab" );
source.open( QIODevice::ReadOnly );
KeyboardTranslator* translator = new KeyboardTranslator( "name-of-translator" );
KeyboardTranslatorReader reader(source);
while ( reader.hasNextEntry() )
translator->addEntry(reader.nextEntry());
source.close();
if ( !reader.parseError() )
{
// parsing succeeded, do something with the translator
}
else
{
// parsing failed
}
Parses the contents of a Keyboard Translator (.keytab) file and returns the entries found in it.
A convertor which maps between key sequences pressed by the user and the character strings which shou...
void addEntry(const Entry &entry)
Adds an entry to this keyboard translator's table.

Definition at line 424 of file KeyboardTranslator.h.

Constructor & Destructor Documentation

◆ KeyboardTranslatorReader()

KeyboardTranslatorReader::KeyboardTranslatorReader ( QIODevice *  source)

Constructs a new reader which parses the given source.

Definition at line 236 of file KeyboardTranslator.cpp.

References _description, readNext(), KeyboardTranslatorReader::Token::TitleKeyword, and tokenize().

Member Function Documentation

◆ createEntry()

KeyboardTranslator::Entry KeyboardTranslatorReader::createEntry ( const QString &  condition,
const QString &  result 
)
static

Parses a condition and result string for a translator entry and produces a keyboard translator entry.

The condition and result strings are in the same format as in

Definition at line 467 of file KeyboardTranslator.cpp.

References hasNextEntry(), nextEntry(), and parseAsCommand().

◆ decodeSequence()

bool KeyboardTranslatorReader::decodeSequence ( const QString &  text,
int &  keyCode,
Qt::KeyboardModifiers &  modifiers,
Qt::KeyboardModifiers &  modifierMask,
KeyboardTranslator::States &  state,
KeyboardTranslator::States &  stateFlags 
)
private

◆ description()

QString KeyboardTranslatorReader::description ( ) const

Returns the description text.

TODO: More documentation

Definition at line 459 of file KeyboardTranslator.cpp.

References _description.

Referenced by KeyboardTranslatorManager::loadTranslator().

◆ hasNextEntry()

bool KeyboardTranslatorReader::hasNextEntry ( )

Returns true if there is another entry in the source stream.

Definition at line 463 of file KeyboardTranslator.cpp.

References _hasNext.

Referenced by createEntry(), and KeyboardTranslatorManager::loadTranslator().

◆ nextEntry()

KeyboardTranslator::Entry KeyboardTranslatorReader::nextEntry ( )

Returns the next entry found in the source stream.

Definition at line 497 of file KeyboardTranslator.cpp.

References _hasNext, _nextEntry, and readNext().

Referenced by createEntry(), and KeyboardTranslatorManager::loadTranslator().

◆ parseAsCommand()

◆ parseAsKeyCode()

bool KeyboardTranslatorReader::parseAsKeyCode ( const QString &  item,
int &  keyCode 
)
staticprivate

Definition at line 436 of file KeyboardTranslator.cpp.

Referenced by decodeSequence().

◆ parseAsModifier()

bool KeyboardTranslatorReader::parseAsModifier ( const QString &  item,
Qt::KeyboardModifier &  modifier 
)
staticprivate

Definition at line 402 of file KeyboardTranslator.cpp.

Referenced by decodeSequence().

◆ parseAsStateFlag()

bool KeyboardTranslatorReader::parseAsStateFlag ( const QString &  item,
KeyboardTranslator::State state 
)
staticprivate

◆ parseError()

bool KeyboardTranslatorReader::parseError ( )

Returns true if an error occurred whilst parsing the input or false if no error occurred.

Definition at line 508 of file KeyboardTranslator.cpp.

Referenced by KeyboardTranslatorManager::loadTranslator().

◆ readNext()

◆ tokenize()

Member Data Documentation

◆ _description

QString KeyboardTranslatorReader::_description
private

Definition at line 485 of file KeyboardTranslator.h.

Referenced by KeyboardTranslatorReader(), and description().

◆ _hasNext

bool KeyboardTranslatorReader::_hasNext
private

Definition at line 487 of file KeyboardTranslator.h.

Referenced by hasNextEntry(), nextEntry(), and readNext().

◆ _nextEntry

KeyboardTranslator::Entry KeyboardTranslatorReader::_nextEntry
private

Definition at line 486 of file KeyboardTranslator.h.

Referenced by nextEntry(), and readNext().

◆ _source

QIODevice* KeyboardTranslatorReader::_source
private

Definition at line 484 of file KeyboardTranslator.h.

Referenced by readNext().


The documentation for this class was generated from the following files: