VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/objects/UIRichTextString.h@ 82781

Last change on this file since 82781 was 76581, checked in by vboxsync, 5 years ago

Fe/QT: scm header guard alignment.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
  • Property svn:mergeinfo set to (toggle deleted branches)
    /branches/VBox-3.0/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h58652,​70973
    /branches/VBox-3.2/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h66309,​66318
    /branches/VBox-4.0/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h70873
    /branches/VBox-4.1/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h74233
    /branches/VBox-4.2/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h91503-91504,​91506-91508,​91510,​91514-91515,​91521
    /branches/VBox-4.3/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h91223
    /branches/VBox-4.3/trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h91223
    /branches/dsen/gui/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h79076-79078,​79089,​79109-79110,​79112-79113,​79127-79130,​79134,​79141,​79151,​79155,​79157-79159,​79193,​79197
    /branches/dsen/gui2/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h79562-79569,​79572-79573,​79578,​79581-79582,​79590-79591,​79598-79599,​79602-79603,​79605-79606,​79632,​79635,​79637,​79644
    /branches/dsen/gui3/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h79645-79692
    /trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemMachine.h79225,​79271
File size: 5.1 KB
Line 
1/* $Id: UIRichTextString.h 76581 2019-01-01 06:24:57Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIRichTextString class declaration.
4 */
5
6/*
7 * Copyright (C) 2015-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef FEQT_INCLUDED_SRC_objects_UIRichTextString_h
19#define FEQT_INCLUDED_SRC_objects_UIRichTextString_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24/* Qt includes: */
25#include <QTextLayout>
26
27/* GUI includes: */
28#include "UILibraryDefs.h"
29
30/** Rich text string implementation which parses the passed QString
31 * and holds it as the tree of the formatted rich text blocks. */
32class SHARED_LIBRARY_STUFF UIRichTextString
33{
34public:
35
36 /** Rich text block types. */
37 enum Type
38 {
39 Type_None,
40 Type_Anchor,
41 Type_Bold,
42 Type_Italic,
43 };
44
45 /** Constructs empty rich text string.
46 * @param enmType Brings the type of <i>this</i> rich text block. */
47 UIRichTextString(Type enmType = Type_None);
48
49 /** Constructs rich text string.
50 * @param strString Brings the string being parsed and held as the tree of rich text blocks.
51 * @param enmType Brings the type of <i>this</i> rich text block.
52 * @param strStringMeta Brings the string containing meta data describing <i>this</i> rich text block. */
53 UIRichTextString(const QString &strString, Type enmType = Type_None, const QString &strStringMeta = QString());
54
55 /** Destructor rich text string. */
56 virtual ~UIRichTextString() /* override */;
57
58 /** Returns the QString representation. */
59 QString toString() const;
60
61 /** Returns the list of existing format ranges appropriate for QTextLayout.
62 * @param iShift Brings the shift of <i>this</i> rich text block accordig to it's root. */
63 QList<QTextLayout::FormatRange> formatRanges(int iShift = 0) const;
64
65 /** Defines the anchor to highlight in <i>this</i> rich text block and in it's children. */
66 void setHoveredAnchor(const QString &strHoveredAnchor);
67
68private:
69
70 /** Parses the string. */
71 void parse();
72
73 /** Used to populate const static map of known patterns.
74 * @note Keep it sync with the method below - #populatePatternHasMeta(). */
75 static QMap<Type, QString> populatePatterns();
76 /** Used to populate const static map of meta flags for the known patterns.
77 * @note Keep it sync with the method above - #populatePatterns(). */
78 static QMap<Type, bool> populatePatternHasMeta();
79
80 /** Recursively searching for the maximum level of the passed pattern.
81 * @param strString Brings the string to check for the current (recursively advanced) pattern in,
82 * @param strPattern Brings the etalon pattern to recursively advance the current pattern with,
83 * @param strCurrentPattern Brings the current (recursively advanced) pattern to check for the presence of,
84 * @param iCurrentLevel Brings the current level of the recursively advanced pattern. */
85 static int searchForMaxLevel(const QString &strString, const QString &strPattern,
86 const QString &strCurrentPattern, int iCurrentLevel = 0);
87
88 /** Recursively composing the pattern of the maximum level.
89 * @param strPattern Brings the etalon pattern to recursively update the current pattern with,
90 * @param strCurrentPattern Brings the current (recursively advanced) pattern,
91 * @param iCurrentLevel Brings the amount of the levels left to recursively advance current pattern. */
92 static QString composeFullPattern(const QString &strPattern,
93 const QString &strCurrentPattern, int iCurrentLevel);
94
95 /** Composes the QTextCharFormat correpoding to passed @a enmType. */
96 static QTextCharFormat textCharFormat(Type enmType);
97
98 /** Holds the type of <i>this</i> rich text block. */
99 Type m_enmType;
100 /** Holds the string of <i>this</i> rich text block. */
101 QString m_strString;
102 /** Holds the string meta data of <i>this</i> rich text block. */
103 QString m_strStringMeta;
104 /** Holds the children of <i>this</i> rich text block. */
105 QMap<int, UIRichTextString*> m_strings;
106
107 /** Holds the anchor of <i>this</i> rich text block. */
108 QString m_strAnchor;
109 /** Holds the anchor to highlight in <i>this</i> rich text block and in it's children. */
110 QString m_strHoveredAnchor;
111
112 /** Holds the <i>any</i> string pattern. */
113 static const QString s_strAny;
114 /** Holds the map of known patterns. */
115 static const QMap<Type, QString> s_patterns;
116 /** Holds the map of meta flags for the known patterns. */
117 static const QMap<Type, bool> s_doPatternHasMeta;
118};
119
120#endif /* !FEQT_INCLUDED_SRC_objects_UIRichTextString_h */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use