[Uml-devel] kdesdk/umbrello/umbrello

Sebastian Stein seb.kde at hpfsc.de
Fri Jul 30 06:53:27 UTC 2004


CVS commit by sstein: 

fix loading of compressed files: the check against the mimetype do not work
anymore, because all files are now returned as x-uml. Ok, not all files.
*.xmi.tar.bz2 is not returned as x-uml, but I can't figure out why.
Nevertheless, now we look at the filename to find out, if it is a compressed
xmi file or not.

Also, now we make sure, that the autosave file is compressed as well.

modified functions:
	bool UMLDoc::openDocument(const KURL& url, const char*)
   bool UMLDoc::saveDocument(const KURL& url, const char *)


  M +14 -6     umldoc.cpp   1.172


--- kdesdk/umbrello/umbrello/umldoc.cpp  #1.171:1.172
@@ -304,8 +304,16 @@ bool UMLDoc::openDocument(const KURL& ur
         bool status = false;
 
-        // check if the xmi file is a compressed archive like tar.bzip2 or tar.gz
-        QString mimetype = KMimeType::findByPath(m_doc_url.path(0), 0, true)->name();
 # if KDE_IS_VERSION(3,1,90)
-        if (mimetype == "application/x-tgz" || mimetype == "application/x-tbz" || mimetype == "application/x-bzip2")
+        // check if the xmi file is a compressed archive like tar.bzip2 or tar.gz
+        QString filetype = m_doc_url.fileName(true);
+        QString mimetype = "";
+        if (filetype.find(QRegExp("\\.tgz$")) != -1)
+        {
+                mimetype = "application/x-gzip";
+        } else if (filetype.find(QRegExp("\\.tar.bz2$")) != -1) {
+                mimetype = "application/x-bzip2";
+        }
+
+        if (mimetype.isEmpty() == false)
         {
                 KTar archive(tmpfile, mimetype);
@@ -445,10 +453,10 @@ bool UMLDoc::saveDocument(const KURL& ur
         QString fileExt = fileInfo.extension();
         QString fileFormat = "xmi";
-        if (fileExt == "xmi")
+        if (fileExt == "xmi" || fileExt == "bak.xmi")
         {
                 fileFormat = "xmi";
-        } else if (fileExt == "xmi.tgz") { 
+        } else if (fileExt == "xmi.tgz" || fileExt == "bak.xmi.tgz") { 
                 fileFormat = "tgz";
-        } else if (fileExt == "xmi.tar.bz2") {
+        } else if (fileExt == "xmi.tar.bz2" || fileExt == "bak.xmi.tar.bz2") {
                 fileFormat = "bz2";
         } else {






More information about the umbrello-devel mailing list