From 0f4c7523eac977da4d8c4f61d043576dc9167a29 Mon Sep 17 00:00:00 2001 From: Santanu Sinha Date: Sun, 24 May 2009 15:42:15 +0530 Subject: [PATCH] Date view + Picture dates are now visible in a new view + Dragdrop search can be made using date --- src/application/application.cpp | 5 + src/application/engine.cpp | 17 ++- src/application/engine.h | 12 +- src/attribute/Makefile.am | 6 + src/attribute/date-manager.cpp | 97 ++++++++++ src/attribute/date-manager.h | 78 ++++++++ src/attribute/date-photo-info.h | 14 ++- src/attribute/date-view-model-column-record.cpp | 102 +++++++++++ src/attribute/date-view-model-column-record.h | 77 ++++++++ src/attribute/date-view.cpp | 222 +++++++++++++++++++++++ src/attribute/date-view.h | 67 +++++++ src/attribute/modification-date.cpp | 40 ++++- src/attribute/modification-date.h | 2 - src/attribute/search-criterion-repo.h | 2 - src/common/types.h | 7 + src/database/database.cpp | 63 ++++--- src/database/database.h | 19 ++- src/importer/camera-source.cpp | 2 +- 18 files changed, 788 insertions(+), 44 deletions(-) create mode 100644 src/attribute/date-manager.cpp create mode 100644 src/attribute/date-manager.h create mode 100644 src/attribute/date-view-model-column-record.cpp create mode 100644 src/attribute/date-view-model-column-record.h create mode 100644 src/attribute/date-view.cpp create mode 100644 src/attribute/date-view.h diff --git a/src/application/application.cpp b/src/application/application.cpp index 8f92e06..94e3145 100644 --- a/src/application/application.cpp +++ b/src/application/application.cpp @@ -30,6 +30,7 @@ #include "browser-renderer.h" #include "camera-source.h" #include "console-renderer.h" +#include "date-manager.h" #include "directory-source.h" #include "directory-storage.h" #include "enlarged-renderer.h" @@ -208,6 +209,10 @@ Application::init() throw() // Plugins. + IPluginPtr date_manager(new DateManager()); + plugins_.insert(std::make_pair("date-manager", + date_manager)); + IPluginPtr property_manager(new PropertyManager()); plugins_.insert(std::make_pair("property-manager", property_manager)); diff --git a/src/application/engine.cpp b/src/application/engine.cpp index c993f3e..758830f 100644 --- a/src/application/engine.cpp +++ b/src/application/engine.cpp @@ -343,10 +343,23 @@ Engine::apply_tag_to_photos( PhotoList &photos, const TagPtr &tag ) } DatePhotoInfoList -Engine::get_dates_with_picture_count(gint year, gint month, gint day) +Engine::get_dates_with_picture_count() +{ + return database_.get_dates_with_picture_count( observer_ ); +} + +DatePhotoInfoList +Engine::get_dates_with_picture_count( gint year ) +{ + return database_.get_dates_with_picture_count( + year, observer_ ); +} + +DatePhotoInfoList +Engine::get_dates_with_picture_count( gint year, gint month ) { return database_.get_dates_with_picture_count( - year, month, day, observer_ ); + year, month, observer_ ); } Glib::Dispatcher & diff --git a/src/application/engine.h b/src/application/engine.h index c34756f..9644360 100644 --- a/src/application/engine.h +++ b/src/application/engine.h @@ -121,9 +121,17 @@ class Engine : void apply_tag_to_photos( PhotoList &photos, const TagPtr &tag ); + //Group by year DatePhotoInfoList - get_dates_with_picture_count( - gint year = -1, gint month = -1, gint day = -1); + get_dates_with_picture_count(); + + //Group by year, month + DatePhotoInfoList + get_dates_with_picture_count( gint year ); + + //Group by year, month, day + DatePhotoInfoList + get_dates_with_picture_count( gint year, gint month ); Glib::Dispatcher & photo_import_begin() throw(); diff --git a/src/attribute/Makefile.am b/src/attribute/Makefile.am index 5141abc..709b64b 100644 --- a/src/attribute/Makefile.am +++ b/src/attribute/Makefile.am @@ -5,8 +5,14 @@ libattribute_la_SOURCES = \ basic-exif-view-model-column-record.h \ basic-exif-view.cpp \ basic-exif-view.h \ + date-manager.cpp \ + date-manager.h \ date-photo-info.cpp \ date-photo-info.h \ + date-view-model-column-record.cpp \ + date-view-model-column-record.h \ + date-view.cpp \ + date-view.h \ exif-data-key.cpp \ exif-data-key.h \ exif-data.cpp \ diff --git a/src/attribute/date-manager.cpp b/src/attribute/date-manager.cpp new file mode 100644 index 0000000..e439abd --- /dev/null +++ b/src/attribute/date-manager.cpp @@ -0,0 +1,97 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * Copyright (C) Santanu Sinha 2009 + * + * Solang is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Solang is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "config.h" + +#include "application.h" +#include "date-manager.h" +#include "main-window.h" + +namespace Solang +{ + +static const std::string uiFile + = PACKAGE_DATA_DIR"/"PACKAGE_NAME"/ui/"PACKAGE_NAME"-property-manager.ui"; +DateManager::DateManager() throw() : + Plugin(), + application_(), + actionGroup_(Gtk::ActionGroup::create()), + uiID_( 1 ), + dockItemName_("date-dock-item"), + dockItemTitle_("Picture Taken Date"), + dockItemBehaviour_(GDL_DOCK_ITEM_BEH_NORMAL), + dockItem_(NULL), + vBox_(false, 6), + scrolledWindow_(), + dateView_() +{ + dockItem_ = gdl_dock_item_new_with_stock(dockItemName_.c_str(), + dockItemTitle_.c_str(), + "gtk-properties", + dockItemBehaviour_); + gtk_container_add(GTK_CONTAINER(dockItem_), + GTK_WIDGET(vBox_.gobj())); + + scrolledWindow_.set_policy(Gtk::POLICY_AUTOMATIC, + Gtk::POLICY_AUTOMATIC); + scrolledWindow_.add(dateView_); + + vBox_.pack_start( scrolledWindow_, Gtk::PACK_EXPAND_WIDGET,0 ); + +} + +DateManager::~DateManager() throw() +{ + //g_object_unref(dockItem_); +} + +void +DateManager::init(Application & application) + throw() +{ + application_ = &application; + dateView_.set_application( &application ); + + Engine & engine = application.get_engine(); + engine.photo_import_end().connect( + sigc::mem_fun(*this, + &DateManager::on_photos_changed) ); + + MainWindow & main_window = application.get_main_window(); + main_window.add_dock_object_left(GDL_DOCK_OBJECT(dockItem_)); + dateView_.populate(); + + initialized_.emit(*this); +} + +void +DateManager::final(Application & application) + throw() +{ + finalized_.emit(*this); +} + +void +DateManager::on_photos_changed() throw() +{ + dateView_.populate( ); + + return; +} + +} // namespace Solang diff --git a/src/attribute/date-manager.h b/src/attribute/date-manager.h new file mode 100644 index 0000000..b47b583 --- /dev/null +++ b/src/attribute/date-manager.h @@ -0,0 +1,78 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * Copyright (C) Santanu Sinha 2009 + * + * Solang is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Solang is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef SOLANG_DATE_MANAGER_H +#define SOLANG_DATE_MANAGER_H + +#include + +#include +#include + +#include "plugin.h" +#include "date-view.h" + +namespace Solang +{ + +class DateManager : + public Plugin +{ +public: + DateManager() throw(); + + virtual + ~DateManager() throw(); + + virtual void + init(Application & application) throw(); + + virtual void + final(Application & application) throw(); + + void + on_photos_changed() throw(); + +protected: + + ApplicationPtr application_; + + Glib::RefPtr actionGroup_; + + Gtk::UIManager::ui_merge_id uiID_; + + const std::string dockItemName_; + + const Glib::ustring dockItemTitle_; + + GdlDockItemBehavior dockItemBehaviour_; + + GtkWidget * dockItem_; + + Gtk::VBox vBox_; + + Gtk::ScrolledWindow scrolledWindow_; + + DateView dateView_; + +private: +}; + +} // namespace Solang + +#endif // SOLANG_DATE_MANAGER_H diff --git a/src/attribute/date-photo-info.h b/src/attribute/date-photo-info.h index 3c6110a..1e295a0 100644 --- a/src/attribute/date-photo-info.h +++ b/src/attribute/date-photo-info.h @@ -10,7 +10,7 @@ class DatePhotoInfo { public: DatePhotoInfo(); - DatePhotoInfo( const ModificationDate &, gint); + DatePhotoInfo( const ModificationDate &, gint); DatePhotoInfo( const DatePhotoInfo & ); ~DatePhotoInfo(); @@ -35,6 +35,18 @@ class DatePhotoInfo }; +inline const ModificationDate & +DatePhotoInfo::get_date() const throw() +{ + return date_; +} + +inline gint +DatePhotoInfo::get_count() const throw() +{ + return count_; +} + } //namespace Solang diff --git a/src/attribute/date-view-model-column-record.cpp b/src/attribute/date-view-model-column-record.cpp new file mode 100644 index 0000000..716a1b3 --- /dev/null +++ b/src/attribute/date-view-model-column-record.cpp @@ -0,0 +1,102 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * Copyright (C) 2009 Santanu Sinha + * + * Solang is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Solang is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif // HAVE_CONFIG_H + +#include "date-view-model-column-record.h" + +namespace Solang +{ + +enum +{ + COLUMN_DATE = 0, + COLUMN_ENTRY, + COLUMN_PHOTO_COUNT, + COLUMN_PERCENTAGE, + COLUMN_COUNT +}; + +DateViewModelColumnRecord::DateViewModelColumnRecord() throw() : + Gtk::TreeModelColumnRecord(), + date_(), + entry_(), + photoCount_(), + percentage_() +{ + add(date_); + add(entry_); + add(photoCount_); + add(percentage_); +} + +DateViewModelColumnRecord::~DateViewModelColumnRecord() throw() +{ +} + +const Gtk::TreeModelColumn & +DateViewModelColumnRecord::get_column_date() const throw() +{ + return date_; +} + +gint +DateViewModelColumnRecord::get_column_date_num() const throw() +{ + return COLUMN_DATE; +} + +const Gtk::TreeModelColumn & +DateViewModelColumnRecord::get_column_entry() const throw() +{ + return entry_; +} + +gint +DateViewModelColumnRecord::get_column_entry_num() const throw() +{ + return COLUMN_ENTRY; +} + +const Gtk::TreeModelColumn & +DateViewModelColumnRecord::get_column_photo_count() const throw() +{ + return photoCount_; +} + +gint +DateViewModelColumnRecord::get_column_photo_count_num() const throw() +{ + return COLUMN_PHOTO_COUNT; +} + +const Gtk::TreeModelColumn & +DateViewModelColumnRecord::get_column_percentage() const throw() +{ + return percentage_; +} + +gint +DateViewModelColumnRecord::get_column_percentage_num() const throw() +{ + return COLUMN_PERCENTAGE; +} + +} // namespace Solang diff --git a/src/attribute/date-view-model-column-record.h b/src/attribute/date-view-model-column-record.h new file mode 100644 index 0000000..b1d2f68 --- /dev/null +++ b/src/attribute/date-view-model-column-record.h @@ -0,0 +1,77 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * Copyright (C) 2009 Santanu Sinha + * + * Solang is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Solang is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef SOLANG_DATE_VIEW_MODEL_COLUMN_RECORD_H +#define SOLANG_DATE_VIEW_MODEL_COLUMN_RECORD_H + +#include +#include +#include + +#include "types.h" +#include "modification-date.h" + +namespace Solang +{ + +class DateViewModelColumnRecord : + public Gtk::TreeModelColumnRecord +{ + public: + DateViewModelColumnRecord() throw(); + + virtual + ~DateViewModelColumnRecord() throw(); + + const Gtk::TreeModelColumn & + get_column_date() const throw(); + + gint + get_column_date_num() const throw(); + + const Gtk::TreeModelColumn & + get_column_entry() const throw(); + + gint + get_column_entry_num() const throw(); + + const Gtk::TreeModelColumn & + get_column_photo_count() const throw(); + + gint + get_column_photo_count_num() const throw(); + + const Gtk::TreeModelColumn & + get_column_percentage() const throw(); + + gint + get_column_percentage_num() const throw(); + + protected: + Gtk::TreeModelColumn date_; + Gtk::TreeModelColumn entry_; //Year/Month/Day + Gtk::TreeModelColumn photoCount_; + Gtk::TreeModelColumn percentage_; + + + private: +}; + +} // namespace Solang + +#endif // SOLANG_DATE_VIEW_MODEL_COLUMN_RECORD_H diff --git a/src/attribute/date-view.cpp b/src/attribute/date-view.cpp new file mode 100644 index 0000000..053c1e8 --- /dev/null +++ b/src/attribute/date-view.cpp @@ -0,0 +1,222 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * Copyright (C) 2009 Santanu Sinha + * + * Solang is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Solang is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif // HAVE_CONFIG_H + +#include +#include + +#include "application.h" +#include "date-view.h" +#include "date-photo-info.h" + +namespace Solang +{ + +DateView::DateView() throw() : + Gtk::TreeView(), + application_(), + modelColumnRecord_(), + treeStore_(Gtk::TreeStore::create(modelColumnRecord_)), + percentage_( ) +{ + configure(); +} + +DateView::~DateView() throw() +{ + unset_model(); +} + +void +DateView::configure() throw() +{ + set_model(treeStore_); + + append_column("Entry", + modelColumnRecord_.get_column_entry()); + int col = append_column("Percentage", percentage_ ); + Gtk::TreeViewColumn* pColumn = get_column(col - 1); +#ifdef GLIBMM_PROPERTIES_ENABLED + pColumn->add_attribute(percentage_.property_value(), + modelColumnRecord_.get_column_percentage()); + pColumn->add_attribute(percentage_.property_text(), + modelColumnRecord_.get_column_photo_count()); +#else + pColumn->add_attribute(percentage_, "value", + modelColumnRecord_.get_column_percentage()); + pColumn->add_attribute(percentage_, "text", + modelColumnRecord_.get_column_photo_count()); +#endif + + set_tooltip_column( modelColumnRecord_.get_column_photo_count_num() ); + set_enable_search(true); + // set_fixed_height_mode(true); + set_grid_lines(Gtk::TREE_VIEW_GRID_LINES_NONE); + set_headers_clickable(false); + set_headers_visible(false); + + std::vector targets; + targets.push_back(Gtk::TargetEntry("STRING", + Gtk::TARGET_SAME_APP, 0)); + targets.push_back(Gtk::TargetEntry("UTF8_STRING", + Gtk::TARGET_SAME_APP, 0)); + enable_model_drag_source(targets, + Gdk::MODIFIER_MASK, Gdk::ACTION_COPY); + +} + +void +DateView::populate() throw() +{ + treeStore_->clear(); + + typedef DatePhotoInfoList::const_iterator DPIterator; + + Engine &engine = application_->get_engine(); + DatePhotoInfoList years = engine.get_dates_with_picture_count(); + for( DPIterator year = years.begin(); year != years.end(); year++ ) + { + Gtk::TreeModel::Row yr = *(treeStore_->append()); + + DatePhotoInfo info = (*year); + ModificationDate dateYr = info.get_date(); + yr[ modelColumnRecord_.get_column_date() ] = dateYr; + std::ostringstream sout; + sout<append( + yr.children() )); + + DatePhotoInfo infoM = (*month); + ModificationDate dateM = infoM.get_date(); + double percentage = 100.0 + * (static_cast(infoM.get_count()) + / static_cast( info.get_count())); + mth[ modelColumnRecord_.get_column_date() ] = dateM; + mth[ modelColumnRecord_.get_column_entry() ] + = map_month_to_name( dateM.get_month() ); + mth[ modelColumnRecord_.get_column_percentage() ] + = percentage; + mth[ modelColumnRecord_.get_column_photo_count() ] + = infoM.get_count(); + DatePhotoInfoList days + = engine.get_dates_with_picture_count( + dateM.get_year(), dateM.get_month()); + for( DPIterator day = days.begin(); + day != days.end(); day++ ) + { + + Gtk::TreeModel::Row dy + = *(treeStore_->append(mth.children())); + + DatePhotoInfo infoD = (*day); + ModificationDate dateD = infoD.get_date(); + std::ostringstream sout; + sout<(infoD.get_count()) + / static_cast( infoM.get_count())); + dy[ modelColumnRecord_.get_column_date() ] = dateD; + dy[ modelColumnRecord_.get_column_entry() ] + = sout.str(); + dy[ modelColumnRecord_.get_column_percentage() ] + = percentage; + dy[ modelColumnRecord_.get_column_photo_count() ] + = infoD.get_count(); + } + } + } +} + +void +DateView::on_drag_data_get( + const Glib::RefPtr& context, + Gtk::SelectionData& selection_data, guint info, guint time) +{ + if( !application_ ) + { + return; + } + Glib::RefPtr selected = get_selection(); + if( 0 == selected->count_selected_rows() ) + return; + + Gtk::TreeModel::iterator item = selected->get_selected(); + + Gtk::TreeModel::Row row= (*item); + ModificationDatePtr key( new ModificationDate( + row[modelColumnRecord_.get_column_date()] ) ); + Glib::ustring criteria = key->get_query_criteria(); + application_->set_drag_item( criteria, key ); + selection_data.set_text( criteria ); + + return; + +} + +void +DateView::set_application( ApplicationPtr application ) throw() +{ + application_ = application; +} + +Glib::ustring +DateView::map_month_to_name(gint month) const throw() +{ + switch( month ) + { + case 1: + return "January"; + case 2: + return "February"; + case 3: + return "March"; + case 4: + return "April"; + case 5: + return "May"; + case 6: + return "June"; + case 7: + return "July"; + case 8: + return "August"; + case 9: + return "September"; + case 10: + return "October"; + case 11: + return "November"; + } + return "December"; +} + +} // namespace Solang diff --git a/src/attribute/date-view.h b/src/attribute/date-view.h new file mode 100644 index 0000000..29d471a --- /dev/null +++ b/src/attribute/date-view.h @@ -0,0 +1,67 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ +/* + * Copyright (C) 2009 Santanu Sinha + * + * Solang is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Solang is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef SOLANG_DATE_VIEW_H +#define SOLANG_DATE_VIEW_H + +#include + +#include "date-view-model-column-record.h" +#include "types.h" + +namespace Solang +{ + +class DateView : + public Gtk::TreeView +{ + public: + DateView() throw(); + + ~DateView() throw(); + + void + populate() throw(); + + void + set_application( ApplicationPtr application ) throw(); + + protected: + virtual void on_drag_data_get( + const Glib::RefPtr& context, + Gtk::SelectionData& selection_data, guint info, guint time); + + ApplicationPtr application_; + + DateViewModelColumnRecord modelColumnRecord_; + + TreeStorePtr treeStore_; + + Gtk::CellRendererProgress percentage_; + + private: + void + configure() throw(); + + Glib::ustring + map_month_to_name(gint month) const throw(); +}; + +} // namespace Solang + +#endif // SOLANG_DATE_VIEW_H diff --git a/src/attribute/modification-date.cpp b/src/attribute/modification-date.cpp index 903e022..c8102b4 100644 --- a/src/attribute/modification-date.cpp +++ b/src/attribute/modification-date.cpp @@ -15,10 +15,19 @@ Glib::ustring ModificationDate::get_query_criteria() const throw() { std::ostringstream sout; - sout<<" ( mod_day="< 0 ) + { + sout<<" ( mod_year="< 0 ) + { + sout<<" and mod_month="< 0 ) + { + sout<<" and mod_day="< #include "types.h" diff --git a/src/common/types.h b/src/common/types.h index 58c7de1..57de5c3 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -74,6 +74,10 @@ typedef std::tr1::shared_ptr IPluginPtr; class DatePhotoInfo; typedef std::vector DatePhotoInfoList; +class ModificationDate; +typedef std::tr1::shared_ptr ConstModificationDatePtr; +typedef std::tr1::shared_ptr ModificationDatePtr; + class Photo; typedef std::tr1::shared_ptr ConstPhotoPtr; typedef std::tr1::shared_ptr PhotoPtr; @@ -139,6 +143,9 @@ class SearchCriterionSource; typedef SearchCriterionSource * SearchCriterionSourcePtr; typedef std::vector SearchCriterionSourceList; +typedef Glib::RefPtr ConstTreeStorePtr; +typedef Glib::RefPtr TreeStorePtr; + typedef Glib::RefPtr ConstTreeModelPtr; typedef Glib::RefPtr TreeModelPtr; diff --git a/src/database/database.cpp b/src/database/database.cpp index fa60287..ff1cc66 100644 --- a/src/database/database.cpp +++ b/src/database/database.cpp @@ -255,39 +255,54 @@ PhotoList Database::search( return photos; } +//Group by year DatePhotoInfoList -Database::get_dates_with_picture_count( - gint year, gint month, gint day, - const ProgressObserverPtr &observer) +Database::get_dates_with_picture_count( const ProgressObserverPtr &observer) { Glib::ustring sql - = "select mod_year, mod_month, mod_day, count(*) from photos "; - if( -1 != year ) - { - std::ostringstream sout; - sout<<" and mod_year="< query - = Gnome::Gda::Query::create( gdaDict_ ); - query->set_sql_text( sql ); - Glib::RefPtr model - = Gnome::Gda::DataModelQuery::create( query ); + Glib::RefPtr model + = gdaConnection_->execute_select_command( sql ); gint32 numRows = model->get_n_rows(); observer->set_num_events( numRows ); diff --git a/src/database/database.h b/src/database/database.h index 58f9fb6..62a554c 100644 --- a/src/database/database.h +++ b/src/database/database.h @@ -77,9 +77,24 @@ class Database const PhotoSearchCriteriaList &criterion, const ProgressObserverPtr & observer) throw(Error); + //Group by year DatePhotoInfoList - get_dates_with_picture_count( - gint year, gint month, gint day, + get_dates_with_picture_count( const ProgressObserverPtr &); + + //Group by year, month + DatePhotoInfoList + get_dates_with_picture_count( gint year, + const ProgressObserverPtr &); + + //Group by year, month, day + DatePhotoInfoList + get_dates_with_picture_count( gint year, gint month, + const ProgressObserverPtr &); + + private: + + DatePhotoInfoList + get_dates_with_picture_count( const Glib::ustring &sql, const ProgressObserverPtr &); // TagList getTags(const PhotoPtr &photo) const throw(Error); diff --git a/src/importer/camera-source.cpp b/src/importer/camera-source.cpp index a15fafc..cbc61c8 100644 --- a/src/importer/camera-source.cpp +++ b/src/importer/camera-source.cpp @@ -123,8 +123,8 @@ CameraSource::import(const IStoragePtr & storage, const TagList &tags, { PhotoList files; create_photo_list( files ); - return import(files, storage, tags, db, observer); gpContext_.cleanup(); //So that this can be recreated + return import(files, storage, tags, db, observer); } void -- 1.6.2.1