7 this file is part of the project scolasync
9 Copyright (C) 2012 Georges Khaznadar <georgesk@ofset.org>
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
30 from Ui_choixEleves
import Ui_Dialog
51 def __init__(self, parent=None, gestionnaire=gestClasse.Sconet):
52 QDialog.__init__(self, parent=parent)
59 self.ui.listWidget.setSelectionMode(QAbstractItemView.ExtendedSelection)
60 self.ui.listWidget.setSortingEnabled(
True)
61 self.ui.checkBoxNumero.setChecked(
True)
62 self.ui.spinBoxNumero.setValue(1)
63 self.ui.spinBoxNumero.setEnabled(
True)
64 self.connect(self.ui.pushButtonFile, SIGNAL(
'clicked()'), self.
fichierEleves)
65 self.connect(self.ui.pushButton_replierArbre, SIGNAL(
"clicked()"), self.
replie)
66 self.connect(self.ui.pushButton_cocher, SIGNAL(
"clicked()"), self.
coche)
67 self.connect(self.ui.pushButton_decocher, SIGNAL(
"clicked()"), self.
decoche)
68 self.connect(self.ui.pushButton_addToList, SIGNAL(
"clicked()"), self.
addToList)
69 self.connect(self.ui.pushButton_delInList, SIGNAL(
"clicked()"), self.
delInList)
70 self.connect(self.ui.pushButton_OK, SIGNAL(
"clicked()"), self.
valid)
71 self.connect(self.ui.pushButton_Esc, SIGNAL(
"clicked()"), self.
escape)
72 self.connect(self.ui.checkBoxNumero, SIGNAL(
"stateChanged(int)"), self.
checkNum)
79 caption=
"Choisissez un nouveau fichier de gestion des élèves"
80 dirname=os.path.dirname(self.
prefs[
"schoolFile"])
81 newFile=QFileDialog.getOpenFileName (self, caption, dirname)
82 if os.path.exists(newFile):
83 self.
prefs[
"schoolFile"]=newFile
84 db.writePrefs(self.
prefs)
95 self.ui.lineEditFile.setText(self.
prefs[
"schoolFile"])
96 self.ui.treeView.connecteGestionnaire(self.
prefs[
"schoolFile"],
99 except Exception
as err:
100 QMessageBox.warning(
None,
101 QApplication.translate(
"Dialog",
"Échec à l'ouverture du fichier élèves",
None, QApplication.UnicodeUTF8),
102 QApplication.translate(
"Dialog",
"Le fichier {schoolfile} n'a pas pu être traité : {erreur}",
None, QApplication.UnicodeUTF8).format(schoolfile=self.
prefs[
"schoolFile"], erreur=err))
111 if state==Qt.Checked:
112 self.ui.spinBoxNumero.setEnabled(
True)
114 self.ui.spinBoxNumero.setEnabled(
False)
122 self.ui.treeView.collapseAll()
130 for e
in self.ui.treeView.expandedItems():
131 e.setCheckState(Qt.Checked)
139 for e
in self.ui.treeView.expandedItems():
140 e.setCheckState(Qt.Unchecked)
150 self.parent().setAvailableNames(self.ui.listWidget.count() > 0)
159 if not self.ui.listWidget.findItems(n,Qt.MatchExactly):
160 self.ui.listWidget.addItem(n)
170 for i
in self.ui.listWidget.selectedIndexes():
172 rows.sort(reverse=
True)
174 self.ui.listWidget.takeItem(r)
185 if self.ui.listWidget.count() == 0:
187 i=self.ui.listWidget.takeItem(0)
189 data=i.data(Qt.DisplayRole)
190 if not isinstance(data, str):
191 data = data.toString()
199 itemList=self.ui.listWidget.findItems(
"*",Qt.MatchWrap | Qt.MatchWildcard)
200 if not isinstance (itemList[0].data(Qt.DisplayRole),str):
201 l=[i.data(Qt.DisplayRole).toString()
for i
in itemList]
203 l=[i.data(Qt.DisplayRole)
for i
in itemList]
214 found=self.ui.listWidget.findItems(item,Qt.MatchExactly)
216 r=self.ui.listWidget.row(found[0])
217 i=self.ui.listWidget.takeItem(r)
219 data=i.data(Qt.DisplayRole)
220 if not isinstance(data, str):
221 data = data.toString()
240 while self.ui.listWidget.count() > 0:
241 self.ui.listWidget.takeItem(0)
252 return self.ui.treeView.checkedItems()
258 if self.ui.checkBoxNumero.isChecked():
259 n=self.ui.spinBoxNumero.value()
261 self.ui.spinBoxNumero.setValue(n+1)
262 result.append(prefixe+e.unique_name)
265 if __name__==
"__main__":
266 app=QApplication(sys.argv)
269 print (
"dialogue ok = %s" %d.ok)
272 print (
"on a dépilé %s" %i)