]> gitweb.hamatoma.de Git - reqt/commitdiff
ReSearch: text search, date criteria
authorHamatoma <hamatoma@gmx.de>
Thu, 24 Nov 2016 00:47:56 +0000 (01:47 +0100)
committerHamatoma <hamatoma@gmx.de>
Thu, 24 Nov 2016 00:47:56 +0000 (01:47 +0100)
appl/refind/mainwindow.ui
appl/research/filecache.cpp
appl/research/filecache.hpp
appl/research/filefinder.cpp
appl/research/filefinder.hpp
appl/research/mainwindow.cpp
appl/research/mainwindow.hpp
appl/research/mainwindow.ui
base/ReFileSearch.cpp
base/ReFileSearch.hpp

index c3224744dc0feeb6a56b16f65a07210bc0e7142b..184dab9d13a797653460a39a9c1ea1aabcbfcc73 100644 (file)
                <string>S&amp;top search</string>
               </property>
               <property name="icon">
-               <iconset resource="refind.qrc">
+               <iconset>
                 <normaloff>:/main/icons/stop.png</normaloff>:/main/icons/stop.png</iconset>
               </property>
              </widget>
                  <string notr="true">^</string>
                 </property>
                 <property name="icon">
-                 <iconset resource="refind.qrc">
+                 <iconset>
                   <normaloff>:/main/icons/folder_go.png</normaloff>:/main/icons/folder_go.png</iconset>
                 </property>
                </widget>
                  <string notr="true">...</string>
                 </property>
                 <property name="icon">
-                 <iconset resource="refind.qrc">
+                 <iconset>
                   <normaloff>:/main/icons/folder_find.png</normaloff>:/main/icons/folder_find.png</iconset>
                 </property>
                </widget>
                <string>S&amp;top search</string>
               </property>
               <property name="icon">
-               <iconset resource="refind.qrc">
+               <iconset>
                 <normaloff>:/main/icons/stop.png</normaloff>:/main/icons/stop.png</iconset>
               </property>
               <property name="shortcut">
                <string>&amp;Export</string>
               </property>
               <property name="icon">
-               <iconset resource="refind.qrc">
+               <iconset>
                 <normaloff>:/main/icons/database_save.png</normaloff>:/main/icons/database_save.png</iconset>
               </property>
               <property name="shortcut">
                <string>&amp;Preview</string>
               </property>
               <property name="icon">
-               <iconset resource="refind.qrc">
+               <iconset>
                 <normaloff>:/main/icons/eye.png</normaloff>:/main/icons/eye.png</iconset>
               </property>
               <property name="shortcut">
      <x>0</x>
      <y>0</y>
      <width>1030</width>
-     <height>26</height>
+     <height>30</height>
     </rect>
    </property>
    <widget class="QMenu" name="menuFile">
   </widget>
   <action name="actionExit">
    <property name="icon">
-    <iconset resource="refind.qrc">
+    <iconset>
      <normaloff>:/main/icons/door_in.png</normaloff>:/main/icons/door_in.png</iconset>
    </property>
    <property name="text">
   </action>
   <action name="actionSearch">
    <property name="icon">
-    <iconset resource="refind.qrc">
+    <iconset>
      <normaloff>:/main/icons/action_go.png</normaloff>:/main/icons/action_go.png</iconset>
    </property>
    <property name="text">
   </action>
   <action name="actionExport">
    <property name="icon">
-    <iconset resource="refind.qrc">
+    <iconset>
      <normaloff>:/main/icons/database_save.png</normaloff>:/main/icons/database_save.png</iconset>
    </property>
    <property name="text">
   </action>
   <action name="actionUp">
    <property name="icon">
-    <iconset resource="refind.qrc">
+    <iconset>
      <normaloff>:/main/icons/folder_go.png</normaloff>:/main/icons/folder_go.png</iconset>
    </property>
    <property name="text">
   </action>
   <action name="actionSelectDirectory">
    <property name="icon">
-    <iconset resource="refind.qrc">
+    <iconset>
      <normaloff>:/main/icons/folder_find.png</normaloff>:/main/icons/folder_find.png</iconset>
    </property>
    <property name="text">
   </action>
   <action name="actionGetAbsPath">
    <property name="icon">
-    <iconset resource="refind.qrc">
+    <iconset>
      <normaloff>:/main/icons/folder.png</normaloff>:/main/icons/folder.png</iconset>
    </property>
    <property name="text">
   </action>
   <action name="actionGetFullName">
    <property name="icon">
-    <iconset resource="refind.qrc">
+    <iconset>
      <normaloff>:/main/icons/table.png</normaloff>
      <normalon>:/main/icons/table.gif</normalon>:/main/icons/table.png</iconset>
    </property>
   </action>
   <action name="actionGetBaseDirectory">
    <property name="icon">
-    <iconset resource="refind.qrc">
+    <iconset>
      <normaloff>:/main/icons/action_paste.png</normaloff>:/main/icons/action_paste.png</iconset>
    </property>
    <property name="text">
   </action>
   <action name="actionReset">
    <property name="icon">
-    <iconset resource="refind.qrc">
+    <iconset>
      <normaloff>:/main/icons/wand.png</normaloff>:/main/icons/wand.png</iconset>
    </property>
    <property name="text">
   </action>
   <action name="actionSaveProgramState">
    <property name="icon">
-    <iconset resource="refind.qrc">
+    <iconset>
      <normaloff>:/main/icons/disk.png</normaloff>:/main/icons/disk.png</iconset>
    </property>
    <property name="text">
   </action>
   <action name="actionOptions">
    <property name="icon">
-    <iconset resource="refind.qrc">
+    <iconset>
      <normaloff>:/main/icons/wrench.png</normaloff>:/main/icons/wrench.png</iconset>
    </property>
    <property name="text">
   </action>
   <action name="actionPreview">
    <property name="icon">
-    <iconset resource="refind.qrc">
+    <iconset>
      <normaloff>:/main/icons/eye.png</normaloff>:/main/icons/eye.png</iconset>
    </property>
    <property name="text">
   </action>
   <action name="actionStart">
    <property name="icon">
-    <iconset resource="refind.qrc">
+    <iconset>
      <normaloff>:/main/icons/action_go.png</normaloff>:/main/icons/action_go.png</iconset>
    </property>
    <property name="text">
     <bool>false</bool>
    </property>
    <property name="icon">
-    <iconset resource="refind.qrc">
+    <iconset>
      <normaloff>:/main/icons/stop.png</normaloff>:/main/icons/stop.png</iconset>
    </property>
    <property name="text">
   <tabstop>comboBoxExcludedDirs</tabstop>
   <tabstop>tableWidget</tabstop>
  </tabstops>
- <resources>
-  <include location="refind.qrc"/>
- </resources>
+ <resources/>
  <connections>
   <connection>
    <sender>actionExit</sender>
index b1416f3b5da0cd180c5e00e833ae4749ead12c06..0f9e343f86a0c7c0dd86b8e99e96b2cc4f2ef6ec 100644 (file)
@@ -94,4 +94,14 @@ const QStringList &FileCache::lines(const QString &filename) const
     return item == NULL ? m_emptyLines : item->lines();
 }
 
+/**
+ * Removes a file from the cache.
+ *
+ * @param filename  the filename with path
+ */
+void FileCache::remove(const QString &filename)
+{
+    m_cache.remove(filename);
+}
+
 
index 33c87ce65dda0e1e164b5d99a650845a0c541e86..96030165ae85703a5c57573d23f01fecabd6d8ae 100644 (file)
@@ -21,6 +21,7 @@ public:
 public:
     void addOrUpdate(const QString& filename);
     const QStringList& lines(const QString& filename) const;
+    void remove(const QString& filename);
 private:
     QMap<QString, FileCacheItem*> m_cache;
     QStringList m_emptyLines;
index 8db0a29e4980376e0bf188ce8f64c664bf50378d..028caa993880c2ba582970162cb686fddcb41d64 100644 (file)
@@ -5,14 +5,21 @@
  * Constructor.
  *
  * @param table the table for the found files
+ * @param cache the file content cache
  */
-FileFinder::FileFinder(QTableWidget& table) :
+FileFinder::FileFinder(QTableWidget& table, FileCache& cache) :
     ReFileSearch(),
     m_table(table),
     m_files(),
     m_dirs(0),
     m_foundFiles(0),
-    m_ignoredFiles(0)
+    m_ignoredFiles(0),
+    m_addNotDetach(false),
+    m_regularExpression(NULL),
+    m_text(NULL),
+    m_inverseSearch(false),
+    m_caseSensitive(false),
+    m_cache(cache)
 {
     setSearchMode(smFiles);
 }
@@ -51,6 +58,32 @@ void FileFinder::addToTable(const QString& full, const QString &path,
     }
 }
 
+/**
+ * Adds a file to the file table.
+ *
+ * @param full  the filename with path
+ * @param path  the path of the file
+ * @param node  the filename without path
+ * @param info  the info about the file
+ */
+void FileFinder::detachFromTable(const QString& full, const QString &path,
+        const QString &node)
+{
+    if (! m_files.contains(full)){
+        ++m_ignoredFiles;
+    } else {
+        ++m_foundFiles;
+        m_files.remove(full);
+        for (int ix = m_table.rowCount() - 1; ix >= 0; --ix){
+            if (m_table.item(ix, colNode)->text() == node
+                    && m_table.item(ix, colPath)->text() == path){
+                m_table.removeRow(ix);
+                break;
+            }
+        }
+    }
+}
+
 /**
  * Clears the table.
  */
@@ -92,10 +125,96 @@ int FileFinder::ignoredFiles() const
 bool FileFinder::handleFile(const QString &full, const QString &path,
         const QString &node, const QFileInfo& info)
 {
-    addToTable(full, path, node, info);
+    bool found = false;
+    if (m_regularExpression != NULL){
+        found = searchWithRegExpr(full);
+    } else if (m_text != NULL){
+        found = searchText(full);
+    }
+    if (found){
+        if (m_addNotDetach)
+            addToTable(full, path, node, info);
+        else
+            detachFromTable(full, path, node);
+    }
     return true;
 }
 
+/**
+ * Searches a text in the file content.
+ *
+ * @param filename  the file to search
+ * @return          <i>true</i>:    if <i>! m_inverseSearch</i>: the text has been found<br>
+ *                                  if <i>m_inverseSearch</i>: the text has not been found<br>
+ */
+bool FileFinder::searchText(const QString &filename)
+{
+    m_cache.addOrUpdate(filename);
+    const QStringList& lines = m_cache.lines(filename);
+    bool rc = false;
+    if (m_caseSensitive){
+       if (m_inverseSearch){
+          rc = true;
+          for (int ix = 0; ix < lines.size(); ++ix){
+              if (lines[ix].indexOf(m_text) < 0){
+                  rc = false;
+                  break;
+              }
+          }
+       } else {
+           rc = false;
+           for (int ix = 0; ix < lines.size(); ++ix){
+               if (lines[ix].indexOf(m_text) >= 0){
+                   rc = true;
+                   break;
+               }
+           }
+       }
+    } else {
+        if (m_inverseSearch){
+
+        } else {
+
+        }
+    }
+    if (! rc)
+        m_cache.remove(filename);
+    return rc;
+}
+
+/**
+ * Searches a regular expression in the file content.
+ *
+ * @param filename  the file to search
+ * @return          <i>true</i>: the text has been found
+ */
+bool FileFinder::searchWithRegExpr(const QString& filename){
+    m_cache.addOrUpdate(filename);
+    const QStringList& lines = m_cache.lines(filename);
+
+    bool rc = false;
+    if (m_inverseSearch){
+       rc = true;
+       for (int ix = 0; ix < lines.size(); ++ix){
+           if (m_regularExpression->match(lines[ix]).hasMatch()){
+               rc = false;
+               break;
+           }
+       }
+    } else {
+        rc = false;
+        for (int ix = 0; ix < lines.size(); ++ix){
+            if (m_regularExpression->match(lines[ix]).hasMatch()){
+                rc = true;
+                break;
+            }
+        }
+    }
+    if (rc)
+        m_cache.remove(filename);
+    return rc;
+}
+
 /**
  * Searches files in a directory tree and put them into a table widget.
  *
@@ -119,3 +238,42 @@ void FileFinder::search(const QString &baseDirectory, const QString &patterns,
     oneDirectory(baseDirectory, 0);
 }
 
+/**
+ * Sets the flag for the search mode.
+ *
+ * @param addNotDetach  <i>true</i>: the found files will be added
+ */
+void FileFinder::setAddNotDetach(bool addNotDetach)
+{
+    m_addNotDetach = addNotDetach;
+}
+
+/**
+ * Sets the text search options.
+ *
+ * @param text                  text to search
+ * @param caseSensitive         <i>true</i>: the search is case sensitive
+ * @param isRegularExpression   <i>true</i>: the text is a regular expression
+ * @param inverseSearch         <i>true</i>: the file is selected if the text
+ *                              is not found
+ */
+void FileFinder::setTextToSearch(const QString &text, bool caseSensitive,
+    bool isRegularExpression, bool inverseSearch)
+{
+    m_inverseSearch = inverseSearch;
+    delete m_text;
+    delete m_regularExpression;
+    m_text = NULL;
+    m_regularExpression = NULL;
+    m_caseSensitive = caseSensitive;
+    if (! text.isEmpty()){
+        if (isRegularExpression){
+            m_regularExpression = new QRegularExpression(text,
+                caseSensitive ? QRegularExpression::NoPatternOption
+                              : QRegularExpression::CaseInsensitiveOption);
+        } else {
+            m_text = new QString(text);
+        }
+    }
+}
+
index 575c72194fee24a30024c67baea37481b84da655..2b45ee2f4d627af5e440bcbd630a03cb85174a44 100644 (file)
@@ -1,11 +1,11 @@
 #ifndef FILEFINDER_H
 #define FILEFINDER_H
 
-
+class FileCache;
 class FileFinder : public ReFileSearch
 {
 public:
-    FileFinder( QTableWidget& m_table);
+    FileFinder( QTableWidget& m_table, FileCache& cache);
     virtual ~FileFinder();
 public:
     void addToTable(const QString& full, const QString &path,
@@ -17,14 +17,25 @@ public:
     int ignoredFiles() const;
     void search(const QString& baseDirectory, const QString& patterns,
                 int minDepth, int maxDepth);
-
-
+    void setAddNotDetach(bool addNotDetach);
+    void setTextToSearch(const QString &text, bool caseSensitive,
+        bool isRegularExpression, bool inverseSearch);
+private:
+    void detachFromTable(const QString &full, const QString &path, const QString &node);
+    bool searchWithRegExpr(const QString &filename);
+    bool searchText(const QString &filename);
 private:
     QTableWidget& m_table;
     QSet<QString> m_files;
     int m_dirs;
     int m_foundFiles;
     int m_ignoredFiles;
+    bool m_addNotDetach;
+    QRegularExpression* m_regularExpression;
+    QString* m_text;
+    bool m_inverseSearch;
+    bool m_caseSensitive;
+    FileCache& m_cache;
 };
 
 #endif // FILEFINDER_H
index 337323cd33df8d317d539a5f6a3720d169fdbb68..9639c1df1dcde7fee1d3b6acd2261cb7e1df48a1 100644 (file)
@@ -64,9 +64,10 @@ void MainWindow::initializeGui(){
     connect(ui->pushButtonAdd, SIGNAL(clicked()), this, SLOT(onAdd()));
     connect(ui->pushButtonClear, SIGNAL(clicked()), this, SLOT(onClear()));
     connect(ui->pushButtonFilter, SIGNAL(clicked()), this, SLOT(onFilter()));
+    connect(ui->pushButtonDetach, SIGNAL(clicked()), this, SLOT(onDetach()));
 
     delete m_fileFinder;
-    m_fileFinder = new FileFinder(*ui->tableWidget);
+    m_fileFinder = new FileFinder(*ui->tableWidget, *m_fileCache);
 
     ui->tableWidget->setColumnWidth(colNode, 200);
     ui->tableWidget->setColumnWidth(colSize, 125);
@@ -102,21 +103,15 @@ void MainWindow::onAboutToQuit()
  */
 void MainWindow::onAdd()
 {
-    QString base = ui->comboBoxBaseDirectory->currentText();
-    if (base.isEmpty()){
-        say(LOG_ERROR, tr("missing a base directory"));
-    } else {
-        m_fileFinder->search(base, ui->comboBoxFilePatterns->currentText(),
-             atoi(ui->lineEditMinDepth->text().toLocal8Bit().data()),
-             atoi(ui->lineEditMaxDepth->text().toLocal8Bit().data()));
-        int files = ui->tableWidget->rowCount();
-        ui->labelFileCount->setText(QString::number(files)
-                                    + " " + tr("file(s)"));
-        say(LOG_INFO, tr("files: %1 already found: %2 processed directories: %3")
-            .arg(m_fileFinder->foundFiles())
-            .arg(m_fileFinder->ignoredFiles())
-            .arg(m_fileFinder->processedDirs()));
-    }
+    searchFiles(true);
+}
+
+/**
+ * Handles the click of the "Detach" button.
+ */
+void MainWindow::onDetach()
+{
+    searchFiles(false);
 }
 
 /**
@@ -182,6 +177,42 @@ bool MainWindow::say(ReLoggerLevel level, const QString& message){
        return level >= LOG_INFO;
 }
 
+/**
+ * Common operation of onAdd() and onDetach().
+ *
+ * @param addNotDetach  <i>true</i>: add the found files<br>
+ *                      <i>false</i>: detach the found files
+ */
+void MainWindow::searchFiles(bool addNotDetach)
+{
+    QString base = ui->comboBoxBaseDirectory->currentText();
+    if (base.isEmpty()){
+        say(LOG_ERROR, tr("missing a base directory"));
+    } else {
+        QDateTime olderThan = comboDate(ui->comboBoxOlder);
+        QDateTime youngerThan = comboDate(ui->comboBoxYounger);
+        m_fileFinder->setOlderThan(olderThan.currentMSecsSinceEpoch() <= 0
+                ? NULL : new QDateTime(olderThan));
+        m_fileFinder->setYoungerThan(olderThan.currentMSecsSinceEpoch() <= 0
+                ? NULL : new QDateTime(youngerThan));
+        m_fileFinder->setTextToSearch(ui->comboBoxTextPattern->currentText(),
+                ui->checkBoxCaseSensitiv->isChecked(),
+                ui->checkBoxRegularExpr->isChecked(),
+                ui->checkBoxInverse->isChecked());
+        m_fileFinder->setAddNotDetach(addNotDetach);
+        m_fileFinder->search(base, ui->comboBoxFilePatterns->currentText(),
+             atoi(ui->lineEditMinDepth->text().toLocal8Bit().data()),
+             atoi(ui->lineEditMaxDepth->text().toLocal8Bit().data()));
+        int files = ui->tableWidget->rowCount();
+        ui->labelFileCount->setText(QString::number(files)
+                                    + " " + tr("file(s)"));
+        say(LOG_INFO, tr("files: %1 already found: %2 processed directories: %3")
+            .arg(m_fileFinder->foundFiles())
+            .arg(m_fileFinder->ignoredFiles())
+            .arg(m_fileFinder->processedDirs()));
+    }
+}
+
 /**
  * Event
  * @param oldString
index 9f7f08322374109674495ea9d0aad697f8b84f15..a192cad29b482699f1f838ad76efdb8f82d8dabd 100644 (file)
@@ -32,10 +32,12 @@ private:
     virtual void onAboutToQuit();
     virtual void onGuiTimerUpdate();
     virtual void onLanguageChange();
+    void searchFiles(bool addNotDetach);
 private slots:
     void onAbout();
     void onAdd();
     void onClear();
+    void onDetach();
     void onFilter();
     void onSelectBaseDirectory();
     void textEdited(const QString& oldString, const QString& newString);
index 4ca7c7fff84e6a5358f0197ac7feb7f35b8532a1..b5e5a0178e766c6ea9bdde4dba4ad3faf5379b72 100644 (file)
                 </item>
                </layout>
               </widget>
+              <widget class="QWidget" name="tabDirectorySearchOptions">
+               <attribute name="title">
+                <string>Directory search options</string>
+               </attribute>
+               <layout class="QVBoxLayout" name="verticalLayout_6">
+                <item>
+                 <layout class="QHBoxLayout" name="horizontalLayout_7" stretch="0,1">
+                  <item>
+                   <widget class="QLabel" name="label_2">
+                    <property name="minimumSize">
+                     <size>
+                      <width>125</width>
+                      <height>0</height>
+                     </size>
+                    </property>
+                    <property name="text">
+                     <string>Text pattern:</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <widget class="ReComboBox" name="comboBoxTextPattern">
+                    <property name="toolTip">
+                     <string>Only files containing this text / text pattern will be found.
+If the checkbox &quot;Regular expression&quot; is selected the text is interpreted as regular expression.
+If the checkbox &quot;inverse search&quot; is checked a file is found only if the file does &lt;b&gt;not&lt;/b&gt; contain the text / text pattern.</string>
+                    </property>
+                    <property name="editable">
+                     <bool>true</bool>
+                    </property>
+                   </widget>
+                  </item>
+                 </layout>
+                </item>
+                <item>
+                 <layout class="QHBoxLayout" name="horizontalLayout_9">
+                  <item>
+                   <widget class="QCheckBox" name="checkBoxCaseSensitiv">
+                    <property name="text">
+                     <string>Case sensitive</string>
+                    </property>
+                    <property name="checked">
+                     <bool>true</bool>
+                    </property>
+                   </widget>
+                  </item>
+                  <item>
+                   <widget class="QCheckBox" name="checkBoxRegularExpr">
+                    <property name="text">
+                     <string>Regular expression</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="QCheckBox" name="checkBoxInverse">
+                    <property name="toolTip">
+                     <string>If checked: a file will be selected only if the pattern is not found</string>
+                    </property>
+                    <property name="text">
+                     <string>inverse search</string>
+                    </property>
+                   </widget>
+                  </item>
+                 </layout>
+                </item>
+                <item>
+                 <layout class="QHBoxLayout" name="horizontalLayout_11">
+                  <item>
+                   <layout class="QHBoxLayout" name="horizontalLayout_8" stretch="0,1">
+                    <item>
+                     <widget class="QLabel" name="label_4">
+                      <property name="minimumSize">
+                       <size>
+                        <width>125</width>
+                        <height>0</height>
+                       </size>
+                      </property>
+                      <property name="text">
+                       <string>Younger then:</string>
+                      </property>
+                     </widget>
+                    </item>
+                    <item>
+                     <widget class="ReComboBox" name="comboBoxYounger">
+                      <property name="toolTip">
+                       <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Formula of the minimal file date.&lt;/p&gt;&lt;p&gt;Example (relative): 3*5days+ 2hour&lt;/p&gt;&lt;p&gt;Example (absolute): 2015.12.31/23:59:59 - 3weeks&lt;/p&gt;&lt;p&gt;A formula is a arithmetic expression with the operators '+', '*' and '^' (potentioning).&lt;/p&gt;&lt;p&gt;Usual precedence: '+' &amp;lt; '*' &amp;lt; '^'&lt;/p&gt;&lt;p&gt;The operands are integer numbers with potentionally a unit.&lt;/p&gt;&lt;p&gt;The first operand may be an absolute date, date and time or time:&lt;/p&gt;&lt;p&gt;Date syntax: yyyy.mm.dd&lt;/p&gt;&lt;p&gt;Time syntax HH:MM:SS&lt;/p&gt;&lt;p&gt;Units: minutes, hours, days, weeks&lt;/p&gt;&lt;p&gt;Abbrevation is allowed: 'd' is the same as 'days'&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+                      </property>
+                      <property name="editable">
+                       <bool>true</bool>
+                      </property>
+                     </widget>
+                    </item>
+                   </layout>
+                  </item>
+                  <item>
+                   <layout class="QHBoxLayout" name="horizontalLayout_10" stretch="0,1">
+                    <item>
+                     <widget class="QLabel" name="label_13">
+                      <property name="minimumSize">
+                       <size>
+                        <width>125</width>
+                        <height>0</height>
+                       </size>
+                      </property>
+                      <property name="text">
+                       <string>Older than:</string>
+                      </property>
+                     </widget>
+                    </item>
+                    <item>
+                     <widget class="QComboBox" name="comboBoxOlder">
+                      <property name="toolTip">
+                       <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Formula of the maximal file date.&lt;/p&gt;&lt;p&gt;Example (relative): 3*5days+ 2hour&lt;/p&gt;&lt;p&gt;Example (absolute): 2015.12.31/23:59:59 - 3weeks&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;A formula is a arithmetic expression with the operators '+', '*' and '^' (potentioning).&lt;/p&gt;&lt;p&gt;Usual precedence: '+' &amp;lt; '*' &amp;lt; '^'&lt;/p&gt;&lt;p&gt;The operands are integer numbers with potentionally a unit.&lt;/p&gt;&lt;p&gt;The first operand may be an absolute date, date and time or time:&lt;/p&gt;&lt;p&gt;Date syntax: yyyy.mm.dd&lt;/p&gt;&lt;p&gt;Time syntax HH:MM:SS&lt;/p&gt;&lt;p&gt;Units: minutes, hours, days, weeks&lt;/p&gt;&lt;p&gt;Abbrevation is allowed: 'd' is the same as 'days'&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+                      </property>
+                      <property name="editable">
+                       <bool>true</bool>
+                      </property>
+                     </widget>
+                    </item>
+                   </layout>
+                  </item>
+                 </layout>
+                </item>
+               </layout>
+              </widget>
               <widget class="QWidget" name="tabSingleFiles">
                <attribute name="title">
                 <string>Single files</string>
               <property name="title">
                <string>Activity</string>
               </property>
-              <widget class="QPushButton" name="pushButtonAdd">
+              <widget class="QLabel" name="labelFileCount">
                <property name="geometry">
                 <rect>
-                 <x>19</x>
-                 <y>27</y>
-                 <width>85</width>
-                 <height>33</height>
+                 <x>0</x>
+                 <y>150</y>
+                 <width>131</width>
+                 <height>20</height>
                 </rect>
                </property>
-               <property name="toolTip">
-                <string>Adds the described files into the table below</string>
-               </property>
                <property name="text">
-                <string>&amp;Add</string>
+                <string notr="true"/>
                </property>
               </widget>
-              <widget class="QPushButton" name="pushButtonClear">
+              <widget class="QWidget" name="">
                <property name="geometry">
                 <rect>
                  <x>19</x>
-                 <y>67</y>
-                 <width>85</width>
-                 <height>33</height>
-                </rect>
-               </property>
-               <property name="toolTip">
-                <string>Clears the table below</string>
-               </property>
-               <property name="text">
-                <string>&amp;Clear</string>
-               </property>
-              </widget>
-              <widget class="QLabel" name="labelFileCount">
-               <property name="geometry">
-                <rect>
-                 <x>0</x>
-                 <y>120</y>
-                 <width>131</width>
-                 <height>20</height>
+                 <y>27</y>
+                 <width>87</width>
+                 <height>113</height>
                 </rect>
                </property>
-               <property name="text">
-                <string notr="true"> </string>
-               </property>
+               <layout class="QVBoxLayout" name="verticalLayout_5">
+                <item>
+                 <widget class="QPushButton" name="pushButtonAdd">
+                  <property name="toolTip">
+                   <string>Adds the described files into the table below</string>
+                  </property>
+                  <property name="text">
+                   <string>&amp;Add</string>
+                  </property>
+                 </widget>
+                </item>
+                <item>
+                 <widget class="QPushButton" name="pushButtonDetach">
+                  <property name="toolTip">
+                   <string>Removes the found files from the table below</string>
+                  </property>
+                  <property name="text">
+                   <string>&amp;Detach</string>
+                  </property>
+                 </widget>
+                </item>
+                <item>
+                 <spacer name="verticalSpacer">
+                  <property name="orientation">
+                   <enum>Qt::Vertical</enum>
+                  </property>
+                  <property name="sizeHint" stdset="0">
+                   <size>
+                    <width>20</width>
+                    <height>40</height>
+                   </size>
+                  </property>
+                 </spacer>
+                </item>
+                <item>
+                 <widget class="QPushButton" name="pushButtonClear">
+                  <property name="toolTip">
+                   <string>Clears the table below</string>
+                  </property>
+                  <property name="text">
+                   <string>&amp;Clear</string>
+                  </property>
+                 </widget>
+                </item>
+               </layout>
               </widget>
              </widget>
             </item>
index 3fe3264ec1de809b321cbf76968af3bfbb8d7c08..aad76a7da5e80e45b330a5ff32ee10e86414656f 100644 (file)
@@ -16,7 +16,9 @@ ReFileSearch::ReFileSearch() :
        m_maxDepth(9999),
        m_searchMode(smFilesAndDirs),
     m_matcher(),
-    m_processedDirs(0)
+    m_processedDirs(0),
+    m_youngerThan(NULL),
+    m_olderThan(NULL)
 {
 }
 
@@ -47,6 +49,16 @@ int ReFileSearch::minDepth() const
        return m_minDepth;
 }
 
+/**
+ * Returns the "older than" value.
+ *
+ * @return the "older than" value
+ */
+QDateTime* ReFileSearch::olderThan() const
+{
+    return m_olderThan;
+}
+
 /**
  * Does the search in one directory.
  *
@@ -75,7 +87,11 @@ void ReFileSearch::oneDirectory(const QString& directory, int depth)
                full += OS_SEPARATOR;
                full += node;
                QFileInfo info(full);
-               if (! info.isDir()){
+        if (m_olderThan != NULL && info.lastModified() > *m_olderThan)
+            continue;
+        if (m_youngerThan != NULL && info.lastModified() < *m_youngerThan)
+            continue;
+        if (! info.isDir()){
                        if (m_searchMode == smDirs || depth < m_minDepth){
                                continue;
                        }
@@ -98,6 +114,16 @@ void ReFileSearch::oneDirectory(const QString& directory, int depth)
     }
 }
 
+/**
+ * Returns the number of processed directories.
+ *
+ * @return the number of directories entered during the search
+ */
+int ReFileSearch::processedDirs() const
+{
+    return m_processedDirs;
+}
+
 /**
  * Returns the current search mode.
  *
@@ -118,11 +144,6 @@ void ReFileSearch::setSearchMode(const SearchMode& searchMode)
        m_searchMode = searchMode;
 }
 
-int ReFileSearch::processedDirs() const
-{
-    return m_processedDirs;
-}
-
 /**
  * Sets the maximal depth.
  *
@@ -143,6 +164,17 @@ void ReFileSearch::setMinDepth(int minDepth)
        m_minDepth = minDepth;
 }
 
+/**
+ * Sets the "older than" value.
+ *
+ * @param youngerThan   NULL: no check of "older than"<br>
+ *                      otherwise: only files older than this will be "found"
+ */
+void ReFileSearch::setOlderThan(QDateTime *olderThan)
+{
+    m_olderThan = olderThan;
+}
+
 /**
  * Sets the search patterns.
  *
@@ -153,3 +185,25 @@ void ReFileSearch::setPatterns(const QString& includeExcludePatterns)
 {
        m_matcher.setPatterns(includeExcludePatterns, ',', '-');
 }
+
+/**
+ * Sets the "younger than" value.
+ *
+ * @param youngerThan   NULL: no check of "younger than"<br>
+ *                      otherwise: only files younger than this will be "found"
+ */
+void ReFileSearch::setYoungerThan(QDateTime *youngerThan)
+{
+    m_youngerThan = youngerThan;
+}
+
+/**
+ * Returns the "younger than" value.
+ *
+ * @return the "younger than" value
+ */
+QDateTime* ReFileSearch::youngerThan() const
+{
+    return m_youngerThan;
+}
+
index 409d886b0e4915b7a963d64000fd65442630b076..c512e3a9a435b90e5ca118eb569e10a37bae96e0 100644 (file)
@@ -43,19 +43,26 @@ public:
        int maxDepth() const;
        int minDepth() const;
        void oneDirectory(const QString& directory, int depth);
+    QDateTime *olderThan() const;
     int processedDirs() const;
        SearchMode searchMode() const;
        void setMaxDepth(int maxDepth);
        void setMinDepth(int minDepth);
+    void setOlderThan(QDateTime *olderThan);
        void setPatterns(const QString& includeExcludePattern);
        void setSearchMode(const SearchMode& searchMode);
+    void setYoungerThan(QDateTime *youngerThan);
+    QDateTime *youngerThan() const;
+
 
 protected:
     int m_minDepth;
     int m_maxDepth;
-       SearchMode m_searchMode;
-       ReIncludeExcludeMatcher m_matcher;
+    SearchMode m_searchMode;
+    ReIncludeExcludeMatcher m_matcher;
     int m_processedDirs;
+    QDateTime* m_youngerThan;
+    QDateTime* m_olderThan;
 };
 
 #endif // REFILESEARCH_HPP