[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kcalcore] /: Port away from KMimeType
From:       Sergio Martins <iamsergio () gmail ! com>
Date:       2015-02-28 23:38:05
Message-ID: E1YRqxR-0001lt-1p () scm ! kde ! org
[Download RAW message or body]

Git commit 6eea6db335e631c4273b0bb820cba615b2d10c87 by Sergio Martins.
Committed on 28/02/2015 at 23:37.
Pushed by smartins into branch 'master'.

Port away from KMimeType

M  +7    -0    autotests/testattachment.cpp
M  +1    -0    autotests/testattachment.h
M  +3    -2    src/incidence.cpp

http://commits.kde.org/kcalcore/6eea6db335e631c4273b0bb820cba615b2d10c87

diff --git a/autotests/testattachment.cpp b/autotests/testattachment.cpp
index 90c7f57..65f0ff8 100644
--- a/autotests/testattachment.cpp
+++ b/autotests/testattachment.cpp
@@ -96,3 +96,10 @@ void AttachmentTest::testSerializer()
     QVERIFY(*attachment == *attachment2);
 }
 
+void AttachmentTest::testWriteToTempFile()
+{
+    Attachment::Ptr inlineAttachment = Attachment::Ptr(new \
Attachment(QByteArray("foo"), QByteArray("image/png"))); +    Event *event = new \
Event(); +    QString file = event->writeAttachmentToTempFile(inlineAttachment);
+    QVERIFY(file.endsWith(".png"));
+}
diff --git a/autotests/testattachment.h b/autotests/testattachment.h
index ab605a1..285f0fd 100644
--- a/autotests/testattachment.h
+++ b/autotests/testattachment.h
@@ -30,6 +30,7 @@ private Q_SLOTS:
     void testValidity();
     void testSerializer_data();
     void testSerializer();
+    void testWriteToTempFile();
 };
 
 #endif
diff --git a/src/incidence.cpp b/src/incidence.cpp
index b668a2a..a1d1649 100644
--- a/src/incidence.cpp
+++ b/src/incidence.cpp
@@ -35,9 +35,9 @@
 #include "incidence.h"
 #include "calformat.h"
 
-#include <KMimeType>
 #include <KTemporaryFile>
 
+#include <QMimeDatabase>
 #include <QTextDocument> // for .toHtmlEscaped() and Qt::mightBeRichText()
 #include <QStringList>
 #include <QTime>
@@ -756,7 +756,8 @@ QString Incidence::writeAttachmentToTempFile(const \
Attachment::Ptr &attachment)  }
     KTemporaryFile *file = new KTemporaryFile();
 
-    QStringList patterns = KMimeType::mimeType(attachment->mimeType())->patterns();
+    QMimeDatabase mimeDb;
+    QStringList patterns = \
mimeDb.mimeTypeForName(attachment->mimeType()).globPatterns();  
     if (!patterns.empty()) {
         file->setSuffix(QString(patterns.first()).remove(QLatin1Char('*')));


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic