Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes

StringProcessor Class Reference

#include <stringProcessor.h>

List of all members.

Classes

struct  CharacterInfo

Public Types

enum  EChangeType {
  eStringToChar = 0,
  eNoChange
}
 

determines if change is needed

More...
enum  EFont {
  eNormalFont = 0,
  eSymbolFont
}
 

list of fonts

More...
enum  EFontSize {
  eTextStyle = 0,
  eDisplayStyle,
  eScriptStyle,
  eScriptScriptStyle
}
 

according to LaTeX

More...
enum  EModifier {
  eBar = 0,
  eUnderline,
  eOverline,
  eNoModifier
}
 

list of symbol modifiers

More...
typedef QList< CharacterInfoTCharacterList

Public Member Functions

 StringProcessor (const QString &text="", int fontSize=0)
void drawText (QPainter *painter, QPointF &point) const
int getAscent () const
TCharacterList getCharacterList () const
 Returns character list computed for current instance of SP.
QStringList getCharacters () const
 Returns character list parsed from input text.
int getDescent () const
int getHeight () const
int getWidth () const
void setFontSize (int fontSize)
bool setText (const QString &text)
const QString & text () const

Static Public Member Functions

static TCharacterList computeCharacterList (const QString &input)
 Process input string to TCharacterList.
static QString getSymbolPrintInfo (const QString &symb, QString &fontFamily)
 Convert symbol to single character and get font info for printing out.
static bool isSpecialSymbol (const QString &symb)
 Checks if given symbol matches with keyword regex.
static QStringList parseSymbols (const QString &input)
 Parse symbols to list (each character as one string).
static QStringList parseSymbols (const TCharacterList &characterList)
 Parse symbols to list.

Static Public Attributes

static const QRegExp escapedCharacterRegex
static const QRegExp keywordRegex
static const QRegExp specCharacterRegex
static const QRegExp whitespaceRegex

Protected Types

enum  EKeywordType {
  eString2Char = 0,
  eFontSize,
  eModifier
}
typedef QPair< QChar, EFontTCharPair
typedef QList< QFont > TFontList
typedef QList< QFontMetrics > TMetricsList
typedef QMap< QString, TCharPairTString2CharMap
typedef QMap< QString, int > TString2KwTypeMap

Protected Member Functions

void computeMetrics ()
void fillFontLists ()
void processText ()
bool updateFont (QFont &font, const CharacterInfo &c) const
 Updates given font according to given charcter, returns true if font was changed.

Static Protected Member Functions

static void addToMaps (const QString &str, const TCharPair &charPair)
static TCharacterList computeCharacterList (const QString &input, int &startIdx, EFontSize fs, EModifier m, bool useModifierOnce=false)
static TCharacterList computeCharacterListInBlock (const QString &input, int &startIdx, EFontSize fs, EModifier m)
 Runs computeCharacterList on text inside balanced '{', '}'.
static void initialize ()
static bool parseFontSize (const QString &symb, EFontSize &fontSize)
static bool parseModifier (const QString &symb, EModifier &modifier)

Protected Attributes

int m_ascent
 max ascent in parsed m_text
TCharacterList m_characterList
 List of parsed characters.
int m_descent
 max descentf in parsed m_text
TFontList m_fontList
int m_fontSize
int m_height
 max height in parsed m_text
TMetricsList m_metricsList
QString m_text
int m_width

Static Protected Attributes

static const QStringList fontFamilyList = "Symbol"
static TString2CharMap string2CharMap
 First in pair is required character, second is index to fontList.
static TString2KwTypeMap string2KwTypeMap

Detailed Description

Definition at line 51 of file stringProcessor.h.


Member Typedef Documentation

Definition at line 86 of file stringProcessor.h.

typedef QPair<QChar, EFont> StringProcessor::TCharPair [protected]

Definition at line 139 of file stringProcessor.h.

typedef QList<QFont> StringProcessor::TFontList [protected]

Definition at line 141 of file stringProcessor.h.

typedef QList<QFontMetrics> StringProcessor::TMetricsList [protected]

Definition at line 142 of file stringProcessor.h.

typedef QMap<QString, TCharPair> StringProcessor::TString2CharMap [protected]

Definition at line 140 of file stringProcessor.h.

typedef QMap<QString, int> StringProcessor::TString2KwTypeMap [protected]

Definition at line 143 of file stringProcessor.h.


Member Enumeration Documentation

determines if change is needed

Enumerator:
eStringToChar 

image is in string2CharMap

eNoChange 

Definition at line 55 of file stringProcessor.h.

list of fonts

Enumerator:
eNormalFont 
eSymbolFont 

Definition at line 59 of file stringProcessor.h.

according to LaTeX

Enumerator:
eTextStyle 
eDisplayStyle 
eScriptStyle 
eScriptScriptStyle 

Definition at line 63 of file stringProcessor.h.

Enumerator:
eString2Char 
eFontSize 
eModifier 

Definition at line 145 of file stringProcessor.h.

list of symbol modifiers

Enumerator:
eBar 
eUnderline 
eOverline 
eNoModifier 

Definition at line 69 of file stringProcessor.h.


Constructor & Destructor Documentation

StringProcessor::StringProcessor ( const QString &  text = "",
int  fontSize = 0 
)

Definition at line 459 of file stringProcessor.cpp.

References computeCharacterList(), computeMetrics(), fillFontLists(), initialize(), m_characterList, m_text, RELLOG, and StringProcessorException::what().

Here is the call graph for this function:


Member Function Documentation

void StringProcessor::addToMaps ( const QString &  str,
const TCharPair charPair 
) [static, protected]

Definition at line 146 of file stringProcessor.cpp.

References string2CharMap, and string2KwTypeMap.

Referenced by initialize().

Here is the caller graph for this function:

StringProcessor::TCharacterList StringProcessor::computeCharacterList ( const QString &  input  )  [static]

Process input string to TCharacterList.

Definition at line 270 of file stringProcessor.cpp.

References DBGLOG_SP, DBGPAR, eNoModifier, and eTextStyle.

Referenced by NameAcceptDialog::myAccept(), Editor::parseCharacter(), Editor::parseCharSet(), parseSymbols(), AutomataWorkSimulator::setInput(), setText(), and StringProcessor().

Here is the caller graph for this function:

StringProcessor::TCharacterList StringProcessor::computeCharacterList ( const QString &  input,
int &  startIdx,
EFontSize  fs,
EModifier  m,
bool  useModifierOnce = false 
) [static, protected]

Definition at line 279 of file stringProcessor.cpp.

References DBGLOG, DBGLOG_SP, DBGPAR, and RELLOG.

StringProcessor::TCharacterList StringProcessor::computeCharacterListInBlock ( const QString &  input,
int &  startIdx,
EFontSize  fs,
EModifier  m 
) [static, protected]

Runs computeCharacterList on text inside balanced '{', '}'.

Definition at line 232 of file stringProcessor.cpp.

void StringProcessor::computeMetrics (  )  [protected]

Definition at line 514 of file stringProcessor.cpp.

References eNoChange, eStringToChar, m_ascent, m_characterList, m_descent, m_fontList, m_height, m_width, string2CharMap, and updateFont().

Referenced by setFontSize(), setText(), and StringProcessor().

Here is the call graph for this function:

Here is the caller graph for this function:

void StringProcessor::drawText ( QPainter *  painter,
QPointF &  point 
) const

Draw text using painter, final position will be stored to point, so it is possible to append next drawing next to drawed text

Definition at line 635 of file stringProcessor.cpp.

References DBGLOG_SP_DRAW, eNoChange, eStringToChar, m_characterList, m_fontList, string2CharMap, and updateFont().

Referenced by StateVar::paint(), StateNormal::paint(), and LabelX::paint().

Here is the call graph for this function:

Here is the caller graph for this function:

void StringProcessor::fillFontLists (  )  [protected]

Definition at line 495 of file stringProcessor.cpp.

References fontFamilyList, m_fontList, m_fontSize, and m_metricsList.

Referenced by setFontSize(), and StringProcessor().

Here is the caller graph for this function:

int StringProcessor::getAscent (  )  const

Definition at line 571 of file stringProcessor.cpp.

References m_ascent.

Referenced by State::getTextAscent().

Here is the caller graph for this function:

StringProcessor::TCharacterList StringProcessor::getCharacterList (  )  const

Returns character list computed for current instance of SP.

Definition at line 454 of file stringProcessor.cpp.

References m_characterList.

Referenced by LabelX::getCharacterList().

Here is the caller graph for this function:

QStringList StringProcessor::getCharacters (  )  const

Returns character list parsed from input text.

Definition at line 449 of file stringProcessor.cpp.

References m_characterList, and parseSymbols().

Referenced by LabelX::getCharacters().

Here is the call graph for this function:

Here is the caller graph for this function:

int StringProcessor::getDescent (  )  const

Definition at line 566 of file stringProcessor.cpp.

References m_descent.

Referenced by State::getTextDescent().

Here is the caller graph for this function:

int StringProcessor::getHeight (  )  const

Definition at line 561 of file stringProcessor.cpp.

References m_height.

Referenced by LabelX::boundingRect(), LabelX::getHeight(), and State::getTextHeight().

Here is the caller graph for this function:

QString StringProcessor::getSymbolPrintInfo ( const QString &  symb,
QString &  fontFamily 
) [static]

Convert symbol to single character and get font info for printing out.

Definition at line 169 of file stringProcessor.cpp.

References fontFamilyList, initialize(), and string2CharMap.

Referenced by SimulationDialog::appendSymbol().

Here is the call graph for this function:

Here is the caller graph for this function:

int StringProcessor::getWidth (  )  const [inline]

Definition at line 96 of file stringProcessor.h.

References m_width.

Referenced by LabelX::boundingRect(), State::getTextWidth(), StateVar::getWidth(), and LabelX::getWidth().

Here is the caller graph for this function:

void StringProcessor::initialize (  )  [static, protected]

Definition at line 53 of file stringProcessor.cpp.

References addToMaps(), DBGLOG_SP, eNormalFont, eSymbolFont, string2CharMap, and string2KwTypeMap.

Referenced by getSymbolPrintInfo(), parseSymbols(), and StringProcessor().

Here is the call graph for this function:

Here is the caller graph for this function:

bool StringProcessor::isSpecialSymbol ( const QString &  symb  )  [static]

Checks if given symbol matches with keyword regex.

Definition at line 159 of file stringProcessor.cpp.

References DBGLOG_SP, DBGPAR, and keywordRegex.

Referenced by SimulationDialog::appendSymbol(), AutomataWorkSimulator::saveInputState(), and TransitionTableImpl::toLaTeXTable().

Here is the caller graph for this function:

bool StringProcessor::parseFontSize ( const QString &  symb,
EFontSize fontSize 
) [static, protected]

Definition at line 186 of file stringProcessor.cpp.

bool StringProcessor::parseModifier ( const QString &  symb,
EModifier modifier 
) [static, protected]

Definition at line 211 of file stringProcessor.cpp.

QStringList StringProcessor::parseSymbols ( const QString &  input  )  [static]

Parse symbols to list (each character as one string).

Definition at line 441 of file stringProcessor.cpp.

References computeCharacterList(), and initialize().

Referenced by getCharacters(), AutomataWorkSimulator::processStep(), and AutomataWorkSimulator::setInput().

Here is the call graph for this function:

Here is the caller graph for this function:

QStringList StringProcessor::parseSymbols ( const TCharacterList characterList  )  [static]

Parse symbols to list.

Definition at line 428 of file stringProcessor.cpp.

References StringProcessor::CharacterInfo::character, and initialize().

Here is the call graph for this function:

void StringProcessor::processText (  )  [protected]
void StringProcessor::setFontSize ( int  fontSize  ) 

Related to eTextStyle.

See also:
EFontSize

Definition at line 594 of file stringProcessor.cpp.

References computeMetrics(), fillFontLists(), and m_fontSize.

Referenced by LabelX::setFontSize(), and State::setStateLabelScale().

Here is the call graph for this function:

Here is the caller graph for this function:

bool StringProcessor::setText ( const QString &  text  ) 

Definition at line 576 of file stringProcessor.cpp.

References computeCharacterList(), computeMetrics(), m_characterList, m_text, RELLOG, and StringProcessorException::what().

Referenced by State::setLabel(), and LabelX::setText().

Here is the call graph for this function:

Here is the caller graph for this function:

const QString& StringProcessor::text (  )  const [inline]

Definition at line 91 of file stringProcessor.h.

References m_text.

Referenced by StateVar::paint(), StateNormal::paint(), and LabelX::setText().

Here is the caller graph for this function:

bool StringProcessor::updateFont ( QFont &  font,
const CharacterInfo c 
) const [protected]

Updates given font according to given charcter, returns true if font was changed.

Definition at line 601 of file stringProcessor.cpp.

References eBar, eOverline, eScriptScriptStyle, eScriptStyle, eUnderline, StringProcessor::CharacterInfo::fontSize, and StringProcessor::CharacterInfo::modifier.

Referenced by computeMetrics(), and drawText().

Here is the caller graph for this function:


Member Data Documentation

Definition at line 127 of file stringProcessor.h.

const QStringList StringProcessor::fontFamilyList = "Symbol" [static, protected]

Definition at line 173 of file stringProcessor.h.

Referenced by fillFontLists(), and getSymbolPrintInfo().

const QRegExp StringProcessor::keywordRegex [static]

Definition at line 124 of file stringProcessor.h.

Referenced by isSpecialSymbol().

int StringProcessor::m_ascent [protected]

max ascent in parsed m_text

Definition at line 187 of file stringProcessor.h.

Referenced by computeMetrics(), and getAscent().

List of parsed characters.

Definition at line 181 of file stringProcessor.h.

Referenced by computeMetrics(), drawText(), getCharacterList(), getCharacters(), setText(), and StringProcessor().

int StringProcessor::m_descent [protected]

max descentf in parsed m_text

Definition at line 188 of file stringProcessor.h.

Referenced by computeMetrics(), and getDescent().

index 0 (== eNormalFont) is standard font used in editor index 1 (== eSymbolFont) is font Symbol

Definition at line 175 of file stringProcessor.h.

Referenced by computeMetrics(), drawText(), and fillFontLists().

int StringProcessor::m_fontSize [protected]

Definition at line 184 of file stringProcessor.h.

Referenced by fillFontLists(), and setFontSize().

int StringProcessor::m_height [protected]

max height in parsed m_text

Definition at line 186 of file stringProcessor.h.

Referenced by computeMetrics(), and getHeight().

Definition at line 178 of file stringProcessor.h.

Referenced by fillFontLists().

QString StringProcessor::m_text [protected]

Definition at line 183 of file stringProcessor.h.

Referenced by setText(), StringProcessor(), and text().

int StringProcessor::m_width [protected]

Definition at line 185 of file stringProcessor.h.

Referenced by computeMetrics(), and getWidth().

const QRegExp StringProcessor::specCharacterRegex [static]

Definition at line 125 of file stringProcessor.h.

First in pair is required character, second is index to fontList.

Definition at line 172 of file stringProcessor.h.

Referenced by addToMaps(), computeMetrics(), drawText(), getSymbolPrintInfo(), and initialize().

Definition at line 169 of file stringProcessor.h.

Referenced by addToMaps(), and initialize().

const QRegExp StringProcessor::whitespaceRegex [static]

Definition at line 126 of file stringProcessor.h.


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