| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/mimetypes/qmimetype.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | - | |||||||||||||
| 8 | - | |||||||||||||
| 9 | - | |||||||||||||
| 10 | - | |||||||||||||
| 11 | QMimeTypePrivate::QMimeTypePrivate() | - | ||||||||||||
| 12 | : loaded(false) | - | ||||||||||||
| 13 | {} executed 7974 times by 24 tests: end of blockExecuted by:
| 7974 | ||||||||||||
| 14 | - | |||||||||||||
| 15 | QMimeTypePrivate::QMimeTypePrivate(const QMimeType &other) | - | ||||||||||||
| 16 | : loaded(other.d->loaded), | - | ||||||||||||
| 17 | name(other.d->name), | - | ||||||||||||
| 18 | localeComments(other.d->localeComments), | - | ||||||||||||
| 19 | genericIconName(other.d->genericIconName), | - | ||||||||||||
| 20 | iconName(other.d->iconName), | - | ||||||||||||
| 21 | globPatterns(other.d->globPatterns) | - | ||||||||||||
| 22 | {} never executed: end of block | 0 | ||||||||||||
| 23 | - | |||||||||||||
| 24 | void QMimeTypePrivate::clear() | - | ||||||||||||
| 25 | { | - | ||||||||||||
| 26 | name.clear(); | - | ||||||||||||
| 27 | localeComments.clear(); | - | ||||||||||||
| 28 | genericIconName.clear(); | - | ||||||||||||
| 29 | iconName.clear(); | - | ||||||||||||
| 30 | globPatterns.clear(); | - | ||||||||||||
| 31 | loaded = false; | - | ||||||||||||
| 32 | } executed 3319 times by 1 test: end of blockExecuted by:
| 3319 | ||||||||||||
| 33 | - | |||||||||||||
| 34 | void QMimeTypePrivate::addGlobPattern(const QString &pattern) | - | ||||||||||||
| 35 | { | - | ||||||||||||
| 36 | globPatterns.append(pattern); | - | ||||||||||||
| 37 | } executed 4136 times by 1 test: end of blockExecuted by:
| 4136 | ||||||||||||
| 38 | QMimeType::QMimeType() : | - | ||||||||||||
| 39 | d(new QMimeTypePrivate()) | - | ||||||||||||
| 40 | { | - | ||||||||||||
| 41 | } executed 40 times by 3 tests: end of blockExecuted by:
| 40 | ||||||||||||
| 42 | - | |||||||||||||
| 43 | - | |||||||||||||
| 44 | - | |||||||||||||
| 45 | - | |||||||||||||
| 46 | - | |||||||||||||
| 47 | QMimeType::QMimeType(const QMimeType &other) : | - | ||||||||||||
| 48 | d(other.d) | - | ||||||||||||
| 49 | { | - | ||||||||||||
| 50 | } executed 14717 times by 22 tests: end of blockExecuted by:
| 14717 | ||||||||||||
| 51 | - | |||||||||||||
| 52 | - | |||||||||||||
| 53 | - | |||||||||||||
| 54 | - | |||||||||||||
| 55 | - | |||||||||||||
| 56 | QMimeType &QMimeType::operator=(const QMimeType &other) | - | ||||||||||||
| 57 | { | - | ||||||||||||
| 58 | if (d != other.d
| 0-4 | ||||||||||||
| 59 | d = other.d; executed 4 times by 1 test: d = other.d;Executed by:
| 4 | ||||||||||||
| 60 | return executed 4 times by 1 test: *this;return *this;Executed by:
executed 4 times by 1 test: return *this;Executed by:
| 4 | ||||||||||||
| 61 | } | - | ||||||||||||
| 62 | - | |||||||||||||
| 63 | - | |||||||||||||
| 64 | - | |||||||||||||
| 65 | - | |||||||||||||
| 66 | - | |||||||||||||
| 67 | - | |||||||||||||
| 68 | QMimeType::QMimeType(const QMimeTypePrivate &dd) : | - | ||||||||||||
| 69 | d(new QMimeTypePrivate(dd)) | - | ||||||||||||
| 70 | { | - | ||||||||||||
| 71 | } executed 11236 times by 24 tests: end of blockExecuted by:
| 11236 | ||||||||||||
| 72 | QMimeType::~QMimeType() | - | ||||||||||||
| 73 | { | - | ||||||||||||
| 74 | } | - | ||||||||||||
| 75 | - | |||||||||||||
| 76 | - | |||||||||||||
| 77 | - | |||||||||||||
| 78 | - | |||||||||||||
| 79 | - | |||||||||||||
| 80 | - | |||||||||||||
| 81 | - | |||||||||||||
| 82 | bool QMimeType::operator==(const QMimeType &other) const | - | ||||||||||||
| 83 | { | - | ||||||||||||
| 84 | return executed 3 times by 1 test: d == other.d || d->name == other.d->name;return d == other.d || d->name == other.d->name;Executed by:
executed 3 times by 1 test: return d == other.d || d->name == other.d->name;Executed by:
| 3 | ||||||||||||
| 85 | } | - | ||||||||||||
| 86 | uint qHash(const QMimeType &key, uint seed) noexcept | - | ||||||||||||
| 87 | { | - | ||||||||||||
| 88 | return never executed: qHash(key.d->name, seed);return qHash(key.d->name, seed);never executed: return qHash(key.d->name, seed); | 0 | ||||||||||||
| 89 | } | - | ||||||||||||
| 90 | bool QMimeType::isValid() const | - | ||||||||||||
| 91 | { | - | ||||||||||||
| 92 | return executed 6692 times by 23 tests: !d->name.isEmpty();return !d->name.isEmpty();Executed by:
executed 6692 times by 23 tests: return !d->name.isEmpty();Executed by:
| 6692 | ||||||||||||
| 93 | } | - | ||||||||||||
| 94 | - | |||||||||||||
| 95 | - | |||||||||||||
| 96 | - | |||||||||||||
| 97 | - | |||||||||||||
| 98 | - | |||||||||||||
| 99 | - | |||||||||||||
| 100 | bool QMimeType::isDefault() const | - | ||||||||||||
| 101 | { | - | ||||||||||||
| 102 | return executed 18 times by 1 test: d->name == QMimeDatabasePrivate::instance()->defaultMimeType();return d->name == QMimeDatabasePrivate::instance()->defaultMimeType();Executed by:
executed 18 times by 1 test: return d->name == QMimeDatabasePrivate::instance()->defaultMimeType();Executed by:
| 18 | ||||||||||||
| 103 | } | - | ||||||||||||
| 104 | - | |||||||||||||
| 105 | - | |||||||||||||
| 106 | - | |||||||||||||
| 107 | - | |||||||||||||
| 108 | - | |||||||||||||
| 109 | QString QMimeType::name() const | - | ||||||||||||
| 110 | { | - | ||||||||||||
| 111 | return executed 12543 times by 3 tests: d->name;return d->name;Executed by:
executed 12543 times by 3 tests: return d->name;Executed by:
| 12543 | ||||||||||||
| 112 | } | - | ||||||||||||
| 113 | - | |||||||||||||
| 114 | - | |||||||||||||
| 115 | - | |||||||||||||
| 116 | - | |||||||||||||
| 117 | - | |||||||||||||
| 118 | - | |||||||||||||
| 119 | QString QMimeType::comment() const | - | ||||||||||||
| 120 | { | - | ||||||||||||
| 121 | QMimeDatabasePrivate::instance()->provider()->loadMimeTypePrivate(*d); | - | ||||||||||||
| 122 | - | |||||||||||||
| 123 | QStringList languageList; | - | ||||||||||||
| 124 | languageList << QLocale().name(); | - | ||||||||||||
| 125 | languageList << QLocale().uiLanguages(); | - | ||||||||||||
| 126 | for (const QString &language : qAsConst(languageList)) { | - | ||||||||||||
| 127 | const QString lang = language == QLatin1String("C")
| 4-14 | ||||||||||||
| 128 | const QString comm = d->localeComments.value(lang); | - | ||||||||||||
| 129 | if (!comm.isEmpty()
| 4-14 | ||||||||||||
| 130 | return executed 14 times by 1 test: comm;return comm;Executed by:
executed 14 times by 1 test: return comm;Executed by:
| 14 | ||||||||||||
| 131 | const int pos = lang.indexOf(QLatin1Char('_')); | - | ||||||||||||
| 132 | if (pos != -1
| 0-4 | ||||||||||||
| 133 | - | |||||||||||||
| 134 | const QString shortLang = lang.left(pos); | - | ||||||||||||
| 135 | const QString commShort = d->localeComments.value(shortLang); | - | ||||||||||||
| 136 | if (!commShort.isEmpty()
| 0-4 | ||||||||||||
| 137 | return executed 4 times by 1 test: commShort;return commShort;Executed by:
executed 4 times by 1 test: return commShort;Executed by:
| 4 | ||||||||||||
| 138 | } never executed: end of block | 0 | ||||||||||||
| 139 | } never executed: end of block | 0 | ||||||||||||
| 140 | - | |||||||||||||
| 141 | - | |||||||||||||
| 142 | return never executed: d->name;return d->name;never executed: return d->name; | 0 | ||||||||||||
| 143 | } | - | ||||||||||||
| 144 | QString QMimeType::genericIconName() const | - | ||||||||||||
| 145 | { | - | ||||||||||||
| 146 | QMimeDatabasePrivate::instance()->provider()->loadGenericIcon(*d); | - | ||||||||||||
| 147 | if (d->genericIconName.isEmpty()
| 4-5 | ||||||||||||
| 148 | - | |||||||||||||
| 149 | - | |||||||||||||
| 150 | - | |||||||||||||
| 151 | - | |||||||||||||
| 152 | - | |||||||||||||
| 153 | QString group = name(); | - | ||||||||||||
| 154 | const int slashindex = group.indexOf(QLatin1Char('/')); | - | ||||||||||||
| 155 | if (slashindex != -1
| 0-4 | ||||||||||||
| 156 | group = group.left(slashindex); executed 4 times by 1 test: group = group.left(slashindex);Executed by:
| 4 | ||||||||||||
| 157 | return executed 4 times by 1 test: group + QLatin1String("-x-generic");return group + QLatin1String("-x-generic");Executed by:
executed 4 times by 1 test: return group + QLatin1String("-x-generic");Executed by:
| 4 | ||||||||||||
| 158 | } | - | ||||||||||||
| 159 | return executed 5 times by 2 tests: d->genericIconName;return d->genericIconName;Executed by:
executed 5 times by 2 tests: return d->genericIconName;Executed by:
| 5 | ||||||||||||
| 160 | } | - | ||||||||||||
| 161 | - | |||||||||||||
| 162 | - | |||||||||||||
| 163 | - | |||||||||||||
| 164 | - | |||||||||||||
| 165 | - | |||||||||||||
| 166 | - | |||||||||||||
| 167 | - | |||||||||||||
| 168 | QString QMimeType::iconName() const | - | ||||||||||||
| 169 | { | - | ||||||||||||
| 170 | QMimeDatabasePrivate::instance()->provider()->loadIcon(*d); | - | ||||||||||||
| 171 | if (d->iconName.isEmpty()
| 3-6 | ||||||||||||
| 172 | - | |||||||||||||
| 173 | d->iconName = name(); | - | ||||||||||||
| 174 | const int slashindex = d->iconName.indexOf(QLatin1Char('/')); | - | ||||||||||||
| 175 | if (slashindex != -1
| 0-6 | ||||||||||||
| 176 | d->iconName[slashindex] = QLatin1Char('-'); executed 6 times by 1 test: d->iconName[slashindex] = QLatin1Char('-');Executed by:
| 6 | ||||||||||||
| 177 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||
| 178 | return executed 9 times by 2 tests: d->iconName;return d->iconName;Executed by:
executed 9 times by 2 tests: return d->iconName;Executed by:
| 9 | ||||||||||||
| 179 | } | - | ||||||||||||
| 180 | - | |||||||||||||
| 181 | - | |||||||||||||
| 182 | - | |||||||||||||
| 183 | - | |||||||||||||
| 184 | - | |||||||||||||
| 185 | QStringList QMimeType::globPatterns() const | - | ||||||||||||
| 186 | { | - | ||||||||||||
| 187 | QMimeDatabasePrivate::instance()->provider()->loadMimeTypePrivate(*d); | - | ||||||||||||
| 188 | return executed 21 times by 2 tests: d->globPatterns;return d->globPatterns;Executed by:
executed 21 times by 2 tests: return d->globPatterns;Executed by:
| 21 | ||||||||||||
| 189 | } | - | ||||||||||||
| 190 | QStringList QMimeType::parentMimeTypes() const | - | ||||||||||||
| 191 | { | - | ||||||||||||
| 192 | return executed 16 times by 1 test: QMimeDatabasePrivate::instance()->provider()->parents(d->name);return QMimeDatabasePrivate::instance()->provider()->parents(d->name);Executed by:
executed 16 times by 1 test: return QMimeDatabasePrivate::instance()->provider()->parents(d->name);Executed by:
| 16 | ||||||||||||
| 193 | } | - | ||||||||||||
| 194 | - | |||||||||||||
| 195 | static void collectParentMimeTypes(const QString &mime, QStringList &allParents) | - | ||||||||||||
| 196 | { | - | ||||||||||||
| 197 | const QStringList parents = QMimeDatabasePrivate::instance()->provider()->parents(mime); | - | ||||||||||||
| 198 | for (const QString &parent : parents) { | - | ||||||||||||
| 199 | - | |||||||||||||
| 200 | if (!allParents.contains(parent)
| 4-24 | ||||||||||||
| 201 | allParents.append(parent); executed 24 times by 1 test: allParents.append(parent);Executed by:
| 24 | ||||||||||||
| 202 | } executed 28 times by 1 test: end of blockExecuted by:
| 28 | ||||||||||||
| 203 | - | |||||||||||||
| 204 | - | |||||||||||||
| 205 | for (const QString &parent : parents) | - | ||||||||||||
| 206 | collectParentMimeTypes(parent, allParents); executed 28 times by 1 test: collectParentMimeTypes(parent, allParents);Executed by:
| 28 | ||||||||||||
| 207 | } executed 36 times by 1 test: end of blockExecuted by:
| 36 | ||||||||||||
| 208 | QStringList QMimeType::allAncestors() const | - | ||||||||||||
| 209 | { | - | ||||||||||||
| 210 | QStringList allParents; | - | ||||||||||||
| 211 | collectParentMimeTypes(d->name, allParents); | - | ||||||||||||
| 212 | return executed 8 times by 1 test: allParents;return allParents;Executed by:
executed 8 times by 1 test: return allParents;Executed by:
| 8 | ||||||||||||
| 213 | } | - | ||||||||||||
| 214 | QStringList QMimeType::aliases() const | - | ||||||||||||
| 215 | { | - | ||||||||||||
| 216 | return executed 8 times by 1 test: QMimeDatabasePrivate::instance()->provider()->listAliases(d->name);return QMimeDatabasePrivate::instance()->provider()->listAliases(d->name);Executed by:
executed 8 times by 1 test: return QMimeDatabasePrivate::instance()->provider()->listAliases(d->name);Executed by:
| 8 | ||||||||||||
| 217 | } | - | ||||||||||||
| 218 | - | |||||||||||||
| 219 | - | |||||||||||||
| 220 | - | |||||||||||||
| 221 | - | |||||||||||||
| 222 | - | |||||||||||||
| 223 | QStringList QMimeType::suffixes() const | - | ||||||||||||
| 224 | { | - | ||||||||||||
| 225 | QMimeDatabasePrivate::instance()->provider()->loadMimeTypePrivate(*d); | - | ||||||||||||
| 226 | - | |||||||||||||
| 227 | QStringList result; | - | ||||||||||||
| 228 | for (const QString &pattern : qAsConst(d->globPatterns)) { | - | ||||||||||||
| 229 | - | |||||||||||||
| 230 | if (pattern.startsWith(QLatin1String("*."))
| 4-2466 | ||||||||||||
| 231 | pattern.length() > 2
| 0-2466 | ||||||||||||
| 232 | pattern.indexOf(QLatin1Char('*'), 2) < 0
| 0-2466 | ||||||||||||
| 233 | const QString suffix = pattern.mid(2); | - | ||||||||||||
| 234 | result.append(suffix); | - | ||||||||||||
| 235 | } executed 2466 times by 23 tests: end of blockExecuted by:
| 2466 | ||||||||||||
| 236 | } executed 2470 times by 23 tests: end of blockExecuted by:
| 2470 | ||||||||||||
| 237 | - | |||||||||||||
| 238 | return executed 2448 times by 23 tests: result;return result;Executed by:
executed 2448 times by 23 tests: return result;Executed by:
| 2448 | ||||||||||||
| 239 | } | - | ||||||||||||
| 240 | - | |||||||||||||
| 241 | - | |||||||||||||
| 242 | - | |||||||||||||
| 243 | - | |||||||||||||
| 244 | - | |||||||||||||
| 245 | - | |||||||||||||
| 246 | QString QMimeType::preferredSuffix() const | - | ||||||||||||
| 247 | { | - | ||||||||||||
| 248 | const QStringList suffixList = suffixes(); | - | ||||||||||||
| 249 | return executed 2447 times by 22 tests: suffixList.isEmpty() ? QString() : suffixList.at(0);return suffixList.isEmpty() ? QString() : suffixList.at(0);Executed by:
executed 2447 times by 22 tests: return suffixList.isEmpty() ? QString() : suffixList.at(0);Executed by:
| 2447 | ||||||||||||
| 250 | } | - | ||||||||||||
| 251 | - | |||||||||||||
| 252 | - | |||||||||||||
| 253 | - | |||||||||||||
| 254 | - | |||||||||||||
| 255 | - | |||||||||||||
| 256 | QString QMimeType::filterString() const | - | ||||||||||||
| 257 | { | - | ||||||||||||
| 258 | QMimeDatabasePrivate::instance()->provider()->loadMimeTypePrivate(*d); | - | ||||||||||||
| 259 | QString filter; | - | ||||||||||||
| 260 | - | |||||||||||||
| 261 | if (!d->globPatterns.empty()
| 0 | ||||||||||||
| 262 | filter += comment() + QLatin1String(" ("); | - | ||||||||||||
| 263 | for (int i = 0; i < d->globPatterns.size()
| 0 | ||||||||||||
| 264 | if (i != 0
| 0 | ||||||||||||
| 265 | filter += QLatin1Char(' '); never executed: filter += QLatin1Char(' '); | 0 | ||||||||||||
| 266 | filter += d->globPatterns.at(i); | - | ||||||||||||
| 267 | } never executed: end of block | 0 | ||||||||||||
| 268 | filter += QLatin1Char(')'); | - | ||||||||||||
| 269 | } never executed: end of block | 0 | ||||||||||||
| 270 | - | |||||||||||||
| 271 | return never executed: filter;return filter;never executed: return filter; | 0 | ||||||||||||
| 272 | } | - | ||||||||||||
| 273 | - | |||||||||||||
| 274 | - | |||||||||||||
| 275 | - | |||||||||||||
| 276 | - | |||||||||||||
| 277 | - | |||||||||||||
| 278 | - | |||||||||||||
| 279 | - | |||||||||||||
| 280 | bool QMimeType::inherits(const QString &mimeTypeName) const | - | ||||||||||||
| 281 | { | - | ||||||||||||
| 282 | if (d->name == mimeTypeName
| 4-52 | ||||||||||||
| 283 | return executed 4 times by 1 test: true;return true;Executed by:
executed 4 times by 1 test: return true;Executed by:
| 4 | ||||||||||||
| 284 | return executed 52 times by 1 test: QMimeDatabasePrivate::instance()->inherits(d->name, mimeTypeName);return QMimeDatabasePrivate::instance()->inherits(d->name, mimeTypeName);Executed by:
executed 52 times by 1 test: return QMimeDatabasePrivate::instance()->inherits(d->name, mimeTypeName);Executed by:
| 52 | ||||||||||||
| 285 | } | - | ||||||||||||
| 286 | - | |||||||||||||
| 287 | - | |||||||||||||
| 288 | QDebug operator<<(QDebug debug, const QMimeType &mime) | - | ||||||||||||
| 289 | { | - | ||||||||||||
| 290 | QDebugStateSaver saver(debug); | - | ||||||||||||
| 291 | if (!mime.isValid()
| 1 | ||||||||||||
| 292 | debug.nospace() << "QMimeType(invalid)"; | - | ||||||||||||
| 293 | } executed 1 time by 1 test: else {end of blockExecuted by:
| 1 | ||||||||||||
| 294 | debug.nospace() << "QMimeType(" << mime.name() << ")"; | - | ||||||||||||
| 295 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||
| 296 | return executed 2 times by 1 test: debug;return debug;Executed by:
executed 2 times by 1 test: return debug;Executed by:
| 2 | ||||||||||||
| 297 | } | - | ||||||||||||
| 298 | - | |||||||||||||
| 299 | - | |||||||||||||
| 300 | - | |||||||||||||
| Switch to Source code | Preprocessed file |