<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 notr="true">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 notr="true">${base}</string>
- </property>
- </item>
- <item row="0" column="1">
- <property name="text">
- <string notr="true">/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 notr="true">\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>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTableWidget" name="tableWidget">
+ <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 notr="true">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 notr="true">${base}</string>
+ </property>
+ </item>
+ <item row="0" column="1">
+ <property name="text">
+ <string notr="true">/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 notr="true">\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>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
<resources/>
<connections>
<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 notr="true">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 notr="true">${datetime}</string>
- </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTableWidget" name="tableWidget">
+ <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 notr="true">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 notr="true">${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 notr="true">${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 notr="true">${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 notr="true">${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 notr="true">${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 notr="true">${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 notr="true">${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 notr="true">${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 notr="true">\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 notr="true">\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 notr="true">\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 notr="true">\\</string>
+ </property>
+ </item>
+ <item row="11" column="1">
+ <property name="text">
+ <string>backslash</string>
+ </property>
+ </item>
+ </widget>
</item>
- <item row="0" column="1">
- <property name="text">
- <string>current date/time</string>
- </property>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
</item>
- <item row="1" column="0">
- <property name="text">
- <string notr="true">${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 notr="true">${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 notr="true">${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 notr="true">${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 notr="true">${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 notr="true">${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 notr="true">${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 notr="true">\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 notr="true">\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 notr="true">\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 notr="true">\\</string>
- </property>
- </item>
- <item row="11" column="1">
- <property name="text">
- <string>backslash</string>
- </property>
- </item>
- </widget>
+ </layout>
</widget>
<resources/>
<connections>
--- /dev/null
+/*
+ * 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 "dialogoptions.hpp"
+#include "ui_dialogoptions.h"
+
+DialogOptions::DialogOptions(ContextHandlerList& handlers, QWidget *parent) :
+ QDialog(parent), ui(new Ui::DialogOptions), m_contextHandlers(handlers){
+ ui->setupUi(this);
+ fillTable();
+}
+
+DialogOptions::~DialogOptions(){
+ delete ui;
+}
+/**
+ * Fills the table with the data from the list.
+ */
+void DialogOptions::fillTable(){
+ int count = m_contextHandlers.list().size();
+ ui->tableWidget->setRowCount(count);
+ QString value;
+ QList < QString > dirMode;
+ for (int row = 0; row < count; row++){
+ ContextHandler* handler = m_contextHandlers.list().at(row);
+ ui->tableWidget->setItem(row, COL_TITLE,
+ new QTableWidgetItem(handler->m_text));
+ ui->tableWidget->setItem(row, COL_PROGRAM,
+ new QTableWidgetItem(handler->m_program));
+ ui->tableWidget->setItem(row, COL_ARGUMENTS,
+ new QTableWidgetItem(handler->m_arguments));
+ value = ui->comboBoxFileType->itemText(handler->m_fileType - 1);
+ ui->tableWidget->setItem(row, COL_FILE_TYPE, new QTableWidgetItem(value));
+ value = ui->comboBoxCurrentDirectory->itemText(
+ handler->m_directoryMode - 1);
+ ui->tableWidget->setItem(row, COL_CURRENT_DIR,
+ new QTableWidgetItem(value));
+ }
+}
+
+/**
+ * Fills the list from the data of the table.
+ */
+void DialogOptions::fromTable(){
+ m_contextHandlers.clear();
+ QList < QString > fileTypes;
+ for (int ix = 0; ix < ui->comboBoxFileType->count(); ix++)
+ fileTypes.append(ui->comboBoxFileType->itemText(ix));
+ for (int ix = 0; ix < ui->comboBoxCurrentDirectory->count(); ix++)
+ fileTypes.append(ui->comboBoxCurrentDirectory->itemText(ix));
+ for (int row = 0; row < ui->tableWidget->rowCount(); row++){
+ ContextHandler* handler = new ContextHandler;
+ handler->m_text = ui->tableWidget->item(row, COL_TITLE)->text();
+ handler->m_program = ui->tableWidget->item(row, COL_PROGRAM)->text();
+ handler->m_arguments = ui->tableWidget->item(row, COL_ARGUMENTS)->text();
+ handler->m_fileType = ContextHandler::FileType(
+ 1
+ + fileTypes.indexOf(
+ ui->comboBoxFileType->itemText(row, COL_FILE_TYPE)->text()));
+ handler->m_directoryMode = ContextHandler::DirMode(
+ 1
+ + fileTypes.indexOf(
+ ui->comboBoxCurrentDirectory->itemText(row, COL_CURRENT_DIR)));
+ m_contextHandlers.list().append(handler);
+ }
+}
+
--- /dev/null
+/*
+ * 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 DIALOGOPTIONS_HPP
+#define DIALOGOPTIONS_HPP
+#include "utils.hpp"
+#include <QDialog>
+
+namespace Ui {
+class DialogOptions;
+}
+
+class DialogOptions: public QDialog {
+ Q_OBJECT
+
+public:
+ explicit DialogOptions(ContextHandlerList& handlers, QWidget *parent = 0);
+ ~DialogOptions();
+private:
+ void fillTable();
+ void fromTable();
+private:
+ Ui::DialogOptions *ui;
+ ContextHandlerList& m_contextHandlers;
+};
+
+#endif // DIALOGOPTIONS_HPP
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DialogOptions</class>
+ <widget class="QDialog" name="DialogOptions">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>944</width>
+ <height>591</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Dialog</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QTabWidget" name="tabWidget">
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Programs (Context Menu)</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTableWidget" name="tableWidget">
+ <property name="minimumSize">
+ <size>
+ <width>850</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="editTriggers">
+ <set>QAbstractItemView::AnyKeyPressed|QAbstractItemView::EditKeyPressed</set>
+ </property>
+ <property name="alternatingRowColors">
+ <bool>false</bool>
+ </property>
+ <property name="selectionMode">
+ <enum>QAbstractItemView::SingleSelection</enum>
+ </property>
+ <property name="selectionBehavior">
+ <enum>QAbstractItemView::SelectRows</enum>
+ </property>
+ <attribute name="horizontalHeaderDefaultSectionSize">
+ <number>175</number>
+ </attribute>
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>true</bool>
+ </attribute>
+ <attribute name="verticalHeaderVisible">
+ <bool>false</bool>
+ </attribute>
+ <row>
+ <property name="text">
+ <string>Neue Zeile</string>
+ </property>
+ </row>
+ <row>
+ <property name="text">
+ <string>edit</string>
+ </property>
+ </row>
+ <column>
+ <property name="text">
+ <string>File Type</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Titel (Menu)</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Program</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Arguments</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Current Directory</string>
+ </property>
+ </column>
+ <item row="0" column="1">
+ <property name="text">
+ <string>Editor</string>
+ </property>
+ </item>
+ <item row="0" column="2">
+ <property name="text">
+ <string>/usr/bin/kate</string>
+ </property>
+ </item>
+ <item row="0" column="3">
+ <property name="text">
+ <string>${full}</string>
+ </property>
+ </item>
+ <item row="0" column="4">
+ <property name="text">
+ <string/>
+ </property>
+ </item>
+ <item row="1" column="1">
+ <property name="text">
+ <string>Shell</string>
+ </property>
+ </item>
+ <item row="1" column="2">
+ <property name="text">
+ <string>/usr/bin/bash</string>
+ </property>
+ </item>
+ <item row="1" column="3">
+ <property name="text">
+ <string/>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButtonAdd">
+ <property name="text">
+ <string>&Add</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButtonDel">
+ <property name="text">
+ <string>D&elete</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButtonUp">
+ <property name="text">
+ <string>&Up</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButtonDown">
+ <property name="text">
+ <string>&Down</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="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Current Entry</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>File Type:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Title:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string><html><head/><body><p>Program:</p></body></html></string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Arguments:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Current Directory:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QComboBox" name="comboBoxFileType">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <item>
+ <property name="text">
+ <string>File</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Directory</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Both</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="lineEditTitle">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QComboBox" name="comboBoxProgram">
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButtonSelectProgram">
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ <property name="icon">
+ <iconset resource="refind.qrc">
+ <normaloff>:/main/icons/layout_add.png</normaloff>:/main/icons/layout_add.png</iconset>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="3">
+ <widget class="QComboBox" name="comboBoxArgument">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <item>
+ <property name="text">
+ <string notr="true">${full}</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string notr="true">${path}</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string notr="true">${node}</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string notr="true">${ext}</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="4">
+ <widget class="QComboBox" name="comboBoxCurrentDirectory">
+ <property name="maximumSize">
+ <size>
+ <width>150</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>Tab 2</string>
+ </attribute>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ <property name="centerButtons">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources>
+ <include location="refind.qrc"/>
+ </resources>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>DialogOptions</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>DialogOptions</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>
#include <QDir>
#include "base/rebase.hpp"
#include "gui/regui.hpp"
+#include "utils.hpp"
#include "mainwindow.hpp"
#include "filefinder.hpp"
#include "textfinder.hpp"
entries = dir.entryInfoList(m_patterns, filters, QDir::NoSort);
QList <QFileInfo>::iterator it;
QString relativePath = ReQStringUtil::nativePath(
- path.mid(1 + m_baseDir.length()));
+ path.mid(1 + m_baseDir.length()));
QString node, ext;
for (it = entries.begin(); it != entries.end(); ++it){
#include <QApplication>
#include "base/rebase.hpp"
#include "gui/regui.hpp"
+#include "utils.hpp"
#include "mainwindow.hpp"
int main(int argc, char *argv[]){
* The latest sources: https://github.com/republib
*/
-#include <QDir>
-#include <QFileDialog>
-#include <QClipboard>
-#include <QLineEdit>
-#include <QMouseEvent>
-#include <QDrag>
-#include <QMimeData>
-#include <QProcess>
#include "base/rebase.hpp"
#include "gui/regui.hpp"
+#include "utils.hpp"
#include "textfinder.hpp"
#include "mainwindow.hpp"
#include "ui_mainwindow.h"
#include "dialogglobalplaceholder.hpp"
#include "filefinder.hpp"
#include "aboutdialog.hpp"
+#include "dialogoptions.hpp"
+#include <QDir>
+#include <QFileDialog>
+#include <QClipboard>
+#include <QLineEdit>
+#include <QMouseEvent>
+#include <QDrag>
+#include <QMimeData>
+#include <QProcess>
+#include <QMessageBox>
/**
* @brief Constructor.
m_lastOrder(Qt::DescendingOrder),
m_homeDir(),
m_storageFile(),
- m_fileHandler(),
- m_dirHandler(){
+ m_contextHandlers(){
ui->setupUi(this);
initializeHome();
m_statusMessage = new QLabel(tr("Willkommen bei refind"));
connect(ui->pushButtonDirectory, SIGNAL(clicked()), this,
SLOT(selectDirectory()));
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
+ connect(ui->actionOptions, SIGNAL(triggered()), this, SLOT(options()));
connect(ui->actionGetAbsPath, SIGNAL(triggered()), this,
SLOT(absPathToClipboard()));
connect(ui->actionGetFullName, SIGNAL(triggered()), this,
SLOT(headerPlaceholder()));
connect(ui->pushButtonFooterPlaceholder, SIGNAL(clicked()), this,
SLOT(footerPlaceholder()));
+ connect(ui->actionPreview, SIGNAL(triggered()), this, SLOT(preview()));
+ connect(ui->pushButtonPreview, SIGNAL(clicked()), this, SLOT(preview()));
m_horizontalHeader = ui->tableWidget->horizontalHeader();
connect(m_horizontalHeader, SIGNAL(sectionClicked ( int ) ),
ui->tableWidget->setColumnWidth(TC_SIZE, 125);
ui->tableWidget->setColumnWidth(TC_MODIFIED, 175);
ui->tableWidget->setColumnWidth(TC_TYPE, 75);
- addContextMenu();
+ prepareContextMenu();
}
/**
delete ui;
}
-/**
- * Prepares the context menu of the result table.
- *
- */
-void MainWindow::addContextMenu(){
- ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(ui->tableWidget,
- SIGNAL(customContextMenuRequested(const QPoint&)),
- SLOT(handleTableContextMenu(const QPoint&)));
- ContextHandler* handler = new ContextHandler();
- handler->m_text = "kedit";
- handler->m_program = "kedit";
- handler->m_arguments = "${full}";
- handler->m_changeToParentDirectory = ContextHandler::DM_UNDEF;
- m_fileHandler.append(handler);
- handler = new ContextHandler();
- handler->m_text = "bash";
- handler->m_program = "konsole";
- handler->m_arguments = "${full}";
- handler->m_changeToParentDirectory = ContextHandler::DM_TO_FILE;
- m_dirHandler.append(handler);
-}
-
-=======
->>>>>>> branch 'master' of git@f-r-e-i.de:/home/git/repo/rplqt
-void MainWindow::mousePressEvent(QMouseEvent* event)
-{
- if (event->button() == Qt::LeftButton
- && ui->tableWidget->geometry().contains(event->pos())) {
-
- QDrag *drag = new QDrag(this);
- QMimeData *mimeData = new QMimeData;
-
- mimeData->setText("test text");
- drag->setMimeData(mimeData);
+void MainWindow::mousePressEvent(QMouseEvent* event){
+ if (event->button() == Qt::LeftButton
+ && ui->tableWidget->geometry().contains(event->pos())){
+
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+ mimeData->setText("test text");
+ drag->setMimeData(mimeData);
#if 0
- const QPixmap image = iconShader.pixmap(QSize(16,16));
- drag->drawPixmap(0, 0, 16, 16, image);
- drag->drawText(QRect(20, 0, 170, 20), tr("copy or move") );
+ const QPixmap image = iconShader.pixmap(QSize(16,16));
+ drag->drawPixmap(0, 0, 16, 16, image);
+ drag->drawText(QRect(20, 0, 170, 20), tr("copy or move") );
- drag->setPixmap(iconPixmap);
+ drag->setPixmap(iconPixmap);
#endif
- Qt::DropAction dropAction = drag->exec();
- }
+ Qt::DropAction dropAction = drag->exec();
+ }
}
/**
* initializeHomeializes the program home directory.
}
/**
- * Handles the event "header column clicked".
- *
- * @param col the col
+ * Starts the about dialog.
*/
-void MainWindow::headerClicked(int col){
- m_lastOrder =
- m_lastOrder == Qt::AscendingOrder ?
- Qt::DescendingOrder : Qt::AscendingOrder;
- ui->tableWidget->sortItems(col, m_lastOrder);
- m_horizontalHeader->setSortIndicatorShown(true);
- m_horizontalHeader->setSortIndicator(col, m_lastOrder);
-}
-
-void MainWindow::preview(){
- QString value;
- QTextStream stream(&value);
- exportToStream(stream, 1);
+void MainWindow::about(){
+ AboutDialog dialog;
+ dialog.exec();
}
/**
- * Starts the about dialog.
+ * Starts the options dialog.
*/
-void MainWindow::about(){
- AboutDialog dialog;
+void MainWindow::options(){
+ DialogOptions dialog(m_contextHandlers, NULL);
dialog.exec();
}
* @param maxRow -1 or the maximum row to export
*/
void MainWindow::exportToStream(QTextStream& stream, int maxRow){
- QHash<QString, QString> placeholders;
- buildGlobalPlaceholders(placeholders);
+ QMap < QString, QString > placeholders;
+ buildGlobalPlaceholders (placeholders);
if (!ui->comboBoxHeader->currentText().isEmpty()){
stream << replaceGlobalPlaceholders(ui->comboBoxHeader, placeholders)
<< endl;
QString error;
for (int ii = 0; ii < count; ii++){
QString line = ui->comboBoxTemplate->currentText();
- QHash<QString, QString> placeholders;
+ QMap < QString, QString > placeholders;
QString path = m_lastBaseDir.absoluteFilePath(
- ReQStringUtil::pathAppend(
- ui->tableWidget->item(ii, TC_PATH)->text(),
- ui->tableWidget->item(ii, TC_NODE)->text()));
+ ReQStringUtil::pathAppend(ui->tableWidget->item(ii, TC_PATH)->text(),
+ ui->tableWidget->item(ii, TC_NODE)->text()));
placeholders.insert("full", ReQStringUtil::nativePath(path));
placeholders.insert("path", ui->tableWidget->item(ii, TC_PATH)->text());
placeholders.insert("ext", ui->tableWidget->item(ii, TC_EXT)->text());
placeholders.insert("node", ui->tableWidget->item(ii, TC_NODE)->text());
- placeholders.insert("modified", ui->tableWidget->item(ii, TC_MODIFIED)->text());
+ placeholders.insert("modified",
+ ui->tableWidget->item(ii, TC_MODIFIED)->text());
placeholders.insert("size", ui->tableWidget->item(ii, TC_SIZE)->text());
- if (! ReQStringUtil::replacePlaceholders(line, placeholders, &error)){
- guiError(ui->comboBoxTemplate, error);
- break;
+ if (!ReQStringUtil::replacePlaceholders(line, placeholders, &error)){
+ guiError(ui->comboBoxTemplate, error);
+ break;
}
stream << replaceEscSequences(line) << endl;
}
* @param position the position of a mouse click
*/
void MainWindow::handleTableContextMenu(const QPoint& position){
- int row = ui->tableWidget->rowAt(position.y());
- if (row >= 0){
- QMenu menu;
-
- QString node = ui->tableWidget->item(row, TC_NODE)->text();
- QString parent = buildAbsPath(row);
- QString full = ReQStringUtil::pathAppend(parent, node);
- QFileInfo file(full);
- QList<ContextHandler*>& list = file.isDir() ? m_dirHandler : m_fileHandler;
- QList<ContextHandler*>::const_iterator it;
- QHash<QAction*, ContextHandler*> actions;
- ContextHandler* handler;
- for (it = list.begin(); it != list.end(); ++it){
- handler = *it;
- QString text = handler->m_text + " " + node;
- actions.insert(menu.addAction(text), handler);
- }
- QAction* selectedItem = menu.exec(ui->tableWidget->viewport()->mapToGlobal(position));
- if (selectedItem != NULL)
- {
- handler = *actions.find(selectedItem);
- QString arguments = handler->m_arguments;
- QString dir;
- switch(handler->m_changeToParentDirectory){
- case ContextHandler::DM_TO_PARENT:
- dir = parent;
- break;
- case ContextHandler::DM_TO_FILE:
- dir = full;
- break;
- default:
- dir = ui->comboBoxDirectory->currentText();
- break;
- }
- QMap<QString, QString> placeholders;
- placeholders.insert("full", full);
- placeholders.insert("node", node);
- placeholders.insert("path", parent);
- placeholders.insert("ext", ReQStringUtil::extensionOf(node));
- QString error;
- QStringList args = arguments.split(' ');
- bool hasErrors = false;
- for (int ix = 0; ix < args.size(); ix++){
- QString arg = args.at(ix);
- if (! ReQStringUtil::replacePlaceholders(arg, placeholders, &error)){
- guiError(NULL, error);
- hasErrors = true;
- break;
- }
- args.replace(ix, arg);
- }
- if (! hasErrors){
- QProcess::startDetached(handler->m_program, args, dir, NULL);
- setStatusMessage(false, "call of " + handler->m_program + " "
- + arguments);
+ int row = ui->tableWidget->rowAt(position.y());
+ if (row >= 0){
+ QMenu menu;
+
+ QString node = ui->tableWidget->item(row, TC_NODE)->text();
+ QString parent = buildAbsPath(row);
+ QString full = ReQStringUtil::pathAppend(parent, node);
+ QFileInfo file(full);
+ bool isDir = file.isDir();
+ QList <ContextHandler*>::const_iterator it;
+ QMap <QAction*, ContextHandler*> actions;
+ ContextHandler* handler;
+ for (it = m_contextHandlers.list().begin();
+ it != m_contextHandlers.list().end(); ++it){
+ handler = *it;
+ if ((isDir && handler->m_fileType == ContextHandler::FT_FILE)
+ || (!isDir && handler->m_fileType == ContextHandler::FT_DIR))
+ continue;
+ QString text = handler->m_text + " " + node;
+ actions.insert(menu.addAction(text), handler);
+ }
+ QAction* selectedItem = menu.exec(
+ ui->tableWidget->viewport()->mapToGlobal(position));
+ if (selectedItem != NULL){
+ handler = *actions.find(selectedItem);
+ QString arguments = handler->m_arguments;
+ QString dir;
+ switch (handler->m_directoryMode) {
+ case ContextHandler::DM_TO_PARENT:
+ dir = parent;
+ break;
+ case ContextHandler::DM_TO_FILE:
+ dir = full;
+ break;
+ default:
+ dir = ui->comboBoxDirectory->currentText();
+ break;
+ }
+ QMap < QString, QString > placeholders;
+ placeholders.insert("full", full);
+ placeholders.insert("node", node);
+ placeholders.insert("path", parent);
+ placeholders.insert("ext", ReQStringUtil::extensionOf(node));
+ QString error;
+ QStringList args = arguments.split(' ');
+ bool hasErrors = false;
+ for (int ix = 0; ix < args.size(); ix++){
+ QString arg = args.at(ix);
+ if (!ReQStringUtil::replacePlaceholders(arg, placeholders, &error)){
+ guiError(NULL, error);
+ hasErrors = true;
+ break;
}
- }
+ args.replace(ix, arg);
+ }
+ if (!hasErrors){
+ QProcess::startDetached(handler->m_program, args, dir, NULL);
+ setStatusMessage(false,
+ tr("started:") + " " + handler->m_program + " " + arguments);
+ }
+ }
+ }
+}
- }
+/**
+ * Handles the event "header column clicked".
+ *
+ * @param col the col
+ */
+void MainWindow::headerClicked(int col){
+ m_lastOrder =
+ m_lastOrder == Qt::AscendingOrder ?
+ Qt::DescendingOrder : Qt::AscendingOrder;
+ ui->tableWidget->sortItems(col, m_lastOrder);
+ m_horizontalHeader->setSortIndicatorShown(true);
+ m_horizontalHeader->setSortIndicator(col, m_lastOrder);
}
/**
handlePlaceholder(ui->comboBoxHeader);
}
+/**
+ * Prepares the context menu of the result table.
+ *
+ */
+void MainWindow::prepareContextMenu(){
+ ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(ui->tableWidget,
+ SIGNAL(customContextMenuRequested(const QPoint&)),
+ SLOT(handleTableContextMenu(const QPoint&)));
+ ContextHandler* handler = new ContextHandler();
+ handler->m_text = "kedit";
+ handler->m_program = "/usr/bin/kate";
+ handler->m_arguments = "${full}";
+ handler->m_directoryMode = ContextHandler::DM_UNDEF;
+ handler->m_fileType = ContextHandler::FT_FILE;
+ m_contextHandlers.list().append(handler);
+ handler = new ContextHandler();
+ handler->m_text = "bash";
+ handler->m_program = "/usr/bin/konsole";
+ handler->m_arguments = "${full}";
+ handler->m_directoryMode = ContextHandler::DM_TO_FILE;
+ handler->m_fileType = ContextHandler::FT_DIR;
+ m_contextHandlers.list().append(handler);
+}
+
/**
* Prepares the text search.
*/
}
}
-void MainWindow::buildGlobalPlaceholders(QHash<QString, QString>& hash){
-
- hash.insert("filepatterns", ui->comboBoxFilePatterns->currentText());
- hash.insert("base", m_lastBaseDir.absolutePath());
- hash.insert("textpattern", ui->comboBoxTextPattern->currentText());
- hash.insert("dirs", QString::number(m_statistics.m_dirs));
- hash.insert("files", QString::number(m_statistics.m_files));
- hash.insert("runtime", QString::number(m_statistics.m_runtimeSeconds, 'g', 3));
- hash.insert("bytes", QString::number(m_statistics.m_bytes));
- hash.insert("megabytes", QString::number((double) m_statistics.m_bytes / 1000000));
- hash.insert("datetime", QDateTime::currentDateTime().toLocalTime().toString(
- "yyyy.MM.dd/hh:mm:ss"));
+/**
+ * Shows a preview of the result export.
+ */
+void MainWindow::preview(){
+ QString value;
+ QTextStream stream(&value);
+ exportToStream(stream, 1);
+ QMessageBox msgBox;
+ msgBox.setText(value);
+ msgBox.setInformativeText(tr("Preview of the Export"));
+ msgBox.setStandardButtons(QMessageBox::Cancel);
+ msgBox.setDefaultButton(QMessageBox::Save);
+ msgBox.exec();
+}
+
+void MainWindow::buildGlobalPlaceholders(QMap <QString, QString>& hash){
+
+ hash.insert("filepatterns", ui->comboBoxFilePatterns->currentText());
+ hash.insert("base", m_lastBaseDir.absolutePath());
+ hash.insert("textpattern", ui->comboBoxTextPattern->currentText());
+ hash.insert("dirs", QString::number(m_statistics.m_dirs));
+ hash.insert("files", QString::number(m_statistics.m_files));
+ hash.insert("runtime",
+ QString::number(m_statistics.m_runtimeSeconds, 'g', 3));
+ hash.insert("bytes", QString::number(m_statistics.m_bytes));
+ hash.insert("megabytes",
+ QString::number((double) m_statistics.m_bytes / 1000000));
+ hash.insert("datetime",
+ QDateTime::currentDateTime().toLocalTime().toString(
+ "yyyy.MM.dd/hh:mm:ss"));
}
/**
* Replaces placeholders valid in header and footer.
* @return <code>text</code> with the esc sequences replaced
*/
QString MainWindow::replaceGlobalPlaceholders(QComboBox* combo,
- QHash<QString, QString>& placeholders){
- QString rc = combo->currentText();
- QString error;
- if (! ReQStringUtil::replacePlaceholders(rc, placeholders, &error))
- guiError(combo, error);
+ QMap <QString, QString>& placeholders){
+ QString rc = combo->currentText();
+ QString error;
+ if (!ReQStringUtil::replacePlaceholders(rc, placeholders, &error))
+ guiError(combo, error);
return replaceEscSequences(rc);
}
storage.restore(ui->comboBoxTemplate, "comboBoxTemplate", true);
storage.restore(ui->comboBoxTextPattern, "comboBoxTextPattern");
storage.restore(ui->comboBoxYounger, "comboBoxYounger");
+ m_contextHandlers.restore(storage);
storage.close();
}
storage.store(ui->comboBoxTemplate, "comboBoxTemplate");
storage.store(ui->comboBoxTextPattern, "comboBoxTextPattern");
storage.store(ui->comboBoxYounger, "comboBoxYounger");
+ m_contextHandlers.save(storage);
storage.close();
}
#if ! defined GUI_REGUI_HPP_
#include "gui/regui.hpp"
#endif
+#if ! defined UTILS_HPP
+#include "utils.hpp"
+#endif
namespace Ui {
class MainWindow;
}
TC_NODE, TC_EXT, TC_SIZE, TC_MODIFIED, TC_TYPE, TC_PATH
};
-struct Statistics {
- Statistics(){
- clear();
- }
- void clear(){
- m_dirs = m_files = 0;
- m_bytes = 0;
- m_runtimeSeconds = 0;
- }
- int m_dirs;
- int m_files;
- int64_t m_bytes;
- double m_runtimeSeconds;
-};
-
-class ContextHandler {
-public:
- enum DirMode {
- DM_UNDEF,
- DM_TO_PARENT,
- DM_TO_FILE
- };
-
-public:
- QString m_text;
- QString m_program;
- QString m_arguments;
- DirMode m_changeToParentDirectory;
-};
-
class MainWindow: public QMainWindow, public ReGuiValidator {
Q_OBJECT
void handleTableContextMenu(const QPoint& position);
void headerClicked(int col);
void headerPlaceholder();
+ void options();
void preview();
void resetParameters();
void saveState();
void up();
private:
- void addContextMenu();
+ void prepareContextMenu();
QString buildAbsPath(int row);
QDir::Filters buildFileTypes();
- void buildGlobalPlaceholders(QHash<QString, QString>& hash);
+ void buildGlobalPlaceholders(QMap <QString, QString>& hash);
QString cellAsText(int row, int col);
void exportToStream(QTextStream& stream, int maxRow = -1);
void handlePlaceholder(QComboBox* target);
void mousePressEvent(QMouseEvent* event);
void prepareTextFind();
QString replaceGlobalPlaceholders(QComboBox* combo,
- QHash<QString, QString>& placeholders);
+ QMap <QString, QString>& placeholders);
void restoreState();
virtual void setStatusMessage(bool error, const QString& message);
private:
QString m_storageFile;
QAction* m_actionEditor;
QAction* m_actionStartShell;
- QList <ContextHandler*> m_fileHandler;
- QList <ContextHandler*> m_dirHandler;
+ ContextHandlerList m_contextHandlers;
};
#endif // MAINWINDOW_HPP
<attribute name="title">
<string>&Size, Date, Depth, Excluded Dirs</string>
</attribute>
- <widget class="QWidget" name="layoutWidget">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>0</y>
- <width>812</width>
- <height>113</height>
- </rect>
- </property>
- <layout class="QGridLayout" name="gridLayout_2">
- <property name="topMargin">
- <number>10</number>
- </property>
- <property name="bottomMargin">
- <number>10</number>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="label_4">
- <property name="maximumSize">
- <size>
- <width>150</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>Min. Size:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="comboBoxMinSize">
- <property name="minimumSize">
- <size>
- <width>175</width>
- <height>0</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>200</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="toolTip">
- <string><html><head/><body><p>Formula of the minimal size.</p><p>Example: 3*512ki + 5MiByte + -2^10</p><p><br/></p><p>A non zero value excludes automatically directories.</p><p>A formula is a arithmetic expression with the operators '+', '*' and '^' (potentioning).</p><p>Usual precedence: '+' &lt; '*' &lt; '^'</p><p>The operands are integer numbers with potentionally a unit.</p><p>Units: factor 1000: KByte, MByte, GByte, TByte<br/>factor 1024: KiByte, MiByte, GiByte, TiByte</p><p><br/></p></body></html></string>
- </property>
- <property name="editable">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QLabel" name="label_6">
- <property name="maximumSize">
- <size>
- <width>200</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>Younger than:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="3">
- <widget class="QComboBox" name="comboBoxYounger">
- <property name="minimumSize">
- <size>
- <width>200</width>
- <height>0</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>16777215</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="toolTip">
- <string><html><head/><body><p>Formula of the minimal file date.</p><p>Example (relative): 3*5days+ 2hour</p><p>Example (absolute): 2015.12.31/23:59:59 - 3weeks</p><p><br/></p><p>A formula is a arithmetic expression with the operators '+', '*' and '^' (potentioning).</p><p>Usual precedence: '+' &lt; '*' &lt; '^'</p><p>The operands are integer numbers with potentionally a unit.</p><p>The first operand may be an absolute date, date and time or time:</p><p>Date syntax: yyyy.mm.dd</p><p>Time syntax HH:MM:SS</p><p>Units: minutes, hours, days, weeks</p><p>Abbrevation is allowed: 'd' is the same as 'days'</p><p><br/></p></body></html></string>
- </property>
- <property name="editable">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="4">
- <widget class="QLabel" name="label_11">
- <property name="text">
- <string>Min. Depth:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="5">
- <widget class="QComboBox" name="comboBoxMinDepth">
- <property name="toolTip">
- <string><html><head/><body><p>Minimal distance of the subdirectory containing the found file from the base directory.</p><p>Example:<br/>Min.Depth: 1<br/>Direcory: /home</p><p>/home/x will not be found</p><p>/home/dir/x will be found</p></body></html></string>
- </property>
- <property name="editable">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_5">
- <property name="maximumSize">
- <size>
- <width>150</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>Max Size:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QComboBox" name="comboBoxMaxSize">
- <property name="minimumSize">
- <size>
- <width>175</width>
- <height>0</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>200</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="toolTip">
- <string><html><head/><body><p>Formula of the maximum size.</p><p>Example: 3*512ki + 5MiByte + -2^10</p><p><br/></p><p>A non zero value excludes automatically directories.</p><p>A formula is a arithmetic expression with the operators '+', '*' and '^' (potentioning).</p><p>Usual precedence: '+' &lt; '*' &lt; '^'</p><p>The operands are integer numbers with potentionally a unit.</p><p>Units: factor 1000: KByte, MByte, GByte, TByte<br/>factor 1024: KiByte, MiByte, GiByte, TiByte</p><p><br/></p></body></html></string>
- </property>
- <property name="editable">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="QLabel" name="label_7">
- <property name="maximumSize">
- <size>
- <width>200</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>Older than:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="3">
- <widget class="QComboBox" name="comboBoxOlder">
- <property name="maximumSize">
- <size>
- <width>200</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="toolTip">
- <string><html><head/><body><p>Formula of the maximal file date.</p><p>Example (relative): 3*5days+ 2hour</p><p>Example (absolute): 2015.12.31/23:59:59 - 3weeks</p><p><br/></p><p>A formula is a arithmetic expression with the operators '+', '*' and '^' (potentioning).</p><p>Usual precedence: '+' &lt; '*' &lt; '^'</p><p>The operands are integer numbers with potentionally a unit.</p><p>The first operand may be an absolute date, date and time or time:</p><p>Date syntax: yyyy.mm.dd</p><p>Time syntax HH:MM:SS</p><p>Units: minutes, hours, days, weeks</p><p>Abbrevation is allowed: 'd' is the same as 'days'</p><p><br/></p></body></html></string>
- </property>
- <property name="editable">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="4">
- <widget class="QLabel" name="label_12">
- <property name="text">
- <string>Max. Depth:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="5">
- <widget class="QComboBox" name="comboBoxMaxDepth">
- <property name="toolTip">
- <string><html><head/><body><p>Maximum distance of the subdirectory containing the found file from the base directory.</p><p>Example:<br/>Max. Depth: 0<br/>It found no files in subdirectories.</p></body></html></string>
- </property>
- <property name="editable">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_13">
- <property name="text">
- <string>Excluded Dirs:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1" colspan="3">
- <widget class="QComboBox" name="comboBoxExcludedDirs">
- <property name="toolTip">
- <string><html><head/><body><p>a comma (',') separated list of directory names not entered for the search.</p><p>Example: .git,.cache</p></body></html></string>
- </property>
- <property name="editable">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="4" colspan="2">
- <widget class="QPushButton" name="pushButtonSearch2">
- <property name="text">
- <string>&Run search</string>
- </property>
- <property name="icon">
- <iconset>
- <normaloff>:/main/icons/action_go.gif</normaloff>
- <normalon>:/main/icons/action_go.png</normalon>:/main/icons/action_go.gif</iconset>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
+ <layout class="QHBoxLayout" name="horizontalLayout_9">
+ <item>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <property name="topMargin">
+ <number>10</number>
+ </property>
+ <property name="bottomMargin">
+ <number>10</number>
+ </property>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="maximumSize">
+ <size>
+ <width>150</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Max Size:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="comboBoxMaxSize">
+ <property name="minimumSize">
+ <size>
+ <width>175</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>200</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string><html><head/><body><p>Formula of the maximum size.</p><p>Example: 3*512ki + 5MiByte + -2^10</p><p><br/></p><p>A non zero value excludes automatically directories.</p><p>A formula is a arithmetic expression with the operators '+', '*' and '^' (potentioning).</p><p>Usual precedence: '+' &lt; '*' &lt; '^'</p><p>The operands are integer numbers with potentionally a unit.</p><p>Units: factor 1000: KByte, MByte, GByte, TByte<br/>factor 1024: KiByte, MiByte, GiByte, TiByte</p><p><br/></p></body></html></string>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QComboBox" name="comboBoxYounger">
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string><html><head/><body><p>Formula of the minimal file date.</p><p>Example (relative): 3*5days+ 2hour</p><p>Example (absolute): 2015.12.31/23:59:59 - 3weeks</p><p><br/></p><p>A formula is a arithmetic expression with the operators '+', '*' and '^' (potentioning).</p><p>Usual precedence: '+' &lt; '*' &lt; '^'</p><p>The operands are integer numbers with potentionally a unit.</p><p>The first operand may be an absolute date, date and time or time:</p><p>Date syntax: yyyy.mm.dd</p><p>Time syntax HH:MM:SS</p><p>Units: minutes, hours, days, weeks</p><p>Abbrevation is allowed: 'd' is the same as 'days'</p><p><br/></p></body></html></string>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="comboBoxMinSize">
+ <property name="minimumSize">
+ <size>
+ <width>175</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>200</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string><html><head/><body><p>Formula of the minimal size.</p><p>Example: 3*512ki + 5MiByte + -2^10</p><p><br/></p><p>A non zero value excludes automatically directories.</p><p>A formula is a arithmetic expression with the operators '+', '*' and '^' (potentioning).</p><p>Usual precedence: '+' &lt; '*' &lt; '^'</p><p>The operands are integer numbers with potentionally a unit.</p><p>Units: factor 1000: KByte, MByte, GByte, TByte<br/>factor 1024: KiByte, MiByte, GiByte, TiByte</p><p><br/></p></body></html></string>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QComboBox" name="comboBoxOlder">
+ <property name="maximumSize">
+ <size>
+ <width>200</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string><html><head/><body><p>Formula of the maximal file date.</p><p>Example (relative): 3*5days+ 2hour</p><p>Example (absolute): 2015.12.31/23:59:59 - 3weeks</p><p><br/></p><p>A formula is a arithmetic expression with the operators '+', '*' and '^' (potentioning).</p><p>Usual precedence: '+' &lt; '*' &lt; '^'</p><p>The operands are integer numbers with potentionally a unit.</p><p>The first operand may be an absolute date, date and time or time:</p><p>Date syntax: yyyy.mm.dd</p><p>Time syntax HH:MM:SS</p><p>Units: minutes, hours, days, weeks</p><p>Abbrevation is allowed: 'd' is the same as 'days'</p><p><br/></p></body></html></string>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="5">
+ <widget class="QComboBox" name="comboBoxMaxDepth">
+ <property name="toolTip">
+ <string><html><head/><body><p>Maximum distance of the subdirectory containing the found file from the base directory.</p><p>Example:<br/>Max. Depth: 0<br/>It found no files in subdirectories.</p></body></html></string>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="maximumSize">
+ <size>
+ <width>150</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Min. Size:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="5">
+ <widget class="QComboBox" name="comboBoxMinDepth">
+ <property name="toolTip">
+ <string><html><head/><body><p>Minimal distance of the subdirectory containing the found file from the base directory.</p><p>Example:<br/>Min.Depth: 1<br/>Direcory: /home</p><p>/home/x will not be found</p><p>/home/dir/x will be found</p></body></html></string>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLabel" name="label_6">
+ <property name="maximumSize">
+ <size>
+ <width>200</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Younger than:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="4" colspan="2">
+ <widget class="QPushButton" name="pushButtonSearch2">
+ <property name="text">
+ <string>&Run search</string>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normaloff>:/main/icons/action_go.gif</normaloff>
+ <normalon>:/main/icons/action_go.png</normalon>:/main/icons/action_go.gif</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QLabel" name="label_7">
+ <property name="maximumSize">
+ <size>
+ <width>200</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Older than:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" colspan="3">
+ <widget class="QComboBox" name="comboBoxExcludedDirs">
+ <property name="toolTip">
+ <string><html><head/><body><p>a comma (',') separated list of directory names not entered for the search.</p><p>Example: .git,.cache</p></body></html></string>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QLabel" name="label_11">
+ <property name="text">
+ <string>Min. Depth:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="4">
+ <widget class="QLabel" name="label_12">
+ <property name="text">
+ <string>Max. Depth:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_13">
+ <property name="text">
+ <string>Excluded Dirs:</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
</widget>
<widget class="QWidget" name="tabExport">
<attribute name="title">
<x>10</x>
<y>11</y>
<width>981</width>
- <height>101</height>
+ <height>103</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
</property>
</spacer>
</item>
+ <item>
+ <widget class="QPushButton" name="pushButtonPreview">
+ <property name="text">
+ <string>&Preview</string>
+ </property>
+ <property name="icon">
+ <iconset resource="refind.qrc">
+ <normaloff>:/main/icons/eye.png</normaloff>:/main/icons/eye.png</iconset>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
<item row="1" column="1">
</property>
<addaction name="actionSearch"/>
<addaction name="separator"/>
+ <addaction name="actionPreview"/>
<addaction name="actionExport"/>
<addaction name="separator"/>
<addaction name="actionSaveProgramState"/>
<addaction name="separator"/>
<addaction name="separator"/>
<addaction name="actionReset"/>
+ <addaction name="separator"/>
+ <addaction name="actionOptions"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menu_Edit"/>
<addaction name="actionGetBaseDirectory"/>
<addaction name="separator"/>
<addaction name="actionReset"/>
+ <addaction name="separator"/>
+ <addaction name="actionOptions"/>
</widget>
<widget class="QToolBar" name="toolBarExit">
<property name="windowTitle">
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
+ <addaction name="actionPreview"/>
<addaction name="actionExport"/>
<addaction name="actionSaveProgramState"/>
<addaction name="actionExit"/>
<string>&About</string>
</property>
<property name="shortcut">
- <string>Ctrl+A</string>
+ <string>Ctrl+Shift+A</string>
</property>
</action>
<action name="actionExport">
<string>Puts the absolute path of the selected file into the clipboard</string>
</property>
<property name="shortcut">
- <string>Ctrl+P</string>
+ <string>Ctrl+Shift+P</string>
</property>
</action>
<action name="actionGetFullName">
<string>Sets the file filter properties to the default</string>
</property>
<property name="shortcut">
- <string>Ctrl+E</string>
+ <string>Ctrl+Shift+R</string>
</property>
</action>
<action name="actionSaveProgramState">
<string>Saves the program state (position, history...) to a file</string>
</property>
<property name="shortcut">
- <string>Ctrl+S</string>
+ <string>Ctrl+Shift+S</string>
+ </property>
+ </action>
+ <action name="actionOptions">
+ <property name="icon">
+ <iconset resource="refind.qrc">
+ <normaloff>:/main/icons/wrench.png</normaloff>:/main/icons/wrench.png</iconset>
+ </property>
+ <property name="text">
+ <string>&Options</string>
+ </property>
+ <property name="toolTip">
+ <string>Dialog for changing the options</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+Shift+O</string>
+ </property>
+ </action>
+ <action name="actionPreview">
+ <property name="icon">
+ <iconset resource="refind.qrc">
+ <normaloff>:/main/icons/eye.png</normaloff>:/main/icons/eye.png</iconset>
+ </property>
+ <property name="text">
+ <string>Pre&view</string>
+ </property>
+ <property name="toolTip">
+ <string>Shows a preview of the result export</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+Shift+V</string>
</property>
</action>
</widget>
../../gui/ReGuiValidator.cpp \
dialogglobalplaceholder.cpp \
dialogfileplaceholder.cpp \
- utils.cpp
+ utils.cpp \
+ dialogoptions.cpp
HEADERS += mainwindow.hpp \
../../gui/regui.hpp \
dialogglobalplaceholder.hpp \
dialogfileplaceholder.hpp \
- utils.hpp
+ utils.hpp \
+ dialogoptions.hpp
FORMS += mainwindow.ui \
aboutdialog.ui \
dialogglobalplaceholder.ui \
- dialogfileplaceholder.ui
+ dialogfileplaceholder.ui \
+ dialogoptions.ui
TRANSLATIONS = refind_de.ts
<file>icons/cog_edit.png</file>
<file>icons/database_save.png</file>
<file>icons/disk.png</file>
+ <file>icons/wrench.png</file>
+ <file>icons/eye.png</file>
</qresource>
</RCC>
*/
#include "base/rebase.hpp"
+#include "utils.hpp"
#include "textfinder.hpp"
/**
--- /dev/null
+/*
+ * 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 "base/rebase.hpp"
+#include "utils.hpp"
+
+/**
+ * Constructor.
+ */
+ContextHandler::ContextHandler() :
+ m_text(),
+ m_program(),
+ m_arguments(),
+ m_directoryMode(DM_TO_PARENT),
+ m_fileType(FT_FILE){
+}
+
+/**
+ * Constructor.
+ */
+ContextHandlerList::ContextHandlerList() :
+ m_list(){
+}
+
+/**
+ * Constructor.
+ */
+ContextHandlerList::~ContextHandlerList(){
+ clear();
+}
+/**
+ * Copy constructor.
+ *
+ * @param source source to copy
+ * @return the instance itself
+ */
+ContextHandlerList::ContextHandlerList(const ContextHandlerList& source) :
+ m_list(){
+ copy(source);
+}
+
+/**
+ * Assignment operator.
+ *
+ * @param source source to copy
+ * @return the instance itself
+ */
+ContextHandlerList& ContextHandlerList::operator =(
+ const ContextHandlerList& source){
+ return copy(source);
+}
+
+/**
+ * Frees the resources.
+ */
+void ContextHandlerList::clear(){
+ QList <ContextHandler*>::const_iterator it;
+ for (it = m_list.begin(); it != m_list.end(); ++it){
+ delete *it;
+ }
+ m_list.clear();
+}
+
+/**
+ * Assignment operator.
+ *
+ * @param source source to copy
+ * @return the instance itself
+ */
+ContextHandlerList& ContextHandlerList::copy(const ContextHandlerList& source){
+ clear();
+ QList <ContextHandler*>::const_iterator it;
+ for (it = source.m_list.begin(); it != source.m_list.end(); ++it){
+ ContextHandler* handler = *it;
+ m_list.append(handler);
+ }
+ return *this;
+}
+
+/**
+ * Stores the list in the storage.
+ *
+ * @param storage IN/OUT: the storage
+ */
+void ContextHandlerList::save(ReStateStorage& storage){
+ QString name = "context.program";
+ QString value;
+ for (int ix = 0; ix < m_list.size(); ix++){
+ ContextHandler* handler = m_list.at(ix);
+ value = handler->m_text + "\t" + handler->m_program + "\t"
+ + QString::number(handler->m_fileType) + "\t"
+ + QString::number(handler->m_directoryMode);
+ storage.store(name, value, ix);
+ }
+}
+
+/**
+ * Reads the list from the storage.
+ *
+ * @param storage
+ */
+void ContextHandlerList::restore(ReStateStorage& storage){
+ QString name = "context.program";
+ clear();
+ int ix = -1;
+ QString value;
+ QStringList cols;
+ while (true){
+ ix++;
+ value = storage.restore(name, ix);
+ if (value.isEmpty())
+ break;
+ cols = value.split('\t');
+ if (cols.size() != 5)
+ break;
+ ContextHandler* handler = new ContextHandler;
+ handler->m_text = cols.at(0);
+ handler->m_program = cols.at(1);
+ handler->m_arguments = cols.at(2);
+ handler->m_fileType = ContextHandler::FileType(
+ 1 + atol(cols.at(3).toUtf8().constData()));
+ handler->m_directoryMode = ContextHandler::DirMode(
+ 1 + atol(cols.at(4).toUtf8().constData()));
+ m_list.append(handler);
+ }
+}
+
+/**
+ * Constructor.
+ */
+Statistics::Statistics(){
+ clear();
+}
+
+/**
+ * Resets all members.
+ */
+void Statistics::clear(){
+ m_dirs = m_files = 0;
+ m_bytes = 0;
+ m_runtimeSeconds = 0;
+}
--- /dev/null
+/*
+ * 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 UTILS_HPP
+#define UTILS_HPP
+
+#include <QTableWidget>
+#include "gui/ReStateStorage.hpp"
+enum {
+ COL_FILE_TYPE, COL_TITLE, COL_PROGRAM, COL_ARGUMENTS, COL_CURRENT_DIR
+};
+class ContextHandler {
+public:
+ enum DirMode {
+ DM_UNDEF, DM_TO_PARENT, DM_TO_FILE
+ };
+ enum FileType {
+ FT_UNDEF, FT_DIR, FT_FILE, FT_ALL
+ };
+public:
+ ContextHandler();
+public:
+ QString m_text;
+ QString m_program;
+ QString m_arguments;
+ DirMode m_directoryMode;
+ FileType m_fileType;
+};
+
+class ContextHandlerList {
+public:
+ ContextHandlerList();
+ ~ContextHandlerList();
+ ContextHandlerList(const ContextHandlerList& source);
+ ContextHandlerList& operator =(const ContextHandlerList& source);
+public:
+ void clear();
+ ContextHandlerList©(const ContextHandlerList& source);
+ QList <ContextHandler*>& list(){
+ return m_list;
+ }
+ void save(ReStateStorage& storage);
+ void restore(ReStateStorage& storage);
+private:
+ QList <ContextHandler*> m_list;
+};
+
+class Statistics {
+public:
+ Statistics();
+public:
+ void clear();
+public:
+ int m_dirs;
+ int m_files;
+ int64_t m_bytes;
+ double m_runtimeSeconds;
+};
+
+#endif // UTILS_HPP
* @return <code>true</code>: success<br>
* <code>false</code>: unknown name found (not replaced)
*/
-bool ReQStringUtil::replacePlaceholders(QString& text,
- const QHash<QString, QString>& placeholders, QString* error){
+bool ReQStringUtil::replacePlaceholders(QString& text, const QMap<QString,
+ QString>& placeholders, QString* error){
int start = 0;
bool rc = true;
QString name;
- QHash<QString, QString>::const_iterator it;
+ QMap<QString, QString>::const_iterator it;
while (start >= 0){
start = text.indexOf("${", start);
if (start < 0)
#endif
}
static QString pathAppend(const QString& base, const QString& path);
- static bool replacePlaceholders(QString& text, const QHash<QString,
+ static bool replacePlaceholders(QString& text, const QMap<QString,
QString>& placeholders, QString* error);
static void skipExpected(const ReString& text, QChar expected, int& index,
int& length);
#include <QThread>
#include <QIODevice>
#include <QTextStream>
-#include <QHash>
+#include <QMap>
#include <QVector>
#include <QDataStream>
#include <QMutex>
}
}
}
+/**
+ * Reads a value from the storage.
+ *
+ * @param name name of the variable
+ * @param index -1 (no array) or the index of the entry
+ * @return "": not found<br>
+ * otherwise: the stored value of the variable
+ */
+QString ReStateStorage::restore(const QString& name, int index)
+{
+ QString rc;
+ if (initForRead()){
+ QString key(name);
+ if (index >= 0)
+ key += QString::number(index);
+ if (m_map.contains(key))
+ rc = m_map.value(key);
+ }
+ return rc;
+}
/**
* Stores the data of a combobox.
*
m_stream->flush();
}
+/**
+ * Stores the data of a combobox.
+ *
+ * @param combo the combobox to store
+ * @param name the name of the combobox
+ * @param withCurrentText <code>true</code>: the current text will be saved too
+ */
+void ReStateStorage::store(const QString& name, const QString& value, int index)
+{
+ if (initForWrite()){
+ QString key(name);
+ if (index >= 0)
+ key += QString::number(index);
+ *m_stream << key << "=" << value << endl;
+ }
+ m_stream->flush();
+
+}
+
bool initForWrite();
void restore(QComboBox* combo, const QString& name, bool withCurrentText =
false);
+ QString restore(const QString& name, int index = -1);
+ void setForm(const QString& form);
void store(const QComboBox* combo, const QString& name,
bool withCurrentText = true);
- void setForm(const QString& form);
+ void store(const QString& name, const QString& value, int index = -1);
private:
QString m_filename;