summaryrefslogtreecommitdiff
path: root/library/mimetype.cpp
Side-by-side diff
Diffstat (limited to 'library/mimetype.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/mimetype.cpp19
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
@@ -17,8 +17,9 @@
** not clear to you.
**
**********************************************************************/
+#define QTOPIA_INTERNAL_MIMEEXT
#include "mimetype.h"
#include "applnk.h"
#include "resource.h"
#include "qpeapplication.h"
@@ -45,8 +46,9 @@ public:
bigIcon.convertFromImage( unscaledIcon.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ) );
}
}
QString id;
+ QString extension;
QString desc;
QPixmap regIcon;
QPixmap bigIcon;
AppLnk app;
@@ -58,8 +60,9 @@ public:
};
MimeType::Dict* MimeType::d=0;
static QMap<QString,QString> *typeFor = 0;
+static QMap<QString,QString> *extFor = 0;
MimeType::Dict& MimeType::dict()
{
if ( !d ) {
@@ -95,8 +98,14 @@ QPixmap MimeType::pixmap() const
MimeTypeData* d = data(i);
return d ? d->regIcon : QPixmap();
}
+QString MimeType::extension() const
+{
+ loadExtensions();
+ return *(*extFor).find(i);
+}
+
QPixmap MimeType::bigPixmap() const
{
MimeTypeData* d = data(i);
return d ? d->bigIcon : QPixmap();
@@ -127,8 +136,9 @@ void MimeType::clear()
void MimeType::loadExtensions()
{
if ( !typeFor ) {
+ extFor = new QMap<QString,QString>;
typeFor = new QMap<QString,QString>;
loadExtensions("/etc/mime.types");
loadExtensions(QPEApplication::qpeDir()+"etc/mime.types");
}
@@ -144,11 +154,14 @@ void MimeType::loadExtensions(const QString& filename)
QStringList tokens = QStringList::split(space, in.readLine());
QStringList::ConstIterator it = tokens.begin();
if ( it != tokens.end() ) {
QString id = *it; ++it;
- while (it != tokens.end()) {
- (*typeFor)[*it] = id;
- ++it;
+ if ( it != tokens.end() ) {
+ (*extFor)[id] = *it;
+ while (it != tokens.end()) {
+ (*typeFor)[*it] = id;
+ ++it;
+ }
}
}
}
}