[Uml-devel] CVS: kdesdk/umbrello/umbrello umlview.cpp,1.9,1.10 umlview.h,1.5,1.6 umlviewdata.cpp,1.2,1.3 umlviewdata.h,1.2,1.3
kde at office.kde.org
kde at office.kde.org
Sat Feb 1 14:41:39 UTC 2003
Update of /home/kde/kdesdk/umbrello/umbrello
In directory office:/tmp/cvs-serv30716
Modified Files:
umlview.cpp umlview.h umlviewdata.cpp umlviewdata.h
Log Message:
The size of the diagrams is now saved to the file.
Index: umlview.cpp
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/umlview.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- umlview.cpp 1 Feb 2003 19:55:05 -0000 1.9
+++ umlview.cpp 1 Feb 2003 22:39:06 -0000 1.10
@@ -67,8 +67,6 @@
#include "umlwidgetdata.h"
#include "floatingtextdata.h"
-static const int defaultCanvasSize = 1300;
-
UMLView::UMLView( QWidget * parent, UMLViewData * pData ) : QCanvasView( parent, "AnUMLView" ) {
m_pData = pData;
init();
@@ -2745,6 +2743,13 @@
void UMLView::fileLoaded() {
setZoom( m_pData->getZoom() );
+ setCanvasSize( m_pData->getCanvasWidth(), m_pData->getCanvasHeight() );
+}
+
+void UMLView::setCanvasSize(int width, int height) {
+ m_pData->setCanvasWidth(width);
+ m_pData->setCanvasHeight(height);
+ canvas()->resize(width, height);
}
#include "umlview.moc"
Index: umlview.h
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/umlview.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- umlview.h 1 Feb 2003 19:55:05 -0000 1.5
+++ umlview.h 1 Feb 2003 22:39:06 -0000 1.6
@@ -676,6 +676,16 @@
*/
void fileLoaded();
+ /**
+ * Sets the diagram width and height in pixels
+ */
+ void setCanvasSize(int width, int height);
+
+ /**
+ * the width and height of a diagram canvas in pixels
+ */
+ static const int defaultCanvasSize = 1300;
+
protected:
/**
Index: umlviewdata.cpp
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/umlviewdata.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- umlviewdata.cpp 1 Feb 2003 19:55:05 -0000 1.2
+++ umlviewdata.cpp 1 Feb 2003 22:39:06 -0000 1.3
@@ -38,6 +38,8 @@
m_nSnapX = 10;
m_nSnapY = 10;
m_nZoom = 100;
+ m_nCanvasWidth = UMLView::defaultCanvasSize;
+ m_nCanvasHeight = UMLView::defaultCanvasSize;
}
UMLViewData::UMLViewData( UMLViewData & other ) {
@@ -149,7 +151,7 @@
m_Options.uiState.useFillColor = nUseFC;
m_bUseSnapToGrid = nSnapgrid;
m_bShowSnapGrid = nShowsnap;
- //FIXME serialise zoom
+ //FIXME serialise zoom, canvas height & width
if (fileversion > 4)
m_Type = (Uml::Diagram_Type)nType;
@@ -286,6 +288,22 @@
m_nZoom = zoom;
}
+int UMLViewData::getCanvasHeight() {
+ return m_nCanvasHeight;
+}
+
+void UMLViewData::setCanvasHeight(int height) {
+ m_nCanvasHeight = height;
+}
+
+int UMLViewData::getCanvasWidth() {
+ return m_nCanvasWidth;
+}
+
+void UMLViewData::setCanvasWidth(int width) {
+ m_nCanvasWidth = width;
+}
+
int UMLViewData::getUniqueID() {
return --m_nLocalID;
}
@@ -491,6 +509,8 @@
viewElement.setAttribute( "snapx", m_nSnapX );
viewElement.setAttribute( "snapy", m_nSnapY );
viewElement.setAttribute( "zoom", m_nZoom );
+ viewElement.setAttribute( "canvasheight", m_nCanvasHeight );
+ viewElement.setAttribute( "canvaswidth", m_nCanvasWidth );
//now save all the widgets
UMLWidgetData * widgetData = 0;
UMLWidgetDataListIt w_it( m_WidgetList );
@@ -568,6 +588,12 @@
QString zoom = qElement.attribute( "zoom", "100" );
m_nZoom = zoom.toInt();
+
+ QString height = qElement.attribute( "canvasheight", QString("%1").arg(UMLView::defaultCanvasSize) );
+ m_nCanvasHeight = height.toInt();
+
+ QString width = qElement.attribute( "canvaswidth", QString("%1").arg(UMLView::defaultCanvasSize) );
+ m_nCanvasWidth = width.toInt();
m_Type = (Uml::Diagram_Type)type.toInt();
if( fillcolor != "" )
Index: umlviewdata.h
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/umlviewdata.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- umlviewdata.h 1 Feb 2003 19:55:05 -0000 1.2
+++ umlviewdata.h 1 Feb 2003 22:39:06 -0000 1.3
@@ -150,6 +150,26 @@
void setZoom(int zoom);
/**
+ * Returns the height of the diagram.
+ */
+ int getCanvasHeight();
+
+ /**
+ * Sets the height of the diagram.
+ */
+ void setCanvasHeight(int height);
+
+ /**
+ * Returns the width of the diagram.
+ */
+ int getCanvasWidth();
+
+ /**
+ * Sets the height of the diagram.
+ */
+ void setCanvasWidth(int width);
+
+ /**
* Returns an ID unique to this diagram. ObjectWidgets will
* need one of these.
*/
@@ -336,6 +356,16 @@
* The zoom level in percent, default 100
*/
int m_nZoom;
+
+ /**
+ * Width of canvas in pixels
+ */
+ int m_nCanvasWidth;
+
+ /**
+ * Height of canvas in pixels
+ */
+ int m_nCanvasHeight;
};
More information about the umbrello-devel
mailing list