[Digikam-devel] [Bug 152424] Workflow organizing : use Color Label Tags over icon view items

Gilles Caulier caulier.gilles at gmail.com
Tue Feb 1 08:43:42 GMT 2011


https://bugs.kde.org/show_bug.cgi?id=152424





--- Comment #49 from Gilles Caulier <caulier gilles gmail com>  2011-02-01 09:43:41 ---
SVN commit 1218200 by cgilles:

TagsCache now create and manage list of ColorLabel tags. Add a new method to
get tagID associate to a Color Label ID.


 M  +29 -1     tagscache.cpp
 M  +16 -5     tagscache.h


--- branches/extragear/graphics/digikam/core/libs/database/tagscache.cpp
#1218199:1218200
@@ -6,7 +6,8 @@
 * Date        : 2010-04-02
 * Description : Cache for Tag information
 *
- * Copyright (C) 2010 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
+ * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot
de>
+ * Copyright (C) 2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General
@@ -29,6 +30,7 @@
 #include <QReadWriteLock>
 #include <QReadLocker>
 #include <QWriteLocker>
+#include <QMap>

 // KDE includes

@@ -77,6 +79,7 @@
    bool                     needUpdateHash;
    bool                     needUpdateProperties;
    bool                     changingDB;
+
    QReadWriteLock           lock;
    QList<TagShortInfo>      infos;
    QMultiHash<QString, int> nameHash;
@@ -84,6 +87,7 @@
    QList<TagProperty>       tagProperties;
    QHash<QString, QList<int> > tagsWithProperty;
    QSet<int>                internalTags;
+    QMap<ColorLabel, int>       colorLabelsTags;              // Map between
color Id and tag label Id created in DB.

    void checkInfos()
    {
@@ -246,9 +250,25 @@
            this, SLOT(slotTagChanged(const TagChangeset&)),
            Qt::DirectConnection);

+    registerColorLabelTagsToDb();
+
    d->initialized = true;
 }

+void TagsCache::registerColorLabelTagsToDb()
+{
+    d->colorLabelsTags.insert(NoneLabel,   
getOrCreateInternalTag(InternalTagName::colorLabelNone()));
+    d->colorLabelsTags.insert(RedLabel,    
getOrCreateInternalTag(InternalTagName::colorLabelRed()));
+    d->colorLabelsTags.insert(OrangeLabel, 
getOrCreateInternalTag(InternalTagName::colorLabelOrange()));
+    d->colorLabelsTags.insert(YellowLabel, 
getOrCreateInternalTag(InternalTagName::colorLabelYellow()));
+    d->colorLabelsTags.insert(GreenLabel,  
getOrCreateInternalTag(InternalTagName::colorLabelGreen()));
+    d->colorLabelsTags.insert(BlueLabel,   
getOrCreateInternalTag(InternalTagName::colorLabelBlue()));
+    d->colorLabelsTags.insert(MagentaLabel,
getOrCreateInternalTag(InternalTagName::colorLabelMagenta()));
+    d->colorLabelsTags.insert(GrayLabel,   
getOrCreateInternalTag(InternalTagName::colorLabelGray()));
+    d->colorLabelsTags.insert(BlackLabel,  
getOrCreateInternalTag(InternalTagName::colorLabelBlack()));
+    d->colorLabelsTags.insert(WhiteLabel,  
getOrCreateInternalTag(InternalTagName::colorLabelWhite()));
+}
+
 void TagsCache::invalidate()
 {
    d->needUpdateInfos      = true;
@@ -829,4 +849,12 @@
    }
 }

+int TagsCache::getTagForColorLabel(ColorLabel label)
+{
+    if (label < NoneLabel || label > WhiteLabel)
+        return 0;
+
+    return d->colorLabelsTags[label];
+}
+
 } // namespace Digikam
--- branches/extragear/graphics/digikam/core/libs/database/tagscache.h
#1218199:1218200
@@ -6,7 +6,8 @@
 * Date        : 2010-04-02
 * Description : Cache for Tag information
 *
- * Copyright (C) 2010 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
+ * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot
de>
+ * Copyright (C) 2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General
@@ -28,6 +29,7 @@

 #include "databasechangesets.h"
 #include "digikam_export.h"
+#include "globals.h"

 namespace Digikam
 {
@@ -186,6 +188,12 @@
     */
    int getOrCreateInternalTag(const QString& tagName);

+    /**
+     * Return internal tags ID corresponding of color label id. see ColorLabel
values from globals.h.
+     * Return 0 if not it's found.
+     */
+    int getTagForColorLabel(ColorLabel label);
+
    static QLatin1String tagPathOfDigikamInternalTags(LeadingSlashPolicy
slashPolicy = IncludeLeadingSlash);
    static QLatin1String propertyNameDigikamInternalTag();
    static QLatin1String propertyNameExcludedFromWriting();
@@ -205,15 +213,18 @@

 private:

-    friend class DatabaseAccess;
-    friend class TagsCacheCreator;
-    friend class ChangingDB;
-
    TagsCache();
    ~TagsCache();
    void initialize();
    void invalidate();
+    void registerColorLabelTagsToDb();

+private:
+
+    friend class DatabaseAccess;
+    friend class TagsCacheCreator;
+    friend class ChangingDB;
+
    class TagsCachePriv;
    TagsCachePriv* const d;
 };

-- 
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the Digikam-devel mailing list