ScolaSync: Fichier source de src/gestclassetreeview.py

ScolaSync 5.1 |

gestclassetreeview.py
Aller à la documentation de ce fichier.
1 #!/usr/bin/python
2
3 licence={}
4 licence['en']="""
5 file gestclassetreeview.py
6 this file is part of the project scolasync
7
8 Copyright (C) 2012 Georges Khaznadar <georgesk@ofset.org>
9
10 This program is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version3 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 """
23
24 import gestClasse
25 from PyQt5.QtWidgets import *
26 from PyQt5.QtCore import *
27 from PyQt5.QtGui import *
28
29 class gestClasseTreeView(QTreeView):
30
33
34 def __init__(self, parent=None):
35 QTreeView.__init__(self, parent)
36 self.gest=None
37 model=QStandardItemModel()
38 self.setModel(model)
39 self.root = self.model().invisibleRootItem()
40 return
41
42 # @param fichier le nom d'un fichier, ou un fichier ouvert en lecture, pour
43 # récupérer des données SCONET
44 # @param gestionnaire un gestionnaire pour exploiter les données du fichier
45 # @param renew vrai si on doit tout effacer avant de recommencer
46 #
47
48 def connecteGestionnaire(self, fichier, gestionnaire=gestClasse.Sconet, renew=False):
49 if renew:
50 m=self.model()
51 m.removeRows(0, m.rowCount())
52 self.root = self.model().invisibleRootItem()
53 self.gest=gestionnaire(fichier)
54 for c in self.gest.collectClasses():
55 rowClasse=[QStandardItem(c)]
56 self.root.appendRow(rowClasse)
57 for e in self.gest.elevesDeClasse(c):
58 name=self.gest.showable_name(e)
59 eleveItem=QStandardItem(name)
60 eleveItem.setCheckable(True)
61 eleveItem.unique_name=self.gest.unique_name(e)
62 rowEleve=[eleveItem]
63 rowClasse[0].appendRow(rowEleve)
64 self.setExpanded(self.model().index(0,0),True)
65 return
66
67
69
70 def expandedItems(self):
71 result=[]
72 m=self.model()
73 for r in range(m.rowCount()):
74 cl=m.item(r)
75 if self.isExpanded(cl.index()):
76 for r1 in range(cl.rowCount()):
77 e=cl.child(r1)
78 result.append(e)
79 return result
80
81
83
84 def allItems(self):
85 result=[]
86 m=self.model()
87 for r in range(m.rowCount()):
88 cl=m.item(r)
89 for r1 in range(cl.rowCount()):
90 e=cl.child(r1)
91 result.append(e)
92 return result
93
94
96
97 def checkedItems(self):
98 result=[]
99 m=self.model()
100 for r in range(m.rowCount()):
101 cl=m.item(r)
102 for r1 in range(cl.rowCount()):
103 e=cl.child(r1)
104 if e.checkState():
105 result.append(e)
106 return result
107
QTreeView
src.gestclassetreeview.gestClasseTreeView.connecteGestionnaire
def connecteGestionnaire(self, fichier, gestionnaire=gestClasse.Sconet, renew=False)
Definition: gestclassetreeview.py:48
src.gestclassetreeview.gestClasseTreeView
Definition: gestclassetreeview.py:29
src.gestclassetreeview.gestClasseTreeView.root
root
Definition: gestclassetreeview.py:39
src.gestclassetreeview.gestClasseTreeView.__init__
def __init__(self, parent=None)
Le constructeur.
Definition: gestclassetreeview.py:34
src.gestclassetreeview.gestClasseTreeView.allItems
def allItems(self)
Definition: gestclassetreeview.py:84
src.gestclassetreeview.gestClasseTreeView.checkedItems
def checkedItems(self)
Definition: gestclassetreeview.py:97
src.gestclassetreeview.gestClasseTreeView.expandedItems
def expandedItems(self)
Definition: gestclassetreeview.py:70
QtCore
QtGui
src.gestclassetreeview.gestClasseTreeView.gest
gest
Definition: gestclassetreeview.py:36
QtWidgets