[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Sat Sep 2 14:24:18 UTC 2006
SVN commit 580057 by okellogg:
UMLListView::findFolderForDiagram(): New.
M +14 -2 clipboard/umldrag.cpp
M +28 -19 umllistview.cpp
M +14 -0 umllistview.h
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/clipboard/umldrag.cpp #580056:580057
@@ -17,6 +17,7 @@
#include "../umldoc.h"
#include "../umlview.h"
#include "../umlobject.h"
+#include "../folder.h"
#include "../classifier.h"
#include "../umlwidget.h"
#include "../umllistview.h"
@@ -497,8 +498,20 @@
kdWarning() << "no diagrams in XMI clip" << endl;
return false;
}
+ UMLListView *listView = UMLApp::app()->getListView();
while ( !diagramElement.isNull() ) {
- UMLView* view = new UMLView(NULL); // UMLFolder parent must be set by caller
+ QString type = diagramElement.attribute("type", "0");
+ Uml::Diagram_Type dt = (Uml::Diagram_Type)type.toInt();
+ UMLListViewItem *parent = listView->findFolderForDiagram(dt);
+ if (parent == NULL)
+ return false;
+ UMLObject *po = parent->getUMLObject();
+ if (po == NULL || po->getBaseType() != Uml::ot_Folder) {
+ kdError() << "UMLDrag::decodeClip2: bad parent for view" << endl;
+ return false;
+ }
+ UMLFolder *f = static_cast<UMLFolder*>(po);
+ UMLView* view = new UMLView(f);
view->loadFromXMI(diagramElement);
diagrams.append(view);
diagramNode = diagramNode.nextSibling();
@@ -513,7 +526,6 @@
kdWarning() << "no listitems in XMI clip" << endl;
return false;
}
- UMLListView *listView = UMLApp::app()->getListView();
UMLListViewItem *currentItem = (UMLListViewItem*)listView->currentItem();
while ( !listItemElement.isNull() ) {
UMLListViewItem* itemData;
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umllistview.cpp #580056:580057
@@ -501,31 +501,40 @@
}//end switch
}
+UMLListViewItem *UMLListView::findFolderForDiagram(Uml::Diagram_Type dt) {
+ UMLListViewItem *p = static_cast<UMLListViewItem*>(currentItem());
+ if (p && Model_Utils::typeIsFolder(p->getType())
+ && !Model_Utils::typeIsRootView(p->getType())) {
+ return p;
+ }
+ switch (dt) {
+ case Uml::dt_UseCase:
+ p = m_lv[Uml::mt_UseCase];
+ break;
+ case Uml::dt_Component:
+ p = m_lv[Uml::mt_Component];
+ break;
+ case Uml::dt_Deployment:
+ p = m_lv[Uml::mt_Deployment];
+ break;
+ case Uml::dt_EntityRelationship:
+ p = m_lv[Uml::mt_EntityRelationship];
+ break;
+ default:
+ p = m_lv[Uml::mt_Logical];
+ break;
+ }
+ return p;
+}
+
void UMLListView::slotDiagramCreated( Uml::IDType id ) {
if( m_doc->loading() )
return;
UMLView *v = m_doc -> findView( id );
if (!v)
return;
- UMLListViewItem * temp = 0, *p = 0;
const Uml::Diagram_Type dt = v->getType();
- //See if we wanted to create diagram in folder
- UMLListViewItem * current = (UMLListViewItem *) currentItem();
- if (current && Model_Utils::typeIsFolder(current->getType()) && !Model_Utils::typeIsRootView(current->getType())) {
- p = current;
- kdDebug() << "UMLListView::slotDiagramCreated: current " << p->getText()
- << ", lvtype " << p->getType() << endl;
- } else if (dt == Uml::dt_UseCase) {
- p = m_lv[Uml::mt_UseCase];
- } else if (dt == Uml::dt_Component) {
- p = m_lv[Uml::mt_Component];
- } else if (dt == Uml::dt_Deployment) {
- p = m_lv[Uml::mt_Deployment];
- } else if (dt == Uml::dt_EntityRelationship) {
- p = m_lv[Uml::mt_EntityRelationship];
- } else {
- p = m_lv[Uml::mt_Logical];
- }
+ UMLListViewItem * temp = 0, *p = findFolderForDiagram(dt);
temp = new UMLListViewItem(p, v->getName(), Model_Utils::convert_DT_LVT(dt), id);
setSelected( temp, true );
UMLApp::app() -> getDocWindow() -> showDocumentation( v , false );
@@ -765,7 +774,7 @@
UMLView* v = m_doc->findView(id);
if ((temp = findView(v)) == NULL) {
kdError() << "UMLListView::slotDiagramRenamed: UMLDoc::findView("
- << ID2STR(id) << " returns NULL" << endl;
+ << ID2STR(id) << ") returns NULL" << endl;
return;
}
temp->setText( v->getName() );
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umllistview.h #580056:580057
@@ -112,6 +112,20 @@
UMLListViewItem* parent = 0);
/**
+ * Find the parent folder for a diagram.
+ * If the currently selected item in the list view is a folder
+ * then that folder is returned as the parent.
+ *
+ * @param dt The Diagram_Type of the diagram.
+ * The type will only be used if there is no currently
+ * selected item, or if the current item is not a folder.
+ * In that case the root folder which is suitable for the
+ * Diagram_Type is returned.
+ * @return Pointer to the parent UMLListViewItem for the diagram.
+ */
+ UMLListViewItem *findFolderForDiagram(Uml::Diagram_Type dt);
+
+ /**
* Determine the parent ListViewItem given an UMLObject.
*
* @param object Pointer to the UMLObject for which to look up the parent.
More information about the umbrello-devel
mailing list