From b65ab2398dcbc2f5c9b1ec33ac0bbf863e3df0ca Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 13 Oct 2018 05:10:14 +0200 Subject: Print destination file when adding sources Use a function to generate the path, so we can reuse it when actually copying files :) --- copydialog.cpp | 20 ++++++++++++++++++++ copydialog.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/copydialog.cpp b/copydialog.cpp index 38a5b9f..f16fda0 100644 --- a/copydialog.cpp +++ b/copydialog.cpp @@ -81,6 +81,26 @@ void CopyDialog::setDestFolder(const QString &dst){ void CopyDialog::setSources(const QStringList &sources){ mSources = sources; + refresh(); +} + +void CopyDialog::refresh(){ + QString res; + for(const QString &p : mSources){ + res.append(QString("%1 %2\n").arg(QChar(0x2b9a)).arg(p)); + res.append(QString("%1 %2\n").arg(QChar(0x2b98)).arg(getDestinationFile(p))); + } + mResultL->setText(res); +} + +QString CopyDialog::getDestinationFile(const QString &srcFn){ + QFileInfo fi(srcFn); + if(fi.exists()){ + QString fn = fi.fileName(); + QString destPath = QString("%1/%2/%3").arg(mDstE->text()).arg(mFolderE->text()).arg(fn); + return destPath; + } + return QString(); } void CopyDialog::closeEvent(QCloseEvent *e){ diff --git a/copydialog.h b/copydialog.h index 8a32372..0eed637 100644 --- a/copydialog.h +++ b/copydialog.h @@ -16,8 +16,11 @@ class CopyDialog : public QDialog { void setSource(const QString &src); void setDestFolder(const QString &dst); void setSources(const QStringList &sources); + void refresh(); + protected: + QString getDestinationFile(const QString &srcFn); virtual void closeEvent(QCloseEvent *e); private: -- cgit v1.2.3-70-g09d2