author | zecke <zecke> | 2004-10-14 16:36:42 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-10-14 16:36:42 (UTC) |
commit | f91c6162ea0e12d2c618072a78467310dcb23077 (patch) (unidiff) | |
tree | 6ad9d060360b4d3530e885a51687625a36a4a365 | |
parent | 91216c486aff5ddb194234cce3c9db453b9f3152 (diff) | |
download | opie-f91c6162ea0e12d2c618072a78467310dcb23077.zip opie-f91c6162ea0e12d2c618072a78467310dcb23077.tar.gz opie-f91c6162ea0e12d2c618072a78467310dcb23077.tar.bz2 |
case 0: it is a label and not a statement, it doesn't need ';' but ':' every decent
c compiler produced in the last twenty years will bitch about it...
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index e770304..6abdc85 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,711 +1,711 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | 12 | ||
13 | #include "advancedfm.h" | 13 | #include "advancedfm.h" |
14 | #include "output.h" | 14 | #include "output.h" |
15 | #include "filePermissions.h" | 15 | #include "filePermissions.h" |
16 | 16 | ||
17 | /* OPIE */ | 17 | /* OPIE */ |
18 | #include <opie2/odebug.h> | 18 | #include <opie2/odebug.h> |
19 | #include <qpe/lnkproperties.h> | 19 | #include <qpe/lnkproperties.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/applnk.h> | 21 | #include <qpe/applnk.h> |
22 | using namespace Opie::Core; | 22 | using namespace Opie::Core; |
23 | 23 | ||
24 | /* QT*/ | 24 | /* QT*/ |
25 | 25 | ||
26 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
27 | #include <qpopupmenu.h> | 27 | #include <qpopupmenu.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | 29 | ||
30 | /* STD */ | 30 | /* STD */ |
31 | 31 | ||
32 | #include <errno.h> | 32 | #include <errno.h> |
33 | #include <stdlib.h> | 33 | #include <stdlib.h> |
34 | #include <unistd.h> | 34 | #include <unistd.h> |
35 | #include <sys/stat.h> | 35 | #include <sys/stat.h> |
36 | #include <dirent.h> | 36 | #include <dirent.h> |
37 | #include <sys/sendfile.h> | 37 | #include <sys/sendfile.h> |
38 | #include <fcntl.h> | 38 | #include <fcntl.h> |
39 | 39 | ||
40 | void AdvancedFm::doDirChange() { | 40 | void AdvancedFm::doDirChange() { |
41 | QString pathItem = CurrentView()->currentItem()->text(0); | 41 | QString pathItem = CurrentView()->currentItem()->text(0); |
42 | if( pathItem == "../") { | 42 | if( pathItem == "../") { |
43 | ListClicked( CurrentView()->currentItem()); | 43 | ListClicked( CurrentView()->currentItem()); |
44 | } else { | 44 | } else { |
45 | if( pathItem.find(" -> ",0,TRUE) != -1) | 45 | if( pathItem.find(" -> ",0,TRUE) != -1) |
46 | pathItem = dealWithSymName((const QString&)pathItem)+"/"; | 46 | pathItem = dealWithSymName((const QString&)pathItem)+"/"; |
47 | // owarn << pathItem << oendl; | 47 | // owarn << pathItem << oendl; |
48 | changeTo( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); | 48 | changeTo( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); |
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | void AdvancedFm::showMenuHidden() { | 52 | void AdvancedFm::showMenuHidden() { |
53 | if (b) { | 53 | if (b) { |
54 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 54 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
55 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 55 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
56 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 56 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
57 | } else { | 57 | } else { |
58 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 58 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
59 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 59 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
60 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 60 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
61 | } | 61 | } |
62 | b = !b; | 62 | b = !b; |
63 | populateView(); | 63 | populateView(); |
64 | } | 64 | } |
65 | 65 | ||
66 | void AdvancedFm::showHidden() { | 66 | void AdvancedFm::showHidden() { |
67 | if (b) { | 67 | if (b) { |
68 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 68 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
69 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 69 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
70 | } else { | 70 | } else { |
71 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 71 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
72 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 72 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
73 | } | 73 | } |
74 | populateView(); | 74 | populateView(); |
75 | } | 75 | } |
76 | 76 | ||
77 | QString AdvancedFm::dealWithSymName(const QString &fileName) { | 77 | QString AdvancedFm::dealWithSymName(const QString &fileName) { |
78 | QString strItem = fileName; | 78 | QString strItem = fileName; |
79 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 79 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
80 | } | 80 | } |
81 | 81 | ||
82 | void AdvancedFm::runThis() { | 82 | void AdvancedFm::runThis() { |
83 | if( !CurrentView()->currentItem()) return; | 83 | if( !CurrentView()->currentItem()) return; |
84 | QString fs; | 84 | QString fs; |
85 | QDir *thisDir = CurrentDir(); | 85 | QDir *thisDir = CurrentDir(); |
86 | 86 | ||
87 | QString curFile = CurrentView()->currentItem()->text(0); | 87 | QString curFile = CurrentView()->currentItem()->text(0); |
88 | QString path = thisDir->canonicalPath(); | 88 | QString path = thisDir->canonicalPath(); |
89 | 89 | ||
90 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 90 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
91 | 91 | ||
92 | curFile = dealWithSymName((const QString&)curFile); | 92 | curFile = dealWithSymName((const QString&)curFile); |
93 | 93 | ||
94 | if(curFile != "../") { | 94 | if(curFile != "../") { |
95 | 95 | ||
96 | fs = getFileSystemType((const QString &) path); | 96 | fs = getFileSystemType((const QString &) path); |
97 | QFileInfo fileInfo( path + "/" + curFile); | 97 | QFileInfo fileInfo( path + "/" + curFile); |
98 | // odebug << fileInfo.owner() << oendl; | 98 | // odebug << fileInfo.owner() << oendl; |
99 | 99 | ||
100 | if( (fileInfo.permission( QFileInfo::ExeUser) | 100 | if( (fileInfo.permission( QFileInfo::ExeUser) |
101 | | fileInfo.permission( QFileInfo::ExeGroup) | 101 | | fileInfo.permission( QFileInfo::ExeGroup) |
102 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 102 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
103 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 103 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
104 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 104 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
105 | e << curFile; | 105 | e << curFile; |
106 | } else { | 106 | } else { |
107 | curFile = path + "/" + curFile; | 107 | curFile = path + "/" + curFile; |
108 | DocLnk nf(curFile); | 108 | DocLnk nf(curFile); |
109 | QString execStr = nf.exec(); | 109 | QString execStr = nf.exec(); |
110 | // odebug << execStr << oendl; | 110 | // odebug << execStr << oendl; |
111 | if( execStr.isEmpty() ) { | 111 | if( execStr.isEmpty() ) { |
112 | } else { | 112 | } else { |
113 | nf.execute(); | 113 | nf.execute(); |
114 | } | 114 | } |
115 | } | 115 | } |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
119 | void AdvancedFm::runText() { | 119 | void AdvancedFm::runText() { |
120 | if( !CurrentView()->currentItem()) return; | 120 | if( !CurrentView()->currentItem()) return; |
121 | QString curFile = CurrentView()->currentItem()->text(0); | 121 | QString curFile = CurrentView()->currentItem()->text(0); |
122 | if(curFile != "../") { | 122 | if(curFile != "../") { |
123 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 123 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
124 | curFile = dealWithSymName((const QString&)curFile); | 124 | curFile = dealWithSymName((const QString&)curFile); |
125 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; | 125 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; |
126 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 126 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
127 | e << curFile; | 127 | e << curFile; |
128 | } | 128 | } |
129 | } | 129 | } |
130 | 130 | ||
131 | void AdvancedFm::makeDir() { | 131 | void AdvancedFm::makeDir() { |
132 | InputDialog *fileDlg; | 132 | InputDialog *fileDlg; |
133 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 133 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
134 | fileDlg->exec(); | 134 | fileDlg->exec(); |
135 | if( fileDlg->result() == 1 ) { | 135 | if( fileDlg->result() == 1 ) { |
136 | QDir *thisDir = CurrentDir(); | 136 | QDir *thisDir = CurrentDir(); |
137 | QString filename = fileDlg->LineEdit1->text(); | 137 | QString filename = fileDlg->LineEdit1->text(); |
138 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 138 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
139 | } | 139 | } |
140 | populateView(); | 140 | populateView(); |
141 | } | 141 | } |
142 | 142 | ||
143 | void AdvancedFm::doDelete() { | 143 | void AdvancedFm::doDelete() { |
144 | QStringList curFileList = getPath(); | 144 | QStringList curFileList = getPath(); |
145 | bool doMsg=true; | 145 | bool doMsg=true; |
146 | int count = curFileList.count(); | 146 | int count = curFileList.count(); |
147 | if( count > 0) { | 147 | if( count > 0) { |
148 | if(count > 1 ) { | 148 | if(count > 1 ) { |
149 | QString msg; | 149 | QString msg; |
150 | msg=tr("<p>Really delete %1 files?</p>").arg(count); | 150 | msg=tr("<p>Really delete %1 files?</p>").arg(count); |
151 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 151 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
152 | ,tr("Yes"),tr("No"),0,0,1) ) | 152 | ,tr("Yes"),tr("No"),0,0,1) ) |
153 | { | 153 | { |
154 | case 0: | 154 | case 0: |
155 | doMsg=false; | 155 | doMsg=false; |
156 | break; | 156 | break; |
157 | case 1: | 157 | case 1: |
158 | return; | 158 | return; |
159 | break; | 159 | break; |
160 | default: | 160 | default: |
161 | return; | 161 | return; |
162 | break; | 162 | break; |
163 | }; | 163 | }; |
164 | } | 164 | } |
165 | 165 | ||
166 | QString myFile; | 166 | QString myFile; |
167 | 167 | ||
168 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 168 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
169 | myFile = (*it); | 169 | myFile = (*it); |
170 | if( myFile.find(" -> ",0,TRUE) != -1) | 170 | if( myFile.find(" -> ",0,TRUE) != -1) |
171 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 171 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
172 | 172 | ||
173 | QString f = CurrentDir()->canonicalPath(); | 173 | QString f = CurrentDir()->canonicalPath(); |
174 | if(f.right(1).find("/",0,TRUE) == -1) | 174 | if(f.right(1).find("/",0,TRUE) == -1) |
175 | f += "/"; | 175 | f += "/"; |
176 | f += myFile; | 176 | f += myFile; |
177 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 177 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
178 | //if file is a directory | 178 | //if file is a directory |
179 | 179 | ||
180 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), | 180 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), |
181 | tr("<p>Really delete %1 and all it's contents?</p>" ).arg( f ) , | 181 | tr("<p>Really delete %1 and all it's contents?</p>" ).arg( f ) , |
182 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 182 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
183 | case 0: | 183 | case 0: |
184 | { | 184 | { |
185 | f=f.left(f.length()-1); | 185 | f=f.left(f.length()-1); |
186 | QString cmd="rm -rf "+f; | 186 | QString cmd="rm -rf "+f; |
187 | startProcess( (const QString)cmd.latin1() ); | 187 | startProcess( (const QString)cmd.latin1() ); |
188 | populateView(); | 188 | populateView(); |
189 | } | 189 | } |
190 | break; | 190 | break; |
191 | case 1: | 191 | case 1: |
192 | // exit | 192 | // exit |
193 | break; | 193 | break; |
194 | default: | 194 | default: |
195 | break; | 195 | break; |
196 | }; | 196 | }; |
197 | 197 | ||
198 | } else { | 198 | } else { |
199 | if(doMsg) { | 199 | if(doMsg) { |
200 | switch ( QMessageBox::warning(this,tr("Delete"), | 200 | switch ( QMessageBox::warning(this,tr("Delete"), |
201 | tr("<p>Really delete %1?</p>").arg( myFile ), | 201 | tr("<p>Really delete %1?</p>").arg( myFile ), |
202 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 202 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
203 | case 0; | 203 | case 0: |
204 | break; | 204 | break; |
205 | case 1: | 205 | case 1: |
206 | return; | 206 | return; |
207 | break; | 207 | break; |
208 | default: | 208 | default: |
209 | return; | 209 | return; |
210 | break; | 210 | break; |
211 | }; | 211 | }; |
212 | } | 212 | } |
213 | 213 | ||
214 | QString cmd="rm "+f; | 214 | QString cmd="rm "+f; |
215 | QFile file(f); | 215 | QFile file(f); |
216 | QFileInfo fi(myFile); | 216 | QFileInfo fi(myFile); |
217 | if( fi.fileName().find("../",0,TRUE)==-1) { | 217 | if( fi.fileName().find("../",0,TRUE)==-1) { |
218 | // odebug << "remove link files "+myFile << oendl; | 218 | // odebug << "remove link files "+myFile << oendl; |
219 | 219 | ||
220 | // DocLnk lnk(f); | 220 | // DocLnk lnk(f); |
221 | DocLnk *lnk; | 221 | DocLnk *lnk; |
222 | lnk = new DocLnk(f); | 222 | lnk = new DocLnk(f); |
223 | // odebug << "Deleting doclnk " + lnk->linkFile() << oendl; | 223 | // odebug << "Deleting doclnk " + lnk->linkFile() << oendl; |
224 | if(lnk->isValid()) | 224 | if(lnk->isValid()) |
225 | lnk->removeLinkFile(); | 225 | lnk->removeLinkFile(); |
226 | // delete lnk; | 226 | // delete lnk; |
227 | file.remove(); | 227 | file.remove(); |
228 | } | 228 | } |
229 | } | 229 | } |
230 | } | 230 | } |
231 | } | 231 | } |
232 | populateView(); | 232 | populateView(); |
233 | } | 233 | } |
234 | 234 | ||
235 | void AdvancedFm::filePerms() { | 235 | void AdvancedFm::filePerms() { |
236 | QStringList curFileList = getPath(); | 236 | QStringList curFileList = getPath(); |
237 | QString filePath; | 237 | QString filePath; |
238 | 238 | ||
239 | filePath = CurrentDir()->canonicalPath()+"/"; | 239 | filePath = CurrentDir()->canonicalPath()+"/"; |
240 | 240 | ||
241 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 241 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
242 | filePermissions *filePerm; | 242 | filePermissions *filePerm; |
243 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 243 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
244 | QPEApplication::execDialog( filePerm ); | 244 | QPEApplication::execDialog( filePerm ); |
245 | if( filePerm ) | 245 | if( filePerm ) |
246 | delete filePerm; | 246 | delete filePerm; |
247 | } | 247 | } |
248 | populateView(); | 248 | populateView(); |
249 | } | 249 | } |
250 | 250 | ||
251 | void AdvancedFm::doProperties() { | 251 | void AdvancedFm::doProperties() { |
252 | #if defined(QT_QWS_OPIE) | 252 | #if defined(QT_QWS_OPIE) |
253 | 253 | ||
254 | QStringList curFileList = getPath(); | 254 | QStringList curFileList = getPath(); |
255 | 255 | ||
256 | QString filePath; | 256 | QString filePath; |
257 | filePath = CurrentDir()->canonicalPath()+"/"; | 257 | filePath = CurrentDir()->canonicalPath()+"/"; |
258 | 258 | ||
259 | // odebug << "" << curFileList.count() << "" << oendl; | 259 | // odebug << "" << curFileList.count() << "" << oendl; |
260 | 260 | ||
261 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 261 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
262 | // odebug << (filePath+*it) << oendl; | 262 | // odebug << (filePath+*it) << oendl; |
263 | DocLnk lnk( (filePath+*it)); | 263 | DocLnk lnk( (filePath+*it)); |
264 | LnkProperties prop( &lnk ); | 264 | LnkProperties prop( &lnk ); |
265 | QPEApplication::execDialog( &prop ); | 265 | QPEApplication::execDialog( &prop ); |
266 | } | 266 | } |
267 | #endif | 267 | #endif |
268 | 268 | ||
269 | } | 269 | } |
270 | 270 | ||
271 | void AdvancedFm::upDir() { | 271 | void AdvancedFm::upDir() { |
272 | 272 | ||
273 | QDir dir( CurrentDir()->canonicalPath()); | 273 | QDir dir( CurrentDir()->canonicalPath()); |
274 | dir.cdUp(); | 274 | dir.cdUp(); |
275 | changeTo(dir.canonicalPath()); | 275 | changeTo(dir.canonicalPath()); |
276 | } | 276 | } |
277 | 277 | ||
278 | void AdvancedFm::copyTimer() { | 278 | void AdvancedFm::copyTimer() { |
279 | QTimer::singleShot(125,this,SLOT(copy())); | 279 | QTimer::singleShot(125,this,SLOT(copy())); |
280 | } | 280 | } |
281 | 281 | ||
282 | void AdvancedFm::copy() { | 282 | void AdvancedFm::copy() { |
283 | QStringList curFileList = getPath(); | 283 | QStringList curFileList = getPath(); |
284 | 284 | ||
285 | QDir *thisDir = CurrentDir(); | 285 | QDir *thisDir = CurrentDir(); |
286 | QDir *thatDir = OtherDir(); | 286 | QDir *thatDir = OtherDir(); |
287 | 287 | ||
288 | bool doMsg = true; | 288 | bool doMsg = true; |
289 | int count = curFileList.count(); | 289 | int count = curFileList.count(); |
290 | if( count > 0) { | 290 | if( count > 0) { |
291 | if(count > 1 ){ | 291 | if(count > 1 ){ |
292 | QString msg; | 292 | QString msg; |
293 | msg=tr("<p>Really copy %1 files?</p>").arg(count); | 293 | msg=tr("<p>Really copy %1 files?</p>").arg(count); |
294 | switch ( QMessageBox::warning(this,tr("Copy"),msg | 294 | switch ( QMessageBox::warning(this,tr("Copy"),msg |
295 | ,tr("Yes"),tr("No"),0,0,1) ) | 295 | ,tr("Yes"),tr("No"),0,0,1) ) |
296 | { | 296 | { |
297 | case 0: | 297 | case 0: |
298 | doMsg=false; | 298 | doMsg=false; |
299 | break; | 299 | break; |
300 | case 1: | 300 | case 1: |
301 | return; | 301 | return; |
302 | break; | 302 | break; |
303 | default: | 303 | default: |
304 | return; | 304 | return; |
305 | break; | 305 | break; |
306 | }; | 306 | }; |
307 | } | 307 | } |
308 | 308 | ||
309 | QString curFile, item, destFile; | 309 | QString curFile, item, destFile; |
310 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 310 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
311 | item=(*it); | 311 | item=(*it); |
312 | if(item.find("->",0,TRUE)) //symlink | 312 | if(item.find("->",0,TRUE)) //symlink |
313 | item = item.left(item.find("->",0,TRUE)); | 313 | item = item.left(item.find("->",0,TRUE)); |
314 | 314 | ||
315 | curFile = thisDir->canonicalPath()+"/"+ item; | 315 | curFile = thisDir->canonicalPath()+"/"+ item; |
316 | destFile = thatDir->canonicalPath()+"/"+ item; | 316 | destFile = thatDir->canonicalPath()+"/"+ item; |
317 | 317 | ||
318 | // odebug << "Destination file is "+destFile << oendl; | 318 | // odebug << "Destination file is "+destFile << oendl; |
319 | // odebug << "CurrentFile file is " + curFile << oendl; | 319 | // odebug << "CurrentFile file is " + curFile << oendl; |
320 | 320 | ||
321 | QFile f(destFile); | 321 | QFile f(destFile); |
322 | if( f.exists()) { | 322 | if( f.exists()) { |
323 | if(doMsg) { | 323 | if(doMsg) { |
324 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 324 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
325 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), | 325 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(item), |
326 | tr("Yes"),tr("No"),0,0,1)) { | 326 | tr("Yes"),tr("No"),0,0,1)) { |
327 | case 0; | 327 | case 0: |
328 | break; | 328 | break; |
329 | case 1: | 329 | case 1: |
330 | return; | 330 | return; |
331 | break; | 331 | break; |
332 | default: | 332 | default: |
333 | return; | 333 | return; |
334 | break; | 334 | break; |
335 | }; | 335 | }; |
336 | } | 336 | } |
337 | f.remove(); | 337 | f.remove(); |
338 | } | 338 | } |
339 | 339 | ||
340 | if( !copyFile( curFile, destFile) ) { | 340 | if( !copyFile( curFile, destFile) ) { |
341 | QMessageBox::message("AdvancedFm", | 341 | QMessageBox::message("AdvancedFm", |
342 | tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 342 | tr( "<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
343 | return; | 343 | return; |
344 | } | 344 | } |
345 | } | 345 | } |
346 | rePopulate(); | 346 | rePopulate(); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | 349 | ||
350 | void AdvancedFm::copyAsTimer() { | 350 | void AdvancedFm::copyAsTimer() { |
351 | QTimer::singleShot(125,this,SLOT(copyAs())); | 351 | QTimer::singleShot(125,this,SLOT(copyAs())); |
352 | } | 352 | } |
353 | 353 | ||
354 | void AdvancedFm::copyAs() { | 354 | void AdvancedFm::copyAs() { |
355 | 355 | ||
356 | QStringList curFileList = getPath(); | 356 | QStringList curFileList = getPath(); |
357 | QString curFile, item; | 357 | QString curFile, item; |
358 | InputDialog *fileDlg; | 358 | InputDialog *fileDlg; |
359 | 359 | ||
360 | QDir *thisDir = CurrentDir(); | 360 | QDir *thisDir = CurrentDir(); |
361 | QDir *thatDir = OtherDir(); | 361 | QDir *thatDir = OtherDir(); |
362 | 362 | ||
363 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 363 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
364 | QString destFile; | 364 | QString destFile; |
365 | item=(*it); | 365 | item=(*it); |
366 | curFile = thisDir->canonicalPath()+"/"+(*it); | 366 | curFile = thisDir->canonicalPath()+"/"+(*it); |
367 | fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); | 367 | fileDlg = new InputDialog( this, tr("Copy %1 As").arg(curFile), TRUE, 0); |
368 | 368 | ||
369 | fileDlg->setInputText((const QString &) destFile ); | 369 | fileDlg->setInputText((const QString &) destFile ); |
370 | fileDlg->exec(); | 370 | fileDlg->exec(); |
371 | 371 | ||
372 | if( fileDlg->result() == 1 ) { | 372 | if( fileDlg->result() == 1 ) { |
373 | QString filename = fileDlg->LineEdit1->text(); | 373 | QString filename = fileDlg->LineEdit1->text(); |
374 | destFile = thatDir->canonicalPath()+"/"+filename; | 374 | destFile = thatDir->canonicalPath()+"/"+filename; |
375 | 375 | ||
376 | QFile f( destFile); | 376 | QFile f( destFile); |
377 | if( f.exists()) { | 377 | if( f.exists()) { |
378 | switch (QMessageBox::warning(this,tr("File Exists!"), | 378 | switch (QMessageBox::warning(this,tr("File Exists!"), |
379 | tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), | 379 | tr("<P> %1 already exists. Ok to overwrite?</p>").arg(item), |
380 | tr("Yes"),tr("No"),0,0,1) ) { | 380 | tr("Yes"),tr("No"),0,0,1) ) { |
381 | case 0: | 381 | case 0: |
382 | f.remove(); | 382 | f.remove(); |
383 | break; | 383 | break; |
384 | case 1: | 384 | case 1: |
385 | return; | 385 | return; |
386 | break; | 386 | break; |
387 | default: | 387 | default: |
388 | return; | 388 | return; |
389 | break; | 389 | break; |
390 | }; | 390 | }; |
391 | } | 391 | } |
392 | if( !copyFile( curFile, destFile) ) { | 392 | if( !copyFile( curFile, destFile) ) { |
393 | QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 393 | QMessageBox::message("AdvancedFm",tr("<p>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
394 | return; | 394 | return; |
395 | } | 395 | } |
396 | } | 396 | } |
397 | delete fileDlg; | 397 | delete fileDlg; |
398 | 398 | ||
399 | } | 399 | } |
400 | rePopulate(); | 400 | rePopulate(); |
401 | // setOtherTabCurrent(); | 401 | // setOtherTabCurrent(); |
402 | qApp->processEvents(); | 402 | qApp->processEvents(); |
403 | 403 | ||
404 | } | 404 | } |
405 | 405 | ||
406 | void AdvancedFm::copySameDirTimer() { | 406 | void AdvancedFm::copySameDirTimer() { |
407 | QTimer::singleShot(125,this,SLOT(copySameDir())); | 407 | QTimer::singleShot(125,this,SLOT(copySameDir())); |
408 | } | 408 | } |
409 | 409 | ||
410 | void AdvancedFm::copySameDir() { | 410 | void AdvancedFm::copySameDir() { |
411 | qApp->processEvents(); | 411 | qApp->processEvents(); |
412 | QStringList curFileList = getPath(); | 412 | QStringList curFileList = getPath(); |
413 | QString curFile, item, destFile; | 413 | QString curFile, item, destFile; |
414 | InputDialog *fileDlg; | 414 | InputDialog *fileDlg; |
415 | 415 | ||
416 | QDir *thisDir = CurrentDir(); | 416 | QDir *thisDir = CurrentDir(); |
417 | 417 | ||
418 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 418 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
419 | item=(*it); | 419 | item=(*it); |
420 | curFile = thisDir->canonicalPath()+"/"+ item; | 420 | curFile = thisDir->canonicalPath()+"/"+ item; |
421 | 421 | ||
422 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 422 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
423 | fileDlg->setInputText((const QString &) destFile ); | 423 | fileDlg->setInputText((const QString &) destFile ); |
424 | fileDlg->exec(); | 424 | fileDlg->exec(); |
425 | 425 | ||
426 | if( fileDlg->result() == 1 ) { | 426 | if( fileDlg->result() == 1 ) { |
427 | 427 | ||
428 | QString filename = fileDlg->LineEdit1->text(); | 428 | QString filename = fileDlg->LineEdit1->text(); |
429 | destFile = thisDir->canonicalPath()+"/"+filename; | 429 | destFile = thisDir->canonicalPath()+"/"+filename; |
430 | 430 | ||
431 | QFile f(destFile); | 431 | QFile f(destFile); |
432 | if( f.exists()) { | 432 | if( f.exists()) { |
433 | switch (QMessageBox::warning(this,tr("Delete"), | 433 | switch (QMessageBox::warning(this,tr("Delete"), |
434 | tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), | 434 | tr("<p> %1 already exists. Do you really want to delete it?</P>").arg(destFile), |
435 | tr("Yes"),tr("No"),0,0,1) ) { | 435 | tr("Yes"),tr("No"),0,0,1) ) { |
436 | case 0: | 436 | case 0: |
437 | f.remove(); | 437 | f.remove(); |
438 | break; | 438 | break; |
439 | case 1: | 439 | case 1: |
440 | return; | 440 | return; |
441 | break; | 441 | break; |
442 | default: | 442 | default: |
443 | return; | 443 | return; |
444 | break; | 444 | break; |
445 | }; | 445 | }; |
446 | } | 446 | } |
447 | if(!copyFile( curFile,destFile) ) { | 447 | if(!copyFile( curFile,destFile) ) { |
448 | QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); | 448 | QMessageBox::message("AdvancedFm",tr("<P>Could not copy %1 to %2</P>").arg(curFile).arg(destFile)); |
449 | return; | 449 | return; |
450 | } | 450 | } |
451 | 451 | ||
452 | // odebug << "copy "+curFile+" as "+destFile << oendl; | 452 | // odebug << "copy "+curFile+" as "+destFile << oendl; |
453 | } | 453 | } |
454 | delete fileDlg; | 454 | delete fileDlg; |
455 | } | 455 | } |
456 | rePopulate(); | 456 | rePopulate(); |
457 | } | 457 | } |
458 | 458 | ||
459 | void AdvancedFm::moveTimer() { | 459 | void AdvancedFm::moveTimer() { |
460 | QTimer::singleShot(125,this,SLOT(move())); | 460 | QTimer::singleShot(125,this,SLOT(move())); |
461 | } | 461 | } |
462 | 462 | ||
463 | void AdvancedFm::move() { | 463 | void AdvancedFm::move() { |
464 | 464 | ||
465 | QStringList curFileList = getPath(); | 465 | QStringList curFileList = getPath(); |
466 | if( curFileList.count() > 0) { | 466 | if( curFileList.count() > 0) { |
467 | QString curFile, destFile, item; | 467 | QString curFile, destFile, item; |
468 | 468 | ||
469 | QDir *thisDir = CurrentDir(); | 469 | QDir *thisDir = CurrentDir(); |
470 | QDir *thatDir = OtherDir(); | 470 | QDir *thatDir = OtherDir(); |
471 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 471 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
472 | item=(*it); | 472 | item=(*it); |
473 | QString destFile = thatDir->canonicalPath(); | 473 | QString destFile = thatDir->canonicalPath(); |
474 | 474 | ||
475 | if(destFile.right(1).find("/",0,TRUE) == -1) | 475 | if(destFile.right(1).find("/",0,TRUE) == -1) |
476 | destFile+="/"; | 476 | destFile+="/"; |
477 | destFile += item; | 477 | destFile += item; |
478 | // odebug << "Destination file is "+destFile << oendl; | 478 | // odebug << "Destination file is "+destFile << oendl; |
479 | 479 | ||
480 | curFile = thisDir->canonicalPath(); | 480 | curFile = thisDir->canonicalPath(); |
481 | if(curFile.right(1).find("/",0,TRUE) == -1) | 481 | if(curFile.right(1).find("/",0,TRUE) == -1) |
482 | curFile +="/"; | 482 | curFile +="/"; |
483 | curFile+= item; | 483 | curFile+= item; |
484 | // odebug << "CurrentFile file is " + curFile << oendl; | 484 | // odebug << "CurrentFile file is " + curFile << oendl; |
485 | 485 | ||
486 | if(QFileInfo(curFile).isDir()) { | 486 | if(QFileInfo(curFile).isDir()) { |
487 | moveDirectory( curFile, destFile ); | 487 | moveDirectory( curFile, destFile ); |
488 | rePopulate(); | 488 | rePopulate(); |
489 | return; | 489 | return; |
490 | } | 490 | } |
491 | QFile f( destFile); | 491 | QFile f( destFile); |
492 | if( f.exists()) { | 492 | if( f.exists()) { |
493 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 493 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
494 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), | 494 | tr("<p>%1 already exists. Ok to overwrite?</P>").arg(destFile), |
495 | tr("Yes"),tr("No"),0,0,1)) { | 495 | tr("Yes"),tr("No"),0,0,1)) { |
496 | case 0: | 496 | case 0: |
497 | break; | 497 | break; |
498 | case 1: | 498 | case 1: |
499 | return; | 499 | return; |
500 | break; | 500 | break; |
501 | default: | 501 | default: |
502 | return; | 502 | return; |
503 | break; | 503 | break; |
504 | }; | 504 | }; |
505 | } | 505 | } |
506 | if( !copyFile( curFile, destFile) ) { | 506 | if( !copyFile( curFile, destFile) ) { |
507 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile)); | 507 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg(curFile)); |
508 | return; | 508 | return; |
509 | } else | 509 | } else |
510 | QFile::remove(curFile); | 510 | QFile::remove(curFile); |
511 | } | 511 | } |
512 | } | 512 | } |
513 | rePopulate(); | 513 | rePopulate(); |
514 | //setOtherTabCurrent(); | 514 | //setOtherTabCurrent(); |
515 | } | 515 | } |
516 | 516 | ||
517 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { | 517 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { |
518 | int err = 0; | 518 | int err = 0; |
519 | if( copyDirectory( src, dest ) ) { | 519 | if( copyDirectory( src, dest ) ) { |
520 | QString cmd = "rm -rf " + src; | 520 | QString cmd = "rm -rf " + src; |
521 | err = system((const char*)cmd); | 521 | err = system((const char*)cmd); |
522 | } else | 522 | } else |
523 | err = -1; | 523 | err = -1; |
524 | 524 | ||
525 | if(err!=0) { | 525 | if(err!=0) { |
526 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src)); | 526 | QMessageBox::message(tr("Note"),tr("<p>Could not move %1</p>").arg( src)); |
527 | return false; | 527 | return false; |
528 | } | 528 | } |
529 | return true; | 529 | return true; |
530 | } | 530 | } |
531 | 531 | ||
532 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { | 532 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { |
533 | 533 | ||
534 | QString cmd = "/bin/cp -fpR " + src + " " + dest; | 534 | QString cmd = "/bin/cp -fpR " + src + " " + dest; |
535 | owarn << cmd << oendl; | 535 | owarn << cmd << oendl; |
536 | int err = system( (const char *) cmd ); | 536 | int err = system( (const char *) cmd ); |
537 | if ( err != 0 ) { | 537 | if ( err != 0 ) { |
538 | QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) ); | 538 | QMessageBox::message("AdvancedFm", tr( "<p>Could not copy %1 to %2</p>").arg( src ).arg( dest ) ); |
539 | return false; | 539 | return false; |
540 | } | 540 | } |
541 | 541 | ||
542 | return true; | 542 | return true; |
543 | } | 543 | } |
544 | 544 | ||
545 | 545 | ||
546 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 546 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
547 | if(QFileInfo(src).isDir()) { | 547 | if(QFileInfo(src).isDir()) { |
548 | if( copyDirectory( src, dest )) { | 548 | if( copyDirectory( src, dest )) { |
549 | // setOtherTabCurrent(); | 549 | // setOtherTabCurrent(); |
550 | rePopulate(); | 550 | rePopulate(); |
551 | return true; | 551 | return true; |
552 | } | 552 | } |
553 | else | 553 | else |
554 | return false; | 554 | return false; |
555 | } | 555 | } |
556 | 556 | ||
557 | 557 | ||
558 | bool success = true; | 558 | bool success = true; |
559 | struct stat status; | 559 | struct stat status; |
560 | QFile srcFile(src); | 560 | QFile srcFile(src); |
561 | QFile destFile(dest); | 561 | QFile destFile(dest); |
562 | int err=0; | 562 | int err=0; |
563 | int read_fd=0; | 563 | int read_fd=0; |
564 | int write_fd=0; | 564 | int write_fd=0; |
565 | struct stat stat_buf; | 565 | struct stat stat_buf; |
566 | off_t offset = 0; | 566 | off_t offset = 0; |
567 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | 567 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
568 | // owarn << "open failed" << oendl; | 568 | // owarn << "open failed" << oendl; |
569 | return success = false; | 569 | return success = false; |
570 | } | 570 | } |
571 | read_fd = srcFile.handle(); | 571 | read_fd = srcFile.handle(); |
572 | if(read_fd != -1) { | 572 | if(read_fd != -1) { |
573 | fstat (read_fd, &stat_buf); | 573 | fstat (read_fd, &stat_buf); |
574 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { | 574 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { |
575 | // owarn << "destfile open failed" << oendl; | 575 | // owarn << "destfile open failed" << oendl; |
576 | return success = false; | 576 | return success = false; |
577 | } | 577 | } |
578 | write_fd = destFile.handle(); | 578 | write_fd = destFile.handle(); |
579 | if(write_fd != -1) { | 579 | if(write_fd != -1) { |
580 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 580 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
581 | if( err == -1) { | 581 | if( err == -1) { |
582 | QString msg; | 582 | QString msg; |
583 | switch(err) { | 583 | switch(err) { |
584 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; | 584 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; |
585 | case EINVAL: msg = "Descriptor is not valid or locked. "; | 585 | case EINVAL: msg = "Descriptor is not valid or locked. "; |
586 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; | 586 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; |
587 | case EIO: msg = "Unspecified error while reading from in_fd."; | 587 | case EIO: msg = "Unspecified error while reading from in_fd."; |
588 | }; | 588 | }; |
589 | success = false; | 589 | success = false; |
590 | // owarn << msg << oendl; | 590 | // owarn << msg << oendl; |
591 | } | 591 | } |
592 | } else { | 592 | } else { |
593 | success = false; | 593 | success = false; |
594 | } | 594 | } |
595 | } else { | 595 | } else { |
596 | success = false; | 596 | success = false; |
597 | } | 597 | } |
598 | srcFile.close(); | 598 | srcFile.close(); |
599 | destFile.close(); | 599 | destFile.close(); |
600 | // Set file permissions | 600 | // Set file permissions |
601 | if( stat( QFile::encodeName(src), &status ) == 0 ) { | 601 | if( stat( QFile::encodeName(src), &status ) == 0 ) { |
602 | chmod( QFile::encodeName(dest), status.st_mode ); | 602 | chmod( QFile::encodeName(dest), status.st_mode ); |
603 | } | 603 | } |
604 | 604 | ||
605 | return success; | 605 | return success; |
606 | } | 606 | } |
607 | 607 | ||
608 | void AdvancedFm::runCommand() { | 608 | void AdvancedFm::runCommand() { |
609 | if( !CurrentView()->currentItem()) return; | 609 | if( !CurrentView()->currentItem()) return; |
610 | QDir *thisDir = CurrentDir(); | 610 | QDir *thisDir = CurrentDir(); |
611 | 611 | ||
612 | QString curFile; | 612 | QString curFile; |
613 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 613 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
614 | 614 | ||
615 | InputDialog *fileDlg; | 615 | InputDialog *fileDlg; |
616 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 616 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
617 | fileDlg->setInputText(curFile); | 617 | fileDlg->setInputText(curFile); |
618 | fileDlg->exec(); | 618 | fileDlg->exec(); |
619 | //QString command; | 619 | //QString command; |
620 | 620 | ||
621 | if( fileDlg->result() == 1 ) { | 621 | if( fileDlg->result() == 1 ) { |
622 | // odebug << fileDlg->LineEdit1->text() << oendl; | 622 | // odebug << fileDlg->LineEdit1->text() << oendl; |
623 | QStringList command; | 623 | QStringList command; |
624 | 624 | ||
625 | command << "/bin/sh"; | 625 | command << "/bin/sh"; |
626 | command << "-c"; | 626 | command << "-c"; |
627 | command << fileDlg->LineEdit1->text(); | 627 | command << fileDlg->LineEdit1->text(); |
628 | Output *outDlg; | 628 | Output *outDlg; |
629 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 629 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
630 | QPEApplication::execDialog( outDlg ); | 630 | QPEApplication::execDialog( outDlg ); |
631 | qApp->processEvents(); | 631 | qApp->processEvents(); |
632 | 632 | ||
633 | } | 633 | } |
634 | } | 634 | } |
635 | 635 | ||
636 | void AdvancedFm::runCommandStd() { | 636 | void AdvancedFm::runCommandStd() { |
637 | if( !CurrentView()->currentItem()) return; | 637 | if( !CurrentView()->currentItem()) return; |
638 | QString curFile; | 638 | QString curFile; |
639 | QDir *thisDir = CurrentDir(); | 639 | QDir *thisDir = CurrentDir(); |
640 | QListView *thisView = CurrentView(); | 640 | QListView *thisView = CurrentView(); |
641 | if( thisView->currentItem()) | 641 | if( thisView->currentItem()) |
642 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 642 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
643 | 643 | ||
644 | InputDialog *fileDlg; | 644 | InputDialog *fileDlg; |
645 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 645 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
646 | fileDlg->setInputText(curFile); | 646 | fileDlg->setInputText(curFile); |
647 | fileDlg->exec(); | 647 | fileDlg->exec(); |
648 | 648 | ||
649 | if( fileDlg->result() == 1 ) { | 649 | if( fileDlg->result() == 1 ) { |
650 | qApp->processEvents(); | 650 | qApp->processEvents(); |
651 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 651 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
652 | } | 652 | } |
653 | } | 653 | } |
654 | 654 | ||
655 | void AdvancedFm::fileStatus() { | 655 | void AdvancedFm::fileStatus() { |
656 | if( !CurrentView()->currentItem()) return; | 656 | if( !CurrentView()->currentItem()) return; |
657 | QString curFile; | 657 | QString curFile; |
658 | curFile = CurrentView()->currentItem()->text(0); | 658 | curFile = CurrentView()->currentItem()->text(0); |
659 | 659 | ||
660 | QStringList command; | 660 | QStringList command; |
661 | command << "/bin/sh"; | 661 | command << "/bin/sh"; |
662 | command << "-c"; | 662 | command << "-c"; |
663 | command << "stat -l "+ curFile; | 663 | command << "stat -l "+ curFile; |
664 | 664 | ||
665 | Output *outDlg; | 665 | Output *outDlg; |
666 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 666 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
667 | QPEApplication::execDialog( outDlg ); | 667 | QPEApplication::execDialog( outDlg ); |
668 | qApp->processEvents(); | 668 | qApp->processEvents(); |
669 | } | 669 | } |
670 | 670 | ||
671 | 671 | ||
672 | void AdvancedFm::mkDir() { | 672 | void AdvancedFm::mkDir() { |
673 | makeDir(); | 673 | makeDir(); |
674 | } | 674 | } |
675 | 675 | ||
676 | void AdvancedFm::rn() { | 676 | void AdvancedFm::rn() { |
677 | renameIt(); | 677 | renameIt(); |
678 | } | 678 | } |
679 | 679 | ||
680 | void AdvancedFm::del() { | 680 | void AdvancedFm::del() { |
681 | doDelete(); | 681 | doDelete(); |
682 | } | 682 | } |
683 | 683 | ||
684 | void AdvancedFm::mkSym() { | 684 | void AdvancedFm::mkSym() { |
685 | QString cmd; | 685 | QString cmd; |
686 | QStringList curFileList = getPath(); | 686 | QStringList curFileList = getPath(); |
687 | if( curFileList.count() > 0) { | 687 | if( curFileList.count() > 0) { |
688 | QDir *thisDir = CurrentDir(); | 688 | QDir *thisDir = CurrentDir(); |
689 | QDir * thatDir = OtherDir(); | 689 | QDir * thatDir = OtherDir(); |
690 | 690 | ||
691 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 691 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
692 | 692 | ||
693 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 693 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
694 | if(destName.right(1) == "/") { | 694 | if(destName.right(1) == "/") { |
695 | destName = destName.left( destName.length() -1); | 695 | destName = destName.left( destName.length() -1); |
696 | } | 696 | } |
697 | 697 | ||
698 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 698 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
699 | 699 | ||
700 | if( curFile.right(1) == "/") { | 700 | if( curFile.right(1) == "/") { |
701 | curFile = curFile.left( curFile.length() -1); | 701 | curFile = curFile.left( curFile.length() -1); |
702 | } | 702 | } |
703 | 703 | ||
704 | cmd = "ln -s "+curFile+" "+destName; | 704 | cmd = "ln -s "+curFile+" "+destName; |
705 | // odebug << cmd << oendl; | 705 | // odebug << cmd << oendl; |
706 | startProcess( (const QString)cmd ); | 706 | startProcess( (const QString)cmd ); |
707 | } | 707 | } |
708 | rePopulate(); | 708 | rePopulate(); |
709 | setOtherTabCurrent(); | 709 | setOtherTabCurrent(); |
710 | } | 710 | } |
711 | } | 711 | } |