Skip to content

Commit

Permalink
Fix table dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
t-sommer committed Nov 21, 2024
1 parent c6f6fdb commit 222b8d4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 75 deletions.
19 changes: 14 additions & 5 deletions fmpy/gui/TableDialog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from PySide6.QtCore import Qt, QAbstractTableModel, QModelIndex
from PySide6.QtGui import QFont, QIcon
from PySide6.QtGui import QFont, QIcon, QGuiApplication
from PySide6.QtWidgets import QDialog, QHeaderView
import pyqtgraph as pg
import numpy as np
Expand All @@ -14,7 +14,7 @@ class TableModel(QAbstractTableModel):
def __init__(self, size, data, startValues, parent=None):
super(TableModel, self).__init__(parent)
self.size = size
self.data = data
self._data = data
self.startValues = startValues
self.boldFont = QFont()
self.boldFont.setBold(True)
Expand Down Expand Up @@ -50,7 +50,7 @@ def data(self, index, role=Qt.DisplayRole):
return None

subs = self.ind2sub(index)
sv = self.data[subs]
sv = self._data[subs]

if role == Qt.DisplayRole or role == Qt.EditRole:
if sv.name in self.startValues:
Expand All @@ -68,7 +68,7 @@ def data(self, index, role=Qt.DisplayRole):

def setData(self, index, value, role):
subs = self.ind2sub(index)
sv = self.data[subs]
sv = self._data[subs]

if value:
self.startValues[sv.name] = value
Expand Down Expand Up @@ -124,7 +124,7 @@ def __init__(self, modelVariables, variable, startValues, parent=None):
variable_name = variable_name[:i]

for sv in self.modelVariables:
if sv.name.startswith(variable_name):
if sv.name.startswith(variable_name + '['):
i = sv.name.rfind('[')
subs = sv.name[i+1:-1]
subs = subs.split(',')
Expand Down Expand Up @@ -195,6 +195,15 @@ def updatePlot(self):
else:
data[subs] = np.nan

color_scheme = QGuiApplication.styleHints().colorScheme()

if color_scheme == Qt.ColorScheme.Dark:
self.ui.graphicsView.setBackground(None)
pg.setConfigOptions(foreground='w')
else:
self.ui.graphicsView.setBackground('w')
pg.setConfigOptions(foreground='k')

self.ui.graphicsView.clear()
plot = self.ui.graphicsView.addPlot()
plot.showGrid(x=True, y=True, alpha=0.25)
Expand Down
76 changes: 6 additions & 70 deletions fmpy/gui/forms/TableDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -10,70 +10,6 @@
<height>561</height>
</rect>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>15</number>
Expand All @@ -86,11 +22,11 @@
}</string>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<widget class="QTableView" name="tableView">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
<enum>QFrame::Shape::NoFrame</enum>
</property>
</widget>
<widget class="QFrame" name="frame">
Expand All @@ -101,7 +37,7 @@
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
<enum>QFrame::Shape::NoFrame</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
Expand Down Expand Up @@ -162,7 +98,7 @@
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -185,10 +121,10 @@
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
Expand Down

0 comments on commit 222b8d4

Please sign in to comment.