mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 23:45:35 +08:00
Ref T199, improved copy dialog
* filter disabling or hiding can be toggled * bootstrap file can be shown/hidden * fixed naming typo "setCacheMode"
This commit is contained in:
@@ -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<QFileSystemModel *>(ui->tv_Destination->model());
|
||||
QFileSystemModel *sourceModel = qobject_cast<QFileSystemModel *>(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<QFileSystemModel *>(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<QFileSystemModel *>(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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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::CCopyConfigurationComponent> 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<BlackMisc::Simulation::Data::TModelSetLastSelection> m_modelSetCurrentSimulator { this };
|
||||
|
||||
@@ -70,6 +70,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_ShowAll">
|
||||
<property name="text">
|
||||
<string>show all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="hs_Mode">
|
||||
<property name="orientation">
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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::CCopyConfigurationDialog> ui;
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user