qmimetype.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9