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 07b2c5f commit bdf13ad
Show file tree
Hide file tree
Showing 10 changed files with 487 additions and 469 deletions.
4 changes: 2 additions & 2 deletions src/devicemappingview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ QVariant DeviceMappingView::data(const QModelIndex &index, int role) const
return QIcon(QIcon::fromTheme("media-optical"));
}
//Icon for target catalog
if( index.column()==10 ){
QModelIndex idx = index.sibling(index.row(), 11);
if( index.column()==11 ){
QModelIndex idx = index.sibling(index.row(), 12);
if( QSortFilterProxyModel::data(idx, Qt::DisplayRole).toBool()==true ){
return QIcon(QIcon::fromTheme("media-optical-blu-ray"));
}
Expand Down
23 changes: 13 additions & 10 deletions src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7328,12 +7328,12 @@ background: url(:/images/link-h.png) repeat-x center;</string>
<widget class="QPushButton" name="BackUp_pushButton_DeleteSelectedMapping">
<property name="maximumSize">
<size>
<width>250</width>
<width>200</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Delete selected mapping</string>
<string>Delete selected</string>
</property>
<property name="icon">
<iconset theme="QIcon::ThemeIcon::EditDelete"/>
Expand All @@ -7357,6 +7357,9 @@ background: url(:/images/link-h.png) repeat-x center;</string>
<property name="text">
<string>Create mapping</string>
</property>
<property name="icon">
<iconset theme="QIcon::ThemeIcon::DocumentSave"/>
</property>
</widget>
</item>
<item>
Expand Down Expand Up @@ -7440,6 +7443,13 @@ background: url(:/images/link-h.png) repeat-x center;</string>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="BackUp_label_CurrentMappings">
<property name="text">
<string>Device mappings</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="BackUp_pushButton_ReloadDeviceMappings">
<property name="maximumSize">
Expand All @@ -7449,7 +7459,7 @@ background: url(:/images/link-h.png) repeat-x center;</string>
</size>
</property>
<property name="text">
<string>Reload device mappings</string>
<string>Reload</string>
</property>
<property name="icon">
<iconset theme="view-refresh"/>
Expand Down Expand Up @@ -7478,13 +7488,6 @@ background: url(:/images/link-h.png) repeat-x center;</string>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="BackUp_label_CurrentMappings">
<property name="text">
<string>Device mappings</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QTableView" name="BackUp_tableView_CurrentMappings">
<property name="lineWidth">
Expand Down
33 changes: 28 additions & 5 deletions src/mainwindow_tab_backup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ void MainWindow::loadBackUpMapping()
{
//Load data from table device_mapping
QSqlQuery query(QSqlDatabase::database("defaultConnection"));

QString querySQL = QLatin1String(R"(
QString querySQL;
querySQL = QLatin1String(R"(
SELECT
dm.mapping_id,
dm.mapping_name,
Expand Down Expand Up @@ -149,11 +149,34 @@ void MainWindow::loadBackUpMapping()
AND dm.mapping_device_target_id = d2.device_id
)");

querySQL += QLatin1String(R"(
ORDER BY dm.mapping_name
)");
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 d1.device_type DESC, d1.device_parent_id ASC, dm.mapping_name ASC ";
query.prepare(querySQL);
query.bindValue(":device_id", selectedDevice->ID);
query.bindValue(":device_parent_id", selectedDevice->ID);

if (!query.exec())
{
Expand Down
Binary file modified src/translations/Katalog_cz_CZ.qm
Binary file not shown.
Loading

0 comments on commit bdf13ad

Please sign in to comment.