-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 4 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 12 |
2 files changed, 8 insertions, 8 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 8d07f69..9721f84 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -108,697 +108,697 @@ void AdvancedFm::populateView() { | |||
108 | thisDir->setNameFilter(filterStr); | 108 | thisDir->setNameFilter(filterStr); |
109 | QString fileL, fileS, fileDate; | 109 | QString fileL, fileS, fileDate; |
110 | QString fs= getFileSystemType((const QString &) path); | 110 | QString fs= getFileSystemType((const QString &) path); |
111 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | 111 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
112 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); | 112 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); |
113 | bool isDir=FALSE; | 113 | bool isDir=FALSE; |
114 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 114 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
115 | QFileInfoListIterator it(*list); | 115 | QFileInfoListIterator it(*list); |
116 | QFileInfo *fi; | 116 | QFileInfo *fi; |
117 | while ( (fi=it.current()) ) { | 117 | while ( (fi=it.current()) ) { |
118 | if (fi->isSymLink() ) { | 118 | if (fi->isSymLink() ) { |
119 | QString symLink=fi->readLink(); | 119 | QString symLink=fi->readLink(); |
120 | QFileInfo sym( symLink); | 120 | QFileInfo sym( symLink); |
121 | fileS.sprintf( "%10i", sym.size() ); | 121 | fileS.sprintf( "%10i", sym.size() ); |
122 | fileL = fi->fileName() +" -> " + sym.filePath().data(); | 122 | fileL = fi->fileName() +" -> " + sym.filePath().data(); |
123 | fileDate = sym.lastModified().toString(); | 123 | fileDate = sym.lastModified().toString(); |
124 | } else { | 124 | } else { |
125 | fileS.sprintf( "%10i", fi->size() ); | 125 | fileS.sprintf( "%10i", fi->size() ); |
126 | fileL = fi->fileName(); | 126 | fileL = fi->fileName(); |
127 | fileDate= fi->lastModified().toString(); | 127 | fileDate= fi->lastModified().toString(); |
128 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { | 128 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { |
129 | // if(fileL == "..") | 129 | // if(fileL == "..") |
130 | fileL += "/"; | 130 | fileL += "/"; |
131 | isDir=TRUE; | 131 | isDir=TRUE; |
132 | } | 132 | } |
133 | } | 133 | } |
134 | QFileInfo fileInfo( path + "/" + fileL); | 134 | QFileInfo fileInfo( path + "/" + fileL); |
135 | 135 | ||
136 | if(fileL !="./" && fi->exists()) { | 136 | if(fileL !="./" && fi->exists()) { |
137 | item = new QListViewItem( thisView, fileL, fileS , fileDate); | 137 | item = new QListViewItem( thisView, fileL, fileS , fileDate); |
138 | 138 | ||
139 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 139 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
140 | 140 | ||
141 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 141 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
142 | pm = Resource::loadPixmap( "lockedfolder" ); | 142 | pm = Resource::loadPixmap( "lockedfolder" ); |
143 | else | 143 | else |
144 | pm= Resource::loadPixmap( "folder" ); | 144 | pm= Resource::loadPixmap( "folder" ); |
145 | } | 145 | } |
146 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 146 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
147 | pm = Resource::loadPixmap( "exec"); | 147 | pm = Resource::loadPixmap( "exec"); |
148 | } | 148 | } |
149 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 149 | else if( (fileInfo.permission( QFileInfo::ExeUser) |
150 | | fileInfo.permission( QFileInfo::ExeGroup) | 150 | | fileInfo.permission( QFileInfo::ExeGroup) |
151 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 151 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
152 | pm = Resource::loadPixmap( "exec"); | 152 | pm = Resource::loadPixmap( "exec"); |
153 | } | 153 | } |
154 | else if( !fi->isReadable() ) { | 154 | else if( !fi->isReadable() ) { |
155 | pm = Resource::loadPixmap( "locked" ); | 155 | pm = Resource::loadPixmap( "locked" ); |
156 | } | 156 | } |
157 | else { //everything else goes by mimetype | 157 | else { //everything else goes by mimetype |
158 | MimeType mt(fi->filePath()); | 158 | MimeType mt(fi->filePath()); |
159 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 159 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
160 | if(pm.isNull()) { | 160 | if(pm.isNull()) { |
161 | pm = unknownXpm; | 161 | pm = unknownXpm; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { | 164 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { |
165 | // odebug << " overlay link image" << oendl; | 165 | // odebug << " overlay link image" << oendl; |
166 | pm= Resource::loadPixmap( "advancedfm/symlink" ); | 166 | pm= Resource::loadPixmap( "advancedfm/symlink" ); |
167 | // pm= Resource::loadPixmap( "folder" ); | 167 | // pm= Resource::loadPixmap( "folder" ); |
168 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 168 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
169 | // QPainter painter( &pm ); | 169 | // QPainter painter( &pm ); |
170 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 170 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
171 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); | 171 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); |
172 | } | 172 | } |
173 | item->setPixmap( 0,pm); | 173 | item->setPixmap( 0,pm); |
174 | 174 | ||
175 | } | 175 | } |
176 | isDir=FALSE; | 176 | isDir=FALSE; |
177 | ++it; | 177 | ++it; |
178 | } | 178 | } |
179 | 179 | ||
180 | if( path.find("dev",0,TRUE) != -1) { | 180 | if( path.find("dev",0,TRUE) != -1) { |
181 | struct stat buf; | 181 | struct stat buf; |
182 | dev_t devT; | 182 | dev_t devT; |
183 | DIR *dir; | 183 | DIR *dir; |
184 | struct dirent *mydirent; | 184 | struct dirent *mydirent; |
185 | 185 | ||
186 | if((dir = opendir( path.latin1())) != NULL) | 186 | if((dir = opendir( path.latin1())) != NULL) |
187 | while ((mydirent = readdir(dir)) != NULL) { | 187 | while ((mydirent = readdir(dir)) != NULL) { |
188 | lstat( mydirent->d_name, &buf); | 188 | lstat( mydirent->d_name, &buf); |
189 | // odebug << mydirent->d_name << oendl; | 189 | // odebug << mydirent->d_name << oendl; |
190 | fileL.sprintf("%s", mydirent->d_name); | 190 | fileL.sprintf("%s", mydirent->d_name); |
191 | devT = buf.st_dev; | 191 | devT = buf.st_dev; |
192 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 192 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
193 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 193 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
194 | if( fileL.find(".") == -1 ) { | 194 | if( fileL.find(".") == -1 ) { |
195 | item= new QListViewItem( thisView, fileL, fileS, fileDate); | 195 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
196 | pm = unknownXpm; | 196 | pm = unknownXpm; |
197 | item->setPixmap( 0,pm); | 197 | item->setPixmap( 0,pm); |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | closedir(dir); | 201 | closedir(dir); |
202 | } | 202 | } |
203 | 203 | ||
204 | thisView->setSorting( 3,FALSE); | 204 | thisView->setSorting( 3,FALSE); |
205 | fillCombo( (const QString &) path ); | 205 | fillCombo( (const QString &) path ); |
206 | } | 206 | } |
207 | 207 | ||
208 | void AdvancedFm::rePopulate() { | 208 | void AdvancedFm::rePopulate() { |
209 | // qDebug("repopulate views"); | 209 | // qDebug("repopulate views"); |
210 | populateView(); | 210 | populateView(); |
211 | setOtherTabCurrent(); | 211 | setOtherTabCurrent(); |
212 | populateView(); | 212 | populateView(); |
213 | 213 | ||
214 | // int tmpTab = whichTab; | 214 | // int tmpTab = whichTab; |
215 | // // odebug << "" << tmpTab << "" << oendl; | 215 | // // odebug << "" << tmpTab << "" << oendl; |
216 | 216 | ||
217 | // for(int i =1; i < 3; i++) { | 217 | // for(int i =1; i < 3; i++) { |
218 | // TabWidget->setCurrentWidget(i - 1); | 218 | // TabWidget->setCurrentWidget(i - 1); |
219 | // populateView(); | 219 | // populateView(); |
220 | // } | 220 | // } |
221 | // TabWidget->setCurrentWidget( tmpTab - 1); | 221 | // TabWidget->setCurrentWidget( tmpTab - 1); |
222 | } | 222 | } |
223 | 223 | ||
224 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { | 224 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { |
225 | // if ( TabWidget->currentWidget() == tab) | 225 | // if ( TabWidget->currentWidget() == tab) |
226 | // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked local"); | 226 | // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked local"); |
227 | // else | 227 | // else |
228 | // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked remote"); | 228 | // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked remote"); |
229 | 229 | ||
230 | 230 | ||
231 | if(selectedItem) { | 231 | if(selectedItem) { |
232 | QString strItem=selectedItem->text(0); | 232 | QString strItem=selectedItem->text(0); |
233 | // owarn << strItem << oendl; | 233 | // owarn << strItem << oendl; |
234 | QString strSize=selectedItem->text(1); | 234 | QString strSize=selectedItem->text(1); |
235 | strSize=strSize.stripWhiteSpace(); | 235 | strSize=strSize.stripWhiteSpace(); |
236 | bool isDirectory = false; | 236 | bool isDirectory = false; |
237 | QString strItem2; | 237 | QString strItem2; |
238 | 238 | ||
239 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink | 239 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink |
240 | strItem2 = dealWithSymName((const QString&)strItem); | 240 | strItem2 = dealWithSymName((const QString&)strItem); |
241 | if(QDir(strItem2).exists() ) | 241 | if(QDir(strItem2).exists() ) |
242 | strItem = strItem2; | 242 | strItem = strItem2; |
243 | } | 243 | } |
244 | 244 | ||
245 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 245 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
246 | 246 | ||
247 | if(QDir(strItem).exists()) | 247 | if(QDir(strItem).exists()) |
248 | isDirectory = true; | 248 | isDirectory = true; |
249 | } | 249 | } |
250 | 250 | ||
251 | if( isDirectory ) { | 251 | if( isDirectory ) { |
252 | CurrentDir()->cd( strItem, TRUE); | 252 | CurrentDir()->cd( strItem, TRUE); |
253 | populateView(); | 253 | populateView(); |
254 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); | 254 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); |
255 | } | 255 | } |
256 | chdir( strItem.latin1()); | 256 | chdir( strItem.latin1()); |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { | 260 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { |
261 | Q_UNUSED(item); | 261 | Q_UNUSED(item); |
262 | switch (mouse) { | 262 | switch (mouse) { |
263 | case 1: | 263 | case 1: |
264 | { | 264 | { |
265 | if(renameBox != 0 ) { | 265 | if(renameBox != 0 ) { |
266 | cancelRename(); | 266 | cancelRename(); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | break; | 269 | break; |
270 | // case 2: | 270 | // case 2: |
271 | // menuTimer.start( 50, TRUE ); | 271 | // menuTimer.start( 50, TRUE ); |
272 | // break; | 272 | // break; |
273 | }; | 273 | }; |
274 | } | 274 | } |
275 | 275 | ||
276 | 276 | ||
277 | void AdvancedFm::refreshCurrentTab() { | 277 | void AdvancedFm::refreshCurrentTab() { |
278 | populateView(); | 278 | populateView(); |
279 | // if ( TabWidget->currentWidget() == tab) { | 279 | // if ( TabWidget->currentWidget() == tab) { |
280 | 280 | ||
281 | } | 281 | } |
282 | 282 | ||
283 | void AdvancedFm::switchToLocalTab() { | 283 | void AdvancedFm::switchToLocalTab() { |
284 | TabWidget->setCurrentWidget(0); | 284 | TabWidget->setCurrentWidget(0); |
285 | // Local_View->setFocus(); | 285 | // Local_View->setFocus(); |
286 | whichTab = 1; | 286 | whichTab = 1; |
287 | } | 287 | } |
288 | 288 | ||
289 | void AdvancedFm::switchToRemoteTab() { | 289 | void AdvancedFm::switchToRemoteTab() { |
290 | TabWidget->setCurrentWidget(1); | 290 | TabWidget->setCurrentWidget(1); |
291 | // Remote_View->setFocus(); | 291 | // Remote_View->setFocus(); |
292 | whichTab = 2; | 292 | whichTab = 2; |
293 | } | 293 | } |
294 | 294 | ||
295 | void AdvancedFm::currentPathComboChanged() { | 295 | void AdvancedFm::currentPathComboChanged() { |
296 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 296 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
297 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); | 297 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); |
298 | populateView(); | 298 | populateView(); |
299 | } else { | 299 | } else { |
300 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 300 | QMessageBox::message(tr("Note"),tr("<p>That directory does not exist</p>")); |
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 304 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
305 | 305 | ||
306 | if ( TabWidget->currentWidget() == tab) { | 306 | if ( TabWidget->currentWidget() == tab) { |
307 | // if ( whichTab == 1) { | 307 | // if ( whichTab == 1) { |
308 | currentPathCombo->lineEdit()->setText( currentPath); | 308 | currentPathCombo->lineEdit()->setText( currentPath); |
309 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 309 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
310 | currentPathCombo->clear(); | 310 | currentPathCombo->clear(); |
311 | localDirPathStringList.prepend( currentPath ); | 311 | localDirPathStringList.prepend( currentPath ); |
312 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 312 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
313 | } | 313 | } |
314 | } else { | 314 | } else { |
315 | currentPathCombo->lineEdit()->setText( currentPath); | 315 | currentPathCombo->lineEdit()->setText( currentPath); |
316 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 316 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
317 | currentPathCombo->clear(); | 317 | currentPathCombo->clear(); |
318 | remoteDirPathStringList.prepend( currentPath ); | 318 | remoteDirPathStringList.prepend( currentPath ); |
319 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 319 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
320 | } | 320 | } |
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | 324 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { |
325 | chdir( currentPath.latin1() ); | 325 | chdir( currentPath.latin1() ); |
326 | CurrentDir()->cd( currentPath, TRUE); | 326 | CurrentDir()->cd( currentPath, TRUE); |
327 | populateView(); | 327 | populateView(); |
328 | update(); | 328 | update(); |
329 | } | 329 | } |
330 | 330 | ||
331 | QStringList AdvancedFm::getPath() { | 331 | QStringList AdvancedFm::getPath() { |
332 | QStringList strList; | 332 | QStringList strList; |
333 | QListView *thisView=CurrentView(); | 333 | QListView *thisView=CurrentView(); |
334 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); | 334 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); |
335 | QListViewItemIterator it( thisView ); | 335 | QListViewItemIterator it( thisView ); |
336 | for ( ; it.current(); ++it ) { | 336 | for ( ; it.current(); ++it ) { |
337 | if ( it.current()->isSelected() ) { | 337 | if ( it.current()->isSelected() ) { |
338 | strList << it.current()->text(0); | 338 | strList << it.current()->text(0); |
339 | // odebug << it.current()->text(0) << oendl; | 339 | // odebug << it.current()->text(0) << oendl; |
340 | } | 340 | } |
341 | } | 341 | } |
342 | return strList; | 342 | return strList; |
343 | } | 343 | } |
344 | 344 | ||
345 | void AdvancedFm::changeTo(const QString dir) { | 345 | void AdvancedFm::changeTo(const QString dir) { |
346 | chdir( dir.latin1()); | 346 | chdir( dir.latin1()); |
347 | CurrentDir()->cd(dir, TRUE); | 347 | CurrentDir()->cd(dir, TRUE); |
348 | populateView(); | 348 | populateView(); |
349 | update(); | 349 | update(); |
350 | } | 350 | } |
351 | 351 | ||
352 | void AdvancedFm::homeButtonPushed() { | 352 | void AdvancedFm::homeButtonPushed() { |
353 | changeTo(QDir::homeDirPath()); | 353 | changeTo(QDir::homeDirPath()); |
354 | } | 354 | } |
355 | 355 | ||
356 | void AdvancedFm::docButtonPushed() { | 356 | void AdvancedFm::docButtonPushed() { |
357 | changeTo(QPEApplication::documentDir()); | 357 | changeTo(QPEApplication::documentDir()); |
358 | } | 358 | } |
359 | 359 | ||
360 | void AdvancedFm::SDButtonPushed() { | 360 | void AdvancedFm::SDButtonPushed() { |
361 | changeTo("/mnt/card");// this can change so fix | 361 | changeTo("/mnt/card");// this can change so fix |
362 | } | 362 | } |
363 | 363 | ||
364 | void AdvancedFm::CFButtonPushed() { | 364 | void AdvancedFm::CFButtonPushed() { |
365 | if(zaurusDevice) | 365 | if(zaurusDevice) |
366 | changeTo("/mnt/cf"); //zaurus | 366 | changeTo("/mnt/cf"); //zaurus |
367 | else | 367 | else |
368 | changeTo("/mnt/hda"); //ipaq | 368 | changeTo("/mnt/hda"); //ipaq |
369 | } | 369 | } |
370 | 370 | ||
371 | void AdvancedFm::QPEButtonPushed() { | 371 | void AdvancedFm::QPEButtonPushed() { |
372 | changeTo(QPEApplication::qpeDir()); | 372 | changeTo(QPEApplication::qpeDir()); |
373 | } | 373 | } |
374 | 374 | ||
375 | void AdvancedFm::doAbout() { | 375 | void AdvancedFm::doAbout() { |
376 | QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); | 376 | QMessageBox::message("AdvancedFm",tr("<P>Advanced FileManager is copyright 2002-2003 by L.J.Potter<llornkcor@handhelds.org> and is licensed by the GPL</P>")); |
377 | } | 377 | } |
378 | 378 | ||
379 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { | 379 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { |
380 | Q_UNUSED(e); | 380 | Q_UNUSED(e); |
381 | } | 381 | } |
382 | 382 | ||
383 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | 383 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
384 | // if( CurrentView()->hasFocus() ) | 384 | // if( CurrentView()->hasFocus() ) |
385 | // e->ignore(); | 385 | // e->ignore(); |
386 | if( currentPathCombo->lineEdit()->hasFocus()) { | 386 | if( currentPathCombo->lineEdit()->hasFocus()) { |
387 | // qDebug("shout!"); | 387 | // qDebug("shout!"); |
388 | } | 388 | } |
389 | 389 | ||
390 | else if( e->key() == Key_Left ) | 390 | else if( e->key() == Key_Left ) |
391 | upDir(); | 391 | upDir(); |
392 | else if( e->key() == Key_Return || e->key() == Key_Enter) | 392 | else if( e->key() == Key_Return || e->key() == Key_Enter) |
393 | navigateToSelected(); | 393 | navigateToSelected(); |
394 | else if( e->key() == Key_Tab) | 394 | else if( e->key() == Key_Tab) |
395 | setOtherTabCurrent(); | 395 | setOtherTabCurrent(); |
396 | else if( e->key() == Key_Delete ) | 396 | else if( e->key() == Key_Delete ) |
397 | del(); | 397 | del(); |
398 | else if( e->key() == Key_A) | 398 | else if( e->key() == Key_A) |
399 | copyAs(); | 399 | copyAs(); |
400 | else if( e->key() == Key_C) | 400 | else if( e->key() == Key_C) |
401 | copy(); | 401 | copy(); |
402 | else if( e->key() == Key_E) | 402 | else if( e->key() == Key_E) |
403 | runThis(); | 403 | runThis(); |
404 | else if( e->key() == Key_G) | 404 | else if( e->key() == Key_G) |
405 | currentPathCombo->lineEdit()->setFocus(); | 405 | currentPathCombo->lineEdit()->setFocus(); |
406 | else if( e->key() == Key_H ) | 406 | else if( e->key() == Key_H ) |
407 | showHidden(); | 407 | showHidden(); |
408 | else if( e->key() == Key_I) | 408 | else if( e->key() == Key_I) |
409 | fileStatus(); | 409 | fileStatus(); |
410 | else if( e->key() == Key_M) | 410 | else if( e->key() == Key_M) |
411 | move(); | 411 | move(); |
412 | else if( e->key() == Key_N ) | 412 | else if( e->key() == Key_N ) |
413 | mkDir(); | 413 | mkDir(); |
414 | else if( e->key() == Key_P) | 414 | else if( e->key() == Key_P) |
415 | filePerms(); | 415 | filePerms(); |
416 | else if( e->key() == Key_R ) | 416 | else if( e->key() == Key_R ) |
417 | rn(); | 417 | rn(); |
418 | else if( e->key() == Key_U ) | 418 | else if( e->key() == Key_U ) |
419 | upDir(); | 419 | upDir(); |
420 | else if( e->key() == Key_1) | 420 | else if( e->key() == Key_1) |
421 | switchToLocalTab(); | 421 | switchToLocalTab(); |
422 | else if( e->key() == Key_2) | 422 | else if( e->key() == Key_2) |
423 | switchToRemoteTab(); | 423 | switchToRemoteTab(); |
424 | else if( e->key() == Key_3) | 424 | else if( e->key() == Key_3) |
425 | CFButtonPushed(); | 425 | CFButtonPushed(); |
426 | else if( e->key() == Key_4) | 426 | else if( e->key() == Key_4) |
427 | SDButtonPushed(); | 427 | SDButtonPushed(); |
428 | else if( e->key() == Key_5 ) | 428 | else if( e->key() == Key_5 ) |
429 | homeButtonPushed(); | 429 | homeButtonPushed(); |
430 | else if( e->key() == Key_6 ) | 430 | else if( e->key() == Key_6 ) |
431 | docButtonPushed(); | 431 | docButtonPushed(); |
432 | else | 432 | else |
433 | e->accept(); | 433 | e->accept(); |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | void AdvancedFm::parsetab(const QString &fileName) { | 437 | void AdvancedFm::parsetab(const QString &fileName) { |
438 | 438 | ||
439 | fileSystemTypeList.clear(); | 439 | fileSystemTypeList.clear(); |
440 | fsList.clear(); | 440 | fsList.clear(); |
441 | struct mntent *me; | 441 | struct mntent *me; |
442 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 442 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
443 | if ( mntfp ) { | 443 | if ( mntfp ) { |
444 | while ( (me = getmntent( mntfp )) != 0 ) { | 444 | while ( (me = getmntent( mntfp )) != 0 ) { |
445 | QString deviceName = me->mnt_fsname; | 445 | QString deviceName = me->mnt_fsname; |
446 | QString filesystemType = me->mnt_type; | 446 | QString filesystemType = me->mnt_type; |
447 | QString mountDir = me->mnt_dir; | 447 | QString mountDir = me->mnt_dir; |
448 | if(deviceName != "none") { | 448 | if(deviceName != "none") { |
449 | if( fsList.contains(filesystemType) == 0 | 449 | if( fsList.contains(filesystemType) == 0 |
450 | & filesystemType.find("proc",0,TRUE) == -1 | 450 | & filesystemType.find("proc",0,TRUE) == -1 |
451 | & filesystemType.find("cramfs",0,TRUE) == -1 | 451 | & filesystemType.find("cramfs",0,TRUE) == -1 |
452 | & filesystemType.find("auto",0,TRUE) == -1) | 452 | & filesystemType.find("auto",0,TRUE) == -1) |
453 | fsList << filesystemType; | 453 | fsList << filesystemType; |
454 | fileSystemTypeList << mountDir+"::"+filesystemType; | 454 | fileSystemTypeList << mountDir+"::"+filesystemType; |
455 | } | 455 | } |
456 | } | 456 | } |
457 | } | 457 | } |
458 | endmntent( mntfp ); | 458 | endmntent( mntfp ); |
459 | } | 459 | } |
460 | 460 | ||
461 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 461 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
462 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 462 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
463 | QString current = currentText;//.right( currentText.length()-1); | 463 | QString current = currentText;//.right( currentText.length()-1); |
464 | QString baseFs; | 464 | QString baseFs; |
465 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 465 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
466 | QString temp = (*it); | 466 | QString temp = (*it); |
467 | QString path = temp.left(temp.find("::",0,TRUE) ); | 467 | QString path = temp.left(temp.find("::",0,TRUE) ); |
468 | path = path.right( path.length()-1); | 468 | path = path.right( path.length()-1); |
469 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 469 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
470 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 470 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
471 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 471 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
472 | } | 472 | } |
473 | } | 473 | } |
474 | return baseFs; | 474 | return baseFs; |
475 | } | 475 | } |
476 | 476 | ||
477 | QString AdvancedFm::getDiskSpace( const QString &path) { | 477 | QString AdvancedFm::getDiskSpace( const QString &path) { |
478 | struct statfs fss; | 478 | struct statfs fss; |
479 | if ( !statfs( path.latin1(), &fss ) ) { | 479 | if ( !statfs( path.latin1(), &fss ) ) { |
480 | int blkSize = fss.f_bsize; | 480 | int blkSize = fss.f_bsize; |
481 | // int totalBlks = fs.f_blocks; | 481 | // int totalBlks = fs.f_blocks; |
482 | int availBlks = fss.f_bavail; | 482 | int availBlks = fss.f_bavail; |
483 | 483 | ||
484 | long mult = blkSize / 1024; | 484 | long mult = blkSize / 1024; |
485 | long div = 1024 / blkSize; | 485 | long div = 1024 / blkSize; |
486 | if ( !mult ) mult = 1; | 486 | if ( !mult ) mult = 1; |
487 | if ( !div ) div = 1; | 487 | if ( !div ) div = 1; |
488 | 488 | ||
489 | return QString::number(availBlks * mult / div); | 489 | return QString::number(availBlks * mult / div); |
490 | } | 490 | } |
491 | return ""; | 491 | return ""; |
492 | } | 492 | } |
493 | 493 | ||
494 | 494 | ||
495 | void AdvancedFm::showFileMenu() { | 495 | void AdvancedFm::showFileMenu() { |
496 | QString curApp; | 496 | QString curApp; |
497 | curApp = CurrentView()->currentItem()->text(0); | 497 | curApp = CurrentView()->currentItem()->text(0); |
498 | 498 | ||
499 | MimeType mt(curApp); | 499 | MimeType mt(curApp); |
500 | const AppLnk* app = mt.application(); | 500 | const AppLnk* app = mt.application(); |
501 | QFile fi(curApp); | 501 | QFile fi(curApp); |
502 | QPopupMenu *m = new QPopupMenu(0); | 502 | QPopupMenu *m = new QPopupMenu(0); |
503 | QPopupMenu *n = new QPopupMenu(0); | 503 | QPopupMenu *n = new QPopupMenu(0); |
504 | // QPopupMenu *o = new QPopupMenu(0); | 504 | // QPopupMenu *o = new QPopupMenu(0); |
505 | m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); | 505 | m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); |
506 | 506 | ||
507 | if ( QFileInfo(fi).isDir()) { | 507 | if ( QFileInfo(fi).isDir()) { |
508 | m->insertSeparator(); | 508 | m->insertSeparator(); |
509 | m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); | 509 | m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); |
510 | } else { | 510 | } else { |
511 | 511 | ||
512 | if (app) | 512 | if (app) |
513 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); | 513 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); |
514 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 514 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
515 | m->insertItem(tr("Execute"),this,SLOT(runThis())); | 515 | m->insertItem(tr("Execute"),this,SLOT(runThis())); |
516 | m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText())); | 516 | m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText())); |
517 | } | 517 | } |
518 | 518 | ||
519 | m->insertItem(tr("Actions"),n); | 519 | m->insertItem(tr("Actions"),n); |
520 | n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); | 520 | n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); |
521 | 521 | ||
522 | n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); | 522 | n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); |
523 | 523 | ||
524 | n->insertSeparator(); | 524 | n->insertSeparator(); |
525 | n->insertItem(tr("Rename"),this,SLOT(renameIt())); | 525 | n->insertItem(tr("Rename"),this,SLOT(renameIt())); |
526 | 526 | ||
527 | n->insertItem(tr("Copy"),this,SLOT(copyTimer())); | 527 | n->insertItem(tr("Copy"),this,SLOT(copyTimer())); |
528 | n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); | 528 | n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); |
529 | n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); | 529 | n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); |
530 | n->insertItem(tr("Move"),this,SLOT(moveTimer())); | 530 | n->insertItem(tr("Move"),this,SLOT(moveTimer())); |
531 | 531 | ||
532 | n->insertSeparator(); | 532 | n->insertSeparator(); |
533 | n->insertItem(tr("Delete"),this,SLOT(doDelete())); | 533 | n->insertItem(tr("Delete"),this,SLOT(doDelete())); |
534 | m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); | 534 | m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); |
535 | 535 | ||
536 | m->insertItem(tr("Run Command"),this,SLOT(runCommand())); | 536 | m->insertItem(tr("Run Command"),this,SLOT(runCommand())); |
537 | m->insertItem(tr("File Info"),this,SLOT(fileStatus())); | 537 | m->insertItem(tr("File Info"),this,SLOT(fileStatus())); |
538 | 538 | ||
539 | m->insertSeparator(); | 539 | m->insertSeparator(); |
540 | m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); | 540 | m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); |
541 | 541 | ||
542 | #if defined(QT_QWS_OPIE) | 542 | #if defined(QT_QWS_OPIE) |
543 | m->insertItem(tr("Properties"),this,SLOT(doProperties())); | 543 | m->insertItem(tr("Properties"),this,SLOT(doProperties())); |
544 | #endif | 544 | #endif |
545 | m->setCheckable(TRUE); | 545 | m->setCheckable(TRUE); |
546 | if (!b) | 546 | if (!b) |
547 | m->setItemChecked(m->idAt(0),TRUE); | 547 | m->setItemChecked(m->idAt(0),TRUE); |
548 | else | 548 | else |
549 | m->setItemChecked(m->idAt(0),FALSE); | 549 | m->setItemChecked(m->idAt(0),FALSE); |
550 | 550 | ||
551 | if(Ir::supported()) | 551 | if(Ir::supported()) |
552 | m->insertItem(tr("Beam File"),this,SLOT(doBeam())); | 552 | m->insertItem(tr("Beam File"),this,SLOT(doBeam())); |
553 | m->setFocus(); | 553 | m->setFocus(); |
554 | 554 | ||
555 | m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); | 555 | m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); |
556 | 556 | ||
557 | if(m) delete m; | 557 | if(m) delete m; |
558 | } | 558 | } |
559 | 559 | ||
560 | 560 | ||
561 | QString AdvancedFm::checkDiskSpace(const QString &path) { | 561 | QString AdvancedFm::checkDiskSpace(const QString &path) { |
562 | struct statfs fss; | 562 | struct statfs fss; |
563 | if ( !statfs( path.latin1(), &fss ) ) { | 563 | if ( !statfs( path.latin1(), &fss ) ) { |
564 | int blkSize = fss.f_bsize; | 564 | int blkSize = fss.f_bsize; |
565 | // int totalBlks = fs.f_blocks; | 565 | // int totalBlks = fs.f_blocks; |
566 | int availBlks = fss.f_bavail; | 566 | int availBlks = fss.f_bavail; |
567 | 567 | ||
568 | long mult = blkSize / 1024; | 568 | long mult = blkSize / 1024; |
569 | long div = 1024 / blkSize; | 569 | long div = 1024 / blkSize; |
570 | if ( !mult ) mult = 1; | 570 | if ( !mult ) mult = 1; |
571 | if ( !div ) div = 1; | 571 | if ( !div ) div = 1; |
572 | 572 | ||
573 | 573 | ||
574 | return QString::number(availBlks * mult / div); | 574 | return QString::number(availBlks * mult / div); |
575 | } | 575 | } |
576 | return ""; | 576 | return ""; |
577 | } | 577 | } |
578 | 578 | ||
579 | void AdvancedFm::addToDocs() { | 579 | void AdvancedFm::addToDocs() { |
580 | QStringList strListPaths = getPath(); | 580 | QStringList strListPaths = getPath(); |
581 | QDir *thisDir = CurrentDir(); | 581 | QDir *thisDir = CurrentDir(); |
582 | 582 | ||
583 | if( strListPaths.count() > 0) { | 583 | if( strListPaths.count() > 0) { |
584 | QString curFile; | 584 | QString curFile; |
585 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { | 585 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { |
586 | curFile = thisDir->canonicalPath()+"/"+(*it); | 586 | curFile = thisDir->canonicalPath()+"/"+(*it); |
587 | // odebug << curFile << oendl; | 587 | // odebug << curFile << oendl; |
588 | QFileInfo fi(curFile); | 588 | QFileInfo fi(curFile); |
589 | DocLnk f; | 589 | DocLnk f; |
590 | // curFile.replace(QRegExp("\\..*"),""); | 590 | // curFile.replace(QRegExp("\\..*"),""); |
591 | f.setName(fi.baseName() ); | 591 | f.setName(fi.baseName() ); |
592 | f.setFile( curFile); | 592 | f.setFile( curFile); |
593 | f.writeLink(); | 593 | f.writeLink(); |
594 | } | 594 | } |
595 | } | 595 | } |
596 | } | 596 | } |
597 | 597 | ||
598 | 598 | ||
599 | void AdvancedFm::customDirsToMenu() { | 599 | void AdvancedFm::customDirsToMenu() { |
600 | 600 | ||
601 | Config cfg("AdvancedFm"); | 601 | Config cfg("AdvancedFm"); |
602 | cfg.setGroup("Menu"); | 602 | cfg.setGroup("Menu"); |
603 | 603 | ||
604 | QStringList list = cfg.readListEntry( "CustomDir", ','); | 604 | QStringList list = cfg.readListEntry( "CustomDir", ','); |
605 | menuButton->insertItems(list ); | 605 | menuButton->insertItems(list ); |
606 | 606 | ||
607 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 607 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
608 | // { | 608 | // { |
609 | // customDirMenu->insertItem(*it ); | 609 | // customDirMenu->insertItem(*it ); |
610 | // } | 610 | // } |
611 | } | 611 | } |
612 | 612 | ||
613 | void AdvancedFm::dirMenuSelected(int item) { | 613 | void AdvancedFm::dirMenuSelected(int item) { |
614 | switch(item) | 614 | switch(item) |
615 | { | 615 | { |
616 | 616 | ||
617 | case -21: | 617 | case -21: |
618 | case 0: | 618 | case 0: |
619 | addCustomDir(); | 619 | addCustomDir(); |
620 | break; | 620 | break; |
621 | case -22: | 621 | case -22: |
622 | case 1: | 622 | case 1: |
623 | removeCustomDir(); | 623 | removeCustomDir(); |
624 | break; | 624 | break; |
625 | default: | 625 | default: |
626 | { | 626 | { |
627 | // gotoCustomDir( menuButton->text(item)); | 627 | // gotoCustomDir( menuButton->text(item)); |
628 | // gotoCustomDir( customDirMenu->text(item)); | 628 | // gotoCustomDir( customDirMenu->text(item)); |
629 | } | 629 | } |
630 | break; | 630 | break; |
631 | 631 | ||
632 | }; | 632 | }; |
633 | } | 633 | } |
634 | 634 | ||
635 | void AdvancedFm::addCustomDir() { | 635 | void AdvancedFm::addCustomDir() { |
636 | Config cfg("AdvancedFm"); | 636 | Config cfg("AdvancedFm"); |
637 | cfg.setGroup("Menu"); | 637 | cfg.setGroup("Menu"); |
638 | QString dir; | 638 | QString dir; |
639 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 639 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
640 | 640 | ||
641 | dir = CurrentDir()->canonicalPath(); | 641 | dir = CurrentDir()->canonicalPath(); |
642 | 642 | ||
643 | bool addIt=true; | 643 | bool addIt=true; |
644 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 644 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
645 | if( dir == (*it)) { | 645 | if( dir == (*it)) { |
646 | addIt=false; | 646 | addIt=false; |
647 | } | 647 | } |
648 | } | 648 | } |
649 | if(addIt) { | 649 | if(addIt) { |
650 | menuButton->insertItem(dir); | 650 | menuButton->insertItem(dir); |
651 | // customDirMenu->insertItem(dir); | 651 | // customDirMenu->insertItem(dir); |
652 | list << dir; | 652 | list << dir; |
653 | } | 653 | } |
654 | 654 | ||
655 | cfg.writeEntry("CustomDir", list, ','); | 655 | cfg.writeEntry("CustomDir", list, ','); |
656 | cfg.write(); | 656 | cfg.write(); |
657 | } | 657 | } |
658 | 658 | ||
659 | void AdvancedFm::removeCustomDir() { | 659 | void AdvancedFm::removeCustomDir() { |
660 | // odebug << "remove custom dir" << oendl; | 660 | // odebug << "remove custom dir" << oendl; |
661 | Config cfg("AdvancedFm"); | 661 | Config cfg("AdvancedFm"); |
662 | cfg.setGroup("Menu"); | 662 | cfg.setGroup("Menu"); |
663 | QString dir; | 663 | QString dir; |
664 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 664 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
665 | QStringList list2; | 665 | QStringList list2; |
666 | dir = CurrentDir()->canonicalPath(); | 666 | dir = CurrentDir()->canonicalPath(); |
667 | int ramble=2; | 667 | int ramble=2; |
668 | // int ramble=-24; | 668 | // int ramble=-24; |
669 | //first remove list | 669 | //first remove list |
670 | if(list.grep(dir,true).isEmpty()) { | 670 | if(list.grep(dir,true).isEmpty()) { |
671 | QMessageBox::message(tr( "AdvancedFm" ), | 671 | QMessageBox::message(tr( "AdvancedFm" ), |
672 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); | 672 | tr("<p>Cannot remove current directory from bookmarks. It is not bookmarked!</p>")); |
673 | } else { | 673 | } else { |
674 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 674 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
675 | if((*it) != dir) { | 675 | if((*it) != dir) { |
676 | //current item is not our current dir, so add it to temp list | 676 | //current item is not our current dir, so add it to temp list |
677 | list2 <<(*it); | 677 | list2 <<(*it); |
678 | } else { | 678 | } else { |
679 | // customDirMenu->removeItem( ramble); | 679 | // customDirMenu->removeItem( ramble); |
680 | menuButton->remove( ramble); | 680 | menuButton->remove( ramble); |
681 | 681 | ||
682 | } | 682 | } |
683 | ramble++; | 683 | ramble++; |
684 | // ramble--; | 684 | // ramble--; |
685 | } | 685 | } |
686 | 686 | ||
687 | cfg.writeEntry("CustomDir", list2, ','); | 687 | cfg.writeEntry("CustomDir", list2, ','); |
688 | cfg.write(); | 688 | cfg.write(); |
689 | } | 689 | } |
690 | // customDirsToMenu(); | 690 | // customDirsToMenu(); |
691 | 691 | ||
692 | } | 692 | } |
693 | 693 | ||
694 | void AdvancedFm::gotoCustomDir(const QString &dir) { | 694 | void AdvancedFm::gotoCustomDir(const QString &dir) { |
695 | // odebug << "gotoCustomDir(const QString &dir) " +dir << oendl; | 695 | // odebug << "gotoCustomDir(const QString &dir) " +dir << oendl; |
696 | // QString curDir = dir; | 696 | // QString curDir = dir; |
697 | // QDir *thisDir = CurrentDir(); | 697 | // QDir *thisDir = CurrentDir(); |
698 | // if( curDir.isEmpty()) { | 698 | // if( curDir.isEmpty()) { |
699 | // } | 699 | // } |
700 | if( dir == s_addBookmark) { | 700 | if( dir == s_addBookmark) { |
701 | addCustomDir(); | 701 | addCustomDir(); |
702 | } | 702 | } |
703 | if( dir == s_removeBookmark) { | 703 | if( dir == s_removeBookmark) { |
704 | removeCustomDir( ); | 704 | removeCustomDir( ); |
705 | } else { | 705 | } else { |
706 | changeTo( dir); | 706 | changeTo( dir); |
707 | // if(QDir( curDir).exists() ) | 707 | // if(QDir( curDir).exists() ) |
708 | // { | 708 | // { |
709 | // thisDir->setPath( curDir ); | 709 | // thisDir->setPath( curDir ); |
710 | // chdir( curDir.latin1() ); | 710 | // chdir( curDir.latin1() ); |
711 | // thisDir->cd( curDir, TRUE); | 711 | // thisDir->cd( curDir, TRUE); |
712 | // populateView(); | 712 | // populateView(); |
713 | // } | 713 | // } |
714 | } | 714 | } |
715 | } | 715 | } |
716 | 716 | ||
717 | QDir *AdvancedFm::CurrentDir() { | 717 | QDir *AdvancedFm::CurrentDir() { |
718 | if ( whichTab == 1) { | 718 | if ( whichTab == 1) { |
719 | // qDebug("CurrentTab is Local"); | 719 | // qDebug("CurrentTab is Local"); |
720 | return ¤tDir; | 720 | return ¤tDir; |
721 | } else { | 721 | } else { |
722 | // qDebug("CurrentTab is Remote"); | 722 | // qDebug("CurrentTab is Remote"); |
723 | return ¤tRemoteDir; | 723 | return ¤tRemoteDir; |
724 | } | 724 | } |
725 | } | 725 | } |
726 | 726 | ||
727 | QDir *AdvancedFm::OtherDir() { | 727 | QDir *AdvancedFm::OtherDir() { |
728 | // if ( TabWidget->currentWidget() == tab) { | 728 | // if ( TabWidget->currentWidget() == tab) { |
729 | if ( whichTab == 1) { | 729 | if ( whichTab == 1) { |
730 | return ¤tRemoteDir; | 730 | return ¤tRemoteDir; |
731 | } else { | 731 | } else { |
732 | return ¤tDir; | 732 | return ¤tDir; |
733 | } | 733 | } |
734 | } | 734 | } |
735 | 735 | ||
736 | QListView * AdvancedFm::CurrentView() { | 736 | QListView * AdvancedFm::CurrentView() { |
737 | // if ( TabWidget->currentWidget() == tab) { | 737 | // if ( TabWidget->currentWidget() == tab) { |
738 | if ( whichTab == 1) { | 738 | if ( whichTab == 1) { |
739 | // qDebug("CurrentView: local"); | 739 | // qDebug("CurrentView: local"); |
740 | return Local_View; | 740 | return Local_View; |
741 | } else { | 741 | } else { |
742 | // owarn << "CurrentView Tab 2" << oendl; | 742 | // owarn << "CurrentView Tab 2" << oendl; |
743 | // qDebug("CurrentView: remote"); | 743 | // qDebug("CurrentView: remote"); |
744 | return Remote_View; | 744 | return Remote_View; |
745 | } | 745 | } |
746 | } | 746 | } |
747 | 747 | ||
748 | QListView * AdvancedFm::OtherView() { | 748 | QListView * AdvancedFm::OtherView() { |
749 | if ( whichTab == 1) | 749 | if ( whichTab == 1) |
750 | return Remote_View; | 750 | return Remote_View; |
751 | else | 751 | else |
752 | return Local_View; | 752 | return Local_View; |
753 | } | 753 | } |
754 | 754 | ||
755 | void AdvancedFm::setOtherTabCurrent() { | 755 | void AdvancedFm::setOtherTabCurrent() { |
756 | // qDebug("setOtherTabCurrent() %d",whichTab); | 756 | // qDebug("setOtherTabCurrent() %d",whichTab); |
757 | if ( whichTab == 1) { | 757 | if ( whichTab == 1) { |
758 | TabWidget->setCurrentWidget(1); | 758 | TabWidget->setCurrentWidget(1); |
759 | } else { | 759 | } else { |
760 | TabWidget->setCurrentWidget(0); | 760 | TabWidget->setCurrentWidget(0); |
761 | } | 761 | } |
762 | // OtherView()->setFocus(); | 762 | // OtherView()->setFocus(); |
763 | OtherView()->setSelected( CurrentView()->firstChild(), true); | 763 | OtherView()->setSelected( CurrentView()->firstChild(), true); |
764 | } | 764 | } |
765 | 765 | ||
766 | void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { | 766 | void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { |
767 | // odebug << "qcop message "+msg << oendl; | 767 | // odebug << "qcop message "+msg << oendl; |
768 | QDataStream stream ( data, IO_ReadOnly ); | 768 | QDataStream stream ( data, IO_ReadOnly ); |
769 | if ( msg == "openDirectory(QString)" ) { | 769 | if ( msg == "openDirectory(QString)" ) { |
770 | // odebug << "received" << oendl; | 770 | // odebug << "received" << oendl; |
771 | QString file; | 771 | QString file; |
772 | stream >> file; | 772 | stream >> file; |
773 | changeTo( (const QString &) file); | 773 | changeTo( (const QString &) file); |
774 | } | 774 | } |
775 | } | 775 | } |
776 | 776 | ||
777 | void AdvancedFm::setDocument(const QString &file) { | 777 | void AdvancedFm::setDocument(const QString &file) { |
778 | changeTo( file); | 778 | changeTo( file); |
779 | 779 | ||
780 | } | 780 | } |
781 | 781 | ||
782 | 782 | ||
783 | void AdvancedFm::findFile(const QString &fileName) { | 783 | void AdvancedFm::findFile(const QString &fileName) { |
784 | QFileInfo fi(fileName); | 784 | QFileInfo fi(fileName); |
785 | QListView *thisView = CurrentView(); | 785 | QListView *thisView = CurrentView(); |
786 | QListViewItemIterator it( thisView ); | 786 | QListViewItemIterator it( thisView ); |
787 | for ( ; it.current(); ++it ) { | 787 | for ( ; it.current(); ++it ) { |
788 | if(it.current()->text(0) == fi.fileName()) { | 788 | if(it.current()->text(0) == fi.fileName()) { |
789 | it.current()->setSelected(true); | 789 | it.current()->setSelected(true); |
790 | thisView->ensureItemVisible(it.current()); | 790 | thisView->ensureItemVisible(it.current()); |
791 | } | 791 | } |
792 | } | 792 | } |
793 | } | 793 | } |
794 | 794 | ||
795 | void AdvancedFm::slotSwitchMenu(int item) { | 795 | void AdvancedFm::slotSwitchMenu(int item) { |
796 | Q_UNUSED(item); | 796 | Q_UNUSED(item); |
797 | // qDebug( "Switch %d",item); | 797 | // qDebug( "Switch %d",item); |
798 | // viewMenu->setItemChecked(item, true); | 798 | // viewMenu->setItemChecked(item, true); |
799 | } | 799 | } |
800 | 800 | ||
801 | void AdvancedFm::navigateToSelected() { | 801 | void AdvancedFm::navigateToSelected() { |
802 | if( !CurrentView()->currentItem()) return; | 802 | if( !CurrentView()->currentItem()) return; |
803 | doDirChange(); | 803 | doDirChange(); |
804 | } | 804 | } |
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index f14f588..706658e 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,708 +1,708 @@ | |||
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 | 12 | ||
13 | #include "advancedfm.h" | 13 | #include "advancedfm.h" |
14 | #include "output.h" | 14 | #include "output.h" |
15 | #include "filePermissions.h" | 15 | #include "filePermissions.h" |
16 | 16 | ||
17 | /* OPIE */ | 17 | /* OPIE */ |
18 | #include <opie2/odebug.h> | 18 | #include <opie2/odebug.h> |
19 | #include <qpe/lnkproperties.h> | 19 | #include <qpe/lnkproperties.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/applnk.h> | 21 | #include <qpe/applnk.h> |
22 | using namespace Opie::Core; | 22 | using namespace Opie::Core; |
23 | 23 | ||
24 | /* QT*/ | 24 | /* QT*/ |
25 | 25 | ||
26 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
27 | #include <qpopupmenu.h> | 27 | #include <qpopupmenu.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | 29 | ||
30 | /* STD */ | 30 | /* STD */ |
31 | 31 | ||
32 | #include <errno.h> | 32 | #include <errno.h> |
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | #include <unistd.h> | 34 | #include <unistd.h> |
35 | #include <sys/stat.h> | 35 | #include <sys/stat.h> |
36 | #include <dirent.h> | 36 | #include <dirent.h> |
37 | #include <sys/sendfile.h> | 37 | #include <sys/sendfile.h> |
38 | #include <fcntl.h> | 38 | #include <fcntl.h> |
39 | 39 | ||
40 | void AdvancedFm::doDirChange() { | 40 | void AdvancedFm::doDirChange() { |
41 | QString pathItem = CurrentView()->currentItem()->text(0); | 41 | QString pathItem = CurrentView()->currentItem()->text(0); |
42 | if( pathItem == "../") { | 42 | if( pathItem == "../") { |
43 | ListClicked( CurrentView()->currentItem()); | 43 | ListClicked( CurrentView()->currentItem()); |
44 | } else { | 44 | } else { |
45 | if( pathItem.find(" -> ",0,TRUE) != -1) | 45 | if( pathItem.find(" -> ",0,TRUE) != -1) |
46 | pathItem = dealWithSymName((const QString&)pathItem)+"/"; | 46 | pathItem = dealWithSymName((const QString&)pathItem)+"/"; |
47 | // owarn << pathItem << oendl; | 47 | // owarn << pathItem << oendl; |
48 | changeTo( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); | 48 | changeTo( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | void AdvancedFm::showMenuHidden() { | 52 | void AdvancedFm::showMenuHidden() { |
53 | if (b) { | 53 | if (b) { |
54 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 54 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
55 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 55 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
56 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 56 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
57 | } else { | 57 | } else { |
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),FALSE); | 60 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
61 | } | 61 | } |
62 | b = !b; | 62 | b = !b; |
63 | populateView(); | 63 | populateView(); |
64 | } | 64 | } |
65 | 65 | ||
66 | void AdvancedFm::showHidden() { | 66 | void AdvancedFm::showHidden() { |
67 | if (b) { | 67 | if (b) { |
68 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 68 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
69 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 69 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
70 | } else { | 70 | } else { |
71 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 71 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
72 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 72 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
73 | } | 73 | } |
74 | populateView(); | 74 | populateView(); |
75 | } | 75 | } |
76 | 76 | ||
77 | QString AdvancedFm::dealWithSymName(const QString &fileName) { | 77 | QString AdvancedFm::dealWithSymName(const QString &fileName) { |
78 | QString strItem = fileName; | 78 | QString strItem = fileName; |
79 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 79 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
80 | } | 80 | } |
81 | 81 | ||
82 | void AdvancedFm::runThis() { | 82 | void AdvancedFm::runThis() { |
83 | if( !CurrentView()->currentItem()) return; | 83 | if( !CurrentView()->currentItem()) return; |
84 | QString fs; | 84 | QString fs; |
85 | QDir *thisDir = CurrentDir(); | 85 | QDir *thisDir = CurrentDir(); |
86 | 86 | ||
87 | QString curFile = CurrentView()->currentItem()->text(0); | 87 | QString curFile = CurrentView()->currentItem()->text(0); |
88 | QString path = thisDir->canonicalPath(); | 88 | QString path = thisDir->canonicalPath(); |
89 | 89 | ||
90 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 90 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
91 | 91 | ||
92 | curFile = dealWithSymName((const QString&)curFile); | 92 | curFile = dealWithSymName((const QString&)curFile); |
93 | 93 | ||
94 | if(curFile != "../") { | 94 | if(curFile != "../") { |
95 | 95 | ||
96 | fs = getFileSystemType((const QString &) path); | 96 | fs = getFileSystemType((const QString &) path); |
97 | QFileInfo fileInfo( path + "/" + curFile); | 97 | QFileInfo fileInfo( path + "/" + curFile); |
98 | // odebug << fileInfo.owner() << oendl; | 98 | // odebug << fileInfo.owner() << oendl; |
99 | 99 | ||
100 | if( (fileInfo.permission( QFileInfo::ExeUser) | 100 | if( (fileInfo.permission( QFileInfo::ExeUser) |
101 | | fileInfo.permission( QFileInfo::ExeGroup) | 101 | | fileInfo.permission( QFileInfo::ExeGroup) |
102 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 102 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
103 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 103 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
104 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 104 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
105 | e << curFile; | 105 | e << curFile; |
106 | } else { | 106 | } else { |
107 | curFile = path + "/" + curFile; | 107 | curFile = path + "/" + curFile; |
108 | DocLnk nf(curFile); | 108 | DocLnk nf(curFile); |
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("Really delete\n%1 files?").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 | }; | 160 | }; |
161 | } | 161 | } |
162 | 162 | ||
163 | QString myFile; | 163 | QString myFile; |
164 | 164 | ||
165 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 165 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
166 | myFile = (*it); | 166 | myFile = (*it); |
167 | if( myFile.find(" -> ",0,TRUE) != -1) | 167 | if( myFile.find(" -> ",0,TRUE) != -1) |
168 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 168 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
169 | 169 | ||
170 | QString f = CurrentDir()->canonicalPath(); | 170 | QString f = CurrentDir()->canonicalPath(); |
171 | if(f.right(1).find("/",0,TRUE) == -1) | 171 | if(f.right(1).find("/",0,TRUE) == -1) |
172 | f += "/"; | 172 | f += "/"; |
173 | f += myFile; | 173 | f += myFile; |
174 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 174 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
175 | //if file is a directory | 175 | //if file is a directory |
176 | 176 | ||
177 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), | 177 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), |
178 | tr("Really delete %1\nand all it's contents ?" ).arg( f ) , | 178 | tr("<p>Really delete %1 and all it's contents?</p>" ).arg( f ) , |
179 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 179 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
180 | case 0: | 180 | case 0: |
181 | { | 181 | { |
182 | f=f.left(f.length()-1); | 182 | f=f.left(f.length()-1); |
183 | QString cmd="rm -rf "+f; | 183 | QString cmd="rm -rf "+f; |
184 | startProcess( (const QString)cmd.latin1() ); | 184 | startProcess( (const QString)cmd.latin1() ); |
185 | populateView(); | 185 | populateView(); |
186 | } | 186 | } |
187 | break; | 187 | break; |
188 | case 1: | 188 | case 1: |
189 | // exit | 189 | // exit |
190 | break; | 190 | break; |
191 | }; | 191 | }; |
192 | 192 | ||
193 | } else { | 193 | } else { |
194 | if(doMsg) { | 194 | if(doMsg) { |
195 | switch ( QMessageBox::warning(this,tr("Delete"), | 195 | switch ( QMessageBox::warning(this,tr("Delete"), |
196 | tr("Really delete\n%1?").arg( myFile ), | 196 | tr("<p>Really delete %1?</p>").arg( myFile ), |
197 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 197 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
198 | case 1: | 198 | case 1: |
199 | return; | 199 | return; |
200 | break; | 200 | break; |
201 | }; | 201 | }; |
202 | } | 202 | } |
203 | 203 | ||
204 | QString cmd="rm "+f; | 204 | QString cmd="rm "+f; |
205 | QFile file(f); | 205 | QFile file(f); |
206 | QFileInfo fi(myFile); | 206 | QFileInfo fi(myFile); |
207 | if( fi.fileName().find("../",0,TRUE)==-1) { | 207 | if( fi.fileName().find("../",0,TRUE)==-1) { |
208 | // odebug << "remove link files "+myFile << oendl; | 208 | // odebug << "remove link files "+myFile << oendl; |
209 | 209 | ||
210 | // DocLnk lnk(f); | 210 | // DocLnk lnk(f); |
211 | DocLnk *lnk; | 211 | DocLnk *lnk; |
212 | lnk = new DocLnk(f); | 212 | lnk = new DocLnk(f); |
213 | // odebug << "Deleting doclnk " + lnk->linkFile() << oendl; | 213 | // odebug << "Deleting doclnk " + lnk->linkFile() << oendl; |
214 | if(lnk->isValid()) | 214 | if(lnk->isValid()) |
215 | lnk->removeLinkFile(); | 215 | lnk->removeLinkFile(); |
216 | // delete lnk; | 216 | // delete lnk; |
217 | file.remove(); | 217 | file.remove(); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | } | 220 | } |
221 | } | 221 | } |
222 | populateView(); | 222 | populateView(); |
223 | } | 223 | } |
224 | 224 | ||
225 | void AdvancedFm::filePerms() { | 225 | void AdvancedFm::filePerms() { |
226 | QStringList curFileList = getPath(); | 226 | QStringList curFileList = getPath(); |
227 | QString filePath; | 227 | QString filePath; |
228 | 228 | ||
229 | filePath = CurrentDir()->canonicalPath()+"/"; | 229 | filePath = CurrentDir()->canonicalPath()+"/"; |
230 | 230 | ||
231 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 231 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
232 | filePermissions *filePerm; | 232 | filePermissions *filePerm; |
233 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 233 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
234 | QPEApplication::execDialog( filePerm ); | 234 | QPEApplication::execDialog( filePerm ); |
235 | if( filePerm ) | 235 | if( filePerm ) |
236 | delete filePerm; | 236 | delete filePerm; |
237 | } | 237 | } |
238 | populateView(); | 238 | populateView(); |
239 | } | 239 | } |
240 | 240 | ||
241 | void AdvancedFm::doProperties() { | 241 | void AdvancedFm::doProperties() { |
242 | #if defined(QT_QWS_OPIE) | 242 | #if defined(QT_QWS_OPIE) |
243 | 243 | ||
244 | QStringList curFileList = getPath(); | 244 | QStringList curFileList = getPath(); |
245 | 245 | ||
246 | QString filePath; | 246 | QString filePath; |
247 | filePath = CurrentDir()->canonicalPath()+"/"; | 247 | filePath = CurrentDir()->canonicalPath()+"/"; |
248 | 248 | ||
249 | // odebug << "" << curFileList.count() << "" << oendl; | 249 | // odebug << "" << curFileList.count() << "" << oendl; |
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 | // odebug << (filePath+*it) << oendl; | 252 | // odebug << (filePath+*it) << oendl; |
253 | DocLnk lnk( (filePath+*it)); | 253 | DocLnk lnk( (filePath+*it)); |
254 | LnkProperties prop( &lnk ); | 254 | LnkProperties prop( &lnk ); |
255 | QPEApplication::execDialog( &prop ); | 255 | QPEApplication::execDialog( &prop ); |
256 | } | 256 | } |
257 | #endif | 257 | #endif |
258 | 258 | ||
259 | } | 259 | } |
260 | 260 | ||
261 | void AdvancedFm::upDir() { | 261 | void AdvancedFm::upDir() { |
262 | QDir *thisDir = CurrentDir(); | 262 | QDir *thisDir = CurrentDir(); |
263 | QString current = thisDir->canonicalPath(); | 263 | QString current = thisDir->canonicalPath(); |
264 | QDir dir(current); | 264 | QDir dir(current); |
265 | dir.cdUp(); | 265 | dir.cdUp(); |
266 | current = dir.canonicalPath(); | 266 | current = dir.canonicalPath(); |
267 | chdir( current.latin1() ); | 267 | chdir( current.latin1() ); |
268 | thisDir->cd( current, TRUE); | 268 | thisDir->cd( current, TRUE); |
269 | 269 | ||
270 | populateView(); | 270 | populateView(); |
271 | update(); | 271 | update(); |
272 | } | 272 | } |
273 | 273 | ||
274 | void AdvancedFm::copyTimer() { | 274 | void AdvancedFm::copyTimer() { |
275 | QTimer::singleShot(125,this,SLOT(copy())); | 275 | QTimer::singleShot(125,this,SLOT(copy())); |
276 | } | 276 | } |
277 | 277 | ||
278 | void AdvancedFm::copy() { | 278 | void AdvancedFm::copy() { |
279 | QStringList curFileList = getPath(); | 279 | QStringList curFileList = getPath(); |
280 | 280 | ||
281 | QDir *thisDir = CurrentDir(); | 281 | QDir *thisDir = CurrentDir(); |
282 | QDir *thatDir = OtherDir(); | 282 | QDir *thatDir = OtherDir(); |
283 | 283 | ||
284 | bool doMsg=true; | 284 | bool doMsg=true; |
285 | int count=curFileList.count(); | 285 | int count=curFileList.count(); |
286 | if( count > 0) { | 286 | if( count > 0) { |
287 | if(count > 1 ){ | 287 | if(count > 1 ){ |
288 | QString msg; | 288 | QString msg; |
289 | msg=tr("Really copy\n%1 files?").arg(count); | 289 | msg=tr("<p>Really copy %1 files?</p>").arg(count); |
290 | switch ( QMessageBox::warning(this,tr("Copy"),msg | 290 | switch ( QMessageBox::warning(this,tr("Copy"),msg |
291 | ,tr("Yes"),tr("No"),0,0,1) ) | 291 | ,tr("Yes"),tr("No"),0,0,1) ) |
292 | { | 292 | { |
293 | case 0: | 293 | case 0: |
294 | doMsg=false; | 294 | doMsg=false; |
295 | break; | 295 | break; |
296 | case 1: | 296 | case 1: |
297 | return; | 297 | return; |
298 | break; | 298 | break; |
299 | }; | 299 | }; |
300 | } | 300 | } |
301 | 301 | ||
302 | QString curFile, item, destFile; | 302 | QString curFile, item, destFile; |
303 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 303 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
304 | item=(*it); | 304 | item=(*it); |
305 | if(item.find("->",0,TRUE)) //symlink | 305 | if(item.find("->",0,TRUE)) //symlink |
306 | item = item.left(item.find("->",0,TRUE)); | 306 | item = item.left(item.find("->",0,TRUE)); |
307 | 307 | ||
308 | curFile = thisDir->canonicalPath()+"/"+ item; | 308 | curFile = thisDir->canonicalPath()+"/"+ item; |
309 | destFile = thatDir->canonicalPath()+"/"+ item; | 309 | destFile = thatDir->canonicalPath()+"/"+ item; |
310 | 310 | ||
311 | // odebug << "Destination file is "+destFile << oendl; | 311 | // odebug << "Destination file is "+destFile << oendl; |
312 | // odebug << "CurrentFile file is " + curFile << oendl; | 312 | // odebug << "CurrentFile file is " + curFile << oendl; |
313 | 313 | ||
314 | QFile f(destFile); | 314 | QFile f(destFile); |
315 | if( f.exists()) { | 315 | if( f.exists()) { |
316 | if(doMsg) { | 316 | if(doMsg) { |
317 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 317 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
318 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), | 318 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), |
319 | tr("Yes"),tr("No"),0,0,1)) { | 319 | tr("Yes"),tr("No"),0,0,1)) { |
320 | case 1: | 320 | case 1: |
321 | return; | 321 | return; |
322 | break; | 322 | break; |
323 | }; | 323 | }; |
324 | } | 324 | } |
325 | f.remove(); | 325 | f.remove(); |
326 | } | 326 | } |
327 | 327 | ||
328 | if( !copyFile( curFile, destFile) ) { | 328 | if( !copyFile( curFile, destFile) ) { |
329 | QMessageBox::message("AdvancedFm", | 329 | QMessageBox::message("AdvancedFm", |
330 | tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 330 | tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
331 | return; | 331 | return; |
332 | } | 332 | } |
333 | } | 333 | } |
334 | rePopulate(); | 334 | rePopulate(); |
335 | } | 335 | } |
336 | } | 336 | } |
337 | 337 | ||
338 | void AdvancedFm::copyAsTimer() { | 338 | void AdvancedFm::copyAsTimer() { |
339 | QTimer::singleShot(125,this,SLOT(copyAs())); | 339 | QTimer::singleShot(125,this,SLOT(copyAs())); |
340 | } | 340 | } |
341 | 341 | ||
342 | void AdvancedFm::copyAs() { | 342 | void AdvancedFm::copyAs() { |
343 | 343 | ||
344 | QStringList curFileList = getPath(); | 344 | QStringList curFileList = getPath(); |
345 | QString curFile, item; | 345 | QString curFile, item; |
346 | InputDialog *fileDlg; | 346 | InputDialog *fileDlg; |
347 | 347 | ||
348 | QDir *thisDir = CurrentDir(); | 348 | QDir *thisDir = CurrentDir(); |
349 | QDir *thatDir = OtherDir(); | 349 | QDir *thatDir = OtherDir(); |
350 | 350 | ||
351 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 351 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
352 | QString destFile; | 352 | QString destFile; |
353 | item=(*it); | 353 | item=(*it); |
354 | curFile = thisDir->canonicalPath()+"/"+(*it); | 354 | curFile = thisDir->canonicalPath()+"/"+(*it); |
355 | fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); | 355 | fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); |
356 | 356 | ||
357 | fileDlg->setInputText((const QString &) destFile ); | 357 | fileDlg->setInputText((const QString &) destFile ); |
358 | fileDlg->exec(); | 358 | fileDlg->exec(); |
359 | 359 | ||
360 | if( fileDlg->result() == 1 ) { | 360 | if( fileDlg->result() == 1 ) { |
361 | QString filename = fileDlg->LineEdit1->text(); | 361 | QString filename = fileDlg->LineEdit1->text(); |
362 | destFile = thatDir->canonicalPath()+"/"+filename; | 362 | destFile = thatDir->canonicalPath()+"/"+filename; |
363 | 363 | ||
364 | QFile f( destFile); | 364 | QFile f( destFile); |
365 | if( f.exists()) { | 365 | if( f.exists()) { |
366 | switch (QMessageBox::warning(this,tr("File Exists!"), | 366 | switch (QMessageBox::warning(this,tr("File Exists!"), |
367 | tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), | 367 | tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), |
368 | tr("Yes"),tr("No"),0,0,1) ) { | 368 | tr("Yes"),tr("No"),0,0,1) ) { |
369 | case 0: | 369 | case 0: |
370 | f.remove(); | 370 | f.remove(); |
371 | break; | 371 | break; |
372 | case 1: | 372 | case 1: |
373 | return; | 373 | return; |
374 | break; | 374 | break; |
375 | }; | 375 | }; |
376 | } | 376 | } |
377 | if( !copyFile( curFile, destFile) ) { | 377 | if( !copyFile( curFile, destFile) ) { |
378 | QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 378 | QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
379 | return; | 379 | return; |
380 | } | 380 | } |
381 | } | 381 | } |
382 | delete fileDlg; | 382 | delete fileDlg; |
383 | 383 | ||
384 | } | 384 | } |
385 | rePopulate(); | 385 | rePopulate(); |
386 | // setOtherTabCurrent(); | 386 | // setOtherTabCurrent(); |
387 | qApp->processEvents(); | 387 | qApp->processEvents(); |
388 | 388 | ||
389 | } | 389 | } |
390 | 390 | ||
391 | void AdvancedFm::copySameDirTimer() { | 391 | void AdvancedFm::copySameDirTimer() { |
392 | QTimer::singleShot(125,this,SLOT(copySameDir())); | 392 | QTimer::singleShot(125,this,SLOT(copySameDir())); |
393 | } | 393 | } |
394 | 394 | ||
395 | void AdvancedFm::copySameDir() { | 395 | void AdvancedFm::copySameDir() { |
396 | qApp->processEvents(); | 396 | qApp->processEvents(); |
397 | QStringList curFileList = getPath(); | 397 | QStringList curFileList = getPath(); |
398 | QString curFile, item, destFile; | 398 | QString curFile, item, destFile; |
399 | InputDialog *fileDlg; | 399 | InputDialog *fileDlg; |
400 | 400 | ||
401 | QDir *thisDir = CurrentDir(); | 401 | QDir *thisDir = CurrentDir(); |
402 | 402 | ||
403 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 403 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
404 | item=(*it); | 404 | item=(*it); |
405 | curFile = thisDir->canonicalPath()+"/"+ item; | 405 | curFile = thisDir->canonicalPath()+"/"+ item; |
406 | 406 | ||
407 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 407 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
408 | fileDlg->setInputText((const QString &) destFile ); | 408 | fileDlg->setInputText((const QString &) destFile ); |
409 | fileDlg->exec(); | 409 | fileDlg->exec(); |
410 | 410 | ||
411 | if( fileDlg->result() == 1 ) { | 411 | if( fileDlg->result() == 1 ) { |
412 | 412 | ||
413 | QString filename = fileDlg->LineEdit1->text(); | 413 | QString filename = fileDlg->LineEdit1->text(); |
414 | destFile = thisDir->canonicalPath()+"/"+filename; | 414 | destFile = thisDir->canonicalPath()+"/"+filename; |
415 | 415 | ||
416 | QFile f(destFile); | 416 | QFile f(destFile); |
417 | if( f.exists()) { | 417 | if( f.exists()) { |
418 | switch (QMessageBox::warning(this,tr("Delete"), | 418 | switch (QMessageBox::warning(this,tr("Delete"), |
419 | tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), | 419 | tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), |
420 | tr("Yes"),tr("No"),0,0,1) ) { | 420 | tr("Yes"),tr("No"),0,0,1) ) { |
421 | case 0: | 421 | case 0: |
422 | 422 | ||
423 | f.remove(); | 423 | f.remove(); |
424 | break; | 424 | break; |
425 | case 1: | 425 | case 1: |
426 | return; | 426 | return; |
427 | break; | 427 | break; |
428 | }; | 428 | }; |
429 | } | 429 | } |
430 | if(!copyFile( curFile,destFile) ) { | 430 | if(!copyFile( curFile,destFile) ) { |
431 | QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 431 | QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
432 | return; | 432 | return; |
433 | } | 433 | } |
434 | 434 | ||
435 | // odebug << "copy "+curFile+" as "+destFile << oendl; | 435 | // odebug << "copy "+curFile+" as "+destFile << oendl; |
436 | } | 436 | } |
437 | delete fileDlg; | 437 | delete fileDlg; |
438 | } | 438 | } |
439 | rePopulate(); | 439 | rePopulate(); |
440 | } | 440 | } |
441 | 441 | ||
442 | void AdvancedFm::moveTimer() { | 442 | void AdvancedFm::moveTimer() { |
443 | QTimer::singleShot(125,this,SLOT(move())); | 443 | QTimer::singleShot(125,this,SLOT(move())); |
444 | } | 444 | } |
445 | 445 | ||
446 | void AdvancedFm::move() { | 446 | void AdvancedFm::move() { |
447 | 447 | ||
448 | QStringList curFileList = getPath(); | 448 | QStringList curFileList = getPath(); |
449 | if( curFileList.count() > 0) { | 449 | if( curFileList.count() > 0) { |
450 | QString curFile, destFile, item; | 450 | QString curFile, destFile, item; |
451 | 451 | ||
452 | QDir *thisDir = CurrentDir(); | 452 | QDir *thisDir = CurrentDir(); |
453 | QDir *thatDir = OtherDir(); | 453 | QDir *thatDir = OtherDir(); |
454 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 454 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
455 | item=(*it); | 455 | item=(*it); |
456 | QString destFile = thatDir->canonicalPath(); | 456 | QString destFile = thatDir->canonicalPath(); |
457 | 457 | ||
458 | if(destFile.right(1).find("/",0,TRUE) == -1) | 458 | if(destFile.right(1).find("/",0,TRUE) == -1) |
459 | destFile+="/"; | 459 | destFile+="/"; |
460 | destFile += item; | 460 | destFile += item; |
461 | // odebug << "Destination file is "+destFile << oendl; | 461 | // odebug << "Destination file is "+destFile << oendl; |
462 | 462 | ||
463 | curFile = thisDir->canonicalPath(); | 463 | curFile = thisDir->canonicalPath(); |
464 | if(curFile.right(1).find("/",0,TRUE) == -1) | 464 | if(curFile.right(1).find("/",0,TRUE) == -1) |
465 | curFile +="/"; | 465 | curFile +="/"; |
466 | curFile+= item; | 466 | curFile+= item; |
467 | // odebug << "CurrentFile file is " + curFile << oendl; | 467 | // odebug << "CurrentFile file is " + curFile << oendl; |
468 | 468 | ||
469 | if(QFileInfo(curFile).isDir()) { | 469 | if(QFileInfo(curFile).isDir()) { |
470 | moveDirectory( curFile, destFile ); | 470 | moveDirectory( curFile, destFile ); |
471 | rePopulate(); | 471 | rePopulate(); |
472 | return; | 472 | return; |
473 | } | 473 | } |
474 | QFile f( destFile); | 474 | QFile f( destFile); |
475 | if( f.exists()) { | 475 | if( f.exists()) { |
476 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 476 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
477 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), | 477 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), |
478 | tr("Yes"),tr("No"),0,0,1)) { | 478 | tr("Yes"),tr("No"),0,0,1)) { |
479 | case 1: | 479 | case 1: |
480 | return; | 480 | return; |
481 | break; | 481 | break; |
482 | }; | 482 | }; |
483 | if( !copyFile( curFile, destFile) ) { | 483 | if( !copyFile( curFile, destFile) ) { |
484 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile)); | 484 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile)); |
485 | return; | 485 | return; |
486 | } else | 486 | } else |
487 | QFile::remove(curFile); | 487 | QFile::remove(curFile); |
488 | } | 488 | } |
489 | } | 489 | } |
490 | } | 490 | } |
491 | rePopulate(); | 491 | rePopulate(); |
492 | //setOtherTabCurrent(); | 492 | //setOtherTabCurrent(); |
493 | } | 493 | } |
494 | 494 | ||
495 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { | 495 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { |
496 | int err = 0; | 496 | int err = 0; |
497 | if( copyDirectory( src, dest ) ) { | 497 | if( copyDirectory( src, dest ) ) { |
498 | QString cmd = "rm -rf " + src; | 498 | QString cmd = "rm -rf " + src; |
499 | err = system((const char*)cmd); | 499 | err = system((const char*)cmd); |
500 | } else | 500 | } else |
501 | err = -1; | 501 | err = -1; |
502 | 502 | ||
503 | if(err!=0) { | 503 | if(err!=0) { |
504 | QMessageBox::message(tr("Note"),tr("Could not move\n") + src); | 504 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src)); |
505 | return false; | 505 | return false; |
506 | } | 506 | } |
507 | return true; | 507 | return true; |
508 | } | 508 | } |
509 | 509 | ||
510 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { | 510 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { |
511 | 511 | ||
512 | QString cmd = "/bin/cp -fpR " + src + " " + dest; | 512 | QString cmd = "/bin/cp -fpR " + src + " " + dest; |
513 | owarn << cmd << oendl; | 513 | owarn << cmd << oendl; |
514 | int err = system( (const char *) cmd ); | 514 | int err = system( (const char *) cmd ); |
515 | if ( err != 0 ) { | 515 | if ( err != 0 ) { |
516 | QMessageBox::message("AdvancedFm", tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); | 516 | QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) ); |
517 | return false; | 517 | return false; |
518 | } | 518 | } |
519 | 519 | ||
520 | return true; | 520 | return true; |
521 | } | 521 | } |
522 | 522 | ||
523 | 523 | ||
524 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 524 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
525 | if(QFileInfo(src).isDir()) { | 525 | if(QFileInfo(src).isDir()) { |
526 | if( copyDirectory( src, dest )) { | 526 | if( copyDirectory( src, dest )) { |
527 | // setOtherTabCurrent(); | 527 | // setOtherTabCurrent(); |
528 | rePopulate(); | 528 | rePopulate(); |
529 | return true; | 529 | return true; |
530 | } | 530 | } |
531 | else | 531 | else |
532 | return false; | 532 | return false; |
533 | } | 533 | } |
534 | 534 | ||
535 | 535 | ||
536 | bool success = true; | 536 | bool success = true; |
537 | struct stat status; | 537 | struct stat status; |
538 | QFile srcFile(src); | 538 | QFile srcFile(src); |
539 | QFile destFile(dest); | 539 | QFile destFile(dest); |
540 | int err=0; | 540 | int err=0; |
541 | int read_fd=0; | 541 | int read_fd=0; |
542 | int write_fd=0; | 542 | int write_fd=0; |
543 | struct stat stat_buf; | 543 | struct stat stat_buf; |
544 | off_t offset = 0; | 544 | off_t offset = 0; |
545 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | 545 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
546 | // owarn << "open failed" << oendl; | 546 | // owarn << "open failed" << oendl; |
547 | return success = false; | 547 | return success = false; |
548 | } | 548 | } |
549 | read_fd = srcFile.handle(); | 549 | read_fd = srcFile.handle(); |
550 | if(read_fd != -1) { | 550 | if(read_fd != -1) { |
551 | fstat (read_fd, &stat_buf); | 551 | fstat (read_fd, &stat_buf); |
552 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { | 552 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { |
553 | // owarn << "destfile open failed" << oendl; | 553 | // owarn << "destfile open failed" << oendl; |
554 | return success = false; | 554 | return success = false; |
555 | } | 555 | } |
556 | write_fd = destFile.handle(); | 556 | write_fd = destFile.handle(); |
557 | if(write_fd != -1) { | 557 | if(write_fd != -1) { |
558 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 558 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
559 | if( err == -1) { | 559 | if( err == -1) { |
560 | QString msg; | 560 | QString msg; |
561 | switch(err) { | 561 | switch(err) { |
562 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; | 562 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; |
563 | case EINVAL: msg = "Descriptor is not valid or locked. "; | 563 | case EINVAL: msg = "Descriptor is not valid or locked. "; |
564 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; | 564 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; |
565 | case EIO: msg = "Unspecified error while reading from in_fd."; | 565 | case EIO: msg = "Unspecified error while reading from in_fd."; |
566 | }; | 566 | }; |
567 | success = false; | 567 | success = false; |
568 | // owarn << msg << oendl; | 568 | // owarn << msg << oendl; |
569 | } | 569 | } |
570 | } else { | 570 | } else { |
571 | success = false; | 571 | success = false; |
572 | } | 572 | } |
573 | } else { | 573 | } else { |
574 | success = false; | 574 | success = false; |
575 | } | 575 | } |
576 | srcFile.close(); | 576 | srcFile.close(); |
577 | destFile.close(); | 577 | destFile.close(); |
578 | // Set file permissions | 578 | // Set file permissions |
579 | if( stat( QFile::encodeName(src), &status ) == 0 ) { | 579 | if( stat( QFile::encodeName(src), &status ) == 0 ) { |
580 | chmod( QFile::encodeName(dest), status.st_mode ); | 580 | chmod( QFile::encodeName(dest), status.st_mode ); |
581 | } | 581 | } |
582 | 582 | ||
583 | return success; | 583 | return success; |
584 | } | 584 | } |
585 | 585 | ||
586 | void AdvancedFm::runCommand() { | 586 | void AdvancedFm::runCommand() { |
587 | if( !CurrentView()->currentItem()) return; | 587 | if( !CurrentView()->currentItem()) return; |
588 | QDir *thisDir = CurrentDir(); | 588 | QDir *thisDir = CurrentDir(); |
589 | 589 | ||
590 | QString curFile; | 590 | QString curFile; |
591 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 591 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
592 | 592 | ||
593 | InputDialog *fileDlg; | 593 | InputDialog *fileDlg; |
594 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 594 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
595 | fileDlg->setInputText(curFile); | 595 | fileDlg->setInputText(curFile); |
596 | fileDlg->exec(); | 596 | fileDlg->exec(); |
597 | //QString command; | 597 | //QString command; |
598 | 598 | ||
599 | if( fileDlg->result() == 1 ) { | 599 | if( fileDlg->result() == 1 ) { |
600 | // odebug << fileDlg->LineEdit1->text() << oendl; | 600 | // odebug << fileDlg->LineEdit1->text() << oendl; |
601 | QStringList command; | 601 | QStringList command; |
602 | 602 | ||
603 | command << "/bin/sh"; | 603 | command << "/bin/sh"; |
604 | command << "-c"; | 604 | command << "-c"; |
605 | command << fileDlg->LineEdit1->text(); | 605 | command << fileDlg->LineEdit1->text(); |
606 | Output *outDlg; | 606 | Output *outDlg; |
607 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 607 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
608 | QPEApplication::execDialog( outDlg ); | 608 | QPEApplication::execDialog( outDlg ); |
609 | qApp->processEvents(); | 609 | qApp->processEvents(); |
610 | 610 | ||
611 | } | 611 | } |
612 | } | 612 | } |
613 | 613 | ||
614 | void AdvancedFm::runCommandStd() { | 614 | void AdvancedFm::runCommandStd() { |
615 | if( !CurrentView()->currentItem()) return; | 615 | if( !CurrentView()->currentItem()) return; |
616 | QString curFile; | 616 | QString curFile; |
617 | QDir *thisDir = CurrentDir(); | 617 | QDir *thisDir = CurrentDir(); |
618 | QListView *thisView = CurrentView(); | 618 | QListView *thisView = CurrentView(); |
619 | if( thisView->currentItem()) | 619 | if( thisView->currentItem()) |
620 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 620 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
621 | 621 | ||
622 | InputDialog *fileDlg; | 622 | InputDialog *fileDlg; |
623 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 623 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
624 | fileDlg->setInputText(curFile); | 624 | fileDlg->setInputText(curFile); |
625 | fileDlg->exec(); | 625 | fileDlg->exec(); |
626 | 626 | ||
627 | if( fileDlg->result() == 1 ) { | 627 | if( fileDlg->result() == 1 ) { |
628 | qApp->processEvents(); | 628 | qApp->processEvents(); |
629 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 629 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
630 | } | 630 | } |
631 | } | 631 | } |
632 | 632 | ||
633 | void AdvancedFm::fileStatus() { | 633 | void AdvancedFm::fileStatus() { |
634 | if( !CurrentView()->currentItem()) return; | 634 | if( !CurrentView()->currentItem()) return; |
635 | QString curFile; | 635 | QString curFile; |
636 | curFile = CurrentView()->currentItem()->text(0); | 636 | curFile = CurrentView()->currentItem()->text(0); |
637 | 637 | ||
638 | QStringList command; | 638 | QStringList command; |
639 | command << "/bin/sh"; | 639 | command << "/bin/sh"; |
640 | command << "-c"; | 640 | command << "-c"; |
641 | command << "stat -l "+ curFile; | 641 | command << "stat -l "+ curFile; |
642 | 642 | ||
643 | Output *outDlg; | 643 | Output *outDlg; |
644 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 644 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
645 | QPEApplication::execDialog( outDlg ); | 645 | QPEApplication::execDialog( outDlg ); |
646 | qApp->processEvents(); | 646 | qApp->processEvents(); |
647 | } | 647 | } |
648 | 648 | ||
649 | 649 | ||
650 | void AdvancedFm::mkDir() { | 650 | void AdvancedFm::mkDir() { |
651 | makeDir(); | 651 | makeDir(); |
652 | } | 652 | } |
653 | 653 | ||
654 | void AdvancedFm::rn() { | 654 | void AdvancedFm::rn() { |
655 | renameIt(); | 655 | renameIt(); |
656 | } | 656 | } |
657 | 657 | ||
658 | void AdvancedFm::del() { | 658 | void AdvancedFm::del() { |
659 | doDelete(); | 659 | doDelete(); |
660 | } | 660 | } |
661 | 661 | ||
662 | void AdvancedFm::mkSym() { | 662 | void AdvancedFm::mkSym() { |
663 | QString cmd; | 663 | QString cmd; |
664 | QStringList curFileList = getPath(); | 664 | QStringList curFileList = getPath(); |
665 | if( curFileList.count() > 0) { | 665 | if( curFileList.count() > 0) { |
666 | QDir *thisDir = CurrentDir(); | 666 | QDir *thisDir = CurrentDir(); |
667 | QDir * thatDir = OtherDir(); | 667 | QDir * thatDir = OtherDir(); |
668 | 668 | ||
669 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 669 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
670 | 670 | ||
671 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 671 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
672 | if(destName.right(1) == "/") { | 672 | if(destName.right(1) == "/") { |
673 | destName = destName.left( destName.length() -1); | 673 | destName = destName.left( destName.length() -1); |
674 | } | 674 | } |
675 | 675 | ||
676 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 676 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
677 | 677 | ||
678 | if( curFile.right(1) == "/") { | 678 | if( curFile.right(1) == "/") { |
679 | curFile = curFile.left( curFile.length() -1); | 679 | curFile = curFile.left( curFile.length() -1); |
680 | } | 680 | } |
681 | 681 | ||
682 | cmd = "ln -s "+curFile+" "+destName; | 682 | cmd = "ln -s "+curFile+" "+destName; |
683 | // odebug << cmd << oendl; | 683 | // odebug << cmd << oendl; |
684 | startProcess( (const QString)cmd ); | 684 | startProcess( (const QString)cmd ); |
685 | } | 685 | } |
686 | rePopulate(); | 686 | rePopulate(); |
687 | setOtherTabCurrent(); | 687 | setOtherTabCurrent(); |
688 | } | 688 | } |
689 | } | 689 | } |
690 | 690 | ||
691 | void AdvancedFm::doBeam() { | 691 | void AdvancedFm::doBeam() { |
692 | Ir ir; | 692 | Ir ir; |
693 | if(!ir.supported()) { | 693 | if(!ir.supported()) { |
694 | } else { | 694 | } else { |
695 | QStringList curFileList = getPath(); | 695 | QStringList curFileList = getPath(); |
696 | if( curFileList.count() > 0) { | 696 | if( curFileList.count() > 0) { |
697 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 697 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
698 | QString curFile = (*it); | 698 | QString curFile = (*it); |
699 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; | 699 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; |
700 | if( curFilePath.right(1) == "/") { | 700 | if( curFilePath.right(1) == "/") { |
701 | curFilePath = curFilePath.left( curFilePath.length() -1); | 701 | curFilePath = curFilePath.left( curFilePath.length() -1); |
702 | } | 702 | } |
703 | Ir *file = new Ir(this, "IR"); | 703 | Ir *file = new Ir(this, "IR"); |
704 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); | 704 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); |
705 | file->send( curFilePath, curFile ); | 705 | file->send( curFilePath, curFile ); |
706 | } | 706 | } |
707 | } | 707 | } |
708 | } | 708 | } |