-rw-r--r-- | library/mimetype.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/library/mimetype.cpp b/library/mimetype.cpp index c6a4453..9fab160 100644 --- a/library/mimetype.cpp +++ b/library/mimetype.cpp | |||
@@ -19,4 +19,5 @@ | |||
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #define QTOPIA_INTERNAL_MIMEEXT | ||
21 | #include "mimetype.h" | 22 | #include "mimetype.h" |
22 | #include "applnk.h" | 23 | #include "applnk.h" |
@@ -47,4 +48,5 @@ public: | |||
47 | } | 48 | } |
48 | QString id; | 49 | QString id; |
50 | QString extension; | ||
49 | QString desc; | 51 | QString desc; |
50 | QPixmap regIcon; | 52 | QPixmap regIcon; |
@@ -60,4 +62,5 @@ public: | |||
60 | MimeType::Dict* MimeType::d=0; | 62 | MimeType::Dict* MimeType::d=0; |
61 | static QMap<QString,QString> *typeFor = 0; | 63 | static QMap<QString,QString> *typeFor = 0; |
64 | static QMap<QString,QString> *extFor = 0; | ||
62 | 65 | ||
63 | MimeType::Dict& MimeType::dict() | 66 | MimeType::Dict& MimeType::dict() |
@@ -97,4 +100,10 @@ QPixmap MimeType::pixmap() const | |||
97 | } | 100 | } |
98 | 101 | ||
102 | QString MimeType::extension() const | ||
103 | { | ||
104 | loadExtensions(); | ||
105 | return *(*extFor).find(i); | ||
106 | } | ||
107 | |||
99 | QPixmap MimeType::bigPixmap() const | 108 | QPixmap MimeType::bigPixmap() const |
100 | { | 109 | { |
@@ -129,4 +138,5 @@ void MimeType::loadExtensions() | |||
129 | { | 138 | { |
130 | if ( !typeFor ) { | 139 | if ( !typeFor ) { |
140 | extFor = new QMap<QString,QString>; | ||
131 | typeFor = new QMap<QString,QString>; | 141 | typeFor = new QMap<QString,QString>; |
132 | loadExtensions("/etc/mime.types"); | 142 | loadExtensions("/etc/mime.types"); |
@@ -146,7 +156,10 @@ void MimeType::loadExtensions(const QString& filename) | |||
146 | if ( it != tokens.end() ) { | 156 | if ( it != tokens.end() ) { |
147 | QString id = *it; ++it; | 157 | QString id = *it; ++it; |
148 | while (it != tokens.end()) { | 158 | if ( it != tokens.end() ) { |
149 | (*typeFor)[*it] = id; | 159 | (*extFor)[id] = *it; |
150 | ++it; | 160 | while (it != tokens.end()) { |
161 | (*typeFor)[*it] = id; | ||
162 | ++it; | ||
163 | } | ||
151 | } | 164 | } |
152 | } | 165 | } |