]> gitweb.hamatoma.de Git - reqt/commitdiff
placeholder dialogs, state storage works
authorhama <hama@siduction.net>
Sun, 26 Apr 2015 14:03:43 +0000 (16:03 +0200)
committerhama <hama@siduction.net>
Sun, 26 Apr 2015 14:03:43 +0000 (16:03 +0200)
15 files changed:
appl/refind/dialogfileplaceholder.cpp [new file with mode: 0644]
appl/refind/dialogfileplaceholder.hpp [new file with mode: 0644]
appl/refind/dialogfileplaceholder.ui [new file with mode: 0644]
appl/refind/dialogglobalplaceholder.cpp [new file with mode: 0644]
appl/refind/dialogglobalplaceholder.hpp [new file with mode: 0644]
appl/refind/dialogglobalplaceholder.ui [new file with mode: 0644]
appl/refind/main.cpp
appl/refind/mainwindow.cpp
appl/refind/mainwindow.hpp
appl/refind/mainwindow.ui
appl/refind/refind.pro
base/ReQStringUtil.cpp
base/ReQStringUtil.hpp
gui/ReStateStorage.cpp
gui/ReStateStorage.hpp

diff --git a/appl/refind/dialogfileplaceholder.cpp b/appl/refind/dialogfileplaceholder.cpp
new file mode 100644 (file)
index 0000000..5ea4100
--- /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 "dialogfileplaceholder.hpp"
+#include "ui_dialogfileplaceholders.h"
+
+DialogFilePlaceholder::DialogFilePlaceholder(QWidget *parent) :
+         QDialog(parent), ui(new Ui::DialogFilePlaceHolders){
+   ui->setupUi(this);
+   connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(ok()));
+}
+
+DialogFilePlaceholder::~DialogFilePlaceholder(){
+   delete ui;
+}
+
+/**
+ * Handles the push of the OK button.
+ */
+void DialogFilePlaceholder::ok(){
+   int row = ui->tableWidget->currentRow();
+   if (row >= 0)
+      m_var = ui->tableWidget->item(row, COL_VAR)->text();
+   close();
+}
+/**
+ * Returns the selected placeholder.
+ *
+ * @return  "": nothing selected<br>
+ *          otherwise: the name of the selected placeholder
+ */
+QString DialogFilePlaceholder::var() const{
+   return m_var;
+}
+
diff --git a/appl/refind/dialogfileplaceholder.hpp b/appl/refind/dialogfileplaceholder.hpp
new file mode 100644 (file)
index 0000000..10c46e3
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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 DIALOGLINEPLACEHOLDERS_HPP
+#define DIALOGLINEPLACEHOLDERS_HPP
+
+#include <QDialog>
+
+namespace Ui {
+class DialogFilePlaceHolders;
+}
+
+class DialogFilePlaceholder: public QDialog {
+   Q_OBJECT
+
+public:
+   enum {
+      COL_VAR, COL_EXAMPLE, COL_DESCR
+   };
+public:
+   explicit DialogFilePlaceholder(QWidget *parent = 0);
+   ~DialogFilePlaceholder();
+public:
+   QString var() const;public slots:
+   void ok();
+
+private:
+   Ui::DialogFilePlaceHolders *ui;
+   QString m_var;
+};
+
+#endif // DIALOGLINEPLACEHOLDERS_HPP
diff --git a/appl/refind/dialogfileplaceholder.ui b/appl/refind/dialogfileplaceholder.ui
new file mode 100644 (file)
index 0000000..214be86
--- /dev/null
@@ -0,0 +1,328 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogFilePlaceHolders</class>
+ <widget class="QDialog" name="DialogFilePlaceHolders">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>800</width>
+    <height>429</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>File Specific Placeholders</string>
+  </property>
+  <property name="modal">
+   <bool>true</bool>
+  </property>
+  <widget class="QDialogButtonBox" name="buttonBox">
+   <property name="geometry">
+    <rect>
+     <x>440</x>
+     <y>380</y>
+     <width>341</width>
+     <height>32</height>
+    </rect>
+   </property>
+   <property name="orientation">
+    <enum>Qt::Horizontal</enum>
+   </property>
+   <property name="standardButtons">
+    <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+   </property>
+  </widget>
+  <widget class="QTableWidget" name="tableWidget">
+   <property name="geometry">
+    <rect>
+     <x>20</x>
+     <y>20</y>
+     <width>761</width>
+     <height>351</height>
+    </rect>
+   </property>
+   <attribute name="horizontalHeaderDefaultSectionSize">
+    <number>190</number>
+   </attribute>
+   <attribute name="horizontalHeaderStretchLastSection">
+    <bool>true</bool>
+   </attribute>
+   <attribute name="verticalHeaderVisible">
+    <bool>false</bool>
+   </attribute>
+   <attribute name="verticalHeaderStretchLastSection">
+    <bool>true</bool>
+   </attribute>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <column>
+    <property name="text">
+     <string>Placeholder</string>
+    </property>
+   </column>
+   <column>
+    <property name="text">
+     <string>Example</string>
+    </property>
+   </column>
+   <column>
+    <property name="text">
+     <string>Description</string>
+    </property>
+   </column>
+   <item row="0" column="0">
+    <property name="text">
+     <string>${base}</string>
+    </property>
+   </item>
+   <item row="0" column="1">
+    <property name="text">
+     <string>/home/bob</string>
+    </property>
+   </item>
+   <item row="0" column="2">
+    <property name="text">
+     <string>base directory</string>
+    </property>
+   </item>
+   <item row="1" column="0">
+    <property name="text">
+     <string notr="true">${full}</string>
+    </property>
+   </item>
+   <item row="1" column="1">
+    <property name="text">
+     <string notr="true">/home/bob/doc/intro.txt</string>
+    </property>
+   </item>
+   <item row="1" column="2">
+    <property name="text">
+     <string>filename with absolute path</string>
+    </property>
+   </item>
+   <item row="2" column="0">
+    <property name="text">
+     <string notr="true">${path}</string>
+    </property>
+   </item>
+   <item row="2" column="1">
+    <property name="text">
+     <string notr="true">doc</string>
+    </property>
+   </item>
+   <item row="2" column="2">
+    <property name="text">
+     <string>relative path</string>
+    </property>
+   </item>
+   <item row="3" column="0">
+    <property name="text">
+     <string notr="true">${node}</string>
+    </property>
+   </item>
+   <item row="3" column="1">
+    <property name="text">
+     <string notr="true">intro.txt</string>
+    </property>
+   </item>
+   <item row="3" column="2">
+    <property name="text">
+     <string>filename with extension</string>
+    </property>
+   </item>
+   <item row="4" column="0">
+    <property name="text">
+     <string notr="true">${name}</string>
+    </property>
+   </item>
+   <item row="4" column="1">
+    <property name="text">
+     <string notr="true">intro</string>
+    </property>
+   </item>
+   <item row="4" column="2">
+    <property name="text">
+     <string>filename without extension</string>
+    </property>
+   </item>
+   <item row="5" column="0">
+    <property name="text">
+     <string notr="true">${ext}</string>
+    </property>
+   </item>
+   <item row="5" column="1">
+    <property name="text">
+     <string notr="true">.txt</string>
+    </property>
+   </item>
+   <item row="5" column="2">
+    <property name="text">
+     <string>extension</string>
+    </property>
+   </item>
+   <item row="6" column="0">
+    <property name="text">
+     <string notr="true">${modified}</string>
+    </property>
+   </item>
+   <item row="6" column="1">
+    <property name="text">
+     <string notr="true">2015.04.03/08:07:14</string>
+    </property>
+   </item>
+   <item row="6" column="2">
+    <property name="text">
+     <string>date/time of the last change</string>
+    </property>
+   </item>
+   <item row="7" column="0">
+    <property name="text">
+     <string notr="true">${size}</string>
+    </property>
+   </item>
+   <item row="7" column="1">
+    <property name="text">
+     <string notr="true">0.001223</string>
+    </property>
+   </item>
+   <item row="7" column="2">
+    <property name="text">
+     <string>file length in megabyte</string>
+    </property>
+   </item>
+   <item row="8" column="0">
+    <property name="text">
+     <string notr="true">${type}</string>
+    </property>
+   </item>
+   <item row="8" column="1">
+    <property name="text">
+     <string notr="true">file</string>
+    </property>
+   </item>
+   <item row="8" column="2">
+    <property name="text">
+     <string>'file', 'dir', 'link (file)', 'link (dir)'</string>
+    </property>
+   </item>
+   <item row="9" column="0">
+    <property name="text">
+     <string>\t</string>
+    </property>
+   </item>
+   <item row="9" column="1">
+    <property name="text">
+     <string notr="true">\t</string>
+    </property>
+   </item>
+   <item row="9" column="2">
+    <property name="text">
+     <string>tabulator</string>
+    </property>
+   </item>
+   <item row="10" column="0">
+    <property name="text">
+     <string notr="true">\n</string>
+    </property>
+   </item>
+   <item row="10" column="1">
+    <property name="text">
+     <string notr="true">\n</string>
+    </property>
+   </item>
+   <item row="10" column="2">
+    <property name="text">
+     <string>newline</string>
+    </property>
+   </item>
+  </widget>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>DialogFilePlaceHolders</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>DialogFilePlaceHolders</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
diff --git a/appl/refind/dialogglobalplaceholder.cpp b/appl/refind/dialogglobalplaceholder.cpp
new file mode 100644 (file)
index 0000000..a882081
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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 "dialogglobalplaceholder.hpp"
+#include "ui_dialogglobalplaceholder.h"
+
+DialogGlobalPlaceholder::DialogGlobalPlaceholder(QWidget *parent) :
+         QDialog(parent), ui(new Ui::DialogGlobalPlaceholder), m_var(){
+   ui->setupUi(this);
+   connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(ok()));
+}
+
+DialogGlobalPlaceholder::~DialogGlobalPlaceholder(){
+   delete ui;
+}
+
+/**
+ * Handles the push of the OK button.
+ */
+void DialogGlobalPlaceholder::ok(){
+   int row = ui->tableWidget->currentRow();
+   if (row >= 0)
+      m_var = ui->tableWidget->item(row, COL_VAR)->text();
+   close();
+}
+
+/**
+ * Returns the selected placeholder.
+ *
+ * @return  "": nothing selected<br>
+ *          otherwise: the name of the selected placeholder
+ */
+QString DialogGlobalPlaceholder::var() const{
+   return m_var;
+}
+
diff --git a/appl/refind/dialogglobalplaceholder.hpp b/appl/refind/dialogglobalplaceholder.hpp
new file mode 100644 (file)
index 0000000..03cbf00
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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 DIALOGGLOBALPLACEHOLDER_HPP
+#define DIALOGGLOBALPLACEHOLDER_HPP
+
+#include <QDialog>
+
+namespace Ui {
+class DialogGlobalPlaceholder;
+}
+
+class DialogGlobalPlaceholder: public QDialog {
+   Q_OBJECT
+public:
+   enum {
+      COL_VAR, COL_DESCR
+   };
+
+public:
+   explicit DialogGlobalPlaceholder(QWidget *parent = 0);
+   ~DialogGlobalPlaceholder();
+public:
+   QString var() const;
+
+public slots:
+   void ok();
+private:
+   Ui::DialogGlobalPlaceholder *ui;
+   QString m_var;
+};
+
+#endif // DIALOGGLOBALPLACEHOLDER_HPP
diff --git a/appl/refind/dialogglobalplaceholder.ui b/appl/refind/dialogglobalplaceholder.ui
new file mode 100644 (file)
index 0000000..84d711c
--- /dev/null
@@ -0,0 +1,283 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogGlobalPlaceholder</class>
+ <widget class="QDialog" name="DialogGlobalPlaceholder">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>583</width>
+    <height>470</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Placeholders for Header and Footer</string>
+  </property>
+  <property name="modal">
+   <bool>true</bool>
+  </property>
+  <widget class="QDialogButtonBox" name="buttonBox">
+   <property name="geometry">
+    <rect>
+     <x>220</x>
+     <y>420</y>
+     <width>341</width>
+     <height>32</height>
+    </rect>
+   </property>
+   <property name="orientation">
+    <enum>Qt::Horizontal</enum>
+   </property>
+   <property name="standardButtons">
+    <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+   </property>
+  </widget>
+  <widget class="QTableWidget" name="tableWidget">
+   <property name="geometry">
+    <rect>
+     <x>20</x>
+     <y>20</y>
+     <width>541</width>
+     <height>391</height>
+    </rect>
+   </property>
+   <attribute name="horizontalHeaderDefaultSectionSize">
+    <number>150</number>
+   </attribute>
+   <attribute name="horizontalHeaderStretchLastSection">
+    <bool>true</bool>
+   </attribute>
+   <attribute name="verticalHeaderVisible">
+    <bool>false</bool>
+   </attribute>
+   <attribute name="verticalHeaderStretchLastSection">
+    <bool>true</bool>
+   </attribute>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <row>
+    <property name="text">
+     <string>New Row</string>
+    </property>
+   </row>
+   <column>
+    <property name="text">
+     <string>Placeholder</string>
+    </property>
+   </column>
+   <column>
+    <property name="text">
+     <string>Description</string>
+    </property>
+   </column>
+   <item row="0" column="0">
+    <property name="text">
+     <string>${datetime}</string>
+    </property>
+   </item>
+   <item row="0" column="1">
+    <property name="text">
+     <string>current date/time</string>
+    </property>
+   </item>
+   <item row="1" column="0">
+    <property name="text">
+     <string>${filepatterns}</string>
+    </property>
+   </item>
+   <item row="1" column="1">
+    <property name="text">
+     <string>current file patterns</string>
+    </property>
+   </item>
+   <item row="2" column="0">
+    <property name="text">
+     <string>${textpattern}</string>
+    </property>
+   </item>
+   <item row="2" column="1">
+    <property name="text">
+     <string>current text pattern</string>
+    </property>
+   </item>
+   <item row="3" column="0">
+    <property name="text">
+     <string>${dirs}</string>
+    </property>
+   </item>
+   <item row="3" column="1">
+    <property name="text">
+     <string>count of found directories</string>
+    </property>
+   </item>
+   <item row="4" column="0">
+    <property name="text">
+     <string>${files}</string>
+    </property>
+   </item>
+   <item row="4" column="1">
+    <property name="text">
+     <string>count of found files</string>
+    </property>
+   </item>
+   <item row="5" column="0">
+    <property name="text">
+     <string>${bytes}</string>
+    </property>
+   </item>
+   <item row="5" column="1">
+    <property name="text">
+     <string>sum of the lengths of the found files</string>
+    </property>
+   </item>
+   <item row="6" column="0">
+    <property name="text">
+     <string>${megabytes}</string>
+    </property>
+   </item>
+   <item row="6" column="1">
+    <property name="text">
+     <string>sum of the lengths of the found files in MBytes</string>
+    </property>
+   </item>
+   <item row="7" column="0">
+    <property name="text">
+     <string>${runtime}</string>
+    </property>
+   </item>
+   <item row="7" column="1">
+    <property name="text">
+     <string>runtime of the search in seconds</string>
+    </property>
+   </item>
+   <item row="8" column="0">
+    <property name="text">
+     <string>\n</string>
+    </property>
+   </item>
+   <item row="8" column="1">
+    <property name="text">
+     <string>newline (line feed)</string>
+    </property>
+   </item>
+   <item row="9" column="0">
+    <property name="text">
+     <string>\r</string>
+    </property>
+   </item>
+   <item row="9" column="1">
+    <property name="text">
+     <string>newline character (carriage return)</string>
+    </property>
+   </item>
+   <item row="10" column="0">
+    <property name="text">
+     <string>\t</string>
+    </property>
+   </item>
+   <item row="10" column="1">
+    <property name="text">
+     <string>tabulator</string>
+    </property>
+   </item>
+   <item row="11" column="0">
+    <property name="text">
+     <string>\\</string>
+    </property>
+   </item>
+   <item row="11" column="1">
+    <property name="text">
+     <string>backslash</string>
+    </property>
+   </item>
+  </widget>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>DialogGlobalPlaceholder</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>DialogGlobalPlaceholder</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>
index 3e01aff1c5459db9c3e5dfee9d23c4b1a7780c2e..d9e4218a9c1fe8dba80ac687be568a0184fda2c9 100644 (file)
 #include "mainwindow.hpp"
 
 int main(int argc, char *argv[]){
-   QApplication a(argc, argv);
-   MainWindow w(argc > 1 ? argv[1] : "");
+   QApplication app(argc, argv);
+   QString startDir = argc > 1 ? argv[1] : "";
+   QString homeDir = argc > 2 ? argv[2] : "";
+   MainWindow w(startDir, homeDir);
+
+   QObject::connect(&app, SIGNAL(aboutToQuit()), &w, SLOT(closing()));
+
    w.show();
 
-   return a.exec();
+   return app.exec();
 }
index 588752244ce3fbf0ec87ed5338404a2c8bfd9fef..1de8f6ad2875c98f32ad04642090e7a7ca0208e8 100644 (file)
@@ -18,6 +18,8 @@
 #include "textfinder.hpp"
 #include "mainwindow.hpp"
 #include "ui_mainwindow.h"
+#include "dialogfileplaceholder.hpp"
+#include "dialogglobalplaceholder.hpp"
 #include "filefinder.hpp"
 #include "aboutdialog.hpp"
 
@@ -26,7 +28,8 @@
  *
  * @param parent    NULL or the parent widget
  */
-MainWindow::MainWindow(const QString& startDir, QWidget *parent) :
+MainWindow::MainWindow(const QString& startDir, const QString& homeDir,
+   QWidget *parent) :
             QMainWindow(parent),
             ui(new Ui::MainWindow),
             m_statusMessage(NULL),
@@ -34,11 +37,16 @@ MainWindow::MainWindow(const QString& startDir, QWidget *parent) :
             m_textFinder(),
             m_lastBaseDir(),
             m_horizontalHeader(NULL),
-            m_lastOrder(Qt::DescendingOrder){
+            m_lastOrder(Qt::DescendingOrder),
+            m_homeDir(),
+            m_storageFile(){
    ui->setupUi(this);
+   initializeHome();
    m_statusMessage = new QLabel(tr("Willkommen bei refind"));
-   ui->comboBoxDirectory->setCurrentText(
-      startDir.isEmpty() ? QDir::currentPath() : startDir);
+   if (!startDir.isEmpty())
+      ui->comboBoxDirectory->setCurrentText(startDir);
+   if (ui->comboBoxDirectory->currentText().isEmpty())
+      ui->comboBoxDirectory->setCurrentText(QDir::currentPath());
    statusBar()->addWidget(m_statusMessage);
    connect(ui->actionSearch, SIGNAL(triggered()), this, SLOT(search()));
    connect(ui->pushButtonSearch, SIGNAL(clicked()), this, SLOT(search()));
@@ -47,6 +55,8 @@ MainWindow::MainWindow(const QString& startDir, QWidget *parent) :
    connect(ui->pushButtonUp, SIGNAL(clicked()), this, SLOT(up()));
    connect(ui->actionSelectDirectory, SIGNAL(triggered()), this,
       SLOT(selectDirectory()));
+   connect(ui->actionSaveProgramState, SIGNAL(triggered()), this,
+      SLOT(saveState()));
    connect(ui->pushButtonDirectory, SIGNAL(clicked()), this,
       SLOT(selectDirectory()));
    connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
@@ -62,6 +72,12 @@ MainWindow::MainWindow(const QString& startDir, QWidget *parent) :
    connect(ui->pushButtonExport, SIGNAL(clicked()), this, SLOT(exportFiles()));
    connect(ui->pushButtonExportFile, SIGNAL(clicked()), this,
       SLOT(selectExportFile()));
+   connect(ui->pushButtonFilePlaceholder, SIGNAL(clicked()), this,
+      SLOT(filePlaceholder()));
+   connect(ui->pushButtonHeaderPlaceholder, SIGNAL(clicked()), this,
+      SLOT(headerPlaceholder()));
+   connect(ui->pushButtonFooterPlaceholder, SIGNAL(clicked()), this,
+      SLOT(footerPlaceholder()));
 
    m_horizontalHeader = ui->tableWidget->horizontalHeader();
    connect(m_horizontalHeader, SIGNAL(sectionClicked ( int ) ),
@@ -74,6 +90,27 @@ MainWindow::MainWindow(const QString& startDir, QWidget *parent) :
    ui->tableWidget->horizontalHeader()->setStretchLastSection(true);
 }
 
+/**
+ * initializeHomeializes the program home directory.
+ */
+void MainWindow::initializeHome(){
+   if (m_homeDir.isEmpty()){
+      m_homeDir = QDir::home().absoluteFilePath(".refind");
+   }
+
+   QDir home(m_homeDir);
+   if (!home.exists()){
+      if (!home.mkpath(m_homeDir)){
+         m_homeDir = home.tempPath() + "/.refind";
+         home.mkpath(m_homeDir);
+      }
+   }
+   if (!m_homeDir.endsWith("/"))
+      m_homeDir += "/";
+   m_storageFile = m_homeDir + "state.conf";
+   restoreState();
+}
+
 /**
  * Handles the event "header column clicked".
  *
@@ -109,6 +146,25 @@ void MainWindow::about(){
    dialog.exec();
 }
 
+/**
+ * Puts the absolute path of the current (selected) file into the clipboard.
+ */
+void MainWindow::absPathToClipboard(){
+   int row = ui->tableWidget->currentRow();
+   if (row >= 0){
+      QClipboard *clipboard = QApplication::clipboard();
+      clipboard->setText(buildAbsPath(row));
+   }
+}
+
+/**
+ * Puts the base directory into the clipboard.
+ */
+void MainWindow::baseDirToClipboard(){
+   QClipboard *clipboard = QApplication::clipboard();
+   clipboard->setText(m_lastBaseDir.absolutePath());
+}
+
 /**
  * Gets the absolute path of the file in the given row.
  *
@@ -124,22 +180,47 @@ QString MainWindow::buildAbsPath(int row){
 }
 
 /**
- * Puts the absolute path of the current (selected) file into the clipboard.
+ * Converts the checkbox states to a filetype mask.
+ * @return the filetypes selected by the checkboxes
  */
-void MainWindow::absPathToClipboard(){
-   int row = ui->tableWidget->currentRow();
-   if (row >= 0){
-      QClipboard *clipboard = QApplication::clipboard();
-      clipboard->setText(buildAbsPath(row));
-   }
+QDir::Filters MainWindow::buildFileTypes(){
+   QDir::Filters rc = 0;
+   if (ui->checkBoxDirs->isChecked())
+      rc |= QDir::Dirs;
+   if (ui->checkBoxFiles->isChecked())
+      rc |= QDir::Files;
+   if (rc == 0)
+      rc |= QDir::Dirs | QDir::Files;
+   if (!ui->checkBoxLinks->isChecked())
+      rc |= QDir::NoSymLinks;
+   if (ui->checkBoxHidden)
+      rc |= QDir::Hidden | QDir::System;
+   QDir::Filters mask = 0;
+   if (ui->checkBoxWritable->isChecked())
+      mask |= QDir::Writable;
+   if (ui->checkBoxReadable->isChecked())
+      mask |= QDir::Readable;
+   if (ui->checkBoxExecutable->isChecked())
+      mask |= QDir::Executable;
+   if (mask == 0)
+      mask |= QDir::PermissionMask;
+   rc |= mask;
+   return rc;
 }
 
 /**
- * Puts the base directory into the clipboard.
+ * Gets the content of the given cell as string.
+ *
+ * @param row   the row number: 0..R-1
+ * @param col   the column number: 0..C-1
+ * @return      the text of the given cell
  */
-void MainWindow::baseDirToClipboard(){
-   QClipboard *clipboard = QApplication::clipboard();
-   clipboard->setText(m_lastBaseDir.absolutePath());
+QString MainWindow::cellAsText(int row, int col){
+   QTableWidgetItem* widget = ui->tableWidget->item(row, col);
+   QString rc;
+   if (widget != NULL)
+      rc = widget->text();
+   return rc;
 }
 
 /**
@@ -178,50 +259,39 @@ QString replaceEscSequences(const QString& text){
    return rc;
 }
 
+void MainWindow::closing(){
+   saveState();
+}
+
 /**
- * Replaces placeholders valid in header and footer.
- *
- * @param text  the text to convert
- * @return      <code>text</code> with the esc sequences replaced
+ * Handles the click of the "export" button.
  */
-QString MainWindow::replaceGlobalPlaceholder(const QString& text){
-   int start = 0;
-   QString replacement;
-   QString name;
-   QString rc = text;
-   while (start >= 0){
-      start = rc.indexOf("${", start);
-      if (start < 0)
-         break;
-      int end = rc.indexOf('}', start + 1);
-      if (end < 0)
-         break;
-      name = rc.mid(start + 2, end - start - 2);
-      if (name == "filepatterns")
-         replacement = ui->comboBoxFilePatterns->currentText();
-      else if (name == "base")
-         replacement = m_lastBaseDir.absolutePath();
-      else if (name == "textpattern")
-         replacement = ui->comboBoxTextPattern->currentText();
-      else if (name == "dirs")
-         replacement = QString::number(m_statistics.m_dirs);
-      else if (name == "files")
-         replacement = QString::number(m_statistics.m_files);
-      else if (name == "runtime")
-         replacement = QString::number(m_statistics.m_runtimeSeconds, 'g', 3);
-      else if (name == "bytes")
-         replacement = QString::number(m_statistics.m_bytes);
-      else if (name == "megabytes")
-         replacement = QString::number((double) m_statistics.m_bytes / 1000000);
+void MainWindow::exportFiles(){
+   comboText(ui->comboBoxHeader);
+   comboText(ui->comboBoxTemplate);
+   comboText(ui->comboBoxExportFile);
+   comboText(ui->comboBoxFooter);
+   if (ui->radioButtonFile->isChecked()){
+      QString fn = ui->comboBoxExportFile->currentText();
+      FILE* fp = fopen(fn.toUtf8(), "w");
+      if (fp == NULL)
+         guiError(ui->comboBoxExportFile, tr("not a valid file: ") + fn);
       else{
-         QString msg = tr("unknown placeholder: ") + name;
-         guiError(ui->comboBoxFooter, msg);
-         break;
+         QTextStream stream(fp);
+         exportToStream(stream);
+         fclose(fp);
+         setStatusMessage(false, tr("result exported to ") + fn);
       }
-      rc = rc.replace("${" + name + "}", replacement);
-      start += replacement.length();
+   }else{
+      QString value;
+      QTextStream stream(&value);
+      m_errors = 0;
+      exportToStream(stream);
+      QClipboard* clipboard = QApplication::clipboard();
+      clipboard->setText(value);
+      if (m_errors == 0)
+         setStatusMessage(false, tr("result exported to the clipboard"));
    }
-   return replaceEscSequences(rc);
 }
 
 /**
@@ -235,7 +305,7 @@ void MainWindow::exportToStream(QTextStream& stream, int maxRow){
       stream << replaceGlobalPlaceholder(ui->comboBoxHeader->currentText())
          << endl;
    }
-   int count = ui->tabWidget->count();
+   int count = ui->tableWidget->rowCount();
    if (count > 0 && maxRow > 0)
       count = maxRow;
    for (int ii = 0; ii < count; ii++){
@@ -284,49 +354,22 @@ void MainWindow::exportToStream(QTextStream& stream, int maxRow){
 }
 
 /**
- * Handles the click of the "export" button.
+ * Handles the push of "select file placeholder".
  */
-void MainWindow::exportFiles(){
-   comboText(ui->comboBoxHeader);
-   comboText(ui->comboBoxTemplate);
-   comboText(ui->comboBoxExportFile);
-   comboText(ui->comboBoxFooter);
-   if (ui->radioButtonFile->isChecked()){
-      QString fn = ui->comboBoxExportFile->currentText();
-      FILE* fp = fopen(fn.toUtf8(), "w");
-      if (fp == NULL)
-         guiError(ui->comboBoxExportFile, tr("not a valid file: ") + fn);
-      else{
-         QTextStream stream(fp);
-         exportToStream(stream);
-         fclose(fp);
-         setStatusMessage(false, tr("result exported to ") + fn);
-      }
-   }else{
-      QString value;
-      QTextStream stream(&value);
-      m_errors = 0;
-      exportToStream(stream);
-      QClipboard* clipboard = QApplication::clipboard();
-      clipboard->setText(value);
-      if (m_errors == 0)
-         setStatusMessage(false, tr("result exported to the clipboard"));
+void MainWindow::filePlaceholder(){
+   DialogFilePlaceholder dialog;
+   dialog.exec();
+   if (!dialog.var().isEmpty()){
+      QComboBox* target = ui->comboBoxTemplate;
+      target->setCurrentText(target->currentText() + dialog.var());
    }
 }
 
 /**
- * Gets the content of the given cell as string.
- *
- * @param row   the row number: 0..R-1
- * @param col   the column number: 0..C-1
- * @return      the text of the given cell
+ * Handles the push of "select placeholder for the footer".
  */
-QString MainWindow::cellAsText(int row, int col){
-   QTableWidgetItem* widget = ui->tableWidget->item(row, col);
-   QString rc;
-   if (widget != NULL)
-      rc = widget->text();
-   return rc;
+void MainWindow::footerPlaceholder(){
+   handlePlaceholder(ui->comboBoxFooter);
 }
 
 /**
@@ -343,32 +386,22 @@ void MainWindow::fullNameToClipboard(){
 }
 
 /**
- * Converts the checkbox states to a filetype mask.
- * @return the filetypes selected by the checkboxes
+ * Handles the global placeholder selection dialog.
+ *
+ * @param target    OUT: the combobox where the result is appended
  */
-QDir::Filters MainWindow::buildFileTypes(){
-   QDir::Filters rc = 0;
-   if (ui->checkBoxDirs->isChecked())
-      rc |= QDir::Dirs;
-   if (ui->checkBoxFiles->isChecked())
-      rc |= QDir::Files;
-   if (rc == 0)
-      rc |= QDir::Dirs | QDir::Files;
-   if (!ui->checkBoxLinks->isChecked())
-      rc |= QDir::NoSymLinks;
-   if (ui->checkBoxHidden)
-      rc |= QDir::Hidden | QDir::System;
-   QDir::Filters mask = 0;
-   if (ui->checkBoxWritable->isChecked())
-      mask |= QDir::Writable;
-   if (ui->checkBoxReadable->isChecked())
-      mask |= QDir::Readable;
-   if (ui->checkBoxExecutable->isChecked())
-      mask |= QDir::Executable;
-   if (mask == 0)
-      mask |= QDir::PermissionMask;
-   rc |= mask;
-   return rc;
+void MainWindow::handlePlaceholder(QComboBox* target){
+   DialogGlobalPlaceholder dialog;
+   dialog.exec();
+   if (!dialog.var().isEmpty())
+      target->setCurrentText(target->currentText() + dialog.var());
+}
+
+/**
+ * Handles the push of "select placeholder for the header".
+ */
+void MainWindow::headerPlaceholder(){
+   handlePlaceholder(ui->comboBoxHeader);
 }
 
 /**
@@ -384,6 +417,60 @@ void MainWindow::prepareTextFind(){
    }
 }
 
+/**
+ * Replaces placeholders valid in header and footer.
+ *
+ * @param text  the text to convert
+ * @return      <code>text</code> with the esc sequences replaced
+ */
+QString MainWindow::replaceGlobalPlaceholder(const QString& text){
+   int start = 0;
+   QString replacement;
+   QString name;
+   QString rc = text;
+   while (start >= 0){
+      start = rc.indexOf("${", start);
+      if (start < 0)
+         break;
+      int end = rc.indexOf('}', start + 1);
+      if (end < 0)
+         break;
+      name = rc.mid(start + 2, end - start - 2);
+      if (name == "filepatterns")
+         replacement = ui->comboBoxFilePatterns->currentText();
+      else if (name == "base")
+         replacement = m_lastBaseDir.absolutePath();
+      else if (name == "textpattern")
+         replacement = ui->comboBoxTextPattern->currentText();
+      else if (name == "dirs")
+         replacement = QString::number(m_statistics.m_dirs);
+      else if (name == "files")
+         replacement = QString::number(m_statistics.m_files);
+      else if (name == "runtime")
+         replacement = QString::number(m_statistics.m_runtimeSeconds, 'g', 3);
+      else if (name == "bytes")
+         replacement = QString::number(m_statistics.m_bytes);
+      else if (name == "megabytes")
+         replacement = QString::number((double) m_statistics.m_bytes / 1000000);
+      else if (name == "datetime")
+         replacement = QDateTime::currentDateTime().toLocalTime().toString(
+            "yyyy.MM.dd/hh:mm:ss");
+      else{
+         QString msg = tr("unknown placeholder: ") + name;
+         guiError(ui->comboBoxFooter, msg);
+         break;
+      }
+      rc = rc.replace("${" + name + "}", replacement);
+      start += replacement.length();
+   }
+   return replaceEscSequences(rc);
+}
+
+/**
+ * @brief Handles the action "reset parameters".
+ *
+ * Most of the filter parameters will be set to the default.
+ */
 void MainWindow::resetParameters(){
    ui->comboBoxFilePatterns->setCurrentText("");
    ui->comboBoxMaxDepth->setCurrentText("");
@@ -405,6 +492,52 @@ void MainWindow::resetParameters(){
    ui->checkBoxExecutable->setChecked(true);
 }
 
+/**
+ * Handles the push of the button "select directory".
+ */
+void MainWindow::restoreState(){
+   ReStateStorage storage(m_storageFile);
+   storage.setForm("main");
+   storage.restore(ui->comboBoxDirectory, "comboBoxDirectory", true);
+   storage.restore(ui->comboBoxExcludedDirs, "comboBoxExcludedDirs", true);
+   storage.restore(ui->comboBoxExportFile, "comboBoxExportFile", true);
+   storage.restore(ui->comboBoxFilePatterns, "comboBoxFilePatterns");
+   storage.restore(ui->comboBoxFooter, "comboBoxFooter", true);
+   storage.restore(ui->comboBoxHeader, "comboBoxHeader", true);
+   storage.restore(ui->comboBoxMaxDepth, "comboBoxMaxDepth");
+   storage.restore(ui->comboBoxMaxSize, "comboBoxMaxSize");
+   storage.restore(ui->comboBoxMinDepth, "comboBoxMinDepth");
+   storage.restore(ui->comboBoxMinSize, "comboBoxMinSize");
+   storage.restore(ui->comboBoxOlder, "comboBoxOlder");
+   storage.restore(ui->comboBoxTemplate, "comboBoxTemplate", true);
+   storage.restore(ui->comboBoxTextPattern, "comboBoxTextPattern");
+   storage.restore(ui->comboBoxYounger, "comboBoxYounger");
+   storage.close();
+}
+
+/**
+ * Handles the push of the button "select directory".
+ */
+void MainWindow::saveState(){
+   ReStateStorage storage(m_storageFile);
+   storage.setForm("main");
+   storage.store(ui->comboBoxDirectory, "comboBoxDirectory");
+   storage.store(ui->comboBoxExcludedDirs, "comboBoxExcludedDirs");
+   storage.store(ui->comboBoxExportFile, "comboBoxExportFile");
+   storage.store(ui->comboBoxFilePatterns, "comboBoxFilePatterns");
+   storage.store(ui->comboBoxFooter, "comboBoxFooter");
+   storage.store(ui->comboBoxHeader, "comboBoxHeader");
+   storage.store(ui->comboBoxMaxDepth, "comboBoxMaxDepth");
+   storage.store(ui->comboBoxMaxSize, "comboBoxMaxSize");
+   storage.store(ui->comboBoxMinDepth, "comboBoxMinDepth");
+   storage.store(ui->comboBoxMinSize, "comboBoxMinSize");
+   storage.store(ui->comboBoxOlder, "comboBoxOlder");
+   storage.store(ui->comboBoxTemplate, "comboBoxTemplate");
+   storage.store(ui->comboBoxTextPattern, "comboBoxTextPattern");
+   storage.store(ui->comboBoxYounger, "comboBoxYounger");
+   storage.close();
+}
+
 /**
  * Handles the "search" button.
  */
@@ -476,7 +609,7 @@ void MainWindow::selectDirectory(){
  * Calls the file selection dialog.
  */
 void MainWindow::selectExportFile(){
-   QString name = QFileDialog::getOpenFileName(this, tr("Select Export File"),
+   QString name = QFileDialog::getSaveFileName(this, tr("Select Export File"),
       ui->comboBoxExportFile->currentText());
    if (!name.isEmpty())
       ui->comboBoxExportFile->setCurrentText(name);
index c28fc44d945e772a26680fd0ec02c6ff1ed7bb6e..616c8756c9b19cccf8d4355133dc1845e351db5a 100644 (file)
@@ -52,18 +52,24 @@ class MainWindow: public QMainWindow, public ReGuiValidator {
    Q_OBJECT
 
 public:
-   explicit MainWindow(const QString& startDir, QWidget *parent = 0);
+   explicit MainWindow(const QString& startDir, const QString& homeDir,
+      QWidget *parent = 0);
    ~MainWindow();
 
 private slots:
    void about();
    void absPathToClipboard();
    void baseDirToClipboard();
+   void closing();
    void exportFiles();
+   void filePlaceholder();
+   void footerPlaceholder();
    void fullNameToClipboard();
    void headerClicked(int col);
+   void headerPlaceholder();
    void preview();
    void resetParameters();
+   void saveState();
    void search();
    void selectDirectory();
    void selectExportFile();
@@ -74,8 +80,11 @@ private:
    QDir::Filters buildFileTypes();
    QString cellAsText(int row, int col);
    void exportToStream(QTextStream& stream, int maxRow = -1);
+   void handlePlaceholder(QComboBox* target);
+   void initializeHome();
    void prepareTextFind();
    QString replaceGlobalPlaceholder(const QString& text);
+   void restoreState();
    virtual void setStatusMessage(bool error, const QString& message);
 private:
    Ui::MainWindow *ui;
@@ -87,6 +96,8 @@ private:
    QHeaderView* m_horizontalHeader;
    Qt::SortOrder m_lastOrder;
    Statistics m_statistics;
+   QString m_homeDir;
+   QString m_storageFile;
 };
 
 #endif // MAINWINDOW_HPP
index e4e66b20d704dd12febab89bc7d60f4b1a8987a7..72fe81f2b70f214002497d446fa1d921fa34ad21 100644 (file)
                <string>Execute the search</string>
               </property>
               <property name="text">
-               <string>&amp;Search</string>
+               <string>&amp;Run search</string>
               </property>
               <property name="icon">
                <iconset>
               <property name="shortcut">
                <string>Ctrl+F</string>
               </property>
+              <property name="autoDefault">
+               <bool>true</bool>
+              </property>
+              <property name="default">
+               <bool>true</bool>
+              </property>
              </widget>
             </item>
             <item row="0" column="5">
                  <string>Select directory by a dialog box</string>
                 </property>
                 <property name="text">
-                 <string>...</string>
+                 <string/>
                 </property>
                 <property name="icon">
                  <iconset resource="refind.qrc">
            <item row="2" column="4" colspan="2">
             <widget class="QPushButton" name="pushButtonSearch2">
              <property name="text">
-              <string>&amp;Search</string>
+              <string>&amp;Run search</string>
              </property>
              <property name="icon">
               <iconset>
             <layout class="QHBoxLayout" name="horizontalLayout_7">
              <item>
               <widget class="QComboBox" name="comboBoxTemplate">
+               <property name="toolTip">
+                <string>Template of a line for each file</string>
+               </property>
                <property name="editable">
                 <bool>true</bool>
                </property>
               </widget>
              </item>
              <item>
-              <widget class="QPushButton" name="pushButtonPlaceholder">
+              <widget class="QPushButton" name="pushButtonFilePlaceholder">
                <property name="maximumSize">
                 <size>
                  <width>50</width>
                 </size>
                </property>
                <property name="toolTip">
-                <string>Placeholder for the template</string>
+                <string>Select a placeholder for the template</string>
                </property>
                <property name="text">
                 <string>...</string>
             <layout class="QHBoxLayout" name="horizontalLayout_6">
              <item>
               <widget class="QComboBox" name="comboBoxExportFile">
+               <property name="toolTip">
+                <string>Name of the export file</string>
+               </property>
                <property name="editable">
                 <bool>true</bool>
                </property>
              </property>
              <property name="maximumSize">
               <size>
-               <width>300</width>
+               <width>16777215</width>
                <height>16777215</height>
               </size>
              </property>
              <property name="toolTip">
-              <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Text at the top of the export file.&lt;/p&gt;&lt;p&gt;Placeholders:&lt;/p&gt;&lt;p&gt;&lt;u&gt;&lt;li&gt;\n newline&lt;/li
-&lt;li&gt;\t tabulator&lt;/li&gt;
-&lt;li&gt;\\ slash&lt;/li&gt;
-&lt;/ul&gt;&lt;/p&gt;
-&lt;/body&gt;&lt;/html&gt;</string>
+              <string>Text at the top of the export file</string>
              </property>
              <property name="editable">
               <bool>true</bool>
            <item row="1" column="3">
             <widget class="QComboBox" name="comboBoxFooter">
              <property name="toolTip">
-              <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Text at the top of the export file.&lt;/p&gt;&lt;p&gt;Placeholders:&lt;/p&gt;&lt;p&gt;&lt;u&gt;&lt;li&gt;\n newline&lt;/li
-&lt;li&gt;\t tabulator&lt;/li&gt;
-&lt;li&gt;\\ slash&lt;/li&gt;
-&lt;/ul&gt;&lt;/p&gt;
-&lt;/body&gt;&lt;/html&gt;</string>
+              <string>Text at the end of the export file</string>
              </property>
              <property name="editable">
               <bool>true</bool>
              </property>
             </widget>
            </item>
+           <item row="0" column="4">
+            <widget class="QPushButton" name="pushButtonHeaderPlaceholder">
+             <property name="maximumSize">
+              <size>
+               <width>50</width>
+               <height>16777215</height>
+              </size>
+             </property>
+             <property name="toolTip">
+              <string>Select a placeholder for the header</string>
+             </property>
+             <property name="text">
+              <string>...</string>
+             </property>
+            </widget>
+           </item>
+           <item row="1" column="4">
+            <widget class="QPushButton" name="pushButtonFooterPlaceholder">
+             <property name="maximumSize">
+              <size>
+               <width>50</width>
+               <height>16777215</height>
+              </size>
+             </property>
+             <property name="toolTip">
+              <string>Select a placeholder for the footer</string>
+             </property>
+             <property name="text">
+              <string>...</string>
+             </property>
+            </widget>
+           </item>
           </layout>
          </widget>
         </widget>
     <addaction name="separator"/>
     <addaction name="actionExport"/>
     <addaction name="separator"/>
+    <addaction name="actionSaveProgramState"/>
     <addaction name="separator"/>
     <addaction name="actionExit"/>
     <addaction name="separator"/>
     <bool>false</bool>
    </attribute>
    <addaction name="actionExport"/>
+   <addaction name="actionSaveProgramState"/>
    <addaction name="actionExit"/>
   </widget>
   <action name="actionExit">
      <normaloff>:/main/icons/action_go.png</normaloff>:/main/icons/action_go.png</iconset>
    </property>
    <property name="text">
-    <string>&amp;Search</string>
+    <string>&amp;Run search</string>
    </property>
    <property name="toolTip">
     <string>Search the files with the given properties</string>
    </property>
    <property name="shortcut">
-    <string>Ctrl+F</string>
+    <string>Ctrl+R</string>
    </property>
   </action>
   <action name="actionAbout">
      <normalon>:/main/icons/table.gif</normalon>:/main/icons/table.png</iconset>
    </property>
    <property name="text">
-    <string>Get &amp;full name</string>
+    <string>&amp;full name to clipboard</string>
    </property>
    <property name="shortcut">
     <string>Ctrl+N</string>
      <normaloff>:/main/icons/action_paste.png</normaloff>:/main/icons/action_paste.png</iconset>
    </property>
    <property name="text">
-    <string>Get &amp;base directory</string>
+    <string>&amp;base directory to clipboard</string>
    </property>
    <property name="toolTip">
     <string>Puts the base directory into the clipboard</string>
     <string>Sets the file filter properties to the default</string>
    </property>
    <property name="shortcut">
-    <string>Ctrl+R</string>
+    <string>Ctrl+E</string>
+   </property>
+  </action>
+  <action name="actionSaveProgramState">
+   <property name="icon">
+    <iconset resource="refind.qrc">
+     <normaloff>:/main/icons/disk.png</normaloff>:/main/icons/disk.png</iconset>
+   </property>
+   <property name="text">
+    <string>Sa&amp;ve</string>
+   </property>
+   <property name="toolTip">
+    <string>Saves the program state (position, history...) to a file</string>
+   </property>
+   <property name="shortcut">
+    <string>Ctrl+S</string>
    </property>
   </action>
  </widget>
   <tabstop>comboBoxDirectory</tabstop>
   <tabstop>pushButtonUp</tabstop>
   <tabstop>pushButtonDirectory</tabstop>
+  <tabstop>pushButtonSearch</tabstop>
   <tabstop>comboBoxFilePatterns</tabstop>
   <tabstop>checkBoxFiles</tabstop>
   <tabstop>checkBoxDirs</tabstop>
   <tabstop>checkBoxLinks</tabstop>
   <tabstop>checkBoxHidden</tabstop>
   <tabstop>checkBoxWritable</tabstop>
+  <tabstop>checkBoxReadable</tabstop>
+  <tabstop>checkBoxExecutable</tabstop>
   <tabstop>comboBoxTextPattern</tabstop>
   <tabstop>checkBoxTextIgnoreCase</tabstop>
   <tabstop>checkBoxRegExpr</tabstop>
   <tabstop>checkBoxBinaryFiles</tabstop>
-  <tabstop>pushButtonSearch</tabstop>
-  <tabstop>tableWidget</tabstop>
   <tabstop>comboBoxMinSize</tabstop>
   <tabstop>comboBoxMaxSize</tabstop>
   <tabstop>comboBoxYounger</tabstop>
   <tabstop>comboBoxMinDepth</tabstop>
   <tabstop>comboBoxMaxDepth</tabstop>
   <tabstop>comboBoxExcludedDirs</tabstop>
+  <tabstop>pushButtonSearch2</tabstop>
+  <tabstop>comboBoxTemplate</tabstop>
+  <tabstop>pushButtonFilePlaceholder</tabstop>
+  <tabstop>comboBoxHeader</tabstop>
+  <tabstop>pushButtonHeaderPlaceholder</tabstop>
+  <tabstop>comboBoxExportFile</tabstop>
+  <tabstop>pushButtonExportFile</tabstop>
+  <tabstop>comboBoxFooter</tabstop>
+  <tabstop>pushButtonFooterPlaceholder</tabstop>
+  <tabstop>radioButtonFile</tabstop>
+  <tabstop>radioButtonClipboard</tabstop>
+  <tabstop>pushButtonExport</tabstop>
+  <tabstop>tabWidget</tabstop>
+  <tabstop>tableWidget</tabstop>
  </tabstops>
  <resources>
   <include location="refind.qrc"/>
index 130a549cf2699ddb126b9a70c800371264ddecb1..d8f3901761234312d6279880267e7018f15f0041 100644 (file)
@@ -22,7 +22,9 @@ SOURCES += main.cpp\
         textfinder.cpp \
         aboutdialog.cpp \
         ../../gui/ReStateStorage.cpp \
-    ../../gui/ReGuiValidator.cpp
+    ../../gui/ReGuiValidator.cpp \
+    dialogglobalplaceholder.cpp \
+    dialogfileplaceholder.cpp
 
 
 HEADERS  += mainwindow.hpp \
@@ -33,11 +35,15 @@ HEADERS  += mainwindow.hpp \
         ../../gui/ReStateStorage.hpp \
         aboutdialog.hpp \
     ../../gui/ReGuiValidator.hpp \
-    ../../gui/regui.hpp
+    ../../gui/regui.hpp \
+    dialogglobalplaceholder.hpp \
+    dialogfileplaceholder.hpp
 
 
 FORMS    += mainwindow.ui \
-        aboutdialog.ui
+        aboutdialog.ui \
+    dialogglobalplaceholder.ui \
+    dialogfileplaceholder.ui
 
 RESOURCES += \
         refind.qrc
index 70825238b9d17fd6dd6b3991e031c92c4694694b..edd3ddd2e215bdb98cd038c7bc3b462803baa0c4 100644 (file)
 #include "base/rebase.hpp"
 #include <QtCore/qmath.h>
 #include <QDateTime>
+
+/**
+ * Removes end of line characters if any.
+ *
+ * @param text  text to inspect
+ * @return      <code>text</code> without trailing '\n' and/or '\r'
+ */
+ReString ReQStringUtil::chomp(const ReString& text)
+{
+    int last = text.length() - 1;
+    while (last >= 0 && (text[last] == '\n' || text[last] == '\r')){
+        last--;
+    }
+    return last == text.length() - 1 ? text : text.mid(0, last + 1);
+}
+
+
 /**
  * @brief Determines the length and vlaue of an integer.
  *
index b5573e721a7f5fcc9382a66eb3686f79ed693187..e968926f2dd61d6de45f562345e5076c21f2bdd8 100644 (file)
@@ -14,6 +14,7 @@
 
 class ReQStringUtil {
 public:
+    static ReString chomp(const ReString& text);
     static int lengthOfDate(const ReString& text, int start = 0, QDate* value =
             NULL);
     static int lengthOfDateTime(const ReString& text, int start = 0,
index dde832210128518a2d861837e1b2d6af6911be52..9bec52e545d0a077acb4c27120be814ea6b97b48 100644 (file)
@@ -25,13 +25,44 @@ ReStateStorage::ReStateStorage(const QString& filename) :
  * Destructor.
  */
 ReStateStorage::~ReStateStorage(){
+   close();
+}
+
+/**
+ * Closes open stream/file and frees the resources.
+ */
+void ReStateStorage::close(){
    delete m_stream;
+   m_stream = NULL;
    if (m_fp != NULL){
       fclose(m_fp);
       m_fp = NULL;
    }
 }
 
+/**
+ * Initializes the instance for writing the storage information.
+ */
+bool ReStateStorage::initForRead(){
+   if (m_fp == NULL)
+      m_fp = fopen(m_filename.toUtf8().constData(), "rb");
+   if (m_fp != NULL && m_stream == NULL){
+      m_stream = new QTextStream(m_fp, QIODevice::ReadOnly);
+      QString line;
+      m_map.clear();
+      QString value;
+      while (!m_stream->atEnd()){
+         line = m_stream->readLine(64 * 1024);
+         int ixAssignment = line.indexOf('=');
+         if (ixAssignment > 0){
+            value = line.mid(ixAssignment + 1);
+            QString key = line.mid(0, ixAssignment);
+            m_map.insert(key, value);
+         }
+      }
+   }
+   return m_stream != NULL;
+}
 /**
  * Initializes the instance for writing the storage information.
  */
@@ -39,7 +70,7 @@ bool ReStateStorage::initForWrite(){
    if (m_fp == NULL)
       m_fp = fopen(m_filename.toUtf8().constData(), "wb");
    if (m_fp != NULL)
-      m_stream = new QTextStream(m_fp, QIODevice::ReadOnly);
+      m_stream = new QTextStream(m_fp, QIODevice::ReadWrite);
    return m_stream != NULL;
 }
 /**
@@ -51,6 +82,15 @@ QString ReStateStorage::form() const{
    return m_form;
 }
 
+/**
+ * Returns the full name of a widget.
+ *
+ * @param name  the name of the widget
+ * @return      <form name> '.' <name> or <name> (if no form name is set)
+ */
+QString ReStateStorage::fullname(const QString& name){
+   return m_form.isEmpty() ? name : m_form + "." + name;
+}
 /**
  * Sets the name of the current form.
  *
@@ -60,6 +100,35 @@ void ReStateStorage::setForm(const QString& form){
    m_form = form;
 }
 
+/**
+ * Restores the data of a combobox.
+ *
+ * @param combo             the combobox to restore
+ * @param name              the name of the combobox
+ * @param withCurrentText   <code>true</code>: the current text will be set too
+ */
+void ReStateStorage::restore(QComboBox* combo, const QString& name,
+   bool withCurrentText){
+   if (initForRead()){
+      QString keyPrefix = fullname(name) + ".item";
+      int ix = 0;
+      QString key;
+      while (true){
+         key = keyPrefix + QString::number(ix);
+         if (!m_map.contains(key))
+            break;
+         combo->addItem(m_map.value(key));
+         ix++;
+      }
+      key = fullname(name) + ".text";
+      if (!withCurrentText)
+         combo->setCurrentText("");
+      else{
+         if (m_map.contains(key))
+            combo->setCurrentText(m_map.value(key));
+      }
+   }
+}
 /**
  * Stores the data of a combobox.
  *
@@ -75,7 +144,7 @@ void ReStateStorage::store(const QComboBox* combo, const QString& name,
          fullname = m_form + ".";
       fullname += name;
       for (int ii = 0; ii < combo->count(); ii++){
-         *m_stream << fullname << ".item:" << ii << "=" << combo->itemText(ii)
+         *m_stream << fullname << ".item" << ii << "=" << combo->itemText(ii)
             << endl;
       }
       if (withCurrentText){
index 9f3837b5f60483ef2563ca23cabc332c07bdf1ed..3f3665c7b618f695e21d8e7886ec120828d168df 100644 (file)
@@ -20,10 +20,15 @@ public:
    ReStateStorage(const QString& filename);
    virtual ~ReStateStorage();
 public:
+   void close();
    QString form() const;
+   QString fullname(const QString& name);
+   bool initForRead();
    bool initForWrite();
+   void restore(QComboBox* combo, const QString& name, bool withCurrentText =
+      false);
    void store(const QComboBox* combo, const QString& name,
-      bool withCurrentText = false);
+      bool withCurrentText = true);
    void setForm(const QString& form);
 
 private:
@@ -31,6 +36,7 @@ private:
    FILE* m_fp;
    QTextStream* m_stream;
    QString m_form;
+   QMap <QString, QString> m_map;
 };
 
 #endif /* GUI_RESTATESTORAGE_HPP_ */