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()
|
||||||
|
|
||||||
|
try:
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetDataCommand(
|
SetDataCommand(
|
||||||
self._data, row, column, value
|
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,6 +158,7 @@ class TableModel(QAbstractTableModel):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
|
try:
|
||||||
if self._headers[column] == "name":
|
if self._headers[column] == "name":
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetNameCommand(
|
SetNameCommand(
|
||||||
|
|
@ -172,6 +178,9 @@ class TableModel(QAbstractTableModel):
|
||||||
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,6 +153,7 @@ class TableModel(QAbstractTableModel):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
|
try:
|
||||||
if self._headers[column] == "name":
|
if self._headers[column] == "name":
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetNameCommand(
|
SetNameCommand(
|
||||||
|
|
@ -178,6 +184,9 @@ class TableModel(QAbstractTableModel):
|
||||||
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,6 +152,7 @@ class TableEditableModel(QAbstractTableModel):
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
if role == Qt.EditRole:
|
if role == Qt.EditRole:
|
||||||
|
try:
|
||||||
if column == 0:
|
if column == 0:
|
||||||
self._undo_stack.push(
|
self._undo_stack.push(
|
||||||
SetXCommand(
|
SetXCommand(
|
||||||
|
|
@ -180,6 +185,9 @@ class TableEditableModel(QAbstractTableModel):
|
||||||
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,6 +117,7 @@ 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:
|
||||||
|
try:
|
||||||
if index.column() == 0:
|
if index.column() == 0:
|
||||||
self._undo_stack.push(
|
self._undo_stack.push(
|
||||||
SetNameCommand(
|
SetNameCommand(
|
||||||
|
|
@ -131,6 +135,9 @@ class TableEditableModel(QAbstractTableModel):
|
||||||
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()
|
||||||
|
|
||||||
|
try:
|
||||||
if self._headers[column] is not None:
|
if self._headers[column] is not None:
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetCommand(
|
SetCommand(
|
||||||
self._ics, row, self._headers[column], value
|
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()
|
||||||
|
|
||||||
|
try:
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetDataCommand(
|
SetDataCommand(
|
||||||
self._data, row, column, value
|
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,6 +161,7 @@ class TableModel(QAbstractTableModel):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
|
try:
|
||||||
if self._headers[column] == "name":
|
if self._headers[column] == "name":
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetNameCommand(
|
SetNameCommand(
|
||||||
|
|
@ -187,6 +193,9 @@ class TableModel(QAbstractTableModel):
|
||||||
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,6 +156,7 @@ 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:
|
||||||
|
try:
|
||||||
if (self.headers[index.column()] == "node1" or
|
if (self.headers[index.column()] == "node1" or
|
||||||
self.headers[index.column()] == "node2"):
|
self.headers[index.column()] == "node2"):
|
||||||
node = self.graph.node(value)
|
node = self.graph.node(value)
|
||||||
|
|
@ -178,6 +182,9 @@ class GraphTableModel(QAbstractTableModel):
|
||||||
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,6 +100,7 @@ class TableModel(QAbstractTableModel):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
|
try:
|
||||||
if self._headers[column] == "value":
|
if self._headers[column] == "value":
|
||||||
if value in tr.r_yes_no:
|
if value in tr.r_yes_no:
|
||||||
value = tr.r_yes_no[value].lower()
|
value = tr.r_yes_no[value].lower()
|
||||||
|
|
@ -107,6 +111,9 @@ class TableModel(QAbstractTableModel):
|
||||||
"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,6 +96,7 @@ class TableModel(QAbstractTableModel):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
column = index.column()
|
column = index.column()
|
||||||
|
|
||||||
|
try:
|
||||||
if self._headers[column] == "name":
|
if self._headers[column] == "name":
|
||||||
self._undo.push(
|
self._undo.push(
|
||||||
SetNameCommand(
|
SetNameCommand(
|
||||||
|
|
@ -116,6 +121,9 @@ class TableModel(QAbstractTableModel):
|
||||||
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