Author: jghali
Date: Sun Dec 16 20:47:03 2018
New Revision: 22794

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22794
Log:
Add const qualifiers to a few UndoObject and ScGuardedPtr methods

Modified:
    trunk/Scribus/scribus/scguardedptr.h
    trunk/Scribus/scribus/undoobject.cpp
    trunk/Scribus/scribus/undoobject.h

Modified: trunk/Scribus/scribus/scguardedptr.h
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=22794&path=/trunk/Scribus/scribus/scguardedptr.h
==============================================================================
--- trunk/Scribus/scribus/scguardedptr.h        (original)
+++ trunk/Scribus/scribus/scguardedptr.h        Sun Dec 16 20:47:03 2018
@@ -41,7 +41,7 @@
        bool operator==( const ScGuardedPtr<T> &p ) const { return (T*)(*this) 
== (T*) p;}
        bool operator!= ( const ScGuardedPtr<T>& p ) const { return !( *this == 
p ); }
 
-       bool isNull(void);
+       bool isNull(void) const;
 
        T* operator->() const { return (T*)(data ? data->pointer : 0); }
        T& operator*() const { return *((T*)(data ? data->pointer : 0)); }
@@ -107,7 +107,7 @@
 };
 
 template<typename T>
-bool ScGuardedPtr<T>::isNull(void)
+bool ScGuardedPtr<T>::isNull(void) const
 {
        if (data)
                return (data->pointer == 0);

Modified: trunk/Scribus/scribus/undoobject.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=22794&path=/trunk/Scribus/scribus/undoobject.cpp
==============================================================================
--- trunk/Scribus/scribus/undoobject.cpp        (original)
+++ trunk/Scribus/scribus/undoobject.cpp        Sun Dec 16 20:47:03 2018
@@ -66,7 +66,7 @@
        return m_id;
 }
 
-QString UndoObject::getUName()
+QString UndoObject::getUName() const
 {
        return m_uname; 
 }
@@ -76,7 +76,7 @@
        m_uname = newUName;
 }
 
-QPixmap* UndoObject::getUPixmap()
+QPixmap* UndoObject::getUPixmap() const
 {
        return m_upixmap;
 }
@@ -86,7 +86,14 @@
        m_upixmap = newUPixmap;
 }
 
-const ScGuardedPtr<UndoObject>& UndoObject::undoObjectPtr()
+const ScGuardedPtr<UndoObject>& UndoObject::undoObjectPtr() const
 {
        return m_objectPtr;
 }
+
+int UndoObject::undoStateCount() const
+{
+       if (m_objectPtr.refCount() > 1)
+               return m_objectPtr.refCount() - 1;
+       return 0;
+}

Modified: trunk/Scribus/scribus/undoobject.h
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=22794&path=/trunk/Scribus/scribus/undoobject.h
==============================================================================
--- trunk/Scribus/scribus/undoobject.h  (original)
+++ trunk/Scribus/scribus/undoobject.h  Sun Dec 16 20:47:03 2018
@@ -78,7 +78,7 @@
         * @brief Returns the name of the UndoObject.
         * @return the name of the UndoObject
         */
-       virtual QString getUName();
+       virtual QString getUName() const;
 
        /**
         * @brief Set the name of the UndoObject
@@ -90,7 +90,7 @@
         * @brief Returns the pixmap connected to this object.
         * @return pixmap connected to this object
         */
-       virtual QPixmap* getUPixmap();
+       virtual QPixmap* getUPixmap() const;
 
        /**
         * @brief Set the pixmap for this object.
@@ -107,7 +107,12 @@
        /**
         * @brief Returns a guarded pointer
         */
-       const ScGuardedPtr<UndoObject>& undoObjectPtr();
+       const ScGuardedPtr<UndoObject>& undoObjectPtr() const;
+
+       /**
+        * @brief Check if current object is owned by some undo state
+        */
+       int undoStateCount() const;
 
        /**
         * @brief Method used when an undo/redo is requested.
@@ -119,6 +124,7 @@
         * @param isUndo If true undo is wanted else if false redo.
         */
        virtual void restore(UndoState* state, bool isUndo) = 0;
+
 private:
        /** @brief id number to be used with the next UndoObject */
        static ulong m_nextId;


_______________________________________________
scribus-commit mailing list
[email protected]
http://lists.scribus.net/mailman/listinfo/scribus-commit

Reply via email to