From 010649f997e894c6a782cfb309b5d5931c2b69e5 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 17 May 2016 10:49:57 +0200 Subject: [PATCH] FolderWizard: remove dead code and fix the alias Remove a bunch of dead code. And also set the root folder name properly since alias is gone. Fix the warning: QWizard::field: No such field 'alias' --- src/gui/folderwizard.cpp | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/gui/folderwizard.cpp b/src/gui/folderwizard.cpp index 60e3fe581..6fcc19206 100644 --- a/src/gui/folderwizard.cpp +++ b/src/gui/folderwizard.cpp @@ -68,13 +68,6 @@ FolderWizardLocalPath::FolderWizardLocalPath() _ui.localFolderLineEdit->setText( QDir::toNativeSeparators( defaultPath ) ); _ui.localFolderLineEdit->setToolTip(tr("Enter the path to the local folder.")); - QString newAlias = Theme::instance()->appName(); - int count = 0; - while (FolderMan::instance()->folder(newAlias)) { - // There is already a folder configured with this name and folder names need to be unique - newAlias = Theme::instance()->appName() + QString::number(++count); - } - _ui.warnLabel->setTextFormat(Qt::RichText); _ui.warnLabel->hide(); } @@ -135,14 +128,6 @@ void FolderWizardLocalPath::slotChooseLocalFolder() if (!dir.isEmpty()) { // set the last directory component name as alias _ui.localFolderLineEdit->setText(QDir::toNativeSeparators(dir)); - - QDir pickedDir(dir); - QString newAlias = pickedDir.dirName(); - int count = 0; - while (FolderMan::instance()->folder(newAlias)) { - // There is already a folder configured with this name and folder names need to be unique - newAlias = pickedDir.dirName() + QString::number(++count); - } } emit completeChanged(); } @@ -503,11 +488,13 @@ FolderWizardSelectiveSync::~FolderWizardSelectiveSync() void FolderWizardSelectiveSync::initializePage() { - QString alias = wizard()->field(QLatin1String("alias")).toString(); QString targetPath = wizard()->property("targetPath").toString(); if (targetPath.startsWith('/')) { targetPath = targetPath.mid(1); } + QString alias = QFileInfo(targetPath).fileName(); + if (alias.isEmpty()) + alias = Theme::instance()->appName(); _treeView->setFolderInfo(targetPath, alias); QWizardPage::initializePage(); } @@ -520,8 +507,10 @@ bool FolderWizardSelectiveSync::validatePage() void FolderWizardSelectiveSync::cleanupPage() { - QString alias = wizard()->field(QLatin1String("alias")).toString(); QString targetPath = wizard()->property("targetPath").toString(); + QString alias = QFileInfo(targetPath).fileName(); + if (alias.isEmpty()) + alias = Theme::instance()->appName(); _treeView->setFolderInfo(targetPath, alias); QWizardPage::cleanupPage(); } -- 2.39.5