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_())