Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | class QTextListPrivate : public QTextBlockGroupPrivate | - |
5 | { | - |
6 | public: | - |
7 | QTextListPrivate(QTextDocument *doc) | - |
8 | : QTextBlockGroupPrivate(doc) | - |
9 | { | - |
10 | } executed: } Execution Count:105 | 105 |
11 | }; | - |
12 | QTextList::QTextList(QTextDocument *doc) | - |
13 | : QTextBlockGroup(*new QTextListPrivate(doc), doc) | - |
14 | { | - |
15 | } executed: } Execution Count:105 | 105 |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | QTextList::~QTextList() | - |
21 | { | - |
22 | } | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | int QTextList::count() const | - |
28 | { | - |
29 | const QTextListPrivate * const d = d_func(); | - |
30 | return d->blocks.count(); executed: return d->blocks.count(); Execution Count:55 | 55 |
31 | } | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | QTextBlock QTextList::item(int i) const | - |
39 | { | - |
40 | const QTextListPrivate * const d = d_func(); | - |
41 | if (i < 0 || i >= d->blocks.size()) partially evaluated: i < 0 no Evaluation Count:0 | yes Evaluation Count:5 |
partially evaluated: i >= d->blocks.size() no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
42 | return QTextBlock(); never executed: return QTextBlock(); | 0 |
43 | return d->blocks.at(i); executed: return d->blocks.at(i); Execution Count:5 | 5 |
44 | } | - |
45 | int QTextList::itemNumber(const QTextBlock &blockIt) const | - |
46 | { | - |
47 | const QTextListPrivate * const d = d_func(); | - |
48 | return d->blocks.indexOf(blockIt); executed: return d->blocks.indexOf(blockIt); Execution Count:82 | 82 |
49 | } | - |
50 | | - |
51 | | - |
52 | | - |
53 | | - |
54 | | - |
55 | | - |
56 | QString QTextList::itemText(const QTextBlock &blockIt) const | - |
57 | { | - |
58 | const QTextListPrivate * const d = d_func(); | - |
59 | int item = d->blocks.indexOf(blockIt) + 1; | - |
60 | if (item <= 0) partially evaluated: item <= 0 no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-14 |
61 | return QString(); never executed: return QString(); | 0 |
62 | | - |
63 | QTextBlock block = d->blocks.at(item-1); | - |
64 | QTextBlockFormat blockFormat = block.blockFormat(); | - |
65 | | - |
66 | QString result; | - |
67 | | - |
68 | const int style = format().style(); | - |
69 | QString numberPrefix; | - |
70 | QString numberSuffix = QLatin1String("."); | - |
71 | | - |
72 | if (format().hasProperty(QTextFormat::ListNumberPrefix)) evaluated: format().hasProperty(QTextFormat::ListNumberPrefix) yes Evaluation Count:3 | yes Evaluation Count:11 |
| 3-11 |
73 | numberPrefix = format().numberPrefix(); executed: numberPrefix = format().numberPrefix(); Execution Count:3 | 3 |
74 | if (format().hasProperty(QTextFormat::ListNumberSuffix)) evaluated: format().hasProperty(QTextFormat::ListNumberSuffix) yes Evaluation Count:3 | yes Evaluation Count:11 |
| 3-11 |
75 | numberSuffix = format().numberSuffix(); executed: numberSuffix = format().numberSuffix(); Execution Count:3 | 3 |
76 | | - |
77 | switch (style) { | - |
78 | case QTextListFormat::ListDecimal: | - |
79 | result = QString::number(item); | - |
80 | break; executed: break; Execution Count:1 | 1 |
81 | | - |
82 | case QTextListFormat::ListLowerAlpha: | - |
83 | case QTextListFormat::ListUpperAlpha: | - |
84 | { | - |
85 | const char baseChar = style == QTextListFormat::ListUpperAlpha ? 'A' : 'a'; evaluated: style == QTextListFormat::ListUpperAlpha yes Evaluation Count:3 | yes Evaluation Count:4 |
| 3-4 |
86 | | - |
87 | int c = item; | - |
88 | while (c > 0) { evaluated: c > 0 yes Evaluation Count:12 | yes Evaluation Count:7 |
| 7-12 |
89 | c--; | - |
90 | result.prepend(QChar(baseChar + (c % 26))); | - |
91 | c /= 26; | - |
92 | } executed: } Execution Count:12 | 12 |
93 | } | - |
94 | break; executed: break; Execution Count:7 | 7 |
95 | case QTextListFormat::ListLowerRoman: | - |
96 | case QTextListFormat::ListUpperRoman: | - |
97 | { | - |
98 | if (item < 5000) { evaluated: item < 5000 yes Evaluation Count:5 | yes Evaluation Count:1 |
| 1-5 |
99 | QByteArray romanNumeral; | - |
100 | | - |
101 | | - |
102 | static const char romanSymbolsLower[] = "iiivixxxlxcccdcmmmm"; | - |
103 | static const char romanSymbolsUpper[] = "IIIVIXXXLXCCCDCMMMM"; | - |
104 | QByteArray romanSymbols; | - |
105 | if (style == QTextListFormat::ListLowerRoman) evaluated: style == QTextListFormat::ListLowerRoman yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
106 | romanSymbols = QByteArray::fromRawData(romanSymbolsLower, sizeof(romanSymbolsLower)); executed: romanSymbols = QByteArray::fromRawData(romanSymbolsLower, sizeof(romanSymbolsLower)); Execution Count:2 | 2 |
107 | else | - |
108 | romanSymbols = QByteArray::fromRawData(romanSymbolsUpper, sizeof(romanSymbolsUpper)); executed: romanSymbols = QByteArray::fromRawData(romanSymbolsUpper, sizeof(romanSymbolsUpper)); Execution Count:3 | 3 |
109 | | - |
110 | int c[] = { 1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000 }; | - |
111 | int n = item; | - |
112 | for (int i = 12; i >= 0; n %= c[i], i--) { evaluated: i >= 0 yes Evaluation Count:65 | yes Evaluation Count:5 |
| 5-65 |
113 | int q = n / c[i]; | - |
114 | if (q > 0) { evaluated: q > 0 yes Evaluation Count:11 | yes Evaluation Count:54 |
| 11-54 |
115 | int startDigit = i + (i+3)/4; | - |
116 | int numDigits; | - |
117 | if (i % 4) { evaluated: i % 4 yes Evaluation Count:6 | yes Evaluation Count:5 |
| 5-6 |
118 | | - |
119 | if ((i-2) % 4) { evaluated: (i-2) % 4 yes Evaluation Count:5 | yes Evaluation Count:1 |
| 1-5 |
120 | | - |
121 | numDigits = 2; | - |
122 | } executed: } Execution Count:5 | 5 |
123 | else { | - |
124 | | - |
125 | numDigits = 1; | - |
126 | } executed: } Execution Count:1 | 1 |
127 | } | - |
128 | else { | - |
129 | | - |
130 | numDigits = q; | - |
131 | } executed: } Execution Count:5 | 5 |
132 | | - |
133 | romanNumeral.append(romanSymbols.mid(startDigit, numDigits)); | - |
134 | } executed: } Execution Count:11 | 11 |
135 | } executed: } Execution Count:65 | 65 |
136 | result = QString::fromLatin1(romanNumeral); | - |
137 | } executed: } Execution Count:5 | 5 |
138 | else { | - |
139 | result = QLatin1String("?"); | - |
140 | } executed: } Execution Count:1 | 1 |
141 | | - |
142 | } | - |
143 | break; executed: break; Execution Count:6 | 6 |
144 | default: | - |
145 | qt_noop(); | - |
146 | } | 0 |
147 | if (blockIt.textDirection() == Qt::RightToLeft) evaluated: blockIt.textDirection() == Qt::RightToLeft yes Evaluation Count:2 | yes Evaluation Count:12 |
| 2-12 |
148 | return numberSuffix + result + numberPrefix; executed: return numberSuffix + result + numberPrefix; Execution Count:2 | 2 |
149 | else | - |
150 | return numberPrefix + result + numberSuffix; executed: return numberPrefix + result + numberSuffix; Execution Count:12 | 12 |
151 | } | - |
152 | void QTextList::removeItem(int i) | - |
153 | { | - |
154 | QTextListPrivate * const d = d_func(); | - |
155 | if (i < 0 || i >= d->blocks.size()) never evaluated: i >= d->blocks.size() | 0 |
156 | return; | 0 |
157 | | - |
158 | QTextBlock block = d->blocks.at(i); | - |
159 | remove(block); | - |
160 | } | 0 |
161 | | - |
162 | | - |
163 | | - |
164 | | - |
165 | | - |
166 | | - |
167 | | - |
168 | void QTextList::remove(const QTextBlock &block) | - |
169 | { | - |
170 | QTextBlockFormat fmt = block.blockFormat(); | - |
171 | fmt.setIndent(fmt.indent() + format().indent()); | - |
172 | fmt.setObjectIndex(-1); | - |
173 | block.docHandle()->setBlockFormat(block, block, fmt, QTextDocumentPrivate::SetFormat); | - |
174 | } executed: } Execution Count:3 | 3 |
175 | | - |
176 | | - |
177 | | - |
178 | | - |
179 | | - |
180 | | - |
181 | void QTextList::add(const QTextBlock &block) | - |
182 | { | - |
183 | QTextBlockFormat fmt = block.blockFormat(); | - |
184 | fmt.setObjectIndex(objectIndex()); | - |
185 | block.docHandle()->setBlockFormat(block, block, fmt, QTextDocumentPrivate::SetFormat); | - |
186 | } executed: } Execution Count:33 | 33 |
187 | | - |
188 | | - |
189 | | - |
| | |