[Uml-devel] KDE/kdesdk/umbrello/umbrello

Andi Fischer andi.fischer at hispeed.ch
Sat Jul 2 09:58:27 UTC 2011


SVN commit 1239070 by fischer:

Some tabs with spaces replaced.
Zoom-Fit enabled and implemented.
Zoom-Label added.



 M  +31 -1     uml.cpp  
 M  +2 -0      uml.h  
 M  +5 -3      umlview.cpp  
 M  +11 -6     widgets/statusbartoolbutton.cpp  
 M  +2 -2      widgets/statusbartoolbutton.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/uml.cpp #1239069:1239070
@@ -91,6 +91,8 @@
 #include <QtGui/QPushButton>
 #include <QtGui/QLabel>
 
+#include <cmath>
+
 /** Static pointer, holding the last created instance. */
 UMLApp* UMLApp::s_instance;
 
@@ -541,6 +543,29 @@
 }
 
 /**
+ * Set zoom to fit the view.
+ */
+void UMLApp::slotZoomFit()
+{
+    currentView()->setZoom(100);  // bring it first to the original values
+    DEBUG(DBG_SRC) << "canvas width=" << currentView()->getCanvasWidth()
+                   << ", height=" << currentView()->getCanvasHeight();
+    DEBUG(DBG_SRC) << "visible width=" << currentView()->visibleWidth()
+                   << ", height=" << currentView()->visibleHeight();
+    int scaleW = ceil(100.0 * currentView()->visibleWidth() / currentView()->getCanvasWidth());
+    int scaleH = ceil(100.0 * currentView()->visibleHeight() / currentView()->getCanvasHeight());
+    DEBUG(DBG_SRC) << "scale width: " << scaleW << ", height: " << scaleH;
+    int scale = 100;
+    if (scaleW < scaleH) {
+        scale = scaleW;
+    }
+    else {
+        scale = scaleH;
+    }
+    setZoom(scale);
+}
+
+/**
  * Set zoom to 100%.
  */
 void UMLApp::slotZoom100()
@@ -573,6 +598,7 @@
 {
     currentView()->setZoom(zoom);
     m_pZoomSlider->setValue(zoom);
+    m_zoomValueLbl->setText(QString::number(zoom) + '%');
 }
 
 /**
@@ -655,13 +681,17 @@
     zoomLayout->setSpacing(0);
     zoomLayout->addItem(new QSpacerItem(0, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
     
+    m_zoomValueLbl = new QLabel("100%");
+    m_zoomValueLbl->setMargin(10);
+    zoomLayout->addWidget(m_zoomValueLbl);
     
     m_pZoomFitSBTB = new StatusBarToolButton(this);
     m_pZoomFitSBTB->setText("Fit");
     m_pZoomFitSBTB->setGroupPosition(StatusBarToolButton::GroupLeft);
     zoomLayout->addWidget(m_pZoomFitSBTB);
     m_pZoomFitSBTB->setContentsMargins(0,0,0,0);
-    m_pZoomFitSBTB->setDisabled(true);
+    //m_pZoomFitSBTB->setDisabled(true);
+    connect(m_pZoomFitSBTB, SIGNAL( clicked() ), this, SLOT( slotZoomFit() ));
     
     m_pZoomFullSBTB = new StatusBarToolButton(this);
     m_pZoomFullSBTB->setText("100%");
--- trunk/KDE/kdesdk/umbrello/umbrello/uml.h #1239069:1239070
@@ -246,6 +246,7 @@
 
     void slotSetZoom(QAction* action);
     void slotZoomSliderMoved(int value);
+    void slotZoomFit();
     void slotZoom100();
     void slotZoomOut();
     void slotZoomIn();
@@ -402,6 +403,7 @@
     /**
      * Statusbar items
      */
+    QLabel*      m_zoomValueLbl;
     QPushButton* m_pZoomOutPB;
     QPushButton* m_pZoomInPB;
     StatusBarToolButton* m_pZoomFitSBTB;
--- trunk/KDE/kdesdk/umbrello/umbrello/umlview.cpp #1239069:1239070
@@ -974,13 +974,13 @@
         }
     }
 
-    /* now we need another look at the associations, because they are no
-     * UMLWidgets */
+    // now we need another look at the associations,
+    // because they are no UMLWidgets
 
     QRect rect;
 
     foreach(AssociationWidget* assoc_obj, m_AssociationList) {
-        /* get the rectangle around all segments of the assoc */
+        // get the rectangle around all segments of the assoc
         rect = assoc_obj->getAssocLineRectangle();
 
         if (startx >= rect.x())
@@ -1001,6 +1001,8 @@
        endy += 20;
     */
 
+//:TODO:    uDebug() << "x=" << startx << ", y=" << starty
+//:TODO:             << ", width=" << endx - startx << ", height=" << endy - starty;
     return QRect(startx, starty,  endx - startx, endy - starty);
 }
 
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/statusbartoolbutton.cpp #1239069:1239070
@@ -31,32 +31,37 @@
 #include <klocale.h>
 
 StatusBarToolButton::StatusBarToolButton(QWidget* parent)
-: QToolButton(parent)
-, mGroupPosition(NotGrouped) {
+  : QToolButton(parent),
+    mGroupPosition(NotGrouped)
+{
 	setToolButtonStyle(Qt::ToolButtonTextOnly);
 	setFocusPolicy(Qt::NoFocus);
 	setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
 }
 
 
-QSize StatusBarToolButton::minimumSizeHint() const {
+QSize StatusBarToolButton::minimumSizeHint() const
+{
 	return sizeHint();
 }
 
 
-QSize StatusBarToolButton::sizeHint() const {
+QSize StatusBarToolButton::sizeHint() const
+{
 	QSize sh = QToolButton::sizeHint();
 	sh.setHeight(fontMetrics().height());
 	return sh;
 }
 
 
-void StatusBarToolButton::setGroupPosition(StatusBarToolButton::GroupPosition groupPosition) {
+void StatusBarToolButton::setGroupPosition(StatusBarToolButton::GroupPosition groupPosition)
+{
 	mGroupPosition = groupPosition;
 }
 
 
-void StatusBarToolButton::paintEvent(QPaintEvent* event) {
+void StatusBarToolButton::paintEvent(QPaintEvent* event)
+{
 	if (mGroupPosition == NotGrouped) {
 		QToolButton::paintEvent(event);
 		return;
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/statusbartoolbutton.h #1239069:1239070
@@ -30,7 +30,8 @@
  *
  * ( button1 | button2 )
  */
-class StatusBarToolButton : public QToolButton {
+class StatusBarToolButton : public QToolButton
+{
 	Q_OBJECT
 public:
 	enum GroupPosition {
@@ -43,7 +44,6 @@
 	StatusBarToolButton(QWidget* parent=0);
 
 	virtual QSize minimumSizeHint() const;
-
 	virtual QSize sizeHint() const;
 
 	void setGroupPosition(StatusBarToolButton::GroupPosition groupPosition);




More information about the umbrello-devel mailing list