-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 71 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 267 |
2 files changed, 150 insertions, 188 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 60558e7..77dca49 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -28,283 +28,269 @@ | |||
28 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
29 | #include <qpe/menubutton.h> | 29 | #include <qpe/menubutton.h> |
30 | 30 | ||
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qlistview.h> | 35 | #include <qlistview.h> |
36 | #include <qlabel.h> | 36 | #include <qlabel.h> |
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | #include <qimage.h> | 39 | #include <qimage.h> |
40 | #include <qmessagebox.h> | 40 | #include <qmessagebox.h> |
41 | #include <qlineedit.h> | 41 | #include <qlineedit.h> |
42 | 42 | ||
43 | #include <sys/stat.h> | 43 | #include <sys/stat.h> |
44 | #include <time.h> | 44 | #include <time.h> |
45 | #include <dirent.h> | 45 | #include <dirent.h> |
46 | #include <fcntl.h> | 46 | #include <fcntl.h> |
47 | #include <sys/vfs.h> | 47 | #include <sys/vfs.h> |
48 | #include <mntent.h> | 48 | #include <mntent.h> |
49 | 49 | ||
50 | AdvancedFm::AdvancedFm( ) | 50 | AdvancedFm::AdvancedFm( ) |
51 | : QMainWindow( ) { | 51 | : QMainWindow( ) { |
52 | init(); | 52 | init(); |
53 | renameBox = 0; | 53 | renameBox = 0; |
54 | 54 | ||
55 | unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 55 | unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
56 | 56 | ||
57 | initConnections(); | 57 | initConnections(); |
58 | whichTab=1; | 58 | whichTab=1; |
59 | rePopulate(); | 59 | rePopulate(); |
60 | currentPathCombo->setFocus(); | 60 | currentPathCombo->setFocus(); |
61 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); | 61 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); |
62 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 62 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
63 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); | 63 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); |
64 | } | 64 | } |
65 | 65 | ||
66 | AdvancedFm::~AdvancedFm() { | 66 | AdvancedFm::~AdvancedFm() { |
67 | } | 67 | } |
68 | 68 | ||
69 | 69 | ||
70 | void AdvancedFm::cleanUp() | 70 | void AdvancedFm::cleanUp() |
71 | { | 71 | { |
72 | QString sfile=QDir::homeDirPath(); | 72 | QString sfile=QDir::homeDirPath(); |
73 | if(sfile.right(1) != "/") | 73 | if(sfile.right(1) != "/") |
74 | sfile+="/._temp"; | 74 | sfile+="/._temp"; |
75 | else | 75 | else |
76 | sfile+="._temp"; | 76 | sfile+="._temp"; |
77 | QFile file( sfile); | 77 | QFile file( sfile); |
78 | if(file.exists()) | 78 | if(file.exists()) |
79 | file.remove(); | 79 | file.remove(); |
80 | } | 80 | } |
81 | 81 | ||
82 | void AdvancedFm::tabChanged(QWidget *w) | 82 | void AdvancedFm::tabChanged(QWidget *w) |
83 | { | 83 | { |
84 | if( w == tab) | 84 | if( w == tab) |
85 | whichTab = 1; | 85 | whichTab = 1; |
86 | else | 86 | else |
87 | whichTab = 2; | 87 | whichTab = 2; |
88 | 88 | ||
89 | // qDebug("tab changed %d", whichTab ); | 89 | // qDebug("tab changed %d", whichTab ); |
90 | 90 | ||
91 | QString path = CurrentDir()->canonicalPath(); | 91 | QString path = CurrentDir()->canonicalPath(); |
92 | currentPathCombo->lineEdit()->setText( path ); | 92 | currentPathCombo->lineEdit()->setText( path ); |
93 | 93 | ||
94 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); | 94 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); |
95 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); | 95 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); |
96 | 96 | ||
97 | QString fs= getFileSystemType( (const QString &) path); | 97 | QString fs= getFileSystemType( (const QString &) path); |
98 | 98 | ||
99 | setCaption("AdvancedFm :: "+fs+" :: " | 99 | setCaption("AdvancedFm :: "+fs+" :: " |
100 | +checkDiskSpace( (const QString &) path )+ " kB free" ); | 100 | +checkDiskSpace( (const QString &) path )+ " kB free" ); |
101 | chdir( path.latin1()); | 101 | chdir( path.latin1()); |
102 | } | 102 | } |
103 | 103 | ||
104 | 104 | ||
105 | void AdvancedFm::populateView() | 105 | void AdvancedFm::populateView() |
106 | { | 106 | { |
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 | thisView->clear(); | 112 | thisView->clear(); |
113 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 113 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
114 | thisDir->setMatchAllDirs(TRUE); | 114 | thisDir->setMatchAllDirs(TRUE); |
115 | thisDir->setNameFilter(filterStr); | 115 | thisDir->setNameFilter(filterStr); |
116 | QString fileL, fileS, fileDate; | 116 | QString fileL, fileS, fileDate; |
117 | QString fs= getFileSystemType((const QString &) path); | 117 | QString fs= getFileSystemType((const QString &) path); |
118 | setCaption("AdvancedFm :: "+fs+" :: " | 118 | setCaption("AdvancedFm :: "+fs+" :: " |
119 | +checkDiskSpace((const QString &) path)+" kB free" ); | 119 | +checkDiskSpace((const QString &) path)+" kB free" ); |
120 | bool isDir=FALSE; | 120 | bool isDir=FALSE; |
121 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 121 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
122 | QFileInfoListIterator it(*list); | 122 | QFileInfoListIterator it(*list); |
123 | QFileInfo *fi; | 123 | QFileInfo *fi; |
124 | while ( (fi=it.current()) ) | 124 | while ( (fi=it.current()) ) { |
125 | { | 125 | if (fi->isSymLink() ) { |
126 | if (fi->isSymLink() ) | ||
127 | { | ||
128 | QString symLink=fi->readLink(); | 126 | QString symLink=fi->readLink(); |
129 | QFileInfo sym( symLink); | 127 | QFileInfo sym( symLink); |
130 | fileS.sprintf( "%10i", sym.size() ); | 128 | fileS.sprintf( "%10i", sym.size() ); |
131 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); | 129 | fileL = fi->fileName() +" -> " + sym.filePath().data(); |
132 | fileDate = sym.lastModified().toString(); | 130 | fileDate = sym.lastModified().toString(); |
133 | } | 131 | } else { |
134 | else | ||
135 | { | ||
136 | fileS.sprintf( "%10i", fi->size() ); | 132 | fileS.sprintf( "%10i", fi->size() ); |
137 | fileL.sprintf( "%s",fi->fileName().data() ); | 133 | fileL = fi->fileName(); |
138 | fileDate= fi->lastModified().toString(); | 134 | fileDate= fi->lastModified().toString(); |
139 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) | 135 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { |
140 | { | ||
141 | fileL+="/"; | 136 | fileL+="/"; |
142 | isDir=TRUE; | 137 | isDir=TRUE; |
143 | } | 138 | } |
144 | } | 139 | } |
145 | |||
146 | QFileInfo fileInfo( path + "/" + fileL); | 140 | QFileInfo fileInfo( path + "/" + fileL); |
147 | 141 | ||
148 | if(fileL !="./" && fi->exists()) | 142 | if(fileL !="./" && fi->exists()) { |
149 | { | 143 | item = new QListViewItem( thisView, fileL, fileS , fileDate); |
150 | item= new QListViewItem( thisView, fileL, fileS , fileDate); | ||
151 | 144 | ||
152 | if(isDir || fileL.find("/",0,TRUE) != -1) | 145 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
153 | { | ||
154 | 146 | ||
155 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 147 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
156 | pm = Resource::loadPixmap( "lockedfolder" ); | 148 | pm = Resource::loadPixmap( "lockedfolder" ); |
157 | else | 149 | else |
158 | pm= Resource::loadPixmap( "folder" ); | 150 | pm= Resource::loadPixmap( "folder" ); |
159 | } | 151 | } |
160 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) | 152 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
161 | { | 153 | pm = Resource::loadPixmap( "exec"); |
162 | pm = Resource::loadPixmap( "exec"); | ||
163 | } | 154 | } |
164 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 155 | else if( (fileInfo.permission( QFileInfo::ExeUser) |
165 | | fileInfo.permission( QFileInfo::ExeGroup) | 156 | | fileInfo.permission( QFileInfo::ExeGroup) |
166 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) | 157 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
167 | { | ||
168 | pm = Resource::loadPixmap( "exec"); | 158 | pm = Resource::loadPixmap( "exec"); |
169 | } | 159 | } |
170 | else if( !fi->isReadable() ) | 160 | else if( !fi->isReadable() ) { |
171 | { | ||
172 | pm = Resource::loadPixmap( "locked" ); | 161 | pm = Resource::loadPixmap( "locked" ); |
173 | } | 162 | } |
174 | else { //everything else goes by mimetype | 163 | else { //everything else goes by mimetype |
175 | MimeType mt(fi->filePath()); | 164 | MimeType mt(fi->filePath()); |
176 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 165 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
177 | if(pm.isNull()) { | 166 | if(pm.isNull()) { |
178 | pm = unknownXpm; | 167 | pm = unknownXpm; |
179 | } | 168 | } |
180 | } | 169 | } |
181 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) | 170 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { |
182 | { | 171 | // qDebug(" overlay link image"); |
183 | // overlay link image | 172 | pm= Resource::loadPixmap( "advancedfm/symlink" ); |
184 | pm= Resource::loadPixmap( "folder" ); | 173 | // pm= Resource::loadPixmap( "folder" ); |
185 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 174 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
186 | QPainter painter( &pm ); | 175 | // QPainter painter( &pm ); |
187 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 176 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
188 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 177 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); |
189 | } | 178 | } |
190 | item->setPixmap( 0,pm); | 179 | item->setPixmap( 0,pm); |
191 | 180 | ||
192 | } | 181 | } |
193 | isDir=FALSE; | 182 | isDir=FALSE; |
194 | ++it; | 183 | ++it; |
195 | } | 184 | } |
196 | 185 | ||
197 | if( path.find("dev",0,TRUE) != -1) | 186 | if( path.find("dev",0,TRUE) != -1) { |
198 | { | ||
199 | struct stat buf; | 187 | struct stat buf; |
200 | dev_t devT; | 188 | dev_t devT; |
201 | DIR *dir; | 189 | DIR *dir; |
202 | struct dirent *mydirent; | 190 | struct dirent *mydirent; |
203 | 191 | ||
204 | if((dir = opendir( path.latin1())) != NULL) | 192 | if((dir = opendir( path.latin1())) != NULL) |
205 | while ((mydirent = readdir(dir)) != NULL) | 193 | while ((mydirent = readdir(dir)) != NULL) { |
206 | { | ||
207 | lstat( mydirent->d_name, &buf); | 194 | lstat( mydirent->d_name, &buf); |
208 | // qDebug(mydirent->d_name); | 195 | // qDebug(mydirent->d_name); |
209 | fileL.sprintf("%s", mydirent->d_name); | 196 | fileL.sprintf("%s", mydirent->d_name); |
210 | devT = buf.st_dev; | 197 | devT = buf.st_dev; |
211 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 198 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
212 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 199 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
213 | if( fileL.find(".") == -1 ) | 200 | if( fileL.find(".") == -1 ) { |
214 | { | ||
215 | item= new QListViewItem( thisView, fileL, fileS, fileDate); | 201 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
216 | pm = unknownXpm; | 202 | pm = unknownXpm; |
217 | item->setPixmap( 0,pm); | 203 | item->setPixmap( 0,pm); |
218 | } | 204 | } |
219 | } | 205 | } |
220 | 206 | ||
221 | closedir(dir); | 207 | closedir(dir); |
222 | } | 208 | } |
223 | 209 | ||
224 | thisView->setSorting( 3,FALSE); | 210 | thisView->setSorting( 3,FALSE); |
225 | fillCombo( (const QString &) path ); | 211 | fillCombo( (const QString &) path ); |
226 | } | 212 | } |
227 | 213 | ||
228 | void AdvancedFm::rePopulate() | 214 | void AdvancedFm::rePopulate() |
229 | { | 215 | { |
230 | int tmpTab = whichTab; | 216 | int tmpTab = whichTab; |
231 | qDebug("%d", tmpTab); | 217 | qDebug("%d", tmpTab); |
232 | 218 | ||
233 | for(int i =1; i < 3; i++) | 219 | for(int i =1; i < 3; i++) |
234 | { | 220 | { |
235 | TabWidget->setCurrentTab(i - 1); | 221 | TabWidget->setCurrentTab(i - 1); |
236 | populateView(); | 222 | populateView(); |
237 | } | 223 | } |
238 | TabWidget->setCurrentTab( tmpTab - 1); | 224 | TabWidget->setCurrentTab( tmpTab - 1); |
239 | } | 225 | } |
240 | 226 | ||
241 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) | 227 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) |
242 | { | 228 | { |
243 | if(selectedItem) | 229 | if(selectedItem) |
244 | { | 230 | { |
245 | QString strItem=selectedItem->text(0); | 231 | QString strItem=selectedItem->text(0); |
246 | QString strSize=selectedItem->text(1); | 232 | QString strSize=selectedItem->text(1); |
247 | strSize=strSize.stripWhiteSpace(); | 233 | strSize=strSize.stripWhiteSpace(); |
248 | bool isDirectory = false; | 234 | bool isDirectory = false; |
249 | QString strItem2; | 235 | QString strItem2; |
250 | 236 | ||
251 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink | 237 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink |
252 | { | 238 | { |
253 | strItem2 = dealWithSymName((const QString&)strItem); | 239 | strItem2 = dealWithSymName((const QString&)strItem); |
254 | if(QDir(strItem2).exists() ) | 240 | if(QDir(strItem2).exists() ) |
255 | strItem = strItem2; | 241 | strItem = strItem2; |
256 | } | 242 | } |
257 | 243 | ||
258 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) | 244 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) |
259 | { | 245 | { |
260 | 246 | ||
261 | if(QDir(strItem).exists()) | 247 | if(QDir(strItem).exists()) |
262 | isDirectory = true; | 248 | isDirectory = true; |
263 | } | 249 | } |
264 | 250 | ||
265 | if( isDirectory ) | 251 | if( isDirectory ) |
266 | { | 252 | { |
267 | CurrentDir()->cd( strItem, TRUE); | 253 | CurrentDir()->cd( strItem, TRUE); |
268 | populateView(); | 254 | populateView(); |
269 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); | 255 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); |
270 | } | 256 | } |
271 | chdir( strItem.latin1()); | 257 | chdir( strItem.latin1()); |
272 | } | 258 | } |
273 | } | 259 | } |
274 | 260 | ||
275 | void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 261 | void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
276 | switch (mouse) { | 262 | switch (mouse) { |
277 | case 1: | 263 | case 1: |
278 | { | 264 | { |
279 | if(renameBox != 0 ) | 265 | if(renameBox != 0 ) |
280 | { | 266 | { |
281 | cancelRename(); | 267 | cancelRename(); |
282 | } | 268 | } |
283 | } | 269 | } |
284 | break; | 270 | break; |
285 | case 2: | 271 | case 2: |
286 | menuTimer.start( 500, TRUE ); | 272 | menuTimer.start( 500, TRUE ); |
287 | break; | 273 | break; |
288 | }; | 274 | }; |
289 | } | 275 | } |
290 | 276 | ||
291 | void AdvancedFm::switchToLocalTab() | 277 | void AdvancedFm::switchToLocalTab() |
292 | { | 278 | { |
293 | TabWidget->setCurrentTab(0); | 279 | TabWidget->setCurrentTab(0); |
294 | Local_View->setFocus(); | 280 | Local_View->setFocus(); |
295 | } | 281 | } |
296 | 282 | ||
297 | void AdvancedFm::switchToRemoteTab() | 283 | void AdvancedFm::switchToRemoteTab() |
298 | { | 284 | { |
299 | TabWidget->setCurrentTab(1); | 285 | TabWidget->setCurrentTab(1); |
300 | Remote_View->setFocus(); | 286 | Remote_View->setFocus(); |
301 | } | 287 | } |
302 | 288 | ||
303 | void AdvancedFm::readConfig() | 289 | void AdvancedFm::readConfig() |
304 | { | 290 | { |
305 | Config cfg("AdvancedFm"); | 291 | Config cfg("AdvancedFm"); |
306 | } | 292 | } |
307 | 293 | ||
308 | void AdvancedFm::writeConfig() | 294 | void AdvancedFm::writeConfig() |
309 | { | 295 | { |
310 | Config cfg("AdvancedFm"); | 296 | Config cfg("AdvancedFm"); |
@@ -587,202 +573,201 @@ void AdvancedFm::showFileMenu() | |||
587 | const AppLnk* app = mt.application(); | 573 | const AppLnk* app = mt.application(); |
588 | QFile fi(curApp); | 574 | QFile fi(curApp); |
589 | QPopupMenu *m = new QPopupMenu(0); | 575 | QPopupMenu *m = new QPopupMenu(0); |
590 | QPopupMenu *n = new QPopupMenu(0); | 576 | QPopupMenu *n = new QPopupMenu(0); |
591 | // QPopupMenu *o = new QPopupMenu(0); | 577 | // QPopupMenu *o = new QPopupMenu(0); |
592 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 578 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
593 | 579 | ||
594 | if ( QFileInfo(fi).isDir() ) | 580 | if ( QFileInfo(fi).isDir() ) |
595 | { | 581 | { |
596 | m->insertSeparator(); | 582 | m->insertSeparator(); |
597 | m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); | 583 | m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); |
598 | } | 584 | } |
599 | else | 585 | else |
600 | { | 586 | { |
601 | 587 | ||
602 | if ( app ) | 588 | if ( app ) |
603 | m->insertItem( app->pixmap(), tr( "Open in " | 589 | m->insertItem( app->pixmap(), tr( "Open in " |
604 | + app->name() ), this, SLOT( runThis() ) ); | 590 | + app->name() ), this, SLOT( runThis() ) ); |
605 | else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 591 | else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
606 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); | 592 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); |
607 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); | 593 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); |
608 | } | 594 | } |
609 | 595 | ||
610 | m->insertItem(tr("Actions"),n); | 596 | m->insertItem(tr("Actions"),n); |
611 | n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); | 597 | n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); |
612 | 598 | ||
613 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 599 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
614 | 600 | ||
615 | n->insertSeparator(); | 601 | n->insertSeparator(); |
616 | n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); | 602 | n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); |
617 | 603 | ||
618 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); | 604 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); |
619 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 605 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
620 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); | 606 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); |
621 | n->insertItem( tr( "Move" ), this, SLOT( move() )); | 607 | n->insertItem( tr( "Move" ), this, SLOT( move() )); |
622 | 608 | ||
623 | n->insertSeparator(); | 609 | n->insertSeparator(); |
624 | n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); | 610 | n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); |
625 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 611 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
626 | 612 | ||
627 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 613 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
628 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 614 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
629 | 615 | ||
630 | m->insertSeparator(); | 616 | m->insertSeparator(); |
631 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 617 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
632 | 618 | ||
633 | #if defined(QT_QWS_OPIE) | 619 | #if defined(QT_QWS_OPIE) |
634 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 620 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
635 | #endif | 621 | #endif |
636 | m->setCheckable(TRUE); | 622 | m->setCheckable(TRUE); |
637 | if (!b) | 623 | if (!b) |
638 | m->setItemChecked(m->idAt(0),TRUE); | 624 | m->setItemChecked(m->idAt(0),TRUE); |
639 | else | 625 | else |
640 | m->setItemChecked(m->idAt(0),FALSE); | 626 | m->setItemChecked(m->idAt(0),FALSE); |
641 | 627 | ||
642 | if(Ir::supported()) | 628 | if(Ir::supported()) |
643 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); | 629 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); |
644 | m->setFocus(); | 630 | m->setFocus(); |
645 | m->exec( QPoint( 4,QCursor::pos().y()) ); | 631 | m->exec( QPoint( 4,QCursor::pos().y()) ); |
646 | 632 | ||
647 | if(m) delete m; | 633 | if(m) delete m; |
648 | } | 634 | } |
649 | 635 | ||
650 | 636 | ||
651 | void AdvancedFm::cancelMenuTimer() | 637 | void AdvancedFm::cancelMenuTimer() |
652 | { | 638 | { |
653 | // qDebug("selectionChanged: cancel menu timer"); | 639 | // qDebug("selectionChanged: cancel menu timer"); |
654 | if( menuTimer.isActive() ) | 640 | if( menuTimer.isActive() ) |
655 | menuTimer.stop(); | 641 | menuTimer.stop(); |
656 | } | 642 | } |
657 | 643 | ||
658 | QString AdvancedFm::checkDiskSpace(const QString &path) | 644 | QString AdvancedFm::checkDiskSpace(const QString &path) |
659 | { | 645 | { |
660 | struct statfs fss; | 646 | struct statfs fss; |
661 | if ( !statfs( path.latin1(), &fss ) ) | 647 | if ( !statfs( path.latin1(), &fss ) ) |
662 | { | 648 | { |
663 | int blkSize = fss.f_bsize; | 649 | int blkSize = fss.f_bsize; |
664 | // int totalBlks = fs.f_blocks; | 650 | // int totalBlks = fs.f_blocks; |
665 | int availBlks = fss.f_bavail; | 651 | int availBlks = fss.f_bavail; |
666 | 652 | ||
667 | long mult = blkSize / 1024; | 653 | long mult = blkSize / 1024; |
668 | long div = 1024 / blkSize; | 654 | long div = 1024 / blkSize; |
669 | if ( !mult ) mult = 1; | 655 | if ( !mult ) mult = 1; |
670 | if ( !div ) div = 1; | 656 | if ( !div ) div = 1; |
671 | 657 | ||
672 | 658 | ||
673 | return QString::number(availBlks * mult / div); | 659 | return QString::number(availBlks * mult / div); |
674 | } | 660 | } |
675 | return ""; | 661 | return ""; |
676 | } | 662 | } |
677 | 663 | ||
678 | void AdvancedFm::addToDocs() | 664 | void AdvancedFm::addToDocs() |
679 | { | 665 | { |
680 | QStringList strListPaths = getPath(); | 666 | QStringList strListPaths = getPath(); |
681 | QDir *thisDir = CurrentDir(); | 667 | QDir *thisDir = CurrentDir(); |
682 | 668 | ||
683 | if( strListPaths.count() > 0) | 669 | if( strListPaths.count() > 0) { |
684 | { | ||
685 | QString curFile; | 670 | QString curFile; |
686 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) | 671 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { |
687 | { | ||
688 | curFile = thisDir->canonicalPath()+"/"+(*it); | 672 | curFile = thisDir->canonicalPath()+"/"+(*it); |
689 | // qDebug(curFile); | 673 | // qDebug(curFile); |
674 | QFileInfo fi(curFile); | ||
690 | DocLnk f; | 675 | DocLnk f; |
691 | // curFile.replace(QRegExp("\\..*"),""); | 676 | // curFile.replace(QRegExp("\\..*"),""); |
692 | f.setName((*it)); | 677 | f.setName(fi.baseName() ); |
693 | f.setFile( curFile); | 678 | f.setFile( curFile); |
694 | f.writeLink(); | 679 | f.writeLink(); |
695 | } | 680 | } |
696 | } | 681 | } |
697 | } | 682 | } |
698 | 683 | ||
699 | 684 | ||
700 | void AdvancedFm::customDirsToMenu() | 685 | void AdvancedFm::customDirsToMenu() |
701 | { | 686 | { |
702 | 687 | ||
703 | Config cfg("AdvancedFm"); | 688 | Config cfg("AdvancedFm"); |
704 | cfg.setGroup("Menu"); | 689 | cfg.setGroup("Menu"); |
705 | 690 | ||
706 | QStringList list = cfg.readListEntry( "CustomDir", ','); | 691 | QStringList list = cfg.readListEntry( "CustomDir", ','); |
707 | menuButton->insertItems(list ); | 692 | menuButton->insertItems(list ); |
708 | 693 | ||
709 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 694 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
710 | // { | 695 | // { |
711 | // customDirMenu->insertItem(*it ); | 696 | // customDirMenu->insertItem(*it ); |
712 | // } | 697 | // } |
713 | } | 698 | } |
714 | 699 | ||
715 | void AdvancedFm::dirMenuSelected(int item) | 700 | void AdvancedFm::dirMenuSelected(int item) |
716 | { | 701 | { |
717 | qDebug("menu item %d", item); | 702 | qDebug("menu item %d", item); |
718 | switch(item) | 703 | switch(item) |
719 | { | 704 | { |
720 | 705 | ||
721 | case -21: | 706 | case -21: |
722 | case 0: | 707 | case 0: |
723 | addCustomDir(); | 708 | addCustomDir(); |
724 | break; | 709 | break; |
725 | case -22: | 710 | case -22: |
726 | case 1: | 711 | case 1: |
727 | removeCustomDir(); | 712 | removeCustomDir(); |
728 | break; | 713 | break; |
729 | default: | 714 | default: |
730 | { | 715 | { |
731 | // gotoCustomDir( menuButton->text(item)); | 716 | // gotoCustomDir( menuButton->text(item)); |
732 | // gotoCustomDir( customDirMenu->text(item)); | 717 | // gotoCustomDir( customDirMenu->text(item)); |
733 | } | 718 | } |
734 | break; | 719 | break; |
735 | 720 | ||
736 | }; | 721 | }; |
737 | } | 722 | } |
738 | 723 | ||
739 | void AdvancedFm::addCustomDir() | 724 | void AdvancedFm::addCustomDir() |
740 | { | 725 | { |
741 | Config cfg("AdvancedFm"); | 726 | Config cfg("AdvancedFm"); |
742 | cfg.setGroup("Menu"); | 727 | cfg.setGroup("Menu"); |
743 | QString dir; | 728 | QString dir; |
744 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 729 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
745 | 730 | ||
746 | dir = CurrentDir()->canonicalPath(); | 731 | dir = CurrentDir()->canonicalPath(); |
747 | 732 | ||
748 | bool addIt=true; | 733 | bool addIt=true; |
749 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 734 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
750 | { | 735 | { |
751 | if( dir == (*it)) | 736 | if( dir == (*it)) |
752 | { | 737 | { |
753 | addIt=false; | 738 | addIt=false; |
754 | } | 739 | } |
755 | } | 740 | } |
756 | if(addIt) | 741 | if(addIt) |
757 | { | 742 | { |
758 | menuButton->insertItem(dir); | 743 | menuButton->insertItem(dir); |
759 | // customDirMenu->insertItem(dir); | 744 | // customDirMenu->insertItem(dir); |
760 | list << dir; | 745 | list << dir; |
761 | } | 746 | } |
762 | 747 | ||
763 | cfg.writeEntry("CustomDir", list, ','); | 748 | cfg.writeEntry("CustomDir", list, ','); |
764 | cfg.write(); | 749 | cfg.write(); |
765 | } | 750 | } |
766 | 751 | ||
767 | void AdvancedFm::removeCustomDir() | 752 | void AdvancedFm::removeCustomDir() |
768 | { | 753 | { |
769 | // qDebug("remove custom dir"); | 754 | // qDebug("remove custom dir"); |
770 | Config cfg("AdvancedFm"); | 755 | Config cfg("AdvancedFm"); |
771 | cfg.setGroup("Menu"); | 756 | cfg.setGroup("Menu"); |
772 | QString dir; | 757 | QString dir; |
773 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 758 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
774 | QStringList list2; | 759 | QStringList list2; |
775 | dir = CurrentDir()->canonicalPath(); | 760 | dir = CurrentDir()->canonicalPath(); |
776 | int ramble=2; | 761 | int ramble=2; |
777 | // int ramble=-24; | 762 | // int ramble=-24; |
778 | //first remove list | 763 | //first remove list |
779 | if(list.grep(dir,true).isEmpty()) | 764 | if(list.grep(dir,true).isEmpty()) |
780 | { | 765 | { |
781 | QMessageBox::message(tr( "AdvancedFm" ), | 766 | QMessageBox::message(tr( "AdvancedFm" ), |
782 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); | 767 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); |
783 | } | 768 | } |
784 | else | 769 | else |
785 | { | 770 | { |
786 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 771 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
787 | { | 772 | { |
788 | if((*it) != dir)//current item is not our current dir, so add it to temp list | 773 | if((*it) != dir)//current item is not our current dir, so add it to temp list |
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 9f21245..00d0e07 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,834 +1,811 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | #include "output.h" | 13 | #include "output.h" |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <opie/otabwidget.h> | 16 | #include <opie/otabwidget.h> |
17 | #include <opie/oprocess.h> | 17 | #include <opie/oprocess.h> |
18 | 18 | ||
19 | #include <qpe/lnkproperties.h> | 19 | #include <qpe/lnkproperties.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/applnk.h> | 23 | #include <qpe/applnk.h> |
24 | #include <qpe/ir.h> | 24 | #include <qpe/ir.h> |
25 | 25 | ||
26 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
27 | #include <qmultilineedit.h> | 27 | #include <qmultilineedit.h> |
28 | 28 | ||
29 | #include <qstring.h> | 29 | #include <qstring.h> |
30 | 30 | ||
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | #include <qpixmap.h> | 32 | #include <qpixmap.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtabwidget.h> | 35 | #include <qtabwidget.h> |
36 | #include <qtoolbutton.h> | 36 | #include <qtoolbutton.h> |
37 | #include <qtabwidget.h> | 37 | #include <qtabwidget.h> |
38 | #include <qlineedit.h> | 38 | #include <qlineedit.h> |
39 | #include <qlistview.h> | 39 | #include <qlistview.h> |
40 | 40 | ||
41 | #include <errno.h> | ||
41 | #include <stdlib.h> | 42 | #include <stdlib.h> |
42 | #include <unistd.h> | 43 | #include <unistd.h> |
43 | #include <sys/stat.h> | 44 | #include <sys/stat.h> |
44 | #include <dirent.h> | 45 | #include <dirent.h> |
45 | #include <sys/sendfile.h> | 46 | #include <sys/sendfile.h> |
46 | #include <fcntl.h> | 47 | #include <fcntl.h> |
47 | 48 | ||
49 | |||
48 | void AdvancedFm::doDirChange() | 50 | void AdvancedFm::doDirChange() |
49 | { | 51 | { |
50 | ListClicked( CurrentView()->currentItem()); | 52 | ListClicked( CurrentView()->currentItem()); |
51 | } | 53 | } |
52 | 54 | ||
53 | void AdvancedFm::showMenuHidden() | 55 | void AdvancedFm::showMenuHidden() |
54 | { | 56 | { |
55 | if (b) | 57 | if (b) |
56 | { | 58 | { |
57 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 59 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
58 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 60 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
59 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 61 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
60 | // b=FALSE; | 62 | // b=FALSE; |
61 | 63 | ||
62 | } | 64 | } |
63 | else | 65 | else |
64 | { | 66 | { |
65 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 67 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
66 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 68 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
67 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 69 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
68 | // b=TRUE; | 70 | // b=TRUE; |
69 | } | 71 | } |
70 | rePopulate(); | 72 | rePopulate(); |
71 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); | 73 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); |
72 | if(b) b = false; else b = true; | 74 | if(b) b = false; else b = true; |
73 | } | 75 | } |
74 | 76 | ||
75 | void AdvancedFm::showHidden() | 77 | void AdvancedFm::showHidden() |
76 | { | 78 | { |
77 | if (b) | 79 | if (b) |
78 | { | 80 | { |
79 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 81 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
80 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 82 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
81 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 83 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
82 | // b=FALSE; | 84 | // b=FALSE; |
83 | 85 | ||
84 | } | 86 | } |
85 | else | 87 | else |
86 | { | 88 | { |
87 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 89 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
88 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 90 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
89 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 91 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
90 | // b=TRUE; | 92 | // b=TRUE; |
91 | } | 93 | } |
92 | rePopulate(); | 94 | rePopulate(); |
93 | } | 95 | } |
94 | 96 | ||
95 | QString AdvancedFm::dealWithSymName(const QString &fileName) | 97 | QString AdvancedFm::dealWithSymName(const QString &fileName) |
96 | { | 98 | { |
97 | QString strItem = fileName; | 99 | QString strItem = fileName; |
98 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 100 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
99 | } | 101 | } |
100 | 102 | ||
101 | void AdvancedFm::runThis() | 103 | void AdvancedFm::runThis() |
102 | { | 104 | { |
103 | QString fs; | 105 | QString fs; |
104 | QDir *thisDir = CurrentDir(); | 106 | QDir *thisDir = CurrentDir(); |
105 | 107 | ||
106 | QString curFile = CurrentView()->currentItem()->text(0); | 108 | QString curFile = CurrentView()->currentItem()->text(0); |
107 | QString path = thisDir->canonicalPath(); | 109 | QString path = thisDir->canonicalPath(); |
108 | 110 | ||
109 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 111 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
110 | 112 | ||
111 | curFile = dealWithSymName((const QString&)curFile); | 113 | curFile = dealWithSymName((const QString&)curFile); |
112 | 114 | ||
113 | if(curFile != "../") | 115 | if(curFile != "../") |
114 | { | 116 | { |
115 | 117 | ||
116 | fs = getFileSystemType((const QString &) path); | 118 | fs = getFileSystemType((const QString &) path); |
117 | QFileInfo fileInfo( path + "/" + curFile); | 119 | QFileInfo fileInfo( path + "/" + curFile); |
118 | qDebug( fileInfo.owner()); | 120 | qDebug( fileInfo.owner()); |
119 | 121 | ||
120 | if( (fileInfo.permission( QFileInfo::ExeUser) | 122 | if( (fileInfo.permission( QFileInfo::ExeUser) |
121 | | fileInfo.permission( QFileInfo::ExeGroup) | 123 | | fileInfo.permission( QFileInfo::ExeGroup) |
122 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 124 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
123 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 125 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
124 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 126 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
125 | e << curFile; | 127 | e << curFile; |
126 | } | 128 | } |
127 | else | 129 | else |
128 | { | 130 | { |
129 | curFile = path + "/" + curFile; | 131 | curFile = path + "/" + curFile; |
130 | DocLnk nf(curFile); | 132 | DocLnk nf(curFile); |
131 | QString execStr = nf.exec(); | 133 | QString execStr = nf.exec(); |
132 | qDebug( execStr); | 134 | qDebug( execStr); |
133 | if( execStr.isEmpty() ) | 135 | if( execStr.isEmpty() ) |
134 | { | 136 | { |
135 | } | 137 | } |
136 | else | 138 | else |
137 | { | 139 | { |
138 | nf.execute(); | 140 | nf.execute(); |
139 | } | 141 | } |
140 | } | 142 | } |
141 | } | 143 | } |
142 | } | 144 | } |
143 | 145 | ||
144 | void AdvancedFm::runText() | 146 | void AdvancedFm::runText() |
145 | { | 147 | { |
146 | QString curFile = CurrentView()->currentItem()->text(0); | 148 | QString curFile = CurrentView()->currentItem()->text(0); |
147 | if(curFile != "../") | 149 | if(curFile != "../") |
148 | { | 150 | { |
149 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 151 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
150 | curFile = dealWithSymName((const QString&)curFile); | 152 | curFile = dealWithSymName((const QString&)curFile); |
151 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; | 153 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; |
152 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 154 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
153 | e << curFile; | 155 | e << curFile; |
154 | } | 156 | } |
155 | } | 157 | } |
156 | 158 | ||
157 | void AdvancedFm::makeDir() | 159 | void AdvancedFm::makeDir() |
158 | { | 160 | { |
159 | InputDialog *fileDlg; | 161 | InputDialog *fileDlg; |
160 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 162 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
161 | fileDlg->exec(); | 163 | fileDlg->exec(); |
162 | if( fileDlg->result() == 1 ) | 164 | if( fileDlg->result() == 1 ) |
163 | { | 165 | { |
164 | QDir *thisDir = CurrentDir(); | 166 | QDir *thisDir = CurrentDir(); |
165 | QString filename = fileDlg->LineEdit1->text(); | 167 | QString filename = fileDlg->LineEdit1->text(); |
166 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 168 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
167 | } | 169 | } |
168 | populateView(); | 170 | populateView(); |
169 | } | 171 | } |
170 | 172 | ||
171 | void AdvancedFm::doDelete() | 173 | void AdvancedFm::doDelete() |
172 | { | 174 | { |
173 | 175 | QStringList curFileList = getPath(); | |
174 | QStringList curFileList = getPath(); | 176 | bool doMsg=true; |
175 | bool doMsg=true; | 177 | int count = curFileList.count(); |
176 | int count = curFileList.count(); | 178 | if( count > 0) { |
177 | if( count > 0) | 179 | if(count > 1 ) { |
178 | { | 180 | QString msg; |
179 | if(count > 1 ) | 181 | msg=tr("Really delete\n%1 files?").arg(count); |
180 | { | 182 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
181 | QString msg; | 183 | ,tr("Yes"),tr("No"),0,0,1) ) |
182 | msg=tr("Really delete\n%1 files?").arg(count); | 184 | { |
183 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 185 | case 0: |
184 | ,tr("Yes"),tr("No"),0,0,1) ) | 186 | doMsg=false; |
185 | { | 187 | break; |
186 | case 0: | 188 | case 1: |
187 | doMsg=false; | 189 | return; |
188 | break; | 190 | break; |
189 | case 1: | 191 | }; |
190 | return; | ||
191 | break; | ||
192 | }; | ||
193 | } | 192 | } |
194 | 193 | ||
195 | QString myFile; | 194 | QString myFile; |
196 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | ||
197 | { | ||
198 | myFile = (*it); | ||
199 | if( myFile.find(" -> ",0,TRUE) != -1) | ||
200 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | ||
201 | |||
202 | QString f = CurrentDir()->canonicalPath(); | ||
203 | if(f.right(1).find("/",0,TRUE) == -1) | ||
204 | f += "/"; | ||
205 | f += myFile; | ||
206 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) //if file is a directory | ||
207 | { | ||
208 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), | ||
209 | tr("Really delete %1\nand all it's contents ?" ).arg( f ) , | ||
210 | tr("Yes"), | ||
211 | tr("No"), | ||
212 | 0, | ||
213 | 0, | ||
214 | 1) ) | ||
215 | { | ||
216 | case 0: | ||
217 | { | ||
218 | f=f.left(f.length()-1); | ||
219 | QString cmd="rm -rf "+f; | ||
220 | startProcess( (const QString)cmd.latin1() ); | ||
221 | populateView(); | ||
222 | } | ||
223 | break; | ||
224 | case 1: | ||
225 | // exit | ||
226 | break; | ||
227 | }; | ||
228 | 195 | ||
229 | } else { | 196 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
230 | if(doMsg) { | 197 | myFile = (*it); |
231 | switch ( QMessageBox::warning(this,tr("Delete"), | 198 | if( myFile.find(" -> ",0,TRUE) != -1) |
232 | tr("Really delete\n%1?").arg( f ), | 199 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
233 | tr("Yes"), | 200 | |
234 | tr("No"), | 201 | QString f = CurrentDir()->canonicalPath(); |
235 | 0, | 202 | if(f.right(1).find("/",0,TRUE) == -1) |
236 | 0, | 203 | f += "/"; |
237 | 1) ) { | 204 | f += myFile; |
238 | case 1: | 205 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
239 | return; | 206 | //if file is a directory |
240 | break; | 207 | |
241 | }; | 208 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), |
242 | } | 209 | tr("Really delete %1\nand all it's contents ?" ).arg( f ) , |
243 | QString cmd="rm "+f; | 210 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
244 | QFile file(f); | 211 | case 0: |
245 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) { | 212 | { |
246 | qDebug("remove link files "+f); | 213 | f=f.left(f.length()-1); |
247 | // AppLnk lnk(f); | 214 | QString cmd="rm -rf "+f; |
248 | // qDebug(lnk.linkFile()); | 215 | startProcess( (const QString)cmd.latin1() ); |
249 | // lnk.removeLinkFile(); | 216 | populateView(); |
250 | file.remove(); | 217 | } |
251 | } | 218 | break; |
219 | case 1: | ||
220 | // exit | ||
221 | break; | ||
222 | }; | ||
223 | |||
224 | } else { | ||
225 | if(doMsg) { | ||
226 | switch ( QMessageBox::warning(this,tr("Delete"), | ||
227 | tr("Really delete\n%1?").arg( myFile ), | ||
228 | tr("Yes"), tr("No"), 0, 0, 1) ) { | ||
229 | case 1: | ||
230 | return; | ||
231 | break; | ||
232 | }; | ||
233 | } | ||
234 | |||
235 | QString cmd="rm "+f; | ||
236 | QFile file(f); | ||
237 | QFileInfo fi(myFile); | ||
238 | if( fi.fileName().find("../",0,TRUE)==-1) { | ||
239 | qDebug("remove link files "+myFile); | ||
240 | |||
241 | // DocLnk lnk(f); | ||
242 | DocLnk *lnk; | ||
243 | lnk = new DocLnk(f); | ||
244 | qDebug("Deleting doclnk " + lnk->linkFile()); | ||
245 | if(lnk->isValid()) | ||
246 | lnk->removeLinkFile(); | ||
247 | // delete lnk; | ||
248 | file.remove(); | ||
249 | } | ||
250 | } | ||
252 | } | 251 | } |
253 | } | 252 | } |
254 | } | 253 | populateView(); |
255 | populateView(); | ||
256 | } | 254 | } |
257 | 255 | ||
258 | void AdvancedFm::filePerms() | 256 | void AdvancedFm::filePerms() |
259 | { | 257 | { |
260 | QStringList curFileList = getPath(); | 258 | QStringList curFileList = getPath(); |
261 | QString filePath; | 259 | QString filePath; |
262 | 260 | ||
263 | filePath = CurrentDir()->canonicalPath()+"/"; | 261 | filePath = CurrentDir()->canonicalPath()+"/"; |
264 | 262 | ||
265 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 263 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
266 | { | 264 | { |
267 | filePermissions *filePerm; | 265 | filePermissions *filePerm; |
268 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 266 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
269 | filePerm->showMaximized(); | 267 | filePerm->showMaximized(); |
270 | filePerm->exec(); | 268 | filePerm->exec(); |
271 | if( filePerm) | 269 | if( filePerm) |
272 | delete filePerm; | 270 | delete filePerm; |
273 | } | 271 | } |
274 | populateView(); | 272 | populateView(); |
275 | } | 273 | } |
276 | 274 | ||
277 | void AdvancedFm::doProperties() | 275 | void AdvancedFm::doProperties() |
278 | { | 276 | { |
279 | #if defined(QT_QWS_OPIE) | 277 | #if defined(QT_QWS_OPIE) |
280 | 278 | ||
281 | QStringList curFileList = getPath(); | 279 | QStringList curFileList = getPath(); |
282 | 280 | ||
283 | QString filePath; | 281 | QString filePath; |
284 | filePath = CurrentDir()->canonicalPath()+"/"; | 282 | filePath = CurrentDir()->canonicalPath()+"/"; |
285 | 283 | ||
286 | qDebug("%d",curFileList.count()); | 284 | qDebug("%d",curFileList.count()); |
287 | 285 | ||
288 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 286 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
289 | { | 287 | { |
290 | qDebug((filePath+*it)); | 288 | qDebug((filePath+*it)); |
291 | DocLnk lnk( (filePath+*it)); | 289 | DocLnk lnk( (filePath+*it)); |
292 | LnkProperties prop( &lnk ); | 290 | LnkProperties prop( &lnk ); |
293 | prop.showMaximized(); | 291 | prop.showMaximized(); |
294 | prop.exec(); | 292 | prop.exec(); |
295 | } | 293 | } |
296 | #endif | 294 | #endif |
297 | 295 | ||
298 | } | 296 | } |
299 | 297 | ||
300 | void AdvancedFm::upDir() | 298 | void AdvancedFm::upDir() |
301 | { | 299 | { |
302 | QDir *thisDir = CurrentDir(); | 300 | QDir *thisDir = CurrentDir(); |
303 | QString current = thisDir->canonicalPath(); | 301 | QString current = thisDir->canonicalPath(); |
304 | QDir dir(current); | 302 | QDir dir(current); |
305 | dir.cdUp(); | 303 | dir.cdUp(); |
306 | current = dir.canonicalPath(); | 304 | current = dir.canonicalPath(); |
307 | chdir( current.latin1() ); | 305 | chdir( current.latin1() ); |
308 | thisDir->cd( current, TRUE); | 306 | thisDir->cd( current, TRUE); |
309 | 307 | ||
310 | populateView(); | 308 | populateView(); |
311 | update(); | 309 | update(); |
312 | } | 310 | } |
313 | 311 | ||
314 | void AdvancedFm::copy() | 312 | void AdvancedFm::copy() |
315 | { | 313 | { |
316 | qApp->processEvents(); | 314 | qApp->processEvents(); |
317 | QStringList curFileList = getPath(); | 315 | QStringList curFileList = getPath(); |
318 | 316 | ||
319 | QDir *thisDir = CurrentDir(); | 317 | QDir *thisDir = CurrentDir(); |
320 | QDir *thatDir = OtherDir(); | 318 | QDir *thatDir = OtherDir(); |
321 | 319 | ||
322 | bool doMsg=true; | 320 | bool doMsg=true; |
323 | int count=curFileList.count(); | 321 | int count=curFileList.count(); |
324 | if( count > 0) { | 322 | if( count > 0) { |
325 | if(count > 1 ){ | 323 | if(count > 1 ){ |
326 | QString msg; | 324 | QString msg; |
327 | msg=tr("Really copy\n%1 files?").arg(count); | 325 | msg=tr("Really copy\n%1 files?").arg(count); |
328 | switch ( QMessageBox::warning(this,tr("Copy"),msg | 326 | switch ( QMessageBox::warning(this,tr("Copy"),msg |
329 | ,tr("Yes"),tr("No"),0,0,1) ) | 327 | ,tr("Yes"),tr("No"),0,0,1) ) |
330 | { | 328 | { |
331 | case 0: | 329 | case 0: |
332 | doMsg=false; | 330 | doMsg=false; |
333 | break; | 331 | break; |
334 | case 1: | 332 | case 1: |
335 | return; | 333 | return; |
336 | break; | 334 | break; |
337 | }; | 335 | }; |
338 | } | 336 | } |
339 | 337 | ||
340 | QString curFile, item, destFile; | 338 | QString curFile, item, destFile; |
341 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 339 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
342 | { | 340 | { |
343 | item=(*it); | 341 | item=(*it); |
344 | if(item.find("->",0,TRUE)) //symlink | 342 | if(item.find("->",0,TRUE)) //symlink |
345 | item = item.left(item.find("->",0,TRUE)); | 343 | item = item.left(item.find("->",0,TRUE)); |
346 | 344 | ||
347 | curFile = thisDir->canonicalPath()+"/"+ item; | 345 | curFile = thisDir->canonicalPath()+"/"+ item; |
348 | destFile = thatDir->canonicalPath()+"/"+ item; | 346 | destFile = thatDir->canonicalPath()+"/"+ item; |
349 | 347 | ||
350 | qDebug("Destination file is "+destFile); | 348 | qDebug("Destination file is "+destFile); |
351 | qDebug("CurrentFile file is " + curFile); | 349 | qDebug("CurrentFile file is " + curFile); |
352 | 350 | ||
353 | QFile f(destFile); | 351 | QFile f(destFile); |
354 | if( f.exists()) | 352 | if( f.exists()) |
355 | { | 353 | { |
356 | if(doMsg) | 354 | if(doMsg) |
357 | { | 355 | { |
358 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 356 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
359 | tr("%1 exists. Ok to overwrite?").arg( item ), | 357 | tr("%1 exists. Ok to overwrite?").arg( item ), |
360 | tr("Yes"),tr("No"),0,0,1) ) | 358 | tr("Yes"),tr("No"),0,0,1) ) |
361 | { | 359 | { |
362 | case 1: | 360 | case 1: |
363 | return; | 361 | return; |
364 | break; | 362 | break; |
365 | }; | 363 | }; |
366 | } | 364 | } |
367 | f.remove(); | 365 | f.remove(); |
368 | } | 366 | } |
369 | 367 | ||
370 | if( !copyFile( curFile, destFile) ) | 368 | if( !copyFile( curFile, destFile) ) { |
371 | { | ||
372 | QMessageBox::message("AdvancedFm", | 369 | QMessageBox::message("AdvancedFm", |
373 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 370 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); |
374 | return; | 371 | return; |
375 | } | 372 | } |
376 | } | 373 | } |
377 | setOtherTabCurrent(); | 374 | setOtherTabCurrent(); |
378 | populateView(); | 375 | populateView(); |
379 | } | 376 | } |
380 | } | 377 | } |
381 | 378 | ||
382 | void AdvancedFm::copyAs() | 379 | void AdvancedFm::copyAs() |
383 | { | 380 | { |
384 | qApp->processEvents(); | 381 | qApp->processEvents(); |
385 | 382 | ||
386 | QStringList curFileList = getPath(); | 383 | QStringList curFileList = getPath(); |
387 | QString curFile, item; | 384 | QString curFile, item; |
388 | InputDialog *fileDlg; | 385 | InputDialog *fileDlg; |
389 | 386 | ||
390 | QDir *thisDir = CurrentDir(); | 387 | QDir *thisDir = CurrentDir(); |
391 | QDir *thatDir = OtherDir(); | 388 | QDir *thatDir = OtherDir(); |
392 | 389 | ||
393 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 390 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
394 | { | 391 | { |
395 | QString destFile; | 392 | QString destFile; |
396 | item=(*it); | 393 | item=(*it); |
397 | curFile = thisDir->canonicalPath()+"/"+(*it); | 394 | curFile = thisDir->canonicalPath()+"/"+(*it); |
398 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); | 395 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); |
399 | 396 | ||
400 | fileDlg->setInputText((const QString &) destFile ); | 397 | fileDlg->setInputText((const QString &) destFile ); |
401 | fileDlg->exec(); | 398 | fileDlg->exec(); |
402 | 399 | ||
403 | if( fileDlg->result() == 1 ) | 400 | if( fileDlg->result() == 1 ) |
404 | { | 401 | { |
405 | QString filename = fileDlg->LineEdit1->text(); | 402 | QString filename = fileDlg->LineEdit1->text(); |
406 | destFile = thatDir->canonicalPath()+"/"+filename; | 403 | destFile = thatDir->canonicalPath()+"/"+filename; |
407 | 404 | ||
408 | QFile f( destFile); | 405 | QFile f( destFile); |
409 | if( f.exists()) | 406 | if( f.exists()) |
410 | { | 407 | { |
411 | switch (QMessageBox::warning(this,tr("File Exists!"), | 408 | switch (QMessageBox::warning(this,tr("File Exists!"), |
412 | item+tr("\nexists. Ok to overwrite?"), | 409 | item+tr("\nexists. Ok to overwrite?"), |
413 | tr("Yes"),tr("No"),0,0,1) ) | 410 | tr("Yes"),tr("No"),0,0,1) ) |
414 | { | 411 | { |
415 | case 0: | 412 | case 0: |
416 | f.remove(); | 413 | f.remove(); |
417 | break; | 414 | break; |
418 | case 1: | 415 | case 1: |
419 | return; | 416 | return; |
420 | break; | 417 | break; |
421 | }; | 418 | }; |
422 | } | 419 | } |
423 | if( !copyFile( curFile, destFile) ) | 420 | if( !copyFile( curFile, destFile) ) { |
424 | { | ||
425 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 421 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
426 | +curFile +tr("to\n")+destFile); | 422 | +curFile +tr("to\n")+destFile); |
427 | return; | 423 | return; |
428 | } | 424 | } |
429 | } | 425 | } |
430 | delete fileDlg; | 426 | delete fileDlg; |
431 | 427 | ||
432 | } | 428 | } |
433 | setOtherTabCurrent(); | 429 | setOtherTabCurrent(); |
434 | populateView(); | 430 | populateView(); |
435 | } | 431 | } |
436 | 432 | ||
437 | void AdvancedFm::copySameDir() | 433 | void AdvancedFm::copySameDir() |
438 | { | 434 | { |
439 | qApp->processEvents(); | 435 | qApp->processEvents(); |
440 | QStringList curFileList = getPath(); | 436 | QStringList curFileList = getPath(); |
441 | QString curFile, item, destFile; | 437 | QString curFile, item, destFile; |
442 | InputDialog *fileDlg; | 438 | InputDialog *fileDlg; |
443 | 439 | ||
444 | QDir *thisDir = CurrentDir(); | 440 | QDir *thisDir = CurrentDir(); |
445 | 441 | ||
446 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 442 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
447 | { | 443 | { |
448 | item=(*it); | 444 | item=(*it); |
449 | curFile = thisDir->canonicalPath()+"/"+ item; | 445 | curFile = thisDir->canonicalPath()+"/"+ item; |
450 | 446 | ||
451 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 447 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
452 | fileDlg->setInputText((const QString &) destFile ); | 448 | fileDlg->setInputText((const QString &) destFile ); |
453 | fileDlg->exec(); | 449 | fileDlg->exec(); |
454 | 450 | ||
455 | if( fileDlg->result() == 1 ) | 451 | if( fileDlg->result() == 1 ) |
456 | { | 452 | { |
457 | 453 | ||
458 | QString filename = fileDlg->LineEdit1->text(); | 454 | QString filename = fileDlg->LineEdit1->text(); |
459 | destFile = thisDir->canonicalPath()+"/"+filename; | 455 | destFile = thisDir->canonicalPath()+"/"+filename; |
460 | 456 | ||
461 | QFile f(destFile); | 457 | QFile f(destFile); |
462 | if( f.exists()) | 458 | if( f.exists()) |
463 | { | 459 | { |
464 | switch (QMessageBox::warning(this,tr("Delete"), | 460 | switch (QMessageBox::warning(this,tr("Delete"), |
465 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 461 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
466 | tr("Yes"),tr("No"),0,0,1) ) { | 462 | tr("Yes"),tr("No"),0,0,1) ) { |
467 | case 0: | 463 | case 0: |
468 | 464 | ||
469 | f.remove(); | 465 | f.remove(); |
470 | break; | 466 | break; |
471 | case 1: | 467 | case 1: |
472 | return; | 468 | return; |
473 | break; | 469 | break; |
474 | }; | 470 | }; |
475 | } | 471 | } |
476 | if(!copyFile( curFile,destFile) ) | 472 | if(!copyFile( curFile,destFile) ) { |
477 | { | ||
478 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 473 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
479 | +curFile +tr("to\n")+destFile); | 474 | +curFile +tr("to\n")+destFile); |
480 | return; | 475 | return; |
481 | } | 476 | } |
482 | 477 | ||
483 | qDebug("copy "+curFile+" as "+destFile); | 478 | qDebug("copy "+curFile+" as "+destFile); |
484 | } | 479 | } |
485 | delete fileDlg; | 480 | delete fileDlg; |
486 | } | 481 | } |
487 | populateView(); | 482 | populateView(); |
488 | } | 483 | } |
489 | 484 | ||
490 | void AdvancedFm::move() | 485 | void AdvancedFm::move() |
491 | { | 486 | { |
492 | qApp->processEvents(); | 487 | qApp->processEvents(); |
493 | 488 | ||
494 | QStringList curFileList = getPath(); | 489 | QStringList curFileList = getPath(); |
495 | if( curFileList.count() > 0) | 490 | if( curFileList.count() > 0) |
496 | { | 491 | { |
497 | QString curFile, destFile, item; | 492 | QString curFile, destFile, item; |
498 | 493 | ||
499 | QDir *thisDir = CurrentDir(); | 494 | QDir *thisDir = CurrentDir(); |
500 | QDir *thatDir = OtherDir(); | 495 | QDir *thatDir = OtherDir(); |
501 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 496 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
502 | { | 497 | { |
503 | item=(*it); | 498 | item=(*it); |
504 | QString destFile = thatDir->canonicalPath(); | 499 | QString destFile = thatDir->canonicalPath(); |
505 | 500 | ||
506 | if(destFile.right(1).find("/",0,TRUE) == -1) | 501 | if(destFile.right(1).find("/",0,TRUE) == -1) |
507 | destFile+="/"; | 502 | destFile+="/"; |
508 | destFile += item; | 503 | destFile += item; |
509 | qDebug("Destination file is "+destFile); | 504 | qDebug("Destination file is "+destFile); |
510 | 505 | ||
511 | curFile = thisDir->canonicalPath(); | 506 | curFile = thisDir->canonicalPath(); |
512 | if(curFile.right(1).find("/",0,TRUE) == -1) | 507 | if(curFile.right(1).find("/",0,TRUE) == -1) |
513 | curFile +="/"; | 508 | curFile +="/"; |
514 | curFile+= item; | 509 | curFile+= item; |
515 | qDebug("CurrentFile file is " + curFile); | 510 | qDebug("CurrentFile file is " + curFile); |
516 | 511 | ||
517 | QFile f( curFile); | 512 | QFile f( curFile); |
518 | if( f.exists()) { | 513 | if( f.exists()) { |
519 | if( !copyFile( curFile, destFile) ) | 514 | if( !copyFile( curFile, destFile) ) { |
520 | { | ||
521 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 515 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
522 | return; | 516 | return; |
523 | } else | 517 | } else |
524 | QFile::remove(curFile); | 518 | QFile::remove(curFile); |
525 | } | 519 | } |
526 | } | 520 | } |
527 | 521 | ||
528 | } | 522 | } |
529 | setOtherTabCurrent(); | 523 | setOtherTabCurrent(); |
530 | populateView(); | 524 | populateView(); |
531 | // populateLocalView(); | 525 | // populateLocalView(); |
532 | } | 526 | } |
533 | 527 | ||
534 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | 528 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) |
535 | { | 529 | { |
536 | // char bf[ 50000 ]; | ||
537 | // int bytesRead; | ||
538 | bool success = true; | 530 | bool success = true; |
539 | struct stat status; | 531 | struct stat status; |
540 | 532 | QFile srcFile(src); | |
541 | // QFile s( src ); | 533 | QFile destFile(dest); |
542 | // QFile d( dest ); | 534 | int err=0; |
543 | |||
544 | int read_fd=0; | 535 | int read_fd=0; |
545 | int write_fd=0; | 536 | int write_fd=0; |
546 | struct stat stat_buf; | 537 | struct stat stat_buf; |
547 | off_t offset = 0; | 538 | off_t offset = 0; |
548 | read_fd = ::open(src.latin1(), O_RDONLY); | 539 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
540 | qWarning("open failed"); | ||
541 | return success = false; | ||
542 | } | ||
543 | read_fd = srcFile.handle(); | ||
549 | if(read_fd != -1) { | 544 | if(read_fd != -1) { |
550 | fstat (read_fd, &stat_buf); | 545 | fstat (read_fd, &stat_buf); |
551 | write_fd = ::open(dest.latin1(), O_WRONLY | O_CREAT, stat_buf.st_mode); | 546 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { |
547 | qWarning("destfile open failed"); | ||
548 | return success = false; | ||
549 | } | ||
550 | write_fd = destFile.handle(); | ||
552 | if(write_fd != -1) { | 551 | if(write_fd != -1) { |
553 | if(sendfile(write_fd, read_fd, &offset, stat_buf.st_size) == -1) { | 552 | err =sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
554 | success = false; | 553 | if( err == -1) { |
554 | QString msg; | ||
555 | switch(err) { | ||
556 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; | ||
557 | case EINVAL: msg = "Descriptor is not valid or locked. "; | ||
558 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; | ||
559 | case EIO: msg = "Unspecified error while reading from in_fd."; | ||
560 | }; | ||
561 | success = false; | ||
562 | qWarning(msg); | ||
555 | } | 563 | } |
556 | } else { | 564 | } else { |
557 | success = false; | 565 | success = false; |
558 | } | 566 | } |
559 | } else { | 567 | } else { |
560 | success = false; | 568 | success = false; |
561 | } | 569 | } |
562 | 570 | srcFile.close(); | |
563 | ::close (read_fd); | 571 | destFile.close(); |
564 | ::close (write_fd); | ||
565 | |||
566 | |||
567 | // if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) | ||
568 | // { | ||
569 | // while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) | ||
570 | // { | ||
571 | // if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | ||
572 | // success = FALSE; | ||
573 | // break; | ||
574 | // } | ||
575 | // } | ||
576 | // if( success && (bytesRead > 0) ) | ||
577 | // { | ||
578 | // d.writeBlock( bf, bytesRead ); | ||
579 | // } | ||
580 | |||
581 | // } | ||
582 | // else | ||
583 | // { | ||
584 | // success = FALSE; | ||
585 | // } | ||
586 | |||
587 | // Set file permissions | 572 | // Set file permissions |
588 | if( stat( (const char *) src, &status ) == 0 ) | 573 | if( stat( (const char *) src, &status ) == 0 ) { |
589 | { | ||
590 | chmod( (const char *) dest, status.st_mode ); | 574 | chmod( (const char *) dest, status.st_mode ); |
591 | } | 575 | } |
592 | 576 | ||
593 | return success; | 577 | return success; |
594 | } | 578 | } |
595 | 579 | ||
596 | void AdvancedFm::runCommand() | 580 | void AdvancedFm::runCommand() |
597 | { | 581 | { |
598 | QDir *thisDir = CurrentDir(); | 582 | QDir *thisDir = CurrentDir(); |
599 | 583 | ||
600 | QString curFile; | 584 | QString curFile; |
601 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 585 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
602 | 586 | ||
603 | InputDialog *fileDlg; | 587 | InputDialog *fileDlg; |
604 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 588 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
605 | fileDlg->setInputText(curFile); | 589 | fileDlg->setInputText(curFile); |
606 | fileDlg->exec(); | 590 | fileDlg->exec(); |
607 | //QString command; | 591 | //QString command; |
608 | 592 | ||
609 | if( fileDlg->result() == 1 ) | 593 | if( fileDlg->result() == 1 ) |
610 | { | 594 | { |
611 | qDebug(fileDlg->LineEdit1->text()); | 595 | qDebug(fileDlg->LineEdit1->text()); |
612 | QStringList command; | 596 | QStringList command; |
613 | 597 | ||
614 | command << "/bin/sh"; | 598 | command << "/bin/sh"; |
615 | command << "-c"; | 599 | command << "-c"; |
616 | command << fileDlg->LineEdit1->text(); | 600 | command << fileDlg->LineEdit1->text(); |
617 | Output *outDlg; | 601 | Output *outDlg; |
618 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 602 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
619 | outDlg->showMaximized(); | 603 | outDlg->showMaximized(); |
620 | outDlg->exec(); | 604 | outDlg->exec(); |
621 | qApp->processEvents(); | 605 | qApp->processEvents(); |
622 | 606 | ||
623 | } | 607 | } |
624 | } | 608 | } |
625 | 609 | ||
626 | void AdvancedFm::runCommandStd() | 610 | void AdvancedFm::runCommandStd() |
627 | { | 611 | { |
628 | QString curFile; | 612 | QString curFile; |
629 | QDir *thisDir = CurrentDir(); | 613 | QDir *thisDir = CurrentDir(); |
630 | QListView *thisView = CurrentView(); | 614 | QListView *thisView = CurrentView(); |
631 | if( thisView->currentItem()) | 615 | if( thisView->currentItem()) |
632 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 616 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
633 | 617 | ||
634 | InputDialog *fileDlg; | 618 | InputDialog *fileDlg; |
635 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 619 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
636 | fileDlg->setInputText(curFile); | 620 | fileDlg->setInputText(curFile); |
637 | fileDlg->exec(); | 621 | fileDlg->exec(); |
638 | 622 | ||
639 | if( fileDlg->result() == 1 ) | 623 | if( fileDlg->result() == 1 ) |
640 | { | 624 | { |
641 | qApp->processEvents(); | 625 | qApp->processEvents(); |
642 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 626 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
643 | } | 627 | } |
644 | } | 628 | } |
645 | 629 | ||
646 | void AdvancedFm::fileStatus() | 630 | void AdvancedFm::fileStatus() |
647 | { | 631 | { |
648 | QString curFile; | 632 | QString curFile; |
649 | curFile = CurrentView()->currentItem()->text(0); | 633 | curFile = CurrentView()->currentItem()->text(0); |
650 | 634 | ||
651 | QStringList command; | 635 | QStringList command; |
652 | command << "/bin/sh"; | 636 | command << "/bin/sh"; |
653 | command << "-c"; | 637 | command << "-c"; |
654 | command << "stat -l "+ curFile; | 638 | command << "stat -l "+ curFile; |
655 | 639 | ||
656 | Output *outDlg; | 640 | Output *outDlg; |
657 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 641 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
658 | outDlg->showMaximized(); | 642 | outDlg->showMaximized(); |
659 | outDlg->exec(); | 643 | outDlg->exec(); |
660 | qApp->processEvents(); | 644 | qApp->processEvents(); |
661 | } | 645 | } |
662 | 646 | ||
663 | 647 | ||
664 | void AdvancedFm::mkDir() | 648 | void AdvancedFm::mkDir() |
665 | { | 649 | { |
666 | makeDir(); | 650 | makeDir(); |
667 | } | 651 | } |
668 | 652 | ||
669 | void AdvancedFm::rn() | 653 | void AdvancedFm::rn() |
670 | { | 654 | { |
671 | renameIt(); | 655 | renameIt(); |
672 | } | 656 | } |
673 | 657 | ||
674 | void AdvancedFm::del() | 658 | void AdvancedFm::del() |
675 | { | 659 | { |
676 | doDelete(); | 660 | doDelete(); |
677 | } | 661 | } |
678 | 662 | ||
679 | void AdvancedFm::mkSym() | 663 | void AdvancedFm::mkSym() |
680 | { | 664 | { |
681 | QString cmd; | 665 | QString cmd; |
682 | QStringList curFileList = getPath(); | 666 | QStringList curFileList = getPath(); |
683 | if( curFileList.count() > 0) | 667 | if( curFileList.count() > 0) |
684 | { | 668 | { |
685 | QDir *thisDir = CurrentDir(); | 669 | QDir *thisDir = CurrentDir(); |
686 | QDir * thatDir = OtherDir(); | 670 | QDir * thatDir = OtherDir(); |
687 | 671 | ||
688 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 672 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
689 | { | 673 | { |
690 | 674 | ||
691 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 675 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
692 | if(destName.right(1) == "/") | 676 | if(destName.right(1) == "/") |
693 | { | 677 | { |
694 | destName = destName.left( destName.length() -1); | 678 | destName = destName.left( destName.length() -1); |
695 | } | 679 | } |
696 | 680 | ||
697 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 681 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
698 | 682 | ||
699 | if( curFile.right(1) == "/") | 683 | if( curFile.right(1) == "/") |
700 | { | 684 | { |
701 | curFile = curFile.left( curFile.length() -1); | 685 | curFile = curFile.left( curFile.length() -1); |
702 | } | 686 | } |
703 | 687 | ||
704 | cmd = "ln -s "+curFile+" "+destName; | 688 | cmd = "ln -s "+curFile+" "+destName; |
705 | qDebug(cmd); | 689 | qDebug(cmd); |
706 | startProcess( (const QString)cmd ); | 690 | startProcess( (const QString)cmd ); |
707 | } | 691 | } |
708 | setOtherTabCurrent(); | 692 | setOtherTabCurrent(); |
709 | populateView(); | 693 | populateView(); |
710 | } | 694 | } |
711 | } | 695 | } |
712 | 696 | ||
713 | void AdvancedFm::doBeam() | 697 | void AdvancedFm::doBeam() |
714 | { | 698 | { |
715 | Ir ir; | 699 | Ir ir; |
716 | if(!ir.supported()) | 700 | if(!ir.supported()) { |
717 | { | 701 | } else { |
718 | } | ||
719 | else | ||
720 | { | ||
721 | QStringList curFileList = getPath(); | 702 | QStringList curFileList = getPath(); |
722 | if( curFileList.count() > 0) | 703 | if( curFileList.count() > 0) { |
723 | { | 704 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
724 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 705 | QString curFile = (*it); |
725 | { | 706 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; |
726 | 707 | if( curFilePath.right(1) == "/") { | |
727 | QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); | 708 | curFilePath = curFilePath.left( curFilePath.length() -1); |
728 | if( curFile.right(1) == "/") | ||
729 | { | ||
730 | curFile = curFile.left( curFile.length() -1); | ||
731 | } | ||
732 | Ir *file = new Ir(this, "IR"); | ||
733 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | ||
734 | file->send( curFile, curFile ); | ||
735 | } | 709 | } |
736 | } | 710 | Ir *file = new Ir(this, "IR"); |
737 | } | 711 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
738 | 712 | file->send( curFilePath, curFile ); | |
713 | } | ||
714 | } | ||
715 | } | ||
739 | } | 716 | } |
740 | 717 | ||
741 | void AdvancedFm::fileBeamFinished( Ir *) | 718 | void AdvancedFm::fileBeamFinished( Ir *) |
742 | { | 719 | { |
743 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 720 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
744 | } | 721 | } |
745 | 722 | ||
746 | void AdvancedFm::selectAll() | 723 | void AdvancedFm::selectAll() |
747 | { | 724 | { |
748 | // if (TabWidget->currentTab() == 0) { | 725 | // if (TabWidget->currentTab() == 0) { |
749 | QListView *thisView = CurrentView(); | 726 | QListView *thisView = CurrentView(); |
750 | thisView->selectAll(true); | 727 | thisView->selectAll(true); |
751 | thisView->setSelected( thisView->firstChild(),false); | 728 | thisView->setSelected( thisView->firstChild(),false); |
752 | // } else { | 729 | // } else { |
753 | // Remote_View->selectAll(true); | 730 | // Remote_View->selectAll(true); |
754 | // Remote_View->setSelected( Remote_View->firstChild(),false); | 731 | // Remote_View->setSelected( Remote_View->firstChild(),false); |
755 | // } | 732 | // } |
756 | } | 733 | } |
757 | 734 | ||
758 | void AdvancedFm::startProcess(const QString & cmd) | 735 | void AdvancedFm::startProcess(const QString & cmd) |
759 | { | 736 | { |
760 | QStringList command; | 737 | QStringList command; |
761 | OProcess *process; | 738 | OProcess *process; |
762 | process = new OProcess(); | 739 | process = new OProcess(); |
763 | connect(process, SIGNAL(processExited(OProcess *)), | 740 | connect(process, SIGNAL(processExited(OProcess *)), |
764 | this, SLOT( processEnded(OProcess *))); | 741 | this, SLOT( processEnded(OProcess *))); |
765 | 742 | ||
766 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), | 743 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), |
767 | this, SLOT( oprocessStderr(OProcess *, char *, int))); | 744 | this, SLOT( oprocessStderr(OProcess *, char *, int))); |
768 | 745 | ||
769 | command << "/bin/sh"; | 746 | command << "/bin/sh"; |
770 | command << "-c"; | 747 | command << "-c"; |
771 | command << cmd.latin1(); | 748 | command << cmd.latin1(); |
772 | *process << command; | 749 | *process << command; |
773 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 750 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
774 | qDebug("could not start process"); | 751 | qDebug("could not start process"); |
775 | } | 752 | } |
776 | 753 | ||
777 | void AdvancedFm::processEnded(OProcess *) | 754 | void AdvancedFm::processEnded(OProcess *) |
778 | { | 755 | { |
779 | // populateLocalView(); | 756 | // populateLocalView(); |
780 | populateView(); | 757 | populateView(); |
781 | } | 758 | } |
782 | 759 | ||
783 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int buflen) { | 760 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int buflen) { |
784 | qWarning("received stderrt %d bytes", buflen); | 761 | qWarning("received stderrt %d bytes", buflen); |
785 | 762 | ||
786 | QString lineStr = buffer; | 763 | QString lineStr = buffer; |
787 | // lineStr=lineStr.left(lineStr.length()-1); | 764 | // lineStr=lineStr.left(lineStr.length()-1); |
788 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 765 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
789 | 766 | ||
790 | // OutputEdit->append(lineStr); | 767 | // OutputEdit->append(lineStr); |
791 | // OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 768 | // OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
792 | } | 769 | } |
793 | 770 | ||
794 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) | 771 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) |
795 | { | 772 | { |
796 | if ( o->inherits( "QLineEdit" ) ) | 773 | if ( o->inherits( "QLineEdit" ) ) |
797 | { | 774 | { |
798 | if ( e->type() == QEvent::KeyPress ) | 775 | if ( e->type() == QEvent::KeyPress ) |
799 | { | 776 | { |
800 | QKeyEvent *ke = (QKeyEvent*)e; | 777 | QKeyEvent *ke = (QKeyEvent*)e; |
801 | if ( ke->key() == Key_Return || | 778 | if ( ke->key() == Key_Return || |
802 | ke->key() == Key_Enter ) | 779 | ke->key() == Key_Enter ) |
803 | { | 780 | { |
804 | okRename(); | 781 | okRename(); |
805 | return true; | 782 | return true; |
806 | } | 783 | } |
807 | else if ( ke->key() == Key_Escape ) | 784 | else if ( ke->key() == Key_Escape ) |
808 | { | 785 | { |
809 | cancelRename(); | 786 | cancelRename(); |
810 | return true; | 787 | return true; |
811 | } | 788 | } |
812 | } | 789 | } |
813 | else if ( e->type() == QEvent::FocusOut ) | 790 | else if ( e->type() == QEvent::FocusOut ) |
814 | { | 791 | { |
815 | cancelRename(); | 792 | cancelRename(); |
816 | return true; | 793 | return true; |
817 | } | 794 | } |
818 | } | 795 | } |
819 | if ( o->inherits( "QListView" ) ) | 796 | if ( o->inherits( "QListView" ) ) |
820 | { | 797 | { |
821 | if ( e->type() == QEvent::FocusOut ) | 798 | if ( e->type() == QEvent::FocusOut ) |
822 | { | 799 | { |
823 | printf("focusIn\n"); | 800 | printf("focusIn\n"); |
824 | 801 | ||
825 | } | 802 | } |
826 | } | 803 | } |
827 | 804 | ||
828 | return QWidget::eventFilter( o, e ); | 805 | return QWidget::eventFilter( o, e ); |
829 | } | 806 | } |
830 | 807 | ||
831 | 808 | ||
832 | void AdvancedFm::cancelRename() | 809 | void AdvancedFm::cancelRename() |
833 | { | 810 | { |
834 | qDebug("cancel rename"); | 811 | qDebug("cancel rename"); |