]> gitweb.hamatoma.de Git - reqt/commitdiff
Research: ReIntComboBox, near-by-search, hits per file, block per file master
authorHamatoma <hamatoma@gmx.de>
Thu, 8 Dec 2016 23:31:49 +0000 (00:31 +0100)
committerHamatoma <hamatoma@gmx.de>
Thu, 8 Dec 2016 23:31:49 +0000 (00:31 +0100)
15 files changed:
appl/research/filefilter.cpp
appl/research/filefilter.hpp
appl/research/mainwindow.cpp
appl/research/mainwindow.ui
appl/research/research.de.ts
appl/research/research.pro
base/ReQStringUtils.cpp
base/ReQStringUtils.hpp
base/ReTest.cpp
cunit/cuReFileUtils.cpp
cunit/cuReQStringUtils.cpp
gui/ReIntComboBox.cpp [new file with mode: 0644]
gui/ReIntComboBox.hpp [new file with mode: 0644]
gui/ReSettings.cpp
gui/regui.hpp

index 16425ae195331f918a19bb45e5675f31d06e2575..faac182fdbce5301186bf57b1ea9c91713787461 100644 (file)
@@ -15,7 +15,7 @@ FileFilter::FileFilter(QTableWidget &table, QListWidget &list, FileCache& cache,
     m_excludeExpr(NULL),
     m_blockStartExpr(NULL),
     m_blockEndExpr(NULL),
     m_excludeExpr(NULL),
     m_blockStartExpr(NULL),
     m_blockEndExpr(NULL),
-    m_singleBlock(false),
+    m_blocksPerFile(false),
     m_caseSensitive(false),
     m_fromHit(0),
     m_toHit(0),
     m_caseSensitive(false),
     m_fromHit(0),
     m_toHit(0),
@@ -54,7 +54,7 @@ void FileFilter::filter(const QString &includePattern,
                         int linesAbove, int linesBelow,
                         bool caseSensitive, PrefixMode prefixMode,
                         const QString& blockStart, const QString& blockEnd,
                         int linesAbove, int linesBelow,
                         bool caseSensitive, PrefixMode prefixMode,
                         const QString& blockStart, const QString& blockEnd,
-                        bool singleBlock)
+                        int blocksPerFile)
 {
     int ixFile = -1;
     int hitNo = 0;
 {
     int ixFile = -1;
     int hitNo = 0;
@@ -65,7 +65,7 @@ void FileFilter::filter(const QString &includePattern,
     m_linesAbove = linesAbove;
     m_linesBelow = linesBelow;
     m_prefixMode = prefixMode;
     m_linesAbove = linesAbove;
     m_linesBelow = linesBelow;
     m_prefixMode = prefixMode;
-    m_singleBlock = singleBlock;
+    m_blocksPerFile = blocksPerFile;
 
     delete m_includeExpr;
     delete m_excludeExpr;
 
     delete m_includeExpr;
     delete m_excludeExpr;
@@ -81,7 +81,7 @@ void FileFilter::filter(const QString &includePattern,
     m_blockEndExpr = blockEnd.isEmpty() ? NULL : new QRegularExpression(blockEnd, option);
     QString full;
     QString node;
     m_blockEndExpr = blockEnd.isEmpty() ? NULL : new QRegularExpression(blockEnd, option);
     QString full;
     QString node;
-    int hitFileNo = -1;
+    int hitFileNo = 0;
     while (ixFile < fileCount - 1 && hitNo < m_toHit){
         ++ixFile;
         full = m_table.item(ixFile, colPath)->text();
     while (ixFile < fileCount - 1 && hitNo < m_toHit){
         ++ixFile;
         full = m_table.item(ixFile, colPath)->text();
@@ -130,6 +130,7 @@ int FileFilter::filterOneFile(const QString& filename, const QString& node,
     default:
         break;
     }
     default:
         break;
     }
+    int currentBlock = 0;
     QString prefixOther = prefixHit;
     if (m_linesAbove + m_linesBelow > 0){
         prefixHit = ">" + prefixHit;
     QString prefixOther = prefixHit;
     if (m_linesAbove + m_linesBelow > 0){
         prefixHit = ">" + prefixHit;
@@ -144,7 +145,7 @@ int FileFilter::filterOneFile(const QString& filename, const QString& node,
         lineNo = m_lastHitPosition.m_line;
     }
     int firstHitFile = true;
         lineNo = m_lastHitPosition.m_line;
     }
     int firstHitFile = true;
-    int firstFileIndex = 0;
+    int firstFileIndex = -1;
     bool inBlock = m_blockStartExpr == NULL;
     while(lastHit < m_toHit && lineNo < lastIx){
         QString line = lines[++lineNo];
     bool inBlock = m_blockStartExpr == NULL;
     while(lastHit < m_toHit && lineNo < lastIx){
         QString line = lines[++lineNo];
@@ -191,7 +192,7 @@ int FileFilter::filterOneFile(const QString& filename, const QString& node,
         }
         if (m_blockEndExpr != 0 && m_blockEndExpr->match(line).hasMatch()){
             inBlock = false;
         }
         if (m_blockEndExpr != 0 && m_blockEndExpr->match(line).hasMatch()){
             inBlock = false;
-            if (m_singleBlock)
+            if (++currentBlock >= m_blocksPerFile)
                 break;
         }
     }
                 break;
         }
     }
index 08c79ff55a40484d03cfe06a390e54309313390a..f2398355cd0d5a9077b3ecbf0ebd80b3a9ffb741 100644 (file)
@@ -30,7 +30,7 @@ public:
                 int fromHit, int toHit, int linesAbove, int linesBelow,
                 bool caseSensitive, PrefixMode prefixMode,
                 const QString& blockStart, const QString& blockEnd,
                 int fromHit, int toHit, int linesAbove, int linesBelow,
                 bool caseSensitive, PrefixMode prefixMode,
                 const QString& blockStart, const QString& blockEnd,
-                bool singleBlock);
+                int blocksPerFile);
 
 private:
     int filterOneFile(const QString &filename, const QString& node, int lastHit,
 
 private:
     int filterOneFile(const QString &filename, const QString& node, int lastHit,
@@ -43,7 +43,7 @@ private:
    QRegularExpression* m_excludeExpr;
    QRegularExpression* m_blockStartExpr;
    QRegularExpression* m_blockEndExpr;
    QRegularExpression* m_excludeExpr;
    QRegularExpression* m_blockStartExpr;
    QRegularExpression* m_blockEndExpr;
-   bool m_singleBlock;
+   int m_blocksPerFile;
    bool m_caseSensitive;
    int m_fromHit;
    int m_toHit;
    bool m_caseSensitive;
    int m_fromHit;
    int m_toHit;
index 24bd7e148fd0290aeff553acfd829fc01240b821..a38ac84277c0da9ab306e8daa536f2a148fed495 100644 (file)
@@ -12,7 +12,7 @@ MainWindow::MainWindow(QApplication& application, const QString& homeDir,
                        const QString& baseDirectory,
                        const QString& filePatterns,
                        QWidget *parent) :
                        const QString& baseDirectory,
                        const QString& filePatterns,
                        QWidget *parent) :
-       ReGuiApplication(application, "rsearch", homeDir, 2, 10100100, "de", parent),
+    ReGuiApplication(application, "research", homeDir, 2, 10100100, "de", parent),
        ReGuiValidator(),
        ui(new Ui::MainWindow),
        m_fileFinder(NULL),
        ReGuiValidator(),
        ui(new Ui::MainWindow),
        m_fileFinder(NULL),
@@ -23,6 +23,7 @@ MainWindow::MainWindow(QApplication& application, const QString& homeDir,
     m_timer(new QTimer(this)),
     m_filenames()
 {
     m_timer(new QTimer(this)),
     m_filenames()
 {
+    ReIntComboBox::m_defaultAnnouncer = this;
        ReComboBox::setDefaultHistorySize(20);
     m_timer->setSingleShot(true);
        initializeGui();
        ReComboBox::setDefaultHistorySize(20);
     m_timer->setSingleShot(true);
        initializeGui();
@@ -154,6 +155,7 @@ void MainWindow::initializeGui(){
 
     connect(m_timer, SIGNAL(timeout()), this, SLOT(onTimerTask()));
 
 
     connect(m_timer, SIGNAL(timeout()), this, SLOT(onTimerTask()));
 
+    ui->comboBoxFromHit->setMinValue(1);
        delete m_fileFinder;
        m_fileFinder = new FileFinder(*ui->tableWidget, *m_fileCache);
 
        delete m_fileFinder;
        m_fileFinder = new FileFinder(*ui->tableWidget, *m_fileCache);
 
@@ -325,7 +327,7 @@ void MainWindow::onFilter()
                   (PrefixMode) ui->comboBoxPrefixMode->currentIndex(),
                   ui->comboBoxStartPattern->currentText(),
                   ui->comboBoxEndPattern->currentText(),
                   (PrefixMode) ui->comboBoxPrefixMode->currentIndex(),
                   ui->comboBoxStartPattern->currentText(),
                   ui->comboBoxEndPattern->currentText(),
-                  ui->checkBoxSingleBlock->isChecked());
+                  ui->comboBoxBlocksPerFile->currentValue());
     switchFilter(false);
     int found = pageSize;
     if (m_lastHitPosition->m_hitCount >= 0
     switchFilter(false);
     int found = pageSize;
     if (m_lastHitPosition->m_hitCount >= 0
index b7a4fc0e56b1c7629cf2ced17508a69c7126f45c..743085aa6ab5c432a48933bbab10c846eba1fdba 100644 (file)
                      </size>
                     </property>
                     <property name="text">
                      </size>
                     </property>
                     <property name="text">
-                     <string>99</string>
+                     <string notr="true">99</string>
                     </property>
                    </widget>
                   </item>
                     </property>
                    </widget>
                   </item>
                      </size>
                     </property>
                     <property name="text">
                      </size>
                     </property>
                     <property name="text">
-                     <string>0</string>
+                     <string notr="true">0</string>
                     </property>
                    </widget>
                   </item>
                     </property>
                    </widget>
                   </item>
@@ -580,205 +580,364 @@ If the checkbox &quot;inverse search&quot; is checked a file is found only if th
              <attribute name="title">
               <string>Options</string>
              </attribute>
              <attribute name="title">
               <string>Options</string>
              </attribute>
-             <layout class="QVBoxLayout" name="verticalLayout_8">
-              <item>
-               <layout class="QGridLayout" name="gridLayout" columnstretch="0,1,0,1,0,2">
-                <property name="sizeConstraint">
-                 <enum>QLayout::SetMaximumSize</enum>
-                </property>
-                <item row="0" column="0">
-                 <widget class="QLabel" name="label_8">
-                  <property name="minimumSize">
-                   <size>
-                    <width>0</width>
-                    <height>0</height>
-                   </size>
-                  </property>
-                  <property name="maximumSize">
-                   <size>
-                    <width>16777215</width>
-                    <height>16777215</height>
-                   </size>
-                  </property>
-                  <property name="text">
-                   <string>Lines above:</string>
-                  </property>
-                 </widget>
-                </item>
-                <item row="0" column="1">
-                 <widget class="ReComboBox" name="comboBoxLinesAbove">
-                  <property name="minimumSize">
-                   <size>
-                    <width>0</width>
-                    <height>0</height>
-                   </size>
-                  </property>
-                  <property name="maximumSize">
-                   <size>
-                    <width>175</width>
-                    <height>16777215</height>
-                   </size>
-                  </property>
-                  <property name="editable">
-                   <bool>true</bool>
-                  </property>
-                  <property name="currentText">
-                   <string>0</string>
-                  </property>
-                 </widget>
-                </item>
-                <item row="0" column="2">
-                 <widget class="QLabel" name="label_9">
-                  <property name="minimumSize">
-                   <size>
-                    <width>0</width>
-                    <height>0</height>
-                   </size>
-                  </property>
-                  <property name="maximumSize">
-                   <size>
-                    <width>16777215</width>
-                    <height>16777215</height>
-                   </size>
-                  </property>
-                  <property name="text">
-                   <string>Lines below:</string>
-                  </property>
-                 </widget>
-                </item>
-                <item row="0" column="3">
-                 <widget class="ReComboBox" name="comboBoxLinesBelow">
-                  <property name="minimumSize">
-                   <size>
-                    <width>0</width>
-                    <height>0</height>
-                   </size>
-                  </property>
-                  <property name="maximumSize">
-                   <size>
-                    <width>175</width>
-                    <height>16777215</height>
-                   </size>
-                  </property>
-                  <property name="editable">
-                   <bool>true</bool>
-                  </property>
-                  <property name="currentText">
-                   <string notr="true">0</string>
-                  </property>
-                 </widget>
-                </item>
-                <item row="0" column="4">
-                 <widget class="QLabel" name="label_18">
-                  <property name="minimumSize">
-                   <size>
-                    <width>0</width>
-                    <height>0</height>
-                   </size>
-                  </property>
-                  <property name="maximumSize">
-                   <size>
-                    <width>16777215</width>
-                    <height>16777215</height>
-                   </size>
-                  </property>
-                  <property name="text">
-                   <string>Prefix:</string>
-                  </property>
-                 </widget>
-                </item>
-                <item row="0" column="5">
-                 <widget class="QComboBox" name="comboBoxPrefixMode">
-                  <property name="minimumSize">
-                   <size>
-                    <width>0</width>
-                    <height>0</height>
-                   </size>
-                  </property>
-                  <property name="maximumSize">
-                   <size>
-                    <width>175</width>
-                    <height>16777215</height>
-                   </size>
-                  </property>
-                  <item>
+             <widget class="QWidget" name="layoutWidget">
+              <property name="geometry">
+               <rect>
+                <x>11</x>
+                <y>11</y>
+                <width>608</width>
+                <height>90</height>
+               </rect>
+              </property>
+              <layout class="QHBoxLayout" name="horizontalLayout_12">
+               <item>
+                <layout class="QFormLayout" name="formLayout_4">
+                 <item row="0" column="0">
+                  <widget class="QLabel" name="label_8">
+                   <property name="minimumSize">
+                    <size>
+                     <width>0</width>
+                     <height>0</height>
+                    </size>
+                   </property>
+                   <property name="maximumSize">
+                    <size>
+                     <width>16777215</width>
+                     <height>16777215</height>
+                    </size>
+                   </property>
                    <property name="text">
                    <property name="text">
-                    <string>Placeholder</string>
+                    <string>Lines above:</string>
+                   </property>
+                  </widget>
+                 </item>
+                 <item row="0" column="1">
+                  <widget class="ReIntComboBox" name="comboBoxLinesAbove">
+                   <property name="minimumSize">
+                    <size>
+                     <width>0</width>
+                     <height>0</height>
+                    </size>
+                   </property>
+                   <property name="maximumSize">
+                    <size>
+                     <width>75</width>
+                     <height>16777215</height>
+                    </size>
+                   </property>
+                   <property name="editable">
+                    <bool>true</bool>
+                   </property>
+                   <property name="currentText">
+                    <string>0</string>
+                   </property>
+                  </widget>
+                 </item>
+                 <item row="2" column="1">
+                  <widget class="ReIntComboBox" name="comboBoxLinesBelow">
+                   <property name="minimumSize">
+                    <size>
+                     <width>0</width>
+                     <height>0</height>
+                    </size>
+                   </property>
+                   <property name="maximumSize">
+                    <size>
+                     <width>75</width>
+                     <height>16777215</height>
+                    </size>
+                   </property>
+                   <property name="editable">
+                    <bool>true</bool>
+                   </property>
+                   <property name="currentText">
+                    <string notr="true">0</string>
+                   </property>
+                  </widget>
+                 </item>
+                 <item row="2" column="0">
+                  <widget class="QLabel" name="label_9">
+                   <property name="minimumSize">
+                    <size>
+                     <width>0</width>
+                     <height>0</height>
+                    </size>
+                   </property>
+                   <property name="maximumSize">
+                    <size>
+                     <width>16777215</width>
+                     <height>16777215</height>
+                    </size>
                    </property>
                    </property>
-                  </item>
-                  <item>
                    <property name="text">
                    <property name="text">
-                    <string>Filename with path</string>
+                    <string>Lines below:</string>
                    </property>
                    </property>
-                  </item>
-                  <item>
+                  </widget>
+                 </item>
+                </layout>
+               </item>
+               <item>
+                <layout class="QFormLayout" name="formLayout_10">
+                 <item row="0" column="0">
+                  <widget class="QCheckBox" name="checkBox">
                    <property name="text">
                    <property name="text">
-                    <string>Filename without path</string>
+                    <string>Case sensitive</string>
                    </property>
                    </property>
-                  </item>
-                  <item>
+                   <property name="checked">
+                    <bool>false</bool>
+                   </property>
+                  </widget>
+                 </item>
+                 <item row="1" column="0">
+                  <widget class="QLabel" name="label_24">
                    <property name="text">
                    <property name="text">
-                    <string>No filename</string>
+                    <string/>
                    </property>
                    </property>
-                  </item>
-                 </widget>
-                </item>
-               </layout>
-              </item>
-             </layout>
+                  </widget>
+                 </item>
+                </layout>
+               </item>
+               <item>
+                <layout class="QFormLayout" name="formLayout_6">
+                 <item row="0" column="0">
+                  <widget class="QLabel" name="label_18">
+                   <property name="minimumSize">
+                    <size>
+                     <width>0</width>
+                     <height>0</height>
+                    </size>
+                   </property>
+                   <property name="maximumSize">
+                    <size>
+                     <width>16777215</width>
+                     <height>16777215</height>
+                    </size>
+                   </property>
+                   <property name="text">
+                    <string>Prefix:</string>
+                   </property>
+                  </widget>
+                 </item>
+                 <item row="0" column="1">
+                  <widget class="QComboBox" name="comboBoxPrefixMode">
+                   <property name="minimumSize">
+                    <size>
+                     <width>0</width>
+                     <height>0</height>
+                    </size>
+                   </property>
+                   <property name="maximumSize">
+                    <size>
+                     <width>16777215</width>
+                     <height>16777215</height>
+                    </size>
+                   </property>
+                   <item>
+                    <property name="text">
+                     <string>Placeholder</string>
+                    </property>
+                   </item>
+                   <item>
+                    <property name="text">
+                     <string>Filename with path</string>
+                    </property>
+                   </item>
+                   <item>
+                    <property name="text">
+                     <string>Filename without path</string>
+                    </property>
+                   </item>
+                   <item>
+                    <property name="text">
+                     <string>No filename</string>
+                    </property>
+                   </item>
+                  </widget>
+                 </item>
+                 <item row="1" column="0">
+                  <widget class="QLabel" name="label_23">
+                   <property name="text">
+                    <string>Hits per file:</string>
+                   </property>
+                  </widget>
+                 </item>
+                 <item row="1" column="1">
+                  <widget class="ReIntComboBox" name="comboBoxHitsPerFile">
+                   <property name="maximumSize">
+                    <size>
+                     <width>75</width>
+                     <height>16777215</height>
+                    </size>
+                   </property>
+                   <property name="editable">
+                    <bool>true</bool>
+                   </property>
+                  </widget>
+                 </item>
+                </layout>
+               </item>
+              </layout>
+             </widget>
             </widget>
             <widget class="QWidget" name="tabBlock">
              <attribute name="title">
               <string>Block</string>
              </attribute>
             </widget>
             <widget class="QWidget" name="tabBlock">
              <attribute name="title">
               <string>Block</string>
              </attribute>
-             <layout class="QFormLayout" name="formLayout_5">
-              <item row="0" column="0">
-               <widget class="QLabel" name="label_16">
-                <property name="text">
-                 <string>Start pattern:</string>
-                </property>
-               </widget>
-              </item>
-              <item row="0" column="1">
-               <widget class="ReComboBox" name="comboBoxStartPattern">
-                <property name="editable">
-                 <bool>true</bool>
-                </property>
-               </widget>
-              </item>
-              <item row="1" column="0">
-               <widget class="QLabel" name="label_17">
-                <property name="text">
-                 <string>End pattern:</string>
-                </property>
-               </widget>
-              </item>
-              <item row="1" column="1">
-               <widget class="ReComboBox" name="comboBoxEndPattern">
-                <property name="editable">
-                 <bool>true</bool>
-                </property>
-               </widget>
+             <layout class="QVBoxLayout" name="verticalLayout_8">
+              <item>
+               <layout class="QHBoxLayout" name="horizontalLayout_14" stretch="1,0">
+                <item>
+                 <layout class="QFormLayout" name="formLayout_5">
+                  <item row="0" column="0">
+                   <widget class="QLabel" name="label_16">
+                    <property name="text">
+                     <string>Start pattern:</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="0" column="1">
+                   <widget class="ReComboBox" name="comboBoxStartPattern">
+                    <property name="editable">
+                     <bool>true</bool>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="1" column="0">
+                   <widget class="QLabel" name="label_17">
+                    <property name="text">
+                     <string>End pattern:</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="1" column="1">
+                   <widget class="ReComboBox" name="comboBoxEndPattern">
+                    <property name="editable">
+                     <bool>true</bool>
+                    </property>
+                   </widget>
+                  </item>
+                 </layout>
+                </item>
+                <item>
+                 <layout class="QFormLayout" name="formLayout_9">
+                  <item row="0" column="0">
+                   <widget class="QLabel" name="label_22">
+                    <property name="text">
+                     <string>Blocks per file:</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="0" column="1">
+                   <widget class="ReIntComboBox" name="comboBoxBlocksPerFile">
+                    <property name="maximumSize">
+                     <size>
+                      <width>75</width>
+                      <height>16777215</height>
+                     </size>
+                    </property>
+                    <property name="editable">
+                     <bool>true</bool>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="1" column="0" colspan="2">
+                   <widget class="QCheckBox" name="checkBoxBlockCaseSensitive">
+                    <property name="text">
+                     <string>Case sensitive</string>
+                    </property>
+                   </widget>
+                  </item>
+                 </layout>
+                </item>
+               </layout>
               </item>
              </layout>
             </widget>
               </item>
              </layout>
             </widget>
-            <widget class="QWidget" name="tabBlockOptions">
+            <widget class="QWidget" name="tabNearBy">
              <attribute name="title">
              <attribute name="title">
-              <string>Block Options</string>
+              <string>&quot;Near by&quot; Search</string>
              </attribute>
              </attribute>
-             <widget class="QCheckBox" name="checkBoxSingleBlock">
-              <property name="geometry">
-               <rect>
-                <x>20</x>
-                <y>20</y>
-                <width>171</width>
-                <height>25</height>
-               </rect>
-              </property>
-              <property name="text">
-               <string>A single block only</string>
-              </property>
-             </widget>
+             <layout class="QVBoxLayout" name="verticalLayout_9">
+              <item>
+               <layout class="QHBoxLayout" name="horizontalLayout_13" stretch="1,0">
+                <item>
+                 <layout class="QFormLayout" name="formLayout_7">
+                  <item row="0" column="0">
+                   <widget class="QLabel" name="label_19">
+                    <property name="text">
+                     <string>Search pattern:</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="0" column="1">
+                   <widget class="ReComboBox" name="comboBoxNearByPattern">
+                    <property name="editable">
+                     <bool>true</bool>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="1" column="0" colspan="2">
+                   <widget class="QCheckBox" name="checkBox_2">
+                    <property name="text">
+                     <string>Case sensitive</string>
+                    </property>
+                   </widget>
+                  </item>
+                 </layout>
+                </item>
+                <item>
+                 <layout class="QFormLayout" name="formLayout_8">
+                  <item row="0" column="0">
+                   <widget class="QLabel" name="label_20">
+                    <property name="text">
+                     <string>Max. lines above the hit:</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="0" column="1">
+                   <widget class="ReComboBox" name="comboBoxNearByAbove">
+                    <property name="maximumSize">
+                     <size>
+                      <width>75</width>
+                      <height>16777215</height>
+                     </size>
+                    </property>
+                    <property name="editable">
+                     <bool>true</bool>
+                    </property>
+                    <property name="currentText">
+                     <string notr="true">0</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="1" column="0">
+                   <widget class="QLabel" name="label_21">
+                    <property name="text">
+                     <string>Max. lines below the hit:</string>
+                    </property>
+                   </widget>
+                  </item>
+                  <item row="1" column="1">
+                   <widget class="ReComboBox" name="comboBoxNearByBelow">
+                    <property name="maximumSize">
+                     <size>
+                      <width>75</width>
+                      <height>16777215</height>
+                     </size>
+                    </property>
+                    <property name="editable">
+                     <bool>true</bool>
+                    </property>
+                    <property name="currentText">
+                     <string notr="true">0</string>
+                    </property>
+                   </widget>
+                  </item>
+                 </layout>
+                </item>
+               </layout>
+              </item>
+             </layout>
             </widget>
            </widget>
           </item>
             </widget>
            </widget>
           </item>
@@ -872,7 +1031,7 @@ If the checkbox &quot;inverse search&quot; is checked a file is found only if th
              </widget>
             </item>
             <item>
              </widget>
             </item>
             <item>
-             <widget class="ReComboBox" name="comboBoxFromHit">
+             <widget class="ReIntComboBox" name="comboBoxFromHit">
               <property name="maximumSize">
                <size>
                 <width>100</width>
               <property name="maximumSize">
                <size>
                 <width>100</width>
@@ -895,7 +1054,7 @@ If the checkbox &quot;inverse search&quot; is checked a file is found only if th
              </widget>
             </item>
             <item>
              </widget>
             </item>
             <item>
-             <widget class="ReComboBox" name="comboBoxPageSize">
+             <widget class="ReIntComboBox" name="comboBoxPageSize">
               <property name="maximumSize">
                <size>
                 <width>100</width>
               <property name="maximumSize">
                <size>
                 <width>100</width>
@@ -909,7 +1068,7 @@ If the checkbox &quot;inverse search&quot; is checked a file is found only if th
                <bool>true</bool>
               </property>
               <property name="currentText">
                <bool>true</bool>
               </property>
               <property name="currentText">
-               <string notr="true">10</string>
+               <string notr="true">50</string>
               </property>
              </widget>
             </item>
               </property>
              </widget>
             </item>
@@ -994,6 +1153,11 @@ If the checkbox &quot;inverse search&quot; is checked a file is found only if th
    <extends>QComboBox</extends>
    <header>gui/ReComboBox.hpp</header>
   </customwidget>
    <extends>QComboBox</extends>
    <header>gui/ReComboBox.hpp</header>
   </customwidget>
+  <customwidget>
+   <class>ReIntComboBox</class>
+   <extends>QComboBox</extends>
+   <header>ReIntComboBox.hpp</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>
  </customwidgets>
  <resources/>
  <connections/>
index 1515dc3fce3dfdd46cb9b1859fbfa71178689bcc..93746505fce6862fbcf88776377b543fac1413aa 100644 (file)
@@ -1211,7 +1211,7 @@ Wenn die Checkbox &quot;Inverse Suche&quot; ausgewählt ist, wird eine Datei nur
     </message>
     <message>
         <source>Found: %1 hit(s) in %2</source>
     </message>
     <message>
         <source>Found: %1 hit(s) in %2</source>
-        <translation>Gefunden: %1 Treffer in %d</translation>
+        <translation>Gefunden: %1 Treffer in %2</translation>
     </message>
     <message>
         <source>missing a base directory</source>
     </message>
     <message>
         <source>missing a base directory</source>
@@ -1229,6 +1229,30 @@ Wenn die Checkbox &quot;Inverse Suche&quot; ausgewählt ist, wird eine Datei nur
         <source>I am working...</source>
         <translation>Ich arbeite...</translation>
     </message>
         <source>I am working...</source>
         <translation>Ich arbeite...</translation>
     </message>
+    <message>
+        <source>Hits per file:</source>
+        <translation>Treffer je Datei:</translation>
+    </message>
+    <message>
+        <source>Blocks per file:</source>
+        <translation>Blöcke je Datei:</translation>
+    </message>
+    <message>
+        <source>Search pattern:</source>
+        <translation>Suchmuster:</translation>
+    </message>
+    <message>
+        <source>Max. lines above the hit:</source>
+        <translation>Max. Zeilen Ã¼ber dem Treffer:</translation>
+    </message>
+    <message>
+        <source>Max. lines below the hit:</source>
+        <translation>Max. Zeilen unter dem Treffer:</translation>
+    </message>
+    <message>
+        <source>&quot;Near by&quot; Search</source>
+        <translation>&quot;Nahe bei&quot;-Suche</translation>
+    </message>
 </context>
 <context>
     <name>QObject</name>
 </context>
 <context>
     <name>QObject</name>
@@ -1391,4 +1415,23 @@ yyy</translatorcomment>
         <translation>Willkommen!</translation>
     </message>
 </context>
         <translation>Willkommen!</translation>
     </message>
 </context>
+<context>
+    <name>ReIntComboBox</name>
+    <message>
+        <source>integer expected, not an empty string</source>
+        <translation>Ganzzahl erwartet, kein leerer String</translation>
+    </message>
+    <message>
+        <source>not a number:</source>
+        <translation>Keine Zahl:</translation>
+    </message>
+    <message>
+        <source>value to small: %1 &lt; %2</source>
+        <translation>Wert zu klein: %1 &lt; %2 </translation>
+    </message>
+    <message>
+        <source>value to large: %1 &gt; %2</source>
+        <translation>Wert zu groß: %1 &gt; %2</translation>
+    </message>
+</context>
 </TS>
 </TS>
index 5b1bfdd7596eab9d67e30257745c5f10b4ba1a09..a72cfce6b90331c462b9e6237da7567fc2e49676 100644 (file)
@@ -34,7 +34,8 @@ SOURCES += main.cpp \
     ../../base/ReFileSearch.cpp \
     filefinder.cpp \
     filecache.cpp \
     ../../base/ReFileSearch.cpp \
     filefinder.cpp \
     filecache.cpp \
-    filefilter.cpp
+    filefilter.cpp \
+    ../../gui/ReIntComboBox.cpp
 
 HEADERS  += mainwindow.hpp \
         ../../base/rebase.hpp \
 
 HEADERS  += mainwindow.hpp \
         ../../base/rebase.hpp \
@@ -49,7 +50,8 @@ HEADERS  += mainwindow.hpp \
     ../../base/ReFileSearch.hpp \
     filefinder.hpp \
     filecache.hpp \
     ../../base/ReFileSearch.hpp \
     filefinder.hpp \
     filecache.hpp \
-    filefilter.hpp
+    filefilter.hpp \
+    ../../gui/ReIntComboBox.hpp
 
 FORMS    += mainwindow.ui \
        aboutdialog.ui
 
 FORMS    += mainwindow.ui \
        aboutdialog.ui
index a9304156fb142d113b178b1d5be7a30d1c414069..036fb301e4e675fbc91d8852909544d520c8df16 100644 (file)
@@ -104,7 +104,31 @@ bool ReQStringUtils::hasPrefixAndNumber(const QString prefix, const QString& lin
                        }
                }
        }
                        }
                }
        }
-       return rc;
+    return rc;
+}
+
+/**
+ * Tests whether a string is a number.
+ *
+ * @param text      text to inspect
+ * @param value     OUT: the value of text interpreted as integer
+ * @return          <i>true</i>: <i>text</i>is a number
+ */
+bool ReQStringUtils::isAnInteger(const QString &text, int *value)
+{
+    bool isNegative = false;
+    bool rc = ! text.isEmpty();
+    if (rc){
+        int start = 0;
+        if (text[0] == QChar('-')){
+            isNegative = true;
+            start = 1;
+        }
+        rc = lengthOfUInt(text, start, 10, (unsigned *) value) == text.length() - start;
+        if (value != NULL && isNegative)
+            *value = - *value;
+    }
+    return rc;
 }
 
 /**
 }
 
 /**
@@ -516,8 +540,8 @@ void ReQStringUtils::skipExpected(const ReString& text, QChar expected,
 QString ReQStringUtils::numberToName(int number, const char* charSet, int charSetSize){
     QString rc;
     if (charSet == NULL){
 QString ReQStringUtils::numberToName(int number, const char* charSet, int charSetSize){
     QString rc;
     if (charSet == NULL){
-        charSet = "-$ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
-        charSetSize = 37+1; // strlen(charSet)
+        charSet = "-$ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+        charSetSize = 26+1+1; // strlen(charSet)
     }
     if (number < 0){
         number = -number;
     }
     if (number < 0){
         number = -number;
index dc23232c3a9c3167e68e546e681cfa1c420b500c..909d42dee6c8d19d1c2c485079ab05a4e6cfeca8 100644 (file)
@@ -58,6 +58,7 @@ public:
        static QString& ensureLastChar(QString& value, QChar lastChar);
        static bool hasPrefixAndNumber(const QString prefix, const QString& line,
                                                                   int& no, QString& value);
        static QString& ensureLastChar(QString& value, QChar lastChar);
        static bool hasPrefixAndNumber(const QString prefix, const QString& line,
                                                                   int& no, QString& value);
+    static bool isAnInteger(const QString& text, int* value = NULL);
        static int lengthOfDate(const ReString& text, int start = 0, QDate* value =
                NULL);
        static int lengthOfDateTime(const ReString& text, int start = 0,
        static int lengthOfDate(const ReString& text, int start = 0, QDate* value =
                NULL);
        static int lengthOfDateTime(const ReString& text, int start = 0,
index 335b634142092037b238d025d21f3510a500fc6a..b9a34a363fef886be0e81d0b092cc40acbdba895 100644 (file)
@@ -444,9 +444,8 @@ void ReTest::assertLogContains(const char* pattern, bool isRegExpr,
  */
 void ReTest::assertLogContainsLocation(int location, const char* file, int lineNo)
 {
  */
 void ReTest::assertLogContainsLocation(int location, const char* file, int lineNo)
 {
-       QByteArray pattern("^.20[\\d:. ]+\\(");
-       pattern += location;
-       pattern += "\\)";
+    char pattern[128];
+    snprintf(pattern, sizeof pattern, "^.20[\\d:. ]+\\(%d\\)", location);
        if (! logContains(pattern, true)){
                error("%s-%d: not found: location %d\n", file, lineNo, location,
                          m_memoryAppender.getLines().join().constData());
        if (! logContains(pattern, true)){
                error("%s-%d: not found: location %d\n", file, lineNo, location,
                          m_memoryAppender.getLines().join().constData());
index 533d777f47cd6eab60841738f144865fce5f9e5c..a4221d3a1efde21139b073e4191f27b84519892b 100644 (file)
@@ -351,7 +351,7 @@ public:
                checkEqu(0, stat(dir.constData(), &info));
                checkF(S_ISDIR(info.st_mode));
                checkF(ReFileUtils::makeDirWithParents(dir.constData(), &m_memoryLogger));
                checkEqu(0, stat(dir.constData(), &info));
                checkF(S_ISDIR(info.st_mode));
                checkF(ReFileUtils::makeDirWithParents(dir.constData(), &m_memoryLogger));
-               checkLogContainsLocation(51003);
+        checkLogContainsLocation(12508);
                checkLogContains(dir.constData(), false);
        }
        void testIsDirectoy(){
                checkLogContains(dir.constData(), false);
        }
        void testIsDirectoy(){
index 087a2c262844183c3c61fcd78352158db30d6567..643036d317676cd34b95e582f3ae86f262bea0f7 100644 (file)
@@ -222,7 +222,7 @@ public:
                checkEqu("1.001 TB", ReQStringUtils::readableSize(1001000000000l));
        }
        void testReadableDuration(){
                checkEqu("1.001 TB", ReQStringUtils::readableSize(1001000000000l));
        }
        void testReadableDuration(){
-#define clf(sec) clock_t(clock_t((sec) * CLOCKS_PER_SEC))
+#define clf(sec) qint64((sec) * 1000)
                checkEqu("0.000 sec", ReQStringUtils::readableDuration(clf(0.0)));
         QString value = ReQStringUtils::readableDuration(clf(1.234));
         checkEqu("1.234 sec", value);
                checkEqu("0.000 sec", ReQStringUtils::readableDuration(clf(0.0)));
         QString value = ReQStringUtils::readableDuration(clf(1.234));
         checkEqu("1.234 sec", value);
@@ -244,7 +244,25 @@ public:
                checkEqu("/a/b/c", s);
        }
 
                checkEqu("/a/b/c", s);
        }
 
+    void testIsAnInteger(){
+        checkT(ReQStringUtils::isAnInteger("1"));
+        int value;
+        checkT(ReQStringUtils::isAnInteger("1", &value));
+        checkEqu(1, value);
+        checkT(ReQStringUtils::isAnInteger("-76453", &value));
+        checkEqu(-76453, value);
+        checkF(ReQStringUtils::isAnInteger(""));
+        checkF(ReQStringUtils::isAnInteger("", &value));
+        checkF(ReQStringUtils::isAnInteger("12a"));
+        checkF(ReQStringUtils::isAnInteger("12a", &value));
+        checkF(ReQStringUtils::isAnInteger(".12"));
+        checkF(ReQStringUtils::isAnInteger(".12", &value));
+        checkF(ReQStringUtils::isAnInteger("-12,"));
+        checkF(ReQStringUtils::isAnInteger("-12,", &value));
+    }
+
        virtual void runTests(void) {
        virtual void runTests(void) {
+        testIsAnInteger();
                testChomp();
                testReadableSize();
                testReadableDuration();
                testChomp();
                testReadableSize();
                testReadableDuration();
diff --git a/gui/ReIntComboBox.cpp b/gui/ReIntComboBox.cpp
new file mode 100644 (file)
index 0000000..723900e
--- /dev/null
@@ -0,0 +1,174 @@
+#include "base/rebase.hpp"
+#include "gui/regui.hpp"
+
+ReAnnouncer* ReIntComboBox::m_defaultAnnouncer = NULL;
+
+/**
+ * Constructor.
+ * @param parent
+ */
+ReIntComboBox::ReIntComboBox(QWidget *parent) :
+    ReComboBox(parent),
+    m_minValue(0),
+    m_maxValue(0x7ffffff),
+    m_defaultValue(0),
+    m_announcer(m_defaultAnnouncer),
+    m_emptyAllowed(false)
+{
+    connect(this, SIGNAL(textEdited(const QString&, const QString&)),
+            this, SLOT(textEdited(const QString&, const QString&)));
+}
+
+/**
+ * Returns the current value.
+ *
+ * @return the current value
+ */
+int ReIntComboBox::currentValue() const
+{
+    QString value = currentText();
+    int rc = m_defaultValue;
+    if (! value.isEmpty())
+        rc = value.toInt();
+    return rc;
+}
+
+/**
+ * Returns the current announcer (logger for error messages).
+ * @return the current announcer
+ */
+ReAnnouncer* ReIntComboBox::announcer() const
+{
+    return m_announcer;
+}
+
+/**
+ * Returns the flag "empty allowed".
+ *
+ * @return the flag "empty allowed"
+ */
+bool ReIntComboBox::emptyAllowed() const
+{
+    return m_emptyAllowed;
+}
+
+/**
+ * Prints an error message with the stored announcer.
+ *
+ * @param message   the error message
+ */
+void ReIntComboBox::error(const QString& message, const QString* defaultValue)
+{
+    if (m_announcer != NULL)
+        m_announcer->say(LOG_ERROR, message);
+    if (defaultValue == NULL){
+        setCurrentText(QString::number(m_defaultValue));
+    } else {
+        if (ReQStringUtils::isAnInteger(*defaultValue))
+            setCurrentText(*defaultValue);
+        else
+            setCurrentText(QString::number(m_defaultValue));
+    }
+}
+/**
+ * Returns the current default value (uses for errors).
+ *
+ * @return the current default value
+ */
+int ReIntComboBox::defaultValue() const
+{
+    return m_defaultValue;
+}
+
+/**
+ * Gets the maximal allowed value.
+ *
+ * @return the maximal allowed value
+ */
+int ReIntComboBox::maxValue() const
+{
+    return m_maxValue;
+}
+
+/**
+ * Gets the maximal allowed value.
+ *
+ * @return the maximal allowed value
+ */
+int ReIntComboBox::minValue() const
+{
+    return m_minValue;
+}
+
+/**
+ * Handles the event "changed text".
+ *
+ * @param oldValue  value before editing
+ * @param newValue  value after editing
+ */
+void ReIntComboBox::textEdited(const QString& oldValue, const QString& newValue)
+{
+    int value;
+    if (newValue.isEmpty()){
+        if (! m_emptyAllowed)
+            error(tr("integer expected, not an empty string"), &oldValue);
+    } else if (! ReQStringUtils::isAnInteger(newValue, &value)){
+        error(tr("not a number:") + " " + newValue, &oldValue);
+    } else if (value < m_minValue) {
+        error(tr("value to small: %1 < %2").arg(value).arg(m_minValue), &oldValue);
+    } else if (value > m_maxValue) {
+        error(tr("value to large: %1 > %2").arg(value).arg(m_maxValue), &oldValue);
+    }
+}
+
+/**
+ * Sets the flag "empty allowed".
+ *
+ * @param emptyAllowed  <i>true</i>: the field may be empty.<br>
+ *                      <i>false</i>: the field must not be empty
+ */
+void ReIntComboBox::setEmptyAllowed(bool emptyAllowed)
+{
+    m_emptyAllowed = emptyAllowed;
+}
+
+/**
+ * Sets the maximal value.
+ *
+ * @param maxValue  the maximal allowed value
+ */
+void ReIntComboBox::setMaxValue(int maxValue)
+{
+    m_maxValue = maxValue;
+}
+
+/**
+ * Sets the minimal value.
+ *
+ * @param minValue  the minimal allowed value
+ */
+void ReIntComboBox::setMinValue(int minValue)
+{
+    m_minValue = minValue;
+}
+
+/**
+ * Sets the maximal value.
+ *
+ * @param maxValue  the maximal allowed value
+ */
+void ReIntComboBox::setDefaultValue(int defaultValue)
+{
+    m_defaultValue = defaultValue;
+}
+
+/**
+ * Sets the announcer (to log errors).
+ *
+ * @param announcer  the new announcer (or NULL)
+ */
+void ReIntComboBox::setAnnouncer(ReAnnouncer* announcer)
+{
+    m_announcer = announcer;
+}
+
diff --git a/gui/ReIntComboBox.hpp b/gui/ReIntComboBox.hpp
new file mode 100644 (file)
index 0000000..788620e
--- /dev/null
@@ -0,0 +1,41 @@
+#ifndef REINTCOMBOBOX_H
+#define REINTCOMBOBOX_H
+
+#ifndef RECOMBOBOX_HPP
+#include "gui/ReComboBox.hpp"
+#endif
+
+class ReAnnouncer;
+/**
+ * Implements a combo box containing a integer as value.
+ */
+class ReIntComboBox : public ReComboBox
+{
+    Q_OBJECT
+public:
+    ReIntComboBox(QWidget *parent);
+public:
+    ReAnnouncer* announcer() const;
+    int currentValue() const;
+    int defaultValue() const;
+    bool emptyAllowed() const;
+    void error(const QString& message, const QString* defaultValue = NULL);
+    int maxValue() const;
+    int minValue() const;
+    void textEdited(const QString& oldValue, const QString& newValue);
+    void setAnnouncer(ReAnnouncer* announcer);
+    void setDefaultValue(int defaultValue);
+    void setEmptyAllowed(bool emptyAllowed);
+    void setMaxValue(int maxValue);
+    void setMinValue(int minValue);
+private:
+    int m_minValue;
+    int m_maxValue;
+    int m_defaultValue;
+    ReAnnouncer* m_announcer;
+    bool m_emptyAllowed;
+public:
+    static ReAnnouncer* m_defaultAnnouncer;
+};
+
+#endif // REINTCOMBOBOX_H
index a07cfb790045c776f4de7d37ba6a0d516a6970cc..94e6f3f2997c1b08c67c68201cb1bf736cf070df 100644 (file)
@@ -27,8 +27,8 @@ enum {
        LOC_CHANGE_VALUE_2,             // 11712
 };
 
        LOC_CHANGE_VALUE_2,             // 11712
 };
 
-QString ReSettings::TRUE = "t";
-QString ReSettings::FALSE = "";
+QString ReSettings::sTRUE = "t";
+QString ReSettings::sFALSE = "";
 
 /**
  * Constructor.
 
 /**
  * Constructor.
@@ -56,10 +56,10 @@ ReProperty::ReProperty(const char* name, const QString& title,
  * Tests whether a given value is allowed respecting the <code>m_limits</code>
  * @param value        the value to test
  * @param error        OUT: NULL or the error message
  * Tests whether a given value is allowed respecting the <code>m_limits</code>
  * @param value        the value to test
  * @param error        OUT: NULL or the error message
- * @return <code>true</code>: the value is allowed<br>
+ * @return <code>sTRUE</code>: the value is allowed<br>
  */
 bool ReProperty::isValid(const QString& value, QString* error) {
  */
 bool ReProperty::isValid(const QString& value, QString* error) {
-       bool rc = true;
+    bool rc = true;
        if (error != NULL)
                *error = "";
        if (m_limits != NULL) {
        if (error != NULL)
                *error = "";
        if (m_limits != NULL) {
@@ -75,11 +75,11 @@ bool ReProperty::isValid(const QString& value, QString* error) {
                                int minimum, maximum;
                                if (sscanf(m_limits, "[%d,%d]", &minimum, &maximum) == 2) {
                                        if (nValue < minimum) {
                                int minimum, maximum;
                                if (sscanf(m_limits, "[%d,%d]", &minimum, &maximum) == 2) {
                                        if (nValue < minimum) {
-                                               rc = false;
+                        rc = false;
                                                if (error != NULL)
                                                        *error = value + " < " + minimum;
                                        } else if (nValue > maximum) {
                                                if (error != NULL)
                                                        *error = value + " < " + minimum;
                                        } else if (nValue > maximum) {
-                                               rc = false;
+                        rc = false;
                                                if (error != NULL)
                                                        *error = value + " < " + maximum;
                                        }
                                                if (error != NULL)
                                                        *error = value + " < " + maximum;
                                        }
@@ -182,7 +182,7 @@ QString ReSettings::topOfHistory(const char* key, const QString& defaultValue) {
  * @return the value of the property
  */
 bool ReSettings::boolValue(const char* name) {
  * @return the value of the property
  */
 bool ReSettings::boolValue(const char* name) {
-       bool rc = false;
+    bool rc = false;
        ReProperty* property = m_settings.value(name, NULL);
        if (property == NULL)
                m_logger->logv(LOG_ERROR, LOC_BOOL_VALUE_1, "missing bool property %s",
        ReProperty* property = m_settings.value(name, NULL);
        if (property == NULL)
                m_logger->logv(LOG_ERROR, LOC_BOOL_VALUE_1, "missing bool property %s",
@@ -330,7 +330,7 @@ void ReSettings::readSettings() {
                                        case PT_BOOL:
                                                property->m_value =
                                                        value.isEmpty() ?
                                        case PT_BOOL:
                                                property->m_value =
                                                        value.isEmpty() ?
-                                                               ReSettings::FALSE : ReSettings::TRUE;
+                                ReSettings::sFALSE : ReSettings::sTRUE;
                                                break;
                                        case PT_INT:
                                                if (property->isValid(value))
                                                break;
                                        case PT_INT:
                                                if (property->isValid(value))
@@ -423,7 +423,7 @@ ReDelayedStorage::ReDelayedStorage(const QString& file, ReLogger* logger,
        m_delay(delay),
        m_file(file),
        m_logger(logger){
        m_delay(delay),
        m_file(file),
        m_logger(logger){
-       m_timer.setSingleShot(true);
+    m_timer.setSingleShot(true);
        connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeout()));
 }
 
        connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeout()));
 }
 
index 19210930e39adacc5465dd80c9c33ef9ef185d4b..4bc0c30db0a75f27628957faa03aa0bd6014b350 100644 (file)
@@ -19,6 +19,7 @@
 #include <QAction>
 #include <QApplication>
 #include "gui/ReComboBox.hpp"
 #include <QAction>
 #include <QApplication>
 #include "gui/ReComboBox.hpp"
+#include "gui/ReIntComboBox.hpp"
 #include "gui/ReGuiUtils.hpp"
 #include "gui/ReGuiQueue.hpp"
 #include "gui/ReStateStorage.hpp"
 #include "gui/ReGuiUtils.hpp"
 #include "gui/ReGuiQueue.hpp"
 #include "gui/ReStateStorage.hpp"