From da71ebc8654e81089c6ffd9bc4a7a06be4b33150 Mon Sep 17 00:00:00 2001 From: Hamatoma Date: Mon, 21 Nov 2016 00:13:15 +0100 Subject: [PATCH] + ReFileSearch, ReComboBox works, + appl/research --- appl/rebackgui/BackupEngine.cpp | 208 +++++----- appl/rebackgui/BackupEngine.hpp | 33 +- appl/rebackgui/Configuration.cpp | 4 +- appl/rebackgui/mainwindow.cpp | 53 ++- appl/rebackgui/mainwindow.hpp | 4 + appl/recommand/CommandProcessor.cpp | 51 ++- appl/recommand/CommandProcessor.hpp | 5 + appl/recommand/cuCommandProcessor.cpp | 39 ++ appl/recommand/main.cpp | 18 +- appl/recommand/recommand.pro | 4 +- appl/reide/SearchEngine.cpp | 48 +++ appl/reide/SearchEngine.hpp | 26 ++ appl/reide/filesearch.ui | 2 +- appl/reide/mainwindow.cpp | 3 +- appl/reide/mainwindow.ui | 57 ++- appl/reide/reide.pro | 9 +- appl/reide/workspace.cpp | 25 +- appl/reprime/reprime.pro | 1 + appl/research/aboutdialog.cpp | 23 ++ appl/research/aboutdialog.hpp | 32 ++ appl/research/aboutdialog.ui | 113 ++++++ appl/research/main.cpp | 11 + appl/research/mainwindow.cpp | 92 +++++ appl/research/mainwindow.hpp | 39 ++ appl/research/mainwindow.ui | 531 ++++++++++++++++++++++++++ appl/research/research.hpp | 14 + appl/research/research.pro | 49 +++ base/ReFile.cpp | 5 + base/ReFileSearch.cpp | 127 ++++++ base/ReFileSearch.hpp | 46 +++ base/ReFileUtils.cpp | 10 +- base/ReFileUtils.hpp | 114 +++++- base/ReRandomizer.cpp | 3 +- base/rebase.hpp | 1 + base/retrace.hpp | 2 +- cunit/allTests.cpp | 2 + cunit/cuReFileSearch.cpp | 74 ++++ cunit/cunit.pro | 7 +- gui/ReComboBox.cpp | 29 +- gui/ReComboBox.hpp | 18 +- gui/ReSettings.hpp | 4 +- gui/regui.hpp | 2 +- os/ReCryptFileSystem.cpp | 13 +- 43 files changed, 1754 insertions(+), 197 deletions(-) create mode 100644 appl/recommand/cuCommandProcessor.cpp create mode 100644 appl/reide/SearchEngine.cpp create mode 100644 appl/reide/SearchEngine.hpp create mode 100644 appl/research/aboutdialog.cpp create mode 100644 appl/research/aboutdialog.hpp create mode 100644 appl/research/aboutdialog.ui create mode 100644 appl/research/main.cpp create mode 100644 appl/research/mainwindow.cpp create mode 100644 appl/research/mainwindow.hpp create mode 100644 appl/research/mainwindow.ui create mode 100644 appl/research/research.hpp create mode 100644 appl/research/research.pro create mode 100644 base/ReFileSearch.cpp create mode 100644 base/ReFileSearch.hpp create mode 100644 cunit/cuReFileSearch.cpp diff --git a/appl/rebackgui/BackupEngine.cpp b/appl/rebackgui/BackupEngine.cpp index 639cda2..fe3c4e7 100644 --- a/appl/rebackgui/BackupEngine.cpp +++ b/appl/rebackgui/BackupEngine.cpp @@ -12,21 +12,21 @@ #include "backupgui.hpp" //#define WITH_TRACE #include "base/retrace.hpp" -DECLARE_TRACER(s_traceSearch, "/tmp/bup_search.log"); -DECLARE_TRACER(s_traceBackup, "/tmp/bup_backup.log"); -DECLARE_TRACER(s_traceChecksum, "/tmp/bup_sum.log"); -DECLARE_TRACER(s_traceClean, "/tmp/bup_clean.log"); +DECLARE_TRACER(s_traceSearch, "/tmp/bup_search.log") +DECLARE_TRACER(s_traceBackup, "/tmp/bup_backup.log") +DECLARE_TRACER(s_traceChecksum, "/tmp/bup_sum.log") +DECLARE_TRACER(s_traceClean, "/tmp/bup_clean.log") +#ifdef USE_MUTEX +#define MUTEX_LOCK(mutex) mutex.lock() +#define MUTEX_UNLOCK(mutex) m_mutex.release() +#else +#define MUTEX_LOCK(mutex) +#define MUTEX_UNLOCK(mutex) +#endif ReVerbose_t BackupEngine::m_verboseLevel = VerboseStandard; bool BackupEngine::m_shouldStop = false; QStringList BackupEngine::m_files; -qint64 BackupEngine::m_hotBytes = 0; -qint64 BackupEngine::m_processedBytes = 0; -int BackupEngine::m_processedFiles = 0; -int BackupEngine::m_matchedFiles = 0; -int BackupEngine::m_hotFiles = 0; -int BackupEngine::m_totalFiles = 0; -int BackupEngine::m_totalDirs = 0; bool BackupEngine::m_searchReady = false; QMutex BackupEngine::m_mutex; QChar BackupEngine::m_separator = '\t'; @@ -45,7 +45,7 @@ static const int MAX_INDEX = 0x7fff; */ BackupEngine::BackupEngine(const QString& name, const QStringList& sourceDirs, const QString& targetDir, - MainWindow* mainWindow) : + ReFileTreeStatistic& statistic, MainWindow* mainWindow) : QThread(), m_sourceDirs(sourceDirs), m_targetBaseDir(targetDir), @@ -53,8 +53,10 @@ BackupEngine::BackupEngine(const QString& name, m_shadowBaseDir(), m_shadowDirs(), m_mainWindow(mainWindow), + m_statistic(statistic), m_name(name) { + m_statistic.clear(); ReQStringUtils::ensureLastChar(m_targetBaseDir, OS_SEPARATOR); for (int ix = 0; ix < sourceDirs.size(); ix++){ ReQStringUtils::ensureLastChar(m_sourceDirs[ix], OS_SEPARATOR); @@ -132,8 +134,8 @@ bool BackupEngine::log(const QString& message){ */ BackupTask::BackupTask(const QString& name, const QStringList& sourceDirs, const QString& targetDir, - MainWindow* mainWindow) : - BackupEngine(name, sourceDirs, targetDir, mainWindow), + ReFileTreeStatistic& statistic, MainWindow* mainWindow) : + BackupEngine(name, sourceDirs, targetDir, statistic, mainWindow), m_lastRelPath(), m_buffer() { @@ -175,10 +177,9 @@ void BackupTask::copyFile(int index, const QString& relPath, QFileInfo sourceInfo(source); if (m_verboseLevel >= VerboseStandard) m_mainWindow->addToFileList(target + " " + ReQStringUtils::readableSize(sourceInfo.size())); - m_mutex.lock(); - m_processedFiles++; - m_processedBytes += sourceInfo.size(); - m_mutex.unlock(); + MUTEX_LOCK(m_mutex); + m_statistic.m_processed.addFile(sourceInfo.size()); + MUTEX_UNLOCK(m_mutex); QString errorMsg = ReFileUtils::copy(source, target, &sourceInfo, m_buffer); if (! errorMsg.isEmpty()){ @@ -207,18 +208,18 @@ void BackupTask::run() qint64 processedBytes, hotBytes; int lastIndex = -1; while (! m_shouldStop){ - m_mutex.lock(); + MUTEX_LOCK(m_mutex); if (m_files.size() == 0) info.clear(); else{ info = m_files.first(); m_files.removeFirst(); } - hotBytes = m_hotBytes; - processedBytes = m_processedBytes; - hotFiles = m_hotFiles; - processedFiles = m_processedFiles; - m_mutex.unlock(); + hotBytes = m_statistic.m_hot.bytes(); + processedBytes = m_statistic.m_processed.bytes(); + hotFiles = m_statistic.m_hot.files(); + processedFiles = m_statistic.m_processed.files();; + MUTEX_UNLOCK(m_mutex); if (info.isEmpty()){ if (m_searchReady) break; @@ -257,10 +258,9 @@ void BackupTask::run() } FILETRACE_IT(s_traceBackup, (s_traceBackup.m_fp, "=== backup ready\n")); - m_mainWindow->externalTaskFinished(QObject::tr("backup complete after %1. Errors: %2") - .arg(ReQStringUtils::readableDuration( - QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch())) - .arg(m_mainWindow->errors())); + m_mainWindow->taskFinished(tr("Backup"), + QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch()); + } /** @@ -273,8 +273,8 @@ void BackupTask::run() */ ChecksumTask::ChecksumTask(const QString& name, const QStringList& sourceDirs, const QString& targetDir, - MainWindow* mainWindow) : - BackupEngine(name, sourceDirs, targetDir, mainWindow), + ReFileTreeStatistic& statistic, MainWindow* mainWindow) : + BackupEngine(name, sourceDirs, targetDir, statistic, mainWindow), m_lastRelPath(), m_buffer() { @@ -302,10 +302,9 @@ QByteArray ChecksumTask::buildChecksum(bool isSource, int index, filename = m_targetDirs.at(index) + relpath + node; qint64 size = 0; QByteArray rc = ReFileUtils::buildChecksum(filename, m_buffer, &size).toHex(); - m_mutex.lock(); - m_processedFiles++; - m_processedBytes += size; - m_mutex.unlock(); + MUTEX_LOCK(m_mutex); + m_statistic.m_processed.addFile(size); + MUTEX_UNLOCK(m_mutex); if (rc.isEmpty()){ error(QObject::tr("cannot build checksum: %1").arg(filename) ); } if (m_verboseLevel >= VerboseStandard){ @@ -324,8 +323,8 @@ QByteArray ChecksumTask::buildChecksum(bool isSource, int index, */ ChecksumOfSourceTask::ChecksumOfSourceTask(const QString& name, const QStringList& sourceDirs, const QString& targetDir, - MainWindow* mainWindow) : - ChecksumTask(name, sourceDirs, targetDir, mainWindow) + ReFileTreeStatistic& statistic, MainWindow* mainWindow) : + ChecksumTask(name, sourceDirs, targetDir, statistic, mainWindow) { } @@ -339,14 +338,14 @@ void ChecksumOfSourceTask::run() QString info; int count = 0; while (! m_shouldStop){ - m_mutex.lock(); + MUTEX_LOCK(m_mutex); if (m_files.size() == 0) info.clear(); else{ info = m_files.first(); m_files.removeFirst(); } - m_mutex.unlock(); + MUTEX_UNLOCK(m_mutex); if (info.isEmpty()){ if (m_searchReady) break; @@ -365,9 +364,9 @@ void ChecksumOfSourceTask::run() if (! checksum.isEmpty()){ QString info = QChar(1 + index) + relPath + m_separator + node + m_separatorString + checksum; - m_mutex.lock(); + MUTEX_LOCK(m_mutex); m_checksumInfo.append(info); - m_mutex.unlock(); + MUTEX_UNLOCK(m_mutex); } } } @@ -388,8 +387,8 @@ void ChecksumOfSourceTask::run() */ ChecksumOfTargetTask::ChecksumOfTargetTask(const QString& name, const QStringList& sourceDirs, const QString& targetDir, - MainWindow* mainWindow) : - ChecksumTask(name, sourceDirs, targetDir, mainWindow) + ReFileTreeStatistic& statistic, MainWindow* mainWindow) : + ChecksumTask(name, sourceDirs, targetDir, statistic, mainWindow) { } @@ -405,14 +404,14 @@ void ChecksumOfTargetTask::run() QString info; int count = 0; while (! m_shouldStop){ - m_mutex.lock(); + MUTEX_LOCK(m_mutex); if (m_checksumInfo.size() == 0) info.clear(); else{ info = m_checksumInfo.first(); m_checksumInfo.removeFirst(); } - m_mutex.unlock(); + MUTEX_UNLOCK(m_mutex); if (info.isEmpty()){ if (m_sourceProcessingReady) break; @@ -442,12 +441,14 @@ void ChecksumOfTargetTask::run() if (m_verboseLevel > VerboseQuiet){ qint64 processedBytes, hotBytes; int hotFiles, processedFiles; - m_mutex.lock(); - hotFiles = m_hotFiles; - hotBytes = m_hotBytes * 2; - processedBytes = m_processedBytes; - processedFiles = m_processedFiles; - m_mutex.unlock(); + MUTEX_LOCK(m_mutex); + hotFiles = m_statistic.m_hot.files(); + // We must read pairs of source/target files which have mostly + // the same size: + hotBytes = m_statistic.m_hot.bytes() * 2; + processedBytes = m_statistic.m_processed.bytes(); + processedFiles = m_statistic.m_processed.files(); + MUTEX_UNLOCK(m_mutex); now = QDateTime::currentMSecsSinceEpoch(); qint64 duration = (now - start.toMSecsSinceEpoch()); double factor = processedBytes / max(1.0, (double) hotBytes); @@ -483,8 +484,9 @@ void ChecksumOfTargetTask::run() */ CleanTask::CleanTask(const QString& name, const QStringList& sourceDirs, - const QString& targetDir, MainWindow* mainWindow) : - BackupEngine(name, sourceDirs, targetDir, mainWindow) + const QString& targetDir, ReFileTreeStatistic& statistic, + MainWindow* mainWindow) : + BackupEngine(name, sourceDirs, targetDir, statistic, mainWindow) { initializeShadowDir(); } @@ -499,17 +501,20 @@ void CleanTask::run() QDateTime start = QDateTime::currentDateTime(); int processedFiles = 0, hotFiles = 0; while (! m_shouldStop){ - m_mutex.lock(); + MUTEX_LOCK(m_mutex); if (m_files.size() == 0) info.clear(); else{ info = m_files.first(); m_files.removeFirst(); } - hotFiles = m_hotFiles; - if (! info.isEmpty()) - processedFiles = ++m_processedFiles; - m_mutex.unlock(); + hotFiles = m_statistic.m_hot.files(); + if (! info.isEmpty()){ + //@ToDo: 0??????????? + m_statistic.m_processed.addFile(0); + processedFiles = m_statistic.m_processed.files(); + } + MUTEX_UNLOCK(m_mutex); if (info.isEmpty()){ if (m_searchReady) break; @@ -610,8 +615,8 @@ void CleanTask::run() SearchTask::SearchTask(bool compareWithTarget, const QString& name, const QString& filePatterns, const QString& dirPatterns, const QStringList& sourceDirs, const QString& targetDir, - MainWindow* mainWindow) : - BackupEngine(name, sourceDirs, targetDir, mainWindow), + ReFileTreeStatistic& statistic, MainWindow* mainWindow) : + BackupEngine(name, sourceDirs, targetDir, statistic, mainWindow), m_fileMatcher(filePatterns), m_dirMatcher(dirPatterns), m_compareWithTarget(compareWithTarget) @@ -641,10 +646,10 @@ void SearchTask::run() m_mainWindow->externalLog(QObject::tr( "Search finished: to process: %1 with %2 matching: %3 total: %4 " "subdirs: %5 runtime: %6") - .arg(m_hotFiles) - .arg(ReQStringUtils::readableSize(m_hotBytes)) - .arg(m_matchedFiles).arg(m_totalFiles) - .arg(m_totalDirs) + .arg( m_statistic.m_hot.files()) + .arg(ReQStringUtils::readableSize(m_statistic.m_hot.bytes())) + .arg(m_statistic.m_matched.files()).arg(m_statistic.m_total.files()) + .arg(m_statistic.m_total.directories()) .arg(ReQStringUtils::readableDuration( QDateTime::currentMSecsSinceEpoch() - start))); } @@ -669,9 +674,9 @@ void SearchTask::searchOneDirectory(const QString& source, int lengthBase = m_sourceDirs.at(index).length(); assert(index < MAX_INDEX); QString prefix; - m_mutex.lock(); - m_totalDirs++; - m_mutex.unlock(); + MUTEX_LOCK(m_mutex); + m_statistic.m_total.addDir(); + MUTEX_UNLOCK(m_mutex); if (source.length() > lengthBase){ prefix = QChar(1 + index) + ReFileUtils::nativePath(source.mid(lengthBase)) + OS_SEPARATOR_STR @@ -694,9 +699,9 @@ void SearchTask::searchOneDirectory(const QString& source, if (! fileInfo.isSymLink() && fileInfo.isDir()){ // nothing to do } else if (! m_fileMatcher.matches(node)){ - m_mutex.lock(); - m_totalFiles++; - m_mutex.unlock(); + MUTEX_LOCK(m_mutex); + m_statistic.m_total.addFile(fileInfo.size()); + MUTEX_UNLOCK(m_mutex); } else { qint64 diff = 0; bool doTransfer = false; @@ -722,15 +727,15 @@ void SearchTask::searchOneDirectory(const QString& source, } FILETRACE_IT(s_traceSearch, (s_traceSearch.m_fp, ">%s\n", node.toLocal8Bit().constData())); - m_mutex.lock(); + qint64 size = it.fileInfo().size(); + MUTEX_LOCK(m_mutex); if (doTransfer){ m_files.append(info); - m_hotFiles++; - m_hotBytes += it.fileInfo().size(); + m_statistic.m_hot.addFile(size); } - m_totalFiles++; - m_matchedFiles++; - m_mutex.unlock(); + m_statistic.m_total.addFile(size); + m_statistic.m_matched.addFile(size); + MUTEX_UNLOCK(m_mutex); } } if (! m_shouldStop){ @@ -773,8 +778,9 @@ void SearchTask::searchOneDirectory(const QString& source, */ SearchTargetTask::SearchTargetTask(const QString& name, const QStringList& sourceDirs, - const QString& targetDir, qint64 maxAgeSec, MainWindow* mainWindow) : - BackupEngine(name, sourceDirs, targetDir, mainWindow), + const QString& targetDir, qint64 maxAgeSec, + ReFileTreeStatistic& statistic, MainWindow* mainWindow) : + BackupEngine(name, sourceDirs, targetDir, statistic, mainWindow), m_maxAge(QDateTime::currentDateTime().addSecs(- maxAgeSec)) { initializeShadowDir(); @@ -793,12 +799,13 @@ bool SearchTargetTask::removeOlder(const QString& directory, const QDateTime& ti QDirIterator it(directory); QString info, node; IF_TRACE(QByteArray directory2(directory.toLocal8Bit())); - m_mutex.lock(); - m_totalDirs++; - m_mutex.unlock(); + MUTEX_LOCK(m_mutex); + m_statistic.m_total.addDir(); + MUTEX_UNLOCK(m_mutex); FILETRACE_IT(s_traceSearch, (s_traceSearch.m_fp, "=removeOlder: %s\n", directory2.constData())); bool isEmpty = true; + qint64 size = 0; while (it.hasNext()){ if (m_shouldStop){ break; @@ -818,12 +825,11 @@ bool SearchTargetTask::removeOlder(const QString& directory, const QDateTime& ti isEmpty = false; info = QChar(MAX_INDEX) + ReFileUtils::nativePath(it.filePath()) + m_separatorString + QChar(CmdRemove); - m_mutex.lock(); + MUTEX_LOCK(m_mutex); m_files.append(info); - m_hotFiles++; - m_hotBytes += it.fileInfo().size(); - m_totalFiles++; - m_mutex.unlock(); + size = it.fileInfo().size(); + m_statistic.m_hot.addFile(size); + MUTEX_UNLOCK(m_mutex); FILETRACE_IT(s_traceSearch, (s_traceSearch.m_fp, "-%s/%s\n", directory2.constData(), fileInfo.baseName().toLocal8Bit().constData())); @@ -836,11 +842,11 @@ bool SearchTargetTask::removeOlder(const QString& directory, const QDateTime& ti m_mainWindow->addToFileList("x " + directory); info = QChar(MAX_INDEX) + directory + m_separatorString + QChar(CmdRemoveDir); - m_mutex.lock(); + MUTEX_LOCK(m_mutex); m_files.append(info); - m_matchedFiles++; - m_hotFiles++; - m_mutex.unlock(); + m_statistic.m_matched.addFile(size); + m_statistic.m_total.addFile(size); + MUTEX_UNLOCK(m_mutex); FILETRACE_IT(s_traceSearch, (s_traceSearch.m_fp, "-%s\n", directory2.constData())); } @@ -863,9 +869,9 @@ void SearchTargetTask::searchOneDirectory(const QString& target, int lengthBase = m_targetDirs.at(index).length(); assert(index < MAX_INDEX); QString prefix; - m_mutex.lock(); - m_totalDirs++; - m_mutex.unlock(); + MUTEX_LOCK(m_mutex); + m_statistic.m_total.addDir(); + MUTEX_UNLOCK(m_mutex); if (target.length() > lengthBase){ relPath = ReFileUtils::nativePath(target.mid(lengthBase)) + OS_SEPARATOR_STR; prefix = QChar(1 + index) + relPath + m_separator; @@ -901,14 +907,14 @@ void SearchTargetTask::searchOneDirectory(const QString& target, info = prefix + QChar(command) + it.fileName(); } } - m_mutex.lock(); + qint64 size = it.fileInfo().size(); + MUTEX_LOCK(m_mutex); if (command != CmdUndef){ m_files.append(info); - m_hotFiles++; - m_hotBytes += it.fileInfo().size(); + m_statistic.m_hot.addFile(size); } - m_totalFiles++; - m_mutex.unlock(); + m_statistic.m_total.addFile(size); + MUTEX_UNLOCK(m_mutex); } } if (! m_shouldStop){ @@ -1033,10 +1039,10 @@ void SearchTargetTask::run() m_mainWindow->externalLog(QObject::tr( "Search in target finished: to process: %1 with %2 dirs to delete: %3 total: %4 " "subdirs: %5 runtime: %6") - .arg(m_hotFiles) - .arg(ReQStringUtils::readableSize(m_hotBytes)) - .arg(m_matchedFiles).arg(m_totalFiles) - .arg(m_totalDirs) + .arg(m_statistic.m_hot.files()) + .arg(ReQStringUtils::readableSize(m_statistic.m_hot.files())) + .arg(m_statistic.m_matched.files()).arg(m_statistic.m_total.files()) + .arg(m_statistic.m_total.directories()) .arg(ReQStringUtils::readableDuration( QDateTime::currentMSecsSinceEpoch() - start))); } diff --git a/appl/rebackgui/BackupEngine.hpp b/appl/rebackgui/BackupEngine.hpp index 5b68fc2..6d85ce3 100644 --- a/appl/rebackgui/BackupEngine.hpp +++ b/appl/rebackgui/BackupEngine.hpp @@ -29,7 +29,7 @@ public: public: BackupEngine(const QString& name, const QStringList& sourceDirs, const QString& targetDir, - MainWindow* mainWindow); + ReFileTreeStatistic& statistic, MainWindow* mainWindow); public: bool error(const QString& message); bool log(const QString& message); @@ -48,19 +48,13 @@ protected: // list of shadow dirs. QStringList m_shadowDirs; MainWindow* m_mainWindow; + ReFileTreeStatistic& m_statistic; QString m_name; public: static ReVerbose_t m_verboseLevel; static bool m_shouldStop; /// Entry: TAB static QStringList m_files; - static qint64 m_hotBytes; - static int m_processedFiles; - static qint64 m_processedBytes; - static int m_hotFiles; - static int m_matchedFiles; - static int m_totalFiles; - static int m_totalDirs; static bool m_searchReady; static QMutex m_mutex; static QChar m_separator; @@ -73,8 +67,9 @@ public: class BackupTask : public BackupEngine { public: - BackupTask(const QString& name, const QStringList& sourceDirs, const QString& targetDir, - MainWindow* mainWindow); + BackupTask(const QString& name, const QStringList& sourceDirs, + const QString& targetDir, + ReFileTreeStatistic& statistic, MainWindow* mainWindow); public: virtual void run(); protected: @@ -91,8 +86,9 @@ private: class ChecksumTask : public BackupEngine { public: - ChecksumTask(const QString& name, const QStringList& sourceDirs, const QString& targetDir, - MainWindow* mainWindow); + ChecksumTask(const QString& name, const QStringList& sourceDirs, + const QString& targetDir, + ReFileTreeStatistic& statistic, MainWindow* mainWindow); public: virtual void run() = 0; protected: @@ -117,7 +113,8 @@ public: class ChecksumOfSourceTask : public ChecksumTask { public: - ChecksumOfSourceTask(const QString& name, const QStringList& sourceDirs, const QString& targetDir, + ChecksumOfSourceTask(const QString& name, const QStringList& sourceDirs, + const QString& targetDir, ReFileTreeStatistic& statistic, MainWindow* mainWindow); public: virtual void run(); @@ -132,7 +129,8 @@ public: class ChecksumOfTargetTask : public ChecksumTask { public: - ChecksumOfTargetTask(const QString& name, const QStringList& sourceDirs, const QString& targetDir, + ChecksumOfTargetTask(const QString& name, const QStringList& sourceDirs, + const QString& targetDir, ReFileTreeStatistic& statistic, MainWindow* mainWindow); public: virtual void run(); @@ -151,7 +149,7 @@ class CleanTask : public BackupEngine { public: CleanTask(const QString& name, const QStringList& sourceDirs, const QString& targetDir, - MainWindow* mainWindow); + ReFileTreeStatistic& statistic, MainWindow* mainWindow); public: virtual void run(); }; @@ -165,7 +163,7 @@ public: SearchTask(bool compareWithTarget, const QString& name, const QString& filePatterns, const QString& dirPatterns, const QStringList& sourceDirs, const QString& targetDir, - MainWindow* mainWindow); + ReFileTreeStatistic& statistic, MainWindow* mainWindow); public: virtual void run(); private: @@ -187,7 +185,8 @@ class SearchTargetTask : public BackupEngine public: SearchTargetTask(const QString& name, const QStringList& sourceDirs, const QString& targetDir, - qint64 maxAgeSec, MainWindow* mainWindow); + qint64 maxAgeSec, ReFileTreeStatistic& statistic, + MainWindow* mainWindow); public: virtual void run(); private: diff --git a/appl/rebackgui/Configuration.cpp b/appl/rebackgui/Configuration.cpp index ae2de13..ec0da50 100644 --- a/appl/rebackgui/Configuration.cpp +++ b/appl/rebackgui/Configuration.cpp @@ -10,9 +10,9 @@ */ #include "backupgui.hpp" -#define WITH_TRACE +//#define WITH_TRACE #include "base/retrace.hpp" -DECLARE_TRACER(s_traceConfig, "/tmp/bup_conf.log"); +DECLARE_TRACER(s_traceConfig, "/tmp/bup_conf.log") /** * Constructor. diff --git a/appl/rebackgui/mainwindow.cpp b/appl/rebackgui/mainwindow.cpp index da6b02f..eda42f1 100644 --- a/appl/rebackgui/mainwindow.cpp +++ b/appl/rebackgui/mainwindow.cpp @@ -12,11 +12,11 @@ #include "backupgui.hpp" #include "aboutdialog.hpp" #include -#define WITH_TRACE +//#define WITH_TRACE #include "base/retrace.hpp" -DECLARE_TRACER(s_traceMain, "/tmp/bup_main.log"); +DECLARE_TRACER(s_traceMain, "/tmp/bup_main.log") -const QString VERSION("2016.10.01"); +const QString VERSION("2016.10.05"); /** * Constructor. @@ -46,7 +46,9 @@ MainWindow::MainWindow(QApplication& application, const QString& homeDir, m_lastDirectory(""), m_lastTarget(""), m_textChangeLocked(false), - m_temporaryMounted("") + m_temporaryMounted(""), + m_statisticSearch(), + m_statisticTask() { initializeGui(); } @@ -210,7 +212,7 @@ void MainWindow::initializeGui(){ initializeGuiLanguage(ui->actionEnglish, ui->actionGerman); startStop(false); ui->actionAutosave->setChecked(true); - connect(ui->actionStart, SIGNAL(triggered()), this, + connect(ui->actionStart, SIGNAL(triggered()), this, SLOT(onStart())); connect(ui->actionChecksums, SIGNAL(triggered()), this, SLOT(onChecksums())); @@ -294,13 +296,6 @@ ReSuccess_t MainWindow::initializeStart(){ ReSuccess_t rc = true; BackupEngine::m_shouldStop = false; BackupEngine::m_searchReady = false; - BackupEngine::m_hotBytes = 0; - BackupEngine::m_hotFiles = 0; - BackupEngine::m_matchedFiles = 0; - BackupEngine::m_totalDirs = 0; - BackupEngine::m_totalFiles = 0; - BackupEngine::m_processedFiles = 0; - BackupEngine::m_processedBytes = 0; BackupEngine::m_files.clear(); ChecksumTask::m_sourceProcessingReady = false; if ( (m_maxListSize = comboInt(ui->comboBoxMaxListLength, -999)) == -999){ @@ -433,15 +428,16 @@ void MainWindow::onChecksums(){ delete m_searchTask; m_searchTask = new SearchTask(false, item.m_name, item.m_filePatterns, item.m_dirPatterns, - item.m_sources, target, this); + item.m_sources, target, + m_statisticSearch, this); m_searchTask->start(); delete m_checksumOfSourceTask; m_checksumOfSourceTask = new ChecksumOfSourceTask(item.m_name, - item.m_sources, target, this); + item.m_sources, target, m_statisticTask, this); m_checksumOfSourceTask->start(); delete m_checksumOfTargetTask; m_checksumOfTargetTask = new ChecksumOfTargetTask(item.m_name, - item.m_sources, target, this); + item.m_sources, target, m_statisticTask2, this); m_checksumOfTargetTask->start(); } } @@ -468,11 +464,12 @@ void MainWindow::onClean() initializeStart(); delete m_searchTargetTask; m_searchTargetTask = new SearchTargetTask(item.m_name, - item.m_sources, target, 14*24*3600, this); + item.m_sources, target, 14*24*3600, + m_statisticSearch, this); m_searchTargetTask->start(); delete m_cleanTask; m_cleanTask = new CleanTask(item.m_name, item.m_sources, target, - this); + m_statisticTask, this); m_cleanTask->start(); } } @@ -719,11 +716,12 @@ void MainWindow::onStart(){ delete m_searchTask; m_searchTask = new SearchTask(true, item.m_name, item.m_filePatterns, item.m_dirPatterns, - item.m_sources, target, this); + item.m_sources, target, + m_statisticSearch, this); m_searchTask->start(); delete m_backupTask; m_backupTask = new BackupTask(item.m_name, item.m_sources, target, - this); + m_statisticTask, this); m_backupTask->start(); } } @@ -795,6 +793,23 @@ void MainWindow::saveState(){ storage.close(); } +/** + * Logs a message about the end of a task. + * + * Note: This method is called from other threads. + * + * @param taskName the name of the task (translated) + * @param duration the duration in milliseconds + */ +void MainWindow::taskFinished(const QString& taskName, qint64 duration) +{ + externalTaskFinished(QObject::tr("%1 complete after %1. Errors: %2 File(s): %3 of %4") + .arg(taskName) + .arg(ReQStringUtils::readableDuration(duration)) + .arg(errors())); + +} + /** * Writes a message. * diff --git a/appl/rebackgui/mainwindow.hpp b/appl/rebackgui/mainwindow.hpp index e86a9a0..e6f504f 100644 --- a/appl/rebackgui/mainwindow.hpp +++ b/appl/rebackgui/mainwindow.hpp @@ -38,6 +38,7 @@ public: void setLastFile(const QString& lastFile); void setLastFile(const QString& lastDir, const QString& lastFile); void saveState(); + void taskFinished(const QString& taskName, qint64 duration); #ifdef __linux__ void unmount(const QString& device); #endif @@ -105,6 +106,9 @@ private: QString m_lastTarget; bool m_textChangeLocked; QString m_temporaryMounted; + ReFileTreeStatistic m_statisticSearch; + ReFileTreeStatistic m_statisticTask; + ReFileTreeStatistic m_statisticTask2; }; #endif // MAINWINDOW_HPP diff --git a/appl/recommand/CommandProcessor.cpp b/appl/recommand/CommandProcessor.cpp index f702b9f..a0a5115 100644 --- a/appl/recommand/CommandProcessor.cpp +++ b/appl/recommand/CommandProcessor.cpp @@ -18,10 +18,11 @@ */ CommandProcessor::CommandProcessor(MainWindow* mainWindow) : m_mainWindow(mainWindow), - m_random() + m_random(), + m_variables(), + m_regExprVariables("\\$(\\w+)|\\$\\{(\\w+)\\}") { m_random.modifySeed(ReRandomizer::nearTrueRandom()); - } /** @@ -54,6 +55,17 @@ void CommandProcessor::out(const QString& message) m_mainWindow->say(LOG_INFO, message); } +/** + * Sets a variable to a given value. + * + * @param name name of the variable + * @param value value of the variable + */ +void CommandProcessor::setVariable(const QString& name, const QString& value) +{ + m_variables[name] = value; +} + /** * @brief CommandProcessor::tail * @param args @@ -221,6 +233,41 @@ void CommandProcessor::euroJackpot(const QStringList& args){ } } +/** + * Replaces the variables by the value of their values. + * + * @param text the text to process + * @return all variables are replaced + */ +QString CommandProcessor::expandVariables(const QString& text) +{ + QString rc = text; + bool found = true; + int differenceOfLength = 0; + while (found){ + found = false; + QRegularExpressionMatchIterator i = m_regExprVariables.globalMatch(rc); + QString variable; + while(i.hasNext()){ + QRegularExpressionMatch match = i.next(); + variable = match.captured(1); + if (variable.isEmpty()) + variable = match.captured(2); + + if (m_variables.contains(variable)){ + found = true; + QString value = m_variables.value(variable); + int varLength = match.capturedLength(0); + int ixStart = match.capturedStart(0); + rc = rc.mid(0, ixStart + differenceOfLength) + value + + rc.mid(ixStart + varLength); + differenceOfLength += value.length() - varLength; + } + } + } + return rc; +} + /** * Displays an error message. * diff --git a/appl/recommand/CommandProcessor.hpp b/appl/recommand/CommandProcessor.hpp index 5c32dd8..6e7f38d 100644 --- a/appl/recommand/CommandProcessor.hpp +++ b/appl/recommand/CommandProcessor.hpp @@ -28,12 +28,17 @@ public: void lotto(const QStringList& args); void nOfM(const QStringList& args); void out(const QString& message); + void setVariable(const QString& name, const QString& value); void tail(const QStringList& args); void time(const QStringList& args); void statement(int lineNo, const QString& text); +protected: + QString expandVariables(const QString& text); protected: MainWindow* m_mainWindow; ReKISSRandomizer m_random; + QMap m_variables; + QRegularExpression m_regExprVariables; }; #endif // COMMANDPROCESSOR_HPP diff --git a/appl/recommand/cuCommandProcessor.cpp b/appl/recommand/cuCommandProcessor.cpp new file mode 100644 index 0000000..ee0ce81 --- /dev/null +++ b/appl/recommand/cuCommandProcessor.cpp @@ -0,0 +1,39 @@ +/* + * Licence: + * You can use and modify this file without any restriction. + * There is no warranty. + * You also can use the licence from http://www.wtfpl.net/. + * The original sources can be found on https://github.com/republib. +*/ +#include "base/rebase.hpp" +#include "CommandProcessor.hpp" + +/** + * @brief Unit test for CommandProcessor + */ +class TestCommandProcessor: public ReTest, public CommandProcessor { +public: + TestCommandProcessor() : + ReTest("CommandProcessor"), + CommandProcessor(NULL){ + doIt(); + } + +public: + void shouldExpandVariables() { + setVariable("x", "y"); + setVariable("y", "1234"); + checkEqu("abcy...", expandVariables("abc$x...")); + checkEqu("abc123...", expandVariables("abc$$x...")); + checkEqu("y", expandVariables("${x}")); + } + + virtual void runTests() { + shouldExpandVariables(); + } +}; + +void testCommandProcessor() { + TestCommandProcessor test; +} + diff --git a/appl/recommand/main.cpp b/appl/recommand/main.cpp index 35b3e89..27a57d2 100644 --- a/appl/recommand/main.cpp +++ b/appl/recommand/main.cpp @@ -13,10 +13,16 @@ #include char** g_argv; int main(int argc, char *argv[]){ - g_argv = argv; - QString homeDir = argc > 1 ? argv[1] : ""; - QApplication a(argc, argv); - MainWindow w(a, homeDir); - w.show(); - return a.exec(); + if (argc >= 2 && strcmp(argv[1], "--test") == 0){ + extern void testCommandProcessor(); + testCommandProcessor(); + return 0; + } else { + g_argv = argv; + QString homeDir = argc > 1 ? argv[1] : ""; + QApplication a(argc, argv); + MainWindow w(a, homeDir); + w.show(); + return a.exec(); + } } diff --git a/appl/recommand/recommand.pro b/appl/recommand/recommand.pro index 318b324..a3d2647 100644 --- a/appl/recommand/recommand.pro +++ b/appl/recommand/recommand.pro @@ -23,6 +23,7 @@ SOURCES += main.cpp\ ../../base/ReRandomizer.cpp \ ../../base/ReStringUtils.cpp \ ../../base/ReProgramArgs.cpp \ + ../../base/ReTest.cpp \ ../../gui/ReStateStorage.cpp \ ../../gui/ReGuiApplication.cpp \ ../../gui/ReGuiValidator.cpp \ @@ -30,7 +31,8 @@ SOURCES += main.cpp\ ../../gui/ReGuiUtils.cpp \ mainwindow.cpp \ CommandProcessor.cpp \ - ../../base/ReProcess.cpp + ../../base/ReProcess.cpp \ + cuCommandProcessor.cpp HEADERS += mainwindow.hpp \ CommandProcessor.hpp \ diff --git a/appl/reide/SearchEngine.cpp b/appl/reide/SearchEngine.cpp new file mode 100644 index 0000000..188c104 --- /dev/null +++ b/appl/reide/SearchEngine.cpp @@ -0,0 +1,48 @@ +#include "SearchEngine.hpp" +#include +#include +#include + +/** + * Constructor. + * + * @param fullName filename with path + */ +FileBuffer::FileBuffer(const QString &fullName) +{ + read(fullName); +} + +/** + * Reads a file into the internal line list. + * + * @param fullName filename with path + */ +void FileBuffer::read(const QString &fullName) +{ + QFile textFile(fullName); + if (textFile.exists()){ + QString line; + OpenMode mode; + if (textFile.open(QIODevice::ReadOnly)){ + QTextStream textStream(&textFile); + while (true) + { + line = textStream.readLine(); + if (line.isNull()) + break; + else + m_lines.append(line); + } + } + textFile.close(); + } +} + +/** + * Constructor. + */ +SearchEngine::SearchEngine() +{ + +} diff --git a/appl/reide/SearchEngine.hpp b/appl/reide/SearchEngine.hpp new file mode 100644 index 0000000..9baf1a3 --- /dev/null +++ b/appl/reide/SearchEngine.hpp @@ -0,0 +1,26 @@ +#ifndef SEARCHENGINE_H +#define SEARCHENGINE_H + +class FileBuffer { +public: + FileBuffer(const QString& fullName); + ~FileBuffer(); +public: + void read(const QString& fullName); + +private: + QString m_node; + QString m_path; + QList m_lines; +}; + +class SearchEngine +{ +public: + SearchEngine(); +public: +private: + +}; + +#endif // SEARCHENGINE_H diff --git a/appl/reide/filesearch.ui b/appl/reide/filesearch.ui index daed0c2..5f4dd7b 100644 --- a/appl/reide/filesearch.ui +++ b/appl/reide/filesearch.ui @@ -20,7 +20,7 @@ QTabWidget::North - 0 + 3 false diff --git a/appl/reide/mainwindow.cpp b/appl/reide/mainwindow.cpp index f1cae74..0fb37a6 100644 --- a/appl/reide/mainwindow.cpp +++ b/appl/reide/mainwindow.cpp @@ -53,7 +53,8 @@ MainWindow::MainWindow(const char* workspace, const char* project, m_perspectives.addPerspective(mainPerspective); m_perspectives.change(mainPerspective->name()); m_perspectives.addPerspective(new ProjectPerspective(proj, this)); - m_delayedStorage = new ReDelayedStorage(m_workspace->historyFile()) + m_delayedStorage = new ReDelayedStorage(m_workspace->fileHistory(), + m_logger); } /** diff --git a/appl/reide/mainwindow.ui b/appl/reide/mainwindow.ui index 332e777..633db19 100644 --- a/appl/reide/mainwindow.ui +++ b/appl/reide/mainwindow.ui @@ -20,7 +20,7 @@ Qt::Vertical - + @@ -81,7 +81,7 @@ true - true + false @@ -168,7 +168,7 @@ true - true + false @@ -204,9 +204,38 @@ 0 0 803 - 35 + 31 + + + Fi&le + + + + + + + + Edi&t + + + + + A&ction + + + + + + Help + + + + + + + @@ -260,6 +289,26 @@ Ctrl+S + + + Open + + + + + Exit + + + + + File search + + + + + About + + diff --git a/appl/reide/reide.pro b/appl/reide/reide.pro index 7f65b9d..c138517 100644 --- a/appl/reide/reide.pro +++ b/appl/reide/reide.pro @@ -18,6 +18,9 @@ SOURCES += \ ../../gui/ReStateStorage.cpp \ ../../gui/ReSettings.cpp \ ../../base/ReFile.cpp \ + ../../base/ReProcess.cpp \ + ../../base/ReStringUtils.cpp \ + ../../base/ReMatcher.cpp \ ../../gui/ReFileTree.cpp \ mainwindow.cpp \ ../../base/ReLogger.cpp \ @@ -37,7 +40,8 @@ SOURCES += \ views/ProjectPerspective.cpp \ views/StartPerspective.cpp \ views/StartView.cpp \ - main.cpp + main.cpp \ + SearchEngine.cpp HEADERS += mainwindow.hpp \ @@ -54,7 +58,8 @@ HEADERS += mainwindow.hpp \ project.hpp \ reide.hpp \ filesearch.hpp \ - views/StartView.hpp + views/StartView.hpp \ + SearchEngine.hpp FORMS += mainwindow.ui \ projectselection.ui \ diff --git a/appl/reide/workspace.cpp b/appl/reide/workspace.cpp index 0aa6de5..feea5fa 100644 --- a/appl/reide/workspace.cpp +++ b/appl/reide/workspace.cpp @@ -21,20 +21,21 @@ const char* Workspace::KEY_HISTORY_PROJECTS = "projecs"; * @param logger the logger */ Workspace::Workspace(const QString& path, ReLogger* logger) : - ReSettings(path, ".reditor.ws", logger) { + ReSettings(path, ".reditor.ws", logger) +{ insertProperty( - new ReProperty("editor.tabwidth", QObject::tr("Tabulator width"), - QObject::tr("Maximal length of the gap displaying a tabulator"), - "4", PT_INT, "[1,16]")); + new ReProperty("editor.tabwidth", QObject::tr("Tabulator width"), + QObject::tr("Maximal length of the gap displaying a tabulator"), + "4", PT_INT, "[1,16]")); insertProperty( - new ReProperty("history.max_projects", - QObject::tr("Maximal project entries"), - QObject::tr( - "Maximal number of projects in the 'last opened projects'"), - "20", PT_INT, "[1,100]")); + new ReProperty("history.max_projects", + QObject::tr("Maximal project entries"), + QObject::tr( + "Maximal number of projects in the 'last opened projects'"), + "20", PT_INT, "[1,100]")); insertProperty( - new ReProperty("history.max_files", QObject::tr("Maximal file entries"), - QObject::tr("Maximal number of files in the 'last opened files'"), - "20", PT_INT, "[1,100]")); + new ReProperty("history.max_files", QObject::tr("Maximal file entries"), + QObject::tr("Maximal number of files in the 'last opened files'"), + "20", PT_INT, "[1,100]")); } diff --git a/appl/reprime/reprime.pro b/appl/reprime/reprime.pro index 3e275a8..d2ac6e4 100644 --- a/appl/reprime/reprime.pro +++ b/appl/reprime/reprime.pro @@ -14,6 +14,7 @@ SOURCES += main.cpp \ ../../base/ReLogger.cpp \ ../../base/ReRandomizer.cpp \ ../../base/ReStringUtils.cpp \ + ../../base/ReQStringUtils.cpp \ ../../base/ReException.cpp \ Prime.cpp diff --git a/appl/research/aboutdialog.cpp b/appl/research/aboutdialog.cpp new file mode 100644 index 0000000..7af1b0f --- /dev/null +++ b/appl/research/aboutdialog.cpp @@ -0,0 +1,23 @@ +/* + * aboutdialog.cpp + * + * (Un)License: Public Domain + * You can use and modify this file without any restriction. + * Do what you want. + * No warranties and disclaimer of any damages. + * More info: http://unlicense.org + * The latest sources: https://github.com/republib + */ + +#include "aboutdialog.hpp" +#include "ui_aboutdialog.h" + +AboutDialog::AboutDialog(const QString& version, QWidget *parent) : + QDialog(parent), ui(new Ui::AboutDialog){ + ui->setupUi(this); + ui->labelVersion->setText(version); +} + +AboutDialog::~AboutDialog(){ + delete ui; +} diff --git a/appl/research/aboutdialog.hpp b/appl/research/aboutdialog.hpp new file mode 100644 index 0000000..bf51cc7 --- /dev/null +++ b/appl/research/aboutdialog.hpp @@ -0,0 +1,32 @@ +/* + * aboutdialog.hpp + * + * (Un)License: Public Domain + * You can use and modify this file without any restriction. + * Do what you want. + * No warranties and disclaimer of any damages. + * More info: http://unlicense.org + * The latest sources: https://github.com/republib + */ + +#ifndef ABOUTDIALOG_HPP +#define ABOUTDIALOG_HPP + +#include + +namespace Ui { +class AboutDialog; +} + +class AboutDialog: public QDialog { + Q_OBJECT + +public: + explicit AboutDialog(const QString& version, QWidget *parent = 0); + ~AboutDialog(); + +private: + Ui::AboutDialog *ui; +}; + +#endif // ABOUTDIALOG_HPP diff --git a/appl/research/aboutdialog.ui b/appl/research/aboutdialog.ui new file mode 100644 index 0000000..0aeded1 --- /dev/null +++ b/appl/research/aboutdialog.ui @@ -0,0 +1,113 @@ + + + AboutDialog + + + + 0 + 0 + 423 + 276 + + + + Dialog + + + + + 20 + 20 + 381 + 181 + + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:9pt; font-weight:600;">ReSearch</span><span style=" font-family:'Sans Serif'; font-size:9pt;"> for text searching/filtering in files</span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:9pt;">This is a program of the project</span></p> +<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:9pt; font-weight:600;">Re</span><span style=" font-family:'Sans Serif'; font-size:9pt;">al </span><span style=" font-family:'Sans Serif'; font-size:9pt; font-weight:600;">Pub</span><span style=" font-family:'Sans Serif'; font-size:9pt;">lic </span><span style=" font-family:'Sans Serif'; font-size:9pt; font-weight:600;">Lib</span><span style=" font-family:'Sans Serif'; font-size:9pt;">rary (RePubLib)</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:9pt;">Sources are public domain and available under</span></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/republib"><span style=" font-family:'Sans Serif'; font-size:9pt; text-decoration: underline; color:#0000ff;">https://github.com/republib</span></a><span style=" font-family:'Sans Serif'; font-size:9pt;"> </span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:9pt;">Implemented in QT (C++) 5.x</span></p></body></html> + + + false + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + 20 + 220 + 381 + 35 + + + + + + + Version: + + + + + + + 2015.05.00 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + &Close + + + + + + + + + + pushButtonOK + clicked() + AboutDialog + close() + + + 357 + 237 + + + 211 + 137 + + + + + diff --git a/appl/research/main.cpp b/appl/research/main.cpp new file mode 100644 index 0000000..8e26a2f --- /dev/null +++ b/appl/research/main.cpp @@ -0,0 +1,11 @@ +#include "research.hpp" +#include "mainwindow.hpp" +char** g_argv; +int main(int argc, char* argv[]) { + g_argv = argv; + QString homeDir = argc > 1 ? argv[1] : ""; + QApplication a(argc, argv); + MainWindow w(a, homeDir); + w.show(); + return a.exec(); +} diff --git a/appl/research/mainwindow.cpp b/appl/research/mainwindow.cpp new file mode 100644 index 0000000..6818f0b --- /dev/null +++ b/appl/research/mainwindow.cpp @@ -0,0 +1,92 @@ +#include "research.hpp" +#include "mainwindow.hpp" +#include "ui_mainwindow.h" +#include "aboutdialog.hpp" + +static const char* VERSION = "2016.11.16"; + +MainWindow::MainWindow(QApplication& application, const QString& homeDir, + QWidget *parent) : + ReGuiApplication(application, "rsearch", homeDir, 2, 10100100, "de", parent), + ReGuiValidator(), + ui(new Ui::MainWindow) +{ + ReComboBox::setDefaultHistorySize(20); + initializeGui(); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +/** + * Initializes the Graphical User Interface. + */ +void MainWindow::initializeGui(){ + ui->setupUi(this); + initializeGuiElements(); + // restoreState(); + m_guiIsInitialized = false; + connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(onAbout())); + connect(ui->comboBoxBaseDirectory, SIGNAL(textEdited(const QString&, const QString&)), + this, SLOT(textEdited(const QString&, const QString&))); + +} + +/** + * Shows the "about" window. + */ +void MainWindow::onAbout() +{ + AboutDialog dialog(VERSION); + dialog.exec(); +} +/** + * Called at the program's end. + */ +void MainWindow::onAboutToQuit() +{ + saveState(); + ReGuiApplication::onAboutToQuit(); +} + +/** + * Set GUI elements from the queue when the GUI timer is triggered. + */ +void MainWindow::onGuiTimerUpdate() +{ +} + + +/** + * The language has been changed. + */ +void MainWindow::onLanguageChange() +{ + initializeGui(); +} + +/** + * Writes a message. + * + * @param level mode of the message, e.g. LOG_ERROR + * @param message the message + * @return falselevel is error or warning + */ +bool MainWindow::say(ReLoggerLevel level, const QString& message){ + setStatusMessage(level, message); + return level >= LOG_INFO; +} + +/** + * Event + * @param oldString + * @param newString + */ +void MainWindow::textEdited(const QString& oldString, const QString& newString) +{ + ReUseParameter(oldString); + ReUseParameter(newString); +} + diff --git a/appl/research/mainwindow.hpp b/appl/research/mainwindow.hpp new file mode 100644 index 0000000..700799a --- /dev/null +++ b/appl/research/mainwindow.hpp @@ -0,0 +1,39 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#ifndef REBASE_HPP +#include "base/rebase.hpp" +#endif +#ifndef REGUI_HPP +#include "gui/regui.hpp" +#endif + +namespace Ui { +class MainWindow; +} + +class MainWindow : public ReGuiApplication, public ReGuiValidator +{ + Q_OBJECT + +public: + explicit MainWindow(QApplication& application, const QString& homeDir, + QWidget *parent = 0); + ~MainWindow(); +public: + virtual bool say(ReLoggerLevel level, const QString& message); + +private: + void initializeGui(); + +private slots: + void onAbout(); + virtual void onAboutToQuit(); + virtual void onGuiTimerUpdate(); + virtual void onLanguageChange(); + void textEdited(const QString& oldString, const QString& newString); + +private: + Ui::MainWindow *ui; +}; +#endif // MAINWINDOW_H diff --git a/appl/research/mainwindow.ui b/appl/research/mainwindow.ui new file mode 100644 index 0000000..c35be51 --- /dev/null +++ b/appl/research/mainwindow.ui @@ -0,0 +1,531 @@ + + + MainWindow + + + + 0 + 0 + 869 + 627 + + + + MainWindow + + + + + + + 0 + + + + Files + + + + + + + + + + + 16777215 + 175 + + + + 0 + + + + Directory search + + + + + + Base directory: + + + + + + + + + + 16777215 + 16777215 + + + + The files will be searched in this directory or its subdirectories + + + true + + + + + + QComboBox::AdjustToContents + + + + + + + + 50 + 16777215 + + + + ... + + + + + + + + + + + Recursive + + + true + + + + + + + Qt::Horizontal + + + + 188 + 17 + + + + + + + + Max. depth: + + + + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + 99 + + + + + + + Min. depth: + + + + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + 0 + + + + + + + + + Patterns: + + + + + + + true + + + + + + + + Single files + + + + + + + + + 16777215 + 175 + + + + Activity + + + + + 19 + 27 + 85 + 33 + + + + &Add + + + + + + 19 + 67 + 85 + 33 + + + + &Clear + + + + + + + + + + true + + + + Name + + + + + Size + + + AlignTrailing|AlignVCenter + + + + + Date + + + AlignLeading|AlignVCenter + + + + + Directory + + + + + + + + + + + Text + + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + 1 + + + + Filter patterns + + + + + + Including pattern: + + + + + + + true + + + + + + + Exluding pattern: + + + + + + + true + + + + + + + + Options + + + + + 175 + 10 + 321 + 35 + + + + + + + Lines above: + + + + + + + + 50 + 16777215 + + + + true + + + 0 + + + + + + + Lines below: + + + + + + + + 50 + 16777215 + + + + true + + + 0 + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + From hit: + + + + + + + + 100 + 16777215 + + + + true + + + 0 + + + + + + + To hit: + + + + + + + + 100 + 16777215 + + + + true + + + 100 + + + + + + + + + + + + + + + Block + + + + + + + + + + 0 + 0 + 869 + 31 + + + + + Fi&le + + + + + + Hel&p + + + + + + + + + TopToolBarArea + + + false + + + + + + &Exit + + + + + &About + + + + + + + ReComboBox + QComboBox +
gui/ReComboBox.hpp
+
+
+ + +
diff --git a/appl/research/research.hpp b/appl/research/research.hpp new file mode 100644 index 0000000..eaa4d76 --- /dev/null +++ b/appl/research/research.hpp @@ -0,0 +1,14 @@ +/* + * Licence: + * You can use and modify this file without any restriction. + * There is no warranty. + * You also can use the licence from http://www.wtfpl.net/. + * The original sources can be found on https://github.com/republib. +*/ + +#ifndef RESEARCH_HPP +#define RESEARCH_HPP +#include "base/rebase.hpp" +#include "gui/regui.hpp" +#include +#endif // RESEARCH_HPP diff --git a/appl/research/research.pro b/appl/research/research.pro new file mode 100644 index 0000000..d4d26ba --- /dev/null +++ b/appl/research/research.pro @@ -0,0 +1,49 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2016-11-15T23:03:11 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = research +TEMPLATE = app +INCLUDEPATH = ../.. + + +SOURCES += main.cpp \ + ../../base/ReException.cpp \ + ../../base/ReConfig.cpp \ + ../../base/ReProcess.cpp \ + ../../base/ReQStringUtils.cpp \ + ../../base/ReFileUtils.cpp \ + ../../base/ReMatcher.cpp \ + ../../base/ReLogger.cpp \ + ../../base/ReRandomizer.cpp \ + ../../base/ReStringUtils.cpp \ + ../../gui/ReComboBox.cpp \ + ../../gui/ReStateStorage.cpp \ + ../../gui/ReGuiApplication.cpp \ + ../../gui/ReGuiValidator.cpp \ + ../../gui/ReGuiQueue.cpp \ + ../../gui/ReGuiUtils.cpp \ + mainwindow.cpp \ + aboutdialog.cpp \ + ../../base/ReFileSearch.cpp + +HEADERS += mainwindow.hpp \ + ../../base/rebase.hpp \ + ../../base/ReQStringUtils.hpp \ + ../../gui/ReComboBox.hpp \ + ../../gui/ReStateStorage.hpp \ + ../../gui/ReGuiValidator.hpp \ + ../../gui/regui.hpp \ + ../../gui/ReGuiUtils.hpp \ + aboutdialog.hpp \ + research.hpp \ + ../../base/ReFileSearch.hpp + +FORMS += mainwindow.ui \ + aboutdialog.ui diff --git a/base/ReFile.cpp b/base/ReFile.cpp index ae1bad8..71bcc97 100644 --- a/base/ReFile.cpp +++ b/base/ReFile.cpp @@ -535,6 +535,11 @@ bool ReFile::findLine(const QString& includePattern, bool includeIsRegExpr, bool includeIgnoreCase, const QString& excludePattern, bool excludeIsRegExpr, bool excludeIgnoreCase, int& lineNo, QString* line) { bool rc = false; + ReUseParameter(includeIgnoreCase); + ReUseParameter(includeIsRegExpr); + ReUseParameter(excludeIsRegExpr); + ReUseParameter(excludeIgnoreCase); + ReUseParameter(excludePattern); if (line != NULL) *line = ""; lineNo = 0; diff --git a/base/ReFileSearch.cpp b/base/ReFileSearch.cpp new file mode 100644 index 0000000..bfd947e --- /dev/null +++ b/base/ReFileSearch.cpp @@ -0,0 +1,127 @@ +/* + * Licence: + * You can use and modify this file without any restriction. + * There is no warranty. + * You also can use the licence from http://www.wtfpl.net/. + * The original sources can be found on https://github.com/republib. +*/ + +#include "base/rebase.hpp" + +/** + * Constructor. + */ +ReFileSearch::ReFileSearch() : + m_minDepth(0), + m_maxDepth(9999), + m_searchMode(smFilesAndDirs), + m_matcher() +{ +} + +/** + * Returns the current maximal depth. + * + * @return the current maximal depth + */ +int ReFileSearch::maxDepth() const +{ + return m_maxDepth; +} + +/** + * Returns the current minimal depth. + * + * @return the current minimal depth + */ +int ReFileSearch::minDepth() const +{ + return m_minDepth; +} + +void ReFileSearch::oneDirectory(const QString& directory, int depth) +{ + QDir dir(directory); + QStringList files = dir.entryList(); + QString node; + QString full; + QStringList dirs; + for (int ix = 0; ix < files.size(); ix++){ + node = files[ix]; + if (node == "." || node == "..") + continue; + full = directory; + full += OS_SEPARATOR; + full += node; + QFileInfo info(full); + if (! info.isDir()){ + if (m_searchMode == smDirs || depth < m_minDepth){ + continue; + } + } else { + if (depth < m_maxDepth) + dirs += full; + + if (m_searchMode == smFiles || depth < m_minDepth){ + continue; + } + } + if (m_matcher.matches(node)) + handleFile(full, directory, node); + } + ++depth; + for (int ix = 0; ix < dirs.size(); ix++){ + oneDirectory(directory + OS_SEPARATOR_STR + dirs[ix], depth); + } +} + +/** + * Returns the current search mode. + * + * @return the current search mode, e.g. smFilesAndDirs + */ +ReFileSearch::SearchMode ReFileSearch::searchMode() const +{ + return m_searchMode; +} + +/** + * Sets the file search mode. + * + * @param searchMode the new mode, e.g. smFilesAndDirs + */ +void ReFileSearch::setSearchMode(const SearchMode& searchMode) +{ + m_searchMode = searchMode; +} + +/** + * Sets the maximal depth. + * + * @param maxDepth the maximal depth + */ +void ReFileSearch::setMaxDepth(int maxDepth) +{ + m_maxDepth = maxDepth; +} + +/** + * Sets the minimal depth. + * + * @param maxDepth the minimal depth + */ +void ReFileSearch::setMinDepth(int minDepth) +{ + m_minDepth = minDepth; +} + +/** + * Sets the search patterns. + * + * @param includeExcludePatterns a list of patterns, separated by ','. + * Exclude patterns start with '-' + */ +void ReFileSearch::setPatterns(const QString& includeExcludePatterns) +{ + m_matcher.setPatterns(includeExcludePatterns, ',', '-'); +} diff --git a/base/ReFileSearch.hpp b/base/ReFileSearch.hpp new file mode 100644 index 0000000..cd777d1 --- /dev/null +++ b/base/ReFileSearch.hpp @@ -0,0 +1,46 @@ +/* + * Licence: + * You can use and modify this file without any restriction. + * There is no warranty. + * You also can use the licence from http://www.wtfpl.net/. + * The original sources can be found on https://github.com/republib. +*/ + +#ifndef REFILESEARCH_HPP +#define REFILESEARCH_HPP + +/** + * An abstract class to search files in a directory tree. + * + * + */ +class ReFileSearch +{ +public: + enum SearchMode { + smUndef, + smFiles, + smDirs, + smFilesAndDirs + }; + +public: + ReFileSearch(); +public: + virtual void handleFile(const QString& full, const QString& path, const QString& node) = 0; + int maxDepth() const; + int minDepth() const; + void oneDirectory(const QString& directory, int depth); + SearchMode searchMode() const; + void setMaxDepth(int maxDepth); + void setMinDepth(int minDepth); + void setPatterns(const QString& includeExcludePattern); + void setSearchMode(const SearchMode& searchMode); +public: + int m_minDepth; + int m_maxDepth; + SearchMode m_searchMode; + ReIncludeExcludeMatcher m_matcher; +}; + +#endif // REFILESEARCH_HPP diff --git a/base/ReFileUtils.cpp b/base/ReFileUtils.cpp index 0bfafe8..8b53943 100644 --- a/base/ReFileUtils.cpp +++ b/base/ReFileUtils.cpp @@ -29,14 +29,6 @@ QDateTime ReFileUtils::m_undefinedTime; ReMountInfo* ReMountInfo::m_instance = NULL; ReBlockDevices* ReBlockDevices::m_instance = NULL; #endif -/** - * Constructor. - */ -ReTreeStatistic::ReTreeStatistic() : - m_files(0), - m_directories(0), - m_fileSizes(0L) { -} /** * Builds a checksum of the given file. @@ -668,7 +660,7 @@ ReSuccess_t ReFileUtils::makeDirWithParents(const char* path, ReLogger* logger) } } } - if (! rc) + if (! rc && logger != NULL) logger->log(LOG_ERROR, LOC_MAKE_DIR_WITH_PARENT_1, QObject::tr("can't create directory (%1): %2").arg(errno) .arg(path)); diff --git a/base/ReFileUtils.hpp b/base/ReFileUtils.hpp index 3ffb5aa..0d53098 100644 --- a/base/ReFileUtils.hpp +++ b/base/ReFileUtils.hpp @@ -13,14 +13,120 @@ #define REFILEUTILS_HPP /** - * Statistic of a directory tree. + * Simple counters of a directory tree. */ -class ReTreeStatistic { - ReTreeStatistic(); +class ReFileTreeCounter +{ public: + /** + * Constructor. + */ + ReFileTreeCounter() : + m_bytes(0), + m_files(0), + m_directories(0LL) + {} + /** + * Copy Constructor. + * @param source instance to copy + */ + ReFileTreeCounter(const ReFileTreeCounter& source) : + m_bytes(source.m_bytes), + m_files(source.m_files), + m_directories(source.m_directories) + { + } + /** + * Assignment operator. + * @param source + * @return + */ + ReFileTreeCounter& operator =(const ReFileTreeCounter& source){ + m_bytes = source.m_bytes; + m_files = source.m_files; + m_directories = source.m_directories; + return *this; + } +public: + /** + * Sets the counters to 0. + */ + inline void clear(){ + m_files = m_directories = 0; + m_bytes = 0; + } + /** + * Add a file to the statistic. + * + * @param size the file's size + */ + inline void addFile(qint64 size){ + m_bytes += size; + ++m_files; + } + /** + * Increments the count of directories. + */ + inline void addDir(){ + ++m_directories; + } + /** + * Returns the sum of file sizes. + * @return the sum of file sizes + */ + qint64 bytes() const { + return m_bytes; + } + /** + * Returns the number of files. + * @return the number of files + */ + int files() const { + return m_files; + } + /** + * Returns the number of files. + * @return the number of files + */ + int directories() const { + return m_directories; + } +protected: + qint64 m_bytes; int m_files; int m_directories; - int64_t m_fileSizes; +}; + +/** + * Statistic of a directory tree. + */ +class ReFileTreeStatistic +{ +public: + /** + * Constructor. + */ + ReFileTreeStatistic() : + m_hot(), + m_processed(), + m_matched(), + m_total() + {} +public: + /** + * Sets all counters to 0. + */ + inline void clear(){ + m_hot.clear(); + m_processed.clear(); + m_matched.clear(); + m_total.clear(); + } +public: + ReFileTreeCounter m_hot; + ReFileTreeCounter m_processed; + ReFileTreeCounter m_matched; + ReFileTreeCounter m_total; }; /** diff --git a/base/ReRandomizer.cpp b/base/ReRandomizer.cpp index 6904efd..2352993 100644 --- a/base/ReRandomizer.cpp +++ b/base/ReRandomizer.cpp @@ -291,10 +291,11 @@ ReRandomizer::~ReRandomizer() { inline int abs(int x) { return x < 0 ? -x : x; } +#ifndef _GLIBCXX_CSTDLIB inline int64_t abs(int64_t x){ return x < 0 ? -x : x; } - +#endif #endif /** diff --git a/base/rebase.hpp b/base/rebase.hpp index 2f93a66..e431e73 100644 --- a/base/rebase.hpp +++ b/base/rebase.hpp @@ -220,6 +220,7 @@ public: #include "base/ReFile.hpp" #include "base/ReDiff.hpp" #include "base/ReMatcher.hpp" +#include "base/ReFileSearch.hpp" #include "base/ReTest.hpp" #include "base/ReRandomizer.hpp" #endif // REBASE_HPP diff --git a/base/retrace.hpp b/base/retrace.hpp index e631b20..b46f410 100644 --- a/base/retrace.hpp +++ b/base/retrace.hpp @@ -19,7 +19,7 @@ #define TRACE2(format, a1, a2) printf(format, a1, a2) #define TRACE_IT(args) printf args #define IF_TRACE(statem) statem -#define DECLARE_TRACER(varName, fileName) static ReTracer varName(fileName) +#define DECLARE_TRACER(varName, fileName) static ReTracer varName(fileName); // Example: FILETRACE_IT(s_tracerLoop, (s_tracerLoop.m_fp, "value: %d", 33)); #define FILETRACE_IT(varName, args) do { if (varName.m_fp != NULL) { \ fprintf args; fflush(varName.m_fp); } } while(false) diff --git a/cunit/allTests.cpp b/cunit/allTests.cpp index cc5dc81..b6dff3b 100644 --- a/cunit/allTests.cpp +++ b/cunit/allTests.cpp @@ -18,6 +18,7 @@ static bool s_allTest = false; static void testBase() { + void testReFileSearch(); void testReProgArgs(); void testReProcess(); void testReRandomizer(); @@ -32,6 +33,7 @@ static void testBase() { void testReWriter(); void testReFile(); void testReMatcher(); + testReFileSearch(); testReFileUtils(); testReQStringUtil(); testReProgArgs(); diff --git a/cunit/cuReFileSearch.cpp b/cunit/cuReFileSearch.cpp new file mode 100644 index 0000000..32b4d2c --- /dev/null +++ b/cunit/cuReFileSearch.cpp @@ -0,0 +1,74 @@ +/* + * cuReFileSearch.cpp + * + * (Un)License: Public Domain + * You can use and modify this file without any restriction. + * Do what you want. + * No warranties and disclaimer of any damages. + * More info: http://unlicense.org + * The latest sources: https://github.com/republib + */ +#include "base/rebase.hpp" +#include + +/** @file + * @brief Unit test of the basic exceptions. + */ + +class TestReFileSearch: public ReTest, public ReFileSearch { +public: + TestReFileSearch() : + ReTest("ReFileSearch") { + doIt(); + } + +public: + void testBasic() { + m_found.clear(); + setPatterns("test3.txt"); + setSearchMode(smFiles); + oneDirectory(m_baseDir, 0); + checkEqu(5, m_found.size()); + checkT(m_found.contains("file3.txt")); + checkT(m_found.contains("dir1/file3.txt")); + checkT(m_found.contains("dir1/dir2/file3.txt")); + checkT(m_found.contains("dir1/dir2/dir3/file3.txt")); + checkT(m_found.contains("dir1/dir2/dir3/dir4/file3.txt")); + } + virtual void handleFile(const QString& full, const QString& path, const QString& node){ + checkEqu(full, path + OS_SEPARATOR_STR + node); + QString relPath = full.mid(m_baseDir.length() + 1); + relPath.replace(OS_SEPARATOR, "/"); + m_found.insert(relPath, 0); + } +private: + void makeFile(const QString& name){ + ReFileUtils::writeToFile(name.toUtf8().data(), name.toUtf8().data()); + } + + void makeTree(){ + m_baseDir = ReFileUtils::tempDir("ReFileSearch", NULL, false); + QString path = m_baseDir; + for (int depth = 0; depth < 5; depth++){ + if (depth > 0) + path += OS_SEPARATOR_STR + QString("dir") + QString::number(depth); + ReFileUtils::makeDirWithParents(path); + for (int ix = 1; ix <= 5; ix++){ + QString name = path + OS_SEPARATOR_STR + "file" + QString::number(ix) + ".txt"; + makeFile(name); + } + } + } + + virtual void runTests() { + makeTree(); + testBasic(); + } +private: + QString m_baseDir; + QMap m_found; +}; +void testReFileSearch() { + TestReFileSearch test; +} + diff --git a/cunit/cunit.pro b/cunit/cunit.pro index e510dc2..797d02d 100644 --- a/cunit/cunit.pro +++ b/cunit/cunit.pro @@ -26,6 +26,7 @@ SOURCES += main.cpp \ ../base/ReContainer.cpp \ ../base/ReException.cpp \ ../base/ReFile.cpp \ + ../base/ReFileSearch.cpp \ ../base/ReFileUtils.cpp \ ../base/ReQStringUtils.cpp \ ../base/ReLogger.cpp \ @@ -56,7 +57,9 @@ SOURCES += main.cpp \ cuReByteStorage.cpp \ cuReProgArgs.cpp \ ../base/ReProcess.cpp \ - ../base/ReProgramArgs.cpp + ../base/ReProgramArgs.cpp \ + ../cunit/cuReFileSearch.cpp + RESERVE = \ cuReEdit.cpp \ @@ -67,7 +70,7 @@ RESERVE = \ cuReCryptFileSystem.cpp \ HEADERS += \ - ../base/ReFile.hpp \ + ../base/ReFileSearch.hpp \ ../base/rebase.hpp \ ../gui/ReEdit.hpp \ ../math/ReMatrix.hpp \ diff --git a/gui/ReComboBox.cpp b/gui/ReComboBox.cpp index 2eea037..87435f4 100644 --- a/gui/ReComboBox.cpp +++ b/gui/ReComboBox.cpp @@ -7,6 +7,9 @@ */ #include "base/rebase.hpp" #include "gui/regui.hpp" +#include "gui/ReComboBox.hpp" + +int ReComboBox::m_defaultHistorySize = 20; /** * Constructor. @@ -16,7 +19,14 @@ ReComboBox::ReComboBox(QWidget *parent) : QComboBox(parent), m_oldString(), - m_historySize(0) + m_historySize(m_defaultHistorySize) +{ +} + +/** + * Destructor. + */ +ReComboBox::~ReComboBox() { } @@ -51,7 +61,7 @@ void ReComboBox::focusOutEvent(QFocusEvent* event) removeItem(m_historySize); } - comboTextEdited(m_oldString, current); + emit textEdited(m_oldString, current); } } QComboBox::focusOutEvent(event); @@ -69,10 +79,21 @@ int ReComboBox::historySize() const } /** - * @brief ReComboBox::setHistorySize - * @param size + * Sets the history size of the instance. + * + * @param size the new size */ void ReComboBox::setHistorySize(int size) { m_historySize = size; } + +/** + * Sets the default history size used at the initialization of a ReComboBox. + * + * @param size the new size + */ +void ReComboBox::setDefaultHistorySize(int size) +{ + m_defaultHistorySize = size; +} diff --git a/gui/ReComboBox.hpp b/gui/ReComboBox.hpp index 5cfa16c..6304d1c 100644 --- a/gui/ReComboBox.hpp +++ b/gui/ReComboBox.hpp @@ -17,18 +17,28 @@ class ReComboBox : public QComboBox Q_OBJECT public: explicit ReComboBox(QWidget *parent = 0); + virtual ~ReComboBox(); public: int historySize() const; void setHistorySize(int size); - +public: + static void setDefaultHistorySize(int size); signals: - void comboTextEdited(const QString& oldText, const QString& newText); + /** + * Signal if the text of the combobox has changed after loosing the focus. + * + * @param oldText the old text (while got the focus) + * @param newText the current text + */ + void textEdited(const QString&, const QString&); private: - virtual void focusInEvent(QFocusEvent* event); - virtual void focusOutEvent(QFocusEvent* event); + void focusInEvent(QFocusEvent* event); + void focusOutEvent(QFocusEvent* event); private: QString m_oldString; int m_historySize; +private: + static int m_defaultHistorySize; }; #endif // RECOMBOBOX_HPP diff --git a/gui/ReSettings.hpp b/gui/ReSettings.hpp index 5734137..135d639 100644 --- a/gui/ReSettings.hpp +++ b/gui/ReSettings.hpp @@ -71,8 +71,8 @@ typedef QMap*> ReChapterMap; class ReSettings { public: - static QString sTRUE; - static QString sFALSE; + static QString TRUE; + static QString FALSE; public: ReSettings(const QString& path, const QString& prefix, ReLogger* logger); ~ReSettings(); diff --git a/gui/regui.hpp b/gui/regui.hpp index 566e3c6..1921093 100644 --- a/gui/regui.hpp +++ b/gui/regui.hpp @@ -18,6 +18,7 @@ #include #include #include +#include "gui/ReComboBox.hpp" #include "gui/ReGuiUtils.hpp" #include "gui/ReGuiQueue.hpp" #include "gui/ReStateStorage.hpp" @@ -26,7 +27,6 @@ #include "gui/ReEdit.hpp" #include "gui/ReSettings.hpp" #include "gui/ReFileTree.hpp" -#include "gui/ReComboBox.hpp" /** * Tests whether a point is inside the rectangle (including border). diff --git a/os/ReCryptFileSystem.cpp b/os/ReCryptFileSystem.cpp index 7a5c2f9..74daacb 100644 --- a/os/ReCryptFileSystem.cpp +++ b/os/ReCryptFileSystem.cpp @@ -251,6 +251,10 @@ ReFileSystem::ErrorCode ReCryptFileSystem::makeDir(const QString& node) { */ ReFileSystem::ErrorCode ReCryptFileSystem::read(const ReFileMetaData& source, int64_t offset, int size, QByteArray& buffer) { + ReUseParameter(source); + ReUseParameter(offset); + ReUseParameter(size); + ReUseParameter(buffer); return EC_SUCCESS; } @@ -260,6 +264,7 @@ ReFileSystem::ErrorCode ReCryptFileSystem::read(const ReFileMetaData& source, */ ReFileSystem::ErrorCode ReCryptFileSystem::remove(const ReFileMetaData& node) { + ReUseParameter(node); return EC_SUCCESS; } @@ -272,6 +277,7 @@ ReFileSystem::ErrorCode ReCryptFileSystem::remove(const ReFileMetaData& node) */ ReFileSystem::ErrorCode ReCryptFileSystem::setDirectory(const QString& path) { + ReUseParameter(path); return EC_SUCCESS; } @@ -288,6 +294,9 @@ ReFileSystem::ErrorCode ReCryptFileSystem::setDirectory(const QString& path) ReFileSystem::ErrorCode ReCryptFileSystem::setProperties(const ReFileMetaData& source, ReFileMetaData& target, bool force) { + ReUseParameter(source); + ReUseParameter(target); + ReUseParameter(force); return EC_SUCCESS; } @@ -473,7 +482,7 @@ bool ReCryptDirectory::removeEntry(const QString& node) rc = ! m_logger->logv(LOG_ERROR, LOC_REMOVE_ENTRY_1, "cannot remove file %s: not found", I18N::s2b(node).constData()); else { - ReFileMetaData& entry2 = *(ReFileMetaData*) entry; + //ReFileMetaData& entry2 = *(ReFileMetaData*) entry; //@ToDo: //m_list.removeOne(entry2); assert(false); @@ -899,6 +908,8 @@ ReFileSystem::ErrorCode ReCryptLeafFile::close() */ ReFileSystem::ErrorCode ReCryptLeafFile::read(int size, QByteArray& buffer) { + ReUseParameter(size); + ReUseParameter(buffer); ReFileSystem::ErrorCode rc = ReFileSystem::EC_SUCCESS; return rc; -- 2.39.5