]> gitweb.hamatoma.de Git - reqt/commitdiff
dayly work
authorhama <hama@siduction.net>
Thu, 21 Jan 2016 23:28:17 +0000 (00:28 +0100)
committerhama <hama@siduction.net>
Thu, 21 Jan 2016 23:28:17 +0000 (00:28 +0100)
20 files changed:
appl/rebackgui/Configuration.cpp [new file with mode: 0644]
appl/rebackgui/Configuration.hpp [new file with mode: 0644]
appl/rebackgui/backupgui.hpp [new file with mode: 0644]
appl/rebackgui/main.cpp
appl/rebackgui/mainwindow.cpp
appl/rebackgui/mainwindow.hpp
appl/rebackgui/mainwindow.ui
appl/rebackgui/rebackgui.pro
appl/reimgconvert/mainwindow.cpp
base/ReFileUtils.cpp
base/ReFileUtils.hpp
base/ReQStringUtils.cpp
base/ReTest.cpp
base/ReTest.hpp
base/rebase.hpp
cunit/allTests.cpp
cunit/cuReFileUtils.cpp
cunit/cuReQStringUtils.cpp
gui/ReGuiApplication.cpp
remodules.hpp

diff --git a/appl/rebackgui/Configuration.cpp b/appl/rebackgui/Configuration.cpp
new file mode 100644 (file)
index 0000000..0c0aec2
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Licence:
+ * You can use and modify this file without any restriction.
+ * There is no warranty.
+ * You also can use the licence from http://www.wtfpl.net/.
+ * The original sources can be found on https://github.com/republib.
+*/
+
+#include "backupgui.hpp"
+
+/**
+ * Constructor.
+ *
+ * @param mainWindow   the GUI actor
+ */
+Configuration::Configuration(MainWindow* mainWindow) :
+       m_filename(),
+       m_mainWindow(mainWindow)
+{
+}
+
+/**
+ * Loads the configuration file.
+ *
+ * @param filename     the file to load. If "": take the default filename
+ */
+void Configuration::load(const QString& filename)
+{
+
+}
+
+/**
+ * Saves the configuration file.
+ *
+ * @param filename     the file to save. If "": take the default filename
+ */
+void Configuration::save(const QString& filename)
+{
+
+}
diff --git a/appl/rebackgui/Configuration.hpp b/appl/rebackgui/Configuration.hpp
new file mode 100644 (file)
index 0000000..ed99dc0
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Licence:
+ * You can use and modify this file without any restriction.
+ * There is no warranty.
+ * You also can use the licence from http://www.wtfpl.net/.
+ * The original sources can be found on https://github.com/republib.
+*/
+
+#ifndef CONFIGURATION_HPP
+#define CONFIGURATION_HPP
+
+class BackupItem{
+public:
+       QString m_name;
+       QStringList m_sources;
+       QString m_target;
+       QDateTime m_lastBackup;
+};
+
+class Configuration
+{
+public:
+       Configuration(MainWindow* mainWindow);
+public:
+       void load(const QString& filename);
+       void save(const QString& filename);
+
+private:
+       QString m_filename;
+       MainWindow* m_mainWindow;
+       QList<BackupItem> m_items;
+};
+
+#endif // CONFIGURATION_HPP
diff --git a/appl/rebackgui/backupgui.hpp b/appl/rebackgui/backupgui.hpp
new file mode 100644 (file)
index 0000000..4df436c
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Licence:
+ * You can use and modify this file without any restriction.
+ * There is no warranty.
+ * You also can use the licence from http://www.wtfpl.net/.
+ * The original sources can be found on https://github.com/republib.
+*/
+
+#ifndef BACKUPGUI_HPP
+#define BACKUPGUI_HPP
+#include "base/rebase.hpp"
+#include "gui/regui.hpp"
+#include "Configuration.hpp"
+#include "mainwindow.hpp"
+#include "ui_mainwindow.h"
+
+#endif // BACKUPGUI_HPP
index b5e8a18ea41e938ad4c7a0ae3068a7c3751c545a..ab553b233b4971bbd9e7e626e872c2f8e36dcbb8 100644 (file)
@@ -6,14 +6,16 @@
  * The original sources can be found on https://github.com/republib.
 */
 
+#include "base/rebase.hpp"
+#include "gui/regui.hpp"
 #include "mainwindow.hpp"
 #include <QApplication>
-
-int main(int argc, char *argv[])
-{
-       QApplication a(argc, argv);
-       MainWindow w;
+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();
 }
index 5ef22d655197768b0b2862417556f60a484e466e..35c95fd2984e3ddafb109186fb15f4682b2c628c 100644 (file)
@@ -6,17 +6,64 @@
  * The original sources can be found on https://github.com/republib.
 */
 
-#include "mainwindow.hpp"
-#include "ui_mainwindow.h"
+#include "backupgui.hpp"
+#include "aboutdialog.hpp"
 
-MainWindow::MainWindow(QWidget *parent) :
-       QMainWindow(parent),
+const QString VERSION("2016.01.20");
+
+MainWindow::MainWindow(const QString& homeDir, QWidget *parent) :
+       ReGuiApplication("reimgconvert", homeDir, 2, 100100100, parent),
        ui(new Ui::MainWindow)
 {
        ui->setupUi(this);
+       initializeGuiElements();
+   startStop(false);
+   connect(ui->actionStart, SIGNAL(triggered()), this,
+         SLOT(onStart()));
+   connect(ui->actionStop, SIGNAL(triggered()), this,
+         SLOT(onStop()));
+   connect(ui->actionSelectTarget, SIGNAL(triggered()), this,
+         SLOT(selectTarget()));
+   connect(ui->actionClear, SIGNAL(triggered()), this, SLOT(clear()));
+   connect(ui->pushButtonStart, SIGNAL(clicked()), this, SLOT(onStart()));
+   connect(ui->pushButtonStop, SIGNAL(clicked()), this, SLOT(onStop()));
+   connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
+   loadConfig();
 }
 
 MainWindow::~MainWindow()
 {
        delete ui;
 }
+
+/**
+ * Starts or stops the backup.
+ *
+ * @param start        <code>true</code>: the search should start
+ */
+void MainWindow::startStop(bool isStart){
+       ui->actionStart->setEnabled(!isStart);
+       ui->pushButtonBackup->setEnabled(! isStart);
+       ui->actionStop->setEnabled(isStart);
+       ui->pushButtonBackup->setEnabled(! isStart);
+       ui->pushButtonStop->setEnabled(isStart);
+}
+
+/**
+ * Loads the configuration file.
+ */
+void MainWindow::loadConfig(){
+
+}
+
+/**
+ * @brief Handles the button click on "convert".
+ */
+void MainWindow::onStart(){
+}
+/**
+ * @brief Handles the button click on "convert".
+ */
+void MainWindow::onStop(){
+}
+
index 754b0019455497f0f40bb07ce9c3697b9a83a29d..3f8409d70e50fc89c4cbe4730d3255cfc553f5e5 100644 (file)
@@ -15,13 +15,22 @@ namespace Ui {
 class MainWindow;
 }
 
-class MainWindow : public ReHomeApplication
+class MainWindow : public ReGuiApplication
 {
        Q_OBJECT
 
 public:
-       explicit MainWindow(QWidget *parent = 0);
+       explicit MainWindow(const QString& homeDir, QWidget *parent = 0);
        ~MainWindow();
+public:
+   bool error(const QString& message);
+   bool log(const QString& message);
+   void setStatusMessage(bool error, const QString& message);
+private:
+       virtual void aboutToQuit();
+       void loadConfig();
+private slots:
+   void about();
 
 private:
        Ui::MainWindow *ui;
index 6050363fa71ed2da04105077f9fef06150d05ee2..52df1aefdd38fca1b90f245be6751daeb20ce30c 100644 (file)
+<?xml version="1.0" encoding="UTF-8"?>
 <ui version="4.0">
  <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow" >
-  <property name="geometry" >
+ <widget class="QMainWindow" name="MainWindow">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>400</width>
-    <height>300</height>
+    <width>820</width>
+    <height>654</height>
    </rect>
   </property>
-  <property name="windowTitle" >
+  <property name="windowTitle">
    <string>MainWindow</string>
   </property>
-  <widget class="QMenuBar" name="menuBar" />
-  <widget class="QToolBar" name="mainToolBar" />
-  <widget class="QWidget" name="centralWidget" />
-  <widget class="QStatusBar" name="statusBar" />
+  <widget class="QWidget" name="centralWidget">
+   <layout class="QVBoxLayout" name="verticalLayout_8">
+    <item>
+     <widget class="QTabWidget" name="tabWidget">
+      <property name="currentIndex">
+       <number>0</number>
+      </property>
+      <widget class="QWidget" name="tab">
+       <attribute name="title">
+        <string>Action</string>
+       </attribute>
+       <layout class="QVBoxLayout" name="verticalLayout_7">
+        <item>
+         <widget class="QSplitter" name="splitter">
+          <property name="orientation">
+           <enum>Qt::Vertical</enum>
+          </property>
+          <widget class="QWidget" name="">
+           <layout class="QVBoxLayout" name="verticalLayout_2">
+            <item>
+             <widget class="QTableWidget" name="tableWidget">
+              <attribute name="horizontalHeaderStretchLastSection">
+               <bool>true</bool>
+              </attribute>
+              <column>
+               <property name="text">
+                <string>Name</string>
+               </property>
+              </column>
+              <column>
+               <property name="text">
+                <string>Target</string>
+               </property>
+              </column>
+              <column>
+               <property name="text">
+                <string>Last backup</string>
+               </property>
+              </column>
+              <column>
+               <property name="text">
+                <string>Source(s)</string>
+               </property>
+              </column>
+             </widget>
+            </item>
+            <item>
+             <layout class="QHBoxLayout" name="horizontalLayout">
+              <item>
+               <widget class="QPushButton" name="pushButtonBackup">
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="text">
+                 <string>Start</string>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <widget class="QPushButton" name="pushButtonStop">
+                <property name="enabled">
+                 <bool>false</bool>
+                </property>
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="text">
+                 <string>Stop</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>
+             </layout>
+            </item>
+           </layout>
+          </widget>
+          <widget class="QWidget" name="">
+           <layout class="QVBoxLayout" name="verticalLayout_3">
+            <item>
+             <layout class="QHBoxLayout" name="horizontalLayout_9">
+              <item>
+               <widget class="QLabel" name="label_5">
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="text">
+                 <string>Log:</string>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <widget class="QPushButton" name="pushButtonClear">
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="text">
+                 <string>Clear</string>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <spacer name="horizontalSpacer_2">
+                <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>
+             <widget class="QListWidget" name="listWidgetLog">
+              <property name="midLineWidth">
+               <number>5</number>
+              </property>
+             </widget>
+            </item>
+           </layout>
+          </widget>
+         </widget>
+        </item>
+       </layout>
+      </widget>
+      <widget class="QWidget" name="tab_2">
+       <attribute name="title">
+        <string>Configuration</string>
+       </attribute>
+       <layout class="QVBoxLayout" name="verticalLayout_9">
+        <item>
+         <widget class="QSplitter" name="splitter_2">
+          <property name="orientation">
+           <enum>Qt::Vertical</enum>
+          </property>
+          <widget class="QWidget" name="">
+           <layout class="QVBoxLayout" name="verticalLayout">
+            <item>
+             <layout class="QHBoxLayout" name="horizontalLayout_7">
+              <item>
+               <widget class="QLabel" name="label">
+                <property name="text">
+                 <string>Backup elements:</string>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <spacer name="horizontalSpacer_8">
+                <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>
+             <widget class="QTableWidget" name="tableWidget_2">
+              <attribute name="horizontalHeaderStretchLastSection">
+               <bool>true</bool>
+              </attribute>
+              <column>
+               <property name="text">
+                <string>Name</string>
+               </property>
+              </column>
+              <column>
+               <property name="text">
+                <string>Target</string>
+               </property>
+              </column>
+              <column>
+               <property name="text">
+                <string>Source(s)</string>
+               </property>
+              </column>
+             </widget>
+            </item>
+            <item>
+             <layout class="QHBoxLayout" name="horizontalLayout_6">
+              <item>
+               <widget class="QPushButton" name="pushButtonNewEntry">
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="text">
+                 <string>New entry</string>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <widget class="QPushButton" name="pushButtonDeleteEntry">
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="text">
+                 <string>Delete entry</string>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <spacer name="horizontalSpacer_9">
+                <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="pushButtonSaveConfig">
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="text">
+                 <string>Save config</string>
+                </property>
+               </widget>
+              </item>
+             </layout>
+            </item>
+           </layout>
+          </widget>
+          <widget class="QWidget" name="">
+           <layout class="QVBoxLayout" name="verticalLayout_6">
+            <item>
+             <layout class="QHBoxLayout" name="horizontalLayout_4">
+              <item>
+               <widget class="QLabel" name="label_2">
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="text">
+                 <string>Name:</string>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <widget class="QLineEdit" name="lineEditName"/>
+              </item>
+              <item>
+               <spacer name="horizontalSpacer_7">
+                <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="pushButtonUpdate">
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="text">
+                 <string>Update</string>
+                </property>
+               </widget>
+              </item>
+             </layout>
+            </item>
+            <item>
+             <layout class="QHBoxLayout" name="horizontalLayout_5">
+              <item>
+               <widget class="QLabel" name="label_3">
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="text">
+                 <string>Target:</string>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <widget class="QLineEdit" name="lineEdit"/>
+              </item>
+              <item>
+               <widget class="QPushButton" name="pushButtonSelectTarget">
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="text">
+                 <string>...</string>
+                </property>
+               </widget>
+              </item>
+             </layout>
+            </item>
+            <item>
+             <layout class="QHBoxLayout" name="horizontalLayout_8">
+              <item>
+               <widget class="QLabel" name="label_4">
+                <property name="text">
+                 <string>Source directories:</string>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <spacer name="horizontalSpacer_10">
+                <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="pushButtonAddSource">
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="text">
+                 <string>Add source</string>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <widget class="QPushButton" name="pushButtonDeleteSource">
+                <property name="minimumSize">
+                 <size>
+                  <width>125</width>
+                  <height>0</height>
+                 </size>
+                </property>
+                <property name="text">
+                 <string>Delete source</string>
+                </property>
+               </widget>
+              </item>
+             </layout>
+            </item>
+            <item>
+             <widget class="QListWidget" name="listWidget_2"/>
+            </item>
+           </layout>
+          </widget>
+         </widget>
+        </item>
+       </layout>
+      </widget>
+      <widget class="QWidget" name="tab_3">
+       <attribute name="title">
+        <string>Files</string>
+       </attribute>
+       <layout class="QVBoxLayout" name="verticalLayout_5">
+        <item>
+         <layout class="QHBoxLayout" name="horizontalLayout_2">
+          <item>
+           <widget class="QLabel" name="label_6">
+            <property name="minimumSize">
+             <size>
+              <width>125</width>
+              <height>0</height>
+             </size>
+            </property>
+            <property name="text">
+             <string>File log:</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QPushButton" name="pushButtonClearFileList">
+            <property name="minimumSize">
+             <size>
+              <width>125</width>
+              <height>0</height>
+             </size>
+            </property>
+            <property name="text">
+             <string>Clear</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <spacer name="horizontalSpacer_4">
+            <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>
+         <widget class="QListWidget" name="listWidgetFiles"/>
+        </item>
+       </layout>
+      </widget>
+      <widget class="QWidget" name="tab_4">
+       <attribute name="title">
+        <string>Errors</string>
+       </attribute>
+       <layout class="QVBoxLayout" name="verticalLayout_4">
+        <item>
+         <layout class="QHBoxLayout" name="horizontalLayout_3">
+          <item>
+           <widget class="QLabel" name="label_7">
+            <property name="minimumSize">
+             <size>
+              <width>125</width>
+              <height>0</height>
+             </size>
+            </property>
+            <property name="text">
+             <string>Error log:</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QPushButton" name="pushButtonClearErrorList">
+            <property name="minimumSize">
+             <size>
+              <width>125</width>
+              <height>0</height>
+             </size>
+            </property>
+            <property name="text">
+             <string>Clear</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <spacer name="horizontalSpacer_6">
+            <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>
+         <widget class="QListWidget" name="listWidgetErrors"/>
+        </item>
+       </layout>
+      </widget>
+     </widget>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QMenuBar" name="menuBar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>820</width>
+     <height>26</height>
+    </rect>
+   </property>
+   <widget class="QMenu" name="menuFile">
+    <property name="title">
+     <string>File</string>
+    </property>
+    <addaction name="actionLoadConfig"/>
+    <addaction name="actionSaveConfig"/>
+    <addaction name="separator"/>
+    <addaction name="actionExit"/>
+   </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>
+    <addaction name="actionStart"/>
+    <addaction name="actionStop"/>
+   </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="actionLoadConfig">
+   <property name="text">
+    <string>Load Config</string>
+   </property>
+  </action>
+  <action name="actionSaveConfig">
+   <property name="text">
+    <string>Save Config</string>
+   </property>
+  </action>
+  <action name="actionExit">
+   <property name="text">
+    <string>Exit</string>
+   </property>
+  </action>
+  <action name="actionStart">
+   <property name="text">
+    <string>Start backup</string>
+   </property>
+  </action>
+  <action name="actionStop">
+   <property name="text">
+    <string>Stop backup</string>
+   </property>
+  </action>
+  <action name="actionAbout">
+   <property name="text">
+    <string>About</string>
+   </property>
+  </action>
  </widget>
- <layoutDefault spacing="6" margin="11" />
- <pixmapfunction></pixmapfunction>
+ <layoutdefault spacing="6" margin="11"/>
  <resources/>
  <connections/>
 </ui>
index ae124c7ed3e6478ef521dbeb4afd0795071ce64c..ee9478d921297e5a4f67aae2d1c88d35a1cf93ab 100644 (file)
@@ -21,7 +21,8 @@ SOURCES += main.cpp\
         ../../gui/ReGuiValidator.cpp \
         ../../gui/ReGuiQueue.cpp \
         mainwindow.cpp \
-        aboutdialog.cpp
+        aboutdialog.cpp \
+    Configuration.cpp
 
 HEADERS  += mainwindow.hpp \
         ../../base/rebase.hpp \
@@ -29,7 +30,9 @@ HEADERS  += mainwindow.hpp \
         ../../gui/ReStateStorage.hpp \
         ../../gui/ReGuiValidator.hpp \
         ../../gui/regui.hpp \
-        aboutdialog.hpp
+        aboutdialog.hpp \
+    Configuration.hpp \
+    backupgui.hpp
 
 FORMS    += mainwindow.ui \
         aboutdialog.ui
index b3de70108c36c0cdea01a3b4027262f2e1e7e296..66fc4f23a3498891cbc3dbdcd7cb0049f848cb77 100644 (file)
@@ -41,7 +41,6 @@ MainWindow::MainWindow(const QString& homeDir, QWidget *parent) :
        ui->setupUi(this);
        initializeGuiElements();
    startStop(false);
-   statusBar()->addWidget(m_statusMessage);
    connect(ui->actionStart, SIGNAL(triggered()), this,
          SLOT(onConvert()));
    connect(ui->actionStop, SIGNAL(triggered()), this,
index 411a39c63e9422b828faec3e57953c30dda9f704..12041a938ccb06685d70d7250212e72ed98ce099 100644 (file)
 #include "base/rebase.hpp"
 
 enum {
-       LOC_DELETE_TREE_1 = LOC_FIRST_OF(LOC_FILE_UTILS), // 11801
-       LOC_DELETE_TREE_2,              // 11802
-       LOC_DELETE_TREE_3,              // 11803
-       LOC_SET_TIMES_1,                // 11804
-       LOC_MAKE_DIR_1,                 // 11805
-       LOC_MAKE_DIR_2,                 // 11806
+       LOC_DELETE_TREE_1 = LOC_FIRST_OF(LOC_FILE_UTILS), // 12501
+       LOC_DELETE_TREE_2,              // 12502
+       LOC_DELETE_TREE_3,              // 12503
+       LOC_SET_TIMES_1,                // 12504
+       LOC_MAKE_DIR_1,                 // 12505
+       LOC_MAKE_DIR_2,                 // 12506
 };
 
 QDateTime ReFileUtils::m_undefinedTime;
index a2f0f8097dd36745702bd72ef4867481156a6966..bd5aacee8e85059b9b3e24e615510c6685d6ff28 100644 (file)
@@ -29,7 +29,7 @@ public:
 class ReFileUtils {
 public:
        static bool deleteTree(const QString& path, bool withBase,
-               ReLogger* logger);
+               ReLogger* logger = NULL);
        static QByteArray cleanPath(const char* path);
        static QString cleanPath(const QString& path);
        static QString extensionOf(const QString& filename);
@@ -63,10 +63,10 @@ public:
                return path.replace(OS_2nd_SEPARATOR, OS_SEPARATOR);
 #endif
        }
-       static bool makeDir(const char* path, ReLogger* logger);
-       static bool makeDir(const QString& path, ReLogger* logger);
-       static bool makeDirWithParents(const char* path, ReLogger* logger);
-       static bool makeDirWithParents(const QString& path, ReLogger* logger);
+       static bool makeDir(const char* path, ReLogger* logger = NULL);
+       static bool makeDir(const QString& path, ReLogger* logger = NULL);
+       static bool makeDirWithParents(const char* path, ReLogger* logger = NULL);
+       static bool makeDirWithParents(const QString& path, ReLogger* logger = NULL);
        static QString nodeOf(const QString& filename);
        static QByteArray nodeOf(const char* filename);
        static QString parentOf(const QString& filename);
index 789edc751c06dac0227e5ef1fa2ce7e5dee198ee..3cc636a4238f7d17c693c090820089eee174dfc4 100644 (file)
@@ -36,12 +36,13 @@ ReString& ReQStringUtils::chomp(ReString& text, char cc) {
        int last = text.length() - 1;
        if (last >= 0){
                if (cc != '\n'){
+                       if (text.at(last) == cc)
                        text.resize(last);
                } else {
                        while (last >= 0 && (text[last] == '\n' || text[last] == '\r')) {
                                last--;
                        }
-                       text.resize(last);
+                       text.resize(last + 1);
                }
        }
        return text;
index 860914b85987a29e47e3f3f979c3a2ff2254dd94..1b5dbb4f5746d125fae4fd0ed35563e08934b1cd 100644 (file)
@@ -322,35 +322,35 @@ bool ReTest::assertEquals(const QTime& expected, const QTime& current,
 }
 
 /**
- * @brief Tests whether a value is true.
+ * @brief Tests whether a value is false.
  *
- * A value of false will be logged.
+ * A value of true will be logged.
  *
  * @param condition     value to test
  * @param file          the file containing the test
  * @param lineNo        the line number containing the test
- * @return              <code>condition</code>
+ * @return              <code>condition</code>
  */
-bool ReTest::assertTrue(bool condition, const char* file, int lineNo) {
-       if (!condition)
-               error("%s-%d: not TRUE", file, lineNo);
-       return condition;
+bool ReTest::assertFalse(bool condition, const char* file, int lineNo) {
+       if (condition)
+               error("%s-%d: not FALSE", file, lineNo);
+       return !condition;
 }
 
 /**
- * @brief Tests whether a value is false.
+ * @brief Tests whether a value is not NULL.
  *
- * A value of true will be logged.
+ * A value of NULL will be logged.
  *
- * @param condition     value to test
+ * @param ptr           value to test
  * @param file          the file containing the test
  * @param lineNo        the line number containing the test
- * @return              <code>! condition</code>
+ * @return              true: ptr is not NULL
  */
-bool ReTest::assertFalse(bool condition, const char* file, int lineNo) {
-       if (condition)
-               error("%s-%d: not FALSE", file, lineNo);
-       return !condition;
+bool ReTest::assertNotNull(const void* ptr, const char* file, int lineNo) {
+       if (ptr == NULL)
+               error("%s-%d: is NULL", file, lineNo);
+       return ptr != NULL;
 }
 
 /**
@@ -370,19 +370,19 @@ bool ReTest::assertNull(const void* ptr, const char* file, int lineNo) {
 }
 
 /**
- * @brief Tests whether a value is not NULL.
+ * @brief Tests whether a value is true.
  *
- * A value of NULL will be logged.
+ * A value of false will be logged.
  *
- * @param ptr           value to test
+ * @param condition     value to test
  * @param file          the file containing the test
  * @param lineNo        the line number containing the test
- * @return              true: ptr is not NULL
+ * @return              <code>condition</code>
  */
-bool ReTest::assertNotNull(const void* ptr, const char* file, int lineNo) {
-       if (ptr == NULL)
-               error("%s-%d: is NULL", file, lineNo);
-       return ptr != NULL;
+bool ReTest::assertTrue(bool condition, const char* file, int lineNo) {
+       if (!condition)
+               error("%s-%d: not TRUE", file, lineNo);
+       return condition;
 }
 
 /**
@@ -418,6 +418,42 @@ bool ReTest::assertEqualFiles(const char* expected, const char* current,
        return rc;
 }
 
+/**
+ * Tests whether the memory logger contains a message matching a given pattern.
+ *
+ * @param pattern      pattern to search
+ * @param isRegExpr    <code>true</code>pattern is a regular expression
+ * @param file         the source file of the test
+ * @param lineNo       the line number of the test
+ */
+void ReTest::assertLogContains(const char* pattern, bool isRegExpr,
+                                                          const char* file, int lineNo)
+{
+       if (! logContains(pattern, isRegExpr)){
+               error("%s-%d: not found: %s", file, lineNo, pattern);
+       }
+}
+
+
+/**
+ * Tests whether the memory logger contains given location.
+ *
+ * @param location     location to identify a specific logging error
+ * @param file         the source file of the test
+ * @param lineNo       the line number of the test
+ */
+void ReTest::assertLogContainsLocation(int location, const char* file, int lineNo)
+{
+       QByteArray pattern("^.20[\\d:. ]+\\(");
+       pattern += location;
+       pattern += "\\)";
+       if (! logContains(pattern, true)){
+               error("%s-%d: not found: location %d\n", file, lineNo, location,
+                         m_memoryAppender.getLines().join().constData());
+
+       }
+}
+
 /**
   * Ensures that the file (or the directory) does not exist.
   *
@@ -464,54 +500,6 @@ bool ReTest::exists(const char* fullname, bool isDir)
        return rc;
 }
 
-/**
- * @brief Writes an info.
- *
- * @param message   message to show
- * @return          true (for expressions)
- */
-bool ReTest::log(const char* message) {
-       m_logger.log(LOG_INFO, 0, message);
-       return true;
-}
-/**
- * @brief Writes a message with arguments.
- *
- * @param format    message to show. With placeholders like <code>std::printf()</code>
- * @param ...       the values for the placeholders in <code>format</code>
- * @return          true (for expressions)
- */
-bool ReTest::logv(const char* format, ...) {
-       va_list ap;
-       va_start(ap, format);
-       m_logger.log(LOG_INFO, 0, format, ap);
-       va_end(ap);
-       return true;
-}
-
-
-/**
- * @brief Tests whether the m_memoryLogger has a message containing a given pattern.
- *
- * @param pattern   regular expression to search
- * @return          true: pattern has been found<br>
- *                  false: otherwise
- */
-bool ReTest::logContains(const char* pattern) {
-       const QList<QByteArray>& lines = m_memoryAppender.getLines();
-       QRegularExpression rexpr(pattern);
-       bool rc = false;
-       QRegularExpressionMatch match;
-       for (int ii = 0; ii < lines.size(); ii++) {
-               const QByteArray& line = lines.at(ii);
-               match = rexpr.match(line);
-               if (match.hasMatch()) {
-                       rc = true;
-                       break;
-               }
-       }
-       return rc;
-}
 
 /**
  * @brief Returns the name of a directory in the temp dir.
@@ -574,3 +562,52 @@ QByteArray ReTest::getTempFile(const char* node, const char* parent,
                unlink(rc.constData());
        return rc;
 }
+/**
+ * @brief Writes an info.
+ *
+ * @param message   message to show
+ * @return          true (for expressions)
+ */
+bool ReTest::log(const char* message) {
+       m_logger.log(LOG_INFO, 0, message);
+       return true;
+}
+
+/**
+ * @brief Tests whether the m_memoryLogger has a message containing a given pattern.
+ *
+ * @param pattern   regular expression to search
+ * @return          true: pattern has been found<br>
+ *                  false: otherwise
+ */
+bool ReTest::logContains(const char* pattern, bool isRegExpr) {
+       const QList<QByteArray>& lines = m_memoryAppender.getLines();
+       QRegularExpression rexpr(pattern);
+       bool rc = false;
+       QRegularExpressionMatch match;
+       for (int ii = 0; ii < lines.size(); ii++) {
+               const QByteArray& line = lines.at(ii);
+               match = rexpr.match(line);
+               if ( (isRegExpr && match.hasMatch())
+                               || (! isRegExpr && line.indexOf(pattern) >= 0)) {
+                       rc = true;
+                       break;
+               }
+       }
+       return rc;
+}
+
+/**
+ * @brief Writes a message with arguments.
+ *
+ * @param format    message to show. With placeholders like <code>std::printf()</code>
+ * @param ...       the values for the placeholders in <code>format</code>
+ * @return          true (for expressions)
+ */
+bool ReTest::logv(const char* format, ...) {
+       va_list ap;
+       va_start(ap, format);
+       m_logger.log(LOG_INFO, 0, format, ap);
+       va_end(ap);
+       return true;
+}
index cb96c2281a4a20f05bc8ea7db62c3b4d5324f8f9..9825370dd187a42f3fb8fd10c39d27fcd5da1bb4 100644 (file)
@@ -53,6 +53,9 @@ public:
        bool assertNotNull(const void* ptr, const char* file, int lineNo);
        bool assertEqualFiles(const char* expected, const char* current,
                const char* file, int lineNo);
+       void assertLogContains(const char* pattern, bool isRegExpr,
+                                                  const char* file, int lineNo);
+       void assertLogContainsLocation(int location, const char* file, int lineNo);
        void ensureNotExist(const char* fullname);
        bool error(const char* message, ...);
        bool exists(const char* fullname, bool isDir = false);
@@ -62,7 +65,7 @@ public:
                bool withSeparator = true);
        QByteArray getTempFile(const char* node, const char* parent = NULL,
                bool deleteIfExists = true);
-       bool logContains(const char* pattern);
+       bool logContains(const char* pattern, bool isRegExpr = true);
        virtual void runTests(void) = 0;
 public:
        inline static char printChar(char cc){
@@ -84,4 +87,6 @@ protected:
 #define checkN(current) assertNull(current, __FILE__, __LINE__)
 #define checkNN(current) assertNotNull(current, __FILE__, __LINE__)
 #define checkFiles(expected, current) assertEqualFiles(expected, current, __FILE__, __LINE__)
+#define checkLogContains(pattern, isReg) assertLogContains(pattern, isReg, __FILE__, __LINE__)
+#define checkLogContainsLocation(location) assertLogContainsLocation(location, __FILE__, __LINE__)
 #endif // RETEST_HPP
index 355b27750a0bc882926724c75f718d2786f8193f..a80380e07ee0842e975b33c4eeba040803e6d615 100644 (file)
@@ -72,7 +72,7 @@ typedef QString ReString;
 #define _mkdir(path) mkdir(path, ALLPERMS)
 #define _rmdir rmdir
 #define _unlink unlink
-typedef qint64 uint64_t;
+//typedef qint64 uint64_t;
 #else
 #define _strcasecmp _stricmp
 #define OS_SEPARATOR '\\'
index 0bc2b41667a9a2c21a6e40d7057563d8e0959d02..d5394674d768810b84aa7193a57a511a50cca399 100644 (file)
@@ -44,11 +44,11 @@ static void testBase() {
        void testReWriter();
        void testReFile();
        void testReMatcher();
+       testReFileUtils();
        testReQStringUtil();
        testReProgArgs();
        testReProcess();
        testReRandomizer();
-       testReFileUtils();
        testReMatcher();
        testReFile();
        if (s_allTest) {
index c4c25d31387302ddc1e3a41969e21c446b8c4df5..8db20b295d35ed7a258ccedcb215864132bcd408 100644 (file)
@@ -323,8 +323,41 @@ public:
                checkUrl("http:index.htm", "http:", "", "",
                                 "index.htm", "");
        }
+       void testMakeDirectoryWithParents(){
+               QByteArray base(ReFileUtils::tempDir("s4711"));
+               QByteArray dir(base);
+               dir +=  "d1";
+               dir += OS_SEPARATOR;
+               dir += "d2";
+               ReFileUtils::deleteTree(QString::fromUtf8(base), true);
+               struct stat info;
+               checkF(0 == stat(base.constData(), &info));
+               // create 3 directories, not ending with a separator:
+               checkT(ReFileUtils::makeDirWithParents(dir.constData()));
+               checkEqu(0, stat(dir.constData(), &info));
+               checkEqu(0, _rmdir(dir.constData()));
+               checkF(0 == stat(dir.constData(), &info));
+               dir.append(OS_SEPARATOR);
+               // create the last directory, with an ending separator
+               checkT(ReFileUtils::makeDirWithParents(dir.constData()));
+               checkEqu(0, stat(dir.constData(), &info));
+
+               // Error: a node is a normal file
+               // Remove trailing separator
+               dir.resize(dir.length() - 1);
+               checkEqu(0, _rmdir(dir.constData()));
+               checkF(0 == stat(dir.constData(), &info));
+               ReFileUtils::writeToFile(dir.constData(), "x");
+               checkEqu(0, stat(dir.constData(), &info));
+               checkF(S_ISDIR(info.st_mode));
+               checkF(ReFileUtils::makeDirWithParents(dir.constData(), &m_memoryLogger));
+               checkLogContainsLocation(51003);
+               checkLogContains(dir.constData(), false);
+       }
 
        virtual void runTests() {
+               testMakeDirectoryWithParents();
+
                testSplitUrl();
                testParentOf();
                testCleanPath();
index 35e523df3ad870999b6c245f5d558577ebf1ed64..ed9c3bb58aabbcb113f82d3d0bd70a8b94b35faa 100644 (file)
@@ -232,8 +232,19 @@ public:
                checkEqu("23:59:59", ReQStringUtils::readableDuration(clf(24*3600-0.1)));
                checkEqu("1:02:03:04", ReQStringUtils::readableDuration(clf(24*3600+2*3600+3*60+4.0)));
        }
+       void testChomp(){
+               QString s = "abc\r\n";
+               checkEqu("abc", ReQStringUtils::chomp(s));
+               checkEqu("abc", s);
+               s = "/a/b/c/";
+               checkEqu("/a/b/c", ReQStringUtils::chomp(s, '/'));
+               checkEqu("/a/b/c", s);
+               checkEqu("/a/b/c", ReQStringUtils::chomp(s, 'b'));
+               checkEqu("/a/b/c", s);
+       }
 
        virtual void runTests(void) {
+               testChomp();
                testReadableSize();
                testReadableDuration();
                testLongestPrefix();
index 249f7bb4889c01797b046358078d78d25dff232a..6c373030361a5b83954a784ac8447cc43152e0ec 100644 (file)
@@ -106,6 +106,7 @@ void ReGuiApplication::initializeGuiElements(){
        QObject::connect(app, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
        connect(m_guiTimer, SIGNAL(timeout()), this, SLOT(guiTimerUpdate()));
        m_guiTimer->start(100);
+       statusBar()->addWidget(m_statusMessage);
 }
 
 /**
index 19e6c2b2e0661b16cdd585965c4ac9a3deedf843..6953b4d2a591ab50e51913b3f655c839a30adb33 100644 (file)
@@ -29,13 +29,14 @@ enum {
        LOC_MFPARSER, // 115
        LOC_TRAVERSER,
        LOC_SETTINGS,
-       LOC_FILE_UTILS,
+       LOC_FILE,
        LOC_FILETREE,
        LOC_STATESTORAGE,       // 120
        LOC_FILESYSTEM,
        LOC_RANDOMIZER,
        LOC_CRYPTFILESYSTEM,
        LOC_GUI_APPLICATION,
+       LOC_FILE_UTILS,         // 125
 
        // Applications:
        LOC_RECFORM_CPPPARSER = 201,