[Digikam-devel] [Bug 120963] optional album date change
Tom Albers
tomalbers at kde.nl
Sun Feb 12 19:05:02 GMT 2006
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=120963
------- Additional Comments From tomalbers kde nl 2006-02-12 20:05 -------
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 */
More information about the Digikam-devel
mailing list