-rw-r--r-- | library/mimetype.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/library/mimetype.cpp b/library/mimetype.cpp index e2e0dab..92fe5e6 100644 --- a/library/mimetype.cpp +++ b/library/mimetype.cpp | |||
@@ -230,40 +230,38 @@ void MimeType::loadExtensions() | |||
230 | } | 230 | } |
231 | 231 | ||
232 | void MimeType::loadExtensions(const QString& filename) | 232 | void MimeType::loadExtensions(const QString& filename) |
233 | { | 233 | { |
234 | QFile file(filename); | 234 | QFile file(filename); |
235 | if ( file.open(IO_ReadOnly) ) { | 235 | if ( file.open(IO_ReadOnly) ) { |
236 | QTextStream in(&file); | 236 | QTextStream in(&file); |
237 | QRegExp space("[ \t]+"); | 237 | QRegExp space("[ \t]+"); |
238 | while (!in.atEnd()) { | 238 | while (!in.atEnd()) { |
239 | QStringList tokens = QStringList::split(space, in.readLine()); | 239 | QStringList tokens = QStringList::split(space, in.readLine()); |
240 | QStringList::ConstIterator it = tokens.begin(); | 240 | QStringList::ConstIterator it = tokens.begin(); |
241 | if ( it != tokens.end() ) { | 241 | if ( it != tokens.end() ) { |
242 | QString id = *it; ++it; | 242 | QString id = *it; ++it; |
243 | // new override old (though left overrides right) | 243 | // new override old (though left overrides right) |
244 | QStringList exts = (*extFor)[id]; | 244 | QStringList exts = (*extFor)[id]; |
245 | QStringList newexts; | 245 | QStringList newexts; |
246 | if ( it != tokens.end() ) { | 246 | while ( it != tokens.end() ) { |
247 | exts.remove(*it); | 247 | exts.remove(*it); |
248 | if ( !newexts.contains(*it) ) | 248 | if ( !newexts.contains(*it) ) |
249 | newexts.append(*it); | 249 | newexts.append(*it); |
250 | while (it != tokens.end()) { | 250 | (*typeFor)[*it] = id; |
251 | (*typeFor)[*it] = id; | 251 | ++it; |
252 | ++it; | ||
253 | } | ||
254 | } | 252 | } |
255 | (*extFor)[id] = newexts + exts; | 253 | (*extFor)[id] = newexts + exts; |
256 | } | 254 | } |
257 | } | 255 | } |
258 | } | 256 | } |
259 | } | 257 | } |
260 | 258 | ||
261 | void MimeType::init( const QString& ext_or_id ) | 259 | void MimeType::init( const QString& ext_or_id ) |
262 | { | 260 | { |
263 | if ( ext_or_id[0] != '/' && ext_or_id.contains('/') ) { | 261 | if ( ext_or_id[0] != '/' && ext_or_id.contains('/') ) { |
264 | i = ext_or_id.lower(); | 262 | i = ext_or_id.lower(); |
265 | } else { | 263 | } else { |
266 | loadExtensions(); | 264 | loadExtensions(); |
267 | int dot = ext_or_id.findRev('.'); | 265 | int dot = ext_or_id.findRev('.'); |
268 | QString ext = dot >= 0 ? ext_or_id.mid(dot+1) : ext_or_id; | 266 | QString ext = dot >= 0 ? ext_or_id.mid(dot+1) : ext_or_id; |
269 | i = (*typeFor)[ext.lower()]; | 267 | i = (*typeFor)[ext.lower()]; |