SVN commit 1164158 by blackie: Thumbnails are now correctly updated when: * It has been rotated in the annotation dialog * It has been rotated in the viewer * The thumbnails size is changed in the settings dialog. M +7 -7 AnnotationDialog/Dialog.cpp M +3 -2 AnnotationDialog/Dialog.h M +0 -1 ImageManager/ThumbnailCache.cpp M +27 -36 MainWindow/Window.cpp M +3 -5 MainWindow/Window.h M +6 -0 Settings/SettingsDialog.cpp M +1 -0 Settings/SettingsDialog.h M +7 -0 Settings/ThumbnailsPage.cpp M +1 -0 Settings/ThumbnailsPage.h M +2 -2 ThumbnailView/ThumbnailFacade.cpp M +1 -1 ThumbnailView/ThumbnailFacade.h M +1 -2 ThumbnailView/ThumbnailWidget.cpp M +1 -1 ThumbnailView/ThumbnailWidget.h M +10 -4 Viewer/ViewerWidget.cpp M +1 -1 Viewer/ViewerWidget.h --- trunk/extragear/graphics/kphotoalbum/AnnotationDialog/Dialog.cpp #1164157:1164158 @@ -437,7 +437,6 @@ } _thumbnailShouldReload = false; - _thumbnailTextShouldReload = false; showHelpDialog( oneAtATime ? InputSingleImageConfigMode : InputMultiImageConfigMode ); @@ -668,6 +667,7 @@ else { DB::ImageInfo& info = _editList[ _current ]; info.rotate(angle); + _rotatedFiles.insert( info.fileName( DB::AbsolutePath ) ); } } @@ -676,11 +676,6 @@ return _thumbnailShouldReload; } -bool AnnotationDialog::Dialog::thumbnailTextShouldReload() const -{ - return _thumbnailTextShouldReload; -} - void AnnotationDialog::Dialog::slotAddTimeInfo() { _addTime->hide(); @@ -984,7 +979,7 @@ // I shouldn't emit changed before I've actually commited the changes, otherwise the listeners will act on the old data. if ( anyChanges ) { MainWindow::DirtyIndicator::markDirty(); - _thumbnailTextShouldReload = true; + _thumbnailShouldReload = true; } QDialog::accept(); @@ -1008,4 +1003,9 @@ } } +Utilities::StringSet AnnotationDialog::Dialog::rotatedFiles() const +{ + return _rotatedFiles; +} + #include "Dialog.moc" --- trunk/extragear/graphics/kphotoalbum/AnnotationDialog/Dialog.h #1164157:1164158 @@ -18,6 +18,7 @@ #ifndef IMAGECONFIG_H #define IMAGECONFIG_H +#include "Utilities/Set.h" #include "ListSelect.h" #include "DB/ImageSearchInfo.h" #include @@ -73,7 +74,7 @@ int configure( DB::ImageInfoList list, bool oneAtATime ); DB::ImageSearchInfo search( DB::ImageSearchInfo* search = 0 ); bool thumbnailShouldReload() const; - bool thumbnailTextShouldReload() const; + Utilities::StringSet rotatedFiles() const; KActionCollection* actions(); protected slots: @@ -135,7 +136,7 @@ int _accept; QList _dockWidgets; bool _thumbnailShouldReload; - bool _thumbnailTextShouldReload; + Utilities::StringSet _rotatedFiles; // Widgets QMainWindow* _dockWindow; --- trunk/extragear/graphics/kphotoalbum/ImageManager/ThumbnailCache.cpp #1164157:1164158 @@ -168,7 +168,6 @@ void ImageManager::ThumbnailCache::removeThumbnail( const QString& fileName ) { - qDebug("Removing"); m_map.remove( fileName ); save(); } --- trunk/extragear/graphics/kphotoalbum/MainWindow/Window.cpp #1164157:1164158 @@ -168,7 +168,7 @@ _stack->addWidget( _thumbnailView->gui() ); _stack->raiseWidget( _browser ); - _optionsDialog = 0; + _settingsDialog = 0; setupMenuBar(); createSarchBar(); @@ -201,10 +201,10 @@ connect( DB::ImageDB::instance(), SIGNAL( dirty() ), _dirtyIndicator, SLOT( markDirtySlot() ) ); connect( DB::ImageDB::instance()->categoryCollection(), SIGNAL( categoryCollectionChanged() ), this, SLOT( slotOptionGroupChanged() ) ); connect( _browser, SIGNAL( imageCount(uint)), _partial, SLOT( showBrowserMatches(uint) ) ); - connect( _thumbnailView, SIGNAL( selectionChanged(int) ), this, SLOT( slotThumbNailSelectionChanged(int) ) ); + connect( _thumbnailView, SIGNAL( selectionChanged(int) ), this, SLOT( updateContextMenuFromSelectionSize(int) ) ); QTimer::singleShot( 0, this, SLOT( delayedInit() ) ); - slotThumbNailSelectionChanged(0); + updateContextMenuFromSelectionSize(0); // Automatically save toolbar settings setAutoSaveSettings(); @@ -302,12 +302,13 @@ void MainWindow::Window::slotOptions() { - if ( ! _optionsDialog ) { - _optionsDialog = new Settings::SettingsDialog( this ); - connect( _optionsDialog, SIGNAL( changed() ), this, SLOT( reloadThumbnailsAndFlushCache() ) ); - connect( _optionsDialog, SIGNAL( changed() ), this, SLOT( startAutoSaveTimer() ) ); + if ( ! _settingsDialog ) { + _settingsDialog = new Settings::SettingsDialog( this ); + connect( _settingsDialog, SIGNAL( changed() ), this, SLOT( reloadThumbnails() ) ); + connect( _settingsDialog, SIGNAL( changed() ), this, SLOT( startAutoSaveTimer() ) ); + connect( _settingsDialog, SIGNAL( thumbnailSizeChanged() ), ImageManager::ThumbnailCache::instance(), SLOT( flush() ) ); } - _optionsDialog->show(); + _settingsDialog->show(); } void MainWindow::Window::slotCreateImageStack() @@ -427,11 +428,13 @@ void MainWindow::Window::configImages( const DB::ImageInfoList& list, bool oneAtATime ) { createAnnotationDialog(); - _annotationDialog->configure( list, oneAtATime ); + if ( _annotationDialog->configure( list, oneAtATime ) == QDialog::Rejected ) + return; + if ( _annotationDialog->thumbnailShouldReload() ) - reloadThumbnails(true); - else if ( _annotationDialog->thumbnailTextShouldReload() ) - _thumbnailView->reload(false, false); + reloadThumbnails(); + Q_FOREACH( const QString& fileName, _annotationDialog->rotatedFiles() ) + ImageManager::ThumbnailCache::instance()->removeThumbnail( fileName ); } @@ -610,7 +613,6 @@ else viewer = new Viewer::ViewerWidget(Viewer::ViewerWidget::ViewerWindow, &_viewerInputMacros); - connect( viewer, SIGNAL( rotated() ), this, SLOT( reloadThumbnailsAndFlushCache() ) ); connect( viewer, SIGNAL( soughtTo(const DB::ResultId&) ), _thumbnailView, SLOT( changeSingleSelection(const DB::ResultId&) ) ); viewer->show( slideShow ); @@ -940,7 +942,7 @@ void MainWindow::Window::showThumbNails() { - reloadThumbnails(false); + reloadThumbnails(); _stack->raiseWidget( _thumbnailView->gui() ); _thumbnailView->gui()->setFocus(); updateStates( true ); @@ -1225,7 +1227,7 @@ statusBar()->showMessage( id.fetchInfo()->fileName(DB::AbsolutePath), 4000 ); } -void MainWindow::Window::slotThumbNailSelectionChanged(int selectionSize) +void MainWindow::Window::updateContextMenuFromSelectionSize(int selectionSize) { _configAllSimultaniously->setEnabled(selectionSize > 1); _configOneAtATime->setEnabled(selectionSize >= 1); @@ -1250,7 +1252,6 @@ ImageManager::ThumbnailCache::instance()->removeThumbnail( info->fileName( DB::AbsolutePath) ); } _dirtyIndicator->markDirty(); - reloadThumbnailsAfterRotation(); } } @@ -1264,22 +1265,12 @@ rotateSelected( 90 ); } -void MainWindow::Window::reloadThumbnails(bool flushCache) +void MainWindow::Window::reloadThumbnails() { - _thumbnailView->reload( flushCache ); - slotThumbNailSelectionChanged( _thumbnailView->selection().size() ); + _thumbnailView->reload(); + updateContextMenuFromSelectionSize( _thumbnailView->selection().size() ); } -void MainWindow::Window::reloadThumbnailsAndFlushCache() -{ - reloadThumbnails(true); -} - -void MainWindow::Window::reloadThumbnailsAfterRotation() -{ - _thumbnailView->reload( true, false ); -} - void MainWindow::Window::slotUpdateViewMenu( DB::Category::ViewType type ) { if ( type == DB::Category::TreeView ) @@ -1506,7 +1497,7 @@ ImageManager::ThumbnailCache::instance()->removeThumbnail( (*it).path() ); } _dirtyIndicator->markDirty(); - reloadThumbnails(true); + reloadThumbnails(); } DB::ImageSearchInfo MainWindow::Window::currentContext() @@ -1610,14 +1601,14 @@ { DB::ImageDB::instance()->setDateRange( range, _dateBar->includeFuzzyCounts() ); _browser->reload(); - reloadThumbnails(false); + reloadThumbnails(); } void MainWindow::Window::clearDateRange() { DB::ImageDB::instance()->clearDateRange(); _browser->reload(); - reloadThumbnails(false); + reloadThumbnails(); } void MainWindow::Window::showThumbNails(const DB::Result& items) @@ -1645,10 +1636,10 @@ "Do you want to do this now?")); if (ret != KMessageBox::Yes) return; - if (!_optionsDialog) - _optionsDialog = new Settings::SettingsDialog(this); - _optionsDialog->showBackendPage(); - ret = _optionsDialog->exec(); + if (!_settingsDialog) + _settingsDialog = new Settings::SettingsDialog(this); + _settingsDialog->showBackendPage(); + ret = _settingsDialog->exec(); if (ret != Settings::SettingsDialog::Accepted) return; } --- trunk/extragear/graphics/kphotoalbum/MainWindow/Window.h #1164157:1164158 @@ -112,10 +112,8 @@ void changePassword(); void slotConfigureKeyBindings(); void slotSetFileName( const DB::ResultId& ); - void slotThumbNailSelectionChanged(int selectionSize); - void reloadThumbnails(bool flushCache); - void reloadThumbnailsAndFlushCache(); - void reloadThumbnailsAfterRotation(); + void updateContextMenuFromSelectionSize(int selectionSize); + void reloadThumbnails(); void slotUpdateViewMenu( DB::Category::ViewType ); void slotShowNotOnDisk(); void slotBuildThumbnails(); @@ -179,7 +177,7 @@ static Window* _instance; ThumbnailView::ThumbnailFacade* _thumbnailView; - Settings::SettingsDialog* _optionsDialog; + Settings::SettingsDialog* _settingsDialog; QPointer _annotationDialog; Q3WidgetStack* _stack; QWidget* _welcome; --- trunk/extragear/graphics/kphotoalbum/Settings/SettingsDialog.cpp #1164157:1164158 @@ -132,6 +132,12 @@ { Utilities::ShowBusyCursor dummy; Settings::SettingsData* opt = Settings::SettingsData::instance(); + + // Must be before I save to the backend. + if ( _thumbnailsPage->thumbnailSizeChanged(opt) ) + emit thumbnailSizeChanged(); + + _generalPage->saveSettings( opt ); _fileVersionDetectionPage->saveSettings( opt ); _thumbnailsPage->saveSettings(opt); --- trunk/extragear/graphics/kphotoalbum/Settings/SettingsDialog.h #1164157:1164158 @@ -50,6 +50,7 @@ signals: void changed(); + void thumbnailSizeChanged(); protected slots: void slotMyOK(); --- trunk/extragear/graphics/kphotoalbum/Settings/ThumbnailsPage.cpp #1164157:1164158 @@ -43,6 +43,7 @@ lay->addWidget( _thumbnailAspectRatio, row, 1 ); // Thumbnail Format + // PENDING(blackie) This is not used anymore and should go away. ++row; QLabel* thumbnailFormatLabel = new QLabel( i18n("Thumbnail format") ); _thumbnailFormat = new KComboBox( this ); @@ -92,6 +93,7 @@ lay->addWidget( _autoShowThumbnailView, row, 1 ); // Thumbnail Cache + // PENDING(blackie) This is not used anymore and should go away ++row; QLabel* cacheLabel = new QLabel( i18n( "Thumbnail screen cache:" ), this ); _thumbnailCacheScreens = new QSpinBox; @@ -194,4 +196,9 @@ _thumbnailCacheScreens->setSuffix( ki18ncp("Thumbnail Cache Screens", " Screen", " Screens").subs(value).toString()); } +bool Settings::ThumbnailsPage::thumbnailSizeChanged( Settings::SettingsData* opt ) const +{ + return _thumbnailSize->value() != opt->thumbSize(); +} + --- trunk/extragear/graphics/kphotoalbum/Settings/ThumbnailsPage.h #1164157:1164158 @@ -18,6 +18,7 @@ ThumbnailsPage( QWidget* parent ); void loadSettings( Settings::SettingsData* ); void saveSettings( Settings::SettingsData* ); + bool thumbnailSizeChanged( Settings::SettingsData* opt ) const; private slots: void thumbnailCacheScreenChanged(int); --- trunk/extragear/graphics/kphotoalbum/ThumbnailView/ThumbnailFacade.cpp #1164157:1164158 @@ -68,9 +68,9 @@ widget()->setCurrentItem( id ); } -void ThumbnailView::ThumbnailFacade::reload( bool flushCache, bool clearSelection) +void ThumbnailView::ThumbnailFacade::reload( bool clearSelection) { - _widget->reload( flushCache, clearSelection ); + _widget->reload( clearSelection ); } DB::Result ThumbnailView::ThumbnailFacade::selection() const --- trunk/extragear/graphics/kphotoalbum/ThumbnailView/ThumbnailFacade.h #1164157:1164158 @@ -35,7 +35,7 @@ ThumbnailFacade(); QWidget* gui(); void setCurrentItem( const DB::ResultId& id ); - void reload( bool flushCache, bool clearSelection=true ); + void reload( bool clearSelection=true ); DB::Result selection() const; DB::Result imageList(Order) const; DB::ResultId mediaIdUnderCursor() const; --- trunk/extragear/graphics/kphotoalbum/ThumbnailView/ThumbnailWidget.cpp #1164157:1164158 @@ -265,9 +265,8 @@ } -void ThumbnailView::ThumbnailWidget::reload(bool flushCache, bool clearSelection) +void ThumbnailView::ThumbnailWidget::reload(bool clearSelection) { - // PENDING(blackie) no more need for flushcache option? if ( clearSelection ) this->clearSelection(); --- trunk/extragear/graphics/kphotoalbum/ThumbnailView/ThumbnailWidget.h #1164157:1164158 @@ -46,7 +46,7 @@ public: ThumbnailWidget( ThumbnailFactory* factory ); - void reload( bool flushCache, bool clearSelection=true ); + void reload( bool clearSelection=true ); DB::ResultId mediaIdUnderCursor() const; QModelIndex indexUnderCursor() const; --- trunk/extragear/graphics/kphotoalbum/Viewer/ViewerWidget.cpp #1164157:1164158 @@ -16,6 +16,7 @@ Boston, MA 02110-1301, USA. */ +#include "ViewerWidget.h" #include #include @@ -42,7 +43,7 @@ #include "InfoBox.h" #include "VideoDisplay.h" #include "MainWindow/DirtyIndicator.h" -#include "ViewerWidget.h" +#include "ImageManager/ThumbnailCache.h" #include #include "VisibleOptionsMenu.h" #include @@ -608,21 +609,21 @@ { currentInfo()->rotate( 90 ); load(); - emit rotated(); + invalidateThumbnail(); } void Viewer::ViewerWidget::rotate180() { currentInfo()->rotate( 180 ); load(); - emit rotated(); + invalidateThumbnail(); } void Viewer::ViewerWidget::rotate270() { currentInfo()->rotate( 270 ); load(); - emit rotated(); + invalidateThumbnail(); } void Viewer::ViewerWidget::showFirst() @@ -1390,4 +1391,9 @@ _videoDisplay->stop(); } +void Viewer::ViewerWidget::invalidateThumbnail() const +{ + ImageManager::ThumbnailCache::instance()->removeThumbnail( currentInfo()->fileName( DB::AbsolutePath ) ); +} + #include "ViewerWidget.moc" --- trunk/extragear/graphics/kphotoalbum/Viewer/ViewerWidget.h #1164157:1164158 @@ -73,7 +73,6 @@ void stopPlayback(); signals: - void rotated(); void soughtTo( const DB::ResultId& id ); protected: @@ -107,6 +106,7 @@ void showNextN(int); void showPrevN(int); int find_tag_in_list(const QStringList &list, QString &namefound); + void invalidateThumbnail() const; protected slots: