Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 76 |
1 files changed, 28 insertions, 48 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 13dad33..c553017 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -47,70 +47,70 @@ | |||
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 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 59 | currentRemoteDir.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 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 67 | currentRemoteDir.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 | populateLocalView(); | 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 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 82 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
83 | // b=FALSE; | 83 | // b=FALSE; |
84 | 84 | ||
85 | } | 85 | } |
86 | else | 86 | else |
87 | { | 87 | { |
88 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 88 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
89 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 89 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
90 | // b=TRUE; | 90 | // b=TRUE; |
91 | } | 91 | } |
92 | PopulateView(); | 92 | populateView(); |
93 | } | 93 | } |
94 | 94 | ||
95 | QString AdvancedFm::dealWithSymName(const QString &fileName) | 95 | QString AdvancedFm::dealWithSymName(const QString &fileName) |
96 | { | 96 | { |
97 | QString strItem = fileName; | 97 | QString strItem = fileName; |
98 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 98 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
99 | } | 99 | } |
100 | 100 | ||
101 | void AdvancedFm::runThis() | 101 | void AdvancedFm::runThis() |
102 | { | 102 | { |
103 | QString fs; | 103 | QString fs; |
104 | QDir *thisDir = CurrentDir(); | 104 | QDir *thisDir = CurrentDir(); |
105 | 105 | ||
106 | QString curFile = CurrentView()->currentItem()->text(0); | 106 | QString curFile = CurrentView()->currentItem()->text(0); |
107 | QString path = thisDir->canonicalPath(); | 107 | QString path = thisDir->canonicalPath(); |
108 | 108 | ||
109 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 109 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
110 | 110 | ||
111 | curFile = dealWithSymName((const QString&)curFile); | 111 | curFile = dealWithSymName((const QString&)curFile); |
112 | 112 | ||
113 | if(curFile != "../") | 113 | if(curFile != "../") |
114 | { | 114 | { |
115 | 115 | ||
116 | fs = getFileSystemType((const QString &) path); | 116 | fs = getFileSystemType((const QString &) path); |
@@ -144,177 +144,177 @@ void AdvancedFm::runThis() | |||
144 | void AdvancedFm::runText() | 144 | void AdvancedFm::runText() |
145 | { | 145 | { |
146 | QString curFile = CurrentView()->currentItem()->text(0); | 146 | QString curFile = CurrentView()->currentItem()->text(0); |
147 | if(curFile != "../") | 147 | if(curFile != "../") |
148 | { | 148 | { |
149 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 149 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
150 | curFile = dealWithSymName((const QString&)curFile); | 150 | curFile = dealWithSymName((const QString&)curFile); |
151 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; | 151 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; |
152 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 152 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
153 | e << curFile; | 153 | e << curFile; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | 156 | ||
157 | void AdvancedFm::makeDir() | 157 | void AdvancedFm::makeDir() |
158 | { | 158 | { |
159 | InputDialog *fileDlg; | 159 | InputDialog *fileDlg; |
160 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 160 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
161 | fileDlg->exec(); | 161 | fileDlg->exec(); |
162 | if( fileDlg->result() == 1 ) | 162 | if( fileDlg->result() == 1 ) |
163 | { | 163 | { |
164 | QDir *thisDir = CurrentDir(); | 164 | QDir *thisDir = CurrentDir(); |
165 | QString filename = fileDlg->LineEdit1->text(); | 165 | QString filename = fileDlg->LineEdit1->text(); |
166 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 166 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
167 | } | 167 | } |
168 | PopulateView(); | 168 | populateView(); |
169 | } | 169 | } |
170 | 170 | ||
171 | void AdvancedFm::doDelete() | 171 | void AdvancedFm::doDelete() |
172 | { | 172 | { |
173 | 173 | ||
174 | QStringList curFileList = getPath(); | 174 | QStringList curFileList = getPath(); |
175 | bool doMsg=true; | 175 | bool doMsg=true; |
176 | int count = curFileList.count(); | 176 | int count = curFileList.count(); |
177 | if( count > 0) | 177 | if( count > 0) |
178 | { | 178 | { |
179 | if(count > 1 ) | 179 | if(count > 1 ) |
180 | { | 180 | { |
181 | QString msg; | 181 | QString msg; |
182 | msg=tr("Really delete\n%1 files?").arg(count); | 182 | msg=tr("Really delete\n%1 files?").arg(count); |
183 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 183 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
184 | ,tr("Yes"),tr("No"),0,0,1) ) | 184 | ,tr("Yes"),tr("No"),0,0,1) ) |
185 | { | 185 | { |
186 | case 0: | 186 | case 0: |
187 | doMsg=false; | 187 | doMsg=false; |
188 | break; | 188 | break; |
189 | case 1: | 189 | case 1: |
190 | return; | 190 | return; |
191 | break; | 191 | break; |
192 | }; | 192 | }; |
193 | } | 193 | } |
194 | 194 | ||
195 | QString myFile; | 195 | QString myFile; |
196 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 196 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
197 | { | 197 | { |
198 | myFile = (*it); | 198 | myFile = (*it); |
199 | if( myFile.find(" -> ",0,TRUE) != -1) | 199 | if( myFile.find(" -> ",0,TRUE) != -1) |
200 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 200 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
201 | 201 | ||
202 | QString f = CurrentDir()->canonicalPath(); | 202 | QString f = CurrentDir()->canonicalPath(); |
203 | if(f.right(1).find("/",0,TRUE) == -1) | 203 | if(f.right(1).find("/",0,TRUE) == -1) |
204 | f += "/"; | 204 | f += "/"; |
205 | f += myFile; | 205 | f += myFile; |
206 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) | 206 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) |
207 | { | 207 | { |
208 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + | 208 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + |
209 | "\nand all it's contents ?" | 209 | "\nand all it's contents ?" |
210 | ,tr("Yes"),tr("No"),0,0,1) ) | 210 | ,tr("Yes"),tr("No"),0,0,1) ) |
211 | { | 211 | { |
212 | case 0: | 212 | case 0: |
213 | { | 213 | { |
214 | f=f.left(f.length()-1); | 214 | f=f.left(f.length()-1); |
215 | QString cmd="rm -rf "+f; | 215 | QString cmd="rm -rf "+f; |
216 | startProcess( (const QString)cmd.latin1() ); | 216 | startProcess( (const QString)cmd.latin1() ); |
217 | PopulateView(); | 217 | populateView(); |
218 | } | 218 | } |
219 | break; | 219 | break; |
220 | case 1: | 220 | case 1: |
221 | // exit | 221 | // exit |
222 | break; | 222 | break; |
223 | }; | 223 | }; |
224 | 224 | ||
225 | } else { | 225 | } else { |
226 | if(doMsg) { | 226 | if(doMsg) { |
227 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f | 227 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f |
228 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 228 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
229 | case 1: | 229 | case 1: |
230 | return; | 230 | return; |
231 | break; | 231 | break; |
232 | }; | 232 | }; |
233 | } | 233 | } |
234 | QString cmd="rm "+f; | 234 | QString cmd="rm "+f; |
235 | QFile file(f); | 235 | QFile file(f); |
236 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) | 236 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) |
237 | file.remove(); | 237 | file.remove(); |
238 | } | 238 | } |
239 | } | 239 | } |
240 | } | 240 | } |
241 | PopulateView(); | 241 | populateView(); |
242 | } | 242 | } |
243 | 243 | ||
244 | void AdvancedFm::filePerms() | 244 | void AdvancedFm::filePerms() |
245 | { | 245 | { |
246 | QStringList curFileList = getPath(); | 246 | QStringList curFileList = getPath(); |
247 | QString filePath; | 247 | QString filePath; |
248 | 248 | ||
249 | filePath = CurrentDir()->canonicalPath()+"/"; | 249 | filePath = CurrentDir()->canonicalPath()+"/"; |
250 | 250 | ||
251 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 251 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
252 | { | 252 | { |
253 | filePermissions *filePerm; | 253 | filePermissions *filePerm; |
254 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 254 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
255 | filePerm->showMaximized(); | 255 | filePerm->showMaximized(); |
256 | filePerm->exec(); | 256 | filePerm->exec(); |
257 | if( filePerm) | 257 | if( filePerm) |
258 | delete filePerm; | 258 | delete filePerm; |
259 | } | 259 | } |
260 | PopulateView(); | 260 | populateView(); |
261 | } | 261 | } |
262 | 262 | ||
263 | void AdvancedFm::doProperties() | 263 | void AdvancedFm::doProperties() |
264 | { | 264 | { |
265 | #if defined(QT_QWS_OPIE) | 265 | #if defined(QT_QWS_OPIE) |
266 | 266 | ||
267 | QStringList curFileList = getPath(); | 267 | QStringList curFileList = getPath(); |
268 | 268 | ||
269 | QString filePath; | 269 | QString filePath; |
270 | filePath = CurrentDir()->canonicalPath()+"/"; | 270 | filePath = CurrentDir()->canonicalPath()+"/"; |
271 | 271 | ||
272 | qDebug("%d",curFileList.count()); | 272 | qDebug("%d",curFileList.count()); |
273 | 273 | ||
274 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 274 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
275 | { | 275 | { |
276 | qDebug((filePath+*it)); | 276 | qDebug((filePath+*it)); |
277 | DocLnk lnk( (filePath+*it)); | 277 | DocLnk lnk( (filePath+*it)); |
278 | LnkProperties prop( &lnk ); | 278 | LnkProperties prop( &lnk ); |
279 | prop.showMaximized(); | 279 | prop.showMaximized(); |
280 | prop.exec(); | 280 | prop.exec(); |
281 | } | 281 | } |
282 | #endif | 282 | #endif |
283 | 283 | ||
284 | } | 284 | } |
285 | 285 | ||
286 | void AdvancedFm::upDir() | 286 | void AdvancedFm::upDir() |
287 | { | 287 | { |
288 | QDir *thisDir = CurrentDir(); | 288 | QDir *thisDir = CurrentDir(); |
289 | QString current = thisDir->canonicalPath(); | 289 | QString current = thisDir->canonicalPath(); |
290 | QDir dir(current); | 290 | QDir dir(current); |
291 | dir.cdUp(); | 291 | dir.cdUp(); |
292 | current = dir.canonicalPath(); | 292 | current = dir.canonicalPath(); |
293 | chdir( current.latin1() ); | 293 | chdir( current.latin1() ); |
294 | thisDir->cd( current, TRUE); | 294 | thisDir->cd( current, TRUE); |
295 | 295 | ||
296 | PopulateView(); | 296 | populateView(); |
297 | update(); | 297 | update(); |
298 | } | 298 | } |
299 | 299 | ||
300 | void AdvancedFm::copy() | 300 | void AdvancedFm::copy() |
301 | { | 301 | { |
302 | qApp->processEvents(); | 302 | qApp->processEvents(); |
303 | QStringList curFileList = getPath(); | 303 | QStringList curFileList = getPath(); |
304 | 304 | ||
305 | QDir *thisDir = CurrentDir(); | 305 | QDir *thisDir = CurrentDir(); |
306 | QDir *thatDir = OtherDir(); | 306 | QDir *thatDir = OtherDir(); |
307 | 307 | ||
308 | bool doMsg=true; | 308 | bool doMsg=true; |
309 | int count=curFileList.count(); | 309 | int count=curFileList.count(); |
310 | if( count > 0) { | 310 | if( count > 0) { |
311 | if(count > 1 ){ | 311 | if(count > 1 ){ |
312 | QString msg; | 312 | QString msg; |
313 | msg=tr("Really copy\n%1 files?").arg(count); | 313 | msg=tr("Really copy\n%1 files?").arg(count); |
314 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 314 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
315 | ,tr("Yes"),tr("No"),0,0,1) ) | 315 | ,tr("Yes"),tr("No"),0,0,1) ) |
316 | { | 316 | { |
317 | case 0: | 317 | case 0: |
318 | doMsg=false; | 318 | doMsg=false; |
319 | break; | 319 | break; |
320 | case 1: | 320 | case 1: |
@@ -339,51 +339,50 @@ void AdvancedFm::copy() | |||
339 | QFile f(destFile); | 339 | QFile f(destFile); |
340 | if( f.exists()) | 340 | if( f.exists()) |
341 | { | 341 | { |
342 | if(doMsg) | 342 | if(doMsg) |
343 | { | 343 | { |
344 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 344 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
345 | tr("%1 exists. Ok to overwrite?").arg( item ), | 345 | tr("%1 exists. Ok to overwrite?").arg( item ), |
346 | tr("Yes"),tr("No"),0,0,1) ) | 346 | tr("Yes"),tr("No"),0,0,1) ) |
347 | { | 347 | { |
348 | case 1: | 348 | case 1: |
349 | return; | 349 | return; |
350 | break; | 350 | break; |
351 | }; | 351 | }; |
352 | } | 352 | } |
353 | f.remove(); | 353 | f.remove(); |
354 | } | 354 | } |
355 | 355 | ||
356 | if( !copyFile( curFile, destFile) ) | 356 | if( !copyFile( curFile, destFile) ) |
357 | { | 357 | { |
358 | QMessageBox::message("AdvancedFm", | 358 | QMessageBox::message("AdvancedFm", |
359 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 359 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); |
360 | return; | 360 | return; |
361 | } | 361 | } |
362 | } | 362 | } |
363 | 363 | setOtherTabCurrent(); | |
364 | PopulateView(); | 364 | populateView(); |
365 | // TabWidget->setCurrentTab(1); | ||
366 | } | 365 | } |
367 | } | 366 | } |
368 | 367 | ||
369 | void AdvancedFm::copyAs() | 368 | void AdvancedFm::copyAs() |
370 | { | 369 | { |
371 | qApp->processEvents(); | 370 | qApp->processEvents(); |
372 | 371 | ||
373 | QStringList curFileList = getPath(); | 372 | QStringList curFileList = getPath(); |
374 | QString curFile, item; | 373 | QString curFile, item; |
375 | InputDialog *fileDlg; | 374 | InputDialog *fileDlg; |
376 | 375 | ||
377 | QDir *thisDir = CurrentDir(); | 376 | QDir *thisDir = CurrentDir(); |
378 | QDir *thatDir = OtherDir(); | 377 | QDir *thatDir = OtherDir(); |
379 | 378 | ||
380 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 379 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
381 | { | 380 | { |
382 | QString destFile; | 381 | QString destFile; |
383 | item=(*it); | 382 | item=(*it); |
384 | curFile = thisDir->canonicalPath()+"/"+(*it); | 383 | curFile = thisDir->canonicalPath()+"/"+(*it); |
385 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); | 384 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); |
386 | 385 | ||
387 | fileDlg->setInputText((const QString &) destFile ); | 386 | fileDlg->setInputText((const QString &) destFile ); |
388 | fileDlg->exec(); | 387 | fileDlg->exec(); |
389 | 388 | ||
@@ -396,49 +395,50 @@ void AdvancedFm::copyAs() | |||
396 | if( f.exists()) | 395 | if( f.exists()) |
397 | { | 396 | { |
398 | switch (QMessageBox::warning(this,tr("File Exists!"), | 397 | switch (QMessageBox::warning(this,tr("File Exists!"), |
399 | item+tr("\nexists. Ok to overwrite?"), | 398 | item+tr("\nexists. Ok to overwrite?"), |
400 | tr("Yes"),tr("No"),0,0,1) ) | 399 | tr("Yes"),tr("No"),0,0,1) ) |
401 | { | 400 | { |
402 | case 0: | 401 | case 0: |
403 | f.remove(); | 402 | f.remove(); |
404 | break; | 403 | break; |
405 | case 1: | 404 | case 1: |
406 | return; | 405 | return; |
407 | break; | 406 | break; |
408 | }; | 407 | }; |
409 | } | 408 | } |
410 | if( !copyFile( curFile, destFile) ) | 409 | if( !copyFile( curFile, destFile) ) |
411 | { | 410 | { |
412 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 411 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
413 | +curFile +tr("to\n")+destFile); | 412 | +curFile +tr("to\n")+destFile); |
414 | return; | 413 | return; |
415 | } | 414 | } |
416 | } | 415 | } |
417 | delete fileDlg; | 416 | delete fileDlg; |
418 | 417 | ||
419 | } | 418 | } |
420 | PopulateView(); | 419 | setOtherTabCurrent(); |
420 | populateView(); | ||
421 | } | 421 | } |
422 | 422 | ||
423 | void AdvancedFm::copySameDir() | 423 | void AdvancedFm::copySameDir() |
424 | { | 424 | { |
425 | qApp->processEvents(); | 425 | qApp->processEvents(); |
426 | QStringList curFileList = getPath(); | 426 | QStringList curFileList = getPath(); |
427 | QString curFile, item, destFile; | 427 | QString curFile, item, destFile; |
428 | InputDialog *fileDlg; | 428 | InputDialog *fileDlg; |
429 | 429 | ||
430 | QDir *thisDir = CurrentDir(); | 430 | QDir *thisDir = CurrentDir(); |
431 | 431 | ||
432 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 432 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
433 | { | 433 | { |
434 | item=(*it); | 434 | item=(*it); |
435 | curFile = thisDir->canonicalPath()+"/"+ item; | 435 | curFile = thisDir->canonicalPath()+"/"+ item; |
436 | 436 | ||
437 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 437 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
438 | fileDlg->setInputText((const QString &) destFile ); | 438 | fileDlg->setInputText((const QString &) destFile ); |
439 | fileDlg->exec(); | 439 | fileDlg->exec(); |
440 | 440 | ||
441 | if( fileDlg->result() == 1 ) | 441 | if( fileDlg->result() == 1 ) |
442 | { | 442 | { |
443 | 443 | ||
444 | QString filename = fileDlg->LineEdit1->text(); | 444 | QString filename = fileDlg->LineEdit1->text(); |
@@ -449,92 +449,93 @@ void AdvancedFm::copySameDir() | |||
449 | { | 449 | { |
450 | switch (QMessageBox::warning(this,tr("Delete"), | 450 | switch (QMessageBox::warning(this,tr("Delete"), |
451 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 451 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
452 | tr("Yes"),tr("No"),0,0,1) ) { | 452 | tr("Yes"),tr("No"),0,0,1) ) { |
453 | case 0: | 453 | case 0: |
454 | 454 | ||
455 | f.remove(); | 455 | f.remove(); |
456 | break; | 456 | break; |
457 | case 1: | 457 | case 1: |
458 | return; | 458 | return; |
459 | break; | 459 | break; |
460 | }; | 460 | }; |
461 | } | 461 | } |
462 | if(!copyFile( curFile,destFile) ) | 462 | if(!copyFile( curFile,destFile) ) |
463 | { | 463 | { |
464 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 464 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
465 | +curFile +tr("to\n")+destFile); | 465 | +curFile +tr("to\n")+destFile); |
466 | return; | 466 | return; |
467 | } | 467 | } |
468 | 468 | ||
469 | qDebug("copy "+curFile+" as "+destFile); | 469 | qDebug("copy "+curFile+" as "+destFile); |
470 | } | 470 | } |
471 | delete fileDlg; | 471 | delete fileDlg; |
472 | } | 472 | } |
473 | PopulateView(); | 473 | populateView(); |
474 | } | 474 | } |
475 | 475 | ||
476 | void AdvancedFm::move() | 476 | void AdvancedFm::move() |
477 | { | 477 | { |
478 | qApp->processEvents(); | 478 | qApp->processEvents(); |
479 | 479 | ||
480 | QStringList curFileList = getPath(); | 480 | QStringList curFileList = getPath(); |
481 | if( curFileList.count() > 0) | 481 | if( curFileList.count() > 0) |
482 | { | 482 | { |
483 | QString curFile, destFile, item; | 483 | QString curFile, destFile, item; |
484 | 484 | ||
485 | QDir *thisDir = CurrentDir(); | 485 | QDir *thisDir = CurrentDir(); |
486 | QDir *thatDir = OtherDir(); | 486 | QDir *thatDir = OtherDir(); |
487 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 487 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
488 | { | 488 | { |
489 | item=(*it); | 489 | item=(*it); |
490 | QString destFile = thatDir->canonicalPath(); | 490 | QString destFile = thatDir->canonicalPath(); |
491 | 491 | ||
492 | if(destFile.right(1).find("/",0,TRUE) == -1) | 492 | if(destFile.right(1).find("/",0,TRUE) == -1) |
493 | destFile+="/"; | 493 | destFile+="/"; |
494 | destFile += item; | 494 | destFile += item; |
495 | qDebug("Destination file is "+destFile); | 495 | qDebug("Destination file is "+destFile); |
496 | 496 | ||
497 | curFile = thisDir->canonicalPath(); | 497 | curFile = thisDir->canonicalPath(); |
498 | if(curFile.right(1).find("/",0,TRUE) == -1) | 498 | if(curFile.right(1).find("/",0,TRUE) == -1) |
499 | curFile +="/"; | 499 | curFile +="/"; |
500 | curFile+= item; | 500 | curFile+= item; |
501 | qDebug("CurrentFile file is " + curFile); | 501 | qDebug("CurrentFile file is " + curFile); |
502 | 502 | ||
503 | QFile f( curFile); | 503 | QFile f( curFile); |
504 | if( f.exists()) { | 504 | if( f.exists()) { |
505 | if( !copyFile( curFile, destFile) ) | 505 | if( !copyFile( curFile, destFile) ) |
506 | { | 506 | { |
507 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 507 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
508 | return; | 508 | return; |
509 | } else | 509 | } else |
510 | QFile::remove(curFile); | 510 | QFile::remove(curFile); |
511 | } | 511 | } |
512 | } | 512 | } |
513 | 513 | ||
514 | } | 514 | } |
515 | populateRemoteView(); | 515 | setOtherTabCurrent(); |
516 | populateLocalView(); | 516 | populateView(); |
517 | // populateLocalView(); | ||
517 | } | 518 | } |
518 | 519 | ||
519 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | 520 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) |
520 | { | 521 | { |
521 | char bf[ 50000 ]; | 522 | char bf[ 50000 ]; |
522 | int bytesRead; | 523 | int bytesRead; |
523 | bool success = TRUE; | 524 | bool success = TRUE; |
524 | struct stat status; | 525 | struct stat status; |
525 | 526 | ||
526 | QFile s( src ); | 527 | QFile s( src ); |
527 | QFile d( dest ); | 528 | QFile d( dest ); |
528 | 529 | ||
529 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) | 530 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) |
530 | { | 531 | { |
531 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) | 532 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) |
532 | { | 533 | { |
533 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 534 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
534 | success = FALSE; | 535 | success = FALSE; |
535 | break; | 536 | break; |
536 | } | 537 | } |
537 | } | 538 | } |
538 | if( success && (bytesRead > 0) ) | 539 | if( success && (bytesRead > 0) ) |
539 | { | 540 | { |
540 | d.writeBlock( bf, bytesRead ); | 541 | d.writeBlock( bf, bytesRead ); |
@@ -622,105 +623,84 @@ void AdvancedFm::fileStatus() | |||
622 | } | 623 | } |
623 | 624 | ||
624 | 625 | ||
625 | void AdvancedFm::mkDir() | 626 | void AdvancedFm::mkDir() |
626 | { | 627 | { |
627 | makeDir(); | 628 | makeDir(); |
628 | } | 629 | } |
629 | 630 | ||
630 | void AdvancedFm::rn() | 631 | void AdvancedFm::rn() |
631 | { | 632 | { |
632 | renameIt(); | 633 | renameIt(); |
633 | } | 634 | } |
634 | 635 | ||
635 | void AdvancedFm::del() | 636 | void AdvancedFm::del() |
636 | { | 637 | { |
637 | doDelete(); | 638 | doDelete(); |
638 | } | 639 | } |
639 | 640 | ||
640 | void AdvancedFm::mkSym() | 641 | void AdvancedFm::mkSym() |
641 | { | 642 | { |
642 | QString cmd; | 643 | QString cmd; |
643 | QStringList curFileList = getPath(); | 644 | QStringList curFileList = getPath(); |
644 | if( curFileList.count() > 0) | 645 | if( curFileList.count() > 0) |
645 | { | 646 | { |
646 | if ( whichTab == 1) | 647 | QDir *thisDir = CurrentDir(); |
647 | { | 648 | QDir * thatDir = OtherDir(); |
648 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | ||
649 | { | ||
650 | 649 | ||
651 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); | ||
652 | if(destName.right(1) == "/") | ||
653 | { | ||
654 | destName = destName.left( destName.length() -1); | ||
655 | } | ||
656 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | ||
657 | if( curFile.right(1) == "/") | ||
658 | { | ||
659 | curFile = curFile.left( curFile.length() -1); | ||
660 | } | ||
661 | cmd = "ln -s "+curFile+" "+destName; | ||
662 | qDebug(cmd); | ||
663 | startProcess( (const QString)cmd ); | ||
664 | } | ||
665 | populateRemoteView(); | ||
666 | TabWidget->setCurrentTab(1); | ||
667 | } | ||
668 | else | ||
669 | { | ||
670 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 650 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
671 | { | 651 | { |
672 | 652 | ||
673 | QString destName = currentDir.canonicalPath()+"/"+(*it); | 653 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
674 | if(destName.right(1) == "/") | 654 | if(destName.right(1) == "/") |
675 | { | 655 | { |
676 | destName = destName.left( destName.length() -1); | 656 | destName = destName.left( destName.length() -1); |
677 | } | 657 | } |
678 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 658 | |
659 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | ||
660 | |||
679 | if( curFile.right(1) == "/") | 661 | if( curFile.right(1) == "/") |
680 | { | 662 | { |
681 | curFile = curFile.left( curFile.length() -1); | 663 | curFile = curFile.left( curFile.length() -1); |
682 | } | 664 | } |
683 | 665 | ||
684 | cmd = "ln -s "+curFile+" "+destName; | 666 | cmd = "ln -s "+curFile+" "+destName; |
685 | qDebug(cmd); | 667 | qDebug(cmd); |
686 | startProcess( (const QString)cmd ); | 668 | startProcess( (const QString)cmd ); |
687 | } | 669 | } |
688 | populateLocalView(); | 670 | setOtherTabCurrent(); |
689 | TabWidget->setCurrentTab(0); | 671 | populateView(); |
690 | } | ||
691 | } | 672 | } |
692 | } | 673 | } |
693 | 674 | ||
694 | void AdvancedFm::doBeam() | 675 | void AdvancedFm::doBeam() |
695 | { | 676 | { |
696 | Ir ir; | 677 | Ir ir; |
697 | if(!ir.supported()) | 678 | if(!ir.supported()) |
698 | { | 679 | { |
699 | } | 680 | } |
700 | else | 681 | else |
701 | { | 682 | { |
702 | |||
703 | QStringList curFileList = getPath(); | 683 | QStringList curFileList = getPath(); |
704 | if( curFileList.count() > 0) | 684 | if( curFileList.count() > 0) |
705 | { | 685 | { |
706 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 686 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
707 | { | 687 | { |
708 | 688 | ||
709 | QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); | 689 | QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); |
710 | if( curFile.right(1) == "/") | 690 | if( curFile.right(1) == "/") |
711 | { | 691 | { |
712 | curFile = curFile.left( curFile.length() -1); | 692 | curFile = curFile.left( curFile.length() -1); |
713 | } | 693 | } |
714 | Ir *file = new Ir(this, "IR"); | 694 | Ir *file = new Ir(this, "IR"); |
715 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 695 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
716 | file->send( curFile, curFile ); | 696 | file->send( curFile, curFile ); |
717 | } | 697 | } |
718 | } | 698 | } |
719 | } | 699 | } |
720 | 700 | ||
721 | } | 701 | } |
722 | 702 | ||
723 | void AdvancedFm::fileBeamFinished( Ir *) | 703 | void AdvancedFm::fileBeamFinished( Ir *) |
724 | { | 704 | { |
725 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 705 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
726 | } | 706 | } |
@@ -734,50 +714,50 @@ void AdvancedFm::selectAll() | |||
734 | // } else { | 714 | // } else { |
735 | // Remote_View->selectAll(true); | 715 | // Remote_View->selectAll(true); |
736 | // Remote_View->setSelected( Remote_View->firstChild(),false); | 716 | // Remote_View->setSelected( Remote_View->firstChild(),false); |
737 | // } | 717 | // } |
738 | } | 718 | } |
739 | 719 | ||
740 | void AdvancedFm::startProcess(const QString & cmd) | 720 | void AdvancedFm::startProcess(const QString & cmd) |
741 | { | 721 | { |
742 | QStringList command; | 722 | QStringList command; |
743 | OProcess *process; | 723 | OProcess *process; |
744 | process = new OProcess(); | 724 | process = new OProcess(); |
745 | connect(process, SIGNAL(processExited(OProcess *)), | 725 | connect(process, SIGNAL(processExited(OProcess *)), |
746 | this, SLOT( processEnded())); | 726 | this, SLOT( processEnded())); |
747 | 727 | ||
748 | command << "/bin/sh"; | 728 | command << "/bin/sh"; |
749 | command << "-c"; | 729 | command << "-c"; |
750 | command << cmd.latin1(); | 730 | command << cmd.latin1(); |
751 | *process << command; | 731 | *process << command; |
752 | if(!process->start(OProcess::NotifyOnExit) ) | 732 | if(!process->start(OProcess::NotifyOnExit) ) |
753 | qDebug("could not start process"); | 733 | qDebug("could not start process"); |
754 | } | 734 | } |
755 | 735 | ||
756 | void AdvancedFm::processEnded() | 736 | void AdvancedFm::processEnded() |
757 | { | 737 | { |
758 | populateLocalView(); | 738 | // populateLocalView(); |
759 | populateRemoteView(); | 739 | populateView(); |
760 | } | 740 | } |
761 | 741 | ||
762 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) | 742 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) |
763 | { | 743 | { |
764 | if ( o->inherits( "QLineEdit" ) ) | 744 | if ( o->inherits( "QLineEdit" ) ) |
765 | { | 745 | { |
766 | if ( e->type() == QEvent::KeyPress ) | 746 | if ( e->type() == QEvent::KeyPress ) |
767 | { | 747 | { |
768 | QKeyEvent *ke = (QKeyEvent*)e; | 748 | QKeyEvent *ke = (QKeyEvent*)e; |
769 | if ( ke->key() == Key_Return || | 749 | if ( ke->key() == Key_Return || |
770 | ke->key() == Key_Enter ) | 750 | ke->key() == Key_Enter ) |
771 | { | 751 | { |
772 | okRename(); | 752 | okRename(); |
773 | return true; | 753 | return true; |
774 | } | 754 | } |
775 | else if ( ke->key() == Key_Escape ) | 755 | else if ( ke->key() == Key_Escape ) |
776 | { | 756 | { |
777 | cancelRename(); | 757 | cancelRename(); |
778 | return true; | 758 | return true; |
779 | } | 759 | } |
780 | } | 760 | } |
781 | else if ( e->type() == QEvent::FocusOut ) | 761 | else if ( e->type() == QEvent::FocusOut ) |
782 | { | 762 | { |
783 | cancelRename(); | 763 | cancelRename(); |
@@ -822,48 +802,48 @@ void AdvancedFm::doRename(QListView * view) | |||
822 | if ( r.width() > view->visibleWidth() ) | 802 | if ( r.width() > view->visibleWidth() ) |
823 | r.setWidth( view->visibleWidth() ); | 803 | r.setWidth( view->visibleWidth() ); |
824 | 804 | ||
825 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 805 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
826 | renameBox->setFrame(true); | 806 | renameBox->setFrame(true); |
827 | 807 | ||
828 | renameBox->setText( view->currentItem()->text(0) ); | 808 | renameBox->setText( view->currentItem()->text(0) ); |
829 | 809 | ||
830 | renameBox->selectAll(); | 810 | renameBox->selectAll(); |
831 | renameBox->installEventFilter( this ); | 811 | renameBox->installEventFilter( this ); |
832 | view->addChild( renameBox, r.x(), r.y() ); | 812 | view->addChild( renameBox, r.x(), r.y() ); |
833 | renameBox->resize( r.size() ); | 813 | renameBox->resize( r.size() ); |
834 | view->viewport()->setFocusProxy( renameBox ); | 814 | view->viewport()->setFocusProxy( renameBox ); |
835 | renameBox->setFocus(); | 815 | renameBox->setFocus(); |
836 | renameBox->show(); | 816 | renameBox->show(); |
837 | 817 | ||
838 | } | 818 | } |
839 | 819 | ||
840 | 820 | ||
841 | void AdvancedFm::renameIt() | 821 | void AdvancedFm::renameIt() |
842 | { | 822 | { |
843 | QListView *thisView = CurrentView(); | 823 | QListView *thisView = CurrentView(); |
844 | oldName = thisView->currentItem()->text(0); | 824 | oldName = thisView->currentItem()->text(0); |
845 | doRename( thisView ); | 825 | doRename( thisView ); |
846 | PopulateView(); | 826 | populateView(); |
847 | } | 827 | } |
848 | 828 | ||
849 | void AdvancedFm::okRename() | 829 | void AdvancedFm::okRename() |
850 | { | 830 | { |
851 | QString newName = renameBox->text(); | 831 | QString newName = renameBox->text(); |
852 | cancelRename(); | 832 | cancelRename(); |
853 | //int tabs=0; | 833 | //int tabs=0; |
854 | QListView * view = CurrentView(); | 834 | QListView * view = CurrentView(); |
855 | QString path = CurrentDir()->canonicalPath() + "/"; | 835 | QString path = CurrentDir()->canonicalPath() + "/"; |
856 | oldName = path + oldName; | 836 | oldName = path + oldName; |
857 | newName = path + newName; | 837 | newName = path + newName; |
858 | 838 | ||
859 | if( view->currentItem() == NULL) | 839 | if( view->currentItem() == NULL) |
860 | return; | 840 | return; |
861 | if( rename( oldName.latin1(), newName.latin1())== -1) | 841 | if( rename( oldName.latin1(), newName.latin1())== -1) |
862 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 842 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
863 | else | 843 | else |
864 | oldName = ""; | 844 | oldName = ""; |
865 | 845 | ||
866 | view->takeItem( view->currentItem() ); | 846 | view->takeItem( view->currentItem() ); |
867 | delete view->currentItem(); | 847 | delete view->currentItem(); |
868 | PopulateView(); | 848 | populateView(); |
869 | } | 849 | } |