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

Andi Fischer andi.fischer at hispeed.ch
Sun Apr 6 09:46:51 UTC 2008


SVN commit 794036 by fischer:

Krazy code checker: porting from QDialog to KDialog.

 M  +18 -29    codeviewerdialog.cpp  
 M  +10 -12    codeviewerdialog.h  
 M  +60 -90    codeviewerdialogbase.ui  


--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/codeviewerdialog.cpp #794035:794036
@@ -11,7 +11,7 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
- *   copyright (C) 2004-2007                                               *
+ *   copyright (C) 2004-2008                                               *
  *   Umbrello UML Modeller Authors <uml-devel at uml.sf.net>                  *
  ***************************************************************************/
 
@@ -19,33 +19,31 @@
 #include "codeviewerdialog.h"
 
 // qt/kde includes
-#include <QLayout>
-#include <QTabWidget>
-#include <QCheckBox>
+#include <QtCore/QString>
+#include <QtGui/QTabWidget>
 #include <kdebug.h>
 #include <klocale.h>
 
 // local includes
-#include "../uml.h"
-#include "../codedocument.h"
-#include "../classifiercodedocument.h"
+#include "uml.h"
+#include "codedocument.h"
+#include "classifiercodedocument.h"
 #include "codeeditor.h"
 
 CodeViewerDialog::CodeViewerDialog ( QWidget* parent, CodeDocument * doc,
                                      Settings::CodeViewerState state,
                                      const char* name, bool modal, Qt::WFlags fl )
-        : QDialog ( parent, fl )
+        : KDialog ( parent, fl ), m_state(state)
 {
     setObjectName(name);
-    uDebug() << "setObjectName(" << name << ")" << endl;
+    uDebug() << "setObjectName(" << name << ")";
     setModal(modal);
-    setupUi(this);
-
-    m_state = state;
-
+    setButtons(KDialog::Cancel);
+    setupUi(mainWidget());
+    setInitialSize(QSize(630, 730));
     initGUI(name);
-
     addCodeDocument(doc);
+    connect(this, SIGNAL(cancelClicked()), mainWidget(), SLOT(close()));
 }
 
 CodeViewerDialog::~CodeViewerDialog()
@@ -55,22 +53,17 @@
 
 void CodeViewerDialog::initGUI ( const char * name)
 {
-    if ( !name )
+    if ( !name ) {
         setObjectName( "CodeViewerDialog" );
+    }
 
     setFont( getState().font );
 
-    // set some viewability parameters
-    int margin = fontMetrics().height();
-    int width = fontMetrics().maxWidth() * getState().width;
-    int height = fontMetrics().lineSpacing() * getState().height;
-
     m_highlightCheckBox->setChecked( getState().blocksAreHighlighted );
     m_showHiddenCodeCB->setChecked ( getState().showHiddenBlocks );
 
+    int margin = fontMetrics().height();
     CodeViewerDialogBase::gridLayout->setMargin(margin);
-
-    resize( QSize(width, height).expandedTo(minimumSizeHint()) );
 }
 
 void CodeViewerDialog::addCodeDocument( CodeDocument * doc)
@@ -78,7 +71,7 @@
     CodeEditor * page = new CodeEditor ( this, "_codedocumenteditor_", doc );
     QString name = doc->getFileName();
     QString ext = doc->getFileExtension();
-    uDebug() << "name=" << name << " / ext=" << ext << endl;
+    uDebug() << "name=" << name << " / ext=" << ext;
     m_tabWidget->addTab(page, (name + (ext.isEmpty() ? "" : ext)));
 
     connect( m_highlightCheckBox, SIGNAL( stateChanged(int) ), page, SLOT( changeHighlighting(int) ) );
@@ -90,26 +83,22 @@
     return m_state;
 }
 
-bool CodeViewerDialog::close ( bool /*alsoDelete*/ )
+bool CodeViewerDialog::close()
 {
     // remember widget size for next time
     m_state.height = height() / fontMetrics().lineSpacing();
     m_state.width = width() / fontMetrics().maxWidth();
-
     // remember block highlighting
     m_state.blocksAreHighlighted = m_highlightCheckBox->isChecked();
-
     // remember block show status
     m_state.showHiddenBlocks = m_showHiddenCodeCB->isChecked();
-
     // run superclass close now
-    return QDialog::close();
+    return KDialog::close();
 }
 
 void CodeViewerDialog::languageChange()
 {
     Uml::Programming_Language pl = UMLApp::app()->getActiveLanguage();
-
     setWindowTitle( tr2i18n( "Code Viewer - " ) + pl );
 }
 
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/codeviewerdialog.h #794035:794036
@@ -19,25 +19,25 @@
 #ifndef CODEVIEWERDIALOG_H
 #define CODEVIEWERDIALOG_H
 
-#include <QtCore/QString>
-
-#include "../codeviewerstate.h"
+#include "codeviewerstate.h"
 #include "ui_codeviewerdialogbase.h"
 
 class CodeDocument;
 
 
-/** This class is sooo ugly I don't know where to begin. For now, its a prototype
-  * that works, and thats all we need. In the future, a re-write is mandated to
-  * bring a bit of beauty to this beast. -b.t.
-  */
-class CodeViewerDialog : public QDialog, private Ui::CodeViewerDialogBase
+/**
+ * This class is sooo ugly I don't know where to begin. For now, its a prototype
+ * that works, and thats all we need. In the future, a re-write is mandated to
+ * bring a bit of beauty to this beast. -b.t.
+ */
+class CodeViewerDialog : public KDialog, private Ui::CodeViewerDialogBase
 {
     Q_OBJECT
 public:
 
     CodeViewerDialog ( QWidget* parent, CodeDocument * doc, Settings::CodeViewerState state,
                        const char* name = 0, bool modal = false, Qt::WFlags fl = 0 );
+
     ~CodeViewerDialog ();
 
     /**
@@ -45,8 +45,6 @@
      */
     Settings::CodeViewerState getState( );
 
-    QString parentDocName;
-
     /**
      * Adds a code document to the tabbed output.
      */
@@ -54,7 +52,7 @@
 
 protected:
 
-    bool close ( bool alsoDelete );
+    bool close ();
 
 private:
 
@@ -68,7 +66,7 @@
 
 protected slots:
 
-    /*
+    /**
      *  Sets the strings of the subwidgets using the current
      *  language.
      */
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/codeviewerdialogbase.ui #794035:794036
@@ -1,103 +1,73 @@
 <ui version="4.0" >
  <class>CodeViewerDialogBase</class>
- <widget class="QDialog" name="CodeViewerDialogBase" >
+ <widget class="QWidget" name="CodeViewerDialogBase" >
   <property name="geometry" >
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>615</width>
-    <height>689</height>
+    <width>614</width>
+    <height>658</height>
    </rect>
   </property>
-  <property name="font" >
-   <font>
-    <family>Courier</family>
-   </font>
-  </property>
   <property name="windowTitle" >
-   <string>Code Viewer</string>
+   <string>Form</string>
   </property>
-  <property name="sizeGripEnabled" >
-   <bool>true</bool>
-  </property>
-  <layout class="QGridLayout" >
-   <item row="0" column="0" >
-    <layout class="QGridLayout" >
-     <item row="0" column="1" >
-      <widget class="QCheckBox" name="m_showHiddenCodeCB" >
-       <property name="text" >
-        <string>Show hidden blocks</string>
-       </property>
-      </widget>
-     </item>
-     <item row="1" column="0" colspan="3" >
-      <widget class="QLabel" name="componentLabel" >
-       <property name="sizePolicy" >
-        <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="text" >
-        <string><p align="center">component name here</p></string>
-       </property>
-       <property name="scaledContents" >
-        <bool>true</bool>
-       </property>
-       <property name="wordWrap" >
-        <bool>false</bool>
-       </property>
-      </widget>
-     </item>
-     <item row="0" column="2" >
-      <widget class="QPushButton" name="m_exitButton" >
-       <property name="sizePolicy" >
-        <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="text" >
-        <string>Close</string>
-       </property>
-      </widget>
-     </item>
-     <item row="0" column="0" >
-      <widget class="QCheckBox" name="m_highlightCheckBox" >
-       <property name="text" >
-        <string>Show block type</string>
-       </property>
-       <property name="checked" >
-        <bool>false</bool>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
-   <item row="1" column="0" >
-    <widget class="QTabWidget" name="m_tabWidget" />
-   </item>
-  </layout>
+  <widget class="QWidget" name="verticalLayout" >
+   <property name="geometry" >
+    <rect>
+     <x>0</x>
+     <y>10</y>
+     <width>611</width>
+     <height>641</height>
+    </rect>
+   </property>
+   <layout class="QVBoxLayout" >
+    <item>
+     <layout class="QGridLayout" >
+      <item row="0" column="1" >
+       <widget class="QCheckBox" name="m_showHiddenCodeCB" >
+        <property name="text" >
+         <string>Show hidden blocks</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="0" colspan="3" >
+       <widget class="QLabel" name="componentLabel" >
+        <property name="sizePolicy" >
+         <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text" >
+         <string><p align="center">component name here</p></string>
+        </property>
+        <property name="scaledContents" >
+         <bool>true</bool>
+        </property>
+        <property name="wordWrap" >
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="0" >
+       <widget class="QCheckBox" name="m_highlightCheckBox" >
+        <property name="text" >
+         <string>Show block type</string>
+        </property>
+        <property name="checked" >
+         <bool>false</bool>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </item>
+    <item>
+     <widget class="QTabWidget" name="m_tabWidget" />
+    </item>
+   </layout>
+  </widget>
  </widget>
- <layoutdefault spacing="6" margin="11" />
- <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
  <resources/>
- <connections>
-  <connection>
-   <sender>m_exitButton</sender>
-   <signal>released()</signal>
-   <receiver>CodeViewerDialogBase</receiver>
-   <slot>close()</slot>
-   <hints>
-    <hint type="sourcelabel" >
-     <x>20</x>
-     <y>20</y>
-    </hint>
-    <hint type="destinationlabel" >
-     <x>20</x>
-     <y>20</y>
-    </hint>
-   </hints>
-  </connection>
- </connections>
+ <connections/>
 </ui>




More information about the umbrello-devel mailing list