]> gitweb.hamatoma.de Git - reqt/commitdiff
rebackgui: Translations, performance, clearing queue
authorHamatoma <git.tortouse@hm.f-r-e-i.de>
Sat, 20 Feb 2016 07:13:40 +0000 (08:13 +0100)
committerHamatoma <git.tortouse@hm.f-r-e-i.de>
Sat, 20 Feb 2016 07:13:40 +0000 (08:13 +0100)
* missed translations in BackupEngine
* file queue must be cleared before running a task
* gui queue: only the last status message must be showed
* gui queue: the timer triggered method stops after one second:
  responsibility of the GUI

appl/rebackgui/BackupEngine.cpp
appl/rebackgui/mainwindow.cpp
appl/rebackgui/rebackgui.de.qm
appl/rebackgui/rebackgui.de.ts

index f9fe13ae5ecf5d6ed2682f9b2b3d23581d98476b..a238b86a38b0bd82056228e5e2b5b6334c4140d9 100644 (file)
@@ -151,11 +151,11 @@ void BackupTask::copyFile(int index, const QString& relPath,
        if (! ReFileUtils::isDirectory(targetDir, &isFile)){
                if (isFile){
                        if (_unlink(I18N::s2b(targetDir).constData()) != 0)
-                               error(tr("cannot remove file (for making a directory (%1): %2")
+                error(QObject::tr("cannot remove file (for making a directory (%1): %2")
                                          .arg(errno).arg(targetDir));
                }
                if (! ReFileUtils::makeDirWithParents(targetDir))
-                       error(tr("cannot make directory (%1): %2").arg(errno).arg(targetDir));
+            error(QObject::tr("cannot make directory (%1): %2").arg(errno).arg(targetDir));
        }
        QFileInfo info(source);
        if (m_verboseLevel >= VerboseStandard)
@@ -219,7 +219,7 @@ void BackupTask::run()
                 if (factor > 1.0)
                     factor = 1;
                                m_mainWindow->externalAppend(ReGuiQueueItem::StatusLine, NULL,
-                                                                                        tr("%1 of %2 (%3 of %4) %5 MB/sec runtime: %6")
+                                             QObject::tr("%1 of %2 (%3 of %4) %5 MB/sec runtime: %6")
                                              .arg(processedFiles).arg(hotFiles)
                                              .arg(ReQStringUtils::readableSize(processedBytes))
                                              .arg(ReQStringUtils::readableSize(hotBytes))
@@ -228,7 +228,7 @@ void BackupTask::run()
                        }
                }
        }
-       m_mainWindow->externalTaskFinished(tr("backup complete after %1. Errors: %2")
+    m_mainWindow->externalTaskFinished(QObject::tr("backup complete after %1. Errors: %2")
                                .arg(ReQStringUtils::readableDuration(
                                        QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch()))
                                                                           .arg(m_mainWindow->errors()));
@@ -344,7 +344,7 @@ void ChecksumOfSourceTask::run()
        }
        m_sourceProcessingReady = true;
        qint64 now = QDateTime::currentMSecsSinceEpoch();
-       m_mainWindow->externalTaskFinished(tr("Building source checksum complete after %1. Processed: %2")
+    m_mainWindow->externalTaskFinished(QObject::tr("Building source checksum complete after %1. Processed: %2")
                                .arg(ReQStringUtils::readableDuration(now - start))
                                                                           .arg(count));
 }
@@ -422,7 +422,7 @@ void ChecksumOfTargetTask::run()
                 if (factor > 1)
                     factor = 1;
                                m_mainWindow->externalAppend(ReGuiQueueItem::StatusLine, NULL,
-                                                                                        tr("%1 of %2 (%3 of %4) %5 MB/sec runtime: %6")
+                                             QObject::tr("%1 of %2 (%3 of %4) %5 MB/sec runtime: %6")
                                        .arg(processedFiles).arg(hotFiles * 2)
                                                                                 .arg(ReQStringUtils::readableSize(processedBytes))
                                                                                 .arg(ReQStringUtils::readableSize(hotBytes))
@@ -433,7 +433,7 @@ void ChecksumOfTargetTask::run()
                }
        }
        now = QDateTime::currentMSecsSinceEpoch();
-       m_mainWindow->externalTaskFinished(tr("Building target checksums complete after %1. Processed: %2 Errors: %3")
+    m_mainWindow->externalTaskFinished(QObject::tr("Building target checksums complete after %1. Processed: %2 Errors: %3")
                                .arg(ReQStringUtils::readableDuration(now - start.toMSecsSinceEpoch()))
                                                                           .arg(count)
                                                                           .arg(m_mainWindow->errors()));
@@ -545,7 +545,7 @@ void CleanTask::run()
                                double factor = double(processedFiles) / max(1, hotFiles);
                                qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch();
                                m_mainWindow->externalAppend(ReGuiQueueItem::StatusLine, NULL,
-                                                                                        tr("%1 of %2 files  %3 files/sec runtime: %6")
+                                             QObject::tr("%1 of %2 files  %3 files/sec runtime: %6")
                                                                                         .arg(processedFiles)
                                                                                         .arg(hotFiles)
                                                                                         .arg(processedFiles * 1000.0 / max(1.0, (double) duration), 0, 'f', 3)
@@ -553,7 +553,7 @@ void CleanTask::run()
                        }
                }
        }
-    m_mainWindow->externalTaskFinished(tr("clean complete after %1. Errors: %2")
+    m_mainWindow->externalTaskFinished(QObject::tr("clean complete after %1. Errors: %2")
                                .arg(ReQStringUtils::readableDuration(
                                        QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch()))
                                                                           .arg(m_mainWindow->errors()));
@@ -599,7 +599,7 @@ void SearchTask::run()
                searchOneDirectory(sourceDir, targetDir, ix);
        }
        m_searchReady = true;
-       m_mainWindow->externalLog(tr(
+    m_mainWindow->externalLog(QObject::tr(
                "Search finished: to process: %1 with %2 matching: %3 total: %4 "
                "subdirs: %5 runtime: %6")
                .arg(m_hotFiles)
@@ -609,13 +609,6 @@ void SearchTask::run()
                  .arg(ReQStringUtils::readableDuration(
                                   QDateTime::currentMSecsSinceEpoch() - start)));
 }
-void checkInfo(const QString& info){
-    int ix = info.indexOf('\t') + 1;
-    if (ix > 0 && ix < info.length() && info.at(ix) > ' '){
-        QChar cc = info.at(ix);
-        ix++;
-    }
-}
 
 /**
  * Search the files to backup and write it to a list.
@@ -772,9 +765,6 @@ bool SearchTargetTask::removeOlder(const QString& directory, const QDateTime& ti
                   isEmpty = false;
            info = QChar(MAX_INDEX) + ReFileUtils::nativePath(it.filePath()) + m_separatorString
                                   + QChar(CmdRemove);
-#if defined _DEBUG
-           checkInfo(info);
-#endif
                   m_mutex.lock();
                   m_files.append(info);
                   m_hotFiles++;
@@ -790,9 +780,6 @@ bool SearchTargetTask::removeOlder(const QString& directory, const QDateTime& ti
                        m_mainWindow->addToFileList("x " + directory);
                info = QChar(MAX_INDEX) + directory + m_separatorString
                                + QChar(CmdRemoveDir);
-#if defined _DEBUG
-           checkInfo(info);
-#endif
         m_mutex.lock();
                m_files.append(info);
                m_matchedFiles++;
@@ -853,9 +840,6 @@ void SearchTargetTask::searchOneDirectory(const QString& target,
                                   info = prefix + QChar(command) + it.fileName();
                           }
                   }
-#if defined _DEBUG
-           checkInfo(info);
-#endif
            m_mutex.lock();
                   if (command != CmdUndef){
                           m_files.append(info);
@@ -931,7 +915,7 @@ void SearchTargetTask::run()
                removeOlder(m_shadowBaseDir, m_maxAge);
        }
        m_searchReady = true;
-       m_mainWindow->externalLog(tr(
+    m_mainWindow->externalLog(QObject::tr(
                "Search in target finished: to process: %1 with %2 dirs to delete: %3 total: %4 "
                "subdirs: %5 runtime: %6")
                .arg(m_hotFiles)
index 4dfad13044acd02193485327f6bca8332e9ed78a..e9d32d5564b4e23115256252b3c6f6151f57b8f2 100644 (file)
@@ -13,7 +13,7 @@
 #include "aboutdialog.hpp"
 #include <QFileDialog>
 
-const QString VERSION("2016.02.19");
+const QString VERSION("2016.02.20");
 
 /**
  * Constructor.
@@ -167,7 +167,11 @@ void MainWindow::onGuiTimerUpdate()
 {
        int count = m_guiQueue.count();
        QListWidget* list;
-       while(count-- > 0){
+    QString statusMessage;
+    int countStatusMessage = 0;
+    clock_t start = clock();
+    clock_t diff;
+    while(count-- > 0 || (diff = clock() - start) > CLOCKS_PER_SEC){
                m_mutexGuiQueue.lock();
                ReGuiQueueItem item = m_guiQueue.popFront();
                m_mutexGuiQueue.unlock();
@@ -192,7 +196,12 @@ void MainWindow::onGuiTimerUpdate()
                                say(LOG_ERROR, item.m_value);
                                break;
                        case ReGuiQueueItem::StatusLine:
-                               setStatusMessage(LOG_INFO, item.m_value);
+                if (++countStatusMessage % 200 != 0)
+                    statusMessage = item.m_value;
+                else {
+                    setStatusMessage(LOG_INFO, item.m_value);
+                    statusMessage.clear();
+                }
                                break;
                        default:
                                say(LOG_ERROR, "unknown item type: " + QString::number(item.m_type)
@@ -201,6 +210,9 @@ void MainWindow::onGuiTimerUpdate()
                        }
                }
        }
+    if (!statusMessage.isEmpty())
+        setStatusMessage(LOG_INFO, statusMessage);
+
 }
 
 /**
@@ -221,6 +233,7 @@ bool MainWindow::initializeStart(){
        BackupEngine::m_totalFiles = 0;
        BackupEngine::m_processedFiles = 0;
        BackupEngine::m_processedBytes = 0;
+    BackupEngine::m_files.clear();
        ChecksumTask::m_sourceProcessingReady = false;
        if ( (m_maxListSize = comboInt(ui->comboBoxMaxListLength, -999)) == -999){
                rc = false;
index 1c8395d7dcedb63afac066109dde52d702261229..f0ba0123ac893b4af1a29503d54b3397fe69655c 100644 (file)
Binary files a/appl/rebackgui/rebackgui.de.qm and b/appl/rebackgui/rebackgui.de.qm differ
index 13869d3ea49b228809737cbd372bb12e6c81c89e..58a2970df98dc573b7b548237f003d4da02aea00 100644 (file)
@@ -52,58 +52,49 @@ p, li { white-space: pre-wrap; }
 <context>
     <name>BackupTask</name>
     <message>
-        <location filename="BackupEngine.cpp" line="154"/>
         <source>cannot remove file (for making a directory (%1): %2</source>
-        <translation>kann Datei nicht löschen, um ein Verzeichnis anzulegen (%1): %2</translation>
+        <translation type="vanished">kann Datei nicht löschen, um ein Verzeichnis anzulegen (%1): %2</translation>
     </message>
     <message>
-        <location filename="BackupEngine.cpp" line="158"/>
         <source>cannot make directory (%1): %2</source>
-        <translation>kann Verzeichnis nicht anlegen (%1): %2</translation>
+        <translation type="vanished">kann Verzeichnis nicht anlegen (%1): %2</translation>
     </message>
     <message>
-        <location filename="BackupEngine.cpp" line="222"/>
         <source>%1 of %2 (%3 of %4) %5 MB/sec runtime: %6</source>
-        <translation>%1 von %2 (%3 von %4) %5 MB/sec Laufzeit: %6</translation>
+        <translation type="vanished">%1 von %2 (%3 von %4) %5 MB/sec Laufzeit: %6</translation>
     </message>
     <message>
-        <location filename="BackupEngine.cpp" line="231"/>
         <source>backup complete after %1. Errors: %2</source>
-        <translation>Sicherung nach %1 fertiggestellt Fehler: %2</translation>
+        <translation type="vanished">Sicherung nach %1 fertiggestellt Fehler: %2</translation>
     </message>
 </context>
 <context>
     <name>ChecksumOfSourceTask</name>
     <message>
-        <location filename="BackupEngine.cpp" line="347"/>
         <source>Building source checksum complete after %1. Processed: %2</source>
-        <translation>Erzeugen der Prüfsummen für die Quelldateien fertig nach %1. Bearbeitet: %2</translation>
+        <translation type="vanished">Erzeugen der Prüfsummen für die Quelldateien fertig nach %1. Bearbeitet: %2</translation>
     </message>
 </context>
 <context>
     <name>ChecksumOfTargetTask</name>
     <message>
-        <location filename="BackupEngine.cpp" line="425"/>
         <source>%1 of %2 (%3 of %4) %5 MB/sec runtime: %6</source>
-        <translation>%1 von %2 (%3 von %4) %5 MB/sec Laufzeit: %6</translation>
+        <translation type="vanished">%1 von %2 (%3 von %4) %5 MB/sec Laufzeit: %6</translation>
     </message>
     <message>
-        <location filename="BackupEngine.cpp" line="436"/>
         <source>Building target checksums complete after %1. Processed: %2 Errors: %3</source>
-        <translation>Erzeugen der Prüfsummen für die Zieldateien fertig nach %1. Bearbeitet: %2 Fehler: %3</translation>
+        <translation type="vanished">Erzeugen der Prüfsummen für die Zieldateien fertig nach %1. Bearbeitet: %2 Fehler: %3</translation>
     </message>
 </context>
 <context>
     <name>CleanTask</name>
     <message>
-        <location filename="BackupEngine.cpp" line="548"/>
         <source>%1 of %2 files  %3 files/sec runtime: %6</source>
-        <translation>%1 von %2 Dateien  %3 Dateien/sec Laufzeit: %6</translation>
+        <translation type="vanished">%1 von %2 Dateien  %3 Dateien/sec Laufzeit: %6</translation>
     </message>
     <message>
-        <location filename="BackupEngine.cpp" line="556"/>
         <source>clean complete after %1. Errors: %2</source>
-        <translation>Bereinigen fertig nach %1. Fehler: %2</translation>
+        <translation type="vanished">Bereinigen fertig nach %1. Fehler: %2</translation>
     </message>
 </context>
 <context>
@@ -410,47 +401,78 @@ p, li { white-space: pre-wrap; }
         <translation></translation>
     </message>
     <message>
-        <location filename="mainwindow.cpp" line="335"/>
-        <location filename="mainwindow.cpp" line="392"/>
-        <location filename="mainwindow.cpp" line="494"/>
+        <location filename="mainwindow.cpp" line="348"/>
+        <location filename="mainwindow.cpp" line="405"/>
+        <location filename="mainwindow.cpp" line="507"/>
         <source>no backup item selected</source>
         <translation>Kein Sicherungselement ausgewählt</translation>
     </message>
     <message>
-        <location filename="mainwindow.cpp" line="340"/>
-        <location filename="mainwindow.cpp" line="397"/>
-        <location filename="mainwindow.cpp" line="499"/>
+        <location filename="mainwindow.cpp" line="353"/>
+        <location filename="mainwindow.cpp" line="410"/>
+        <location filename="mainwindow.cpp" line="512"/>
         <source>Target not available</source>
         <translation>Ziel nicht vorhanden</translation>
     </message>
     <message>
-        <location filename="mainwindow.cpp" line="366"/>
+        <location filename="mainwindow.cpp" line="379"/>
         <source>Select Source Directory</source>
         <translation>Quellverzeichnis auswählen</translation>
     </message>
     <message>
-        <location filename="mainwindow.cpp" line="451"/>
+        <location filename="mainwindow.cpp" line="464"/>
         <source>Select Target Directory</source>
         <translation>Zielverzeichnis auswählen</translation>
     </message>
     <message>
-        <location filename="mainwindow.cpp" line="457"/>
+        <location filename="mainwindow.cpp" line="470"/>
         <source>target initialized with %1</source>
         <translation>Ziel mit %1 vorbelegt</translation>
     </message>
 </context>
 <context>
     <name>QObject</name>
+    <message>
+        <location filename="BackupEngine.cpp" line="154"/>
+        <source>cannot remove file (for making a directory (%1): %2</source>
+        <translation>kann Datei nicht löschen, um ein Verzeichnis anzulegen (%1): %2</translation>
+    </message>
+    <message>
+        <location filename="BackupEngine.cpp" line="158"/>
+        <source>cannot make directory (%1): %2</source>
+        <translation>kann Verzeichnis nicht anlegen (%1): %2</translation>
+    </message>
+    <message>
+        <location filename="BackupEngine.cpp" line="222"/>
+        <location filename="BackupEngine.cpp" line="425"/>
+        <source>%1 of %2 (%3 of %4) %5 MB/sec runtime: %6</source>
+        <translation>%1 von %2 (%3 von %4) %5 MB/sec Laufzeit: %6</translation>
+    </message>
+    <message>
+        <location filename="BackupEngine.cpp" line="231"/>
+        <source>backup complete after %1. Errors: %2</source>
+        <translation>Sicherung nach %1 fertiggestellt Fehler: %2</translation>
+    </message>
     <message>
         <location filename="BackupEngine.cpp" line="281"/>
         <source>cannot build checksum: %1</source>
         <translation>Kann Prüfsumme nicht ermitteln: %1</translation>
     </message>
+    <message>
+        <location filename="BackupEngine.cpp" line="347"/>
+        <source>Building source checksum complete after %1. Processed: %2</source>
+        <translation>Erzeugen der Prüfsummen für die Quelldateien fertig nach %1. Bearbeitet: %2</translation>
+    </message>
     <message>
         <location filename="BackupEngine.cpp" line="407"/>
         <source>checksum differs: </source>
         <translation>Prüfsummen unterscheiden sich:</translation>
     </message>
+    <message>
+        <location filename="BackupEngine.cpp" line="436"/>
+        <source>Building target checksums complete after %1. Processed: %2 Errors: %3</source>
+        <translation>Erzeugen der Prüfsummen für die Zieldateien fertig nach %1. Bearbeitet: %2 Fehler: %3</translation>
+    </message>
     <message>
         <location filename="BackupEngine.cpp" line="501"/>
         <source>cannot delete (%1): %2</source>
@@ -477,15 +499,35 @@ p, li { white-space: pre-wrap; }
         <translation>Kann Zieldatei nicht umbenennen (%1): %2 -&gt; %3</translation>
     </message>
     <message>
-        <location filename="BackupEngine.cpp" line="904"/>
+        <location filename="BackupEngine.cpp" line="548"/>
+        <source>%1 of %2 files  %3 files/sec runtime: %6</source>
+        <translation>%1 von %2 Dateien  %3 Dateien/sec Laufzeit: %6</translation>
+    </message>
+    <message>
+        <location filename="BackupEngine.cpp" line="556"/>
+        <source>clean complete after %1. Errors: %2</source>
+        <translation>Bereinigen fertig nach %1. Fehler: %2</translation>
+    </message>
+    <message>
+        <location filename="BackupEngine.cpp" line="602"/>
+        <source>Search finished: to process: %1 with %2 matching: %3 total: %4 subdirs: %5 runtime: %6</source>
+        <translation>Suche beendet: zu behandeln: %1 mit %2 passend: %3 gesamt: %4 Unterverz: %5 Laufzeit: %6</translation>
+    </message>
+    <message>
+        <location filename="BackupEngine.cpp" line="888"/>
         <source>cannot create shadow directory (%1): %2</source>
         <translation>Kann Schattenverzeichnis nicht erstellen (%1): %2</translation>
     </message>
     <message>
-        <location filename="BackupEngine.cpp" line="909"/>
+        <location filename="BackupEngine.cpp" line="893"/>
         <source>cannot move to shadow directory (%1): %2 -&gt; %3</source>
         <translation>Kann Datei nicht in Schattenverzeichnis verschieben (%1): %2 -&gt; %3</translation>
     </message>
+    <message>
+        <location filename="BackupEngine.cpp" line="918"/>
+        <source>Search in target finished: to process: %1 with %2 dirs to delete: %3 total: %4 subdirs: %5 runtime: %6</source>
+        <translation>Suche im Ziel bendet: zu behandeln: %1 mit %2 zu löschende Verzeichnisse: %3 gesamt: %4 Unterverz.: %5 Laufzeit: %6</translation>
+    </message>
     <message>
         <location filename="Configuration.cpp" line="68"/>
         <source>item</source>
@@ -510,17 +552,17 @@ p, li { white-space: pre-wrap; }
         <translation>Kann nicht schreiben (%1): %2</translation>
     </message>
     <message>
-        <location filename="mainwindow.cpp" line="213"/>
+        <location filename="mainwindow.cpp" line="225"/>
         <source>Search started...</source>
         <translation>Suche gestartet...</translation>
     </message>
     <message>
-        <location filename="mainwindow.cpp" line="668"/>
+        <location filename="mainwindow.cpp" line="681"/>
         <source>yes</source>
         <translation>Ja</translation>
     </message>
     <message>
-        <location filename="mainwindow.cpp" line="668"/>
+        <location filename="mainwindow.cpp" line="681"/>
         <source>no</source>
         <translation>nein</translation>
     </message>
@@ -634,17 +676,15 @@ p, li { white-space: pre-wrap; }
 <context>
     <name>SearchTargetTask</name>
     <message>
-        <location filename="BackupEngine.cpp" line="934"/>
         <source>Search in target finished: to process: %1 with %2 dirs to delete: %3 total: %4 subdirs: %5 runtime: %6</source>
-        <translation>Suche im Ziel bendet: zu behandeln: %1 mit %2 zu löschende Verzeichnisse: %3 gesamt: %4 Unterverz.: %5 Laufzeit: %6</translation>
+        <translation type="vanished">Suche im Ziel bendet: zu behandeln: %1 mit %2 zu löschende Verzeichnisse: %3 gesamt: %4 Unterverz.: %5 Laufzeit: %6</translation>
     </message>
 </context>
 <context>
     <name>SearchTask</name>
     <message>
-        <location filename="BackupEngine.cpp" line="602"/>
         <source>Search finished: to process: %1 with %2 matching: %3 total: %4 subdirs: %5 runtime: %6</source>
-        <translation>Suche beendet: zu behandeln: %1 mit %2 passend: %3 gesamt: %4 Unterverz: %5 Laufzeit: %6</translation>
+        <translation type="vanished">Suche beendet: zu behandeln: %1 mit %2 passend: %3 gesamt: %4 Unterverz: %5 Laufzeit: %6</translation>
     </message>
 </context>
 </TS>