Skip to content

Commit

Permalink
Merge pull request #927 from opengisch/helpbutton
Browse files Browse the repository at this point in the history
Help button in wizard
  • Loading branch information
signedav authored Jul 1, 2024
2 parents 216ad6d + 8a7e14e commit 18ec6d5
Show file tree
Hide file tree
Showing 13 changed files with 386 additions and 3 deletions.
19 changes: 19 additions & 0 deletions QgisModelBaker/gui/workflow_wizard/database_selection_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,24 @@ def is_valid(self):
)
return res

def help_text(self):
logline = self.tr(
"Here you have to set the connection parameters for your datasource..."
)
help_paragraphs = self.tr(
"""
<h4 align="justify">On GeoPackage</h4>
<p align="justify">You can select a <code>gpkg</code> file.<br />
Or if you want to create a new one, just type the desired name on an existing path (and it will be created).</p>
<h4 align="justify">On PostgreSQL</h4>
<p align="justify">For a detailed description of each parameter, see the <a href="https://opengisch.github.io/QgisModelBaker/user_guide/import_workflow/#2-database-selection">documentation</a></p>
<p align="justify">A <b>superuser login</b> must be configured in the Model Baker settings <i>Database &lt; Model Baker &lt; Settings<i>.
"""
)
docutext = self.tr(
'Find more information about the <b>database settings</b> in the <a href="https://opengisch.github.io/QgisModelBaker/user_guide/import_workflow/">documentation</a>...'
)
return logline, help_paragraphs, docutext

def nextId(self):
return self.workflow_wizard.next_id()
16 changes: 16 additions & 0 deletions QgisModelBaker/gui/workflow_wizard/default_baskets_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,19 @@ def _skip(self):
self.skip_button.setDisabled(True)
self.baskets_panel.setDisabled(True)
self.setComplete(True)

def help_text(self):
logline = self.tr(
"Honestly, I don't know if you want to create the baskets or skip this step.<br />See below..."
)
help_paragraphs = self.tr(
"""
<p align="justify">If you plan to <b>import data later</b> (from <code>xtf</code> or <code>xml</code>), the necessary baskets will be created on import anyway.</p>
<p align="justify">However, if you have no data to import and want to <b>collect the data fresh</b>, you may need to create the baskets.</p>
<p align="justify">The checked baskets are those that Model Baker has identified as <i>relevant</i> according to the recognised <a href="https://opengisch.github.io/QgisModelBaker/background_info/extended_models_optimization/#basket-handling">inheritance</a>.</p>
"""
)
docutext = self.tr(
'Find more information about this in the <a href="https://opengisch.github.io/QgisModelBaker/user_guide/import_workflow/#5-create-baskets">documentation</a> and about baskets and datasets in general <a href="https://opengisch.github.io/QgisModelBaker/background_info/basket_handling/">here</a>...'
)
return logline, help_paragraphs, docutext
16 changes: 16 additions & 0 deletions QgisModelBaker/gui/workflow_wizard/execution_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,19 @@ def _on_process_finished(self, exit_code, result):
message = self.tr("Finished with errors!")

self.workflow_wizard.log_panel.print_info(message, level)

def help_text(self):
logline = self.tr("Run, skip or edit the required ili2db sessions...")
help_paragraphs = self.tr(
"""
<p align="justify">With the small triangle next to run, you can expand the possiblities.</p>
<p align="justify">Usually the required ili2db sessions are detected, you should not need to <b>skip</b> them.</p>
<p align="justify">You might need to <b>edit</b> the command in case your system requires it. But you would know, if you need to.</p>
<p align="justify">A pretty common use case is, that you want to import <b>invalid</b> data, to fix 'em in QGIS.<br />
So you can create schemas <b>without constraints</b> and/or import data <b>without validation</b>.</p>
"""
)
docutext = self.tr(
'Find more information about this in the <a href="https://opengisch.github.io/QgisModelBaker/user_guide/import_workflow/#4-run-ili2db-sessions">documentation</a>...'
)
return logline, help_paragraphs, docutext
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,21 @@ def _set_current_export_target(self, text):
== QValidator.Acceptable
)
self.workflow_wizard.current_export_target = text

def help_text(self):
logline = self.tr(
"You want to export your data to an xml-file? There are two big options..."
)
help_paragraphs = self.tr(
"""
<h4>Filter</h4>
<p align="justify">You can filter your data by the models, datasets or baskets in which it is stored.</p>
<h4>Format</h4>
<p align="justify">Still you can choose <b>Export data in another model</b>, which allows you to select a base model as the data format.<br />
Even if the data is stored in an extended model.</p>
"""
)
docutext = self.tr(
'Find more information about <b>exporting data</b> in the <a href="https://opengisch.github.io/QgisModelBaker/user_guide/export_workflow/#2-export-data">documentation</a>...'
)
return logline, help_paragraphs, docutext
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,24 @@ def _datasetmanager_dialog_finished(self):
gui_utils.SourceModel.Columns.DATASET,
DatasetComboDelegate(self, self.db_connector),
)

def help_text(self):
logline = self.tr(
"Now you can see all the datafiles to import into your database..."
)
help_paragraphs = self.tr(
"""
<h4>The list</h4>
<p align="justify">Those are the datafiles you've chosen for import or were detected automatically. If one shouldn't be there, you can remove it with <code><b>-</b></code>.</p>
<p align="justify">Maybe you want to add <b>referenced data</b> file from the repositories (ilidata.xml).</p>
<p align="justify">Or you may want to change the order of the imports (perhaps the user data depends on the catalogue data, etc.),<br />which you can do by dragging and dropping with the arrows on the left.</p>
<h4>Delete</h4>
<p align="justify">If you choose to delete, the existing data will be deleted before the new data is imported.<br />Usually this makes no difference when using baskets, as an update will also replace the data.</p>
<h4>Dataset</h4>
<p align="justify">Choose the dataset. If you need another, then create a new one via the <b>Dataset manager</b>.</p>
"""
)
docutext = self.tr(
'Find more information about this page in the <a href="https://opengisch.github.io/QgisModelBaker/user_guide/import_workflow/#6-import-of-interlis-data">documentation</a> and about baskets and datasets in general <a href="https://opengisch.github.io/QgisModelBaker/background_info/basket_handling/">here</a> ...'
)
return logline, help_paragraphs, docutext
Original file line number Diff line number Diff line change
Expand Up @@ -578,3 +578,28 @@ def _load_metaconfig(self):
self.workflow_wizard.refresh_import_models()

self.workflow_wizard.busy(self, False)

def help_text(self):
logline = self.tr(
"Now the given models are detected. You may not need all of 'em..."
)
help_paragraphs = self.tr(
"""
<p align="justify">There are several ways the Model Baker wizard detects INTERLIS models:
<ul>
<li>Read from the selected local ini file.</li>
<li>Selected from the repositories.</li>
<li>Parsed from the selected transfer or catalogue files.</li>
<li>Depending model of a catalogue referenced in the ilidata.xml of the repositories.</li>
<li>Defined as ili2db attribute in the metaconfiguration received from the UsabILIty Hub.</li>
</ul></p>
<p align="justify">You can <b>check or uncheck</b> the models you want to import to a physical schema.</p>
<p align="justify">As well you can select a <b>Metaconfiguration</b> file from the repositories to load ili2db settings and styling properties into QGIS project.<br />
More information about those metaconfigurations in the <a href="https://opengisch.github.io/QgisModelBaker/background_info/usabilityhub/modelbaker_integration/">documentation</a>.</p>
<p align="justify">The <b>Advanced Options</b> allow you to edit the most important <b>ili2db settings</b></p>
"""
)
docutext = self.tr(
'Find more information about this in the <a href="https://opengisch.github.io/QgisModelBaker/user_guide/import_workflow/#3-import-of-interlis-model">documentation</a>...'
)
return logline, help_paragraphs, docutext
15 changes: 15 additions & 0 deletions QgisModelBaker/gui/workflow_wizard/import_source_selection_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,18 @@ def _clear_cache_button_clicked(self):
IliToppingFileCache.CACHE_PATH, str(exception)
),
)

def help_text(self):
logline = self.tr(
"Here you need to add the models and/or files you want to use..."
)
help_paragraphs = self.tr(
"""
<p align="justify">You can select a model from the <b>repository</b> and add it with the <code><b>+</b></code>.</p>
<p align="justify">You can add <b>local files</b> (<code>ili</code>, <code>xtf</code>, <code>xml</code>, <code>toml</code> etc.) via the file browser or with <b>drag and drop</b>.</p>
"""
)
docutext = self.tr(
'Find more information about the <b>source selection</b> in the <a href="https://opengisch.github.io/QgisModelBaker/user_guide/import_workflow/#1-source-selection">documentation</a>...'
)
return logline, help_paragraphs, docutext
20 changes: 20 additions & 0 deletions QgisModelBaker/gui/workflow_wizard/intro_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,23 @@ def _on_generate(self):
def _on_export(self):
self.next_id = gui_utils.PageIds.ExportDatabaseSelection
self.workflow_wizard.next()

def help_text(self):
logline = self.tr(
"You have just opened the Workflow Wizard, now you need to choose your plans..."
)
help_paragraphs = self.tr(
"""
<h4 align="justify">> Choose data files and models to import or generate a new database</h4>
<p align="justify">If you want to <b>create a physical database </b> based on an INTERLIS model, regardless of whether it is based on an ili-file or a model from the repository.</p>
<p align="justify">Or if you want to <b>import data</b> (catalogues or user data), regardless of whether the database already exists or not.</p>
<h4 align="justify">> Generate a QGIS Project from an existing database</h4>
<p align="justify">If you want to select a database from which to <b>create a QGIS project</b>.</p>
<h4 align="justify">> Export data from an existing database</h4>
<p align="justify">If you want to <b>export data</b> to an XTF file.</p>
"""
)
docutext = self.tr(
'Find more information about the <b>workflow wizard</b> in the <a href="https://opengisch.github.io/QgisModelBaker/user_guide/import_workflow/">documentation</a>...'
)
return logline, help_paragraphs, docutext
19 changes: 19 additions & 0 deletions QgisModelBaker/gui/workflow_wizard/project_creation_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,3 +711,22 @@ def _inheritance(self):
for setting_record in setting_records:
if setting_record["tag"] == "ch.ehi.ili2db.inheritanceTrafo":
return setting_record["setting"]

def help_text(self):
logline = self.tr(
"Most of the time you won't need to change anything here.<br />Just press Generate :-)"
)
help_paragraphs = self.tr(
"""
<h4>Project Topping</h4>
<p align="justify">If your database was created using a <b>metaconfiguration</b> (you'd know this), it will now be recognised.</p>
<p align="justify">If not, you may still be able to choose a <b>project topping</b> from the repositories.</p>
<h4>Project Optimization</h4>
<p align="justify">The project is optimized depending on the inheritance structure of the INTERLIS model on which it is based.<br />
Means it hides unused layers etc. Read more about optimization strategies <a href="https://opengisch.github.io/QgisModelBaker/background_info/extended_models_optimization/">here</a>.</p>
"""
)
docutext = self.tr(
'Find more information about this page in the <a href="https://opengisch.github.io/QgisModelBaker/user_guide/import_workflow/#7-generate-the-qgis-project">documentation</a>...'
)
return logline, help_paragraphs, docutext
18 changes: 18 additions & 0 deletions QgisModelBaker/gui/workflow_wizard/tid_configuration_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,21 @@ def _set_tid_configuration(self):
self.workflow_wizard.log_panel.print_info(message, LogLevel.WARNING)
self.progress_bar.setValue(100)
self.setStyleSheet(gui_utils.ERROR_STYLE)

def help_text(self):
logline = self.tr(
"OIDs can be a pain to fill up - let Model Baker do it for you..."
)
help_paragraphs = self.tr(
"""
<p align="justify">Model Baker recognized the OID Type according to the model and proposed <b>default expressions</b>.</p>
<p align="justify">You still can change them. In case of <b><code>STANDARDOID</code></b> you have to set your own prefix.</p>
<h4>Reset the <code>t_id</code> value</h4>
<p align="justify">When using <code>STANDARDOID</code> or <code>I32OID</code> we need a sequence. Here we take the one from the <code>t_id</code>.<br />
When you change it here, be aware that you don't set it lower than a currently used <code>t_id</code>.</p>
"""
)
docutext = self.tr(
'Find more information about this page in the <a href="https://opengisch.github.io/QgisModelBaker/user_guide/import_workflow/#8-oid-values">documentation</a> and about OID settings in general <a href="https://opengisch.github.io/QgisModelBaker/background_info/oid_tid_generator/#tid_(oid)_manager">here</a>'
)
return logline, help_paragraphs, docutext
60 changes: 59 additions & 1 deletion QgisModelBaker/gui/workflow_wizard/workflow_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import re

from qgis.PyQt.QtCore import QEventLoop, QSize, Qt, QTimer
from qgis.PyQt.QtGui import QPixmap
from qgis.PyQt.QtWidgets import QDialog, QSplitter, QVBoxLayout, QWizard

import QgisModelBaker.libs.modelbaker.utils.db_utils as db_utils
Expand Down Expand Up @@ -81,7 +82,7 @@ def __init__(self, iface, base_config, parent):

self.setWindowTitle(self.tr("QGIS Model Baker Wizard"))
self.setWizardStyle(QWizard.ModernStyle)
self.setOption(QWizard.NoCancelButtonOnLastPage)
self.setOptions(QWizard.NoCancelButtonOnLastPage | QWizard.HaveHelpButton)

self.current_id = 0

Expand Down Expand Up @@ -215,6 +216,9 @@ def __init__(self, iface, base_config, parent):

self.currentIdChanged.connect(self.id_changed)

# on pressing the help button
self.helpRequested.connect(self._show_help)

def sizeHint(self):
return QSize(
self.fontMetrics().lineSpacing() * 48, self.fontMetrics().lineSpacing() * 48
Expand Down Expand Up @@ -694,6 +698,34 @@ def append_dropped_files(self, dropped_files, dropped_ini_files):
dropped_ini_files[0]
)

def _show_help(self):
current_id = self.currentId()
title = self.tr("Help at {}".format(self._current_page_title(current_id)))
logline, help_paragraphs, docutext = self.currentPage().help_text()
text = """<hr>
{help_paragraphs}
<hr>
{docu_and_community_paragraphs}
""".format(
help_paragraphs=help_paragraphs,
docutext=docutext,
docu_and_community_paragraphs=self.tr(
"""
<p align="justify">{docutext}</p>
<p align="justify">...or get community help at {forum} or at {github}</p>
"""
).format(
docutext=docutext,
forum='<a href="https://interlis.discourse.group/c/interlis-werkzeuge/qgis-model-baker">Model Baker @ INTERLIS Forum</a>',
github='<a href="https://github.com/opengisch/QgisModelBaker/issues">GitHub</a>',
),
)
log_paragraph = f'<p align="justify"><b><code>&lt; {logline}</code></b></p>'

self.help_dlg = HelpDialog(self, title, log_paragraph, text)
self.help_dlg.setAttribute(Qt.WA_DeleteOnClose)
self.help_dlg.show()

def busy(self, page, busy, text="Busy..."):
page.setEnabled(not busy)
self.log_panel.busy_bar.setVisible(busy)
Expand Down Expand Up @@ -732,3 +764,29 @@ def append_dropped_files(self, dropped_files, dropped_ini_files):
self.workflow_wizard.append_dropped_files(dropped_files, dropped_ini_files)
self.workflow_wizard.restart()
self.workflow_wizard.next()


class HelpDialog(QDialog, gui_utils.get_ui_class("help_dialog.ui")):
def __init__(
self,
parent=None,
title="Help",
logline="I need somebody",
text="Not just anybody",
):
QDialog.__init__(self, parent)
self.setupUi(self)

self.setWindowTitle(title)
scaled_pixmap = QPixmap(
os.path.join(
os.path.dirname(__file__), "../../images/QgisModelBaker-icon.svg"
)
).scaled(
int(self.fontMetrics().lineSpacing() * 4.5),
self.fontMetrics().lineSpacing() * 5,
)

self.imagelabel.setPixmap(scaled_pixmap)
self.loglinelabel.setText(logline)
self.textlabel.setText(text)
10 changes: 8 additions & 2 deletions QgisModelBaker/qgismodelbaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
QTranslator,
QUrl,
)
from qgis.PyQt.QtGui import QDesktopServices, QIcon
from qgis.PyQt.QtGui import QDesktopServices, QIcon, QPixmap
from qgis.PyQt.QtWidgets import QAction, QMessageBox
from qgis.utils import available_plugins

Expand Down Expand Up @@ -399,7 +399,13 @@ def show_help_documentation(self):

def show_about_dialog(self):
self.msg = QMessageBox()
self.msg.setIcon(QMessageBox.Information)
pixmap = QPixmap(
os.path.join(os.path.dirname(__file__), "images/QgisModelBaker-icon.svg")
).scaled(
int(self.msg.fontMetrics().lineSpacing() * 4.5),
self.msg.fontMetrics().lineSpacing() * 5,
)
self.msg.setIconPixmap(pixmap)
self.msg.setTextFormat(Qt.RichText)
self.msg.setWindowTitle(self.tr("About Model Baker"))
self.msg.setText(
Expand Down
Loading

0 comments on commit 18ec6d5

Please sign in to comment.