mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 00:45:46 +08:00
refs #887, skip copy steps if there is no other swift version to copy from
* pages as enum * buttons to copy/select/deselect (when UI component is used detached from wizard) * avoid crash when there is no other swift version (->empty model)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
cb024b0245
commit
1076eb2b29
@@ -19,6 +19,12 @@ namespace BlackGui
|
|||||||
ui(new Ui::CConfigurationWizard)
|
ui(new Ui::CConfigurationWizard)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
// no other versions, skip copy pages
|
||||||
|
if (!ui->comp_CopySettings->hasOtherVersionData())
|
||||||
|
{
|
||||||
|
this->setStartId(ConfigSimulator);
|
||||||
|
}
|
||||||
ui->wp_CopyCaches->setConfigComponent(ui->comp_CopyCaches);
|
ui->wp_CopyCaches->setConfigComponent(ui->comp_CopyCaches);
|
||||||
ui->wp_CopySettings->setConfigComponent(ui->comp_CopySettings);
|
ui->wp_CopySettings->setConfigComponent(ui->comp_CopySettings);
|
||||||
ui->wp_Simulator->setConfigComponent(ui->comp_Simulator);
|
ui->wp_Simulator->setConfigComponent(ui->comp_Simulator);
|
||||||
@@ -30,7 +36,11 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CConfigurationWizard::wizardCurrentIdChanged(int id)
|
void CConfigurationWizard::wizardCurrentIdChanged(int id)
|
||||||
{
|
{
|
||||||
Q_UNUSED(id);
|
const int lastId = m_lastId;
|
||||||
|
m_lastId = id; // update
|
||||||
|
const bool backward = id < lastId;
|
||||||
|
Q_UNUSED(backward);
|
||||||
|
|
||||||
const QWizardPage *page = this->currentPage();
|
const QWizardPage *page = this->currentPage();
|
||||||
if (page == ui->wp_CopyCaches)
|
if (page == ui->wp_CopyCaches)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,6 +29,14 @@ namespace BlackGui
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//! Page ids
|
||||||
|
enum Pages
|
||||||
|
{
|
||||||
|
CopySettings,
|
||||||
|
CopyCaches,
|
||||||
|
ConfigSimulator
|
||||||
|
};
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
explicit CConfigurationWizard(QWidget *parent = nullptr);
|
explicit CConfigurationWizard(QWidget *parent = nullptr);
|
||||||
|
|
||||||
@@ -40,6 +48,7 @@ namespace BlackGui
|
|||||||
void wizardCurrentIdChanged(int id);
|
void wizardCurrentIdChanged(int id);
|
||||||
|
|
||||||
QScopedPointer<Ui::CConfigurationWizard> ui;
|
QScopedPointer<Ui::CConfigurationWizard> ui;
|
||||||
|
int m_lastId = -1;
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -32,13 +32,16 @@ namespace BlackGui
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->cb_OtherVersions->clear();
|
ui->cb_OtherVersions->clear();
|
||||||
ui->cb_OtherVersions->addItems(CDirectoryUtils::swiftApplicationDataDirectoryList(true, true));
|
ui->cb_OtherVersions->addItems(CDirectoryUtils::swiftApplicationDataDirectoryList(true, true));
|
||||||
m_versionDirs = CDirectoryUtils::swiftApplicationDataDirectoryList(true, false); // not beautified
|
m_otherVersionDirs = CDirectoryUtils::swiftApplicationDataDirectoryList(true, false); // not beautified
|
||||||
|
|
||||||
this->initCurrentDirectories();
|
this->initCurrentDirectories();
|
||||||
this->preselectMissingOurOutdated();
|
this->preselectMissingOurOutdated();
|
||||||
|
|
||||||
connect(ui->rb_Cache, &QRadioButton::toggled, this, &CCopyConfigurationComponent::initCurrentDirectories);
|
connect(ui->rb_Cache, &QRadioButton::toggled, this, &CCopyConfigurationComponent::initCurrentDirectories);
|
||||||
connect(ui->cb_OtherVersions, &QComboBox::currentTextChanged, this, &CCopyConfigurationComponent::initCurrentDirectories);
|
connect(ui->cb_OtherVersions, &QComboBox::currentTextChanged, this, &CCopyConfigurationComponent::initCurrentDirectories);
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCopyConfigurationComponent::~CCopyConfigurationComponent()
|
CCopyConfigurationComponent::~CCopyConfigurationComponent()
|
||||||
@@ -65,15 +68,20 @@ namespace BlackGui
|
|||||||
const QString dirOther = this->getOtherVersionsSelectedDirectory();
|
const QString dirOther = this->getOtherVersionsSelectedDirectory();
|
||||||
const QString dirCurrent = this->getThisVersionDirectory();
|
const QString dirCurrent = this->getThisVersionDirectory();
|
||||||
|
|
||||||
|
ui->tv_Source->clearSelection();
|
||||||
ui->tv_Destination->clearSelection();
|
ui->tv_Destination->clearSelection();
|
||||||
|
|
||||||
const CDirectoryUtils::DirComparison comp = CDirectoryUtils::compareTwoDirectories(dirOther, dirCurrent);
|
const CDirectoryUtils::DirComparison comp = CDirectoryUtils::compareTwoDirectories(dirOther, dirCurrent);
|
||||||
const QFileSystemModel *model = qobject_cast<QFileSystemModel *>(ui->tv_Destination->model());
|
const QFileSystemModel *model = qobject_cast<QFileSystemModel *>(ui->tv_Destination->model());
|
||||||
|
if (!model) { return; }
|
||||||
|
|
||||||
QStringList select = comp.missingInTarget.toList();
|
QStringList select = comp.missingInTarget.toList();
|
||||||
select.append(comp.newerInSource.toList());
|
select.append(comp.newerInSource.toList());
|
||||||
for (const QString &file : as_const(comp.missingInTarget))
|
for (const QString &file : as_const(comp.missingInTarget))
|
||||||
{
|
{
|
||||||
ui->tv_Destination->setCurrentIndex(model->index(file));
|
const QModelIndex index = model->index(file);
|
||||||
|
if (!index.isValid()) continue;
|
||||||
|
ui->tv_Destination->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +90,6 @@ namespace BlackGui
|
|||||||
ui->le_CurrentVersion->setText(CDirectoryUtils::applicationDirectoryPath());
|
ui->le_CurrentVersion->setText(CDirectoryUtils::applicationDirectoryPath());
|
||||||
this->setComboBoxWidth();
|
this->setComboBoxWidth();
|
||||||
const QString dir = this->getOtherVersionsSelectedDirectory();
|
const QString dir = this->getOtherVersionsSelectedDirectory();
|
||||||
if (dir.isEmpty()) { return; }
|
|
||||||
|
|
||||||
// source
|
// source
|
||||||
QFileSystemModel *sourceModel = qobject_cast<QFileSystemModel *>(ui->tv_Source->model());
|
QFileSystemModel *sourceModel = qobject_cast<QFileSystemModel *>(ui->tv_Source->model());
|
||||||
@@ -99,9 +106,13 @@ namespace BlackGui
|
|||||||
ui->tv_Source->resizeColumnToContents(0);
|
ui->tv_Source->resizeColumnToContents(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const QModelIndex sourceIndex = sourceModel->setRootPath(dir);
|
|
||||||
ui->tv_Source->setRootIndex(sourceIndex);
|
if (!dir.isEmpty())
|
||||||
ui->tv_Source->setSortingEnabled(true);
|
{
|
||||||
|
const QModelIndex sourceIndex = sourceModel->setRootPath(dir);
|
||||||
|
ui->tv_Source->setRootIndex(sourceIndex);
|
||||||
|
ui->tv_Source->setSortingEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
// destination
|
// destination
|
||||||
QFileSystemModel *destinationModel = qobject_cast<QFileSystemModel *>(ui->tv_Destination->model());
|
QFileSystemModel *destinationModel = qobject_cast<QFileSystemModel *>(ui->tv_Destination->model());
|
||||||
@@ -125,6 +136,11 @@ namespace BlackGui
|
|||||||
ui->tv_Destination->resizeColumnToContents(0);
|
ui->tv_Destination->resizeColumnToContents(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CCopyConfigurationComponent::hasOtherVersionData() const
|
||||||
|
{
|
||||||
|
return !m_otherVersionDirs.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
void CCopyConfigurationComponent::currentVersionChanged(const QString &text)
|
void CCopyConfigurationComponent::currentVersionChanged(const QString &text)
|
||||||
{
|
{
|
||||||
Q_UNUSED(text);
|
Q_UNUSED(text);
|
||||||
@@ -138,9 +154,10 @@ namespace BlackGui
|
|||||||
|
|
||||||
QString CCopyConfigurationComponent::getOtherVersionsSelectedDirectory() const
|
QString CCopyConfigurationComponent::getOtherVersionsSelectedDirectory() const
|
||||||
{
|
{
|
||||||
const QString s = m_versionDirs.at(ui->cb_OtherVersions->currentIndex());
|
if (ui->cb_OtherVersions->count() < 1) { return ""; }
|
||||||
const QFileInfoList dirs(CDirectoryUtils::swiftApplicationDataDirectories());
|
const QFileInfoList dirs(CDirectoryUtils::swiftApplicationDataDirectories());
|
||||||
if (dirs.isEmpty()) { return ""; }
|
if (dirs.isEmpty()) { return ""; }
|
||||||
|
const QString s = m_otherVersionDirs.at(ui->cb_OtherVersions->currentIndex());
|
||||||
QString dir;
|
QString dir;
|
||||||
for (const QFileInfo &info : dirs)
|
for (const QFileInfo &info : dirs)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ namespace BlackGui
|
|||||||
//! Init file content
|
//! Init file content
|
||||||
void initCurrentDirectories();
|
void initCurrentDirectories();
|
||||||
|
|
||||||
|
//! Are there other versions to copy from
|
||||||
|
bool hasOtherVersionData() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! The current version changed
|
//! The current version changed
|
||||||
void currentVersionChanged(const QString &text);
|
void currentVersionChanged(const QString &text);
|
||||||
@@ -64,10 +67,10 @@ namespace BlackGui
|
|||||||
//! Get the selected files
|
//! Get the selected files
|
||||||
QStringList getSelectedFiles() const;
|
QStringList getSelectedFiles() const;
|
||||||
|
|
||||||
//! Combobox width
|
//! Set calculated combobox width
|
||||||
void setComboBoxWidth();
|
void setComboBoxWidth();
|
||||||
|
|
||||||
QStringList m_versionDirs;
|
QStringList m_otherVersionDirs;
|
||||||
QScopedPointer<Ui::CCopyConfigurationComponent> ui;
|
QScopedPointer<Ui::CCopyConfigurationComponent> ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,27 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pb_SelectAll">
|
||||||
|
<property name="text">
|
||||||
|
<string>select all</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pb_ClearSelection">
|
||||||
|
<property name="text">
|
||||||
|
<string>clear selection</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pb_CopyOver">
|
||||||
|
<property name="text">
|
||||||
|
<string>copy over</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="hs_Mode">
|
<spacer name="hs_Mode">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|||||||
Reference in New Issue
Block a user