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/>.
46 def __init__(self, parent=None, oldName="", nameList=[], driveIdent=None):
47 QDialog.__init__(self, parent)
50 assert driveIdent !=
None
51 self.stickId, self.uuid, self.
tattoo = driveIdent
52 self.
ui=Ui_nameAdrive.Ui_Dialog()
55 self.ui.listWidget.addItem(n)
56 self.ui.lineEditOld.setText(self.
oldName)
58 self.connect(self.ui.listWidget, SIGNAL(
"itemSelectionChanged()"), self.
selectionChanged)
59 self.connect(self.ui.pushButtonOK, SIGNAL(
"clicked()"), self.
ok)
60 self.connect(self.ui.pushButtonEsc, SIGNAL(
"clicked()"), self.
esc)
71 m=self.numPattern.match(
"%s" %self.
oldName)
75 regexp=QString(
"^%s-.*" %num)
76 possible=lw.findItems(regexp,Qt.MatchRegExp)
78 lw.setCurrentItem(possible[0])
80 lw.setCurrentItem(lw.item(0))
82 lw.setCurrentItem(lw.item(0))
91 l=self.ui.listWidget.selectedItems()
93 t=i.data(Qt.DisplayRole).toString()
94 self.ui.lineEditNew.setText(t)
102 newName=
u"%s" %self.ui.lineEditNew.text()
103 newName.encode(
"utf-8")
104 db.writeStudent(self.stickId, self.uuid, self.
tattoo, newName)
105 self.parent().namesDialog.takeItem(newName)
106 self.parent().checkDisks(noLoop=
True)
107 self.done(QDialog.Accepted)
115 self.done(QDialog.Rejected)