[Uml-devel] KDE/kdesdk/umbrello/umbrello

Ralf Habacker ralf.habacker at gmail.com
Mon Mar 12 02:05:44 UTC 2012


SVN commit 1285082 by habacker:

Added diagram dot export support.

 M  +1 -0      CMakeLists.txt  
 A             dialogs/umlfiledialog.cpp   [License: GPL (v2+)]
 A             dialogs/umlfiledialog.h   [License: GPL (v2+)]
 M  +3 -2      umlviewimageexporter.cpp  
 M  +5 -2      umlviewimageexporter.h  
 M  +32 -1     umlviewimageexportermodel.cpp  
 M  +1 -0      umlviewimageexportermodel.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/CMakeLists.txt #1285081:1285082
@@ -235,6 +235,7 @@
     dialogs/umlcheckconstraintdialog.cpp
     dialogs/umlentityattributedialog.cpp
     dialogs/umlforeignkeyconstraintdialog.cpp
+    dialogs/umlfiledialog.cpp
     dialogs/umloperationdialog.cpp
     dialogs/umltemplatedialog.cpp
     dialogs/umlroledialog.cpp
--- trunk/KDE/kdesdk/umbrello/umbrello/umlviewimageexporter.cpp #1285081:1285082
@@ -10,6 +10,7 @@
 
 // own header
 #include "umlviewimageexporter.h"
+#include "umlfiledialog.h"
 
 // application specific includes
 #include "umlviewimageexportermodel.h"
@@ -125,7 +126,7 @@
 
     // configure & show the file dialog
     KUrl url;
-    QPointer<KFileDialog> dialog = new KFileDialog(url, QString(), UMLApp::app());
+    QPointer<UMLFileDialog> dialog = new UMLFileDialog(url, QString(), UMLApp::app());
     prepareFileDialog(dialog);
     dialog->exec();
 
@@ -158,7 +159,7 @@
  *
  * @param fileDialog The dialog to prepare.
  */
-void UMLViewImageExporter::prepareFileDialog(KFileDialog *fileDialog)
+void UMLViewImageExporter::prepareFileDialog(UMLFileDialog *fileDialog)
 {
     // get all supported mime types
     QStringList mimeTypes = UMLViewImageExporterModel::supportedMimeTypes();
--- trunk/KDE/kdesdk/umbrello/umbrello/umlviewimageexporter.h #1285081:1285082
@@ -11,11 +11,14 @@
 #ifndef UMLVIEWIMAGEEXPORTER_H
 #define UMLVIEWIMAGEEXPORTER_H
 
+#include "umlviewimageexportermodel.h"
+
 #include <QtCore/QString>
+
 #include <kurl.h>
 
 class UMLScene;
-class KFileDialog;
+class UMLFileDialog;
 
 /**
  * Exports the scene as an image.
@@ -43,7 +46,7 @@
     bool getParametersFromUser();
 
     bool prepareExport();
-    void prepareFileDialog(KFileDialog *fileDialog);
+    void prepareFileDialog(UMLFileDialog *fileDialog);
 
 };
 
--- trunk/KDE/kdesdk/umbrello/umbrello/umlviewimageexportermodel.cpp #1285081:1285082
@@ -13,6 +13,7 @@
 
 // application specific includes
 #include "debug_utils.h"
+#include "dotgenerator.h"
 #include "model_utils.h"
 #include "uml.h"
 #include "umldoc.h"
@@ -61,6 +62,8 @@
                 s_supportedImageTypesList << format;
         }
         // specific supported formats
+        if (!s_supportedImageTypesList.contains("dot"))
+            s_supportedImageTypesList << "dot";
         if (!s_supportedImageTypesList.contains("eps"))
             s_supportedImageTypesList << "eps";
         if (!s_supportedImageTypesList.contains("svg"))
@@ -103,6 +106,7 @@
 {
     const QString imgType = imageType.toLower();
     if (QString("bmp") == imgType) return "image/bmp";
+    if (QString("dot") == imgType) return "image/x-dot";
     if (QString("jpeg") == imgType) return "image/jpeg";
     if (QString("pbm") == imgType) return "image/x-portable-bitmap";
     if (QString("pgm") == imgType) return "image/x-portable-graymap";
@@ -126,6 +130,7 @@
 QString UMLViewImageExporterModel::mimeTypeToImageType(const QString& mimeType)
 {
     if (QString("image/bmp") == mimeType) return "bmp";
+    if (QString("image/x-dot") == mimeType) return "dot";
     if (QString("image/jpeg") == mimeType) return "jpeg";
     if (QString("image/x-portable-bitmap") == mimeType) return "pbm";
     if (QString("image/x-portable-graymap") == mimeType) return "pgm";
@@ -329,7 +334,11 @@
     scene->clearSelected();
 
     QString imageMimeType = UMLViewImageExporterModel::imageTypeToMimeType(imageType);
-    if (imageMimeType == "image/x-eps") {
+    if (imageMimeType == "image/x-dot") {
+        if (!exportViewToDot(scene, fileName)) {
+            return false;
+        }
+    } else if (imageMimeType == "image/x-eps") {
         if (!exportViewToEps(scene, fileName, true)) {
             return false;
         }
@@ -347,6 +356,28 @@
 }
 
 /**
+ * Exports the view to the file 'fileName' as a dot file.
+ *
+ * @param scene     The scene to export.
+ * @param fileName  The name of the file where the image will be saved.
+ * @return True if the operation was successful,
+ *         false if a problem occurred while exporting.
+ */
+bool UMLViewImageExporterModel::exportViewToDot(UMLScene* scene, const QString &fileName) const
+{
+    if (!scene) {
+        uWarning() << "Scene is null!";
+        return false;
+    }
+
+    DotGenerator dot;
+    bool result = dot.createDotFile(scene, fileName, QLatin1String("export"));
+
+    DEBUG(DBG_IEM) << "saving to file " << fileName << result;
+    return result;
+}
+
+/**
  * Exports the view to the file 'fileName' as EPS.
  *
  * @param scene    The scene to export.
--- trunk/KDE/kdesdk/umbrello/umbrello/umlviewimageexportermodel.h #1285081:1285082
@@ -51,6 +51,7 @@
     bool prepareDirectory(const KUrl &url) const;
 
     bool exportViewTo(UMLScene* scene, const QString &imageType, const QString &fileName) const;
+    bool exportViewToDot(UMLScene* scene, const QString &fileName) const;
     bool exportViewToEps(UMLScene* scene, const QString &fileName, bool isEPS) const;
     bool exportViewToSvg(UMLScene* scene, const QString &fileName) const;
     bool exportViewToPixmap(UMLScene* scene, const QString &imageType, const QString &fileName) const;




More information about the umbrello-devel mailing list