-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #765 from opengisch/mapthemes_export
Topping Exporter: Additive Project Settings (MapThemes, Variables and Layouts)
- Loading branch information
Showing
5 changed files
with
229 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
/*************************************************************************** | ||
------------------- | ||
begin : 2022-12-07 | ||
git sha : :%H$ | ||
copyright : (C) 2022 by Dave Signer | ||
email : david at opengis ch | ||
***************************************************************************/ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
""" | ||
|
||
from qgis.core import QgsProject | ||
from qgis.PyQt.QtCore import Qt | ||
from qgis.PyQt.QtWidgets import QWizardPage | ||
|
||
from QgisModelBaker.utils import gui_utils | ||
from QgisModelBaker.utils.gui_utils import CheckEntriesModel | ||
|
||
PAGE_UI = gui_utils.get_ui_class("topping_wizard/additives.ui") | ||
|
||
|
||
class AdditivesPage(QWizardPage, PAGE_UI): | ||
def __init__(self, parent, title): | ||
QWizardPage.__init__(self) | ||
|
||
self.topping_wizard = parent | ||
|
||
self.setupUi(self) | ||
|
||
self.setStyleSheet(gui_utils.DEFAULT_STYLE) | ||
self.setTitle(title) | ||
|
||
self.mapthemes_model = CheckEntriesModel() | ||
self.mapthemes_view.setModel(self.mapthemes_model) | ||
self.mapthemes_view.clicked.connect(self.mapthemes_view.model().check) | ||
self.mapthemes_view.space_pressed.connect(self.mapthemes_view.model().check) | ||
self.variables_model = CheckEntriesModel() | ||
self.variables_view.setModel(self.variables_model) | ||
self.variables_view.clicked.connect(self.variables_view.model().check) | ||
self.variables_view.space_pressed.connect(self.variables_view.model().check) | ||
self.layouts_model = CheckEntriesModel() | ||
self.layouts_view.setModel(self.layouts_model) | ||
self.layouts_view.clicked.connect(self.layouts_view.model().check) | ||
self.layouts_view.space_pressed.connect(self.layouts_view.model().check) | ||
|
||
def initializePage(self) -> None: | ||
maptheme_collection = QgsProject.instance().mapThemeCollection() | ||
self.mapthemes_model.setStringList(maptheme_collection.mapThemes()) | ||
self.mapthemes_model.check_all(Qt.Checked) | ||
self.mapthemes_view.setEnabled(self.mapthemes_model.rowCount()) | ||
|
||
variables_keys = [] | ||
variables_keys = QgsProject.instance().customVariables().keys() | ||
self.variables_model.setStringList(variables_keys) | ||
self.variables_model.check_all(Qt.Checked) | ||
self.mapthemes_view.setEnabled(self.variables_model.rowCount()) | ||
|
||
layout_manager = QgsProject.instance().layoutManager() | ||
layout_names = [layout.name() for layout in layout_manager.printLayouts()] | ||
self.layouts_model.setStringList(layout_names) | ||
self.layouts_model.check_all(Qt.Checked) | ||
self.layouts_view.setEnabled(self.layouts_model.rowCount()) | ||
return super().initializePage() | ||
|
||
def validatePage(self) -> bool: | ||
self.topping_wizard.topping.export_settings.mapthemes = ( | ||
self.mapthemes_model.checked_entries() | ||
) | ||
self.topping_wizard.topping.export_settings.variables = ( | ||
self.variables_model.checked_entries() | ||
) | ||
self.topping_wizard.topping.export_settings.layouts = ( | ||
self.layouts_model.checked_entries() | ||
) | ||
return super().validatePage() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>Models</class> | ||
<widget class="QDialog" name="Models"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>800</width> | ||
<height>600</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Select Files</string> | ||
</property> | ||
<layout class="QGridLayout" name="gridLayout"> | ||
<item row="0" column="0" colspan="2"> | ||
<widget class="QLabel" name="description"> | ||
<property name="minimumSize"> | ||
<size> | ||
<width>0</width> | ||
<height>0</height> | ||
</size> | ||
</property> | ||
<property name="font"> | ||
<font> | ||
<weight>75</weight> | ||
<bold>true</bold> | ||
</font> | ||
</property> | ||
<property name="text"> | ||
<string>Select the Map Themes that should be exported, as well as the custom project variables and the print layouts.</string> | ||
</property> | ||
<property name="alignment"> | ||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> | ||
</property> | ||
<property name="wordWrap"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="2" column="0" colspan="2"> | ||
<widget class="SpaceCheckListView" name="mapthemes_view" native="true"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="3" column="0" colspan="2"> | ||
<widget class="QLabel" name="variables_label"> | ||
<property name="text"> | ||
<string>Custom Project Variables</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="6" column="0" colspan="2"> | ||
<widget class="SpaceCheckListView" name="layouts_view" native="true"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="4" column="0" colspan="2"> | ||
<widget class="SpaceCheckListView" name="variables_view" native="true"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="5" column="0"> | ||
<widget class="QLabel" name="layouts_label"> | ||
<property name="text"> | ||
<string>Print Layouts (exported as templates)</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="0" colspan="2"> | ||
<widget class="QLabel" name="mapthemes_label"> | ||
<property name="text"> | ||
<string>Map Themes</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<customwidgets> | ||
<customwidget> | ||
<class>SpaceCheckListView</class> | ||
<extends></extends> | ||
<header>QgisModelBaker.utils.gui_utils</header> | ||
<container>1</container> | ||
</customwidget> | ||
</customwidgets> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters