-rw-r--r-- | library/mimetype.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/library/mimetype.cpp b/library/mimetype.cpp index c6a4453..9fab160 100644 --- a/library/mimetype.cpp +++ b/library/mimetype.cpp | |||
@@ -18,6 +18,7 @@ | |||
18 | ** | 18 | ** |
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" |
23 | #include "resource.h" | 24 | #include "resource.h" |
@@ -46,6 +47,7 @@ public: | |||
46 | } | 47 | } |
47 | } | 48 | } |
48 | QString id; | 49 | QString id; |
50 | QString extension; | ||
49 | QString desc; | 51 | QString desc; |
50 | QPixmap regIcon; | 52 | QPixmap regIcon; |
51 | QPixmap bigIcon; | 53 | QPixmap bigIcon; |
@@ -59,6 +61,7 @@ public: | |||
59 | 61 | ||
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() |
64 | { | 67 | { |
@@ -96,6 +99,12 @@ QPixmap MimeType::pixmap() const | |||
96 | return d ? d->regIcon : QPixmap(); | 99 | return d ? d->regIcon : QPixmap(); |
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 | { |
101 | MimeTypeData* d = data(i); | 110 | MimeTypeData* d = data(i); |
@@ -128,6 +137,7 @@ void MimeType::clear() | |||
128 | void MimeType::loadExtensions() | 137 | 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"); |
133 | loadExtensions(QPEApplication::qpeDir()+"etc/mime.types"); | 143 | loadExtensions(QPEApplication::qpeDir()+"etc/mime.types"); |
@@ -145,6 +155,8 @@ void MimeType::loadExtensions(const QString& filename) | |||
145 | QStringList::ConstIterator it = tokens.begin(); | 155 | QStringList::ConstIterator it = tokens.begin(); |
146 | if ( it != tokens.end() ) { | 156 | if ( it != tokens.end() ) { |
147 | QString id = *it; ++it; | 157 | QString id = *it; ++it; |
158 | if ( it != tokens.end() ) { | ||
159 | (*extFor)[id] = *it; | ||
148 | while (it != tokens.end()) { | 160 | while (it != tokens.end()) { |
149 | (*typeFor)[*it] = id; | 161 | (*typeFor)[*it] = id; |
150 | ++it; | 162 | ++it; |
@@ -153,6 +165,7 @@ void MimeType::loadExtensions(const QString& filename) | |||
153 | } | 165 | } |
154 | } | 166 | } |
155 | } | 167 | } |
168 | } | ||
156 | 169 | ||
157 | void MimeType::init( const QString& ext_or_id ) | 170 | void MimeType::init( const QString& ext_or_id ) |
158 | { | 171 | { |