From: Hamatoma Date: Sun, 31 Jan 2016 22:59:50 +0000 (+0100) Subject: rebackgui: options: maxList + autoClear X-Git-Url: https://gitweb.hamatoma.de/?a=commitdiff_plain;h=d736ce29e837068d4ee250013e2db925525432ef;p=reqt rebackgui: options: maxList + autoClear --- diff --git a/appl/rebackgui/BackupEngine.cpp b/appl/rebackgui/BackupEngine.cpp index 5e7eadc..02dd33e 100644 --- a/appl/rebackgui/BackupEngine.cpp +++ b/appl/rebackgui/BackupEngine.cpp @@ -149,7 +149,8 @@ void SearchTask::searchOneDirectory(const QString& source, m_totalDirs++; m_mutex.unlock(); if (source.length() > lengthBase){ - prefix = QChar(1 + index) + source.mid(lengthBase) + OS_SEPARATOR_STR + prefix = QChar(1 + index) + + ReFileUtils::nativePath(source.mid(lengthBase)) + OS_SEPARATOR_STR + m_separator; } else { prefix = QChar(1 + index) + m_separatorString; @@ -506,15 +507,26 @@ void ChecksumOfTargetTask::run() error(QObject::tr("checksum differs: ") + relPath + node + " [" + sourceChecksum + "/" + checksum + "]"); } - now = QDateTime::currentMSecsSinceEpoch(); - qint64 estimated = (now - start) * m_hotBytes * 2 / max(1LL, m_processedBytes); + qint64 processedBytes, hotBytes; + int hotFiles, processedFiles; + m_mutex.lock(); + hotFiles = m_hotFiles; + hotBytes = m_hotBytes; + processedBytes = m_processedBytes; + processedFiles = m_processedFiles; + m_mutex.unlock(); + now = QDateTime::currentMSecsSinceEpoch(); + qint64 duration = (now - start); + qint64 estimated = qint64 ((double) duration * (double) hotBytes * 2.0 + / (double) max(1LL, processedBytes)); + qint64 rest = estimated - duration; m_mainWindow->externalAppend(ReGuiQueueItem::StatusLine, NULL, tr("%1 of %2 (%3 of %4) %5 MB/sec Remaining: %6 of %7") - .arg(m_processedFiles).arg(m_hotFiles * 2) - .arg(ReQStringUtils::readableSize(m_processedBytes)) - .arg(ReQStringUtils::readableSize(m_hotBytes * 2)) - .arg(m_processedBytes / 1024.0 / 1024 / (now - start) * 1000, 0, 'f', 3) - .arg(ReQStringUtils::readableDuration(estimated - (now - start))) + .arg(m_processedFiles).arg(hotFiles * 2) + .arg(ReQStringUtils::readableSize(processedBytes)) + .arg(ReQStringUtils::readableSize(hotBytes * 2)) + .arg(processedBytes / 1024.0 / 1024 / duration * 1000.0, 0, 'f', 3) + .arg(ReQStringUtils::readableDuration(rest)) .arg(ReQStringUtils::readableDuration(estimated))); } diff --git a/appl/rebackgui/mainwindow.cpp b/appl/rebackgui/mainwindow.cpp index 293657c..7f421f4 100644 --- a/appl/rebackgui/mainwindow.cpp +++ b/appl/rebackgui/mainwindow.cpp @@ -30,7 +30,8 @@ MainWindow::MainWindow(const QString& homeDir, QWidget *parent) : m_backupTask(NULL), m_checksumOfSourceTask(NULL), m_checksumOfTargetTask(NULL), - m_errors(0) + m_errors(0), + m_maxListSize(1000) { ui->setupUi(this); initializeGuiElements(); @@ -161,10 +162,14 @@ QString MainWindow::extractTarget(const QString& dir){ void MainWindow::onGuiTimerUpdate() { int count = m_guiQueue.count(); + QListWidget* list; while(count-- > 0){ m_mutexGuiQueue.lock(); ReGuiQueueItem item = m_guiQueue.popFront(); m_mutexGuiQueue.unlock(); + if (item.m_type == ReGuiQueueItem::ListEnd + && (list = reinterpret_cast(item.m_widget))->count() >= m_maxListSize) + delete list->takeItem(0); if (item.m_type == ReGuiQueueItem::Undef) break; if (! item.apply()){ @@ -196,8 +201,12 @@ void MainWindow::onGuiTimerUpdate() /** * Common initializations for all task starts. + * + * @return true: success
+ * otherwise: error occurred */ -void MainWindow::initializeStart(){ +bool MainWindow::initializeStart(){ + bool rc = true; BackupEngine::m_searchReady = false; BackupEngine::m_hotBytes = 0; BackupEngine::m_hotFiles = 0; @@ -207,8 +216,18 @@ void MainWindow::initializeStart(){ BackupEngine::m_processedFiles = 0; BackupEngine::m_processedBytes = 0; ChecksumTask::m_sourceProcessingReady = false; + if ( (m_maxListSize = comboInt(ui->comboBoxMaxListLength, -999)) == -999){ + rc = false; + m_maxListSize = 100; + ui->comboBoxMaxListLength->setEditText(QString::number(m_maxListSize)); + } m_errors = 0; startStop(true); + if (ui->checkBoxAutoClean->isChecked()){ + onClearFileList(); + onClearErrorList(); + } + return rc; } /** diff --git a/appl/rebackgui/mainwindow.hpp b/appl/rebackgui/mainwindow.hpp index 9e2163b..2913641 100644 --- a/appl/rebackgui/mainwindow.hpp +++ b/appl/rebackgui/mainwindow.hpp @@ -38,7 +38,7 @@ public: public slots: private: QString extractTarget(const QString& dir); - void initializeStart(); + bool initializeStart(); void writeTargetConfiguration(BackupItem& item, const QString& target); private slots: void onAbout(); @@ -74,6 +74,7 @@ private: ChecksumOfSourceTask* m_checksumOfSourceTask; ChecksumOfTargetTask* m_checksumOfTargetTask; int m_errors; + int m_maxListSize; }; #endif // MAINWINDOW_HPP diff --git a/appl/rebackgui/mainwindow.ui b/appl/rebackgui/mainwindow.ui index c62cbfb..627650b 100644 --- a/appl/rebackgui/mainwindow.ui +++ b/appl/rebackgui/mainwindow.ui @@ -7,7 +7,7 @@ 0 0 820 - 679 + 662 @@ -73,6 +73,87 @@ + + + + + + + 125 + 0 + + + + Options: + + + + + + + + 125 + 0 + + + + Max. list length: + + + + + + + + 125 + 0 + + + + Max. length of the file list / error list. 0: unlimited + + + true + + + 100 + + + + + + + + 125 + 0 + + + + Starting a task cleans filelist and errorlist + + + Start cleans + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + diff --git a/base/ReFileUtils.cpp b/base/ReFileUtils.cpp index e1bcf51..16fb242 100644 --- a/base/ReFileUtils.cpp +++ b/base/ReFileUtils.cpp @@ -485,9 +485,11 @@ bool ReFileUtils::makeDir(const char* path, ReLogger* logger) { bool rc = true; if (stat(path, &info) != 0) { rc = _mkdir(path) == 0; - if (!rc && logger != NULL) - logger->log(LOG_ERROR, LOC_MAKE_DIR_1, - QObject::tr("can't create directory (%1): %2").arg(errno).arg(path)); + if (!rc){ + if (logger != NULL) + logger->log(LOG_ERROR, LOC_MAKE_DIR_1, + QObject::tr("can't create directory (%1): %2").arg(errno).arg(path)); + } } else if (!S_ISDIR(info.st_mode)) { rc = false; if (logger != NULL) diff --git a/gui/ReGuiApplication.cpp b/gui/ReGuiApplication.cpp index 1fc1523..f80c676 100644 --- a/gui/ReGuiApplication.cpp +++ b/gui/ReGuiApplication.cpp @@ -40,7 +40,7 @@ ReGuiApplication::ReGuiApplication(const char* applicationName, m_guiQueue(), m_guiTimer(new QTimer(this)), m_statusMessage(new QLabel(tr("Welcome!"))), - m_mutexGuiQueue() + m_mutexGuiQueue() { m_logger.buildStandardAppender(I18N::s2b(m_homeDir) + applicationName, maxLogSize, maxLogFiles); diff --git a/gui/ReGuiQueue.cpp b/gui/ReGuiQueue.cpp index da230a0..2a1a345 100644 --- a/gui/ReGuiQueue.cpp +++ b/gui/ReGuiQueue.cpp @@ -16,7 +16,7 @@ * Constructor. */ ReGuiQueue::ReGuiQueue() : - QVector(), + QList(), m_locker() { } @@ -96,7 +96,8 @@ bool ReGuiQueueItem::apply() const { QListWidget* list = reinterpret_cast(m_widget); list->addItem(m_value); - list->setCurrentRow(list->count() - 1); + int count = list->count(); + list->setCurrentRow(count - 1); break; } case ListAppendToCurrent: diff --git a/gui/ReGuiQueue.hpp b/gui/ReGuiQueue.hpp index 97dd4c9..33613d7 100644 --- a/gui/ReGuiQueue.hpp +++ b/gui/ReGuiQueue.hpp @@ -72,7 +72,7 @@ public: * Qt allows manipulating GUI elements only in the main thread. * This queue allows the exchange of information from other threads. */ -class ReGuiQueue : protected QVector +class ReGuiQueue : protected QList { public: ReGuiQueue();