From 3e1573e6b4e8fa2f2b666ad6cb2d9ea241b7bc99 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 12 Jan 2018 04:27:11 +0100 Subject: [PATCH] Ref T199, improved copy dialog * filter disabling or hiding can be toggled * bootstrap file can be shown/hidden * fixed naming typo "setCacheMode" --- .../components/copyconfigurationcomponent.cpp | 47 ++++++++++++++----- .../components/copyconfigurationcomponent.h | 13 +++++ .../components/copyconfigurationcomponent.ui | 7 +++ .../components/copyconfigurationdialog.cpp | 12 ++++- .../components/copyconfigurationdialog.h | 8 +++- .../components/setuploadingdialog.cpp | 3 +- 6 files changed, 76 insertions(+), 14 deletions(-) diff --git a/src/blackgui/components/copyconfigurationcomponent.cpp b/src/blackgui/components/copyconfigurationcomponent.cpp index b55da084a..8b7b45c20 100644 --- a/src/blackgui/components/copyconfigurationcomponent.cpp +++ b/src/blackgui/components/copyconfigurationcomponent.cpp @@ -45,13 +45,15 @@ namespace BlackGui ui->setupUi(this); this->initOtherSwiftVersions(); + ui->cb_ShowAll->setChecked(m_nameFilterDisables); connect(ui->rb_Cache, &QRadioButton::toggled, [ = ](bool) { this->initCurrentDirectories(true); }); connect(ui->cb_OtherVersions, &QComboBox::currentTextChanged, [ = ] { this->initCurrentDirectories(true); }); connect(ui->pb_SelectAll, &QPushButton::clicked, ui->tv_Source, &QTreeView::selectAll); connect(ui->pb_ClearSelection, &QPushButton::clicked, ui->tv_Source, &QTreeView::clearSelection); connect(ui->pb_CopyOver, &QPushButton::clicked, this, &CCopyConfigurationComponent::copySelectedFiles); + connect(ui->cb_ShowAll, &QCheckBox::released, this, &CCopyConfigurationComponent::changeNameFilterDisables); - // create default caches with timestamps + // create default caches with timestamps on disk // possible for small caches, but not the large model sets (too slow) m_modelSetCurrentSimulator.synchronize(); m_modelSetCurrentSimulator.set(m_modelSetCurrentSimulator.get()); @@ -166,7 +168,15 @@ namespace BlackGui "modelcache*.json", "*setup.json" }); - return cacheFilter; + if (!m_withBootstrapFile) { return cacheFilter; } + + static const QStringList cacheFilterBs = [ = ] + { + QStringList f(cacheFilter); + f.push_back(CDirectoryUtils::bootstrapFileName()); + return f; + }(); + return cacheFilterBs; } else { @@ -178,7 +188,11 @@ namespace BlackGui void CCopyConfigurationComponent::initCurrentDirectories(bool preselectMissingOrOutdated) { const QString destinationDir = this->getThisVersionDirectory(); // cache or settings dir - if (m_initializedDestinationDir != destinationDir) + + QFileSystemModel *destinationModel = qobject_cast(ui->tv_Destination->model()); + QFileSystemModel *sourceModel = qobject_cast(ui->tv_Source->model()); + + if (!destinationModel || m_initializedDestinationDir != destinationDir) { m_initializedDestinationDir = destinationDir; const QDir thisVersionDirectory(destinationDir); @@ -194,13 +208,10 @@ namespace BlackGui ui->le_CurrentVersion->setText(destinationDir); // destination - QFileSystemModel *destinationModel = qobject_cast(ui->tv_Destination->model()); if (!destinationModel) { destinationModel = new QFileSystemModel(this); - destinationModel->setNameFilterDisables(true); destinationModel->setFilter(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs); - destinationModel->setNameFilters(this->getSourceFileFilter()); ui->tv_Destination->setModel(destinationModel); ui->tv_Destination->setSortingEnabled(true); @@ -215,19 +226,19 @@ namespace BlackGui const QModelIndex destinationIndex = destinationModel->setRootPath(destinationDir); ui->tv_Destination->setRootIndex(destinationIndex); } + destinationModel->setNameFilters(this->getSourceFileFilter()); + destinationModel->setNameFilterDisables(m_nameFilterDisables); + // source const QString sourceDir = this->getOtherVersionsSelectedDirectory(); - if (m_initializedSourceDir != sourceDir) + if (!sourceModel || m_initializedSourceDir != sourceDir) { m_initializedSourceDir = sourceDir; - QFileSystemModel *sourceModel = qobject_cast(ui->tv_Source->model()); if (!sourceModel) { sourceModel = new QFileSystemModel(this); - sourceModel->setNameFilterDisables(true); // hide/disable only sourceModel->setFilter(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs); - sourceModel->setNameFilters(this->getSourceFileFilter()); ui->tv_Source->setModel(sourceModel); ui->tv_Source->setSortingEnabled(true); // hide/disable only connectOnce(sourceModel, &QFileSystemModel::directoryLoaded, this, [ = ](const QString & path) @@ -244,6 +255,8 @@ namespace BlackGui const QModelIndex sourceIndex = sourceModel->setRootPath(sourceDir); ui->tv_Source->setRootIndex(sourceIndex); } + sourceModel->setNameFilters(this->getSourceFileFilter()); + sourceModel->setNameFilterDisables(m_nameFilterDisables); } bool CCopyConfigurationComponent::hasOtherVersionData() const @@ -262,6 +275,13 @@ namespace BlackGui ui->tv_Source->selectAll(); } + void CCopyConfigurationComponent::setNameFilterDisables(bool disable) + { + if (m_nameFilterDisables == disable) { return; } + m_nameFilterDisables = disable; + this->initCurrentDirectories(true); + } + void CCopyConfigurationComponent::resizeEvent(QResizeEvent *event) { const int w = 0.45 * this->width(); @@ -377,9 +397,14 @@ namespace BlackGui } } + void CCopyConfigurationComponent::changeNameFilterDisables() + { + this->setNameFilterDisables(ui->cb_ShowAll->isChecked()); + } + const CLogCategoryList &CCopyConfigurationWizardPage::getLogCategories() { - static const BlackMisc::CLogCategoryList cats { CLogCategory::wizard(), CLogCategory::guiComponent() }; + static const CLogCategoryList cats { CLogCategory::wizard(), CLogCategory::guiComponent() }; return cats; } diff --git a/src/blackgui/components/copyconfigurationcomponent.h b/src/blackgui/components/copyconfigurationcomponent.h index e6827847b..670714a51 100644 --- a/src/blackgui/components/copyconfigurationcomponent.h +++ b/src/blackgui/components/copyconfigurationcomponent.h @@ -66,6 +66,12 @@ namespace BlackGui //! Select all void selectAll(); + //! \copydoc QFileSystemModel::setNameFilterDisables + void setNameFilterDisables(bool disable); + + //! Show bootstrap file? + void setWithBootstrapFile(bool withBootstrapFile) { m_withBootstrapFile = withBootstrapFile; } + protected: //! \copydoc QWidget::resizeEvent virtual void resizeEvent(QResizeEvent *event) override; @@ -99,11 +105,18 @@ namespace BlackGui //! Init the other swift versions void initOtherSwiftVersions(); + //! Set name filter disables from ui + void changeNameFilterDisables(); + QStringList m_otherVersionDirs; QScopedPointer ui; QString m_initializedSourceDir; QString m_initializedDestinationDir; bool m_logCopiedFiles = true; + bool m_nameFilterDisables = false; //!< name filter disables or hides + bool m_withBootstrapFile = false; + + // caches will be initialized (default files on disk) BlackMisc::Simulation::Data::CModelCaches m_modelCaches{false, this}; BlackMisc::Simulation::Data::CModelSetCaches m_modelSetCaches{false, this}; BlackMisc::CData m_modelSetCurrentSimulator { this }; diff --git a/src/blackgui/components/copyconfigurationcomponent.ui b/src/blackgui/components/copyconfigurationcomponent.ui index c382e1c29..30645746d 100644 --- a/src/blackgui/components/copyconfigurationcomponent.ui +++ b/src/blackgui/components/copyconfigurationcomponent.ui @@ -70,6 +70,13 @@ + + + + show all + + + diff --git a/src/blackgui/components/copyconfigurationdialog.cpp b/src/blackgui/components/copyconfigurationdialog.cpp index 17f44b8fe..827897179 100644 --- a/src/blackgui/components/copyconfigurationdialog.cpp +++ b/src/blackgui/components/copyconfigurationdialog.cpp @@ -25,7 +25,7 @@ namespace BlackGui CCopyConfigurationDialog::~CCopyConfigurationDialog() { } - void CCopyConfigurationDialog::setCacheCode() + void CCopyConfigurationDialog::setCacheMode() { ui->comp_CopyConfiguration->setCacheMode(); } @@ -39,5 +39,15 @@ namespace BlackGui { ui->comp_CopyConfiguration->selectAll(); } + + void CCopyConfigurationDialog::setNameFilterDisables(bool disable) + { + ui->comp_CopyConfiguration->setNameFilterDisables(disable); + } + + void CCopyConfigurationDialog::setWithBootstrapFile(bool withBootstrapFile) + { + ui->comp_CopyConfiguration->setWithBootstrapFile(withBootstrapFile); + } } // ns } // ns diff --git a/src/blackgui/components/copyconfigurationdialog.h b/src/blackgui/components/copyconfigurationdialog.h index 4ae273b96..d48bd43fa 100644 --- a/src/blackgui/components/copyconfigurationdialog.h +++ b/src/blackgui/components/copyconfigurationdialog.h @@ -36,7 +36,7 @@ namespace BlackGui virtual ~CCopyConfigurationDialog(); //! For cache data - void setCacheCode(); + void setCacheMode(); //! For settings void setSettingsMode(); @@ -44,6 +44,12 @@ namespace BlackGui //! Select all settings or caches void selectAll(); + //! \copydoc QFileSystemModel::setNameFilterDisables + void setNameFilterDisables(bool disable); + + //! \copydoc CCopyConfigurationComponent::setWithBootstrapFile + void setWithBootstrapFile(bool withBootstrapFile); + private: QScopedPointer ui; }; diff --git a/src/blackgui/components/setuploadingdialog.cpp b/src/blackgui/components/setuploadingdialog.cpp index b4e67b700..68c90354d 100644 --- a/src/blackgui/components/setuploadingdialog.cpp +++ b/src/blackgui/components/setuploadingdialog.cpp @@ -162,8 +162,9 @@ namespace BlackGui if (!m_copyFromOtherSwiftVersion) { CCopyConfigurationDialog *d = new CCopyConfigurationDialog(this); + d->setWithBootstrapFile(true); d->setModal(true); - d->setCacheCode(); + d->setCacheMode(); m_copyFromOtherSwiftVersion.reset(d); }