gestclassetreeview.py
Aller à la documentation de ce fichier.
#!/usr/bin/python
licence={}
licence['en']="""
file gestclassetreeview.py
this file is part of the project scolasync
Copyright (C) 2012 Georges Khaznadar <georgesk@ofset.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import gestClasse
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
class gestClasseTreeView(QTreeView):
def __init__(self, parent=None):
QTreeView.__init__(self, parent)
self.gest=None
model=QStandardItemModel()
self.setModel(model)
self.root = self.model().invisibleRootItem()
return
# @param fichier le nom d'un fichier, ou un fichier ouvert en lecture, pour
# récupérer des données SCONET
# @param gestionnaire un gestionnaire pour exploiter les données du fichier
# @param renew vrai si on doit tout effacer avant de recommencer
#
def connecteGestionnaire(self, fichier, gestionnaire=gestClasse.Sconet, renew=False):
if renew:
m=self.model()
m.removeRows(0, m.rowCount())
self.root = self.model().invisibleRootItem()
self.gest=gestionnaire(fichier)
for c in self.gest.collectClasses():
rowClasse=[QStandardItem(c)]
self.root.appendRow(rowClasse)
for e in self.gest.elevesDeClasse(c):
name=self.gest.showable_name(e)
eleveItem=QStandardItem(name)
eleveItem.setCheckable(True)
eleveItem.unique_name=self.gest.unique_name(e)
rowEleve=[eleveItem]
rowClasse[0].appendRow(rowEleve)
self.setExpanded(self.model().index(0,0),True)
return
def expandedItems(self):
result=[]
m=self.model()
for r in range(m.rowCount()):
cl=m.item(r)
if self.isExpanded(cl.index()):
for r1 in range(cl.rowCount()):
e=cl.child(r1)
result.append(e)
return result
def allItems(self):
result=[]
m=self.model()
for r in range(m.rowCount()):
cl=m.item(r)
for r1 in range(cl.rowCount()):
e=cl.child(r1)
result.append(e)
return result
def checkedItems(self):
result=[]
m=self.model()
for r in range(m.rowCount()):
cl=m.item(r)
for r1 in range(cl.rowCount()):
e=cl.child(r1)
if e.checkState():
result.append(e)
return result
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