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

List:       kde-commits
Subject:    [digikam/frameworks] libs/album: Support simple methods to seach album by type and id (not global id
From:       Marcel Wiesweg <marcel.wiesweg () gmx ! de>
Date:       2015-09-11 16:48:53
Message-ID: E1ZaRVN-0003pi-L2 () scm ! kde ! org
[Download RAW message or body]

Git commit db9ca6d49536ce4ff512ea8ec35b3e918dcbd29c by Marcel Wiesweg.
Committed on 11/09/2015 at 16:43.
Pushed by mwiesweg into branch 'frameworks'.

Support simple methods to seach album by type and id (not global id)

M  +11   -6    libs/album/album.cpp
M  +8    -0    libs/album/album.h
M  +5    -0    libs/album/albummanager.cpp
M  +6    -0    libs/album/albummanager.h

http://commits.kde.org/digikam/db9ca6d49536ce4ff512ea8ec35b3e918dcbd29c

diff --git a/libs/album/album.cpp b/libs/album/album.cpp
index 9373b61..eb27d4c 100644
--- a/libs/album/album.cpp
+++ b/libs/album/album.cpp
@@ -226,23 +226,28 @@ void Album::clear()
 =

 int Album::globalID() const
 {
-    switch (m_type)
+    return globalID(m_type, m_id);
+}
+
+int Album::globalID(Type type, int id)
+{
+    switch (type)
     {
         // Use the upper bits to create unique ids.
         case (PHYSICAL):
-            return m_id;
+            return id;
 =

         case (TAG):
-            return m_id | (1 << 28);
+            return id | (1 << 28);
 =

         case (DATE):
-            return m_id | (1 << 29);
+            return id | (1 << 29);
 =

         case (SEARCH):
-            return m_id | (1 << 30);
+            return id | (1 << 30);
 =

         case (FACE):
-            return m_id | (1 << 31);
+            return id | (1 << 31);
 =

         default:
             qCDebug(DIGIKAM_GENERAL_LOG) << "Unknown album type";
diff --git a/libs/album/album.h b/libs/album/album.h
index 413c988..7494545 100644
--- a/libs/album/album.h
+++ b/libs/album/album.h
@@ -242,6 +242,14 @@ public:
      */
     void setUsedByLabelsTree(bool isUsed);
 =

+    /**
+     * @brief Produces the global id
+     * @param type The type of the album
+     * @param id the (type-specific) id of the album
+     * @return the global id
+     */
+    static int globalID(Type type, int id);
+
 protected:
 =

     /**
diff --git a/libs/album/albummanager.cpp b/libs/album/albummanager.cpp
index 5642a7e..ac38328 100644
--- a/libs/album/albummanager.cpp
+++ b/libs/album/albummanager.cpp
@@ -2028,6 +2028,11 @@ Album* AlbumManager::findAlbum(int gid) const
     return d->allAlbumsIdHash.value(gid);
 }
 =

+Album* AlbumManager::findAlbum(Album::Type type, int id) const
+{
+    return findAlbum(Album::globalID(type, id));
+}
+
 TAlbum* AlbumManager::findTAlbum(const QString& tagPath) const
 {
     // handle gracefully with or without leading slash
diff --git a/libs/album/albummanager.h b/libs/album/albummanager.h
index ce2d55b..4f25118 100644
--- a/libs/album/albummanager.h
+++ b/libs/album/albummanager.h
@@ -240,6 +240,12 @@ public:
     Album*    findAlbum(int gid) const;
 =

     /**
+     * @return a Album with the given type and id
+     * @param id the id for the album (not the global id)
+     */
+    Album*    findAlbum(Album::Type type, int id) const;
+
+    /**
      * @return a TAlbum with given tag path, or 0 if not found
      * @param tagPath the tag path ("People/Friend/John")
      */

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

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