Пример #1
0
/**
 * 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);
                    }
                }
            }