6 this file is part of the project scolasync
8 Copyright (C) 2012 Georges Khaznadar <georgesk@ofset.org>
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.
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.
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/>.
27 from Ui_choixEleves
import Ui_Dialog
46 def __init__(self, parent=None, gestionnaire=gestClasse.Sconet):
47 QDialog.__init__(self, parent=parent)
54 self.
ui.listWidget.setSelectionMode(QAbstractItemView.ExtendedSelection)
55 self.
ui.listWidget.setSortingEnabled(
True)
56 self.
ui.checkBoxNumero.setChecked(
True)
57 self.
ui.spinBoxNumero.setValue(1)
58 self.
ui.spinBoxNumero.setEnabled(
True)
60 self.
ui.pushButton_replierArbre.clicked.connect(self.
replie)
61 self.
ui.pushButton_cocher.clicked.connect(self.
coche)
62 self.
ui.pushButton_decocher.clicked.connect(self.
decoche)
63 self.
ui.pushButton_addToList.clicked.connect(self.
addToList)
64 self.
ui.pushButton_delInList.clicked.connect(self.
delInList)
65 self.
ui.pushButton_OK.clicked.connect(self.
valid)
66 self.
ui.pushButton_Esc.clicked.connect(self.
escape)
67 self.
ui.checkBoxNumero.stateChanged.connect(self.
checkNum)
73 caption=
"Choisissez un nouveau fichier de gestion des élèves"
74 dirname=os.path.dirname(self.
prefs[
"schoolFile"])
75 newFile=QFileDialog.getOpenFileName (self, caption, dirname)
76 if os.path.exists(newFile):
77 self.
prefs[
"schoolFile"]=newFile
78 db.writePrefs(self.
prefs)
88 self.
ui.lineEditFile.setText(self.
prefs[
"schoolFile"])
89 self.
ui.treeView.connecteGestionnaire(self.
prefs[
"schoolFile"],
92 except Exception
as err:
93 QMessageBox.warning(
None,
94 QApplication.translate(
"Dialog",
"Échec à l'ouverture du fichier élèves",
None),
95 QApplication.translate(
"Dialog",
"Le fichier {schoolfile} n'a pas pu être traité : {erreur}",
None).format(schoolfile=self.
prefs[
"schoolFile"], erreur=err))
103 if state==Qt.Checked:
104 self.
ui.spinBoxNumero.setEnabled(
True)
106 self.
ui.spinBoxNumero.setEnabled(
False)
113 self.
ui.treeView.collapseAll()
120 for e
in self.
ui.treeView.expandedItems():
121 e.setCheckState(Qt.Checked)
128 for e
in self.
ui.treeView.expandedItems():
129 e.setCheckState(Qt.Unchecked)
138 self.parent().setAvailableNames(self.
ui.listWidget.count() > 0)
146 if not self.
ui.listWidget.findItems(n,Qt.MatchExactly):
147 self.
ui.listWidget.addItem(n)
156 for i
in self.
ui.listWidget.selectedIndexes():
158 rows.sort(reverse=
True)
160 self.
ui.listWidget.takeItem(r)
170 if self.
ui.listWidget.count() == 0:
172 i=self.
ui.listWidget.takeItem(0)
174 data=i.data(Qt.DisplayRole)
181 itemList=self.
ui.listWidget.findItems(
"*",Qt.MatchWrap | Qt.MatchWildcard)
182 l=[i.data(Qt.DisplayRole)
for i
in itemList]
192 found=self.
ui.listWidget.findItems(item,Qt.MatchExactly)
194 r=self.
ui.listWidget.row(found[0])
195 i=self.
ui.listWidget.takeItem(r)
197 data=i.data(Qt.DisplayRole)
214 while self.
ui.listWidget.count() > 0:
215 self.
ui.listWidget.takeItem(0)
225 return self.
ui.treeView.checkedItems()
231 if self.
ui.checkBoxNumero.isChecked():
232 n=self.
ui.spinBoxNumero.value()
234 self.
ui.spinBoxNumero.setValue(n+1)
235 result.append(prefixe+e.unique_name)
238 if __name__==
"__main__":
239 app=QApplication(sys.argv)
242 print (
"dialogue ok = %s" %d.ok)
245 print (
"on a dépilé %s" %i)