Skip to content
This repository has been archived by the owner on Sep 1, 2019. It is now read-only.

Commit

Permalink
implement export list of files
Browse files Browse the repository at this point in the history
closes #17
  • Loading branch information
mmozeiko committed Feb 27, 2017
1 parent 0dfa017 commit 7dcbc43
Show file tree
Hide file tree
Showing 10 changed files with 522 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set(UI
main_window.ui
remote_widget.ui
transfer_dialog.ui
export_dialog.ui
progress_dialog.ui
job_widget.ui
mount_widget.ui
Expand All @@ -23,6 +24,7 @@ set(MOC
main_window.h
remote_widget.h
transfer_dialog.h
export_dialog.h
progress_dialog.h
job_widget.h
mount_widget.h
Expand All @@ -43,6 +45,7 @@ set(SOURCE
main_window.cpp
remote_widget.cpp
transfer_dialog.cpp
export_dialog.cpp
progress_dialog.cpp
job_widget.cpp
mount_widget.cpp
Expand Down
129 changes: 129 additions & 0 deletions src/export_dialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#include "export_dialog.h"
#include "utils.h"

ExportDialog::ExportDialog(const QString& remote, const QDir& path, QWidget* parent)
: QDialog(parent)
{
ui.setupUi(this);
resize(0, 0);

mTarget = remote + ":" + path.path();

QObject::connect(ui.buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, this, [=]()
{
ui.rbText->setChecked(true);
ui.checkVerbose->setChecked(false);
ui.checkSameFilesystem->setChecked(false);
ui.textMinSize->clear();
ui.textMinAge->clear();
ui.textMaxAge->clear();
ui.spinMaxDepth->setValue(0);
ui.textExclude->clear();
ui.textExtra->clear();
});
ui.buttonBox->button(QDialogButtonBox::RestoreDefaults)->click();

QObject::connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
QObject::connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);

QObject::connect(ui.fileBrowse, &QToolButton::clicked, this, [=]()
{
QString file = QFileDialog::getSaveFileName(this, "Choose destination file");
if (!file.isEmpty())
{
ui.textFile->setText(QDir::toNativeSeparators(file));
}
});

QSettings settings;
settings.beginGroup("Export");
ReadSettings(&settings, this);
settings.endGroup();
}

ExportDialog::~ExportDialog()
{
if (result() == QDialog::Accepted)
{
QSettings settings;
settings.beginGroup("Export");
WriteSettings(&settings, this);
settings.remove("textFile");
settings.endGroup();
}
}

QString ExportDialog::getDestination() const
{
return ui.textFile->text();
}

bool ExportDialog::onlyFilenames() const
{
return ui.rbText->isChecked();
}

QStringList ExportDialog::getOptions() const
{
QStringList list;
list << "lsl";
if (ui.checkVerbose->isChecked())
{
list << "--verbose";
}
if (ui.checkSameFilesystem->isChecked())
{
list << "--one-file-system";
}
if (!ui.textMinSize->text().isEmpty())
{
list << "--min-size" << ui.textMinSize->text();
}
if (!ui.textMinAge->text().isEmpty())
{
list << "--min-age" << ui.textMinAge->text();
}
if (!ui.textMaxAge->text().isEmpty())
{
list << "--max-age" << ui.textMaxAge->text();
}
if (ui.spinMaxDepth->value() != 0)
{
list << "--max-depth" << ui.spinMaxDepth->text();
}

QString excluded = ui.textExclude->toPlainText().trimmed();
if (!excluded.isEmpty())
{
for (auto line : excluded.split('\n'))
{
list << "--exclude" << line;
}
}

QString extra = ui.textExtra->text().trimmed();
if (!extra.isEmpty())
{
for (auto arg : extra.split(' '))
{
list << arg;
}
}

list << mTarget;

return list;
}

void ExportDialog::done(int r)
{
if (r == QDialog::Accepted)
{
if (ui.textFile->text().isEmpty())
{
QMessageBox::warning(this, "Warning", "Please enter destination filename!");
return;
}
}
QDialog::done(r);
}
23 changes: 23 additions & 0 deletions src/export_dialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once

#include "pch.h"
#include "ui_export_dialog.h"

class ExportDialog : public QDialog
{
Q_OBJECT

public:
ExportDialog(const QString& remote, const QDir& path, QWidget* parent = nullptr);
~ExportDialog();

QString getDestination() const;
bool onlyFilenames() const;
QStringList getOptions() const;

private:
Ui::ExportDialog ui;
QString mTarget;

void done(int r) override;
};
Loading

0 comments on commit 7dcbc43

Please sign in to comment.