2
2
import logging
3
3
from inspect import stack
4
4
import numpy as np
5
- from larray_editor .utils import (get_font , from_qvariant , to_qvariant , to_text_string ,
5
+ from larray_editor .utils import (get_font , to_text_string ,
6
6
is_float , is_number , LinearGradient , SUPPORTED_FORMATS , scale_to_01range ,
7
7
Product , is_number_value , get_sample , get_sample_indices , logger )
8
8
from qtpy .QtCore import Qt , QModelIndex , QAbstractTableModel , Signal
@@ -101,7 +101,7 @@ def flags(self, index):
101
101
raise NotImplementedError ()
102
102
103
103
def headerData (self , section , orientation , role = Qt .DisplayRole ):
104
- return to_qvariant ()
104
+ return None
105
105
106
106
def data (self , index , role = Qt .DisplayRole ):
107
107
raise NotImplementedError ()
@@ -157,23 +157,22 @@ def get_values(self, left=0, right=None):
157
157
158
158
def data (self , index , role = Qt .DisplayRole ):
159
159
if not index .isValid ():
160
- return to_qvariant ()
160
+ return None
161
161
162
162
if role == Qt .TextAlignmentRole :
163
- return to_qvariant ( int (Qt .AlignCenter | Qt .AlignVCenter ) )
163
+ return int (Qt .AlignCenter | Qt .AlignVCenter )
164
164
elif role == Qt .FontRole :
165
165
return self .font
166
166
elif role == Qt .BackgroundColorRole :
167
167
color = QColor (Qt .lightGray )
168
168
color .setAlphaF (.4 )
169
169
return color
170
170
elif role == Qt .DisplayRole :
171
- value = self .get_value (index )
172
- return to_qvariant (value )
173
- elif role == Qt .ToolTipRole :
174
- return to_qvariant ()
171
+ return self .get_value (index )
172
+ # elif role == Qt.ToolTipRole:
173
+ # return None
175
174
else :
176
- return to_qvariant ()
175
+ return None
177
176
178
177
179
178
class LabelsArrayModel (AbstractArrayModel ):
@@ -223,23 +222,22 @@ def get_values(self, left=0, top=0, right=None, bottom=None):
223
222
224
223
def data (self , index , role = Qt .DisplayRole ):
225
224
if not index .isValid ():
226
- return to_qvariant ()
225
+ return None
227
226
228
227
if role == Qt .TextAlignmentRole :
229
- return to_qvariant ( int (Qt .AlignCenter | Qt .AlignVCenter ) )
228
+ return int (Qt .AlignCenter | Qt .AlignVCenter )
230
229
elif role == Qt .FontRole :
231
230
return self .font
232
231
elif role == Qt .BackgroundColorRole :
233
232
color = QColor (Qt .lightGray )
234
233
color .setAlphaF (.4 )
235
234
return color
236
235
elif role == Qt .DisplayRole :
237
- value = self .get_value (index )
238
- return to_qvariant (value )
239
- elif role == Qt .ToolTipRole :
240
- return to_qvariant ()
236
+ return self .get_value (index )
237
+ # elif role == Qt.ToolTipRole:
238
+ # return None
241
239
else :
242
- return to_qvariant ()
240
+ return None
243
241
244
242
245
243
class DataArrayModel (AbstractArrayModel ):
@@ -375,14 +373,14 @@ def flags(self, index):
375
373
def data (self , index , role = Qt .DisplayRole ):
376
374
"""Cell content"""
377
375
if not index .isValid ():
378
- return to_qvariant ()
376
+ return None
379
377
# if role == Qt.DecorationRole:
380
378
# return ima.icon('editcopy')
381
379
# if role == Qt.DisplayRole:
382
380
# return ""
383
381
384
382
if role == Qt .TextAlignmentRole :
385
- return to_qvariant ( int (Qt .AlignRight | Qt .AlignVCenter ) )
383
+ return int (Qt .AlignRight | Qt .AlignVCenter )
386
384
elif role == Qt .FontRole :
387
385
return self .font
388
386
@@ -394,7 +392,7 @@ def data(self, index, role=Qt.DisplayRole):
394
392
elif isinstance (value , str ) and not isinstance (value , np .str_ ):
395
393
return value
396
394
else :
397
- return to_qvariant ( self ._format % value )
395
+ return self ._format % value
398
396
elif role == Qt .BackgroundColorRole :
399
397
if self .bgcolor_possible and self .bg_gradient is not None and value is not np .ma .masked :
400
398
if self .bg_value is None :
@@ -418,8 +416,8 @@ def data(self, index, role=Qt.DisplayRole):
418
416
v = self .bg_value [i , j ]
419
417
return self .bg_gradient [v ]
420
418
# elif role == Qt.ToolTipRole:
421
- # return to_qvariant( "{}\n{}".format(repr(value),self.get_labels(index) ))
422
- return to_qvariant ()
419
+ # return "{}\n{}".format(repr(value),self.get_labels(index))
420
+ return None
423
421
424
422
def get_values (self , left = 0 , top = 0 , right = None , bottom = None , sample = False ):
425
423
width , height = self .total_rows , self .total_cols
@@ -567,5 +565,5 @@ def setData(self, index, value, role=Qt.EditRole):
567
565
if not index .isValid () or self .readonly :
568
566
return False
569
567
i , j = index .row (), index .column ()
570
- result = self .set_values (i , j , i + 1 , j + 1 , from_qvariant ( value , str ) )
568
+ result = self .set_values (i , j , i + 1 , j + 1 , value )
571
569
return result is not None
0 commit comments