Skip to content

Commit

Permalink
https://github.com/StephaneCouturier/Katalog/issues/340
Browse files Browse the repository at this point in the history
  • Loading branch information
StephaneCouturier committed Dec 2, 2024
1 parent 92e832f commit f7ffa0b
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 26 deletions.
14 changes: 9 additions & 5 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ MainWindow::MainWindow(QWidget *parent) :
//Set current version, release date, and development mode
currentVersion = "2.3";
collection->appVersion = currentVersion;
releaseDate = "2024-11-30";
releaseDate = "2024-12-02";
developmentMode = false;
themeID = 1; //default value for the theme = Katalog Colors (light).
selectedTab = 3; //default value for the first launch = Create screen.
Expand Down Expand Up @@ -85,10 +85,14 @@ MainWindow::MainWindow(QWidget *parent) :
hideDevelopmentUIItems();
}

QButtonGroup buttonGroup;
buttonGroup.addButton(ui->Devices_radioButton_DeviceTree);
buttonGroup.addButton(ui->Devices_radioButton_StorageList);
buttonGroup.addButton(ui->Devices_radioButton_CatalogList);
QButtonGroup buttonGroupDevices;
buttonGroupDevices.addButton(ui->Devices_radioButton_DeviceTree);
buttonGroupDevices.addButton(ui->Devices_radioButton_StorageList);
buttonGroupDevices.addButton(ui->Devices_radioButton_CatalogList);

QButtonGroup buttonGroupBackUp;
buttonGroupBackUp.addButton(ui->BackUp_radioButton_Source);
buttonGroupBackUp.addButton(ui->BackUp_radioButton_Target);

//Settings screen
ui->Settings_lineEdit_DatabaseFilePath->setText(collection->databaseFilePath);
Expand Down
2 changes: 2 additions & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,8 @@ class MainWindow : public QMainWindow
void on_BackUp_pushButton_ReloadTargetList_clicked();
void on_BackUp_pushButton_DeleteSelectedMapping_clicked();
void on_BackUp_checkBox_DisplayFullTable_checkStateChanged(const Qt::CheckState &arg1);
void on_BackUp_radioButton_Source_clicked();
void on_BackUp_radioButton_Target_clicked();

//Statistics
void on_Statistics_pushButton_EditDeviceStatisticsFile_clicked();
Expand Down
17 changes: 17 additions & 0 deletions src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7466,6 +7466,23 @@ background: url(:/images/link-h.png) repeat-x center;</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="BackUp_radioButton_Source">
<property name="text">
<string>based on Sources</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="BackUp_radioButton_Target">
<property name="text">
<string>based on Targets</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
Expand Down
6 changes: 6 additions & 0 deletions src/mainwindow_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,12 @@
fileSortCaseSensitive = settings.value("Settings/FileCaseSensitiveSort").toBool();
ui->Settings_checkBox_SettingsFileCaseSensitiveSort->setChecked(fileSortCaseSensitive);

//BackUp Tab
QString filterMappingTable = settings.value("BackUp/FilterMappingTable", "Source").toString();
if(filterMappingTable=="Target"){
ui->BackUp_radioButton_Target->setChecked(true);
}

//Restore DEV Settings
if(developmentMode==true){
ui->Settings_comboBox_DatabaseMode->setCurrentText(tr(collection->databaseMode.toStdString().c_str()));
Expand Down
80 changes: 59 additions & 21 deletions src/mainwindow_tab_backup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ void MainWindow::on_BackUp_checkBox_DisplayFullTable_checkStateChanged(const Qt:
loadBackUpMapping();
}

void MainWindow::on_BackUp_radioButton_Source_clicked()
{
QSettings settings(collection->settingsFilePath, QSettings:: IniFormat);
settings.setValue("BackUp/FilterMappingTable", "Source");
}

void MainWindow::on_BackUp_radioButton_Target_clicked()
{
QSettings settings(collection->settingsFilePath, QSettings:: IniFormat);
settings.setValue("BackUp/FilterMappingTable", "Target");
}

//Methods-----------------------------------------------------------------------

Expand Down Expand Up @@ -149,28 +160,55 @@ void MainWindow::loadBackUpMapping()
AND dm.mapping_device_target_id = d2.device_id
)");

if ( selectedDevice->type == "Storage" ){
querySQL += " AND d1.device_parent_id =:device_parent_id ";
}
else if ( selectedDevice->type == "Catalog" ){
querySQL += " AND d1.device_id =:device_id ";
if(ui->BackUp_radioButton_Target->isChecked()==true){
if ( selectedDevice->type == "Storage" ){
querySQL += " AND d2.device_parent_id =:device_parent_id ";
}
else if ( selectedDevice->type == "Catalog" ){
querySQL += " AND d2.device_id =:device_id ";
}
else if ( selectedDevice->type == "Virtual" ){
QString prepareSQL = QLatin1String(R"(
AND d2.device_id IN (
WITH RECURSIVE hierarchy AS (
SELECT device_id, device_parent_id, device_name
FROM device
WHERE device_id = :device_id
UNION ALL
SELECT t.device_id, t.device_parent_id, t.device_name
FROM device t
JOIN hierarchy h ON t.device_parent_id = h.device_id
)
SELECT device_id
FROM hierarchy)
)");
querySQL += prepareSQL;
}
}
else if ( selectedDevice->type == "Virtual" ){
QString prepareSQL = QLatin1String(R"(
AND d1.device_id IN (
WITH RECURSIVE hierarchy AS (
SELECT device_id, device_parent_id, device_name
FROM device
WHERE device_id = :device_id
UNION ALL
SELECT t.device_id, t.device_parent_id, t.device_name
FROM device t
JOIN hierarchy h ON t.device_parent_id = h.device_id
)
SELECT device_id
FROM hierarchy)
)");
querySQL += prepareSQL;
else{
if ( selectedDevice->type == "Storage" ){
querySQL += " AND d1.device_parent_id =:device_parent_id ";
}
else if ( selectedDevice->type == "Catalog" ){
querySQL += " AND d1.device_id =:device_id ";
}
else if ( selectedDevice->type == "Virtual" ){
QString prepareSQL = QLatin1String(R"(
AND d1.device_id IN (
WITH RECURSIVE hierarchy AS (
SELECT device_id, device_parent_id, device_name
FROM device
WHERE device_id = :device_id
UNION ALL
SELECT t.device_id, t.device_parent_id, t.device_name
FROM device t
JOIN hierarchy h ON t.device_parent_id = h.device_id
)
SELECT device_id
FROM hierarchy)
)");
querySQL += prepareSQL;
}
}

querySQL +=" ORDER BY dm.mapping_name ASC ";
Expand Down

0 comments on commit f7ffa0b

Please sign in to comment.