From: Hamatoma Date: Sun, 20 Dec 2015 21:24:03 +0000 (+0100) Subject: ReFind: windows improvements X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=30a379918a0296614d52e79ff98d4f50aa2307f0;p=reqt ReFind: windows improvements * handling of u:\ * wrong export strings --- diff --git a/appl/refind/filefinder.cpp b/appl/refind/filefinder.cpp index 259a2b0..4497864 100644 --- a/appl/refind/filefinder.cpp +++ b/appl/refind/filefinder.cpp @@ -106,7 +106,11 @@ void FileFinder::setTextFinder(TextFinder* textFinder){ */ void FileFinder::fillTable(const QString& path, int depth){ QFileInfoList entries; +#if defined __linux__ QDir dir(path); +#elif defined WIN32 + QDir dir(path.length() == 2 && path[1] == ':' ? path + "\\" : path); +#endif QDir::Filters filters = m_fileTypes | QDir::NoDotAndDotDot; if (m_patterns.count() == 0) entries = dir.entryInfoList(filters, QDir::NoSort); diff --git a/appl/refind/mainwindow.cpp b/appl/refind/mainwindow.cpp index cd47be3..a40959a 100644 --- a/appl/refind/mainwindow.cpp +++ b/appl/refind/mainwindow.cpp @@ -33,6 +33,14 @@ const QString VERSION("2015.12.15"); +inline QString addEsc(const QString& text){ + QString rc = text; +#if defined WIN32 + rc.replace("\\", "\\\\"); +#endif + return rc; +} + /** * @brief Constructor. * @@ -245,11 +253,11 @@ QString MainWindow::cellAsText(int row, int col){ QString replaceEscSequences(const QString& text){ QString rc = text; int start = 0; - QString replacement; while (start < rc.length()){ - start = text.indexOf('\\', start); - if (start < 0) + int ix = text.indexOf('\\', start); + if (ix < 0) break; + start += ix; QChar replacement = 0; switch (text[start + 1].toLatin1()) { case 'n': @@ -265,9 +273,8 @@ QString replaceEscSequences(const QString& text){ replacement = text[start + 1]; break; } - rc.remove(start, 1); - rc[start] = replacement; - start++; + rc.replace(start, 2, replacement); + start++; } return rc; } @@ -335,11 +342,12 @@ void MainWindow::exportToStream(QTextStream& stream, int maxRow){ for (int ii = 0; ii < count; ii++){ QString line = ui->comboBoxTemplate->currentText(); QMap < QString, QString > placeholders; - QString path = m_lastBaseDir.absoluteFilePath( + QString path = m_lastBaseDir.absoluteFilePath( ReFileUtils::pathAppend(ui->tableWidget->item(ii, TC_PATH)->text(), ui->tableWidget->item(ii, TC_NODE)->text())); - placeholders.insert("full", ReQStringUtils::nativePath(path)); - placeholders.insert("path", ui->tableWidget->item(ii, TC_PATH)->text()); + placeholders.insert("full", addEsc(ReQStringUtils::nativePath(path))); + path = ReFileUtils::nativePath(ui->tableWidget->item(ii, TC_PATH)->text()); + placeholders.insert("path", addEsc(path)); placeholders.insert("ext", ui->tableWidget->item(ii, TC_EXT)->text()); placeholders.insert("node", ui->tableWidget->item(ii, TC_NODE)->text()); placeholders.insert("modified", @@ -715,14 +723,6 @@ 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. * @@ -730,7 +730,7 @@ inline QString addEsc(const QString& text){ */ void MainWindow::buildGlobalPlaceholders(QMap & hash){ - hash.insert("filepatterns", addEsc(ui->comboBoxFilePatterns->currentText())); + hash.insert("filepatterns", ui->comboBoxFilePatterns->currentText()); hash.insert("base", m_lastBaseDir.absolutePath()); hash.insert("textpattern", addEsc(ui->comboBoxTextPattern->currentText())); hash.insert("dirs", QString::number(m_statistics.m_dirs)); diff --git a/appl/refind/refind.pro b/appl/refind/refind.pro index 16dcfad..1555566 100644 --- a/appl/refind/refind.pro +++ b/appl/refind/refind.pro @@ -26,6 +26,7 @@ SOURCES += main.cpp\ aboutdialog.cpp \ ../../gui/ReStateStorage.cpp \ ../../gui/ReGuiValidator.cpp \ + ../../gui/ReGuiQueue.cpp \ dialogglobalplaceholder.cpp \ dialogfileplaceholder.cpp \ utils.cpp \ @@ -37,7 +38,6 @@ SOURCES += main.cpp\ HEADERS += mainwindow.hpp \ ../../base/rebase.hpp \ filefinder.hpp \ - ../../base/ReQStringUtil.hpp \ textfinder.hpp \ ../../gui/ReStateStorage.hpp \ aboutdialog.hpp \ diff --git a/base/ReFileUtils.cpp b/base/ReFileUtils.cpp index 0a4fc30..5edbcc1 100644 --- a/base/ReFileUtils.cpp +++ b/base/ReFileUtils.cpp @@ -118,7 +118,7 @@ bool ReFileUtils::deleteTree(const QString& path, bool withBase, } } } - if (withBase && (rmdir(I18N::s2b(path))) != 0) { + if (withBase && (_rmdir(I18N::s2b(path))) != 0) { rc = false; logger->logv(LOG_ERROR, LOC_DELETE_TREE_3, "cannot delete directory (%d): %s", errno, I18N::s2b(path).constData()); @@ -659,7 +659,7 @@ QByteArray ReFileUtils::tempFile(const char* node, const char* parent, rc += node; struct stat info; if (deleteIfExists && stat(rc.constData(), &info) == 0) - unlink(rc.constData()); + _unlink(rc.constData()); return rc; } diff --git a/base/ReLogger.cpp b/base/ReLogger.cpp index 697eba6..d85fe3f 100644 --- a/base/ReLogger.cpp +++ b/base/ReLogger.cpp @@ -494,7 +494,6 @@ void ReStreamAppender::log(ReLoggerLevel level, int location, fputc('\n', m_fp); fflush(m_fp); } -#pragma GCC diagnostic warning "-Wunused-parameter" /** @class ReFileAppender ReLogger.hpp "base/ReLogger.hpp" * @@ -564,7 +563,6 @@ void ReFileAppender::open() { * @param message the logging message * @param logger the calling logger */ -#pragma GCC diagnostic ignored "-Wunused-parameter" void ReFileAppender::log(ReLoggerLevel level, int location, const char* message, ReLogger* logger) { if (m_fp != NULL) { @@ -575,7 +573,6 @@ void ReFileAppender::log(ReLoggerLevel level, int location, const char* message, fflush(m_fp); } } -#pragma GCC diagnostic warning "-Wunused-parameter" /** @class ReMemoryAppender ReLogger.hpp "base/ReLogger.hpp" * @@ -613,7 +610,6 @@ ReMemoryAppender::~ReMemoryAppender() { * @param message the logging message * @param logger the calling logger */ -#pragma GCC diagnostic ignored "-Wunused-parameter" void ReMemoryAppender::log(ReLoggerLevel level, int location, const char* message, ReLogger* logger) { if (m_lines.size() >= m_maxLines) @@ -626,7 +622,6 @@ void ReMemoryAppender::log(ReLoggerLevel level, int location, m_lines.append(msg); } } -#pragma GCC diagnostic warning "-Wunused-parameter" /** * @brief Returns the list of lines. diff --git a/gui/ReGuiQueue.cpp b/gui/ReGuiQueue.cpp index 8c61576..ad3f486 100644 --- a/gui/ReGuiQueue.cpp +++ b/gui/ReGuiQueue.cpp @@ -13,6 +13,7 @@ * Constructor. */ ReGuiQueue::ReGuiQueue() : + QVector(), m_locker() { }