[Digikam-devel] extragear/graphics/digikam

Marcel Wiesweg marcel.wiesweg at gmx.de
Wed Sep 6 12:57:40 BST 2006


SVN commit 581429 by mwiesweg:

Open image editor faster (when is has been opened once)

- EditorWindow is no longer WDestructiveClose:
  - initialization for each opening takes significant time
- introduce resetImage method in Canvas and DImgInterface
  to reduce memory usage when closed (most importantly, delete DImg object)

If the image is cached, scaling and drawing is now the limiting factor when opening IE.

- use queryClose and queryExit in ShowFoto

CCMAIL: digikam-devel at kde.org



 M  +2 -0      showfoto/main.cpp  
 M  +9 -7      showfoto/showfoto.cpp  
 M  +2 -1      showfoto/showfoto.h  
 M  +17 -5     utilities/imageeditor/canvas/canvas.cpp  
 M  +3 -0      utilities/imageeditor/canvas/canvas.h  
 M  +22 -7     utilities/imageeditor/canvas/dimginterface.cpp  
 M  +2 -0      utilities/imageeditor/canvas/dimginterface.h  
 M  +1 -1      utilities/imageeditor/editor/editorwindow.cpp  
 M  +2 -0      utilities/imageeditor/editor/imagewindow.cpp  


--- trunk/extragear/graphics/digikam/showfoto/main.cpp #581428:581429
@@ -119,5 +119,7 @@
     KGlobal::locale()->insertCatalogue("digikamimageplugins");
 
     return app.exec();
+
+    delete w;
 }
 
--- trunk/extragear/graphics/digikam/showfoto/showfoto.cpp #581428:581429
@@ -219,20 +219,22 @@
     delete m_rightSidebar;
 }
 
-void ShowFoto::closeEvent(QCloseEvent* e)
+bool ShowFoto::queryClose()
 {
-    if (!e)
-        return;
-
     // wait if a save operation is currently running
     if (!waitForSavingToComplete())
-        return;
+        return false;
 
     if (m_currentItem && !promptUserSave(m_currentItem->url()))
-        return;
+        return false;
 
+    return true;
+}
+
+bool ShowFoto::queryExit()
+{
     saveSettings();
-    e->accept();
+    return true;
 }
 
 void ShowFoto::setupConnections()
--- trunk/extragear/graphics/digikam/showfoto/showfoto.h #581428:581429
@@ -91,7 +91,8 @@
 
 private:
 
-    void closeEvent(QCloseEvent* e);
+    bool queryClose();
+    bool queryExit();
 
     void setupActions();
     void setupConnections();
--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/canvas.cpp #581428:581429
@@ -387,8 +387,15 @@
     delete d;
 }
 
-void Canvas::load(const QString& filename, IOFileSettingsContainer *IOFileSettings)
+void Canvas::resetImage()
 {
+    reset();
+    viewport()->setUpdatesEnabled(false);
+    d->im->resetImage();
+}
+
+void Canvas::reset()
+{
     if (d->rubber)
     {
         delete d->rubber;
@@ -401,12 +408,17 @@
     {
         delete d->imageHistogram;
         d->imageHistogram = 0;
-    }    
-    
-    viewport()->setUpdatesEnabled(false);
+    }
 
     d->tileCache.clear();
+}
 
+void Canvas::load(const QString& filename, IOFileSettingsContainer *IOFileSettings)
+{
+    reset();
+
+    viewport()->setUpdatesEnabled(false);
+
     d->im->load( filename, IOFileSettings, d->parent );
     emit signalLoadingStarted(filename);
 }
@@ -674,7 +686,7 @@
     QRegion clipRegion(er);
     cr = d->pixmapRect.intersect(cr);
 
-    if (!cr.isEmpty())
+    if (!cr.isEmpty() && d->im->imageValid())
     {
         clipRegion -= QRect(contentsToViewport(cr.topLeft()), cr.size());
 
--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/canvas.h #581428:581429
@@ -62,6 +62,7 @@
 
     void  saveAs(const QString& filename, IOFileSettingsContainer *IOFileSettings,
                  bool setExifOrientationTag, const QString& mimeType=QString::null);
+    void  resetImage();
     void  switchToLastSaved(const QString& newFilename);
     void  abortSaving();
     void  setModified();
@@ -127,6 +128,8 @@
     void drawHistogramPixmapBusy();
     void drawHistogramPixmap();
 
+    void reset();
+
 public slots:
 
     void slotIncreaseZoom();
--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/dimginterface.cpp #581428:581429
@@ -175,8 +175,27 @@
 void DImgInterface::load(const QString& filename, IOFileSettingsContainer *iofileSettings,
                          QWidget *parent)
 {
+    resetValues();
+
+    d->filename       = filename;
+    d->iofileSettings = iofileSettings;
+    d->parent         = parent;
+
+    d->thread->load( LoadingDescription(filename, iofileSettings->rawDecodingSettings),
+                     SharedLoadSaveThread::AccessModeReadWrite,
+                     SharedLoadSaveThread::LoadingPolicyFirstRemovePrevious);
+}
+
+void DImgInterface::resetImage()
+{
+    resetValues();
+    d->image.reset();
+}
+
+void DImgInterface::resetValues()
+{
     d->valid          = false;
-    d->filename       = filename;
+    d->filename       = QString();
     d->width          = 0;
     d->height         = 0;
     d->origWidth      = 0;
@@ -189,15 +208,11 @@
     d->contrast       = 1.0;
     d->brightness     = 0.0;
     d->changedBCG     = false;
-    d->iofileSettings = iofileSettings;
-    d->parent         = parent;
+    d->iofileSettings = 0;
+    d->parent         = 0;
 
     d->cmod.reset();
     d->undoMan->clear();
-
-    d->thread->load( LoadingDescription(filename, iofileSettings->rawDecodingSettings),
-                     SharedLoadSaveThread::AccessModeReadWrite,
-                     SharedLoadSaveThread::LoadingPolicyFirstRemovePrevious);
 }
 
 void DImgInterface::setICCSettings(ICCSettingsContainer *cmSettings)
--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/dimginterface.h #581428:581429
@@ -72,6 +72,7 @@
     void   clearUndoManager();
     void   setUndoManagerOrigin();
     void   updateUndoState();
+    void   resetImage();
 
     void   zoom(double val);
 
@@ -165,6 +166,7 @@
 private:
 
     void   exifRotate(const QString& filename);
+    void   resetValues();
 
     DImgInterface();
 
--- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/editorwindow.cpp #581428:581429
@@ -96,7 +96,7 @@
 {
 
 EditorWindow::EditorWindow(const char *name)
-            : KMainWindow(0, name, WType_TopLevel|WDestructiveClose)
+            : KMainWindow(0, name, WType_TopLevel)
 {
     d = new EditorWindowPriv;
 
--- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/imagewindow.cpp #581428:581429
@@ -217,6 +217,8 @@
     // put right side bar in a defined state
     emit signalNoCurrentItem();
 
+    m_canvas->resetImage();
+
     saveSettings();
 
     e->accept();



More information about the Digikam-devel mailing list