KDirWatch: request for a small change into the API

Flavio Castelli micron at bglug.it
Fri Jul 27 12:51:36 BST 2007


Hi, talking on irc with Andreas we thought to perform a small clean on 
KDirWatch::addEntry method.

This is the actual method:
	addDir (const QString &path, bool watchFiles=false, bool recursive=false)

We thought to add a new enum to KDirWatch and substitute the booleans with a 
simple flag. This would be a good choice for ABI maintenance.

As you will already have noticed, these modifications would break both API and 
ABI. Since kdelibs is in API freeze, I'm asking the permission to commit 
these small changes next monday (30th July).

Apps using KDirWatch won't be hurt since the "watchFiles" and "recursive" 
options aren't used because they're not implemented (btw, I've just done it).

Let me know what I have to do.

Cheers
	Flavio

Index: kdirwatch.h
===================================================================
--- kdirwatch.h	(revision 692764)
+++ kdirwatch.h	(working copy)
@@ -67,6 +67,13 @@
   Q_OBJECT
 
   public:
+
+   enum Action { DoNothing = -1,
+                 Recursive =  0x001,
+                 WatchFiles = 0x002
+   };
+   Q_DECLARE_FLAGS(Actions, Action)
+   
    /**
     * Constructor.
     *
@@ -97,8 +104,7 @@
     * @param watchFiles if true, the KDirWatch will also watch files - NOT 
IMPLEMENTED YET
     * @param recursive if true, all sub directories are also watched - NOT 
IMPLEMENTED YET
     */
-   void addDir(const QString& path,
-	       bool watchFiles = false, bool recursive = false);
+   void addDir(const QString& path, Actions actions = DoNothing);
 
    /**
     * Adds a file to be watched.
Index: kdirwatch.cpp
===================================================================
--- kdirwatch.cpp	(revision 692764)
+++ kdirwatch.cpp	(working copy)
@@ -505,7 +505,7 @@
  * this entry needs another entry to watch himself (when notExistent).
  */
 void KDirWatchPrivate::addEntry(KDirWatch* instance, const QString& _path,
-				Entry* sub_entry, bool isDir)
+                       Entry* sub_entry, bool isDir, KDirWatch::Actions 
actions)
 {
   QString path = _path;
   if (path.startsWith("/dev/") || (path == "/dev"))
@@ -1270,13 +1270,9 @@
 
 
 // TODO: add watchFiles/recursive support
-void KDirWatch::addDir( const QString& _path,
-			bool watchFiles, bool recursive)
+void KDirWatch::addDir( const QString& _path, Actions actions)
 {
-  if (watchFiles || recursive) {
-    kDebug(7001) << "addDir - recursive/watchFiles not supported yet in KDE 
3.x" << endl;
-  }
-  if (d) d->addEntry(this, _path, 0, true);
+  if (d) d->addEntry(this, _path, 0, true, actions);
 }
 
 void KDirWatch::addFile( const QString& _path )
Index: kdirwatch_p.h
===================================================================
--- kdirwatch_p.h	(revision 692764)
+++ kdirwatch_p.h	(working copy)
@@ -115,7 +115,8 @@
 
   void resetList (KDirWatch*,bool);
   void useFreq(Entry* e, int newFreq);
-  void addEntry(KDirWatch*,const QString&, Entry*, bool);
+  void addEntry(KDirWatch* instance,const QString& _path, Entry* sub_entry,
+                bool isDir, KDirWatch::Actions actions = 
KDirWatch::DoNothing);
   void removeEntry(KDirWatch*,const QString&, Entry*);
   bool stopEntryScan(KDirWatch*, Entry*);
   bool restartEntryScan(KDirWatch*, Entry*, bool );


Cheers
	Flavio

-- 
|§ micron<- ICQ #118796665
|§ GPG Key:
|§  ~ Keyserver: pgp.mit.edu
|§  ~ KeyID: 6D632BED

~ "Progress is merely a realisation of utopias" ~




More information about the kde-core-devel mailing list