[niepce] Import the Flag from XMP files, from the Niepce namespace. Don't draw the flags in the filmstrip.



commit 20405ca02f33bdd318e42bf355b5036477b08f29
Author: Hub Figuiere <hub figuiere net>
Date:   Sun Nov 6 07:28:52 2011 -0800

    Import the Flag from XMP files, from the Niepce namespace.
    Don't draw the flags in the filmstrip.

 doc/xmp.txt                           |    3 +++
 src/engine/db/libmetadata.cpp         |    5 +++++
 src/engine/db/library.cpp             |   10 ++++++----
 src/fwk/utils/exempi.cpp              |   11 +++++++++++
 src/fwk/utils/exempi.hpp              |    1 +
 src/niepce/ui/librarycellrenderer.hpp |    2 +-
 src/niepce/ui/thumbstripview.cpp      |    1 +
 7 files changed, 28 insertions(+), 5 deletions(-)
---
diff --git a/doc/xmp.txt b/doc/xmp.txt
index 621ae17..23c4f91 100644
--- a/doc/xmp.txt
+++ b/doc/xmp.txt
@@ -9,4 +9,7 @@ niepce::NIEPCE_XMP_NS_PREFIX = "niepce";
 
 This namespace is to store metadata spefic to Niepce Digital.
 
+Values in the "niepce" namespace:
 
+Flag   	  : int (-1, 0, 1) # whether the image is flagged or not. 
+                           # -1 = reject. 1 = pick, 0 = no flag.
diff --git a/src/engine/db/libmetadata.cpp b/src/engine/db/libmetadata.cpp
index ac31b33..972aecb 100644
--- a/src/engine/db/libmetadata.cpp
+++ b/src/engine/db/libmetadata.cpp
@@ -23,6 +23,7 @@
 
 #include "fwk/base/debug.hpp"
 #include "libmetadata.hpp"
+#include "niepce/xmp.hpp"
 
 namespace eng {
 
@@ -51,6 +52,10 @@ bool xmpPropertyNameFromIndex(int meta, std::string & ns, std::string & property
         ns = NS_TIFF;
         property = "Orientation";
         break;
+    case MAKE_METADATA_IDX(eng::META_NS_NIEPCE, eng::META_NIEPCE_FLAG):
+        ns = niepce::NIEPCE_XMP_NAMESPACE;
+        property = "Flag";
+        break;
     default:
         found = false;
         break;
diff --git a/src/engine/db/library.cpp b/src/engine/db/library.cpp
index 684e166..7850273 100644
--- a/src/engine/db/library.cpp
+++ b/src/engine/db/library.cpp
@@ -271,7 +271,7 @@ int Library::addFile(int folder_id, const std::string & file, bool manage)
     DBG_ASSERT(!manage, "manage not supported");
     DBG_ASSERT(folder_id != -1, "invalid folder ID");
     try {
-        int32_t rating, label_id, orientation;
+        int32_t rating, label_id, orientation, flag;
         std::string label;  
         fwk::MimeType mime = fwk::MimeType(file);
         eng::LibFile::FileType file_type = eng::LibFile::mimetype_to_filetype(mime);
@@ -280,6 +280,7 @@ int Library::addFile(int folder_id, const std::string & file, bool manage)
         orientation = meta.orientation();
         rating = meta.rating();
         label = meta.label();
+        flag = meta.flag();
         time_t creation_date = meta.creation_date();
         if(creation_date == -1) {
             creation_date = 0;
@@ -292,17 +293,18 @@ int Library::addFile(int folder_id, const std::string & file, bool manage)
         SQLStatement sql(boost::format("INSERT INTO files ("
                                        " main_file, name, parent_id, "
                                        " import_date, mod_date, "
-                                       " orientation, file_date, rating, label, file_type,"
-                                       " xmp) "
+                                       " orientation, file_date, rating, label, "
+                                       " file_type, flag, xmp) "
                                        " VALUES ("
                                        " '%1%', '%2%', '%3%', "
                                        " '%4%', '%4%',"
                                        " '%5%', '%6%', '%7%', '%8%', '%9%',"
+                                       " '%10%',"
                                        " ?1);") 
                          % fs_file_id % fwk::path_basename(file) % folder_id
                          % time(NULL)
                          % orientation % creation_date % rating
-                         % label_id % file_type);
+                         % label_id % file_type % flag);
         std::string buf = meta.serialize_inline();
         sql.bind(1, buf);
         if(m_dbdrv->execute_statement(sql)) {
diff --git a/src/fwk/utils/exempi.cpp b/src/fwk/utils/exempi.cpp
index 202da18..6783d2b 100644
--- a/src/fwk/utils/exempi.cpp
+++ b/src/fwk/utils/exempi.cpp
@@ -30,6 +30,7 @@
 #include <exempi/xmpconsts.h>
 
 #include "fwk/base/debug.hpp"
+#include "niepce/xmp.hpp"
 #include "exempi.hpp"
 #include "pathutils.hpp"
 
@@ -190,6 +191,16 @@ int32_t XmpMeta::rating() const
     return _rating;
 }
 
+int32_t XmpMeta::flag() const
+{
+    int32_t _flag = 0;
+    if(!xmp_get_property_int32(m_xmp, niepce::NIEPCE_XMP_NAMESPACE, "Flag", 
+                               &_flag, NULL)) {
+        ERR_OUT("get \"Flag\" property failed: %d", xmp_get_error());
+    }
+    return _flag;
+}
+
 
 time_t  XmpMeta::creation_date() const
 {
diff --git a/src/fwk/utils/exempi.hpp b/src/fwk/utils/exempi.hpp
index 4e75445..80477b7 100644
--- a/src/fwk/utils/exempi.hpp
+++ b/src/fwk/utils/exempi.hpp
@@ -145,6 +145,7 @@ public:
     std::string label() const;
     /** return the rating, -1 is not found (not set) */
     int32_t rating() const;
+    int32_t flag() const;
     time_t  creation_date() const;
     std::string creation_date_str() const;
     const std::vector< std::string > & keywords() const;
diff --git a/src/niepce/ui/librarycellrenderer.hpp b/src/niepce/ui/librarycellrenderer.hpp
index 99f040d..ae9126d 100644
--- a/src/niepce/ui/librarycellrenderer.hpp
+++ b/src/niepce/ui/librarycellrenderer.hpp
@@ -74,7 +74,7 @@ public:
     void set_drawlabel(bool val)
         { m_drawlabel = val; }
     void set_drawflag(bool val)
-        { m_drawlabel = val; }
+        { m_drawflag = val; }
 
     Glib::PropertyProxy_ReadOnly<eng::LibFile::Ptr> property_libfile() const;
     Glib::PropertyProxy<eng::LibFile::Ptr>          property_libfile();
diff --git a/src/niepce/ui/thumbstripview.cpp b/src/niepce/ui/thumbstripview.cpp
index 12504b4..a2f3d44 100644
--- a/src/niepce/ui/thumbstripview.cpp
+++ b/src/niepce/ui/thumbstripview.cpp
@@ -72,6 +72,7 @@ ThumbStripCell::ThumbStripCell()
     set_drawemblem(false);
     set_drawrating(false);
     set_drawlabel(false);
+    set_drawflag(false);
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]