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/>.
28 from Ui_choixEleves
import Ui_Dialog
49 def __init__(self, parent=None, gestionnaire=gestClasse.Sconet):
50 QDialog.__init__(self, parent=parent)
57 self.ui.listWidget.setSelectionMode(QAbstractItemView.ExtendedSelection)
58 self.ui.listWidget.setSortingEnabled(
True)
59 self.ui.checkBoxNumero.setChecked(
True)
60 self.ui.spinBoxNumero.setValue(1)
61 self.ui.spinBoxNumero.setEnabled(
True)
62 self.connect(self.ui.pushButtonFile, SIGNAL(
'clicked()'), self.
fichierEleves)
63 self.connect(self.ui.pushButton_replierArbre, SIGNAL(
"clicked()"), self.
replie)
64 self.connect(self.ui.pushButton_cocher, SIGNAL(
"clicked()"), self.
coche)
65 self.connect(self.ui.pushButton_decocher, SIGNAL(
"clicked()"), self.
decoche)
66 self.connect(self.ui.pushButton_addToList, SIGNAL(
"clicked()"), self.
addToList)
67 self.connect(self.ui.pushButton_delInList, SIGNAL(
"clicked()"), self.
delInList)
68 self.connect(self.ui.pushButton_OK, SIGNAL(
"clicked()"), self.
valid)
69 self.connect(self.ui.pushButton_Esc, SIGNAL(
"clicked()"), self.
escape)
70 self.connect(self.ui.checkBoxNumero, SIGNAL(
"stateChanged(int)"), self.
checkNum)
77 caption=
"Choisissez un nouveau fichier de gestion des élèves"
78 dirname=os.path.dirname(self.
prefs[
"schoolFile"])
79 newFile=QFileDialog.getOpenFileName (self, caption, dirname)
80 if os.path.exists(newFile):
81 self.
prefs[
"schoolFile"]=
"%s" %newFile.toUtf8()
82 db.writePrefs(self.
prefs)
93 self.ui.lineEditFile.setText(self.
prefs[
"schoolFile"])
94 self.ui.treeView.connecteGestionnaire(self.
prefs[
"schoolFile"],
98 QMessageBox.warning(
None,
99 QApplication.translate(
"Dialog",
"Échec à l'ouverture du fichier élèves",
None, QApplication.UnicodeUTF8),
100 QApplication.translate(
"Dialog",
"Le fichier %1 n'a pas pu être traité",
None, QApplication.UnicodeUTF8).arg(self.
prefs[
"schoolFile"]))
109 if state==Qt.Checked:
110 self.ui.spinBoxNumero.setEnabled(
True)
112 self.ui.spinBoxNumero.setEnabled(
False)
120 self.ui.treeView.collapseAll()
128 for e
in self.ui.treeView.expandedItems():
129 e.setCheckState(Qt.Checked)
137 for e
in self.ui.treeView.expandedItems():
138 e.setCheckState(Qt.Unchecked)
147 self.parent().setAvailableNames(self.ui.listWidget.count() > 0)
156 if not self.ui.listWidget.findItems(n,Qt.MatchExactly):
157 self.ui.listWidget.addItem(n)
167 for i
in self.ui.listWidget.selectedIndexes():
169 rows.sort(reverse=
True)
171 self.ui.listWidget.takeItem(r)
182 if self.count() == 0:
184 i=self.ui.listWidget.takeItem(0)
186 return i.data(Qt.DisplayRole).toString()
193 itemList=self.ui.listWidget.findItems(QString(
"*"),Qt.MatchWrap | Qt.MatchWildcard)
194 l=[i.data(Qt.DisplayRole).toString()
for i
in itemList]
205 found=self.ui.listWidget.findItems(item,Qt.MatchExactly)
207 r=self.ui.listWidget.row(found[0])
208 i=self.ui.listWidget.takeItem(r)
210 return i.data(Qt.DisplayRole).toString()
228 while self.ui.listWidget.count() > 0:
229 self.ui.listWidget.takeItem(0)
240 return self.ui.treeView.checkedItems()
246 if self.ui.checkBoxNumero.isChecked():
247 n=self.ui.spinBoxNumero.value()
248 prefixe=QString(
"%1-").arg(n,fieldWidth=2,fillChar=QChar(
"0"))
249 self.ui.spinBoxNumero.setValue(n+1)
250 result.append(prefixe+e.unique_name)
253 if __name__==
"__main__":
254 app=QApplication(sys.argv)
257 print "dialogue ok =", d.ok
260 print (
u"on a dépilé %s" %i).encode(
"utf-8")