From: Hamatoma Date: Sat, 19 Dec 2015 23:13:49 +0000 (+0100) Subject: Refind: windows improvements X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=99fcbca5560ab6a5ba8b3a6c45744086047e717d;p=reqt Refind: windows improvements --- diff --git a/appl/refind/filefinder.cpp b/appl/refind/filefinder.cpp index 34c3172..330d0ec 100644 --- a/appl/refind/filefinder.cpp +++ b/appl/refind/filefinder.cpp @@ -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; diff --git a/appl/refind/mainwindow.cpp b/appl/refind/mainwindow.cpp index a035843..1785a97 100644 --- a/appl/refind/mainwindow.cpp +++ b/appl/refind/mainwindow.cpp @@ -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 & 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)); diff --git a/base/ReFileUtils.cpp b/base/ReFileUtils.cpp index 6d99c1e..0a4fc30 100644 --- a/base/ReFileUtils.cpp +++ b/base/ReFileUtils.cpp @@ -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--; } diff --git a/base/rebase.hpp b/base/rebase.hpp index 0b03d5e..18db3d3 100644 --- a/base/rebase.hpp +++ b/base/rebase.hpp @@ -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.