summaryrefslogtreecommitdiff
path: root/library/mimetype.cpp
Unidiff
Diffstat (limited to 'library/mimetype.cpp') (more/less context) (show whitespace changes)
-rw-r--r--library/mimetype.cpp13
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
@@ -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:
60MimeType::Dict* MimeType::d=0; 62MimeType::Dict* MimeType::d=0;
61static QMap<QString,QString> *typeFor = 0; 63static QMap<QString,QString> *typeFor = 0;
64static QMap<QString,QString> *extFor = 0;
62 65
63MimeType::Dict& MimeType::dict() 66MimeType::Dict& MimeType::dict()
@@ -97,4 +100,10 @@ QPixmap MimeType::pixmap() const
97} 100}
98 101
102QString MimeType::extension() const
103{
104 loadExtensions();
105 return *(*extFor).find(i);
106}
107
99QPixmap MimeType::bigPixmap() const 108QPixmap 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,4 +156,6 @@ 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;
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;
@@ -154,4 +166,5 @@ void MimeType::loadExtensions(const QString& filename)
154 } 166 }
155} 167}
168}
156 169
157void MimeType::init( const QString& ext_or_id ) 170void MimeType::init( const QString& ext_or_id )