Changeset 72167 in vbox for trunk/src/VBox
- Timestamp:
- May 8, 2018 4:24:47 PM (7 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r72166 r72167 1012 1012 src/medium/UIMediumDetailsWidget.cpp \ 1013 1013 src/medium/UIMediumManager.cpp \ 1014 src/objects/UIRichTextString.cpp \1015 1014 src/runtime/UIConsoleEventHandler.cpp \ 1016 1015 src/runtime/UIFrameBuffer.cpp \ … … 1235 1234 src/medium/UIMediumDefs.cpp \ 1236 1235 src/medium/UIMediumEnumerator.cpp \ 1236 src/objects/UIRichTextString.cpp \ 1237 1237 src/runtime/UIActionPoolRuntime.cpp \ 1238 1238 src/selector/UIActionPoolSelector.cpp \ … … 1412 1412 src/medium/UIMediumDefs.cpp \ 1413 1413 src/medium/UIMediumEnumerator.cpp \ 1414 src/objects/UIRichTextString.cpp \ 1414 1415 src/runtime/UIActionPoolRuntime.cpp \ 1415 1416 src/selector/UIActionPoolSelector.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/objects/UIRichTextString.cpp
r69500 r72167 5 5 6 6 /* 7 * Copyright (C) 2015-201 7Oracle Corporation7 * Copyright (C) 2015-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 32 32 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 33 33 34 const QString UIRichTextString::m_sstrAny = QString("[\\s\\S]*"); 35 const QMap<UIRichTextString::Type, QString> UIRichTextString::m_sPatterns = populatePatterns(); 36 const QMap<UIRichTextString::Type, bool> UIRichTextString::m_sPatternHasMeta = populatePatternHasMeta(); 37 38 UIRichTextString::UIRichTextString(Type type /* = Type_None */) 39 : m_type(type) 34 35 const QString UIRichTextString::s_strAny = QString("[\\s\\S]*"); 36 const QMap<UIRichTextString::Type, QString> UIRichTextString::s_patterns = populatePatterns(); 37 const QMap<UIRichTextString::Type, bool> UIRichTextString::s_doPatternHasMeta = populatePatternHasMeta(); 38 39 UIRichTextString::UIRichTextString(Type enmType /* = Type_None */) 40 : m_enmType(enmType) 40 41 , m_strString(QString()) 41 42 , m_strStringMeta(QString()) … … 43 44 } 44 45 45 UIRichTextString::UIRichTextString(const QString &strString, Type type /* = Type_None */, const QString &strStringMeta /* = QString() */)46 : m_ type(type)46 UIRichTextString::UIRichTextString(const QString &strString, Type enmType /* = Type_None */, const QString &strStringMeta /* = QString() */) 47 : m_enmType(enmType) 47 48 , m_strString(strString) 48 49 , m_strStringMeta(strStringMeta) … … 82 83 range.start = iShift; 83 84 range.length = toString().size(); 84 range.format = textCharFormat(m_ type);85 range.format = textCharFormat(m_enmType); 85 86 /* Enable anchor if present: */ 86 87 if (!m_strAnchor.isNull()) … … 120 121 121 122 /* Parse the passed QString with all the known patterns: */ 122 foreach (const Type &enmPattern, m_sPatterns.keys())123 foreach (const Type &enmPattern, s_patterns.keys()) 123 124 { 124 125 /* Get the current pattern: */ 125 const QString strPattern = m_sPatterns.value(enmPattern);126 const QString strPattern = s_patterns.value(enmPattern); 126 127 127 128 /* Recursively parse the string: */ … … 148 149 m_strString.remove(iPosition, regExp.cap(0).size()); 149 150 /* And paste that string as our child: */ 150 const bool fPatterHasMeta = m_sPatternHasMeta.value(enmPattern);151 const bool fPatterHasMeta = s_doPatternHasMeta.value(enmPattern); 151 152 const QString strSubString = !fPatterHasMeta ? regExp.cap(1) : regExp.cap(2); 152 153 const QString strSubMeta = !fPatterHasMeta ? QString() : regExp.cap(1); … … 183 184 const QString &strCurrentPattern, int iCurrentLevel /* = 0 */) 184 185 { 185 QRegExp regExp(strCurrentPattern.arg( m_sstrAny));186 QRegExp regExp(strCurrentPattern.arg(s_strAny)); 186 187 regExp.setMinimal(true); 187 188 if (regExp.indexIn(strString) != -1) 188 189 return searchForMaxLevel(strString, strPattern, 189 strCurrentPattern.arg( m_sstrAny + strPattern + m_sstrAny),190 strCurrentPattern.arg(s_strAny + strPattern + s_strAny), 190 191 iCurrentLevel + 1); 191 192 return iCurrentLevel; … … 198 199 if (iCurrentLevel > 1) 199 200 return composeFullPattern(strPattern, 200 strCurrentPattern.arg( m_sstrAny + strPattern + m_sstrAny),201 strCurrentPattern.arg(s_strAny + strPattern + s_strAny), 201 202 iCurrentLevel - 1); 202 return strCurrentPattern.arg( m_sstrAny);203 } 204 205 /* static */ 206 QTextCharFormat UIRichTextString::textCharFormat(Type type)203 return strCurrentPattern.arg(s_strAny); 204 } 205 206 /* static */ 207 QTextCharFormat UIRichTextString::textCharFormat(Type enmType) 207 208 { 208 209 QTextCharFormat format; 209 switch ( type)210 switch (enmType) 210 211 { 211 212 case Type_Anchor: … … 233 234 return format; 234 235 } 235 -
trunk/src/VBox/Frontends/VirtualBox/src/objects/UIRichTextString.h
r69500 r72167 5 5 6 6 /* 7 * Copyright (C) 2015-201 7Oracle Corporation7 * Copyright (C) 2015-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 22 22 #include <QTextLayout> 23 23 24 /* GUI includes: */ 25 #include "UILibraryDefs.h" 26 24 27 /** Rich text string implementation which parses the passed QString 25 28 * and holds it as the tree of the formatted rich text blocks. */ 26 class UIRichTextString29 class SHARED_LIBRARY_STUFF UIRichTextString 27 30 { 28 31 public: … … 37 40 }; 38 41 39 /** Default (empty) constructor. */ 40 UIRichTextString(Type type = Type_None); 42 /** Constructs empty rich text string. 43 * @param enmType Brings the type of <i>this</i> rich text block. */ 44 UIRichTextString(Type enmType = Type_None); 41 45 42 /** Construct or taking passed QString.43 * @param strString holds the string being parsed and held as the tree of rich text blocks,44 * @param type holds the type of <i>this</i> rich text block,45 * @param strStringMeta holds the string containing meta data describing <i>this</i> rich text block. */46 UIRichTextString(const QString &strString, Type type = Type_None, const QString &strStringMeta = QString());46 /** Constructs rich text string. 47 * @param strString Brings the string being parsed and held as the tree of rich text blocks. 48 * @param enmType Brings the type of <i>this</i> rich text block. 49 * @param strStringMeta Brings the string containing meta data describing <i>this</i> rich text block. */ 50 UIRichTextString(const QString &strString, Type enmType = Type_None, const QString &strStringMeta = QString()); 47 51 48 /** Destructor . */49 ~UIRichTextString();52 /** Destructor rich text string. */ 53 virtual ~UIRichTextString() /* override */; 50 54 51 55 /** Returns the QString representation. */ … … 53 57 54 58 /** Returns the list of existing format ranges appropriate for QTextLayout. 55 * @param iShift holds the shift of <i>this</i> rich text block accordig to it's root. */59 * @param iShift Brings the shift of <i>this</i> rich text block accordig to it's root. */ 56 60 QList<QTextLayout::FormatRange> formatRanges(int iShift = 0) const; 57 61 … … 65 69 66 70 /** Used to populate const static map of known patterns. 67 * @note Keep it sync with the method below - #populatePatternHasMeta(). */71 * @note Keep it sync with the method below - #populatePatternHasMeta(). */ 68 72 static QMap<Type, QString> populatePatterns(); 69 73 /** Used to populate const static map of meta flags for the known patterns. 70 * @note Keep it sync with the method above - #populatePatterns(). */74 * @note Keep it sync with the method above - #populatePatterns(). */ 71 75 static QMap<Type, bool> populatePatternHasMeta(); 72 76 73 77 /** Recursively searching for the maximum level of the passed pattern. 74 * @param strString holds the string to check for the current (recursively advanced) pattern in,75 * @param strPattern holds the etalon pattern to recursively advance the current pattern with,76 * @param strCurrentPattern holds the current (recursively advanced) pattern to check for the presence of,77 * @param iCurrentLevel holds the current level of the recursively advanced pattern. */78 * @param strString Brings the string to check for the current (recursively advanced) pattern in, 79 * @param strPattern Brings the etalon pattern to recursively advance the current pattern with, 80 * @param strCurrentPattern Brings the current (recursively advanced) pattern to check for the presence of, 81 * @param iCurrentLevel Brings the current level of the recursively advanced pattern. */ 78 82 static int searchForMaxLevel(const QString &strString, const QString &strPattern, 79 83 const QString &strCurrentPattern, int iCurrentLevel = 0); 80 84 81 85 /** Recursively composing the pattern of the maximum level. 82 * @param strPattern holds the etalon pattern to recursively update the current pattern with,83 * @param strCurrentPattern holds the current (recursively advanced) pattern,84 * @param iCurrentLevel holds the amount of the levels left to recursively advance current pattern. */86 * @param strPattern Brings the etalon pattern to recursively update the current pattern with, 87 * @param strCurrentPattern Brings the current (recursively advanced) pattern, 88 * @param iCurrentLevel Brings the amount of the levels left to recursively advance current pattern. */ 85 89 static QString composeFullPattern(const QString &strPattern, 86 90 const QString &strCurrentPattern, int iCurrentLevel); 87 91 88 /** Composes the QTextCharFormat correpoding to passed @a type. */89 static QTextCharFormat textCharFormat(Type type);92 /** Composes the QTextCharFormat correpoding to passed @a enmType. */ 93 static QTextCharFormat textCharFormat(Type enmType); 90 94 91 95 /** Holds the type of <i>this</i> rich text block. */ 92 Type m_type;96 Type m_enmType; 93 97 /** Holds the string of <i>this</i> rich text block. */ 94 QString m_strString;98 QString m_strString; 95 99 /** Holds the string meta data of <i>this</i> rich text block. */ 96 QString m_strStringMeta;100 QString m_strStringMeta; 97 101 /** Holds the children of <i>this</i> rich text block. */ 98 QMap<int, UIRichTextString*> m_strings;102 QMap<int, UIRichTextString*> m_strings; 99 103 100 104 /** Holds the anchor of <i>this</i> rich text block. */ 101 QString m_strAnchor;105 QString m_strAnchor; 102 106 /** Holds the anchor to highlight in <i>this</i> rich text block and in it's children. */ 103 QString m_strHoveredAnchor;107 QString m_strHoveredAnchor; 104 108 105 109 /** Holds the <i>any</i> string pattern. */ 106 static const QString m_sstrAny;110 static const QString s_strAny; 107 111 /** Holds the map of known patterns. */ 108 static const QMap<Type, QString> m_sPatterns;112 static const QMap<Type, QString> s_patterns; 109 113 /** Holds the map of meta flags for the known patterns. */ 110 static const QMap<Type, bool> m_sPatternHasMeta;114 static const QMap<Type, bool> s_doPatternHasMeta; 111 115 }; 112 116 113 117 #endif /* !___UIRichTextString_h___ */ 114
Note:
See TracChangeset
for help on using the changeset viewer.