bool isFile;
if (! ReFileUtils::isDirectory(targetDir, &isFile)){
if (isFile){
- if (unlink(I18N::s2b(targetDir).constData()) != 0)
+ if (_unlink(I18N::s2b(targetDir).constData()) != 0)
error(tr("cannot remove file (for making a directory (%1): %2")
.arg(errno).arg(targetDir));
}
.arg(ReQStringUtils::readableDuration(estimated)));
}
}
- m_mainWindow->externalTaskFinished(tr("backup complete after ")
- + ReQStringUtils::readableDuration(
- QDateTime::currentMSecsSinceEpoch() - start));
+ m_mainWindow->externalTaskFinished(tr("backup complete after %1. Errors: %2")
+ .arg(ReQStringUtils::readableDuration(
+ QDateTime::currentMSecsSinceEpoch() - start))
+ .arg(m_mainWindow->errors()));
}
#include "aboutdialog.hpp"
#include <QFileDialog>
-const QString VERSION("2016.01.20");
+const QString VERSION("2016.01.30");
/**
* Constructor.
m_currentRowBackup(0),
m_lastSource(),
m_searchTask(NULL),
- m_backupTask(NULL)
+ m_backupTask(NULL),
+ m_errors(0)
{
ui->setupUi(this);
initializeGuiElements();
bool MainWindow::error(const QString& message){
ui->listWidgetError->addItem(message);
ui->listWidgetError->setCurrentRow(ui->listWidgetError->count() - 1);
+ m_errors++;
return false;
}
* Handles the push of the button "select directory".
*/
void MainWindow::onAddSource(){
- QString dir = QFileDialog::getExistingDirectory(this,
- tr("Select Source Directory"), m_lastSource,
- QFileDialog::ShowDirsOnly);
- if (!dir.isEmpty()){
- m_lastSource = ReFileUtils::nativePath(dir);
- ui->listWidgetSource->addItem(m_lastSource);
+ QFileDialog dialog(NULL);
+ dialog.setOption(QFileDialog::ShowDirsOnly, true);
+ // native dialog does not support multiselection:
+ dialog.setOption(QFileDialog::DontUseNativeDialog,true);
+ dialog.setFileMode(QFileDialog::Directory);
+ dialog.setWindowTitle(tr("Select Source Directory"));
+ dialog.setDirectory(ReFileUtils::parentOf(m_lastSource));
+ QListView *listView = dialog.findChild<QListView*>("listView");
+ if (listView) {
+ listView->setSelectionMode(QAbstractItemView::MultiSelection);
+ }
+ QTreeView *treeView = dialog.findChild<QTreeView*>();
+ if (treeView) {
+ treeView->setSelectionMode(QAbstractItemView::MultiSelection);
+ }
+
+ if (dialog.exec()){
+ QStringList dirs = dialog.selectedFiles();
+ if (dirs.size() > 0){
+ m_lastSource = ReFileUtils::nativePath(dirs.at(0));
+ for (int ix = 0; ix < dirs.size(); ix++){
+ QString newEntry = ReFileUtils::nativePath(dirs.at(ix));
+ bool found = false;
+ for (int ix2 = 0; ! found && ix2 < ui->listWidgetSource->count(); ix2++){
+ QString oldEntry = ui->listWidgetSource->item(ix2)->text();
+ if (oldEntry.isEmpty()){
+ ui->listWidgetSource->takeItem(ix2);
+ ix2--;
+ }
+ found = oldEntry == newEntry;
+ }
+ if (! found)
+ ui->listWidgetSource->addItem(newEntry);
+ }
+ }
}
}
BackupEngine::m_totalFiles = 0;
BackupEngine::m_processedFiles = 0;
BackupEngine::m_processedBytes = 0;
-
+ m_errors = 0;
QString target = BackupUtils::findTarget(item, &m_logger);
if (target.isEmpty()){
say(LOG_ERROR, tr("Target not available"));
*/
void MainWindow::updateItem(int index){
m_currentRowConfiguration = index;
- BackupItem& item = m_configuration.items()[index];
- ui->lineEditName->setText(item.m_name);
- ui->lineEditTarget->setText(item.m_target);
- ui->listWidgetSource->clear();
- ui->comboBoxFilePatterns->setEditText(item.m_filePatterns);
- ui->comboBoxDirPatterns->setEditText(item.m_dirPatterns);
- for (int ix = 0; ix < item.m_sources.size(); ix++){
- ui->listWidgetSource->insertItem(ix, m_lastSource = item.m_sources.at(ix));
- }
+ if (index < m_configuration.items().size()){
+ BackupItem& item = m_configuration.items()[index];
+ ui->lineEditName->setText(item.m_name);
+ ui->lineEditTarget->setText(item.m_target);
+ ui->listWidgetSource->clear();
+ ui->comboBoxFilePatterns->setEditText(item.m_filePatterns);
+ ui->comboBoxDirPatterns->setEditText(item.m_dirPatterns);
+ for (int ix = 0; ix < item.m_sources.size(); ix++){
+ ui->listWidgetSource->insertItem(ix, m_lastSource = item.m_sources.at(ix));
+ }
+ }
}
/**
target->setItem(row, base + 3, new QTableWidgetItem(item.m_sources.join(" ")));
}
}
+int MainWindow::errors() const
+{
+ return m_errors;
+}
+
* @return the permissions used by linux,
* e.G. <code>S_IRUSR | S_IWGRP</code>
*/
-mode_t ReFileUtils::linuxPermissions(QFile::Permissions permissions){
+mode_t ReFileUtils::nativePermissions(QFile::Permissions permissions){
mode_t rc = 0;
+#if defined __linux__
if (permissions.testFlag(QFile::ReadOwner))
rc |= S_IRUSR;
if (permissions.testFlag(QFile::ReadGroup))
rc |= S_IXGRP;
if (permissions.testFlag(QFile::ExeOther))
rc |= S_IXOTH;
+#elif defined _WIN32
+ if (permissions.testFlag(QFile::ReadOwner) || permissions.testFlag(QFile::ReadOther))
+ rc |= _S_IREAD;
+ if (permissions.testFlag(QFile::ReadOwner) ||permissions.testFlag(QFile::WriteOther))
+ rc |= _S_IWRITE;
+#endif
return rc;
}
else {
const char* end;
const char* start = path;
+ rc = true;
+ dir.clear();
while (rc && (end = strchr(start, OS_SEPARATOR)) != NULL) {
if (end == path) {
start++;
dir.append(start, end - start);
start = end + 1;
#if defined _WIN32
- if (dir.length() == 2 && dir.at(1) == ':')
+ if (dir.length() == 2 && dir.at(1) == ':'){
+ dir.append(OS_SEPARATOR);
continue;
+ }
#endif
rc = makeDir(dir.constData(), logger);
dir += OS_SEPARATOR;
bool ReFileUtils::setPermissions(const char* filename,
QFile::Permissions permissions, ReLogger* logger) {
bool rc = true;
- if (chmod(filename, linuxPermissions(permissions)) != 0){
+ if (chmod(filename, nativePermissions(permissions)) != 0){
if (logger != NULL)
logger->logv(LOG_ERROR, LOC_SET_TIMES_1,
"cannot change permissions (%d): $s", errno, filename);