[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Bkphotoalbum=5D_ThumbnailView=3A_Confirm_grid_resize?=
From:       "Jesper K.Pedersen" <jesper.pedersen () kdab ! com>
Date:       2011-05-31 20:37:24
Message-ID: 20110531203724.56824A60A9 () git ! kde ! org
[Download RAW message or body]

Git commit 437eca91f88393f778db697fc993fbe045b64c1e by Jesper K. Pedersen.
Committed on 31/05/2011 at 21:58.
Pushed by blackie into branch 'master'.

Confirm grid resize

If the user by accident resizes the grid in the thumbnail viewer, then
all his thumbnails will be recreated, which can be a rather expensive
operation. Therefore ask for confirmation when grid is done being
resized.

M  +30   -14   ThumbnailView/GridResizeInteraction.cpp     
M  +2    -0    ThumbnailView/GridResizeInteraction.h     

http://commits.kde.org/kphotoalbum/437eca91f88393f778db697fc993fbe045b64c1e

diff --git a/ThumbnailView/GridResizeInteraction.cpp \
b/ThumbnailView/GridResizeInteraction.cpp index 2efb365..8376278 100644
--- a/ThumbnailView/GridResizeInteraction.cpp
+++ b/ThumbnailView/GridResizeInteraction.cpp
@@ -25,7 +25,9 @@
 #include "Settings/SettingsData.h"
 #include <KSharedConfig>
 #include <KGlobal>
-
+#include "MainWindow/Window.h"
+#include <klocale.h>
+#include <KMessageBox>
 ThumbnailView::GridResizeInteraction::GridResizeInteraction( ThumbnailFactory* \
factory )  : ThumbnailComponent( factory )
 {
@@ -35,7 +37,6 @@ bool ThumbnailView::GridResizeInteraction::mousePressEvent( \
QMouseEvent* event )  {
     _resizing = true;
     _mousePressPos = event->pos();
-    _origWidth = widget()->cellWidth();
     enterGridReziingMode();
     return true;
 }
@@ -44,21 +45,26 @@ bool ThumbnailView::GridResizeInteraction::mousePressEvent( \
QMouseEvent* event )  bool ThumbnailView::GridResizeInteraction::mouseMoveEvent( \
QMouseEvent* event )  {
     QPoint dist = event->pos() - _mousePressPos;
-
-    Settings::SettingsData::instance()->setThumbSize( qMax( 32, _origWidth + \
                dist.x()/5 ) );
-    widget()->model()->reset();
-    cellGeometryInfo()->calculateCellSize();
+    setCellSize( qMax( 32, _origWidth + dist.x()/5 ) );
     return true;
 }
 
 
 bool ThumbnailView::GridResizeInteraction::mouseReleaseEvent( QMouseEvent* )
 {
-    _resizing = false;
     leaveGridResizingMode();
+    _resizing = false;
     return true;
 }
 
+void ThumbnailView::GridResizeInteraction::setCellSize(int size)
+{
+    Settings::SettingsData::instance()->setThumbSize( size );
+    model()->reset();
+    cellGeometryInfo()->calculateCellSize();
+}
+
+
 bool ThumbnailView::GridResizeInteraction::isResizingGrid()
 {
     return _resizing;
@@ -67,17 +73,27 @@ bool ThumbnailView::GridResizeInteraction::isResizingGrid()
 
 void ThumbnailView::GridResizeInteraction::leaveGridResizingMode()
 {
-    KGlobal::config()->sync();
-    model()->reset();
-    cellGeometryInfo()->flushCache();
-    ImageManager::ThumbnailCache::instance()->flush();
-    model()->updateVisibleRowInfo();
-    widget()->setCurrentIndex( model()->index( m_currentRow, 0 ) );
-    ImageManager::ThumbnailBuilder::instance()->buildAll();
+    int code =  KMessageBox::questionYesNo( MainWindow::Window::theMainWindow(),
+                                            i18n("Really resize grid, it will result \
in all thumbnails being regenerated?"), +                                            \
i18n("Really resize grid?"), +                                            \
KStandardGuiItem::yes(), KStandardGuiItem::no(), +                                    \
QLatin1String("resizeGrid")); +    if ( code == KMessageBox::Yes ) {
+        KGlobal::config()->sync();
+        model()->reset();
+        cellGeometryInfo()->flushCache();
+        ImageManager::ThumbnailCache::instance()->flush();
+        model()->updateVisibleRowInfo();
+        widget()->setCurrentIndex( model()->index( m_currentRow, 0 ) );
+        ImageManager::ThumbnailBuilder::instance()->buildAll();
+    }
+    else
+        setCellSize( _origWidth );
 }
 
 void ThumbnailView::GridResizeInteraction::enterGridReziingMode()
 {
+    _origWidth = widget()->cellWidth();
     ImageManager::ThumbnailBuilder::instance()->cancelRequests();
     m_currentRow = widget()->currentIndex().row();
     widget()->verticalScrollBar()->setValue(0);
diff --git a/ThumbnailView/GridResizeInteraction.h \
b/ThumbnailView/GridResizeInteraction.h index 682add0..0865558 100644
--- a/ThumbnailView/GridResizeInteraction.h
+++ b/ThumbnailView/GridResizeInteraction.h
@@ -53,6 +53,8 @@ public:
     void leaveGridResizingMode();
 
 private:
+    void setCellSize(int size);
+
     /**
      * The position the mouse was pressed down, in view port coordinates
      */


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic