-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index f25048a..8b98898 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -109,760 +109,762 @@ void AdvancedFm::runThis() { | |||
109 | QString execStr = nf.exec(); | 109 | QString execStr = nf.exec(); |
110 | // odebug << execStr << oendl; | 110 | // odebug << execStr << oendl; |
111 | if( execStr.isEmpty() ) { | 111 | if( execStr.isEmpty() ) { |
112 | } else { | 112 | } else { |
113 | nf.execute(); | 113 | nf.execute(); |
114 | } | 114 | } |
115 | } | 115 | } |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | void AdvancedFm::runText() { | 119 | void AdvancedFm::runText() { |
120 | if( !CurrentView()->currentItem()) return; | 120 | if( !CurrentView()->currentItem()) return; |
121 | QString curFile = CurrentView()->currentItem()->text(0); | 121 | QString curFile = CurrentView()->currentItem()->text(0); |
122 | if(curFile != "../") { | 122 | if(curFile != "../") { |
123 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 123 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
124 | curFile = dealWithSymName((const QString&)curFile); | 124 | curFile = dealWithSymName((const QString&)curFile); |
125 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; | 125 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; |
126 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 126 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
127 | e << curFile; | 127 | e << curFile; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | void AdvancedFm::makeDir() { | 131 | void AdvancedFm::makeDir() { |
132 | InputDialog *fileDlg; | 132 | InputDialog *fileDlg; |
133 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 133 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
134 | fileDlg->exec(); | 134 | fileDlg->exec(); |
135 | if( fileDlg->result() == 1 ) { | 135 | if( fileDlg->result() == 1 ) { |
136 | QDir *thisDir = CurrentDir(); | 136 | QDir *thisDir = CurrentDir(); |
137 | QString filename = fileDlg->LineEdit1->text(); | 137 | QString filename = fileDlg->LineEdit1->text(); |
138 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 138 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
139 | } | 139 | } |
140 | populateView(); | 140 | populateView(); |
141 | } | 141 | } |
142 | 142 | ||
143 | void AdvancedFm::doDelete() { | 143 | void AdvancedFm::doDelete() { |
144 | QStringList curFileList = getPath(); | 144 | QStringList curFileList = getPath(); |
145 | bool doMsg=true; | 145 | bool doMsg=true; |
146 | int count = curFileList.count(); | 146 | int count = curFileList.count(); |
147 | if( count > 0) { | 147 | if( count > 0) { |
148 | if(count > 1 ) { | 148 | if(count > 1 ) { |
149 | QString msg; | 149 | QString msg; |
150 | msg=tr("<p>Really delete %1 files?</p>").arg(count); | 150 | msg=tr("<p>Really delete %1 files?</p>").arg(count); |
151 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 151 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
152 | ,tr("Yes"),tr("No"),0,0,1) ) | 152 | ,tr("Yes"),tr("No"),0,0,1) ) |
153 | { | 153 | { |
154 | case 0: | 154 | case 0: |
155 | doMsg=false; | 155 | doMsg=false; |
156 | break; | 156 | break; |
157 | case 1: | 157 | case 1: |
158 | return; | 158 | return; |
159 | break; | 159 | break; |
160 | default: | 160 | default: |
161 | return; | 161 | return; |
162 | break; | 162 | break; |
163 | }; | 163 | }; |
164 | } | 164 | } |
165 | 165 | ||
166 | QString myFile; | 166 | QString myFile; |
167 | 167 | ||
168 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 168 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
169 | myFile = (*it); | 169 | myFile = (*it); |
170 | if( myFile.find(" -> ",0,TRUE) != -1) | 170 | if( myFile.find(" -> ",0,TRUE) != -1) |
171 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 171 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
172 | 172 | ||
173 | QString f = CurrentDir()->canonicalPath(); | 173 | QString f = CurrentDir()->canonicalPath(); |
174 | if(f.right(1).find("/",0,TRUE) == -1) | 174 | if(f.right(1).find("/",0,TRUE) == -1) |
175 | f += "/"; | 175 | f += "/"; |
176 | f += myFile; | 176 | f += myFile; |
177 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 177 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
178 | //if file is a directory | 178 | //if file is a directory |
179 | 179 | ||
180 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), | 180 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), |
181 | tr("<p>Really delete %1 and all it's contents?</p>" ).arg( f ) , | 181 | tr("<p>Really delete %1 and all it's contents?</p>" ).arg( f ) , |
182 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 182 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
183 | case 0: | 183 | case 0: |
184 | { | 184 | { |
185 | f=f.left(f.length()-1); | 185 | f=f.left(f.length()-1); |
186 | QString cmd="rm -rf "+f; | 186 | QString cmd="rm -rf "+f; |
187 | startProcess( (const QString)cmd.latin1() ); | 187 | startProcess( (const QString)cmd.latin1() ); |
188 | populateView(); | 188 | populateView(); |
189 | } | 189 | } |
190 | break; | 190 | break; |
191 | case 1: | 191 | case 1: |
192 | // exit | 192 | // exit |
193 | break; | 193 | break; |
194 | default: | 194 | default: |
195 | break; | 195 | break; |
196 | }; | 196 | }; |
197 | 197 | ||
198 | } else { | 198 | } else { |
199 | if(doMsg) { | 199 | if(doMsg) { |
200 | switch ( QMessageBox::warning(this,tr("Delete"), | 200 | switch ( QMessageBox::warning(this,tr("Delete"), |
201 | tr("<p>Really delete %1?</p>").arg( myFile ), | 201 | tr("<p>Really delete %1?</p>").arg( myFile ), |
202 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 202 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
203 | case 1: | 203 | case 1: |
204 | return; | 204 | return; |
205 | break; | 205 | break; |
206 | default: | 206 | default: |
207 | return; | 207 | return; |
208 | break; | 208 | break; |
209 | }; | 209 | }; |
210 | } | 210 | } |
211 | 211 | ||
212 | QString cmd="rm "+f; | 212 | QString cmd="rm "+f; |
213 | QFile file(f); | 213 | QFile file(f); |
214 | QFileInfo fi(myFile); | 214 | QFileInfo fi(myFile); |
215 | if( fi.fileName().find("../",0,TRUE)==-1) { | 215 | if( fi.fileName().find("../",0,TRUE)==-1) { |
216 | // odebug << "remove link files "+myFile << oendl; | 216 | // odebug << "remove link files "+myFile << oendl; |
217 | 217 | ||
218 | // DocLnk lnk(f); | 218 | // DocLnk lnk(f); |
219 | DocLnk *lnk; | 219 | DocLnk *lnk; |
220 | lnk = new DocLnk(f); | 220 | lnk = new DocLnk(f); |
221 | // odebug << "Deleting doclnk " + lnk->linkFile() << oendl; | 221 | // odebug << "Deleting doclnk " + lnk->linkFile() << oendl; |
222 | if(lnk->isValid()) | 222 | if(lnk->isValid()) |
223 | lnk->removeLinkFile(); | 223 | lnk->removeLinkFile(); |
224 | // delete lnk; | 224 | // delete lnk; |
225 | file.remove(); | 225 | file.remove(); |
226 | } | 226 | } |
227 | } | 227 | } |
228 | } | 228 | } |
229 | } | 229 | } |
230 | populateView(); | 230 | populateView(); |
231 | } | 231 | } |
232 | 232 | ||
233 | void AdvancedFm::filePerms() { | 233 | void AdvancedFm::filePerms() { |
234 | QStringList curFileList = getPath(); | 234 | QStringList curFileList = getPath(); |
235 | QString filePath; | 235 | QString filePath; |
236 | 236 | ||
237 | filePath = CurrentDir()->canonicalPath()+"/"; | 237 | filePath = CurrentDir()->canonicalPath()+"/"; |
238 | 238 | ||
239 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 239 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
240 | filePermissions *filePerm; | 240 | filePermissions *filePerm; |
241 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 241 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
242 | QPEApplication::execDialog( filePerm ); | 242 | QPEApplication::execDialog( filePerm ); |
243 | if( filePerm ) | 243 | if( filePerm ) |
244 | delete filePerm; | 244 | delete filePerm; |
245 | } | 245 | } |
246 | populateView(); | 246 | populateView(); |
247 | } | 247 | } |
248 | 248 | ||
249 | void AdvancedFm::doProperties() { | 249 | void AdvancedFm::doProperties() { |
250 | #if defined(QT_QWS_OPIE) | 250 | #if defined(QT_QWS_OPIE) |
251 | 251 | ||
252 | QStringList curFileList = getPath(); | 252 | QStringList curFileList = getPath(); |
253 | 253 | ||
254 | QString filePath; | 254 | QString filePath; |
255 | filePath = CurrentDir()->canonicalPath()+"/"; | 255 | filePath = CurrentDir()->canonicalPath()+"/"; |
256 | 256 | ||
257 | // odebug << "" << curFileList.count() << "" << oendl; | 257 | // odebug << "" << curFileList.count() << "" << oendl; |
258 | 258 | ||
259 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 259 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
260 | // odebug << (filePath+*it) << oendl; | 260 | // odebug << (filePath+*it) << oendl; |
261 | DocLnk lnk( (filePath+*it)); | 261 | DocLnk lnk( (filePath+*it)); |
262 | LnkProperties prop( &lnk ); | 262 | LnkProperties prop( &lnk ); |
263 | QPEApplication::execDialog( &prop ); | 263 | QPEApplication::execDialog( &prop ); |
264 | } | 264 | } |
265 | #endif | 265 | #endif |
266 | 266 | ||
267 | } | 267 | } |
268 | 268 | ||
269 | void AdvancedFm::upDir() { | 269 | void AdvancedFm::upDir() { |
270 | 270 | ||
271 | QDir dir( CurrentDir()->canonicalPath()); | 271 | QDir dir( CurrentDir()->canonicalPath()); |
272 | dir.cdUp(); | 272 | dir.cdUp(); |
273 | changeTo(dir.canonicalPath()); | 273 | changeTo(dir.canonicalPath()); |
274 | } | 274 | } |
275 | 275 | ||
276 | void AdvancedFm::copyTimer() { | 276 | void AdvancedFm::copyTimer() { |
277 | QTimer::singleShot(125,this,SLOT(copy())); | 277 | QTimer::singleShot(125,this,SLOT(copy())); |
278 | } | 278 | } |
279 | 279 | ||
280 | void AdvancedFm::copy() { | 280 | void AdvancedFm::copy() { |
281 | QStringList curFileList = getPath(); | 281 | QStringList curFileList = getPath(); |
282 | 282 | ||
283 | QDir *thisDir = CurrentDir(); | 283 | QDir *thisDir = CurrentDir(); |
284 | QDir *thatDir = OtherDir(); | 284 | QDir *thatDir = OtherDir(); |
285 | 285 | ||
286 | bool doMsg = true; | 286 | bool doMsg = true; |
287 | int count = curFileList.count(); | 287 | int count = curFileList.count(); |
288 | if( count > 0) { | 288 | if( count > 0) { |
289 | if(count > 1 ){ | 289 | if(count > 1 ){ |
290 | QString msg; | 290 | QString msg; |
291 | msg=tr("<p>Really copy %1 files?</p>").arg(count); | 291 | msg=tr("<p>Really copy %1 files?</p>").arg(count); |
292 | switch ( QMessageBox::warning(this,tr("Copy"),msg | 292 | switch ( QMessageBox::warning(this,tr("Copy"),msg |
293 | ,tr("Yes"),tr("No"),0,0,1) ) | 293 | ,tr("Yes"),tr("No"),0,0,1) ) |
294 | { | 294 | { |
295 | case 0: | 295 | case 0: |
296 | doMsg=false; | 296 | doMsg=false; |
297 | break; | 297 | break; |
298 | case 1: | 298 | case 1: |
299 | return; | 299 | return; |
300 | break; | 300 | break; |
301 | default: | 301 | default: |
302 | return; | 302 | return; |
303 | break; | 303 | break; |
304 | }; | 304 | }; |
305 | } | 305 | } |
306 | 306 | ||
307 | QString curFile, item, destFile; | 307 | QString curFile, item, destFile; |
308 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 308 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
309 | item=(*it); | 309 | item=(*it); |
310 | if(item.find("->",0,TRUE)) //symlink | 310 | if(item.find("->",0,TRUE)) //symlink |
311 | item = item.left(item.find("->",0,TRUE)); | 311 | item = item.left(item.find("->",0,TRUE)); |
312 | 312 | ||
313 | curFile = thisDir->canonicalPath()+"/"+ item; | 313 | curFile = thisDir->canonicalPath()+"/"+ item; |
314 | destFile = thatDir->canonicalPath()+"/"+ item; | 314 | destFile = thatDir->canonicalPath()+"/"+ item; |
315 | 315 | ||
316 | // odebug << "Destination file is "+destFile << oendl; | 316 | // odebug << "Destination file is "+destFile << oendl; |
317 | // odebug << "CurrentFile file is " + curFile << oendl; | 317 | // odebug << "CurrentFile file is " + curFile << oendl; |
318 | 318 | ||
319 | QFile f(destFile); | 319 | QFile f(destFile); |
320 | if( f.exists()) { | 320 | if( f.exists()) { |
321 | if(doMsg) { | 321 | if(doMsg) { |
322 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 322 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
323 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), | 323 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), |
324 | tr("Yes"),tr("No"),0,0,1)) { | 324 | tr("Yes"),tr("No"),0,0,1)) { |
325 | case 1: | 325 | case 1: |
326 | return; | 326 | return; |
327 | break; | 327 | break; |
328 | default: | 328 | default: |
329 | return; | 329 | return; |
330 | break; | 330 | break; |
331 | }; | 331 | }; |
332 | } | 332 | } |
333 | f.remove(); | 333 | f.remove(); |
334 | } | 334 | } |
335 | 335 | ||
336 | if( !copyFile( curFile, destFile) ) { | 336 | if( !copyFile( curFile, destFile) ) { |
337 | QMessageBox::message("AdvancedFm", | 337 | QMessageBox::message("AdvancedFm", |
338 | tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 338 | tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
339 | return; | 339 | return; |
340 | } | 340 | } |
341 | } | 341 | } |
342 | rePopulate(); | 342 | rePopulate(); |
343 | } | 343 | } |
344 | } | 344 | } |
345 | 345 | ||
346 | void AdvancedFm::copyAsTimer() { | 346 | void AdvancedFm::copyAsTimer() { |
347 | QTimer::singleShot(125,this,SLOT(copyAs())); | 347 | QTimer::singleShot(125,this,SLOT(copyAs())); |
348 | } | 348 | } |
349 | 349 | ||
350 | void AdvancedFm::copyAs() { | 350 | void AdvancedFm::copyAs() { |
351 | 351 | ||
352 | QStringList curFileList = getPath(); | 352 | QStringList curFileList = getPath(); |
353 | QString curFile, item; | 353 | QString curFile, item; |
354 | InputDialog *fileDlg; | 354 | InputDialog *fileDlg; |
355 | 355 | ||
356 | QDir *thisDir = CurrentDir(); | 356 | QDir *thisDir = CurrentDir(); |
357 | QDir *thatDir = OtherDir(); | 357 | QDir *thatDir = OtherDir(); |
358 | 358 | ||
359 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 359 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
360 | QString destFile; | 360 | QString destFile; |
361 | item=(*it); | 361 | item=(*it); |
362 | curFile = thisDir->canonicalPath()+"/"+(*it); | 362 | curFile = thisDir->canonicalPath()+"/"+(*it); |
363 | fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); | 363 | fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); |
364 | 364 | ||
365 | fileDlg->setInputText((const QString &) destFile ); | 365 | fileDlg->setInputText((const QString &) destFile ); |
366 | fileDlg->exec(); | 366 | fileDlg->exec(); |
367 | 367 | ||
368 | if( fileDlg->result() == 1 ) { | 368 | if( fileDlg->result() == 1 ) { |
369 | QString filename = fileDlg->LineEdit1->text(); | 369 | QString filename = fileDlg->LineEdit1->text(); |
370 | destFile = thatDir->canonicalPath()+"/"+filename; | 370 | destFile = thatDir->canonicalPath()+"/"+filename; |
371 | 371 | ||
372 | QFile f( destFile); | 372 | QFile f( destFile); |
373 | if( f.exists()) { | 373 | if( f.exists()) { |
374 | switch (QMessageBox::warning(this,tr("File Exists!"), | 374 | switch (QMessageBox::warning(this,tr("File Exists!"), |
375 | tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), | 375 | tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), |
376 | tr("Yes"),tr("No"),0,0,1) ) { | 376 | tr("Yes"),tr("No"),0,0,1) ) { |
377 | case 0: | 377 | case 0: |
378 | f.remove(); | 378 | f.remove(); |
379 | break; | 379 | break; |
380 | case 1: | 380 | case 1: |
381 | return; | 381 | return; |
382 | break; | 382 | break; |
383 | default: | 383 | default: |
384 | return; | 384 | return; |
385 | break; | 385 | break; |
386 | }; | 386 | }; |
387 | } | 387 | } |
388 | if( !copyFile( curFile, destFile) ) { | 388 | if( !copyFile( curFile, destFile) ) { |
389 | QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 389 | QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
390 | return; | 390 | return; |
391 | } | 391 | } |
392 | } | 392 | } |
393 | delete fileDlg; | 393 | delete fileDlg; |
394 | 394 | ||
395 | } | 395 | } |
396 | rePopulate(); | 396 | rePopulate(); |
397 | // setOtherTabCurrent(); | 397 | // setOtherTabCurrent(); |
398 | qApp->processEvents(); | 398 | qApp->processEvents(); |
399 | 399 | ||
400 | } | 400 | } |
401 | 401 | ||
402 | void AdvancedFm::copySameDirTimer() { | 402 | void AdvancedFm::copySameDirTimer() { |
403 | QTimer::singleShot(125,this,SLOT(copySameDir())); | 403 | QTimer::singleShot(125,this,SLOT(copySameDir())); |
404 | } | 404 | } |
405 | 405 | ||
406 | void AdvancedFm::copySameDir() { | 406 | void AdvancedFm::copySameDir() { |
407 | qApp->processEvents(); | 407 | qApp->processEvents(); |
408 | QStringList curFileList = getPath(); | 408 | QStringList curFileList = getPath(); |
409 | QString curFile, item, destFile; | 409 | QString curFile, item, destFile; |
410 | InputDialog *fileDlg; | 410 | InputDialog *fileDlg; |
411 | 411 | ||
412 | QDir *thisDir = CurrentDir(); | 412 | QDir *thisDir = CurrentDir(); |
413 | 413 | ||
414 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 414 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
415 | item=(*it); | 415 | item=(*it); |
416 | curFile = thisDir->canonicalPath()+"/"+ item; | 416 | curFile = thisDir->canonicalPath()+"/"+ item; |
417 | 417 | ||
418 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 418 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
419 | fileDlg->setInputText((const QString &) destFile ); | 419 | fileDlg->setInputText((const QString &) destFile ); |
420 | fileDlg->exec(); | 420 | fileDlg->exec(); |
421 | 421 | ||
422 | if( fileDlg->result() == 1 ) { | 422 | if( fileDlg->result() == 1 ) { |
423 | 423 | ||
424 | QString filename = fileDlg->LineEdit1->text(); | 424 | QString filename = fileDlg->LineEdit1->text(); |
425 | destFile = thisDir->canonicalPath()+"/"+filename; | 425 | destFile = thisDir->canonicalPath()+"/"+filename; |
426 | 426 | ||
427 | QFile f(destFile); | 427 | QFile f(destFile); |
428 | if( f.exists()) { | 428 | if( f.exists()) { |
429 | switch (QMessageBox::warning(this,tr("Delete"), | 429 | switch (QMessageBox::warning(this,tr("Delete"), |
430 | tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), | 430 | tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), |
431 | tr("Yes"),tr("No"),0,0,1) ) { | 431 | tr("Yes"),tr("No"),0,0,1) ) { |
432 | case 0: | 432 | case 0: |
433 | 433 | ||
434 | f.remove(); | 434 | f.remove(); |
435 | break; | 435 | break; |
436 | case 1: | 436 | case 1: |
437 | return; | 437 | return; |
438 | break; | 438 | break; |
439 | default: | 439 | default: |
440 | return; | 440 | return; |
441 | break; | 441 | break; |
442 | }; | 442 | }; |
443 | } | 443 | } |
444 | if(!copyFile( curFile,destFile) ) { | 444 | if(!copyFile( curFile,destFile) ) { |
445 | QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 445 | QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
446 | return; | 446 | return; |
447 | } | 447 | } |
448 | 448 | ||
449 | // odebug << "copy "+curFile+" as "+destFile << oendl; | 449 | // odebug << "copy "+curFile+" as "+destFile << oendl; |
450 | } | 450 | } |
451 | delete fileDlg; | 451 | delete fileDlg; |
452 | } | 452 | } |
453 | rePopulate(); | 453 | rePopulate(); |
454 | } | 454 | } |
455 | 455 | ||
456 | void AdvancedFm::moveTimer() { | 456 | void AdvancedFm::moveTimer() { |
457 | QTimer::singleShot(125,this,SLOT(move())); | 457 | QTimer::singleShot(125,this,SLOT(move())); |
458 | } | 458 | } |
459 | 459 | ||
460 | void AdvancedFm::move() { | 460 | void AdvancedFm::move() { |
461 | 461 | ||
462 | QStringList curFileList = getPath(); | 462 | QStringList curFileList = getPath(); |
463 | if( curFileList.count() > 0) { | 463 | if( curFileList.count() > 0) { |
464 | QString curFile, destFile, item; | 464 | QString curFile, destFile, item; |
465 | 465 | ||
466 | QDir *thisDir = CurrentDir(); | 466 | QDir *thisDir = CurrentDir(); |
467 | QDir *thatDir = OtherDir(); | 467 | QDir *thatDir = OtherDir(); |
468 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 468 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
469 | item=(*it); | 469 | item=(*it); |
470 | QString destFile = thatDir->canonicalPath(); | 470 | QString destFile = thatDir->canonicalPath(); |
471 | 471 | ||
472 | if(destFile.right(1).find("/",0,TRUE) == -1) | 472 | if(destFile.right(1).find("/",0,TRUE) == -1) |
473 | destFile+="/"; | 473 | destFile+="/"; |
474 | destFile += item; | 474 | destFile += item; |
475 | // odebug << "Destination file is "+destFile << oendl; | 475 | // odebug << "Destination file is "+destFile << oendl; |
476 | 476 | ||
477 | curFile = thisDir->canonicalPath(); | 477 | curFile = thisDir->canonicalPath(); |
478 | if(curFile.right(1).find("/",0,TRUE) == -1) | 478 | if(curFile.right(1).find("/",0,TRUE) == -1) |
479 | curFile +="/"; | 479 | curFile +="/"; |
480 | curFile+= item; | 480 | curFile+= item; |
481 | // odebug << "CurrentFile file is " + curFile << oendl; | 481 | // odebug << "CurrentFile file is " + curFile << oendl; |
482 | 482 | ||
483 | if(QFileInfo(curFile).isDir()) { | 483 | if(QFileInfo(curFile).isDir()) { |
484 | moveDirectory( curFile, destFile ); | 484 | moveDirectory( curFile, destFile ); |
485 | rePopulate(); | 485 | rePopulate(); |
486 | return; | 486 | return; |
487 | } | 487 | } |
488 | QFile f( destFile); | 488 | QFile f( destFile); |
489 | if( f.exists()) { | 489 | if( f.exists()) { |
490 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 490 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
491 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), | 491 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), |
492 | tr("Yes"),tr("No"),0,0,1)) { | 492 | tr("Yes"),tr("No"),0,0,1)) { |
493 | case 0: | ||
494 | break; | ||
493 | case 1: | 495 | case 1: |
494 | return; | 496 | return; |
495 | break; | 497 | break; |
496 | default: | 498 | default: |
497 | return; | 499 | return; |
498 | break; | 500 | break; |
499 | }; | 501 | }; |
502 | } | ||
500 | if( !copyFile( curFile, destFile) ) { | 503 | if( !copyFile( curFile, destFile) ) { |
501 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile)); | 504 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile)); |
502 | return; | 505 | return; |
503 | } else | 506 | } else |
504 | QFile::remove(curFile); | 507 | QFile::remove(curFile); |
505 | } | ||
506 | } | 508 | } |
507 | } | 509 | } |
508 | rePopulate(); | 510 | rePopulate(); |
509 | //setOtherTabCurrent(); | 511 | //setOtherTabCurrent(); |
510 | } | 512 | } |
511 | 513 | ||
512 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { | 514 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { |
513 | int err = 0; | 515 | int err = 0; |
514 | if( copyDirectory( src, dest ) ) { | 516 | if( copyDirectory( src, dest ) ) { |
515 | QString cmd = "rm -rf " + src; | 517 | QString cmd = "rm -rf " + src; |
516 | err = system((const char*)cmd); | 518 | err = system((const char*)cmd); |
517 | } else | 519 | } else |
518 | err = -1; | 520 | err = -1; |
519 | 521 | ||
520 | if(err!=0) { | 522 | if(err!=0) { |
521 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src)); | 523 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src)); |
522 | return false; | 524 | return false; |
523 | } | 525 | } |
524 | return true; | 526 | return true; |
525 | } | 527 | } |
526 | 528 | ||
527 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { | 529 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { |
528 | 530 | ||
529 | QString cmd = "/bin/cp -fpR " + src + " " + dest; | 531 | QString cmd = "/bin/cp -fpR " + src + " " + dest; |
530 | owarn << cmd << oendl; | 532 | owarn << cmd << oendl; |
531 | int err = system( (const char *) cmd ); | 533 | int err = system( (const char *) cmd ); |
532 | if ( err != 0 ) { | 534 | if ( err != 0 ) { |
533 | QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) ); | 535 | QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) ); |
534 | return false; | 536 | return false; |
535 | } | 537 | } |
536 | 538 | ||
537 | return true; | 539 | return true; |
538 | } | 540 | } |
539 | 541 | ||
540 | 542 | ||
541 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 543 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
542 | if(QFileInfo(src).isDir()) { | 544 | if(QFileInfo(src).isDir()) { |
543 | if( copyDirectory( src, dest )) { | 545 | if( copyDirectory( src, dest )) { |
544 | // setOtherTabCurrent(); | 546 | // setOtherTabCurrent(); |
545 | rePopulate(); | 547 | rePopulate(); |
546 | return true; | 548 | return true; |
547 | } | 549 | } |
548 | else | 550 | else |
549 | return false; | 551 | return false; |
550 | } | 552 | } |
551 | 553 | ||
552 | 554 | ||
553 | bool success = true; | 555 | bool success = true; |
554 | struct stat status; | 556 | struct stat status; |
555 | QFile srcFile(src); | 557 | QFile srcFile(src); |
556 | QFile destFile(dest); | 558 | QFile destFile(dest); |
557 | int err=0; | 559 | int err=0; |
558 | int read_fd=0; | 560 | int read_fd=0; |
559 | int write_fd=0; | 561 | int write_fd=0; |
560 | struct stat stat_buf; | 562 | struct stat stat_buf; |
561 | off_t offset = 0; | 563 | off_t offset = 0; |
562 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | 564 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
563 | // owarn << "open failed" << oendl; | 565 | // owarn << "open failed" << oendl; |
564 | return success = false; | 566 | return success = false; |
565 | } | 567 | } |
566 | read_fd = srcFile.handle(); | 568 | read_fd = srcFile.handle(); |
567 | if(read_fd != -1) { | 569 | if(read_fd != -1) { |
568 | fstat (read_fd, &stat_buf); | 570 | fstat (read_fd, &stat_buf); |
569 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { | 571 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { |
570 | // owarn << "destfile open failed" << oendl; | 572 | // owarn << "destfile open failed" << oendl; |
571 | return success = false; | 573 | return success = false; |
572 | } | 574 | } |
573 | write_fd = destFile.handle(); | 575 | write_fd = destFile.handle(); |
574 | if(write_fd != -1) { | 576 | if(write_fd != -1) { |
575 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 577 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
576 | if( err == -1) { | 578 | if( err == -1) { |
577 | QString msg; | 579 | QString msg; |
578 | switch(err) { | 580 | switch(err) { |
579 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; | 581 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; |
580 | case EINVAL: msg = "Descriptor is not valid or locked. "; | 582 | case EINVAL: msg = "Descriptor is not valid or locked. "; |
581 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; | 583 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; |
582 | case EIO: msg = "Unspecified error while reading from in_fd."; | 584 | case EIO: msg = "Unspecified error while reading from in_fd."; |
583 | }; | 585 | }; |
584 | success = false; | 586 | success = false; |
585 | // owarn << msg << oendl; | 587 | // owarn << msg << oendl; |
586 | } | 588 | } |
587 | } else { | 589 | } else { |
588 | success = false; | 590 | success = false; |
589 | } | 591 | } |
590 | } else { | 592 | } else { |
591 | success = false; | 593 | success = false; |
592 | } | 594 | } |
593 | srcFile.close(); | 595 | srcFile.close(); |
594 | destFile.close(); | 596 | destFile.close(); |
595 | // Set file permissions | 597 | // Set file permissions |
596 | if( stat( QFile::encodeName(src), &status ) == 0 ) { | 598 | if( stat( QFile::encodeName(src), &status ) == 0 ) { |
597 | chmod( QFile::encodeName(dest), status.st_mode ); | 599 | chmod( QFile::encodeName(dest), status.st_mode ); |
598 | } | 600 | } |
599 | 601 | ||
600 | return success; | 602 | return success; |
601 | } | 603 | } |
602 | 604 | ||
603 | void AdvancedFm::runCommand() { | 605 | void AdvancedFm::runCommand() { |
604 | if( !CurrentView()->currentItem()) return; | 606 | if( !CurrentView()->currentItem()) return; |
605 | QDir *thisDir = CurrentDir(); | 607 | QDir *thisDir = CurrentDir(); |
606 | 608 | ||
607 | QString curFile; | 609 | QString curFile; |
608 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 610 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
609 | 611 | ||
610 | InputDialog *fileDlg; | 612 | InputDialog *fileDlg; |
611 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 613 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
612 | fileDlg->setInputText(curFile); | 614 | fileDlg->setInputText(curFile); |
613 | fileDlg->exec(); | 615 | fileDlg->exec(); |
614 | //QString command; | 616 | //QString command; |
615 | 617 | ||
616 | if( fileDlg->result() == 1 ) { | 618 | if( fileDlg->result() == 1 ) { |
617 | // odebug << fileDlg->LineEdit1->text() << oendl; | 619 | // odebug << fileDlg->LineEdit1->text() << oendl; |
618 | QStringList command; | 620 | QStringList command; |
619 | 621 | ||
620 | command << "/bin/sh"; | 622 | command << "/bin/sh"; |
621 | command << "-c"; | 623 | command << "-c"; |
622 | command << fileDlg->LineEdit1->text(); | 624 | command << fileDlg->LineEdit1->text(); |
623 | Output *outDlg; | 625 | Output *outDlg; |
624 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 626 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
625 | QPEApplication::execDialog( outDlg ); | 627 | QPEApplication::execDialog( outDlg ); |
626 | qApp->processEvents(); | 628 | qApp->processEvents(); |
627 | 629 | ||
628 | } | 630 | } |
629 | } | 631 | } |
630 | 632 | ||
631 | void AdvancedFm::runCommandStd() { | 633 | void AdvancedFm::runCommandStd() { |
632 | if( !CurrentView()->currentItem()) return; | 634 | if( !CurrentView()->currentItem()) return; |
633 | QString curFile; | 635 | QString curFile; |
634 | QDir *thisDir = CurrentDir(); | 636 | QDir *thisDir = CurrentDir(); |
635 | QListView *thisView = CurrentView(); | 637 | QListView *thisView = CurrentView(); |
636 | if( thisView->currentItem()) | 638 | if( thisView->currentItem()) |
637 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 639 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
638 | 640 | ||
639 | InputDialog *fileDlg; | 641 | InputDialog *fileDlg; |
640 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 642 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
641 | fileDlg->setInputText(curFile); | 643 | fileDlg->setInputText(curFile); |
642 | fileDlg->exec(); | 644 | fileDlg->exec(); |
643 | 645 | ||
644 | if( fileDlg->result() == 1 ) { | 646 | if( fileDlg->result() == 1 ) { |
645 | qApp->processEvents(); | 647 | qApp->processEvents(); |
646 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 648 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
647 | } | 649 | } |
648 | } | 650 | } |
649 | 651 | ||
650 | void AdvancedFm::fileStatus() { | 652 | void AdvancedFm::fileStatus() { |
651 | if( !CurrentView()->currentItem()) return; | 653 | if( !CurrentView()->currentItem()) return; |
652 | QString curFile; | 654 | QString curFile; |
653 | curFile = CurrentView()->currentItem()->text(0); | 655 | curFile = CurrentView()->currentItem()->text(0); |
654 | 656 | ||
655 | QStringList command; | 657 | QStringList command; |
656 | command << "/bin/sh"; | 658 | command << "/bin/sh"; |
657 | command << "-c"; | 659 | command << "-c"; |
658 | command << "stat -l "+ curFile; | 660 | command << "stat -l "+ curFile; |
659 | 661 | ||
660 | Output *outDlg; | 662 | Output *outDlg; |
661 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 663 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
662 | QPEApplication::execDialog( outDlg ); | 664 | QPEApplication::execDialog( outDlg ); |
663 | qApp->processEvents(); | 665 | qApp->processEvents(); |
664 | } | 666 | } |
665 | 667 | ||
666 | 668 | ||
667 | void AdvancedFm::mkDir() { | 669 | void AdvancedFm::mkDir() { |
668 | makeDir(); | 670 | makeDir(); |
669 | } | 671 | } |
670 | 672 | ||
671 | void AdvancedFm::rn() { | 673 | void AdvancedFm::rn() { |
672 | renameIt(); | 674 | renameIt(); |
673 | } | 675 | } |
674 | 676 | ||
675 | void AdvancedFm::del() { | 677 | void AdvancedFm::del() { |
676 | doDelete(); | 678 | doDelete(); |
677 | } | 679 | } |
678 | 680 | ||
679 | void AdvancedFm::mkSym() { | 681 | void AdvancedFm::mkSym() { |
680 | QString cmd; | 682 | QString cmd; |
681 | QStringList curFileList = getPath(); | 683 | QStringList curFileList = getPath(); |
682 | if( curFileList.count() > 0) { | 684 | if( curFileList.count() > 0) { |
683 | QDir *thisDir = CurrentDir(); | 685 | QDir *thisDir = CurrentDir(); |
684 | QDir * thatDir = OtherDir(); | 686 | QDir * thatDir = OtherDir(); |
685 | 687 | ||
686 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 688 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
687 | 689 | ||
688 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 690 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
689 | if(destName.right(1) == "/") { | 691 | if(destName.right(1) == "/") { |
690 | destName = destName.left( destName.length() -1); | 692 | destName = destName.left( destName.length() -1); |
691 | } | 693 | } |
692 | 694 | ||
693 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 695 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
694 | 696 | ||
695 | if( curFile.right(1) == "/") { | 697 | if( curFile.right(1) == "/") { |
696 | curFile = curFile.left( curFile.length() -1); | 698 | curFile = curFile.left( curFile.length() -1); |
697 | } | 699 | } |
698 | 700 | ||
699 | cmd = "ln -s "+curFile+" "+destName; | 701 | cmd = "ln -s "+curFile+" "+destName; |
700 | // odebug << cmd << oendl; | 702 | // odebug << cmd << oendl; |
701 | startProcess( (const QString)cmd ); | 703 | startProcess( (const QString)cmd ); |
702 | } | 704 | } |
703 | rePopulate(); | 705 | rePopulate(); |
704 | setOtherTabCurrent(); | 706 | setOtherTabCurrent(); |
705 | } | 707 | } |
706 | } | 708 | } |
707 | 709 | ||
708 | void AdvancedFm::doBeam() { | 710 | void AdvancedFm::doBeam() { |
709 | Ir ir; | 711 | Ir ir; |
710 | if(!ir.supported()) { | 712 | if(!ir.supported()) { |
711 | } else { | 713 | } else { |
712 | QStringList curFileList = getPath(); | 714 | QStringList curFileList = getPath(); |
713 | if( curFileList.count() > 0) { | 715 | if( curFileList.count() > 0) { |
714 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 716 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
715 | QString curFile = (*it); | 717 | QString curFile = (*it); |
716 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; | 718 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; |
717 | if( curFilePath.right(1) == "/") { | 719 | if( curFilePath.right(1) == "/") { |
718 | curFilePath = curFilePath.left( curFilePath.length() -1); | 720 | curFilePath = curFilePath.left( curFilePath.length() -1); |
719 | } | 721 | } |
720 | Ir *file = new Ir(this, "IR"); | 722 | Ir *file = new Ir(this, "IR"); |
721 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); | 723 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); |
722 | file->send( curFilePath, curFile ); | 724 | file->send( curFilePath, curFile ); |
723 | } | 725 | } |
724 | } | 726 | } |
725 | } | 727 | } |
726 | } | 728 | } |
727 | 729 | ||
728 | void AdvancedFm::fileBeamFinished( Ir *) { | 730 | void AdvancedFm::fileBeamFinished( Ir *) { |
729 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 731 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
730 | } | 732 | } |
731 | 733 | ||
732 | void AdvancedFm::selectAll() { | 734 | void AdvancedFm::selectAll() { |
733 | QListView *thisView = CurrentView(); | 735 | QListView *thisView = CurrentView(); |
734 | thisView->selectAll(true); | 736 | thisView->selectAll(true); |
735 | thisView->setSelected( thisView->firstChild(),false); | 737 | thisView->setSelected( thisView->firstChild(),false); |
736 | } | 738 | } |
737 | 739 | ||
738 | void AdvancedFm::startProcess(const QString & cmd) { | 740 | void AdvancedFm::startProcess(const QString & cmd) { |
739 | QStringList command; | 741 | QStringList command; |
740 | OProcess *process; | 742 | OProcess *process; |
741 | process = new OProcess(); | 743 | process = new OProcess(); |
742 | connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*))); | 744 | connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*))); |
743 | connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int))); | 745 | connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int))); |
744 | 746 | ||
745 | command << "/bin/sh"; | 747 | command << "/bin/sh"; |
746 | command << "-c"; | 748 | command << "-c"; |
747 | command << cmd.latin1(); | 749 | command << cmd.latin1(); |
748 | *process << command; | 750 | *process << command; |
749 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 751 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
750 | odebug << "could not start process" << oendl; | 752 | odebug << "could not start process" << oendl; |
751 | } | 753 | } |
752 | 754 | ||
753 | void AdvancedFm::processEnded(OProcess *) { | 755 | void AdvancedFm::processEnded(OProcess *) { |
754 | rePopulate(); | 756 | rePopulate(); |
755 | } | 757 | } |
756 | 758 | ||
757 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { | 759 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
758 | // owarn << "received stderrt " << buflen << " bytes" << oendl; | 760 | // owarn << "received stderrt " << buflen << " bytes" << oendl; |
759 | 761 | ||
760 | QString lineStr = buffer; | 762 | QString lineStr = buffer; |
761 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 763 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
762 | } | 764 | } |
763 | 765 | ||
764 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | 766 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { |
765 | if ( o->inherits( "QLineEdit" ) ) { | 767 | if ( o->inherits( "QLineEdit" ) ) { |
766 | if ( e->type() == QEvent::KeyPress ) { | 768 | if ( e->type() == QEvent::KeyPress ) { |
767 | QKeyEvent *ke = (QKeyEvent*)e; | 769 | QKeyEvent *ke = (QKeyEvent*)e; |
768 | if ( ke->key() == Key_Return || | 770 | if ( ke->key() == Key_Return || |
769 | ke->key() == Key_Enter ) { | 771 | ke->key() == Key_Enter ) { |
770 | okRename(); | 772 | okRename(); |
771 | return true; | 773 | return true; |
772 | } | 774 | } |
773 | else if ( ke->key() == Key_Escape ) { | 775 | else if ( ke->key() == Key_Escape ) { |
774 | cancelRename(); | 776 | cancelRename(); |
775 | return true; | 777 | return true; |
776 | } | 778 | } |
777 | } | 779 | } |
778 | else if ( e->type() == QEvent::FocusOut ) { | 780 | else if ( e->type() == QEvent::FocusOut ) { |
779 | cancelRename(); | 781 | cancelRename(); |
780 | return true; | 782 | return true; |
781 | } | 783 | } |
782 | } | 784 | } |
783 | if ( o->inherits( "QListView" ) ) { | 785 | if ( o->inherits( "QListView" ) ) { |
784 | if ( e->type() == QEvent::FocusIn ) { | 786 | if ( e->type() == QEvent::FocusIn ) { |
785 | if( o == Local_View) { //keep track of which view | 787 | if( o == Local_View) { //keep track of which view |
786 | whichTab = 1; | 788 | whichTab = 1; |
787 | viewMenu->setItemChecked(viewMenu->idAt(0), true); | 789 | viewMenu->setItemChecked(viewMenu->idAt(0), true); |
788 | viewMenu->setItemChecked(viewMenu->idAt(1), false); | 790 | viewMenu->setItemChecked(viewMenu->idAt(1), false); |
789 | } else { | 791 | } else { |
790 | whichTab = 2; | 792 | whichTab = 2; |
791 | viewMenu->setItemChecked(viewMenu->idAt(0), false); | 793 | viewMenu->setItemChecked(viewMenu->idAt(0), false); |
792 | viewMenu->setItemChecked(viewMenu->idAt(1), true); | 794 | viewMenu->setItemChecked(viewMenu->idAt(1), true); |
793 | } | 795 | } |
794 | } | 796 | } |
795 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection | 797 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection |
796 | } | 798 | } |
797 | 799 | ||
798 | return QWidget::eventFilter( o, e ); | 800 | return QWidget::eventFilter( o, e ); |
799 | } | 801 | } |
800 | 802 | ||
801 | 803 | ||
802 | void AdvancedFm::cancelRename() { | 804 | void AdvancedFm::cancelRename() { |
803 | // odebug << "cancel rename" << oendl; | 805 | // odebug << "cancel rename" << oendl; |
804 | QListView * view; | 806 | QListView * view; |
805 | view = CurrentView(); | 807 | view = CurrentView(); |
806 | 808 | ||
807 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 809 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
808 | delete renameBox; | 810 | delete renameBox; |
809 | renameBox = 0; | 811 | renameBox = 0; |
810 | if ( resetFocus ) { | 812 | if ( resetFocus ) { |
811 | view->viewport()->setFocusProxy( view); | 813 | view->viewport()->setFocusProxy( view); |
812 | view->setFocus(); | 814 | view->setFocus(); |
813 | } | 815 | } |
814 | } | 816 | } |
815 | 817 | ||
816 | void AdvancedFm::doRename(QListView * view) { | 818 | void AdvancedFm::doRename(QListView * view) { |
817 | if( !CurrentView()->currentItem()) return; | 819 | if( !CurrentView()->currentItem()) return; |
818 | 820 | ||
819 | QRect r = view->itemRect( view->currentItem( )); | 821 | QRect r = view->itemRect( view->currentItem( )); |
820 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 822 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
821 | r.setX( view->contentsX() ); | 823 | r.setX( view->contentsX() ); |
822 | if ( r.width() > view->visibleWidth() ) | 824 | if ( r.width() > view->visibleWidth() ) |
823 | r.setWidth( view->visibleWidth() ); | 825 | r.setWidth( view->visibleWidth() ); |
824 | 826 | ||
825 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 827 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
826 | renameBox->setFrame(true); | 828 | renameBox->setFrame(true); |
827 | renameBox->setText( view->currentItem()->text(0) ); | 829 | renameBox->setText( view->currentItem()->text(0) ); |
828 | renameBox->selectAll(); | 830 | renameBox->selectAll(); |
829 | renameBox->installEventFilter( this ); | 831 | renameBox->installEventFilter( this ); |
830 | view->addChild( renameBox, r.x(), r.y() ); | 832 | view->addChild( renameBox, r.x(), r.y() ); |
831 | renameBox->resize( r.size() ); | 833 | renameBox->resize( r.size() ); |
832 | view->viewport()->setFocusProxy( renameBox ); | 834 | view->viewport()->setFocusProxy( renameBox ); |
833 | renameBox->setFocus(); | 835 | renameBox->setFocus(); |
834 | renameBox->show(); | 836 | renameBox->show(); |
835 | } | 837 | } |
836 | 838 | ||
837 | 839 | ||
838 | void AdvancedFm::renameIt() { | 840 | void AdvancedFm::renameIt() { |
839 | if( !CurrentView()->currentItem()) return; | 841 | if( !CurrentView()->currentItem()) return; |
840 | 842 | ||
841 | QListView *thisView = CurrentView(); | 843 | QListView *thisView = CurrentView(); |
842 | oldName = thisView->currentItem()->text(0); | 844 | oldName = thisView->currentItem()->text(0); |
843 | doRename( thisView ); | 845 | doRename( thisView ); |
844 | } | 846 | } |
845 | 847 | ||
846 | void AdvancedFm::okRename() { | 848 | void AdvancedFm::okRename() { |
847 | qDebug("okrename"); | 849 | qDebug("okrename"); |
848 | if( !renameBox) return; | 850 | if( !renameBox) return; |
849 | 851 | ||
850 | QString newName = renameBox->text(); | 852 | QString newName = renameBox->text(); |
851 | cancelRename(); | 853 | cancelRename(); |
852 | QListView * view = CurrentView(); | 854 | QListView * view = CurrentView(); |
853 | QString path = CurrentDir()->canonicalPath() + "/"; | 855 | QString path = CurrentDir()->canonicalPath() + "/"; |
854 | oldName = path + oldName; | 856 | oldName = path + oldName; |
855 | newName = path + newName; | 857 | newName = path + newName; |
856 | if( rename( oldName.latin1(), newName.latin1())== -1) | 858 | if( rename( oldName.latin1(), newName.latin1())== -1) |
857 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 859 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
858 | else | 860 | else |
859 | oldName = ""; | 861 | oldName = ""; |
860 | QListViewItem *item = view->currentItem(); | 862 | QListViewItem *item = view->currentItem(); |
861 | view->takeItem( item ); | 863 | view->takeItem( item ); |
862 | delete item; | 864 | delete item; |
863 | rePopulate(); | 865 | rePopulate(); |
864 | } | 866 | } |
865 | 867 | ||
866 | void AdvancedFm::openSearch() { | 868 | void AdvancedFm::openSearch() { |
867 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); | 869 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); |
868 | } | 870 | } |