summaryrefslogtreecommitdiff
path: root/plugins/CopyEngine/Ultracopier/FileExistsDialog.cpp
diff options
context:
space:
mode:
authorThomas Preud'homme <robotux@celest.fr>2018-02-23 23:49:48 +0000
committerThomas Preud'homme <robotux@celest.fr>2018-02-23 23:49:48 +0000
commitbd56579c7d9de94c17287adefa118290e6b7ba33 (patch)
tree666d7d0b6945b442573b7a3145969f66a53aa460 /plugins/CopyEngine/Ultracopier/FileExistsDialog.cpp
parentb3c8bdcc0d1e4b2ab298847a7902b6d60410a5bc (diff)
New upstream version 1.4.0.3
Diffstat (limited to 'plugins/CopyEngine/Ultracopier/FileExistsDialog.cpp')
-rw-r--r--plugins/CopyEngine/Ultracopier/FileExistsDialog.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/plugins/CopyEngine/Ultracopier/FileExistsDialog.cpp b/plugins/CopyEngine/Ultracopier/FileExistsDialog.cpp
index 0e3ca78..91df1f8 100644
--- a/plugins/CopyEngine/Ultracopier/FileExistsDialog.cpp
+++ b/plugins/CopyEngine/Ultracopier/FileExistsDialog.cpp
@@ -2,11 +2,17 @@
#include "ui_fileExistsDialog.h"
#include "TransferThread.h"
+#ifdef Q_OS_WIN32
+#define CURRENTSEPARATOR "\\"
+#else
+#define CURRENTSEPARATOR "/"
+#endif
+
#include <QRegularExpression>
#include <QFileInfo>
#include <QMessageBox>
-FileExistsDialog::FileExistsDialog(QWidget *parent,QFileInfo source,QFileInfo destination,QString firstRenamingRule,QString otherRenamingRule) :
+FileExistsDialog::FileExistsDialog(QWidget *parent, QFileInfo source, QFileInfo destination, std::string firstRenamingRule, std::string otherRenamingRule) :
QDialog(parent),
ui(new Ui::fileExistsDialog)
{
@@ -21,20 +27,20 @@ FileExistsDialog::FileExistsDialog(QWidget *parent,QFileInfo source,QFileInfo de
action=FileExists_Cancel;
destinationInfo=destination;
oldName=TransferThread::resolvedName(destination);
- ui->lineEditNewName->setText(oldName);
- ui->lineEditNewName->setPlaceholderText(oldName);
+ ui->lineEditNewName->setText(QString::fromStdString(oldName));
+ ui->lineEditNewName->setPlaceholderText(QString::fromStdString(oldName));
ui->Overwrite->addAction(ui->actionOverwrite_if_newer);
ui->Overwrite->addAction(ui->actionOverwrite_if_not_same_modification_date);
ui->label_content_source_size->setText(QString::number(source.size()));
ui->label_content_source_modified->setText(source.lastModified().toString());
- ui->label_content_source_file_name->setText(TransferThread::resolvedName(source));
+ ui->label_content_source_file_name->setText(QString::fromStdString(TransferThread::resolvedName(source)));
QString folder=source.absolutePath();
if(folder.size()>80)
folder=folder.mid(0,38)+"..."+folder.mid(folder.size()-38);
ui->label_content_source_folder->setText(folder);
ui->label_content_destination_size->setText(QString::number(destination.size()));
ui->label_content_destination_modified->setText(destination.lastModified().toString());
- ui->label_content_destination_file_name->setText(TransferThread::resolvedName(destination));
+ ui->label_content_destination_file_name->setText(QString::fromStdString(TransferThread::resolvedName(destination)));
folder=destination.absolutePath();
if(folder.size()>80)
folder=folder.mid(0,38)+"..."+folder.mid(folder.size()-38);
@@ -98,19 +104,19 @@ void FileExistsDialog::changeEvent(QEvent *e)
}
}
-QString FileExistsDialog::getNewName()
+std::string FileExistsDialog::getNewName()
{
- if(oldName==ui->lineEditNewName->text() || ui->checkBoxAlways->isChecked())
+ if(oldName==ui->lineEditNewName->text().toStdString() || ui->checkBoxAlways->isChecked())
return oldName;
else
- return ui->lineEditNewName->text();
+ return ui->lineEditNewName->text().toStdString();
}
void FileExistsDialog::on_SuggestNewName_clicked()
{
QFileInfo destinationInfo=this->destinationInfo;
QString absolutePath=destinationInfo.absolutePath();
- QString fileName=TransferThread::resolvedName(destinationInfo);
+ QString fileName=QString::fromStdString(TransferThread::resolvedName(destinationInfo));
QString suffix="";
QString destination;
QString newFileName;
@@ -127,26 +133,26 @@ void FileExistsDialog::on_SuggestNewName_clicked()
{
if(num==1)
{
- if(firstRenamingRule==QStringLiteral(""))
+ if(firstRenamingRule.empty())
newFileName=tr("%1 - copy").arg(fileName);
else
{
- newFileName=firstRenamingRule;
+ newFileName=QString::fromStdString(firstRenamingRule);
newFileName.replace("%name%",fileName);
}
}
else
{
- if(otherRenamingRule=="")
+ if(otherRenamingRule.empty())
newFileName=tr("%1 - copy (%2)").arg(fileName).arg(num);
else
{
- newFileName=otherRenamingRule;
+ newFileName=QString::fromStdString(otherRenamingRule);
newFileName.replace(QStringLiteral("%name%"),fileName);
newFileName.replace(QStringLiteral("%number%"),QString::number(num));
}
}
- destination=absolutePath+QDir::separator()+newFileName+suffix;
+ destination=absolutePath+CURRENTSEPARATOR+newFileName+suffix;
destinationInfo.setFile(destination);
num++;
}
@@ -202,7 +208,7 @@ bool FileExistsDialog::getAlways()
void FileExistsDialog::updateRenameButton()
{
- ui->Rename->setEnabled(ui->checkBoxAlways->isChecked() || (!ui->lineEditNewName->text().contains(QRegularExpression("[/\\\\\\*]")) && oldName!=ui->lineEditNewName->text() && !ui->lineEditNewName->text().isEmpty()));
+ ui->Rename->setEnabled(ui->checkBoxAlways->isChecked() || (!ui->lineEditNewName->text().contains(QRegularExpression("[/\\\\\\*]")) && oldName!=ui->lineEditNewName->text().toStdString() && !ui->lineEditNewName->text().isEmpty()));
}
void FileExistsDialog::on_checkBoxAlways_toggled(bool checked)