1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
|
# coding: utf-8
# /*##########################################################################
#
# Copyright (c) 2016 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# ###########################################################################*/
"""
This module contains an :class:`SafeFileSystemModel`.
"""
__authors__ = ["V. Valls"]
__license__ = "MIT"
__date__ = "22/11/2017"
import sys
import os.path
import logging
import weakref
from silx.gui import qt
from silx.third_party import six
from .SafeFileIconProvider import SafeFileIconProvider
_logger = logging.getLogger(__name__)
class _Item(object):
def __init__(self, fileInfo):
self.__fileInfo = fileInfo
self.__parent = None
self.__children = None
self.__absolutePath = None
def isDrive(self):
if sys.platform == "win32":
return self.parent().parent() is None
else:
return False
def isRoot(self):
return self.parent() is None
def isFile(self):
"""
Returns true if the path is a file.
It avoid to access to the `Qt.QFileInfo` in case the file is a drive.
"""
if self.isDrive():
return False
return self.__fileInfo.isFile()
def isDir(self):
"""
Returns true if the path is a directory.
The default `qt.QFileInfo.isDir` can freeze the file system with
network drives. This function avoid the freeze in case of browsing
the root.
"""
if self.isDrive():
# A drive is a directory, we don't have to synchronize the
# drive to know that
return True
return self.__fileInfo.isDir()
def absoluteFilePath(self):
"""
Returns an absolute path including the file name.
This function uses in most cases the default
`qt.QFileInfo.absoluteFilePath`. But it is known to freeze the file
system with network drives.
This function uses `qt.QFileInfo.filePath` in case of root drives, to
avoid this kind of issues. In case of drive, the result is the same,
while the file path is already absolute.
:rtype: str
"""
if self.__absolutePath is None:
if self.isRoot():
path = ""
elif self.isDrive():
path = self.__fileInfo.filePath()
else:
path = os.path.join(self.parent().absoluteFilePath(), self.__fileInfo.fileName())
if path == "":
return "/"
self.__absolutePath = path
return self.__absolutePath
def child(self):
self.populate()
return self.__children
def childAt(self, position):
self.populate()
return self.__children[position]
def childCount(self):
self.populate()
return len(self.__children)
def indexOf(self, item):
self.populate()
return self.__children.index(item)
def parent(self):
parent = self.__parent
if parent is None:
return None
return parent()
def filePath(self):
return self.__fileInfo.filePath()
def fileName(self):
if self.isDrive():
name = self.absoluteFilePath()
if name[-1] == "/":
name = name[:-1]
return name
return os.path.basename(self.absoluteFilePath())
def fileInfo(self):
"""
Returns the Qt file info.
:rtype: Qt.QFileInfo
"""
return self.__fileInfo
def _setParent(self, parent):
self.__parent = weakref.ref(parent)
def findChildrenByPath(self, path):
if path == "":
return self
path = path.replace("\\", "/")
if path[-1] == "/":
path = path[:-1]
names = path.split("/")
caseSensitive = qt.QFSFileEngine(path).caseSensitive()
count = len(names)
cursor = self
for name in names:
for item in cursor.child():
if caseSensitive:
same = item.fileName() == name
else:
same = item.fileName().lower() == name.lower()
if same:
cursor = item
count -= 1
break
else:
return None
if count == 0:
break
else:
return None
return cursor
def populate(self):
if self.__children is not None:
return
self.__children = []
if self.isRoot():
items = qt.QDir.drives()
else:
directory = qt.QDir(self.absoluteFilePath())
filters = qt.QDir.AllEntries | qt.QDir.Hidden | qt.QDir.System
items = directory.entryInfoList(filters)
for fileInfo in items:
i = _Item(fileInfo)
self.__children.append(i)
i._setParent(self)
class _RawFileSystemModel(qt.QAbstractItemModel):
"""
This class implement a file system model and try to avoid freeze. On Qt4,
:class:`qt.QFileSystemModel` is known to freeze the file system when
network drives are available.
To avoid this behaviour, this class does not use
`qt.QFileInfo.absoluteFilePath` nor `qt.QFileInfo.canonicalPath` to reach
information on drives.
This model do not take care of sorting and filtering. This features are
managed by another model, by composition.
And because it is the end of life of Qt4, we do not implement asynchronous
loading of files as it is done by :class:`qt.QFileSystemModel`, nor some
useful features.
"""
__directoryLoadedSync = qt.Signal(str)
"""This signal is connected asynchronously to a slot. It allows to
emit directoryLoaded as an asynchronous signal."""
directoryLoaded = qt.Signal(str)
"""This signal is emitted when the gatherer thread has finished to load the
path."""
rootPathChanged = qt.Signal(str)
"""This signal is emitted whenever the root path has been changed to a
newPath."""
NAME_COLUMN = 0
SIZE_COLUMN = 1
TYPE_COLUMN = 2
LAST_MODIFIED_COLUMN = 3
def __init__(self, parent=None):
qt.QAbstractItemModel.__init__(self, parent)
self.__computer = _Item(qt.QFileInfo())
self.__header = "Name", "Size", "Type", "Last modification"
self.__currentPath = ""
self.__iconProvider = SafeFileIconProvider()
self.__directoryLoadedSync.connect(self.__emitDirectoryLoaded, qt.Qt.QueuedConnection)
def headerData(self, section, orientation, role=qt.Qt.DisplayRole):
if orientation == qt.Qt.Horizontal:
if role == qt.Qt.DisplayRole:
return self.__header[section]
if role == qt.Qt.TextAlignmentRole:
return qt.Qt.AlignRight if section == 1 else qt.Qt.AlignLeft
return None
def flags(self, index):
if not index.isValid():
return 0
return qt.Qt.ItemIsEnabled | qt.Qt.ItemIsSelectable
def columnCount(self, parent=qt.QModelIndex()):
return len(self.__header)
def rowCount(self, parent=qt.QModelIndex()):
item = self.__getItem(parent)
return item.childCount()
def data(self, index, role=qt.Qt.DisplayRole):
if not index.isValid():
return None
column = index.column()
if role in [qt.Qt.DisplayRole, qt.Qt.EditRole]:
if column == self.NAME_COLUMN:
return self.__displayName(index)
elif column == self.SIZE_COLUMN:
return self.size(index)
elif column == self.TYPE_COLUMN:
return self.type(index)
elif column == self.LAST_MODIFIED_COLUMN:
return self.lastModified(index)
else:
_logger.warning("data: invalid display value column %d", index.column())
elif role == qt.QFileSystemModel.FilePathRole:
return self.filePath(index)
elif role == qt.QFileSystemModel.FileNameRole:
return self.fileName(index)
elif role == qt.Qt.DecorationRole:
if column == self.NAME_COLUMN:
icon = self.fileIcon(index)
if icon is None or icon.isNull():
if self.isDir(index):
self.__iconProvider.icon(qt.QFileIconProvider.Folder)
else:
self.__iconProvider.icon(qt.QFileIconProvider.File)
return icon
elif role == qt.Qt.TextAlignmentRole:
if column == self.SIZE_COLUMN:
return qt.Qt.AlignRight
elif role == qt.QFileSystemModel.FilePermissions:
return self.permissions(index)
return None
def index(self, *args, **kwargs):
path_api = False
path_api |= len(args) >= 1 and isinstance(args[0], six.string_types)
path_api |= "path" in kwargs
if path_api:
return self.__indexFromPath(*args, **kwargs)
else:
return self.__index(*args, **kwargs)
def __index(self, row, column, parent=qt.QModelIndex()):
if parent.isValid() and parent.column() != 0:
return None
parentItem = self.__getItem(parent)
item = parentItem.childAt(row)
return self.createIndex(row, column, item)
def __indexFromPath(self, path, column=0):
"""
Uses the index(str) C++ API
:rtype: qt.QModelIndex
"""
if path == "":
return qt.QModelIndex()
item = self.__computer.findChildrenByPath(path)
if item is None:
return qt.QModelIndex()
return self.createIndex(item.parent().indexOf(item), column, item)
def parent(self, index):
if not index.isValid():
return qt.QModelIndex()
item = self.__getItem(index)
if index is None:
return qt.QModelIndex()
parent = item.parent()
if parent is None or parent is self.__computer:
return qt.QModelIndex()
return self.createIndex(parent.parent().indexOf(parent), 0, parent)
def __emitDirectoryLoaded(self, path):
self.directoryLoaded.emit(path)
def __emitRootPathChanged(self, path):
self.rootPathChanged.emit(path)
def __getItem(self, index):
if not index.isValid():
return self.__computer
item = index.internalPointer()
return item
def fileIcon(self, index):
item = self.__getItem(index)
if self.__iconProvider is not None:
fileInfo = item.fileInfo()
result = self.__iconProvider.icon(fileInfo)
else:
style = qt.QApplication.instance().style()
if item.isRoot():
result = style.standardIcon(qt.QStyle.SP_ComputerIcon)
elif item.isDrive():
result = style.standardIcon(qt.QStyle.SP_DriveHDIcon)
elif item.isDir():
result = style.standardIcon(qt.QStyle.SP_DirIcon)
else:
result = style.standardIcon(qt.QStyle.SP_FileIcon)
return result
def _item(self, index):
item = self.__getItem(index)
return item
def fileInfo(self, index):
item = self.__getItem(index)
result = item.fileInfo()
return result
def __fileIcon(self, index):
item = self.__getItem(index)
result = item.fileName()
return result
def __displayName(self, index):
item = self.__getItem(index)
result = item.fileName()
return result
def fileName(self, index):
item = self.__getItem(index)
result = item.fileName()
return result
def filePath(self, index):
item = self.__getItem(index)
result = item.fileInfo().filePath()
return result
def isDir(self, index):
item = self.__getItem(index)
result = item.isDir()
return result
def lastModified(self, index):
item = self.__getItem(index)
result = item.fileInfo().lastModified()
return result
def permissions(self, index):
item = self.__getItem(index)
result = item.fileInfo().permissions()
return result
def size(self, index):
item = self.__getItem(index)
result = item.fileInfo().size()
return result
def type(self, index):
item = self.__getItem(index)
if self.__iconProvider is not None:
fileInfo = item.fileInfo()
result = self.__iconProvider.type(fileInfo)
else:
if item.isRoot():
result = "Computer"
elif item.isDrive():
result = "Drive"
elif item.isDir():
result = "Directory"
else:
fileInfo = item.fileInfo()
result = fileInfo.suffix()
return result
# File manipulation
# bool remove(const QModelIndex & index) const
# bool rmdir(const QModelIndex & index) const
# QModelIndex mkdir(const QModelIndex & parent, const QString & name)
# Configuration
def rootDirectory(self):
return qt.QDir(self.rootPath())
def rootPath(self):
return self.__currentPath
def setRootPath(self, path):
if self.__currentPath == path:
return
self.__currentPath = path
item = self.__computer.findChildrenByPath(path)
self.__emitRootPathChanged(path)
if item is None or item.parent() is None:
return qt.QModelIndex()
index = self.createIndex(item.parent().indexOf(item), 0, item)
self.__directoryLoadedSync.emit(path)
return index
def iconProvider(self):
# FIXME: invalidate the model
return self.__iconProvider
def setIconProvider(self, provider):
# FIXME: invalidate the model
self.__iconProvider = provider
# bool resolveSymlinks() const
# void setResolveSymlinks(bool enable)
def setNameFilterDisables(self, enable):
return None
def nameFilterDisables(self):
return None
def myComputer(self, role=qt.Qt.DisplayRole):
return None
def setNameFilters(self, filters):
return
def nameFilters(self):
return None
def filter(self):
return self.__filters
def setFilter(self, filters):
return
def setReadOnly(self, enable):
assert(enable is True)
def isReadOnly(self):
return False
class SafeFileSystemModel(qt.QSortFilterProxyModel):
"""
This class implement a file system model and try to avoid freeze. On Qt4,
:class:`qt.QFileSystemModel` is known to freeze the file system when
network drives are available.
To avoid this behaviour, this class does not use
`qt.QFileInfo.absoluteFilePath` nor `qt.QFileInfo.canonicalPath` to reach
information on drives.
And because it is the end of life of Qt4, we do not implement asynchronous
loading of files as it is done by :class:`qt.QFileSystemModel`, nor some
useful features.
"""
def __init__(self, parent=None):
qt.QSortFilterProxyModel.__init__(self, parent=parent)
self.__nameFilterDisables = sys.platform == "darwin"
self.__nameFilters = []
self.__filters = qt.QDir.AllEntries | qt.QDir.NoDotAndDotDot | qt.QDir.AllDirs
sourceModel = _RawFileSystemModel(self)
self.setSourceModel(sourceModel)
@property
def directoryLoaded(self):
return self.sourceModel().directoryLoaded
@property
def rootPathChanged(self):
return self.sourceModel().rootPathChanged
def index(self, *args, **kwargs):
path_api = False
path_api |= len(args) >= 1 and isinstance(args[0], six.string_types)
path_api |= "path" in kwargs
if path_api:
return self.__indexFromPath(*args, **kwargs)
else:
return self.__index(*args, **kwargs)
def __index(self, row, column, parent=qt.QModelIndex()):
return qt.QSortFilterProxyModel.index(self, row, column, parent)
def __indexFromPath(self, path, column=0):
"""
Uses the index(str) C++ API
:rtype: qt.QModelIndex
"""
if path == "":
return qt.QModelIndex()
index = self.sourceModel().index(path, column)
index = self.mapFromSource(index)
return index
def lessThan(self, leftSourceIndex, rightSourceIndex):
sourceModel = self.sourceModel()
sortColumn = self.sortColumn()
if sortColumn == _RawFileSystemModel.NAME_COLUMN:
leftItem = sourceModel._item(leftSourceIndex)
rightItem = sourceModel._item(rightSourceIndex)
if sys.platform != "darwin":
# Sort directories before files
leftIsDir = leftItem.isDir()
rightIsDir = rightItem.isDir()
if leftIsDir ^ rightIsDir:
return leftIsDir
return leftItem.fileName().lower() < rightItem.fileName().lower()
elif sortColumn == _RawFileSystemModel.SIZE_COLUMN:
left = sourceModel.fileInfo(leftSourceIndex)
right = sourceModel.fileInfo(rightSourceIndex)
return left.size() < right.size()
elif sortColumn == _RawFileSystemModel.TYPE_COLUMN:
left = sourceModel.type(leftSourceIndex)
right = sourceModel.type(rightSourceIndex)
return left < right
elif sortColumn == _RawFileSystemModel.LAST_MODIFIED_COLUMN:
left = sourceModel.fileInfo(leftSourceIndex)
right = sourceModel.fileInfo(rightSourceIndex)
return left.lastModified() < right.lastModified()
else:
_logger.warning("Unsupported sorted column %d", sortColumn)
return False
def __filtersAccepted(self, item, filters):
"""
Check individual flag filters.
"""
if not (filters & (qt.QDir.Dirs | qt.QDir.AllDirs)):
# Hide dirs
if item.isDir():
return False
if not (filters & qt.QDir.Files):
# Hide files
if item.isFile():
return False
if not (filters & qt.QDir.Drives):
# Hide drives
if item.isDrive():
return False
fileInfo = item.fileInfo()
if fileInfo is None:
return False
filterPermissions = (filters & qt.QDir.PermissionMask) != 0
if filterPermissions and (filters & (qt.QDir.Dirs | qt.QDir.Files)):
if (filters & qt.QDir.Readable):
# Hide unreadable
if not fileInfo.isReadable():
return False
if (filters & qt.QDir.Writable):
# Hide unwritable
if not fileInfo.isWritable():
return False
if (filters & qt.QDir.Executable):
# Hide unexecutable
if not fileInfo.isExecutable():
return False
if (filters & qt.QDir.NoSymLinks):
# Hide sym links
if fileInfo.isSymLink():
return False
if not (filters & qt.QDir.System):
# Hide system
if not item.isDir() and not item.isFile():
return False
fileName = item.fileName()
isDot = fileName == "."
isDotDot = fileName == ".."
if not (filters & qt.QDir.Hidden):
# Hide hidden
if not (isDot or isDotDot) and fileInfo.isHidden():
return False
if filters & (qt.QDir.NoDot | qt.QDir.NoDotDot | qt.QDir.NoDotAndDotDot):
# Hide parent/self references
if filters & qt.QDir.NoDot:
if isDot:
return False
if filters & qt.QDir.NoDotDot:
if isDotDot:
return False
if filters & qt.QDir.NoDotAndDotDot:
if isDot or isDotDot:
return False
return True
def filterAcceptsRow(self, sourceRow, sourceParent):
if not sourceParent.isValid():
return True
sourceModel = self.sourceModel()
index = sourceModel.index(sourceRow, 0, sourceParent)
if not index.isValid():
return True
item = sourceModel._item(index)
filters = self.__filters
if item.isDrive():
# Let say a user always have access to a drive
# It avoid to access to fileInfo then avoid to freeze the file
# system
return True
if not self.__filtersAccepted(item, filters):
return False
if self.__nameFilterDisables:
return True
if item.isDir() and (filters & qt.QDir.AllDirs):
# dont apply the filters to directory names
return True
return self.__nameFiltersAccepted(item)
def __nameFiltersAccepted(self, item):
if len(self.__nameFilters) == 0:
return True
fileName = item.fileName()
for reg in self.__nameFilters:
if reg.exactMatch(fileName):
return True
return False
def setNameFilterDisables(self, enable):
self.__nameFilterDisables = enable
self.invalidate()
def nameFilterDisables(self):
return self.__nameFilterDisables
def myComputer(self, role=qt.Qt.DisplayRole):
return self.sourceModel().myComputer(role)
def setNameFilters(self, filters):
self.__nameFilters = []
isCaseSensitive = self.__filters & qt.QDir.CaseSensitive
caseSensitive = qt.Qt.CaseSensitive if isCaseSensitive else qt.Qt.CaseInsensitive
for f in filters:
reg = qt.QRegExp(f, caseSensitive, qt.QRegExp.Wildcard)
self.__nameFilters.append(reg)
self.invalidate()
def nameFilters(self):
return [f.pattern() for f in self.__nameFilters]
def filter(self):
return self.__filters
def setFilter(self, filters):
self.__filters = filters
# In case of change of case sensitivity
self.setNameFilters(self.nameFilters())
self.invalidate()
def setReadOnly(self, enable):
assert(enable is True)
def isReadOnly(self):
return False
def rootPath(self):
return self.sourceModel().rootPath()
def setRootPath(self, path):
index = self.sourceModel().setRootPath(path)
index = self.mapFromSource(index)
return index
def flags(self, index):
sourceModel = self.sourceModel()
index = self.mapToSource(index)
filters = sourceModel.flags(index)
if self.__nameFilterDisables:
item = sourceModel._item(index)
if not self.__nameFiltersAccepted(item):
filters &= ~qt.Qt.ItemIsEnabled
return filters
def fileIcon(self, index):
sourceModel = self.sourceModel()
index = self.mapToSource(index)
return sourceModel.fileIcon(index)
def fileInfo(self, index):
sourceModel = self.sourceModel()
index = self.mapToSource(index)
return sourceModel.fileInfo(index)
def fileName(self, index):
sourceModel = self.sourceModel()
index = self.mapToSource(index)
return sourceModel.fileName(index)
def filePath(self, index):
sourceModel = self.sourceModel()
index = self.mapToSource(index)
return sourceModel.filePath(index)
def isDir(self, index):
sourceModel = self.sourceModel()
index = self.mapToSource(index)
return sourceModel.isDir(index)
def lastModified(self, index):
sourceModel = self.sourceModel()
index = self.mapToSource(index)
return sourceModel.lastModified(index)
def permissions(self, index):
sourceModel = self.sourceModel()
index = self.mapToSource(index)
return sourceModel.permissions(index)
def size(self, index):
sourceModel = self.sourceModel()
index = self.mapToSource(index)
return sourceModel.size(index)
def type(self, index):
sourceModel = self.sourceModel()
index = self.mapToSource(index)
return sourceModel.type(index)
|