KDE/kdevplatform

Andreas Pakulat apaku at gmx.de
Sat Sep 29 23:19:14 UTC 2007


SVN commit 718893 by apaku:

A real class for the status information is needed as QMap<KUrl,VcsState>
doesn't work with QVariant and thus with signals.

This new class is now just a container for a url and a state, but its possible
to use new state's by an extendedState-API.

CC'ing kdevelop list for API review

CCMAIL:kdevelop-devel at kdevelop.org


 M  +6 -6      plugins/subversion/svnkjobbase.cpp  
 M  +64 -0     vcs/vcshelpers.cpp  
 M  +36 -10    vcs/vcshelpers.h  


--- trunk/KDE/kdevplatform/plugins/subversion/svnkjobbase.cpp #718892:718893
@@ -40,25 +40,25 @@
 
         foreach( SvnStatusHolder _holder, holderList ){
 
-            int stat = KDevelop::ItemUnknown;
+            int stat = KDevelop::VcsStatusInfo::ItemUnknown;
             if( _holder.textStatus == svn_wc_status_normal &&
                 _holder.propStatus == svn_wc_status_normal){
 
-                stat = KDevelop::ItemUpToDate;
+                stat = KDevelop::VcsStatusInfo::ItemUpToDate;
             }
             else if( _holder.textStatus == svn_wc_status_added ){
-                stat = KDevelop::ItemAdded;
+                stat = KDevelop::VcsStatusInfo::ItemAdded;
             }
             else if( _holder.textStatus == svn_wc_status_modified ||
                      _holder.propStatus == svn_wc_status_modified ){
-                stat = KDevelop::ItemModified;
+                stat = KDevelop::VcsStatusInfo::ItemModified;
             }
             else if( _holder.textStatus == svn_wc_status_deleted ){
-                stat = KDevelop::ItemDeleted;
+                stat = KDevelop::VcsStatusInfo::ItemDeleted;
             }
             else if( _holder.textStatus == svn_wc_status_conflicted ||
                      _holder.propStatus == svn_wc_status_conflicted ){
-                stat = KDevelop::ItemHasConflicts;
+                stat = KDevelop::VcsStatusInfo::ItemHasConflicts;
             }
 
             QVariant statVar( stat );
--- trunk/KDE/kdevplatform/vcs/vcshelpers.cpp #718892:718893
@@ -28,6 +28,70 @@
 namespace KDevelop
 {
 
+class VcsStatusInfoPrivate
+{
+public:
+    int state;
+    KUrl url;
+};
+
+VcsStatusInfo::VcsStatusInfo()
+    : d( new VcsStatusInfoPrivate)
+{
+    d->state = VcsStatusInfo::ItemUnknown;
+}
+
+VcsStatusInfo::~VcsStatusInfo()
+{
+    delete d;
+}
+
+VcsStatusInfo::VcsStatusInfo( const VcsStatusInfo& rhs )
+    : d(new VcsStatusInfoPrivate)
+{
+    d->state = rhs.d->state;
+    d->url = rhs.d->url;
+}
+
+VcsStatusInfo& VcsStatusInfo::operator=( const VcsStatusInfo& rhs)
+{
+    if(this == &rhs)
+        return *this;
+    d->state = rhs.d->state;
+    d->url = rhs.d->url;
+    return *this;
+}
+
+void VcsStatusInfo::setUrl( const KUrl& url )
+{
+    d->url = url;
+}
+
+void VcsStatusInfo::setExtendedState( int newstate )
+{
+    d->state = newstate;
+}
+
+void VcsStatusInfo::setState( VcsStatusInfo::State state )
+{
+    d->state = state;
+}
+
+int VcsStatusInfo::extendedState() const
+{
+    return d->state;
+}
+
+KUrl VcsStatusInfo::url() const
+{
+    return d->url;
+}
+
+VcsStatusInfo::State VcsStatusInfo::state() const
+{
+    return VcsStatusInfo::State(d->state);
+}
+
 class VcsMappingPrivate
 {
     public:
--- trunk/KDE/kdevplatform/vcs/vcshelpers.h #718892:718893
@@ -23,6 +23,9 @@
 #define VCSHELPERS_H
 
 #include <QtCore/QVariant>
+
+#include <kurl.h>
+
 #include <vcsexport.h>
 
 class QString;
@@ -31,19 +34,41 @@
 namespace KDevelop
 {
 
-/**
- * Status of a local file
- */
-enum VcsState
+class VcsStatusInfo
 {
-    ItemUnknown             /**<No VCS information about a file is known (or file is not under VCS control).*/,
-    ItemUpToDate        /**<Item was updated or it is already at up to date version.*/,
-    ItemAdded           /**<Item was added to the repository but not committed.*/,
-    ItemModified        /**<Item was modified locally.*/,
-    ItemDeleted         /**<Item is scheduled to be deleted. */,
-    ItemHasConflicts    /**<Local version has conflicts that need to be resolved before commit.*/
+public:
+    /**
+     * Status of a local file
+     */
+    enum State
+    {
+        ItemUnknown      = 0   /**<No VCS information about a file is known (or file is not under VCS control).*/,
+        ItemUpToDate     = 1   /**<Item was updated or it is already at up to date version.*/,
+        ItemAdded        = 2   /**<Item was added to the repository but not committed.*/,
+        ItemModified     = 3   /**<Item was modified locally.*/,
+        ItemDeleted      = 4   /**<Item is scheduled to be deleted. */,
+        ItemHasConflicts = 5   /**<Local version has conflicts that need to be resolved before commit.*/,
+	ItemUserState    = 1000 /**special states for individual vcs implementations should use this as base.*/
+    };
+
+    VcsStatusInfo();
+    virtual ~VcsStatusInfo();
+    VcsStatusInfo(const VcsStatusInfo&);
+
+    KUrl url() const;
+    void setUrl( const KUrl& );
+
+    VcsStatusInfo::State state() const;
+    void setState( VcsStatusInfo::State ); 
+
+    int extendedState() const;
+    void setExtendedState( int ); 
+    VcsStatusInfo& operator=( const VcsStatusInfo& rhs);
+private:
+    class VcsStatusInfoPrivate* d;
 };
 
+
 /**
  * Small container class that has a mapping of
  * repository-location -> local location including a recursion flag
@@ -79,6 +104,7 @@
 }
 
 Q_DECLARE_METATYPE( KDevelop::VcsMapping )
+Q_DECLARE_METATYPE( KDevelop::VcsStatusInfo )
 
 #endif
 




More information about the KDevelop-devel mailing list