Version: 0.8.1 (using KDE KDE 3.5.0) Installed from: Ubuntu Packages OS: Linux In the "Album properties" dialogue, there is a button to change the date of the album to the "average" date of the pictures. (For me, usually the given date is off by a month or so.) I would prefer a button to set the album date to that of a selected picture. There was a similar bug 89364 (Change date of album to exif date of first image) FIXED, but it does not seem to work.
> (For me, usually the given date is off by a month or so.) Can you verify that for me? Try with a small set of images, note down the dates and calculate the avarage. If it is not correct, please open a bugreport and mention the dates of the images as an example... For the rest of the report, have you any idea how to implement that in the album properties dialog? Just a button next to avarage 'selected image'?
> open a bugreport and mention the dates of the images as an example... OK. I will do so. > For the rest of the report, have you any idea how to implement that in the album > properties dialog? Just a button next to avarage 'selected image'? Yes, that would be fine. But what if no image is selected? Perhaps we need four buttons: [First] [Last] [Selected] [Average] ?
Created attachment 14585 [details] prposed patch [selected] is difficult, because a selection can contain multiple images, I dont think it is worth the efford to code that. But the [lowest] and [highest] is not very difficult, please apply attached patch and see if it works like expected.
I do not know how to apply the patch (I am using a debian binary). But the proposed solution sounds OK to me.
SVN commit 508790 by toma: Add two other buttons to the property settings of the album. Lowest and Highest date. BUG: 120963 M +20 -0 digikam/albumdb.cpp M +16 -2 digikam/albumdb.h M +48 -8 digikam/albumpropsedit.cpp M +3 -1 digikam/albumpropsedit.h M +2 -0 showfoto/showfoto.cpp --- trunk/extragear/graphics/digikam/digikam/albumdb.cpp #508789:508790 @@ -1074,6 +1074,26 @@ return values[0]; } +QDate AlbumDB::getAlbumLowestDate(int albumID) +{ + QStringList values; + execSql( QString("SELECT MIN(datetime) FROM Images " + "WHERE dirid=%1 GROUP BY dirid") + .arg( albumID ), &values); + QDate itemDate = QDate::fromString( values[0], Qt::ISODate ); + return itemDate; +} + +QDate AlbumDB::getAlbumHighestDate(int albumID) +{ + QStringList values; + execSql( QString("SELECT MAX(datetime) FROM Images " + "WHERE dirid=%1 GROUP BY dirid") + .arg( albumID ), &values); + QDate itemDate = QDate::fromString( values[0], Qt::ISODate ); + return itemDate; +} + QDate AlbumDB::getAlbumAverageDate(int albumID) { QStringList values; --- trunk/extragear/graphics/digikam/digikam/albumdb.h #508789:508790 @@ -453,9 +453,23 @@ QString getAlbumURL(int albumID); /** + * Returns the lowest/oldest date of all images for that album. + * @param albumID the id of the album to calculate + * @return the date. + */ + QDate getAlbumLowestDate(int albumID); + + /** + * Returns the highest/newest date of all images for that album. + * @param albumID the id of the album to calculate + * @return the date. + */ + QDate getAlbumHighestDate(int albumID); + + /** * Returns the average date of all images for that album. - * @param albumID the id of the album to calculate the average in - * @return the average date. + * @param albumID the id of the album to calculate + * @return the date. */ QDate getAlbumAverageDate(int albumID); --- trunk/extragear/graphics/digikam/digikam/albumpropsedit.cpp #508789:508790 @@ -33,6 +33,7 @@ #include <qlistview.h> #include <qframe.h> #include <qheader.h> +#include <qhbox.h> #include <qpushbutton.h> // KDE includes. @@ -134,11 +135,22 @@ topLayout->addWidget( datePicker_, 5, 1 ); dateLabel->setBuddy( datePicker_ ); - QPushButton *avgButton = new QPushButton( - i18n("This is a button which calculates " - "the average date", - "&Average" ), plainPage( ) ); - topLayout->addWidget( avgButton, 6, 1); + QHBox *buttonRow = new QHBox( plainPage( ) ); + QPushButton *dateLowButton = new QPushButton( + i18n("Button to select the date of the first image", + "&Lowest" ), + buttonRow ); + QPushButton *dateAvgButton = new QPushButton( + i18n("This is a button which calculates the average date", + "&Average" ), + buttonRow ); + QPushButton *dateHighButton = new QPushButton( + i18n("Button to select the date of the last image", + "&Highest" ), + buttonRow ); + + + topLayout->addWidget( buttonRow, 6, 1); setTabOrder(titleEdit_, collectionCombo_); setTabOrder(collectionCombo_, commentsEdit_); @@ -179,8 +191,12 @@ connect(titleEdit_, SIGNAL(textChanged(const QString&)), SLOT(slotTitleChanged(const QString&))); - connect(avgButton, SIGNAL( clicked() ), - SLOT( slotAverageButtonClicked())); + connect(dateLowButton, SIGNAL( clicked() ), + SLOT( slotDateLowButtonClicked())); + connect(dateAvgButton, SIGNAL( clicked() ), + SLOT( slotDateAverageButtonClicked())); + connect(dateHighButton, SIGNAL( clicked() ), + SLOT( slotDateHighButtonClicked())); adjustSize(); } @@ -277,11 +293,35 @@ enableButtonOK(!newtitle.isEmpty()); } -void AlbumPropsEdit::slotAverageButtonClicked() +void AlbumPropsEdit::slotDateLowButtonClicked() { setCursor( KCursor::waitCursor() ); AlbumDB* db = AlbumManager::instance()->albumDB(); + QDate avDate = db->getAlbumLowestDate( album_->id() ); + setCursor( KCursor::arrowCursor() ); + + if ( avDate.isValid() ) + datePicker_->setDate( avDate ); +} + +void AlbumPropsEdit::slotDateHighButtonClicked() +{ + setCursor( KCursor::waitCursor() ); + + AlbumDB* db = AlbumManager::instance()->albumDB(); + QDate avDate = db->getAlbumHighestDate( album_->id() ); + setCursor( KCursor::arrowCursor() ); + + if ( avDate.isValid() ) + datePicker_->setDate( avDate ); +} + +void AlbumPropsEdit::slotDateAverageButtonClicked() +{ + setCursor( KCursor::waitCursor() ); + + AlbumDB* db = AlbumManager::instance()->albumDB(); QDate avDate = db->getAlbumAverageDate( album_->id() ); setCursor( KCursor::arrowCursor() ); --- trunk/extragear/graphics/digikam/digikam/albumpropsedit.h #508789:508790 @@ -89,7 +89,9 @@ private slots: void slotTitleChanged(const QString& newtitle); - void slotAverageButtonClicked(); + void slotDateLowButtonClicked(); + void slotDateAverageButtonClicked(); + void slotDateHighButtonClicked(); }; } // namespace Digikam --- trunk/extragear/graphics/digikam/showfoto/showfoto.cpp #508789:508790 @@ -1,10 +1,12 @@ /* ============================================================ * Author: Renchi Raju <renchi@pooh.tam.uiuc.edu> * Gilles Caulier <caulier dot gilles at free.fr> + * Tom Albers <tomalbers@kde.nl> * Date : 2004-11-22 * Description : stand alone digiKam image editor GUI * * Copyright 2004-2005 by Renchi Raju, Gilles Caulier + * Copyright 2005-2006 by Tom Albers * Copyright 2006 by Gilles Caulier * * This program is free software; you can redistribute it
SVN commit 508791 by toma: backport SVN commit 508790 by toma: Add two other buttons to the property settings of the album. Lowest and Highest date. CCBUG: 120963 M +20 -0 albumdb.cpp M +16 -2 albumdb.h M +48 -8 albumpropsedit.cpp M +3 -1 albumpropsedit.h --- branches/stable/extragear/graphics/digikam/digikam/albumdb.cpp #508790:508791 @@ -1060,6 +1060,26 @@ return values[0]; } +QDate AlbumDB::getAlbumLowestDate(int albumID) +{ + QStringList values; + execSql( QString("SELECT MIN(datetime) FROM Images " + "WHERE dirid=%1 GROUP BY dirid") + .arg( albumID ), &values); + QDate itemDate = QDate::fromString( values[0], Qt::ISODate ); + return itemDate; +} + +QDate AlbumDB::getAlbumHighestDate(int albumID) +{ + QStringList values; + execSql( QString("SELECT MAX(datetime) FROM Images " + "WHERE dirid=%1 GROUP BY dirid") + .arg( albumID ), &values); + QDate itemDate = QDate::fromString( values[0], Qt::ISODate ); + return itemDate; +} + QDate AlbumDB::getAlbumAverageDate(int albumID) { QStringList values; --- branches/stable/extragear/graphics/digikam/digikam/albumdb.h #508790:508791 @@ -442,9 +442,23 @@ QString getAlbumURL(int albumID); /** + * Returns the lowest/oldest date of all images for that album. + * @param albumID the id of the album to calculate + * @return the date. + */ + QDate getAlbumLowestDate(int albumID); + + /** + * Returns the highest/newest date of all images for that album. + * @param albumID the id of the album to calculate + * @return the date. + */ + QDate getAlbumHighestDate(int albumID); + + /** * Returns the average date of all images for that album. - * @param albumID the id of the album to calculate the average in - * @return the average date. + * @param albumID the id of the album to calculate + * @return the date. */ QDate getAlbumAverageDate(int albumID); --- branches/stable/extragear/graphics/digikam/digikam/albumpropsedit.cpp #508790:508791 @@ -33,6 +33,7 @@ #include <qlistview.h> #include <qframe.h> #include <qheader.h> +#include <qhbox.h> #include <qpushbutton.h> // KDE includes. @@ -129,11 +130,22 @@ topLayout->addWidget( datePicker_, 5, 1 ); dateLabel->setBuddy( datePicker_ ); - QPushButton *avgButton = new QPushButton( - i18n("This is a button which calculates " - "the average date", - "&Average" ), plainPage( ) ); - topLayout->addWidget( avgButton, 6, 1); + QHBox *buttonRow = new QHBox( plainPage( ) ); + QPushButton *dateLowButton = new QPushButton( + i18n("Button to select the date of the first image", + "&Lowest" ), + buttonRow ); + QPushButton *dateAvgButton = new QPushButton( + i18n("This is a button which calculates the average date", + "&Average" ), + buttonRow ); + QPushButton *dateHighButton = new QPushButton( + i18n("Button to select the date of the last image", + "&Highest" ), + buttonRow ); + + + topLayout->addWidget( buttonRow, 6, 1); setTabOrder(titleEdit_, collectionCombo_); setTabOrder(collectionCombo_, commentsEdit_); @@ -174,8 +186,12 @@ connect(titleEdit_, SIGNAL(textChanged(const QString&)), SLOT(slotTitleChanged(const QString&))); - connect(avgButton, SIGNAL( clicked() ), - SLOT( slotAverageButtonClicked())); + connect(dateLowButton, SIGNAL( clicked() ), + SLOT( slotDateLowButtonClicked())); + connect(dateAvgButton, SIGNAL( clicked() ), + SLOT( slotDateAverageButtonClicked())); + connect(dateHighButton, SIGNAL( clicked() ), + SLOT( slotDateHighButtonClicked())); adjustSize(); } @@ -272,11 +288,35 @@ enableButtonOK(!newtitle.isEmpty()); } -void AlbumPropsEdit::slotAverageButtonClicked() +void AlbumPropsEdit::slotDateLowButtonClicked() { setCursor( KCursor::waitCursor() ); AlbumDB* db = AlbumManager::instance()->albumDB(); + QDate avDate = db->getAlbumLowestDate( album_->id() ); + setCursor( KCursor::arrowCursor() ); + + if ( avDate.isValid() ) + datePicker_->setDate( avDate ); +} + +void AlbumPropsEdit::slotDateHighButtonClicked() +{ + setCursor( KCursor::waitCursor() ); + + AlbumDB* db = AlbumManager::instance()->albumDB(); + QDate avDate = db->getAlbumHighestDate( album_->id() ); + setCursor( KCursor::arrowCursor() ); + + if ( avDate.isValid() ) + datePicker_->setDate( avDate ); +} + +void AlbumPropsEdit::slotDateAverageButtonClicked() +{ + setCursor( KCursor::waitCursor() ); + + AlbumDB* db = AlbumManager::instance()->albumDB(); QDate avDate = db->getAlbumAverageDate( album_->id() ); setCursor( KCursor::arrowCursor() ); --- branches/stable/extragear/graphics/digikam/digikam/albumpropsedit.h #508790:508791 @@ -84,7 +84,9 @@ private slots: void slotTitleChanged(const QString& newtitle); - void slotAverageButtonClicked(); + void slotDateLowButtonClicked(); + void slotDateAverageButtonClicked(); + void slotDateHighButtonClicked(); }; #endif /* ALBUMPROPSEDIT_H */