/** * Copy operation. * @param fromView flag if it is from view * @return the mime data */ QMimeData* UMLClipboard::copy(bool fromView/*=false*/) { //Clear previous copied data m_AssociationList.clear(); m_ItemList.clear(); m_ObjectList.clear(); m_ViewList.clear(); UMLDragData *data = 0; QPixmap* png = 0; UMLListView * listView = UMLApp::app()->listView(); if (fromView) { m_type = clip4; UMLScene *scene = UMLApp::app()->currentView()->umlScene(); scene->checkSelections(); m_WidgetList = scene->selectedWidgetsExt(); //if there is no selected widget then there is no copy action if (!m_WidgetList.count()) { return 0; } m_AssociationList = scene->selectedAssocs(); scene->copyAsImage(png); } else { //if the copy action is being performed from the ListView UMLListViewItemList itemsSelected = listView->selectedItems(); if (itemsSelected.count() <= 0) { return 0; } //Set What type of copy operation are we performing and //also fill m_ViewList with all the selected Diagrams setCopyType(itemsSelected); //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 itemsSelected.clear(); //For each selected view select all the Actors, USe Cases and Concepts //widgets in the ListView foreach (UMLView* view, m_ViewList ) { UMLObjectList objects = view->umlScene()->umlObjects(); foreach (UMLObject* o, objects ) { UMLListViewItem *item = listView->findUMLObject(o); if (item) { listView->setCurrentItem(item); } } }
/** * Copy operation. * @param fromView flag if it is from view * @return the mime data */ QMimeData* UMLClipboard::copy(bool fromView/*=false*/) { // Clear previous copied data m_AssociationList.clear(); m_ObjectList.clear(); m_ViewList.clear(); UMLDragData *data = 0; QPixmap* png = 0; UMLListView * listView = UMLApp::app()->listView(); if (fromView) { m_type = clip4; UMLView *view = UMLApp::app()->currentView(); if (view == 0) { uError() << "UMLApp::app()->currentView() is NULL"; return 0; } UMLScene *scene = view->umlScene(); if (scene == 0) { uError() << "currentView umlScene() is NULL"; return 0; } m_WidgetList = scene->selectedWidgetsExt(); //if there is no selected widget then there is no copy action if (!m_WidgetList.count()) { return 0; } m_AssociationList = scene->selectedAssocs(); scene->copyAsImage(png); // Clip4 needs related widgets. addRelatedWidgets(); // Clip4 needs UMLObjects because it's possible the UMLObject // is no longer there when pasting this mime data. This happens for // example when using cut-paste or pasting to another Umbrello // instance. fillObjectListForWidgets(m_WidgetList); foreach (WidgetBase* widget, m_AssociationList) { if (widget->umlObject() != 0) { m_ObjectList.append(widget->umlObject()); } } } else {