diff --git a/.github/workflows/run_unit_tests.yml b/.github/workflows/run_unit_tests.yml
index 37628b76..c610bedb 100644
--- a/.github/workflows/run_unit_tests.yml
+++ b/.github/workflows/run_unit_tests.yml
@@ -15,13 +15,13 @@ jobs:
os: [windows-latest, ubuntu-22.04]
python-version: [3.8, 3.9, "3.10", 3.11]
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Version from Git tags
run: git describe --tags
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v4
+ uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
@@ -43,6 +43,9 @@ jobs:
- name: List packages
run:
pip list
+ - name: Install coverage
+ run:
+ python -m pip install coverage[toml]
- name: Run tests
run: |
if [ "$RUNNER_OS" != "Windows" ]; then
@@ -51,4 +54,6 @@ jobs:
coverage run -m unittest discover --verbose
shell: bash
- name: Upload coverage report to Codecov
- uses: codecov/codecov-action@v3
+ uses: codecov/codecov-action@v4
+ env:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
diff --git a/bin/append_license.py b/bin/append_license.py
index fd11f9e6..2f55f473 100755
--- a/bin/append_license.py
+++ b/bin/append_license.py
@@ -6,6 +6,7 @@
license_text = [
"######################################################################################################################\n",
"# Copyright (C) 2017-2022 Spine project consortium\n",
+ "# Copyright Spine Items contributors\n",
"# This file is part of Spine Items.\n",
"# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General\n",
"# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)\n",
diff --git a/bin/update_copyrights.py b/bin/update_copyrights.py
deleted file mode 100644
index 536f572b..00000000
--- a/bin/update_copyrights.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/env python
-
-from pathlib import Path
-import time
-
-
-current_year = time.gmtime().tm_year
-root_dir = Path(__file__).parent.parent
-project_source_dir = Path(root_dir, "spine_items")
-test_source_dir = Path(root_dir, "tests")
-
-expected = f"# Copyright (C) 2017-{current_year} Spine project consortium"
-
-
-def update_copyrights(path, suffix, recursive=True):
- for path in path.iterdir():
- if path.suffix == suffix:
- i = 0
- with open(path) as python_file:
- lines = python_file.readlines()
- for i, line in enumerate(lines[1:4]):
- if line.startswith("# Copyright (C) "):
- lines[i + 1] = lines[i + 1][:21] + str(current_year) + lines[i + 1][25:]
- break
- if len(lines) <= i + 1 or not lines[i + 1].startswith(expected):
- print(f"Confusing or no copyright: {path}")
- else:
- with open(path, "w") as python_file:
- python_file.writelines(lines)
- elif recursive and path.is_dir():
- update_copyrights(path, suffix)
-
-
-update_copyrights(root_dir, ".py", recursive=False)
-update_copyrights(project_source_dir, ".py")
-update_copyrights(project_source_dir, ".ui")
-update_copyrights(test_source_dir, ".py")
-
-print("Done. Don't forget to update append_license.py!")
diff --git a/pyproject.toml b/pyproject.toml
index e0a725e8..c2ff02ab 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -13,7 +13,7 @@ classifiers = [
]
requires-python = ">=3.8.1, <3.12"
dependencies = [
- "pyside6 >= 6.5.0, != 6.5.3",
+ "pyside6 >= 6.5.0, != 6.5.3, != 6.6.3",
"pyodbc >=4.0",
# v1.4 does not pass tests
"sqlalchemy >=1.3, <1.4",
@@ -27,9 +27,6 @@ dependencies = [
[project.urls]
Repository = "https://github.com/spine-tools/spine-items"
-[project.optional-dependencies]
-dev = ["coverage[toml]"]
-
[build-system]
requires = ["setuptools>=64", "setuptools_scm[toml]>=6.2", "wheel", "build"]
build-backend = "setuptools.build_meta"
@@ -58,5 +55,4 @@ ignore_errors = true
[tool.black]
line-length = 120
-skip-string-normalization = true
exclude = '\.git|ui|resources_icons_rc.py'
diff --git a/requirements.txt b/requirements.txt
index 2ec92a1f..51082f94 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,4 @@
-e git+https://github.com/spine-tools/Spine-Database-API.git#egg=spinedb_api
-e git+https://github.com/spine-tools/spine-engine.git#egg=spine_engine
-e git+https://github.com/spine-tools/Spine-Toolbox.git#egg=spinetoolbox
--e .[dev]
+-e .
diff --git a/spine_items/__init__.py b/spine_items/__init__.py
index 6d178f1b..0c9759f5 100644
--- a/spine_items/__init__.py
+++ b/spine_items/__init__.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,9 +10,57 @@
# this program. If not, see .
######################################################################################################################
-"""
-Spine items.
+""" Spine items. """
+from .version import __version__
-"""
-from .version import __version__
+def _factories_and_executable_items():
+ from . import data_connection
+ from .data_connection.data_connection_factory import DataConnectionFactory
+ from . import data_store
+ from .data_store.data_store_factory import DataStoreFactory
+ from . import data_transformer
+ from .data_transformer.data_transformer_factory import DataTransformerFactory
+ from .data_transformer import specification_factory
+ from . import exporter
+ from .exporter.exporter_factory import ExporterFactory
+ from .exporter import specification_factory
+ from . import importer
+ from .importer.importer_factory import ImporterFactory
+ from .importer import specification_factory
+ from . import merger
+ from .merger.merger_factory import MergerFactory
+ from . import tool
+ from .tool.tool_factory import ToolFactory
+ from .tool import specification_factory
+ from . import view
+ from .view.view_factory import ViewFactory
+
+ modules = (data_connection, data_store, data_transformer, exporter, importer, merger, tool, view)
+ item_infos = tuple(module.item_info.ItemInfo for module in modules)
+ factories = (
+ DataConnectionFactory,
+ DataStoreFactory,
+ DataTransformerFactory,
+ ExporterFactory,
+ ImporterFactory,
+ MergerFactory,
+ ToolFactory,
+ ViewFactory,
+ )
+ factories = {info.item_type(): factory for info, factory in zip(item_infos, factories)}
+ executables = {module.item_info.ItemInfo.item_type(): module.executable_item.ExecutableItem for module in modules}
+ specification_item_submodules = (data_transformer, exporter, importer, tool)
+ specification_factories = {
+ module.item_info.ItemInfo.item_type(): module.specification_factory.SpecificationFactory
+ for module in specification_item_submodules
+ }
+ return (
+ factories.copy,
+ executables.copy,
+ specification_factories.copy,
+ )
+
+
+item_factories, executable_items, item_specification_factories = _factories_and_executable_items()
+del _factories_and_executable_items
diff --git a/spine_items/animations.py b/spine_items/animations.py
index 3c560928..98ede7c5 100644
--- a/spine_items/animations.py
+++ b/spine_items/animations.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Animation class for importers and exporters.
-
-"""
-
+"""Animation class for importers and exporters."""
from PySide6.QtGui import QPainterPath, QFont, QFontMetrics
from PySide6.QtCore import Qt, Signal, Slot, QObject, QTimeLine, QRectF, QPointF, QLineF
from PySide6.QtWidgets import QGraphicsPathItem
diff --git a/spine_items/commands.py b/spine_items/commands.py
index 3a01817f..a9ca8e68 100644
--- a/spine_items/commands.py
+++ b/spine_items/commands.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,53 +10,59 @@
# this program. If not, see .
######################################################################################################################
-"""
-Undo/redo commands that can be used by multiple project items.
-
-"""
+"""Undo/redo commands that can be used by multiple project items."""
from spinetoolbox.project_commands import SpineToolboxCommand
class UpdateCancelOnErrorCommand(SpineToolboxCommand):
- def __init__(self, project_item, cancel_on_error):
+ def __init__(self, item_name, cancel_on_error, project):
"""Command to update Importer, Exporter, and Merger cancel on error setting.
Args:
- project_item (ProjectItem): Item
+ item_name (str): Item's name
cancel_on_error (bool): New setting
+ project (SpineToolboxProject): project
"""
super().__init__()
- self._project_item = project_item
+ self._item_name = item_name
self._redo_cancel_on_error = cancel_on_error
self._undo_cancel_on_error = not cancel_on_error
- self.setText(f"change {project_item.name} cancel on error setting")
+ self._project = project
+ self.setText(f"change {item_name} cancel on error setting")
def redo(self):
- self._project_item.set_cancel_on_error(self._redo_cancel_on_error)
+ item = self._project.get_item(self._item_name)
+ item.set_cancel_on_error(self._redo_cancel_on_error)
def undo(self):
- self._project_item.set_cancel_on_error(self._undo_cancel_on_error)
+ item = self._project.get_item(self._item_name)
+ item.set_cancel_on_error(self._undo_cancel_on_error)
class UpdateOnConflictCommand(SpineToolboxCommand):
- def __init__(self, project_item, on_conflict):
+ def __init__(self, item_name, on_conflict, project):
"""Command to update Importer and Merger 'on conflict' setting.
Args:
- project_item (ProjectItem): Item
+ item_name (str): Item's name
on_conflict (str): New setting
+ project (SpineToolboxProject): project
"""
super().__init__()
- self._project_item = project_item
+ self._item_name = item_name
self._redo_on_conflict = on_conflict
- self._undo_on_conflict = self._project_item.on_conflict
- self.setText(f"change {project_item.name} on conflict setting")
+ project_item = project.get_item(item_name)
+ self._undo_on_conflict = project_item.on_conflict
+ self._project = project
+ self.setText(f"change {item_name} on conflict setting")
def redo(self):
- self._project_item.set_on_conflict(self._redo_on_conflict)
+ item = self._project.get_item(self._item_name)
+ item.set_on_conflict(self._redo_on_conflict)
def undo(self):
- self._project_item.set_on_conflict(self._undo_on_conflict)
+ item = self._project.get_item(self._item_name)
+ item.set_on_conflict(self._undo_on_conflict)
class ChangeItemSelectionCommand(SpineToolboxCommand):
@@ -82,42 +89,52 @@ def undo(self):
class UpdateCmdLineArgsCommand(SpineToolboxCommand):
- def __init__(self, item, cmd_line_args):
+ def __init__(self, item_name, cmd_line_args, project):
"""Command to update Tool command line args.
Args:
- item (ProjectItemBase): the item
+ item_name (str): item's name
cmd_line_args (list): list of command line args
+ project (SpineToolboxProject): project
"""
super().__init__()
- self.item = item
- self.redo_cmd_line_args = cmd_line_args
- self.undo_cmd_line_args = self.item.cmd_line_args
- self.setText(f"change command line arguments of {item.name}")
+ self._item_name = item_name
+ self._redo_cmd_line_args = cmd_line_args
+ item = project.get_item(item_name)
+ self._undo_cmd_line_args = item.cmd_line_args
+ self._project = project
+ self.setText(f"change command line arguments of {item_name}")
def redo(self):
- self.item.update_cmd_line_args(self.redo_cmd_line_args)
+ item = self._project.get_item(self._item_name)
+ item.update_cmd_line_args(self._redo_cmd_line_args)
def undo(self):
- self.item.update_cmd_line_args(self.undo_cmd_line_args)
+ item = self._project.get_item(self._item_name)
+ item.update_cmd_line_args(self._undo_cmd_line_args)
class UpdateGroupIdCommand(SpineToolboxCommand):
- def __init__(self, item, group_id):
+ def __init__(self, item_name, group_id, project):
"""Command to update item group identifier.
Args:
- item (ProjectItemBase): the item
+ item_name (str): item's name
group_id (str): group identifier
+ project (SpineToolboxProject): project
"""
super().__init__()
- self._item = item
+ self._item_name = item_name
self._redo_group_id = group_id
- self._undo_group_id = self._item.group_id
- self.setText(f"change group identifier of {item.name}")
+ item = project.get_item(item_name)
+ self._undo_group_id = item.group_id
+ self._project = project
+ self.setText(f"change group identifier of {item_name}")
def redo(self):
- self._item.do_set_group_id(self._redo_group_id)
+ item = self._project.get_item(self._item_name)
+ item.do_set_group_id(self._redo_group_id)
def undo(self):
- self._item.do_set_group_id(self._undo_group_id)
+ item = self._project.get_item(self._item_name)
+ item.do_set_group_id(self._undo_group_id)
diff --git a/spine_items/data_connection/__init__.py b/spine_items/data_connection/__init__.py
index 96706b48..3c83086f 100644
--- a/spine_items/data_connection/__init__.py
+++ b/spine_items/data_connection/__init__.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,7 +10,4 @@
# this program. If not, see .
######################################################################################################################
-"""
-Data connection plugin.
-
-"""
+"""Data connection plugin."""
diff --git a/spine_items/data_connection/commands.py b/spine_items/data_connection/commands.py
index f04c7dfc..9ca7d409 100644
--- a/spine_items/data_connection/commands.py
+++ b/spine_items/data_connection/commands.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,10 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Undo/redo commands for the DataConnection project item.
-
-"""
+"""Undo/redo commands for the DataConnection project item."""
from pathlib import Path
from spine_items.commands import SpineToolboxCommand
@@ -20,67 +18,79 @@
class AddDCReferencesCommand(SpineToolboxCommand):
"""Command to add DC references."""
- def __init__(self, dc, file_refs, db_refs):
+ def __init__(self, dc_name, file_refs, db_refs, project):
"""
Args:
- dc (DataConnection): the DC
+ dc_name (str): DC name
file_refs (list of str): list of file refs to add
db_refs (list of str): list of db refs to add
+ project (SpineToolboxProject): project
"""
super().__init__()
- self.dc = dc
- self.file_refs = file_refs
- self.db_refs = db_refs
- self.setText(f"add references to {dc.name}")
+ self._dc_name = dc_name
+ self._file_refs = file_refs
+ self._db_refs = db_refs
+ self._project = project
+ self.setText(f"add references to {dc_name}")
def redo(self):
- self.dc.do_add_references(self.file_refs, self.db_refs)
+ dc = self._project.get_item(self._dc_name)
+ dc.do_add_references(self._file_refs, self._db_refs)
def undo(self):
- self.dc.do_remove_references(self.file_refs, self.db_refs)
+ dc = self._project.get_item(self._dc_name)
+ dc.do_remove_references(self._file_refs, self._db_refs)
class RemoveDCReferencesCommand(SpineToolboxCommand):
"""Command to remove DC references."""
- def __init__(self, dc, file_refs, db_refs):
+ def __init__(self, dc_name, file_refs, db_refs, project):
"""
Args:
- dc (DataConnection): the DC
+ dc_name (str): DC name
file_refs (list of str): list of file refs to remove
db_refs (list of str): list of db refs to remove
+ project (SpineToolboxProject): project
"""
super().__init__()
- self.dc = dc
- self.file_refs = file_refs
- self.db_refs = db_refs
- self.setText(f"remove references from {dc.name}")
+ self._dc_name = dc_name
+ self._file_refs = file_refs
+ self._db_refs = db_refs
+ self._project = project
+ self.setText(f"remove references from {dc_name}")
def redo(self):
- self.dc.do_remove_references(self.file_refs, self.db_refs)
+ dc = self._project.get_item(self._dc_name)
+ dc.do_remove_references(self._file_refs, self._db_refs)
def undo(self):
- self.dc.do_add_references(self.file_refs, self.db_refs)
+ dc = self._project.get_item(self._dc_name)
+ dc.do_add_references(self._file_refs, self._db_refs)
class MoveReferenceToData(SpineToolboxCommand):
"""Command to move DC references to data."""
- def __init__(self, dc, paths):
+ def __init__(self, dc_name, paths, project):
"""
Args:
- dc (DataConnection): the DC
+ dc_name (str): DC name
paths (list of str): list of paths to move
+ project (SpineToolboxProject): project
"""
super().__init__()
- self._dc = dc
+ self._dc_name = dc_name
self._paths = paths
- self.setText("copy references to data")
+ self._project = project
+ self.setText(f"copy references to data in {dc_name}")
def redo(self):
- self._dc.do_copy_to_project(self._paths)
- self._dc.do_remove_references(self._paths, [])
+ dc = self._project.get_item(self._dc_name)
+ dc.do_copy_to_project(self._paths)
+ dc.do_remove_references(self._paths, [])
def undo(self):
- self._dc.delete_files_from_project([Path(p).name for p in self._paths])
- self._dc.do_add_references(self._paths, [])
+ dc = self._project.get_item(self._dc_name)
+ dc.delete_files_from_project([Path(p).name for p in self._paths])
+ dc.do_add_references(self._paths, [])
diff --git a/spine_items/data_connection/custom_file_system_watcher.py b/spine_items/data_connection/custom_file_system_watcher.py
index 685d20f6..7a6da872 100644
--- a/spine_items/data_connection/custom_file_system_watcher.py
+++ b/spine_items/data_connection/custom_file_system_watcher.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains CustomFileSystemWatcher.
-
-"""
-
+"""Contains CustomFileSystemWatcher."""
import os
from PySide6.QtCore import QFileSystemWatcher, Signal, Slot
diff --git a/spine_items/data_connection/data_connection.py b/spine_items/data_connection/data_connection.py
index 1b9ffaf8..9b07d1e7 100644
--- a/spine_items/data_connection/data_connection.py
+++ b/spine_items/data_connection/data_connection.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,8 +9,8 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""Module for data connection class."""
+"""Module for data connection class."""
import os
import shutil
import logging
@@ -97,11 +98,6 @@ def item_type():
"""See base class."""
return ItemInfo.item_type()
- @staticmethod
- def item_category():
- """See base class."""
- return ItemInfo.item_category()
-
@property
def executable_class(self):
return ExecutableItem
@@ -218,7 +214,7 @@ def _add_file_references(self, paths):
if repeated_paths:
self._logger.msg_warning.emit(f"Reference to file(s) {repeated_paths} already exists")
if new_paths:
- self._toolbox.undo_stack.push(AddDCReferencesCommand(self, new_paths, []))
+ self._toolbox.undo_stack.push(AddDCReferencesCommand(self.name, new_paths, [], self._project))
@Slot(bool)
def show_add_db_reference_dialog(self, _=False):
@@ -235,7 +231,7 @@ def show_add_db_reference_dialog(self, _=False):
self._database_validator.validate_url(
url["dialect"], sa_url, self._log_database_reference_error, success_slot=None
)
- self._toolbox.undo_stack.push(AddDCReferencesCommand(self, [], [url]))
+ self._toolbox.undo_stack.push(AddDCReferencesCommand(self.name, [], [url], self._project))
def _has_db_reference(self, url):
"""Checks if given database URL exists already.
@@ -255,13 +251,20 @@ def _has_db_reference(self, url):
return True
return False
- @Slot(str)
- def _log_database_reference_error(self, error):
+ @Slot(str, object)
+ def _log_database_reference_error(self, error, url):
"""Logs final database validation error messages.
Args:
error (str): message
+ url (URL): SqlAlchemy URL of the database
"""
+ url_text = remove_credentials_from_url(str(url))
+ for row in range(self._db_ref_root.rowCount()):
+ item = self._db_ref_root.child(row)
+ if url_text == item.text():
+ self._mark_as_missing(item)
+ break
self._logger.msg_error.emit(f"{self.name}: invalid database URL: {error}")
def do_add_references(self, file_refs, db_refs):
@@ -299,7 +302,9 @@ def remove_references(self, _=False):
file_references.append(index.data(Qt.ItemDataRole.DisplayRole))
elif parent == db_ref_root_index:
db_references.append(index.data(_Role.DB_URL_REFERENCE))
- self._toolbox.undo_stack.push(RemoveDCReferencesCommand(self, file_references, db_references))
+ self._toolbox.undo_stack.push(
+ RemoveDCReferencesCommand(self.name, file_references, db_references, self._project)
+ )
self._logger.msg.emit("Selected references removed")
def do_remove_references(self, file_refs, db_refs):
@@ -493,7 +498,9 @@ def copy_to_project(self, _=False):
if not selected_indexes:
self._logger.msg_warning.emit("No files to copy")
return
- self._toolbox.undo_stack.push(MoveReferenceToData(self, [index.data() for index in selected_indexes]))
+ self._toolbox.undo_stack.push(
+ MoveReferenceToData(self.name, [index.data() for index in selected_indexes], self._project)
+ )
def do_copy_to_project(self, paths):
"""Copies given files to item's data directory.
diff --git a/spine_items/data_connection/data_connection_factory.py b/spine_items/data_connection/data_connection_factory.py
index ead05841..cbe10234 100644
--- a/spine_items/data_connection/data_connection_factory.py
+++ b/spine_items/data_connection/data_connection_factory.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-The DataConnectionFactory class.
-
-"""
-
+"""The DataConnectionFactory class."""
from PySide6.QtGui import QColor
from spinetoolbox.project_item.project_item_factory import ProjectItemFactory
from .data_connection_icon import DataConnectionIcon
diff --git a/spine_items/data_connection/data_connection_icon.py b/spine_items/data_connection/data_connection_icon.py
index 05fa1f2f..3fe67d1f 100644
--- a/spine_items/data_connection/data_connection_icon.py
+++ b/spine_items/data_connection/data_connection_icon.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Module for data connection icon class.
-
-"""
-
+"""Module for data connection icon class."""
import os
from PySide6.QtCore import QObject, Qt, QTimer, Signal
from PySide6.QtWidgets import QGraphicsItem
@@ -88,4 +85,3 @@ def select_on_drag_over(self):
self._drag_over = False
self._toolbox.ui.graphicsView.scene().clearSelection()
self.setSelected(True)
- self.select_item()
diff --git a/spine_items/data_connection/executable_item.py b/spine_items/data_connection/executable_item.py
index c46beeb2..8baeb8a3 100644
--- a/spine_items/data_connection/executable_item.py
+++ b/spine_items/data_connection/executable_item.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,10 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains Data Connection's executable item as well as support utilities.
-
-"""
+"""Contains Data Connection's executable item as well as support utilities."""
import os
from spine_engine.project_item.executable_item_base import ExecutableItemBase
from spine_engine.utils.serialization import deserialize_path
@@ -29,7 +27,7 @@ def __init__(self, name, file_references, db_references, project_dir, logger):
Args:
name (str): item's name
file_references (list): a list of absolute paths to connected files
- db_references (list): a list of urls to connected dbs
+ db_references (list): a list of url dicts to connected dbs
project_dir (str): absolute path to project directory
logger (LoggerInterface): a logger
"""
diff --git a/spine_items/data_connection/item_info.py b/spine_items/data_connection/item_info.py
index fa7297f0..13ed1188 100644
--- a/spine_items/data_connection/item_info.py
+++ b/spine_items/data_connection/item_info.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,19 +10,11 @@
# this program. If not, see .
######################################################################################################################
-"""
-Data Connection project item info.
-
-"""
+"""Data Connection project item info."""
from spine_engine.project_item.project_item_info import ProjectItemInfo
class ItemInfo(ProjectItemInfo):
- @staticmethod
- def item_category():
- """See base class."""
- return "Data Connections"
-
@staticmethod
def item_type():
"""See base class."""
diff --git a/spine_items/data_connection/output_resources.py b/spine_items/data_connection/output_resources.py
index d7b66a00..6bb6c893 100644
--- a/spine_items/data_connection/output_resources.py
+++ b/spine_items/data_connection/output_resources.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,15 +9,13 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains utilities to scan for Data Connection's output resources.
-"""
+"""Contains utilities to scan for Data Connection's output resources."""
from pathlib import Path
from spine_engine.project_item.project_item_resource import file_resource, transient_file_resource, url_resource
from spine_engine.utils.serialization import path_in_dir
from spinedb_api.helpers import remove_credentials_from_url
-from ..utils import convert_to_sqlalchemy_url, unsplit_url_credentials
+from ..utils import convert_to_sqlalchemy_url
def scan_for_resources(provider, file_paths, urls, project_dir):
diff --git a/spine_items/data_connection/ui/__init__.py b/spine_items/data_connection/ui/__init__.py
index 4a162847..a7ecd49b 100644
--- a/spine_items/data_connection/ui/__init__.py
+++ b/spine_items/data_connection/ui/__init__.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
diff --git a/spine_items/data_connection/ui/data_connection_properties.py b/spine_items/data_connection/ui/data_connection_properties.py
index a750371b..9e63b68b 100644
--- a/spine_items/data_connection/ui/data_connection_properties.py
+++ b/spine_items/data_connection/ui/data_connection_properties.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
diff --git a/spine_items/data_connection/utils.py b/spine_items/data_connection/utils.py
index 1e8b5b4c..382b27d8 100644
--- a/spine_items/data_connection/utils.py
+++ b/spine_items/data_connection/utils.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,6 +9,7 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
+
"""This module contains utilities for Data Connection."""
import sys
import urllib.parse
@@ -32,18 +34,20 @@ def restore_database_references(references_list, credentials_dict, project_dir):
# legacy db reference
url = urllib.parse.urlparse(reference_dict)
dialect = _dialect_from_scheme(url.scheme)
- database = url.path[1:]
+ path = url.path
+ if dialect == "sqlite" and sys.platform == "win32":
+ # Remove extra '/' from file path on Windows.
+ path = path[1:]
db_reference = {
"dialect": dialect,
"host": url.hostname,
"port": url.port,
- "database": database,
+ "database": path,
}
else:
db_reference = dict(reference_dict)
if db_reference["dialect"] == "sqlite":
db_reference["database"] = deserialize_path(db_reference["database"], project_dir)
-
db_reference["username"], db_reference["password"] = credentials_dict.get(
convert_url_to_safe_string(db_reference), (None, None)
)
diff --git a/spine_items/data_connection/widgets/__init__.py b/spine_items/data_connection/widgets/__init__.py
index f722e088..672b5890 100644
--- a/spine_items/data_connection/widgets/__init__.py
+++ b/spine_items/data_connection/widgets/__init__.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,7 +10,4 @@
# this program. If not, see .
######################################################################################################################
-"""
-Widgets for the Data Connection project item.
-
-"""
+"""Widgets for the Data Connection project item."""
diff --git a/spine_items/data_connection/widgets/add_data_connection_widget.py b/spine_items/data_connection/widgets/add_data_connection_widget.py
index e5dce92d..861b3d8a 100644
--- a/spine_items/data_connection/widgets/add_data_connection_widget.py
+++ b/spine_items/data_connection/widgets/add_data_connection_widget.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Widget shown to user when a new Data Connection is created.
-
-"""
-
+"""Widget shown to user when a new Data Connection is created."""
from spinetoolbox.widgets.add_project_item_widget import AddProjectItemWidget
from ..data_connection import DataConnection
from ..item_info import ItemInfo
diff --git a/spine_items/data_connection/widgets/custom_menus.py b/spine_items/data_connection/widgets/custom_menus.py
index c970a005..9904b3ae 100644
--- a/spine_items/data_connection/widgets/custom_menus.py
+++ b/spine_items/data_connection/widgets/custom_menus.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Classes for custom context menus and pop-up menus.
-
-"""
-
+"""Classes for custom context menus and pop-up menus."""
from spinetoolbox.widgets.custom_menus import CustomContextMenu
@@ -37,7 +34,7 @@ def __init__(self, parent, position, index, dc):
self.add_action("Remove reference(s)", enabled=dc.any_refs_selected)
self.add_action("Copy file reference(s) to project", enabled=dc.file_refs_selected)
self.addSeparator()
- self.add_action("Refresh reference(s)", enabled=dc.file_refs_selected)
+ self.add_action("Refresh reference(s)", enabled=dc.any_refs_selected)
class DcDataContextMenu(CustomContextMenu):
diff --git a/spine_items/data_connection/widgets/data_connection_properties_widget.py b/spine_items/data_connection/widgets/data_connection_properties_widget.py
index 3c5a9e3a..7dc2112f 100644
--- a/spine_items/data_connection/widgets/data_connection_properties_widget.py
+++ b/spine_items/data_connection/widgets/data_connection_properties_widget.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Data connection properties widget.
-
-"""
-
+"""Data connection properties widget."""
import os
from PySide6.QtCore import QPoint, Qt, Slot, QUrl
from spinetoolbox.widgets.properties_widget import PropertiesWidgetBase
@@ -51,8 +48,7 @@ def show_references_context_menu(self, pos):
pos (QPoint): Mouse position
"""
index = self.ui.treeView_dc_references.indexAt(pos)
- dc_index = self._toolbox.ui.treeView_project.currentIndex()
- dc = self._toolbox.project_item_model.item(dc_index).project_item
+ dc = self._active_item
global_pos = self.ui.treeView_dc_references.viewport().mapToGlobal(pos)
dc_ref_context_menu = DcRefContextMenu(self, global_pos, index, dc)
option = dc_ref_context_menu.get_action()
@@ -86,8 +82,7 @@ def show_data_context_menu(self, pos):
pos (QPoint): Mouse position
"""
index = self.ui.treeView_dc_data.indexAt(pos)
- dc_index = self._toolbox.ui.treeView_project.currentIndex()
- dc = self._toolbox.project_item_model.item(dc_index).project_item
+ dc = self._active_item
global_pos = self.ui.treeView_dc_data.viewport().mapToGlobal(pos)
dc_data_context_menu = DcDataContextMenu(self, global_pos, index, dc)
option = dc_data_context_menu.get_action()
diff --git a/spine_items/data_store/__init__.py b/spine_items/data_store/__init__.py
index 4086ac13..86f6272f 100644
--- a/spine_items/data_store/__init__.py
+++ b/spine_items/data_store/__init__.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,7 +10,4 @@
# this program. If not, see .
######################################################################################################################
-"""
-Data store plugin.
-
-"""
+"""Data store plugin."""
diff --git a/spine_items/data_store/commands.py b/spine_items/data_store/commands.py
index a68b813f..4f096164 100644
--- a/spine_items/data_store/commands.py
+++ b/spine_items/data_store/commands.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,10 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Undo/redo commands for the DataStore project item.
-
-"""
+"""Undo/redo commands for the DataStore project item."""
from enum import IntEnum, unique
from spine_items.commands import SpineToolboxCommand
@@ -23,33 +21,41 @@ class CommandId(IntEnum):
class UpdateDSURLCommand(SpineToolboxCommand):
- def __init__(self, ds, was_url_valid, **kwargs):
- """Command to update DS url.
+ """Command to update DS url."""
+ def __init__(self, ds_name, was_url_valid, project, **kwargs):
+ """
Args:
- ds (DataStore): the DS
+ ds_name (str): DS name
was_url_valid (bool): True if previous URL was valid, False otherwise
- kwargs: url keys and their values
+ project (SpineToolboxProject): project
+ **kwargs: url keys and their values
"""
super().__init__()
- self.ds = ds
+ self._ds_name = ds_name
self._undo_url_is_valid = was_url_valid
- self.redo_kwargs = kwargs
- self.undo_kwargs = {k: self.ds.url()[k] for k in kwargs}
+ self._redo_kwargs = kwargs
+ ds = project.get_item(ds_name)
+ self._undo_kwargs = {k: ds.url()[k] for k in kwargs}
+ self._project = project
if len(kwargs) == 1:
- self.setText(f"change {list(kwargs.keys())[0]} of {ds.name}")
+ self.setText(f"change {list(kwargs.keys())[0]} of {ds_name}")
else:
- self.setText(f"change url of {ds.name}")
+ self.setText(f"change url of {ds_name}")
def id(self):
return CommandId.UPDATE_URL.value
def mergeWith(self, command):
- if not isinstance(command, UpdateDSURLCommand) or self.ds is not command.ds or command._undo_url_is_valid:
+ if (
+ not isinstance(command, UpdateDSURLCommand)
+ or self._ds_name != command._ds_name
+ or command._undo_url_is_valid
+ ):
return False
diff_key = None
- for key, value in self.redo_kwargs.items():
- old_value = self.undo_kwargs[key]
+ for key, value in self._redo_kwargs.items():
+ old_value = self._undo_kwargs[key]
if value != old_value:
if diff_key is not None:
return False
@@ -59,16 +65,18 @@ def mergeWith(self, command):
raise RuntimeError("Logic error: nothing changes between undo and redo URLs.")
if diff_key == "dialect":
return False
- changed_value = command.redo_kwargs[diff_key]
- if self.redo_kwargs[diff_key] == changed_value:
+ changed_value = command._redo_kwargs[diff_key]
+ if self._redo_kwargs[diff_key] == changed_value:
return False
- self.redo_kwargs[diff_key] = changed_value
- if self.redo_kwargs[diff_key] == self.undo_kwargs[diff_key]:
+ self._redo_kwargs[diff_key] = changed_value
+ if self._redo_kwargs[diff_key] == self._undo_kwargs[diff_key]:
self.setObsolete(True)
return True
def redo(self):
- self.ds.do_update_url(**self.redo_kwargs)
+ ds = self._project.get_item(self._ds_name)
+ ds.do_update_url(**self._redo_kwargs)
def undo(self):
- self.ds.do_update_url(**self.undo_kwargs)
+ ds = self._project.get_item(self._ds_name)
+ ds.do_update_url(**self._undo_kwargs)
diff --git a/spine_items/data_store/data_store.py b/spine_items/data_store/data_store.py
index 536ae6b7..fa19e24d 100644
--- a/spine_items/data_store/data_store.py
+++ b/spine_items/data_store/data_store.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,18 +10,14 @@
# this program. If not, see .
######################################################################################################################
-"""
-Module for data store class.
-
-"""
-
+""" Module for data store class. """
import os
from dataclasses import dataclass
from shutil import copyfile
from PySide6.QtCore import Slot
from PySide6.QtWidgets import QFileDialog, QApplication, QMenu
from PySide6.QtGui import QAction
-from spinedb_api.helpers import vacuum
+from spinedb_api.helpers import remove_credentials_from_url, vacuum
from spine_engine.project_item.project_item_resource import database_resource, ProjectItemResource
from spinetoolbox.project_item.project_item import ProjectItem
from spinetoolbox.helpers import create_dir
@@ -74,17 +71,21 @@ def __init__(self, name, description, x, y, toolbox, project, url):
self._purge_settings = None
self._purge_dialog = None
self._database_validator = DatabaseConnectionValidator(self)
+ db_map = self.get_db_map_for_ds()
+ # Notify db manager about the Data Stores in the project so it can notify abobut the dirtyness of them
+ self._toolbox.db_mngr.add_data_store_db_map(db_map, self)
+
+ def get_db_map_for_ds(self):
+ """Returns the db map for the Data Store"""
+ if self._url.get("dialect"):
+ return self._toolbox.db_mngr.get_db_map(self.sql_alchemy_url(), self._logger, codename=self.name)
+ return None
@staticmethod
def item_type():
"""See base class."""
return ItemInfo.item_type()
- @staticmethod
- def item_category():
- """See base class."""
- return ItemInfo.item_category()
-
@property
def executable_class(self):
return ExecutableItem
@@ -157,7 +158,7 @@ def _new_sqlite_file(self):
url = dict(self._url)
url["database"] = abs_path
sa_url = convert_to_sqlalchemy_url(url, self.name)
- self._toolbox.db_mngr.create_new_spine_database(sa_url, self._logger)
+ self._toolbox.db_mngr.create_new_spine_database(sa_url, self._logger, overwrite=True)
self.update_url(dialect="sqlite", database=abs_path)
return True
@@ -188,7 +189,7 @@ def update_url(self, **kwargs):
kwargs = {k: v for k, v in kwargs.items() if v != self._url[k]}
if not kwargs:
return False
- self._toolbox.undo_stack.push(UpdateDSURLCommand(self, invalidating_url, **kwargs))
+ self._toolbox.undo_stack.push(UpdateDSURLCommand(self.name, invalidating_url, self._project, **kwargs))
return True
def do_update_url(self, **kwargs):
@@ -214,6 +215,20 @@ def do_update_url(self, **kwargs):
self._resources_to_successors_changed()
self._check_notifications()
+ def has_listeners(self):
+ """Checks whether the Data Store has listeners or not
+
+ Returns:
+ (bool): True if there are listeners for the Data Store, False otherwise
+ """
+ if self._multi_db_editors_open:
+ return bool(
+ self._toolbox.db_mngr.db_map_listeners(
+ self._toolbox.db_mngr.get_db_map(self.sql_alchemy_url(), self._logger, codename=self.name)
+ )
+ )
+ return False
+
def _update_actions_enabled(self):
url_exists = convert_to_sqlalchemy_url(self._url, self.name) is not None
url_valid = url_exists and self._url_validated
@@ -244,7 +259,7 @@ def _show_purge_dialog(self, _=False):
def _purge(self):
"""Purges the database."""
self._purge_settings = self._purge_dialog.get_checked_states()
- db_map = self._toolbox.db_mngr.get_db_map(self.sql_alchemy_url(), self._logger, self.name)
+ db_map = self._toolbox.db_mngr.get_db_map(self.sql_alchemy_url(), self._logger, codename=self.name)
if db_map is None:
return
db_map_purge_data = {db_map: {item_type for item_type, checked in self._purge_settings.items() if checked}}
@@ -280,18 +295,17 @@ def _handle_open_url_menu_triggered(self, action):
@Slot(bool)
def open_url_in_spine_db_editor(self, checked=False):
"""Opens current url in the Spine database editor."""
- if not self._url_validated:
- self._logger.msg_error.emit(
- f"{self.name} is still validating the database URL or the URL is invalid."
- )
- return
- sa_url = self.sql_alchemy_url()
- if sa_url is not None:
- db_url_codenames = {sa_url: self.name}
- self._toolbox.db_mngr.open_db_editor(db_url_codenames)
- self._check_notifications()
+ self._open_spine_db_editor(reuse_existing=True)
def _open_url_in_new_db_editor(self, checked=False):
+ self._open_spine_db_editor(reuse_existing=False)
+
+ def _open_spine_db_editor(self, reuse_existing):
+ """Opens Data Store's URL in Spine Database editor.
+
+ Args:
+ reuse_existing (bool): if True and the URL is already open, just raise the window
+ """
if not self._url_validated:
self._logger.msg_error.emit(
f"{self.name} is still validating the database URL or the URL is invalid."
@@ -299,7 +313,9 @@ def _open_url_in_new_db_editor(self, checked=False):
return
sa_url = self.sql_alchemy_url()
if sa_url is not None:
- MultiSpineDBEditor(self._toolbox.db_mngr, {sa_url: self.name}).show()
+ db_url_codenames = {sa_url: self.name}
+ self._toolbox.db_mngr.open_db_editor(db_url_codenames, reuse_existing)
+ self._check_notifications()
def _open_url_in_existing_db_editor(self, db_editor):
if not self._url_validated:
@@ -344,6 +360,7 @@ def create_new_spine_database(self, checked=False):
def _check_notifications(self):
"""Updates the SqlAlchemy format URL and checks for notifications"""
+ self.clear_notifications()
self._update_actions_enabled()
sa_url = convert_to_sqlalchemy_url(self._url, self.name)
if sa_url is None:
@@ -355,25 +372,45 @@ def _check_notifications(self):
self._database_validator.validate_url(
self._url["dialect"], sa_url, self._set_invalid_url_notification, self._accept_url
)
+ db_map = self.get_db_map_for_ds()
+ if db_map:
+ clean = not self._toolbox.db_mngr.is_dirty(db_map)
+ self.notify_about_dirtiness(clean)
- @Slot(str)
- def _set_invalid_url_notification(self, error_message):
+ @Slot(bool)
+ def notify_about_dirtiness(self, clean):
+ """
+ Handles the notification for the dirtiness of the Data Store
+
+ Args:
+ clean (bool): Whether the db_map corresponding to the DS is clean
+ """
+ if not clean:
+ self.add_notification(f"{self.name} has uncommitted changes")
+ else:
+ self.remove_notification(f"{self.name} has uncommitted changes")
+
+ @Slot(str, object)
+ def _set_invalid_url_notification(self, error_message, url):
"""Sets a single notification that warns about broken URL.
Args:
error_message (str): URL failure message
+ url (URL): SqlAlchemy URL
"""
self.clear_notifications()
- self.add_notification(f"Couldn't connect to the database: {error_message}")
+ self.add_notification(
+ f"Couldn't connect to the database {remove_credentials_from_url(str(url))}: {error_message}"
+ )
if self._resource_to_replace is None:
self._resources_to_predecessors_changed()
self._resources_to_successors_changed()
- @Slot()
- def _accept_url(self):
+ @Slot(object)
+ def _accept_url(self, url):
"""Sets URL as validated and updates advertised resources."""
self._url_validated = True
- self.clear_notifications()
+ self.clear_other_notifications(f"{self.name} has uncommitted changes")
if self._resource_to_replace is not None and self._resource_to_replace.is_valid:
old = self._resource_to_replace.resource
sa_url = convert_to_sqlalchemy_url(self._url, self.name)
@@ -385,6 +422,7 @@ def _accept_url(self):
self._resources_to_predecessors_changed()
self._resources_to_successors_changed()
self._update_actions_enabled()
+ self._toolbox.db_mngr.update_data_store_db_maps()
def is_url_validated(self):
"""Tests whether the URL has been validated.
@@ -446,6 +484,8 @@ def from_dict(name, item_dict, toolbox, project):
def rename(self, new_name, rename_data_dir_message):
"""See base class."""
old_data_dir = os.path.abspath(self.data_dir) # Old data_dir before rename
+ old_name = self.name
+ self.rename_data_store_in_db_mngr(old_name) # Notify db manager about the rename
if not super().rename(new_name, rename_data_dir_message):
return False
# If dialect is sqlite and db line edit refers to a file in the old data_dir, db line edit needs updating
@@ -494,7 +534,17 @@ def resources_for_direct_predecessors(self):
"""See base class."""
return self.resources_for_direct_successors()
+ def rename_data_store_in_db_mngr(self, old_name):
+ """Renames the Data Store in the used db manager"""
+ db_map = self.get_db_map_for_ds()
+ self._toolbox.db_mngr.update_data_store_db_maps()
+ index = next((i for i, store in enumerate(self._toolbox.db_mngr.data_stores[db_map]) if store.name == old_name))
+ if index is not None:
+ self._toolbox.db_mngr.data_stores[db_map][index] = self
+
def tear_down(self):
"""See base class"""
self._database_validator.wait_for_finish()
+ db_map = self.get_db_map_for_ds()
+ self._toolbox.db_mngr.remove_data_store_db_map(db_map, self)
super().tear_down()
diff --git a/spine_items/data_store/data_store_factory.py b/spine_items/data_store/data_store_factory.py
index 7cc897f6..07d2a4ad 100644
--- a/spine_items/data_store/data_store_factory.py
+++ b/spine_items/data_store/data_store_factory.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-The DataStoreFactory class.
-
-"""
-
+"""The DataStoreFactory class."""
from PySide6.QtGui import QColor
from spinetoolbox.project_item.project_item_factory import ProjectItemFactory
from .data_store import DataStore
diff --git a/spine_items/data_store/data_store_icon.py b/spine_items/data_store/data_store_icon.py
index 9ba6f51d..8104719d 100644
--- a/spine_items/data_store/data_store_icon.py
+++ b/spine_items/data_store/data_store_icon.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Module for data store icon class.
-
-"""
-
+"""Module for data store icon class."""
from spinetoolbox.project_item_icon import ProjectItemIcon
@@ -35,5 +32,5 @@ def mouseDoubleClickEvent(self, e):
e (QGraphicsSceneMouseEvent): Event
"""
super().mouseDoubleClickEvent(e)
- item = self._toolbox.project_item_model.get_item(self._name)
- item.project_item.open_url_in_spine_db_editor()
+ item = self._toolbox.project().get_item(self._name)
+ item.open_url_in_spine_db_editor()
diff --git a/spine_items/data_store/executable_item.py b/spine_items/data_store/executable_item.py
index 342e02b5..693edc9c 100644
--- a/spine_items/data_store/executable_item.py
+++ b/spine_items/data_store/executable_item.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,13 +10,10 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains Data Store's executable item as well as support utilities.
-
-"""
+"""Contains Data Store's executable item as well as support utilities."""
from pathlib import Path
from spinedb_api import DatabaseMapping
-from spinedb_api.exception import SpineDBAPIError, SpineDBVersionError
+from spinedb_api.exception import SpineDBAPIError
from spine_engine.project_item.executable_item_base import ExecutableItemBase
from spine_engine.utils.serialization import deserialize_path
from .item_info import ItemInfo
@@ -58,14 +56,15 @@ def _get_url(self):
self._logger.msg_error.emit("SQLite file does not exist.")
return None
if not self._validated:
- try:
- DatabaseMapping.create_engine(self._url, create=True)
- return self._url
- except SpineDBVersionError as v_err:
- prompt = {"type": "upgrade_db", "url": self._url, "current": v_err.current, "expected": v_err.expected}
- if not self._logger.prompt.emit(prompt):
+ prompt_data = DatabaseMapping.get_upgrade_db_prompt_data(self._url, create=True)
+ if prompt_data is not None:
+ kwargs = self._logger.prompt.emit(prompt_data)
+ if kwargs is None:
return None
- DatabaseMapping.create_engine(self._url, upgrade=True)
+ else:
+ kwargs = {}
+ try:
+ DatabaseMapping.create_engine(self._url, create=True, **kwargs)
return self._url
except SpineDBAPIError as err:
self._logger.msg_error.emit(str(err))
diff --git a/spine_items/data_store/item_info.py b/spine_items/data_store/item_info.py
index c35bfae4..53258e0a 100644
--- a/spine_items/data_store/item_info.py
+++ b/spine_items/data_store/item_info.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,19 +10,11 @@
# this program. If not, see .
######################################################################################################################
-"""
-Data Store project item info.
-
-"""
+"""Data Store project item info."""
from spine_engine.project_item.project_item_info import ProjectItemInfo
class ItemInfo(ProjectItemInfo):
- @staticmethod
- def item_category():
- """See base class."""
- return "Data Stores"
-
@staticmethod
def item_type():
"""See base class."""
diff --git a/spine_items/data_store/output_resources.py b/spine_items/data_store/output_resources.py
index 30ed936e..9705d459 100644
--- a/spine_items/data_store/output_resources.py
+++ b/spine_items/data_store/output_resources.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,10 +9,8 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains utilities to scan for Data Store's output resources.
-"""
+"""Contains utilities to scan for Data Store's output resources."""
from spine_engine.project_item.project_item_resource import database_resource
from spine_items.utils import database_label
diff --git a/spine_items/data_store/ui/__init__.py b/spine_items/data_store/ui/__init__.py
index b448fd15..2636b0c5 100644
--- a/spine_items/data_store/ui/__init__.py
+++ b/spine_items/data_store/ui/__init__.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
diff --git a/spine_items/data_store/ui/data_store_properties.py b/spine_items/data_store/ui/data_store_properties.py
index 946d9656..ebcd671f 100644
--- a/spine_items/data_store/ui/data_store_properties.py
+++ b/spine_items/data_store/ui/data_store_properties.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
diff --git a/spine_items/data_store/widgets/__init__.py b/spine_items/data_store/widgets/__init__.py
index 8a671642..f12430e0 100644
--- a/spine_items/data_store/widgets/__init__.py
+++ b/spine_items/data_store/widgets/__init__.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
diff --git a/spine_items/data_store/widgets/add_data_store_widget.py b/spine_items/data_store/widgets/add_data_store_widget.py
index 4291e0c2..60b2abe0 100644
--- a/spine_items/data_store/widgets/add_data_store_widget.py
+++ b/spine_items/data_store/widgets/add_data_store_widget.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Widget shown to user when a new Data Store is created.
-
-"""
-
+"""Widget shown to user when a new Data Store is created."""
from spinetoolbox.widgets.add_project_item_widget import AddProjectItemWidget
from ..data_store import DataStore
from ..item_info import ItemInfo
diff --git a/spine_items/data_store/widgets/data_store_properties_widget.py b/spine_items/data_store/widgets/data_store_properties_widget.py
index 9fa22c4c..68e0d612 100644
--- a/spine_items/data_store/widgets/data_store_properties_widget.py
+++ b/spine_items/data_store/widgets/data_store_properties_widget.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Data store properties widget.
-
-"""
-
+"""Data store properties widget."""
from spinetoolbox.widgets.properties_widget import PropertiesWidgetBase
from spinedb_api import SUPPORTED_DIALECTS
from ...widgets import UrlSelectorMixin
diff --git a/spine_items/data_transformer/__init__.py b/spine_items/data_transformer/__init__.py
index ccec3891..9ee74808 100644
--- a/spine_items/data_transformer/__init__.py
+++ b/spine_items/data_transformer/__init__.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,7 +10,4 @@
# this program. If not, see .
######################################################################################################################
-"""
-Data transformer plugin.
-
-"""
+"""Data transformer plugin."""
diff --git a/spine_items/data_transformer/commands.py b/spine_items/data_transformer/commands.py
index 1865679f..6122a4b7 100644
--- a/spine_items/data_transformer/commands.py
+++ b/spine_items/data_transformer/commands.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,10 +9,8 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains Data transformer's undo commands.
-"""
+"""Contains Data transformer's undo commands."""
from PySide6.QtGui import QUndoCommand
diff --git a/spine_items/data_transformer/data_transformer.py b/spine_items/data_transformer/data_transformer.py
index 02e9f9f7..01c5b7ee 100644
--- a/spine_items/data_transformer/data_transformer.py
+++ b/spine_items/data_transformer/data_transformer.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,10 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains the :class:`DataTransformer` project item.
-
-"""
+"""Contains the :class:`DataTransformer` project item."""
from json import dump
from PySide6.QtCore import Slot
from spinetoolbox.project_item.project_item import ProjectItem
@@ -52,11 +50,6 @@ def item_type():
"""See base class."""
return ItemInfo.item_type()
- @staticmethod
- def item_category():
- """See base class."""
- return ItemInfo.item_category()
-
@property
def executable_class(self):
return ExecutableItem
diff --git a/spine_items/data_transformer/data_transformer_factory.py b/spine_items/data_transformer/data_transformer_factory.py
index b4a069c9..f586982a 100644
--- a/spine_items/data_transformer/data_transformer_factory.py
+++ b/spine_items/data_transformer/data_transformer_factory.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains the :class:`DataTransformerFactory` class.
-
-"""
-
+"""Contains the :class:`DataTransformerFactory` class."""
from PySide6.QtGui import QColor
from spinetoolbox.project_item.project_item_factory import ProjectItemFactory
from spinetoolbox.widgets.custom_menus import ItemSpecificationMenu
diff --git a/spine_items/data_transformer/data_transformer_icon.py b/spine_items/data_transformer/data_transformer_icon.py
index a2db920b..300b9e5f 100644
--- a/spine_items/data_transformer/data_transformer_icon.py
+++ b/spine_items/data_transformer/data_transformer_icon.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains :class:`DataTransformerIcon`.
-
-"""
-
+"""Contains :class:`DataTransformerIcon`."""
from spinetoolbox.project_item_icon import ProjectItemIcon
@@ -36,5 +33,5 @@ def mouseDoubleClickEvent(self, e):
e (QGraphicsSceneMouseEvent): Event
"""
super().mouseDoubleClickEvent(e)
- item = self._toolbox.project_item_model.get_item(self._name)
- item.project_item.show_specification_window()
+ item = self._toolbox.project().get_item(self._name)
+ item.show_specification_window()
diff --git a/spine_items/data_transformer/data_transformer_specification.py b/spine_items/data_transformer/data_transformer_specification.py
index 5c27b2ef..2d738fd9 100644
--- a/spine_items/data_transformer/data_transformer_specification.py
+++ b/spine_items/data_transformer/data_transformer_specification.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains Data transformer's specification.
-
-"""
-
+"""Contains Data transformer's specification."""
from spine_engine.project_item.project_item_specification import ProjectItemSpecification
from .item_info import ItemInfo
from .settings import EntityClassRenamingSettings, settings_from_dict
@@ -34,7 +31,7 @@ def __init__(self, name, settings=None, description=None):
settings (FilterSettings, optional): filter settings
description (str, optional): specification's description
"""
- super().__init__(name, description, ItemInfo.item_type(), ItemInfo.item_category())
+ super().__init__(name, description, ItemInfo.item_type())
self.settings = settings
def is_equivalent(self, other):
diff --git a/spine_items/data_transformer/executable_item.py b/spine_items/data_transformer/executable_item.py
index 6e29e064..23d66e15 100644
--- a/spine_items/data_transformer/executable_item.py
+++ b/spine_items/data_transformer/executable_item.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,10 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains Data transformer's executable item as well as support utilities.
-
-"""
+"""Contains Data transformer's executable item as well as support utilities."""
from spine_engine.project_item.executable_item_base import ExecutableItemBase
from spine_engine.spine_engine import ItemExecutionFinishState
from .filter_config_path import filter_config_path
diff --git a/spine_items/data_transformer/filter_config_path.py b/spine_items/data_transformer/filter_config_path.py
index 5ccf3abb..a21470ae 100644
--- a/spine_items/data_transformer/filter_config_path.py
+++ b/spine_items/data_transformer/filter_config_path.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,10 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains utilities for filter config paths.
-
-"""
+"""Contains utilities for filter config paths."""
from pathlib import Path
diff --git a/spine_items/data_transformer/item_info.py b/spine_items/data_transformer/item_info.py
index 1acdf33f..e5129957 100644
--- a/spine_items/data_transformer/item_info.py
+++ b/spine_items/data_transformer/item_info.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,19 +10,11 @@
# this program. If not, see .
######################################################################################################################
-"""
-Data transformer project item info.
-
-"""
+"""Data transformer project item info."""
from spine_engine.project_item.project_item_info import ProjectItemInfo
class ItemInfo(ProjectItemInfo):
- @staticmethod
- def item_category():
- """See base class."""
- return "Manipulators"
-
@staticmethod
def item_type():
"""See base class."""
diff --git a/spine_items/data_transformer/mvcmodels/__init__.py b/spine_items/data_transformer/mvcmodels/__init__.py
index 8095b663..046209e7 100644
--- a/spine_items/data_transformer/mvcmodels/__init__.py
+++ b/spine_items/data_transformer/mvcmodels/__init__.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
diff --git a/spine_items/data_transformer/mvcmodels/class_renames_table_model.py b/spine_items/data_transformer/mvcmodels/class_renames_table_model.py
index 94300f44..71db5641 100644
--- a/spine_items/data_transformer/mvcmodels/class_renames_table_model.py
+++ b/spine_items/data_transformer/mvcmodels/class_renames_table_model.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,13 +10,9 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains the :class:`ClassRenamesTableModel` class.
-
-"""
+"""Contains the :class:`ClassRenamesTableModel` class."""
from enum import IntEnum, unique
import pickle
-
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt
from ..commands import InsertRow, SetData
from ..widgets.drop_target_table import DROP_MIME_TYPE
diff --git a/spine_items/data_transformer/mvcmodels/parameter_drop_target_table_model.py b/spine_items/data_transformer/mvcmodels/parameter_drop_target_table_model.py
index 9c926cf2..e5ca439f 100644
--- a/spine_items/data_transformer/mvcmodels/parameter_drop_target_table_model.py
+++ b/spine_items/data_transformer/mvcmodels/parameter_drop_target_table_model.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,10 +9,8 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains a table model that can be used as drop target.
-"""
+"""Contains a table model that can be used as drop target."""
import pickle
from PySide6.QtCore import QAbstractTableModel
from ..commands import InsertRow
diff --git a/spine_items/data_transformer/mvcmodels/parameter_renames_table_model.py b/spine_items/data_transformer/mvcmodels/parameter_renames_table_model.py
index 6f99c095..f406ef78 100644
--- a/spine_items/data_transformer/mvcmodels/parameter_renames_table_model.py
+++ b/spine_items/data_transformer/mvcmodels/parameter_renames_table_model.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,10 +9,8 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains :class:`ParameterRenamesTableModel`.
-"""
+"""Contains :class:`ParameterRenamesTableModel`."""
from enum import IntEnum, unique
from PySide6.QtCore import QModelIndex, Qt
from .parameter_drop_target_table_model import ParameterDropTargetTableModel
diff --git a/spine_items/data_transformer/mvcmodels/value_transformations_table_model.py b/spine_items/data_transformer/mvcmodels/value_transformations_table_model.py
index de4726af..57baf503 100644
--- a/spine_items/data_transformer/mvcmodels/value_transformations_table_model.py
+++ b/spine_items/data_transformer/mvcmodels/value_transformations_table_model.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,10 +9,8 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains :class:`ValueTransformTableModel`.
-"""
+"""Contains :class:`ValueTransformTableModel`."""
from enum import IntEnum, unique
from PySide6.QtCore import QModelIndex, Qt
from .parameter_drop_target_table_model import ParameterDropTargetTableModel
diff --git a/spine_items/data_transformer/output_resources.py b/spine_items/data_transformer/output_resources.py
index 2997ebbb..05146ea2 100644
--- a/spine_items/data_transformer/output_resources.py
+++ b/spine_items/data_transformer/output_resources.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,11 +9,8 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains utilities to scan for Data Transformer's output resources.
-
-"""
+"""Contains utilities to scan for Data Transformer's output resources."""
from spine_engine.project_item.project_item_resource import database_resource
from spinedb_api import append_filter_config
from spinedb_api.filters.tools import store_filter
diff --git a/spine_items/data_transformer/settings.py b/spine_items/data_transformer/settings.py
index e68a0947..2cc24adc 100644
--- a/spine_items/data_transformer/settings.py
+++ b/spine_items/data_transformer/settings.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,10 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains settings classes for filters and manipulators.
-
-"""
+"""Contains settings classes for filters and manipulators."""
from spinedb_api.filters.renamer import entity_class_renamer_config, parameter_renamer_config
from spinedb_api.filters.value_transformer import value_transformer_config
diff --git a/spine_items/data_transformer/specification_factory.py b/spine_items/data_transformer/specification_factory.py
index 97cda2d1..a3527afd 100644
--- a/spine_items/data_transformer/specification_factory.py
+++ b/spine_items/data_transformer/specification_factory.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,10 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Data transformer's specification factory.
-
-"""
+"""Data transformer's specification factory."""
from spine_engine.project_item.project_item_specification_factory import ProjectItemSpecificationFactory
from .item_info import ItemInfo
from .data_transformer_specification import DataTransformerSpecification
diff --git a/spine_items/data_transformer/ui/__init__.py b/spine_items/data_transformer/ui/__init__.py
index 8095b663..046209e7 100644
--- a/spine_items/data_transformer/ui/__init__.py
+++ b/spine_items/data_transformer/ui/__init__.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
diff --git a/spine_items/data_transformer/ui/class_renamer_editor.py b/spine_items/data_transformer/ui/class_renamer_editor.py
deleted file mode 100644
index bf2ad0ac..00000000
--- a/spine_items/data_transformer/ui/class_renamer_editor.py
+++ /dev/null
@@ -1,112 +0,0 @@
-# -*- coding: utf-8 -*-
-######################################################################################################################
-# Copyright (C) 2017-2022 Spine project consortium
-# This file is part of Spine Items.
-# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
-# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
-# any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
-# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
-# this program. If not, see .
-######################################################################################################################
-
-################################################################################
-## Form generated from reading UI file 'class_renamer_editor.ui'
-##
-## Created by: Qt User Interface Compiler version 6.5.2
-##
-## WARNING! All changes made in this file will be lost when recompiling UI file!
-################################################################################
-
-from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
- QMetaObject, QObject, QPoint, QRect,
- QSize, QTime, QUrl, Qt)
-from PySide6.QtGui import (QAction, QBrush, QColor, QConicalGradient,
- QCursor, QFont, QFontDatabase, QGradient,
- QIcon, QImage, QKeySequence, QLinearGradient,
- QPainter, QPalette, QPixmap, QRadialGradient,
- QTransform)
-from PySide6.QtWidgets import (QAbstractItemView, QApplication, QHBoxLayout, QHeaderView,
- QPushButton, QSizePolicy, QSpacerItem, QSplitter,
- QTreeWidgetItem, QVBoxLayout, QWidget)
-
-from spine_items.data_transformer.widgets.class_tree_widget import ClassTreeWidget
-from spine_items.data_transformer.widgets.drop_target_table import DropTargetTable
-from spine_items import resources_icons_rc
-
-class Ui_Form(object):
- def setupUi(self, Form):
- if not Form.objectName():
- Form.setObjectName(u"Form")
- Form.resize(619, 368)
- self.remove_class_action = QAction(Form)
- self.remove_class_action.setObjectName(u"remove_class_action")
- self.remove_class_action.setShortcutContext(Qt.WidgetShortcut)
- self.verticalLayout_2 = QVBoxLayout(Form)
- self.verticalLayout_2.setObjectName(u"verticalLayout_2")
- self.splitter = QSplitter(Form)
- self.splitter.setObjectName(u"splitter")
- self.splitter.setOrientation(Qt.Horizontal)
- self.splitter.setChildrenCollapsible(False)
- self.available_classes_tree_widget = ClassTreeWidget(self.splitter)
- __qtreewidgetitem = QTreeWidgetItem()
- __qtreewidgetitem.setText(0, u"1");
- self.available_classes_tree_widget.setHeaderItem(__qtreewidgetitem)
- self.available_classes_tree_widget.setObjectName(u"available_classes_tree_widget")
- self.available_classes_tree_widget.setDragEnabled(True)
- self.available_classes_tree_widget.setDragDropMode(QAbstractItemView.DragOnly)
- self.available_classes_tree_widget.setDefaultDropAction(Qt.CopyAction)
- self.available_classes_tree_widget.setSelectionMode(QAbstractItemView.ExtendedSelection)
- self.splitter.addWidget(self.available_classes_tree_widget)
- self.available_classes_tree_widget.header().setVisible(False)
- self.verticalLayoutWidget = QWidget(self.splitter)
- self.verticalLayoutWidget.setObjectName(u"verticalLayoutWidget")
- self.verticalLayout = QVBoxLayout(self.verticalLayoutWidget)
- self.verticalLayout.setObjectName(u"verticalLayout")
- self.verticalLayout.setContentsMargins(0, 0, 0, 0)
- self.horizontalLayout = QHBoxLayout()
- self.horizontalLayout.setObjectName(u"horizontalLayout")
- self.add_class_button = QPushButton(self.verticalLayoutWidget)
- self.add_class_button.setObjectName(u"add_class_button")
-
- self.horizontalLayout.addWidget(self.add_class_button)
-
- self.remove_class_button = QPushButton(self.verticalLayoutWidget)
- self.remove_class_button.setObjectName(u"remove_class_button")
-
- self.horizontalLayout.addWidget(self.remove_class_button)
-
- self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
-
- self.horizontalLayout.addItem(self.horizontalSpacer)
-
-
- self.verticalLayout.addLayout(self.horizontalLayout)
-
- self.renaming_table_view = DropTargetTable(self.verticalLayoutWidget)
- self.renaming_table_view.setObjectName(u"renaming_table_view")
- self.renaming_table_view.setAcceptDrops(True)
- self.renaming_table_view.setDragDropMode(QAbstractItemView.DropOnly)
-
- self.verticalLayout.addWidget(self.renaming_table_view)
-
- self.splitter.addWidget(self.verticalLayoutWidget)
-
- self.verticalLayout_2.addWidget(self.splitter)
-
-
- self.retranslateUi(Form)
-
- QMetaObject.connectSlotsByName(Form)
- # setupUi
-
- def retranslateUi(self, Form):
- Form.setWindowTitle(QCoreApplication.translate("Form", u"Form", None))
- self.remove_class_action.setText(QCoreApplication.translate("Form", u"Remove class", None))
-#if QT_CONFIG(shortcut)
- self.remove_class_action.setShortcut(QCoreApplication.translate("Form", u"Del", None))
-#endif // QT_CONFIG(shortcut)
- self.add_class_button.setText(QCoreApplication.translate("Form", u"Add", None))
- self.remove_class_button.setText(QCoreApplication.translate("Form", u"Remove", None))
- # retranslateUi
-
diff --git a/spine_items/data_transformer/ui/class_renamer_editor.ui b/spine_items/data_transformer/ui/class_renamer_editor.ui
deleted file mode 100644
index d286c662..00000000
--- a/spine_items/data_transformer/ui/class_renamer_editor.ui
+++ /dev/null
@@ -1,135 +0,0 @@
-
-
-
- Form
-
-
-
- 0
- 0
- 619
- 368
-
-
-
- Form
-
-
-
-
-
- Qt::Horizontal
-
-
- false
-
-
-
- true
-
-
- QAbstractItemView::DragOnly
-
-
- Qt::CopyAction
-
-
- QAbstractItemView::ExtendedSelection
-
-
- false
-
-
-
- 1
-
-
-
-
-
-
-
-
-
-
- Add
-
-
-
-
-
-
- Remove
-
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
-
-
- true
-
-
- QAbstractItemView::DropOnly
-
-
-
-
-
-
-
-
-
-
- Remove class
-
-
- Del
-
-
- Qt::WidgetShortcut
-
-
-
-
-
- DropTargetTable
- QTableView
- spine_items/data_transformer/widgets/drop_target_table.h
-
-
- ClassTreeWidget
- QTreeWidget
- spine_items/data_transformer/widgets/class_tree_widget.h
-
-
-
-
-
-
-
diff --git a/spine_items/data_transformer/ui/data_transformer_properties.py b/spine_items/data_transformer/ui/data_transformer_properties.py
index 96f4d075..fc9ce728 100644
--- a/spine_items/data_transformer/ui/data_transformer_properties.py
+++ b/spine_items/data_transformer/ui/data_transformer_properties.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -85,7 +86,7 @@ def setupUi(self, Form):
def retranslateUi(self, Form):
Form.setWindowTitle(QCoreApplication.translate("Form", u"Form", None))
- self.specification_label.setText(QCoreApplication.translate("Form", u"Specification", None))
+ self.specification_label.setText(QCoreApplication.translate("Form", u"Specification:", None))
#if QT_CONFIG(tooltip)
self.specification_combo_box.setToolTip(QCoreApplication.translate("Form", u"
Tool specification for this Tool
", None))
#endif // QT_CONFIG(tooltip)
diff --git a/spine_items/data_transformer/ui/data_transformer_properties.ui b/spine_items/data_transformer/ui/data_transformer_properties.ui
index 7ef1222f..d98c12d6 100644
--- a/spine_items/data_transformer/ui/data_transformer_properties.ui
+++ b/spine_items/data_transformer/ui/data_transformer_properties.ui
@@ -2,6 +2,7 @@
-
- Form
-
-
-
- 0
- 0
- 616
- 530
-
-
-
- Form
-
-
-
-
-
- Qt::Horizontal
-
-
- false
-
-
-
- true
-
-
- QAbstractItemView::DragOnly
-
-
- Qt::CopyAction
-
-
- false
-
-
-
- 1
-
-
-
-
-
-
-
-
-
-
- Add
-
-
-
-
-
-
- Remove
-
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
-
-
- QAbstractItemView::DropOnly
-
-
-
-
-
-
-
-
-
-
- Remove parameter
-
-
- Del
-
-
- Qt::WidgetShortcut
-
-
-
-
-
- ParameterTreeWidget
- QTreeWidget
- ./widgets/parameter_tree_widget.h
-
-
- DropTargetTable
- QTableView
- spine_items/data_transformer/widgets/drop_target_table.h
-
-
-
-
-
diff --git a/spine_items/data_transformer/ui/specification_editor_widget.py b/spine_items/data_transformer/ui/specification_editor_widget.py
index 4aa25c2e..ca6839d9 100644
--- a/spine_items/data_transformer/ui/specification_editor_widget.py
+++ b/spine_items/data_transformer/ui/specification_editor_widget.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
diff --git a/spine_items/data_transformer/ui/value_transformer_editor.py b/spine_items/data_transformer/ui/value_transformer_editor.py
deleted file mode 100644
index 14f86a51..00000000
--- a/spine_items/data_transformer/ui/value_transformer_editor.py
+++ /dev/null
@@ -1,178 +0,0 @@
-# -*- coding: utf-8 -*-
-######################################################################################################################
-# Copyright (C) 2017-2022 Spine project consortium
-# This file is part of Spine Items.
-# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
-# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
-# any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
-# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
-# this program. If not, see .
-######################################################################################################################
-
-################################################################################
-## Form generated from reading UI file 'value_transformer_editor.ui'
-##
-## Created by: Qt User Interface Compiler version 6.5.2
-##
-## WARNING! All changes made in this file will be lost when recompiling UI file!
-################################################################################
-
-from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
- QMetaObject, QObject, QPoint, QRect,
- QSize, QTime, QUrl, Qt)
-from PySide6.QtGui import (QAction, QBrush, QColor, QConicalGradient,
- QCursor, QFont, QFontDatabase, QGradient,
- QIcon, QImage, QKeySequence, QLinearGradient,
- QPainter, QPalette, QPixmap, QRadialGradient,
- QTransform)
-from PySide6.QtWidgets import (QAbstractItemView, QApplication, QComboBox, QFormLayout,
- QHBoxLayout, QHeaderView, QLabel, QListWidget,
- QListWidgetItem, QPushButton, QSizePolicy, QSpacerItem,
- QSplitter, QTreeWidgetItem, QVBoxLayout, QWidget)
-
-from ..widgets.parameter_tree_widget import ParameterTreeWidget
-from spine_items.data_transformer.widgets.drop_target_table import DropTargetTable
-
-class Ui_Form(object):
- def setupUi(self, Form):
- if not Form.objectName():
- Form.setObjectName(u"Form")
- Form.resize(938, 368)
- self.remove_parameter_action = QAction(Form)
- self.remove_parameter_action.setObjectName(u"remove_parameter_action")
- self.remove_parameter_action.setShortcutContext(Qt.WidgetShortcut)
- self.remove_instruction_action = QAction(Form)
- self.remove_instruction_action.setObjectName(u"remove_instruction_action")
- self.remove_instruction_action.setShortcutContext(Qt.WidgetShortcut)
- self.horizontalLayout = QHBoxLayout(Form)
- self.horizontalLayout.setObjectName(u"horizontalLayout")
- self.splitter = QSplitter(Form)
- self.splitter.setObjectName(u"splitter")
- self.splitter.setOrientation(Qt.Horizontal)
- self.splitter.setChildrenCollapsible(False)
- self.available_parameters_tree_view = ParameterTreeWidget(self.splitter)
- __qtreewidgetitem = QTreeWidgetItem()
- __qtreewidgetitem.setText(0, u"1");
- self.available_parameters_tree_view.setHeaderItem(__qtreewidgetitem)
- self.available_parameters_tree_view.setObjectName(u"available_parameters_tree_view")
- self.available_parameters_tree_view.setDragEnabled(True)
- self.available_parameters_tree_view.setDragDropMode(QAbstractItemView.DragOnly)
- self.available_parameters_tree_view.setDefaultDropAction(Qt.CopyAction)
- self.splitter.addWidget(self.available_parameters_tree_view)
- self.available_parameters_tree_view.header().setVisible(False)
- self.verticalLayoutWidget_2 = QWidget(self.splitter)
- self.verticalLayoutWidget_2.setObjectName(u"verticalLayoutWidget_2")
- self.verticalLayout_2 = QVBoxLayout(self.verticalLayoutWidget_2)
- self.verticalLayout_2.setObjectName(u"verticalLayout_2")
- self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
- self.horizontalLayout_2 = QHBoxLayout()
- self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
- self.add_parameter_button = QPushButton(self.verticalLayoutWidget_2)
- self.add_parameter_button.setObjectName(u"add_parameter_button")
-
- self.horizontalLayout_2.addWidget(self.add_parameter_button)
-
- self.remove_parameter_button = QPushButton(self.verticalLayoutWidget_2)
- self.remove_parameter_button.setObjectName(u"remove_parameter_button")
-
- self.horizontalLayout_2.addWidget(self.remove_parameter_button)
-
- self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
-
- self.horizontalLayout_2.addItem(self.horizontalSpacer)
-
-
- self.verticalLayout_2.addLayout(self.horizontalLayout_2)
-
- self.transformations_table_view = DropTargetTable(self.verticalLayoutWidget_2)
- self.transformations_table_view.setObjectName(u"transformations_table_view")
- self.transformations_table_view.setAcceptDrops(True)
- self.transformations_table_view.setDragDropMode(QAbstractItemView.DropOnly)
- self.transformations_table_view.setSelectionBehavior(QAbstractItemView.SelectRows)
- self.transformations_table_view.setShowGrid(False)
- self.transformations_table_view.horizontalHeader().setStretchLastSection(True)
-
- self.verticalLayout_2.addWidget(self.transformations_table_view)
-
- self.splitter.addWidget(self.verticalLayoutWidget_2)
-
- self.horizontalLayout.addWidget(self.splitter)
-
- self.verticalLayout_3 = QVBoxLayout()
- self.verticalLayout_3.setObjectName(u"verticalLayout_3")
- self.horizontalLayout_3 = QHBoxLayout()
- self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
- self.add_instruction_button = QPushButton(Form)
- self.add_instruction_button.setObjectName(u"add_instruction_button")
- self.add_instruction_button.setEnabled(False)
-
- self.horizontalLayout_3.addWidget(self.add_instruction_button)
-
- self.remove_instruction_button = QPushButton(Form)
- self.remove_instruction_button.setObjectName(u"remove_instruction_button")
- self.remove_instruction_button.setEnabled(False)
-
- self.horizontalLayout_3.addWidget(self.remove_instruction_button)
-
- self.horizontalSpacer_2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
-
- self.horizontalLayout_3.addItem(self.horizontalSpacer_2)
-
-
- self.verticalLayout_3.addLayout(self.horizontalLayout_3)
-
- self.instructions_list_view = QListWidget(Form)
- self.instructions_list_view.setObjectName(u"instructions_list_view")
- self.instructions_list_view.setEnabled(False)
-
- self.verticalLayout_3.addWidget(self.instructions_list_view)
-
- self.instruction_options_layout = QFormLayout()
- self.instruction_options_layout.setObjectName(u"instruction_options_layout")
- self.label = QLabel(Form)
- self.label.setObjectName(u"label")
-
- self.instruction_options_layout.setWidget(0, QFormLayout.LabelRole, self.label)
-
- self.operation_combo_box = QComboBox(Form)
- self.operation_combo_box.addItem("")
- self.operation_combo_box.addItem("")
- self.operation_combo_box.addItem("")
- self.operation_combo_box.setObjectName(u"operation_combo_box")
-
- self.instruction_options_layout.setWidget(0, QFormLayout.FieldRole, self.operation_combo_box)
-
-
- self.verticalLayout_3.addLayout(self.instruction_options_layout)
-
-
- self.horizontalLayout.addLayout(self.verticalLayout_3)
-
-
- self.retranslateUi(Form)
-
- QMetaObject.connectSlotsByName(Form)
- # setupUi
-
- def retranslateUi(self, Form):
- Form.setWindowTitle(QCoreApplication.translate("Form", u"Form", None))
- self.remove_parameter_action.setText(QCoreApplication.translate("Form", u"Remove parameter", None))
-#if QT_CONFIG(shortcut)
- self.remove_parameter_action.setShortcut(QCoreApplication.translate("Form", u"Del", None))
-#endif // QT_CONFIG(shortcut)
- self.remove_instruction_action.setText(QCoreApplication.translate("Form", u"Remove instruction", None))
-#if QT_CONFIG(shortcut)
- self.remove_instruction_action.setShortcut(QCoreApplication.translate("Form", u"Del", None))
-#endif // QT_CONFIG(shortcut)
- self.add_parameter_button.setText(QCoreApplication.translate("Form", u"Add", None))
- self.remove_parameter_button.setText(QCoreApplication.translate("Form", u"Remove", None))
- self.add_instruction_button.setText(QCoreApplication.translate("Form", u"Add", None))
- self.remove_instruction_button.setText(QCoreApplication.translate("Form", u"Remove", None))
- self.label.setText(QCoreApplication.translate("Form", u"Operation:", None))
- self.operation_combo_box.setItemText(0, QCoreApplication.translate("Form", u"multiply", None))
- self.operation_combo_box.setItemText(1, QCoreApplication.translate("Form", u"negate", None))
- self.operation_combo_box.setItemText(2, QCoreApplication.translate("Form", u"invert", None))
-
- # retranslateUi
-
diff --git a/spine_items/data_transformer/ui/value_transformer_editor.ui b/spine_items/data_transformer/ui/value_transformer_editor.ui
deleted file mode 100644
index 371fa11d..00000000
--- a/spine_items/data_transformer/ui/value_transformer_editor.ui
+++ /dev/null
@@ -1,228 +0,0 @@
-
-
-
- Form
-
-
-
- 0
- 0
- 938
- 368
-
-
-
- Form
-
-
-
-
-
- Qt::Horizontal
-
-
- false
-
-
-
- true
-
-
- QAbstractItemView::DragOnly
-
-
- Qt::CopyAction
-
-
- false
-
-
-
- 1
-
-
-
-
-
-
-
-
-
-
- Add
-
-
-
-
-
-
- Remove
-
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
-
-
- true
-
-
- QAbstractItemView::DropOnly
-
-
- QAbstractItemView::SelectRows
-
-
- false
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- false
-
-
- Add
-
-
-
-
-
-
- false
-
-
- Remove
-
-
-
-
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
-
-
-
-
- false
-
-
-
-
-
-
-
-
- Operation:
-
-
-
-
-
-
-
- multiply
-
-
-
-
- negate
-
-
-
-
- invert
-
-
-
-
-
-
-
-
-
-
-
- Remove parameter
-
-
- Del
-
-
- Qt::WidgetShortcut
-
-
-
-
- Remove instruction
-
-
- Del
-
-
- Qt::WidgetShortcut
-
-
-
-
-
- ParameterTreeWidget
- QTreeWidget
- ./widgets/parameter_tree_widget.h
-
-
- DropTargetTable
- QTableView
- spine_items/data_transformer/widgets/drop_target_table.h
-
-
-
-
-
diff --git a/spine_items/data_transformer/widgets/__init__.py b/spine_items/data_transformer/widgets/__init__.py
index 8095b663..046209e7 100644
--- a/spine_items/data_transformer/widgets/__init__.py
+++ b/spine_items/data_transformer/widgets/__init__.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
diff --git a/spine_items/data_transformer/widgets/add_data_transformer_widget.py b/spine_items/data_transformer/widgets/add_data_transformer_widget.py
index a5f081de..7e3fad9c 100644
--- a/spine_items/data_transformer/widgets/add_data_transformer_widget.py
+++ b/spine_items/data_transformer/widgets/add_data_transformer_widget.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Widget shown to user when a new Data transformer is created.
-
-"""
-
+"""Widget shown to user when a new Data transformer is created."""
from spinetoolbox.widgets.add_project_item_widget import AddProjectItemWidget
from ..item_info import ItemInfo
from ..data_transformer import DataTransformer
diff --git a/spine_items/data_transformer/widgets/class_rename.py b/spine_items/data_transformer/widgets/class_rename.py
index f637808d..f7d4d8f9 100644
--- a/spine_items/data_transformer/widgets/class_rename.py
+++ b/spine_items/data_transformer/widgets/class_rename.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,12 +9,9 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains classes to manage entity class renaming.
-"""
+"""Contains classes to manage entity class renaming."""
from PySide6.QtCore import QObject, Qt, Slot, QSortFilterProxyModel
-
from ..commands import RemoveRow, InsertRow
from ..mvcmodels.class_renames_table_model import ClassRenamesTableModel
from ..settings import EntityClassRenamingSettings
diff --git a/spine_items/data_transformer/widgets/class_tree_widget.py b/spine_items/data_transformer/widgets/class_tree_widget.py
index 523937df..b36addad 100644
--- a/spine_items/data_transformer/widgets/class_tree_widget.py
+++ b/spine_items/data_transformer/widgets/class_tree_widget.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,14 +9,11 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains :class:`ClassTreeWidget`.
-"""
+"""Contains :class:`ClassTreeWidget`."""
import pickle
from PySide6.QtCore import QMimeData
from PySide6.QtWidgets import QTreeWidget, QMessageBox, QTreeWidgetItem
-
from spinedb_api import DatabaseMapping, SpineDBAPIError
from .drop_target_table import DROP_MIME_TYPE
@@ -50,7 +48,7 @@ def load_data(self, url):
self, "Error while reading database", f"Could not read from database {url}:\n{error}"
)
finally:
- db_map.connection.close()
+ db_map.close()
self.clear()
for class_name in classes:
self.addTopLevelItem(QTreeWidgetItem([class_name]))
diff --git a/spine_items/data_transformer/widgets/copy_paste.py b/spine_items/data_transformer/widgets/copy_paste.py
index a0fee2c1..2c1b2ac6 100644
--- a/spine_items/data_transformer/widgets/copy_paste.py
+++ b/spine_items/data_transformer/widgets/copy_paste.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,10 +9,8 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains shared functions that provide copy-paste functionality.
-"""
+"""Contains shared functions that provide copy-paste functionality."""
import pickle
from PySide6.QtCore import QMimeData
from PySide6.QtWidgets import QApplication
diff --git a/spine_items/data_transformer/widgets/data_transformer_properties_widget.py b/spine_items/data_transformer/widgets/data_transformer_properties_widget.py
index 0c1e42ee..0e208392 100644
--- a/spine_items/data_transformer/widgets/data_transformer_properties_widget.py
+++ b/spine_items/data_transformer/widgets/data_transformer_properties_widget.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,10 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Data transformer properties widget.
-
-"""
+"""Data transformer properties widget."""
from spinetoolbox.widgets.properties_widget import PropertiesWidgetBase
from ..item_info import ItemInfo
diff --git a/spine_items/data_transformer/widgets/drop_target_table.py b/spine_items/data_transformer/widgets/drop_target_table.py
index 29c7385b..cfc53eab 100644
--- a/spine_items/data_transformer/widgets/drop_target_table.py
+++ b/spine_items/data_transformer/widgets/drop_target_table.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,10 +9,8 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains a table view that can accept drops.
-"""
+"""Contains a table view that can accept drops."""
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QTableView
diff --git a/spine_items/data_transformer/widgets/instructions_editor.py b/spine_items/data_transformer/widgets/instructions_editor.py
index 75971ef5..3e908870 100644
--- a/spine_items/data_transformer/widgets/instructions_editor.py
+++ b/spine_items/data_transformer/widgets/instructions_editor.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,10 +9,8 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains controller that manages value transformations editor.
-"""
+"""Contains controller that manages value transformations editor."""
from PySide6.QtCore import QModelIndex, QObject, Slot
from PySide6.QtWidgets import QLineEdit, QFormLayout
from ..commands import AppendInstruction, ChangeInstructionParameter, ChangeOperation, RemoveInstruction
diff --git a/spine_items/data_transformer/widgets/parameter_rename.py b/spine_items/data_transformer/widgets/parameter_rename.py
index 1c507f8f..93fad56a 100644
--- a/spine_items/data_transformer/widgets/parameter_rename.py
+++ b/spine_items/data_transformer/widgets/parameter_rename.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,12 +9,9 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains classes to manage parameter renaming.
-"""
+"""Contains classes to manage parameter renaming."""
from PySide6.QtCore import QObject, QSortFilterProxyModel, Qt, Slot
-
from ..commands import InsertRow, RemoveRow
from ..mvcmodels.parameter_renames_table_model import ParameterRenamesTableModel, RenamesTableColumn
from ..settings import ParameterRenamingSettings
diff --git a/spine_items/data_transformer/widgets/parameter_tree_widget.py b/spine_items/data_transformer/widgets/parameter_tree_widget.py
index 9f7a4d23..45615de6 100644
--- a/spine_items/data_transformer/widgets/parameter_tree_widget.py
+++ b/spine_items/data_transformer/widgets/parameter_tree_widget.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,14 +9,11 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains :class:`ParameterTreeWidget`.
-"""
+"""Contains :class:`ParameterTreeWidget`."""
import pickle
from PySide6.QtCore import QMimeData
from PySide6.QtWidgets import QTreeWidget, QMessageBox, QTreeWidgetItem
-
from spinedb_api import DatabaseMapping, SpineDBAPIError
from .drop_target_table import DROP_MIME_TYPE
@@ -56,7 +54,7 @@ def load_data(self, url):
self, "Error while reading database", f"Could not read from database {url}:\n{error}"
)
finally:
- db_map.connection.close()
+ db_map.close()
self.clear()
for class_name, parameter_names in parameters.items():
class_item = QTreeWidgetItem([class_name])
diff --git a/spine_items/data_transformer/widgets/specification_editor_window.py b/spine_items/data_transformer/widgets/specification_editor_window.py
index 0226fe97..c223fe4a 100644
--- a/spine_items/data_transformer/widgets/specification_editor_window.py
+++ b/spine_items/data_transformer/widgets/specification_editor_window.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,12 +9,12 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains :class:`SpecificationEditorWindow`.
-"""
+"""Contains :class:`SpecificationEditorWindow`."""
from PySide6.QtCore import Qt, Slot
-from PySide6.QtWidgets import QFileDialog
+from PySide6.QtWidgets import QFileDialog, QHeaderView
+
+from spinetoolbox.helpers import disconnect
from spinetoolbox.project_item.specification_editor_window import (
SpecificationEditorWindowBase,
ChangeSpecPropertyCommand,
@@ -77,6 +78,17 @@ def __init__(self, toolbox, specification=None, item=None, urls=None):
self._ui.database_url_combo_box.addItems(urls if urls is not None else [])
self._ui.filter_combo_box.currentTextChanged.connect(self._change_filter_widget)
self._set_current_filter_name(filter_name)
+ for view in (
+ self._ui.available_parameters_tree_view,
+ self._ui.available_classes_tree_widget,
+ ):
+ view.header().setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents)
+ for view in (
+ self._ui.parameter_rename_table_view,
+ self._ui.transformations_table_view,
+ self._ui.class_rename_table_view,
+ ):
+ view.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents)
@property
def settings_group(self):
@@ -87,7 +99,7 @@ def _make_ui(self):
return Ui_MainWindow()
- def _make_new_specification(self, spec_name, exiting=None):
+ def _make_new_specification(self, spec_name):
"""See base class."""
description = self._spec_toolbar.description()
filter_name = self._ui.filter_combo_box.currentText()
@@ -124,9 +136,8 @@ def _set_current_filter_name(self, filter_name):
if previous_interface is not None:
previous_interface.tear_down()
self._current_filter_name = filter_name
- self._ui.filter_combo_box.currentTextChanged.disconnect(self._change_filter_widget)
- self._ui.filter_combo_box.setCurrentText(filter_name)
- self._ui.filter_combo_box.currentTextChanged.connect(self._change_filter_widget)
+ with disconnect(self._ui.filter_combo_box.currentTextChanged, self._change_filter_widget):
+ self._ui.filter_combo_box.setCurrentText(filter_name)
interface = self._filter_sub_interfaces.get(filter_name)
if interface is None:
interface = dict(zip(_FILTER_NAMES, (ClassRename, ParameterRename, ValueTransformation)))[filter_name](
diff --git a/spine_items/data_transformer/widgets/value_transformation.py b/spine_items/data_transformer/widgets/value_transformation.py
index 54364cb8..baebb6a9 100644
--- a/spine_items/data_transformer/widgets/value_transformation.py
+++ b/spine_items/data_transformer/widgets/value_transformation.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,12 +9,9 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains classes to manage parameter value transformation.
-"""
+"""Contains classes to manage parameter value transformation."""
from PySide6.QtCore import QObject, QSortFilterProxyModel, Qt, Slot
-
from ..commands import InsertRow, RemoveRow
from ..mvcmodels.value_transformations_table_model import (
ValueTransformationsTableModel,
diff --git a/spine_items/database_validation.py b/spine_items/database_validation.py
index 6eb55129..9d3e5d46 100644
--- a/spine_items/database_validation.py
+++ b/spine_items/database_validation.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,13 +9,11 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
+
"""Utilities to validate that a database exists."""
from pathlib import Path
-from sqlalchemy.engine.url import make_url
-
from PySide6.QtCore import QObject, QRunnable, QThread, QThreadPool, QTimer, Signal, Slot
from PySide6.QtWidgets import QApplication
-
from spine_items.utils import check_database_url
@@ -32,7 +31,7 @@ def __init__(self, dialect, sa_url, finish_slot, fail_slot, success_slot):
"""
super().__init__()
self._dialect = dialect
- self._sa_url = make_url(sa_url)
+ self._sa_url = sa_url
self._signals = _TaskSignals()
self._signals.moveToThread(None)
self._signals.validation_failed.connect(fail_slot)
@@ -47,20 +46,21 @@ def run(self):
if self._dialect == "sqlite":
database_path = Path(self._sa_url.database)
if not database_path.exists():
- self._signals.validation_failed.emit("File does not exist. Check the Database field in the URL.")
+ self._signals.validation_failed.emit(
+ "File does not exist. Check the Database field in the URL.", self._sa_url
+ )
return
elif database_path.is_dir():
self._signals.validation_failed.emit(
- "Database points to a directory, not a file." " Check the Database field in the URL."
+ "Database points to a directory, not a file. Check the Database field in the URL.",
+ self._sa_url,
)
return
error = check_database_url(self._sa_url)
if error is not None:
- self._signals.validation_failed.emit(error)
+ self._signals.validation_failed.emit(error, self._sa_url)
return
- self._signals.validation_succeeded.emit()
- except Exception as error:
- self._signals.validation_failed.emit(str(error))
+ self._signals.validation_succeeded.emit(self._sa_url)
finally:
self._signals.finished.emit()
application = QApplication.instance()
@@ -71,8 +71,8 @@ def run(self):
class _TaskSignals(QObject):
"""Signals for validation task."""
- validation_failed = Signal(str)
- validation_succeeded = Signal()
+ validation_failed = Signal(str, object)
+ validation_succeeded = Signal(object)
finished = Signal()
@@ -94,6 +94,10 @@ def __init__(self, parent=None):
self._deferred_task = None
self._closed = False
+ def is_busy(self):
+ """Tests if there is a validator task running."""
+ return self._busy
+
def validate_url(self, dialect, sa_url, fail_slot, success_slot):
"""Connects signals and starts a task to validate the given URL.
diff --git a/spine_items/db_writer_executable_item_base.py b/spine_items/db_writer_executable_item_base.py
index 771c64af..994df7e8 100644
--- a/spine_items/db_writer_executable_item_base.py
+++ b/spine_items/db_writer_executable_item_base.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,10 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains base classes for items that write to db.
-
-"""
+"""Contains base classes for items that write to db."""
from spine_engine.project_item.executable_item_base import ExecutableItemBase
from spinedb_api.spine_db_client import SpineDBClient
diff --git a/spine_items/db_writer_item_base.py b/spine_items/db_writer_item_base.py
index 018e3f0f..2dc25986 100644
--- a/spine_items/db_writer_item_base.py
+++ b/spine_items/db_writer_item_base.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,9 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains base classes for items that write to db.
-
-"""
+"""Contains base classes for items that write to db."""
from PySide6.QtCore import Slot
+from spine_engine.utils.helpers import ExecutionDirection
from spinetoolbox.project_item.project_item import ProjectItem
@@ -29,7 +28,7 @@ def successor_data_stores(self):
@Slot(object, object)
def handle_execution_successful(self, execution_direction, engine_state):
"""Notifies Toolbox of successful database import."""
- if execution_direction != "FORWARD":
+ if execution_direction != ExecutionDirection.FORWARD:
return
committed_db_maps = set()
for successor in self.successor_data_stores():
diff --git a/spine_items/exporter/__init__.py b/spine_items/exporter/__init__.py
index 8095b663..1a3c9f14 100644
--- a/spine_items/exporter/__init__.py
+++ b/spine_items/exporter/__init__.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,3 +9,5 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
+
+"""Exporter plugin."""
diff --git a/spine_items/exporter/commands.py b/spine_items/exporter/commands.py
index 993ba4fc..3536fc53 100644
--- a/spine_items/exporter/commands.py
+++ b/spine_items/exporter/commands.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,71 +9,102 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains Exporter's undo commands.
-"""
+"""Contains Exporter's undo commands."""
from copy import copy, deepcopy
from enum import IntEnum, unique
from PySide6.QtCore import QModelIndex, Qt
from PySide6.QtGui import QUndoCommand
+
+from spinetoolbox.helpers import SealCommand
from spinetoolbox.project_commands import SpineToolboxCommand
from .mvcmodels.mappings_table_model import MappingsTableModel
@unique
-class _ID(IntEnum):
+class CommandId(IntEnum):
CHANGE_POSITION = 1
+ CHANGE_FIXED_TABLE_NAME = 2
+ CHANGE_OUT_LABEL = 3
class UpdateOutLabel(SpineToolboxCommand):
"""Command to update exporter's output label."""
- def __init__(self, exporter, out_label, in_label, previous_label):
+ def __init__(self, exporter_name, out_label, in_label, previous_label, project):
"""
Args:
- exporter (Exporter): exporter
+ exporter_name (str): exporter's name
out_label (str): new output resource label
in_label (str): associated input resource label
previous_label (str): previous output resource label
+ project (SpineToolboxProject): project
"""
super().__init__()
- self._exporter = exporter
+ self._exporter_name = exporter_name
self._out_label = out_label
self._previous_out_label = previous_label
self._in_label = in_label
- self.setText(f"change output label in {exporter.name}")
+ self._project = project
+ self.setText(f"change output label in {exporter_name}")
+ self._sealed = False
+
+ def id(self):
+ return 1
def redo(self):
- self._exporter.set_out_label(self._out_label, self._in_label)
+ exporter = self._project.get_item(self._exporter_name)
+ exporter.set_out_label(self._out_label, self._in_label)
def undo(self):
- self._exporter.set_out_label(self._previous_out_label, self._in_label)
+ exporter = self._project.get_item(self._exporter_name)
+ exporter.set_out_label(self._previous_out_label, self._in_label)
+
+ def mergeWith(self, other):
+ if not self._sealed:
+ if (
+ isinstance(other, UpdateOutLabel)
+ and self._exporter_name == other._exporter_name
+ and self._in_label == other._in_label
+ ):
+ if self._previous_out_label != other._out_label:
+ self._out_label = other._out_label
+ else:
+ self.setObsolete(True)
+ return True
+ if isinstance(other, SealCommand):
+ self._sealed = True
+ return True
+ return False
class UpdateOutUrl(SpineToolboxCommand):
"""Command to update exporter's output URL."""
- def __init__(self, exporter, in_label, url, previous_url):
+ def __init__(self, exporter_name, in_label, url, previous_url, project):
"""
Args:
- exporter (Exporter): exporter
+ exporter_name (str): exporter's name
in_label (str): input resource label
url (dict, optional): new URL dict
previous_url (dict, optional): previous URL dict
+ project (SpineToolboxProject): project
"""
super().__init__()
- self._exporter = exporter
+ self._exporter_name = exporter_name
self._in_label = in_label
self._url = copy(url)
self._previous_url = copy(previous_url)
- self.setText(f"change output URL in {exporter.name}")
+ self._project = project
+ self.setText(f"change output URL in {exporter_name}")
def redo(self):
- self._exporter.set_out_url(self._in_label, copy(self._url))
+ exporter = self._project.get_item(self._exporter_name)
+ exporter.set_out_url(self._in_label, copy(self._url))
def undo(self):
- self._exporter.set_out_url(self._in_label, copy(self._previous_url))
+ exporter = self._project.get_item(self._exporter_name)
+ exporter.set_out_url(self._in_label, copy(self._previous_url))
class NewMapping(QUndoCommand):
@@ -294,6 +326,8 @@ def undo(self):
class SetFixedTableName(QUndoCommand):
+ ID = CommandId.CHANGE_FIXED_TABLE_NAME.value
+
def __init__(self, index, old_name, new_name):
"""
Args:
@@ -305,6 +339,7 @@ def __init__(self, index, old_name, new_name):
self._index = index
self._old_name = old_name
self._new_name = new_name
+ self._sealed = False
def redo(self):
self._index.model().setData(self._index, self._new_name, MappingsTableModel.FIXED_TABLE_NAME_ROLE)
@@ -312,6 +347,22 @@ def redo(self):
def undo(self):
self._index.model().setData(self._index, self._old_name, MappingsTableModel.FIXED_TABLE_NAME_ROLE)
+ def id(self):
+ return self.ID
+
+ def mergeWith(self, other):
+ if not self._sealed:
+ if isinstance(other, SetFixedTableName) and self.id() == other.id() and self._index == other._index:
+ if self._old_name != other._new_name:
+ self._new_name = other._new_name
+ else:
+ self.setObsolete(True)
+ return True
+ if isinstance(other, SealCommand):
+ self._sealed = True
+ return True
+ return False
+
class SetGroupFunction(QUndoCommand):
def __init__(self, index, old_function, new_function):
@@ -347,10 +398,10 @@ def __init__(self, index, old_dimension, new_dimension):
self._new_dimension = new_dimension
def redo(self):
- self._index.model().setData(self._index, self._new_dimension, MappingsTableModel.HIGHLIGHT_DIMENSION_ROLE)
+ self._index.model().setData(self._index, self._new_dimension, MappingsTableModel.HIGHLIGHT_POSITION_ROLE)
def undo(self):
- self._index.model().setData(self._index, self._old_dimension, MappingsTableModel.HIGHLIGHT_DIMENSION_ROLE)
+ self._index.model().setData(self._index, self._old_dimension, MappingsTableModel.HIGHLIGHT_POSITION_ROLE)
class SetMappingPositions(QUndoCommand):
@@ -385,7 +436,7 @@ def previous_positions(self):
return self._previous_positions
def id(self):
- return int(_ID.CHANGE_POSITION)
+ return int(CommandId.CHANGE_POSITION)
def redo(self):
self._mapping_editor_table_model.set_positions(self._positions, self._mapping_name)
@@ -417,7 +468,7 @@ def __init__(self, editor, is_fixed_table_checked, previous_fixed_table_name, ma
self._previous_mapping_root = self._mapping_index.data(MappingsTableModel.MAPPING_ROOT_ROLE)
def id(self):
- return int(_ID.CHANGE_POSITION)
+ return int(CommandId.CHANGE_POSITION)
def mergeWith(self, other):
if self._mapping_editor_table_model is not None:
@@ -534,19 +585,23 @@ def undo(self):
class UpdateOutputTimeStampsFlag(SpineToolboxCommand):
"""Command to set exporter's output directory time stamps flag."""
- def __init__(self, exporter, value):
+ def __init__(self, exporter_name, value, project):
"""
Args:
- exporter (Exporter): exporter item
+ exporter_name (str): exporter's name
value (bool): flag's new value
+ project (SpineToolboxProject): project
"""
super().__init__()
- self.setText(f"toggle output time stamps setting of {exporter.name}")
- self._exporter = exporter
+ self.setText(f"toggle output time stamps setting of {exporter_name}")
+ self._exporter_name = exporter_name
self._value = value
+ self._project = project
def redo(self):
- self._exporter.set_output_time_stamps_flag(self._value)
+ exporter = self._project.get_item(self._exporter_name)
+ exporter.set_output_time_stamps_flag(self._value)
def undo(self):
- self._exporter.set_output_time_stamps_flag(not self._value)
+ exporter = self._project.get_item(self._exporter_name)
+ exporter.set_output_time_stamps_flag(not self._value)
diff --git a/spine_items/exporter/do_work.py b/spine_items/exporter/do_work.py
index bb866ef6..5ced6ff7 100644
--- a/spine_items/exporter/do_work.py
+++ b/spine_items/exporter/do_work.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,15 +10,11 @@
# this program. If not, see .
######################################################################################################################
-"""
-Exporter's execute kernel (do_work), as target for a multiprocess.Process
-
-"""
+"""Exporter's execute kernel (do_work), as target for a multiprocess.Process"""
import os
from datetime import datetime
from pathlib import Path
from time import time
-
from spinedb_api.spine_io.exporters.writer import write, WriterException
from spinedb_api.spine_io.exporters.csv_writer import CsvWriter
from spinedb_api.spine_io.exporters.excel_writer import ExcelWriter
@@ -98,7 +95,7 @@ def do_work(
if not successful:
return False, written_files
finally:
- database_map.connection.close()
+ database_map.close()
return all(successes), written_files
diff --git a/spine_items/exporter/executable_item.py b/spine_items/exporter/executable_item.py
index 2c115310..0efdab8f 100644
--- a/spine_items/exporter/executable_item.py
+++ b/spine_items/exporter/executable_item.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,15 +10,11 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains Exporter's executable item as well as support utilities.
-
-"""
+"""Contains Exporter's executable item as well as support utilities."""
import json
import os
from json import dump
from pathlib import Path
-
from spine_engine.project_item.executable_item_base import ExecutableItemBase
from spine_engine.project_item.project_item_resource import file_resource_in_pack
from spine_engine.utils.returning_process import ReturningProcess
diff --git a/spine_items/exporter/export_manifest.py b/spine_items/exporter/export_manifest.py
index 53ab7188..a08d2547 100644
--- a/spine_items/exporter/export_manifest.py
+++ b/spine_items/exporter/export_manifest.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,10 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains utilities to manage export manifest files.
-
-"""
+"""Contains utilities to manage export manifest files."""
import json
from itertools import dropwhile
from pathlib import Path
diff --git a/spine_items/exporter/exporter.py b/spine_items/exporter/exporter.py
index 65ff93bd..aa42afb7 100644
--- a/spine_items/exporter/exporter.py
+++ b/spine_items/exporter/exporter.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,19 +10,16 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains the :class:`Exporter` project item.
-
-"""
+"""Contains the :class:`Exporter` project item."""
from dataclasses import dataclass
from itertools import combinations, zip_longest
from operator import itemgetter
from pathlib import Path
-
from PySide6.QtCore import Slot, Qt
-
+from spinetoolbox.helpers import SealCommand
from spinetoolbox.project_item.project_item import ProjectItem
from spine_engine.utils.serialization import deserialize_path
+from spine_engine.utils.helpers import ExecutionDirection
from spinedb_api import clear_filter_configs
from .export_manifest import exported_files_as_resources
from .specification import OutputFormat
@@ -30,7 +28,7 @@
from .widgets.export_list_item import ExportListItem
from .item_info import ItemInfo
from .executable_item import ExecutableItem
-from .commands import UpdateOutLabel, UpdateOutputTimeStampsFlag, UpdateOutUrl
+from .commands import CommandId, UpdateOutLabel, UpdateOutputTimeStampsFlag, UpdateOutUrl
from .output_channel import OutputChannel
from .utils import EXPORTER_EXECUTION_MANIFEST_FILE_PREFIX, output_database_resources
@@ -100,11 +98,6 @@ def item_type():
"""See base class."""
return ItemInfo.item_type()
- @staticmethod
- def item_category():
- """See base class."""
- return ItemInfo.item_category()
-
@property
def executable_class(self):
return ExecutableItem
@@ -119,7 +112,7 @@ def has_out_url(self):
def handle_execution_successful(self, execution_direction, engine_state):
"""See base class."""
- if execution_direction != "FORWARD":
+ if execution_direction != ExecutionDirection.FORWARD:
return
self._resources_to_successors_changed()
@@ -138,7 +131,7 @@ def _cancel_on_error_option_changed(self, checkbox_state):
cancel = checkbox_state == Qt.CheckState.Checked.value
if self._cancel_on_error == cancel:
return
- self._toolbox.undo_stack.push(UpdateCancelOnErrorCommand(self, cancel))
+ self._toolbox.undo_stack.push(UpdateCancelOnErrorCommand(self.name, cancel, self._project))
def set_cancel_on_error(self, cancel):
"""Sets the Cancel export on error option."""
@@ -166,6 +159,7 @@ def _update_properties_tab(self):
output_format = self._specification.output_format if self._specification is not None else None
item.set_out_url_enabled(output_format is None or output_format == OutputFormat.SQL)
item.out_label_changed.connect(self._update_out_label)
+ item.out_label_editing_finished.connect(self._seal_out_label_update)
item.out_url_changed.connect(self._update_out_url)
self._properties_ui.output_time_stamps_check_box.setCheckState(
Qt.CheckState.Checked if self._append_output_time_stamps else Qt.CheckState.Unchecked
@@ -300,7 +294,16 @@ def _update_out_label(self, out_label, in_label):
in_label (str): associated in label
"""
previous = next(c for c in self._output_channels if c.in_label == in_label)
- self._toolbox.undo_stack.push(UpdateOutLabel(self, out_label, in_label, previous.out_label))
+ self._toolbox.undo_stack.push(UpdateOutLabel(self.name, out_label, in_label, previous.out_label, self._project))
+
+ @Slot(str)
+ def _seal_out_label_update(self, in_label):
+ """Pushes a sealing command to undo stack.
+
+ Args:
+ in_label (str): associated in label
+ """
+ self._toolbox.undo_stack.push(SealCommand(CommandId.CHANGE_OUT_LABEL.value))
@Slot(str, dict)
def _update_out_url(self, in_label, url_dict):
@@ -313,7 +316,9 @@ def _update_out_url(self, in_label, url_dict):
for channel in self._output_channels:
if channel.in_label == in_label:
if channel.out_url != url_dict:
- self._toolbox.undo_stack.push(UpdateOutUrl(self, in_label, url_dict, channel.out_url))
+ self._toolbox.undo_stack.push(
+ UpdateOutUrl(self.name, in_label, url_dict, channel.out_url, self._project)
+ )
break
else:
raise RuntimeError(f"Logic error: cannot find channel for input label {in_label}")
@@ -484,7 +489,7 @@ def _change_output_time_stamps_flag(self, checkbox_state):
flag = checkbox_state == Qt.CheckState.Checked.value
if flag == self._append_output_time_stamps:
return
- self._toolbox.undo_stack.push(UpdateOutputTimeStampsFlag(self, flag))
+ self._toolbox.undo_stack.push(UpdateOutputTimeStampsFlag(self.name, flag, self._project))
def set_output_time_stamps_flag(self, flag):
"""
diff --git a/spine_items/exporter/exporter_factory.py b/spine_items/exporter/exporter_factory.py
index ef07e24e..14207d68 100644
--- a/spine_items/exporter/exporter_factory.py
+++ b/spine_items/exporter/exporter_factory.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains :class:`ExporterFactory`.
-
-"""
-
+"""Contains :class:`ExporterFactory`."""
from PySide6.QtGui import QColor
from spinetoolbox.project_item.project_item_factory import ProjectItemFactory
from .exporter import Exporter
diff --git a/spine_items/exporter/exporter_icon.py b/spine_items/exporter/exporter_icon.py
index 06e9b3ef..8a4d6a23 100644
--- a/spine_items/exporter/exporter_icon.py
+++ b/spine_items/exporter/exporter_icon.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,11 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains :class:`ExporterIcon`.
-
-"""
-
+"""Contains :class:`ExporterIcon`."""
from spinetoolbox.project_item_icon import ProjectItemIcon
from ..animations import ExporterAnimation, AnimationSignaller
@@ -41,5 +38,5 @@ def mouseDoubleClickEvent(self, e):
e (QGraphicsSceneMouseEvent): Event
"""
super().mouseDoubleClickEvent(e)
- item = self._toolbox.project_item_model.get_item(self._name)
- item.project_item.show_specification_window()
+ item = self._toolbox.project().get_item(self._name)
+ item.show_specification_window()
diff --git a/spine_items/exporter/item_info.py b/spine_items/exporter/item_info.py
index 11a5fb1e..d08ec8e3 100644
--- a/spine_items/exporter/item_info.py
+++ b/spine_items/exporter/item_info.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,19 +9,12 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Exporter project item info.
-"""
+"""Exporter project item info."""
from spine_engine.project_item.project_item_info import ProjectItemInfo
class ItemInfo(ProjectItemInfo):
- @staticmethod
- def item_category():
- """See base class."""
- return "Exporters"
-
@staticmethod
def item_type():
"""See base class."""
diff --git a/spine_items/exporter/mvcmodels/__init__.py b/spine_items/exporter/mvcmodels/__init__.py
index 8095b663..046209e7 100644
--- a/spine_items/exporter/mvcmodels/__init__.py
+++ b/spine_items/exporter/mvcmodels/__init__.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
diff --git a/spine_items/exporter/mvcmodels/database_list_model.py b/spine_items/exporter/mvcmodels/database_list_model.py
deleted file mode 100644
index 1370ae5e..00000000
--- a/spine_items/exporter/mvcmodels/database_list_model.py
+++ /dev/null
@@ -1,125 +0,0 @@
-######################################################################################################################
-# Copyright (C) 2017-2022 Spine project consortium
-# This file is part of Spine Items.
-# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
-# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
-# any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
-# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
-# this program. If not, see .
-######################################################################################################################
-
-"""
-Contains a model for Exporter's output preview.
-
-"""
-from PySide6.QtCore import QAbstractListModel, QModelIndex, Qt
-from spine_items.utils import Database
-
-
-class DatabaseListModel(QAbstractListModel):
- """A model for exporter database lists."""
-
- def __init__(self, databases):
- """
- Args:
- databases (list of Database): databases to list
- """
- super().__init__()
- self._databases = databases
-
- def add(self, database):
- """
- Appends a database to the list.
-
- Args:
- database (Database): a database to add
- """
- row = len(self._databases)
- self.beginInsertRows(QModelIndex(), row, row)
- self._databases.append(database)
- self.endInsertRows()
-
- def data(self, index, role=Qt.ItemDataRole.DisplayRole):
- if not index.isValid():
- return None
- if role == Qt.ItemDataRole.DisplayRole:
- return self._databases[index.row()].url
- return None
-
- def insertRows(self, row, count, parent=QModelIndex()):
- self.beginInsertRows(parent, row, row + count - 1)
- self._databases = self._databases[:row] + [Database() for _ in range(count)] + self._databases[row:]
- self.endInsertRows()
-
- def item(self, url):
- """
- Returns database item for given URL.
-
- Args:
- url (str): database URL
-
- Returns:
- Database: a database
- """
- for db in self._databases:
- if db.url == url:
- return db
- raise RuntimeError(f"Database '{url}' not found.")
-
- def items(self):
- """
- Returns a list of databases this model contains.
-
- Returns:
- list of Database: database
- """
- return self._databases
-
- def remove(self, url):
- """
- Removes database item with given URL.
-
- Args:
- url (str): database URL
-
- Returns:
- Database: removed database or None if not found
- """
- for row, db in enumerate(self._databases):
- if db.url == url:
- self.removeRows(row, 1)
- return db
- return None
-
- def removeRows(self, row, count, parent=QModelIndex()):
- self.beginRemoveRows(parent, row, row + count - 1)
- self._databases = self._databases[:row] + self._databases[row + count :]
- self.endRemoveRows()
-
- def rowCount(self, parent=QModelIndex()):
- return len(self._databases)
-
- def update_url(self, old, new):
- """
- Updates a database URL.
-
- Args:
- old (str): old URL
- new (str): new URL
- """
- for row, db in enumerate(self._databases):
- if old == db.url:
- db.url = new
- index = self.index(row, 0)
- self.dataChanged.emit(index, index, [Qt.ItemDataRole.DisplayRole])
- return
-
- def urls(self):
- """
- Returns database URLs.
-
- Returns:
- set of str: database URLs
- """
- return {db.url for db in self._databases}
diff --git a/spine_items/exporter/mvcmodels/full_url_list_model.py b/spine_items/exporter/mvcmodels/full_url_list_model.py
index a44a6769..166d2428 100644
--- a/spine_items/exporter/mvcmodels/full_url_list_model.py
+++ b/spine_items/exporter/mvcmodels/full_url_list_model.py
@@ -8,6 +8,7 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
+
"""Exporter's ``FullUrlListModel``."""
from PySide6.QtCore import QAbstractListModel, QModelIndex, Qt
diff --git a/spine_items/exporter/mvcmodels/mapping_editor_table_model.py b/spine_items/exporter/mvcmodels/mapping_editor_table_model.py
index 20db81aa..9c15edcf 100644
--- a/spine_items/exporter/mvcmodels/mapping_editor_table_model.py
+++ b/spine_items/exporter/mvcmodels/mapping_editor_table_model.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,13 +9,10 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains model for export mapping setup table.
-"""
+"""Contains model for export mapping setup table."""
from enum import IntEnum, unique
from operator import itemgetter
-
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt
from PySide6.QtGui import QFont, QColor
from spinedb_api.mapping import is_pivoted, is_regular, Position, value_index
@@ -24,12 +22,10 @@
FixedValueMapping,
ExpandedParameterValueMapping,
ExpandedParameterDefaultValueMapping,
- FeatureEntityClassMapping,
- FeatureParameterDefinitionMapping,
- ObjectClassMapping,
- ObjectGroupMapping,
- ObjectGroupObjectMapping,
- ObjectMapping,
+ EntityClassMapping,
+ EntityGroupMapping,
+ EntityGroupEntityMapping,
+ EntityMapping,
ParameterDefaultValueMapping,
ParameterDefaultValueIndexMapping,
ParameterDefinitionMapping,
@@ -38,27 +34,18 @@
ParameterValueListValueMapping,
ParameterValueMapping,
ParameterValueTypeMapping,
- RelationshipClassMapping,
- RelationshipClassObjectClassMapping,
- RelationshipMapping,
- RelationshipObjectMapping,
+ DimensionMapping,
+ ElementMapping,
ScenarioActiveFlagMapping,
ScenarioAlternativeMapping,
ScenarioBeforeAlternativeMapping,
ScenarioDescriptionMapping,
ScenarioMapping,
- ToolFeatureEntityClassMapping,
- ToolFeatureMethodEntityClassMapping,
- ToolFeatureMethodMethodMapping,
- ToolFeatureMethodParameterDefinitionMapping,
- ToolFeatureParameterDefinitionMapping,
- ToolFeatureRequiredFlagMapping,
- ToolMapping,
IndexNameMapping,
DefaultValueIndexNameMapping,
ParameterDefaultValueTypeMapping,
)
-from spinetoolbox.helpers import color_from_index
+from spinetoolbox.helpers import color_from_index, plain_to_rich
from ..commands import SetMappingNullable, SetMappingPositions, SetMappingProperty
@@ -165,9 +152,9 @@ def data(self, index, role=Qt.ItemDataRole.DisplayRole):
return self._mapping_colors.get(m.position, QColor(Qt.GlobalColor.gray).lighter())
elif role == Qt.ItemDataRole.ToolTipRole:
if column == EditorColumn.FILTER:
- return "Regular expression to filter database items."
+ return plain_to_rich("Regular expression to filter database items.")
elif column == EditorColumn.NULLABLE:
- return "When checked, ignore this row if it yields nothing to export."
+ return plain_to_rich("When checked, ignore this row if it yields nothing to export.")
if role == self.MAPPING_ITEM_ROLE:
return self._mappings[index.row()]
return None
@@ -443,13 +430,12 @@ def compact(self):
DefaultValueIndexNameMapping: "Default value index names",
ExpandedParameterDefaultValueMapping: "Default values",
ExpandedParameterValueMapping: "Parameter values",
- FeatureEntityClassMapping: "Entity classes",
- FeatureParameterDefinitionMapping: "Parameter definitions",
IndexNameMapping: "Parameter index names",
- ObjectClassMapping: "Object classes",
- ObjectGroupMapping: "Object groups",
- ObjectGroupObjectMapping: "Objects",
- ObjectMapping: "Objects",
+ EntityClassMapping: "Entity classes",
+ EntityGroupMapping: "Entity groups",
+ EntityGroupEntityMapping: "Entities",
+ EntityMapping: "Entities",
+ ElementMapping: "Elements",
ParameterDefaultValueMapping: "Default values",
ParameterDefaultValueIndexMapping: "Default value indexes",
ParameterDefaultValueTypeMapping: "Default value types",
@@ -459,22 +445,12 @@ def compact(self):
ParameterValueListValueMapping: "Value list values",
ParameterValueMapping: "Parameter values",
ParameterValueTypeMapping: "Value types",
- RelationshipClassMapping: "Relationship classes",
- RelationshipClassObjectClassMapping: "Object classes",
- RelationshipMapping: "Relationships",
- RelationshipObjectMapping: "Objects",
+ DimensionMapping: "Dimensions",
ScenarioActiveFlagMapping: "Active flags",
ScenarioAlternativeMapping: "Alternatives",
ScenarioBeforeAlternativeMapping: "Before alternatives",
ScenarioDescriptionMapping: "Scenarios description",
ScenarioMapping: "Scenarios",
- ToolFeatureEntityClassMapping: "Entity classes",
- ToolFeatureMethodEntityClassMapping: "Entity classes",
- ToolFeatureMethodMethodMapping: "Methods",
- ToolFeatureMethodParameterDefinitionMapping: "Parameter definitions",
- ToolFeatureParameterDefinitionMapping: "Parameter definitions",
- ToolFeatureRequiredFlagMapping: "Required flags",
- ToolMapping: "Tools",
}
diff --git a/spine_items/exporter/mvcmodels/mappings_table_model.py b/spine_items/exporter/mvcmodels/mappings_table_model.py
index 0d1d7108..8994be8f 100644
--- a/spine_items/exporter/mvcmodels/mappings_table_model.py
+++ b/spine_items/exporter/mvcmodels/mappings_table_model.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,16 +9,14 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains the :class:`MappingListModel` model.
-"""
+"""Contains the :class:`MappingListModel` model."""
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt, Signal
from spinedb_api.export_mapping.export_mapping import (
ParameterDefaultValueIndexMapping,
ParameterValueIndexMapping,
- RelationshipClassObjectClassMapping,
- RelationshipClassMapping,
+ DimensionMapping,
+ EntityClassMapping,
)
from spinetoolbox.helpers import unique_name
@@ -40,12 +39,12 @@ class MappingsTableModel(QAbstractTableModel):
MAPPING_TYPE_ROLE = Qt.ItemDataRole.UserRole + 2
MAPPING_ROOT_ROLE = Qt.ItemDataRole.UserRole + 3
ALWAYS_EXPORT_HEADER_ROLE = Qt.ItemDataRole.UserRole + 4
- RELATIONSHIP_DIMENSIONS_ROLE = Qt.ItemDataRole.UserRole + 5
+ ENTITY_DIMENSIONS_ROLE = Qt.ItemDataRole.UserRole + 5
USE_FIXED_TABLE_NAME_FLAG_ROLE = Qt.ItemDataRole.UserRole + 6
FIXED_TABLE_NAME_ROLE = Qt.ItemDataRole.UserRole + 7
PARAMETER_DIMENSIONS_ROLE = Qt.ItemDataRole.UserRole + 8
GROUP_FN_ROLE = Qt.ItemDataRole.UserRole + 9
- HIGHLIGHT_DIMENSION_ROLE = Qt.ItemDataRole.UserRole + 10
+ HIGHLIGHT_POSITION_ROLE = Qt.ItemDataRole.UserRole + 10
def __init__(self, mappings=None, parent=None):
"""
@@ -116,8 +115,8 @@ def data(self, index, role=Qt.ItemDataRole.DisplayRole):
return spec.root
if role == self.ALWAYS_EXPORT_HEADER_ROLE:
return spec.always_export_header
- if role == self.RELATIONSHIP_DIMENSIONS_ROLE:
- return _instance_occurrences(spec.root, RelationshipClassObjectClassMapping)
+ if role == self.ENTITY_DIMENSIONS_ROLE:
+ return _instance_occurrences(spec.root, DimensionMapping)
if role == self.USE_FIXED_TABLE_NAME_FLAG_ROLE:
return spec.use_fixed_table_name_flag
if role == self.FIXED_TABLE_NAME_ROLE:
@@ -129,13 +128,11 @@ def data(self, index, role=Qt.ItemDataRole.DisplayRole):
return dimensions
if role == self.GROUP_FN_ROLE:
return spec.group_fn
- if role == self.HIGHLIGHT_DIMENSION_ROLE:
- highlighting_mapping = next(
- (m for m in spec.root.flatten() if isinstance(m, RelationshipClassMapping)), None
- )
+ if role == self.HIGHLIGHT_POSITION_ROLE:
+ highlighting_mapping = next((m for m in spec.root.flatten() if isinstance(m, EntityClassMapping)), None)
if highlighting_mapping is None:
return None
- return highlighting_mapping.highlight_dimension
+ return highlighting_mapping.highlight_position
return None
def flags(self, index):
@@ -239,14 +236,12 @@ def setData(self, index, value, role=Qt.ItemDataRole.EditRole):
elif role == self.GROUP_FN_ROLE:
spec.group_fn = value
self.dataChanged.emit(index, index, [self.GROUP_FN_ROLE])
- elif role == self.HIGHLIGHT_DIMENSION_ROLE:
- highlighting_mapping = next(
- (m for m in spec.root.flatten() if isinstance(m, RelationshipClassMapping)), None
- )
+ elif role == self.HIGHLIGHT_POSITION_ROLE:
+ highlighting_mapping = next((m for m in spec.root.flatten() if isinstance(m, EntityClassMapping)), None)
if highlighting_mapping is None:
return False
- highlighting_mapping.highlight_dimension = value
- self.dataChanged.emit(index, index, [self.HIGHLIGHT_DIMENSION_ROLE])
+ highlighting_mapping.highlight_position = value
+ self.dataChanged.emit(index, index, [self.HIGHLIGHT_POSITION_ROLE])
return True
return False
diff --git a/spine_items/exporter/mvcmodels/mappings_table_proxy.py b/spine_items/exporter/mvcmodels/mappings_table_proxy.py
index 368dc8e8..61aeb1ca 100644
--- a/spine_items/exporter/mvcmodels/mappings_table_proxy.py
+++ b/spine_items/exporter/mvcmodels/mappings_table_proxy.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,10 +9,8 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains the :class:`MappingsTableProxy` model.
-"""
+"""Contains the :class:`MappingsTableProxy` model."""
from itertools import takewhile
from PySide6.QtCore import QSortFilterProxyModel
diff --git a/spine_items/exporter/mvcmodels/preview_table_model.py b/spine_items/exporter/mvcmodels/preview_table_model.py
index 1fc3d683..1d147489 100644
--- a/spine_items/exporter/mvcmodels/preview_table_model.py
+++ b/spine_items/exporter/mvcmodels/preview_table_model.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,10 +9,8 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains model for a single export preview table.
-"""
+"""Contains model for a single export preview table."""
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt
diff --git a/spine_items/exporter/mvcmodels/preview_tree_model.py b/spine_items/exporter/mvcmodels/preview_tree_model.py
index 6d36cae8..62071f39 100644
--- a/spine_items/exporter/mvcmodels/preview_tree_model.py
+++ b/spine_items/exporter/mvcmodels/preview_tree_model.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,13 +9,10 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains model for export preview tables.
-"""
+"""Contains model for export preview tables."""
from itertools import takewhile
from operator import methodcaller
-
from PySide6.QtCore import QAbstractItemModel, QModelIndex, Qt
diff --git a/spine_items/exporter/output_channel.py b/spine_items/exporter/output_channel.py
index 56a41343..007e432d 100644
--- a/spine_items/exporter/output_channel.py
+++ b/spine_items/exporter/output_channel.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,13 +9,10 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Contains :class:`OutputChannel` class.
-"""
+"""Contains :class:`OutputChannel` class."""
from contextlib import suppress
from dataclasses import dataclass, InitVar
-
from spine_engine.utils.serialization import deserialize_path, serialize_path
diff --git a/spine_items/exporter/preview_table_writer.py b/spine_items/exporter/preview_table_writer.py
index fe9be0a2..2d25f377 100644
--- a/spine_items/exporter/preview_table_writer.py
+++ b/spine_items/exporter/preview_table_writer.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -8,10 +9,8 @@
# Public License for more details. You should have received a copy of the GNU Lesser General Public License along with
# this program. If not, see .
######################################################################################################################
-"""
-Functions to write export preview tables.
-"""
+"""Functions to write export preview tables."""
import numpy
from spinedb_api.spine_io.exporters.writer import Writer
diff --git a/spine_items/exporter/specification.py b/spine_items/exporter/specification.py
index fcc462b9..2a1907cb 100644
--- a/spine_items/exporter/specification.py
+++ b/spine_items/exporter/specification.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,10 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Contains Exporter's specifications.
-
-"""
+"""Contains Exporter's specifications."""
from dataclasses import dataclass
from enum import Enum, unique
from spine_engine.project_item.project_item_specification import ProjectItemSpecification
@@ -21,9 +19,9 @@
ExportMapping,
FixedValueMapping,
from_dict as mapping_from_dict,
- ObjectClassMapping,
- ObjectGroupMapping,
- ObjectGroupObjectMapping,
+ EntityClassMapping,
+ EntityGroupMapping,
+ EntityGroupEntityMapping,
ParameterValueIndexMapping,
ParameterDefaultValueIndexMapping,
IndexNameMapping,
@@ -36,22 +34,30 @@
@unique
class MappingType(Enum):
alternatives = "alternatives"
- features = "features"
- objects = "objects"
- object_groups = "object_groups"
- object_parameter_default_values = "object_default_parameter_values"
- object_parameter_values = "object_parameter_values"
+ entities = "entities"
+ entity_groups = "entity_groups"
+ entity_parameter_default_values = "entity_parameter_default_values"
+ entity_parameter_values = "entity_parameter_values"
+ entity_dimension_parameter_default_values = "entity_dimension_parameter_default_values"
+ entity_dimension_parameter_values = "entity_dimension_parameter_values"
parameter_value_lists = "parameter_value_lists"
- relationships = "relationships"
- relationship_parameter_default_values = "relationship_default_parameter_values"
- relationship_parameter_values = "relationship_parameter_values"
- relationship_object_parameter_default_values = "relationship_object_parameter_default_values"
- relationship_object_parameter_values = "relationship_object_parameter_values"
scenario_alternatives = "scenario_alternatives"
scenarios = "scenarios"
- tool_features = "tool_features"
- tool_feature_methods = "tool_feature_methods"
- tools = "tools"
+
+ @classmethod
+ def from_legacy_type(cls, type_str):
+ type_str = {
+ "objects": "entities",
+ "object_groups": "entity_groups",
+ "object_default_parameter_values": "entity_parameter_default_values",
+ "object_parameter_values": "entity_parameter_values",
+ "relationships": "entities",
+ "relationship_default_parameter_values": "entity_parameter_default_values",
+ "relationship_parameter_values": "entity_parameter_values",
+ "relationship_object_parameter_default_values": "entity_dimension_parameter_default_values",
+ "relationship_object_parameter_values": "entity_dimension_parameter_values",
+ }.get(type_str, type_str)
+ return cls(type_str)
@unique
@@ -161,7 +167,7 @@ def from_dict(mapping_dict):
MappingSpecification: deserialized specification
"""
root = mapping_from_dict(mapping_dict.pop("root"))
- type_ = MappingType(mapping_dict.pop("type"))
+ type_ = MappingType.from_legacy_type(mapping_dict.pop("type"))
return MappingSpecification(root=root, type=type_, **mapping_dict)
@@ -176,7 +182,7 @@ def __init__(self, name="", description="", mapping_specifications=None, output_
mapping_specifications (dict, optional): mapping from export mapping name to ``MappingSpecification``
output_format (OutputFormat): output format
"""
- super().__init__(name, description, ItemInfo.item_type(), ItemInfo.item_category())
+ super().__init__(name, description, ItemInfo.item_type())
if mapping_specifications is None:
mapping_specifications = dict()
self._mapping_specifications = mapping_specifications
@@ -294,17 +300,17 @@ def from_dict(specification_dict):
# Legacy: remove parameter value mappings from object group mappings,
# they're not supported anymore.
if spec_dict["type"] == "object_group_parameter_values":
- spec_dict["type"] = MappingType.object_groups.value
+ spec_dict["type"] = MappingType.entity_groups.value
keep_map_types = {
FixedValueMapping.MAP_TYPE,
- ObjectClassMapping.MAP_TYPE,
- ObjectGroupMapping.MAP_TYPE,
- ObjectGroupObjectMapping.MAP_TYPE,
+ EntityClassMapping.MAP_TYPE,
+ EntityGroupMapping.MAP_TYPE,
+ EntityGroupEntityMapping.MAP_TYPE,
}
spec_dict["mapping"] = [m for m in spec_dict["mapping"] if m["map_type"] in keep_map_types]
mapping_specifications = {
name: MappingSpecification(
- MappingType(spec_dict["type"]),
+ MappingType.from_legacy_type(spec_dict["type"]),
spec_dict.get("enabled", True),
spec_dict.get("always_export_header", True),
spec_dict.get("group_fn", legacy_group_fn_from_dict(spec_dict["mapping"])),
diff --git a/spine_items/exporter/specification_factory.py b/spine_items/exporter/specification_factory.py
index 9e7692c6..5e15076f 100644
--- a/spine_items/exporter/specification_factory.py
+++ b/spine_items/exporter/specification_factory.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -9,10 +10,7 @@
# this program. If not, see .
######################################################################################################################
-"""
-Exporter's specification factory.
-
-"""
+"""Exporter's specification factory."""
from spine_engine.project_item.project_item_specification_factory import ProjectItemSpecificationFactory
from .item_info import ItemInfo
from .specification import Specification
diff --git a/spine_items/exporter/ui/__init__.py b/spine_items/exporter/ui/__init__.py
index 8095b663..046209e7 100644
--- a/spine_items/exporter/ui/__init__.py
+++ b/spine_items/exporter/ui/__init__.py
@@ -1,5 +1,6 @@
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
diff --git a/spine_items/exporter/ui/export_list_item.py b/spine_items/exporter/ui/export_list_item.py
index 4654d8ba..55fe910b 100644
--- a/spine_items/exporter/ui/export_list_item.py
+++ b/spine_items/exporter/ui/export_list_item.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
diff --git a/spine_items/exporter/ui/exporter_properties.py b/spine_items/exporter/ui/exporter_properties.py
index 18a9a17f..fcf3d0d6 100644
--- a/spine_items/exporter/ui/exporter_properties.py
+++ b/spine_items/exporter/ui/exporter_properties.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
diff --git a/spine_items/exporter/ui/specification_editor.py b/spine_items/exporter/ui/specification_editor.py
index 87c1f1ba..ae168e90 100644
--- a/spine_items/exporter/ui/specification_editor.py
+++ b/spine_items/exporter/ui/specification_editor.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
######################################################################################################################
# Copyright (C) 2017-2022 Spine project consortium
+# Copyright Spine Items contributors
# This file is part of Spine Items.
# Spine Items is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
@@ -26,10 +27,11 @@
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QAbstractItemView, QApplication, QCheckBox, QComboBox,
- QDockWidget, QFormLayout, QHBoxLayout, QHeaderView,
- QLabel, QLineEdit, QMainWindow, QPushButton,
- QSizePolicy, QSpacerItem, QSpinBox, QTableView,
- QToolButton, QTreeView, QVBoxLayout, QWidget)
+ QFormLayout, QFrame, QHBoxLayout, QHeaderView,
+ QLabel, QLayout, QLineEdit, QMainWindow,
+ QPushButton, QSizePolicy, QSpacerItem, QSpinBox,
+ QSplitter, QTableView, QToolButton, QTreeView,
+ QVBoxLayout, QWidget)
from spinetoolbox.widgets.custom_combobox import ElidedCombobox
from spine_items import resources_icons_rc
@@ -38,82 +40,189 @@ class Ui_MainWindow(object):
def setupUi(self, MainWindow):
if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
- MainWindow.resize(1146, 801)
+ MainWindow.resize(1086, 780)
MainWindow.setDockNestingEnabled(True)
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget")
- MainWindow.setCentralWidget(self.centralwidget)
- self.mappings_dock = QDockWidget(MainWindow)
- self.mappings_dock.setObjectName(u"mappings_dock")
- self.dockWidgetContents = QWidget()
- self.dockWidgetContents.setObjectName(u"dockWidgetContents")
- self.verticalLayout = QVBoxLayout(self.dockWidgetContents)
- self.verticalLayout.setSpacing(3)
- self.verticalLayout.setObjectName(u"verticalLayout")
- self.verticalLayout.setContentsMargins(3, 3, 3, 3)
- self.horizontalLayout_2 = QHBoxLayout()
- self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
- self.add_mapping_button = QPushButton(self.dockWidgetContents)
- self.add_mapping_button.setObjectName(u"add_mapping_button")
+ self.verticalLayout_10 = QVBoxLayout(self.centralwidget)
+ self.verticalLayout_10.setObjectName(u"verticalLayout_10")
+ self.horizontalLayout_3 = QHBoxLayout()
+ self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
+ self.horizontalLayout_3.setSizeConstraint(QLayout.SetDefaultConstraint)
+ self.label = QLabel(self.centralwidget)
+ self.label.setObjectName(u"label")
+ sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
+ sizePolicy.setHorizontalStretch(0)
+ sizePolicy.setVerticalStretch(0)
+ sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
+ self.label.setSizePolicy(sizePolicy)
- self.horizontalLayout_2.addWidget(self.add_mapping_button)
+ self.horizontalLayout_3.addWidget(self.label)
- self.remove_mapping_button = QPushButton(self.dockWidgetContents)
- self.remove_mapping_button.setObjectName(u"remove_mapping_button")
+ self.export_format_combo_box = QComboBox(self.centralwidget)
+ self.export_format_combo_box.setObjectName(u"export_format_combo_box")
+ sizePolicy1 = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
+ sizePolicy1.setHorizontalStretch(1)
+ sizePolicy1.setVerticalStretch(0)
+ sizePolicy1.setHeightForWidth(self.export_format_combo_box.sizePolicy().hasHeightForWidth())
+ self.export_format_combo_box.setSizePolicy(sizePolicy1)
- self.horizontalLayout_2.addWidget(self.remove_mapping_button)
+ self.horizontalLayout_3.addWidget(self.export_format_combo_box)
- self.toggle_enabled_button = QPushButton(self.dockWidgetContents)
- self.toggle_enabled_button.setObjectName(u"toggle_enabled_button")
+ self.live_preview_check_box = QCheckBox(self.centralwidget)
+ self.live_preview_check_box.setObjectName(u"live_preview_check_box")
+ self.live_preview_check_box.setChecked(False)
- self.horizontalLayout_2.addWidget(self.toggle_enabled_button)
+ self.horizontalLayout_3.addWidget(self.live_preview_check_box)
- self.horizontalSpacer_2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
+ self.frame_preview = QFrame(self.centralwidget)
+ self.frame_preview.setObjectName(u"frame_preview")
+ self.frame_preview.setEnabled(False)
+ sizePolicy2 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
+ sizePolicy2.setHorizontalStretch(0)
+ sizePolicy2.setVerticalStretch(0)
+ sizePolicy2.setHeightForWidth(self.frame_preview.sizePolicy().hasHeightForWidth())
+ self.frame_preview.setSizePolicy(sizePolicy2)
+ self.frame_preview.setFrameShape(QFrame.StyledPanel)
+ self.frame_preview.setFrameShadow(QFrame.Raised)
+ self.horizontalLayout = QHBoxLayout(self.frame_preview)
+ self.horizontalLayout.setObjectName(u"horizontalLayout")
+ self.horizontalLayout.setContentsMargins(3, 0, 3, 0)
+ self.label_9 = QLabel(self.frame_preview)
+ self.label_9.setObjectName(u"label_9")
- self.horizontalLayout_2.addItem(self.horizontalSpacer_2)
+ self.horizontalLayout.addWidget(self.label_9)
+
+ self.database_url_combo_box = ElidedCombobox(self.frame_preview)
+ self.database_url_combo_box.setObjectName(u"database_url_combo_box")
+ sizePolicy3 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
+ sizePolicy3.setHorizontalStretch(0)
+ sizePolicy3.setVerticalStretch(0)
+ sizePolicy3.setHeightForWidth(self.database_url_combo_box.sizePolicy().hasHeightForWidth())
+ self.database_url_combo_box.setSizePolicy(sizePolicy3)
+ self.database_url_combo_box.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
+ self.database_url_combo_box.setMinimumContentsLength(16)
+
+ self.horizontalLayout.addWidget(self.database_url_combo_box)
+
+ self.load_url_from_fs_button = QToolButton(self.frame_preview)
+ self.load_url_from_fs_button.setObjectName(u"load_url_from_fs_button")
+ icon = QIcon()
+ icon.addFile(u":/icons/folder-open-solid.svg", QSize(), QIcon.Normal, QIcon.Off)
+ self.load_url_from_fs_button.setIcon(icon)
+ self.horizontalLayout.addWidget(self.load_url_from_fs_button)
- self.verticalLayout.addLayout(self.horizontalLayout_2)
+ self.label_3 = QLabel(self.frame_preview)
+ self.label_3.setObjectName(u"label_3")
+
+ self.horizontalLayout.addWidget(self.label_3)
- self.mappings_table = QTableView(self.dockWidgetContents)
+ self.max_preview_tables_spin_box = QSpinBox(self.frame_preview)
+ self.max_preview_tables_spin_box.setObjectName(u"max_preview_tables_spin_box")
+ self.max_preview_tables_spin_box.setMaximum(16777215)
+ self.max_preview_tables_spin_box.setSingleStep(10)
+ self.max_preview_tables_spin_box.setValue(20)
+
+ self.horizontalLayout.addWidget(self.max_preview_tables_spin_box)
+
+ self.label_2 = QLabel(self.frame_preview)
+ self.label_2.setObjectName(u"label_2")
+
+ self.horizontalLayout.addWidget(self.label_2)
+
+ self.max_preview_rows_spin_box = QSpinBox(self.frame_preview)
+ self.max_preview_rows_spin_box.setObjectName(u"max_preview_rows_spin_box")
+ self.max_preview_rows_spin_box.setMaximum(16777215)
+ self.max_preview_rows_spin_box.setSingleStep(10)
+ self.max_preview_rows_spin_box.setValue(20)
+
+ self.horizontalLayout.addWidget(self.max_preview_rows_spin_box)
+
+
+ self.horizontalLayout_3.addWidget(self.frame_preview)
+
+
+ self.verticalLayout_10.addLayout(self.horizontalLayout_3)
+
+ self.splitter_3 = QSplitter(self.centralwidget)
+ self.splitter_3.setObjectName(u"splitter_3")
+ self.splitter_3.setOrientation(Qt.Horizontal)
+ self.splitter_2 = QSplitter(self.splitter_3)
+ self.splitter_2.setObjectName(u"splitter_2")
+ self.splitter_2.setOrientation(Qt.Vertical)
+ self.mapping_list_layout_widget = QWidget(self.splitter_2)
+ self.mapping_list_layout_widget.setObjectName(u"mapping_list_layout_widget")
+ self.verticalLayout_9 = QVBoxLayout(self.mapping_list_layout_widget)
+ self.verticalLayout_9.setSpacing(0)
+ self.verticalLayout_9.setObjectName(u"verticalLayout_9")
+ self.frame = QFrame(self.mapping_list_layout_widget)
+ self.frame.setObjectName(u"frame")
+ self.frame.setFrameShape(QFrame.StyledPanel)
+ self.frame.setFrameShadow(QFrame.Raised)
+ self.verticalLayout_11 = QVBoxLayout(self.frame)
+ self.verticalLayout_11.setSpacing(0)
+ self.verticalLayout_11.setObjectName(u"verticalLayout_11")
+ self.verticalLayout_11.setContentsMargins(3, 3, 3, 3)
+ self.label_11 = QLabel(self.frame)
+ self.label_11.setObjectName(u"label_11")
+
+ self.verticalLayout_11.addWidget(self.label_11)
+
+
+ self.verticalLayout_9.addWidget(self.frame)
+
+ self.mappings_table = QTableView(self.mapping_list_layout_widget)
self.mappings_table.setObjectName(u"mappings_table")
self.mappings_table.setContextMenuPolicy(Qt.CustomContextMenu)
self.mappings_table.setSelectionBehavior(QAbstractItemView.SelectRows)
self.mappings_table.setShowGrid(False)
self.mappings_table.verticalHeader().setVisible(False)
- self.verticalLayout.addWidget(self.mappings_table)
+ self.verticalLayout_9.addWidget(self.mappings_table)
- self.horizontalLayout_6 = QHBoxLayout()
- self.horizontalLayout_6.setObjectName(u"horizontalLayout_6")
- self.horizontalSpacer_4 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
+ self.splitter_2.addWidget(self.mapping_list_layout_widget)
+ self.mapping_controls_layout_widget = QWidget(self.splitter_2)
+ self.mapping_controls_layout_widget.setObjectName(u"mapping_controls_layout_widget")
+ self.verticalLayout_8 = QVBoxLayout(self.mapping_controls_layout_widget)
+ self.verticalLayout_8.setObjectName(u"verticalLayout_8")
+ self.horizontalLayout_2 = QHBoxLayout()
+ self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
+ self.add_mapping_button = QPushButton(self.mapping_controls_layout_widget)
+ self.add_mapping_button.setObjectName(u"add_mapping_button")
- self.horizontalLayout_6.addItem(self.horizontalSpacer_4)
+ self.horizontalLayout_2.addWidget(self.add_mapping_button)
+
+ self.remove_mapping_button = QPushButton(self.mapping_controls_layout_widget)
+ self.remove_mapping_button.setObjectName(u"remove_mapping_button")
+
+ self.horizontalLayout_2.addWidget(self.remove_mapping_button)
+
+ self.toggle_enabled_button = QPushButton(self.mapping_controls_layout_widget)
+ self.toggle_enabled_button.setObjectName(u"toggle_enabled_button")
- self.write_earlier_button = QPushButton(self.dockWidgetContents)
+ self.horizontalLayout_2.addWidget(self.toggle_enabled_button)
+
+ self.horizontalSpacer_2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
+
+ self.horizontalLayout_2.addItem(self.horizontalSpacer_2)
+
+ self.write_earlier_button = QPushButton(self.mapping_controls_layout_widget)
self.write_earlier_button.setObjectName(u"write_earlier_button")
- self.horizontalLayout_6.addWidget(self.write_earlier_button)
+ self.horizontalLayout_2.addWidget(self.write_earlier_button)
- self.write_later_button = QPushButton(self.dockWidgetContents)
+ self.write_later_button = QPushButton(self.mapping_controls_layout_widget)
self.write_later_button.setObjectName(u"write_later_button")
- self.horizontalLayout_6.addWidget(self.write_later_button)
+ self.horizontalLayout_2.addWidget(self.write_later_button)
- self.verticalLayout.addLayout(self.horizontalLayout_6)
+ self.verticalLayout_8.addLayout(self.horizontalLayout_2)
- self.mappings_dock.setWidget(self.dockWidgetContents)
- MainWindow.addDockWidget(Qt.LeftDockWidgetArea, self.mappings_dock)
- self.mapping_options_dock = QDockWidget(MainWindow)
- self.mapping_options_dock.setObjectName(u"mapping_options_dock")
- self.mapping_options_contents = QWidget()
+ self.mapping_options_contents = QFrame(self.mapping_controls_layout_widget)
self.mapping_options_contents.setObjectName(u"mapping_options_contents")
- self.verticalLayout_7 = QVBoxLayout(self.mapping_options_contents)
- self.verticalLayout_7.setSpacing(3)
- self.verticalLayout_7.setObjectName(u"verticalLayout_7")
- self.verticalLayout_7.setContentsMargins(3, 3, 3, 3)
- self.formLayout = QFormLayout()
+ self.formLayout = QFormLayout(self.mapping_options_contents)
self.formLayout.setObjectName(u"formLayout")
self.label_4 = QLabel(self.mapping_options_contents)
self.label_4.setObjectName(u"label_4")
@@ -128,30 +237,20 @@ def setupUi(self, MainWindow):
self.item_type_combo_box.addItem("")
self.item_type_combo_box.addItem("")
self.item_type_combo_box.addItem("")
- self.item_type_combo_box.addItem("")
- self.item_type_combo_box.addItem("")
- self.item_type_combo_box.addItem("")
- self.item_type_combo_box.addItem("")
- self.item_type_combo_box.addItem("")
self.item_type_combo_box.setObjectName(u"item_type_combo_box")
self.formLayout.setWidget(0, QFormLayout.FieldRole, self.item_type_combo_box)
- self.always_export_header_check_box = QCheckBox(self.mapping_options_contents)
- self.always_export_header_check_box.setObjectName(u"always_export_header_check_box")
-
- self.formLayout.setWidget(1, QFormLayout.SpanningRole, self.always_export_header_check_box)
-
self.label_8 = QLabel(self.mapping_options_contents)
self.label_8.setObjectName(u"label_8")
self.formLayout.setWidget(2, QFormLayout.LabelRole, self.label_8)
- self.relationship_dimensions_spin_box = QSpinBox(self.mapping_options_contents)
- self.relationship_dimensions_spin_box.setObjectName(u"relationship_dimensions_spin_box")
- self.relationship_dimensions_spin_box.setMinimum(1)
+ self.entity_dimensions_spin_box = QSpinBox(self.mapping_options_contents)
+ self.entity_dimensions_spin_box.setObjectName(u"entity_dimensions_spin_box")
+ self.entity_dimensions_spin_box.setMinimum(0)
- self.formLayout.setWidget(2, QFormLayout.FieldRole, self.relationship_dimensions_spin_box)
+ self.formLayout.setWidget(2, QFormLayout.FieldRole, self.entity_dimensions_spin_box)
self.label_7 = QLabel(self.mapping_options_contents)
self.label_7.setObjectName(u"label_7")
@@ -190,225 +289,95 @@ def setupUi(self, MainWindow):
self.fix_table_name_check_box = QCheckBox(self.mapping_options_contents)
self.fix_table_name_check_box.setObjectName(u"fix_table_name_check_box")
- self.formLayout.setWidget(6, QFormLayout.LabelRole, self.fix_table_name_check_box)
+ self.formLayout.setWidget(7, QFormLayout.LabelRole, self.fix_table_name_check_box)
self.fix_table_name_line_edit = QLineEdit(self.mapping_options_contents)
self.fix_table_name_line_edit.setObjectName(u"fix_table_name_line_edit")
- self.formLayout.setWidget(6, QFormLayout.FieldRole, self.fix_table_name_line_edit)
+ self.formLayout.setWidget(7, QFormLayout.FieldRole, self.fix_table_name_line_edit)
+
+ self.always_export_header_check_box = QCheckBox(self.mapping_options_contents)
+ self.always_export_header_check_box.setObjectName(u"always_export_header_check_box")
+
+ self.formLayout.setWidget(10, QFormLayout.LabelRole, self.always_export_header_check_box)
+
+ self.compact_button = QPushButton(self.mapping_options_contents)
+ self.compact_button.setObjectName(u"compact_button")
+
+ self.formLayout.setWidget(10, QFormLayout.FieldRole, self.compact_button)
self.label_6 = QLabel(self.mapping_options_contents)
self.label_6.setObjectName(u"label_6")
- self.formLayout.setWidget(7, QFormLayout.LabelRole, self.label_6)
+ self.formLayout.setWidget(6, QFormLayout.LabelRole, self.label_6)
self.group_fn_combo_box = QComboBox(self.mapping_options_contents)
self.group_fn_combo_box.setObjectName(u"group_fn_combo_box")
- self.formLayout.setWidget(7, QFormLayout.FieldRole, self.group_fn_combo_box)
+ self.formLayout.setWidget(6, QFormLayout.FieldRole, self.group_fn_combo_box)
- self.verticalLayout_7.addLayout(self.formLayout)
+ self.verticalLayout_8.addWidget(self.mapping_options_contents)
- self.verticalSpacer_3 = QSpacerItem(20, 12, QSizePolicy.Minimum, QSizePolicy.Expanding)
-
- self.verticalLayout_7.addItem(self.verticalSpacer_3)
-
- self.mapping_options_dock.setWidget(self.mapping_options_contents)
- MainWindow.addDockWidget(Qt.LeftDockWidgetArea, self.mapping_options_dock)
- self.mapping_spec_dock = QDockWidget(MainWindow)
- self.mapping_spec_dock.setObjectName(u"mapping_spec_dock")
- self.mapping_spec_contents = QWidget()
- self.mapping_spec_contents.setObjectName(u"mapping_spec_contents")
- self.mapping_spec_contents.setEnabled(False)
- self.verticalLayout_2 = QVBoxLayout(self.mapping_spec_contents)
- self.verticalLayout_2.setSpacing(3)
- self.verticalLayout_2.setObjectName(u"verticalLayout_2")
- self.verticalLayout_2.setContentsMargins(3, 3, 3, 3)
- self.mapping_table_view = QTableView(self.mapping_spec_contents)
+ self.mapping_table_view = QTableView(self.mapping_controls_layout_widget)
self.mapping_table_view.setObjectName(u"mapping_table_view")
self.mapping_table_view.setSelectionMode(QAbstractItemView.SingleSelection)
self.mapping_table_view.horizontalHeader().setStretchLastSection(True)
self.mapping_table_view.verticalHeader().setVisible(False)
- self.verticalLayout_2.addWidget(self.mapping_table_view)
-
- self.horizontalLayout_5 = QHBoxLayout()
- self.horizontalLayout_5.setObjectName(u"horizontalLayout_5")
- self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
+ self.verticalLayout_8.addWidget(self.mapping_table_view)
- self.horizontalLayout_5.addItem(self.horizontalSpacer)
-
- self.compact_button = QPushButton(self.mapping_spec_contents)
- self.compact_button.setObjectName(u"compact_button")
-
- self.horizontalLayout_5.addWidget(self.compact_button)
-
-
- self.verticalLayout_2.addLayout(self.horizontalLayout_5)
-
- self.mapping_spec_dock.setWidget(self.mapping_spec_contents)
- MainWindow.addDockWidget(Qt.LeftDockWidgetArea, self.mapping_spec_dock)
- self.preview_tables_dock = QDockWidget(MainWindow)
- self.preview_tables_dock.setObjectName(u"preview_tables_dock")
- self.dockWidgetContents_5 = QWidget()
- self.dockWidgetContents_5.setObjectName(u"dockWidgetContents_5")
- self.verticalLayout_3 = QVBoxLayout(self.dockWidgetContents_5)
- self.verticalLayout_3.setSpacing(3)
- self.verticalLayout_3.setObjectName(u"verticalLayout_3")
- self.verticalLayout_3.setContentsMargins(3, 3, 3, 3)
- self.preview_tree_view = QTreeView(self.dockWidgetContents_5)
+ self.splitter_2.addWidget(self.mapping_controls_layout_widget)
+ self.splitter_3.addWidget(self.splitter_2)
+ self.splitter = QSplitter(self.splitter_3)
+ self.splitter.setObjectName(u"splitter")
+ self.splitter.setOrientation(Qt.Horizontal)
+ self.preview_tree_view = QTreeView(self.splitter)
self.preview_tree_view.setObjectName(u"preview_tree_view")
+ sizePolicy4 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+ sizePolicy4.setHorizontalStretch(1)
+ sizePolicy4.setVerticalStretch(0)
+ sizePolicy4.setHeightForWidth(self.preview_tree_view.sizePolicy().hasHeightForWidth())
+ self.preview_tree_view.setSizePolicy(sizePolicy4)
+ self.splitter.addWidget(self.preview_tree_view)
self.preview_tree_view.header().setVisible(False)
-
- self.verticalLayout_3.addWidget(self.preview_tree_view)
-
- self.preview_tables_dock.setWidget(self.dockWidgetContents_5)
- MainWindow.addDockWidget(Qt.RightDockWidgetArea, self.preview_tables_dock)
- self.preview_contents_dock = QDockWidget(MainWindow)
- self.preview_contents_dock.setObjectName(u"preview_contents_dock")
- self.dockWidgetContents_6 = QWidget()
- self.dockWidgetContents_6.setObjectName(u"dockWidgetContents_6")
- self.verticalLayout_4 = QVBoxLayout(self.dockWidgetContents_6)
- self.verticalLayout_4.setSpacing(3)
- self.verticalLayout_4.setObjectName(u"verticalLayout_4")
- self.verticalLayout_4.setContentsMargins(3, 3, 3, 3)
- self.preview_table_view = QTableView(self.dockWidgetContents_6)
+ self.preview_table_view = QTableView(self.splitter)
self.preview_table_view.setObjectName(u"preview_table_view")
+ sizePolicy5 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
+ sizePolicy5.setHorizontalStretch(5)
+ sizePolicy5.setVerticalStretch(0)
+ sizePolicy5.setHeightForWidth(self.preview_table_view.sizePolicy().hasHeightForWidth())
+ self.preview_table_view.setSizePolicy(sizePolicy5)
+ self.splitter.addWidget(self.preview_table_view)
+ self.splitter_3.addWidget(self.splitter)
- self.verticalLayout_4.addWidget(self.preview_table_view)
-
- self.preview_contents_dock.setWidget(self.dockWidgetContents_6)
- MainWindow.addDockWidget(Qt.RightDockWidgetArea, self.preview_contents_dock)
- self.export_options_dock = QDockWidget(MainWindow)
- self.export_options_dock.setObjectName(u"export_options_dock")
- self.export_options_dock.setAllowedAreas(Qt.AllDockWidgetAreas)
- self.dockWidgetContents_7 = QWidget()
- self.dockWidgetContents_7.setObjectName(u"dockWidgetContents_7")
- self.verticalLayout_5 = QVBoxLayout(self.dockWidgetContents_7)
- self.verticalLayout_5.setSpacing(3)
- self.verticalLayout_5.setObjectName(u"verticalLayout_5")
- self.verticalLayout_5.setContentsMargins(3, 3, 3, 3)
- self.horizontalLayout_4 = QHBoxLayout()
- self.horizontalLayout_4.setObjectName(u"horizontalLayout_4")
- self.label = QLabel(self.dockWidgetContents_7)
- self.label.setObjectName(u"label")
- sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
- sizePolicy.setHorizontalStretch(0)
- sizePolicy.setVerticalStretch(0)
- sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
- self.label.setSizePolicy(sizePolicy)
- font = QFont()
- font.setPointSize(10)
- self.label.setFont(font)
-
- self.horizontalLayout_4.addWidget(self.label)
-
- self.export_format_combo_box = QComboBox(self.dockWidgetContents_7)
- self.export_format_combo_box.setObjectName(u"export_format_combo_box")
- sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed)
- sizePolicy1.setHorizontalStretch(1)
- sizePolicy1.setVerticalStretch(0)
- sizePolicy1.setHeightForWidth(self.export_format_combo_box.sizePolicy().hasHeightForWidth())
- self.export_format_combo_box.setSizePolicy(sizePolicy1)
-
- self.horizontalLayout_4.addWidget(self.export_format_combo_box)
-
-
- self.verticalLayout_5.addLayout(self.horizontalLayout_4)
-
- self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
-
- self.verticalLayout_5.addItem(self.verticalSpacer)
-
- self.export_options_dock.setWidget(self.dockWidgetContents_7)
- MainWindow.addDockWidget(Qt.LeftDockWidgetArea, self.export_options_dock)
- self.preview_controls_dock = QDockWidget(MainWindow)
- self.preview_controls_dock.setObjectName(u"preview_controls_dock")
- self.dockWidgetContents_4 = QWidget()
- self.dockWidgetContents_4.setObjectName(u"dockWidgetContents_4")
- self.verticalLayout_6 = QVBoxLayout(self.dockWidgetContents_4)
- self.verticalLayout_6.setSpacing(3)
- self.verticalLayout_6.setObjectName(u"verticalLayout_6")
- self.verticalLayout_6.setContentsMargins(3, 3, 3, 3)
- self.horizontalLayout_3 = QHBoxLayout()
- self.horizontalLayout_3.setObjectName(u"horizontalLayout_3")
- self.label_9 = QLabel(self.dockWidgetContents_4)
- self.label_9.setObjectName(u"label_9")
- self.label_9.setFont(font)
-
- self.horizontalLayout_3.addWidget(self.label_9)
-
- self.database_url_combo_box = ElidedCombobox(self.dockWidgetContents_4)
- self.database_url_combo_box.setObjectName(u"database_url_combo_box")
- sizePolicy2 = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
- sizePolicy2.setHorizontalStretch(0)
- sizePolicy2.setVerticalStretch(0)
- sizePolicy2.setHeightForWidth(self.database_url_combo_box.sizePolicy().hasHeightForWidth())
- self.database_url_combo_box.setSizePolicy(sizePolicy2)
- self.database_url_combo_box.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLengthWithIcon)
- self.database_url_combo_box.setMinimumContentsLength(0)
-
- self.horizontalLayout_3.addWidget(self.database_url_combo_box)
-
- self.load_url_from_fs_button = QToolButton(self.dockWidgetContents_4)
- self.load_url_from_fs_button.setObjectName(u"load_url_from_fs_button")
- icon = QIcon()
- icon.addFile(u":/icons/folder-open-solid.svg", QSize(), QIcon.Normal, QIcon.Off)
- self.load_url_from_fs_button.setIcon(icon)
-
- self.horizontalLayout_3.addWidget(self.load_url_from_fs_button)
-
+ self.verticalLayout_10.addWidget(self.splitter_3)
- self.verticalLayout_6.addLayout(self.horizontalLayout_3)
-
- self.horizontalLayout = QHBoxLayout()
- self.horizontalLayout.setObjectName(u"horizontalLayout")
- self.live_preview_check_box = QCheckBox(self.dockWidgetContents_4)
- self.live_preview_check_box.setObjectName(u"live_preview_check_box")
- self.live_preview_check_box.setChecked(False)
-
- self.horizontalLayout.addWidget(self.live_preview_check_box)
-
- self.horizontalSpacer_3 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
-
- self.horizontalLayout.addItem(self.horizontalSpacer_3)
-
- self.label_3 = QLabel(self.dockWidgetContents_4)
- self.label_3.setObjectName(u"label_3")
-
- self.horizontalLayout.addWidget(self.label_3)
-
- self.max_preview_tables_spin_box = QSpinBox(self.dockWidgetContents_4)
- self.max_preview_tables_spin_box.setObjectName(u"max_preview_tables_spin_box")
- self.max_preview_tables_spin_box.setMaximum(16777215)
- self.max_preview_tables_spin_box.setSingleStep(10)
- self.max_preview_tables_spin_box.setValue(20)
-
- self.horizontalLayout.addWidget(self.max_preview_tables_spin_box)
-
- self.label_2 = QLabel(self.dockWidgetContents_4)
- self.label_2.setObjectName(u"label_2")
-
- self.horizontalLayout.addWidget(self.label_2)
-
- self.max_preview_rows_spin_box = QSpinBox(self.dockWidgetContents_4)
- self.max_preview_rows_spin_box.setObjectName(u"max_preview_rows_spin_box")
- self.max_preview_rows_spin_box.setMaximum(16777215)
- self.max_preview_rows_spin_box.setSingleStep(10)
- self.max_preview_rows_spin_box.setValue(20)
-
- self.horizontalLayout.addWidget(self.max_preview_rows_spin_box)
-
-
- self.verticalLayout_6.addLayout(self.horizontalLayout)
-
- self.verticalSpacer_2 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
-
- self.verticalLayout_6.addItem(self.verticalSpacer_2)
-
- self.preview_controls_dock.setWidget(self.dockWidgetContents_4)
- MainWindow.addDockWidget(Qt.RightDockWidgetArea, self.preview_controls_dock)
+ MainWindow.setCentralWidget(self.centralwidget)
+ QWidget.setTabOrder(self.export_format_combo_box, self.live_preview_check_box)
+ QWidget.setTabOrder(self.live_preview_check_box, self.database_url_combo_box)
+ QWidget.setTabOrder(self.database_url_combo_box, self.load_url_from_fs_button)
+ QWidget.setTabOrder(self.load_url_from_fs_button, self.max_preview_tables_spin_box)
+ QWidget.setTabOrder(self.max_preview_tables_spin_box, self.max_preview_rows_spin_box)
+ QWidget.setTabOrder(self.max_preview_rows_spin_box, self.mappings_table)
+ QWidget.setTabOrder(self.mappings_table, self.add_mapping_button)
+ QWidget.setTabOrder(self.add_mapping_button, self.remove_mapping_button)
+ QWidget.setTabOrder(self.remove_mapping_button, self.toggle_enabled_button)
+ QWidget.setTabOrder(self.toggle_enabled_button, self.write_earlier_button)
+ QWidget.setTabOrder(self.write_earlier_button, self.write_later_button)
+ QWidget.setTabOrder(self.write_later_button, self.item_type_combo_box)
+ QWidget.setTabOrder(self.item_type_combo_box, self.entity_dimensions_spin_box)
+ QWidget.setTabOrder(self.entity_dimensions_spin_box, self.highlight_dimension_spin_box)
+ QWidget.setTabOrder(self.highlight_dimension_spin_box, self.parameter_type_combo_box)
+ QWidget.setTabOrder(self.parameter_type_combo_box, self.parameter_dimensions_spin_box)
+ QWidget.setTabOrder(self.parameter_dimensions_spin_box, self.group_fn_combo_box)
+ QWidget.setTabOrder(self.group_fn_combo_box, self.fix_table_name_check_box)
+ QWidget.setTabOrder(self.fix_table_name_check_box, self.fix_table_name_line_edit)
+ QWidget.setTabOrder(self.fix_table_name_line_edit, self.always_export_header_check_box)
+ QWidget.setTabOrder(self.always_export_header_check_box, self.compact_button)
+ QWidget.setTabOrder(self.compact_button, self.mapping_table_view)
+ QWidget.setTabOrder(self.mapping_table_view, self.preview_tree_view)
+ QWidget.setTabOrder(self.preview_tree_view, self.preview_table_view)
self.retranslateUi(MainWindow)
@@ -417,7 +386,16 @@ def setupUi(self, MainWindow):
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None))
- self.mappings_dock.setWindowTitle(QCoreApplication.translate("MainWindow", u"Mappings", None))
+ self.label.setText(QCoreApplication.translate("MainWindow", u"Export format:", None))
+ self.live_preview_check_box.setText(QCoreApplication.translate("MainWindow", u"Live preview", None))
+ self.label_9.setText(QCoreApplication.translate("MainWindow", u"Database url:", None))
+#if QT_CONFIG(tooltip)
+ self.load_url_from_fs_button.setToolTip(QCoreApplication.translate("MainWindow", u"