/** * Gets called when the users chooses to print all diagrams, the current * diagram, a selection of diagrams or diagrams by type. It will change the * listed diagrams in the diagram box. */ void DiagramPrintPage::slotClicked() { UMLViewList list = m_doc->viewIterator(); QString type; // clear list with diagrams to print m_nIdList.clear(); UMLScene *currentScene = UMLApp::app()->currentView()->umlScene(); if (m_pCurrentRB->isChecked()) { m_pTypeCB->setEnabled(false); m_pSelectLW->setEnabled(false); m_pSelectLW->clear(); m_pSelectLW->addItem(currentScene->name()); m_pSelectLW->setCurrentRow(0); m_nIdList.append(currentScene->ID()); } if (m_pAllRB->isChecked()) { m_pTypeCB->setEnabled(false); m_pSelectLW->setEnabled(false); m_pSelectLW->clear(); foreach (UMLView * view, list) { m_pSelectLW->addItem(view->umlScene()->name()); m_nIdList.append(view->umlScene()->ID()); }
/** * Remove the widget */ void CmdRemoveWidget::redo() { UMLScene* umlScene = scene(); UMLWidget* widget = umlScene->findWidget(m_widgetId); if (widget != 0) { umlScene->removeWidgetCmd(widget); } }
/** * Add the widget back */ void CmdRemoveWidget::undo() { QDomElement widgetElement = m_element.firstChild().toElement(); UMLScene* umlScene = scene(); UMLWidget* widget = umlScene->loadWidgetFromXMI(widgetElement); addWidgetToScene(widget); }
/** * Overrides the standard operation. */ void UMLView::hideEvent(QHideEvent* he) { UMLApp* theApp = UMLApp::app(); WorkToolBar* tb = theApp->workToolBar(); UMLScene *us = umlScene(); disconnect(tb, SIGNAL(sigButtonChanged(int)), us, SLOT(slotToolBarChanged(int))); disconnect(us, SIGNAL(sigResetToolBar()), tb, SLOT(slotResetToolBar())); us->hideEvent(he); }
/** * Overrides the standard operation. */ void UMLView::showEvent(QShowEvent* se) { UMLApp* theApp = UMLApp::app(); WorkToolBar* tb = theApp->workToolBar(); UMLScene *us = umlScene(); connect(tb, SIGNAL(sigButtonChanged(int)), us, SLOT(slotToolBarChanged(int))); connect(us, SIGNAL(sigResetToolBar()), tb, SLOT(slotResetToolBar())); umlScene()->showEvent(se); us->resetToolbar(); }
/** * 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 {
/** * Moves the point or line if active. */ void AssociationLine::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { UMLScene* scene = m_associationWidget->umlScene(); QPointF oldPos = event->scenePos(); QPointF newPos( scene->snappedX(oldPos.x()), scene->snappedY(oldPos.y()) ); // Prevent the moving vertex from disappearing underneath a widget // (else there's no way to get it back.) UMLWidget *onW = scene->widgetAt(newPos); if (onW && onW->baseType() != WidgetBase::wt_Box) { // boxes are transparent const qreal pX = newPos.x(); const qreal pY = newPos.y(); const qreal wX = onW->x(); const qreal wY = onW->y(); const qreal wWidth = onW->width(); const qreal wHeight = onW->height(); if (pX > wX && pX < wX + wWidth) { const qreal midX = wX + wWidth / 2.0; if (pX <= midX) newPos.setX(wX); else newPos.setX(wX + wWidth); } if (pY > wY && pY < wY + wHeight) { const qreal midY = wY + wHeight / 2.0; if (pY <= midY) newPos.setY(wY); else newPos.setY(wY + wHeight); } } if (m_activePointIndex != -1) { // Move a single point (snap behaviour) setPoint(m_activePointIndex, newPos); } else if (m_activeSegmentIndex != -1 && !isEndSegmentIndex(m_activeSegmentIndex)) { // Move a segment (between two points, snap behaviour not implemented) QPointF delta = event->scenePos() - event->lastScenePos(); setPoint(m_activeSegmentIndex, m_points[m_activeSegmentIndex] + delta); setPoint(m_activeSegmentIndex + 1, m_points[m_activeSegmentIndex + 1] + delta); } }