* More info: http://unlicense.org
* The latest sources: https://github.com/republib
*/
-#include "backupgui.hpp"\r
-\r
-BackupUtils::BackupUtils()\r
-{\r
-\r
-}\r
-/**\r
- * Converts a date time to a string.\r
- *\r
- * @param dateTime the timepoint to convert\r
- * @return the string representation\r
- */\r
-QString BackupUtils::dateToString(const QDateTime &dateTime)\r
-{\r
- QString rc = dateTime.toString("yyyy.MM.dd/hh:mm:ss");\r
- return rc;\r
-}\r
-\r
-/**\r
- * Finds the real path of a target directory.\r
- *\r
- * Note: if the medium of the target is an external medium\r
- * the path can change.\r
- *\r
- * @param item the info about the backup item\r
- * @return "": not found<br>\r
- * otherwise: the full path of the target directory\r
- */\r
-QString BackupUtils::findTarget(const BackupItem& item, ReLogger* logger)\r
-{\r
- QString rc;\r
-#if defined __linux__\r
- if (item.m_target.startsWith(";/")){\r
- // the path is an absolute path on a fixed disk:\r
- rc = item.m_target.mid(1);\r
- } else {\r
-\r
- }\r
-#elif defined _WIN32\r
- QStringList drives = ReFileUtils::findRootDirs();\r
- QStringList::const_iterator it;\r
- for (it = drives.cbegin(); it != drives.cend(); ++it){\r
- QString path = *it;\r
- ReQStringUtils::ensureLastChar(path, OS_SEPARATOR);\r
- int pos = item.m_target.indexOf(';');\r
- if (pos >= 0)\r
- path += item.m_target.mid(pos + 1);\r
- else\r
- path += item.m_target;\r
- QString markerFile = nameOfTargetDescription(path);\r
- if (QFileInfo(markerFile).exists()){\r
- if (rc.isEmpty())\r
- rc = ReFileUtils::parentOf(markerFile);\r
- ReConfig config(I18N::s2b(markerFile), true, logger);\r
- if (! config.asString((item.m_uid + ".created").toLatin1(),\r
- "").isEmpty()){\r
- rc = ReFileUtils::parentOf(markerFile);\r
- break;\r
- }\r
- }\r
- }\r
-#endif\r
- return rc;\r
-}\r
-\r
-/**\r
- * Returns the name of the file marking a backup target.\r
- *\r
- * @param path the path of the file\r
- * @return the full name of the file\r
- */\r
-QString BackupUtils::nameOfTargetDescription(const QString& path){\r
- QString fname = path;\r
- ReQStringUtils::ensureLastChar(fname, OS_SEPARATOR);\r
- fname += ".rebackgui.target";\r
- return fname;\r
-}\r
-\r
-/**\r
- * Prepares the target base directory.\r
- *\r
- * Creates a file. The program uses this file to recognize a target directory.\r
- *\r
- * @param path the target base directory\r
- * @param item the info about the backup item\r
- * @param logger the logger\r
- * @return <code>true</code>: target is already initialized\r
- */\r
-bool BackupUtils::prepareTarget(const QString& path, BackupItem &item,\r
- ReLogger* logger)\r
-{\r
- bool rc = false;\r
- QString fname = nameOfTargetDescription(path);\r
- ReConfig config(I18N::s2b(fname), false, logger);\r
- QByteArray key = item.m_uid.toLatin1() + ".created";\r
- if (config.asString(key.constData(), "").isEmpty()){\r
- config.put(key, dateToString(QDateTime::currentDateTime()).toLatin1().constData());\r
- rc = true;\r
- }\r
- return rc;\r
-}\r
-\r
-/**\r
- * Converts a string into a date time.\r
- *\r
- * @param dateTime the string convert\r
- * @return the date time\r
- */\r
-QDateTime BackupUtils::stringToDate(const QString &dateTime)\r
-{\r
- QDateTime rc;\r
- rc.fromString(dateTime, "yyyy.MM.dd/hh:mm:ss");\r
- return rc;\r
-}\r
-\r
-\r
+#include "backupgui.hpp"
+
+BackupUtils::BackupUtils()
+{
+
+}
+/**
+ * Converts a date time to a string.
+ *
+ * @param dateTime the timepoint to convert
+ * @return the string representation
+ */
+QString BackupUtils::dateToString(const QDateTime &dateTime)
+{
+ QString rc = dateTime.toString("yyyy.MM.dd/hh:mm:ss");
+ return rc;
+}
+
+/**
+ * Finds the real path of a target directory.
+ *
+ * Note: if the medium of the target is an external medium
+ * the path can change.
+ *
+ * @param item the info about the backup item
+ * @return "": not found<br>
+ * otherwise: the full path of the target directory
+ */
+QString BackupUtils::findTarget(const BackupItem& item, ReLogger* logger)
+{
+ QString rc;
+#if defined __linux__
+ if (item.m_target.startsWith(";/")){
+ // the path is an absolute path on a fixed disk:
+ rc = item.m_target.mid(1);
+ } else {
+
+ }
+#elif defined _WIN32
+ QStringList drives = ReFileUtils::findRootDirs();
+ QStringList::const_iterator it;
+ for (it = drives.cbegin(); it != drives.cend(); ++it){
+ QString path = *it;
+ ReQStringUtils::ensureLastChar(path, OS_SEPARATOR);
+ int pos = item.m_target.indexOf(';');
+ if (pos >= 0)
+ path += item.m_target.mid(pos + 1);
+ else
+ path += item.m_target;
+ QString markerFile = nameOfTargetDescription(path);
+ if (QFileInfo(markerFile).exists()){
+ if (rc.isEmpty())
+ rc = ReFileUtils::parentOf(markerFile);
+ ReConfig config(I18N::s2b(markerFile), true, logger);
+ if (! config.asString((item.m_uid + ".created").toLatin1(),
+ "").isEmpty()){
+ rc = ReFileUtils::parentOf(markerFile);
+ break;
+ }
+ }
+ }
+#endif
+ return rc;
+}
+
+/**
+ * Returns the name of the file marking a backup target.
+ *
+ * @param path the path of the file
+ * @return the full name of the file
+ */
+QString BackupUtils::nameOfTargetDescription(const QString& path){
+ QString fname = path;
+ ReQStringUtils::ensureLastChar(fname, OS_SEPARATOR);
+ fname += ".rebackgui.target";
+ return fname;
+}
+
+/**
+ * Prepares the target base directory.
+ *
+ * Creates a file. The program uses this file to recognize a target directory.
+ *
+ * @param path the target base directory
+ * @param item the info about the backup item
+ * @param logger the logger
+ * @return <code>true</code>: target is already initialized
+ */
+bool BackupUtils::prepareTarget(const QString& path, BackupItem &item,
+ ReLogger* logger)
+{
+ bool rc = false;
+ QString fname = nameOfTargetDescription(path);
+ ReConfig config(I18N::s2b(fname), false, logger);
+ QByteArray key = item.m_uid.toLatin1() + ".created";
+ if (config.asString(key.constData(), "").isEmpty()){
+ config.put(key, dateToString(QDateTime::currentDateTime()).toLatin1().constData());
+ rc = true;
+ }
+ return rc;
+}
+
+/**
+ * Converts a string into a date time.
+ *
+ * @param dateTime the string convert
+ * @return the date time
+ */
+QDateTime BackupUtils::stringToDate(const QString &dateTime)
+{
+ QDateTime rc = QDateTime::fromString(dateTime, "yyyy.MM.dd/hh:mm:ss");
+ return rc;
+}
+
+
SLOT(onStart()));
connect(ui->actionChecksums, SIGNAL(triggered()), this,
SLOT(onChecksums()));
+ connect(ui->actionClean, SIGNAL(triggered()), this,
+ SLOT(onClean()));
connect(ui->actionStop, SIGNAL(triggered()), this,
SLOT(onStop()));
connect(ui->pushButtonBackup, SIGNAL(clicked()), this, SLOT(onStart()));
* otherwise: error occurred
*/
bool MainWindow::initializeStart(){
- setStatusMessage(LOG_INFO, QObject::tr("Search started..."));
+ setStatusMessage(LOG_INFO, QObject::tr("Search started..."));
bool rc = true;
- BackupEngine::m_shouldStop = false;
- BackupEngine::m_searchReady = false;
- BackupEngine::m_hotBytes = 0;
+ BackupEngine::m_shouldStop = false;
+ BackupEngine::m_searchReady = false;
+ BackupEngine::m_hotBytes = 0;
BackupEngine::m_hotFiles = 0;
BackupEngine::m_matchedFiles = 0;
BackupEngine::m_totalDirs = 0;
item.m_sources.append(ui->listWidgetSource->item(ix)->text());
}
updateTable();
- saveState();
+ saveState();
}
/**
*/
void MainWindow::onVerboseIndexChanged(int index)
{
- BackupEngine::m_verboseLevel = (ReVerbose_t) index;
+ BackupEngine::m_verboseLevel = (ReVerbose_t) index;
}
/**
ui->actionStop->setEnabled(isStart);
ui->pushButtonBackup->setEnabled(! isStart);
ui->pushButtonStop->setEnabled(isStart);
- ui->pushButtonChecksum->setEnabled(! isStart);
- ui->pushButtonClean->setEnabled(! isStart);
- ui->actionChecksums->setEnabled(! isStart);
+ ui->pushButtonChecksum->setEnabled(! isStart);
+ ui->pushButtonClean->setEnabled(! isStart);
+ ui->actionChecksums->setEnabled(! isStart);
+ ui->actionClean->setEnabled(! isStart);
if (isStart)
BackupEngine::m_verboseLevel = (ReVerbose_t) ui->comboBoxVerbose->currentIndex();
}
updateTableRow(row, item, ui->tableWidgetConfiguration);
} else {
int base = target == ui->tableWidget ? 1 : 0;
+ QString active = QObject::tr(item.m_active ? "yes" : "no");
+ if (base == 1)
+ target->setItem(row, 0, new QTableWidgetItem(active));
target->setItem(row, base + 0, new QTableWidgetItem(item.m_name));
target->setItem(row, base + 1, new QTableWidgetItem(item.m_target));
target->setItem(row, base + 2, new QTableWidgetItem(! item.m_lastBackup.isValid() ? "" :