6 this file is part of the project scolasync
8 Copyright (C) 2010 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/>.
28 import os.path, subprocess
30 import Ui_copyToDialog1
45 def __init__(self,parent = None, workdir=""):
46 QDialog.__init__(self,parent)
48 self.
_ui=Ui_copyToDialog1.Ui_Dialog()
49 self._ui.setupUi(self)
50 self._ui.travailEdit.setText(workdir)
58 QObject.connect(self._ui.selectButton, SIGNAL(
"clicked()"), self.
select)
59 QObject.connect(self._ui.removeButton, SIGNAL(
"clicked()"), self.
remove)
60 QObject.connect(self._ui.cancelButton, SIGNAL(
"clicked()"), self.
cancel)
61 QObject.connect(self._ui.continueButton, SIGNAL(
"clicked()"), self.
cont)
62 QObject.connect(self._ui.travailEdit, SIGNAL(
"editingFinished()"), self.
changeWd)
69 newDir=self._ui.travailEdit.text()
70 self.mainWindow.changeWd(newDir)
94 self._model1.setFilter(QDir.AllEntries)
95 self._ui.listViewFrom.setModel(self.
_model1)
96 QObject.connect(self._ui.listViewFrom, SIGNAL(
"doubleClicked(QModelIndex)"), self.
cd)
104 path=directory.path()
105 cwdIndex = self._model1.index(path)
106 self._ui.listViewFrom.setRootIndex(cwdIndex)
107 self._ui.lineEdit.setText(path)
115 d=
"%s" %index.data().toString()
116 p=
"%s" %self._fromDir.path()
117 j=os.path.abspath(os.path.join(p,d))
127 self.
_model2 = QStandardItemModel()
131 self._proxyModel.setSourceModel(self.
_model2)
133 self._proxyModel.setDynamicSortFilter(
True)
146 sel=self._ui.listViewFrom.selectedIndexes()
149 d=
"%s" %index.data().toString()
150 p=
"%s" %self._fromDir.path()
151 j=os.path.abspath(os.path.join(p,d))
152 f=self._model2.findItems(j)
154 self._model2.appendRow(QStandardItem(j))
155 self._proxyModel.sort(0)
159 print (
"%s est déjà sélectionné" %j)
168 p=subprocess.Popen(
"du -s '%s' | awk '{print $1}'" %path,
169 shell=
True, stdout=subprocess.PIPE)
170 size=p.communicate()[0]
175 unit=
"%s" %QApplication.translate(
"Dialog",
"%s kilo-octets",
None, QApplication.UnicodeUTF8)
177 total= 0.1*int(10*total/1024)
178 unit=
"%s" %QApplication.translate(
"Dialog",
"%s méga-octets",
None, QApplication.UnicodeUTF8)
180 total= 0.1*int(10*total/1024)
181 unit=
"%s" %QApplication.translate(
"Dialog",
"%s giga-octets",
None, QApplication.UnicodeUTF8)
182 self._ui.lineEdit_size.setText(unit %total)
190 sel=self._ui.listViewTo.selectedIndexes()
193 sourceIndex=self._proxyModel.mapToSource(index)
194 self._model2.removeRow(sourceIndex.row())
195 self._proxyModel.sort(0)
206 sl=self._model2.findItems(
"*",Qt.MatchWildcard)
207 return map(
lambda x: (
"%s" %x.text()), sl)
209 if __name__==
"__main__":
211 app = QApplication(sys.argv)
214 sys.exit(app.exec_())
def cd
Change le répertoire courant si possible.
def selectedList
Renvoie une liste de répertoires et de fichiers qui ont été sélectionnés pour la copie sur clé USB...
def setFromListeDir
Choisit un répertoire pour la liste source.
Un dialogue pour choisir un ensemble de fichiers à transférer vers une collection de clés USB...
def setupToListe
Met en place un visionneur de fichierspour les fichiers reçus.
def changeWd
changement du répertoire de travail
def displaySize
Affiche la taille de la sélection courante.
def select
Ajoute le répertoire ou le fichier sélectionné dans le navigateur de fichiers à la liste de sélection...
def cancel
L'action provoquée par le bouton d'échappement : fermeture du dialogue.
def cont
L'action provoquée par le bouton de continuation : fermeture du dialogue et self.ok devient vrai...
_proxyModel
on connecte la liste d'items standard via un proxy qui autorise le tri alphabétique ...
def setupFromListe
Met en place un visionneur de fichiers dans la liste source.
def remove
Supprime le répertoire ou le fichier sélectionné dans la liste de sélections.