-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 1179 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 7 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmData.cpp | 38 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 591 | ||||
-rw-r--r-- | noncore/apps/advancedfm/filePermissions.cpp | 2 |
5 files changed, 858 insertions, 959 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 91318f1..2fc4b49 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1,920 +1,891 @@ | |||
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 | 15 | ||
16 | // #include <opie/ofileselector.h> | 16 | // #include <opie/ofileselector.h> |
17 | // #include <opie/ofiledialog.h> | 17 | // #include <opie/ofiledialog.h> |
18 | 18 | ||
19 | #include <opie/osplitter.h> | 19 | #include <opie/osplitter.h> |
20 | 20 | ||
21 | #include <qpe/filemanager.h> | 21 | #include <qpe/filemanager.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
25 | #include <qpe/mimetype.h> | 25 | #include <qpe/mimetype.h> |
26 | #include <qpe/applnk.h> | 26 | #include <qpe/applnk.h> |
27 | #include <qpe/ir.h> | 27 | #include <qpe/ir.h> |
28 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
29 | #include <qpe/menubutton.h> | 29 | #include <qpe/menubutton.h> |
30 | 30 | ||
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qlistview.h> | 35 | #include <qlistview.h> |
36 | #include <qlabel.h> | 36 | #include <qlabel.h> |
37 | #include <qwidget.h> | 37 | #include <qwidget.h> |
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | #include <qimage.h> | 39 | #include <qimage.h> |
40 | #include <qmessagebox.h> | 40 | #include <qmessagebox.h> |
41 | #include <qlineedit.h> | 41 | #include <qlineedit.h> |
42 | 42 | ||
43 | #include <qpe/qpemessagebox.h> | ||
44 | |||
43 | #include <sys/stat.h> | 45 | #include <sys/stat.h> |
44 | #include <time.h> | 46 | #include <time.h> |
45 | #include <dirent.h> | 47 | #include <dirent.h> |
46 | #include <fcntl.h> | 48 | #include <fcntl.h> |
47 | #include <sys/vfs.h> | 49 | #include <sys/vfs.h> |
48 | #include <mntent.h> | 50 | #include <mntent.h> |
49 | 51 | ||
50 | AdvancedFm::AdvancedFm( ) | 52 | AdvancedFm::AdvancedFm( ) |
51 | : QMainWindow( ) { | 53 | : QMainWindow( ) { |
52 | init(); | 54 | init(); |
53 | renameBox = 0; | 55 | renameBox = 0; |
54 | 56 | ||
55 | unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 57 | unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
56 | 58 | ||
57 | initConnections(); | 59 | initConnections(); |
58 | whichTab=1; | 60 | whichTab=1; |
59 | rePopulate(); | 61 | rePopulate(); |
60 | currentPathCombo->setFocus(); | 62 | currentPathCombo->setFocus(); |
61 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); | 63 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); |
62 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 64 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
63 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); | 65 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); |
64 | } | 66 | } |
65 | 67 | ||
66 | AdvancedFm::~AdvancedFm() { | 68 | AdvancedFm::~AdvancedFm() { |
67 | } | 69 | } |
68 | 70 | ||
69 | 71 | ||
70 | void AdvancedFm::cleanUp() | 72 | void AdvancedFm::cleanUp() { |
71 | { | 73 | QString sfile=QDir::homeDirPath(); |
72 | QString sfile=QDir::homeDirPath(); | 74 | if(sfile.right(1) != "/") |
73 | if(sfile.right(1) != "/") | 75 | sfile+="/._temp"; |
74 | sfile+="/._temp"; | 76 | else |
75 | else | 77 | sfile+="._temp"; |
76 | sfile+="._temp"; | 78 | QFile file( sfile); |
77 | QFile file( sfile); | 79 | if(file.exists()) |
78 | if(file.exists()) | 80 | file.remove(); |
79 | file.remove(); | ||
80 | } | 81 | } |
81 | 82 | ||
82 | void AdvancedFm::tabChanged(QWidget *w) | 83 | void AdvancedFm::tabChanged(QWidget *) { |
83 | { | 84 | // qWarning("tab changed"); |
84 | if( w == tab) | 85 | QString path = CurrentDir()->canonicalPath(); |
85 | whichTab = 1; | 86 | currentPathCombo->lineEdit()->setText( path ); |
86 | else | 87 | |
87 | whichTab = 2; | 88 | if(whichTab == 1) { |
89 | viewMenu->setItemChecked(viewMenu->idAt(0), true); | ||
90 | viewMenu->setItemChecked(viewMenu->idAt(1), false); | ||
91 | } else { | ||
92 | viewMenu->setItemChecked(viewMenu->idAt(0), false); | ||
93 | viewMenu->setItemChecked(viewMenu->idAt(1), true); | ||
94 | } | ||
88 | 95 | ||
89 | // qDebug("tab changed %d", whichTab ); | 96 | QString fs= getFileSystemType( (const QString &) path); |
90 | 97 | ||
91 | QString path = CurrentDir()->canonicalPath(); | 98 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
92 | currentPathCombo->lineEdit()->setText( path ); | 99 | +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); |
93 | 100 | chdir( path.latin1()); | |
94 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); | 101 | } |
95 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); | 102 | |
96 | 103 | ||
97 | QString fs= getFileSystemType( (const QString &) path); | 104 | void AdvancedFm::populateView() { |
98 | 105 | QPixmap pm; | |
99 | setCaption("AdvancedFm :: "+fs+" :: " | 106 | QListView *thisView = CurrentView(); |
100 | +checkDiskSpace( (const QString &) path )+ " kB free" ); | 107 | QDir *thisDir = CurrentDir(); |
101 | chdir( path.latin1()); | 108 | QString path = thisDir->canonicalPath(); |
102 | } | 109 | // qWarning("path is "+path); |
103 | 110 | thisView->clear(); | |
104 | 111 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | |
105 | void AdvancedFm::populateView() | 112 | thisDir->setMatchAllDirs(TRUE); |
106 | { | 113 | thisDir->setNameFilter(filterStr); |
107 | QPixmap pm; | 114 | QString fileL, fileS, fileDate; |
108 | QListView *thisView = CurrentView(); | 115 | QString fs= getFileSystemType((const QString &) path); |
109 | QDir *thisDir = CurrentDir(); | 116 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
110 | QString path = thisDir->canonicalPath(); | 117 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); |
111 | 118 | bool isDir=FALSE; | |
112 | thisView->clear(); | 119 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
113 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 120 | QFileInfoListIterator it(*list); |
114 | thisDir->setMatchAllDirs(TRUE); | 121 | QFileInfo *fi; |
115 | thisDir->setNameFilter(filterStr); | 122 | while ( (fi=it.current()) ) { |
116 | QString fileL, fileS, fileDate; | ||
117 | QString fs= getFileSystemType((const QString &) path); | ||
118 | setCaption("AdvancedFm :: "+fs+" :: " | ||
119 | +checkDiskSpace((const QString &) path)+" kB free" ); | ||
120 | bool isDir=FALSE; | ||
121 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | ||
122 | QFileInfoListIterator it(*list); | ||
123 | QFileInfo *fi; | ||
124 | while ( (fi=it.current()) ) { | ||
125 | if (fi->isSymLink() ) { | 123 | if (fi->isSymLink() ) { |
126 | QString symLink=fi->readLink(); | 124 | QString symLink=fi->readLink(); |
127 | QFileInfo sym( symLink); | 125 | QFileInfo sym( symLink); |
128 | fileS.sprintf( "%10i", sym.size() ); | 126 | fileS.sprintf( "%10i", sym.size() ); |
129 | fileL = fi->fileName() +" -> " + sym.filePath().data(); | 127 | fileL = fi->fileName() +" -> " + sym.filePath().data(); |
130 | fileDate = sym.lastModified().toString(); | 128 | fileDate = sym.lastModified().toString(); |
131 | } else { | 129 | } else { |
132 | fileS.sprintf( "%10i", fi->size() ); | 130 | fileS.sprintf( "%10i", fi->size() ); |
133 | fileL = fi->fileName(); | 131 | fileL = fi->fileName(); |
134 | fileDate= fi->lastModified().toString(); | 132 | fileDate= fi->lastModified().toString(); |
135 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { | 133 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { |
136 | fileL+="/"; | 134 | // if(fileL == "..") |
137 | isDir=TRUE; | 135 | fileL += "/"; |
138 | } | 136 | isDir=TRUE; |
139 | } | 137 | } |
138 | } | ||
140 | QFileInfo fileInfo( path + "/" + fileL); | 139 | QFileInfo fileInfo( path + "/" + fileL); |
141 | 140 | ||
142 | if(fileL !="./" && fi->exists()) { | 141 | if(fileL !="./" && fi->exists()) { |
143 | item = new QListViewItem( thisView, fileL, fileS , fileDate); | 142 | item = new QListViewItem( thisView, fileL, fileS , fileDate); |
144 | 143 | ||
145 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 144 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
146 | 145 | ||
147 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 146 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
148 | pm = Resource::loadPixmap( "lockedfolder" ); | 147 | pm = Resource::loadPixmap( "lockedfolder" ); |
149 | else | 148 | else |
150 | pm= Resource::loadPixmap( "folder" ); | 149 | pm= Resource::loadPixmap( "folder" ); |
151 | } | 150 | } |
152 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 151 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
153 | pm = Resource::loadPixmap( "exec"); | 152 | pm = Resource::loadPixmap( "exec"); |
154 | } | 153 | } |
155 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 154 | else if( (fileInfo.permission( QFileInfo::ExeUser) |
156 | | fileInfo.permission( QFileInfo::ExeGroup) | 155 | | fileInfo.permission( QFileInfo::ExeGroup) |
157 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 156 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
158 | pm = Resource::loadPixmap( "exec"); | 157 | pm = Resource::loadPixmap( "exec"); |
159 | } | 158 | } |
160 | else if( !fi->isReadable() ) { | 159 | else if( !fi->isReadable() ) { |
161 | pm = Resource::loadPixmap( "locked" ); | 160 | pm = Resource::loadPixmap( "locked" ); |
162 | } | 161 | } |
163 | else { //everything else goes by mimetype | 162 | else { //everything else goes by mimetype |
164 | MimeType mt(fi->filePath()); | 163 | MimeType mt(fi->filePath()); |
165 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 164 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
166 | if(pm.isNull()) { | 165 | if(pm.isNull()) { |
167 | pm = unknownXpm; | 166 | pm = unknownXpm; |
168 | } | 167 | } |
169 | } | 168 | } |
170 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { | 169 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { |
171 | // qDebug(" overlay link image"); | 170 | // qDebug(" overlay link image"); |
172 | pm= Resource::loadPixmap( "advancedfm/symlink" ); | 171 | pm= Resource::loadPixmap( "advancedfm/symlink" ); |
173 | // pm= Resource::loadPixmap( "folder" ); | 172 | // pm= Resource::loadPixmap( "folder" ); |
174 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 173 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
175 | // QPainter painter( &pm ); | 174 | // QPainter painter( &pm ); |
176 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 175 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
177 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); | 176 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); |
178 | } | 177 | } |
179 | item->setPixmap( 0,pm); | 178 | item->setPixmap( 0,pm); |
180 | 179 | ||
181 | } | 180 | } |
182 | isDir=FALSE; | 181 | isDir=FALSE; |
183 | ++it; | 182 | ++it; |
184 | } | 183 | } |
185 | 184 | ||
186 | if( path.find("dev",0,TRUE) != -1) { | 185 | if( path.find("dev",0,TRUE) != -1) { |
187 | struct stat buf; | 186 | struct stat buf; |
188 | dev_t devT; | 187 | dev_t devT; |
189 | DIR *dir; | 188 | DIR *dir; |
190 | struct dirent *mydirent; | 189 | struct dirent *mydirent; |
191 | 190 | ||
192 | if((dir = opendir( path.latin1())) != NULL) | 191 | if((dir = opendir( path.latin1())) != NULL) |
193 | while ((mydirent = readdir(dir)) != NULL) { | 192 | while ((mydirent = readdir(dir)) != NULL) { |
194 | lstat( mydirent->d_name, &buf); | 193 | lstat( mydirent->d_name, &buf); |
195 | // qDebug(mydirent->d_name); | 194 | // qDebug(mydirent->d_name); |
196 | fileL.sprintf("%s", mydirent->d_name); | 195 | fileL.sprintf("%s", mydirent->d_name); |
197 | devT = buf.st_dev; | 196 | devT = buf.st_dev; |
198 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 197 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
199 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 198 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
200 | if( fileL.find(".") == -1 ) { | 199 | if( fileL.find(".") == -1 ) { |
201 | item= new QListViewItem( thisView, fileL, fileS, fileDate); | 200 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
202 | pm = unknownXpm; | 201 | pm = unknownXpm; |
203 | item->setPixmap( 0,pm); | 202 | item->setPixmap( 0,pm); |
204 | } | 203 | } |
205 | } | 204 | } |
206 | 205 | ||
207 | closedir(dir); | 206 | closedir(dir); |
208 | } | 207 | } |
209 | 208 | ||
210 | thisView->setSorting( 3,FALSE); | 209 | thisView->setSorting( 3,FALSE); |
211 | fillCombo( (const QString &) path ); | 210 | fillCombo( (const QString &) path ); |
212 | } | 211 | } |
213 | 212 | ||
214 | void AdvancedFm::rePopulate() | 213 | void AdvancedFm::rePopulate() { |
215 | { | 214 | populateView(); |
216 | int tmpTab = whichTab; | 215 | setOtherTabCurrent(); |
217 | qDebug("%d", tmpTab); | 216 | populateView(); |
218 | 217 | ||
219 | for(int i =1; i < 3; i++) | 218 | // int tmpTab = whichTab; |
220 | { | 219 | // // qDebug("%d", tmpTab); |
221 | TabWidget->setCurrentWidget(i - 1); | 220 | |
222 | populateView(); | 221 | // for(int i =1; i < 3; i++) { |
223 | } | 222 | // TabWidget->setCurrentWidget(i - 1); |
224 | TabWidget->setCurrentWidget( tmpTab - 1); | 223 | // populateView(); |
224 | // } | ||
225 | // TabWidget->setCurrentWidget( tmpTab - 1); | ||
225 | } | 226 | } |
226 | 227 | ||
227 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) | 228 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { |
228 | { | 229 | //qWarning("listclicked"); |
229 | if(selectedItem) | 230 | if(selectedItem) { |
230 | { | ||
231 | QString strItem=selectedItem->text(0); | 231 | QString strItem=selectedItem->text(0); |
232 | // qWarning(strItem); | ||
232 | QString strSize=selectedItem->text(1); | 233 | QString strSize=selectedItem->text(1); |
233 | strSize=strSize.stripWhiteSpace(); | 234 | strSize=strSize.stripWhiteSpace(); |
234 | bool isDirectory = false; | 235 | bool isDirectory = false; |
235 | QString strItem2; | 236 | QString strItem2; |
236 | 237 | ||
237 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 )//if symlink | 238 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink |
238 | { | 239 | strItem2 = dealWithSymName((const QString&)strItem); |
239 | strItem2 = dealWithSymName((const QString&)strItem); | 240 | if(QDir(strItem2).exists() ) |
240 | if(QDir(strItem2).exists() ) | ||
241 | strItem = strItem2; | 241 | strItem = strItem2; |
242 | } | 242 | } |
243 | 243 | ||
244 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) | 244 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
245 | { | ||
246 | 245 | ||
247 | if(QDir(strItem).exists()) | 246 | if(QDir(strItem).exists()) |
248 | isDirectory = true; | 247 | isDirectory = true; |
249 | } | 248 | } |
250 | 249 | ||
251 | if( isDirectory ) | 250 | if( isDirectory ) { |
252 | { | 251 | CurrentDir()->cd( strItem, TRUE); |
253 | CurrentDir()->cd( strItem, TRUE); | 252 | populateView(); |
254 | populateView(); | 253 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); |
255 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); | 254 | } |
256 | } | ||
257 | chdir( strItem.latin1()); | 255 | chdir( strItem.latin1()); |
258 | } | 256 | } |
259 | } | 257 | } |
260 | 258 | ||
261 | void AdvancedFm::ListPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 259 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { |
262 | switch (mouse) { | 260 | dealWithSchmooSchmaa( item->listView()); |
263 | case 1: | 261 | switch (mouse) { |
264 | { | 262 | case 1: |
265 | if(renameBox != 0 ) | 263 | { |
266 | { | 264 | if(renameBox != 0 ) { |
267 | cancelRename(); | 265 | cancelRename(); |
268 | } | 266 | } |
269 | } | 267 | } |
270 | break; | 268 | break; |
271 | case 2: | 269 | case 2: |
272 | menuTimer.start( 500, TRUE ); | 270 | menuTimer.start( 500, TRUE ); |
273 | break; | 271 | break; |
274 | }; | 272 | }; |
275 | } | 273 | } |
276 | 274 | ||
277 | void AdvancedFm::switchToLocalTab() | 275 | |
278 | { | 276 | void AdvancedFm::switchToLocalTab() { |
279 | TabWidget->setCurrentWidget(0); | 277 | //qWarning("switch to local view"); |
280 | Local_View->setFocus(); | 278 | TabWidget->setCurrentWidget(0); |
279 | Local_View->setFocus(); | ||
281 | } | 280 | } |
282 | 281 | ||
283 | void AdvancedFm::switchToRemoteTab() | 282 | void AdvancedFm::switchToRemoteTab() { |
284 | { | 283 | //qWarning("switch to local view"); |
285 | TabWidget->setCurrentWidget(1); | 284 | TabWidget->setCurrentWidget(1); |
286 | Remote_View->setFocus(); | 285 | Remote_View->setFocus(); |
287 | } | 286 | } |
288 | 287 | ||
289 | void AdvancedFm::readConfig() | 288 | void AdvancedFm::readConfig() { |
290 | { | 289 | Config cfg("AdvancedFm"); |
291 | Config cfg("AdvancedFm"); | ||
292 | } | 290 | } |
293 | 291 | ||
294 | void AdvancedFm::writeConfig() | 292 | void AdvancedFm::writeConfig() { |
295 | { | 293 | Config cfg("AdvancedFm"); |
296 | Config cfg("AdvancedFm"); | ||
297 | } | 294 | } |
298 | 295 | ||
299 | void AdvancedFm::currentPathComboChanged() | 296 | void AdvancedFm::currentPathComboChanged() { |
300 | { | 297 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
301 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) | ||
302 | { | ||
303 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); | 298 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); |
304 | populateView(); | 299 | populateView(); |
305 | } | 300 | } else { |
306 | else | ||
307 | { | ||
308 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 301 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
309 | } | 302 | } |
310 | } | 303 | } |
311 | 304 | ||
312 | void AdvancedFm::fillCombo(const QString ¤tPath) | 305 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
313 | { | 306 | |
314 | // qDebug("%d",TabWidget->currentTab()); | 307 | if ( whichTab == 1) { |
315 | if ( whichTab == 1) | ||
316 | { | ||
317 | currentPathCombo->lineEdit()->setText( currentPath); | 308 | currentPathCombo->lineEdit()->setText( currentPath); |
318 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) | 309 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
319 | { | 310 | currentPathCombo->clear(); |
320 | currentPathCombo->clear(); | 311 | localDirPathStringList.prepend( currentPath ); |
321 | localDirPathStringList.prepend( currentPath ); | 312 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
322 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 313 | } |
323 | } | 314 | } else { |
324 | } | ||
325 | else | ||
326 | { | ||
327 | currentPathCombo->lineEdit()->setText( currentPath); | 315 | currentPathCombo->lineEdit()->setText( currentPath); |
328 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) | 316 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
329 | { | 317 | currentPathCombo->clear(); |
330 | currentPathCombo->clear(); | 318 | remoteDirPathStringList.prepend( currentPath ); |
331 | remoteDirPathStringList.prepend( currentPath ); | 319 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
332 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 320 | } |
333 | } | 321 | } |
334 | } | 322 | } |
335 | } | 323 | |
336 | 324 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | |
337 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) | 325 | chdir( currentPath.latin1() ); |
338 | { | 326 | CurrentDir()->cd( currentPath, TRUE); |
339 | chdir( currentPath.latin1() ); | 327 | populateView(); |
340 | CurrentDir()->cd( currentPath, TRUE); | 328 | update(); |
341 | populateView(); | 329 | } |
342 | update(); | 330 | |
343 | } | 331 | QStringList AdvancedFm::getPath() { |
344 | 332 | QStringList strList; | |
345 | QStringList AdvancedFm::getPath() | 333 | QListView *thisView=CurrentView(); |
346 | { | 334 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); |
347 | QStringList strList; | 335 | QListViewItemIterator it( thisView ); |
348 | QListView *thisView=CurrentView(); | 336 | for ( ; it.current(); ++it ) { |
349 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); | 337 | if ( it.current()->isSelected() ) { |
350 | QListViewItemIterator it( thisView ); | 338 | strList << it.current()->text(0); |
351 | for ( ; it.current(); ++it ) | ||
352 | { | ||
353 | if ( it.current()->isSelected() ) | ||
354 | { | ||
355 | strList << it.current()->text(0); | ||
356 | // qDebug(it.current()->text(0)); | 339 | // qDebug(it.current()->text(0)); |
357 | } | 340 | } |
358 | } | 341 | } |
359 | return strList; | 342 | return strList; |
360 | } | 343 | } |
361 | 344 | ||
362 | void AdvancedFm::homeButtonPushed() | 345 | void AdvancedFm::homeButtonPushed() { |
363 | { | 346 | QString current = QDir::homeDirPath(); |
364 | QString current = QDir::homeDirPath(); | 347 | chdir( current.latin1() ); |
365 | chdir( current.latin1() ); | 348 | CurrentDir()->cd( current, TRUE); |
366 | CurrentDir()->cd( current, TRUE); | 349 | populateView(); |
367 | populateView(); | 350 | update(); |
368 | update(); | 351 | } |
369 | } | 352 | |
370 | 353 | void AdvancedFm::docButtonPushed() { | |
371 | void AdvancedFm::docButtonPushed() | 354 | QString current = QPEApplication::documentDir(); |
372 | { | 355 | chdir( current.latin1() ); |
373 | QString current = QPEApplication::documentDir(); | 356 | CurrentDir()->cd( current, TRUE); |
374 | chdir( current.latin1() ); | 357 | populateView(); |
375 | CurrentDir()->cd( current, TRUE); | 358 | update(); |
376 | populateView(); | 359 | } |
377 | update(); | 360 | |
378 | } | 361 | void AdvancedFm::SDButtonPushed() { |
379 | 362 | QString current = "/mnt/card";// this can change so fix | |
380 | void AdvancedFm::SDButtonPushed() | 363 | chdir( current.latin1() ); |
381 | { | 364 | CurrentDir()->cd( current, TRUE); |
382 | QString current = "/mnt/card";// this can change so fix | 365 | populateView(); |
383 | chdir( current.latin1() ); | 366 | update(); |
384 | CurrentDir()->cd( current, TRUE); | 367 | } |
385 | populateView(); | 368 | |
386 | update(); | 369 | void AdvancedFm::CFButtonPushed() { |
387 | } | 370 | QString current; |
388 | 371 | if(zaurusDevice) | |
389 | void AdvancedFm::CFButtonPushed() | 372 | current= "/mnt/cf"; //zaurus |
390 | { | 373 | else |
391 | QString current; | 374 | current = "/mnt/hda"; //ipaq |
392 | if(zaurusDevice) | 375 | chdir( current.latin1() ); |
393 | current= "/mnt/cf"; //zaurus | 376 | CurrentDir()->cd( current, TRUE); |
394 | else | 377 | populateView(); |
395 | current = "/mnt/hda"; //ipaq | 378 | update(); |
396 | chdir( current.latin1() ); | 379 | } |
397 | CurrentDir()->cd( current, TRUE); | 380 | |
398 | populateView(); | 381 | |
399 | update(); | 382 | void AdvancedFm::doAbout() { |
400 | } | 383 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" |
401 | 384 | "is copyright 2002-2003 by\n" | |
402 | 385 | "L.J.Potter<llornkcor@handhelds.org>\n" | |
403 | void AdvancedFm::doAbout() | 386 | "and is licensed by the GPL")); |
404 | { | 387 | } |
405 | QMessageBox::message("AdvancedFm",tr("Advanced FileManager\n" | 388 | |
406 | "is copyright 2002-2003 by\n" | 389 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { |
407 | "L.J.Potter<llornkcor@handhelds.org>\n" | 390 | // qWarning("key %d", e->key()); |
408 | "and is licensed by the GPL")); | 391 | // if( CurrentView()->hasFocus() ) |
409 | } | 392 | { |
410 | |||
411 | void AdvancedFm::keyPressEvent( QKeyEvent *e) | ||
412 | { | ||
413 | // e->accept(); | ||
414 | if( CurrentView()->hasFocus() ) | ||
415 | { | ||
416 | switch ( e->key() ) { | 393 | switch ( e->key() ) { |
394 | case Key_Left: | ||
395 | upDir(); | ||
396 | break; | ||
397 | case Key_Next: | ||
398 | break; | ||
399 | case Key_Return: | ||
400 | case Key_Enter: | ||
401 | navigateToSelected(); | ||
402 | break; | ||
403 | case Key_Tab: { | ||
404 | setOtherTabCurrent(); | ||
405 | } | ||
406 | break; | ||
417 | case Key_Delete: | 407 | case Key_Delete: |
418 | del(); | 408 | del(); |
419 | break; | 409 | break; |
420 | case Key_A: | 410 | case Key_A: |
421 | copyAs(); | 411 | copyAs(); |
422 | break; | 412 | break; |
423 | case Key_C: | 413 | case Key_C: |
424 | copy(); | 414 | copy(); |
425 | break; | 415 | break; |
426 | case Key_E: | 416 | case Key_E: |
427 | runThis(); | 417 | runThis(); |
428 | break; | 418 | break; |
429 | case Key_G: | 419 | case Key_G: |
430 | { | 420 | { |
431 | currentPathCombo->lineEdit()->setFocus(); | 421 | currentPathCombo->lineEdit()->setFocus(); |
432 | } | 422 | } |
433 | break; | 423 | break; |
434 | 424 | ||
435 | case Key_H: | 425 | case Key_H: |
436 | showHidden(); | 426 | showHidden(); |
437 | break; | 427 | break; |
438 | case Key_I: | 428 | case Key_I: |
439 | fileStatus(); | 429 | fileStatus(); |
440 | break; | 430 | break; |
441 | case Key_M: | 431 | case Key_M: |
442 | move(); | 432 | move(); |
443 | break; | 433 | break; |
444 | case Key_N: | 434 | case Key_N: |
445 | mkDir(); | 435 | mkDir(); |
446 | break; | 436 | break; |
447 | case Key_P: | 437 | case Key_P: |
448 | filePerms(); | 438 | filePerms(); |
449 | break; | 439 | break; |
450 | case Key_R: | 440 | case Key_R: |
451 | rn(); | 441 | rn(); |
452 | break; | 442 | break; |
453 | case Key_U: | 443 | case Key_U: |
454 | upDir(); | 444 | upDir(); |
455 | break; | 445 | break; |
456 | case Key_1: | 446 | case Key_1: |
457 | switchToLocalTab(); | 447 | switchToLocalTab(); |
458 | break; | 448 | break; |
459 | case Key_2: | 449 | case Key_2: |
460 | switchToRemoteTab(); | 450 | switchToRemoteTab(); |
461 | break; | 451 | break; |
462 | case Key_3: | 452 | case Key_3: |
463 | CFButtonPushed(); | 453 | CFButtonPushed(); |
464 | break; | 454 | break; |
465 | case Key_4: | 455 | case Key_4: |
466 | SDButtonPushed(); | 456 | SDButtonPushed(); |
467 | break; | 457 | break; |
468 | case Key_5: | 458 | case Key_5: |
469 | homeButtonPushed(); | 459 | homeButtonPushed(); |
470 | break; | 460 | break; |
471 | case Key_6: | 461 | case Key_6: |
472 | docButtonPushed(); | 462 | docButtonPushed(); |
473 | break; | 463 | break; |
474 | case Key_7: | 464 | case Key_7: |
475 | break; | 465 | break; |
476 | case Key_8: | 466 | case Key_8: |
477 | break; | 467 | break; |
478 | case Key_9: | 468 | case Key_9: |
479 | break; | 469 | break; |
480 | case Key_0: | 470 | case Key_0: |
481 | break; | 471 | break; |
482 | }; | 472 | }; |
483 | e->accept(); | 473 | e->accept(); |
484 | } | 474 | } |
485 | } | 475 | } |
486 | 476 | ||
487 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) | 477 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
488 | { | 478 | if( CurrentView()->hasFocus() ) |
489 | if( CurrentView()->hasFocus() ) | 479 | e->ignore(); |
490 | e->ignore(); | ||
491 | } | 480 | } |
492 | 481 | ||
493 | 482 | ||
494 | void AdvancedFm::QPEButtonPushed() | 483 | void AdvancedFm::QPEButtonPushed() { |
495 | { | 484 | QString current = QPEApplication::qpeDir(); |
496 | QString current = QPEApplication::qpeDir(); | 485 | chdir( current.latin1() ); |
497 | chdir( current.latin1() ); | 486 | CurrentDir()->cd( current, TRUE); |
498 | CurrentDir()->cd( current, TRUE); | 487 | populateView(); |
499 | populateView(); | 488 | update(); |
500 | update(); | ||
501 | } | 489 | } |
502 | 490 | ||
503 | void AdvancedFm::parsetab(const QString &fileName) | 491 | void AdvancedFm::parsetab(const QString &fileName) { |
504 | { | ||
505 | 492 | ||
506 | fileSystemTypeList.clear(); | 493 | fileSystemTypeList.clear(); |
507 | fsList.clear(); | 494 | fsList.clear(); |
508 | struct mntent *me; | 495 | struct mntent *me; |
509 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 496 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
510 | if ( mntfp ) | 497 | if ( mntfp ) { |
511 | { | 498 | while ( (me = getmntent( mntfp )) != 0 ) { |
512 | while ( (me = getmntent( mntfp )) != 0 ) | 499 | QString deviceName = me->mnt_fsname; |
513 | { | 500 | QString filesystemType = me->mnt_type; |
514 | QString deviceName = me->mnt_fsname; | 501 | QString mountDir = me->mnt_dir; |
515 | QString filesystemType = me->mnt_type; | 502 | if(deviceName != "none") { |
516 | QString mountDir = me->mnt_dir; | 503 | if( fsList.contains(filesystemType) == 0 |
517 | if(deviceName != "none") | 504 | & filesystemType.find("proc",0,TRUE) == -1 |
518 | { | 505 | & filesystemType.find("cramfs",0,TRUE) == -1 |
519 | if( fsList.contains(filesystemType) == 0 | 506 | & filesystemType.find("auto",0,TRUE) == -1) |
520 | & filesystemType.find("proc",0,TRUE) == -1 | 507 | fsList << filesystemType; |
521 | & filesystemType.find("cramfs",0,TRUE) == -1 | 508 | fileSystemTypeList << mountDir+"::"+filesystemType; |
522 | & filesystemType.find("auto",0,TRUE) == -1) | 509 | } |
523 | fsList << filesystemType; | 510 | } |
524 | fileSystemTypeList << mountDir+"::"+filesystemType; | 511 | } |
512 | endmntent( mntfp ); | ||
513 | } | ||
514 | |||
515 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | ||
516 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | ||
517 | QString current = currentText;//.right( currentText.length()-1); | ||
518 | QString baseFs; | ||
519 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | ||
520 | QString temp = (*it); | ||
521 | QString path = temp.left(temp.find("::",0,TRUE) ); | ||
522 | path = path.right( path.length()-1); | ||
523 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | ||
524 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | ||
525 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | ||
525 | } | 526 | } |
526 | } | 527 | } |
527 | } | 528 | return baseFs; |
528 | endmntent( mntfp ); | 529 | } |
529 | } | 530 | |
530 | 531 | QString AdvancedFm::getDiskSpace( const QString &path) { | |
531 | QString AdvancedFm::getFileSystemType(const QString ¤tText) | 532 | struct statfs fss; |
532 | { | 533 | if ( !statfs( path.latin1(), &fss ) ) { |
533 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 534 | int blkSize = fss.f_bsize; |
534 | QString current = currentText;//.right( currentText.length()-1); | ||
535 | QString baseFs; | ||
536 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | ||
537 | QString temp = (*it); | ||
538 | QString path = temp.left(temp.find("::",0,TRUE) ); | ||
539 | path = path.right( path.length()-1); | ||
540 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | ||
541 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | ||
542 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | ||
543 | } | ||
544 | } | ||
545 | return baseFs; | ||
546 | } | ||
547 | |||
548 | QString AdvancedFm::getDiskSpace( const QString &path) | ||
549 | { | ||
550 | struct statfs fss; | ||
551 | if ( !statfs( path.latin1(), &fss ) ) { | ||
552 | int blkSize = fss.f_bsize; | ||
553 | // int totalBlks = fs.f_blocks; | 535 | // int totalBlks = fs.f_blocks; |
554 | int availBlks = fss.f_bavail; | 536 | int availBlks = fss.f_bavail; |
555 | 537 | ||
556 | long mult = blkSize / 1024; | 538 | long mult = blkSize / 1024; |
557 | long div = 1024 / blkSize; | 539 | long div = 1024 / blkSize; |
558 | if ( !mult ) mult = 1; | 540 | if ( !mult ) mult = 1; |
559 | if ( !div ) div = 1; | 541 | if ( !div ) div = 1; |
560 | 542 | ||
561 | return QString::number(availBlks * mult / div); | 543 | return QString::number(availBlks * mult / div); |
562 | } | 544 | } |
563 | return ""; | 545 | return ""; |
564 | } | 546 | } |
565 | 547 | ||
566 | 548 | ||
567 | void AdvancedFm::showFileMenu() | 549 | void AdvancedFm::showFileMenu() { |
568 | { | 550 | QString curApp; |
569 | QString curApp; | 551 | curApp = CurrentView()->currentItem()->text(0); |
570 | curApp = CurrentView()->currentItem()->text(0); | ||
571 | 552 | ||
572 | MimeType mt( curApp ); | 553 | MimeType mt( curApp ); |
573 | const AppLnk* app = mt.application(); | 554 | const AppLnk* app = mt.application(); |
574 | QFile fi(curApp); | 555 | QFile fi(curApp); |
575 | QPopupMenu *m = new QPopupMenu(0); | 556 | QPopupMenu *m = new QPopupMenu(0); |
576 | QPopupMenu *n = new QPopupMenu(0); | 557 | QPopupMenu *n = new QPopupMenu(0); |
577 | // QPopupMenu *o = new QPopupMenu(0); | 558 | // QPopupMenu *o = new QPopupMenu(0); |
578 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 559 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
579 | 560 | ||
580 | if ( QFileInfo(fi).isDir() ) | 561 | if ( QFileInfo(fi).isDir() ) { |
581 | { | ||
582 | m->insertSeparator(); | 562 | m->insertSeparator(); |
583 | m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); | 563 | m->insertItem( tr( "Change Directory" ), this, SLOT( doDirChange() )); |
584 | } | 564 | } else { |
585 | else | ||
586 | { | ||
587 | 565 | ||
588 | if ( app ) | 566 | if ( app ) |
589 | m->insertItem( app->pixmap(), tr( "Open in " | 567 | m->insertItem( app->pixmap(), tr( "Open in " |
590 | + app->name() ), this, SLOT( runThis() ) ); | 568 | + app->name() ), this, SLOT( runThis() ) ); |
591 | else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 569 | else if( QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
592 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); | 570 | m->insertItem( tr( "Execute" ), this, SLOT( runThis() ) ); |
593 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); | 571 | m->insertItem( Resource::loadPixmap( "txt" ), tr( "Open as text" ),this, SLOT( runText() ) ); |
594 | } | 572 | } |
595 | 573 | ||
596 | m->insertItem(tr("Actions"),n); | 574 | m->insertItem(tr("Actions"),n); |
597 | n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); | 575 | n->insertItem( tr( "Make Directory" ), this, SLOT( makeDir() )); |
598 | 576 | ||
599 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 577 | n->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
600 | 578 | ||
601 | n->insertSeparator(); | 579 | n->insertSeparator(); |
602 | n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); | 580 | n->insertItem( tr( "Rename" ), this, SLOT( renameIt() )); |
603 | 581 | ||
604 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); | 582 | n->insertItem( tr( "Copy" ), this, SLOT( copy() )); |
605 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); | 583 | n->insertItem( tr( "Copy As" ), this, SLOT( copyAs() )); |
606 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); | 584 | n->insertItem( tr( "Copy Same Dir" ), this, SLOT( copySameDir() )); |
607 | n->insertItem( tr( "Move" ), this, SLOT( move() )); | 585 | n->insertItem( tr( "Move" ), this, SLOT( move() )); |
608 | 586 | ||
609 | n->insertSeparator(); | 587 | n->insertSeparator(); |
610 | n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); | 588 | n->insertItem( tr( "Delete" ), this, SLOT( doDelete() )); |
611 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 589 | m->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
612 | 590 | ||
613 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); | 591 | m->insertItem( tr( "Run Command" ), this, SLOT( runCommand() )); |
614 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); | 592 | m->insertItem( tr( "File Info" ), this, SLOT( fileStatus() )); |
615 | 593 | ||
616 | m->insertSeparator(); | 594 | m->insertSeparator(); |
617 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); | 595 | m->insertItem( tr( "Set Permissions" ), this, SLOT( filePerms() )); |
618 | 596 | ||
619 | #if defined(QT_QWS_OPIE) | 597 | #if defined(QT_QWS_OPIE) |
620 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); | 598 | m->insertItem( tr( "Properties" ), this, SLOT( doProperties() )); |
621 | #endif | 599 | #endif |
622 | m->setCheckable(TRUE); | 600 | m->setCheckable(TRUE); |
623 | if (!b) | 601 | if (!b) |
624 | m->setItemChecked(m->idAt(0),TRUE); | 602 | m->setItemChecked(m->idAt(0),TRUE); |
625 | else | 603 | else |
626 | m->setItemChecked(m->idAt(0),FALSE); | 604 | m->setItemChecked(m->idAt(0),FALSE); |
627 | 605 | ||
628 | if(Ir::supported()) | 606 | if(Ir::supported()) |
629 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); | 607 | m->insertItem( tr( "Beam File" ), this, SLOT( doBeam() )); |
630 | m->setFocus(); | 608 | m->setFocus(); |
631 | m->exec( QPoint( 4,QCursor::pos().y()) ); | 609 | m->exec( QPoint( 4,QCursor::pos().y()) ); |
632 | 610 | ||
633 | if(m) delete m; | 611 | if(m) delete m; |
634 | } | 612 | } |
635 | 613 | ||
636 | 614 | ||
637 | void AdvancedFm::cancelMenuTimer() | 615 | void AdvancedFm::cancelMenuTimer() { |
638 | { | 616 | |
639 | // qDebug("selectionChanged: cancel menu timer"); | 617 | if( menuTimer.isActive() ) |
640 | if( menuTimer.isActive() ) | 618 | menuTimer.stop(); |
641 | menuTimer.stop(); | ||
642 | } | 619 | } |
643 | 620 | ||
644 | QString AdvancedFm::checkDiskSpace(const QString &path) | 621 | QString AdvancedFm::checkDiskSpace(const QString &path) { |
645 | { | 622 | struct statfs fss; |
646 | struct statfs fss; | 623 | if ( !statfs( path.latin1(), &fss ) ) { |
647 | if ( !statfs( path.latin1(), &fss ) ) | 624 | int blkSize = fss.f_bsize; |
648 | { | ||
649 | int blkSize = fss.f_bsize; | ||
650 | // int totalBlks = fs.f_blocks; | 625 | // int totalBlks = fs.f_blocks; |
651 | int availBlks = fss.f_bavail; | 626 | int availBlks = fss.f_bavail; |
652 | 627 | ||
653 | long mult = blkSize / 1024; | 628 | long mult = blkSize / 1024; |
654 | long div = 1024 / blkSize; | 629 | long div = 1024 / blkSize; |
655 | if ( !mult ) mult = 1; | 630 | if ( !mult ) mult = 1; |
656 | if ( !div ) div = 1; | 631 | if ( !div ) div = 1; |
657 | 632 | ||
658 | 633 | ||
659 | return QString::number(availBlks * mult / div); | 634 | return QString::number(availBlks * mult / div); |
660 | } | 635 | } |
661 | return ""; | 636 | return ""; |
662 | } | 637 | } |
663 | 638 | ||
664 | void AdvancedFm::addToDocs() | 639 | void AdvancedFm::addToDocs() { |
665 | { | 640 | QStringList strListPaths = getPath(); |
666 | QStringList strListPaths = getPath(); | 641 | QDir *thisDir = CurrentDir(); |
667 | QDir *thisDir = CurrentDir(); | ||
668 | 642 | ||
669 | if( strListPaths.count() > 0) { | 643 | if( strListPaths.count() > 0) { |
670 | QString curFile; | 644 | QString curFile; |
671 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { | 645 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { |
672 | curFile = thisDir->canonicalPath()+"/"+(*it); | 646 | curFile = thisDir->canonicalPath()+"/"+(*it); |
673 | // qDebug(curFile); | 647 | // qDebug(curFile); |
674 | QFileInfo fi(curFile); | 648 | QFileInfo fi(curFile); |
675 | DocLnk f; | 649 | DocLnk f; |
676 | // curFile.replace(QRegExp("\\..*"),""); | 650 | // curFile.replace(QRegExp("\\..*"),""); |
677 | f.setName(fi.baseName() ); | 651 | f.setName(fi.baseName() ); |
678 | f.setFile( curFile); | 652 | f.setFile( curFile); |
679 | f.writeLink(); | 653 | f.writeLink(); |
680 | } | 654 | } |
681 | } | 655 | } |
682 | } | 656 | } |
683 | 657 | ||
684 | 658 | ||
685 | void AdvancedFm::customDirsToMenu() | 659 | void AdvancedFm::customDirsToMenu() { |
686 | { | ||
687 | 660 | ||
688 | Config cfg("AdvancedFm"); | 661 | Config cfg("AdvancedFm"); |
689 | cfg.setGroup("Menu"); | 662 | cfg.setGroup("Menu"); |
690 | 663 | ||
691 | QStringList list = cfg.readListEntry( "CustomDir", ','); | 664 | QStringList list = cfg.readListEntry( "CustomDir", ','); |
692 | menuButton->insertItems(list ); | 665 | menuButton->insertItems(list ); |
693 | 666 | ||
694 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 667 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
695 | // { | 668 | // { |
696 | // customDirMenu->insertItem(*it ); | 669 | // customDirMenu->insertItem(*it ); |
697 | // } | 670 | // } |
698 | } | 671 | } |
699 | 672 | ||
700 | void AdvancedFm::dirMenuSelected(int item) | 673 | void AdvancedFm::dirMenuSelected(int item) { |
701 | { | 674 | switch(item) |
702 | qDebug("menu item %d", item); | 675 | { |
703 | switch(item) | ||
704 | { | ||
705 | 676 | ||
706 | case -21: | 677 | case -21: |
707 | case 0: | 678 | case 0: |
708 | addCustomDir(); | 679 | addCustomDir(); |
709 | break; | 680 | break; |
710 | case -22: | 681 | case -22: |
711 | case 1: | 682 | case 1: |
712 | removeCustomDir(); | 683 | removeCustomDir(); |
713 | break; | 684 | break; |
714 | default: | 685 | default: |
715 | { | 686 | { |
716 | // gotoCustomDir( menuButton->text(item)); | 687 | // gotoCustomDir( menuButton->text(item)); |
717 | // gotoCustomDir( customDirMenu->text(item)); | 688 | // gotoCustomDir( customDirMenu->text(item)); |
718 | } | 689 | } |
719 | break; | 690 | break; |
720 | 691 | ||
721 | }; | 692 | }; |
722 | } | 693 | } |
723 | 694 | ||
724 | void AdvancedFm::addCustomDir() | 695 | void AdvancedFm::addCustomDir() { |
725 | { | 696 | Config cfg("AdvancedFm"); |
726 | Config cfg("AdvancedFm"); | 697 | cfg.setGroup("Menu"); |
727 | cfg.setGroup("Menu"); | 698 | QString dir; |
728 | QString dir; | 699 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
729 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 700 | |
730 | 701 | dir = CurrentDir()->canonicalPath(); | |
731 | dir = CurrentDir()->canonicalPath(); | 702 | |
732 | 703 | bool addIt=true; | |
733 | bool addIt=true; | 704 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
734 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 705 | if( dir == (*it)) { |
735 | { | 706 | addIt=false; |
736 | if( dir == (*it)) | 707 | } |
737 | { | 708 | } |
738 | addIt=false; | 709 | if(addIt) { |
739 | } | ||
740 | } | ||
741 | if(addIt) | ||
742 | { | ||
743 | menuButton->insertItem(dir); | 710 | menuButton->insertItem(dir); |
744 | // customDirMenu->insertItem(dir); | 711 | // customDirMenu->insertItem(dir); |
745 | list << dir; | 712 | list << dir; |
746 | } | 713 | } |
747 | 714 | ||
748 | cfg.writeEntry("CustomDir", list, ','); | 715 | cfg.writeEntry("CustomDir", list, ','); |
749 | cfg.write(); | 716 | cfg.write(); |
750 | } | 717 | } |
751 | 718 | ||
752 | void AdvancedFm::removeCustomDir() | 719 | void AdvancedFm::removeCustomDir() { |
753 | { | ||
754 | // qDebug("remove custom dir"); | 720 | // qDebug("remove custom dir"); |
755 | Config cfg("AdvancedFm"); | 721 | Config cfg("AdvancedFm"); |
756 | cfg.setGroup("Menu"); | 722 | cfg.setGroup("Menu"); |
757 | QString dir; | 723 | QString dir; |
758 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 724 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
759 | QStringList list2; | 725 | QStringList list2; |
760 | dir = CurrentDir()->canonicalPath(); | 726 | dir = CurrentDir()->canonicalPath(); |
761 | int ramble=2; | 727 | int ramble=2; |
762 | // int ramble=-24; | 728 | // int ramble=-24; |
763 | //first remove list | 729 | //first remove list |
764 | if(list.grep(dir,true).isEmpty()) | 730 | if(list.grep(dir,true).isEmpty()) { |
765 | { | ||
766 | QMessageBox::message(tr( "AdvancedFm" ), | 731 | QMessageBox::message(tr( "AdvancedFm" ), |
767 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); | 732 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); |
768 | } | 733 | } else { |
769 | else | 734 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
770 | { | 735 | if((*it) != dir) { |
771 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 736 | //current item is not our current dir, so add it to temp list |
772 | { | 737 | list2 <<(*it); |
773 | if((*it) != dir)//current item is not our current dir, so add it to temp list | 738 | } else { |
774 | { | ||
775 | list2 <<(*it); | ||
776 | } | ||
777 | else | ||
778 | { | ||
779 | // customDirMenu->removeItem( ramble); | 739 | // customDirMenu->removeItem( ramble); |
780 | menuButton->remove( ramble); | 740 | menuButton->remove( ramble); |
781 | 741 | ||
782 | } | 742 | } |
783 | ramble++; | 743 | ramble++; |
784 | // ramble--; | 744 | // ramble--; |
785 | } | 745 | } |
786 | 746 | ||
787 | cfg.writeEntry("CustomDir", list2, ','); | 747 | cfg.writeEntry("CustomDir", list2, ','); |
788 | cfg.write(); | 748 | cfg.write(); |
789 | } | 749 | } |
790 | // customDirsToMenu(); | 750 | // customDirsToMenu(); |
791 | 751 | ||
792 | } | 752 | } |
793 | 753 | ||
794 | void AdvancedFm::gotoCustomDir(const QString &dir) | 754 | void AdvancedFm::gotoCustomDir(const QString &dir) { |
795 | { | ||
796 | // qDebug("gotoCustomDir(const QString &dir) " +dir ); | 755 | // qDebug("gotoCustomDir(const QString &dir) " +dir ); |
797 | // QString curDir = dir; | 756 | // QString curDir = dir; |
798 | // QDir *thisDir = CurrentDir(); | 757 | // QDir *thisDir = CurrentDir(); |
799 | // if( curDir.isEmpty()) { | 758 | // if( curDir.isEmpty()) { |
800 | // } | 759 | // } |
801 | if( dir == s_addBookmark) | 760 | if( dir == s_addBookmark) { |
802 | { | ||
803 | addCustomDir(); | 761 | addCustomDir(); |
804 | } | 762 | } |
805 | if( dir == s_removeBookmark) | 763 | if( dir == s_removeBookmark) { |
806 | { | ||
807 | removeCustomDir( ); | 764 | removeCustomDir( ); |
808 | } | 765 | } else { |
809 | else | 766 | gotoDirectory( dir); |
810 | { | ||
811 | gotoDirectory( dir); | ||
812 | // if(QDir( curDir).exists() ) | 767 | // if(QDir( curDir).exists() ) |
813 | // { | 768 | // { |
814 | // thisDir->setPath( curDir ); | 769 | // thisDir->setPath( curDir ); |
815 | // chdir( curDir.latin1() ); | 770 | // chdir( curDir.latin1() ); |
816 | // thisDir->cd( curDir, TRUE); | 771 | // thisDir->cd( curDir, TRUE); |
817 | // populateView(); | 772 | // populateView(); |
818 | // } | 773 | // } |
819 | } | 774 | } |
820 | } | 775 | } |
821 | 776 | ||
822 | QDir *AdvancedFm::CurrentDir() | 777 | QDir *AdvancedFm::CurrentDir() { |
823 | { | 778 | |
824 | if ( whichTab == 1) | 779 | if ( whichTab == 1) { |
825 | { | 780 | return ¤tDir; |
826 | return ¤tDir; | 781 | } else { |
827 | } | 782 | return ¤tRemoteDir; |
828 | else | 783 | } |
829 | { | ||
830 | return ¤tRemoteDir; | ||
831 | } | ||
832 | } | 784 | } |
833 | 785 | ||
834 | QDir *AdvancedFm::OtherDir() | 786 | QDir *AdvancedFm::OtherDir() { |
835 | { | 787 | if ( whichTab == 1) { |
836 | if ( whichTab == 1) | 788 | return ¤tRemoteDir; |
837 | { | 789 | } else { |
838 | return ¤tRemoteDir; | 790 | return ¤tDir; |
839 | } | 791 | } |
840 | else | ||
841 | { | ||
842 | return ¤tDir; | ||
843 | } | ||
844 | } | 792 | } |
845 | 793 | ||
846 | QListView * AdvancedFm::CurrentView() | 794 | QListView * AdvancedFm::CurrentView() { |
847 | { | 795 | if ( whichTab == 1) { |
848 | if ( whichTab == 1) | 796 | // qWarning("CurrentView Tab 1"); |
849 | return Local_View; | 797 | return Local_View; |
850 | else | 798 | } else { |
851 | return Remote_View; | 799 | // qWarning("CurrentView Tab 2"); |
800 | return Remote_View; | ||
801 | } | ||
852 | } | 802 | } |
853 | 803 | ||
854 | QListView * AdvancedFm::OtherView() | 804 | QListView * AdvancedFm::OtherView() { |
855 | { | 805 | if ( whichTab == 1) |
856 | if ( whichTab == 1) | 806 | return Remote_View; |
857 | return Remote_View; | 807 | else |
858 | else | 808 | return Local_View; |
859 | return Local_View; | ||
860 | } | 809 | } |
861 | 810 | ||
862 | void AdvancedFm::setOtherTabCurrent() | 811 | void AdvancedFm::setOtherTabCurrent() { |
863 | { | 812 | // qWarning("setOtherTabCurrent()"); |
864 | if ( whichTab == 1) | 813 | if ( whichTab == 1) { |
865 | TabWidget->setCurrentWidget(1); | 814 | TabWidget->setCurrentWidget(1); |
866 | else | 815 | } else { |
867 | TabWidget->setCurrentWidget(0); | 816 | TabWidget->setCurrentWidget(0); |
817 | } | ||
818 | OtherView()->setFocus(); | ||
819 | OtherView()->setSelected( CurrentView()->firstChild(), true); | ||
868 | } | 820 | } |
869 | 821 | ||
870 | void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { | 822 | void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { |
871 | qDebug("qcop message "+msg ); | 823 | // qDebug("qcop message "+msg ); |
872 | QDataStream stream ( data, IO_ReadOnly ); | 824 | QDataStream stream ( data, IO_ReadOnly ); |
873 | if ( msg == "openDirectory(QString)" ) { | 825 | if ( msg == "openDirectory(QString)" ) { |
874 | qDebug("received"); | 826 | // qDebug("received"); |
875 | QString file; | 827 | QString file; |
876 | stream >> file; | 828 | stream >> file; |
877 | gotoDirectory( (const QString &) file); | 829 | gotoDirectory( (const QString &) file); |
878 | } | 830 | } |
879 | } | 831 | } |
880 | 832 | ||
881 | void AdvancedFm::setDocument(const QString &file) { | 833 | void AdvancedFm::setDocument(const QString &file) { |
882 | gotoDirectory( file); | 834 | gotoDirectory( file); |
883 | 835 | ||
884 | } | 836 | } |
885 | 837 | ||
886 | void AdvancedFm::gotoDirectory(const QString &file) { | 838 | void AdvancedFm::gotoDirectory(const QString &file) { |
887 | 839 | // qWarning("goto dir "+file); | |
888 | QString curDir = file; | 840 | QString curDir = file; |
889 | QDir *thisDir = CurrentDir(); | 841 | QDir *thisDir = CurrentDir(); |
890 | if(QDir( curDir).exists() ) { | 842 | if(QDir( curDir).exists() ) { |
891 | thisDir->setPath( curDir ); | 843 | thisDir->setPath( curDir ); |
892 | chdir( curDir.latin1() ); | 844 | chdir( curDir.latin1() ); |
893 | thisDir->cd( curDir, TRUE); | 845 | thisDir->cd( curDir, TRUE); |
894 | populateView(); | 846 | populateView(); |
895 | } | 847 | } |
896 | else if(QFileInfo(curDir).exists()) { | 848 | else if(QFileInfo(curDir).exists()) { |
897 | QFileInfo fileInfo(curDir); | 849 | QFileInfo fileInfo(curDir); |
898 | curDir=fileInfo.dirPath(); | 850 | curDir=fileInfo.dirPath(); |
899 | if(QDir( curDir).exists() ) { | 851 | if(QDir( curDir).exists() ) { |
900 | thisDir->setPath( curDir ); | 852 | thisDir->setPath( curDir ); |
901 | chdir( curDir.latin1() ); | 853 | chdir( curDir.latin1() ); |
902 | thisDir->cd( curDir, TRUE); | 854 | thisDir->cd( curDir, TRUE); |
903 | populateView(); | 855 | populateView(); |
904 | } | 856 | } |
905 | findFile(file); | 857 | findFile(file); |
906 | } | 858 | } |
907 | 859 | ||
908 | } | 860 | } |
909 | 861 | ||
910 | void AdvancedFm::findFile(const QString &fileName) { | 862 | void AdvancedFm::findFile(const QString &fileName) { |
911 | QFileInfo fi(fileName); | 863 | QFileInfo fi(fileName); |
912 | QListView *thisView = CurrentView(); | 864 | QListView *thisView = CurrentView(); |
913 | QListViewItemIterator it( thisView ); | 865 | QListViewItemIterator it( thisView ); |
914 | for ( ; it.current(); ++it ) { | 866 | for ( ; it.current(); ++it ) { |
915 | if(it.current()->text(0) == fi.fileName()) { | 867 | if(it.current()->text(0) == fi.fileName()) { |
916 | it.current()->setSelected(true); | 868 | it.current()->setSelected(true); |
917 | thisView->ensureItemVisible(it.current()); | 869 | thisView->ensureItemVisible(it.current()); |
918 | } | 870 | } |
919 | } | 871 | } |
920 | } | 872 | } |
873 | |||
874 | void AdvancedFm::slotSwitchMenu(int ) { | ||
875 | // qDebug("Switch %d", item); | ||
876 | // viewMenu->setItemChecked(item, true); | ||
877 | } | ||
878 | |||
879 | void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) { | ||
880 | tabChanged( w); | ||
881 | if( w == Local_View) { | ||
882 | Remote_View->clearFocus(); | ||
883 | } else { | ||
884 | Local_View->clearFocus(); | ||
885 | } | ||
886 | } | ||
887 | |||
888 | void AdvancedFm::navigateToSelected() { | ||
889 | if( !CurrentView()->currentItem()) return; | ||
890 | doDirChange(); | ||
891 | } | ||
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index 5e2c769..5f6eabb 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h | |||
@@ -1,180 +1,185 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | advancedfm.h | 2 | advancedfm.h |
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 | #ifndef ADVANCEDFM_H | 12 | #ifndef ADVANCEDFM_H |
13 | #define ADVANCEDFM_H | 13 | #define ADVANCEDFM_H |
14 | #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties | 14 | #define QTOPIA_INTERNAL_FSLP // to get access to fileproperties |
15 | #define QT_QWS_OPIE | 15 | #define QT_QWS_OPIE |
16 | 16 | ||
17 | //#include <opie/otabwidget.h> | 17 | //#include <opie/otabwidget.h> |
18 | #include <opie/oprocess.h> | 18 | #include <opie/oprocess.h> |
19 | 19 | ||
20 | #include <qpe/ir.h> | 20 | #include <qpe/ir.h> |
21 | #include <qpe/qcopenvelope_qws.h> | 21 | #include <qpe/qcopenvelope_qws.h> |
22 | 22 | ||
23 | #include <qvariant.h> | 23 | #include <qvariant.h> |
24 | #include <qdialog.h> | 24 | #include <qdialog.h> |
25 | #include <qmainwindow.h> | 25 | #include <qmainwindow.h> |
26 | #include <qstringlist.h> | 26 | #include <qstringlist.h> |
27 | #include <qdir.h> | 27 | #include <qdir.h> |
28 | #include <qstring.h> | 28 | #include <qstring.h> |
29 | #include <qpoint.h> | 29 | #include <qpoint.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qpixmap.h> | 31 | #include <qpixmap.h> |
32 | 32 | ||
33 | class OSplitter; | 33 | class OSplitter; |
34 | class QVBoxLayout; | 34 | class QVBoxLayout; |
35 | class QHBoxLayout; | 35 | class QHBoxLayout; |
36 | class QGridLayout; | 36 | class QGridLayout; |
37 | class QComboBox; | 37 | class QComboBox; |
38 | class QListView; | 38 | class QListView; |
39 | class QListviewItem; | 39 | class QListviewItem; |
40 | class QLabel; | 40 | class QLabel; |
41 | class QProgressBar; | 41 | class QProgressBar; |
42 | class QSpinBox; | 42 | class QSpinBox; |
43 | class QTabWidget; | 43 | class QTabWidget; |
44 | class QWidget; | 44 | class QWidget; |
45 | class QPopupMenu; | 45 | class QPopupMenu; |
46 | class QFile; | 46 | class QFile; |
47 | class QListViewItem; | 47 | class QListViewItem; |
48 | class QLineEdit; | 48 | class QLineEdit; |
49 | class MenuButton; | 49 | class MenuButton; |
50 | 50 | ||
51 | class QToolButton; | 51 | class QToolButton; |
52 | class Ir; | 52 | class Ir; |
53 | 53 | ||
54 | class AdvancedFm : public QMainWindow | 54 | class AdvancedFm : public QMainWindow |
55 | { | 55 | { |
56 | Q_OBJECT | 56 | Q_OBJECT |
57 | public: | 57 | public: |
58 | AdvancedFm(); | 58 | AdvancedFm(); |
59 | ~AdvancedFm(); | 59 | ~AdvancedFm(); |
60 | protected slots: | 60 | protected slots: |
61 | void slotSwitchMenu(int); | ||
61 | void selectAll(); | 62 | void selectAll(); |
62 | void addToDocs(); | 63 | void addToDocs(); |
63 | void doDirChange(); | 64 | void doDirChange(); |
64 | void mkDir(); | 65 | void mkDir(); |
65 | void del(); | 66 | void del(); |
66 | void rn(); | 67 | void rn(); |
67 | void populateView(); | 68 | void populateView(); |
68 | void rePopulate(); | 69 | void rePopulate(); |
69 | void showHidden(); | 70 | void showHidden(); |
70 | void showMenuHidden(); | 71 | void showMenuHidden(); |
71 | void writeConfig(); | 72 | void writeConfig(); |
72 | void readConfig(); | 73 | void readConfig(); |
73 | void ListClicked(QListViewItem *); | 74 | void ListClicked(QListViewItem *); |
74 | void ListPressed( int, QListViewItem *, const QPoint&, int); | 75 | void ListPressed( int, QListViewItem *, const QPoint&, int); |
75 | void makeDir(); | 76 | void makeDir(); |
76 | void doDelete(); | 77 | void doDelete(); |
77 | void tabChanged(QWidget*); | 78 | void tabChanged(QWidget*); |
78 | void cleanUp(); | 79 | void cleanUp(); |
79 | void renameIt(); | 80 | void renameIt(); |
80 | void runThis(); | 81 | void runThis(); |
81 | void runText(); | 82 | void runText(); |
82 | void filePerms(); | 83 | void filePerms(); |
83 | void doProperties(); | 84 | void doProperties(); |
84 | void runCommand(); | 85 | void runCommand(); |
85 | void runCommandStd(); | 86 | void runCommandStd(); |
86 | QStringList getPath(); | 87 | QStringList getPath(); |
87 | void mkSym(); | 88 | void mkSym(); |
88 | void switchToLocalTab(); | 89 | void switchToLocalTab(); |
89 | void switchToRemoteTab(); | 90 | void switchToRemoteTab(); |
90 | 91 | ||
91 | protected: | 92 | protected: |
92 | 93 | ||
93 | OSplitter *TabWidget; | 94 | OSplitter *TabWidget; |
94 | QCopChannel * channel; | 95 | QCopChannel * channel; |
95 | QPixmap unknownXpm; | 96 | QPixmap unknownXpm; |
96 | int whichTab; | 97 | int whichTab; |
97 | // QTabWidget *TabWidget; | 98 | // QTabWidget *TabWidget; |
98 | QWidget *tab, *tab_2, *tab_3; | 99 | QWidget *tab, *tab_2, *tab_3; |
99 | QListView *Local_View, *Remote_View; | 100 | QListView *Local_View, *Remote_View; |
100 | 101 | ||
101 | QLineEdit *currentPathEdit; | 102 | QLineEdit *currentPathEdit; |
102 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/; | 103 | QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu /*, *customDirMenu*/; |
103 | QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; | 104 | QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
104 | // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; | 105 | // QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton; |
105 | QDir currentDir, currentRemoteDir; | 106 | QDir currentDir, currentRemoteDir; |
106 | QComboBox *currentPathCombo; | 107 | QComboBox *currentPathCombo; |
107 | QString filterStr, s_addBookmark, s_removeBookmark; | 108 | QString filterStr, s_addBookmark, s_removeBookmark; |
108 | QListViewItem * item; | 109 | QListViewItem * item; |
109 | bool b; | 110 | bool b; |
110 | QStringList fileSystemTypeList, fsList; | 111 | QStringList fileSystemTypeList, fsList; |
111 | int currentServerConfig; | 112 | int currentServerConfig; |
112 | bool zaurusDevice; | 113 | bool zaurusDevice; |
113 | QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; | 114 | QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3; |
114 | QStringList remoteDirPathStringList, localDirPathStringList; | 115 | QStringList remoteDirPathStringList, localDirPathStringList; |
115 | QLineEdit *renameBox; | 116 | QLineEdit *renameBox; |
116 | 117 | ||
117 | void init(); | 118 | void init(); |
118 | void initConnections(); | 119 | void initConnections(); |
119 | void keyReleaseEvent( QKeyEvent *); | 120 | void keyReleaseEvent( QKeyEvent *); |
120 | void keyPressEvent( QKeyEvent *); | 121 | void keyPressEvent( QKeyEvent *); |
121 | QString getFileSystemType(const QString &); | 122 | QString getFileSystemType(const QString &); |
122 | QString getDiskSpace(const QString &); | 123 | QString getDiskSpace(const QString &); |
123 | void parsetab(const QString &fileName); | 124 | void parsetab(const QString &fileName); |
124 | QString checkDiskSpace(const QString &); | 125 | QString checkDiskSpace(const QString &); |
125 | QString dealWithSymName(const QString &); | 126 | QString dealWithSymName(const QString &); |
126 | QDir *CurrentDir(); | 127 | QDir *CurrentDir(); |
127 | QDir *OtherDir(); | 128 | QDir *OtherDir(); |
128 | QListView *CurrentView(); | 129 | QListView *CurrentView(); |
129 | QListView *OtherView(); | 130 | QListView *OtherView(); |
130 | void setOtherTabCurrent(); | 131 | void setOtherTabCurrent(); |
132 | void dealWithSchmooSchmaa(QWidget *); | ||
131 | 133 | ||
132 | protected slots: | 134 | protected slots: |
135 | void openSearch(); | ||
133 | void dirMenuSelected(int); | 136 | void dirMenuSelected(int); |
134 | void showFileMenu(); | 137 | void showFileMenu(); |
135 | void cancelMenuTimer(); | 138 | void cancelMenuTimer(); |
136 | void homeButtonPushed(); | 139 | void homeButtonPushed(); |
137 | void docButtonPushed(); | 140 | void docButtonPushed(); |
138 | void SDButtonPushed(); | 141 | void SDButtonPushed(); |
139 | void CFButtonPushed(); | 142 | void CFButtonPushed(); |
140 | void QPEButtonPushed(); | 143 | void QPEButtonPushed(); |
141 | void upDir(); | 144 | void upDir(); |
142 | void currentPathComboChanged(); | 145 | void currentPathComboChanged(); |
143 | void copy(); | 146 | void copy(); |
144 | void copyAs(); | 147 | void copyAs(); |
145 | void copySameDir(); | 148 | void copySameDir(); |
146 | void currentPathComboActivated(const QString &); | 149 | void currentPathComboActivated(const QString &); |
147 | void fillCombo(const QString &); | 150 | void fillCombo(const QString &); |
148 | bool copyFile( const QString & , const QString & ); | 151 | bool copyFile( const QString & , const QString & ); |
149 | void move(); | 152 | void move(); |
150 | void fileStatus(); | 153 | void fileStatus(); |
151 | void doAbout(); | 154 | void doAbout(); |
152 | void doBeam(); | 155 | void doBeam(); |
153 | void fileBeamFinished( Ir *); | 156 | void fileBeamFinished( Ir *); |
154 | 157 | ||
158 | // void slotSwitchtoLocal(int); | ||
159 | |||
155 | private: | 160 | private: |
156 | MenuButton *menuButton; | 161 | MenuButton *menuButton; |
157 | QString oldName; | 162 | QString oldName; |
158 | QTimer menuTimer; | 163 | QTimer menuTimer; |
159 | void startProcess(const QString &); | 164 | void startProcess(const QString &); |
160 | bool eventFilter( QObject * , QEvent * ); | 165 | bool eventFilter( QObject * , QEvent * ); |
161 | void cancelRename(); | 166 | void cancelRename(); |
162 | void doRename(QListView *); | 167 | void doRename(QListView *); |
163 | void okRename(); | 168 | void okRename(); |
164 | void customDirsToMenu(); | 169 | void customDirsToMenu(); |
165 | void addCustomDir(); | 170 | void addCustomDir(); |
166 | void removeCustomDir(); | 171 | void removeCustomDir(); |
167 | void gotoDirectory(const QString &); | 172 | void gotoDirectory(const QString &); |
168 | void openSearch(); | 173 | void navigateToSelected(); |
169 | void findFile(const QString &); | 174 | void findFile(const QString &); |
170 | 175 | ||
171 | private slots: | 176 | private slots: |
172 | void processEnded(OProcess *); | 177 | void processEnded(OProcess *); |
173 | void oprocessStderr(OProcess *, char *, int); | 178 | void oprocessStderr(OProcess *, char *, int); |
174 | void gotoCustomDir(const QString &); | 179 | void gotoCustomDir(const QString &); |
175 | void qcopReceive(const QCString&, const QByteArray&); | 180 | void qcopReceive(const QCString&, const QByteArray&); |
176 | void setDocument(const QString &); | 181 | void setDocument(const QString &); |
177 | 182 | ||
178 | }; | 183 | }; |
179 | 184 | ||
180 | #endif // ADVANCEDFM_H | 185 | #endif // ADVANCEDFM_H |
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp index 463b202..ddaa39a 100644 --- a/noncore/apps/advancedfm/advancedfmData.cpp +++ b/noncore/apps/advancedfm/advancedfmData.cpp | |||
@@ -1,286 +1,288 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | advancedfmData.cpp | 2 | advancedfmData.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Mon 09-23-2002 13:24:11 | 4 | ** Created: Mon 09-23-2002 13:24:11 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | 13 | ||
14 | #include <opie/osplitter.h> | 14 | #include <opie/osplitter.h> |
15 | #include <qpe/storage.h> | 15 | #include <qpe/storage.h> |
16 | 16 | ||
17 | #include <qpe/qpeapplication.h> | 17 | #include <qpe/qpeapplication.h> |
18 | #include <qpe/resource.h> | 18 | #include <qpe/resource.h> |
19 | #include <qpe/menubutton.h> | 19 | #include <qpe/menubutton.h> |
20 | 20 | ||
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qhbox.h> | 22 | #include <qhbox.h> |
23 | #include <qmenubar.h> | 23 | #include <qmenubar.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qtoolbutton.h> | 25 | #include <qtoolbutton.h> |
26 | #include <qlineedit.h> | 26 | #include <qlineedit.h> |
27 | #include <qlistview.h> | 27 | #include <qlistview.h> |
28 | 28 | ||
29 | #include <sys/utsname.h> | 29 | #include <sys/utsname.h> |
30 | 30 | ||
31 | 31 | ||
32 | void AdvancedFm::init() { | 32 | void AdvancedFm::init() { |
33 | #if defined(QT_QWS_OPIE) | 33 | #if defined(QT_QWS_OPIE) |
34 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<< OPIE!!!"); | 34 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<< OPIE!!!"); |
35 | #endif | 35 | #endif |
36 | setCaption( tr( "AdvancedFm" ) ); | 36 | setCaption( tr( "AdvancedFm" ) ); |
37 | 37 | ||
38 | QVBoxLayout *layout = new QVBoxLayout( this ); | 38 | QVBoxLayout *layout = new QVBoxLayout( this ); |
39 | layout->setSpacing( 2); | 39 | layout->setSpacing( 2); |
40 | layout->setMargin( 2); | 40 | layout->setMargin( 2); |
41 | 41 | ||
42 | QMenuBar *menuBar = new QMenuBar(this); | 42 | QMenuBar *menuBar = new QMenuBar(this); |
43 | fileMenu = new QPopupMenu( this ); | 43 | fileMenu = new QPopupMenu( this ); |
44 | viewMenu = new QPopupMenu( this ); | 44 | viewMenu = new QPopupMenu( this ); |
45 | // customDirMenu = new QPopupMenu( this ); | 45 | // customDirMenu = new QPopupMenu( this ); |
46 | 46 | ||
47 | layout->addWidget( menuBar ); | 47 | layout->addWidget( menuBar ); |
48 | 48 | ||
49 | menuBar->insertItem( tr( "File" ), fileMenu); | 49 | menuBar->insertItem( tr( "File" ), fileMenu); |
50 | menuBar->insertItem( tr( "View" ), viewMenu); | 50 | menuBar->insertItem( tr( "View" ), viewMenu); |
51 | 51 | ||
52 | cdUpButton = new QToolButton( 0,"cdUpButton"); | 52 | cdUpButton = new QToolButton( 0,"cdUpButton"); |
53 | cdUpButton->setPixmap(Resource::loadPixmap("up")); | 53 | cdUpButton->setPixmap(Resource::loadPixmap("up")); |
54 | cdUpButton->setAutoRaise( true ); | 54 | cdUpButton->setAutoRaise( true ); |
55 | menuBar->insertItem( cdUpButton ); | 55 | menuBar->insertItem( cdUpButton ); |
56 | 56 | ||
57 | 57 | ||
58 | QHBox *lineBox = new QHBox( this ); | 58 | QHBox *lineBox = new QHBox( this ); |
59 | 59 | ||
60 | qpeDirButton= new QToolButton( 0,"QPEButton"); | 60 | qpeDirButton= new QToolButton( 0,"QPEButton"); |
61 | qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); | 61 | qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); |
62 | qpeDirButton->setAutoRaise( true ); | 62 | qpeDirButton->setAutoRaise( true ); |
63 | menuBar->insertItem( qpeDirButton ); | 63 | menuBar->insertItem( qpeDirButton ); |
64 | 64 | ||
65 | cfButton = new QToolButton( 0, "CFButton"); | 65 | cfButton = new QToolButton( 0, "CFButton"); |
66 | cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); | 66 | cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); |
67 | cfButton->setAutoRaise( true ); | 67 | cfButton->setAutoRaise( true ); |
68 | menuBar->insertItem( cfButton ); | 68 | menuBar->insertItem( cfButton ); |
69 | 69 | ||
70 | sdButton = new QToolButton( 0, "SDButton"); | 70 | sdButton = new QToolButton( 0, "SDButton"); |
71 | sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard")); | 71 | sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard")); |
72 | sdButton->setAutoRaise( true ); | 72 | sdButton->setAutoRaise( true ); |
73 | menuBar->insertItem( sdButton ); | 73 | menuBar->insertItem( sdButton ); |
74 | 74 | ||
75 | docButton = new QToolButton( 0,"docsButton"); | 75 | docButton = new QToolButton( 0,"docsButton"); |
76 | docButton->setPixmap(Resource::loadPixmap("DocsIcon")); | 76 | docButton->setPixmap(Resource::loadPixmap("DocsIcon")); |
77 | docButton->setAutoRaise( true ); | 77 | docButton->setAutoRaise( true ); |
78 | menuBar->insertItem( docButton ); | 78 | menuBar->insertItem( docButton ); |
79 | 79 | ||
80 | homeButton = new QToolButton( 0, "homeButton"); | 80 | homeButton = new QToolButton( 0, "homeButton"); |
81 | homeButton->setPixmap(Resource::loadPixmap("home")); | 81 | homeButton->setPixmap(Resource::loadPixmap("home")); |
82 | homeButton->setAutoRaise( true ); | 82 | homeButton->setAutoRaise( true ); |
83 | menuBar->insertItem( homeButton ); | 83 | menuBar->insertItem( homeButton ); |
84 | 84 | ||
85 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); | 85 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); |
86 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 86 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
87 | fileMenu->insertSeparator(); | 87 | fileMenu->insertSeparator(); |
88 | fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() )); | 88 | fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() )); |
89 | fileMenu->insertSeparator(); | 89 | fileMenu->insertSeparator(); |
90 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); | 90 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); |
91 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); | 91 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); |
92 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); | 92 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); |
93 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); | 93 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); |
94 | fileMenu->insertSeparator(); | 94 | fileMenu->insertSeparator(); |
95 | fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 95 | fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
96 | fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() )); | 96 | fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() )); |
97 | fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 97 | fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
98 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); | 98 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); |
99 | fileMenu->setCheckable(TRUE); | 99 | fileMenu->setCheckable(TRUE); |
100 | 100 | ||
101 | viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 101 | viewMenu->insertItem( tr( "Switch to View 1" ), this, SLOT( switchToLocalTab())); |
102 | viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 102 | viewMenu->insertItem( tr( "Switch to View 2" ), this, SLOT( switchToRemoteTab())); |
103 | // viewMenu->insertSeparator(); | 103 | // viewMenu->insertSeparator(); |
104 | // viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); | 104 | // viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); |
105 | viewMenu->setCheckable(TRUE); | 105 | viewMenu->setCheckable(true); |
106 | viewMenu->setItemChecked( viewMenu->idAt(0), true); | ||
107 | viewMenu->setItemChecked( viewMenu->idAt(1), false); | ||
106 | 108 | ||
107 | s_addBookmark = tr("Bookmark Directory"); | 109 | s_addBookmark = tr("Bookmark Directory"); |
108 | s_removeBookmark = tr("Remove Current Directory from Bookmarks"); | 110 | s_removeBookmark = tr("Remove Current Directory from Bookmarks"); |
109 | 111 | ||
110 | // menuButton->insertItem(""); | 112 | // menuButton->insertItem(""); |
111 | 113 | ||
112 | // customDirMenu->insertItem(tr("Add This Directory")); | 114 | // customDirMenu->insertItem(tr("Add This Directory")); |
113 | // customDirMenu->insertItem(tr("Remove This Directory")); | 115 | // customDirMenu->insertItem(tr("Remove This Directory")); |
114 | // customDirMenu->insertSeparator(); | 116 | // customDirMenu->insertSeparator(); |
115 | 117 | ||
116 | menuButton = new MenuButton( lineBox ); | 118 | menuButton = new MenuButton( lineBox ); |
117 | 119 | ||
118 | menuButton->setUseLabel(false); | 120 | menuButton->setUseLabel(false); |
119 | menuButton->setMaximumWidth( 20 ); | 121 | menuButton->setMaximumWidth( 20 ); |
120 | menuButton->insertItem( s_addBookmark); | 122 | menuButton->insertItem( s_addBookmark); |
121 | menuButton->insertItem( s_removeBookmark); | 123 | menuButton->insertItem( s_removeBookmark); |
122 | menuButton->insertSeparator(); | 124 | menuButton->insertSeparator(); |
125 | menuButton->setFocusPolicy(NoFocus); | ||
123 | 126 | ||
124 | customDirsToMenu(); | 127 | customDirsToMenu(); |
125 | 128 | ||
126 | currentPathCombo = new QComboBox( FALSE, lineBox, "currentPathCombo" ); | 129 | currentPathCombo = new QComboBox( FALSE, lineBox, "currentPathCombo" ); |
127 | currentPathCombo->setEditable(TRUE); | 130 | currentPathCombo->setEditable(TRUE); |
128 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 131 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
129 | 132 | currentPathCombo->setFocusPolicy(NoFocus); | |
130 | layout->addWidget( lineBox ); | 133 | layout->addWidget( lineBox ); |
131 | 134 | ||
132 | 135 | ||
133 | TabWidget = new OSplitter( Horizontal, this, "TabWidget" ); | 136 | TabWidget = new OSplitter( Horizontal, this, "TabWidget" ); |
134 | // TabWidget = new QTabWidget( this, "TabWidget" ); | 137 | // TabWidget = new QTabWidget( this, "TabWidget" ); |
135 | layout->addWidget( TabWidget, 4 ); | 138 | layout->addWidget( TabWidget, 4 ); |
136 | 139 | ||
137 | tab = new QWidget( TabWidget, "tab" ); | 140 | tab = new QWidget( TabWidget, "tab" ); |
138 | tabLayout = new QGridLayout( tab ); | 141 | tabLayout = new QGridLayout( tab ); |
139 | tabLayout->setSpacing( 2); | 142 | tabLayout->setSpacing( 2); |
140 | tabLayout->setMargin( 2); | 143 | tabLayout->setMargin( 2); |
141 | 144 | ||
142 | Local_View = new QListView( tab, "Local_View" ); | 145 | Local_View = new QListView( tab, "Local_View" ); |
143 | Local_View->addColumn( tr("File"),130); | 146 | Local_View->addColumn( tr("File"),130); |
144 | Local_View->addColumn( tr("Size"),-1); | 147 | Local_View->addColumn( tr("Size"),-1); |
145 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 148 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
146 | Local_View->addColumn( tr("Date"),-1); | 149 | Local_View->addColumn( tr("Date"),-1); |
147 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 150 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
148 | Local_View->setAllColumnsShowFocus(TRUE); | 151 | Local_View->setAllColumnsShowFocus(TRUE); |
149 | Local_View->setMultiSelection( TRUE ); | 152 | Local_View->setMultiSelection( TRUE ); |
150 | Local_View->setSelectionMode(QListView::Extended); | 153 | Local_View->setSelectionMode(QListView::Extended); |
151 | 154 | Local_View->setFocusPolicy(StrongFocus); | |
155 | Local_View->installEventFilter( this ); | ||
156 | |||
152 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 157 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
153 | 158 | ||
154 | tabLayout->addWidget( Local_View, 0, 0 ); | 159 | tabLayout->addWidget( Local_View, 0, 0 ); |
155 | 160 | ||
156 | TabWidget->addWidget( tab,"advancedfm/smFileBrowser.png", tr("1")); | 161 | TabWidget->addWidget( tab,"advancedfm/smFileBrowser.png", tr("1")); |
157 | // TabWidget->insertTab( tab, tr("1")); | 162 | // TabWidget->insertTab( tab, tr("1")); |
158 | 163 | ||
159 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 164 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
160 | tabLayout_2 = new QGridLayout( tab_2 ); | 165 | tabLayout_2 = new QGridLayout( tab_2 ); |
161 | tabLayout_2->setSpacing( 2); | 166 | tabLayout_2->setSpacing( 2); |
162 | tabLayout_2->setMargin( 2); | 167 | tabLayout_2->setMargin( 2); |
163 | 168 | ||
164 | Remote_View = new QListView( tab_2, "Remote_View" ); | 169 | Remote_View = new QListView( tab_2, "Remote_View" ); |
165 | Remote_View->addColumn( tr("File"),130); | 170 | Remote_View->addColumn( tr("File"),130); |
166 | Remote_View->addColumn( tr("Size"),-1); | 171 | Remote_View->addColumn( tr("Size"),-1); |
167 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 172 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
168 | Remote_View->addColumn( tr("Date"),-1); | 173 | Remote_View->addColumn( tr("Date"),-1); |
169 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 174 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
170 | Remote_View->setAllColumnsShowFocus(TRUE); | 175 | Remote_View->setAllColumnsShowFocus(TRUE); |
171 | Remote_View->setMultiSelection( TRUE ); | 176 | Remote_View->setMultiSelection( TRUE ); |
172 | Remote_View->setSelectionMode(QListView::Extended); | 177 | Remote_View->setSelectionMode(QListView::Extended); |
173 | 178 | Remote_View->setFocusPolicy(StrongFocus); | |
174 | 179 | Remote_View->installEventFilter( this ); | |
180 | |||
175 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 181 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
176 | 182 | ||
177 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 183 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
178 | 184 | ||
179 | TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); | 185 | TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); |
180 | TabWidget->setSizeChange( 370 ); | 186 | TabWidget->setSizeChange( 370 ); |
181 | // TabWidget->insertTab( tab_2, tr( "2")); | 187 | // TabWidget->insertTab( tab_2, tr( "2")); |
182 | 188 | ||
183 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); | 189 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); |
184 | tabLayout_3 = new QGridLayout( tab_3 ); | 190 | tabLayout_3 = new QGridLayout( tab_3 ); |
185 | tabLayout_3->setSpacing( 2); | 191 | tabLayout_3->setSpacing( 2); |
186 | tabLayout_3->setMargin( 2); | 192 | tabLayout_3->setMargin( 2); |
187 | 193 | ||
188 | 194 | ||
189 | // OFileDialog fileDialog; | 195 | // OFileDialog fileDialog; |
190 | // fileDialog; | 196 | // fileDialog; |
191 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy | 197 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy |
192 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); | 198 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); |
193 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); | 199 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); |
194 | 200 | ||
195 | QListView *fileTree; | 201 | QListView *fileTree; |
196 | fileTree = new QListView( tab_3, "tree" ); | 202 | fileTree = new QListView( tab_3, "tree" ); |
197 | 203 | ||
198 | 204 | ||
199 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); | 205 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); |
200 | 206 | ||
201 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); | 207 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); |
202 | */ | 208 | */ |
203 | 209 | ||
204 | /////////////// | 210 | /////////////// |
205 | 211 | ||
206 | 212 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | |
207 | struct utsname name; /* check for embedix kernel running on the zaurus*/ | ||
208 | if (uname(&name) != -1) { | ||
209 | QString release=name.release; | ||
210 | if(release.find("embedix",0,TRUE) !=-1) { | ||
211 | zaurusDevice=TRUE; | 213 | zaurusDevice=TRUE; |
212 | } else { | 214 | else |
213 | zaurusDevice=FALSE; | 215 | zaurusDevice=FALSE; |
214 | } | 216 | |
215 | } | ||
216 | 217 | ||
217 | if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) { | 218 | if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) { |
218 | qDebug("not have sd"); | 219 | qDebug("not have sd"); |
219 | sdButton->hide(); | 220 | sdButton->hide(); |
220 | } | 221 | } |
221 | if( !StorageInfo::hasCf() ) { | 222 | if( !StorageInfo::hasCf() ) { |
222 | qDebug("not have cf"); | 223 | qDebug("not have cf"); |
223 | cfButton->hide(); | 224 | cfButton->hide(); |
224 | } | 225 | } |
225 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 226 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
226 | currentDir.setPath( QDir::currentDirPath()); | 227 | currentDir.setPath( QDir::currentDirPath()); |
227 | 228 | ||
228 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 229 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
229 | currentRemoteDir.setPath( QDir::currentDirPath()); | 230 | currentRemoteDir.setPath( QDir::currentDirPath()); |
230 | 231 | ||
231 | // b = TRUE; | 232 | // b = TRUE; |
232 | 233 | ||
233 | filterStr="*"; | 234 | filterStr="*"; |
234 | b=FALSE; | 235 | b=FALSE; |
235 | showMenuHidden(); | 236 | showMenuHidden(); |
236 | TabWidget->setCurrentWidget(0); | 237 | TabWidget->setCurrentWidget(0); |
237 | 238 | ||
238 | } | 239 | } |
239 | 240 | ||
240 | void AdvancedFm::initConnections() | 241 | void AdvancedFm::initConnections() |
241 | { | 242 | { |
242 | 243 | ||
243 | connect( qApp,SIGNAL( aboutToQuit()), | 244 | connect( qApp,SIGNAL( aboutToQuit()), |
244 | this, SLOT( cleanUp()) ); | 245 | this, SLOT( cleanUp()) ); |
245 | connect( qpeDirButton ,SIGNAL(released()), | 246 | connect( qpeDirButton ,SIGNAL(released()), |
246 | this,SLOT( QPEButtonPushed()) ); | 247 | this,SLOT( QPEButtonPushed()) ); |
247 | connect( cfButton ,SIGNAL(released()), | 248 | connect( cfButton ,SIGNAL(released()), |
248 | this,SLOT( CFButtonPushed()) ); | 249 | this,SLOT( CFButtonPushed()) ); |
249 | connect( sdButton ,SIGNAL(released()), | 250 | connect( sdButton ,SIGNAL(released()), |
250 | this,SLOT( SDButtonPushed()) ); | 251 | this,SLOT( SDButtonPushed()) ); |
251 | connect( cdUpButton ,SIGNAL(released()), | 252 | connect( cdUpButton ,SIGNAL(released()), |
252 | this,SLOT( upDir()) ); | 253 | this,SLOT( upDir()) ); |
253 | connect( docButton,SIGNAL(released()), | 254 | connect( docButton,SIGNAL(released()), |
254 | this,SLOT( docButtonPushed()) ); | 255 | this,SLOT( docButtonPushed()) ); |
255 | connect( homeButton,SIGNAL(released()), | 256 | connect( homeButton,SIGNAL(released()), |
256 | this,SLOT( homeButtonPushed()) ); | 257 | this,SLOT( homeButtonPushed()) ); |
257 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 258 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
258 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 259 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
259 | 260 | ||
260 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 261 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
261 | this,SLOT(currentPathComboChanged())); | 262 | this,SLOT(currentPathComboChanged())); |
262 | 263 | ||
263 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 264 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
264 | this,SLOT( ListClicked(QListViewItem *)) ); | 265 | this,SLOT( ListClicked(QListViewItem *)) ); |
265 | 266 | ||
266 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 267 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
267 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 268 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
268 | 269 | ||
269 | connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); | 270 | connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); |
270 | 271 | ||
271 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 272 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
272 | this,SLOT( ListClicked(QListViewItem *)) ); | 273 | this,SLOT( ListClicked(QListViewItem *)) ); |
273 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 274 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
274 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 275 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
275 | 276 | ||
276 | connect( TabWidget,SIGNAL(currentChanged(QWidget *)), | 277 | connect( TabWidget,SIGNAL(currentChanged(QWidget *)), |
277 | this,SLOT(tabChanged(QWidget*))); | 278 | this,SLOT(tabChanged(QWidget*))); |
278 | 279 | ||
279 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); | 280 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); |
280 | 281 | ||
281 | connect( menuButton, SIGNAL( selected(const QString &)), SLOT(gotoCustomDir(const QString&))); | 282 | connect( menuButton, SIGNAL( selected(const QString &)), SLOT(gotoCustomDir(const QString&))); |
282 | // connect( menuButton, SIGNAL( selected( int)), SLOT( dirMenuSelected(int))); | 283 | // connect( menuButton, SIGNAL( selected( int)), SLOT( dirMenuSelected(int))); |
283 | 284 | connect( viewMenu, SIGNAL( activated(int )), this, SLOT(slotSwitchMenu(int ))); | |
284 | // connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int))); | 285 | // connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int))); |
285 | 286 | ||
286 | } | 287 | } |
288 | |||
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 544350c..c0be948 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,881 +1,802 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | #include "output.h" | 13 | #include "output.h" |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <opie/otabwidget.h> | 16 | #include <opie/otabwidget.h> |
17 | #include <opie/oprocess.h> | 17 | #include <opie/oprocess.h> |
18 | 18 | ||
19 | #include <qpe/lnkproperties.h> | 19 | #include <qpe/lnkproperties.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/applnk.h> | 23 | #include <qpe/applnk.h> |
24 | #include <qpe/ir.h> | 24 | #include <qpe/ir.h> |
25 | 25 | ||
26 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
27 | #include <qmultilineedit.h> | 27 | #include <qmultilineedit.h> |
28 | 28 | ||
29 | #include <qstring.h> | 29 | #include <qstring.h> |
30 | 30 | ||
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | #include <qpixmap.h> | 32 | #include <qpixmap.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtabwidget.h> | 35 | #include <qtabwidget.h> |
36 | #include <qtoolbutton.h> | 36 | #include <qtoolbutton.h> |
37 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
38 | #include <qlistview.h> | 38 | #include <qlistview.h> |
39 | 39 | ||
40 | #include <errno.h> | 40 | #include <errno.h> |
41 | #include <stdlib.h> | 41 | #include <stdlib.h> |
42 | #include <unistd.h> | 42 | #include <unistd.h> |
43 | #include <sys/stat.h> | 43 | #include <sys/stat.h> |
44 | #include <dirent.h> | 44 | #include <dirent.h> |
45 | #include <sys/sendfile.h> | 45 | #include <sys/sendfile.h> |
46 | #include <fcntl.h> | 46 | #include <fcntl.h> |
47 | 47 | ||
48 | 48 | ||
49 | void AdvancedFm::doDirChange() | 49 | void AdvancedFm::doDirChange() { |
50 | { | 50 | QString pathItem = CurrentView()->currentItem()->text(0); |
51 | ListClicked( CurrentView()->currentItem()); | 51 | if( pathItem == "../") { |
52 | ListClicked( CurrentView()->currentItem()); | ||
53 | } else { | ||
54 | if( pathItem.find(" -> ",0,TRUE) != -1) | ||
55 | pathItem = dealWithSymName((const QString&)pathItem)+"/"; | ||
56 | // qWarning(pathItem); | ||
57 | gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); | ||
58 | } | ||
52 | } | 59 | } |
53 | 60 | ||
54 | void AdvancedFm::showMenuHidden() | 61 | void AdvancedFm::showMenuHidden() { |
55 | { | 62 | if (b) { |
56 | if (b) | ||
57 | { | ||
58 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 63 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
59 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 64 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
60 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 65 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
61 | // b=FALSE; | 66 | } else { |
62 | |||
63 | } | ||
64 | else | ||
65 | { | ||
66 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 67 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
67 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 68 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
68 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 69 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
69 | // b=TRUE; | ||
70 | } | 70 | } |
71 | rePopulate(); | 71 | rePopulate(); |
72 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); | ||
73 | b = !b; | 72 | b = !b; |
74 | } | 73 | } |
75 | 74 | ||
76 | void AdvancedFm::showHidden() | 75 | void AdvancedFm::showHidden() { |
77 | { | 76 | if (b) { |
78 | if (b) | ||
79 | { | ||
80 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 77 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
81 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 78 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
82 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 79 | } else { |
83 | // b=FALSE; | ||
84 | |||
85 | } | ||
86 | else | ||
87 | { | ||
88 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 80 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
89 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 81 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
90 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | ||
91 | // b=TRUE; | ||
92 | } | 82 | } |
93 | rePopulate(); | 83 | rePopulate(); |
94 | } | 84 | } |
95 | 85 | ||
96 | QString AdvancedFm::dealWithSymName(const QString &fileName) | 86 | QString AdvancedFm::dealWithSymName(const QString &fileName) { |
97 | { | 87 | QString strItem = fileName; |
98 | QString strItem = fileName; | 88 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
99 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | ||
100 | } | 89 | } |
101 | 90 | ||
102 | void AdvancedFm::runThis() | 91 | void AdvancedFm::runThis() { |
103 | { | 92 | if( !CurrentView()->currentItem()) return; |
104 | QString fs; | 93 | QString fs; |
105 | QDir *thisDir = CurrentDir(); | 94 | QDir *thisDir = CurrentDir(); |
106 | 95 | ||
107 | QString curFile = CurrentView()->currentItem()->text(0); | 96 | QString curFile = CurrentView()->currentItem()->text(0); |
108 | QString path = thisDir->canonicalPath(); | 97 | QString path = thisDir->canonicalPath(); |
109 | 98 | ||
110 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 99 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
111 | 100 | ||
112 | curFile = dealWithSymName((const QString&)curFile); | 101 | curFile = dealWithSymName((const QString&)curFile); |
113 | 102 | ||
114 | if(curFile != "../") | 103 | if(curFile != "../") { |
115 | { | ||
116 | 104 | ||
117 | fs = getFileSystemType((const QString &) path); | 105 | fs = getFileSystemType((const QString &) path); |
118 | QFileInfo fileInfo( path + "/" + curFile); | 106 | QFileInfo fileInfo( path + "/" + curFile); |
119 | qDebug( fileInfo.owner()); | 107 | // qDebug( fileInfo.owner()); |
120 | 108 | ||
121 | if( (fileInfo.permission( QFileInfo::ExeUser) | 109 | if( (fileInfo.permission( QFileInfo::ExeUser) |
122 | | fileInfo.permission( QFileInfo::ExeGroup) | 110 | | fileInfo.permission( QFileInfo::ExeGroup) |
123 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 111 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
124 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 112 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
125 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 113 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
126 | e << curFile; | 114 | e << curFile; |
127 | } | 115 | } else { |
128 | else | ||
129 | { | ||
130 | curFile = path + "/" + curFile; | 116 | curFile = path + "/" + curFile; |
131 | DocLnk nf(curFile); | 117 | DocLnk nf(curFile); |
132 | QString execStr = nf.exec(); | 118 | QString execStr = nf.exec(); |
133 | qDebug( execStr); | 119 | // qDebug( execStr); |
134 | if( execStr.isEmpty() ) | 120 | if( execStr.isEmpty() ) { |
135 | { | 121 | } else { |
136 | } | ||
137 | else | ||
138 | { | ||
139 | nf.execute(); | 122 | nf.execute(); |
140 | } | 123 | } |
141 | } | 124 | } |
142 | } | 125 | } |
143 | } | 126 | } |
144 | 127 | ||
145 | void AdvancedFm::runText() | 128 | void AdvancedFm::runText() { |
146 | { | 129 | if( !CurrentView()->currentItem()) return; |
147 | QString curFile = CurrentView()->currentItem()->text(0); | 130 | QString curFile = CurrentView()->currentItem()->text(0); |
148 | if(curFile != "../") | 131 | if(curFile != "../") { |
149 | { | ||
150 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 132 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
151 | curFile = dealWithSymName((const QString&)curFile); | 133 | curFile = dealWithSymName((const QString&)curFile); |
152 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; | 134 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; |
153 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 135 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
154 | e << curFile; | 136 | e << curFile; |
155 | } | 137 | } |
156 | } | 138 | } |
157 | 139 | ||
158 | void AdvancedFm::makeDir() | 140 | void AdvancedFm::makeDir() { |
159 | { | ||
160 | InputDialog *fileDlg; | 141 | InputDialog *fileDlg; |
161 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 142 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
162 | fileDlg->exec(); | 143 | fileDlg->exec(); |
163 | if( fileDlg->result() == 1 ) | 144 | if( fileDlg->result() == 1 ) { |
164 | { | ||
165 | QDir *thisDir = CurrentDir(); | 145 | QDir *thisDir = CurrentDir(); |
166 | QString filename = fileDlg->LineEdit1->text(); | 146 | QString filename = fileDlg->LineEdit1->text(); |
167 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 147 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
168 | } | 148 | } |
169 | populateView(); | 149 | populateView(); |
170 | } | 150 | } |
171 | 151 | ||
172 | void AdvancedFm::doDelete() | 152 | void AdvancedFm::doDelete() { |
173 | { | ||
174 | QStringList curFileList = getPath(); | 153 | QStringList curFileList = getPath(); |
175 | bool doMsg=true; | 154 | bool doMsg=true; |
176 | int count = curFileList.count(); | 155 | int count = curFileList.count(); |
177 | if( count > 0) { | 156 | if( count > 0) { |
178 | if(count > 1 ) { | 157 | if(count > 1 ) { |
179 | QString msg; | 158 | QString msg; |
180 | msg=tr("Really delete\n%1 files?").arg(count); | 159 | msg=tr("Really delete\n%1 files?").arg(count); |
181 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 160 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
182 | ,tr("Yes"),tr("No"),0,0,1) ) | 161 | ,tr("Yes"),tr("No"),0,0,1) ) |
183 | { | 162 | { |
184 | case 0: | 163 | case 0: |
185 | doMsg=false; | 164 | doMsg=false; |
186 | break; | 165 | break; |
187 | case 1: | 166 | case 1: |
188 | return; | 167 | return; |
189 | break; | 168 | break; |
190 | }; | 169 | }; |
191 | } | 170 | } |
192 | 171 | ||
193 | QString myFile; | 172 | QString myFile; |
194 | 173 | ||
195 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 174 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
196 | myFile = (*it); | 175 | myFile = (*it); |
197 | if( myFile.find(" -> ",0,TRUE) != -1) | 176 | if( myFile.find(" -> ",0,TRUE) != -1) |
198 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 177 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
199 | 178 | ||
200 | QString f = CurrentDir()->canonicalPath(); | 179 | QString f = CurrentDir()->canonicalPath(); |
201 | if(f.right(1).find("/",0,TRUE) == -1) | 180 | if(f.right(1).find("/",0,TRUE) == -1) |
202 | f += "/"; | 181 | f += "/"; |
203 | f += myFile; | 182 | f += myFile; |
204 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 183 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
205 | //if file is a directory | 184 | //if file is a directory |
206 | 185 | ||
207 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), | 186 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), |
208 | tr("Really delete %1\nand all it's contents ?" ).arg( f ) , | 187 | tr("Really delete %1\nand all it's contents ?" ).arg( f ) , |
209 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 188 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
210 | case 0: | 189 | case 0: |
211 | { | 190 | { |
212 | f=f.left(f.length()-1); | 191 | f=f.left(f.length()-1); |
213 | QString cmd="rm -rf "+f; | 192 | QString cmd="rm -rf "+f; |
214 | startProcess( (const QString)cmd.latin1() ); | 193 | startProcess( (const QString)cmd.latin1() ); |
215 | populateView(); | 194 | populateView(); |
216 | } | 195 | } |
217 | break; | 196 | break; |
218 | case 1: | 197 | case 1: |
219 | // exit | 198 | // exit |
220 | break; | 199 | break; |
221 | }; | 200 | }; |
222 | 201 | ||
223 | } else { | 202 | } else { |
224 | if(doMsg) { | 203 | if(doMsg) { |
225 | switch ( QMessageBox::warning(this,tr("Delete"), | 204 | switch ( QMessageBox::warning(this,tr("Delete"), |
226 | tr("Really delete\n%1?").arg( myFile ), | 205 | tr("Really delete\n%1?").arg( myFile ), |
227 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 206 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
228 | case 1: | 207 | case 1: |
229 | return; | 208 | return; |
230 | break; | 209 | break; |
231 | }; | 210 | }; |
232 | } | 211 | } |
233 | 212 | ||
234 | QString cmd="rm "+f; | 213 | QString cmd="rm "+f; |
235 | QFile file(f); | 214 | QFile file(f); |
236 | QFileInfo fi(myFile); | 215 | QFileInfo fi(myFile); |
237 | if( fi.fileName().find("../",0,TRUE)==-1) { | 216 | if( fi.fileName().find("../",0,TRUE)==-1) { |
238 | qDebug("remove link files "+myFile); | 217 | // qDebug("remove link files "+myFile); |
239 | 218 | ||
240 | // DocLnk lnk(f); | 219 | // DocLnk lnk(f); |
241 | DocLnk *lnk; | 220 | DocLnk *lnk; |
242 | lnk = new DocLnk(f); | 221 | lnk = new DocLnk(f); |
243 | qDebug("Deleting doclnk " + lnk->linkFile()); | 222 | // qDebug("Deleting doclnk " + lnk->linkFile()); |
244 | if(lnk->isValid()) | 223 | if(lnk->isValid()) |
245 | lnk->removeLinkFile(); | 224 | lnk->removeLinkFile(); |
246 | // delete lnk; | 225 | // delete lnk; |
247 | file.remove(); | 226 | file.remove(); |
248 | } | 227 | } |
249 | } | 228 | } |
250 | } | 229 | } |
251 | } | 230 | } |
252 | populateView(); | 231 | populateView(); |
253 | } | 232 | } |
254 | 233 | ||
255 | void AdvancedFm::filePerms() | 234 | void AdvancedFm::filePerms() { |
256 | { | 235 | QStringList curFileList = getPath(); |
257 | QStringList curFileList = getPath(); | 236 | QString filePath; |
258 | QString filePath; | ||
259 | 237 | ||
260 | filePath = CurrentDir()->canonicalPath()+"/"; | 238 | filePath = CurrentDir()->canonicalPath()+"/"; |
261 | 239 | ||
262 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 240 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
263 | { | ||
264 | filePermissions *filePerm; | 241 | filePermissions *filePerm; |
265 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 242 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
266 | filePerm->showMaximized(); | 243 | filePerm->showMaximized(); |
267 | filePerm->exec(); | 244 | filePerm->exec(); |
268 | if( filePerm) | 245 | if( filePerm) |
269 | delete filePerm; | 246 | delete filePerm; |
270 | } | 247 | } |
271 | populateView(); | 248 | populateView(); |
272 | } | 249 | } |
273 | 250 | ||
274 | void AdvancedFm::doProperties() | 251 | void AdvancedFm::doProperties() { |
275 | { | ||
276 | #if defined(QT_QWS_OPIE) | 252 | #if defined(QT_QWS_OPIE) |
277 | 253 | ||
278 | QStringList curFileList = getPath(); | 254 | QStringList curFileList = getPath(); |
279 | 255 | ||
280 | QString filePath; | 256 | QString filePath; |
281 | filePath = CurrentDir()->canonicalPath()+"/"; | 257 | filePath = CurrentDir()->canonicalPath()+"/"; |
282 | 258 | ||
283 | qDebug("%d",curFileList.count()); | 259 | // qDebug("%d",curFileList.count()); |
284 | 260 | ||
285 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 261 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
286 | { | 262 | // qDebug((filePath+*it)); |
287 | qDebug((filePath+*it)); | 263 | DocLnk lnk( (filePath+*it)); |
288 | DocLnk lnk( (filePath+*it)); | 264 | LnkProperties prop( &lnk ); |
289 | LnkProperties prop( &lnk ); | 265 | prop.showMaximized(); |
290 | prop.showMaximized(); | 266 | prop.exec(); |
291 | prop.exec(); | 267 | } |
292 | } | ||
293 | #endif | 268 | #endif |
294 | 269 | ||
295 | } | 270 | } |
296 | 271 | ||
297 | void AdvancedFm::upDir() | 272 | void AdvancedFm::upDir() { |
298 | { | ||
299 | QDir *thisDir = CurrentDir(); | 273 | QDir *thisDir = CurrentDir(); |
300 | QString current = thisDir->canonicalPath(); | 274 | QString current = thisDir->canonicalPath(); |
301 | QDir dir(current); | 275 | QDir dir(current); |
302 | dir.cdUp(); | 276 | dir.cdUp(); |
303 | current = dir.canonicalPath(); | 277 | current = dir.canonicalPath(); |
304 | chdir( current.latin1() ); | 278 | chdir( current.latin1() ); |
305 | thisDir->cd( current, TRUE); | 279 | thisDir->cd( current, TRUE); |
306 | 280 | ||
307 | populateView(); | 281 | populateView(); |
308 | update(); | 282 | update(); |
309 | } | 283 | } |
310 | 284 | ||
311 | void AdvancedFm::copy() | 285 | void AdvancedFm::copy() { |
312 | { | 286 | qApp->processEvents(); |
313 | qApp->processEvents(); | 287 | QStringList curFileList = getPath(); |
314 | QStringList curFileList = getPath(); | ||
315 | 288 | ||
316 | QDir *thisDir = CurrentDir(); | 289 | QDir *thisDir = CurrentDir(); |
317 | QDir *thatDir = OtherDir(); | 290 | QDir *thatDir = OtherDir(); |
318 | |||
319 | bool doMsg=true; | ||
320 | int count=curFileList.count(); | ||
321 | if( count > 0) { | ||
322 | if(count > 1 ){ | ||
323 | QString msg; | ||
324 | msg=tr("Really copy\n%1 files?").arg(count); | ||
325 | switch ( QMessageBox::warning(this,tr("Copy"),msg | ||
326 | ,tr("Yes"),tr("No"),0,0,1) ) | ||
327 | { | ||
328 | case 0: | ||
329 | doMsg=false; | ||
330 | break; | ||
331 | case 1: | ||
332 | return; | ||
333 | break; | ||
334 | }; | ||
335 | } | ||
336 | 291 | ||
337 | QString curFile, item, destFile; | 292 | bool doMsg=true; |
338 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 293 | int count=curFileList.count(); |
339 | { | 294 | if( count > 0) { |
340 | item=(*it); | 295 | if(count > 1 ){ |
341 | if(item.find("->",0,TRUE)) //symlink | 296 | QString msg; |
342 | item = item.left(item.find("->",0,TRUE)); | 297 | msg=tr("Really copy\n%1 files?").arg(count); |
343 | 298 | switch ( QMessageBox::warning(this,tr("Copy"),msg | |
344 | curFile = thisDir->canonicalPath()+"/"+ item; | 299 | ,tr("Yes"),tr("No"),0,0,1) ) |
345 | destFile = thatDir->canonicalPath()+"/"+ item; | 300 | { |
346 | 301 | case 0: | |
347 | qDebug("Destination file is "+destFile); | 302 | doMsg=false; |
348 | qDebug("CurrentFile file is " + curFile); | 303 | break; |
349 | 304 | case 1: | |
350 | QFile f(destFile); | 305 | return; |
351 | if( f.exists()) | 306 | break; |
352 | { | 307 | }; |
353 | if(doMsg) | 308 | } |
354 | { | 309 | |
355 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 310 | QString curFile, item, destFile; |
356 | tr("%1 exists. Ok to overwrite?").arg( item ), | 311 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
357 | tr("Yes"),tr("No"),0,0,1) ) | 312 | item=(*it); |
358 | { | 313 | if(item.find("->",0,TRUE)) //symlink |
359 | case 1: | 314 | item = item.left(item.find("->",0,TRUE)); |
360 | return; | 315 | |
361 | break; | 316 | curFile = thisDir->canonicalPath()+"/"+ item; |
362 | }; | 317 | destFile = thatDir->canonicalPath()+"/"+ item; |
363 | } | 318 | |
319 | // qDebug("Destination file is "+destFile); | ||
320 | // qDebug("CurrentFile file is " + curFile); | ||
321 | |||
322 | QFile f(destFile); | ||
323 | if( f.exists()) { | ||
324 | if(doMsg) { | ||
325 | switch ( QMessageBox::warning(this,tr("File Exists!"), | ||
326 | tr("%1 exists. Ok to overwrite?").arg( item ), | ||
327 | tr("Yes"),tr("No"),0,0,1) ) { | ||
328 | case 1: | ||
329 | return; | ||
330 | break; | ||
331 | }; | ||
332 | } | ||
364 | f.remove(); | 333 | f.remove(); |
365 | } | 334 | } |
366 | 335 | ||
367 | if( !copyFile( curFile, destFile) ) { | 336 | if( !copyFile( curFile, destFile) ) { |
368 | QMessageBox::message("AdvancedFm", | 337 | QMessageBox::message("AdvancedFm", |
369 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 338 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); |
370 | return; | 339 | return; |
371 | } | 340 | } |
372 | } | 341 | } |
373 | setOtherTabCurrent(); | 342 | rePopulate(); |
374 | populateView(); | 343 | setOtherTabCurrent(); |
375 | } | 344 | } |
376 | } | 345 | } |
377 | 346 | ||
378 | void AdvancedFm::copyAs() | 347 | void AdvancedFm::copyAs() { |
379 | { | 348 | qApp->processEvents(); |
380 | qApp->processEvents(); | ||
381 | 349 | ||
382 | QStringList curFileList = getPath(); | 350 | QStringList curFileList = getPath(); |
383 | QString curFile, item; | 351 | QString curFile, item; |
384 | InputDialog *fileDlg; | 352 | InputDialog *fileDlg; |
385 | 353 | ||
386 | QDir *thisDir = CurrentDir(); | 354 | QDir *thisDir = CurrentDir(); |
387 | QDir *thatDir = OtherDir(); | 355 | QDir *thatDir = OtherDir(); |
388 | 356 | ||
389 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 357 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
390 | { | ||
391 | QString destFile; | 358 | QString destFile; |
392 | item=(*it); | 359 | item=(*it); |
393 | curFile = thisDir->canonicalPath()+"/"+(*it); | 360 | curFile = thisDir->canonicalPath()+"/"+(*it); |
394 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); | 361 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); |
395 | 362 | ||
396 | fileDlg->setInputText((const QString &) destFile ); | 363 | fileDlg->setInputText((const QString &) destFile ); |
397 | fileDlg->exec(); | 364 | fileDlg->exec(); |
398 | 365 | ||
399 | if( fileDlg->result() == 1 ) | 366 | if( fileDlg->result() == 1 ) { |
400 | { | 367 | QString filename = fileDlg->LineEdit1->text(); |
401 | QString filename = fileDlg->LineEdit1->text(); | 368 | destFile = thatDir->canonicalPath()+"/"+filename; |
402 | destFile = thatDir->canonicalPath()+"/"+filename; | ||
403 | 369 | ||
404 | QFile f( destFile); | 370 | QFile f( destFile); |
405 | if( f.exists()) | 371 | if( f.exists()) { |
406 | { | 372 | switch (QMessageBox::warning(this,tr("File Exists!"), |
407 | switch (QMessageBox::warning(this,tr("File Exists!"), | 373 | item+tr("\nexists. Ok to overwrite?"), |
408 | item+tr("\nexists. Ok to overwrite?"), | 374 | tr("Yes"),tr("No"),0,0,1) ) { |
409 | tr("Yes"),tr("No"),0,0,1) ) | 375 | case 0: |
410 | { | 376 | f.remove(); |
411 | case 0: | 377 | break; |
412 | f.remove(); | 378 | case 1: |
413 | break; | 379 | return; |
414 | case 1: | 380 | break; |
415 | return; | 381 | }; |
416 | break; | 382 | } |
417 | }; | 383 | if( !copyFile( curFile, destFile) ) { |
418 | } | 384 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
419 | if( !copyFile( curFile, destFile) ) { | 385 | +curFile +tr("to\n")+destFile); |
420 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 386 | return; |
421 | +curFile +tr("to\n")+destFile); | 387 | } |
422 | return; | 388 | } |
423 | } | ||
424 | } | ||
425 | delete fileDlg; | 389 | delete fileDlg; |
426 | 390 | ||
427 | } | 391 | } |
428 | setOtherTabCurrent(); | 392 | rePopulate(); |
429 | populateView(); | 393 | setOtherTabCurrent(); |
430 | } | 394 | } |
431 | 395 | ||
432 | void AdvancedFm::copySameDir() | 396 | void AdvancedFm::copySameDir() { |
433 | { | ||
434 | qApp->processEvents(); | 397 | qApp->processEvents(); |
435 | QStringList curFileList = getPath(); | 398 | QStringList curFileList = getPath(); |
436 | QString curFile, item, destFile; | 399 | QString curFile, item, destFile; |
437 | InputDialog *fileDlg; | 400 | InputDialog *fileDlg; |
438 | 401 | ||
439 | QDir *thisDir = CurrentDir(); | 402 | QDir *thisDir = CurrentDir(); |
440 | 403 | ||
441 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 404 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
442 | { | ||
443 | item=(*it); | 405 | item=(*it); |
444 | curFile = thisDir->canonicalPath()+"/"+ item; | 406 | curFile = thisDir->canonicalPath()+"/"+ item; |
445 | 407 | ||
446 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 408 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
447 | fileDlg->setInputText((const QString &) destFile ); | 409 | fileDlg->setInputText((const QString &) destFile ); |
448 | fileDlg->exec(); | 410 | fileDlg->exec(); |
449 | 411 | ||
450 | if( fileDlg->result() == 1 ) | 412 | if( fileDlg->result() == 1 ) { |
451 | { | ||
452 | 413 | ||
453 | QString filename = fileDlg->LineEdit1->text(); | 414 | QString filename = fileDlg->LineEdit1->text(); |
454 | destFile = thisDir->canonicalPath()+"/"+filename; | 415 | destFile = thisDir->canonicalPath()+"/"+filename; |
455 | 416 | ||
456 | QFile f(destFile); | 417 | QFile f(destFile); |
457 | if( f.exists()) | 418 | if( f.exists()) { |
458 | { | ||
459 | switch (QMessageBox::warning(this,tr("Delete"), | 419 | switch (QMessageBox::warning(this,tr("Delete"), |
460 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 420 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
461 | tr("Yes"),tr("No"),0,0,1) ) { | 421 | tr("Yes"),tr("No"),0,0,1) ) { |
462 | case 0: | 422 | case 0: |
463 | 423 | ||
464 | f.remove(); | 424 | f.remove(); |
465 | break; | 425 | break; |
466 | case 1: | 426 | case 1: |
467 | return; | 427 | return; |
468 | break; | 428 | break; |
469 | }; | 429 | }; |
470 | } | 430 | } |
471 | if(!copyFile( curFile,destFile) ) { | 431 | if(!copyFile( curFile,destFile) ) { |
472 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 432 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
473 | +curFile +tr("to\n")+destFile); | 433 | +curFile +tr("to\n")+destFile); |
474 | return; | 434 | return; |
475 | } | 435 | } |
476 | 436 | ||
477 | qDebug("copy "+curFile+" as "+destFile); | 437 | // qDebug("copy "+curFile+" as "+destFile); |
478 | } | 438 | } |
479 | delete fileDlg; | 439 | delete fileDlg; |
480 | } | 440 | } |
481 | populateView(); | 441 | populateView(); |
482 | } | 442 | } |
483 | 443 | ||
484 | void AdvancedFm::move() | 444 | void AdvancedFm::move() { |
485 | { | ||
486 | qApp->processEvents(); | 445 | qApp->processEvents(); |
487 | 446 | ||
488 | QStringList curFileList = getPath(); | 447 | QStringList curFileList = getPath(); |
489 | if( curFileList.count() > 0) | 448 | if( curFileList.count() > 0) { |
490 | { | ||
491 | QString curFile, destFile, item; | 449 | QString curFile, destFile, item; |
492 | 450 | ||
493 | QDir *thisDir = CurrentDir(); | 451 | QDir *thisDir = CurrentDir(); |
494 | QDir *thatDir = OtherDir(); | 452 | QDir *thatDir = OtherDir(); |
495 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 453 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
496 | { | ||
497 | item=(*it); | 454 | item=(*it); |
498 | QString destFile = thatDir->canonicalPath(); | 455 | QString destFile = thatDir->canonicalPath(); |
499 | 456 | ||
500 | if(destFile.right(1).find("/",0,TRUE) == -1) | 457 | if(destFile.right(1).find("/",0,TRUE) == -1) |
501 | destFile+="/"; | 458 | destFile+="/"; |
502 | destFile += item; | 459 | destFile += item; |
503 | qDebug("Destination file is "+destFile); | 460 | // qDebug("Destination file is "+destFile); |
504 | 461 | ||
505 | curFile = thisDir->canonicalPath(); | 462 | curFile = thisDir->canonicalPath(); |
506 | if(curFile.right(1).find("/",0,TRUE) == -1) | 463 | if(curFile.right(1).find("/",0,TRUE) == -1) |
507 | curFile +="/"; | 464 | curFile +="/"; |
508 | curFile+= item; | 465 | curFile+= item; |
509 | qDebug("CurrentFile file is " + curFile); | 466 | // qDebug("CurrentFile file is " + curFile); |
510 | 467 | ||
511 | QFile f( curFile); | 468 | QFile f( curFile); |
512 | if( f.exists()) { | 469 | if( f.exists()) { |
513 | if( !copyFile( curFile, destFile) ) { | 470 | if( !copyFile( curFile, destFile) ) { |
514 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 471 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
515 | return; | 472 | return; |
516 | } else | 473 | } else |
517 | QFile::remove(curFile); | 474 | QFile::remove(curFile); |
518 | } | 475 | } |
519 | } | 476 | } |
520 | 477 | ||
521 | } | 478 | } |
522 | populateView(); | 479 | rePopulate(); |
523 | setOtherTabCurrent(); | 480 | setOtherTabCurrent(); |
524 | populateView(); | ||
525 | } | 481 | } |
526 | 482 | ||
527 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | 483 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
528 | { | ||
529 | bool success = true; | 484 | bool success = true; |
530 | struct stat status; | 485 | struct stat status; |
531 | QFile srcFile(src); | 486 | QFile srcFile(src); |
532 | QFile destFile(dest); | 487 | QFile destFile(dest); |
533 | int err=0; | 488 | int err=0; |
534 | int read_fd=0; | 489 | int read_fd=0; |
535 | int write_fd=0; | 490 | int write_fd=0; |
536 | struct stat stat_buf; | 491 | struct stat stat_buf; |
537 | off_t offset = 0; | 492 | off_t offset = 0; |
538 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | 493 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
539 | qWarning("open failed"); | 494 | // qWarning("open failed"); |
540 | return success = false; | 495 | return success = false; |
541 | } | 496 | } |
542 | read_fd = srcFile.handle(); | 497 | read_fd = srcFile.handle(); |
543 | if(read_fd != -1) { | 498 | if(read_fd != -1) { |
544 | fstat (read_fd, &stat_buf); | 499 | fstat (read_fd, &stat_buf); |
545 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { | 500 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { |
546 | qWarning("destfile open failed"); | 501 | // qWarning("destfile open failed"); |
547 | return success = false; | 502 | return success = false; |
548 | } | 503 | } |
549 | write_fd = destFile.handle(); | 504 | write_fd = destFile.handle(); |
550 | if(write_fd != -1) { | 505 | if(write_fd != -1) { |
551 | err =sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 506 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
552 | if( err == -1) { | 507 | if( err == -1) { |
553 | QString msg; | 508 | QString msg; |
554 | switch(err) { | 509 | switch(err) { |
555 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; | 510 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; |
556 | case EINVAL: msg = "Descriptor is not valid or locked. "; | 511 | case EINVAL: msg = "Descriptor is not valid or locked. "; |
557 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; | 512 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; |
558 | case EIO: msg = "Unspecified error while reading from in_fd."; | 513 | case EIO: msg = "Unspecified error while reading from in_fd."; |
559 | }; | 514 | }; |
560 | success = false; | 515 | success = false; |
561 | qWarning(msg); | 516 | // qWarning(msg); |
562 | } | 517 | } |
563 | } else { | 518 | } else { |
564 | success = false; | 519 | success = false; |
565 | } | 520 | } |
566 | } else { | 521 | } else { |
567 | success = false; | 522 | success = false; |
568 | } | 523 | } |
569 | srcFile.close(); | 524 | srcFile.close(); |
570 | destFile.close(); | 525 | destFile.close(); |
571 | // Set file permissions | 526 | // Set file permissions |
572 | if( stat( (const char *) src, &status ) == 0 ) { | 527 | if( stat( (const char *) src, &status ) == 0 ) { |
573 | chmod( (const char *) dest, status.st_mode ); | 528 | chmod( (const char *) dest, status.st_mode ); |
574 | } | 529 | } |
575 | 530 | ||
576 | return success; | 531 | return success; |
577 | } | 532 | } |
578 | 533 | ||
579 | void AdvancedFm::runCommand() | 534 | void AdvancedFm::runCommand() { |
580 | { | 535 | if( !CurrentView()->currentItem()) return; |
581 | QDir *thisDir = CurrentDir(); | 536 | QDir *thisDir = CurrentDir(); |
582 | 537 | ||
583 | QString curFile; | 538 | QString curFile; |
584 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 539 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
585 | 540 | ||
586 | InputDialog *fileDlg; | 541 | InputDialog *fileDlg; |
587 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 542 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
588 | fileDlg->setInputText(curFile); | 543 | fileDlg->setInputText(curFile); |
589 | fileDlg->exec(); | 544 | fileDlg->exec(); |
590 | //QString command; | 545 | //QString command; |
591 | 546 | ||
592 | if( fileDlg->result() == 1 ) | 547 | if( fileDlg->result() == 1 ) { |
593 | { | 548 | // qDebug(fileDlg->LineEdit1->text()); |
594 | qDebug(fileDlg->LineEdit1->text()); | ||
595 | QStringList command; | 549 | QStringList command; |
596 | 550 | ||
597 | command << "/bin/sh"; | 551 | command << "/bin/sh"; |
598 | command << "-c"; | 552 | command << "-c"; |
599 | command << fileDlg->LineEdit1->text(); | 553 | command << fileDlg->LineEdit1->text(); |
600 | Output *outDlg; | 554 | Output *outDlg; |
601 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 555 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
602 | outDlg->showMaximized(); | 556 | outDlg->showMaximized(); |
603 | outDlg->exec(); | 557 | outDlg->exec(); |
604 | qApp->processEvents(); | 558 | qApp->processEvents(); |
605 | 559 | ||
606 | } | 560 | } |
607 | } | 561 | } |
608 | 562 | ||
609 | void AdvancedFm::runCommandStd() | 563 | void AdvancedFm::runCommandStd() { |
610 | { | 564 | if( !CurrentView()->currentItem()) return; |
611 | QString curFile; | 565 | QString curFile; |
612 | QDir *thisDir = CurrentDir(); | 566 | QDir *thisDir = CurrentDir(); |
613 | QListView *thisView = CurrentView(); | 567 | QListView *thisView = CurrentView(); |
614 | if( thisView->currentItem()) | 568 | if( thisView->currentItem()) |
615 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 569 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
616 | 570 | ||
617 | InputDialog *fileDlg; | 571 | InputDialog *fileDlg; |
618 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 572 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
619 | fileDlg->setInputText(curFile); | 573 | fileDlg->setInputText(curFile); |
620 | fileDlg->exec(); | 574 | fileDlg->exec(); |
621 | 575 | ||
622 | if( fileDlg->result() == 1 ) | 576 | if( fileDlg->result() == 1 ) { |
623 | { | ||
624 | qApp->processEvents(); | 577 | qApp->processEvents(); |
625 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 578 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
626 | } | 579 | } |
627 | } | 580 | } |
628 | 581 | ||
629 | void AdvancedFm::fileStatus() | 582 | void AdvancedFm::fileStatus() { |
630 | { | 583 | if( !CurrentView()->currentItem()) return; |
631 | QString curFile; | 584 | QString curFile; |
632 | curFile = CurrentView()->currentItem()->text(0); | 585 | curFile = CurrentView()->currentItem()->text(0); |
633 | 586 | ||
634 | QStringList command; | 587 | QStringList command; |
635 | command << "/bin/sh"; | 588 | command << "/bin/sh"; |
636 | command << "-c"; | 589 | command << "-c"; |
637 | command << "stat -l "+ curFile; | 590 | command << "stat -l "+ curFile; |
638 | 591 | ||
639 | Output *outDlg; | 592 | Output *outDlg; |
640 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 593 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
641 | outDlg->showMaximized(); | 594 | outDlg->showMaximized(); |
642 | outDlg->exec(); | 595 | outDlg->exec(); |
643 | qApp->processEvents(); | 596 | qApp->processEvents(); |
644 | } | 597 | } |
645 | 598 | ||
646 | 599 | ||
647 | void AdvancedFm::mkDir() | 600 | void AdvancedFm::mkDir() { |
648 | { | ||
649 | makeDir(); | 601 | makeDir(); |
650 | } | 602 | } |
651 | 603 | ||
652 | void AdvancedFm::rn() | 604 | void AdvancedFm::rn() { |
653 | { | ||
654 | renameIt(); | 605 | renameIt(); |
655 | } | 606 | } |
656 | 607 | ||
657 | void AdvancedFm::del() | 608 | void AdvancedFm::del() { |
658 | { | ||
659 | doDelete(); | 609 | doDelete(); |
660 | } | 610 | } |
661 | 611 | ||
662 | void AdvancedFm::mkSym() | 612 | void AdvancedFm::mkSym() { |
663 | { | ||
664 | QString cmd; | 613 | QString cmd; |
665 | QStringList curFileList = getPath(); | 614 | QStringList curFileList = getPath(); |
666 | if( curFileList.count() > 0) | 615 | if( curFileList.count() > 0) { |
667 | { | ||
668 | QDir *thisDir = CurrentDir(); | 616 | QDir *thisDir = CurrentDir(); |
669 | QDir * thatDir = OtherDir(); | 617 | QDir * thatDir = OtherDir(); |
670 | 618 | ||
671 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 619 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
672 | { | ||
673 | 620 | ||
674 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 621 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
675 | if(destName.right(1) == "/") | 622 | if(destName.right(1) == "/") { |
676 | { | ||
677 | destName = destName.left( destName.length() -1); | 623 | destName = destName.left( destName.length() -1); |
678 | } | 624 | } |
679 | 625 | ||
680 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 626 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
681 | 627 | ||
682 | if( curFile.right(1) == "/") | 628 | if( curFile.right(1) == "/") { |
683 | { | ||
684 | curFile = curFile.left( curFile.length() -1); | 629 | curFile = curFile.left( curFile.length() -1); |
685 | } | 630 | } |
686 | 631 | ||
687 | cmd = "ln -s "+curFile+" "+destName; | 632 | cmd = "ln -s "+curFile+" "+destName; |
688 | qDebug(cmd); | 633 | // qDebug(cmd); |
689 | startProcess( (const QString)cmd ); | 634 | startProcess( (const QString)cmd ); |
690 | } | 635 | } |
636 | rePopulate(); | ||
691 | setOtherTabCurrent(); | 637 | setOtherTabCurrent(); |
692 | populateView(); | ||
693 | } | 638 | } |
694 | } | 639 | } |
695 | 640 | ||
696 | void AdvancedFm::doBeam() | 641 | void AdvancedFm::doBeam() { |
697 | { | ||
698 | Ir ir; | 642 | Ir ir; |
699 | if(!ir.supported()) { | 643 | if(!ir.supported()) { |
700 | } else { | 644 | } else { |
701 | QStringList curFileList = getPath(); | 645 | QStringList curFileList = getPath(); |
702 | if( curFileList.count() > 0) { | 646 | if( curFileList.count() > 0) { |
703 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 647 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
704 | QString curFile = (*it); | 648 | QString curFile = (*it); |
705 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; | 649 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; |
706 | if( curFilePath.right(1) == "/") { | 650 | if( curFilePath.right(1) == "/") { |
707 | curFilePath = curFilePath.left( curFilePath.length() -1); | 651 | curFilePath = curFilePath.left( curFilePath.length() -1); |
708 | } | 652 | } |
709 | Ir *file = new Ir(this, "IR"); | 653 | Ir *file = new Ir(this, "IR"); |
710 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 654 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
711 | file->send( curFilePath, curFile ); | 655 | file->send( curFilePath, curFile ); |
712 | } | 656 | } |
713 | } | 657 | } |
714 | } | 658 | } |
715 | } | 659 | } |
716 | 660 | ||
717 | void AdvancedFm::fileBeamFinished( Ir *) | 661 | void AdvancedFm::fileBeamFinished( Ir *) { |
718 | { | ||
719 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 662 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
720 | } | 663 | } |
721 | 664 | ||
722 | void AdvancedFm::selectAll() | 665 | void AdvancedFm::selectAll() { |
723 | { | ||
724 | // if (TabWidget->currentTab() == 0) { | ||
725 | QListView *thisView = CurrentView(); | 666 | QListView *thisView = CurrentView(); |
726 | thisView->selectAll(true); | 667 | thisView->selectAll(true); |
727 | thisView->setSelected( thisView->firstChild(),false); | 668 | thisView->setSelected( thisView->firstChild(),false); |
728 | // } else { | ||
729 | // Remote_View->selectAll(true); | ||
730 | // Remote_View->setSelected( Remote_View->firstChild(),false); | ||
731 | // } | ||
732 | } | 669 | } |
733 | 670 | ||
734 | void AdvancedFm::startProcess(const QString & cmd) | 671 | void AdvancedFm::startProcess(const QString & cmd) { |
735 | { | ||
736 | QStringList command; | 672 | QStringList command; |
737 | OProcess *process; | 673 | OProcess *process; |
738 | process = new OProcess(); | 674 | process = new OProcess(); |
739 | connect(process, SIGNAL(processExited(OProcess *)), | 675 | connect(process, SIGNAL(processExited(OProcess *)), |
740 | this, SLOT( processEnded(OProcess *))); | 676 | this, SLOT( processEnded(OProcess *))); |
741 | 677 | ||
742 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), | 678 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), |
743 | this, SLOT( oprocessStderr(OProcess *, char *, int))); | 679 | this, SLOT( oprocessStderr(OProcess *, char *, int))); |
744 | 680 | ||
745 | command << "/bin/sh"; | 681 | command << "/bin/sh"; |
746 | command << "-c"; | 682 | command << "-c"; |
747 | command << cmd.latin1(); | 683 | command << cmd.latin1(); |
748 | *process << command; | 684 | *process << command; |
749 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 685 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
750 | qDebug("could not start process"); | 686 | qDebug("could not start process"); |
751 | } | 687 | } |
752 | 688 | ||
753 | void AdvancedFm::processEnded(OProcess *) | 689 | void AdvancedFm::processEnded(OProcess *) { |
754 | { | ||
755 | // populateLocalView(); | ||
756 | populateView(); | 690 | populateView(); |
757 | } | 691 | } |
758 | 692 | ||
759 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int buflen) { | 693 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
760 | qWarning("received stderrt %d bytes", buflen); | 694 | // qWarning("received stderrt %d bytes", buflen); |
761 | 695 | ||
762 | QString lineStr = buffer; | 696 | QString lineStr = buffer; |
763 | // lineStr=lineStr.left(lineStr.length()-1); | ||
764 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 697 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
765 | |||
766 | // OutputEdit->append(lineStr); | ||
767 | // OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | ||
768 | } | 698 | } |
769 | 699 | ||
770 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) | 700 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { |
771 | { | 701 | if ( o->inherits( "QLineEdit" ) ) { |
772 | if ( o->inherits( "QLineEdit" ) ) | 702 | if ( e->type() == QEvent::KeyPress ) { |
773 | { | ||
774 | if ( e->type() == QEvent::KeyPress ) | ||
775 | { | ||
776 | QKeyEvent *ke = (QKeyEvent*)e; | 703 | QKeyEvent *ke = (QKeyEvent*)e; |
777 | if ( ke->key() == Key_Return || | 704 | if ( ke->key() == Key_Return || |
778 | ke->key() == Key_Enter ) | 705 | ke->key() == Key_Enter ) { |
779 | { | ||
780 | okRename(); | 706 | okRename(); |
781 | return true; | 707 | return true; |
782 | } | 708 | } |
783 | else if ( ke->key() == Key_Escape ) | 709 | else if ( ke->key() == Key_Escape ) { |
784 | { | ||
785 | cancelRename(); | 710 | cancelRename(); |
786 | return true; | 711 | return true; |
787 | } | 712 | } |
788 | } | 713 | } |
789 | else if ( e->type() == QEvent::FocusOut ) | 714 | else if ( e->type() == QEvent::FocusOut ) { |
790 | { | ||
791 | cancelRename(); | 715 | cancelRename(); |
792 | return true; | 716 | return true; |
793 | } | 717 | } |
794 | } | 718 | } |
795 | if ( o->inherits( "QListView" ) ) | 719 | if ( o->inherits( "QListView" ) ) { |
796 | { | 720 | if ( e->type() == QEvent::FocusIn ) { |
797 | if ( e->type() == QEvent::FocusOut ) | 721 | if( o == Local_View) { //keep track of which view |
798 | { | 722 | whichTab=1; |
799 | printf("focusIn\n"); | 723 | } |
800 | 724 | else { | |
801 | } | 725 | whichTab=2; |
802 | } | 726 | } |
727 | } | ||
728 | OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection | ||
729 | } | ||
803 | 730 | ||
804 | return QWidget::eventFilter( o, e ); | 731 | return QWidget::eventFilter( o, e ); |
805 | } | 732 | } |
806 | 733 | ||
807 | 734 | ||
808 | void AdvancedFm::cancelRename() | 735 | void AdvancedFm::cancelRename() { |
809 | { | 736 | // qDebug("cancel rename"); |
810 | qDebug("cancel rename"); | ||
811 | QListView * view; | 737 | QListView * view; |
812 | view = CurrentView(); | 738 | view = CurrentView(); |
813 | 739 | ||
814 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 740 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
815 | delete renameBox; | 741 | delete renameBox; |
816 | renameBox = 0; | 742 | renameBox = 0; |
817 | if ( resetFocus ) | 743 | if ( resetFocus ) { |
818 | { | ||
819 | view->viewport()->setFocusProxy( view); | 744 | view->viewport()->setFocusProxy( view); |
820 | view->setFocus(); | 745 | view->setFocus(); |
821 | } | 746 | } |
822 | } | 747 | } |
823 | 748 | ||
824 | void AdvancedFm::doRename(QListView * view) | 749 | void AdvancedFm::doRename(QListView * view) { |
825 | { | 750 | if( !CurrentView()->currentItem()) return; |
826 | 751 | ||
827 | QRect r = view->itemRect( view->currentItem( )); | 752 | QRect r = view->itemRect( view->currentItem( )); |
828 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 753 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
829 | r.setX( view->contentsX() ); | 754 | r.setX( view->contentsX() ); |
830 | if ( r.width() > view->visibleWidth() ) | 755 | if ( r.width() > view->visibleWidth() ) |
831 | r.setWidth( view->visibleWidth() ); | 756 | r.setWidth( view->visibleWidth() ); |
832 | 757 | ||
833 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 758 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
834 | renameBox->setFrame(true); | 759 | renameBox->setFrame(true); |
835 | 760 | ||
836 | renameBox->setText( view->currentItem()->text(0) ); | 761 | renameBox->setText( view->currentItem()->text(0) ); |
837 | 762 | ||
838 | renameBox->selectAll(); | 763 | renameBox->selectAll(); |
839 | renameBox->installEventFilter( this ); | 764 | renameBox->installEventFilter( this ); |
840 | view->addChild( renameBox, r.x(), r.y() ); | 765 | view->addChild( renameBox, r.x(), r.y() ); |
841 | renameBox->resize( r.size() ); | 766 | renameBox->resize( r.size() ); |
842 | view->viewport()->setFocusProxy( renameBox ); | 767 | view->viewport()->setFocusProxy( renameBox ); |
843 | renameBox->setFocus(); | 768 | renameBox->setFocus(); |
844 | renameBox->show(); | 769 | renameBox->show(); |
845 | |||
846 | } | 770 | } |
847 | 771 | ||
848 | 772 | ||
849 | void AdvancedFm::renameIt() | 773 | void AdvancedFm::renameIt() { |
850 | { | 774 | if( !CurrentView()->currentItem()) return; |
851 | QListView *thisView = CurrentView(); | 775 | QListView *thisView = CurrentView(); |
852 | oldName = thisView->currentItem()->text(0); | 776 | oldName = thisView->currentItem()->text(0); |
853 | doRename( thisView ); | 777 | doRename( thisView ); |
854 | populateView(); | 778 | populateView(); |
855 | } | 779 | } |
856 | 780 | ||
857 | void AdvancedFm::okRename() | 781 | void AdvancedFm::okRename() { |
858 | { | 782 | if( !CurrentView()->currentItem()) return; |
859 | QString newName = renameBox->text(); | 783 | QString newName = renameBox->text(); |
860 | cancelRename(); | 784 | cancelRename(); |
861 | // int tabs=0; | 785 | QListView * view = CurrentView(); |
862 | QListView * view = CurrentView(); | 786 | QString path = CurrentDir()->canonicalPath() + "/"; |
863 | QString path = CurrentDir()->canonicalPath() + "/"; | 787 | oldName = path + oldName; |
864 | oldName = path + oldName; | 788 | newName = path + newName; |
865 | newName = path + newName; | 789 | |
866 | 790 | if( rename( oldName.latin1(), newName.latin1())== -1) | |
867 | if( view->currentItem() == NULL) | 791 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
868 | return; | 792 | else |
869 | if( rename( oldName.latin1(), newName.latin1())== -1) | 793 | oldName = ""; |
870 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 794 | |
871 | else | 795 | view->takeItem( view->currentItem() ); |
872 | oldName = ""; | 796 | delete view->currentItem(); |
873 | 797 | populateView(); | |
874 | view->takeItem( view->currentItem() ); | ||
875 | delete view->currentItem(); | ||
876 | populateView(); | ||
877 | } | 798 | } |
878 | 799 | ||
879 | void AdvancedFm::openSearch() { | 800 | void AdvancedFm::openSearch() { |
880 | 801 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); | |
881 | } | 802 | } |
diff --git a/noncore/apps/advancedfm/filePermissions.cpp b/noncore/apps/advancedfm/filePermissions.cpp index 4de6d12..9698de7 100644 --- a/noncore/apps/advancedfm/filePermissions.cpp +++ b/noncore/apps/advancedfm/filePermissions.cpp | |||
@@ -1,270 +1,270 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2002 ljp ljp@llornkcor.com | 2 | ** copyright 2002 ljp ljp@llornkcor.com |
3 | ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter | 3 | ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ****************************************************************************/ | 13 | ****************************************************************************/ |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <qfileinfo.h> | 16 | #include <qfileinfo.h> |
17 | 17 | ||
18 | #include <qcheckbox.h> | 18 | #include <qcheckbox.h> |
19 | #include <qlabel.h> | 19 | #include <qlabel.h> |
20 | #include <qlineedit.h> | 20 | #include <qlineedit.h> |
21 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
22 | 22 | ||
23 | #include <unistd.h> | 23 | #include <unistd.h> |
24 | #include <sys/stat.h> | 24 | #include <sys/stat.h> |
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | #include <sys/types.h> | 26 | #include <sys/types.h> |
27 | #include <pwd.h> | 27 | #include <pwd.h> |
28 | #include <grp.h> | 28 | #include <grp.h> |
29 | 29 | ||
30 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) | 30 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) |
31 | : QDialog( parent, name, modal, fl ) | 31 | : QDialog( parent, name, modal, fl ) |
32 | { | 32 | { |
33 | if ( !name ) | 33 | if ( !name ) |
34 | setName( "filePermissions" ); | 34 | setName( tr("filePermissions") ); |
35 | // qDebug("FilePermissions "+fileName); | 35 | // qDebug("FilePermissions "+fileName); |
36 | /* resize( 236, 210 ); | 36 | /* resize( 236, 210 ); |
37 | setMaximumSize( QSize( 236, 210 ) ); | 37 | setMaximumSize( QSize( 236, 210 ) ); |
38 | */ setCaption( tr( "Set File Permissions" ) ); | 38 | */ setCaption( tr( "Set File Permissions" ) ); |
39 | 39 | ||
40 | TextLabel1 = new QLabel( this, "TextLabel1" ); | 40 | TextLabel1 = new QLabel( this, "TextLabel1" ); |
41 | TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); | 41 | TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); |
42 | TextLabel1->setText( tr( "Set file permissions for:" ) ); | 42 | TextLabel1->setText( tr( "Set file permissions for:" ) ); |
43 | 43 | ||
44 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 44 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
45 | LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); | 45 | LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); |
46 | LineEdit1->setReadOnly(true); | 46 | LineEdit1->setReadOnly(true); |
47 | 47 | ||
48 | TextLabel4 = new QLabel( this, "TextLabel4" ); | 48 | TextLabel4 = new QLabel( this, "TextLabel4" ); |
49 | TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); | 49 | TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); |
50 | TextLabel4->setText( tr( "owner" ) ); | 50 | TextLabel4->setText( tr( "owner" ) ); |
51 | 51 | ||
52 | TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); | 52 | TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); |
53 | TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); | 53 | TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); |
54 | TextLabel4_2->setText( tr( "group" ) ); | 54 | TextLabel4_2->setText( tr( "group" ) ); |
55 | 55 | ||
56 | TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); | 56 | TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); |
57 | TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); | 57 | TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); |
58 | TextLabel4_3->setText( tr( "others" ) ); | 58 | TextLabel4_3->setText( tr( "others" ) ); |
59 | 59 | ||
60 | CheckBox1 = new QCheckBox( this, "CheckBox1" ); | 60 | CheckBox1 = new QCheckBox( this, "CheckBox1" ); |
61 | CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); | 61 | CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); |
62 | connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); | 62 | connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); |
63 | 63 | ||
64 | CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); | 64 | CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); |
65 | CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); | 65 | CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); |
66 | connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); | 66 | connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); |
67 | 67 | ||
68 | CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); | 68 | CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); |
69 | CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); | 69 | CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); |
70 | connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); | 70 | connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); |
71 | 71 | ||
72 | CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); | 72 | CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); |
73 | CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); | 73 | CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); |
74 | connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); | 74 | connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); |
75 | 75 | ||
76 | CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); | 76 | CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); |
77 | CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); | 77 | CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); |
78 | connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); | 78 | connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); |
79 | 79 | ||
80 | CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); | 80 | CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); |
81 | CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); | 81 | CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); |
82 | connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); | 82 | connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); |
83 | 83 | ||
84 | CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); | 84 | CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); |
85 | CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); | 85 | CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); |
86 | connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); | 86 | connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); |
87 | 87 | ||
88 | CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); | 88 | CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); |
89 | CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) ); | 89 | CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) ); |
90 | connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); | 90 | connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); |
91 | 91 | ||
92 | CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); | 92 | CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); |
93 | CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); | 93 | CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); |
94 | connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); | 94 | connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); |
95 | 95 | ||
96 | GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); | 96 | GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); |
97 | GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); | 97 | GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); |
98 | 98 | ||
99 | OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); | 99 | OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); |
100 | OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); | 100 | OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); |
101 | 101 | ||
102 | TextLabel5 = new QLabel( this, "TextLabel5" ); | 102 | TextLabel5 = new QLabel( this, "TextLabel5" ); |
103 | TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); | 103 | TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); |
104 | TextLabel5->setText( tr( "Owner" ) ); | 104 | TextLabel5->setText( tr( "Owner" ) ); |
105 | 105 | ||
106 | TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); | 106 | TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); |
107 | TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); | 107 | TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); |
108 | TextLabel5_2->setText( tr( "Group" ) ); | 108 | TextLabel5_2->setText( tr( "Group" ) ); |
109 | 109 | ||
110 | ModeLine = new QLineEdit( this, "TextLabelMode" ); | 110 | ModeLine = new QLineEdit( this, "TextLabelMode" ); |
111 | ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); | 111 | ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); |
112 | 112 | ||
113 | TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); | 113 | TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); |
114 | TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); | 114 | TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); |
115 | TextLabel3_2->setText( tr( "read" ) ); | 115 | TextLabel3_2->setText( tr( "read" ) ); |
116 | TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 116 | TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
117 | 117 | ||
118 | TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); | 118 | TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); |
119 | TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); | 119 | TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); |
120 | TextLabel3_2_2->setText( tr( "write" ) ); | 120 | TextLabel3_2_2->setText( tr( "write" ) ); |
121 | TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 121 | TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
122 | 122 | ||
123 | TextLabel3 = new QLabel( this, "TextLabel3" ); | 123 | TextLabel3 = new QLabel( this, "TextLabel3" ); |
124 | TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); | 124 | TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); |
125 | TextLabel3->setText( tr( "execute" ) ); | 125 | TextLabel3->setText( tr( "execute" ) ); |
126 | TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 126 | TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
127 | 127 | ||
128 | struct stat buf; | 128 | struct stat buf; |
129 | mode_t mode; | 129 | mode_t mode; |
130 | file = fileName; | 130 | file = fileName; |
131 | QFileInfo fi(file); | 131 | QFileInfo fi(file); |
132 | 132 | ||
133 | LineEdit1->setText( file); | 133 | LineEdit1->setText( file); |
134 | OwnerLineEdit->setText( fi.owner()); | 134 | OwnerLineEdit->setText( fi.owner()); |
135 | GroupLineEdit->setText( fi.group()); | 135 | GroupLineEdit->setText( fi.group()); |
136 | 136 | ||
137 | if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); } | 137 | if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); } |
138 | if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); } | 138 | if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); } |
139 | if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); } | 139 | if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); } |
140 | 140 | ||
141 | if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); } | 141 | if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); } |
142 | if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); } | 142 | if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); } |
143 | if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); } | 143 | if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); } |
144 | 144 | ||
145 | if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } | 145 | if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } |
146 | if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } | 146 | if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } |
147 | if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } | 147 | if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } |
148 | 148 | ||
149 | stat(file.latin1(), &buf); | 149 | stat(file.latin1(), &buf); |
150 | mode = buf.st_mode; | 150 | mode = buf.st_mode; |
151 | modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); | 151 | modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); |
152 | ModeLine->setText(modeStr); | 152 | ModeLine->setText(modeStr); |
153 | bool ok; | 153 | bool ok; |
154 | i_mode = modeStr.toInt(&ok,10); | 154 | i_mode = modeStr.toInt(&ok,10); |
155 | 155 | ||
156 | } | 156 | } |
157 | 157 | ||
158 | /* | 158 | /* |
159 | * Destroys the object and frees any allocated resources | 159 | * Destroys the object and frees any allocated resources |
160 | */ | 160 | */ |
161 | filePermissions::~filePermissions() | 161 | filePermissions::~filePermissions() |
162 | { | 162 | { |
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | // might this be better as a callback routine??? | 166 | // might this be better as a callback routine??? |
167 | void filePermissions::ownReadCheck() { | 167 | void filePermissions::ownReadCheck() { |
168 | if(CheckBox1->isChecked()) { i_mode +=400; } | 168 | if(CheckBox1->isChecked()) { i_mode +=400; } |
169 | else i_mode -=400; | 169 | else i_mode -=400; |
170 | modeStr.sprintf("0%d",i_mode); | 170 | modeStr.sprintf("0%d",i_mode); |
171 | ModeLine->setText( modeStr); | 171 | ModeLine->setText( modeStr); |
172 | // 0400 | 172 | // 0400 |
173 | } | 173 | } |
174 | 174 | ||
175 | void filePermissions::ownWriteCheck() { | 175 | void filePermissions::ownWriteCheck() { |
176 | if(CheckBox1_2->isChecked()) { i_mode +=200; } | 176 | if(CheckBox1_2->isChecked()) { i_mode +=200; } |
177 | else i_mode -=200; | 177 | else i_mode -=200; |
178 | modeStr.sprintf("0%d",i_mode); | 178 | modeStr.sprintf("0%d",i_mode); |
179 | ModeLine->setText(modeStr); | 179 | ModeLine->setText(modeStr); |
180 | // 0200 | 180 | // 0200 |
181 | } | 181 | } |
182 | 182 | ||
183 | void filePermissions::ownExeCheck() { | 183 | void filePermissions::ownExeCheck() { |
184 | if(CheckBox1_3->isChecked()) { i_mode +=100; } | 184 | if(CheckBox1_3->isChecked()) { i_mode +=100; } |
185 | else i_mode -=100; | 185 | else i_mode -=100; |
186 | modeStr.sprintf("0%d",i_mode); | 186 | modeStr.sprintf("0%d",i_mode); |
187 | ModeLine->setText(modeStr); | 187 | ModeLine->setText(modeStr); |
188 | // 0100 | 188 | // 0100 |
189 | } | 189 | } |
190 | 190 | ||
191 | void filePermissions::grpReadCheck() { | 191 | void filePermissions::grpReadCheck() { |
192 | if(CheckBox1_4->isChecked()) { i_mode +=40; } | 192 | if(CheckBox1_4->isChecked()) { i_mode +=40; } |
193 | else i_mode -=40; | 193 | else i_mode -=40; |
194 | modeStr.sprintf("0%d",i_mode); | 194 | modeStr.sprintf("0%d",i_mode); |
195 | ModeLine->setText(modeStr); | 195 | ModeLine->setText(modeStr); |
196 | // 0040 | 196 | // 0040 |
197 | } | 197 | } |
198 | 198 | ||
199 | void filePermissions::grpWriteCheck() { | 199 | void filePermissions::grpWriteCheck() { |
200 | if(CheckBox1_5->isChecked()) { i_mode +=20; } | 200 | if(CheckBox1_5->isChecked()) { i_mode +=20; } |
201 | else i_mode -=20; | 201 | else i_mode -=20; |
202 | modeStr.sprintf("0%d",i_mode); | 202 | modeStr.sprintf("0%d",i_mode); |
203 | ModeLine->setText(modeStr); | 203 | ModeLine->setText(modeStr); |
204 | // 0020 | 204 | // 0020 |
205 | } | 205 | } |
206 | 206 | ||
207 | void filePermissions::grpExeCheck() { | 207 | void filePermissions::grpExeCheck() { |
208 | if(CheckBox1_6->isChecked()) { i_mode +=10; } | 208 | if(CheckBox1_6->isChecked()) { i_mode +=10; } |
209 | else i_mode -=10; | 209 | else i_mode -=10; |
210 | modeStr.sprintf("0%d",i_mode); | 210 | modeStr.sprintf("0%d",i_mode); |
211 | ModeLine->setText(modeStr); | 211 | ModeLine->setText(modeStr); |
212 | // 0010 | 212 | // 0010 |
213 | } | 213 | } |
214 | 214 | ||
215 | void filePermissions::wrldReadCheck() { | 215 | void filePermissions::wrldReadCheck() { |
216 | if(CheckBox1_7->isChecked()) { i_mode +=4; } | 216 | if(CheckBox1_7->isChecked()) { i_mode +=4; } |
217 | else i_mode -=4; | 217 | else i_mode -=4; |
218 | modeStr.sprintf("0%d",i_mode); | 218 | modeStr.sprintf("0%d",i_mode); |
219 | ModeLine->setText(modeStr); | 219 | ModeLine->setText(modeStr); |
220 | // 0004 | 220 | // 0004 |
221 | } | 221 | } |
222 | 222 | ||
223 | void filePermissions::wrldWriteCheck() { | 223 | void filePermissions::wrldWriteCheck() { |
224 | if(CheckBox1_8->isChecked()) { i_mode +=2; } | 224 | if(CheckBox1_8->isChecked()) { i_mode +=2; } |
225 | else i_mode -=2; | 225 | else i_mode -=2; |
226 | modeStr.sprintf("0%d",i_mode); | 226 | modeStr.sprintf("0%d",i_mode); |
227 | ModeLine->setText(modeStr); | 227 | ModeLine->setText(modeStr); |
228 | // 0002 | 228 | // 0002 |
229 | } | 229 | } |
230 | 230 | ||
231 | void filePermissions::wrldExeCheck() { | 231 | void filePermissions::wrldExeCheck() { |
232 | if(CheckBox1_8_2->isChecked()) { i_mode +=1; } | 232 | if(CheckBox1_8_2->isChecked()) { i_mode +=1; } |
233 | else i_mode -=1; | 233 | else i_mode -=1; |
234 | modeStr.sprintf("0%d",i_mode); | 234 | modeStr.sprintf("0%d",i_mode); |
235 | ModeLine->setText(modeStr); | 235 | ModeLine->setText(modeStr); |
236 | // 0001 | 236 | // 0001 |
237 | } | 237 | } |
238 | 238 | ||
239 | void filePermissions::accept() { | 239 | void filePermissions::accept() { |
240 | 240 | ||
241 | QFileInfo fi(file); | 241 | QFileInfo fi(file); |
242 | struct passwd *pwd=0; | 242 | struct passwd *pwd=0; |
243 | struct group *grp=0; | 243 | struct group *grp=0; |
244 | pwd = getpwnam(OwnerLineEdit->text().latin1() ); | 244 | pwd = getpwnam(OwnerLineEdit->text().latin1() ); |
245 | if(pwd == NULL) { | 245 | if(pwd == NULL) { |
246 | perror("getpwnam"); | 246 | perror("getpwnam"); |
247 | QMessageBox::warning(this,tr("Warning"),tr("Error- no user") ); | 247 | QMessageBox::warning(this,tr("Warning"),tr("Error- no user") ); |
248 | return; | 248 | return; |
249 | } else { | 249 | } else { |
250 | grp = getgrnam(GroupLineEdit->text().latin1()); | 250 | grp = getgrnam(GroupLineEdit->text().latin1()); |
251 | if(grp==NULL) { | 251 | if(grp==NULL) { |
252 | perror("getgrnam"); | 252 | perror("getgrnam"); |
253 | QMessageBox::warning(this,tr("Warning"),tr("Error- no group")); | 253 | QMessageBox::warning(this,tr("Warning"),tr("Error- no group")); |
254 | return; | 254 | return; |
255 | } | 255 | } |
256 | if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { | 256 | if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { |
257 | perror("chown"); | 257 | perror("chown"); |
258 | QMessageBox::warning(this,tr("Warning"),tr("Error setting ownership or group") ); | 258 | QMessageBox::warning(this,tr("Warning"),tr("Error setting ownership or group") ); |
259 | return; | 259 | return; |
260 | } | 260 | } |
261 | bool ok; | 261 | bool ok; |
262 | uint moder = modeStr.toUInt(&ok,8); | 262 | uint moder = modeStr.toUInt(&ok,8); |
263 | if( chmod( file.latin1(), moder) < 0) { | 263 | if( chmod( file.latin1(), moder) < 0) { |
264 | perror("chmod"); | 264 | perror("chmod"); |
265 | QMessageBox::warning(this,tr("Warning"),tr("Error setting mode") ); | 265 | QMessageBox::warning(this,tr("Warning"),tr("Error setting mode") ); |
266 | return; | 266 | return; |
267 | } | 267 | } |
268 | } | 268 | } |
269 | close(); | 269 | close(); |
270 | } | 270 | } |