QMimeSource* UMLClipboard::copy(bool fromView/*=false*/) { //Clear previous copied data m_AssociationList.clear(); m_ItemList.clear(); m_ObjectList.clear(); m_ViewList.clear(); UMLDrag *data = 0; QPixmap* png = 0; UMLListView * listView = UMLApp::app()->getListView(); UMLListViewItemList selectedItems; selectedItems.setAutoDelete(false); if(fromView) { m_type = clip4; UMLView *view = UMLApp::app()->getCurrentView(); view->checkSelections(); if(!view->getSelectedWidgets(m_WidgetList)) { return 0; } //if there is no selected widget then there is no copy action if(!m_WidgetList.count()) { return 0; } m_AssociationList = view->getSelectedAssocs(); view->copyAsImage(png); } else { //if the copy action is being performed from the ListView if(!listView->getSelectedItems(selectedItems)) { return 0; } //Set What type of copy operation are we performing and //also fill m_ViewList with all the selected Diagrams setCopyType(selectedItems); //if we are copying a diagram or part of a diagram, select the items //on the ListView that correspond to a UseCase, Actor or Concept //in the Diagram if(m_type == clip2) { //Fill the member lists with all the object and stuff to be copied //to the clipboard selectedItems.clear(); //For each selected view select all the Actors, USe Cases and Concepts //widgets in the ListView for (UMLViewListIt vit(m_ViewList); vit.current(); ++vit) { UMLObjectList objects = vit.current()->getUMLObjects(); for (UMLObjectListIt oit(objects); oit.current(); ++oit) { UMLObject *o = oit.current(); UMLListViewItem *item = listView->findUMLObject(o); if(item) { listView->setSelected(item, true); } } } if(!listView->getSelectedItems(selectedItems)) { return 0; } } if(!fillSelectionLists(selectedItems)) { return 0; } } int i =0; switch(m_type) { case clip1: data = new UMLDrag(m_ObjectList); break; case clip2: data = new UMLDrag(m_ObjectList, m_ItemList, m_ViewList); break; case clip3: data = new UMLDrag(m_ItemList); break; case clip4: if(png) { UMLView *view = UMLApp::app()->getCurrentView(); data = new UMLDrag(m_ObjectList, m_WidgetList, m_AssociationList, *png, view->getType()); } else { return 0; } break; case clip5: data = new UMLDrag(m_ObjectList, i); // The int i is used to differentiate // which UMLDrag constructor gets called. break; } return (QMimeSource*)data; }