~ubuntu-branches/ubuntu/vivid/kdesdk/vivid

« back to all changes in this revision

Viewing changes to umbrello/umbrello/clipboard/umlclipboard.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-06-06 11:49:54 UTC
  • mfrom: (0.4.21)
  • Revision ID: package-import@ubuntu.com-20120606114954-rdls73fzlpzxglbx
Tags: 4:4.8.80-0ubuntu1
* New uptream beta release
* Update dont_export_private_classes.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include "umllistview.h"
31
31
#include "umllistviewitem.h"
32
32
#include "umlobjectlist.h"
 
33
#include "umlscene.h"
33
34
#include "umlview.h"
34
35
#include "umlwidget.h"
35
36
#include "uml.h"
77
78
 
78
79
    if (fromView) {
79
80
        m_type = clip4;
80
 
        UMLView *view = UMLApp::app()->currentView();
81
 
        view->checkSelections();
82
 
        if(!view->getSelectedWidgets(m_WidgetList)) {
83
 
            return 0;
84
 
        }
 
81
        UMLScene *scene = UMLApp::app()->currentView()->umlScene();
 
82
        scene->checkSelections();
 
83
        m_WidgetList = scene->selectedWidgetsExt();
85
84
        //if there is no selected widget then there is no copy action
86
85
        if (!m_WidgetList.count()) {
87
86
            return 0;
88
87
        }
89
 
        m_AssociationList = view->getSelectedAssocs();
90
 
        view->copyAsImage(png);
 
88
        m_AssociationList = scene->selectedAssocs();
 
89
        scene->copyAsImage(png);
91
90
 
92
91
    } else { //if the copy action is being performed from the ListView
93
92
        UMLListViewItemList itemsSelected = listView->selectedItems();
108
107
            //For each selected view select all the Actors, USe Cases and Concepts
109
108
            //widgets in the ListView
110
109
            foreach (UMLView* view, m_ViewList ) {
111
 
                UMLObjectList objects = view->umlObjects();
 
110
                UMLObjectList objects = view->umlScene()->umlObjects();
112
111
                foreach (UMLObject* o, objects ) {
113
112
                    UMLListViewItem *item = listView->findUMLObject(o);
114
113
                    if (item) {
140
139
        if (png) {
141
140
            UMLView *view = UMLApp::app()->currentView();
142
141
            data = new UMLDragData(m_ObjectList, m_WidgetList,
143
 
                               m_AssociationList, *png, view->type());
 
142
                                   m_AssociationList, *png, view->umlScene()->type());
144
143
        } else {
145
144
            return 0;
146
145
        }
298
297
    } else if ( Model_Utils::typeIsDiagram(type) ) {
299
298
        withDiagrams = true;
300
299
        onlyAttsOps = false;
301
 
        view = doc->findView( item->getID() );
 
300
        view = doc->findView( item->ID() );
302
301
        m_ViewList.append( view );
303
302
    } else if ( Model_Utils::typeIsFolder(type) ) {
304
303
        onlyAttsOps = false;
354
353
    UMLListView *listView = UMLApp::app()->listView();
355
354
    for (int i = 0; i < parent->childCount(); i++) {
356
355
        UMLListViewItem *childItem = static_cast<UMLListViewItem*>(parent->child(i));
357
 
        Uml::IDType oldID = childItem->getID();
 
356
        Uml::IDType oldID = childItem->ID();
358
357
        Uml::IDType newID = chgLog->findNewID(oldID);
359
358
        UMLListViewItem *shouldNotExist = listView->findItem(newID);
360
359
        if (shouldNotExist) {
537
536
        return false;
538
537
    }
539
538
 
540
 
    if( diagramType != UMLApp::app()->currentView()->type() ) {
 
539
    UMLScene *currentScene = UMLApp::app()->currentView()->umlScene();
 
540
    if( diagramType != currentScene->type() ) {
541
541
        if( !checkPasteWidgets(widgets) ) {
542
542
            while ( !assocs.isEmpty() ) {
543
543
                delete assocs.takeFirst();
561
561
 
562
562
    //now add any widget we are want to paste
563
563
    bool objectAlreadyExists = false;
564
 
    UMLView *currentView = UMLApp::app()->currentView();
565
 
    currentView->beginPartialWidgetPaste();
 
564
    currentScene->beginPartialWidgetPaste();
566
565
 
567
566
    foreach ( UMLWidget* widget, widgets ) {
568
567
 
569
568
        Uml::IDType oldId = widget->id();
570
569
        Uml::IDType newId = idchanges->findNewID(oldId);
571
570
        // how should findWidget find ::None id, which is returned for the first entry ?
572
 
        if (currentView->findWidget(newId)) {
 
571
        if (currentScene->findWidget(newId)) {
573
572
            uError() << "widget (oldID=" << ID2STR(oldId) << ", newID="
574
573
                << ID2STR(newId) << ") already exists in target view.";
575
574
            widgets.removeAll(widget);
576
575
            delete widget;
577
576
            objectAlreadyExists = true;
578
577
        } else {
579
 
            if (currentView->type() == Uml::DiagramType::Activity || currentView->type() == Uml::DiagramType::State)
 
578
            if (currentScene->type() == Uml::DiagramType::Activity ||
 
579
                currentScene->type() == Uml::DiagramType::State) {
580
580
                widget->setID(doc->assignNewID(widget->id()));
581
 
            if (! currentView->addWidget(widget, true)) {
582
 
                currentView->endPartialWidgetPaste();
 
581
            }
 
582
            if (! currentScene->addWidget(widget, true)) {
 
583
                currentScene->endPartialWidgetPaste();
583
584
                return false;
584
585
            }
585
586
        }
587
588
 
588
589
    //now paste the associations
589
590
    foreach ( AssociationWidget* assoc, assocs ) {
590
 
        if (!currentView->addAssociation(assoc, true)) {
591
 
            currentView->endPartialWidgetPaste();
 
591
        if (!currentScene->addAssociation(assoc, true)) {
 
592
            currentScene->endPartialWidgetPaste();
592
593
            return false;
593
594
        }
594
595
    }
595
596
 
596
 
    currentView->clearSelected();
597
 
    currentView->selectWidgets(widgets);
 
597
    currentScene->clearSelected();
 
598
    currentScene->selectWidgets(widgets);
598
599
    foreach ( AssociationWidget* assoc, assocs ) {
599
 
        currentView->selectWidgetsOfAssoc(assoc);
 
600
        currentScene->selectWidgetsOfAssoc(assoc);
600
601
    }
601
602
 
602
603
    //Activate all the pasted associations and widgets
603
 
    currentView->activate();
604
 
    currentView->endPartialWidgetPaste();
 
604
    currentScene->activate();
 
605
    currentScene->endPartialWidgetPaste();
605
606
 
606
607
    /*
607
608
    UMLListView *listView = UMLApp::app()->listView();