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/>.
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 QObject.connect(self._ui.selectButton, SIGNAL(
"clicked()"), self.
select)
57 QObject.connect(self._ui.removeButton, SIGNAL(
"clicked()"), self.
remove)
58 QObject.connect(self._ui.cancelButton, SIGNAL(
"clicked()"), self.
cancel)
59 QObject.connect(self._ui.continueButton, SIGNAL(
"clicked()"), self.
cont)
60 QObject.connect(self._ui.travailEdit, SIGNAL(
"editingFinished()"), self.
changeWd)
67 newDir=
u"%s" %self._ui.travailEdit.text().toUtf8()
68 self.mainWindow.changeWd(newDir)
92 self._model1.setFilter(QDir.AllEntries)
93 self._ui.listViewFrom.setModel(self.
_model1)
94 QObject.connect(self._ui.listViewFrom, SIGNAL(
"doubleClicked(QModelIndex)"), 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().toString()
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=
u"%s" %index.data().toString()
148 p=
u"%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 j,
"est déjà sélectionné"
166 p=subprocess.Popen(
u"du -s '%s' | awk '{print $1}'" %path,
167 shell=
True, stdout=subprocess.PIPE)
168 size=p.communicate()[0]
173 unit=
u"%s" %QApplication.translate(
"Dialog",
"%s kilo-octets",
None, QApplication.UnicodeUTF8)
175 total= 0.1*int(10*total/1024)
176 unit=
u"%s" %QApplication.translate(
"Dialog",
"%s méga-octets",
None, QApplication.UnicodeUTF8)
178 total= 0.1*int(10*total/1024)
179 unit=
u"%s" %QApplication.translate(
"Dialog",
"%s giga-octets",
None, QApplication.UnicodeUTF8)
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_())