]> gitweb.hamatoma.de Git - reqt/commitdiff
rebackgui: options: maxList + autoClear
authorHamatoma <git.tortouse@hm.f-r-e-i.de>
Sun, 31 Jan 2016 22:59:50 +0000 (23:59 +0100)
committerHamatoma <git.tortouse@hm.f-r-e-i.de>
Sun, 31 Jan 2016 22:59:50 +0000 (23:59 +0100)
appl/rebackgui/BackupEngine.cpp
appl/rebackgui/mainwindow.cpp
appl/rebackgui/mainwindow.hpp
appl/rebackgui/mainwindow.ui
base/ReFileUtils.cpp
gui/ReGuiApplication.cpp
gui/ReGuiQueue.cpp
gui/ReGuiQueue.hpp

index 5e7eadcd45025c6e46d5e60f44bc77af8179503e..02dd33e8c367a646ebdaaa0162c35525df011cd4 100644 (file)
@@ -149,7 +149,8 @@ void SearchTask::searchOneDirectory(const QString& source,
        m_totalDirs++;
        m_mutex.unlock();
        if (source.length() > lengthBase){
-               prefix = QChar(1 + index) + source.mid(lengthBase) + OS_SEPARATOR_STR
+        prefix = QChar(1 + index)
+                + ReFileUtils::nativePath(source.mid(lengthBase)) + OS_SEPARATOR_STR
                                + m_separator;
        } else {
                prefix = QChar(1 + index) + m_separatorString;
@@ -506,15 +507,26 @@ void ChecksumOfTargetTask::run()
                                        error(QObject::tr("checksum differs: ") + relPath + node
                                                  + " [" + sourceChecksum + "/" + checksum + "]");
                        }
-                       now = QDateTime::currentMSecsSinceEpoch();
-                       qint64 estimated = (now - start) * m_hotBytes * 2 /  max(1LL, m_processedBytes);
+            qint64 processedBytes, hotBytes;
+            int hotFiles, processedFiles;
+            m_mutex.lock();
+            hotFiles = m_hotFiles;
+            hotBytes = m_hotBytes;
+            processedBytes = m_processedBytes;
+            processedFiles = m_processedFiles;
+            m_mutex.unlock();
+            now = QDateTime::currentMSecsSinceEpoch();
+            qint64 duration = (now - start);
+            qint64 estimated = qint64 ((double) duration * (double) hotBytes * 2.0
+                                       /  (double) max(1LL, processedBytes));
+            qint64 rest = estimated - duration;
                        m_mainWindow->externalAppend(ReGuiQueueItem::StatusLine, NULL,
                                        tr("%1 of %2 (%3 of %4) %5 MB/sec Remaining: %6 of %7")
-                                       .arg(m_processedFiles).arg(m_hotFiles * 2)
-                                                                                .arg(ReQStringUtils::readableSize(m_processedBytes))
-                                                                                .arg(ReQStringUtils::readableSize(m_hotBytes * 2))
-                                                                                .arg(m_processedBytes / 1024.0 / 1024 / (now - start) * 1000, 0, 'f', 3)
-                                                                                .arg(ReQStringUtils::readableDuration(estimated - (now - start)))
+                    .arg(m_processedFiles).arg(hotFiles * 2)
+                                         .arg(ReQStringUtils::readableSize(processedBytes))
+                                         .arg(ReQStringUtils::readableSize(hotBytes * 2))
+                                         .arg(processedBytes / 1024.0 / 1024 / duration * 1000.0, 0, 'f', 3)
+                                         .arg(ReQStringUtils::readableDuration(rest))
                                                                                 .arg(ReQStringUtils::readableDuration(estimated)));
 
                }
index 293657c2fcb7379a3812e544f7020781585d0920..7f421f487aca30aa8cba5548223f34c8dfacdcb9 100644 (file)
@@ -30,7 +30,8 @@ MainWindow::MainWindow(const QString& homeDir, QWidget *parent) :
        m_backupTask(NULL),
        m_checksumOfSourceTask(NULL),
        m_checksumOfTargetTask(NULL),
-       m_errors(0)
+    m_errors(0),
+    m_maxListSize(1000)
 {
        ui->setupUi(this);
        initializeGuiElements();
@@ -161,10 +162,14 @@ QString MainWindow::extractTarget(const QString& dir){
 void MainWindow::onGuiTimerUpdate()
 {
        int count = m_guiQueue.count();
+    QListWidget* list;
        while(count-- > 0){
                m_mutexGuiQueue.lock();
                ReGuiQueueItem item = m_guiQueue.popFront();
                m_mutexGuiQueue.unlock();
+        if (item.m_type == ReGuiQueueItem::ListEnd
+                && (list = reinterpret_cast<QListWidget*>(item.m_widget))->count() >= m_maxListSize)
+            delete list->takeItem(0);
                if (item.m_type == ReGuiQueueItem::Undef)
                        break;
                if (! item.apply()){
@@ -196,8 +201,12 @@ void MainWindow::onGuiTimerUpdate()
 
 /**
  * Common initializations for all task starts.
+ *
+ * @return  <code>true</code>: success<br>
+ *          otherwise: error occurred
  */
-void MainWindow::initializeStart(){
+bool MainWindow::initializeStart(){
+    bool rc = true;
        BackupEngine::m_searchReady = false;
        BackupEngine::m_hotBytes = 0;
        BackupEngine::m_hotFiles = 0;
@@ -207,8 +216,18 @@ void MainWindow::initializeStart(){
        BackupEngine::m_processedFiles = 0;
        BackupEngine::m_processedBytes = 0;
        ChecksumTask::m_sourceProcessingReady = false;
+    if ( (m_maxListSize = comboInt(ui->comboBoxMaxListLength, -999)) == -999){
+        rc = false;
+        m_maxListSize = 100;
+        ui->comboBoxMaxListLength->setEditText(QString::number(m_maxListSize));
+    }
        m_errors = 0;
        startStop(true);
+    if (ui->checkBoxAutoClean->isChecked()){
+        onClearFileList();
+        onClearErrorList();
+    }
+    return rc;
 }
 
 /**
index 9e2163b8b189ac74c9298be554e72335da129386..291364135b2789a31ea84077a720e4aa7a57616a 100644 (file)
@@ -38,7 +38,7 @@ public:
 public slots:
 private:
    QString extractTarget(const QString& dir);
-   void initializeStart();
+   bool initializeStart();
    void writeTargetConfiguration(BackupItem& item, const QString& target);
 private slots:
    void onAbout();
@@ -74,6 +74,7 @@ private:
        ChecksumOfSourceTask* m_checksumOfSourceTask;
        ChecksumOfTargetTask* m_checksumOfTargetTask;
        int m_errors;
+    int m_maxListSize;
 };
 
 #endif // MAINWINDOW_HPP
index c62cbfbc607833cba79a3013434810412e3a8f49..627650bce5cb7b3b5985b3daa503e999d29eeea5 100644 (file)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>820</width>
-    <height>679</height>
+    <height>662</height>
    </rect>
   </property>
   <property name="windowTitle">
               </column>
              </widget>
             </item>
+            <item>
+             <layout class="QHBoxLayout" name="horizontalLayout_11">
+              <item>
+               <widget class="QLabel" name="label_10">
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="text">
+                 <string>Options:</string>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <widget class="QLabel" name="label_11">
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="text">
+                 <string>Max. list length:</string>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <widget class="QComboBox" name="comboBoxMaxListLength">
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="toolTip">
+                 <string>Max. length of the file list / error list. 0: unlimited</string>
+                </property>
+                <property name="editable">
+                 <bool>true</bool>
+                </property>
+                <property name="currentText">
+                 <string>100</string>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <widget class="QCheckBox" name="checkBoxAutoClean">
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="toolTip">
+                 <string>Starting a task cleans filelist and errorlist</string>
+                </property>
+                <property name="text">
+                 <string>Start cleans</string>
+                </property>
+                <property name="checked">
+                 <bool>true</bool>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <spacer name="horizontalSpacer_3">
+                <property name="orientation">
+                 <enum>Qt::Horizontal</enum>
+                </property>
+                <property name="sizeHint" stdset="0">
+                 <size>
+                  <width>40</width>
+                  <height>20</height>
+                 </size>
+                </property>
+               </spacer>
+              </item>
+             </layout>
+            </item>
             <item>
              <layout class="QHBoxLayout" name="horizontalLayout">
               <item>
index e1bcf518eb729eabae8800b9a6c35c6b90d5fd3b..16fb24254d1bf518af10aaa47ff1985970b1a644 100644 (file)
@@ -485,9 +485,11 @@ bool ReFileUtils::makeDir(const char* path, ReLogger* logger) {
        bool rc = true;
        if (stat(path, &info) != 0) {
                rc = _mkdir(path) == 0;
-               if (!rc && logger != NULL)
-                       logger->log(LOG_ERROR, LOC_MAKE_DIR_1,
-                               QObject::tr("can't create directory (%1): %2").arg(errno).arg(path));
+        if (!rc){
+            if (logger != NULL)
+                logger->log(LOG_ERROR, LOC_MAKE_DIR_1,
+                            QObject::tr("can't create directory (%1): %2").arg(errno).arg(path));
+        }
        } else if (!S_ISDIR(info.st_mode)) {
                rc = false;
                if (logger != NULL)
index 1fc1523e07dc33617d3d09e0a83b98b9d2baeb9f..f80c676fb947009a26263350e30c7b7a50c2938b 100644 (file)
@@ -40,7 +40,7 @@ ReGuiApplication::ReGuiApplication(const char* applicationName,
        m_guiQueue(),
        m_guiTimer(new QTimer(this)),
        m_statusMessage(new QLabel(tr("Welcome!"))),
-       m_mutexGuiQueue()
+    m_mutexGuiQueue()
 {
        m_logger.buildStandardAppender(I18N::s2b(m_homeDir) + applicationName,
                                                                   maxLogSize, maxLogFiles);
index da230a0ba75a9d530e636fc7a18aa40219a49cae..2a1a345855fca20b1cd5fbdd0966a766217cd0fb 100644 (file)
@@ -16,7 +16,7 @@
  * Constructor.
  */
 ReGuiQueue::ReGuiQueue() :
-       QVector<ReGuiQueueItem>(),
+    QList<ReGuiQueueItem>(),
        m_locker()
 {
 }
@@ -96,7 +96,8 @@ bool ReGuiQueueItem::apply() const
                {
                        QListWidget* list = reinterpret_cast<QListWidget*>(m_widget);
                        list->addItem(m_value);
-                       list->setCurrentRow(list->count() - 1);
+            int count = list->count();
+            list->setCurrentRow(count - 1);
                        break;
                }
                case ListAppendToCurrent:
index 97dd4c9fea1da93334712e7134ce541f2ee6fb29..33613d7da6160b8b2ff3d891c169053831f0feb5 100644 (file)
@@ -72,7 +72,7 @@ public:
  * Qt allows manipulating GUI elements only in the main thread.
  * This queue allows the exchange of information from other threads.
  */
-class ReGuiQueue : protected QVector<ReGuiQueueItem>
+class ReGuiQueue : protected QList<ReGuiQueueItem>
 {
 public:
        ReGuiQueue();