Skip to content

Commit

Permalink
GUI for extended model optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
signedav committed Sep 8, 2023
1 parent 2a3bbcc commit d82ea80
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 22 deletions.
13 changes: 13 additions & 0 deletions QgisModelBaker/gui/workflow_wizard/project_creation_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from QgisModelBaker.libs.modelbaker.generator.generator import Generator
from QgisModelBaker.libs.modelbaker.iliwrapper.globals import DbIliMode
from QgisModelBaker.libs.modelbaker.iliwrapper.ilicache import IliToppingFileItemModel
from QgisModelBaker.libs.modelbaker.utils.globals import OptimizeStrategy
from QgisModelBaker.utils import gui_utils
from QgisModelBaker.utils.globals import CATALOGUE_DATASETNAME
from QgisModelBaker.utils.gui_utils import LogColor
Expand All @@ -48,6 +49,15 @@ def __init__(self, parent, title):
self.setTitle(title)
self.setStyleSheet(gui_utils.DEFAULT_STYLE)

self.optimize_combo.clear()
self.optimize_combo.addItem(
self.tr("Hide unused base class layers"), OptimizeStrategy.HIDE
)
self.optimize_combo.addItem(
self.tr("Group unused base class layers"), OptimizeStrategy.GROUP
)
self.optimize_combo.addItem(self.tr("No optimization"), OptimizeStrategy.NONE)

self.db_simple_factory = DbSimpleFactory()
self.configuration = None

Expand All @@ -74,6 +84,7 @@ def _create_project(self):
self.configuration.dbschema,
mgmt_uri=mgmt_uri,
consider_basket_handling=True,
optimize_strategy=self.optimize_combo.currentData(),
)
generator.stdout.connect(self.workflow_wizard.log_panel.print_info)
generator.new_message.connect(self.workflow_wizard.log_panel.show_message)
Expand Down Expand Up @@ -257,12 +268,14 @@ def _create_project(self):

self.progress_bar.setValue(55)

print(self.optimize_combo.currentData())
# on geopackages we don't use the transaction mode on default, since this leaded to troubles, except the topping sais so
project = Project(
auto_transaction=not bool(self.configuration.tool & DbIliMode.gpkg)
or custom_project_properties.get("transaction_mode", "")
== "AutomaticGroups",
context={"catalogue_datasetname": CATALOGUE_DATASETNAME},
optimize_strategy=self.optimize_combo.currentData(),
)
project.layers = available_layers
project.relations = relations
Expand Down
88 changes: 66 additions & 22 deletions QgisModelBaker/ui/workflow_wizard/project_creation.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,63 @@
<string>Select Files</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="optimize_combo">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Hide unused base class layers:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;- Base class layers with same named extensions will be &lt;span style=&quot; font-style:italic;&quot;&gt;hidden&lt;/span&gt; and and base class layers with multiple extensions as well. Except if the extension is in the same model, then it's will &lt;span style=&quot; font-style:italic;&quot;&gt;not&lt;/span&gt; be &lt;span style=&quot; font-style:italic;&quot;&gt;hidden&lt;/span&gt; but &lt;span style=&quot; font-style:italic;&quot;&gt;renamed&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;- Relations of hidden layers will &lt;span style=&quot; font-style:italic;&quot;&gt;not&lt;/span&gt; be &lt;span style=&quot; font-style:italic;&quot;&gt;created&lt;/span&gt; and with them &lt;span style=&quot; font-style:italic;&quot;&gt;no&lt;/span&gt; widgets&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Group unused base class layers:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;- Base class layers with same named extensions will be &lt;span style=&quot; font-style:italic;&quot;&gt;collected in a group&lt;/span&gt; and base class layers with multiple extensions as well. Except if the extension is in the same model, then it's will &lt;span style=&quot; font-style:italic;&quot;&gt;not&lt;/span&gt; be &lt;span style=&quot; font-style:italic;&quot;&gt;grouped&lt;/span&gt; but &lt;span style=&quot; font-style:italic;&quot;&gt;renamed&lt;/span&gt;.&lt;/p&gt;&lt;p&gt;- Relations of grouped layers will be &lt;span style=&quot; font-style:italic;&quot;&gt;created&lt;/span&gt; but the widgets &lt;span style=&quot; font-style:italic;&quot;&gt;notapplied&lt;/span&gt; to the form.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<item>
<property name="text">
<string>Hide unused base class layers</string>
</property>
</item>
<item>
<property name="text">
<string>Group unused base class layers</string>
</property>
</item>
<item>
<property name="text">
<string>No optimization</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If you don't get it - nevermind and keep the default. If it's not like expected - try again with 'No optimization'...&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Should the project be optimized concerning inheritances?</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="description">
<property name="minimumSize">
Expand All @@ -39,27 +96,7 @@
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="2">
<widget class="QProgressBar" name="progress_bar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -72,13 +109,20 @@
</property>
</spacer>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QCommandLinkButton" name="create_project_button">
<property name="text">
<string>Generate</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QProgressBar" name="progress_bar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
Expand Down

0 comments on commit d82ea80

Please sign in to comment.