]> gitweb.hamatoma.de Git - reqt/commitdiff
Refind: windows improvements
authorHamatoma <git.tortouse@hm.f-r-e-i.de>
Sat, 19 Dec 2015 23:13:49 +0000 (00:13 +0100)
committerHamatoma <git.tortouse@hm.f-r-e-i.de>
Sat, 19 Dec 2015 23:13:49 +0000 (00:13 +0100)
appl/refind/filefinder.cpp
appl/refind/mainwindow.cpp
base/ReFileUtils.cpp
base/rebase.hpp

index 34c31724319e02f600d7fe7e7ecfd415f2a25dff..330d0eca33b3e546426bec7277ba5d6c2eca69c4 100644 (file)
@@ -39,8 +39,8 @@ FileFinder::FileFinder() :
                        m_statistics(),
                        m_announcer(NULL),
                        m_observer(NULL){
-   m_youngerThan.setMSecsSinceEpoch(0);
-   m_olderThan.setMSecsSinceEpoch(0);
+    m_youngerThan.setMSecsSinceEpoch(0);
+    m_olderThan.setMSecsSinceEpoch(0);
 }
 
 FileFinder::~FileFinder(){
@@ -151,13 +151,14 @@ void FileFinder::fillTable(const QString& path, int depth){
                 m_table->setItem(m_lines, TC_MODIFIED,
                        new QTableWidgetItem(
                           it->lastModified().toString("yyyy.MM.dd/hh:mm:ss")));
-                m_lines++;
-                clock_t now = clock();
-                if (now > nextUpdate){
-                         m_table->setRowCount(m_lines);
-                         nextUpdate = now + CLOCKS_PER_SEC;
-                }
-         }
+    }
+    clock_t now = clock();
+    if (now > nextUpdate){
+      m_table->setRowCount(m_lines);
+      if (m_announcer != NULL)
+          m_announcer->say(LOG_INFO, path);
+      nextUpdate = now + CLOCKS_PER_SEC;
+    }
    }
    for (it2 = antiPatterns.begin(); it2 != antiPatterns.end(); ++it2){
           delete *it2;
index a03584390df3a5efa76e7f5ff8f3a933d1b1e5d5..1785a97cc6b7f00ca5ec588d6c0f26d45245cc5c 100644 (file)
@@ -639,6 +639,7 @@ ReObserver::ReturnCode MainWindow::notify(const char* message)
        if (strcmp(message, "ready") == 0){
                ui->pushButtonSearch->setEnabled(true);
                ui->pushButtonSearch2->setEnabled(true);
+        m_statistics = m_finder->statistics();
        }
        return ReObserver::SUCCESS;
 }
@@ -682,6 +683,14 @@ msgBox.setDefaultButton(QMessageBox::Save);
 msgBox.exec();
 }
 
+inline QString addEsc(const QString& text){
+    QString rc = text;
+#if defined WIN32
+    rc.replace("\\", "\\\\");
+#endif
+    return rc;
+}
+
 /**
  * Builds the hash with the global placeholders with their current values.
  *
@@ -689,9 +698,9 @@ msgBox.exec();
  */
 void MainWindow::buildGlobalPlaceholders(QMap <QString, QString>& hash){
 
-hash.insert("filepatterns", ui->comboBoxFilePatterns->currentText());
+hash.insert("filepatterns", addEsc(ui->comboBoxFilePatterns->currentText()));
 hash.insert("base", m_lastBaseDir.absolutePath());
-hash.insert("textpattern", ui->comboBoxTextPattern->currentText());
+hash.insert("textpattern", addEsc(ui->comboBoxTextPattern->currentText()));
 hash.insert("dirs", QString::number(m_statistics.m_dirs));
 hash.insert("files", QString::number(m_statistics.m_files));
 hash.insert("runtime", QString::number(m_statistics.m_runtimeSeconds, 'g', 3));
@@ -793,6 +802,7 @@ storage.close();
  */
 void MainWindow::populateFinder(FileFinder& finder){
        finder.setObserver(this);
+    finder.setAnnouncer(this);
        finder.setBaseDir(comboText(ui->comboBoxDirectory));
        finder.setTable(ui->tableWidget);
        m_lastBaseDir.cd(comboText(ui->comboBoxDirectory));
index 6d99c1e8aa3512060527b3f6cc0d58e224454583..0a4fc302f24610db9625b1bddf65c7018669acc9 100644 (file)
@@ -100,7 +100,7 @@ bool ReFileUtils::deleteTree(const QString& path, bool withBase,
                        if (info.isDir()) {
                                if (!deleteTree(full, false, logger))
                                        rc = false;
-                               else if (rmdir(I18N::s2b(full)) != 0) {
+                else if (_rmdir(I18N::s2b(full)) != 0) {
                                        rc = false;
                                        if (logger != NULL)
                                                logger->logv(LOG_ERROR, LOC_DELETE_TREE_1,
@@ -178,7 +178,7 @@ QByteArray ReFileUtils::extensionOf(const char* filename) {
                                if ((cc = filename[ix - 1]) != '/' && cc != '\\')
                                        rc.append(filename + ix);
                                break;
-                       } else if (cc == '\\' or cc == '/')
+            } else if (cc == '\\' || cc == '/')
                                break;
                        ix--;
                }
index 0b03d5e4062a05840c434f1410d6ef197f7315cc..18db3d35c3e5d72441bbd6c5b420f738e98fd996 100644 (file)
@@ -147,7 +147,7 @@ inline int hexToInt(char hex, int defaultValue = -1){
  * @param value the value to round
  */
 inline int roundInt(double value) {
-       return (int) round(value);
+    return (int) value < 0.0 ? ceil(value - 0.5) : floor(value + 0.5);
 }
 /** An observer can be informed about state changes.
  * Pure abstract class.