######################################################################################################################
# Copyright (C) 2017-2020 Spine project consortium
# This file is part of Spine Toolbox.
# Spine Toolbox 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 <http://www.gnu.org/licenses/>.
######################################################################################################################
"""
An editor widget for editing a map type parameter values.
:author: A. Soininen (VTT)
:date: 11.2.2020
"""
from PySide2.QtCore import Qt, Slot
from PySide2.QtWidgets import QMenu, QWidget
from spinedb_api import Map
from ..mvcmodels.map_model import MapModel
[docs]class MapEditor(QWidget):
"""
A widget for editing maps.
Attributes:
parent (QWidget):
"""
def __init__(self, parent=None):
from ..ui.map_editor import Ui_MapEditor
super().__init__(parent)
self._model = MapModel(Map(["key_1"], [0.0]))
self._ui = Ui_MapEditor()
self._ui.setupUi(self)
self._ui.map_table_view.setModel(self._model)
self._ui.map_table_view.setContextMenuPolicy(Qt.CustomContextMenu)
self._ui.map_table_view.customContextMenuRequested.connect(self._show_table_context_menu)
@Slot("QPoint", name="_show_table_context_menu")
[docs] def set_value(self, value):
"""Sets the parameter value to be edited."""
self._model.reset(value)
[docs] def value(self):
"""Returns the parameter value currently being edited."""
return self._model.value()