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

Andi Fischer andi.fischer at hispeed.ch
Thu Apr 9 13:40:15 UTC 2009


SVN commit 951484 by fischer:

Compiler warning about QCustomEvent fixed. Code formatting and API approved.

 M  +33 -14    cmdlineexportallviewsevent.cpp  
 M  +11 -32    cmdlineexportallviewsevent.h  
 M  +2 -5      main.cpp  
 M  +1 -1      uml.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/cmdlineexportallviewsevent.cpp #951483:951484
@@ -4,42 +4,61 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *   copyright (C) 2006-2008                                               *
+ *   copyright (C) 2006-2009                                               *
  *   Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                  *
  ***************************************************************************/
 
 // own header
 #include "cmdlineexportallviewsevent.h"
 
-// qt includes
-#include <QtCore/QStringList>
+// app includes
+#include "uml.h"
+#include "umlviewimageexportermodel.h"
 
 // kde includes
 #include <kapplication.h>
 #include <kdebug.h>
 
-// app includes
-#include "uml.h"
-#include "umlviewimageexportermodel.h"
+// qt includes
+#include <QtCore/QStringList>
+#include <QtGui/QCloseEvent>
 
+const QEvent::Type CmdLineExportAllViewsEvent::type_ =
+    (QEvent::Type)QEvent::registerEventType(QEvent::User + 1);
 
 /**
  * Returns the type of the event.
+ * @return event type
  */
-int CmdLineExportAllViewsEvent::getType()
+QEvent::Type CmdLineExportAllViewsEvent::eventType()
 {
-    return QEvent::User + 1;
+    return type_;
 }
 
+/**
+ * Constructor.
+ * @param imageType The type of the images the views will be exported to.
+ * @param directory The url of the directory where the images will be saved.
+ * @param useFolders If the tree structure of the views in the document must be created
+ *                   in the target directory.
+ */
 CmdLineExportAllViewsEvent::CmdLineExportAllViewsEvent(const QString &imageType, const KUrl &directory, const bool useFolders)
-  : QCustomEvent(CmdLineExportAllViewsEvent::getType())
+  : QEvent(type_),
+    m_imageType(imageType),
+    m_directory(directory),
+    m_useFolders(useFolders)
 {
-    m_imageType = imageType;
-    m_directory = directory;
-    m_useFolders = useFolders;
+    uDebug() << "created with type value " << type_;
 }
 
 /**
+ * Destructor for CmdLineExportAllViewsEvent
+ */
+CmdLineExportAllViewsEvent::~CmdLineExportAllViewsEvent()
+{
+}
+
+/**
  * Exports all the views using UMLViewImageExporterModel, prints the errors
  * occurred in the error output and sends a close event to the application to finish it.
  * To export the views, it uses the attributes set when the event was created.
@@ -48,9 +67,9 @@
 {
     QStringList errors = UMLViewImageExporterModel().exportAllViews(m_imageType, m_directory, m_useFolders);
     if (!errors.isEmpty()) {
-        uError() << "Errors while exporting:";
+        uError() << "CmdLineExportAllViewsEvent::exportAllViews(): Errors while exporting:";
         for (QStringList::Iterator it = errors.begin(); it != errors.end(); ++it) {
-            uError() << *it << endl;
+            uError() << *it;
         }
     }
 
--- trunk/KDE/kdesdk/umbrello/umbrello/cmdlineexportallviewsevent.h #951483:951484
@@ -1,23 +1,22 @@
 /***************************************************************************
- *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *   copyright (C) 2006                                                    *
+ *   copyright (C) 2006 -2009                                              *
  *   Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                  *
  ***************************************************************************/
 
 #ifndef CMDLINEEXPORTALLVIEWSEVENT_H
 #define CMDLINEEXPORTALLVIEWSEVENT_H
 
-#include <qevent.h>
+#include <QtCore/QEvent>
 #include <kurl.h>
 
 /**
  * This class provides an event that is posted to the UMLApp when the "export all views"
- * option was set in the command line. Once the QT main loop begins, the event is processed.
+ * option was set in the command line. Once the Qt main loop begins, the event is processed.
  *
  * The processing made in UMLApp is execute the exportAllViews method in the event.
  * This method exports all the views using UMLViewImageExporterModel and then finishes
@@ -25,46 +24,26 @@
  *
  * @see UMLViewImageExporterModel
  */
-class CmdLineExportAllViewsEvent : public QCustomEvent {
+class CmdLineExportAllViewsEvent : public QEvent 
+{
 public:
 
-    static int getType();
+    static QEvent::Type eventType();
 
-    /**
-     * Constructor for CmdLineExportAllViewsEvent.
-     *
-     * @param imageType The type of the images the views will be exported to.
-     * @param directory The url of the directory where the images will be saved.
-     * @param useFolders If the tree structure of the views in the document must be created
-     *                   in the target directory.
-     */
     CmdLineExportAllViewsEvent(const QString &imageType, const KUrl &directory, const bool useFolders);
 
-    /**
-     * Destructor for CmdLineExportAllViewsEvent
-     */
-    virtual ~CmdLineExportAllViewsEvent() {
-    }
+    virtual ~CmdLineExportAllViewsEvent();
 
     void exportAllViews();
 
 private:
 
-    /**
-     * The type of the images the views will be exported to.
-     */
-    QString m_imageType;
+    static const QEvent::Type type_;
 
-    /**
-     * The url of the directory where the images will be saved.
-     */
-    KUrl m_directory;
+    QString m_imageType;   ///< The type of the images the views will be exported to.
+    KUrl    m_directory;   ///< The url of the directory where the images will be saved.
+    bool    m_useFolders;  ///< If tree structure of the views in the document must be created in the target directory.
 
-    /**
-     * If the tree structure of the views in the document must be created
-     * in the target directory.
-     */
-    bool m_useFolders;
 };
 
 #endif
--- trunk/KDE/kdesdk/umbrello/umbrello/main.cpp #951483:951484
@@ -1,11 +1,10 @@
 /***************************************************************************
- *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *   copyright (C) 2002-2007                                               *
+ *   copyright (C) 2002-2009                                               *
  *   Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                  *
  ***************************************************************************/
 
@@ -126,7 +125,6 @@
     return true;
 }
 
-
 void initDocument(KCmdLineArgs *args)
 {
     if ( args -> count() ) {
@@ -142,7 +140,6 @@
     }
 }
 
-
 void exportAllViews(KCmdLineArgs *args, const QStringList &exportOpt)
 {
     QString extension(exportOpt.last());
@@ -162,7 +159,7 @@
 
     uDebug() << "directory: " << directory.prettyUrl();
 
-    // the event is posted so when the QT loop begins it's processed. UMLApp process this event executing
+    // the event is posted so when the Qt loop begins it's processed. UMLApp process this event executing
     // the method it provides for exporting the views. Once all the views were exported, a quit event
     // is sent and the app finishes without user interaction
     kapp->postEvent(UMLApp::app(), new CmdLineExportAllViewsEvent(extension, directory, useFolders));
--- trunk/KDE/kdesdk/umbrello/umbrello/uml.cpp #951483:951484
@@ -1978,7 +1978,7 @@
 
 void UMLApp::customEvent(QEvent* e)
 {
-    if (e->type() == CmdLineExportAllViewsEvent::getType()) {
+    if (e->type() == CmdLineExportAllViewsEvent::eventType()) {
         CmdLineExportAllViewsEvent* exportAllViewsEvent = static_cast<CmdLineExportAllViewsEvent*>(e);
         exportAllViewsEvent->exportAllViews();
     }




More information about the umbrello-devel mailing list