author | llornkcor <llornkcor> | 2003-12-20 21:29:39 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-12-20 21:29:39 (UTC) |
commit | 8e884631cc002011a9abab37be9223d4a1421ff2 (patch) (unidiff) | |
tree | bab42e2a2a305e95a37ce56d52960540240c3c04 | |
parent | c7bad76e8d576fc0b6999775c89c724c6fa89158 (diff) | |
download | opie-8e884631cc002011a9abab37be9223d4a1421ff2.zip opie-8e884631cc002011a9abab37be9223d4a1421ff2.tar.gz opie-8e884631cc002011a9abab37be9223d4a1421ff2.tar.bz2 |
fix popupmenu position on large screens
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index ecf471d..ac16540 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -100,795 +100,796 @@ void AdvancedFm::tabChanged(QWidget *) { | |||
100 | chdir( path.latin1()); | 100 | chdir( path.latin1()); |
101 | } | 101 | } |
102 | 102 | ||
103 | 103 | ||
104 | void AdvancedFm::populateView() { | 104 | void AdvancedFm::populateView() { |
105 | 105 | ||
106 | qWarning("PopulateView"); | 106 | qWarning("PopulateView"); |
107 | QPixmap pm; | 107 | QPixmap pm; |
108 | QListView *thisView = CurrentView(); | 108 | QListView *thisView = CurrentView(); |
109 | QDir *thisDir = CurrentDir(); | 109 | QDir *thisDir = CurrentDir(); |
110 | QString path = thisDir->canonicalPath(); | 110 | QString path = thisDir->canonicalPath(); |
111 | 111 | ||
112 | qWarning("path is "+path); | 112 | qWarning("path is "+path); |
113 | thisView->clear(); | 113 | thisView->clear(); |
114 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 114 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
115 | thisDir->setMatchAllDirs(TRUE); | 115 | thisDir->setMatchAllDirs(TRUE); |
116 | thisDir->setNameFilter(filterStr); | 116 | thisDir->setNameFilter(filterStr); |
117 | QString fileL, fileS, fileDate; | 117 | QString fileL, fileS, fileDate; |
118 | QString fs= getFileSystemType((const QString &) path); | 118 | QString fs= getFileSystemType((const QString &) path); |
119 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | 119 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
120 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); | 120 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); |
121 | bool isDir=FALSE; | 121 | bool isDir=FALSE; |
122 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 122 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
123 | QFileInfoListIterator it(*list); | 123 | QFileInfoListIterator it(*list); |
124 | QFileInfo *fi; | 124 | QFileInfo *fi; |
125 | while ( (fi=it.current()) ) { | 125 | while ( (fi=it.current()) ) { |
126 | if (fi->isSymLink() ) { | 126 | if (fi->isSymLink() ) { |
127 | QString symLink=fi->readLink(); | 127 | QString symLink=fi->readLink(); |
128 | QFileInfo sym( symLink); | 128 | QFileInfo sym( symLink); |
129 | fileS.sprintf( "%10i", sym.size() ); | 129 | fileS.sprintf( "%10i", sym.size() ); |
130 | fileL = fi->fileName() +" -> " + sym.filePath().data(); | 130 | fileL = fi->fileName() +" -> " + sym.filePath().data(); |
131 | fileDate = sym.lastModified().toString(); | 131 | fileDate = sym.lastModified().toString(); |
132 | } else { | 132 | } else { |
133 | fileS.sprintf( "%10i", fi->size() ); | 133 | fileS.sprintf( "%10i", fi->size() ); |
134 | fileL = fi->fileName(); | 134 | fileL = fi->fileName(); |
135 | fileDate= fi->lastModified().toString(); | 135 | fileDate= fi->lastModified().toString(); |
136 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { | 136 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { |
137 | // if(fileL == "..") | 137 | // if(fileL == "..") |
138 | fileL += "/"; | 138 | fileL += "/"; |
139 | isDir=TRUE; | 139 | isDir=TRUE; |
140 | } | 140 | } |
141 | } | 141 | } |
142 | QFileInfo fileInfo( path + "/" + fileL); | 142 | QFileInfo fileInfo( path + "/" + fileL); |
143 | 143 | ||
144 | if(fileL !="./" && fi->exists()) { | 144 | if(fileL !="./" && fi->exists()) { |
145 | item = new QListViewItem( thisView, fileL, fileS , fileDate); | 145 | item = new QListViewItem( thisView, fileL, fileS , fileDate); |
146 | 146 | ||
147 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 147 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
148 | 148 | ||
149 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 149 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
150 | pm = Resource::loadPixmap( "lockedfolder" ); | 150 | pm = Resource::loadPixmap( "lockedfolder" ); |
151 | else | 151 | else |
152 | pm= Resource::loadPixmap( "folder" ); | 152 | pm= Resource::loadPixmap( "folder" ); |
153 | } | 153 | } |
154 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 154 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
155 | pm = Resource::loadPixmap( "exec"); | 155 | pm = Resource::loadPixmap( "exec"); |
156 | } | 156 | } |
157 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 157 | else if( (fileInfo.permission( QFileInfo::ExeUser) |
158 | | fileInfo.permission( QFileInfo::ExeGroup) | 158 | | fileInfo.permission( QFileInfo::ExeGroup) |
159 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 159 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
160 | pm = Resource::loadPixmap( "exec"); | 160 | pm = Resource::loadPixmap( "exec"); |
161 | } | 161 | } |
162 | else if( !fi->isReadable() ) { | 162 | else if( !fi->isReadable() ) { |
163 | pm = Resource::loadPixmap( "locked" ); | 163 | pm = Resource::loadPixmap( "locked" ); |
164 | } | 164 | } |
165 | else { //everything else goes by mimetype | 165 | else { //everything else goes by mimetype |
166 | MimeType mt(fi->filePath()); | 166 | MimeType mt(fi->filePath()); |
167 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 167 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
168 | if(pm.isNull()) { | 168 | if(pm.isNull()) { |
169 | pm = unknownXpm; | 169 | pm = unknownXpm; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { | 172 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { |
173 | // qDebug(" overlay link image"); | 173 | // qDebug(" overlay link image"); |
174 | pm= Resource::loadPixmap( "advancedfm/symlink" ); | 174 | pm= Resource::loadPixmap( "advancedfm/symlink" ); |
175 | // pm= Resource::loadPixmap( "folder" ); | 175 | // pm= Resource::loadPixmap( "folder" ); |
176 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 176 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
177 | // QPainter painter( &pm ); | 177 | // QPainter painter( &pm ); |
178 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 178 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
179 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); | 179 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); |
180 | } | 180 | } |
181 | item->setPixmap( 0,pm); | 181 | item->setPixmap( 0,pm); |
182 | 182 | ||
183 | } | 183 | } |
184 | isDir=FALSE; | 184 | isDir=FALSE; |
185 | ++it; | 185 | ++it; |
186 | } | 186 | } |
187 | 187 | ||
188 | if( path.find("dev",0,TRUE) != -1) { | 188 | if( path.find("dev",0,TRUE) != -1) { |
189 | struct stat buf; | 189 | struct stat buf; |
190 | dev_t devT; | 190 | dev_t devT; |
191 | DIR *dir; | 191 | DIR *dir; |
192 | struct dirent *mydirent; | 192 | struct dirent *mydirent; |
193 | 193 | ||
194 | if((dir = opendir( path.latin1())) != NULL) | 194 | if((dir = opendir( path.latin1())) != NULL) |
195 | while ((mydirent = readdir(dir)) != NULL) { | 195 | while ((mydirent = readdir(dir)) != NULL) { |
196 | lstat( mydirent->d_name, &buf); | 196 | lstat( mydirent->d_name, &buf); |
197 | // qDebug(mydirent->d_name); | 197 | // qDebug(mydirent->d_name); |
198 | fileL.sprintf("%s", mydirent->d_name); | 198 | fileL.sprintf("%s", mydirent->d_name); |
199 | devT = buf.st_dev; | 199 | devT = buf.st_dev; |
200 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 200 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
201 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 201 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
202 | if( fileL.find(".") == -1 ) { | 202 | if( fileL.find(".") == -1 ) { |
203 | item= new QListViewItem( thisView, fileL, fileS, fileDate); | 203 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
204 | pm = unknownXpm; | 204 | pm = unknownXpm; |
205 | item->setPixmap( 0,pm); | 205 | item->setPixmap( 0,pm); |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
209 | closedir(dir); | 209 | closedir(dir); |
210 | } | 210 | } |
211 | 211 | ||
212 | thisView->setSorting( 3,FALSE); | 212 | thisView->setSorting( 3,FALSE); |
213 | fillCombo( (const QString &) path ); | 213 | fillCombo( (const QString &) path ); |
214 | } | 214 | } |
215 | 215 | ||
216 | void AdvancedFm::rePopulate() { | 216 | void AdvancedFm::rePopulate() { |
217 | populateView(); | 217 | populateView(); |
218 | setOtherTabCurrent(); | 218 | setOtherTabCurrent(); |
219 | populateView(); | 219 | populateView(); |
220 | 220 | ||
221 | // int tmpTab = whichTab; | 221 | // int tmpTab = whichTab; |
222 | // // qDebug("%d", tmpTab); | 222 | // // qDebug("%d", tmpTab); |
223 | 223 | ||
224 | // for(int i =1; i < 3; i++) { | 224 | // for(int i =1; i < 3; i++) { |
225 | // TabWidget->setCurrentWidget(i - 1); | 225 | // TabWidget->setCurrentWidget(i - 1); |
226 | // populateView(); | 226 | // populateView(); |
227 | // } | 227 | // } |
228 | // TabWidget->setCurrentWidget( tmpTab - 1); | 228 | // TabWidget->setCurrentWidget( tmpTab - 1); |
229 | } | 229 | } |
230 | 230 | ||
231 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { | 231 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { |
232 | //qWarning("listclicked"); | 232 | //qWarning("listclicked"); |
233 | if(selectedItem) { | 233 | if(selectedItem) { |
234 | QString strItem=selectedItem->text(0); | 234 | QString strItem=selectedItem->text(0); |
235 | // qWarning(strItem); | 235 | // qWarning(strItem); |
236 | QString strSize=selectedItem->text(1); | 236 | QString strSize=selectedItem->text(1); |
237 | strSize=strSize.stripWhiteSpace(); | 237 | strSize=strSize.stripWhiteSpace(); |
238 | bool isDirectory = false; | 238 | bool isDirectory = false; |
239 | QString strItem2; | 239 | QString strItem2; |
240 | 240 | ||
241 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink | 241 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink |
242 | strItem2 = dealWithSymName((const QString&)strItem); | 242 | strItem2 = dealWithSymName((const QString&)strItem); |
243 | if(QDir(strItem2).exists() ) | 243 | if(QDir(strItem2).exists() ) |
244 | strItem = strItem2; | 244 | strItem = strItem2; |
245 | } | 245 | } |
246 | 246 | ||
247 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 247 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
248 | 248 | ||
249 | if(QDir(strItem).exists()) | 249 | if(QDir(strItem).exists()) |
250 | isDirectory = true; | 250 | isDirectory = true; |
251 | } | 251 | } |
252 | 252 | ||
253 | if( isDirectory ) { | 253 | if( isDirectory ) { |
254 | CurrentDir()->cd( strItem, TRUE); | 254 | CurrentDir()->cd( strItem, TRUE); |
255 | populateView(); | 255 | populateView(); |
256 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); | 256 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); |
257 | } | 257 | } |
258 | chdir( strItem.latin1()); | 258 | chdir( strItem.latin1()); |
259 | } | 259 | } |
260 | } | 260 | } |
261 | 261 | ||
262 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { | 262 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { |
263 | dealWithSchmooSchmaa( item->listView()); | 263 | dealWithSchmooSchmaa( item->listView()); |
264 | switch (mouse) { | 264 | switch (mouse) { |
265 | case 1: | 265 | case 1: |
266 | { | 266 | { |
267 | if(renameBox != 0 ) { | 267 | if(renameBox != 0 ) { |
268 | cancelRename(); | 268 | cancelRename(); |
269 | } | 269 | } |
270 | } | 270 | } |
271 | break; | 271 | break; |
272 | case 2: | 272 | case 2: |
273 | menuTimer.start( 500, TRUE ); | 273 | menuTimer.start( 500, TRUE ); |
274 | break; | 274 | break; |
275 | }; | 275 | }; |
276 | } | 276 | } |
277 | 277 | ||
278 | 278 | ||
279 | void AdvancedFm::switchToLocalTab() { | 279 | void AdvancedFm::switchToLocalTab() { |
280 | //qWarning("switch to local view"); | 280 | //qWarning("switch to local view"); |
281 | TabWidget->setCurrentWidget(0); | 281 | TabWidget->setCurrentWidget(0); |
282 | Local_View->setFocus(); | 282 | Local_View->setFocus(); |
283 | } | 283 | } |
284 | 284 | ||
285 | void AdvancedFm::switchToRemoteTab() { | 285 | void AdvancedFm::switchToRemoteTab() { |
286 | //qWarning("switch to local view"); | 286 | //qWarning("switch to local view"); |
287 | TabWidget->setCurrentWidget(1); | 287 | TabWidget->setCurrentWidget(1); |
288 | Remote_View->setFocus(); | 288 | Remote_View->setFocus(); |
289 | } | 289 | } |
290 | 290 | ||
291 | void AdvancedFm::readConfig() { | 291 | void AdvancedFm::readConfig() { |
292 | Config cfg("AdvancedFm"); | 292 | Config cfg("AdvancedFm"); |
293 | } | 293 | } |
294 | 294 | ||
295 | void AdvancedFm::writeConfig() { | 295 | void AdvancedFm::writeConfig() { |
296 | Config cfg("AdvancedFm"); | 296 | Config cfg("AdvancedFm"); |
297 | } | 297 | } |
298 | 298 | ||
299 | void AdvancedFm::currentPathComboChanged() { | 299 | void AdvancedFm::currentPathComboChanged() { |
300 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 300 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
301 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); | 301 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); |
302 | populateView(); | 302 | populateView(); |
303 | } else { | 303 | } else { |
304 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 304 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
305 | } | 305 | } |
306 | } | 306 | } |
307 | 307 | ||
308 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 308 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
309 | 309 | ||
310 | if ( whichTab == 1) { | 310 | if ( whichTab == 1) { |
311 | currentPathCombo->lineEdit()->setText( currentPath); | 311 | currentPathCombo->lineEdit()->setText( currentPath); |
312 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 312 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
313 | currentPathCombo->clear(); | 313 | currentPathCombo->clear(); |
314 | localDirPathStringList.prepend( currentPath ); | 314 | localDirPathStringList.prepend( currentPath ); |
315 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 315 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
316 | } | 316 | } |
317 | } else { | 317 | } else { |
318 | currentPathCombo->lineEdit()->setText( currentPath); | 318 | currentPathCombo->lineEdit()->setText( currentPath); |
319 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 319 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
320 | currentPathCombo->clear(); | 320 | currentPathCombo->clear(); |
321 | remoteDirPathStringList.prepend( currentPath ); | 321 | remoteDirPathStringList.prepend( currentPath ); |
322 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 322 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
323 | } | 323 | } |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | 327 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { |
328 | chdir( currentPath.latin1() ); | 328 | chdir( currentPath.latin1() ); |
329 | CurrentDir()->cd( currentPath, TRUE); | 329 | CurrentDir()->cd( currentPath, TRUE); |
330 | populateView(); | 330 | populateView(); |
331 | update(); | 331 | update(); |
332 | } | 332 | } |
333 | 333 | ||
334 | QStringList AdvancedFm::getPath() { | 334 | QStringList AdvancedFm::getPath() { |
335 | QStringList strList; | 335 | QStringList strList; |
336 | QListView *thisView=CurrentView(); | 336 | QListView *thisView=CurrentView(); |
337 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); | 337 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); |
338 | QListViewItemIterator it( thisView ); | 338 | QListViewItemIterator it( thisView ); |
339 | for ( ; it.current(); ++it ) { | 339 | for ( ; it.current(); ++it ) { |
340 | if ( it.current()->isSelected() ) { | 340 | if ( it.current()->isSelected() ) { |
341 | strList << it.current()->text(0); | 341 | strList << it.current()->text(0); |
342 | // qDebug(it.current()->text(0)); | 342 | // qDebug(it.current()->text(0)); |
343 | } | 343 | } |
344 | } | 344 | } |
345 | return strList; | 345 | return strList; |
346 | } | 346 | } |
347 | 347 | ||
348 | void AdvancedFm::homeButtonPushed() { | 348 | void AdvancedFm::homeButtonPushed() { |
349 | QString current = QDir::homeDirPath(); | 349 | QString current = QDir::homeDirPath(); |
350 | chdir( current.latin1() ); | 350 | chdir( current.latin1() ); |
351 | CurrentDir()->cd( current, TRUE); | 351 | CurrentDir()->cd( current, TRUE); |
352 | populateView(); | 352 | populateView(); |
353 | update(); | 353 | update(); |
354 | } | 354 | } |
355 | 355 | ||
356 | void AdvancedFm::docButtonPushed() { | 356 | void AdvancedFm::docButtonPushed() { |
357 | QString current = QPEApplication::documentDir(); | 357 | QString current = QPEApplication::documentDir(); |
358 | chdir( current.latin1() ); | 358 | chdir( current.latin1() ); |
359 | CurrentDir()->cd( current, TRUE); | 359 | CurrentDir()->cd( current, TRUE); |
360 | populateView(); | 360 | populateView(); |
361 | update(); | 361 | update(); |
362 | } | 362 | } |
363 | 363 | ||
364 | void AdvancedFm::SDButtonPushed() { | 364 | void AdvancedFm::SDButtonPushed() { |
365 | QString current = "/mnt/card";// this can change so fix | 365 | QString current = "/mnt/card";// this can change so fix |
366 | chdir( current.latin1() ); | 366 | chdir( current.latin1() ); |
367 | CurrentDir()->cd( current, TRUE); | 367 | CurrentDir()->cd( current, TRUE); |
368 | populateView(); | 368 | populateView(); |
369 | update(); | 369 | update(); |
370 | } | 370 | } |
371 | 371 | ||
372 | void AdvancedFm::CFButtonPushed() { | 372 | void AdvancedFm::CFButtonPushed() { |
373 | QString current; | 373 | QString current; |
374 | if(zaurusDevice) | 374 | if(zaurusDevice) |
375 | current= "/mnt/cf"; //zaurus | 375 | current= "/mnt/cf"; //zaurus |
376 | else | 376 | else |
377 | current = "/mnt/hda"; //ipaq | 377 | current = "/mnt/hda"; //ipaq |
378 | chdir( current.latin1() ); | 378 | chdir( current.latin1() ); |
379 | CurrentDir()->cd( current, TRUE); | 379 | CurrentDir()->cd( current, TRUE); |
380 | populateView(); | 380 | populateView(); |
381 | update(); | 381 | update(); |
382 | } | 382 | } |
383 | 383 | ||
384 | 384 | ||
385 | void AdvancedFm::doAbout() { | 385 | void AdvancedFm::doAbout() { |
386 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" | 386 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" |
387 | "is copyright 2002-2003 by\n" | 387 | "is copyright 2002-2003 by\n" |
388 | "L.J.Potter<llornkcor@handhelds.org>\n" | 388 | "L.J.Potter<llornkcor@handhelds.org>\n" |
389 | "and is licensed by the GPL")); | 389 | "and is licensed by the GPL")); |
390 | } | 390 | } |
391 | 391 | ||
392 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { | 392 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { |
393 | // qWarning("key %d", e->key()); | 393 | // qWarning("key %d", e->key()); |
394 | // if( CurrentView()->hasFocus() ) | 394 | // if( CurrentView()->hasFocus() ) |
395 | { | 395 | { |
396 | switch ( e->key() ) { | 396 | switch ( e->key() ) { |
397 | case Key_Left: | 397 | case Key_Left: |
398 | upDir(); | 398 | upDir(); |
399 | break; | 399 | break; |
400 | case Key_Next: | 400 | case Key_Next: |
401 | break; | 401 | break; |
402 | case Key_Return: | 402 | case Key_Return: |
403 | case Key_Enter: | 403 | case Key_Enter: |
404 | navigateToSelected(); | 404 | navigateToSelected(); |
405 | break; | 405 | break; |
406 | case Key_Tab: { | 406 | case Key_Tab: { |
407 | setOtherTabCurrent(); | 407 | setOtherTabCurrent(); |
408 | } | 408 | } |
409 | break; | 409 | break; |
410 | case Key_Delete: | 410 | case Key_Delete: |
411 | del(); | 411 | del(); |
412 | break; | 412 | break; |
413 | case Key_A: | 413 | case Key_A: |
414 | copyAs(); | 414 | copyAs(); |
415 | break; | 415 | break; |
416 | case Key_C: | 416 | case Key_C: |
417 | copy(); | 417 | copy(); |
418 | break; | 418 | break; |
419 | case Key_E: | 419 | case Key_E: |
420 | runThis(); | 420 | runThis(); |
421 | break; | 421 | break; |
422 | case Key_G: | 422 | case Key_G: |
423 | { | 423 | { |
424 | currentPathCombo->lineEdit()->setFocus(); | 424 | currentPathCombo->lineEdit()->setFocus(); |
425 | } | 425 | } |
426 | break; | 426 | break; |
427 | 427 | ||
428 | case Key_H: | 428 | case Key_H: |
429 | showHidden(); | 429 | showHidden(); |
430 | break; | 430 | break; |
431 | case Key_I: | 431 | case Key_I: |
432 | fileStatus(); | 432 | fileStatus(); |
433 | break; | 433 | break; |
434 | case Key_M: | 434 | case Key_M: |
435 | move(); | 435 | move(); |
436 | break; | 436 | break; |
437 | case Key_N: | 437 | case Key_N: |
438 | mkDir(); | 438 | mkDir(); |
439 | break; | 439 | break; |
440 | case Key_P: | 440 | case Key_P: |
441 | filePerms(); | 441 | filePerms(); |
442 | break; | 442 | break; |
443 | case Key_R: | 443 | case Key_R: |
444 | rn(); | 444 | rn(); |
445 | break; | 445 | break; |
446 | case Key_U: | 446 | case Key_U: |
447 | upDir(); | 447 | upDir(); |
448 | break; | 448 | break; |
449 | case Key_1: | 449 | case Key_1: |
450 | switchToLocalTab(); | 450 | switchToLocalTab(); |
451 | break; | 451 | break; |
452 | case Key_2: | 452 | case Key_2: |
453 | switchToRemoteTab(); | 453 | switchToRemoteTab(); |
454 | break; | 454 | break; |
455 | case Key_3: | 455 | case Key_3: |
456 | CFButtonPushed(); | 456 | CFButtonPushed(); |
457 | break; | 457 | break; |
458 | case Key_4: | 458 | case Key_4: |
459 | SDButtonPushed(); | 459 | SDButtonPushed(); |
460 | break; | 460 | break; |
461 | case Key_5: | 461 | case Key_5: |
462 | homeButtonPushed(); | 462 | homeButtonPushed(); |
463 | break; | 463 | break; |
464 | case Key_6: | 464 | case Key_6: |
465 | docButtonPushed(); | 465 | docButtonPushed(); |
466 | break; | 466 | break; |
467 | case Key_7: | 467 | case Key_7: |
468 | break; | 468 | break; |
469 | case Key_8: | 469 | case Key_8: |
470 | break; | 470 | break; |
471 | case Key_9: | 471 | case Key_9: |
472 | break; | 472 | break; |
473 | case Key_0: | 473 | case Key_0: |
474 | break; | 474 | break; |
475 | }; | 475 | }; |
476 | e->accept(); | 476 | e->accept(); |
477 | } | 477 | } |
478 | } | 478 | } |
479 | 479 | ||
480 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | 480 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
481 | if( CurrentView()->hasFocus() ) | 481 | if( CurrentView()->hasFocus() ) |
482 | e->ignore(); | 482 | e->ignore(); |
483 | } | 483 | } |
484 | 484 | ||
485 | 485 | ||
486 | void AdvancedFm::QPEButtonPushed() { | 486 | void AdvancedFm::QPEButtonPushed() { |
487 | QString current = QPEApplication::qpeDir(); | 487 | QString current = QPEApplication::qpeDir(); |
488 | chdir( current.latin1() ); | 488 | chdir( current.latin1() ); |
489 | CurrentDir()->cd( current, TRUE); | 489 | CurrentDir()->cd( current, TRUE); |
490 | populateView(); | 490 | populateView(); |
491 | update(); | 491 | update(); |
492 | } | 492 | } |
493 | 493 | ||
494 | void AdvancedFm::parsetab(const QString &fileName) { | 494 | void AdvancedFm::parsetab(const QString &fileName) { |
495 | 495 | ||
496 | fileSystemTypeList.clear(); | 496 | fileSystemTypeList.clear(); |
497 | fsList.clear(); | 497 | fsList.clear(); |
498 | struct mntent *me; | 498 | struct mntent *me; |
499 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 499 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
500 | if ( mntfp ) { | 500 | if ( mntfp ) { |
501 | while ( (me = getmntent( mntfp )) != 0 ) { | 501 | while ( (me = getmntent( mntfp )) != 0 ) { |
502 | QString deviceName = me->mnt_fsname; | 502 | QString deviceName = me->mnt_fsname; |
503 | QString filesystemType = me->mnt_type; | 503 | QString filesystemType = me->mnt_type; |
504 | QString mountDir = me->mnt_dir; | 504 | QString mountDir = me->mnt_dir; |
505 | if(deviceName != "none") { | 505 | if(deviceName != "none") { |
506 | if( fsList.contains(filesystemType) == 0 | 506 | if( fsList.contains(filesystemType) == 0 |
507 | & filesystemType.find("proc",0,TRUE) == -1 | 507 | & filesystemType.find("proc",0,TRUE) == -1 |
508 | & filesystemType.find("cramfs",0,TRUE) == -1 | 508 | & filesystemType.find("cramfs",0,TRUE) == -1 |
509 | & filesystemType.find("auto",0,TRUE) == -1) | 509 | & filesystemType.find("auto",0,TRUE) == -1) |
510 | fsList << filesystemType; | 510 | fsList << filesystemType; |
511 | fileSystemTypeList << mountDir+"::"+filesystemType; | 511 | fileSystemTypeList << mountDir+"::"+filesystemType; |
512 | } | 512 | } |
513 | } | 513 | } |
514 | } | 514 | } |
515 | endmntent( mntfp ); | 515 | endmntent( mntfp ); |
516 | } | 516 | } |
517 | 517 | ||
518 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 518 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
519 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 519 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
520 | QString current = currentText;//.right( currentText.length()-1); | 520 | QString current = currentText;//.right( currentText.length()-1); |
521 | QString baseFs; | 521 | QString baseFs; |
522 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 522 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
523 | QString temp = (*it); | 523 | QString temp = (*it); |
524 | QString path = temp.left(temp.find("::",0,TRUE) ); | 524 | QString path = temp.left(temp.find("::",0,TRUE) ); |
525 | path = path.right( path.length()-1); | 525 | path = path.right( path.length()-1); |
526 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 526 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
527 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 527 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
528 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 528 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
529 | } | 529 | } |
530 | } | 530 | } |
531 | return baseFs; | 531 | return baseFs; |
532 | } | 532 | } |
533 | 533 | ||
534 | QString AdvancedFm::getDiskSpace( const QString &path) { | 534 | QString AdvancedFm::getDiskSpace( const QString &path) { |
535 | struct statfs fss; | 535 | struct statfs fss; |
536 | if ( !statfs( path.latin1(), &fss ) ) { | 536 | if ( !statfs( path.latin1(), &fss ) ) { |
537 | int blkSize = fss.f_bsize; | 537 | int blkSize = fss.f_bsize; |
538 | // int totalBlks = fs.f_blocks; | 538 | // int totalBlks = fs.f_blocks; |
539 | int availBlks = fss.f_bavail; | 539 | int availBlks = fss.f_bavail; |
540 | 540 | ||
541 | long mult = blkSize / 1024; | 541 | long mult = blkSize / 1024; |
542 | long div = 1024 / blkSize; | 542 | long div = 1024 / blkSize; |
543 | if ( !mult ) mult = 1; | 543 | if ( !mult ) mult = 1; |
544 | if ( !div ) div = 1; | 544 | if ( !div ) div = 1; |
545 | 545 | ||
546 | return QString::number(availBlks * mult / div); | 546 | return QString::number(availBlks * mult / div); |
547 | } | 547 | } |
548 | return ""; | 548 | return ""; |
549 | } | 549 | } |
550 | 550 | ||
551 | 551 | ||
552 | void AdvancedFm::showFileMenu() { | 552 | void AdvancedFm::showFileMenu() { |
553 | QString curApp; | 553 | QString curApp; |
554 | curApp = CurrentView()->currentItem()->text(0); | 554 | curApp = CurrentView()->currentItem()->text(0); |
555 | 555 | ||
556 | MimeType mt( curApp ); | 556 | MimeType mt( curApp ); |
557 | const AppLnk* app = mt.application(); | 557 | const AppLnk* app = mt.application(); |
558 | QFile fi(curApp); | 558 | QFile fi(curApp); |
559 | QPopupMenu *m = new QPopupMenu(0); | 559 | QPopupMenu *m = new QPopupMenu(0); |
560 | QPopupMenu *n = new QPopupMenu(0); | 560 | QPopupMenu *n = new QPopupMenu(0); |
561 | // QPopupMenu *o = new QPopupMenu(0); | 561 | // QPopupMenu *o = new QPopupMenu(0); |
562 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 562 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
563 | 563 | ||
564 | if ( QFileInfo(fi).isDir() ) { | 564 | if ( QFileInfo(fi).isDir() ) { |
565 | m->insertSeparator(); | 565 | m->insertSeparator(); |
566 | m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); | 566 | m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); |
567 | } else { | 567 | } else { |
568 | 568 | ||
569 | if ( app ) | 569 | if ( app ) |
570 | m->insertItem( app->pixmap(), tr( "Open in " | 570 | m->insertItem( app->pixmap(), tr( "Open in " |
571 | + app->name() ), this, SLOT( runThis() ) ); | 571 | + app->name() ), this, SLOT( runThis() ) ); |
572 | else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 572 | else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
573 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); | 573 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); |
574 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); | 574 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); |
575 | } | 575 | } |
576 | 576 | ||
577 | m->insertItem(tr("Actions"),n); | 577 | m->insertItem(tr("Actions"),n); |
578 | n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); | 578 | n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); |
579 | 579 | ||
580 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 580 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
581 | 581 | ||
582 | n->insertSeparator(); | 582 | n->insertSeparator(); |
583 | n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); | 583 | n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); |
584 | 584 | ||
585 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); | 585 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); |
586 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 586 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
587 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); | 587 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); |
588 | n->insertItem( tr( "Move" ), this, SLOT( move() )); | 588 | n->insertItem( tr( "Move" ), this, SLOT( move() )); |
589 | 589 | ||
590 | n->insertSeparator(); | 590 | n->insertSeparator(); |
591 | n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); | 591 | n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); |
592 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 592 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
593 | 593 | ||
594 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 594 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
595 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 595 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
596 | 596 | ||
597 | m->insertSeparator(); | 597 | m->insertSeparator(); |
598 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 598 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
599 | 599 | ||
600 | #if defined(QT_QWS_OPIE) | 600 | #if defined(QT_QWS_OPIE) |
601 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 601 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
602 | #endif | 602 | #endif |
603 | m->setCheckable(TRUE); | 603 | m->setCheckable(TRUE); |
604 | if (!b) | 604 | if (!b) |
605 | m->setItemChecked(m->idAt(0),TRUE); | 605 | m->setItemChecked(m->idAt(0),TRUE); |
606 | else | 606 | else |
607 | m->setItemChecked(m->idAt(0),FALSE); | 607 | m->setItemChecked(m->idAt(0),FALSE); |
608 | 608 | ||
609 | if(Ir::supported()) | 609 | if(Ir::supported()) |
610 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); | 610 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); |
611 | m->setFocus(); | 611 | m->setFocus(); |
612 | m->exec( QPoint( 4,QCursor::pos().y()) ); | 612 | |
613 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | ||
613 | 614 | ||
614 | if(m) delete m; | 615 | if(m) delete m; |
615 | } | 616 | } |
616 | 617 | ||
617 | 618 | ||
618 | void AdvancedFm::cancelMenuTimer() { | 619 | void AdvancedFm::cancelMenuTimer() { |
619 | 620 | ||
620 | if( menuTimer.isActive() ) | 621 | if( menuTimer.isActive() ) |
621 | menuTimer.stop(); | 622 | menuTimer.stop(); |
622 | } | 623 | } |
623 | 624 | ||
624 | QString AdvancedFm::checkDiskSpace(const QString &path) { | 625 | QString AdvancedFm::checkDiskSpace(const QString &path) { |
625 | struct statfs fss; | 626 | struct statfs fss; |
626 | if ( !statfs( path.latin1(), &fss ) ) { | 627 | if ( !statfs( path.latin1(), &fss ) ) { |
627 | int blkSize = fss.f_bsize; | 628 | int blkSize = fss.f_bsize; |
628 | // int totalBlks = fs.f_blocks; | 629 | // int totalBlks = fs.f_blocks; |
629 | int availBlks = fss.f_bavail; | 630 | int availBlks = fss.f_bavail; |
630 | 631 | ||
631 | long mult = blkSize / 1024; | 632 | long mult = blkSize / 1024; |
632 | long div = 1024 / blkSize; | 633 | long div = 1024 / blkSize; |
633 | if ( !mult ) mult = 1; | 634 | if ( !mult ) mult = 1; |
634 | if ( !div ) div = 1; | 635 | if ( !div ) div = 1; |
635 | 636 | ||
636 | 637 | ||
637 | return QString::number(availBlks * mult / div); | 638 | return QString::number(availBlks * mult / div); |
638 | } | 639 | } |
639 | return ""; | 640 | return ""; |
640 | } | 641 | } |
641 | 642 | ||
642 | void AdvancedFm::addToDocs() { | 643 | void AdvancedFm::addToDocs() { |
643 | QStringList strListPaths = getPath(); | 644 | QStringList strListPaths = getPath(); |
644 | QDir *thisDir = CurrentDir(); | 645 | QDir *thisDir = CurrentDir(); |
645 | 646 | ||
646 | if( strListPaths.count() > 0) { | 647 | if( strListPaths.count() > 0) { |
647 | QString curFile; | 648 | QString curFile; |
648 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { | 649 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { |
649 | curFile = thisDir->canonicalPath()+"/"+(*it); | 650 | curFile = thisDir->canonicalPath()+"/"+(*it); |
650 | // qDebug(curFile); | 651 | // qDebug(curFile); |
651 | QFileInfo fi(curFile); | 652 | QFileInfo fi(curFile); |
652 | DocLnk f; | 653 | DocLnk f; |
653 | // curFile.replace(QRegExp("\\..*"),""); | 654 | // curFile.replace(QRegExp("\\..*"),""); |
654 | f.setName(fi.baseName() ); | 655 | f.setName(fi.baseName() ); |
655 | f.setFile( curFile); | 656 | f.setFile( curFile); |
656 | f.writeLink(); | 657 | f.writeLink(); |
657 | } | 658 | } |
658 | } | 659 | } |
659 | } | 660 | } |
660 | 661 | ||
661 | 662 | ||
662 | void AdvancedFm::customDirsToMenu() { | 663 | void AdvancedFm::customDirsToMenu() { |
663 | 664 | ||
664 | Config cfg("AdvancedFm"); | 665 | Config cfg("AdvancedFm"); |
665 | cfg.setGroup("Menu"); | 666 | cfg.setGroup("Menu"); |
666 | 667 | ||
667 | QStringList list = cfg.readListEntry( "CustomDir", ','); | 668 | QStringList list = cfg.readListEntry( "CustomDir", ','); |
668 | menuButton->insertItems(list ); | 669 | menuButton->insertItems(list ); |
669 | 670 | ||
670 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 671 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
671 | // { | 672 | // { |
672 | // customDirMenu->insertItem(*it ); | 673 | // customDirMenu->insertItem(*it ); |
673 | // } | 674 | // } |
674 | } | 675 | } |
675 | 676 | ||
676 | void AdvancedFm::dirMenuSelected(int item) { | 677 | void AdvancedFm::dirMenuSelected(int item) { |
677 | switch(item) | 678 | switch(item) |
678 | { | 679 | { |
679 | 680 | ||
680 | case -21: | 681 | case -21: |
681 | case 0: | 682 | case 0: |
682 | addCustomDir(); | 683 | addCustomDir(); |
683 | break; | 684 | break; |
684 | case -22: | 685 | case -22: |
685 | case 1: | 686 | case 1: |
686 | removeCustomDir(); | 687 | removeCustomDir(); |
687 | break; | 688 | break; |
688 | default: | 689 | default: |
689 | { | 690 | { |
690 | // gotoCustomDir( menuButton->text(item)); | 691 | // gotoCustomDir( menuButton->text(item)); |
691 | // gotoCustomDir( customDirMenu->text(item)); | 692 | // gotoCustomDir( customDirMenu->text(item)); |
692 | } | 693 | } |
693 | break; | 694 | break; |
694 | 695 | ||
695 | }; | 696 | }; |
696 | } | 697 | } |
697 | 698 | ||
698 | void AdvancedFm::addCustomDir() { | 699 | void AdvancedFm::addCustomDir() { |
699 | Config cfg("AdvancedFm"); | 700 | Config cfg("AdvancedFm"); |
700 | cfg.setGroup("Menu"); | 701 | cfg.setGroup("Menu"); |
701 | QString dir; | 702 | QString dir; |
702 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 703 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
703 | 704 | ||
704 | dir = CurrentDir()->canonicalPath(); | 705 | dir = CurrentDir()->canonicalPath(); |
705 | 706 | ||
706 | bool addIt=true; | 707 | bool addIt=true; |
707 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 708 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
708 | if( dir == (*it)) { | 709 | if( dir == (*it)) { |
709 | addIt=false; | 710 | addIt=false; |
710 | } | 711 | } |
711 | } | 712 | } |
712 | if(addIt) { | 713 | if(addIt) { |
713 | menuButton->insertItem(dir); | 714 | menuButton->insertItem(dir); |
714 | // customDirMenu->insertItem(dir); | 715 | // customDirMenu->insertItem(dir); |
715 | list << dir; | 716 | list << dir; |
716 | } | 717 | } |
717 | 718 | ||
718 | cfg.writeEntry("CustomDir", list, ','); | 719 | cfg.writeEntry("CustomDir", list, ','); |
719 | cfg.write(); | 720 | cfg.write(); |
720 | } | 721 | } |
721 | 722 | ||
722 | void AdvancedFm::removeCustomDir() { | 723 | void AdvancedFm::removeCustomDir() { |
723 | // qDebug("remove custom dir"); | 724 | // qDebug("remove custom dir"); |
724 | Config cfg("AdvancedFm"); | 725 | Config cfg("AdvancedFm"); |
725 | cfg.setGroup("Menu"); | 726 | cfg.setGroup("Menu"); |
726 | QString dir; | 727 | QString dir; |
727 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 728 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
728 | QStringList list2; | 729 | QStringList list2; |
729 | dir = CurrentDir()->canonicalPath(); | 730 | dir = CurrentDir()->canonicalPath(); |
730 | int ramble=2; | 731 | int ramble=2; |
731 | // int ramble=-24; | 732 | // int ramble=-24; |
732 | //first remove list | 733 | //first remove list |
733 | if(list.grep(dir,true).isEmpty()) { | 734 | if(list.grep(dir,true).isEmpty()) { |
734 | QMessageBox::message(tr( "AdvancedFm" ), | 735 | QMessageBox::message(tr( "AdvancedFm" ), |
735 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); | 736 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); |
736 | } else { | 737 | } else { |
737 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 738 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
738 | if((*it) != dir) { | 739 | if((*it) != dir) { |
739 | //current item is not our current dir, so add it to temp list | 740 | //current item is not our current dir, so add it to temp list |
740 | list2 <<(*it); | 741 | list2 <<(*it); |
741 | } else { | 742 | } else { |
742 | // customDirMenu->removeItem( ramble); | 743 | // customDirMenu->removeItem( ramble); |
743 | menuButton->remove( ramble); | 744 | menuButton->remove( ramble); |
744 | 745 | ||
745 | } | 746 | } |
746 | ramble++; | 747 | ramble++; |
747 | // ramble--; | 748 | // ramble--; |
748 | } | 749 | } |
749 | 750 | ||
750 | cfg.writeEntry("CustomDir", list2, ','); | 751 | cfg.writeEntry("CustomDir", list2, ','); |
751 | cfg.write(); | 752 | cfg.write(); |
752 | } | 753 | } |
753 | // customDirsToMenu(); | 754 | // customDirsToMenu(); |
754 | 755 | ||
755 | } | 756 | } |
756 | 757 | ||
757 | void AdvancedFm::gotoCustomDir(const QString &dir) { | 758 | void AdvancedFm::gotoCustomDir(const QString &dir) { |
758 | // qDebug("gotoCustomDir(const QString &dir) " +dir ); | 759 | // qDebug("gotoCustomDir(const QString &dir) " +dir ); |
759 | // QString curDir = dir; | 760 | // QString curDir = dir; |
760 | // QDir *thisDir = CurrentDir(); | 761 | // QDir *thisDir = CurrentDir(); |
761 | // if( curDir.isEmpty()) { | 762 | // if( curDir.isEmpty()) { |
762 | // } | 763 | // } |
763 | if( dir == s_addBookmark) { | 764 | if( dir == s_addBookmark) { |
764 | addCustomDir(); | 765 | addCustomDir(); |
765 | } | 766 | } |
766 | if( dir == s_removeBookmark) { | 767 | if( dir == s_removeBookmark) { |
767 | removeCustomDir( ); | 768 | removeCustomDir( ); |
768 | } else { | 769 | } else { |
769 | gotoDirectory( dir); | 770 | gotoDirectory( dir); |
770 | // if(QDir( curDir).exists() ) | 771 | // if(QDir( curDir).exists() ) |
771 | // { | 772 | // { |
772 | // thisDir->setPath( curDir ); | 773 | // thisDir->setPath( curDir ); |
773 | // chdir( curDir.latin1() ); | 774 | // chdir( curDir.latin1() ); |
774 | // thisDir->cd( curDir, TRUE); | 775 | // thisDir->cd( curDir, TRUE); |
775 | // populateView(); | 776 | // populateView(); |
776 | // } | 777 | // } |
777 | } | 778 | } |
778 | } | 779 | } |
779 | 780 | ||
780 | QDir *AdvancedFm::CurrentDir() { | 781 | QDir *AdvancedFm::CurrentDir() { |
781 | 782 | ||
782 | if ( whichTab == 1) { | 783 | if ( whichTab == 1) { |
783 | return ¤tDir; | 784 | return ¤tDir; |
784 | } else { | 785 | } else { |
785 | return ¤tRemoteDir; | 786 | return ¤tRemoteDir; |
786 | } | 787 | } |
787 | } | 788 | } |
788 | 789 | ||
789 | QDir *AdvancedFm::OtherDir() { | 790 | QDir *AdvancedFm::OtherDir() { |
790 | if ( whichTab == 1) { | 791 | if ( whichTab == 1) { |
791 | return ¤tRemoteDir; | 792 | return ¤tRemoteDir; |
792 | } else { | 793 | } else { |
793 | return ¤tDir; | 794 | return ¤tDir; |
794 | } | 795 | } |
795 | } | 796 | } |
796 | 797 | ||
797 | QListView * AdvancedFm::CurrentView() { | 798 | QListView * AdvancedFm::CurrentView() { |
798 | if ( whichTab == 1) { | 799 | if ( whichTab == 1) { |
799 | // qWarning("CurrentView Tab 1"); | 800 | // qWarning("CurrentView Tab 1"); |
800 | return Local_View; | 801 | return Local_View; |
801 | } else { | 802 | } else { |
802 | // qWarning("CurrentView Tab 2"); | 803 | // qWarning("CurrentView Tab 2"); |
803 | return Remote_View; | 804 | return Remote_View; |
804 | } | 805 | } |
805 | } | 806 | } |
806 | 807 | ||
807 | QListView * AdvancedFm::OtherView() { | 808 | QListView * AdvancedFm::OtherView() { |
808 | if ( whichTab == 1) | 809 | if ( whichTab == 1) |
809 | return Remote_View; | 810 | return Remote_View; |
810 | else | 811 | else |
811 | return Local_View; | 812 | return Local_View; |
812 | } | 813 | } |
813 | 814 | ||
814 | void AdvancedFm::setOtherTabCurrent() { | 815 | void AdvancedFm::setOtherTabCurrent() { |
815 | qWarning("setOtherTabCurrent() %d", whichTab); | 816 | qWarning("setOtherTabCurrent() %d", whichTab); |
816 | if ( whichTab == 1) { | 817 | if ( whichTab == 1) { |
817 | TabWidget->setCurrentWidget(1); | 818 | TabWidget->setCurrentWidget(1); |
818 | } else { | 819 | } else { |
819 | TabWidget->setCurrentWidget(0); | 820 | TabWidget->setCurrentWidget(0); |
820 | } | 821 | } |
821 | OtherView()->setFocus(); | 822 | OtherView()->setFocus(); |
822 | OtherView()->setSelected( CurrentView()->firstChild(), true); | 823 | OtherView()->setSelected( CurrentView()->firstChild(), true); |
823 | } | 824 | } |
824 | 825 | ||
825 | void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { | 826 | void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { |
826 | // qDebug("qcop message "+msg ); | 827 | // qDebug("qcop message "+msg ); |
827 | QDataStream stream ( data, IO_ReadOnly ); | 828 | QDataStream stream ( data, IO_ReadOnly ); |
828 | if ( msg == "openDirectory(QString)" ) { | 829 | if ( msg == "openDirectory(QString)" ) { |
829 | // qDebug("received"); | 830 | // qDebug("received"); |
830 | QString file; | 831 | QString file; |
831 | stream >> file; | 832 | stream >> file; |
832 | gotoDirectory( (const QString &) file); | 833 | gotoDirectory( (const QString &) file); |
833 | } | 834 | } |
834 | } | 835 | } |
835 | 836 | ||
836 | void AdvancedFm::setDocument(const QString &file) { | 837 | void AdvancedFm::setDocument(const QString &file) { |
837 | gotoDirectory( file); | 838 | gotoDirectory( file); |
838 | 839 | ||
839 | } | 840 | } |
840 | 841 | ||
841 | void AdvancedFm::gotoDirectory(const QString &file) { | 842 | void AdvancedFm::gotoDirectory(const QString &file) { |
842 | // qWarning("goto dir "+file); | 843 | // qWarning("goto dir "+file); |
843 | QString curDir = file; | 844 | QString curDir = file; |
844 | QDir *thisDir = CurrentDir(); | 845 | QDir *thisDir = CurrentDir(); |
845 | if(QDir( curDir).exists() ) { | 846 | if(QDir( curDir).exists() ) { |
846 | thisDir->setPath( curDir ); | 847 | thisDir->setPath( curDir ); |
847 | chdir( curDir.latin1() ); | 848 | chdir( curDir.latin1() ); |
848 | thisDir->cd( curDir, TRUE); | 849 | thisDir->cd( curDir, TRUE); |
849 | populateView(); | 850 | populateView(); |
850 | } | 851 | } |
851 | else if(QFileInfo(curDir).exists()) { | 852 | else if(QFileInfo(curDir).exists()) { |
852 | QFileInfo fileInfo(curDir); | 853 | QFileInfo fileInfo(curDir); |
853 | curDir=fileInfo.dirPath(); | 854 | curDir=fileInfo.dirPath(); |
854 | if(QDir( curDir).exists() ) { | 855 | if(QDir( curDir).exists() ) { |
855 | thisDir->setPath( curDir ); | 856 | thisDir->setPath( curDir ); |
856 | chdir( curDir.latin1() ); | 857 | chdir( curDir.latin1() ); |
857 | thisDir->cd( curDir, TRUE); | 858 | thisDir->cd( curDir, TRUE); |
858 | populateView(); | 859 | populateView(); |
859 | } | 860 | } |
860 | findFile(file); | 861 | findFile(file); |
861 | } | 862 | } |
862 | 863 | ||
863 | } | 864 | } |
864 | 865 | ||
865 | void AdvancedFm::findFile(const QString &fileName) { | 866 | void AdvancedFm::findFile(const QString &fileName) { |
866 | QFileInfo fi(fileName); | 867 | QFileInfo fi(fileName); |
867 | QListView *thisView = CurrentView(); | 868 | QListView *thisView = CurrentView(); |
868 | QListViewItemIterator it( thisView ); | 869 | QListViewItemIterator it( thisView ); |
869 | for ( ; it.current(); ++it ) { | 870 | for ( ; it.current(); ++it ) { |
870 | if(it.current()->text(0) == fi.fileName()) { | 871 | if(it.current()->text(0) == fi.fileName()) { |
871 | it.current()->setSelected(true); | 872 | it.current()->setSelected(true); |
872 | thisView->ensureItemVisible(it.current()); | 873 | thisView->ensureItemVisible(it.current()); |
873 | } | 874 | } |
874 | } | 875 | } |
875 | } | 876 | } |
876 | 877 | ||
877 | void AdvancedFm::slotSwitchMenu(int ) { | 878 | void AdvancedFm::slotSwitchMenu(int ) { |
878 | // qDebug("Switch %d", item); | 879 | // qDebug("Switch %d", item); |
879 | // viewMenu->setItemChecked(item, true); | 880 | // viewMenu->setItemChecked(item, true); |
880 | } | 881 | } |
881 | 882 | ||
882 | void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) { | 883 | void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) { |
883 | tabChanged( w); | 884 | tabChanged( w); |
884 | if( w == Local_View) { | 885 | if( w == Local_View) { |
885 | Remote_View->clearFocus(); | 886 | Remote_View->clearFocus(); |
886 | } else { | 887 | } else { |
887 | Local_View->clearFocus(); | 888 | Local_View->clearFocus(); |
888 | } | 889 | } |
889 | } | 890 | } |
890 | 891 | ||
891 | void AdvancedFm::navigateToSelected() { | 892 | void AdvancedFm::navigateToSelected() { |
892 | if( !CurrentView()->currentItem()) return; | 893 | if( !CurrentView()->currentItem()) return; |
893 | doDirChange(); | 894 | doDirChange(); |
894 | } | 895 | } |