]> gitweb.hamatoma.de Git - reqt/commitdiff
Research: improvements
authorHamatoma <hamatoma@gmx.de>
Fri, 25 Nov 2016 23:37:56 +0000 (00:37 +0100)
committerHamatoma <hamatoma@gmx.de>
Fri, 25 Nov 2016 23:37:56 +0000 (00:37 +0100)
appl/research/filefilter.cpp
appl/research/filefilter.hpp
appl/research/mainwindow.cpp
appl/research/mainwindow.hpp
appl/research/mainwindow.ui

index 205775777930e5b6512966696ce9ee7c0b9bf596..68a8ecc81fa18335510e59510a0550021ef026e2 100644 (file)
@@ -120,6 +120,8 @@ int FileFilter::filterOneFile(const QString& filename, int lastHit)
         }
         m_lastHitPosition.m_line = lineNo;
         m_lastHitPosition.m_hitNo = ++lastHit;
+        if (m_lastHitPosition.m_hitNo > m_lastHitPosition.m_maxHitNo)
+            m_lastHitPosition.m_maxHitNo = m_lastHitPosition.m_hitNo;
         if (lastHit >= m_fromHit){
             for (int ix = max(lastLine + 1, max(0, lineNo - m_linesAbove));
                  ix <= min(lineNo + m_linesBelow, lastIx);
index 827d625c37a6005192ff458084b3ddc1ec3858e2..a86dc2c179c417f7d842955ba64cae545567bfde 100644 (file)
@@ -8,13 +8,15 @@ public:
         m_filename(),
         m_line(0),
         m_hitNo(0),
-        m_hitCount(-1)
+        m_hitCount(-1),
+        m_maxHitNo(0)
     {}
 public:
     QString m_filename;
     int m_line;
     int m_hitNo;
     int m_hitCount;
+    int m_maxHitNo;
 };
 
 class FileFilter
index d211ddbca0abfebf94d5631174a97cfd1383f43a..581441ee98058fdad13d4b9a04cdcbe4a4cc7353 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "QFileDialog"
 
-static const char* VERSION = "2016.11.16";
+static const char* VERSION = "2016.11.26";
 
 MainWindow::MainWindow(QApplication& application, const QString& homeDir,
                                           QWidget *parent) :
@@ -84,20 +84,34 @@ void MainWindow::initializeGui(){
     ui->tableWidget->setColumnWidth(colNode, 200);
     ui->tableWidget->setColumnWidth(colSize, 125);
     ui->tableWidget->setColumnWidth(colDate, 175);
-
+    switchFilter(true);
     if (m_test){
-        ui->comboBoxBaseDirectory->setCurrentText("/etc");
-        ui->comboBoxFilePatterns->setCurrentText("*asu*");
-        ui->comboBoxIncludingPattern->setCurrentText("#!");
+        ui->comboBoxBaseDirectory->setCurrentText("/home/mhm/labor");
+        ui->comboBoxFilePatterns->setCurrentText("big*.txt");
+        ui->comboBoxIncludingPattern->setCurrentText("47");
         onAdd();
     }
 }
 
+/**
+ * Writes the known number of hits into the label.
+ */
+void MainWindow::logHits(){
+    if (m_lastHitPosition->m_hitCount >= 0)
+        ui->labelHits->setText(tr("%1 hit(s)").arg(m_lastHitPosition->m_hitCount));
+    else
+        ui->labelHits->setText(tr(">= %1 hit(s)").arg(m_lastHitPosition->m_maxHitNo));
+}
+
+/**
+ * Handles the change of the search criteria.
+ */
 void MainWindow::clearLastHitPosition(const QString&, const QString&)
 {
     m_lastHitPosition->m_filename.clear();
     m_lastHitPosition->m_hitCount = -1;
     m_lastHitPosition->m_hitNo = -1;
+    m_lastHitPosition->m_maxHitNo = 0;
 }
 
 /**
@@ -157,6 +171,7 @@ void MainWindow::onFilter()
     filter.filter(ui->comboBoxIncludingPattern->currentText(),
                   ui->comboBoxExcludingPattern->currentText(),
                   from, to, above, below, false);
+    switchFilter(false);
 }
 
 /**
@@ -260,6 +275,26 @@ void MainWindow::searchFiles(bool addNotDetach)
     }
 }
 
+/**
+ * Switches the filter state.
+ *
+ * @param first     <i>true</i>: a new resultset is expected.
+ */
+void MainWindow::switchFilter(bool first){
+    ui->pushButtonFilter->setEnabled(first);
+    ui->pushButtonPrevious->setEnabled(! first);
+    ui->pushButtonNext->setEnabled(! first);
+    if (first){
+        int start = comboInt(ui->comboBoxFromHit, 1);
+        int pageSize = comboInt(ui->comboBoxToHit, start + 50) - start + 1;
+        ui->comboBoxFromHit->setCurrentText("1");
+        ui->comboBoxToHit->setCurrentText(QString::number(pageSize));
+        ui->labelHits->setText("");
+    } else {
+        logHits();
+    }
+}
+
 /**
  * Event
  * @param oldString
index 240f7a44c1323cc9f95f7d1c26a39d6428733d37..623d46faa84b2b078441fe28d96ef3668fbe40c1 100644 (file)
@@ -30,10 +30,12 @@ public:
 private:
     int comboboxToInt(QComboBox &combobox, int defaultValue);
     void initializeGui();
+    void logHits();
     virtual void onAboutToQuit();
     virtual void onGuiTimerUpdate();
     virtual void onLanguageChange();
     void searchFiles(bool addNotDetach);
+    void switchFilter(bool first);
 private slots:
     void clearLastHitPosition(const QString &, const QString &);
     void onAbout();
index 605bc0b4da167832292fab9bbfde5a4d6d84b9a2..e6aa7816707a6eb9b0889458dbf081362b8fca42 100644 (file)
@@ -596,8 +596,21 @@ If the checkbox &quot;inverse search&quot; is checked a file is found only if th
               </property>
              </spacer>
             </item>
+            <item>
+             <widget class="QLabel" name="labelHits">
+              <property name="text">
+               <string>123456 Hits</string>
+              </property>
+              <property name="textFormat">
+               <enum>Qt::PlainText</enum>
+              </property>
+             </widget>
+            </item>
             <item>
              <widget class="QPushButton" name="pushButtonPrevious">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
               <property name="maximumSize">
                <size>
                 <width>25</width>
@@ -614,6 +627,9 @@ If the checkbox &quot;inverse search&quot; is checked a file is found only if th
             </item>
             <item>
              <widget class="QPushButton" name="pushButtonNext">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
               <property name="maximumSize">
                <size>
                 <width>25</width>