mirror of https://gitlab.com/pamhyr/pamhyr2
pamhyr: Catch some table data type exception (crash Fix).
parent
e8ae1c0631
commit
464209b6e5
|
|
@ -17,6 +17,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import traceback
|
||||||
|
|
||||||
from datetime import date, time, datetime, timedelta
|
from datetime import date, time, datetime, timedelta
|
||||||
|
|
||||||
|
|
@ -212,11 +213,15 @@ class TableModel(QAbstractTableModel):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
self._undo.push(
|
try:
|
||||||
SetDataCommand(
|
self._undo.push(
|
||||||
self._data, row, column, value
|
SetDataCommand(
|
||||||
|
self._data, row, column, value
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
except Exception as e:
|
||||||
|
logger.info(e)
|
||||||
|
logger.debug(traceback.format_exc())
|
||||||
|
|
||||||
self.dataChanged.emit(index, index)
|
self.dataChanged.emit(index, index)
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@ class SetDataCommand(QUndoCommand):
|
||||||
self._index = index
|
self._index = index
|
||||||
self._column = column
|
self._column = column
|
||||||
self._old = self._data.get_i(self._index)[self._column]
|
self._old = self._data.get_i(self._index)[self._column]
|
||||||
self._new = new_value
|
_type = self._data.get_type_column(self._column)
|
||||||
|
self._new = _type(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._data._set_i_c_v(self._index, self._column, self._old)
|
self._data._set_i_c_v(self._index, self._column, self._old)
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import traceback
|
||||||
|
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
|
|
@ -43,6 +46,8 @@ from View.BoundaryCondition.UndoCommand import (
|
||||||
)
|
)
|
||||||
from View.BoundaryCondition.translate import *
|
from View.BoundaryCondition.translate import *
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
class ComboBoxDelegate(QItemDelegate):
|
class ComboBoxDelegate(QItemDelegate):
|
||||||
|
|
@ -153,25 +158,29 @@ class TableModel(QAbstractTableModel):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
if self._headers[column] == "name":
|
try:
|
||||||
self._undo.push(
|
if self._headers[column] == "name":
|
||||||
SetNameCommand(
|
self._undo.push(
|
||||||
self._bcs, self._tab,row, value
|
SetNameCommand(
|
||||||
|
self._bcs, self._tab,row, value
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
elif self._headers[column] == "type":
|
||||||
elif self._headers[column] == "type":
|
key = next(k for k, v in long_types.items() if v == value)
|
||||||
key = next(k for k, v in long_types.items() if v == value)
|
self._undo.push(
|
||||||
self._undo.push(
|
SetTypeCommand(
|
||||||
SetTypeCommand(
|
self._bcs, self._tab,row, BC_types[key]
|
||||||
self._bcs, self._tab,row, BC_types[key]
|
)
|
||||||
)
|
)
|
||||||
)
|
elif self._headers[column] == "node":
|
||||||
elif self._headers[column] == "node":
|
self._undo.push(
|
||||||
self._undo.push(
|
SetNodeCommand(
|
||||||
SetNodeCommand(
|
self._bcs, self._tab,row, self._data.node(value)
|
||||||
self._bcs, self._tab,row, self._data.node(value)
|
)
|
||||||
)
|
)
|
||||||
)
|
except Exception as e:
|
||||||
|
logger.info(e)
|
||||||
|
logger.debug(traceback.format_exc())
|
||||||
|
|
||||||
self.dataChanged.emit(index, index)
|
self.dataChanged.emit(index, index)
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class SetNameCommand(QUndoCommand):
|
||||||
self._tab = tab
|
self._tab = tab
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._bcs.get(self._tab, self._index).name
|
self._old = self._bcs.get(self._tab, self._index).name
|
||||||
self._new = new_value
|
self._new = str(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._bcs.get(self._tab, self._index).name = self._old
|
self._bcs.get(self._tab, self._index).name = self._old
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import traceback
|
||||||
|
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
|
|
@ -40,6 +43,8 @@ from View.Frictions.UndoCommand import (
|
||||||
|
|
||||||
from View.Frictions.translate import *
|
from View.Frictions.translate import *
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
class ComboBoxDelegate(QItemDelegate):
|
class ComboBoxDelegate(QItemDelegate):
|
||||||
|
|
@ -148,36 +153,40 @@ class TableModel(QAbstractTableModel):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
if self._headers[column] == "name":
|
try:
|
||||||
self._undo.push(
|
if self._headers[column] == "name":
|
||||||
SetNameCommand(
|
self._undo.push(
|
||||||
self._frictions, row, value
|
SetNameCommand(
|
||||||
|
self._frictions, row, value
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
elif self._headers[column] == "begin_kp":
|
||||||
elif self._headers[column] == "begin_kp":
|
self._undo.push(
|
||||||
self._undo.push(
|
SetBeginCommand(
|
||||||
SetBeginCommand(
|
self._frictions, row, value
|
||||||
self._frictions, row, value
|
)
|
||||||
)
|
)
|
||||||
)
|
elif self._headers[column] == "end_kp":
|
||||||
elif self._headers[column] == "end_kp":
|
self._undo.push(
|
||||||
self._undo.push(
|
SetEndCommand(
|
||||||
SetEndCommand(
|
self._frictions, row, value
|
||||||
self._frictions, row, value
|
)
|
||||||
)
|
)
|
||||||
)
|
elif self._headers[column] == "begin_strickler":
|
||||||
elif self._headers[column] == "begin_strickler":
|
self._undo.push(
|
||||||
self._undo.push(
|
SetBeginStricklerCommand(
|
||||||
SetBeginStricklerCommand(
|
self._frictions, row, self._study.river.strickler(value)
|
||||||
self._frictions, row, self._study.river.strickler(value)
|
)
|
||||||
)
|
)
|
||||||
)
|
elif self._headers[column] == "end_strickler":
|
||||||
elif self._headers[column] == "end_strickler":
|
self._undo.push(
|
||||||
self._undo.push(
|
SetEndStricklerCommand(
|
||||||
SetEndStricklerCommand(
|
self._frictions, row, self._study.river.strickler(value)
|
||||||
self._frictions, row, self._study.river.strickler(value)
|
)
|
||||||
)
|
)
|
||||||
)
|
except Exception as e:
|
||||||
|
logger.info(e)
|
||||||
|
logger.debug(traceback.format_exc())
|
||||||
|
|
||||||
self.dataChanged.emit(index, index)
|
self.dataChanged.emit(index, index)
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ class SetNameCommand(QUndoCommand):
|
||||||
self._frictions = frictions
|
self._frictions = frictions
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._frictions.get(self._index).name
|
self._old = self._frictions.get(self._index).name
|
||||||
self._new = new_value
|
self._new = str(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._frictions.get(self._index).name = self._old
|
self._frictions.get(self._index).name = self._old
|
||||||
|
|
@ -48,7 +48,7 @@ class SetBeginCommand(QUndoCommand):
|
||||||
self._frictions = frictions
|
self._frictions = frictions
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._frictions.get(self._index).begin_kp
|
self._old = self._frictions.get(self._index).begin_kp
|
||||||
self._new = new_value
|
self._new = float(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._frictions.get(self._index).begin_kp = float(self._old)
|
self._frictions.get(self._index).begin_kp = float(self._old)
|
||||||
|
|
@ -63,7 +63,7 @@ class SetEndCommand(QUndoCommand):
|
||||||
self._frictions = frictions
|
self._frictions = frictions
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._frictions.get(self._index).end_kp
|
self._old = self._frictions.get(self._index).end_kp
|
||||||
self._new = new_value
|
self._new = float(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._frictions.get(self._index).end_kp = float(self._old)
|
self._frictions.get(self._index).end_kp = float(self._old)
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import logging
|
||||||
|
import traceback
|
||||||
|
|
||||||
from tools import timer, trace
|
from tools import timer, trace
|
||||||
|
|
||||||
|
|
@ -36,6 +38,8 @@ from Model.Geometry.ProfileXYZ import ProfileXYZ
|
||||||
|
|
||||||
from View.Geometry.Profile.UndoCommand import *
|
from View.Geometry.Profile.UndoCommand import *
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -148,38 +152,42 @@ class TableEditableModel(QAbstractTableModel):
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
if role == Qt.EditRole:
|
if role == Qt.EditRole:
|
||||||
if column == 0:
|
try:
|
||||||
self._undo_stack.push(
|
if column == 0:
|
||||||
SetXCommand(
|
self._undo_stack.push(
|
||||||
self._profile, row,
|
SetXCommand(
|
||||||
self._profile.point(row).x,
|
self._profile, row,
|
||||||
value
|
self._profile.point(row).x,
|
||||||
|
value
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
elif column == 1:
|
||||||
elif column == 1:
|
self._undo_stack.push(
|
||||||
self._undo_stack.push(
|
SetYCommand(
|
||||||
SetYCommand(
|
self._profile, row,
|
||||||
self._profile, row,
|
self._profile.point(row).y,
|
||||||
self._profile.point(row).y,
|
value
|
||||||
value
|
)
|
||||||
)
|
)
|
||||||
)
|
elif column == 2:
|
||||||
elif column == 2:
|
self._undo_stack.push(
|
||||||
self._undo_stack.push(
|
SetZCommand(
|
||||||
SetZCommand(
|
self._profile, row,
|
||||||
self._profile, row,
|
self._profile.point(row).z,
|
||||||
self._profile.point(row).z,
|
value
|
||||||
value
|
)
|
||||||
)
|
)
|
||||||
)
|
elif column == 3:
|
||||||
elif column == 3:
|
self._undo_stack.push(
|
||||||
self._undo_stack.push(
|
SetNameCommand(
|
||||||
SetNameCommand(
|
self._profile, row,
|
||||||
self._profile, row,
|
self._profile.point(row).name,
|
||||||
self._profile.point(row).name,
|
value
|
||||||
value
|
)
|
||||||
)
|
)
|
||||||
)
|
except Exception as e:
|
||||||
|
logger.info(e)
|
||||||
|
logger.debug(traceback.format_exc())
|
||||||
|
|
||||||
self.dataChanged.emit(index, index)
|
self.dataChanged.emit(index, index)
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,13 @@ class SetDataCommand(QUndoCommand):
|
||||||
self._profile = profile
|
self._profile = profile
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = old_value
|
self._old = old_value
|
||||||
self._new = new_value
|
self._new = self.type(new_value)
|
||||||
|
|
||||||
class SetXCommand(SetDataCommand):
|
class SetXCommand(SetDataCommand):
|
||||||
|
def __init__(self, reach, index, old_value, new_value):
|
||||||
|
self.type = float
|
||||||
|
super(SetXCommand, self).__init__(reach, index, old_value, new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._profile.point(self._index).x = self._old
|
self._profile.point(self._index).x = self._old
|
||||||
|
|
||||||
|
|
@ -42,6 +46,10 @@ class SetXCommand(SetDataCommand):
|
||||||
self._profile.point(self._index).x = self._new
|
self._profile.point(self._index).x = self._new
|
||||||
|
|
||||||
class SetYCommand(SetDataCommand):
|
class SetYCommand(SetDataCommand):
|
||||||
|
def __init__(self, reach, index, old_value, new_value):
|
||||||
|
self.type = float
|
||||||
|
super(SetYCommand, self).__init__(reach, index, old_value, new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._profile.point(self._index).y = self._old
|
self._profile.point(self._index).y = self._old
|
||||||
|
|
||||||
|
|
@ -49,6 +57,10 @@ class SetYCommand(SetDataCommand):
|
||||||
self._profile.point(self._index).y = self._new
|
self._profile.point(self._index).y = self._new
|
||||||
|
|
||||||
class SetZCommand(SetDataCommand):
|
class SetZCommand(SetDataCommand):
|
||||||
|
def __init__(self, reach, index, old_value, new_value):
|
||||||
|
self.type = float
|
||||||
|
super(SetZCommand, self).__init__(reach, index, old_value, new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._profile.point(self._index).z = self._old
|
self._profile.point(self._index).z = self._old
|
||||||
|
|
||||||
|
|
@ -56,6 +68,10 @@ class SetZCommand(SetDataCommand):
|
||||||
self._profile.point(self._index).z = self._new
|
self._profile.point(self._index).z = self._new
|
||||||
|
|
||||||
class SetNameCommand(SetDataCommand):
|
class SetNameCommand(SetDataCommand):
|
||||||
|
def __init__(self, reach, index, old_value, new_value):
|
||||||
|
self.type = str
|
||||||
|
super(SetNameCommand, self).__init__(reach, index, old_value, new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._profile.point(self._index).name = self._old
|
self._profile.point(self._index).name = self._old
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
import logging
|
||||||
|
import traceback
|
||||||
|
|
||||||
from tools import timer, trace
|
from tools import timer, trace
|
||||||
|
|
||||||
|
|
@ -37,6 +39,7 @@ from Model.Geometry import Reach
|
||||||
from Model.Geometry.ProfileXYZ import ProfileXYZ
|
from Model.Geometry.ProfileXYZ import ProfileXYZ
|
||||||
from View.Geometry.UndoCommand import *
|
from View.Geometry.UndoCommand import *
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
|
@ -114,23 +117,27 @@ class TableEditableModel(QAbstractTableModel):
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
if role == Qt.EditRole and index.column() != 2:
|
if role == Qt.EditRole and index.column() != 2:
|
||||||
if index.column() == 0:
|
try:
|
||||||
self._undo_stack.push(
|
if index.column() == 0:
|
||||||
SetNameCommand(
|
self._undo_stack.push(
|
||||||
self._reach, index.row(),
|
SetNameCommand(
|
||||||
self._reach.profile(index.row()).name,
|
self._reach, index.row(),
|
||||||
value
|
self._reach.profile(index.row()).name,
|
||||||
|
value
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
if index.column() == 1:
|
if index.column() == 1:
|
||||||
self._undo_stack.push(
|
self._undo_stack.push(
|
||||||
SetKPCommand(
|
SetKPCommand(
|
||||||
self._reach, index.row(),
|
self._reach, index.row(),
|
||||||
self._reach.profile(index.row()).kp,
|
self._reach.profile(index.row()).kp,
|
||||||
value
|
value
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
except Exception as e:
|
||||||
|
logger.info(e)
|
||||||
|
logger.debug(traceback.format_exc())
|
||||||
|
|
||||||
self.dataChanged.emit(index, index)
|
self.dataChanged.emit(index, index)
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,13 @@ class SetDataCommand(QUndoCommand):
|
||||||
self._reach = reach
|
self._reach = reach
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = old_value
|
self._old = old_value
|
||||||
self._new = new_value
|
self._new = self.type(new_value)
|
||||||
|
|
||||||
class SetNameCommand(SetDataCommand):
|
class SetNameCommand(SetDataCommand):
|
||||||
|
def __init__(self, reach, index, old_value, new_value):
|
||||||
|
self.type = str
|
||||||
|
super(SetNameCommand, self).__init__(reach, index, old_value, new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._reach.profile(self._index).name = self._old
|
self._reach.profile(self._index).name = self._old
|
||||||
|
|
||||||
|
|
@ -43,6 +47,10 @@ class SetNameCommand(SetDataCommand):
|
||||||
self._reach.profile(self._index).name = self._new
|
self._reach.profile(self._index).name = self._new
|
||||||
|
|
||||||
class SetKPCommand(SetDataCommand):
|
class SetKPCommand(SetDataCommand):
|
||||||
|
def __init__(self, reach, index, old_value, new_value):
|
||||||
|
self.type = float
|
||||||
|
super(SetKPCommand, self).__init__(reach, index, old_value, new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._reach.profile(self._index).kp = self._old
|
self._reach.profile(self._index).kp = self._old
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import traceback
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
|
|
@ -39,6 +41,8 @@ from View.InitialConditions.UndoCommand import (
|
||||||
|
|
||||||
from View.InitialConditions.translate import *
|
from View.InitialConditions.translate import *
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
class ComboBoxDelegate(QItemDelegate):
|
class ComboBoxDelegate(QItemDelegate):
|
||||||
|
|
@ -135,12 +139,16 @@ class TableModel(QAbstractTableModel):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
if self._headers[column] is not None:
|
try:
|
||||||
self._undo.push(
|
if self._headers[column] is not None:
|
||||||
SetCommand(
|
self._undo.push(
|
||||||
self._ics, row, self._headers[column], value
|
SetCommand(
|
||||||
|
self._ics, row, self._headers[column], value
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
except Exception as e:
|
||||||
|
logger.info(e)
|
||||||
|
logger.debug(traceback.format_exc())
|
||||||
|
|
||||||
self.dataChanged.emit(index, index)
|
self.dataChanged.emit(index, index)
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,12 @@ class SetCommand(QUndoCommand):
|
||||||
self._row = row
|
self._row = row
|
||||||
self._column = column
|
self._column = column
|
||||||
self._old = self._ics.get(self._row)[column]
|
self._old = self._ics.get(self._row)[column]
|
||||||
self._new = new_value
|
|
||||||
|
_type = float
|
||||||
|
if column == "name" or column == "comment":
|
||||||
|
_type = str
|
||||||
|
|
||||||
|
self._new = _type(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._ics.get(self._row)[self._column] = self._old
|
self._ics.get(self._row)[self._column] = self._old
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import traceback
|
||||||
from datetime import date, time, datetime, timedelta
|
from datetime import date, time, datetime, timedelta
|
||||||
|
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
@ -210,11 +211,15 @@ class TableModel(QAbstractTableModel):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
self._undo.push(
|
try:
|
||||||
SetDataCommand(
|
self._undo.push(
|
||||||
self._data, row, column, value
|
SetDataCommand(
|
||||||
|
self._data, row, column, value
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
except Exception as e:
|
||||||
|
logger.info(e)
|
||||||
|
logger.debug(traceback.format_exc())
|
||||||
|
|
||||||
self.dataChanged.emit(index, index)
|
self.dataChanged.emit(index, index)
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,8 @@ class SetDataCommand(QUndoCommand):
|
||||||
self._index = index
|
self._index = index
|
||||||
self._column = column
|
self._column = column
|
||||||
self._old = self._data.get_i(self._index)[self._column]
|
self._old = self._data.get_i(self._index)[self._column]
|
||||||
self._new = new_value
|
_type = self._data.get_type_column(self._column)
|
||||||
|
self._new = _type(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._data._set_i_c_v(self._index, self._column, self._old)
|
self._data._set_i_c_v(self._index, self._column, self._old)
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import traceback
|
||||||
|
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
|
|
@ -43,6 +46,8 @@ from Model.LateralContribution.LateralContributionTypes import (
|
||||||
)
|
)
|
||||||
from View.LateralContribution.translate import *
|
from View.LateralContribution.translate import *
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
class ComboBoxDelegate(QItemDelegate):
|
class ComboBoxDelegate(QItemDelegate):
|
||||||
|
|
@ -156,37 +161,41 @@ class TableModel(QAbstractTableModel):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
if self._headers[column] == "name":
|
try:
|
||||||
self._undo.push(
|
if self._headers[column] == "name":
|
||||||
SetNameCommand(
|
self._undo.push(
|
||||||
self._lcs, self._tab, row, value
|
SetNameCommand(
|
||||||
|
self._lcs, self._tab, row, value
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
elif self._headers[column] == "type":
|
||||||
elif self._headers[column] == "type":
|
key = next(k for k, v in long_types.items() if v == value)
|
||||||
key = next(k for k, v in long_types.items() if v == value)
|
self._undo.push(
|
||||||
self._undo.push(
|
SetTypeCommand(
|
||||||
SetTypeCommand(
|
self._lcs, self._tab, row, LC_types[key]
|
||||||
self._lcs, self._tab, row, LC_types[key]
|
)
|
||||||
)
|
)
|
||||||
)
|
elif self._headers[column] == "edge":
|
||||||
elif self._headers[column] == "edge":
|
self._undo.push(
|
||||||
self._undo.push(
|
SetEdgeCommand(
|
||||||
SetEdgeCommand(
|
self._lcs, self._tab, row, self._data.edge(value)
|
||||||
self._lcs, self._tab, row, self._data.edge(value)
|
)
|
||||||
)
|
)
|
||||||
)
|
elif self._headers[column] == "begin_kp":
|
||||||
elif self._headers[column] == "begin_kp":
|
self._undo.push(
|
||||||
self._undo.push(
|
SetBeginCommand(
|
||||||
SetBeginCommand(
|
self._lcs, self._tab, row, value
|
||||||
self._lcs, self._tab, row, value
|
)
|
||||||
)
|
)
|
||||||
)
|
elif self._headers[column] == "end_kp":
|
||||||
elif self._headers[column] == "end_kp":
|
self._undo.push(
|
||||||
self._undo.push(
|
SetEndCommand(
|
||||||
SetEndCommand(
|
self._lcs, self._tab, row, value
|
||||||
self._lcs, self._tab, row, value
|
)
|
||||||
)
|
)
|
||||||
)
|
except Exception as e:
|
||||||
|
logger.info(e)
|
||||||
|
logger.debug(traceback.format_exc())
|
||||||
|
|
||||||
self.dataChanged.emit(index, index)
|
self.dataChanged.emit(index, index)
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class SetNameCommand(QUndoCommand):
|
||||||
self._tab = tab
|
self._tab = tab
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._lcs.get(self._tab, self._index).name
|
self._old = self._lcs.get(self._tab, self._index).name
|
||||||
self._new = new_value
|
self._new = str(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._lcs.get(self._tab, self._index).name = self._old
|
self._lcs.get(self._tab, self._index).name = self._old
|
||||||
|
|
@ -50,7 +50,7 @@ class SetBeginCommand(QUndoCommand):
|
||||||
self._tab = tab
|
self._tab = tab
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._lcs.get(self._tab, self._index).begin_kp
|
self._old = self._lcs.get(self._tab, self._index).begin_kp
|
||||||
self._new = new_value
|
self._new = float(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._lcs.get(self._tab, self._index).begin_kp = float(self._old)
|
self._lcs.get(self._tab, self._index).begin_kp = float(self._old)
|
||||||
|
|
@ -66,7 +66,7 @@ class SetEndCommand(QUndoCommand):
|
||||||
self._tab = tab
|
self._tab = tab
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._lcs.get(self._tab, self._index).end_kp
|
self._old = self._lcs.get(self._tab, self._index).end_kp
|
||||||
self._new = new_value
|
self._new = float(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._lcs.get(self._tab, self._index).end_kp = float(self._old)
|
self._lcs.get(self._tab, self._index).end_kp = float(self._old)
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import traceback
|
||||||
|
|
||||||
from Model.Network.Node import Node
|
from Model.Network.Node import Node
|
||||||
from Model.Network.Edge import Edge
|
from Model.Network.Edge import Edge
|
||||||
from Model.Network.Graph import Graph
|
from Model.Network.Graph import Graph
|
||||||
|
|
@ -153,31 +156,35 @@ class GraphTableModel(QAbstractTableModel):
|
||||||
def setData(self, index, value, role=Qt.EditRole):
|
def setData(self, index, value, role=Qt.EditRole):
|
||||||
if index.isValid():
|
if index.isValid():
|
||||||
if role == Qt.EditRole:
|
if role == Qt.EditRole:
|
||||||
if (self.headers[index.column()] == "node1" or
|
try:
|
||||||
self.headers[index.column()] == "node2"):
|
if (self.headers[index.column()] == "node1" or
|
||||||
node = self.graph.node(value)
|
self.headers[index.column()] == "node2"):
|
||||||
self._undo.push(
|
node = self.graph.node(value)
|
||||||
SetNodeCommand(
|
self._undo.push(
|
||||||
self.graph,
|
SetNodeCommand(
|
||||||
self.rows[index.row()],
|
self.graph,
|
||||||
self.headers[index.column()],
|
self.rows[index.row()],
|
||||||
node
|
self.headers[index.column()],
|
||||||
|
node
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
# elif self.headers[index.column()] == "enable":
|
||||||
# elif self.headers[index.column()] == "enable":
|
# self._undo.push(
|
||||||
# self._undo.push(
|
# EnableEdgeCommand(
|
||||||
# EnableEdgeCommand(
|
# self.rows[index.row()], value
|
||||||
# self.rows[index.row()], value
|
# )
|
||||||
# )
|
# )
|
||||||
# )
|
else:
|
||||||
else:
|
self._undo.push(
|
||||||
self._undo.push(
|
SetCommand(
|
||||||
SetCommand(
|
self.rows[index.row()],
|
||||||
self.rows[index.row()],
|
self.headers[index.column()],
|
||||||
self.headers[index.column()],
|
value
|
||||||
value
|
)
|
||||||
)
|
)
|
||||||
)
|
except Exception as e:
|
||||||
|
logger.info(e)
|
||||||
|
logger.debug(traceback.format_exc())
|
||||||
|
|
||||||
self.dataChanged.emit(index, index, [Qt.DisplayRole])
|
self.dataChanged.emit(index, index, [Qt.DisplayRole])
|
||||||
self.layoutChanged.emit()
|
self.layoutChanged.emit()
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import traceback
|
||||||
|
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
|
|
@ -97,16 +100,20 @@ class TableModel(QAbstractTableModel):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
if self._headers[column] == "value":
|
try:
|
||||||
if value in tr.r_yes_no:
|
if self._headers[column] == "value":
|
||||||
value = tr.r_yes_no[value].lower()
|
if value in tr.r_yes_no:
|
||||||
|
value = tr.r_yes_no[value].lower()
|
||||||
|
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetCommand(
|
SetCommand(
|
||||||
self._params, row,
|
self._params, row,
|
||||||
"value", value
|
"value", value
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
except Exception as e:
|
||||||
|
logger.info(e)
|
||||||
|
logger.debug(traceback.format_exc())
|
||||||
|
|
||||||
self.dataChanged.emit(index, index)
|
self.dataChanged.emit(index, index)
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ class SetCommand(QUndoCommand):
|
||||||
self._index = index
|
self._index = index
|
||||||
self._column = column
|
self._column = column
|
||||||
self._old = self._data.get(self._index)[column]
|
self._old = self._data.get(self._index)[column]
|
||||||
self._new = new_value
|
self._new = str(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._data.get(self._index)[self._column] = self._old
|
self._data.get(self._index)[self._column] = self._old
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import traceback
|
||||||
|
|
||||||
from tools import trace, timer
|
from tools import trace, timer
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
from PyQt5.QtCore import (
|
||||||
|
|
@ -39,8 +42,9 @@ from View.Stricklers.UndoCommand import (
|
||||||
|
|
||||||
from View.Stricklers.translate import *
|
from View.Stricklers.translate import *
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
class TableModel(QAbstractTableModel):
|
class TableModel(QAbstractTableModel):
|
||||||
def __init__(self, data=None, undo=None, tab=""):
|
def __init__(self, data=None, undo=None, tab=""):
|
||||||
|
|
@ -92,30 +96,34 @@ class TableModel(QAbstractTableModel):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
if self._headers[column] == "name":
|
try:
|
||||||
self._undo.push(
|
if self._headers[column] == "name":
|
||||||
SetNameCommand(
|
self._undo.push(
|
||||||
self._data, row, value
|
SetNameCommand(
|
||||||
|
self._data, row, value
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
elif self._headers[column] == "comment":
|
||||||
elif self._headers[column] == "comment":
|
self._undo.push(
|
||||||
self._undo.push(
|
SetCommentCommand(
|
||||||
SetCommentCommand(
|
self._data, row, value
|
||||||
self._data, row, value
|
)
|
||||||
)
|
)
|
||||||
)
|
elif self._headers[column] == "minor":
|
||||||
elif self._headers[column] == "minor":
|
self._undo.push(
|
||||||
self._undo.push(
|
SetMinorCommand(
|
||||||
SetMinorCommand(
|
self._data, row, value
|
||||||
self._data, row, value
|
)
|
||||||
)
|
)
|
||||||
)
|
elif self._headers[column] == "medium":
|
||||||
elif self._headers[column] == "medium":
|
self._undo.push(
|
||||||
self._undo.push(
|
SetMediumCommand(
|
||||||
SetMediumCommand(
|
self._data, row, value
|
||||||
self._data, row, value
|
)
|
||||||
)
|
)
|
||||||
)
|
except Exception as e:
|
||||||
|
logger.info(e)
|
||||||
|
logger.debug(traceback.format_exc())
|
||||||
|
|
||||||
self.dataChanged.emit(index, index)
|
self.dataChanged.emit(index, index)
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ class SetNameCommand(QUndoCommand):
|
||||||
self._data = data
|
self._data = data
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._data.get(self._index).name
|
self._old = self._data.get(self._index).name
|
||||||
self._new = new_value
|
self._new = str(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._data.get(self._index).name = self._old
|
self._data.get(self._index).name = self._old
|
||||||
|
|
@ -48,7 +48,7 @@ class SetCommentCommand(QUndoCommand):
|
||||||
self._data = data
|
self._data = data
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._data.get(self._index).comment
|
self._old = self._data.get(self._index).comment
|
||||||
self._new = new_value
|
self._new = str(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._data.get(self._index).comment = self._old
|
self._data.get(self._index).comment = self._old
|
||||||
|
|
@ -63,7 +63,7 @@ class SetMinorCommand(QUndoCommand):
|
||||||
self._data = data
|
self._data = data
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._data.get(self._index).minor
|
self._old = self._data.get(self._index).minor
|
||||||
self._new = new_value
|
self._new = float(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._data.get(self._index).minor = self._old
|
self._data.get(self._index).minor = self._old
|
||||||
|
|
@ -78,7 +78,7 @@ class SetMediumCommand(QUndoCommand):
|
||||||
self._data = data
|
self._data = data
|
||||||
self._index = index
|
self._index = index
|
||||||
self._old = self._data.get(self._index).medium
|
self._old = self._data.get(self._index).medium
|
||||||
self._new = new_value
|
self._new = float(new_value)
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
self._data.get(self._index).medium = self._old
|
self._data.get(self._index).medium = self._old
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue