mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +08:00
refactor: Remove unused/deprecated components
This commit is contained in:
@@ -341,7 +341,6 @@ add_library(gui SHARED
|
||||
components/loginoverviewcomponent.h
|
||||
components/updateinfodialog.ui
|
||||
components/aircraftpartshistory.ui
|
||||
components/copyconfigurationdialog.ui
|
||||
components/autopublishdialog.ui
|
||||
components/logincomponent.h
|
||||
components/audionotificationcomponent.ui
|
||||
@@ -358,7 +357,6 @@ add_library(gui SHARED
|
||||
components/autopublishcomponent.h
|
||||
components/audioadvanceddistributeddialog.ui
|
||||
components/settingsadvancedcomponent.h
|
||||
components/copyconfigurationcomponent.h
|
||||
components/airportdialog.h
|
||||
components/settingsmatchingdialog.cpp
|
||||
components/modelmatcherlogcomponent.h
|
||||
@@ -693,7 +691,6 @@ add_library(gui SHARED
|
||||
components/logindialog.ui
|
||||
components/cockpitcomcomponent.cpp
|
||||
components/logcomponent.cpp
|
||||
components/copyconfigurationdialog.cpp
|
||||
components/configurationwizard.cpp
|
||||
components/downloadcomponent.ui
|
||||
components/dbquickmappingwizard.cpp
|
||||
@@ -725,7 +722,6 @@ add_library(gui SHARED
|
||||
components/interpolationlogdisplaydialog.ui
|
||||
components/installxswiftbusdialog.h
|
||||
components/settingssimulatorbasicscomponent.ui
|
||||
components/copyconfigurationdialog.h
|
||||
components/scalescreenfactor.cpp
|
||||
components/downloadcomponent.h
|
||||
components/audioadvanceddistributeddialog.cpp
|
||||
@@ -774,7 +770,6 @@ add_library(gui SHARED
|
||||
components/loginadvcomponent.ui
|
||||
components/datasettingscomponent.ui
|
||||
components/cockpitcomtransmissioncomponent.cpp
|
||||
components/copyconfigurationcomponent.cpp
|
||||
components/firstmodelsetcomponent.ui
|
||||
components/settingsnetworkcomponent.ui
|
||||
components/cgsourceselector.cpp
|
||||
@@ -794,7 +789,6 @@ add_library(gui SHARED
|
||||
components/datainfoareacomponent.h
|
||||
components/dbownmodelscomponent.cpp
|
||||
components/marginsinput.h
|
||||
components/copyconfigurationcomponent.ui
|
||||
components/registercomponent.cpp
|
||||
components/statusmessageform.cpp
|
||||
components/settingsxswiftbuscomponent.h
|
||||
|
||||
@@ -1,461 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
#include "ui_copyconfigurationcomponent.h"
|
||||
#include "copyconfigurationcomponent.h"
|
||||
#include "blackgui/components/configurationwizard.h"
|
||||
#include "blackcore/data/globalsetup.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackconfig/buildconfig.h"
|
||||
#include "blackmisc/swiftdirectories.h"
|
||||
#include "blackmisc/directoryutils.h"
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include "blackmisc/datacache.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/slot.h"
|
||||
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfoList>
|
||||
#include <QFileSystemModel>
|
||||
#include <QDir>
|
||||
#include <QDesktopServices>
|
||||
#include <QPointer>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Simulation::Data;
|
||||
using namespace BlackConfig;
|
||||
using namespace BlackGui;
|
||||
using namespace BlackCore;
|
||||
using namespace BlackCore::Data;
|
||||
|
||||
namespace BlackGui::Components
|
||||
{
|
||||
const QStringList &CCopyConfigurationComponent::getLogCategories()
|
||||
{
|
||||
static const QStringList cats { CLogCategories::guiComponent() };
|
||||
return cats;
|
||||
}
|
||||
|
||||
CCopyConfigurationComponent::CCopyConfigurationComponent(QWidget *parent) : QFrame(parent),
|
||||
ui(new Ui::CCopyConfigurationComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->initOtherSwiftVersions();
|
||||
this->setWidths();
|
||||
m_hasOtherSwiftVersions = CApplicationInfoList::hasOtherSwiftDataDirectories();
|
||||
|
||||
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);
|
||||
connect(ui->tb_OpenOtherVersionsDir, &QToolButton::clicked, this, &CCopyConfigurationComponent::openOtherVersionsSelectedDirectory);
|
||||
connect(ui->tb_OpenThisVersionDir, &QToolButton::clicked, this, &CCopyConfigurationComponent::openOtherVersionsSelectedDirectory);
|
||||
|
||||
// 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());
|
||||
m_modelsCurrentSimulator.synchronize();
|
||||
m_modelsCurrentSimulator.set(m_modelsCurrentSimulator.get());
|
||||
m_launcherSetup.synchronize();
|
||||
m_launcherSetup.set(m_launcherSetup.get());
|
||||
m_vatsimSetup.synchronize();
|
||||
m_vatsimSetup.set(m_vatsimSetup.get());
|
||||
}
|
||||
|
||||
CCopyConfigurationComponent::~CCopyConfigurationComponent()
|
||||
{}
|
||||
|
||||
void CCopyConfigurationComponent::setCacheMode()
|
||||
{
|
||||
ui->rb_Cache->setChecked(true);
|
||||
}
|
||||
|
||||
void CCopyConfigurationComponent::setSettingsMode()
|
||||
{
|
||||
ui->rb_Settings->setChecked(true);
|
||||
}
|
||||
|
||||
int CCopyConfigurationComponent::copySelectedFiles()
|
||||
{
|
||||
const QStringList files = this->getSelectedFiles();
|
||||
if (files.isEmpty()) { return 0; }
|
||||
|
||||
const QString destinationDir = this->getThisVersionDirectory();
|
||||
const QString sourceDir = this->getOtherVersionsSelectedDirectory();
|
||||
if (destinationDir.isEmpty()) { return 0; }
|
||||
const QDir source(sourceDir);
|
||||
const QDir destination(destinationDir);
|
||||
if (!destination.exists()) { return 0; }
|
||||
|
||||
// init model caches if applicable (.rev file entries)
|
||||
this->initCaches(files);
|
||||
|
||||
int c = 0;
|
||||
QStringList copied;
|
||||
QStringList skipped;
|
||||
for (const QString &file : files)
|
||||
{
|
||||
const QString relativePath = source.relativeFilePath(file);
|
||||
const QString target = CFileUtils::appendFilePaths(destinationDir, relativePath);
|
||||
if (relativePath.contains('/'))
|
||||
{
|
||||
const QString targetDir = CFileUtils::stripFileFromPath(target);
|
||||
const bool dirOk = destination.mkpath(targetDir);
|
||||
if (!dirOk) { continue; }
|
||||
}
|
||||
QFile::remove(target); // copy does not overwrite
|
||||
const bool s = QFile::copy(file, target);
|
||||
if (s)
|
||||
{
|
||||
c++;
|
||||
copied << target;
|
||||
}
|
||||
else
|
||||
{
|
||||
skipped << target;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_logCopiedFiles)
|
||||
{
|
||||
if (!copied.isEmpty())
|
||||
{
|
||||
CLogMessage(this).info(u"Copied %1 files, list: '%2'") << copied.size() << copied.join(", ");
|
||||
}
|
||||
if (!skipped.isEmpty())
|
||||
{
|
||||
CLogMessage(this).info(u"Skipped %1 files, list: '%2'") << skipped.size() << skipped.join(", ");
|
||||
}
|
||||
}
|
||||
|
||||
// bye
|
||||
return c;
|
||||
}
|
||||
|
||||
void CCopyConfigurationComponent::preselectMissingOrOutdated()
|
||||
{
|
||||
const QString dirOther = this->getOtherVersionsSelectedDirectory();
|
||||
const QString dirCurrent = this->getThisVersionDirectory();
|
||||
|
||||
ui->tv_Source->clearSelection();
|
||||
ui->tv_Destination->clearSelection();
|
||||
|
||||
const CDirectoryUtils::DirComparison comp = CDirectoryUtils::compareTwoDirectories(dirOther, dirCurrent, true);
|
||||
const QFileSystemModel *sourceModel = qobject_cast<QFileSystemModel *>(ui->tv_Source->model());
|
||||
if (!sourceModel) { return; }
|
||||
|
||||
QStringList select = comp.missingInTarget.values();
|
||||
select.append(comp.newerInSource.values());
|
||||
for (const QString &file : std::as_const(comp.missingInTarget))
|
||||
{
|
||||
const QModelIndex index = sourceModel->index(file);
|
||||
if (!index.isValid()) continue;
|
||||
ui->tv_Source->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
const QStringList &CCopyConfigurationComponent::getSourceFileFilter()
|
||||
{
|
||||
if (ui->rb_Cache->isChecked())
|
||||
{
|
||||
// only copy setup and model caches
|
||||
static const QStringList cacheFilter = [=] {
|
||||
QStringList cf({ m_modelSetCurrentSimulator.getFilename(),
|
||||
m_modelsCurrentSimulator.getFilename(),
|
||||
m_launcherSetup.getFilename(),
|
||||
m_vatsimSetup.getFilename(),
|
||||
m_lastVatsimServer.getFilename(),
|
||||
m_lastServer.getFilename(),
|
||||
m_lastAircraftModel.getFilename() });
|
||||
cf.append(m_modelSetCaches.getAllFilenames());
|
||||
cf.append(m_modelCaches.getAllFilenames());
|
||||
return CFileUtils::getFileNamesOnly(cf);
|
||||
}();
|
||||
if (!m_withBootstrapFile) { return cacheFilter; }
|
||||
|
||||
static const QStringList cacheFilterBs = [=] {
|
||||
QStringList f(cacheFilter);
|
||||
f.push_back(CSwiftDirectories::bootstrapFileName());
|
||||
return f;
|
||||
}();
|
||||
return cacheFilterBs;
|
||||
}
|
||||
else
|
||||
{
|
||||
static const QStringList settingsFilter({ "*.json" });
|
||||
return settingsFilter;
|
||||
}
|
||||
}
|
||||
|
||||
void CCopyConfigurationComponent::initCurrentDirectories(bool preselectMissingOrOutdated)
|
||||
{
|
||||
const QString destinationDir = this->getThisVersionDirectory(); // cache or settings dir
|
||||
|
||||
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);
|
||||
if (!thisVersionDirectory.exists())
|
||||
{
|
||||
const bool hasDir = thisVersionDirectory.mkpath(destinationDir);
|
||||
if (!hasDir)
|
||||
{
|
||||
ui->le_CurrentVersion->setText("No swift target dir");
|
||||
return;
|
||||
}
|
||||
}
|
||||
ui->le_CurrentVersion->setText(destinationDir);
|
||||
|
||||
// destination
|
||||
if (!destinationModel)
|
||||
{
|
||||
destinationModel = new QFileSystemModel(this);
|
||||
destinationModel->setFilter(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);
|
||||
ui->tv_Destination->setModel(destinationModel);
|
||||
ui->tv_Destination->setSortingEnabled(true);
|
||||
|
||||
// disconnect when done, there have been problems that the lambda was called when the view was already destroyed
|
||||
connectOnce(destinationModel, &QFileSystemModel::directoryLoaded, this, [=](const QString &path) {
|
||||
Q_UNUSED(path);
|
||||
ui->tv_Destination->resizeColumnToContents(0);
|
||||
ui->tv_Destination->expandAll();
|
||||
});
|
||||
}
|
||||
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_hasOtherSwiftVersions)
|
||||
{
|
||||
// no ther versions
|
||||
return;
|
||||
}
|
||||
else if (!sourceModel || m_initializedSourceDir != sourceDir)
|
||||
{
|
||||
m_initializedSourceDir = sourceDir;
|
||||
if (!sourceModel)
|
||||
{
|
||||
sourceModel = new QFileSystemModel(this);
|
||||
sourceModel->setFilter(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);
|
||||
ui->tv_Source->setModel(sourceModel);
|
||||
ui->tv_Source->setSortingEnabled(true); // hide/disable only
|
||||
connectOnce(sourceModel, &QFileSystemModel::directoryLoaded, this, [=](const QString &path) {
|
||||
Q_UNUSED(path);
|
||||
ui->tv_Source->resizeColumnToContents(0);
|
||||
ui->tv_Source->expandAll();
|
||||
if (preselectMissingOrOutdated)
|
||||
{
|
||||
this->preselectMissingOrOutdated();
|
||||
}
|
||||
});
|
||||
}
|
||||
const QModelIndex sourceIndex = sourceModel->setRootPath(sourceDir);
|
||||
ui->tv_Source->setRootIndex(sourceIndex);
|
||||
}
|
||||
sourceModel->setNameFilters(this->getSourceFileFilter());
|
||||
sourceModel->setNameFilterDisables(m_nameFilterDisables);
|
||||
}
|
||||
|
||||
bool CCopyConfigurationComponent::hasOtherVersionData() const
|
||||
{
|
||||
return !m_otherVersionDirs.isEmpty();
|
||||
}
|
||||
|
||||
void CCopyConfigurationComponent::allowToggleCacheSettings(bool allow)
|
||||
{
|
||||
ui->rb_Cache->setEnabled(allow);
|
||||
ui->rb_Settings->setEnabled(allow);
|
||||
}
|
||||
|
||||
void CCopyConfigurationComponent::selectAll()
|
||||
{
|
||||
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)
|
||||
{
|
||||
this->setWidths();
|
||||
QFrame::resizeEvent(event);
|
||||
}
|
||||
|
||||
void CCopyConfigurationComponent::currentVersionChanged(const QString &text)
|
||||
{
|
||||
Q_UNUSED(text);
|
||||
this->initCurrentDirectories();
|
||||
}
|
||||
|
||||
const QString &CCopyConfigurationComponent::getThisVersionDirectory() const
|
||||
{
|
||||
return ui->rb_Cache->isChecked() ? CDataCache::persistentStore() : CSettingsCache::persistentStore();
|
||||
}
|
||||
|
||||
QString CCopyConfigurationComponent::getOtherVersionsSelectedDirectory() const
|
||||
{
|
||||
if (ui->cb_OtherVersions->count() < 1) { return {}; }
|
||||
const QFileInfoList dirs(CSwiftDirectories::applicationDataDirectories());
|
||||
if (dirs.isEmpty()) { return {}; }
|
||||
const QString otherVersionDir = m_otherVersionDirs.at(ui->cb_OtherVersions->currentIndex());
|
||||
QString dir;
|
||||
for (const QFileInfo &info : dirs)
|
||||
{
|
||||
if (info.absoluteFilePath().contains(otherVersionDir))
|
||||
{
|
||||
dir = info.absoluteFilePath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (dir.isEmpty()) { return {}; }
|
||||
dir = CFileUtils::appendFilePaths(dir, ui->rb_Cache->isChecked() ?
|
||||
CDataCache::relativeFilePath() :
|
||||
CSettingsCache::relativeFilePath());
|
||||
return dir;
|
||||
}
|
||||
|
||||
void CCopyConfigurationComponent::openOtherVersionsSelectedDirectory()
|
||||
{
|
||||
const QObject *s = sender();
|
||||
const QString d = (s == ui->tb_OpenOtherVersionsDir) ?
|
||||
this->getOtherVersionsSelectedDirectory() :
|
||||
this->getThisVersionDirectory();
|
||||
if (d.isEmpty()) { return; }
|
||||
QDir dir(d);
|
||||
if (!dir.exists()) { return; }
|
||||
const QUrl url = QUrl::fromLocalFile(dir.path());
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
|
||||
QStringList CCopyConfigurationComponent::getSelectedFiles() const
|
||||
{
|
||||
if (!m_hasOtherSwiftVersions) { return QStringList(); }
|
||||
const QModelIndexList indexes = ui->tv_Source->selectionModel()->selectedIndexes();
|
||||
if (indexes.isEmpty()) { return QStringList(); }
|
||||
const QFileSystemModel *sourceModel = qobject_cast<QFileSystemModel *>(ui->tv_Source->model());
|
||||
|
||||
QStringList files;
|
||||
for (const QModelIndex &index : indexes)
|
||||
{
|
||||
if (!index.isValid()) continue;
|
||||
const QString file = sourceModel->filePath(index);
|
||||
if (!files.contains(file))
|
||||
{
|
||||
files.push_back(file);
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
void CCopyConfigurationComponent::initCaches(const QStringList &files)
|
||||
{
|
||||
if (files.isEmpty()) { return; }
|
||||
if (!ui->rb_Cache->isChecked()) { return; }
|
||||
for (const QString &file : files)
|
||||
{
|
||||
if (file.contains("modelset", Qt::CaseInsensitive))
|
||||
{
|
||||
this->initMultiSimulatorCache(&m_modelSetCaches, file);
|
||||
}
|
||||
else if (file.contains("modelcache", Qt::CaseInsensitive))
|
||||
{
|
||||
this->initMultiSimulatorCache(&m_modelCaches, file);
|
||||
}
|
||||
}
|
||||
|
||||
// allow the cache files to be generated before we will override them
|
||||
CGuiApplication::processEventsFor(2500);
|
||||
}
|
||||
|
||||
void CCopyConfigurationComponent::initMultiSimulatorCache(IMultiSimulatorModelCaches *cache, const QString &fileName)
|
||||
{
|
||||
const CSimulatorInfo info = cache->getSimulatorForFilename(fileName);
|
||||
if (info.isNoSimulator()) { return; }
|
||||
if (cache->isSaved(info)) { return; } // already a file and hence in .rev
|
||||
const QFileInfo fi(fileName);
|
||||
const CStatusMessage msg = cache->setCacheTimestamp(fi.lastModified(), info); // create cache file and timestamp in .rev
|
||||
if (msg.isFailure())
|
||||
{
|
||||
CLogMessage(this).preformatted(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void CCopyConfigurationComponent::initOtherSwiftVersions()
|
||||
{
|
||||
ui->cb_OtherVersions->clear();
|
||||
const QMap<QString, CApplicationInfo> otherVersions = CApplicationInfoList::currentApplicationDataDirectoryMapWithoutCurrentVersion();
|
||||
for (const auto [dir, info] : makePairsRange(otherVersions))
|
||||
{
|
||||
if (info.isNull())
|
||||
{
|
||||
const QString infoString = CDirectoryUtils::decodeNormalizedDirectory(dir);
|
||||
ui->cb_OtherVersions->addItem(infoString);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->cb_OtherVersions->addItem(QStringLiteral("swift %1 (%2)").arg(info.getVersionString(), info.getPlatform()));
|
||||
}
|
||||
m_otherVersionDirs.push_back(dir);
|
||||
}
|
||||
}
|
||||
|
||||
void CCopyConfigurationComponent::changeNameFilterDisables()
|
||||
{
|
||||
this->setNameFilterDisables(ui->cb_ShowAll->isChecked());
|
||||
}
|
||||
|
||||
void CCopyConfigurationComponent::setWidths()
|
||||
{
|
||||
const int w = this->width();
|
||||
const int wCb = qRound(0.45 * w);
|
||||
const int wView = qRound(0.4 * w);
|
||||
ui->cb_OtherVersions->setMaximumWidth(wCb);
|
||||
ui->tv_Destination->setMinimumWidth(wView);
|
||||
ui->tv_Source->setMinimumWidth(wView);
|
||||
}
|
||||
|
||||
const QStringList &CCopyConfigurationWizardPage::getLogCategories()
|
||||
{
|
||||
static const QStringList cats { CLogCategories::wizard(), CLogCategories::guiComponent() };
|
||||
return cats;
|
||||
}
|
||||
|
||||
void CCopyConfigurationWizardPage::initializePage()
|
||||
{
|
||||
Q_ASSERT_X(m_config, Q_FUNC_INFO, "Missing config");
|
||||
const QString name = m_config->objectName().toLower();
|
||||
if (name.contains("setting", Qt::CaseInsensitive))
|
||||
{
|
||||
m_config->setSettingsMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_config->setCacheMode();
|
||||
}
|
||||
m_config->allowToggleCacheSettings(false);
|
||||
m_config->initCurrentDirectories(true);
|
||||
}
|
||||
|
||||
bool CCopyConfigurationWizardPage::validatePage()
|
||||
{
|
||||
if (CConfigurationWizard::lastWizardStepSkipped(this->wizard())) { return true; }
|
||||
m_config->copySelectedFiles();
|
||||
return true;
|
||||
}
|
||||
} // ns
|
||||
@@ -1,167 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_COMPONENTS_COPYCONFIGURATION_H
|
||||
#define BLACKGUI_COMPONENTS_COPYCONFIGURATION_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackcore/data/launchersetup.h"
|
||||
#include "blackcore/data/vatsimsetup.h"
|
||||
#include "blackmisc/simulation/data/modelcaches.h"
|
||||
#include "blackmisc/simulation/data/lastmodel.h"
|
||||
#include "blackmisc/network/data/lastserver.h"
|
||||
#include <QFrame>
|
||||
#include <QWizardPage>
|
||||
#include <QDir>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CCopyConfigurationComponent;
|
||||
}
|
||||
namespace BlackGui::Components
|
||||
{
|
||||
//! Copy configuration (i.e. settings and cache files)
|
||||
//! \deprecated replaced by CCopySettingsAndCachesComponent
|
||||
class BLACKGUI_EXPORT CCopyConfigurationComponent : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Log.categories
|
||||
static const QStringList &getLogCategories();
|
||||
|
||||
//! Constructor
|
||||
explicit CCopyConfigurationComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CCopyConfigurationComponent() override;
|
||||
|
||||
//! Cache mode
|
||||
void setCacheMode();
|
||||
|
||||
//! Settings mode
|
||||
void setSettingsMode();
|
||||
|
||||
//! Selected files are copied
|
||||
int copySelectedFiles();
|
||||
|
||||
//! Init file content
|
||||
void initCurrentDirectories(bool preselectMissingOrOutdated = false);
|
||||
|
||||
//! Are there other versions to copy from?
|
||||
bool hasOtherVersionData() const;
|
||||
|
||||
//! Allow to toggle cache and settings
|
||||
void allowToggleCacheSettings(bool allow);
|
||||
|
||||
//! Log copied files
|
||||
void logCopiedFiles(bool log) { m_logCopiedFiles = log; }
|
||||
|
||||
//! 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;
|
||||
|
||||
private:
|
||||
//! Preselect newer files
|
||||
void preselectMissingOrOutdated();
|
||||
|
||||
//! Filter out items from preselection
|
||||
//! \remark formally newer files are preselected
|
||||
bool preselectActiveFiles(const QString &file) const;
|
||||
|
||||
//! Source file filter
|
||||
const QStringList &getSourceFileFilter();
|
||||
|
||||
//! The current version changed
|
||||
void currentVersionChanged(const QString &text);
|
||||
|
||||
//! This version's directory (cache or setting)
|
||||
const QString &getThisVersionDirectory() const;
|
||||
|
||||
//! Get the selected directory
|
||||
QString getOtherVersionsSelectedDirectory() const;
|
||||
|
||||
//! Other the directory of that other version
|
||||
void openOtherVersionsSelectedDirectory();
|
||||
|
||||
//! Get the selected files
|
||||
QStringList getSelectedFiles() const;
|
||||
|
||||
//! Init caches if required (create .rev entries with high level functions)
|
||||
void initCaches(const QStringList &files);
|
||||
|
||||
//! Init a multi simulator cache (modelset/models)
|
||||
void initMultiSimulatorCache(BlackMisc::Simulation::Data::IMultiSimulatorModelCaches *cache, const QString &fileName);
|
||||
|
||||
//! Init the other swift versions
|
||||
void initOtherSwiftVersions();
|
||||
|
||||
//! Set name filter disables from ui
|
||||
void changeNameFilterDisables();
|
||||
|
||||
//! Set widths
|
||||
void setWidths();
|
||||
|
||||
QScopedPointer<Ui::CCopyConfigurationComponent> ui;
|
||||
QStringList m_otherVersionDirs;
|
||||
QString m_initializedSourceDir;
|
||||
QString m_initializedDestinationDir;
|
||||
bool m_logCopiedFiles = true;
|
||||
bool m_nameFilterDisables = false; //!< name filter disables or hides
|
||||
bool m_withBootstrapFile = false;
|
||||
bool m_hasOtherSwiftVersions = false;
|
||||
|
||||
// caches will be explicitly initialized in initCaches
|
||||
BlackMisc::Simulation::Data::CModelCaches m_modelCaches { false, this };
|
||||
BlackMisc::Simulation::Data::CModelSetCaches m_modelSetCaches { false, this };
|
||||
|
||||
// caches will be initialized so they can be overriden
|
||||
// those caches do not harm if they exists default initialized
|
||||
//! \fixme this is a workaround, as it creates files on disk even if those are not copied. It was much nicer if the cache would init themself if the file appears
|
||||
BlackMisc::CData<BlackMisc::Network::Data::TLastServer> m_lastServer { this }; //!< recently used server (VATSIM, other)
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::TSimulatorLastSelection> m_modelSetCurrentSimulator { this };
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::TModelCacheLastSelection> m_modelsCurrentSimulator { this };
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::TLastModel> m_lastAircraftModel { this }; //!< recently used aircraft model
|
||||
BlackMisc::CData<BlackCore::Data::TLauncherSetup> m_launcherSetup { this };
|
||||
BlackMisc::CData<BlackCore::Data::TVatsimSetup> m_vatsimSetup { this };
|
||||
BlackMisc::CData<BlackCore::Data::TVatsimLastServer> m_lastVatsimServer { this }; //!< recently used VATSIM server
|
||||
};
|
||||
|
||||
/*!
|
||||
* Wizard page for CCopyConfigurationComponent
|
||||
*/
|
||||
class CCopyConfigurationWizardPage : public QWizardPage
|
||||
{
|
||||
public:
|
||||
//! Constructors
|
||||
using QWizardPage::QWizardPage;
|
||||
|
||||
//! Log.categories
|
||||
static const QStringList &getLogCategories();
|
||||
|
||||
//! Set config
|
||||
void setConfigComponent(CCopyConfigurationComponent *config) { m_config = config; }
|
||||
|
||||
//! \copydoc QWizardPage::initializePage
|
||||
virtual void initializePage() override;
|
||||
|
||||
//! \copydoc QWizardPage::validatePage
|
||||
virtual bool validatePage() override;
|
||||
|
||||
private:
|
||||
CCopyConfigurationComponent *m_config = nullptr;
|
||||
};
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
@@ -1,274 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CCopyConfigurationComponent</class>
|
||||
<widget class="QFrame" name="CCopyConfigurationComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>640</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="fl_Destination_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QWidget" name="wi_Mode" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_RadioButtons">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_Settings">
|
||||
<property name="text">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rb_Cache">
|
||||
<property name="text">
|
||||
<string>Cache</string>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<widget class="QCheckBox" name="cb_ShowAll">
|
||||
<property name="text">
|
||||
<string>show all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="hs_Mode">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QFrame" name="fr_Directories">
|
||||
<layout class="QHBoxLayout" name="hl_Directories">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_Source">
|
||||
<property name="title">
|
||||
<string>Source (other versions)</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_Source">
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="ft_OtherVersions">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="hl_OtherVersions">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cb_OtherVersions">
|
||||
<property name="frame">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="tb_OpenOtherVersionsDir">
|
||||
<property name="toolTip">
|
||||
<string>open this directory</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeView" name="tv_Source">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::MultiSelection</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="animated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_Destination">
|
||||
<property name="title">
|
||||
<string>Destination (this version)</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_Destination">
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="fr_Destination">
|
||||
<layout class="QHBoxLayout" name="fl_Destination">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_CurrentVersion">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="tb_OpenThisVersionDir">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTreeView" name="tv_Destination">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="animated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,45 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
#include "copyconfigurationdialog.h"
|
||||
#include "ui_copyconfigurationdialog.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
|
||||
namespace BlackGui::Components
|
||||
{
|
||||
CCopyConfigurationDialog::CCopyConfigurationDialog(QWidget *parent) : QDialog(parent),
|
||||
ui(new Ui::CCopyConfigurationDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
}
|
||||
|
||||
CCopyConfigurationDialog::~CCopyConfigurationDialog()
|
||||
{}
|
||||
|
||||
void CCopyConfigurationDialog::setCacheMode()
|
||||
{
|
||||
ui->comp_CopyConfiguration->setCacheMode();
|
||||
}
|
||||
|
||||
void CCopyConfigurationDialog::setSettingsMode()
|
||||
{
|
||||
ui->comp_CopyConfiguration->setSettingsMode();
|
||||
}
|
||||
|
||||
void CCopyConfigurationDialog::selectAll()
|
||||
{
|
||||
ui->comp_CopyConfiguration->selectAll();
|
||||
}
|
||||
|
||||
void CCopyConfigurationDialog::setNameFilterDisables(bool disable)
|
||||
{
|
||||
ui->comp_CopyConfiguration->setNameFilterDisables(disable);
|
||||
}
|
||||
|
||||
bool CCopyConfigurationDialog::event(QEvent *event)
|
||||
{
|
||||
if (CGuiApplication::triggerShowHelp(this, event)) { return true; }
|
||||
return QDialog::event(event);
|
||||
}
|
||||
} // ns
|
||||
@@ -1,52 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2017 swift Project Community / Contributors
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_COMPONENTS_COPYCONFIGURATIONDIALOG_H
|
||||
#define BLACKGUI_COMPONENTS_COPYCONFIGURATIONDIALOG_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include <QDialog>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CCopyConfigurationDialog;
|
||||
}
|
||||
namespace BlackGui::Components
|
||||
{
|
||||
//! Dialog to copy cache and settings
|
||||
//! \deprecated replaced by CCopySettingsAndCachesComponent
|
||||
class BLACKGUI_EXPORT CCopyConfigurationDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CCopyConfigurationDialog(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CCopyConfigurationDialog() override;
|
||||
|
||||
//! For cache data
|
||||
void setCacheMode();
|
||||
|
||||
//! For settings
|
||||
void setSettingsMode();
|
||||
|
||||
//! Select all settings or caches
|
||||
void selectAll();
|
||||
|
||||
//! \copydoc QFileSystemModel::setNameFilterDisables
|
||||
void setNameFilterDisables(bool disable);
|
||||
|
||||
protected:
|
||||
//! \copydoc QObject::event
|
||||
virtual bool event(QEvent *event) override;
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CCopyConfigurationDialog> ui;
|
||||
};
|
||||
} // ns
|
||||
#endif // guard
|
||||
@@ -1,88 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CCopyConfigurationDialog</class>
|
||||
<widget class="QDialog" name="CCopyConfigurationDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>640</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Copy configuration component</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CCopyConfigurationComponent" name="comp_CopyConfiguration">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="bb_CopyConfigurationDialog">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CCopyConfigurationComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/copyconfigurationcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>bb_CopyConfigurationDialog</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CCopyConfigurationDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>bb_CopyConfigurationDialog</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CCopyConfigurationDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -82,15 +82,6 @@ QDialog::separator:hover {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
/* selector QWizard not working, so using individual components */
|
||||
/* the wizard pages are currently hardcoded */
|
||||
/*
|
||||
BlackGui--Components--CCopyConfigurationComponent {
|
||||
background: black;
|
||||
background-image: url(:/textures/icons/textures/texture-inner.jpg);
|
||||
}
|
||||
*/
|
||||
|
||||
/* setup load dialog details frame */
|
||||
/*
|
||||
BlackGui--Components--CSetupLoadingDialog #fr_Details {
|
||||
|
||||
Reference in New Issue
Block a user