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

Sharan Rao sharanrao at gmail.com
Sat Nov 17 23:15:46 UTC 2007


SVN commit 738091 by sharan:

remove hard coded strings from diagram print page. instead generate them automatically from enum entries.



 M  +14 -29    diagramprintpage.cpp  
 M  +2 -2      diagramprintpage.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/diagramprintpage.cpp #738090:738091
@@ -30,8 +30,8 @@
 #include "../umlview.h"
 #include "../umlviewlist.h"
 #include "../umlnamespace.h"
+#include "../model_utils.h"
 
-
 DiagramPrintPage::DiagramPrintPage(QWidget * parent, UMLDoc * m_pDoc) : QWidget(parent), m_pDoc(m_pDoc) {
     int margin = fontMetrics().height();
     setWindowTitle(i18n("&Diagrams"));
@@ -88,24 +88,20 @@
 
     m_ViewType = Uml::dt_Class;
     connect(m_pFilterBG, SIGNAL(clicked(int)), this, SLOT(slotClicked(int)));
-    connect(m_pTypeCB, SIGNAL(activated(const QString&)), this, SLOT(slotActivated(const QString&)));
+    connect(m_pTypeCB, SIGNAL(activated(int)), this, SLOT(slotActivated(int)));
 
     QStringList types;
-    types << i18n("Class")
-          << i18n("Use Case")
-          << i18n("Collaboration")
-          << i18n("Sequence")
-          << i18n("State")
-          << i18n("Activity")
-          << i18n("Component")
-          << i18n("Deployment");
+    // diagramNo 1 is Uml::dt_Class
+    // digaramNo 9 is Uml::dt_EntityRelationship
+    for (int diagramNo=1; diagramNo < 10; diagramNo++) {
+        types<< Model_Utils::diagramTypeToString( ( Uml::Diagram_Type )diagramNo ) ;
+    }
+
     m_pTypeCB -> insertItems(0, types);
 }
 
 DiagramPrintPage::~DiagramPrintPage()
 {
-    disconnect(m_pFilterBG, SIGNAL(clicked(int)), this, SLOT(slotClicked(int)));
-    disconnect(m_pTypeCB, SIGNAL(activated(const QString&)), this, SLOT(slotActivated(const QString&)));
 }
 
 int DiagramPrintPage::printUmlCount() {
@@ -204,26 +200,15 @@
     }
 }
 
-void DiagramPrintPage::slotActivated(const QString & text) {
+void DiagramPrintPage::slotActivated(int index) {
     UMLViewList list = m_pDoc -> getViewIterator();
 
-    if(text == i18n("Class"))
-        m_ViewType = Uml::dt_Class;
-    else if(text == i18n("Sequence"))
-        m_ViewType = Uml::dt_Sequence;
-    else if(text == i18n("Use Case"))
-        m_ViewType = Uml::dt_UseCase;
-    else if(text == i18n("Collaboration"))
-        m_ViewType = Uml::dt_Collaboration;
-    else if(text == i18n("State"))
-        m_ViewType = Uml::dt_State;
-    else if(text == i18n("Activity"))
-        m_ViewType = Uml::dt_Activity;
-    else if(text == i18n("Component"))
-        m_ViewType = Uml::dt_Component;
-    else if(text == i18n("Deployment"))
-        m_ViewType = Uml::dt_Deployment;
+    // combo box entries start from 0 index
+    // valid diagram_type enum values start from 1
+    m_ViewType = ( Uml::Diagram_Type )( index + 1 );
+
     m_pSelectLB -> clear();
+
     m_nIdList.clear();
     foreach ( UMLView * view , list) {
         if(view -> getType() == m_ViewType) {
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/diagramprintpage.h #738090:738091
@@ -47,7 +47,7 @@
     DiagramPrintPage(QWidget * parent, UMLDoc *doc);
 
     /**
-     *  Stnadard deconstructor.
+     *  Standard deconstructor.
      */
     ~DiagramPrintPage();
 
@@ -91,7 +91,7 @@
      * Gets called when the user chooses another diagram type. Only diagrams of
      * this type will be shown in the diagram box.
      */
-    void slotActivated(const QString & text);
+    void slotActivated(int index);
 };
 
 #endif




More information about the umbrello-devel mailing list