GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
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:
Collaboration graph
[legend]

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
}

Definition at line 423 of file KeyboardTranslator.h.

Constructor & Destructor Documentation

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

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 array(), command, hasNextEntry(), nextEntry(), and parseAsCommand().

bool KeyboardTranslatorReader::decodeSequence ( const QString &  text,
int keyCode,
Qt::KeyboardModifiers &  modifiers,
Qt::KeyboardModifiers &  modifierMask,
KeyboardTranslator::States &  state,
KeyboardTranslator::States &  stateFlags 
)
private
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().

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().

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().

bool KeyboardTranslatorReader::parseAsCommand ( const QString &  text,
KeyboardTranslator::Command command 
)
staticprivate
bool KeyboardTranslatorReader::parseAsKeyCode ( const QString &  item,
int keyCode 
)
staticprivate

Definition at line 436 of file KeyboardTranslator.cpp.

Referenced by decodeSequence().

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

Definition at line 402 of file KeyboardTranslator.cpp.

Referenced by decodeSequence().

bool KeyboardTranslatorReader::parseAsStateFlag ( const QString &  item,
KeyboardTranslator::State state 
)
staticprivate
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().

void KeyboardTranslatorReader::readNext ( )
private
QList< KeyboardTranslatorReader::Token > KeyboardTranslatorReader::tokenize ( const QString &  line)
private

Member Data Documentation

QString KeyboardTranslatorReader::_description
private

Definition at line 484 of file KeyboardTranslator.h.

Referenced by description(), and KeyboardTranslatorReader().

bool KeyboardTranslatorReader::_hasNext
private

Definition at line 486 of file KeyboardTranslator.h.

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

KeyboardTranslator::Entry KeyboardTranslatorReader::_nextEntry
private

Definition at line 485 of file KeyboardTranslator.h.

Referenced by nextEntry(), and readNext().

QIODevice* KeyboardTranslatorReader::_source
private

Definition at line 483 of file KeyboardTranslator.h.

Referenced by readNext().


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