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

David Faure faure at kde.org
Mon Oct 15 22:36:02 UTC 2007


SVN commit 725656 by dfaure:

Fix compilation - constness is really a mess in this code...


 M  +9 -8      linepath.cpp  
 M  +6 -6      linepath.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/linepath.cpp #725655:725656
@@ -93,16 +93,17 @@
     connect( view, SIGNAL( sigLineWidthChanged( Uml::IDType ) ), this, SLOT( slotLineWidthChanged( Uml::IDType ) ) );
 }
 
-QPoint LinePath::getPoint( int pointIndex ) {
+QPoint LinePath::getPoint( int pointIndex ) const {
     int count = m_LineList.count();
     if( count == 0 || pointIndex > count  || pointIndex < 0)
         return QPoint( -1, -1 );
 
     if( pointIndex == count ) {
-        Q3CanvasLine * line = m_LineList.last();
+        Q3CanvasLine * line = m_LineList.getLast();
         return line -> endPoint();
     }
-    Q3CanvasLine * line = m_LineList.at( pointIndex );
+    // Q3PtrList's constness sucked... remove this cast when porting to QList
+    Q3CanvasLine * line = const_cast<LinePath*>(this)->m_LineList.at( pointIndex );
     return line -> startPoint();
 }
 
@@ -290,7 +291,7 @@
     return false;
 }
 
-int LinePath::count() {
+int LinePath::count() const {
     return m_LineList.count() + 1;
 }
 
@@ -782,7 +783,7 @@
     line -> setPoints( common.x(), common.y(), p.x(), p.y() );
 }
 
-bool LinePath::operator==( LinePath & rhs ) {
+bool LinePath::operator==( const LinePath & rhs ) {
     if( this -> m_LineList.count() != rhs.m_LineList.count() )
         return false;
 
@@ -794,7 +795,7 @@
     return true;
 }
 
-LinePath & LinePath::operator=( LinePath & rhs ) {
+LinePath & LinePath::operator=( const LinePath & rhs ) {
     if( this == &rhs )
         return *this;
     //clear out the old canvas objects
@@ -821,7 +822,7 @@
     return view -> canvas();
 }
 
-Uml::Association_Type LinePath::getAssocType() {
+Uml::Association_Type LinePath::getAssocType() const {
     if( m_pAssociation )
         return m_pAssociation -> getAssocType();
     return Uml::at_Association;
@@ -877,7 +878,7 @@
     m_DockRegion = region;
 }
 
-bool LinePath::hasPoints () {
+bool LinePath::hasPoints () const {
     int count = m_LineList.count();
     if (count>1)
         return true;
--- trunk/KDE/kdesdk/umbrello/umbrello/linepath.h #725655:725656
@@ -56,12 +56,12 @@
     /**
     *   equal to (==) operator
     */
-    bool operator==( LinePath & rhs );
+    bool operator==( const LinePath & rhs );
 
     /**
     *   copy ( = ) operator
     */
-    LinePath & operator=( LinePath & rhs );
+    LinePath & operator=( const LinePath & rhs );
 
     /**
     *   Enum to tell whether the line docks top/bottom or left/right
@@ -75,13 +75,13 @@
     */
     void setDockRegion( Region region );
 
-    bool hasPoints ();
+    bool hasPoints () const;
     void dumpPoints ();
 
     /**
     *   Returns the point at the point index.
     */
-    QPoint getPoint( int pointIndex );
+    QPoint getPoint( int pointIndex ) const;
 
     /**
     *   Sets the position of an already set point.
@@ -115,7 +115,7 @@
     *   Returns the amount of POINTS on the line.
     *   Includes start and end points.
     */
-    int count();
+    int count() const;
 
     /**
     *   Returns -1 if the given point is not on the line.
@@ -252,7 +252,7 @@
     *   This class doesn't hold this information but is a wrapper
     *   method to stop calls to undefined variable like m_pAssociation.
     */
-    Uml::Association_Type getAssocType();
+    Uml::Association_Type getAssocType() const;
 
     /**
     *   Returns the Line Color to use.




More information about the umbrello-devel mailing list