Bug 110073 - please add drop down list for stereotypes
Summary: please add drop down list for stereotypes
Status: RESOLVED FIXED
Alias: None
Product: umbrello
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Fedora RPMs Linux
: NOR wishlist
Target Milestone: ---
Assignee: Umbrello Development Group
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-03 03:06 UTC by Gavin C. Flower
Modified: 2005-09-10 19:25 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gavin C. Flower 2005-08-03 03:06:10 UTC
Version:            (using KDE KDE 3.4.2)
Installed from:    Fedora RPMs

It would be good if there was a list of stereotypes that could be used in a drop down list for classes (or anuwhere eslse appropriate).

A drop down list of stereotypes would minimize misspellings and encourage the use of existing stereotypes.
Comment 1 Oliver Kellogg 2005-09-10 19:25:12 UTC
SVN commit 459386 by okellogg:

BUG:110073 - Change m_pStereotypeLE into m_pStereotypeCB (KComboBox *)


 M  +2 -2      ChangeLog  
 M  +57 -14    umbrello/dialogs/classgenpage.cpp  
 M  +17 -13    umbrello/dialogs/classgenpage.h  


--- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #459385:459386
@@ -10,8 +10,8 @@
 
 * Bugs fixed / wishes implemented (see http://bugs.kde.org)
  57588  57672  58809  66461  67719  72016  79433  87252  88117  97162
-105564 108223 109591 109636 110216 110231 110379 111088 111470 111502
-111759 111768 112017 112293
+105564 108223 109591 109636 110073 110216 110231 110379 111088 111470
+111502 111759 111768 112017 112293
 
 Version 1.4.2 (maintenance release)
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/dialogs/classgenpage.cpp #459385:459386
@@ -12,16 +12,33 @@
  *                                                                         *
  ***************************************************************************/
 
+// my own header
+#include "classgenpage.h"
+
+// qt includes
 #include <qlayout.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qbuttongroup.h>
+#include <qmultilineedit.h>
+#include <qradiobutton.h>
+#include <qcheckbox.h>
 
+// kde includes
 #include <klocale.h>
+#include <kdebug.h>
 #include <kmessagebox.h>
-#include <kdebug.h>
+#include <kcombobox.h>
 
+// my class includes
+#include "../umlobject.h"
+#include "../objectwidget.h"
+#include "../umldoc.h"
 #include "../artifact.h"
 #include "../component.h"
 #include "../umlview.h"
-#include "classgenpage.h"
+#include "../stereotype.h"
 
 ClassGenPage::ClassGenPage(UMLDoc* d, QWidget* parent, UMLObject* o) : QWidget(parent) {
     m_pWidget = 0;
@@ -70,7 +87,7 @@
     m_pClassNameLE->setFocus();
     m_pNameL->setBuddy(m_pClassNameLE);
 
-    m_pStereoTypeLE = 0;
+    m_pStereoTypeCB = 0;
     m_pPackageLE = 0;
     m_pAbstractCB = 0;
     m_pDeconCB = 0;
@@ -81,14 +98,14 @@
         m_pStereoTypeL = new QLabel(i18n("&Stereotype name:"), this);
         m_pNameLayout -> addWidget(m_pStereoTypeL, 1, 0);
 
-        m_pStereoTypeLE = new QLineEdit(this);
-        m_pNameLayout -> addWidget(m_pStereoTypeLE, 1, 1);
+        m_pStereoTypeCB = new KComboBox(true, this);
+        m_pNameLayout -> addWidget(m_pStereoTypeCB, 1, 1);
 
-        m_pStereoTypeLE -> setText(o -> getStereotype(false));
-        m_pStereoTypeL->setBuddy(m_pStereoTypeLE);
+        m_pStereoTypeCB->setCurrentText( o->getStereotype() );
+        m_pStereoTypeL->setBuddy(m_pStereoTypeCB);
     }
     if (t == Uml::ot_Interface || t == Uml::ot_Datatype || t == Uml::ot_Enum) {
-        m_pStereoTypeLE->setEnabled(false);
+        m_pStereoTypeCB->setEditable(false);
     }
 
     if (t == Uml::ot_Class || t == Uml::ot_Interface) {
@@ -192,6 +209,26 @@
     else
         m_pProtectedRB -> setChecked(true);
 
+    // manage stereotypes
+    m_pStereoTypeCB -> setDuplicatesEnabled(false);//only allow one of each type in box
+    insertStereotype (QString("")); // an empty stereotype is the default
+    int defaultStereotype=0;
+    bool foundDefaultStereotype = false;
+    for (UMLStereotypeListIt it(m_pUmldoc->getStereotypes()); it.current(); ++it) {
+        if (!foundDefaultStereotype) {
+            if ( m_pObject->getStereotype() == it.current()->getName()) {
+                foundDefaultStereotype = true;
+            }
+            defaultStereotype++;
+        }
+        insertStereotype (it.current()->getName());
+    }
+    // lookup for a default stereotype, if the operation doesn't have one
+    if (foundDefaultStereotype)
+        m_pStereoTypeCB -> setCurrentItem(defaultStereotype);
+    else
+        m_pStereoTypeCB -> setCurrentItem(-1);
+
     ///////////
     m_pDoc->setWordWrap(QMultiLineEdit::WidgetWidth);
     //////////
@@ -295,10 +332,10 @@
     m_pStereoTypeL = new QLabel(i18n("Stereotype name:"), this);
     m_pNameLayout->addWidget(m_pStereoTypeL, 1, 0);
 
-    m_pStereoTypeLE = new QLineEdit(this);
-    m_pNameLayout->addWidget(m_pStereoTypeLE, 1, 1);
+    m_pStereoTypeCB = new KComboBox(true, this);
+    m_pNameLayout->addWidget(m_pStereoTypeCB, 1, 1);
 
-    m_pStereoTypeLE->setText( widget->getUMLObject()->getStereotype(false) );
+    m_pStereoTypeCB->setCurrentText( widget->getUMLObject()->getStereotype() );
 
     m_pInstanceL = new QLabel(this);
     m_pInstanceL->setText(i18n("Instance name:"));
@@ -324,14 +361,20 @@
 
 ClassGenPage::~ClassGenPage() {}
 
+void ClassGenPage::insertStereotype( const QString& type, int index )
+{
+    m_pStereoTypeCB->insertItem( type, index );
+    m_pStereoTypeCB->completionObject()->addItem( type );
+}
+
 void ClassGenPage::updateObject() {
     if(m_pObject) {
         QString name = m_pClassNameLE -> text();
 
         m_pObject -> setDoc(m_pDoc -> text());
 
-        if(m_pStereoTypeLE)
-            m_pObject -> setStereotype(m_pStereoTypeLE -> text());
+        if(m_pStereoTypeCB)
+            m_pObject -> setStereotype(m_pStereoTypeCB->currentText());
         if(m_pPackageLE)
             m_pObject -> setPackage(m_pPackageLE -> text());
         if( m_pAbstractCB )
@@ -400,7 +443,7 @@
         } else {
             o->setName(name);
         }
-        o->setStereotype( m_pStereoTypeLE->text() );
+        o->setStereotype( m_pStereoTypeCB->currentText() );
     }
 }
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/dialogs/classgenpage.h #459385:459386
@@ -15,21 +15,22 @@
 #ifndef CLASSGENPAGE_H
 #define CLASSGENPAGE_H
 
-//quicktime class includes
 #include <qwidget.h>
-#include <qgroupbox.h>
-#include <qlabel.h>
-#include <qlineedit.h>
-#include <qbuttongroup.h>
-#include <qmultilineedit.h>
-#include <qradiobutton.h>
-#include <qcheckbox.h>
 
-//my class includes
-#include "../umlobject.h"
-#include "../objectwidget.h"
-#include "../umldoc.h"
+class QGroupBox;
+class QLabel;
+class QLineEdit;
+class QButtonGroup;
+class QMultiLineEdit;
+class QRadioButton;
+class QCheckBox;
+class KComboBox;
 
+class UMLObject;
+class UMLWidget;
+class ObjectWidget;
+class UMLDoc;
+
 /**
  * Displays properties of a UMLObject in a dialog box.  This is not usually directly
  * called.  The class @ref ClassPropDlg will set this up for you.
@@ -84,7 +85,8 @@
     QGroupBox *m_pDocGB;
     QButtonGroup        * m_pButtonBG;
     QLabel * m_pNameL, * m_pInstanceL, * m_pStereoTypeL, * m_pPackageL;
-    QLineEdit * m_pClassNameLE, *m_pInstanceLE, * m_pStereoTypeLE, * m_pPackageLE;
+    QLineEdit * m_pClassNameLE, *m_pInstanceLE, * m_pPackageLE;
+    KComboBox * m_pStereoTypeCB;
     QRadioButton * m_pPublicRB, * m_pPrivateRB, * m_pProtectedRB;
     QCheckBox * m_pMultiCB, * m_pDrawActorCB, * m_pAbstractCB, * m_pDeconCB;
     QMultiLineEdit * m_pDoc;
@@ -96,6 +98,8 @@
     QRadioButton* m_pDefaultRB,* m_pFileRB,* m_pLibraryRB,* m_pTableRB;
     QCheckBox* m_pExecutableCB;
 
+    void insertStereotype(const QString& type, int index = -1);
+
 public slots:
     /**
      *  When the draw as actor check box is toggled, the draw