mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Network: Fix missing file and pep8.
This commit is contained in:
1 parent
46b943c800
commit
5fec95cc4d
6 files changed
+168
-4
No files matched your search
@@ -0,0 +1,91 @@
|
||||
# ProfileDialog.py -- Pamhyr
|
||||
# Copyright (C) 2025 INRAE
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
import random
|
||||
|
||||
from tools import logger_exception
|
||||
|
||||
from View.Tools.PamhyrWindow import PamhyrDialog
|
||||
from View.Network.translate import NetworkTranslate
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
)
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel,
|
||||
QCoreApplication, QModelIndex, pyqtSlot,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QPushButton, QLineEdit,
|
||||
QFileDialog, QTableView, QAbstractItemView,
|
||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
|
||||
QTextEdit,
|
||||
)
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class SelectProfileDialog(PamhyrDialog):
|
||||
_pamhyr_ui = "SelectProfile"
|
||||
_pamhyr_name = "Select profile"
|
||||
|
||||
def __init__(self, study=None, config=None,
|
||||
reach=None, trad=None, parent=None):
|
||||
self._trad = trad
|
||||
if self._trad is not None:
|
||||
name = trad["dialog_select_profile_title"]
|
||||
|
||||
super(SelectProfileDialog, self).__init__(
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._reach = reach
|
||||
self._profile = None
|
||||
|
||||
self.setup_combobox()
|
||||
|
||||
def setup_combobox(self):
|
||||
self.combobox_add_items(
|
||||
"comboBox",
|
||||
list(
|
||||
map(
|
||||
lambda p: p.display_name(),
|
||||
self._reach.reach.profiles)))
|
||||
|
||||
def accept(self):
|
||||
profile = self.get_combobox_text("comboBox")
|
||||
|
||||
self._profile = next(
|
||||
filter(
|
||||
lambda p: p.display_name() == profile,
|
||||
self._reach.reach.profiles
|
||||
)
|
||||
)
|
||||
|
||||
super(SelectProfileDialog, self).accept()
|
||||
|
||||
def reject(self):
|
||||
self.close()
|
||||
@@ -117,6 +117,7 @@ class DelEdgeCommand(QUndoCommand):
|
||||
def redo(self):
|
||||
self._graph.remove_edge(self._edge)
|
||||
|
||||
|
||||
class SplitEdgeCommand(QUndoCommand):
|
||||
def __init__(self, graph, edge, profile):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -139,6 +140,7 @@ class SplitEdgeCommand(QUndoCommand):
|
||||
self._new_r1.set_as_not_deleted()
|
||||
self._new_r2.set_as_not_deleted()
|
||||
|
||||
|
||||
class SetCommand(QUndoCommand):
|
||||
def __init__(self, element, column, new_value):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
@@ -46,9 +46,12 @@ class NetworkTranslate(MainTranslate):
|
||||
"Network", "Delete node reservoir"
|
||||
)
|
||||
|
||||
self._dict["menu_del_edge"] = _translate("Network", "Delete the reach")
|
||||
self._dict["menu_split_edge"] = _translate("Network", "Split the reach")
|
||||
self._dict["menu_ena_edge"] = _translate("Network", "Enable the reach")
|
||||
self._dict["menu_del_edge"] = _translate("Network",
|
||||
"Delete the reach")
|
||||
self._dict["menu_split_edge"] = _translate("Network",
|
||||
"Split the reach")
|
||||
self._dict["menu_ena_edge"] = _translate("Network",
|
||||
"Enable the reach")
|
||||
self._dict["menu_dis_edge"] = _translate("Network",
|
||||
"Disable the reach")
|
||||
self._dict["menu_rev_edge"] = _translate(
|
||||
|
||||
Reference in new issue
Block a user