From e4919de8b120ee77e26d8d79febe3ac40666b285 Mon Sep 17 00:00:00 2001 From: Santanu Sinha
Date: Thu, 21 May 2009 16:00:56 +0530 Subject: [PATCH 4/4] Support for Date Wise Photo count generation A new class DatePhotoInfo was added. A list of this type of objects is returned by the Engine if required. The query canbe filtered using the paramters of this function. --- src/application/engine.cpp | 8 +++++ src/application/engine.h | 4 ++ src/attribute/Makefile.am | 2 + src/attribute/date-photo-info.cpp | 53 ++++++++++++++++++++++++++++++ src/attribute/date-photo-info.h | 41 +++++++++++++++++++++++ src/common/types.h | 3 ++ src/database/database.cpp | 64 +++++++++++++++++++++++++++++++++++++ src/database/database.h | 45 ++++++++++++++----------- 8 files changed, 200 insertions(+), 20 deletions(-) create mode 100644 src/attribute/date-photo-info.cpp create mode 100644 src/attribute/date-photo-info.h diff --git a/src/application/engine.cpp b/src/application/engine.cpp index 61419d3..4773c01 100644 --- a/src/application/engine.cpp +++ b/src/application/engine.cpp @@ -21,6 +21,7 @@ #include "config.h" #endif // HAVE_CONFIG_H +#include "date-photo-info.h" #include "engine.h" #include "i-photo-destination.h" #include "i-photo-source.h" @@ -340,6 +341,13 @@ Engine::apply_tag_to_photos( PhotoList &photos, const TagPtr &tag ) return; } +DatePhotoInfoList +Engine::get_dates_with_picture_count(gint year, gint month, gint day) +{ + return database_.get_dates_with_picture_count( + year, month, day, observer_ ); +} + Glib::Dispatcher & Engine::photo_import_begin() throw() { diff --git a/src/application/engine.h b/src/application/engine.h index 14917b0..946f839 100644 --- a/src/application/engine.h +++ b/src/application/engine.h @@ -119,6 +119,10 @@ class Engine : void apply_tag_to_photos( PhotoList &photos, const TagPtr &tag ); + + DatePhotoInfoList + get_dates_with_picture_count( + gint year = -1, gint month = -1, gint day = -1); Glib::Dispatcher & photo_import_begin() throw(); diff --git a/src/attribute/Makefile.am b/src/attribute/Makefile.am index 3d4fc98..b2fcf1a 100644 --- a/src/attribute/Makefile.am +++ b/src/attribute/Makefile.am @@ -5,6 +5,8 @@ libattribute_la_SOURCES = \ basic-exif-view-model-column-record.h \ basic-exif-view.cpp \ basic-exif-view.h \ + date-photo-info.cpp \ + date-photo-info.h \ exif-data-key.cpp \ exif-data-key.h \ exif-data.cpp \ diff --git a/src/attribute/date-photo-info.cpp b/src/attribute/date-photo-info.cpp new file mode 100644 index 0000000..531ac23 --- /dev/null +++ b/src/attribute/date-photo-info.cpp @@ -0,0 +1,53 @@ +#include "date-photo-info.h" + +namespace Solang +{ + +DatePhotoInfo::DatePhotoInfo() + :date_(), + count_(0) +{ +} + +DatePhotoInfo::DatePhotoInfo( + const ModificationDate &date, gint count ) + :date_( date ), + count_( count ) +{ +} + +DatePhotoInfo::DatePhotoInfo( const DatePhotoInfo &rhs ) + :date_( rhs.date_ ), + count_( rhs.count_ ) +{ +} + + +DatePhotoInfo::~DatePhotoInfo() +{ +} + +DatePhotoInfo & +DatePhotoInfo::operator =( const DatePhotoInfo &rhs ) +{ + if( this != &rhs ) + { + date_ = rhs.date_; + count_ = rhs.count_; + } + return *this; +} + +void +DatePhotoInfo::set_date( const ModificationDate &date) throw() +{ + date_ = date; +} + +void +DatePhotoInfo::set_count(gint count) throw() +{ + count_ = count; +} + +} diff --git a/src/attribute/date-photo-info.h b/src/attribute/date-photo-info.h new file mode 100644 index 0000000..3c6110a --- /dev/null +++ b/src/attribute/date-photo-info.h @@ -0,0 +1,41 @@ +#ifndef SOLANG_DATE_PHOTO_INFO_H +#define SOLANG_DATE_PHOTO_INFO_H + +#include "modification-date.h" + +namespace Solang +{ + +class DatePhotoInfo +{ + public: + DatePhotoInfo(); + DatePhotoInfo( const ModificationDate &, gint); + DatePhotoInfo( const DatePhotoInfo & ); + ~DatePhotoInfo(); + + DatePhotoInfo & + operator =( const DatePhotoInfo & ); + + inline const ModificationDate & + get_date() const throw(); + + void + set_date( const ModificationDate &) throw(); + + inline gint + get_count() const throw(); + + void + set_count(gint) throw(); + + private: + ModificationDate date_; + gint count_; + +}; + +} //namespace Solang + + +#endif //SOLANG_DATE_PHOTO_INFO_H diff --git a/src/common/types.h b/src/common/types.h index 5750ab4..082a9bd 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -68,6 +68,9 @@ class IPlugin; typedef std::tr1::shared_ptr