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
41 def __init__(self,parent = None, workdir=""):
42 QDialog.__init__(self,parent)
44 self.
_ui=Ui_copyToDialog1.Ui_Dialog()
45 self.
_ui.setupUi(self)
46 self.
_ui.travailEdit.setText(workdir)
54 self.
_ui.selectButton.clicked.connect(self.
select)
55 self.
_ui.removeButton.clicked.connect(self.
remove)
56 self.
_ui.cancelButton.clicked.connect(self.
cancel)
57 self.
_ui.continueButton.clicked.connect(self.
cont)
58 self.
_ui.travailEdit.editingFinished.connect(self.
changeWd)
64 newDir=self.
_ui.travailEdit.text()
86 self.
_model1.setFilter(QDir.AllEntries)
88 self.
_ui.listViewFrom.doubleClicked.connect(self.
cd)
96 cwdIndex = self.
_model1.index(path)
97 self.
_ui.listViewFrom.setRootIndex(cwdIndex)
98 self.
_ui.lineEdit.setText(path)
105 d=
"%s" %index.data()
107 j=os.path.abspath(os.path.join(p,d))
116 self.
_model2 = QStandardItemModel()
134 sel=self.
_ui.listViewFrom.selectedIndexes()
137 d=
"%s" %index.data()
139 j=os.path.abspath(os.path.join(p,d))
142 self.
_model2.appendRow(QStandardItem(j))
147 print (
"%s est déjà sélectionné" %j)
155 p=subprocess.Popen(
"du -s '%s' | awk '{print $1}'" %path,
156 shell=
True, stdout=subprocess.PIPE)
157 size=p.communicate()[0]
162 unit=
"%s" %QApplication.translate(
"Dialog",
"%s kilo-octets",
None)
164 total= 0.1*int(10*total/1024)
165 unit=
"%s" %QApplication.translate(
"Dialog",
"%s méga-octets",
None)
167 total= 0.1*int(10*total/1024)
168 unit=
"%s" %QApplication.translate(
"Dialog",
"%s giga-octets",
None)
169 self.
_ui.lineEdit_size.setText(unit %total)
176 sel=self.
_ui.listViewTo.selectedIndexes()
180 self.
_model2.removeRow(sourceIndex.row())
191 sl=self.
_model2.findItems(
"*",Qt.MatchWildcard)
192 return map(
lambda x: (
"%s" %x.text()), sl)
194 if __name__==
"__main__":
196 app = QApplication(sys.argv)
199 sys.exit(app.exec_())