[Uml-devel] CVS: kdesdk/umbrello/umbrello uml.cpp,1.6,1.7 umlview.cpp,1.8,1.9 umlview.h,1.4,1.5 umlviewdata.cpp,1.1,1.2 umlviewdata.h,1.1,1.2

kde at office.kde.org kde at office.kde.org
Sat Feb 1 11:56:08 UTC 2003


Update of /home/kde/kdesdk/umbrello/umbrello
In directory office:/tmp/cvs-serv28176

Modified Files:
	uml.cpp umlview.cpp umlview.h umlviewdata.cpp umlviewdata.h 
Log Message:
The zoom level of each diagram is now saved and loaded from files


Index: uml.cpp
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/uml.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- uml.cpp	31 Jan 2003 19:57:10 -0000	1.6
+++ uml.cpp	1 Feb 2003 19:55:05 -0000	1.7
@@ -1071,11 +1071,10 @@
 
 	//		menu -> removeItemAt( i );
 	menu -> clear();
-	for(QListIterator<UMLView> views = getDocument()->
-	                                   getViewIterator();
-	        views.current();
-	        ++views)
-		menu -> insertItem( views.current()->getName(), views.current(), SLOT( slotShowView() ) );
+	for(QListIterator<UMLView> views = getDocument()->getViewIterator(); views.current(); ++views) {
+		menu->insertItem( views.current()->getName(), views.current(), SLOT( slotShowView() ) );
+		views.current()->fileLoaded();
+	}
 }
 
 void UMLApp::slotImportClasses() {

Index: umlview.cpp
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/umlview.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- umlview.cpp	31 Jan 2003 19:57:10 -0000	1.8
+++ umlview.cpp	1 Feb 2003 19:55:05 -0000	1.9
@@ -107,6 +107,7 @@
 	connect( this, SIGNAL(sigRemovePopupMenu()), this, SLOT(slotRemovePopupMenu() ) );
 	connect( (UMLApp *)getDocument() -> parent() , SIGNAL( sigCutSuccessful() ),
 	         this, SLOT( slotCutSuccessful() ) );
+
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -2711,29 +2712,39 @@
 }
 
 void UMLView::setZoom(int zoom) {
-	if(zoom<10) zoom = 10;
-	else if (zoom > 500) zoom = 500;
+	if (zoom < 10) {
+		zoom = 10;
+	} else if (zoom > 500) {
+		zoom = 500;
+	}
 
 	QWMatrix wm;
 	wm.scale(zoom/100.0,zoom/100.0);
 	setWorldMatrix(wm);
+
+	m_pData->setZoom( currentZoom() );
 }
 
 int UMLView::currentZoom() {
 	return (int)(worldMatrix().m11()*100.0);
 }
 
-
 void UMLView::zoomIn() {
 	QWMatrix wm = worldMatrix();
 	wm.scale(1.5,1.5); // adjust zooming step here
 	setWorldMatrix(wm);
+	m_pData->setZoom( currentZoom() );
 }
 
 void UMLView::zoomOut() {
 	QWMatrix wm = worldMatrix();
 	wm.scale(2.0/3.0, 2.0/3.0); //adjust zooming step here
 	setWorldMatrix(wm);
+	m_pData->setZoom( currentZoom() );
+}
+
+void UMLView::fileLoaded() {
+	setZoom( m_pData->getZoom() );
 }
 
 #include "umlview.moc"

Index: umlview.h
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/umlview.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- umlview.h	31 Jan 2003 00:10:15 -0000	1.4
+++ umlview.h	1 Feb 2003 19:55:05 -0000	1.5
@@ -670,6 +670,12 @@
 	 */
 	void toggleShowGrid();
 
+	/**
+	 * Changes the zoom to the currently set level (now loaded from file)
+	 * Called from UMLApp::slotUpdateViews()
+	 */
+	void fileLoaded();
+
 protected:
 
 	/**

Index: umlviewdata.cpp
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/umlviewdata.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- umlviewdata.cpp	23 Jan 2003 22:21:13 -0000	1.1
+++ umlviewdata.cpp	1 Feb 2003 19:55:05 -0000	1.2
@@ -37,14 +37,15 @@
 	m_bShowSnapGrid = false;
 	m_nSnapX = 10;
 	m_nSnapY = 10;
+	m_nZoom = 100;
 }
 
-UMLViewData::~UMLViewData() {}
-
 UMLViewData::UMLViewData( UMLViewData & other ) {
 	*this = other;
 }
 
+UMLViewData::~UMLViewData() {}
+
 UMLViewData & UMLViewData::operator=( UMLViewData & rhs ) {
 	if( this == &rhs )
 		return *this;
@@ -121,7 +122,7 @@
 			>> nUseFC
 			>> m_nSnapX
 			>> m_nSnapY
-			>> nShowsnap 
+			>> nShowsnap
 			>> nSnapgrid;
 		*stream >> nTemp;
 		if (fileversion < 5)
@@ -148,9 +149,11 @@
 		m_Options.uiState.useFillColor = nUseFC;
 		m_bUseSnapToGrid = nSnapgrid;
 		m_bShowSnapGrid = nShowsnap;
+		//FIXME serialise zoom
+
 		if (fileversion > 4)
 			m_Type = (Uml::Diagram_Type)nType;
-		else 
+		else
 			switch (nType)
 			{
 				case /* UCDIAGRAM */ 300 :
@@ -275,6 +278,14 @@
 	m_nID = id;
 }
 
+int UMLViewData::getZoom() {
+	return m_nZoom;
+}
+
+void UMLViewData::setZoom(int zoom) {
+	m_nZoom = zoom;
+}
+
 int UMLViewData::getUniqueID() {
 	return --m_nLocalID;
 }
@@ -366,7 +377,7 @@
 					return false;
 				m_WidgetList.append( widgetData );
 				*stream >> stype;
-			}//end while 
+			}//end while
 		}
 	}//end else
 	return true;
@@ -479,6 +490,7 @@
 	viewElement.setAttribute( "snapgrid", m_bUseSnapToGrid );
 	viewElement.setAttribute( "snapx", m_nSnapX );
 	viewElement.setAttribute( "snapy", m_nSnapY );
+	viewElement.setAttribute( "zoom", m_nZoom );
 	//now save all the widgets
 	UMLWidgetData * widgetData = 0;
 	UMLWidgetDataListIt w_it( m_WidgetList );
@@ -553,6 +565,10 @@
 
 	QString snapy = qElement.attribute( "snapy", "10" );
 	m_nSnapY = snapy.toInt();
+
+	QString zoom = qElement.attribute( "zoom", "100" );
+	m_nZoom = zoom.toInt();
+
 	m_Type = (Uml::Diagram_Type)type.toInt();
 	if( fillcolor != "" )
 		m_Options.uiState.fillColor = QColor( fillcolor );

Index: umlviewdata.h
===================================================================
RCS file: /home/kde/kdesdk/umbrello/umbrello/umlviewdata.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- umlviewdata.h	23 Jan 2003 22:21:13 -0000	1.1
+++ umlviewdata.h	1 Feb 2003 19:55:05 -0000	1.2
@@ -26,6 +26,7 @@
 	friend class UMLView;
 
 public:
+
 	/**
 	 * 		Constructor
 	 */
@@ -139,6 +140,16 @@
 	void setID( int id );
 
 	/**
+	 * 		Returns the zoom of the diagram.
+	 */
+	int getZoom();
+
+	/**
+	 * 		Sets the zoom of the diagram.
+	 */
+	void setZoom(int zoom);
+
+	/**
 	 * 		Returns an ID unique to this diagram.  ObjectWidgets will
 	 *		need one of these.
 	 */
@@ -320,6 +331,12 @@
 	 * 		Determines whether to show the snap grid.  The default will be on if the grid is on.
 	 */
 	bool m_bShowSnapGrid;
+
+	/**
+	 * The zoom level in percent, default 100
+	 */
+	int m_nZoom;
+
 };
 
 #endif





More information about the umbrello-devel mailing list