[Uml-devel] branches/work/isi-umbrello/umbrello/umbrello

Thibault Normand thibault.normand at gmail.com
Wed Dec 13 13:52:34 UTC 2006


SVN commit 613163 by tnormand:

+ Add Commands (Undo/Redo)
+ cmd_create_class
+ cmd_create_classdiag

+MERGE #613158

 A             cmds (directory)  
 AM            cmds/cmd_create_class.cpp   [License: no copyright]
 AM            cmds/cmd_create_class.h  
 AM            cmds/cmd_create_classdiag.cpp   [License: no copyright]
 AM            cmds/cmd_create_classdiag.h   [License: no copyright]
 M  +3 -1      package.cpp  
 M  +1 -1      umldoc.cpp  
 M  +1 -1      umlobject.cpp  
 M  +24 -17    umlview.cpp  
 M  +12 -0     umlwidgetcontroller.cpp  


** branches/work/isi-umbrello/umbrello/umbrello/cmds/cmd_create_class.cpp #property svn:executable
   + *
** branches/work/isi-umbrello/umbrello/umbrello/cmds/cmd_create_class.h #property svn:executable
   + *
** branches/work/isi-umbrello/umbrello/umbrello/cmds/cmd_create_classdiag.cpp #property svn:executable
   + *
** branches/work/isi-umbrello/umbrello/umbrello/cmds/cmd_create_classdiag.h #property svn:executable
   + *
--- branches/work/isi-umbrello/umbrello/umbrello/package.cpp #613162:613163
@@ -233,7 +233,9 @@
     for (UMLObjectListIt oit(m_objects); oit.current(); ++oit) {
         UMLObject *obj = oit.current();
         if (! obj->resolveRef()) {
-            m_objects.remove(obj);
+            Uml::Object_Type ot = obj->getBaseType();
+            if (ot != Uml::ot_Package && ot != Uml::ot_Folder)
+                m_objects.remove(obj);
             overallSuccess = false;
         }
     }
--- branches/work/isi-umbrello/umbrello/umbrello/umldoc.cpp #613162:613163
@@ -841,7 +841,7 @@
     if (s != NULL) {
         return s;
     }
-    s = new UMLStereotype(name);
+    s = new UMLStereotype(name, STR2ID(name));
     addStereotype(s);
     //emit modified();
     return s;
--- branches/work/isi-umbrello/umbrello/umbrello/umlobject.cpp #613162:613163
@@ -237,7 +237,7 @@
 
 void UMLObject::setDoc(const QString &d) {
     m_Doc = d;
-    emit modified();
+    //emit modified();  No, this is done centrally at DocWindow::updateDocumentation()
 }
 
 Uml::Object_Type UMLObject::getBaseType() const {
--- branches/work/isi-umbrello/umbrello/umbrello/umlview.cpp #613162:613163
@@ -27,6 +27,7 @@
 #include <qcolor.h>
 #include <qmatrix.h>
 #include <qregexp.h>
+#include <q3paintdevicemetrics.h>
 //Added by qt3to4:
 #include <QTextStream>
 #include <QHideEvent>
@@ -223,33 +224,39 @@
 void UMLView::print(KPrinter *pPrinter, QPainter & pPainter) {
     int height, width;
     //get the size of the page
+    pPrinter->setFullPage( true );
+    Q3PaintDeviceMetrics metrics(pPrinter);
     QFontMetrics fm = pPainter.fontMetrics(); // use the painter font metrics, not the screen fm!
     int fontHeight  = fm.lineSpacing();
-    int marginX = pPrinter->margins().width();
-    int marginY = pPrinter->margins().height();
+    uint left, right, top, bottom;
+    // fetch printer margins individual for all four page sides, as at least top and bottom are not the same
+    pPrinter->margins ( &top, &left, &bottom, &right );
+    // give a little extra space at each side
+    left += 2;
+    right += 2;
+    top += 2;
+    bottom += 2;
 
     if(pPrinter->orientation() == KPrinter::Landscape) {
         // we are printing in LANDSCAPE --> swap marginX and marginY
-        // this is needed, as KPrinter reports width margin strictly as printer
-        // default orientation margin - and not depend on LANDSCAPE/PORTRAIT
-        int temp = marginX;
-        marginX = marginY;
-        marginY = temp;
+        uint right_old = right;
+        // the DiagramRight side is printed at PrintersTop
+        right = top;
+        // the DiagramTop side is printed at PrintersLeft
+        top = left;
+        // the DiagramLeft side is printed at PrintersBottom
+        left = bottom;
+        // the DiagramBottom side is printed at PrintersRight
+        bottom = right_old;
     }
 
     // The printer will probably use a different font with different font metrics,
     // force the widgets to update accordingly on paint
     forceUpdateWidgetFontMetrics(&pPainter);
 
-    //double margin at bottom of page as it doesn't print down there
-    //on my printer, so play safe as default.
-    if(pPrinter->orientation() == KPrinter::Portrait) {
-        width = pPrinter->width() - marginX * 2;
-        height = pPrinter->height() - fontHeight - 4 - marginY * 3;
-    } else {
-        width = pPrinter->width() - marginX * 2;
-        height = pPrinter->height() - fontHeight - 4 - marginY * 2;
-    }
+    width = metrics.width() - left - right;
+    height = metrics.height() - top - bottom;
+
     //get the smallest rect holding the diagram
     QRect rect = getDiagramRect();
     //now draw to printer
@@ -346,7 +353,7 @@
     // set viewport - the physical mapping
     // --> Qt's QPainter will map all drawed elements from diagram area ( window )
     //     to printer area ( viewport )
-    pPainter.setViewport( marginX, marginY, width, height );
+    pPainter.setViewport( left, top, width, height );
 
     // get Diagram
     getDiagram(QRect(rect.x(), rect.y(), windowWidth, diagramHeight), pPainter);
--- branches/work/isi-umbrello/umbrello/umbrello/umlwidgetcontroller.cpp #613162:613163
@@ -93,6 +93,7 @@
         if (m_widget->m_bSelected && count > 1) {
             //Single selection is made in release event if the widget wasn't moved
             m_inMoveArea = true;
+            lastUpdate.start();
             return;
         }
 
@@ -165,7 +166,18 @@
         widget->getWidgetController()->moveWidgetBy(diffX, diffY);
 
         if (update) {
+            /* adjustAssocs() does not take along association line breaks:
             widget->adjustAssocs(widget->getX(), widget->getY());
+             ***** instead: */
+            // Move any selected associations.
+            AssociationWidgetList awl = m_widget->m_pView->getSelectedAssocs();
+            AssociationWidgetListIt assoc_it(awl);
+            AssociationWidget* assocwidget = NULL;
+            while ((assocwidget = assoc_it.current()) != NULL) {
+                    ++assoc_it;
+                    if (assocwidget->getSelected())
+                            assocwidget->moveEntireAssoc(diffX, diffY);
+            }
         }
     }
     m_widget->m_pView->resizeCanvasToItems();




More information about the umbrello-devel mailing list