]> gitweb.hamatoma.de Git - reqt/commitdiff
proj. example, rebackgui: fix for clean
authorhama <hama@siduction.net>
Sun, 14 Feb 2016 10:36:34 +0000 (11:36 +0100)
committerhama <hama@siduction.net>
Sun, 14 Feb 2016 10:36:34 +0000 (11:36 +0100)
15 files changed:
appl/example/aboutdialog.cpp [new file with mode: 0644]
appl/example/aboutdialog.hpp [new file with mode: 0644]
appl/example/aboutdialog.ui [new file with mode: 0644]
appl/example/example.hpp [new file with mode: 0644]
appl/example/example.pro [new file with mode: 0644]
appl/example/main.cpp [new file with mode: 0644]
appl/example/mainwindow.cpp [new file with mode: 0644]
appl/example/mainwindow.hpp [new file with mode: 0644]
appl/example/mainwindow.ui [new file with mode: 0644]
appl/rebackgui/BackupEngine.cpp
appl/rebackgui/mainwindow.cpp
base/ReQStringUtils.cpp
gui/ReGuiApplication.cpp
gui/ReGuiApplication.hpp
gui/regui.hpp

diff --git a/appl/example/aboutdialog.cpp b/appl/example/aboutdialog.cpp
new file mode 100644 (file)
index 0000000..eedd0a8
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * aboutdialog.cpp
+ *
+ * (Un)License: Public Domain
+ * You can use and modify this file without any restriction.
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * More info: http://unlicense.org
+ * The latest sources: https://github.com/republib
+ */
+
+#include "aboutdialog.hpp"
+#include "ui_aboutdialog.h"
+
+AboutDialog::AboutDialog(const QString& version, QWidget *parent) :
+         QDialog(parent), ui(new Ui::AboutDialog){
+   ui->setupUi(this);
+   ui->labelVersion->setText(version);
+}
+
+AboutDialog::~AboutDialog(){
+   delete ui;
+}
diff --git a/appl/example/aboutdialog.hpp b/appl/example/aboutdialog.hpp
new file mode 100644 (file)
index 0000000..bf51cc7
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * aboutdialog.hpp
+ *
+ * (Un)License: Public Domain
+ * You can use and modify this file without any restriction.
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * More info: http://unlicense.org
+ * The latest sources: https://github.com/republib
+ */
+
+#ifndef ABOUTDIALOG_HPP
+#define ABOUTDIALOG_HPP
+
+#include <QDialog>
+
+namespace Ui {
+class AboutDialog;
+}
+
+class AboutDialog: public QDialog {
+   Q_OBJECT
+
+public:
+   explicit AboutDialog(const QString& version, QWidget *parent = 0);
+   ~AboutDialog();
+
+private:
+   Ui::AboutDialog *ui;
+};
+
+#endif // ABOUTDIALOG_HPP
diff --git a/appl/example/aboutdialog.ui b/appl/example/aboutdialog.ui
new file mode 100644 (file)
index 0000000..5870ff0
--- /dev/null
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>AboutDialog</class>
+ <widget class="QDialog" name="AboutDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>423</width>
+    <height>289</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Dialog</string>
+  </property>
+  <property name="modal">
+   <bool>true</bool>
+  </property>
+  <widget class="QTextEdit" name="textEdit">
+   <property name="geometry">
+    <rect>
+     <x>20</x>
+     <y>20</y>
+     <width>381</width>
+     <height>221</height>
+    </rect>
+   </property>
+   <property name="readOnly">
+    <bool>true</bool>
+   </property>
+   <property name="html">
+    <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Droid Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:600;&quot;&gt;ReBackupGui&lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt; for backup of directories to external media.&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;This is a program of the project&lt;/span&gt;&lt;/p&gt;
+&lt;p align=&quot;center&quot; style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:600;&quot;&gt;Re&lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;al &lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:600;&quot;&gt;Pub&lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;lic &lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:600;&quot;&gt;Lib&lt;/span&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;rary (RePubLib)&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;Sources are public domain and available under&lt;/span&gt;&lt;/p&gt;
+&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;https://github.com/republib&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt; text-decoration: underline; color:#0000ff;&quot;&gt;https://github.com/republib&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt; &lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;Implemented in QT (C++) 5.x&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;Icons: Mark James, &lt;/span&gt;&lt;a href=&quot;http://famfamfam.com&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt; text-decoration: underline; color:#0000ff;&quot;&gt;http://famfamfam.com&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'Sans Serif'; font-size:9pt;&quot;&gt; &lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+   </property>
+   <property name="acceptRichText">
+    <bool>false</bool>
+   </property>
+   <property name="textInteractionFlags">
+    <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
+   </property>
+  </widget>
+  <widget class="QWidget" name="layoutWidget">
+   <property name="geometry">
+    <rect>
+     <x>20</x>
+     <y>250</y>
+     <width>381</width>
+     <height>32</height>
+    </rect>
+   </property>
+   <layout class="QHBoxLayout" name="horizontalLayout">
+    <item>
+     <widget class="QLabel" name="label">
+      <property name="text">
+       <string>Version:</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <widget class="QLabel" name="labelVersion">
+      <property name="text">
+       <string>2015.05.00</string>
+      </property>
+     </widget>
+    </item>
+    <item>
+     <spacer name="horizontalSpacer">
+      <property name="orientation">
+       <enum>Qt::Horizontal</enum>
+      </property>
+      <property name="sizeHint" stdset="0">
+       <size>
+        <width>40</width>
+        <height>20</height>
+       </size>
+      </property>
+     </spacer>
+    </item>
+    <item>
+     <widget class="QPushButton" name="pushButtonOK">
+      <property name="text">
+       <string>&amp;OK</string>
+      </property>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>pushButtonOK</sender>
+   <signal>clicked()</signal>
+   <receiver>AboutDialog</receiver>
+   <slot>close()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>196</x>
+     <y>183</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>199</x>
+     <y>108</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/appl/example/example.hpp b/appl/example/example.hpp
new file mode 100644 (file)
index 0000000..c13a13c
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * backupgui.hpp
+ *
+ * (Un)License: Public Domain
+ * You can use and modify this file without any restriction.
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * More info: http://unlicense.org
+ * The latest sources: https://github.com/republib
+ */
+
+#ifndef BACKUPGUI_HPP
+#define BACKUPGUI_HPP
+#include "base/rebase.hpp"
+#include "gui/regui.hpp"
+#include "mainwindow.hpp"
+#include "ui_mainwindow.h"
+
+#endif // BACKUPGUI_HPP
diff --git a/appl/example/example.pro b/appl/example/example.pro
new file mode 100644 (file)
index 0000000..7ebd176
--- /dev/null
@@ -0,0 +1,47 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2016-01-18T00:51:17
+#
+#-------------------------------------------------
+
+QT       += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = rebackgui
+TEMPLATE = app
+INCLUDEPATH = ../..
+
+SOURCES += main.cpp\
+        ../../base/ReException.cpp \
+        ../../base/ReConfig.cpp \
+        ../../base/ReQStringUtils.cpp \
+        ../../base/ReFileUtils.cpp \
+        ../../base/ReMatcher.cpp \
+        ../../base/ReLogger.cpp \
+        ../../base/ReRandomizer.cpp \
+        ../../base/ReStringUtils.cpp \
+        ../../gui/ReStateStorage.cpp \
+        ../../gui/ReGuiApplication.cpp \
+        ../../gui/ReGuiValidator.cpp \
+        ../../gui/ReGuiQueue.cpp \
+       ../../gui/ReGuiUtils.cpp \
+        mainwindow.cpp \
+        aboutdialog.cpp
+
+HEADERS  += mainwindow.hpp \
+        ../../base/rebase.hpp \
+        ../../base/ReQStringUtils.hpp \
+        ../../gui/ReStateStorage.hpp \
+        ../../gui/ReGuiValidator.hpp \
+        ../../gui/regui.hpp \
+       ../../gui/ReGuiUtils.hpp \
+        aboutdialog.hpp
+
+FORMS    += mainwindow.ui \
+        aboutdialog.ui
+
+DISTFILES += \
+       ReBackGui.html \
+       osconnect.pl
+
diff --git a/appl/example/main.cpp b/appl/example/main.cpp
new file mode 100644 (file)
index 0000000..0d45da3
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * main.cpp
+ *
+ * (Un)License: Public Domain
+ * You can use and modify this file without any restriction.
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * More info: http://unlicense.org
+ * The latest sources: https://github.com/republib
+ */
+
+#include "base/rebase.hpp"
+#include "gui/regui.hpp"
+#include "mainwindow.hpp"
+#include <QApplication>
+char** g_argv;
+int main(int argc, char *argv[]){
+   g_argv = argv;
+   QString homeDir = argc > 1 ? argv[1] : "";
+   QApplication a(argc, argv);
+   MainWindow w(homeDir);
+       w.show();
+       return a.exec();
+}
diff --git a/appl/example/mainwindow.cpp b/appl/example/mainwindow.cpp
new file mode 100644 (file)
index 0000000..916b6cc
--- /dev/null
@@ -0,0 +1,207 @@
+/*
+ * mainwindow.cpp
+ *
+ * (Un)License: Public Domain
+ * You can use and modify this file without any restriction.
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * More info: http://unlicense.org
+ * The latest sources: https://github.com/republib
+ */
+
+#include "example.hpp"
+#include "aboutdialog.hpp"
+#include <QFileDialog>
+
+const QString VERSION("2016.02.14");
+
+/**
+ * Constructor.
+ *
+ * @param homeDir      the home directory. If "": usage of the user's homedir
+ * @param parent       QT parent or NULL
+ */
+MainWindow::MainWindow(const QString& homeDir, QWidget *parent) :
+       ReGuiApplication("rebackupgui", homeDir, 2, 100100100, parent),
+       ReGuiValidator(),
+       ui(new Ui::MainWindow),
+       m_errors(0)
+{
+       ui->setupUi(this);
+       initializeGuiElements();
+   startStop(false);
+   connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(onAbout()));
+   connect(ui->pushButtonStart, SIGNAL(clicked()), this, SLOT(onStart()));
+}
+
+/**
+ * Destructor.
+ */
+MainWindow::~MainWindow()
+{
+       delete ui;
+}
+
+/**
+ * Appends a line to the filelist.
+ *
+ * Note: this method is called by a non main thread.
+ *
+ * @param info info to add
+ */
+void MainWindow::addToFileList(const QString info){
+       // externalAppend(ReGuiQueueItem::ListEnd, ui->listWidgetFile, info);
+}
+
+/**
+ * Returns the error count.
+ * @return     the error count
+ */
+int MainWindow::errors() const
+{
+       return m_errors;
+}
+
+
+/**
+ * Set GUI elements from the queue when the GUI timer is triggered.
+ */
+void MainWindow::onGuiTimerUpdate()
+{
+       int count = m_guiQueue.count();
+       QListWidget* list;
+       while(count-- > 0){
+               m_mutexGuiQueue.lock();
+               ReGuiQueueItem item = m_guiQueue.popFront();
+               m_mutexGuiQueue.unlock();
+               int m_maxListSize = 0x7fffffff;
+               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()){
+                       switch (item.m_type){
+                       case ReGuiQueueItem::ListEnd:
+                               // todo
+                               break;
+                       case ReGuiQueueItem::ReadyMessage:
+                               say(LOG_INFO, item.m_value);
+                               startStop(false);
+                               break;
+                       case ReGuiQueueItem::LogMessage:
+                               say(LOG_INFO, item.m_value);
+                               break;
+                       case ReGuiQueueItem::LogError:
+                               say(LOG_ERROR, item.m_value);
+                               break;
+                       case ReGuiQueueItem::StatusLine:
+                               setStatusMessage(LOG_INFO, item.m_value);
+                               break;
+                       default:
+                               say(LOG_ERROR, "unknown item type: " + QString::number(item.m_type)
+                                       + " " + item.m_value);
+                               break;
+                       }
+               }
+       }
+}
+
+/**
+ * Common initializations for all task starts.
+ *
+ * @return  <code>true</code>: success<br>
+ *          otherwise: error occurred
+ */
+bool MainWindow::initializeStart(){
+       bool rc = true;
+       startStop(true);
+       // ToDo
+       return rc;
+}
+
+/**
+ * Called at the program's end.
+ */
+void MainWindow::onAboutToQuit()
+{
+       ReGuiApplication::onAboutToQuit();
+}
+
+/**
+ * Shows the "about" window.
+ */
+void MainWindow::onAbout()
+{
+       AboutDialog dialog(VERSION);
+       dialog.exec();
+}
+
+
+/**
+ * Starts the backup.
+ */
+void MainWindow::onStart(){
+       // ToDo
+}
+
+/**
+ * Reads the history of the widget values and other parameters and set it.
+ */
+void MainWindow::restoreState(){
+       ReStateStorage storage(m_storageFile, &m_logger);
+       storage.setForm("main");
+       //storage.restore(ui->comboBoxFilePatterns, "comboBoxFilePatterns", false);
+       //storage.restore(ui->comboBoxDirPatterns, "comboBoxDirPatterns", false);
+       storage.close();
+}
+
+/**
+ * Stores the history of the widget values and other parameters.
+ */
+void MainWindow::saveState(){
+       ReStateStorage storage(m_storageFile, &m_logger);
+       storage.setForm("main");
+       //storage.store(ui->comboBoxFilePatterns, "comboBoxFilePatterns");
+       //storage.store(ui->comboBoxDirPatterns, "comboBoxDirPatterns");
+       storage.close();
+}
+
+/**
+ * Writes a message.
+ *
+ * @param level                mode of the message, e.g. LOG_ERROR
+ * @param message      the message
+ * @return                     <code>false</code>level is error or warning
+ */
+bool MainWindow::say(ReLoggerLevel level, const QString& message){
+       switch(level){
+       case LOG_ERROR:
+       case LOG_WARNING:
+               // todo
+               setStatusMessage(LOG_ERROR, message);
+               m_errors++;
+               break;
+       default:
+       case LOG_INFO:
+               //ui->listWidgetLog->addItem(message);
+               //ui->listWidgetLog->setCurrentRow(ui->listWidgetLog->count() - 1);
+               break;
+       }
+       return level >= LOG_INFO;
+}
+
+/**
+ * Starts or stops the backup.
+ *
+ * @param start        <code>true</code>: the search should start
+ */
+void MainWindow::startStop(bool isStart){
+       ReUseParameter(isStart);
+       // ui->actionStart->setEnabled(!isStart);
+       // todo
+}
+
+
+
+
diff --git a/appl/example/mainwindow.hpp b/appl/example/mainwindow.hpp
new file mode 100644 (file)
index 0000000..3da3df4
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * mainwindow.hpp
+ *
+ * (Un)License: Public Domain
+ * You can use and modify this file without any restriction.
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * More info: http://unlicense.org
+ * The latest sources: https://github.com/republib
+ */
+
+#ifndef MAINWINDOW_HPP
+#define MAINWINDOW_HPP
+#ifndef BACKUPGUI_HPP
+#include "example.hpp"
+#endif
+namespace Ui {
+class MainWindow;
+}
+
+class MainWindow : public ReGuiApplication, public ReGuiValidator
+{
+       Q_OBJECT
+
+public:
+       explicit MainWindow(const QString& homeDir, QWidget *parent = 0);
+       ~MainWindow();
+public:
+   int errors() const;
+   void expandFileList(const QString info);
+   virtual bool say(ReLoggerLevel level, const QString& message);
+   void startStop(bool isStart);
+   void restoreState();
+   void saveState();
+
+   void addToFileList(const QString info);
+private:
+   bool initializeStart();
+private slots:
+   void onAbout();
+   virtual void onAboutToQuit();
+   virtual void onGuiTimerUpdate();
+   void onStart();
+private:
+       Ui::MainWindow *ui;
+       int m_errors;
+};
+
+#endif // MAINWINDOW_HPP
diff --git a/appl/example/mainwindow.ui b/appl/example/mainwindow.ui
new file mode 100644 (file)
index 0000000..8128739
--- /dev/null
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>535</width>
+    <height>405</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>MainWindow</string>
+  </property>
+  <widget class="QWidget" name="centralWidget">
+   <widget class="QPushButton" name="pushButtonStart">
+    <property name="geometry">
+     <rect>
+      <x>11</x>
+      <y>155</y>
+      <width>106</width>
+      <height>30</height>
+     </rect>
+    </property>
+    <property name="text">
+     <string>PushButton</string>
+    </property>
+   </widget>
+  </widget>
+  <widget class="QMenuBar" name="menuBar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>535</width>
+     <height>26</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menuFile">
+    <property name="title">
+     <string>File</string>
+    </property>
+    <addaction name="separator"/>
+   </widget>
+   <widget class="QMenu" name="menuEdit">
+    <property name="title">
+     <string>Edit</string>
+    </property>
+   </widget>
+   <widget class="QMenu" name="menuHelp">
+    <property name="title">
+     <string>Help</string>
+    </property>
+    <addaction name="actionAbout"/>
+   </widget>
+   <widget class="QMenu" name="menuAction">
+    <property name="title">
+     <string>Action</string>
+    </property>
+   </widget>
+   <addaction name="menuFile"/>
+   <addaction name="menuEdit"/>
+   <addaction name="menuAction"/>
+   <addaction name="menuHelp"/>
+  </widget>
+  <widget class="QToolBar" name="mainToolBar">
+   <attribute name="toolBarArea">
+    <enum>TopToolBarArea</enum>
+   </attribute>
+   <attribute name="toolBarBreak">
+    <bool>false</bool>
+   </attribute>
+  </widget>
+  <widget class="QStatusBar" name="statusBar"/>
+  <action name="actionAbout">
+   <property name="text">
+    <string>About</string>
+   </property>
+  </action>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
index 0a6b39a5a766c0867aa2135506b52868464c01b1..1f718486c32634c06e03642cf52cb9a36cd6bc17 100644 (file)
@@ -206,8 +206,8 @@ void BackupTask::run()
                        node = info.mid(pos + 1);
                        copyFile(index, relPath, node);
                        if (m_verboseLevel > VerboseQuiet){
-                qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch();
-                double factor = double(m_processedBytes) / max(1LL, m_hotBytes);
+                               qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch();
+                               double factor = double(m_processedBytes) / max(1LL, m_hotBytes);
                                m_mainWindow->externalAppend(ReGuiQueueItem::StatusLine, NULL,
                                                                                         tr("%1 of %2 (%3 of %4) %5 MB/sec runtime: %6")
                                                                                         .arg(m_processedFiles).arg(m_hotFiles)
@@ -220,7 +220,7 @@ void BackupTask::run()
        }
        m_mainWindow->externalTaskFinished(tr("backup complete after %1. Errors: %2")
                                .arg(ReQStringUtils::readableDuration(
-                    QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch()))
+                                       QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch()))
                                                                           .arg(m_mainWindow->errors()));
 }
 
@@ -398,22 +398,22 @@ void ChecksumOfTargetTask::run()
                                                  + " [" + sourceChecksum + "/" + checksum + "]");
                        }
                        if (m_verboseLevel > VerboseQuiet){
-                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.toMSecsSinceEpoch());
-                double factor = m_processedBytes / double(max(1LL, m_hotBytes * 2));
+                               qint64 processedBytes, hotBytes;
+                               int hotFiles, processedFiles;
+                               m_mutex.lock();
+                               hotFiles = m_hotFiles * 2;
+                               hotBytes = m_hotBytes * 2;
+                               processedBytes = m_processedBytes;
+                               processedFiles = m_processedFiles;
+                               m_mutex.unlock();
+                               now = QDateTime::currentMSecsSinceEpoch();
+                               qint64 duration = (now - start.toMSecsSinceEpoch());
+                               double factor = processedBytes / double(max(1LL, hotBytes));
                                m_mainWindow->externalAppend(ReGuiQueueItem::StatusLine, NULL,
                                                                                         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 * 2))
+                                                                                .arg(ReQStringUtils::readableSize(hotBytes))
                                                                                 .arg(processedBytes / 1024.0 / 1024 / max(1LL, duration) * 1000.0, 0, 'f', 3)
                                                                                 .arg(ReQStringUtils::runtimeEstimation(start, factor)));
                        }
@@ -422,7 +422,7 @@ void ChecksumOfTargetTask::run()
        }
        now = QDateTime::currentMSecsSinceEpoch();
        m_mainWindow->externalTaskFinished(tr("Building target checksums complete after %1. Processed: %2 Errors: %3")
-                .arg(ReQStringUtils::readableDuration(now - start.toMSecsSinceEpoch()))
+                               .arg(ReQStringUtils::readableDuration(now - start.toMSecsSinceEpoch()))
                                                                           .arg(count)
                                                                           .arg(m_mainWindow->errors()));
 }
@@ -526,8 +526,8 @@ void CleanTask::run()
                                break;
                        }
                        if (m_verboseLevel > VerboseQuiet){
-                double factor = double(m_processedFiles) / max(1, m_hotFiles);
-                qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch();
+                               double factor = double(m_processedFiles) / max(1, m_hotFiles);
+                               qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch();
                                m_mainWindow->externalAppend(ReGuiQueueItem::StatusLine, NULL,
                                                                                         tr("%1 of %2 (%3 of %4) %5 MB/sec runtime: %6")
                                                                                         .arg(m_processedFiles)
@@ -542,7 +542,7 @@ void CleanTask::run()
        }
        m_mainWindow->externalTaskFinished(tr("backup complete after %1. Errors: %2")
                                .arg(ReQStringUtils::readableDuration(
-                    QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch()))
+                                       QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch()))
                                                                           .arg(m_mainWindow->errors()));
 }
 
@@ -639,29 +639,29 @@ void SearchTask::searchOneDirectory(const QString& source,
                   m_mutex.unlock();
           } else {
                   qint64 diff = 0;
-           bool doTransfer = false;
+                  bool doTransfer = false;
                   if (! m_compareWithTarget)
-               doTransfer = true;
+                          doTransfer = true;
                   else if (target.isEmpty())
-               doTransfer = true;
+                          doTransfer = true;
                   else {
                           QFileInfo trg(target + it.fileName());
                           if (! trg.exists())
-                   doTransfer = true;
+                                  doTransfer = true;
                           else {
                                   const QFileInfo src = it.fileInfo();
                                   if (trg.size() != src.size())
-                       doTransfer = true;
+                                          doTransfer = true;
                                   else if ((diff = src.lastModified().toMSecsSinceEpoch()
                                                   - trg.lastModified().toMSecsSinceEpoch()) > 2000)
-                       doTransfer = true;
+                                          doTransfer = true;
                           }
                   }
-           if (doTransfer){
+                  if (doTransfer){
                           info = prefix + it.fileName();
                   }
                   m_mutex.lock();
-           if (doTransfer){
+                  if (doTransfer){
                           m_files.append(info);
                           m_hotFiles++;
                           m_hotBytes += it.fileInfo().size();
@@ -835,7 +835,6 @@ void SearchTargetTask::searchOneDirectory(const QString& target,
        if (! m_shouldStop){
                QDirIterator it2(target);
                QString node;
-               QString source;
                while (it2.hasNext()){
                        if (m_shouldStop){
                           break;
@@ -872,6 +871,8 @@ void SearchTargetTask::moveToShadow(const QString& target, const QString& relPat
                if (rename(I18N::s2b(target).constData(), I18N::s2b(shadow).constData()) != 0){
                        error(QObject::tr("cannot move to shadow directory (%1): %2 -> %3")
                                  .arg(errno).arg(target).arg(shadow));
+               } else if (m_verboseLevel >= VerboseStandard){
+                               m_mainWindow->addToFileList("~ " + target);
                }
        }
 }
index 860aa0631a0207d5e784e2a3614ab9d5f2097a40..60a2f92e8d5af16393daf70945cf4a8fc1c771b9 100644 (file)
@@ -87,14 +87,6 @@ MainWindow::~MainWindow()
        delete ui;
 }
 
-/**
- * Calles at the program's end.
- */
-void MainWindow::onAboutToQuit()
-{
-
-}
-
 /**
  * Appends a line to the filelist.
  *
@@ -222,6 +214,15 @@ bool MainWindow::initializeStart(){
        return rc;
 }
 
+/**
+ * Called at the program's end.
+ */
+void MainWindow::onAboutToQuit()
+{
+       saveState();
+       ReGuiApplication::onAboutToQuit();
+}
+
 /**
  * Shows the "about" window.
  */
index 827190571e2760c463910b6d4e6bf1db1ef1c440..c4609df5269b4a0db97c0216dfdda5b484884a9b 100644 (file)
@@ -546,14 +546,15 @@ QString ReQStringUtils::readableDuration(qint64 durationMilliSec){
  */
 QString ReQStringUtils::runtimeEstimation(const QDateTime& start,
                double factor){
-    qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch();
+       qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch();
        if (factor < 1)
                factor = 1;
        else if (factor <= 0.001)
                factor = 0.001;
        qint64 estimated = qint64((double) duration / factor);
-       QString rc = QObject::tr("%1 of %2").arg(readableDuration(duration))
-                                               .arg(readableDuration(estimated));
+       QString rc = QObject::tr("%1 of %2 (%3 %)").arg(readableDuration(duration))
+                                               .arg(readableDuration(estimated))
+                                               .arg(min(100, int (factor * 100)));
        return rc;
 }
 /**
index cbaab68dced5cda554f609ff1cb634c81eefa987..131bd68d6f44b87733430f3b19ef01420dcc0a73 100644 (file)
@@ -114,7 +114,7 @@ void ReGuiApplication::externalTaskFinished(const QString& message){
  */
 void ReGuiApplication::initializeGuiElements(){
        QCoreApplication* app = QCoreApplication::instance();
-       QObject::connect(app, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
+       QObject::connect(app, SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit()));
        connect(m_guiTimer, SIGNAL(timeout()), this, SLOT(onGuiTimerUpdate()));
        m_guiTimer->start(100);
        statusBar()->addWidget(m_statusMessage);
@@ -196,10 +196,10 @@ void ReGuiApplication::externalLog(const QString& message){
 void ReGuiApplication::setStatusMessage(ReLoggerLevel level, const QString& message){
    switch(level){
    case LOG_ERROR:
-          m_statusMessage->setText("! " + message);
+          m_statusMessage->setText("+ " + message);
           break;
    case LOG_WARNING:
-          m_statusMessage->setText("+ " + message);
+          m_statusMessage->setText("! " + message);
           break;
        default:
           m_statusMessage->setText(message);
index 868528d03c98865b53c1e9458ed21325d2b3d9cb..0d6c7bf06f293565d1156af19d2509157774a339 100644 (file)
@@ -22,11 +22,6 @@ public:
        ReGuiApplication(const char* applicationName,
                                                 const QString& homeDir, int maxLogFiles, int maxLogSize,
                                          QWidget *parent);
-public slots:
-       /**
-        * Callback method called when the application is closed.
-        */
-       virtual void onAboutToQuit();
 public:
        const QByteArray& applicationName() const;
        QString fileOfHome(const QString& node);
@@ -45,6 +40,7 @@ protected slots:
         * Reads the <code>m_guiQueue</code>.
         */
        virtual void onGuiTimerUpdate() = 0;
+       virtual void onAboutToQuit();
 protected:
        QByteArray m_applicationName;
        /// the base directory for resources of the program like configuration file.
index 2255d12cf4dedb60b7e8e6840f67c5cd86dd79da..8e8f9e7d5a4956e62e48ba9d8340bf1f3cfc1ee1 100644 (file)
@@ -15,6 +15,7 @@
 #include <QPushButton>
 #include <QLabel>
 #include <QTableWidget>
+#include <QListWidget>
 #include "gui/ReGuiUtils.hpp"
 #include "gui/ReGuiQueue.hpp"
 #include "gui/ReStateStorage.hpp"