[Marble-commits] KDE/kdeedu/marble/src/lib

Bastian Holst bastianholst at gmx.de
Wed Apr 14 23:44:46 CEST 2010


SVN commit 1114914 by bholst:

Marble DataMigration ProgressDialog progress fixes.


 M  +32 -24    DataMigration.cpp  


--- trunk/KDE/kdeedu/marble/src/lib/DataMigration.cpp #1114913:1114914
@@ -114,31 +114,46 @@
                 return;
             }
 
-            if( QDir( dirs.top() ).entryList( QDir::Dirs
-                                              | QDir::Files
-                                              | QDir::NoSymLinks
-                                              | QDir::NoDotAndDotDot ).size() == 0 )
+            QString sourceDirPath = dirs.top();
+            mDebug() << "DataMigration: Current source dir path ="
+                     << sourceDirPath;
+            mDebug() << "SliceSize =" << progressSliceSizeStack.top();
+
+            if( !sourceDirPath.startsWith( sourcePath ) ) {
+                dirs.pop();
+                progress += progressSliceSizeStack.pop();
+                progressDialog.setValue( progress );
+                continue;
+            }
+
+            QDir sourceDir( sourceDirPath );
+            // Creating child file/dir lists.
+            QStringList files = sourceDir.entryList( QDir::Files
+                                                     | QDir::NoSymLinks
+                                                     | QDir::NoDotAndDotDot );
+            QStringList childDirs = sourceDir.entryList( QDir::Dirs
+                                                         | QDir::NoSymLinks
+                                                         | QDir::NoDotAndDotDot );
+            int childSliceSize = 0;
+            if( !childDirs.isEmpty() ) {
+                childSliceSize = progressSliceSizeStack.pop() / childDirs.size();
+                progressSliceSizeStack.push( 0 );
+            }
+
+            if( files.isEmpty() && childDirs.isEmpty() )
             {
                 // Remove empty directory
+                mDebug() << "DataMigration:" << dirs.top()
+                         << "finished";
                 QDir().rmdir( dirs.pop() );
-                progressSliceSizeStack.pop();
+                progress += progressSliceSizeStack.pop();
+                progressDialog.setValue( progress );
             }
             else {
-                QString sourceDirPath = dirs.top();
-
-                if( !sourceDirPath.startsWith( sourcePath ) ) {
-                    dirs.pop();
-                    continue;
-                }
-
-                QDir sourceDir( sourceDirPath );
-                QStringList childDirs = sourceDir.entryList( QDir::Dirs
-                                                             | QDir::NoSymLinks
-                                                             | QDir::NoDotAndDotDot );
-
                 // Add child directories to the stack
                 foreach( const QString& childDir, childDirs ) {
                     dirs.push( sourceDirPath + '/' + childDir );
+                    progressSliceSizeStack.push( childSliceSize );
                 }
 
                 // Creating target dir
@@ -147,11 +162,7 @@
                 targetDirPath.prepend( target );
                 QDir().mkpath( targetDirPath );
 
-                progressSliceSizeStack.push( progressSliceSizeStack.top() / ( childDirs.size() + 1 ) );
                 // Copying contents
-                QStringList files = sourceDir.entryList( QDir::Files
-                                                         | QDir::NoSymLinks
-                                                         | QDir::NoDotAndDotDot );
                 foreach( const QString& file, files ) {
                     if( progressDialog.wasCanceled() ) {
                         return;
@@ -172,9 +183,6 @@
                     QFile::copy( sourceFilePath, targetFilePath );
                     QFile::remove( sourceFilePath );
                 }
-
-                progress += progressSliceSizeStack.top();
-                progressDialog.setValue( progress );
             }
         }
     }


More information about the Marble-commits mailing list