[Uml-devel] branches/work/soc-umbrello/umbrello

Andi Fischer andi.fischer at hispeed.ch
Sun Jan 1 16:20:07 UTC 2012


SVN commit 1271025 by fischer:

Constructor improved. Member variables renamed. Krazy2 issue fixed.

 M  +42 -49    uml.cpp  
 M  +3 -4      uml.h  
 M  +3 -4      umlviewimageexporterall.cpp  


--- branches/work/soc-umbrello/umbrello/uml.cpp #1271024:1271025
@@ -79,7 +79,6 @@
 #include <QtCore/QRegExp>
 #include <QtCore/QTimer>
 #include <QtGui/QClipboard>
-#include <QtGui/QDialogButtonBox>
 #include <QtGui/QSlider>
 #include <QtGui/QToolButton>
 #include <QtGui/QKeyEvent>
@@ -119,30 +118,35 @@
 /**
  * Constructor. Calls all init functions to create the application.
  */
-UMLApp::UMLApp(QWidget* parent) : KXmlGuiWindow(parent)
+UMLApp::UMLApp(QWidget* parent)
+  : KXmlGuiWindow(parent),
+    m_langSelect(0),
+    m_zoomSelect(0),
+    m_activeLanguage(Uml::ProgrammingLanguage::Reserved),
+    m_codegen(0),
+    m_commoncodegenpolicy(new CodeGenerationPolicy()),
+    m_policyext(0),
+    m_config(KGlobal::config()),
+    m_view(0),
+    m_doc(new UMLDoc()),
+    m_listView(0),
+    m_pDocWindow(0),
+    m_refactoringAssist(0),
+    m_clipTimer(0),
+    m_copyTimer(0),
+    m_loading(false),
+    m_imageMimeType(QString()),
+    m_settingsDlg(0),
+    m_imageExporterAll(new UMLViewImageExporterAll()),
+    m_xhtmlGenerator(0),
+    m_pUndoStack(new KUndoStack(this)),
+    m_hasBegunMacro(false),
+    m_printSettings(0),
+    m_printer(new QPrinter())
 {
     s_instance   = this;
-    m_pDocWindow = 0;
-    m_config     = KGlobal::config();
-    m_listView   = 0;
-    m_langSelect = 0;
-    m_zoomSelect = 0;
-    m_loading    = false;
-    m_clipTimer  = 0;
-    m_copyTimer  = 0;
-    m_codegen    = 0;
-    m_policyext  = 0;
-    m_commoncodegenpolicy = 0;
-    m_xhtmlGenerator = 0;
-    m_activeLanguage = Uml::ProgrammingLanguage::Reserved;
-    m_pUndoStack = new KUndoStack(this);
-    m_doc = new UMLDoc();
     m_doc->init();
-    m_hasBegunMacro = false;
-    m_printSettings = 0;
-    m_printer = new QPrinter;
     m_printer->setFullPage(true);
-    m_dlg = NULL;
 
     readOptionState();
     initActions();
@@ -160,7 +164,6 @@
 
     //get a reference to the Code->Active Language and to the Diagram->Zoom menu
     m_langSelect = findMenu(QString("active_lang_menu") );
-
     //in case langSelect hasn't been initialized we create the Popup menu.
     //it will be hidden, but at least we wont crash if someone takes the entry away from the ui.rc file
     if (m_langSelect == NULL) {
@@ -168,7 +171,6 @@
     }
 
     m_zoomSelect = findMenu(QString("zoom_menu") );
-
     //in case zoomSelect hasn't been initialized we create the Popup menu.
     //it will be hidden, but at least we wont crash if some one takes the entry away from the ui.rc file
     if (m_zoomSelect == NULL) {
@@ -179,10 +181,6 @@
     connect(m_zoomSelect,SIGNAL(aboutToShow()),this,SLOT(setupZoomMenu()));
     connect(m_zoomSelect,SIGNAL(triggered(QAction*)),this,SLOT(slotSetZoom(QAction*)));
 
-    m_refactoringAssist   = NULL;
-    m_commoncodegenpolicy = new CodeGenerationPolicy();
-    m_imageExporterAll    = new UMLViewImageExporterAll();
-
     setAutoSaveSettings();
     m_toolsbar->setToolButtonStyle(Qt::ToolButtonIconOnly);  // too many items for text, really we want a toolbox widget
 }
@@ -741,7 +739,7 @@
 void UMLApp::initView()
 {
     setCaption(m_doc->url().fileName(),false);
-    m_view = NULL;
+    m_view = 0;
     m_toolsbar = new WorkToolBar(this);
     m_toolsbar->setWindowTitle(i18n("Diagram Toolbar"));
     addToolBar(Qt::TopToolBarArea, m_toolsbar);
@@ -1267,27 +1265,21 @@
  */
 bool UMLApp::slotPrintSettings()
 {
-    if (m_printSettings)
+    if (m_printSettings) {
         delete m_printSettings;
+    }
     m_printSettings = new DiagramPrintPage(0, m_doc);
 
-    QDialog *d = new QDialog;
-    QVBoxLayout *layout = new QVBoxLayout; 
-    layout->addWidget(m_printSettings);
+    QPointer<KDialog> dlg = new KDialog();
+    dlg->setMainWidget(m_printSettings);
 
-    QDialogButtonBox *b = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
-    connect(b, SIGNAL(accepted()), d, SLOT(accept()));
-    connect(b, SIGNAL(rejected()), d, SLOT(reject()));
-    layout->addWidget(b);
-    d->setLayout(layout);
+    bool result = dlg->exec() == QDialog::Accepted;
 
-    bool result = d->exec() == QDialog::Accepted;
-
     // keep settings
-    layout->removeWidget(m_printSettings);
+    dlg->setMainWidget(0);
     m_printSettings->setParent(0);
 
-    delete d;
+    delete dlg;
     return result;
 }
 
@@ -1304,6 +1296,7 @@
     QPointer<QPrintPreviewDialog> preview = new QPrintPreviewDialog(m_printer,this);
     connect(preview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(slotPrintPreviewPaintRequested(QPrinter*)));
     preview->exec();
+    delete preview;
     delete m_printSettings;
     m_printSettings = 0;
     resetStatusMsg();
@@ -1761,15 +1754,15 @@
 {
        Settings::OptionState& optionState = Settings::optionState();
 
-       m_dlg = new SettingsDlg(this, &optionState);
-       connect(m_dlg, SIGNAL(applyClicked()), this, SLOT(slotApplyPrefs()));
+       m_settingsDlg = new SettingsDlg(this, &optionState);
+       connect(m_settingsDlg, SIGNAL(applyClicked()), this, SLOT(slotApplyPrefs()));
 
-       if ( m_dlg->exec() == QDialog::Accepted && m_dlg->getChangesApplied() ) {
+       if ( m_settingsDlg->exec() == QDialog::Accepted && m_settingsDlg->getChangesApplied() ) {
            slotApplyPrefs();
        }
 
-       delete m_dlg;
-       m_dlg = NULL;
+       delete m_settingsDlg;
+       m_settingsDlg = 0;
 }
 
 /**
@@ -1777,7 +1770,7 @@
  */
 void UMLApp::slotApplyPrefs()
 {
-    if (m_dlg) {
+    if (m_settingsDlg) {
         // we need this to sync both values
         Settings::OptionState& optionState = Settings::optionState();
         bool stackBrowsing = (m_layout->indexOf(m_tabWidget) != -1);
@@ -1820,7 +1813,7 @@
         }
 
         m_doc->settingsChanged( optionState );
-        const QString plStr = m_dlg->getCodeGenerationLanguage();
+        const QString plStr = m_settingsDlg->getCodeGenerationLanguage();
         Uml::ProgrammingLanguage pl = Uml::ProgrammingLanguage::fromString(plStr);
         setGenerator(pl);
     }
@@ -2736,7 +2729,7 @@
  * Sets the default mime type for all diagrams that are exported as images.
  * @param mimeType   the mime type
  */
-void UMLApp::setImageMimeType(QString const & mimeType)
+void UMLApp::setImageMimeType(const QString& mimeType)
 {
     m_imageMimeType = mimeType;
 }
--- branches/work/soc-umbrello/umbrello/uml.h #1271024:1271025
@@ -128,7 +128,7 @@
     void setCurrentView(UMLView* view);
     UMLView* currentView() const;
 
-    void setImageMimeType(QString const & mimeType);
+    void setImageMimeType(const QString& mimeType);
     QString imageMimeType() const;
 
     bool editCutCopy(bool bFromView);
@@ -183,8 +183,6 @@
     virtual void saveProperties(KConfigGroup & cfg);
     virtual void readProperties(const KConfigGroup & cfg);
 
-    CodeGenerationPolicy * m_commoncodegenpolicy;
-
     void updateLangSelectMenu(Uml::ProgrammingLanguage activeLanguage);
 
 public slots:
@@ -315,6 +313,7 @@
 
     Uml::ProgrammingLanguage  m_activeLanguage;  ///< Active language.
     CodeGenerator*            m_codegen;         ///< Active code generator.
+    CodeGenerationPolicy*     m_commoncodegenpolicy;
     CodeGenPolicyExt*         m_policyext;       ///< Active policy extension.
     // Only used for new code generators ({Cpp,Java,Ruby,D}CodeGenerator).
 
@@ -400,7 +399,7 @@
 
     QString m_imageMimeType;  ///< Default mime type to use for image export.
 
-    SettingsDlg* m_dlg;  ///< The global UML settings dialog.
+    SettingsDlg* m_settingsDlg;  ///< The global UML settings dialog.
 
     UMLViewImageExporterAll* m_imageExporterAll;  ///< Used to export all the views.
 
--- branches/work/soc-umbrello/umbrello/umlviewimageexporterall.cpp #1271024:1271025
@@ -4,7 +4,7 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *   copyright (C) 2006-2010                                               *
+ *   copyright (C) 2006-2011                                               *
  *   Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                  *
  ***************************************************************************/
 
@@ -12,7 +12,7 @@
 #include "umlviewimageexporterall.h"
 
 // application specific includes
-#include "dialogs/exportallviewsdialog.h"
+#include "exportallviewsdialog.h"
 #include "umlviewimageexportermodel.h"
 #include "uml.h"
 #include "umldoc.h"
@@ -33,7 +33,7 @@
  */
 UMLViewImageExporterAll::UMLViewImageExporterAll()
 {
-    m_dialog = new ExportAllViewsDialog(0, "exportAllViewsDialog", false, 0, UMLApp::app()->imageMimeType());
+    m_dialog = new ExportAllViewsDialog(0, "exportAllViewsDialog");
 }
 
 /**
@@ -83,4 +83,3 @@
     }
     umlDoc->writeToStatusBar(i18nc("reset status bar", "Ready."));
 }
-




More information about the umbrello-devel mailing list