5 this file is part of the project scolasync
7 Copyright (C) 2010 Georges Khaznadar <georgesk@ofset.org>
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 import os.path, subprocess
28 import Ui_copyToDialog1
43 def __init__(self,parent = None, workdir=""):
44 QDialog.__init__(self,parent)
46 self.
_ui=Ui_copyToDialog1.Ui_Dialog()
47 self._ui.setupUi(self)
48 self._ui.travailEdit.setText(workdir)
56 self._ui.selectButton.clicked.connect(self.
select)
57 self._ui.removeButton.clicked.connect(self.
remove)
58 self._ui.cancelButton.clicked.connect(self.
cancel)
59 self._ui.continueButton.clicked.connect(self.
cont)
60 self._ui.travailEdit.editingFinished.connect(self.
changeWd)
67 newDir=self._ui.travailEdit.text()
68 self.mainWindow.changeWd(newDir)
92 self._model1.setFilter(QDir.AllEntries)
93 self._ui.listViewFrom.setModel(self.
_model1)
94 self._ui.listViewFrom.doubleClicked.connect(self.
cd)
102 path=directory.path()
103 cwdIndex = self._model1.index(path)
104 self._ui.listViewFrom.setRootIndex(cwdIndex)
105 self._ui.lineEdit.setText(path)
113 d=
"%s" %index.data()
114 p=
"%s" %self._fromDir.path()
115 j=os.path.abspath(os.path.join(p,d))
125 self.
_model2 = QStandardItemModel()
129 self._proxyModel.setSourceModel(self.
_model2)
131 self._proxyModel.setDynamicSortFilter(
True)
144 sel=self._ui.listViewFrom.selectedIndexes()
147 d=
"%s" %index.data()
148 p=
"%s" %self._fromDir.path()
149 j=os.path.abspath(os.path.join(p,d))
150 f=self._model2.findItems(j)
152 self._model2.appendRow(QStandardItem(j))
153 self._proxyModel.sort(0)
157 print (
"%s est déjà sélectionné" %j)
166 p=subprocess.Popen(
"du -s '%s' | awk '{print $1}'" %path,
167 shell=
True, stdout=subprocess.PIPE)
168 size=p.communicate()[0]
173 unit=
"%s" %QApplication.translate(
"Dialog",
"%s kilo-octets",
None)
175 total= 0.1*int(10*total/1024)
176 unit=
"%s" %QApplication.translate(
"Dialog",
"%s méga-octets",
None)
178 total= 0.1*int(10*total/1024)
179 unit=
"%s" %QApplication.translate(
"Dialog",
"%s giga-octets",
None)
180 self._ui.lineEdit_size.setText(unit %total)
188 sel=self._ui.listViewTo.selectedIndexes()
191 sourceIndex=self._proxyModel.mapToSource(index)
192 self._model2.removeRow(sourceIndex.row())
193 self._proxyModel.sort(0)
204 sl=self._model2.findItems(
"*",Qt.MatchWildcard)
205 return map(
lambda x: (
"%s" %x.text()), sl)
207 if __name__==
"__main__":
209 app = QApplication(sys.argv)
212 sys.exit(app.exec_())
def selectedList(self)
Renvoie une liste de répertoires et de fichiers qui ont été sélectionnés pour la copie sur clé USB...
def setFromListeDir(self, directory)
Choisit un répertoire pour la liste source.
def cd(self, index)
Change le répertoire courant si possible.
def setupFromListe(self)
Met en place un visionneur de fichiers dans la liste source.
def cancel(self)
L'action provoquée par le bouton d'échappement : fermeture du dialogue.
Un dialogue pour choisir un ensemble de fichiers à transférer vers une collection de clés USB...
def setupToListe(self)
Met en place un visionneur de fichierspour les fichiers reçus.
def changeWd(self)
changement du répertoire de travail
def cont(self)
L'action provoquée par le bouton de continuation : fermeture du dialogue et self.ok devient vrai...
def displaySize(self)
Affiche la taille de la sélection courante.
def select(self)
Ajoute le répertoire ou le fichier sélectionné dans le navigateur de fichiers à la liste de sélection...
_proxyModel
on connecte la liste d'items standard via un proxy qui autorise le tri alphabétique ...
def remove(self)
Supprime le répertoire ou le fichier sélectionné dans la liste de sélections.