#include <stringProcessor.h>
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< CharacterInfo > | TCharacterList |
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, EFont > | TCharPair |
typedef QList< QFont > | TFontList |
typedef QList< QFontMetrics > | TMetricsList |
typedef QMap< QString, TCharPair > | TString2CharMap |
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 |
Definition at line 51 of file stringProcessor.h.
typedef QList<CharacterInfo> StringProcessor::TCharacterList |
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.
determines if change is needed
Definition at line 55 of file stringProcessor.h.
according to LaTeX
Definition at line 63 of file stringProcessor.h.
enum StringProcessor::EKeywordType [protected] |
Definition at line 145 of file stringProcessor.h.
list of symbol modifiers
Definition at line 69 of file stringProcessor.h.
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().
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().
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().
StringProcessor::TCharacterList StringProcessor::computeCharacterList | ( | const QString & | input, | |
int & | startIdx, | |||
EFontSize | fs, | |||
EModifier | m, | |||
bool | useModifierOnce = false | |||
) | [static, protected] |
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().
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().
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().
int StringProcessor::getAscent | ( | ) | const |
Definition at line 571 of file stringProcessor.cpp.
References m_ascent.
Referenced by State::getTextAscent().
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().
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().
int StringProcessor::getDescent | ( | ) | const |
Definition at line 566 of file stringProcessor.cpp.
References m_descent.
Referenced by State::getTextDescent().
int StringProcessor::getHeight | ( | ) | const |
Definition at line 561 of file stringProcessor.cpp.
References m_height.
Referenced by LabelX::boundingRect(), LabelX::getHeight(), and State::getTextHeight().
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().
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().
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().
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().
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().
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().
void StringProcessor::processText | ( | ) | [protected] |
void StringProcessor::setFontSize | ( | int | fontSize | ) |
Related to eTextStyle.
Definition at line 594 of file stringProcessor.cpp.
References computeMetrics(), fillFontLists(), and m_fontSize.
Referenced by LabelX::setFontSize(), and State::setStateLabelScale().
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().
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().
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().
const QRegExp StringProcessor::escapedCharacterRegex [static] |
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().
TCharacterList StringProcessor::m_characterList [protected] |
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().
TFontList StringProcessor::m_fontList [protected] |
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().
TMetricsList StringProcessor::m_metricsList [protected] |
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.
StringProcessor::TString2CharMap StringProcessor::string2CharMap [static, protected] |
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().
StringProcessor::TString2KwTypeMap StringProcessor::string2KwTypeMap [static, protected] |
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.