author | llornkcor <llornkcor> | 2003-02-24 03:53:24 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-02-24 03:53:24 (UTC) |
commit | 009b85e8daa341d4a2fc62404f4a58715e775b86 (patch) (unidiff) | |
tree | 754ec3b77412e22c90b1da7d68c609436189dcfd | |
parent | 04470810d71cc8aa3ddde193559312fd3ecc7a11 (diff) | |
download | opie-009b85e8daa341d4a2fc62404f4a58715e775b86.zip opie-009b85e8daa341d4a2fc62404f4a58715e775b86.tar.gz opie-009b85e8daa341d4a2fc62404f4a58715e775b86.tar.bz2 |
whoops
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 062a013..f46503c 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,474 +1,474 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | #include "output.h" | 13 | #include "output.h" |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <opie/otabwidget.h> | 16 | #include <opie/otabwidget.h> |
17 | #include <opie/oprocess.h> | 17 | #include <opie/oprocess.h> |
18 | 18 | ||
19 | #include <qpe/lnkproperties.h> | 19 | #include <qpe/lnkproperties.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/qpemenubar.h> | 21 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpetoolbar.h> | 22 | #include <qpe/qpetoolbar.h> |
23 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <qpe/applnk.h> | 25 | #include <qpe/applnk.h> |
26 | #include <qpe/ir.h> | 26 | #include <qpe/ir.h> |
27 | 27 | ||
28 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
29 | #include <qmultilineedit.h> | 29 | #include <qmultilineedit.h> |
30 | 30 | ||
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | 32 | ||
33 | #include <qlayout.h> | 33 | #include <qlayout.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qcombobox.h> | 35 | #include <qcombobox.h> |
36 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
37 | #include <qtabwidget.h> | 37 | #include <qtabwidget.h> |
38 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
39 | #include <qtabwidget.h> | 39 | #include <qtabwidget.h> |
40 | #include <qlineedit.h> | 40 | #include <qlineedit.h> |
41 | #include <qlistview.h> | 41 | #include <qlistview.h> |
42 | 42 | ||
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | #include <unistd.h> | 44 | #include <unistd.h> |
45 | #include <sys/stat.h> | 45 | #include <sys/stat.h> |
46 | #include <dirent.h> | 46 | #include <dirent.h> |
47 | 47 | ||
48 | 48 | ||
49 | void AdvancedFm::doDirChange() | 49 | void AdvancedFm::doDirChange() |
50 | { | 50 | { |
51 | ListClicked( CurrentView()->currentItem()); | 51 | ListClicked( CurrentView()->currentItem()); |
52 | } | 52 | } |
53 | 53 | ||
54 | void AdvancedFm::showMenuHidden() | 54 | void AdvancedFm::showMenuHidden() |
55 | { | 55 | { |
56 | if (b) | 56 | if (b) |
57 | { | 57 | { |
58 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 58 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
59 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 59 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
60 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 60 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
61 | // b=FALSE; | 61 | // b=FALSE; |
62 | 62 | ||
63 | } | 63 | } |
64 | else | 64 | else |
65 | { | 65 | { |
66 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 66 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
67 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 67 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
68 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 68 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
69 | // b=TRUE; | 69 | // b=TRUE; |
70 | } | 70 | } |
71 | populateView(); | 71 | populateView(); |
72 | // populateRemoteView(); | 72 | // populateRemoteView(); |
73 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); | 73 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); |
74 | if(b) b = false; else b = true; | 74 | if(b) b = false; else b = true; |
75 | } | 75 | } |
76 | 76 | ||
77 | void AdvancedFm::showHidden() | 77 | void AdvancedFm::showHidden() |
78 | { | 78 | { |
79 | if (b) | 79 | if (b) |
80 | { | 80 | { |
81 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 81 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
82 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 82 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
83 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 83 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
84 | // b=FALSE; | 84 | // b=FALSE; |
85 | 85 | ||
86 | } | 86 | } |
87 | else | 87 | else |
88 | { | 88 | { |
89 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 89 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
90 | s OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 90 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
91 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 91 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
92 | // b=TRUE; | 92 | // b=TRUE; |
93 | } | 93 | } |
94 | populateView(); | 94 | populateView(); |
95 | } | 95 | } |
96 | 96 | ||
97 | QString AdvancedFm::dealWithSymName(const QString &fileName) | 97 | QString AdvancedFm::dealWithSymName(const QString &fileName) |
98 | { | 98 | { |
99 | QString strItem = fileName; | 99 | QString strItem = fileName; |
100 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 100 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
101 | } | 101 | } |
102 | 102 | ||
103 | void AdvancedFm::runThis() | 103 | void AdvancedFm::runThis() |
104 | { | 104 | { |
105 | QString fs; | 105 | QString fs; |
106 | QDir *thisDir = CurrentDir(); | 106 | QDir *thisDir = CurrentDir(); |
107 | 107 | ||
108 | QString curFile = CurrentView()->currentItem()->text(0); | 108 | QString curFile = CurrentView()->currentItem()->text(0); |
109 | QString path = thisDir->canonicalPath(); | 109 | QString path = thisDir->canonicalPath(); |
110 | 110 | ||
111 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 111 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
112 | 112 | ||
113 | curFile = dealWithSymName((const QString&)curFile); | 113 | curFile = dealWithSymName((const QString&)curFile); |
114 | 114 | ||
115 | if(curFile != "../") | 115 | if(curFile != "../") |
116 | { | 116 | { |
117 | 117 | ||
118 | fs = getFileSystemType((const QString &) path); | 118 | fs = getFileSystemType((const QString &) path); |
119 | QFileInfo fileInfo( path + "/" + curFile); | 119 | QFileInfo fileInfo( path + "/" + curFile); |
120 | qDebug( fileInfo.owner()); | 120 | qDebug( fileInfo.owner()); |
121 | 121 | ||
122 | if( (fileInfo.permission( QFileInfo::ExeUser) | 122 | if( (fileInfo.permission( QFileInfo::ExeUser) |
123 | | fileInfo.permission( QFileInfo::ExeGroup) | 123 | | fileInfo.permission( QFileInfo::ExeGroup) |
124 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 124 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
125 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 125 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
126 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 126 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
127 | e << curFile; | 127 | e << curFile; |
128 | } | 128 | } |
129 | else | 129 | else |
130 | { | 130 | { |
131 | curFile = path + "/" + curFile; | 131 | curFile = path + "/" + curFile; |
132 | DocLnk nf(curFile); | 132 | DocLnk nf(curFile); |
133 | QString execStr = nf.exec(); | 133 | QString execStr = nf.exec(); |
134 | qDebug( execStr); | 134 | qDebug( execStr); |
135 | if( execStr.isEmpty() ) | 135 | if( execStr.isEmpty() ) |
136 | { | 136 | { |
137 | } | 137 | } |
138 | else | 138 | else |
139 | { | 139 | { |
140 | nf.execute(); | 140 | nf.execute(); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | } | 143 | } |
144 | } | 144 | } |
145 | 145 | ||
146 | void AdvancedFm::runText() | 146 | void AdvancedFm::runText() |
147 | { | 147 | { |
148 | QString curFile = CurrentView()->currentItem()->text(0); | 148 | QString curFile = CurrentView()->currentItem()->text(0); |
149 | if(curFile != "../") | 149 | if(curFile != "../") |
150 | { | 150 | { |
151 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 151 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
152 | curFile = dealWithSymName((const QString&)curFile); | 152 | curFile = dealWithSymName((const QString&)curFile); |
153 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; | 153 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; |
154 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 154 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
155 | e << curFile; | 155 | e << curFile; |
156 | } | 156 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | void AdvancedFm::makeDir() | 159 | void AdvancedFm::makeDir() |
160 | { | 160 | { |
161 | InputDialog *fileDlg; | 161 | InputDialog *fileDlg; |
162 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 162 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
163 | fileDlg->exec(); | 163 | fileDlg->exec(); |
164 | if( fileDlg->result() == 1 ) | 164 | if( fileDlg->result() == 1 ) |
165 | { | 165 | { |
166 | QDir *thisDir = CurrentDir(); | 166 | QDir *thisDir = CurrentDir(); |
167 | QString filename = fileDlg->LineEdit1->text(); | 167 | QString filename = fileDlg->LineEdit1->text(); |
168 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 168 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
169 | } | 169 | } |
170 | populateView(); | 170 | populateView(); |
171 | } | 171 | } |
172 | 172 | ||
173 | void AdvancedFm::doDelete() | 173 | void AdvancedFm::doDelete() |
174 | { | 174 | { |
175 | 175 | ||
176 | QStringList curFileList = getPath(); | 176 | QStringList curFileList = getPath(); |
177 | bool doMsg=true; | 177 | bool doMsg=true; |
178 | int count = curFileList.count(); | 178 | int count = curFileList.count(); |
179 | if( count > 0) | 179 | if( count > 0) |
180 | { | 180 | { |
181 | if(count > 1 ) | 181 | if(count > 1 ) |
182 | { | 182 | { |
183 | QString msg; | 183 | QString msg; |
184 | msg=tr("Really delete\n%1 files?").arg(count); | 184 | msg=tr("Really delete\n%1 files?").arg(count); |
185 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 185 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
186 | ,tr("Yes"),tr("No"),0,0,1) ) | 186 | ,tr("Yes"),tr("No"),0,0,1) ) |
187 | { | 187 | { |
188 | case 0: | 188 | case 0: |
189 | doMsg=false; | 189 | doMsg=false; |
190 | break; | 190 | break; |
191 | case 1: | 191 | case 1: |
192 | return; | 192 | return; |
193 | break; | 193 | break; |
194 | }; | 194 | }; |
195 | } | 195 | } |
196 | 196 | ||
197 | QString myFile; | 197 | QString myFile; |
198 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 198 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
199 | { | 199 | { |
200 | myFile = (*it); | 200 | myFile = (*it); |
201 | if( myFile.find(" -> ",0,TRUE) != -1) | 201 | if( myFile.find(" -> ",0,TRUE) != -1) |
202 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 202 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
203 | 203 | ||
204 | QString f = CurrentDir()->canonicalPath(); | 204 | QString f = CurrentDir()->canonicalPath(); |
205 | if(f.right(1).find("/",0,TRUE) == -1) | 205 | if(f.right(1).find("/",0,TRUE) == -1) |
206 | f += "/"; | 206 | f += "/"; |
207 | f += myFile; | 207 | f += myFile; |
208 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) | 208 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) |
209 | { | 209 | { |
210 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + | 210 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + |
211 | "\nand all it's contents ?" | 211 | "\nand all it's contents ?" |
212 | ,tr("Yes"),tr("No"),0,0,1) ) | 212 | ,tr("Yes"),tr("No"),0,0,1) ) |
213 | { | 213 | { |
214 | case 0: | 214 | case 0: |
215 | { | 215 | { |
216 | f=f.left(f.length()-1); | 216 | f=f.left(f.length()-1); |
217 | QString cmd="rm -rf "+f; | 217 | QString cmd="rm -rf "+f; |
218 | startProcess( (const QString)cmd.latin1() ); | 218 | startProcess( (const QString)cmd.latin1() ); |
219 | populateView(); | 219 | populateView(); |
220 | } | 220 | } |
221 | break; | 221 | break; |
222 | case 1: | 222 | case 1: |
223 | // exit | 223 | // exit |
224 | break; | 224 | break; |
225 | }; | 225 | }; |
226 | 226 | ||
227 | } else { | 227 | } else { |
228 | if(doMsg) { | 228 | if(doMsg) { |
229 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f | 229 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f |
230 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 230 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
231 | case 1: | 231 | case 1: |
232 | return; | 232 | return; |
233 | break; | 233 | break; |
234 | }; | 234 | }; |
235 | } | 235 | } |
236 | QString cmd="rm "+f; | 236 | QString cmd="rm "+f; |
237 | QFile file(f); | 237 | QFile file(f); |
238 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) | 238 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) |
239 | file.remove(); | 239 | file.remove(); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | } | 242 | } |
243 | populateView(); | 243 | populateView(); |
244 | } | 244 | } |
245 | 245 | ||
246 | void AdvancedFm::filePerms() | 246 | void AdvancedFm::filePerms() |
247 | { | 247 | { |
248 | QStringList curFileList = getPath(); | 248 | QStringList curFileList = getPath(); |
249 | QString filePath; | 249 | QString filePath; |
250 | 250 | ||
251 | filePath = CurrentDir()->canonicalPath()+"/"; | 251 | filePath = CurrentDir()->canonicalPath()+"/"; |
252 | 252 | ||
253 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 253 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
254 | { | 254 | { |
255 | filePermissions *filePerm; | 255 | filePermissions *filePerm; |
256 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 256 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
257 | filePerm->showMaximized(); | 257 | filePerm->showMaximized(); |
258 | filePerm->exec(); | 258 | filePerm->exec(); |
259 | if( filePerm) | 259 | if( filePerm) |
260 | delete filePerm; | 260 | delete filePerm; |
261 | } | 261 | } |
262 | populateView(); | 262 | populateView(); |
263 | } | 263 | } |
264 | 264 | ||
265 | void AdvancedFm::doProperties() | 265 | void AdvancedFm::doProperties() |
266 | { | 266 | { |
267 | #if defined(QT_QWS_OPIE) | 267 | #if defined(QT_QWS_OPIE) |
268 | 268 | ||
269 | QStringList curFileList = getPath(); | 269 | QStringList curFileList = getPath(); |
270 | 270 | ||
271 | QString filePath; | 271 | QString filePath; |
272 | filePath = CurrentDir()->canonicalPath()+"/"; | 272 | filePath = CurrentDir()->canonicalPath()+"/"; |
273 | 273 | ||
274 | qDebug("%d",curFileList.count()); | 274 | qDebug("%d",curFileList.count()); |
275 | 275 | ||
276 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 276 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
277 | { | 277 | { |
278 | qDebug((filePath+*it)); | 278 | qDebug((filePath+*it)); |
279 | DocLnk lnk( (filePath+*it)); | 279 | DocLnk lnk( (filePath+*it)); |
280 | LnkProperties prop( &lnk ); | 280 | LnkProperties prop( &lnk ); |
281 | prop.showMaximized(); | 281 | prop.showMaximized(); |
282 | prop.exec(); | 282 | prop.exec(); |
283 | } | 283 | } |
284 | #endif | 284 | #endif |
285 | 285 | ||
286 | } | 286 | } |
287 | 287 | ||
288 | void AdvancedFm::upDir() | 288 | void AdvancedFm::upDir() |
289 | { | 289 | { |
290 | QDir *thisDir = CurrentDir(); | 290 | QDir *thisDir = CurrentDir(); |
291 | QString current = thisDir->canonicalPath(); | 291 | QString current = thisDir->canonicalPath(); |
292 | QDir dir(current); | 292 | QDir dir(current); |
293 | dir.cdUp(); | 293 | dir.cdUp(); |
294 | current = dir.canonicalPath(); | 294 | current = dir.canonicalPath(); |
295 | chdir( current.latin1() ); | 295 | chdir( current.latin1() ); |
296 | thisDir->cd( current, TRUE); | 296 | thisDir->cd( current, TRUE); |
297 | 297 | ||
298 | populateView(); | 298 | populateView(); |
299 | update(); | 299 | update(); |
300 | } | 300 | } |
301 | 301 | ||
302 | void AdvancedFm::copy() | 302 | void AdvancedFm::copy() |
303 | { | 303 | { |
304 | qApp->processEvents(); | 304 | qApp->processEvents(); |
305 | QStringList curFileList = getPath(); | 305 | QStringList curFileList = getPath(); |
306 | 306 | ||
307 | QDir *thisDir = CurrentDir(); | 307 | QDir *thisDir = CurrentDir(); |
308 | QDir *thatDir = OtherDir(); | 308 | QDir *thatDir = OtherDir(); |
309 | 309 | ||
310 | bool doMsg=true; | 310 | bool doMsg=true; |
311 | int count=curFileList.count(); | 311 | int count=curFileList.count(); |
312 | if( count > 0) { | 312 | if( count > 0) { |
313 | if(count > 1 ){ | 313 | if(count > 1 ){ |
314 | QString msg; | 314 | QString msg; |
315 | msg=tr("Really copy\n%1 files?").arg(count); | 315 | msg=tr("Really copy\n%1 files?").arg(count); |
316 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 316 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
317 | ,tr("Yes"),tr("No"),0,0,1) ) | 317 | ,tr("Yes"),tr("No"),0,0,1) ) |
318 | { | 318 | { |
319 | case 0: | 319 | case 0: |
320 | doMsg=false; | 320 | doMsg=false; |
321 | break; | 321 | break; |
322 | case 1: | 322 | case 1: |
323 | return; | 323 | return; |
324 | break; | 324 | break; |
325 | }; | 325 | }; |
326 | } | 326 | } |
327 | 327 | ||
328 | QString curFile, item, destFile; | 328 | QString curFile, item, destFile; |
329 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 329 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
330 | { | 330 | { |
331 | item=(*it); | 331 | item=(*it); |
332 | if(item.find("->",0,TRUE)) //symlink | 332 | if(item.find("->",0,TRUE)) //symlink |
333 | item = item.left(item.find("->",0,TRUE)); | 333 | item = item.left(item.find("->",0,TRUE)); |
334 | 334 | ||
335 | curFile = thisDir->canonicalPath()+"/"+ item; | 335 | curFile = thisDir->canonicalPath()+"/"+ item; |
336 | destFile = thatDir->canonicalPath()+"/"+ item; | 336 | destFile = thatDir->canonicalPath()+"/"+ item; |
337 | 337 | ||
338 | qDebug("Destination file is "+destFile); | 338 | qDebug("Destination file is "+destFile); |
339 | qDebug("CurrentFile file is " + curFile); | 339 | qDebug("CurrentFile file is " + curFile); |
340 | 340 | ||
341 | QFile f(destFile); | 341 | QFile f(destFile); |
342 | if( f.exists()) | 342 | if( f.exists()) |
343 | { | 343 | { |
344 | if(doMsg) | 344 | if(doMsg) |
345 | { | 345 | { |
346 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 346 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
347 | tr("%1 exists. Ok to overwrite?").arg( item ), | 347 | tr("%1 exists. Ok to overwrite?").arg( item ), |
348 | tr("Yes"),tr("No"),0,0,1) ) | 348 | tr("Yes"),tr("No"),0,0,1) ) |
349 | { | 349 | { |
350 | case 1: | 350 | case 1: |
351 | return; | 351 | return; |
352 | break; | 352 | break; |
353 | }; | 353 | }; |
354 | } | 354 | } |
355 | f.remove(); | 355 | f.remove(); |
356 | } | 356 | } |
357 | 357 | ||
358 | if( !copyFile( curFile, destFile) ) | 358 | if( !copyFile( curFile, destFile) ) |
359 | { | 359 | { |
360 | QMessageBox::message("AdvancedFm", | 360 | QMessageBox::message("AdvancedFm", |
361 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 361 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); |
362 | return; | 362 | return; |
363 | } | 363 | } |
364 | } | 364 | } |
365 | setOtherTabCurrent(); | 365 | setOtherTabCurrent(); |
366 | populateView(); | 366 | populateView(); |
367 | } | 367 | } |
368 | } | 368 | } |
369 | 369 | ||
370 | void AdvancedFm::copyAs() | 370 | void AdvancedFm::copyAs() |
371 | { | 371 | { |
372 | qApp->processEvents(); | 372 | qApp->processEvents(); |
373 | 373 | ||
374 | QStringList curFileList = getPath(); | 374 | QStringList curFileList = getPath(); |
375 | QString curFile, item; | 375 | QString curFile, item; |
376 | InputDialog *fileDlg; | 376 | InputDialog *fileDlg; |
377 | 377 | ||
378 | QDir *thisDir = CurrentDir(); | 378 | QDir *thisDir = CurrentDir(); |
379 | QDir *thatDir = OtherDir(); | 379 | QDir *thatDir = OtherDir(); |
380 | 380 | ||
381 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 381 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
382 | { | 382 | { |
383 | QString destFile; | 383 | QString destFile; |
384 | item=(*it); | 384 | item=(*it); |
385 | curFile = thisDir->canonicalPath()+"/"+(*it); | 385 | curFile = thisDir->canonicalPath()+"/"+(*it); |
386 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); | 386 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); |
387 | 387 | ||
388 | fileDlg->setInputText((const QString &) destFile ); | 388 | fileDlg->setInputText((const QString &) destFile ); |
389 | fileDlg->exec(); | 389 | fileDlg->exec(); |
390 | 390 | ||
391 | if( fileDlg->result() == 1 ) | 391 | if( fileDlg->result() == 1 ) |
392 | { | 392 | { |
393 | QString filename = fileDlg->LineEdit1->text(); | 393 | QString filename = fileDlg->LineEdit1->text(); |
394 | destFile = thatDir->canonicalPath()+"/"+filename; | 394 | destFile = thatDir->canonicalPath()+"/"+filename; |
395 | 395 | ||
396 | QFile f( destFile); | 396 | QFile f( destFile); |
397 | if( f.exists()) | 397 | if( f.exists()) |
398 | { | 398 | { |
399 | switch (QMessageBox::warning(this,tr("File Exists!"), | 399 | switch (QMessageBox::warning(this,tr("File Exists!"), |
400 | item+tr("\nexists. Ok to overwrite?"), | 400 | item+tr("\nexists. Ok to overwrite?"), |
401 | tr("Yes"),tr("No"),0,0,1) ) | 401 | tr("Yes"),tr("No"),0,0,1) ) |
402 | { | 402 | { |
403 | case 0: | 403 | case 0: |
404 | f.remove(); | 404 | f.remove(); |
405 | break; | 405 | break; |
406 | case 1: | 406 | case 1: |
407 | return; | 407 | return; |
408 | break; | 408 | break; |
409 | }; | 409 | }; |
410 | } | 410 | } |
411 | if( !copyFile( curFile, destFile) ) | 411 | if( !copyFile( curFile, destFile) ) |
412 | { | 412 | { |
413 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 413 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
414 | +curFile +tr("to\n")+destFile); | 414 | +curFile +tr("to\n")+destFile); |
415 | return; | 415 | return; |
416 | } | 416 | } |
417 | } | 417 | } |
418 | delete fileDlg; | 418 | delete fileDlg; |
419 | 419 | ||
420 | } | 420 | } |
421 | setOtherTabCurrent(); | 421 | setOtherTabCurrent(); |
422 | populateView(); | 422 | populateView(); |
423 | } | 423 | } |
424 | 424 | ||
425 | void AdvancedFm::copySameDir() | 425 | void AdvancedFm::copySameDir() |
426 | { | 426 | { |
427 | qApp->processEvents(); | 427 | qApp->processEvents(); |
428 | QStringList curFileList = getPath(); | 428 | QStringList curFileList = getPath(); |
429 | QString curFile, item, destFile; | 429 | QString curFile, item, destFile; |
430 | InputDialog *fileDlg; | 430 | InputDialog *fileDlg; |
431 | 431 | ||
432 | QDir *thisDir = CurrentDir(); | 432 | QDir *thisDir = CurrentDir(); |
433 | 433 | ||
434 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 434 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
435 | { | 435 | { |
436 | item=(*it); | 436 | item=(*it); |
437 | curFile = thisDir->canonicalPath()+"/"+ item; | 437 | curFile = thisDir->canonicalPath()+"/"+ item; |
438 | 438 | ||
439 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 439 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
440 | fileDlg->setInputText((const QString &) destFile ); | 440 | fileDlg->setInputText((const QString &) destFile ); |
441 | fileDlg->exec(); | 441 | fileDlg->exec(); |
442 | 442 | ||
443 | if( fileDlg->result() == 1 ) | 443 | if( fileDlg->result() == 1 ) |
444 | { | 444 | { |
445 | 445 | ||
446 | QString filename = fileDlg->LineEdit1->text(); | 446 | QString filename = fileDlg->LineEdit1->text(); |
447 | destFile = thisDir->canonicalPath()+"/"+filename; | 447 | destFile = thisDir->canonicalPath()+"/"+filename; |
448 | 448 | ||
449 | QFile f(destFile); | 449 | QFile f(destFile); |
450 | if( f.exists()) | 450 | if( f.exists()) |
451 | { | 451 | { |
452 | switch (QMessageBox::warning(this,tr("Delete"), | 452 | switch (QMessageBox::warning(this,tr("Delete"), |
453 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 453 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
454 | tr("Yes"),tr("No"),0,0,1) ) { | 454 | tr("Yes"),tr("No"),0,0,1) ) { |
455 | case 0: | 455 | case 0: |
456 | 456 | ||
457 | f.remove(); | 457 | f.remove(); |
458 | break; | 458 | break; |
459 | case 1: | 459 | case 1: |
460 | return; | 460 | return; |
461 | break; | 461 | break; |
462 | }; | 462 | }; |
463 | } | 463 | } |
464 | if(!copyFile( curFile,destFile) ) | 464 | if(!copyFile( curFile,destFile) ) |
465 | { | 465 | { |
466 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 466 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
467 | +curFile +tr("to\n")+destFile); | 467 | +curFile +tr("to\n")+destFile); |
468 | return; | 468 | return; |
469 | } | 469 | } |
470 | 470 | ||
471 | qDebug("copy "+curFile+" as "+destFile); | 471 | qDebug("copy "+curFile+" as "+destFile); |
472 | } | 472 | } |
473 | delete fileDlg; | 473 | delete fileDlg; |
474 | } | 474 | } |