[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kio/bookmarks
From:       Daniel Teske <teske () squorn ! de>
Date:       2005-05-31 22:11:56
Message-ID: 1117577516.630697.8723.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 420377 by teske:

Add the (static) methods
int KBookmark::depth( const QString & address )
QString KBookmark::commonParent( QString A, QString B)



 M  +14 -0     kbookmark.cc  
 M  +15 -0     kbookmark.h  


--- trunk/KDE/kdelibs/kio/bookmarks/kbookmark.cc #420376:420377
@@ -357,6 +357,20 @@
     return grp.first();
 }
 
+QString KBookmark::commonParent(QString A, QString B)
+{
+    while(depth(A) > depth(B))
+        A = parentAddress(A);
+    while(depth(B) > depth(A))
+        B = parentAddress(B);
+    while(A != B)
+    {
+        A = parentAddress(A);
+        B = parentAddress(B);
+    }
+    return A;
+}
+
 static QDomNode cd_or_create(QDomNode node, QString name)
 {
     QDomNode subnode = node.namedItem(name);
--- trunk/KDE/kdelibs/kio/bookmarks/kbookmark.h #420376:420377
@@ -156,6 +156,21 @@
     { return parentAddress(address) + '/' + QString::number(positionInParent(address)+1); }
 
     /**
+     * @return depth of the address, depth of root is 0
+     * This doesn't check whether the adress actually exists
+     * @since 3.5
+     */
+    static int depth( const QString & address )
+    { return address.contains('/'); }
+
+    /**
+     * @return the common parent of both addresses which 
+     * has the greatest depth
+     * @since 3.5
+     */
+     static QString commonParent(QString A, QString B);
+
+    /**
      * Get the value of a specific metadata item.
      * @param key Name of the metadata item
      * @return Value of the metadata item. QString::null is returned in case
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic