-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 34 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 26 |
2 files changed, 45 insertions, 15 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index c653b90..9edf7c1 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1,881 +1,899 @@ | |||
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 | #define DEVELOPERS_VERSION | 12 | #define DEVELOPERS_VERSION |
13 | #include "advancedfm.h" | 13 | #include "advancedfm.h" |
14 | 14 | ||
15 | #include <opie/otabwidget.h> | 15 | #include <opie/otabwidget.h> |
16 | // #include <opie/ofileselector.h> | 16 | // #include <opie/ofileselector.h> |
17 | // #include <opie/ofiledialog.h> | 17 | // #include <opie/ofiledialog.h> |
18 | 18 | ||
19 | #include <qpe/filemanager.h> | 19 | #include <qpe/filemanager.h> |
20 | #include <qpe/qcopenvelope_qws.h> | 20 | #include <qpe/qcopenvelope_qws.h> |
21 | #include <qpe/qpemenubar.h> | 21 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpetoolbar.h> | 22 | #include <qpe/qpetoolbar.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qpe/mimetype.h> | 26 | #include <qpe/mimetype.h> |
27 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
28 | #include <qpe/ir.h> | 28 | #include <qpe/ir.h> |
29 | #include <qpe/resource.h> | 29 | #include <qpe/resource.h> |
30 | 30 | ||
31 | #include <qtabwidget.h> | 31 | #include <qtabwidget.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
35 | #include <qdir.h> | 35 | #include <qdir.h> |
36 | #include <qfile.h> | 36 | #include <qfile.h> |
37 | #include <qstring.h> | 37 | #include <qstring.h> |
38 | #include <qcombobox.h> | 38 | #include <qcombobox.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qlistview.h> | 40 | #include <qlistview.h> |
41 | #include <qmainwindow.h> | 41 | #include <qmainwindow.h> |
42 | #include <qlabel.h> | 42 | #include <qlabel.h> |
43 | #include <qprogressbar.h> | 43 | #include <qprogressbar.h> |
44 | #include <qspinbox.h> | 44 | #include <qspinbox.h> |
45 | #include <qwidget.h> | 45 | #include <qwidget.h> |
46 | #include <qlayout.h> | 46 | #include <qlayout.h> |
47 | #include <qimage.h> | 47 | #include <qimage.h> |
48 | #include <qpixmap.h> | 48 | #include <qpixmap.h> |
49 | #include <qmessagebox.h> | 49 | #include <qmessagebox.h> |
50 | #include <qlineedit.h> | 50 | #include <qlineedit.h> |
51 | #include <qregexp.h> | 51 | #include <qregexp.h> |
52 | 52 | ||
53 | #include <unistd.h> | 53 | #include <unistd.h> |
54 | #include <stdlib.h> | 54 | #include <stdlib.h> |
55 | #include <sys/stat.h> | 55 | #include <sys/stat.h> |
56 | #include <dirent.h> | 56 | #include <dirent.h> |
57 | #include <stdio.h> | 57 | #include <stdio.h> |
58 | #include <time.h> | 58 | #include <time.h> |
59 | #include <fcntl.h> | 59 | #include <fcntl.h> |
60 | #include <mntent.h> | 60 | #include <mntent.h> |
61 | #include <string.h> | 61 | #include <string.h> |
62 | #include <errno.h> | 62 | #include <errno.h> |
63 | #include <sys/vfs.h> | 63 | #include <sys/vfs.h> |
64 | #include <mntent.h> | 64 | #include <mntent.h> |
65 | #include <sys/utsname.h> | 65 | #include <sys/utsname.h> |
66 | 66 | ||
67 | AdvancedFm::AdvancedFm( ) | 67 | AdvancedFm::AdvancedFm( ) |
68 | : QMainWindow( ) { | 68 | : QMainWindow( ) { |
69 | init(); | 69 | init(); |
70 | renameBox = 0; | ||
71 | |||
70 | initConnections(); | 72 | initConnections(); |
71 | populateLocalView(); | 73 | populateLocalView(); |
72 | populateRemoteView(); | 74 | populateRemoteView(); |
73 | currentPathCombo->setFocus(); | 75 | currentPathCombo->setFocus(); |
74 | } | 76 | } |
75 | 77 | ||
76 | AdvancedFm::~AdvancedFm() { | 78 | AdvancedFm::~AdvancedFm() { |
77 | } | 79 | } |
78 | 80 | ||
79 | void AdvancedFm::cleanUp() { | 81 | void AdvancedFm::cleanUp() { |
80 | QString sfile=QDir::homeDirPath(); | 82 | QString sfile=QDir::homeDirPath(); |
81 | if(sfile.right(1) != "/") | 83 | if(sfile.right(1) != "/") |
82 | sfile+="/._temp"; | 84 | sfile+="/._temp"; |
83 | else | 85 | else |
84 | sfile+="._temp"; | 86 | sfile+="._temp"; |
85 | QFile file( sfile); | 87 | QFile file( sfile); |
86 | if(file.exists()) | 88 | if(file.exists()) |
87 | file.remove(); | 89 | file.remove(); |
88 | } | 90 | } |
89 | 91 | ||
90 | void AdvancedFm::tabChanged(QWidget *w) { | 92 | void AdvancedFm::tabChanged(QWidget *w) { |
91 | qDebug("tab changed %d",TabWidget->getCurrentTab()); | 93 | qDebug("tab changed %d",TabWidget->getCurrentTab()); |
92 | 94 | ||
93 | if ( w == tab) { | 95 | if ( w == tab) { |
94 | // if (TabWidget->getCurrentTab() == 0) { | 96 | // if (TabWidget->getCurrentTab() == 0) { |
95 | // if (TabWidget->currentPageIndex() == 0) { | 97 | // if (TabWidget->currentPageIndex() == 0) { |
96 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 98 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
97 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); | 99 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); |
98 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); | 100 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); |
99 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 101 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
100 | setCaption("AdvancedFm :: "+fs+" :: " | 102 | setCaption("AdvancedFm :: "+fs+" :: " |
101 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | 103 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); |
102 | 104 | ||
103 | } | 105 | } |
104 | if ( w == tab_2) { | 106 | if ( w == tab_2) { |
105 | // if (TabWidget->getCurrentTab() == 1) { | 107 | // if (TabWidget->getCurrentTab() == 1) { |
106 | 108 | ||
107 | // if (TabWidget->currentPageIndex() == 1) { | 109 | // if (TabWidget->currentPageIndex() == 1) { |
108 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); | 110 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); |
109 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); | 111 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); |
110 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); | 112 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); |
111 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 113 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
112 | setCaption("AdvancedFm :: "+fs+" :: " | 114 | setCaption("AdvancedFm :: "+fs+" :: " |
113 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | 115 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); |
114 | } | 116 | } |
115 | } | 117 | } |
116 | 118 | ||
117 | 119 | ||
118 | void AdvancedFm::populateLocalView() { | 120 | void AdvancedFm::populateLocalView() { |
119 | QPixmap pm; | 121 | QPixmap pm; |
120 | Local_View->clear(); | 122 | Local_View->clear(); |
121 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 123 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
122 | currentDir.setMatchAllDirs(TRUE); | 124 | currentDir.setMatchAllDirs(TRUE); |
123 | currentDir.setNameFilter(filterStr); | 125 | currentDir.setNameFilter(filterStr); |
124 | QString fileL, fileS, fileDate; | 126 | QString fileL, fileS, fileDate; |
125 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 127 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
126 | setCaption("AdvancedFm :: "+fs+" :: " | 128 | setCaption("AdvancedFm :: "+fs+" :: " |
127 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | 129 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); |
128 | bool isDir=FALSE; | 130 | bool isDir=FALSE; |
129 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 131 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
130 | QFileInfoListIterator it(*list); | 132 | QFileInfoListIterator it(*list); |
131 | QFileInfo *fi; | 133 | QFileInfo *fi; |
132 | while ( (fi=it.current()) ) { | 134 | while ( (fi=it.current()) ) { |
133 | if (fi->isSymLink() ) { | 135 | if (fi->isSymLink() ) { |
134 | QString symLink=fi->readLink(); | 136 | QString symLink=fi->readLink(); |
135 | QFileInfo sym( symLink); | 137 | QFileInfo sym( symLink); |
136 | fileS.sprintf( "%10i", sym.size() ); | 138 | fileS.sprintf( "%10i", sym.size() ); |
137 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); | 139 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); |
138 | fileDate = sym.lastModified().toString(); | 140 | fileDate = sym.lastModified().toString(); |
139 | } else { | 141 | } else { |
140 | fileS.sprintf( "%10i", fi->size() ); | 142 | fileS.sprintf( "%10i", fi->size() ); |
141 | fileL.sprintf( "%s",fi->fileName().data() ); | 143 | fileL.sprintf( "%s",fi->fileName().data() ); |
142 | fileDate= fi->lastModified().toString(); | 144 | fileDate= fi->lastModified().toString(); |
143 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 145 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
144 | fileL+="/"; | 146 | fileL+="/"; |
145 | isDir=TRUE; | 147 | isDir=TRUE; |
146 | } | 148 | } |
147 | } | 149 | } |
148 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); | 150 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); |
149 | if(fileL !="./" && fi->exists()) { | 151 | if(fileL !="./" && fi->exists()) { |
150 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); | 152 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); |
151 | 153 | ||
152 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 154 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
153 | 155 | ||
154 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 156 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
155 | pm = Resource::loadPixmap( "lockedfolder" ); | 157 | pm = Resource::loadPixmap( "lockedfolder" ); |
156 | else | 158 | else |
157 | pm= Resource::loadPixmap( "folder" ); | 159 | pm= Resource::loadPixmap( "folder" ); |
158 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 160 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
159 | pm = Resource::loadPixmap( "exec"); | 161 | pm = Resource::loadPixmap( "exec"); |
160 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 162 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
161 | | fileInfo.permission( QFileInfo::ExeGroup) | 163 | | fileInfo.permission( QFileInfo::ExeGroup) |
162 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 164 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
163 | pm = Resource::loadPixmap( "exec"); | 165 | pm = Resource::loadPixmap( "exec"); |
164 | } else if( !fi->isReadable() ) { | 166 | } else if( !fi->isReadable() ) { |
165 | pm = Resource::loadPixmap( "locked" ); | 167 | pm = Resource::loadPixmap( "locked" ); |
166 | } else { //everything else goes by mimetype | 168 | } else { //everything else goes by mimetype |
167 | MimeType mt(fi->filePath()); | 169 | MimeType mt(fi->filePath()); |
168 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 170 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
169 | if(pm.isNull()) | 171 | if(pm.isNull()) |
170 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 172 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
171 | } | 173 | } |
172 | item->setPixmap( 0,pm); | 174 | item->setPixmap( 0,pm); |
173 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 175 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
174 | // overlay link image | 176 | // overlay link image |
175 | pm= Resource::loadPixmap( "folder" ); | 177 | pm= Resource::loadPixmap( "folder" ); |
176 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 178 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
177 | QPainter painter( &pm ); | 179 | QPainter painter( &pm ); |
178 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 180 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
179 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 181 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
180 | item->setPixmap( 0, pm); | 182 | item->setPixmap( 0, pm); |
181 | } | 183 | } |
182 | } | 184 | } |
183 | isDir=FALSE; | 185 | isDir=FALSE; |
184 | ++it; | 186 | ++it; |
185 | } | 187 | } |
186 | 188 | ||
187 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { | 189 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { |
188 | struct stat buf; | 190 | struct stat buf; |
189 | dev_t devT; | 191 | dev_t devT; |
190 | DIR *dir; | 192 | DIR *dir; |
191 | struct dirent *mydirent; | 193 | struct dirent *mydirent; |
192 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) | 194 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) |
193 | while ((mydirent = readdir(dir)) != NULL) { | 195 | while ((mydirent = readdir(dir)) != NULL) { |
194 | lstat( mydirent->d_name, &buf); | 196 | lstat( mydirent->d_name, &buf); |
195 | qDebug(mydirent->d_name); | 197 | qDebug(mydirent->d_name); |
196 | fileL.sprintf("%s", mydirent->d_name); | 198 | fileL.sprintf("%s", mydirent->d_name); |
197 | devT = buf.st_dev; | 199 | devT = buf.st_dev; |
198 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 200 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
199 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 201 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
200 | if( fileL.find(".") == -1 ){ | 202 | if( fileL.find(".") == -1 ){ |
201 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); | 203 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); |
202 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 204 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
203 | item->setPixmap( 0,pm); | 205 | item->setPixmap( 0,pm); |
204 | } | 206 | } |
205 | } | 207 | } |
206 | 208 | ||
207 | closedir(dir); | 209 | closedir(dir); |
208 | } | 210 | } |
209 | 211 | ||
210 | Local_View->setSorting( 3,FALSE); | 212 | Local_View->setSorting( 3,FALSE); |
211 | fillCombo( (const QString &) currentDir.canonicalPath()); | 213 | fillCombo( (const QString &) currentDir.canonicalPath()); |
212 | } | 214 | } |
213 | 215 | ||
214 | 216 | ||
215 | void AdvancedFm::populateRemoteView() { | 217 | void AdvancedFm::populateRemoteView() { |
216 | QPixmap pm; | 218 | QPixmap pm; |
217 | Remote_View->clear(); | 219 | Remote_View->clear(); |
218 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 220 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
219 | currentRemoteDir.setMatchAllDirs(TRUE); | 221 | currentRemoteDir.setMatchAllDirs(TRUE); |
220 | currentRemoteDir.setNameFilter(filterStr); | 222 | currentRemoteDir.setNameFilter(filterStr); |
221 | QString fileL, fileS, fileDate; | 223 | QString fileL, fileS, fileDate; |
222 | 224 | ||
223 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 225 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
224 | setCaption("AdvancedFm :: "+fs+" :: " | 226 | setCaption("AdvancedFm :: "+fs+" :: " |
225 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | 227 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); |
226 | bool isDir=FALSE; | 228 | bool isDir=FALSE; |
227 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 229 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
228 | QFileInfoListIterator it(*list); | 230 | QFileInfoListIterator it(*list); |
229 | QFileInfo *fi; | 231 | QFileInfo *fi; |
230 | while ( (fi=it.current()) ) { | 232 | while ( (fi=it.current()) ) { |
231 | if (fi->isSymLink() ){ | 233 | if (fi->isSymLink() ){ |
232 | QString symLink=fi->readLink(); | 234 | QString symLink=fi->readLink(); |
233 | // qDebug("Symlink detected "+symLink); | 235 | // qDebug("Symlink detected "+symLink); |
234 | QFileInfo sym( symLink); | 236 | QFileInfo sym( symLink); |
235 | fileS.sprintf( "%10i", sym.size() ); | 237 | fileS.sprintf( "%10i", sym.size() ); |
236 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); | 238 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); |
237 | fileDate = sym.lastModified().toString(); | 239 | fileDate = sym.lastModified().toString(); |
238 | } else { | 240 | } else { |
239 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 241 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
240 | fileS.sprintf( "%10i", fi->size() ); | 242 | fileS.sprintf( "%10i", fi->size() ); |
241 | fileL.sprintf( "%s",fi->fileName().data() ); | 243 | fileL.sprintf( "%s",fi->fileName().data() ); |
242 | fileDate= fi->lastModified().toString(); | 244 | fileDate= fi->lastModified().toString(); |
243 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { | 245 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { |
244 | fileL+="/"; | 246 | fileL+="/"; |
245 | isDir=TRUE; | 247 | isDir=TRUE; |
246 | // qDebug( fileL); | 248 | // qDebug( fileL); |
247 | } | 249 | } |
248 | } | 250 | } |
249 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); | 251 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); |
250 | if(fileL !="./" && fi->exists()) { | 252 | if(fileL !="./" && fi->exists()) { |
251 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 253 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
252 | QPixmap pm; | 254 | QPixmap pm; |
253 | 255 | ||
254 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 256 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
255 | if( !QDir( fi->filePath() ).isReadable()) | 257 | if( !QDir( fi->filePath() ).isReadable()) |
256 | pm = Resource::loadPixmap( "lockedfolder" ); | 258 | pm = Resource::loadPixmap( "lockedfolder" ); |
257 | else | 259 | else |
258 | pm= Resource::loadPixmap( "folder" ); | 260 | pm= Resource::loadPixmap( "folder" ); |
259 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 261 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
260 | pm = Resource::loadPixmap( "exec"); | 262 | pm = Resource::loadPixmap( "exec"); |
261 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 263 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
262 | | fileInfo.permission( QFileInfo::ExeGroup) | 264 | | fileInfo.permission( QFileInfo::ExeGroup) |
263 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 265 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
264 | pm = Resource::loadPixmap( "exec"); | 266 | pm = Resource::loadPixmap( "exec"); |
265 | } else if( !fi->isReadable() ) { | 267 | } else if( !fi->isReadable() ) { |
266 | pm = Resource::loadPixmap( "locked" ); | 268 | pm = Resource::loadPixmap( "locked" ); |
267 | } else { | 269 | } else { |
268 | MimeType mt(fi->filePath()); | 270 | MimeType mt(fi->filePath()); |
269 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 271 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
270 | if(pm.isNull()) | 272 | if(pm.isNull()) |
271 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 273 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
272 | } | 274 | } |
273 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 275 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
274 | // overlay link image | 276 | // overlay link image |
275 | pm= Resource::loadPixmap( "folder" ); | 277 | pm= Resource::loadPixmap( "folder" ); |
276 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 278 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
277 | QPainter painter( &pm ); | 279 | QPainter painter( &pm ); |
278 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 280 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
279 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 281 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
280 | } | 282 | } |
281 | item->setPixmap( 0, pm); | 283 | item->setPixmap( 0, pm); |
282 | } | 284 | } |
283 | isDir=FALSE; | 285 | isDir=FALSE; |
284 | ++it; | 286 | ++it; |
285 | } | 287 | } |
286 | 288 | ||
287 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { | 289 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { |
288 | struct stat buf; | 290 | struct stat buf; |
289 | DIR *dir; | 291 | DIR *dir; |
290 | struct dirent *mydirent; | 292 | struct dirent *mydirent; |
291 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) | 293 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) |
292 | while ((mydirent = readdir(dir)) != NULL) { | 294 | while ((mydirent = readdir(dir)) != NULL) { |
293 | lstat( mydirent->d_name, &buf); | 295 | lstat( mydirent->d_name, &buf); |
294 | qDebug(mydirent->d_name); | 296 | qDebug(mydirent->d_name); |
295 | fileL.sprintf("%s", mydirent->d_name); | 297 | fileL.sprintf("%s", mydirent->d_name); |
296 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); | 298 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); |
297 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 299 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
298 | if( fileL.find(".") == -1 ){ | 300 | if( fileL.find(".") == -1 ){ |
299 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 301 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
300 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 302 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
301 | item->setPixmap( 0,pm); | 303 | item->setPixmap( 0,pm); |
302 | } | 304 | } |
303 | } | 305 | } |
304 | 306 | ||
305 | closedir(dir); | 307 | closedir(dir); |
306 | } | 308 | } |
307 | 309 | ||
308 | Remote_View->setSorting( 3,FALSE); | 310 | Remote_View->setSorting( 3,FALSE); |
309 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); | 311 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); |
310 | } | 312 | } |
311 | 313 | ||
312 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) { | 314 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) { |
313 | if(selectedItem) { | 315 | if(selectedItem) { |
314 | QString strItem=selectedItem->text(0); | 316 | QString strItem=selectedItem->text(0); |
315 | QString strSize=selectedItem->text(1); | 317 | QString strSize=selectedItem->text(1); |
316 | strSize=strSize.stripWhiteSpace(); | 318 | strSize=strSize.stripWhiteSpace(); |
317 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 319 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
318 | QString strItem2 = dealWithSymName((const QString&)strItem); | 320 | QString strItem2 = dealWithSymName((const QString&)strItem); |
319 | // QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 321 | // QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
320 | if(QDir(strItem2).exists() ) { | 322 | if(QDir(strItem2).exists() ) { |
321 | currentDir.cd(strItem2, TRUE); | 323 | currentDir.cd(strItem2, TRUE); |
322 | populateLocalView(); | 324 | populateLocalView(); |
323 | 325 | ||
324 | } | 326 | } |
325 | } else { // not a symlink | 327 | } else { // not a symlink |
326 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 328 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
327 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 329 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
328 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 330 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
329 | currentDir.cd(strItem,FALSE); | 331 | currentDir.cd(strItem,FALSE); |
330 | populateLocalView(); | 332 | populateLocalView(); |
331 | Local_View->ensureItemVisible(Local_View->firstChild()); | 333 | Local_View->ensureItemVisible(Local_View->firstChild()); |
332 | 334 | ||
333 | } else { | 335 | } else { |
334 | currentDir.cdUp(); | 336 | currentDir.cdUp(); |
335 | populateLocalView(); | 337 | populateLocalView(); |
336 | Local_View->ensureItemVisible(Local_View->firstChild()); | 338 | Local_View->ensureItemVisible(Local_View->firstChild()); |
337 | } | 339 | } |
338 | if(QDir(strItem).exists()){ | 340 | if(QDir(strItem).exists()){ |
339 | currentDir.cd(strItem, TRUE); | 341 | currentDir.cd(strItem, TRUE); |
340 | Local_View->ensureItemVisible(Local_View->firstChild()); | 342 | Local_View->ensureItemVisible(Local_View->firstChild()); |
341 | populateLocalView(); | 343 | populateLocalView(); |
342 | } | 344 | } |
343 | } else { | 345 | } else { |
344 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 346 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
345 | if( QFile::exists(strItem ) ) { | 347 | if( QFile::exists(strItem ) ) { |
346 | // qDebug("clicked item "+strItem); | 348 | // qDebug("clicked item "+strItem); |
347 | // DocLnk doc( strItem, FALSE ); | 349 | // DocLnk doc( strItem, FALSE ); |
348 | // doc.execute(); | 350 | // doc.execute(); |
349 | // Local_View->clearSelection(); | 351 | // Local_View->clearSelection(); |
350 | } | 352 | } |
351 | } //end not symlink | 353 | } //end not symlink |
352 | chdir(strItem.latin1()); | 354 | chdir(strItem.latin1()); |
353 | } | 355 | } |
354 | 356 | ||
355 | } | 357 | } |
356 | } | 358 | } |
357 | 359 | ||
358 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { | 360 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { |
359 | 361 | ||
360 | if(selectedItem) { | 362 | if(selectedItem) { |
361 | QString strItem=selectedItem->text(0); | 363 | QString strItem=selectedItem->text(0); |
362 | QString strSize=selectedItem->text(1); | 364 | QString strSize=selectedItem->text(1); |
363 | strSize=strSize.stripWhiteSpace(); | 365 | strSize=strSize.stripWhiteSpace(); |
364 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 366 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
365 | QString strItem2 = dealWithSymName((const QString&)strItem); | 367 | QString strItem2 = dealWithSymName((const QString&)strItem); |
366 | // QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 368 | // QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
367 | currentRemoteDir.cd(strItem2, TRUE); | 369 | currentRemoteDir.cd(strItem2, TRUE); |
368 | populateRemoteView(); | 370 | populateRemoteView(); |
369 | } else { // not a symlink | 371 | } else { // not a symlink |
370 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 372 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
371 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { | 373 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { |
372 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 374 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
373 | currentRemoteDir.cd(strItem,FALSE); | 375 | currentRemoteDir.cd(strItem,FALSE); |
374 | populateRemoteView(); | 376 | populateRemoteView(); |
375 | Remote_View->ensureItemVisible(Remote_View->firstChild()); | 377 | Remote_View->ensureItemVisible(Remote_View->firstChild()); |
376 | } else { | 378 | } else { |
377 | currentRemoteDir.cdUp(); | 379 | currentRemoteDir.cdUp(); |
378 | populateRemoteView(); | 380 | populateRemoteView(); |
379 | Remote_View->ensureItemVisible(Remote_View->firstChild()); | 381 | Remote_View->ensureItemVisible(Remote_View->firstChild()); |
380 | } | 382 | } |
381 | if(QDir(strItem).exists()){ | 383 | if(QDir(strItem).exists()){ |
382 | currentRemoteDir.cd(strItem, TRUE); | 384 | currentRemoteDir.cd(strItem, TRUE); |
383 | populateRemoteView(); | 385 | populateRemoteView(); |
384 | Remote_View->ensureItemVisible(Remote_View->firstChild()); | 386 | Remote_View->ensureItemVisible(Remote_View->firstChild()); |
385 | } | 387 | } |
386 | } else { | 388 | } else { |
387 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 389 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
388 | if( QFile::exists(strItem ) ) { | 390 | if( QFile::exists(strItem ) ) { |
389 | // qDebug("clicked item "+strItem); | 391 | // qDebug("clicked item "+strItem); |
390 | // DocLnk doc( strItem, FALSE ); | 392 | // DocLnk doc( strItem, FALSE ); |
391 | // doc.execute(); | 393 | // doc.execute(); |
392 | // Remote_View->clearSelection(); | 394 | // Remote_View->clearSelection(); |
393 | } | 395 | } |
394 | } //end not symlink | 396 | } //end not symlink |
395 | chdir(strItem.latin1()); | 397 | chdir(strItem.latin1()); |
396 | } | 398 | } |
397 | } | 399 | } |
398 | } | 400 | } |
399 | 401 | ||
400 | 402 | ||
401 | void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 403 | void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
402 | // qDebug("list pressed"); | 404 | // qDebug("list pressed"); |
403 | switch (mouse) { | 405 | switch (mouse) { |
404 | case 1: | 406 | case 1: |
407 | { | ||
408 | if(renameBox != 0 ) | ||
409 | { | ||
410 | qDebug("cancel rename"); | ||
411 | cancelRename(); | ||
412 | } | ||
413 | |||
414 | } | ||
405 | break; | 415 | break; |
406 | case 2: | 416 | case 2: |
407 | menuTimer.start( 500, TRUE ); | 417 | menuTimer.start( 500, TRUE ); |
408 | qDebug("Start menu timer\n"); | 418 | qDebug("Start menu timer\n"); |
409 | break; | 419 | break; |
410 | }; | 420 | }; |
411 | } | 421 | } |
412 | 422 | ||
413 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { | 423 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { |
414 | 424 | ||
415 | switch (mouse) { | 425 | switch (mouse) { |
416 | case 1: | 426 | case 1: |
417 | break; | 427 | { |
418 | case 2: | 428 | if(renameBox != 0 ) |
419 | menuTimer.start( 500, TRUE ); | 429 | { |
420 | qDebug("Start menu timer"); | 430 | qDebug("cancel rename"); |
421 | break; | 431 | cancelRename(); |
422 | }; | 432 | } |
433 | } | ||
434 | break; | ||
435 | case 2: | ||
436 | menuTimer.start( 500, TRUE ); | ||
437 | qDebug("Start menu timer"); | ||
438 | break; | ||
439 | }; | ||
423 | } | 440 | } |
424 | 441 | ||
425 | 442 | ||
426 | void AdvancedFm::switchToLocalTab() { | 443 | void AdvancedFm::switchToLocalTab() { |
427 | TabWidget->setCurrentTab(0); | 444 | TabWidget->setCurrentTab(0); |
428 | Local_View->setFocus(); | 445 | Local_View->setFocus(); |
429 | } | 446 | } |
430 | 447 | ||
431 | void AdvancedFm::switchToRemoteTab() { | 448 | void AdvancedFm::switchToRemoteTab() { |
432 | TabWidget->setCurrentTab(1); | 449 | TabWidget->setCurrentTab(1); |
433 | Remote_View->setFocus(); | 450 | Remote_View->setFocus(); |
434 | } | 451 | } |
435 | 452 | ||
436 | void AdvancedFm::readConfig() { | 453 | void AdvancedFm::readConfig() { |
437 | Config cfg("AdvancedFm"); | 454 | Config cfg("AdvancedFm"); |
438 | } | 455 | } |
439 | 456 | ||
440 | void AdvancedFm::writeConfig() { | 457 | void AdvancedFm::writeConfig() { |
441 | Config cfg("AdvancedFm"); | 458 | Config cfg("AdvancedFm"); |
442 | } | 459 | } |
443 | 460 | ||
444 | void AdvancedFm::currentPathComboChanged() { | 461 | void AdvancedFm::currentPathComboChanged() { |
445 | if (TabWidget->getCurrentTab() == 0) { | 462 | if (TabWidget->getCurrentTab() == 0) { |
446 | // if (TabWidget->currentPageIndex() == 0) { | 463 | // if (TabWidget->currentPageIndex() == 0) { |
447 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 464 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
448 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 465 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
449 | populateLocalView(); | 466 | populateLocalView(); |
450 | } else { | 467 | } else { |
451 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 468 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
452 | } | 469 | } |
453 | } | 470 | } |
454 | if (TabWidget->getCurrentTab() == 0) { | 471 | if (TabWidget->getCurrentTab() == 0) { |
455 | // if (TabWidget->currentPageIndex() == 0) { | 472 | // if (TabWidget->currentPageIndex() == 0) { |
456 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 473 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
457 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); | 474 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); |
458 | populateRemoteView(); | 475 | populateRemoteView(); |
459 | } else { | 476 | } else { |
460 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 477 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
461 | } | 478 | } |
462 | } | 479 | } |
463 | } | 480 | } |
464 | 481 | ||
465 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 482 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
466 | qDebug("%d",TabWidget->getCurrentTab()); | 483 | qDebug("%d",TabWidget->getCurrentTab()); |
467 | if (TabWidget->getCurrentTab() == 0) { | 484 | if (TabWidget->getCurrentTab() == 0) { |
468 | // if (TabWidget->currentPageIndex() == 0) { | 485 | // if (TabWidget->currentPageIndex() == 0) { |
469 | currentPathCombo->lineEdit()->setText( currentPath); | 486 | currentPathCombo->lineEdit()->setText( currentPath); |
470 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 487 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
471 | currentPathCombo->clear(); | 488 | currentPathCombo->clear(); |
472 | localDirPathStringList.prepend( currentPath ); | 489 | localDirPathStringList.prepend( currentPath ); |
473 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 490 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
474 | } | 491 | } |
475 | } else { | 492 | } else { |
476 | currentPathCombo->lineEdit()->setText( currentPath); | 493 | currentPathCombo->lineEdit()->setText( currentPath); |
477 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 494 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
478 | currentPathCombo->clear(); | 495 | currentPathCombo->clear(); |
479 | remoteDirPathStringList.prepend( currentPath ); | 496 | remoteDirPathStringList.prepend( currentPath ); |
480 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 497 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
481 | } | 498 | } |
482 | } | 499 | } |
483 | } | 500 | } |
484 | 501 | ||
485 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | 502 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { |
486 | if (TabWidget->getCurrentTab() == 0) { | 503 | if (TabWidget->getCurrentTab() == 0) { |
487 | // if (TabWidget->currentPageIndex() == 0) { | 504 | // if (TabWidget->currentPageIndex() == 0) { |
488 | chdir( currentPath.latin1() ); | 505 | chdir( currentPath.latin1() ); |
489 | currentDir.cd( currentPath, TRUE); | 506 | currentDir.cd( currentPath, TRUE); |
490 | populateLocalView(); | 507 | populateLocalView(); |
491 | update(); | 508 | update(); |
492 | } else { | 509 | } else { |
493 | chdir( currentPath.latin1() ); | 510 | chdir( currentPath.latin1() ); |
494 | currentRemoteDir.cd( currentPath, TRUE); | 511 | currentRemoteDir.cd( currentPath, TRUE); |
495 | populateRemoteView(); | 512 | populateRemoteView(); |
496 | update(); | 513 | update(); |
497 | } | 514 | } |
498 | } | 515 | } |
499 | 516 | ||
500 | QStringList AdvancedFm::getPath() { | 517 | QStringList AdvancedFm::getPath() { |
501 | QStringList strList; | 518 | QStringList strList; |
502 | if (TabWidget->getCurrentTab() == 0) { | 519 | if (TabWidget->getCurrentTab() == 0) { |
503 | // if (TabWidget->currentPageIndex() == 0) { | 520 | // if (TabWidget->currentPageIndex() == 0) { |
504 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 521 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
505 | QListViewItemIterator it( Local_View ); | 522 | QListViewItemIterator it( Local_View ); |
506 | for ( ; it.current(); ++it ) { | 523 | for ( ; it.current(); ++it ) { |
507 | if ( it.current()->isSelected() ) { | 524 | if ( it.current()->isSelected() ) { |
508 | strList << it.current()->text(0); | 525 | strList << it.current()->text(0); |
509 | qDebug(it.current()->text(0)); | 526 | qDebug(it.current()->text(0)); |
510 | } | 527 | } |
511 | } | 528 | } |
512 | return strList; | 529 | return strList; |
513 | } else { | 530 | } else { |
514 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 531 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
515 | QListViewItemIterator it( Remote_View ); | 532 | QListViewItemIterator it( Remote_View ); |
516 | for ( ; it.current(); ++it ) { | 533 | for ( ; it.current(); ++it ) { |
517 | if ( it.current()->isSelected() ) { | 534 | if ( it.current()->isSelected() ) { |
518 | strList << it.current()->text(0); | 535 | strList << it.current()->text(0); |
519 | qDebug(it.current()->text(0)); | 536 | qDebug(it.current()->text(0)); |
520 | } | 537 | } |
521 | } | 538 | } |
522 | return strList; | 539 | return strList; |
523 | } | 540 | } |
524 | return ""; | 541 | return ""; |
525 | } | 542 | } |
526 | 543 | ||
527 | void AdvancedFm::homeButtonPushed() { | 544 | void AdvancedFm::homeButtonPushed() { |
528 | QString current = QDir::homeDirPath(); | 545 | QString current = QDir::homeDirPath(); |
529 | chdir( current.latin1() ); | 546 | chdir( current.latin1() ); |
530 | if (TabWidget->getCurrentTab() == 0) { | 547 | if (TabWidget->getCurrentTab() == 0) { |
531 | // if (TabWidget->currentPageIndex() == 0) { | 548 | // if (TabWidget->currentPageIndex() == 0) { |
532 | currentDir.cd( current, TRUE); | 549 | currentDir.cd( current, TRUE); |
533 | populateLocalView(); | 550 | populateLocalView(); |
534 | } else { | 551 | } else { |
535 | currentRemoteDir.cd( current, TRUE); | 552 | currentRemoteDir.cd( current, TRUE); |
536 | populateRemoteView(); | 553 | populateRemoteView(); |
537 | } | 554 | } |
538 | update(); | 555 | update(); |
539 | } | 556 | } |
540 | 557 | ||
541 | void AdvancedFm::docButtonPushed() { | 558 | void AdvancedFm::docButtonPushed() { |
542 | QString current = QPEApplication::documentDir(); | 559 | QString current = QPEApplication::documentDir(); |
543 | chdir( current.latin1() ); | 560 | chdir( current.latin1() ); |
544 | 561 | ||
545 | if (TabWidget->getCurrentTab() == 0) { | 562 | if (TabWidget->getCurrentTab() == 0) { |
546 | //if (TabWidget->currentPageIndex() == 0) { | 563 | //if (TabWidget->currentPageIndex() == 0) { |
547 | currentDir.cd( current, TRUE); | 564 | currentDir.cd( current, TRUE); |
548 | populateLocalView(); | 565 | populateLocalView(); |
549 | } else { | 566 | } else { |
550 | currentRemoteDir.cd( current, TRUE); | 567 | currentRemoteDir.cd( current, TRUE); |
551 | populateRemoteView(); | 568 | populateRemoteView(); |
552 | } | 569 | } |
553 | update(); | 570 | update(); |
554 | } | 571 | } |
555 | 572 | ||
556 | void AdvancedFm::SDButtonPushed() { | 573 | void AdvancedFm::SDButtonPushed() { |
557 | QString current = "/mnt/card";// this can change so fix | 574 | QString current = "/mnt/card";// this can change so fix |
558 | chdir( current.latin1() ); | 575 | chdir( current.latin1() ); |
559 | if (TabWidget->getCurrentTab() == 0) { | 576 | if (TabWidget->getCurrentTab() == 0) { |
560 | // if (TabWidget->currentPageIndex() == 0) { | 577 | // if (TabWidget->currentPageIndex() == 0) { |
561 | currentDir.cd( current, TRUE); | 578 | currentDir.cd( current, TRUE); |
562 | populateLocalView(); | 579 | populateLocalView(); |
563 | } else { | 580 | } else { |
564 | currentRemoteDir.cd( current, TRUE); | 581 | currentRemoteDir.cd( current, TRUE); |
565 | populateRemoteView(); | 582 | populateRemoteView(); |
566 | } | 583 | } |
567 | update(); | 584 | update(); |
568 | 585 | ||
569 | } | 586 | } |
570 | 587 | ||
571 | void AdvancedFm::CFButtonPushed() { | 588 | void AdvancedFm::CFButtonPushed() { |
572 | QString current; | 589 | QString current; |
573 | if(zaurusDevice) | 590 | if(zaurusDevice) |
574 | current= "/mnt/cf"; //zaurus | 591 | current= "/mnt/cf"; //zaurus |
575 | else | 592 | else |
576 | current = "/mnt/hda"; //ipaq | 593 | current = "/mnt/hda"; //ipaq |
577 | 594 | ||
578 | chdir( current.latin1() ); | 595 | chdir( current.latin1() ); |
579 | if (TabWidget->getCurrentTab() == 0) { | 596 | if (TabWidget->getCurrentTab() == 0) { |
580 | // if (TabWidget->currentPageIndex() == 0) { | 597 | // if (TabWidget->currentPageIndex() == 0) { |
581 | currentDir.cd( current, TRUE); | 598 | currentDir.cd( current, TRUE); |
582 | populateLocalView(); | 599 | populateLocalView(); |
583 | } else { | 600 | } else { |
584 | currentRemoteDir.cd( current, TRUE); | 601 | currentRemoteDir.cd( current, TRUE); |
585 | populateRemoteView(); | 602 | populateRemoteView(); |
586 | } | 603 | } |
587 | update(); | 604 | update(); |
588 | } | 605 | } |
589 | 606 | ||
590 | 607 | ||
591 | 608 | ||
592 | void AdvancedFm::doAbout() { | 609 | void AdvancedFm::doAbout() { |
593 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" | 610 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" |
594 | "is copyright 2002 by\n" | 611 | "is copyright 2002 by\n" |
595 | "L.J.Potter<llornkcor@handhelds.org>\n" | 612 | "L.J.Potter<llornkcor@handhelds.org>\n" |
596 | "and is licensed by the GPL")); | 613 | "and is licensed by the GPL")); |
597 | } | 614 | } |
598 | 615 | ||
599 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | 616 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
600 | if( TabWidget->hasFocus()) | 617 | if( TabWidget->hasFocus()) |
601 | switch ( e->key() ) { | 618 | switch ( e->key() ) { |
602 | case Key_Delete: | 619 | case Key_Delete: |
603 | del(); | 620 | del(); |
604 | break; | 621 | break; |
605 | case Key_H: | 622 | case Key_H: |
606 | showHidden(); | 623 | showHidden(); |
607 | break; | 624 | break; |
608 | case Key_E: | 625 | case Key_E: |
609 | runThis(); | 626 | runThis(); |
610 | break; | 627 | break; |
611 | case Key_C: | 628 | case Key_C: |
612 | copy(); | 629 | copy(); |
613 | break; | 630 | break; |
614 | case Key_A: | 631 | case Key_A: |
615 | copyAs(); | 632 | copyAs(); |
616 | break; | 633 | break; |
617 | case Key_M: | 634 | case Key_M: |
618 | move(); | 635 | move(); |
619 | break; | 636 | break; |
620 | case Key_R: | 637 | case Key_R: |
621 | rn(); | 638 | rn(); |
622 | break; | 639 | break; |
623 | case Key_I: | 640 | case Key_I: |
624 | fileStatus(); | 641 | fileStatus(); |
625 | break; | 642 | break; |
626 | case Key_U: | 643 | case Key_U: |
627 | upDir(); | 644 | upDir(); |
628 | break; | 645 | break; |
629 | case Key_P: | 646 | case Key_P: |
630 | filePerms(); | 647 | filePerms(); |
631 | break; | 648 | break; |
632 | case Key_N: | 649 | case Key_N: |
633 | mkDir(); | 650 | mkDir(); |
634 | break; | 651 | break; |
635 | case Key_1: | 652 | case Key_1: |
636 | switchToLocalTab(); | 653 | switchToLocalTab(); |
637 | break; | 654 | break; |
638 | case Key_2: | 655 | case Key_2: |
639 | switchToRemoteTab(); | 656 | switchToRemoteTab(); |
640 | break; | 657 | break; |
641 | case Key_3: | 658 | case Key_3: |
642 | CFButtonPushed(); | 659 | CFButtonPushed(); |
643 | break; | 660 | break; |
644 | case Key_4: | 661 | case Key_4: |
645 | SDButtonPushed(); | 662 | SDButtonPushed(); |
646 | break; | 663 | break; |
647 | case Key_5: | 664 | case Key_5: |
648 | homeButtonPushed(); | 665 | homeButtonPushed(); |
649 | break; | 666 | break; |
650 | case Key_6: | 667 | case Key_6: |
651 | docButtonPushed(); | 668 | docButtonPushed(); |
652 | break; | 669 | break; |
653 | case Key_7: | 670 | case Key_7: |
654 | break; | 671 | break; |
655 | case Key_8: | 672 | case Key_8: |
656 | break; | 673 | break; |
657 | case Key_9: | 674 | case Key_9: |
658 | break; | 675 | break; |
659 | case Key_0: | 676 | case Key_0: |
660 | break; | 677 | break; |
661 | } | 678 | } |
662 | } | 679 | } |
663 | 680 | ||
664 | 681 | ||
665 | void AdvancedFm::QPEButtonPushed() { | 682 | void AdvancedFm::QPEButtonPushed() { |
666 | QString current = QPEApplication::qpeDir(); | 683 | QString current = QPEApplication::qpeDir(); |
667 | chdir( current.latin1() ); | 684 | chdir( current.latin1() ); |
668 | if (TabWidget->getCurrentTab() == 0) { | 685 | if (TabWidget->getCurrentTab() == 0) { |
669 | // if (TabWidget->currentPageIndex() == 0) { | 686 | // if (TabWidget->currentPageIndex() == 0) { |
670 | currentDir.cd( current, TRUE); | 687 | currentDir.cd( current, TRUE); |
671 | populateLocalView(); | 688 | populateLocalView(); |
672 | } else { | 689 | } else { |
673 | currentRemoteDir.cd( current, TRUE); | 690 | currentRemoteDir.cd( current, TRUE); |
674 | populateRemoteView(); | 691 | populateRemoteView(); |
675 | } | 692 | } |
676 | update(); | 693 | update(); |
677 | } | 694 | } |
678 | 695 | ||
679 | void AdvancedFm::parsetab(const QString &fileName) { | 696 | void AdvancedFm::parsetab(const QString &fileName) { |
680 | 697 | ||
681 | fileSystemTypeList.clear(); | 698 | fileSystemTypeList.clear(); |
682 | fsList.clear(); | 699 | fsList.clear(); |
683 | struct mntent *me; | 700 | struct mntent *me; |
684 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 701 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
685 | if ( mntfp ) { | 702 | if ( mntfp ) { |
686 | while ( (me = getmntent( mntfp )) != 0 ) { | 703 | while ( (me = getmntent( mntfp )) != 0 ) { |
687 | QString deviceName = me->mnt_fsname; | 704 | QString deviceName = me->mnt_fsname; |
688 | QString filesystemType = me->mnt_type; | 705 | QString filesystemType = me->mnt_type; |
689 | QString mountDir = me->mnt_dir; | 706 | QString mountDir = me->mnt_dir; |
690 | if(deviceName != "none") { | 707 | if(deviceName != "none") { |
691 | if( fsList.contains(filesystemType) == 0 | 708 | if( fsList.contains(filesystemType) == 0 |
692 | & filesystemType.find("proc",0,TRUE) == -1 | 709 | & filesystemType.find("proc",0,TRUE) == -1 |
693 | & filesystemType.find("cramfs",0,TRUE) == -1 | 710 | & filesystemType.find("cramfs",0,TRUE) == -1 |
694 | & filesystemType.find("auto",0,TRUE) == -1) | 711 | & filesystemType.find("auto",0,TRUE) == -1) |
695 | fsList << filesystemType; | 712 | fsList << filesystemType; |
696 | fileSystemTypeList << mountDir+"::"+filesystemType; | 713 | fileSystemTypeList << mountDir+"::"+filesystemType; |
697 | } | 714 | } |
698 | } | 715 | } |
699 | } | 716 | } |
700 | endmntent( mntfp ); | 717 | endmntent( mntfp ); |
701 | } | 718 | } |
702 | 719 | ||
703 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 720 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
704 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 721 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
705 | QString current = currentText;//.right( currentText.length()-1); | 722 | QString current = currentText;//.right( currentText.length()-1); |
706 | QString baseFs; | 723 | QString baseFs; |
707 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 724 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
708 | QString temp = (*it); | 725 | QString temp = (*it); |
709 | QString path = temp.left(temp.find("::",0,TRUE) ); | 726 | QString path = temp.left(temp.find("::",0,TRUE) ); |
710 | path = path.right( path.length()-1); | 727 | path = path.right( path.length()-1); |
711 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 728 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
712 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 729 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
713 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 730 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
714 | } | 731 | } |
715 | } | 732 | } |
716 | return baseFs; | 733 | return baseFs; |
717 | } | 734 | } |
718 | 735 | ||
719 | QString AdvancedFm::getDiskSpace( const QString &path) { | 736 | QString AdvancedFm::getDiskSpace( const QString &path) { |
720 | struct statfs fss; | 737 | struct statfs fss; |
721 | if ( !statfs( path.latin1(), &fss ) ) { | 738 | if ( !statfs( path.latin1(), &fss ) ) { |
722 | int blkSize = fss.f_bsize; | 739 | int blkSize = fss.f_bsize; |
723 | // int totalBlks = fs.f_blocks; | 740 | // int totalBlks = fs.f_blocks; |
724 | int availBlks = fss.f_bavail; | 741 | int availBlks = fss.f_bavail; |
725 | 742 | ||
726 | long mult = blkSize / 1024; | 743 | long mult = blkSize / 1024; |
727 | long div = 1024 / blkSize; | 744 | long div = 1024 / blkSize; |
728 | if ( !mult ) mult = 1; | 745 | if ( !mult ) mult = 1; |
729 | if ( !div ) div = 1; | 746 | if ( !div ) div = 1; |
730 | 747 | ||
731 | return QString::number(availBlks * mult / div); | 748 | return QString::number(availBlks * mult / div); |
732 | } | 749 | } |
733 | return ""; | 750 | return ""; |
734 | } | 751 | } |
735 | 752 | ||
736 | 753 | ||
737 | void AdvancedFm::showFileMenu() { | 754 | void AdvancedFm::showFileMenu() { |
738 | 755 | ||
739 | QString curApp; | 756 | QString curApp; |
740 | bool isLocalView = false; | 757 | bool isLocalView = false; |
741 | if (TabWidget->getCurrentTab() == 0) { | 758 | if (TabWidget->getCurrentTab() == 0) { |
742 | // if (TabWidget->currentPageIndex() == 0) { | 759 | // if (TabWidget->currentPageIndex() == 0) { |
743 | isLocalView = TRUE; | 760 | isLocalView = TRUE; |
744 | curApp = Local_View->currentItem()->text(0); | 761 | curApp = Local_View->currentItem()->text(0); |
745 | } else { | 762 | } else { |
746 | curApp = Remote_View->currentItem()->text(0); | 763 | curApp = Remote_View->currentItem()->text(0); |
747 | } | 764 | } |
748 | 765 | ||
749 | MimeType mt( curApp ); | 766 | MimeType mt( curApp ); |
750 | const AppLnk* app = mt.application(); | 767 | const AppLnk* app = mt.application(); |
751 | QFile fi(curApp); | 768 | QFile fi(curApp); |
752 | QPopupMenu *m = new QPopupMenu(0); | 769 | QPopupMenu *m = new QPopupMenu(0); |
753 | QPopupMenu *n = new QPopupMenu(0); | 770 | QPopupMenu *n = new QPopupMenu(0); |
754 | // QPopupMenu *o = new QPopupMenu(0); | 771 | // QPopupMenu *o = new QPopupMenu(0); |
755 | if (TabWidget->getCurrentTab() == 0) | 772 | if (TabWidget->getCurrentTab() == 0) |
756 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 773 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
757 | else | 774 | else |
758 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); | 775 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showRemoteHidden() )); |
759 | 776 | ||
760 | if ( QFileInfo(fi).isDir() ) { | 777 | if ( QFileInfo(fi).isDir() ) { |
761 | m->insertSeparator(); | 778 | m->insertSeparator(); |
762 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 779 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
763 | } else { | 780 | } else { |
764 | 781 | ||
765 | if ( app ) | 782 | if ( app ) |
766 | m->insertItem( app->pixmap(), tr( "Open in " | 783 | m->insertItem( app->pixmap(), tr( "Open in " |
767 | + app->name() ), this, SLOT( runThis() ) ); | 784 | + app->name() ), this, SLOT( runThis() ) ); |
768 | else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 785 | else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
769 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); | 786 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); |
770 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); | 787 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); |
771 | } | 788 | } |
772 | 789 | ||
773 | m->insertItem(tr("Actions"),n); | 790 | m->insertItem(tr("Actions"),n); |
774 | if(isLocalView) | 791 | if(isLocalView) |
775 | n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 792 | n->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
776 | else | 793 | else |
777 | n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 794 | n->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
778 | 795 | ||
779 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 796 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
780 | 797 | ||
781 | n->insertSeparator(); | 798 | n->insertSeparator(); |
782 | 799 | ||
783 | 800 | ||
784 | if(isLocalView) | 801 | if(isLocalView) |
785 | n->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 802 | n->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
786 | else | 803 | else |
787 | n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 804 | n->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
788 | 805 | ||
789 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); | 806 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); |
790 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 807 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
791 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); | 808 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); |
792 | n->insertItem( tr( "Move" ), this, SLOT( move() )); | 809 | n->insertItem( tr( "Move" ), this, SLOT( move() )); |
793 | 810 | ||
794 | n->insertSeparator(); | 811 | n->insertSeparator(); |
795 | 812 | ||
796 | if(isLocalView) | 813 | if(isLocalView) |
797 | n->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 814 | n->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
798 | else | 815 | else |
799 | n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 816 | n->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
800 | 817 | ||
801 | 818 | ||
802 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 819 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
803 | 820 | ||
804 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 821 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
805 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 822 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
806 | 823 | ||
807 | m->insertSeparator(); | 824 | m->insertSeparator(); |
808 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 825 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
809 | 826 | ||
810 | #if defined(QT_QWS_OPIE) | 827 | #if defined(QT_QWS_OPIE) |
811 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 828 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
812 | #endif | 829 | #endif |
813 | m->setCheckable(TRUE); | 830 | m->setCheckable(TRUE); |
814 | if (!b) | 831 | if (!b) |
815 | m->setItemChecked(m->idAt(0),TRUE); | 832 | m->setItemChecked(m->idAt(0),TRUE); |
816 | else | 833 | else |
817 | m->setItemChecked(m->idAt(0),FALSE); | 834 | m->setItemChecked(m->idAt(0),FALSE); |
818 | 835 | ||
819 | if(Ir::supported()) | 836 | if(Ir::supported()) |
820 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); | 837 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); |
821 | m->setFocus(); | 838 | m->setFocus(); |
822 | m->exec( QPoint( 4,QCursor::pos().y()) ); | 839 | m->exec( QPoint( 4,QCursor::pos().y()) ); |
823 | 840 | ||
824 | if(m) delete m; | 841 | if(m) delete m; |
825 | } | 842 | } |
826 | 843 | ||
827 | 844 | ||
828 | void AdvancedFm::cancelMenuTimer() { | 845 | void AdvancedFm::cancelMenuTimer() { |
829 | 846 | ||
830 | // qDebug("selectionChanged: cancel menu timer"); | 847 | // qDebug("selectionChanged: cancel menu timer"); |
831 | if( menuTimer.isActive() ) | 848 | if( menuTimer.isActive() ) |
832 | menuTimer.stop(); | 849 | menuTimer.stop(); |
833 | } | 850 | } |
834 | 851 | ||
835 | QString AdvancedFm::checkDiskSpace(const QString &path) { | 852 | QString AdvancedFm::checkDiskSpace(const QString &path) { |
836 | struct statfs fss; | 853 | struct statfs fss; |
837 | if ( !statfs( path.latin1(), &fss ) ) { | 854 | if ( !statfs( path.latin1(), &fss ) ) { |
838 | int blkSize = fss.f_bsize; | 855 | int blkSize = fss.f_bsize; |
839 | // int totalBlks = fs.f_blocks; | 856 | // int totalBlks = fs.f_blocks; |
840 | int availBlks = fss.f_bavail; | 857 | int availBlks = fss.f_bavail; |
841 | 858 | ||
842 | long mult = blkSize / 1024; | 859 | long mult = blkSize / 1024; |
843 | long div = 1024 / blkSize; | 860 | long div = 1024 / blkSize; |
844 | if ( !mult ) mult = 1; | 861 | if ( !mult ) mult = 1; |
845 | if ( !div ) div = 1; | 862 | if ( !div ) div = 1; |
846 | 863 | ||
847 | 864 | ||
848 | return QString::number(availBlks * mult / div); | 865 | return QString::number(availBlks * mult / div); |
849 | } | 866 | } |
850 | return ""; | 867 | return ""; |
851 | } | 868 | } |
852 | 869 | ||
853 | void AdvancedFm::addToDocs() { | 870 | void AdvancedFm::addToDocs() { |
854 | QStringList strListPaths = getPath(); | 871 | QStringList strListPaths = getPath(); |
855 | if( strListPaths.count() > 0) { | 872 | if( strListPaths.count() > 0) { |
856 | QString curFile; | 873 | QString curFile; |
857 | if (TabWidget->getCurrentTab() == 0) { | 874 | if (TabWidget->getCurrentTab() == 0) { |
858 | // if (TabWidget->currentPageIndex() == 0) { | 875 | // if (TabWidget->currentPageIndex() == 0) { |
859 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { | 876 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { |
860 | curFile = currentDir.canonicalPath()+"/"+(*it); | 877 | curFile = currentDir.canonicalPath()+"/"+(*it); |
861 | qDebug(curFile); | 878 | qDebug(curFile); |
862 | DocLnk f; | 879 | DocLnk f; |
863 | // curFile.replace(QRegExp("\\..*"),""); | 880 | // curFile.replace(QRegExp("\\..*"),""); |
864 | f.setName((*it)); | 881 | f.setName((*it)); |
865 | f.setFile( curFile); | 882 | f.setFile( curFile); |
866 | f.writeLink(); | 883 | f.writeLink(); |
867 | } | 884 | } |
868 | } else { | 885 | } else { |
869 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { | 886 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { |
870 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 887 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
871 | qDebug(curFile); | 888 | qDebug(curFile); |
872 | 889 | ||
873 | DocLnk f; | 890 | DocLnk f; |
874 | // curFile.replace(QRegExp("\\..*"),""); | 891 | // curFile.replace(QRegExp("\\..*"),""); |
875 | f.setName((*it)); | 892 | f.setName((*it)); |
876 | f.setFile( curFile); | 893 | f.setFile( curFile); |
877 | f.writeLink(); | 894 | f.writeLink(); |
878 | } | 895 | } |
879 | } | 896 | } |
880 | } | 897 | } |
881 | } | 898 | } |
899 | |||
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index f067013..2ddcabc 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -262,864 +262,876 @@ void AdvancedFm::localDelete() { | |||
262 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 262 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
263 | case 1: | 263 | case 1: |
264 | return; | 264 | return; |
265 | break; | 265 | break; |
266 | }; | 266 | }; |
267 | } | 267 | } |
268 | QString cmd="rm "+f; | 268 | QString cmd="rm "+f; |
269 | QFile file(f); | 269 | QFile file(f); |
270 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) | 270 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) |
271 | file.remove(); | 271 | file.remove(); |
272 | } | 272 | } |
273 | } | 273 | } |
274 | } | 274 | } |
275 | populateLocalView(); | 275 | populateLocalView(); |
276 | } | 276 | } |
277 | 277 | ||
278 | void AdvancedFm::remoteDelete() { | 278 | void AdvancedFm::remoteDelete() { |
279 | QStringList curFileList = getPath(); | 279 | QStringList curFileList = getPath(); |
280 | bool doMsg=true; | 280 | bool doMsg=true; |
281 | int count=curFileList.count(); | 281 | int count=curFileList.count(); |
282 | if( count > 0) { | 282 | if( count > 0) { |
283 | if(count > 1 ){ | 283 | if(count > 1 ){ |
284 | QString msg; | 284 | QString msg; |
285 | msg=tr("Really delete\n%1 files?").arg(count); | 285 | msg=tr("Really delete\n%1 files?").arg(count); |
286 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 286 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
287 | ,tr("Yes"),tr("No"),0,0,1) ) { | 287 | ,tr("Yes"),tr("No"),0,0,1) ) { |
288 | case 0: | 288 | case 0: |
289 | doMsg=false; | 289 | doMsg=false; |
290 | break; | 290 | break; |
291 | case 1: | 291 | case 1: |
292 | return; | 292 | return; |
293 | break; | 293 | break; |
294 | }; | 294 | }; |
295 | } | 295 | } |
296 | 296 | ||
297 | QString myFile; | 297 | QString myFile; |
298 | 298 | ||
299 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 299 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
300 | myFile = (*it); | 300 | myFile = (*it); |
301 | if(myFile.find(" -> ",0,TRUE) != -1) | 301 | if(myFile.find(" -> ",0,TRUE) != -1) |
302 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); | 302 | myFile = myFile.left(myFile.find(" -> ",0,TRUE)); |
303 | QString f = currentRemoteDir.canonicalPath(); | 303 | QString f = currentRemoteDir.canonicalPath(); |
304 | if(f.right(1).find("/",0,TRUE) == -1) | 304 | if(f.right(1).find("/",0,TRUE) == -1) |
305 | f+="/"; | 305 | f+="/"; |
306 | f+=myFile; | 306 | f+=myFile; |
307 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 307 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
308 | switch ( QMessageBox::warning(this,tr("Delete Directory"),tr("Really delete\n")+f+ | 308 | switch ( QMessageBox::warning(this,tr("Delete Directory"),tr("Really delete\n")+f+ |
309 | "\nand all it's contents ?", | 309 | "\nand all it's contents ?", |
310 | tr("Yes"),tr("No"),0,0,1) ) { | 310 | tr("Yes"),tr("No"),0,0,1) ) { |
311 | case 0: { | 311 | case 0: { |
312 | f=f.left(f.length()-1); | 312 | f=f.left(f.length()-1); |
313 | QString cmd="rm -rf "+f; | 313 | QString cmd="rm -rf "+f; |
314 | startProcess( (const QString)cmd ); | 314 | startProcess( (const QString)cmd ); |
315 | populateRemoteView(); | 315 | populateRemoteView(); |
316 | } | 316 | } |
317 | break; | 317 | break; |
318 | case 1: | 318 | case 1: |
319 | // exit | 319 | // exit |
320 | break; | 320 | break; |
321 | }; | 321 | }; |
322 | 322 | ||
323 | } else { | 323 | } else { |
324 | if(doMsg) { | 324 | if(doMsg) { |
325 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f | 325 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f |
326 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 326 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
327 | case 1: | 327 | case 1: |
328 | return; | 328 | return; |
329 | break; | 329 | break; |
330 | }; | 330 | }; |
331 | } | 331 | } |
332 | QString cmd="rm "+f; | 332 | QString cmd="rm "+f; |
333 | QFile file(f); | 333 | QFile file(f); |
334 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) | 334 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) |
335 | file.remove(); | 335 | file.remove(); |
336 | } | 336 | } |
337 | } | 337 | } |
338 | } | 338 | } |
339 | populateRemoteView(); | 339 | populateRemoteView(); |
340 | } | 340 | } |
341 | 341 | ||
342 | 342 | ||
343 | void AdvancedFm::filePerms() { | 343 | void AdvancedFm::filePerms() { |
344 | 344 | ||
345 | QStringList curFileList = getPath(); | 345 | QStringList curFileList = getPath(); |
346 | QString filePath; | 346 | QString filePath; |
347 | 347 | ||
348 | if (TabWidget->getCurrentTab() == 0) { | 348 | if (TabWidget->getCurrentTab() == 0) { |
349 | filePath = currentDir.canonicalPath()+"/"; | 349 | filePath = currentDir.canonicalPath()+"/"; |
350 | } else { | 350 | } else { |
351 | filePath= currentRemoteDir.canonicalPath()+"/"; | 351 | filePath= currentRemoteDir.canonicalPath()+"/"; |
352 | } | 352 | } |
353 | 353 | ||
354 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 354 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
355 | filePermissions *filePerm; | 355 | filePermissions *filePerm; |
356 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 356 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
357 | filePerm->showMaximized(); | 357 | filePerm->showMaximized(); |
358 | filePerm->exec(); | 358 | filePerm->exec(); |
359 | if( filePerm) | 359 | if( filePerm) |
360 | delete filePerm; | 360 | delete filePerm; |
361 | } | 361 | } |
362 | if (TabWidget->getCurrentTab() == 0) { | 362 | if (TabWidget->getCurrentTab() == 0) { |
363 | populateLocalView(); | 363 | populateLocalView(); |
364 | } else { | 364 | } else { |
365 | populateRemoteView(); | 365 | populateRemoteView(); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | 368 | ||
369 | void AdvancedFm::doProperties() { | 369 | void AdvancedFm::doProperties() { |
370 | #if defined(QT_QWS_OPIE) | 370 | #if defined(QT_QWS_OPIE) |
371 | 371 | ||
372 | QStringList curFileList = getPath(); | 372 | QStringList curFileList = getPath(); |
373 | 373 | ||
374 | QString filePath; | 374 | QString filePath; |
375 | if (TabWidget->getCurrentTab() == 0) { | 375 | if (TabWidget->getCurrentTab() == 0) { |
376 | filePath = currentDir.canonicalPath()+"/"; | 376 | filePath = currentDir.canonicalPath()+"/"; |
377 | } else { | 377 | } else { |
378 | filePath= currentRemoteDir.canonicalPath()+"/"; | 378 | filePath= currentRemoteDir.canonicalPath()+"/"; |
379 | } | 379 | } |
380 | qDebug("%d",curFileList.count()); | 380 | qDebug("%d",curFileList.count()); |
381 | 381 | ||
382 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 382 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
383 | qDebug((filePath+*it)); | 383 | qDebug((filePath+*it)); |
384 | DocLnk lnk( (filePath+*it)); | 384 | DocLnk lnk( (filePath+*it)); |
385 | LnkProperties prop( &lnk ); | 385 | LnkProperties prop( &lnk ); |
386 | prop.showMaximized(); | 386 | prop.showMaximized(); |
387 | prop.exec(); | 387 | prop.exec(); |
388 | } | 388 | } |
389 | #endif | 389 | #endif |
390 | 390 | ||
391 | } | 391 | } |
392 | 392 | ||
393 | void AdvancedFm::upDir() { | 393 | void AdvancedFm::upDir() { |
394 | if (TabWidget->getCurrentTab() == 0) { | 394 | if (TabWidget->getCurrentTab() == 0) { |
395 | QString current = currentDir.canonicalPath(); | 395 | QString current = currentDir.canonicalPath(); |
396 | QDir dir(current); | 396 | QDir dir(current); |
397 | dir.cdUp(); | 397 | dir.cdUp(); |
398 | current = dir.canonicalPath(); | 398 | current = dir.canonicalPath(); |
399 | chdir( current.latin1() ); | 399 | chdir( current.latin1() ); |
400 | currentDir.cd( current, TRUE); | 400 | currentDir.cd( current, TRUE); |
401 | populateLocalView(); | 401 | populateLocalView(); |
402 | update(); | 402 | update(); |
403 | } else { | 403 | } else { |
404 | QString current = currentRemoteDir.canonicalPath(); | 404 | QString current = currentRemoteDir.canonicalPath(); |
405 | QDir dir(current); | 405 | QDir dir(current); |
406 | dir.cdUp(); | 406 | dir.cdUp(); |
407 | current = dir.canonicalPath(); | 407 | current = dir.canonicalPath(); |
408 | chdir( current.latin1() ); | 408 | chdir( current.latin1() ); |
409 | currentRemoteDir.cd( current, TRUE); | 409 | currentRemoteDir.cd( current, TRUE); |
410 | populateRemoteView(); | 410 | populateRemoteView(); |
411 | update(); | 411 | update(); |
412 | } | 412 | } |
413 | } | 413 | } |
414 | 414 | ||
415 | void AdvancedFm::copy() { | 415 | void AdvancedFm::copy() { |
416 | qApp->processEvents(); | 416 | qApp->processEvents(); |
417 | QStringList curFileList = getPath(); | 417 | QStringList curFileList = getPath(); |
418 | bool doMsg=true; | 418 | bool doMsg=true; |
419 | int count=curFileList.count(); | 419 | int count=curFileList.count(); |
420 | if( count > 0) { | 420 | if( count > 0) { |
421 | if(count > 1 ){ | 421 | if(count > 1 ){ |
422 | QString msg; | 422 | QString msg; |
423 | msg=tr("Really copy\n%1 files?").arg(count); | 423 | msg=tr("Really copy\n%1 files?").arg(count); |
424 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 424 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
425 | ,tr("Yes"),tr("No"),0,0,1) ) { | 425 | ,tr("Yes"),tr("No"),0,0,1) ) { |
426 | case 0: | 426 | case 0: |
427 | doMsg=false; | 427 | doMsg=false; |
428 | break; | 428 | break; |
429 | case 1: | 429 | case 1: |
430 | return; | 430 | return; |
431 | break; | 431 | break; |
432 | }; | 432 | }; |
433 | } | 433 | } |
434 | 434 | ||
435 | QString curFile, item, destFile; | 435 | QString curFile, item, destFile; |
436 | if (TabWidget->getCurrentTab() == 0) { | 436 | if (TabWidget->getCurrentTab() == 0) { |
437 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 437 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
438 | item=(*it); | 438 | item=(*it); |
439 | if(item.find("->",0,TRUE)) //symlink | 439 | if(item.find("->",0,TRUE)) //symlink |
440 | item = item.left(item.find("->",0,TRUE)); | 440 | item = item.left(item.find("->",0,TRUE)); |
441 | 441 | ||
442 | destFile = currentRemoteDir.canonicalPath()+"/"+ item; | 442 | destFile = currentRemoteDir.canonicalPath()+"/"+ item; |
443 | qDebug("Destination file is "+destFile); | 443 | qDebug("Destination file is "+destFile); |
444 | 444 | ||
445 | curFile = currentDir.canonicalPath()+"/"+ item; | 445 | curFile = currentDir.canonicalPath()+"/"+ item; |
446 | qDebug("CurrentFile file is " + curFile); | 446 | qDebug("CurrentFile file is " + curFile); |
447 | 447 | ||
448 | QFile f(destFile); | 448 | QFile f(destFile); |
449 | if( f.exists()) { | 449 | if( f.exists()) { |
450 | if(doMsg) { | 450 | if(doMsg) { |
451 | switch ( QMessageBox::warning(this,tr("File Exists!"), tr("%1 exists. Ok to overwrite?").arg( item ), tr("Yes"),tr("No"),0,0,1) ) { | 451 | switch ( QMessageBox::warning(this,tr("File Exists!"), tr("%1 exists. Ok to overwrite?").arg( item ), tr("Yes"),tr("No"),0,0,1) ) { |
452 | case 1: | 452 | case 1: |
453 | return; | 453 | return; |
454 | break; | 454 | break; |
455 | }; | 455 | }; |
456 | } | 456 | } |
457 | f.remove(); | 457 | f.remove(); |
458 | } | 458 | } |
459 | if(!copyFile( curFile, destFile) ) { | 459 | if(!copyFile( curFile, destFile) ) { |
460 | QMessageBox::message("AdvancedFm",tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 460 | QMessageBox::message("AdvancedFm",tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); |
461 | return; | 461 | return; |
462 | } | 462 | } |
463 | } | 463 | } |
464 | populateRemoteView(); | 464 | populateRemoteView(); |
465 | TabWidget->setCurrentTab(1); | 465 | TabWidget->setCurrentTab(1); |
466 | 466 | ||
467 | } else { | 467 | } else { |
468 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 468 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
469 | item= (*it); | 469 | item= (*it); |
470 | if(item.find("->",0,TRUE)) //symlink | 470 | if(item.find("->",0,TRUE)) //symlink |
471 | item = item.left(item.find("->",0,TRUE)); | 471 | item = item.left(item.find("->",0,TRUE)); |
472 | 472 | ||
473 | destFile = currentDir.canonicalPath()+"/"+ item; | 473 | destFile = currentDir.canonicalPath()+"/"+ item; |
474 | qDebug("Destination file is "+destFile); | 474 | qDebug("Destination file is "+destFile); |
475 | 475 | ||
476 | curFile = currentRemoteDir.canonicalPath()+"/"+ item;; | 476 | curFile = currentRemoteDir.canonicalPath()+"/"+ item;; |
477 | qDebug("CurrentFile file is " + curFile); | 477 | qDebug("CurrentFile file is " + curFile); |
478 | 478 | ||
479 | QFile f(destFile); | 479 | QFile f(destFile); |
480 | if( f.exists()) { | 480 | if( f.exists()) { |
481 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 481 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
482 | item+tr("\nexists. Ok to overwrite?"), | 482 | item+tr("\nexists. Ok to overwrite?"), |
483 | tr("Yes"),tr("No"),0,0,1) ) { | 483 | tr("Yes"),tr("No"),0,0,1) ) { |
484 | case 1: | 484 | case 1: |
485 | return; | 485 | return; |
486 | break; | 486 | break; |
487 | }; | 487 | }; |
488 | f.remove(); | 488 | f.remove(); |
489 | } | 489 | } |
490 | if(!copyFile( curFile, destFile) ) { | 490 | if(!copyFile( curFile, destFile) ) { |
491 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 491 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
492 | +curFile +tr("to\n")+destFile); | 492 | +curFile +tr("to\n")+destFile); |
493 | return; | 493 | return; |
494 | 494 | ||
495 | } | 495 | } |
496 | } | 496 | } |
497 | populateLocalView(); | 497 | populateLocalView(); |
498 | TabWidget->setCurrentTab(0); | 498 | TabWidget->setCurrentTab(0); |
499 | } | 499 | } |
500 | 500 | ||
501 | } | 501 | } |
502 | } | 502 | } |
503 | 503 | ||
504 | void AdvancedFm::copyAs() { | 504 | void AdvancedFm::copyAs() { |
505 | qApp->processEvents(); | 505 | qApp->processEvents(); |
506 | 506 | ||
507 | QStringList curFileList = getPath(); | 507 | QStringList curFileList = getPath(); |
508 | QString curFile, item; | 508 | QString curFile, item; |
509 | InputDialog *fileDlg; | 509 | InputDialog *fileDlg; |
510 | if (TabWidget->getCurrentTab() == 0) { | 510 | if (TabWidget->getCurrentTab() == 0) { |
511 | qDebug("tab 1"); | 511 | qDebug("tab 1"); |
512 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 512 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
513 | QString destFile; | 513 | QString destFile; |
514 | item=(*it); | 514 | item=(*it); |
515 | curFile = currentDir.canonicalPath()+"/"+(*it); | 515 | curFile = currentDir.canonicalPath()+"/"+(*it); |
516 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | 516 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); |
517 | 517 | ||
518 | fileDlg->setInputText((const QString &) destFile ); | 518 | fileDlg->setInputText((const QString &) destFile ); |
519 | fileDlg->exec(); | 519 | fileDlg->exec(); |
520 | 520 | ||
521 | if( fileDlg->result() == 1 ) { | 521 | if( fileDlg->result() == 1 ) { |
522 | QString filename = fileDlg->LineEdit1->text(); | 522 | QString filename = fileDlg->LineEdit1->text(); |
523 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | 523 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; |
524 | 524 | ||
525 | QFile f(destFile); | 525 | QFile f(destFile); |
526 | if( f.exists()) { | 526 | if( f.exists()) { |
527 | switch (QMessageBox::warning(this,tr("File Exists!"), | 527 | switch (QMessageBox::warning(this,tr("File Exists!"), |
528 | item+tr("\nexists. Ok to overwrite?"), | 528 | item+tr("\nexists. Ok to overwrite?"), |
529 | tr("Yes"),tr("No"),0,0,1) ) { | 529 | tr("Yes"),tr("No"),0,0,1) ) { |
530 | case 0: | 530 | case 0: |
531 | f.remove(); | 531 | f.remove(); |
532 | break; | 532 | break; |
533 | case 1: | 533 | case 1: |
534 | return; | 534 | return; |
535 | break; | 535 | break; |
536 | }; | 536 | }; |
537 | } | 537 | } |
538 | if(!copyFile( curFile,destFile) ) { | 538 | if(!copyFile( curFile,destFile) ) { |
539 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 539 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
540 | +curFile +tr("to\n")+destFile); | 540 | +curFile +tr("to\n")+destFile); |
541 | return; | 541 | return; |
542 | } | 542 | } |
543 | } | 543 | } |
544 | delete fileDlg; | 544 | delete fileDlg; |
545 | 545 | ||
546 | } | 546 | } |
547 | populateRemoteView(); | 547 | populateRemoteView(); |
548 | TabWidget->setCurrentTab(1); | 548 | TabWidget->setCurrentTab(1); |
549 | 549 | ||
550 | } else { | 550 | } else { |
551 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 551 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
552 | 552 | ||
553 | item=(*it); | 553 | item=(*it); |
554 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 554 | curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
555 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); | 555 | fileDlg = new InputDialog( this,tr("Copy "+curFile+" As"), TRUE, 0); |
556 | 556 | ||
557 | QString destFile; | 557 | QString destFile; |
558 | fileDlg->setInputText((const QString &) destFile); | 558 | fileDlg->setInputText((const QString &) destFile); |
559 | fileDlg->exec(); | 559 | fileDlg->exec(); |
560 | 560 | ||
561 | if( fileDlg->result() == 1 ) { | 561 | if( fileDlg->result() == 1 ) { |
562 | QString filename = fileDlg->LineEdit1->text(); | 562 | QString filename = fileDlg->LineEdit1->text(); |
563 | destFile = currentDir.canonicalPath()+"/"+filename; | 563 | destFile = currentDir.canonicalPath()+"/"+filename; |
564 | 564 | ||
565 | QFile f( destFile); | 565 | QFile f( destFile); |
566 | if( f.exists()) { | 566 | if( f.exists()) { |
567 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 567 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
568 | item+tr("\nexists. Ok to overwrite?"), | 568 | item+tr("\nexists. Ok to overwrite?"), |
569 | tr("Yes"),tr("No"),0,0,1) ) { | 569 | tr("Yes"),tr("No"),0,0,1) ) { |
570 | case 0: | 570 | case 0: |
571 | f.remove(); | 571 | f.remove(); |
572 | break; | 572 | break; |
573 | case 1: | 573 | case 1: |
574 | return; | 574 | return; |
575 | break; | 575 | break; |
576 | }; | 576 | }; |
577 | } | 577 | } |
578 | if(!copyFile( curFile,destFile) ) { | 578 | if(!copyFile( curFile,destFile) ) { |
579 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 579 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
580 | +curFile +tr("to\n")+destFile); | 580 | +curFile +tr("to\n")+destFile); |
581 | return; | 581 | return; |
582 | } | 582 | } |
583 | 583 | ||
584 | } | 584 | } |
585 | delete fileDlg; | 585 | delete fileDlg; |
586 | 586 | ||
587 | } | 587 | } |
588 | populateLocalView(); | 588 | populateLocalView(); |
589 | TabWidget->setCurrentTab(0); | 589 | TabWidget->setCurrentTab(0); |
590 | } | 590 | } |
591 | } | 591 | } |
592 | 592 | ||
593 | void AdvancedFm::copySameDir() { | 593 | void AdvancedFm::copySameDir() { |
594 | qApp->processEvents(); | 594 | qApp->processEvents(); |
595 | QStringList curFileList = getPath(); | 595 | QStringList curFileList = getPath(); |
596 | QString curFile, item, destFile; | 596 | QString curFile, item, destFile; |
597 | InputDialog *fileDlg; | 597 | InputDialog *fileDlg; |
598 | 598 | ||
599 | if (TabWidget->getCurrentTab() == 0) { | 599 | if (TabWidget->getCurrentTab() == 0) { |
600 | 600 | ||
601 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 601 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
602 | item=(*it); | 602 | item=(*it); |
603 | curFile = currentDir.canonicalPath()+"/"+ item; | 603 | curFile = currentDir.canonicalPath()+"/"+ item; |
604 | 604 | ||
605 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 605 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
606 | fileDlg->setInputText((const QString &) destFile ); | 606 | fileDlg->setInputText((const QString &) destFile ); |
607 | fileDlg->exec(); | 607 | fileDlg->exec(); |
608 | 608 | ||
609 | if( fileDlg->result() == 1 ) { | 609 | if( fileDlg->result() == 1 ) { |
610 | 610 | ||
611 | QString filename = fileDlg->LineEdit1->text(); | 611 | QString filename = fileDlg->LineEdit1->text(); |
612 | destFile = currentDir.canonicalPath()+"/"+filename; | 612 | destFile = currentDir.canonicalPath()+"/"+filename; |
613 | 613 | ||
614 | QFile f(destFile); | 614 | QFile f(destFile); |
615 | if( f.exists()) { | 615 | if( f.exists()) { |
616 | switch (QMessageBox::warning(this,tr("Delete"), | 616 | switch (QMessageBox::warning(this,tr("Delete"), |
617 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 617 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
618 | tr("Yes"),tr("No"),0,0,1) ) { | 618 | tr("Yes"),tr("No"),0,0,1) ) { |
619 | case 0: | 619 | case 0: |
620 | 620 | ||
621 | f.remove(); | 621 | f.remove(); |
622 | break; | 622 | break; |
623 | case 1: | 623 | case 1: |
624 | return; | 624 | return; |
625 | break; | 625 | break; |
626 | }; | 626 | }; |
627 | } | 627 | } |
628 | if(!copyFile( curFile,destFile) ) { | 628 | if(!copyFile( curFile,destFile) ) { |
629 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 629 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
630 | +curFile +tr("to\n")+destFile); | 630 | +curFile +tr("to\n")+destFile); |
631 | return; | 631 | return; |
632 | } | 632 | } |
633 | 633 | ||
634 | qDebug("copy "+curFile+" as "+destFile); | 634 | qDebug("copy "+curFile+" as "+destFile); |
635 | } | 635 | } |
636 | delete fileDlg; | 636 | delete fileDlg; |
637 | } | 637 | } |
638 | populateLocalView(); | 638 | populateLocalView(); |
639 | 639 | ||
640 | } else { | 640 | } else { |
641 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 641 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
642 | item=(*it); | 642 | item=(*it); |
643 | curFile = currentRemoteDir.canonicalPath()+"/"+ item; | 643 | curFile = currentRemoteDir.canonicalPath()+"/"+ item; |
644 | 644 | ||
645 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 645 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
646 | fileDlg->setInputText((const QString &) destFile); | 646 | fileDlg->setInputText((const QString &) destFile); |
647 | fileDlg->exec(); | 647 | fileDlg->exec(); |
648 | if( fileDlg->result() == 1 ) { | 648 | if( fileDlg->result() == 1 ) { |
649 | QString filename = fileDlg->LineEdit1->text(); | 649 | QString filename = fileDlg->LineEdit1->text(); |
650 | 650 | ||
651 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; | 651 | destFile = currentRemoteDir.canonicalPath()+"/"+filename; |
652 | 652 | ||
653 | QFile f(destFile); | 653 | QFile f(destFile); |
654 | if( f.exists()) { | 654 | if( f.exists()) { |
655 | switch ( QMessageBox::warning(this,tr("Delete"), | 655 | switch ( QMessageBox::warning(this,tr("Delete"), |
656 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 656 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
657 | tr("Yes"),tr("No"),0,0,1) ) { | 657 | tr("Yes"),tr("No"),0,0,1) ) { |
658 | case 0: | 658 | case 0: |
659 | f.remove(); | 659 | f.remove(); |
660 | break; | 660 | break; |
661 | case 1: | 661 | case 1: |
662 | return; | 662 | return; |
663 | break; | 663 | break; |
664 | }; | 664 | }; |
665 | } | 665 | } |
666 | if(!copyFile( curFile,destFile) ) { | 666 | if(!copyFile( curFile,destFile) ) { |
667 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 667 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
668 | +curFile +tr("to\n")+destFile); | 668 | +curFile +tr("to\n")+destFile); |
669 | return; | 669 | return; |
670 | } | 670 | } |
671 | qDebug("copy "+curFile+" as "+destFile); | 671 | qDebug("copy "+curFile+" as "+destFile); |
672 | } | 672 | } |
673 | delete fileDlg; | 673 | delete fileDlg; |
674 | } | 674 | } |
675 | populateRemoteView(); | 675 | populateRemoteView(); |
676 | } | 676 | } |
677 | } | 677 | } |
678 | 678 | ||
679 | void AdvancedFm::move() { | 679 | void AdvancedFm::move() { |
680 | qApp->processEvents(); | 680 | qApp->processEvents(); |
681 | 681 | ||
682 | QStringList curFileList = getPath(); | 682 | QStringList curFileList = getPath(); |
683 | if( curFileList.count() > 0) { | 683 | if( curFileList.count() > 0) { |
684 | QString curFile, destFile, item; | 684 | QString curFile, destFile, item; |
685 | 685 | ||
686 | if (TabWidget->getCurrentTab() == 0) { | 686 | if (TabWidget->getCurrentTab() == 0) { |
687 | 687 | ||
688 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 688 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
689 | item=(*it); | 689 | item=(*it); |
690 | QString destFile = currentRemoteDir.canonicalPath(); | 690 | QString destFile = currentRemoteDir.canonicalPath(); |
691 | 691 | ||
692 | if(destFile.right(1).find("/",0,TRUE) == -1) | 692 | if(destFile.right(1).find("/",0,TRUE) == -1) |
693 | destFile+="/"; | 693 | destFile+="/"; |
694 | destFile += item; | 694 | destFile += item; |
695 | curFile = currentDir.canonicalPath(); | 695 | curFile = currentDir.canonicalPath(); |
696 | 696 | ||
697 | qDebug("Destination file is "+destFile); | 697 | qDebug("Destination file is "+destFile); |
698 | 698 | ||
699 | if(curFile.right(1).find("/",0,TRUE) == -1) | 699 | if(curFile.right(1).find("/",0,TRUE) == -1) |
700 | curFile +="/"; | 700 | curFile +="/"; |
701 | 701 | ||
702 | curFile+= item; | 702 | curFile+= item; |
703 | qDebug("CurrentFile file is " + curFile); | 703 | qDebug("CurrentFile file is " + curFile); |
704 | 704 | ||
705 | QFile f( curFile); | 705 | QFile f( curFile); |
706 | if( f.exists()) { | 706 | if( f.exists()) { |
707 | if(!copyFile( curFile,destFile) ) { | 707 | if(!copyFile( curFile,destFile) ) { |
708 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 708 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
709 | return; | 709 | return; |
710 | } else | 710 | } else |
711 | QFile::remove(curFile); | 711 | QFile::remove(curFile); |
712 | } | 712 | } |
713 | } | 713 | } |
714 | 714 | ||
715 | TabWidget->setCurrentTab(1); | 715 | TabWidget->setCurrentTab(1); |
716 | 716 | ||
717 | } else { //view 2 | 717 | } else { //view 2 |
718 | 718 | ||
719 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 719 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
720 | item = (*it); | 720 | item = (*it); |
721 | QString destFile = currentDir.canonicalPath(); | 721 | QString destFile = currentDir.canonicalPath(); |
722 | 722 | ||
723 | if(destFile.right(1).find("/",0,TRUE) == -1) | 723 | if(destFile.right(1).find("/",0,TRUE) == -1) |
724 | destFile+="/"; | 724 | destFile+="/"; |
725 | 725 | ||
726 | destFile += item; | 726 | destFile += item; |
727 | 727 | ||
728 | qDebug("Destination file is "+destFile); | 728 | qDebug("Destination file is "+destFile); |
729 | 729 | ||
730 | curFile = currentRemoteDir.canonicalPath(); | 730 | curFile = currentRemoteDir.canonicalPath(); |
731 | 731 | ||
732 | if(curFile.right(1).find("/",0,TRUE) == -1) | 732 | if(curFile.right(1).find("/",0,TRUE) == -1) |
733 | curFile +="/"; | 733 | curFile +="/"; |
734 | curFile+= item; | 734 | curFile+= item; |
735 | qDebug("CurrentFile file is " + curFile); | 735 | qDebug("CurrentFile file is " + curFile); |
736 | 736 | ||
737 | QFile f( curFile); | 737 | QFile f( curFile); |
738 | if( f.exists()) { | 738 | if( f.exists()) { |
739 | if(!copyFile( curFile, destFile) ) { | 739 | if(!copyFile( curFile, destFile) ) { |
740 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); | 740 | QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile); |
741 | return; | 741 | return; |
742 | } else | 742 | } else |
743 | QFile::remove( curFile); | 743 | QFile::remove( curFile); |
744 | } | 744 | } |
745 | TabWidget->setCurrentTab(0); | 745 | TabWidget->setCurrentTab(0); |
746 | } | 746 | } |
747 | } | 747 | } |
748 | populateRemoteView(); | 748 | populateRemoteView(); |
749 | populateLocalView(); | 749 | populateLocalView(); |
750 | } | 750 | } |
751 | } | 751 | } |
752 | 752 | ||
753 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 753 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
754 | char bf[ 50000 ]; | 754 | char bf[ 50000 ]; |
755 | int bytesRead; | 755 | int bytesRead; |
756 | bool success = TRUE; | 756 | bool success = TRUE; |
757 | struct stat status; | 757 | struct stat status; |
758 | 758 | ||
759 | QFile s( src ); | 759 | QFile s( src ); |
760 | QFile d( dest ); | 760 | QFile d( dest ); |
761 | 761 | ||
762 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { | 762 | if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) { |
763 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { | 763 | while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) { |
764 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 764 | if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
765 | success = FALSE; | 765 | success = FALSE; |
766 | break; | 766 | break; |
767 | } | 767 | } |
768 | } | 768 | } |
769 | if( success && (bytesRead > 0) ){ | 769 | if( success && (bytesRead > 0) ){ |
770 | d.writeBlock( bf, bytesRead ); | 770 | d.writeBlock( bf, bytesRead ); |
771 | } | 771 | } |
772 | } else { | 772 | } else { |
773 | success = FALSE; | 773 | success = FALSE; |
774 | } | 774 | } |
775 | 775 | ||
776 | // Set file permissions | 776 | // Set file permissions |
777 | if( stat( (const char *) src, &status ) == 0 ){ | 777 | if( stat( (const char *) src, &status ) == 0 ){ |
778 | chmod( (const char *) dest, status.st_mode ); | 778 | chmod( (const char *) dest, status.st_mode ); |
779 | } | 779 | } |
780 | 780 | ||
781 | return success; | 781 | return success; |
782 | } | 782 | } |
783 | 783 | ||
784 | void AdvancedFm::runCommand() { | 784 | void AdvancedFm::runCommand() { |
785 | QString curFile; | 785 | QString curFile; |
786 | if (TabWidget->getCurrentTab() == 0) { | 786 | if (TabWidget->getCurrentTab() == 0) { |
787 | if( Local_View->currentItem()) | 787 | if( Local_View->currentItem()) |
788 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 788 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
789 | } else { | 789 | } else { |
790 | if(Remote_View->currentItem()) | 790 | if(Remote_View->currentItem()) |
791 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); | 791 | curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0); |
792 | } | 792 | } |
793 | 793 | ||
794 | InputDialog *fileDlg; | 794 | InputDialog *fileDlg; |
795 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 795 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
796 | fileDlg->setInputText(curFile); | 796 | fileDlg->setInputText(curFile); |
797 | fileDlg->exec(); | 797 | fileDlg->exec(); |
798 | //QString command; | 798 | //QString command; |
799 | 799 | ||
800 | if( fileDlg->result() == 1 ) { | 800 | if( fileDlg->result() == 1 ) { |
801 | qDebug(fileDlg->LineEdit1->text()); | 801 | qDebug(fileDlg->LineEdit1->text()); |
802 | QStringList command; | 802 | QStringList command; |
803 | 803 | ||
804 | command << "/bin/sh"; | 804 | command << "/bin/sh"; |
805 | command << "-c"; | 805 | command << "-c"; |
806 | command << fileDlg->LineEdit1->text(); | 806 | command << fileDlg->LineEdit1->text(); |
807 | Output *outDlg; | 807 | Output *outDlg; |
808 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 808 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
809 | outDlg->showMaximized(); | 809 | outDlg->showMaximized(); |
810 | outDlg->exec(); | 810 | outDlg->exec(); |
811 | qApp->processEvents(); | 811 | qApp->processEvents(); |
812 | 812 | ||
813 | } | 813 | } |
814 | } | 814 | } |
815 | 815 | ||
816 | void AdvancedFm::runCommandStd() { | 816 | void AdvancedFm::runCommandStd() { |
817 | QString curFile; | 817 | QString curFile; |
818 | if (TabWidget->getCurrentTab() == 0) { | 818 | if (TabWidget->getCurrentTab() == 0) { |
819 | if( Local_View->currentItem()) | 819 | if( Local_View->currentItem()) |
820 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); | 820 | curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0); |
821 | } else { | 821 | } else { |
822 | if(Remote_View->currentItem()) | 822 | if(Remote_View->currentItem()) |
823 | curFile = currentRemoteDir.canonicalPath() +"/" | 823 | curFile = currentRemoteDir.canonicalPath() +"/" |
824 | + Remote_View->currentItem()->text(0); | 824 | + Remote_View->currentItem()->text(0); |
825 | } | 825 | } |
826 | 826 | ||
827 | InputDialog *fileDlg; | 827 | InputDialog *fileDlg; |
828 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 828 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
829 | fileDlg->setInputText(curFile); | 829 | fileDlg->setInputText(curFile); |
830 | fileDlg->exec(); | 830 | fileDlg->exec(); |
831 | 831 | ||
832 | if( fileDlg->result() == 1 ) { | 832 | if( fileDlg->result() == 1 ) { |
833 | qApp->processEvents(); | 833 | qApp->processEvents(); |
834 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 834 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
835 | } | 835 | } |
836 | } | 836 | } |
837 | 837 | ||
838 | void AdvancedFm::fileStatus() { | 838 | void AdvancedFm::fileStatus() { |
839 | QString curFile; | 839 | QString curFile; |
840 | if (TabWidget->getCurrentTab() == 0) { | 840 | if (TabWidget->getCurrentTab() == 0) { |
841 | curFile = Local_View->currentItem()->text(0); | 841 | curFile = Local_View->currentItem()->text(0); |
842 | } else { | 842 | } else { |
843 | curFile = Remote_View->currentItem()->text(0); | 843 | curFile = Remote_View->currentItem()->text(0); |
844 | } | 844 | } |
845 | 845 | ||
846 | QStringList command; | 846 | QStringList command; |
847 | command << "/bin/sh"; | 847 | command << "/bin/sh"; |
848 | command << "-c"; | 848 | command << "-c"; |
849 | command << "stat -l "+ curFile; | 849 | command << "stat -l "+ curFile; |
850 | 850 | ||
851 | Output *outDlg; | 851 | Output *outDlg; |
852 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 852 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
853 | outDlg->showMaximized(); | 853 | outDlg->showMaximized(); |
854 | outDlg->exec(); | 854 | outDlg->exec(); |
855 | qApp->processEvents(); | 855 | qApp->processEvents(); |
856 | 856 | ||
857 | 857 | ||
858 | // Output *outDlg; | 858 | // Output *outDlg; |
859 | // outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 859 | // outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
860 | // outDlg->showMaximized(); | 860 | // outDlg->showMaximized(); |
861 | // outDlg->show(); | 861 | // outDlg->show(); |
862 | // qApp->processEvents(); | 862 | // qApp->processEvents(); |
863 | 863 | ||
864 | // FILE *fp; | 864 | // FILE *fp; |
865 | // char line[130]; | 865 | // char line[130]; |
866 | // sleep(1); | 866 | // sleep(1); |
867 | // fp = popen( (const char *) command, "r"); | 867 | // fp = popen( (const char *) command, "r"); |
868 | // if ( !fp ) { | 868 | // if ( !fp ) { |
869 | // qDebug("Could not execute '" + command + "'! err=%d", fp); | 869 | // qDebug("Could not execute '" + command + "'! err=%d", fp); |
870 | // QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | 870 | // QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); |
871 | // pclose(fp); | 871 | // pclose(fp); |
872 | // return; | 872 | // return; |
873 | // } else { | 873 | // } else { |
874 | // while ( fgets( line, sizeof line, fp)) { | 874 | // while ( fgets( line, sizeof line, fp)) { |
875 | // outDlg->OutputEdit->append(line); | 875 | // outDlg->OutputEdit->append(line); |
876 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | 876 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); |
877 | 877 | ||
878 | // } | 878 | // } |
879 | 879 | ||
880 | // } | 880 | // } |
881 | // pclose(fp); | 881 | // pclose(fp); |
882 | } | 882 | } |
883 | 883 | ||
884 | 884 | ||
885 | void AdvancedFm::mkDir() { | 885 | void AdvancedFm::mkDir() { |
886 | if (TabWidget->getCurrentTab() == 0) | 886 | if (TabWidget->getCurrentTab() == 0) |
887 | localMakDir(); | 887 | localMakDir(); |
888 | else | 888 | else |
889 | remoteMakDir(); | 889 | remoteMakDir(); |
890 | 890 | ||
891 | } | 891 | } |
892 | 892 | ||
893 | void AdvancedFm::rn() { | 893 | void AdvancedFm::rn() { |
894 | if (TabWidget->getCurrentTab() == 0) | 894 | if (TabWidget->getCurrentTab() == 0) |
895 | localRename(); | 895 | localRename(); |
896 | else | 896 | else |
897 | remoteRename(); | 897 | remoteRename(); |
898 | 898 | ||
899 | } | 899 | } |
900 | 900 | ||
901 | void AdvancedFm::del() { | 901 | void AdvancedFm::del() { |
902 | if (TabWidget->getCurrentTab() == 0) | 902 | if (TabWidget->getCurrentTab() == 0) |
903 | localDelete(); | 903 | localDelete(); |
904 | else | 904 | else |
905 | remoteDelete(); | 905 | remoteDelete(); |
906 | } | 906 | } |
907 | 907 | ||
908 | void AdvancedFm::mkSym() { | 908 | void AdvancedFm::mkSym() { |
909 | QString cmd; | 909 | QString cmd; |
910 | QStringList curFileList = getPath(); | 910 | QStringList curFileList = getPath(); |
911 | if( curFileList.count() > 0) { | 911 | if( curFileList.count() > 0) { |
912 | 912 | ||
913 | if (TabWidget->getCurrentTab() == 0) { | 913 | if (TabWidget->getCurrentTab() == 0) { |
914 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 914 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
915 | 915 | ||
916 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); | 916 | QString destName = currentRemoteDir.canonicalPath()+"/"+(*it); |
917 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 917 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
918 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 918 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
919 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 919 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
920 | cmd = "ln -s "+curFile+" "+destName; | 920 | cmd = "ln -s "+curFile+" "+destName; |
921 | qDebug(cmd); | 921 | qDebug(cmd); |
922 | startProcess( (const QString)cmd ); | 922 | startProcess( (const QString)cmd ); |
923 | } | 923 | } |
924 | populateRemoteView(); | 924 | populateRemoteView(); |
925 | TabWidget->setCurrentTab(1); | 925 | TabWidget->setCurrentTab(1); |
926 | } else { | 926 | } else { |
927 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 927 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
928 | 928 | ||
929 | QString destName = currentDir.canonicalPath()+"/"+(*it); | 929 | QString destName = currentDir.canonicalPath()+"/"+(*it); |
930 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); | 930 | if(destName.right(1) == "/") destName = destName.left( destName.length() -1); |
931 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 931 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
932 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 932 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
933 | 933 | ||
934 | cmd = "ln -s "+curFile+" "+destName; | 934 | cmd = "ln -s "+curFile+" "+destName; |
935 | qDebug(cmd); | 935 | qDebug(cmd); |
936 | startProcess( (const QString)cmd ); | 936 | startProcess( (const QString)cmd ); |
937 | } | 937 | } |
938 | populateLocalView(); | 938 | populateLocalView(); |
939 | TabWidget->setCurrentTab(0); | 939 | TabWidget->setCurrentTab(0); |
940 | } | 940 | } |
941 | } | 941 | } |
942 | } | 942 | } |
943 | 943 | ||
944 | void AdvancedFm::doBeam() { | 944 | void AdvancedFm::doBeam() { |
945 | Ir ir; | 945 | Ir ir; |
946 | if(!ir.supported()){ | 946 | if(!ir.supported()){ |
947 | } else { | 947 | } else { |
948 | 948 | ||
949 | QStringList curFileList = getPath(); | 949 | QStringList curFileList = getPath(); |
950 | if( curFileList.count() > 0) { | 950 | if( curFileList.count() > 0) { |
951 | 951 | ||
952 | if (TabWidget->getCurrentTab() == 0) { | 952 | if (TabWidget->getCurrentTab() == 0) { |
953 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 953 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
954 | 954 | ||
955 | QString curFile = currentDir.canonicalPath()+"/"+(*it); | 955 | QString curFile = currentDir.canonicalPath()+"/"+(*it); |
956 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 956 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
957 | Ir *file = new Ir(this, "IR"); | 957 | Ir *file = new Ir(this, "IR"); |
958 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 958 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
959 | file->send( curFile, curFile ); | 959 | file->send( curFile, curFile ); |
960 | } | 960 | } |
961 | 961 | ||
962 | } else { | 962 | } else { |
963 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 963 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
964 | 964 | ||
965 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); | 965 | QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it); |
966 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 966 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
967 | Ir *file = new Ir(this, "IR"); | 967 | Ir *file = new Ir(this, "IR"); |
968 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 968 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
969 | file->send( curFile, curFile ); | 969 | file->send( curFile, curFile ); |
970 | 970 | ||
971 | } | 971 | } |
972 | } | 972 | } |
973 | } | 973 | } |
974 | } | 974 | } |
975 | 975 | ||
976 | } | 976 | } |
977 | 977 | ||
978 | void AdvancedFm::fileBeamFinished( Ir *) { | 978 | void AdvancedFm::fileBeamFinished( Ir *) { |
979 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 979 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
980 | 980 | ||
981 | } | 981 | } |
982 | 982 | ||
983 | void AdvancedFm::selectAll() { | 983 | void AdvancedFm::selectAll() { |
984 | if (TabWidget->getCurrentTab() == 0) { | 984 | if (TabWidget->getCurrentTab() == 0) { |
985 | Local_View->selectAll(true); | 985 | Local_View->selectAll(true); |
986 | Local_View->setSelected( Local_View->firstChild(),false); | 986 | Local_View->setSelected( Local_View->firstChild(),false); |
987 | } else { | 987 | } else { |
988 | Remote_View->selectAll(true); | 988 | Remote_View->selectAll(true); |
989 | Remote_View->setSelected( Remote_View->firstChild(),false); | 989 | Remote_View->setSelected( Remote_View->firstChild(),false); |
990 | } | 990 | } |
991 | } | 991 | } |
992 | 992 | ||
993 | void AdvancedFm::startProcess(const QString & cmd) { | 993 | void AdvancedFm::startProcess(const QString & cmd) { |
994 | QStringList command; | 994 | QStringList command; |
995 | OProcess *process; | 995 | OProcess *process; |
996 | process = new OProcess(); | 996 | process = new OProcess(); |
997 | connect(process, SIGNAL(processExited(OProcess *)), | 997 | connect(process, SIGNAL(processExited(OProcess *)), |
998 | this, SLOT( processEnded())); | 998 | this, SLOT( processEnded())); |
999 | 999 | ||
1000 | command << "/bin/sh"; | 1000 | command << "/bin/sh"; |
1001 | command << "-c"; | 1001 | command << "-c"; |
1002 | command << cmd.latin1(); | 1002 | command << cmd.latin1(); |
1003 | *process << command; | 1003 | *process << command; |
1004 | if(!process->start(OProcess::NotifyOnExit) ) | 1004 | if(!process->start(OProcess::NotifyOnExit) ) |
1005 | qDebug("could not start process"); | 1005 | qDebug("could not start process"); |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | void AdvancedFm::processEnded() { | 1008 | void AdvancedFm::processEnded() { |
1009 | populateLocalView(); | 1009 | populateLocalView(); |
1010 | populateRemoteView(); | 1010 | populateRemoteView(); |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { | 1013 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { |
1014 | if ( o->inherits( "QLineEdit" ) ) { | 1014 | if ( o->inherits( "QLineEdit" ) ) { |
1015 | if ( e->type() == QEvent::KeyPress ) { | 1015 | if ( e->type() == QEvent::KeyPress ) { |
1016 | QKeyEvent *ke = (QKeyEvent*)e; | 1016 | QKeyEvent *ke = (QKeyEvent*)e; |
1017 | if ( ke->key() == Key_Return || | 1017 | if ( ke->key() == Key_Return || |
1018 | ke->key() == Key_Enter ) { | 1018 | ke->key() == Key_Enter ) { |
1019 | okRename(); | 1019 | okRename(); |
1020 | return true; | 1020 | return true; |
1021 | } else if ( ke->key() == Key_Escape ) { | 1021 | } else if ( ke->key() == Key_Escape ) { |
1022 | cancelRename(); | 1022 | cancelRename(); |
1023 | return true; | 1023 | return true; |
1024 | } | 1024 | } |
1025 | } else if ( e->type() == QEvent::FocusOut ) { | 1025 | } else if ( e->type() == QEvent::FocusOut ) { |
1026 | cancelRename(); | 1026 | cancelRename(); |
1027 | return true; | 1027 | return true; |
1028 | } | 1028 | } |
1029 | } | 1029 | } |
1030 | if ( o->inherits( "QListView" ) ) { | ||
1031 | if ( e->type() == QEvent::FocusOut ) { | ||
1032 | printf("focusIn\n"); | ||
1033 | |||
1034 | } | ||
1035 | } | ||
1036 | |||
1030 | return QWidget::eventFilter( o, e ); | 1037 | return QWidget::eventFilter( o, e ); |
1031 | } | 1038 | } |
1032 | 1039 | ||
1033 | 1040 | ||
1034 | void AdvancedFm::cancelRename() { | 1041 | void AdvancedFm::cancelRename() |
1042 | { | ||
1035 | qDebug("cancel rename"); | 1043 | qDebug("cancel rename"); |
1036 | QListView * view; | 1044 | QListView * view; |
1037 | if (TabWidget->getCurrentTab() == 0) { | 1045 | if (TabWidget->getCurrentTab() == 0) |
1038 | view = Local_View; | 1046 | { |
1039 | } | 1047 | view = Local_View; |
1048 | } | ||
1040 | else | 1049 | else |
1041 | { | 1050 | { |
1042 | view = Remote_View; | 1051 | view = Remote_View; |
1043 | } | 1052 | } |
1044 | 1053 | ||
1045 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 1054 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
1046 | delete renameBox; | 1055 | delete renameBox; |
1047 | renameBox = 0; | 1056 | renameBox = 0; |
1048 | if ( resetFocus ) { | 1057 | if ( resetFocus ) { |
1049 | view->viewport()->setFocusProxy( view); | 1058 | view->viewport()->setFocusProxy( view); |
1050 | view->setFocus(); | 1059 | view->setFocus(); |
1051 | } | 1060 | } |
1052 | } | 1061 | } |
1053 | 1062 | ||
1054 | void AdvancedFm::doRename(QListView * view) { | 1063 | void AdvancedFm::doRename(QListView * view) |
1064 | { | ||
1055 | 1065 | ||
1056 | QRect r = view->itemRect( view->currentItem( )); | 1066 | QRect r = view->itemRect( view->currentItem( )); |
1057 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 1067 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
1058 | r.setX( view->contentsX() ); | 1068 | r.setX( view->contentsX() ); |
1059 | if ( r.width() > view->visibleWidth() ) | 1069 | if ( r.width() > view->visibleWidth() ) |
1060 | r.setWidth( view->visibleWidth() ); | 1070 | r.setWidth( view->visibleWidth() ); |
1061 | 1071 | ||
1062 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 1072 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
1063 | renameBox->setFrame(true); | 1073 | renameBox->setFrame(true); |
1064 | 1074 | ||
1065 | renameBox->setText( view->currentItem()->text(0) ); | 1075 | renameBox->setText( view->currentItem()->text(0) ); |
1066 | 1076 | ||
1067 | renameBox->selectAll(); | 1077 | renameBox->selectAll(); |
1068 | renameBox->installEventFilter( this ); | 1078 | renameBox->installEventFilter( this ); |
1069 | view->addChild( renameBox, r.x(), r.y() ); | 1079 | view->addChild( renameBox, r.x(), r.y() ); |
1070 | renameBox->resize( r.size() ); | 1080 | renameBox->resize( r.size() ); |
1071 | view->viewport()->setFocusProxy( renameBox ); | 1081 | view->viewport()->setFocusProxy( renameBox ); |
1072 | renameBox->setFocus(); | 1082 | renameBox->setFocus(); |
1073 | renameBox->show(); | 1083 | renameBox->show(); |
1074 | 1084 | ||
1075 | } | 1085 | } |
1076 | 1086 | ||
1077 | 1087 | ||
1078 | void AdvancedFm::localRename() { | 1088 | void AdvancedFm::localRename() |
1089 | { | ||
1079 | oldName = Local_View->currentItem()->text(0); | 1090 | oldName = Local_View->currentItem()->text(0); |
1080 | doRename(Local_View ); | 1091 | doRename(Local_View ); |
1081 | populateLocalView(); | 1092 | populateLocalView(); |
1082 | } | 1093 | } |
1083 | 1094 | ||
1084 | void AdvancedFm::remoteRename() | 1095 | void AdvancedFm::remoteRename() |
1085 | { | 1096 | { |
1086 | oldName = Remote_View->currentItem()->text(0); | 1097 | oldName = Remote_View->currentItem()->text(0); |
1087 | doRename(Local_View ); | 1098 | doRename(Local_View ); |
1088 | populateRemoteView(); | 1099 | populateRemoteView(); |
1089 | } | 1100 | } |
1090 | 1101 | ||
1091 | void AdvancedFm::okRename() { | 1102 | void AdvancedFm::okRename() |
1103 | { | ||
1092 | QString newName = renameBox->text(); | 1104 | QString newName = renameBox->text(); |
1093 | cancelRename(); | 1105 | cancelRename(); |
1094 | int tabs=0; | 1106 | int tabs=0; |
1095 | QListView * view; | 1107 | QListView * view; |
1096 | tabs = TabWidget->getCurrentTab(); | 1108 | tabs = TabWidget->getCurrentTab(); |
1097 | if ( tabs == 0) | 1109 | if ( tabs == 0) |
1098 | { | 1110 | { |
1099 | view = Local_View; | 1111 | view = Local_View; |
1100 | QString path = currentDir.canonicalPath() + "/"; | 1112 | QString path = currentDir.canonicalPath() + "/"; |
1101 | oldName = path + oldName; | 1113 | oldName = path + oldName; |
1102 | newName = path + newName; | 1114 | newName = path + newName; |
1103 | } | 1115 | } |
1104 | else | 1116 | else |
1105 | { | 1117 | { |
1106 | view = Remote_View; | 1118 | view = Remote_View; |
1107 | QString path = currentRemoteDir.canonicalPath() + "/"; | 1119 | QString path = currentRemoteDir.canonicalPath() + "/"; |
1108 | oldName = path + oldName; | 1120 | oldName = path + oldName; |
1109 | newName = path + newName; | 1121 | newName = path + newName; |
1110 | } | 1122 | } |
1111 | 1123 | ||
1112 | if( view->currentItem() == NULL) | 1124 | if( view->currentItem() == NULL) |
1113 | return; | 1125 | return; |
1114 | if( rename(oldName.latin1(), newName.latin1())== -1) | 1126 | if( rename(oldName.latin1(), newName.latin1())== -1) |
1115 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 1127 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
1116 | else | 1128 | else |
1117 | oldName = ""; | 1129 | oldName = ""; |
1118 | 1130 | ||
1119 | view->takeItem( view->currentItem() ); | 1131 | view->takeItem( view->currentItem() ); |
1120 | delete view->currentItem(); | 1132 | delete view->currentItem(); |
1121 | if ( tabs == 0) | 1133 | if ( tabs == 0) |
1122 | populateLocalView(); | 1134 | populateLocalView(); |
1123 | else | 1135 | else |
1124 | populateRemoteView(); | 1136 | populateRemoteView(); |
1125 | } | 1137 | } |