[Uml-devel] KDE/kdesdk/umbrello/umbrello
Sharan Rao
sharanrao at gmail.com
Thu Jul 26 14:25:16 UTC 2007
SVN commit 692907 by sharan:
Modify the package to which a class belongs to in the properties dialog.
Can also select the package in the Class Wizard.
One issues remains, when I add a class with a name to a package which already consists of a class with that name.
Will sort that out soon.
M +42 -15 dialogs/classgenpage.cpp
M +1 -1 dialogs/classgenpage.h
M +1 -0 dialogs/classwizard.cpp
M +16 -0 package.cpp
M +11 -0 package.h
M +8 -0 umldoc.cpp
M +9 -0 umldoc.h
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/classgenpage.cpp #692906:692907
@@ -42,6 +42,13 @@
#include "../component.h"
#include "../umlview.h"
#include "../stereotype.h"
+#include "../umlpackagelist.h"
+#include "../umllistviewitem.h"
+#include "../umllistview.h"
+#include "../model_utils.h"
+#include "../package.h"
+#include "../folder.h"
+#include "../codeimport/import_utils.h"
ClassGenPage::ClassGenPage(UMLDoc* d, QWidget* parent, UMLObject* o) : QWidget(parent) {
m_pWidget = 0;
@@ -109,15 +116,25 @@
}
if (t == Uml::ot_Class || t == Uml::ot_Interface) {
- m_pPackageL = new QLabel(i18n("&Package name:"), this);
+ m_pPackageL = new QLabel(i18n("Package name:"), this);
m_pNameLayout -> addWidget(m_pPackageL, 2, 0);
- m_pPackageLE = new QLineEdit(this);
- m_pNameLayout -> addWidget(m_pPackageLE, 2, 1);
+ m_pPackageCB = new KComboBox(this);
+ m_pPackageCB->setEditable(true);
+ m_pNameLayout -> addWidget(m_pPackageCB, 2, 1);
- m_pPackageLE -> setText(o -> getPackage());
- m_pPackageLE -> setEnabled(false);
- m_pPackageL->setBuddy(m_pPackageLE);
+ UMLPackageList packageList = m_pUmldoc->getPackages();
+ foreach( UMLPackage* package, packageList ) {
+ m_pPackageCB->addItem(package->getName());
+ }
+ UMLPackage* parentPackage = o->getUMLPackage();
+
+ // if parent package == NULL
+ // or if the parent package is the Logical View folder
+ if ( parentPackage == NULL || parentPackage== static_cast<UMLPackage*>(m_pUmldoc->getRootFolder(Uml::mt_Logical)))
+ m_pPackageCB->setEditText( QString() );
+ else
+ m_pPackageCB->setEditText(parentPackage->getName());
}
if (t == Uml::ot_Class || t == Uml::ot_UseCase ) {
@@ -172,6 +189,7 @@
}
}
+
//setup scope
m_pButtonBG = new Q3ButtonGroup(i18n("Visibility"), this);
QHBoxLayout * scopeLayout = new QHBoxLayout(m_pButtonBG);
@@ -191,6 +209,7 @@
m_pImplementationRB = new QRadioButton(i18n("Imple&mentation"), m_pButtonBG);
scopeLayout -> addWidget(m_pImplementationRB);
topLayout -> addWidget(m_pButtonBG);
+
//setup documentation
m_pDocGB = new Q3GroupBox(this);
QHBoxLayout * docLayout = new QHBoxLayout(m_pDocGB);
@@ -383,18 +402,26 @@
if(m_pStereoTypeCB)
m_pObject -> setStereotype(m_pStereoTypeCB->currentText());
- /**
- * @todo enable the package lineedit field amd add logic for changing the package
- if(m_pPackageLE)
- m_pObject -> setPackage(m_pPackageLE -> text());
- */
- if ( m_pObject->getUMLPackage() == NULL ) {
- kDebug() << k_funcinfo << "Parent package not set, setting it to Logical View folder"<<endl;
- UMLFolder* folder = m_pUmldoc->getRootFolder( Uml::mt_Logical );
- m_pObject->setUMLPackage( ( UMLPackage* )folder );
+ QString packageName = m_pPackageCB->currentText().trimmed();
+ UMLObject* newPackage = NULL;
+
+ if ( !packageName.isEmpty()) {
+ if ( ( newPackage = m_pUmldoc->findUMLObject(packageName, Uml::ot_Package) ) == NULL )
+ newPackage = Import_Utils::createUMLObject(Uml::ot_Package, packageName);
+ } else {
+ newPackage = m_pUmldoc->getRootFolder( Uml::mt_Logical );
}
+ // adjust list view items
+ UMLListView *lv = UMLApp::app()->getListView();
+ UMLListViewItem *newLVParent = lv->findUMLObject(newPackage);
+ lv->moveObject(m_pObject->getID(),
+ Model_Utils::convert_OT_LVT(m_pObject),
+ newLVParent);
+
+ m_pObject->emitModified();
+
if( m_pAbstractCB )
m_pObject -> setAbstract( m_pAbstractCB -> isChecked() );
//make sure unique name
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/classgenpage.h #692906:692907
@@ -84,7 +84,7 @@
Q3ButtonGroup * m_pButtonBG;
QLabel * m_pNameL, * m_pInstanceL, * m_pStereoTypeL, * m_pPackageL;
QLineEdit * m_pClassNameLE, *m_pInstanceLE, * m_pPackageLE;
- KComboBox * m_pStereoTypeCB;
+ KComboBox * m_pStereoTypeCB, *m_pPackageCB ;
QRadioButton *m_pPublicRB, *m_pPrivateRB, *m_pProtectedRB, *m_pImplementationRB;
QCheckBox * m_pMultiCB, * m_pDrawActorCB, * m_pAbstractCB, * m_pDeconCB;
Q3MultiLineEdit * m_pDoc;
--- trunk/KDE/kdesdk/umbrello/umbrello/dialogs/classwizard.cpp #692906:692907
@@ -41,6 +41,7 @@
num.setNum( ++i);
newName = name;
newName.append("_").append( num );
+ m_pDoc->signalUMLObjectCreated(m_pClass);
} while( pTemp );
//setup pages
setupPages();
--- trunk/KDE/kdesdk/umbrello/umbrello/package.cpp #692906:692907
@@ -173,6 +173,22 @@
return Model_Utils::findObjectInList(id, m_objects);
}
+
+void UMLPackage::appendPackages(UMLPackageList& packages, bool includeNested ) {
+ for (UMLObjectListIt oit(m_objects); oit.current(); ++oit) {
+ UMLObject *o = oit.current();
+ Object_Type ot = o->getBaseType();
+ if (ot == ot_Package) {
+ packages.append((UMLPackage *)o);
+ if (includeNested) {
+ UMLPackage *inner = static_cast<UMLPackage*>(o);
+ inner->appendPackages(packages);
+ }
+ }
+ }
+}
+
+
void UMLPackage::appendClassifiers(UMLClassifierList& classifiers,
bool includeNested /* = true */) {
for (UMLObjectListIt oit(m_objects); oit.current(); ++oit) {
--- trunk/KDE/kdesdk/umbrello/umbrello/package.h #692906:692907
@@ -123,7 +123,18 @@
*/
UMLObject * findObjectById(Uml::IDType id);
+
/**
+ * Append all packages from this packaed ( and those from nested packeges)
+ * to the given UMLPackageList.
+ *
+ * @param packages The list to append to
+ * @param includeNested Whether to include the packages from nested packages
+ * (default:true)
+ */
+ void appendPackages(UMLPackageList& packages, bool includeNested = true);
+
+ /**
* Append all classifiers from this package (and those from
* nested packages) to the given UMLClassifierList.
*
--- trunk/KDE/kdesdk/umbrello/umbrello/umldoc.cpp #692906:692907
@@ -1838,6 +1838,14 @@
UMLApp::app()->setDiagramMenuItemsState(false);
}
+
+UMLPackageList UMLDoc::getPackages(bool includeNested /* = true */) {
+ UMLPackageList packageList;
+ m_root[mt_Logical]->appendPackages(packageList, includeNested);
+ return packageList;
+}
+
+
UMLClassifierList UMLDoc::getConcepts(bool includeNested /* =true */) {
UMLClassifierList conceptList;
m_root[mt_Logical]->appendClassifiers(conceptList, includeNested);
--- trunk/KDE/kdesdk/umbrello/umbrello/umldoc.h #692906:692907
@@ -39,6 +39,7 @@
#include "umlentitylist.h"
#include "umlviewlist.h"
#include "umlstereotypelist.h"
+#include "umlpackagelist.h"
#define ENC_UNKNOWN 0
#define ENC_UNICODE 1
@@ -539,7 +540,15 @@
*/
UMLAssociationList getAssociations();
+
/**
+ * Returns a list of the packages in this UMLDoc,
+ *
+ * @return List of UMLPackages.
+ */
+ UMLPackageList getPackages(bool includeNested = true);
+
+ /**
* Controls the printing of the program.
*
* @param pPrinter The printer (object) to use.
More information about the umbrello-devel
mailing list