| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/text/qtextlist.cpp | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | class QTextListPrivate : public QTextBlockGroupPrivate | - | ||||||||||||
| 5 | { | - | ||||||||||||
| 6 | public: | - | ||||||||||||
| 7 | QTextListPrivate(QTextDocument *doc) | - | ||||||||||||
| 8 | : QTextBlockGroupPrivate(doc) | - | ||||||||||||
| 9 | { | - | ||||||||||||
| 10 | } never executed:  end of block | 0 | ||||||||||||
| 11 | }; | - | ||||||||||||
| 12 | QTextList::QTextList(QTextDocument *doc) | - | ||||||||||||
| 13 | : QTextBlockGroup(*new QTextListPrivate(doc), doc) | - | ||||||||||||
| 14 | { | - | ||||||||||||
| 15 | } never executed:  end of block | 0 | ||||||||||||
| 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 never executed: d->blocks.count(); return d->blocks.count();never executed:  return d->blocks.count(); | 0 | ||||||||||||
| 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 
 
 | 0 | ||||||||||||
| 42 | return never executed: QTextBlock(); return QTextBlock();never executed:  return QTextBlock(); | 0 | ||||||||||||
| 43 | return never executed: d->blocks.at(i); return d->blocks.at(i);never executed:  return d->blocks.at(i); | 0 | ||||||||||||
| 44 | } | - | ||||||||||||
| 45 | int QTextList::itemNumber(const QTextBlock &blockIt) const | - | ||||||||||||
| 46 | { | - | ||||||||||||
| 47 | const QTextListPrivate * const d = d_func(); | - | ||||||||||||
| 48 | return never executed: d->blocks.indexOf(blockIt); return d->blocks.indexOf(blockIt);never executed:  return d->blocks.indexOf(blockIt); | 0 | ||||||||||||
| 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 
 | 0 | ||||||||||||
| 61 | return never executed: QString(); 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) 
 | 0 | ||||||||||||
| 73 | numberPrefix = format().numberPrefix(); never executed:  numberPrefix = format().numberPrefix(); | 0 | ||||||||||||
| 74 | if (format().hasProperty(QTextFormat::ListNumberSuffix) 
 | 0 | ||||||||||||
| 75 | numberSuffix = format().numberSuffix(); never executed:  numberSuffix = format().numberSuffix(); | 0 | ||||||||||||
| 76 | - | |||||||||||||
| 77 | switch (style) { | - | ||||||||||||
| 78 | case never executed: QTextListFormat::ListDecimal: case QTextListFormat::ListDecimal:never executed:  case QTextListFormat::ListDecimal: | 0 | ||||||||||||
| 79 | result = QString::number(item); | - | ||||||||||||
| 80 | break; never executed:  break; | 0 | ||||||||||||
| 81 | - | |||||||||||||
| 82 | case never executed: QTextListFormat::ListLowerAlpha: case QTextListFormat::ListLowerAlpha:never executed:  case QTextListFormat::ListLowerAlpha: | 0 | ||||||||||||
| 83 | case never executed: QTextListFormat::ListUpperAlpha: case QTextListFormat::ListUpperAlpha:never executed:  case QTextListFormat::ListUpperAlpha: | 0 | ||||||||||||
| 84 | { | - | ||||||||||||
| 85 | const char baseChar = style == QTextListFormat::ListUpperAlpha 
 | 0 | ||||||||||||
| 86 | - | |||||||||||||
| 87 | int c = item; | - | ||||||||||||
| 88 | while (c > 0 
 | 0 | ||||||||||||
| 89 | c--; | - | ||||||||||||
| 90 | result.prepend(QChar(baseChar + (c % 26))); | - | ||||||||||||
| 91 | c /= 26; | - | ||||||||||||
| 92 | } never executed:  end of block | 0 | ||||||||||||
| 93 | } | - | ||||||||||||
| 94 | break; never executed:  break; | 0 | ||||||||||||
| 95 | case never executed: QTextListFormat::ListLowerRoman: case QTextListFormat::ListLowerRoman:never executed:  case QTextListFormat::ListLowerRoman: | 0 | ||||||||||||
| 96 | case never executed: QTextListFormat::ListUpperRoman: case QTextListFormat::ListUpperRoman:never executed:  case QTextListFormat::ListUpperRoman: | 0 | ||||||||||||
| 97 | { | - | ||||||||||||
| 98 | if (item < 5000 
 | 0 | ||||||||||||
| 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 
 | 0 | ||||||||||||
| 106 | romanSymbols = QByteArray::fromRawData(romanSymbolsLower, sizeof(romanSymbolsLower)); never executed:  romanSymbols = QByteArray::fromRawData(romanSymbolsLower, sizeof(romanSymbolsLower)); | 0 | ||||||||||||
| 107 | else | - | ||||||||||||
| 108 | romanSymbols = QByteArray::fromRawData(romanSymbolsUpper, sizeof(romanSymbolsUpper)); never executed:  romanSymbols = QByteArray::fromRawData(romanSymbolsUpper, sizeof(romanSymbolsUpper)); | 0 | ||||||||||||
| 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 
 | 0 | ||||||||||||
| 113 | int q = n / c[i]; | - | ||||||||||||
| 114 | if (q > 0 
 | 0 | ||||||||||||
| 115 | int startDigit = i + (i+3)/4; | - | ||||||||||||
| 116 | int numDigits; | - | ||||||||||||
| 117 | if (i % 4 
 | 0 | ||||||||||||
| 118 | - | |||||||||||||
| 119 | if (( 
 
 | 0 | ||||||||||||
| 120 | - | |||||||||||||
| 121 | numDigits = 2; | - | ||||||||||||
| 122 | } never executed:  end of block | 0 | ||||||||||||
| 123 | else { | - | ||||||||||||
| 124 | - | |||||||||||||
| 125 | numDigits = 1; | - | ||||||||||||
| 126 | } never executed:  end of block | 0 | ||||||||||||
| 127 | } | - | ||||||||||||
| 128 | else { | - | ||||||||||||
| 129 | - | |||||||||||||
| 130 | numDigits = q; | - | ||||||||||||
| 131 | } never executed:  end of block | 0 | ||||||||||||
| 132 | - | |||||||||||||
| 133 | romanNumeral.append(romanSymbols.mid(startDigit, numDigits)); | - | ||||||||||||
| 134 | } never executed:  end of block | 0 | ||||||||||||
| 135 | } never executed:  end of block | 0 | ||||||||||||
| 136 | result = QString::fromLatin1(romanNumeral); | - | ||||||||||||
| 137 | } never executed:  end of block | 0 | ||||||||||||
| 138 | else { | - | ||||||||||||
| 139 | result = QLatin1String("?"); | - | ||||||||||||
| 140 | } never executed:  end of block | 0 | ||||||||||||
| 141 | - | |||||||||||||
| 142 | } | - | ||||||||||||
| 143 | break; never executed:  break; | 0 | ||||||||||||
| 144 | default never executed: : default:never executed:  default: | 0 | ||||||||||||
| 145 | ((!(false)) ? qt_assert("false",__FILE__,269) : qt_noop()); | - | ||||||||||||
| 146 | } never executed:  end of block | 0 | ||||||||||||
| 147 | if (blockIt.textDirection() == Qt::RightToLeft 
 | 0 | ||||||||||||
| 148 | return never executed: numberSuffix + result + numberPrefix; return numberSuffix + result + numberPrefix;never executed:  return numberSuffix + result + numberPrefix; | 0 | ||||||||||||
| 149 | else | - | ||||||||||||
| 150 | return never executed: numberPrefix + result + numberSuffix; return numberPrefix + result + numberSuffix;never executed:  return numberPrefix + result + numberSuffix; | 0 | ||||||||||||
| 151 | } | - | ||||||||||||
| 152 | void QTextList::removeItem(int i) | - | ||||||||||||
| 153 | { | - | ||||||||||||
| 154 | QTextListPrivate * const d = d_func(); | - | ||||||||||||
| 155 | if (i < 0 
 
 | 0 | ||||||||||||
| 156 | return; never executed:  return; | 0 | ||||||||||||
| 157 | - | |||||||||||||
| 158 | QTextBlock block = d->blocks.at(i); | - | ||||||||||||
| 159 | remove(block); | - | ||||||||||||
| 160 | } never executed:  end of block | 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 | } never executed:  end of block | 0 | ||||||||||||
| 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 | } never executed:  end of block | 0 | ||||||||||||
| 187 | - | |||||||||||||
| 188 | - | |||||||||||||
| Switch to Source code | Preprocessed file |