author | cniehaus <cniehaus> | 2003-05-17 18:17:11 (UTC) |
---|---|---|
committer | cniehaus <cniehaus> | 2003-05-17 18:17:11 (UTC) |
commit | 982d7a64a7526379fc0f3b0ae64fdcce430775ff (patch) (unidiff) | |
tree | fedd5d50bb4cdfd923a9deb09e8cd6c19f8b2e31 | |
parent | 325096fb28d129429b17a781c4c1e8d6ca9aa585 (diff) | |
download | opie-982d7a64a7526379fc0f3b0ae64fdcce430775ff.zip opie-982d7a64a7526379fc0f3b0ae64fdcce430775ff.tar.gz opie-982d7a64a7526379fc0f3b0ae64fdcce430775ff.tar.bz2 |
ported to HEAD
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 2201960..9f21245 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,896 +1,905 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | #include "output.h" | 13 | #include "output.h" |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <opie/otabwidget.h> | 16 | #include <opie/otabwidget.h> |
17 | #include <opie/oprocess.h> | 17 | #include <opie/oprocess.h> |
18 | 18 | ||
19 | #include <qpe/lnkproperties.h> | 19 | #include <qpe/lnkproperties.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/applnk.h> | 23 | #include <qpe/applnk.h> |
24 | #include <qpe/ir.h> | 24 | #include <qpe/ir.h> |
25 | 25 | ||
26 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
27 | #include <qmultilineedit.h> | 27 | #include <qmultilineedit.h> |
28 | 28 | ||
29 | #include <qstring.h> | 29 | #include <qstring.h> |
30 | 30 | ||
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | #include <qpixmap.h> | 32 | #include <qpixmap.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtabwidget.h> | 35 | #include <qtabwidget.h> |
36 | #include <qtoolbutton.h> | 36 | #include <qtoolbutton.h> |
37 | #include <qtabwidget.h> | 37 | #include <qtabwidget.h> |
38 | #include <qlineedit.h> | 38 | #include <qlineedit.h> |
39 | #include <qlistview.h> | 39 | #include <qlistview.h> |
40 | 40 | ||
41 | #include <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 | void AdvancedFm::doDirChange() | 48 | void AdvancedFm::doDirChange() |
49 | { | 49 | { |
50 | ListClicked( CurrentView()->currentItem()); | 50 | ListClicked( CurrentView()->currentItem()); |
51 | } | 51 | } |
52 | 52 | ||
53 | void AdvancedFm::showMenuHidden() | 53 | void AdvancedFm::showMenuHidden() |
54 | { | 54 | { |
55 | if (b) | 55 | if (b) |
56 | { | 56 | { |
57 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 57 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
58 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 58 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
59 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 59 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
60 | // b=FALSE; | 60 | // b=FALSE; |
61 | 61 | ||
62 | } | 62 | } |
63 | else | 63 | else |
64 | { | 64 | { |
65 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 65 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
66 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 66 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
67 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 67 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
68 | // b=TRUE; | 68 | // b=TRUE; |
69 | } | 69 | } |
70 | rePopulate(); | 70 | rePopulate(); |
71 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); | 71 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); |
72 | if(b) b = false; else b = true; | 72 | if(b) b = false; else b = true; |
73 | } | 73 | } |
74 | 74 | ||
75 | void AdvancedFm::showHidden() | 75 | void AdvancedFm::showHidden() |
76 | { | 76 | { |
77 | if (b) | 77 | if (b) |
78 | { | 78 | { |
79 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 79 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
80 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 80 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
81 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 81 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
82 | // b=FALSE; | 82 | // b=FALSE; |
83 | 83 | ||
84 | } | 84 | } |
85 | else | 85 | else |
86 | { | 86 | { |
87 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 87 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
88 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 88 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
89 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 89 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
90 | // b=TRUE; | 90 | // b=TRUE; |
91 | } | 91 | } |
92 | rePopulate(); | 92 | rePopulate(); |
93 | } | 93 | } |
94 | 94 | ||
95 | QString AdvancedFm::dealWithSymName(const QString &fileName) | 95 | QString AdvancedFm::dealWithSymName(const QString &fileName) |
96 | { | 96 | { |
97 | QString strItem = fileName; | 97 | QString strItem = fileName; |
98 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 98 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
99 | } | 99 | } |
100 | 100 | ||
101 | void AdvancedFm::runThis() | 101 | void AdvancedFm::runThis() |
102 | { | 102 | { |
103 | QString fs; | 103 | QString fs; |
104 | QDir *thisDir = CurrentDir(); | 104 | QDir *thisDir = CurrentDir(); |
105 | 105 | ||
106 | QString curFile = CurrentView()->currentItem()->text(0); | 106 | QString curFile = CurrentView()->currentItem()->text(0); |
107 | QString path = thisDir->canonicalPath(); | 107 | QString path = thisDir->canonicalPath(); |
108 | 108 | ||
109 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 109 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
110 | 110 | ||
111 | curFile = dealWithSymName((const QString&)curFile); | 111 | curFile = dealWithSymName((const QString&)curFile); |
112 | 112 | ||
113 | if(curFile != "../") | 113 | if(curFile != "../") |
114 | { | 114 | { |
115 | 115 | ||
116 | fs = getFileSystemType((const QString &) path); | 116 | fs = getFileSystemType((const QString &) path); |
117 | QFileInfo fileInfo( path + "/" + curFile); | 117 | QFileInfo fileInfo( path + "/" + curFile); |
118 | qDebug( fileInfo.owner()); | 118 | qDebug( fileInfo.owner()); |
119 | 119 | ||
120 | if( (fileInfo.permission( QFileInfo::ExeUser) | 120 | if( (fileInfo.permission( QFileInfo::ExeUser) |
121 | | fileInfo.permission( QFileInfo::ExeGroup) | 121 | | fileInfo.permission( QFileInfo::ExeGroup) |
122 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 122 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
123 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 123 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
124 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 124 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
125 | e << curFile; | 125 | e << curFile; |
126 | } | 126 | } |
127 | else | 127 | else |
128 | { | 128 | { |
129 | curFile = path + "/" + curFile; | 129 | curFile = path + "/" + curFile; |
130 | DocLnk nf(curFile); | 130 | DocLnk nf(curFile); |
131 | QString execStr = nf.exec(); | 131 | QString execStr = nf.exec(); |
132 | qDebug( execStr); | 132 | qDebug( execStr); |
133 | if( execStr.isEmpty() ) | 133 | if( execStr.isEmpty() ) |
134 | { | 134 | { |
135 | } | 135 | } |
136 | else | 136 | else |
137 | { | 137 | { |
138 | nf.execute(); | 138 | nf.execute(); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | void AdvancedFm::runText() | 144 | void AdvancedFm::runText() |
145 | { | 145 | { |
146 | QString curFile = CurrentView()->currentItem()->text(0); | 146 | QString curFile = CurrentView()->currentItem()->text(0); |
147 | if(curFile != "../") | 147 | if(curFile != "../") |
148 | { | 148 | { |
149 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 149 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
150 | curFile = dealWithSymName((const QString&)curFile); | 150 | curFile = dealWithSymName((const QString&)curFile); |
151 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; | 151 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; |
152 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 152 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
153 | e << curFile; | 153 | e << curFile; |
154 | } | 154 | } |
155 | } | 155 | } |
156 | 156 | ||
157 | void AdvancedFm::makeDir() | 157 | void AdvancedFm::makeDir() |
158 | { | 158 | { |
159 | InputDialog *fileDlg; | 159 | InputDialog *fileDlg; |
160 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 160 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
161 | fileDlg->exec(); | 161 | fileDlg->exec(); |
162 | if( fileDlg->result() == 1 ) | 162 | if( fileDlg->result() == 1 ) |
163 | { | 163 | { |
164 | QDir *thisDir = CurrentDir(); | 164 | QDir *thisDir = CurrentDir(); |
165 | QString filename = fileDlg->LineEdit1->text(); | 165 | QString filename = fileDlg->LineEdit1->text(); |
166 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 166 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
167 | } | 167 | } |
168 | populateView(); | 168 | populateView(); |
169 | } | 169 | } |
170 | 170 | ||
171 | void AdvancedFm::doDelete() | 171 | void AdvancedFm::doDelete() |
172 | { | 172 | { |
173 | 173 | ||
174 | QStringList curFileList = getPath(); | 174 | QStringList curFileList = getPath(); |
175 | bool doMsg=true; | 175 | bool doMsg=true; |
176 | int count = curFileList.count(); | 176 | int count = curFileList.count(); |
177 | if( count > 0) | 177 | if( count > 0) |
178 | { | 178 | { |
179 | if(count > 1 ) | 179 | if(count > 1 ) |
180 | { | 180 | { |
181 | QString msg; | 181 | QString msg; |
182 | msg=tr("Really delete\n%1 files?").arg(count); | 182 | msg=tr("Really delete\n%1 files?").arg(count); |
183 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 183 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
184 | ,tr("Yes"),tr("No"),0,0,1) ) | 184 | ,tr("Yes"),tr("No"),0,0,1) ) |
185 | { | 185 | { |
186 | case 0: | 186 | case 0: |
187 | doMsg=false; | 187 | doMsg=false; |
188 | break; | 188 | break; |
189 | case 1: | 189 | case 1: |
190 | return; | 190 | return; |
191 | break; | 191 | break; |
192 | }; | 192 | }; |
193 | } | 193 | } |
194 | 194 | ||
195 | QString myFile; | 195 | QString myFile; |
196 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 196 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
197 | { | 197 | { |
198 | myFile = (*it); | 198 | myFile = (*it); |
199 | if( myFile.find(" -> ",0,TRUE) != -1) | 199 | if( myFile.find(" -> ",0,TRUE) != -1) |
200 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 200 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
201 | 201 | ||
202 | QString f = CurrentDir()->canonicalPath(); | 202 | QString f = CurrentDir()->canonicalPath(); |
203 | if(f.right(1).find("/",0,TRUE) == -1) | 203 | if(f.right(1).find("/",0,TRUE) == -1) |
204 | f += "/"; | 204 | f += "/"; |
205 | f += myFile; | 205 | f += myFile; |
206 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) //if file is a directory | 206 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) //if file is a directory |
207 | { | 207 | { |
208 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), tr("Really delete\n") + f + | 208 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), |
209 | "\nand all it's contents ?" | 209 | tr("Really delete %1\nand all it's contents ?" ).arg( f ) , |
210 | ,tr("Yes"),tr("No"),0,0,1) ) | 210 | tr("Yes"), |
211 | tr("No"), | ||
212 | 0, | ||
213 | 0, | ||
214 | 1) ) | ||
211 | { | 215 | { |
212 | case 0: | 216 | case 0: |
213 | { | 217 | { |
214 | f=f.left(f.length()-1); | 218 | f=f.left(f.length()-1); |
215 | QString cmd="rm -rf "+f; | 219 | QString cmd="rm -rf "+f; |
216 | startProcess( (const QString)cmd.latin1() ); | 220 | startProcess( (const QString)cmd.latin1() ); |
217 | populateView(); | 221 | populateView(); |
218 | } | 222 | } |
219 | break; | 223 | break; |
220 | case 1: | 224 | case 1: |
221 | // exit | 225 | // exit |
222 | break; | 226 | break; |
223 | }; | 227 | }; |
224 | 228 | ||
225 | } else { | 229 | } else { |
226 | if(doMsg) { | 230 | if(doMsg) { |
227 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f | 231 | switch ( QMessageBox::warning(this,tr("Delete"), |
228 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 232 | tr("Really delete\n%1?").arg( f ), |
233 | tr("Yes"), | ||
234 | tr("No"), | ||
235 | 0, | ||
236 | 0, | ||
237 | 1) ) { | ||
229 | case 1: | 238 | case 1: |
230 | return; | 239 | return; |
231 | break; | 240 | break; |
232 | }; | 241 | }; |
233 | } | 242 | } |
234 | QString cmd="rm "+f; | 243 | QString cmd="rm "+f; |
235 | QFile file(f); | 244 | QFile file(f); |
236 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) { | 245 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) { |
237 | qDebug("remove link files "+f); | 246 | qDebug("remove link files "+f); |
238 | // AppLnk lnk(f); | 247 | // AppLnk lnk(f); |
239 | // qDebug(lnk.linkFile()); | 248 | // qDebug(lnk.linkFile()); |
240 | // lnk.removeLinkFile(); | 249 | // lnk.removeLinkFile(); |
241 | file.remove(); | 250 | file.remove(); |
242 | } | 251 | } |
243 | } | 252 | } |
244 | } | 253 | } |
245 | } | 254 | } |
246 | populateView(); | 255 | populateView(); |
247 | } | 256 | } |
248 | 257 | ||
249 | void AdvancedFm::filePerms() | 258 | void AdvancedFm::filePerms() |
250 | { | 259 | { |
251 | QStringList curFileList = getPath(); | 260 | QStringList curFileList = getPath(); |
252 | QString filePath; | 261 | QString filePath; |
253 | 262 | ||
254 | filePath = CurrentDir()->canonicalPath()+"/"; | 263 | filePath = CurrentDir()->canonicalPath()+"/"; |
255 | 264 | ||
256 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 265 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
257 | { | 266 | { |
258 | filePermissions *filePerm; | 267 | filePermissions *filePerm; |
259 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 268 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
260 | filePerm->showMaximized(); | 269 | filePerm->showMaximized(); |
261 | filePerm->exec(); | 270 | filePerm->exec(); |
262 | if( filePerm) | 271 | if( filePerm) |
263 | delete filePerm; | 272 | delete filePerm; |
264 | } | 273 | } |
265 | populateView(); | 274 | populateView(); |
266 | } | 275 | } |
267 | 276 | ||
268 | void AdvancedFm::doProperties() | 277 | void AdvancedFm::doProperties() |
269 | { | 278 | { |
270 | #if defined(QT_QWS_OPIE) | 279 | #if defined(QT_QWS_OPIE) |
271 | 280 | ||
272 | QStringList curFileList = getPath(); | 281 | QStringList curFileList = getPath(); |
273 | 282 | ||
274 | QString filePath; | 283 | QString filePath; |
275 | filePath = CurrentDir()->canonicalPath()+"/"; | 284 | filePath = CurrentDir()->canonicalPath()+"/"; |
276 | 285 | ||
277 | qDebug("%d",curFileList.count()); | 286 | qDebug("%d",curFileList.count()); |
278 | 287 | ||
279 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 288 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
280 | { | 289 | { |
281 | qDebug((filePath+*it)); | 290 | qDebug((filePath+*it)); |
282 | DocLnk lnk( (filePath+*it)); | 291 | DocLnk lnk( (filePath+*it)); |
283 | LnkProperties prop( &lnk ); | 292 | LnkProperties prop( &lnk ); |
284 | prop.showMaximized(); | 293 | prop.showMaximized(); |
285 | prop.exec(); | 294 | prop.exec(); |
286 | } | 295 | } |
287 | #endif | 296 | #endif |
288 | 297 | ||
289 | } | 298 | } |
290 | 299 | ||
291 | void AdvancedFm::upDir() | 300 | void AdvancedFm::upDir() |
292 | { | 301 | { |
293 | QDir *thisDir = CurrentDir(); | 302 | QDir *thisDir = CurrentDir(); |
294 | QString current = thisDir->canonicalPath(); | 303 | QString current = thisDir->canonicalPath(); |
295 | QDir dir(current); | 304 | QDir dir(current); |
296 | dir.cdUp(); | 305 | dir.cdUp(); |
297 | current = dir.canonicalPath(); | 306 | current = dir.canonicalPath(); |
298 | chdir( current.latin1() ); | 307 | chdir( current.latin1() ); |
299 | thisDir->cd( current, TRUE); | 308 | thisDir->cd( current, TRUE); |
300 | 309 | ||
301 | populateView(); | 310 | populateView(); |
302 | update(); | 311 | update(); |
303 | } | 312 | } |
304 | 313 | ||
305 | void AdvancedFm::copy() | 314 | void AdvancedFm::copy() |
306 | { | 315 | { |
307 | qApp->processEvents(); | 316 | qApp->processEvents(); |
308 | QStringList curFileList = getPath(); | 317 | QStringList curFileList = getPath(); |
309 | 318 | ||
310 | QDir *thisDir = CurrentDir(); | 319 | QDir *thisDir = CurrentDir(); |
311 | QDir *thatDir = OtherDir(); | 320 | QDir *thatDir = OtherDir(); |
312 | 321 | ||
313 | bool doMsg=true; | 322 | bool doMsg=true; |
314 | int count=curFileList.count(); | 323 | int count=curFileList.count(); |
315 | if( count > 0) { | 324 | if( count > 0) { |
316 | if(count > 1 ){ | 325 | if(count > 1 ){ |
317 | QString msg; | 326 | QString msg; |
318 | msg=tr("Really copy\n%1 files?").arg(count); | 327 | msg=tr("Really copy\n%1 files?").arg(count); |
319 | switch ( QMessageBox::warning(this,tr("Copy"),msg | 328 | switch ( QMessageBox::warning(this,tr("Copy"),msg |
320 | ,tr("Yes"),tr("No"),0,0,1) ) | 329 | ,tr("Yes"),tr("No"),0,0,1) ) |
321 | { | 330 | { |
322 | case 0: | 331 | case 0: |
323 | doMsg=false; | 332 | doMsg=false; |
324 | break; | 333 | break; |
325 | case 1: | 334 | case 1: |
326 | return; | 335 | return; |
327 | break; | 336 | break; |
328 | }; | 337 | }; |
329 | } | 338 | } |
330 | 339 | ||
331 | QString curFile, item, destFile; | 340 | QString curFile, item, destFile; |
332 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 341 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
333 | { | 342 | { |
334 | item=(*it); | 343 | item=(*it); |
335 | if(item.find("->",0,TRUE)) //symlink | 344 | if(item.find("->",0,TRUE)) //symlink |
336 | item = item.left(item.find("->",0,TRUE)); | 345 | item = item.left(item.find("->",0,TRUE)); |
337 | 346 | ||
338 | curFile = thisDir->canonicalPath()+"/"+ item; | 347 | curFile = thisDir->canonicalPath()+"/"+ item; |
339 | destFile = thatDir->canonicalPath()+"/"+ item; | 348 | destFile = thatDir->canonicalPath()+"/"+ item; |
340 | 349 | ||
341 | qDebug("Destination file is "+destFile); | 350 | qDebug("Destination file is "+destFile); |
342 | qDebug("CurrentFile file is " + curFile); | 351 | qDebug("CurrentFile file is " + curFile); |
343 | 352 | ||
344 | QFile f(destFile); | 353 | QFile f(destFile); |
345 | if( f.exists()) | 354 | if( f.exists()) |
346 | { | 355 | { |
347 | if(doMsg) | 356 | if(doMsg) |
348 | { | 357 | { |
349 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 358 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
350 | tr("%1 exists. Ok to overwrite?").arg( item ), | 359 | tr("%1 exists. Ok to overwrite?").arg( item ), |
351 | tr("Yes"),tr("No"),0,0,1) ) | 360 | tr("Yes"),tr("No"),0,0,1) ) |
352 | { | 361 | { |
353 | case 1: | 362 | case 1: |
354 | return; | 363 | return; |
355 | break; | 364 | break; |
356 | }; | 365 | }; |
357 | } | 366 | } |
358 | f.remove(); | 367 | f.remove(); |
359 | } | 368 | } |
360 | 369 | ||
361 | if( !copyFile( curFile, destFile) ) | 370 | if( !copyFile( curFile, destFile) ) |
362 | { | 371 | { |
363 | QMessageBox::message("AdvancedFm", | 372 | QMessageBox::message("AdvancedFm", |
364 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 373 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); |
365 | return; | 374 | return; |
366 | } | 375 | } |
367 | } | 376 | } |
368 | setOtherTabCurrent(); | 377 | setOtherTabCurrent(); |
369 | populateView(); | 378 | populateView(); |
370 | } | 379 | } |
371 | } | 380 | } |
372 | 381 | ||
373 | void AdvancedFm::copyAs() | 382 | void AdvancedFm::copyAs() |
374 | { | 383 | { |
375 | qApp->processEvents(); | 384 | qApp->processEvents(); |
376 | 385 | ||
377 | QStringList curFileList = getPath(); | 386 | QStringList curFileList = getPath(); |
378 | QString curFile, item; | 387 | QString curFile, item; |
379 | InputDialog *fileDlg; | 388 | InputDialog *fileDlg; |
380 | 389 | ||
381 | QDir *thisDir = CurrentDir(); | 390 | QDir *thisDir = CurrentDir(); |
382 | QDir *thatDir = OtherDir(); | 391 | QDir *thatDir = OtherDir(); |
383 | 392 | ||
384 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 393 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
385 | { | 394 | { |
386 | QString destFile; | 395 | QString destFile; |
387 | item=(*it); | 396 | item=(*it); |
388 | curFile = thisDir->canonicalPath()+"/"+(*it); | 397 | curFile = thisDir->canonicalPath()+"/"+(*it); |
389 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); | 398 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); |
390 | 399 | ||
391 | fileDlg->setInputText((const QString &) destFile ); | 400 | fileDlg->setInputText((const QString &) destFile ); |
392 | fileDlg->exec(); | 401 | fileDlg->exec(); |
393 | 402 | ||
394 | if( fileDlg->result() == 1 ) | 403 | if( fileDlg->result() == 1 ) |
395 | { | 404 | { |
396 | QString filename = fileDlg->LineEdit1->text(); | 405 | QString filename = fileDlg->LineEdit1->text(); |
397 | destFile = thatDir->canonicalPath()+"/"+filename; | 406 | destFile = thatDir->canonicalPath()+"/"+filename; |
398 | 407 | ||
399 | QFile f( destFile); | 408 | QFile f( destFile); |
400 | if( f.exists()) | 409 | if( f.exists()) |
401 | { | 410 | { |
402 | switch (QMessageBox::warning(this,tr("File Exists!"), | 411 | switch (QMessageBox::warning(this,tr("File Exists!"), |
403 | item+tr("\nexists. Ok to overwrite?"), | 412 | item+tr("\nexists. Ok to overwrite?"), |
404 | tr("Yes"),tr("No"),0,0,1) ) | 413 | tr("Yes"),tr("No"),0,0,1) ) |
405 | { | 414 | { |
406 | case 0: | 415 | case 0: |
407 | f.remove(); | 416 | f.remove(); |
408 | break; | 417 | break; |
409 | case 1: | 418 | case 1: |
410 | return; | 419 | return; |
411 | break; | 420 | break; |
412 | }; | 421 | }; |
413 | } | 422 | } |
414 | if( !copyFile( curFile, destFile) ) | 423 | if( !copyFile( curFile, destFile) ) |
415 | { | 424 | { |
416 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 425 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
417 | +curFile +tr("to\n")+destFile); | 426 | +curFile +tr("to\n")+destFile); |
418 | return; | 427 | return; |
419 | } | 428 | } |
420 | } | 429 | } |
421 | delete fileDlg; | 430 | delete fileDlg; |
422 | 431 | ||
423 | } | 432 | } |
424 | setOtherTabCurrent(); | 433 | setOtherTabCurrent(); |
425 | populateView(); | 434 | populateView(); |
426 | } | 435 | } |
427 | 436 | ||
428 | void AdvancedFm::copySameDir() | 437 | void AdvancedFm::copySameDir() |
429 | { | 438 | { |
430 | qApp->processEvents(); | 439 | qApp->processEvents(); |
431 | QStringList curFileList = getPath(); | 440 | QStringList curFileList = getPath(); |
432 | QString curFile, item, destFile; | 441 | QString curFile, item, destFile; |
433 | InputDialog *fileDlg; | 442 | InputDialog *fileDlg; |
434 | 443 | ||
435 | QDir *thisDir = CurrentDir(); | 444 | QDir *thisDir = CurrentDir(); |
436 | 445 | ||
437 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 446 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
438 | { | 447 | { |
439 | item=(*it); | 448 | item=(*it); |
440 | curFile = thisDir->canonicalPath()+"/"+ item; | 449 | curFile = thisDir->canonicalPath()+"/"+ item; |
441 | 450 | ||
442 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 451 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
443 | fileDlg->setInputText((const QString &) destFile ); | 452 | fileDlg->setInputText((const QString &) destFile ); |
444 | fileDlg->exec(); | 453 | fileDlg->exec(); |
445 | 454 | ||
446 | if( fileDlg->result() == 1 ) | 455 | if( fileDlg->result() == 1 ) |
447 | { | 456 | { |
448 | 457 | ||
449 | QString filename = fileDlg->LineEdit1->text(); | 458 | QString filename = fileDlg->LineEdit1->text(); |
450 | destFile = thisDir->canonicalPath()+"/"+filename; | 459 | destFile = thisDir->canonicalPath()+"/"+filename; |
451 | 460 | ||
452 | QFile f(destFile); | 461 | QFile f(destFile); |
453 | if( f.exists()) | 462 | if( f.exists()) |
454 | { | 463 | { |
455 | switch (QMessageBox::warning(this,tr("Delete"), | 464 | switch (QMessageBox::warning(this,tr("Delete"), |
456 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 465 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
457 | tr("Yes"),tr("No"),0,0,1) ) { | 466 | tr("Yes"),tr("No"),0,0,1) ) { |
458 | case 0: | 467 | case 0: |
459 | 468 | ||
460 | f.remove(); | 469 | f.remove(); |
461 | break; | 470 | break; |
462 | case 1: | 471 | case 1: |
463 | return; | 472 | return; |
464 | break; | 473 | break; |
465 | }; | 474 | }; |
466 | } | 475 | } |
467 | if(!copyFile( curFile,destFile) ) | 476 | if(!copyFile( curFile,destFile) ) |
468 | { | 477 | { |
469 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 478 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
470 | +curFile +tr("to\n")+destFile); | 479 | +curFile +tr("to\n")+destFile); |
471 | return; | 480 | return; |
472 | } | 481 | } |
473 | 482 | ||
474 | qDebug("copy "+curFile+" as "+destFile); | 483 | qDebug("copy "+curFile+" as "+destFile); |
475 | } | 484 | } |
476 | delete fileDlg; | 485 | delete fileDlg; |
477 | } | 486 | } |
478 | populateView(); | 487 | populateView(); |
479 | } | 488 | } |
480 | 489 | ||
481 | void AdvancedFm::move() | 490 | void AdvancedFm::move() |
482 | { | 491 | { |
483 | qApp->processEvents(); | 492 | qApp->processEvents(); |
484 | 493 | ||
485 | QStringList curFileList = getPath(); | 494 | QStringList curFileList = getPath(); |
486 | if( curFileList.count() > 0) | 495 | if( curFileList.count() > 0) |
487 | { | 496 | { |
488 | QString curFile, destFile, item; | 497 | QString curFile, destFile, item; |
489 | 498 | ||
490 | QDir *thisDir = CurrentDir(); | 499 | QDir *thisDir = CurrentDir(); |
491 | QDir *thatDir = OtherDir(); | 500 | QDir *thatDir = OtherDir(); |
492 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 501 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
493 | { | 502 | { |
494 | item=(*it); | 503 | item=(*it); |
495 | QString destFile = thatDir->canonicalPath(); | 504 | QString destFile = thatDir->canonicalPath(); |
496 | 505 | ||
497 | if(destFile.right(1).find("/",0,TRUE) == -1) | 506 | if(destFile.right(1).find("/",0,TRUE) == -1) |
498 | destFile+="/"; | 507 | destFile+="/"; |
499 | destFile += item; | 508 | destFile += item; |
500 | qDebug("Destination file is "+destFile); | 509 | qDebug("Destination file is "+destFile); |
501 | 510 | ||
502 | curFile = thisDir->canonicalPath(); | 511 | curFile = thisDir->canonicalPath(); |
503 | if(curFile.right(1).find("/",0,TRUE) == -1) | 512 | if(curFile.right(1).find("/",0,TRUE) == -1) |
504 | curFile +="/"; | 513 | curFile +="/"; |
505 | curFile+= item; | 514 | curFile+= item; |
506 | qDebug("CurrentFile file is " + curFile); | 515 | qDebug("CurrentFile file is " + curFile); |
507 | 516 | ||
508 | QFile f( curFile); | 517 | QFile f( curFile); |
509 | if( f.exists()) { | 518 | if( f.exists()) { |
510 | if( !copyFile( curFile, destFile) ) | 519 | if( !copyFile( curFile, destFile) ) |
511 | { | 520 | { |
512 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 521 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
513 | return; | 522 | return; |
514 | } else | 523 | } else |
515 | QFile::remove(curFile); | 524 | QFile::remove(curFile); |
516 | } | 525 | } |
517 | } | 526 | } |
518 | 527 | ||
519 | } | 528 | } |
520 | setOtherTabCurrent(); | 529 | setOtherTabCurrent(); |
521 | populateView(); | 530 | populateView(); |
522 | // populateLocalView(); | 531 | // populateLocalView(); |
523 | } | 532 | } |
524 | 533 | ||
525 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | 534 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) |
526 | { | 535 | { |
527 | // char bf[ 50000 ]; | 536 | // char bf[ 50000 ]; |
528 | // int bytesRead; | 537 | // int bytesRead; |
529 | bool success = true; | 538 | bool success = true; |
530 | struct stat status; | 539 | struct stat status; |
531 | 540 | ||
532 | // QFile s( src ); | 541 | // QFile s( src ); |
533 | // QFile d( dest ); | 542 | // QFile d( dest ); |
534 | 543 | ||
535 | int read_fd=0; | 544 | int read_fd=0; |
536 | int write_fd=0; | 545 | int write_fd=0; |
537 | struct stat stat_buf; | 546 | struct stat stat_buf; |
538 | off_t offset = 0; | 547 | off_t offset = 0; |
539 | read_fd = ::open(src.latin1(), O_RDONLY); | 548 | read_fd = ::open(src.latin1(), O_RDONLY); |
540 | if(read_fd != -1) { | 549 | if(read_fd != -1) { |
541 | fstat (read_fd, &stat_buf); | 550 | fstat (read_fd, &stat_buf); |
542 | write_fd = ::open(dest.latin1(), O_WRONLY | O_CREAT, stat_buf.st_mode); | 551 | write_fd = ::open(dest.latin1(), O_WRONLY | O_CREAT, stat_buf.st_mode); |
543 | if(write_fd != -1) { | 552 | if(write_fd != -1) { |
544 | if(sendfile(write_fd, read_fd, &offset, stat_buf.st_size) == -1) { | 553 | if(sendfile(write_fd, read_fd, &offset, stat_buf.st_size) == -1) { |
545 | success = false; | 554 | success = false; |
546 | } | 555 | } |
547 | } else { | 556 | } else { |
548 | success = false; | 557 | success = false; |
549 | } | 558 | } |
550 | } else { | 559 | } else { |
551 | success = false; | 560 | success = false; |
552 | } | 561 | } |
553 | 562 | ||
554 | ::close (read_fd); | 563 | ::close (read_fd); |
555 | ::close (write_fd); | 564 | ::close (write_fd); |
556 | 565 | ||
557 | 566 | ||
558 | // if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) | 567 | // if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) |
559 | // { | 568 | // { |
560 | // while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) | 569 | // while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) |
561 | // { | 570 | // { |
562 | // if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ | 571 | // if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){ |
563 | // success = FALSE; | 572 | // success = FALSE; |
564 | // break; | 573 | // break; |
565 | // } | 574 | // } |
566 | // } | 575 | // } |
567 | // if( success && (bytesRead > 0) ) | 576 | // if( success && (bytesRead > 0) ) |
568 | // { | 577 | // { |
569 | // d.writeBlock( bf, bytesRead ); | 578 | // d.writeBlock( bf, bytesRead ); |
570 | // } | 579 | // } |
571 | 580 | ||
572 | // } | 581 | // } |
573 | // else | 582 | // else |
574 | // { | 583 | // { |
575 | // success = FALSE; | 584 | // success = FALSE; |
576 | // } | 585 | // } |
577 | 586 | ||
578 | // Set file permissions | 587 | // Set file permissions |
579 | if( stat( (const char *) src, &status ) == 0 ) | 588 | if( stat( (const char *) src, &status ) == 0 ) |
580 | { | 589 | { |
581 | chmod( (const char *) dest, status.st_mode ); | 590 | chmod( (const char *) dest, status.st_mode ); |
582 | } | 591 | } |
583 | 592 | ||
584 | return success; | 593 | return success; |
585 | } | 594 | } |
586 | 595 | ||
587 | void AdvancedFm::runCommand() | 596 | void AdvancedFm::runCommand() |
588 | { | 597 | { |
589 | QDir *thisDir = CurrentDir(); | 598 | QDir *thisDir = CurrentDir(); |
590 | 599 | ||
591 | QString curFile; | 600 | QString curFile; |
592 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 601 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
593 | 602 | ||
594 | InputDialog *fileDlg; | 603 | InputDialog *fileDlg; |
595 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 604 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
596 | fileDlg->setInputText(curFile); | 605 | fileDlg->setInputText(curFile); |
597 | fileDlg->exec(); | 606 | fileDlg->exec(); |
598 | //QString command; | 607 | //QString command; |
599 | 608 | ||
600 | if( fileDlg->result() == 1 ) | 609 | if( fileDlg->result() == 1 ) |
601 | { | 610 | { |
602 | qDebug(fileDlg->LineEdit1->text()); | 611 | qDebug(fileDlg->LineEdit1->text()); |
603 | QStringList command; | 612 | QStringList command; |
604 | 613 | ||
605 | command << "/bin/sh"; | 614 | command << "/bin/sh"; |
606 | command << "-c"; | 615 | command << "-c"; |
607 | command << fileDlg->LineEdit1->text(); | 616 | command << fileDlg->LineEdit1->text(); |
608 | Output *outDlg; | 617 | Output *outDlg; |
609 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 618 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
610 | outDlg->showMaximized(); | 619 | outDlg->showMaximized(); |
611 | outDlg->exec(); | 620 | outDlg->exec(); |
612 | qApp->processEvents(); | 621 | qApp->processEvents(); |
613 | 622 | ||
614 | } | 623 | } |
615 | } | 624 | } |
616 | 625 | ||
617 | void AdvancedFm::runCommandStd() | 626 | void AdvancedFm::runCommandStd() |
618 | { | 627 | { |
619 | QString curFile; | 628 | QString curFile; |
620 | QDir *thisDir = CurrentDir(); | 629 | QDir *thisDir = CurrentDir(); |
621 | QListView *thisView = CurrentView(); | 630 | QListView *thisView = CurrentView(); |
622 | if( thisView->currentItem()) | 631 | if( thisView->currentItem()) |
623 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 632 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
624 | 633 | ||
625 | InputDialog *fileDlg; | 634 | InputDialog *fileDlg; |
626 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 635 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
627 | fileDlg->setInputText(curFile); | 636 | fileDlg->setInputText(curFile); |
628 | fileDlg->exec(); | 637 | fileDlg->exec(); |
629 | 638 | ||
630 | if( fileDlg->result() == 1 ) | 639 | if( fileDlg->result() == 1 ) |
631 | { | 640 | { |
632 | qApp->processEvents(); | 641 | qApp->processEvents(); |
633 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 642 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
634 | } | 643 | } |
635 | } | 644 | } |
636 | 645 | ||
637 | void AdvancedFm::fileStatus() | 646 | void AdvancedFm::fileStatus() |
638 | { | 647 | { |
639 | QString curFile; | 648 | QString curFile; |
640 | curFile = CurrentView()->currentItem()->text(0); | 649 | curFile = CurrentView()->currentItem()->text(0); |
641 | 650 | ||
642 | QStringList command; | 651 | QStringList command; |
643 | command << "/bin/sh"; | 652 | command << "/bin/sh"; |
644 | command << "-c"; | 653 | command << "-c"; |
645 | command << "stat -l "+ curFile; | 654 | command << "stat -l "+ curFile; |
646 | 655 | ||
647 | Output *outDlg; | 656 | Output *outDlg; |
648 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 657 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
649 | outDlg->showMaximized(); | 658 | outDlg->showMaximized(); |
650 | outDlg->exec(); | 659 | outDlg->exec(); |
651 | qApp->processEvents(); | 660 | qApp->processEvents(); |
652 | } | 661 | } |
653 | 662 | ||
654 | 663 | ||
655 | void AdvancedFm::mkDir() | 664 | void AdvancedFm::mkDir() |
656 | { | 665 | { |
657 | makeDir(); | 666 | makeDir(); |
658 | } | 667 | } |
659 | 668 | ||
660 | void AdvancedFm::rn() | 669 | void AdvancedFm::rn() |
661 | { | 670 | { |
662 | renameIt(); | 671 | renameIt(); |
663 | } | 672 | } |
664 | 673 | ||
665 | void AdvancedFm::del() | 674 | void AdvancedFm::del() |
666 | { | 675 | { |
667 | doDelete(); | 676 | doDelete(); |
668 | } | 677 | } |
669 | 678 | ||
670 | void AdvancedFm::mkSym() | 679 | void AdvancedFm::mkSym() |
671 | { | 680 | { |
672 | QString cmd; | 681 | QString cmd; |
673 | QStringList curFileList = getPath(); | 682 | QStringList curFileList = getPath(); |
674 | if( curFileList.count() > 0) | 683 | if( curFileList.count() > 0) |
675 | { | 684 | { |
676 | QDir *thisDir = CurrentDir(); | 685 | QDir *thisDir = CurrentDir(); |
677 | QDir * thatDir = OtherDir(); | 686 | QDir * thatDir = OtherDir(); |
678 | 687 | ||
679 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 688 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
680 | { | 689 | { |
681 | 690 | ||
682 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 691 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
683 | if(destName.right(1) == "/") | 692 | if(destName.right(1) == "/") |
684 | { | 693 | { |
685 | destName = destName.left( destName.length() -1); | 694 | destName = destName.left( destName.length() -1); |
686 | } | 695 | } |
687 | 696 | ||
688 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 697 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
689 | 698 | ||
690 | if( curFile.right(1) == "/") | 699 | if( curFile.right(1) == "/") |
691 | { | 700 | { |
692 | curFile = curFile.left( curFile.length() -1); | 701 | curFile = curFile.left( curFile.length() -1); |
693 | } | 702 | } |
694 | 703 | ||
695 | cmd = "ln -s "+curFile+" "+destName; | 704 | cmd = "ln -s "+curFile+" "+destName; |
696 | qDebug(cmd); | 705 | qDebug(cmd); |
697 | startProcess( (const QString)cmd ); | 706 | startProcess( (const QString)cmd ); |
698 | } | 707 | } |
699 | setOtherTabCurrent(); | 708 | setOtherTabCurrent(); |
700 | populateView(); | 709 | populateView(); |
701 | } | 710 | } |
702 | } | 711 | } |
703 | 712 | ||
704 | void AdvancedFm::doBeam() | 713 | void AdvancedFm::doBeam() |
705 | { | 714 | { |
706 | Ir ir; | 715 | Ir ir; |
707 | if(!ir.supported()) | 716 | if(!ir.supported()) |
708 | { | 717 | { |
709 | } | 718 | } |
710 | else | 719 | else |
711 | { | 720 | { |
712 | QStringList curFileList = getPath(); | 721 | QStringList curFileList = getPath(); |
713 | if( curFileList.count() > 0) | 722 | if( curFileList.count() > 0) |
714 | { | 723 | { |
715 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 724 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
716 | { | 725 | { |
717 | 726 | ||
718 | QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); | 727 | QString curFile = CurrentDir()->canonicalPath()+"/"+(*it); |
719 | if( curFile.right(1) == "/") | 728 | if( curFile.right(1) == "/") |
720 | { | 729 | { |
721 | curFile = curFile.left( curFile.length() -1); | 730 | curFile = curFile.left( curFile.length() -1); |
722 | } | 731 | } |
723 | Ir *file = new Ir(this, "IR"); | 732 | Ir *file = new Ir(this, "IR"); |
724 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 733 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
725 | file->send( curFile, curFile ); | 734 | file->send( curFile, curFile ); |
726 | } | 735 | } |
727 | } | 736 | } |
728 | } | 737 | } |
729 | 738 | ||
730 | } | 739 | } |
731 | 740 | ||
732 | void AdvancedFm::fileBeamFinished( Ir *) | 741 | void AdvancedFm::fileBeamFinished( Ir *) |
733 | { | 742 | { |
734 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 743 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
735 | } | 744 | } |
736 | 745 | ||
737 | void AdvancedFm::selectAll() | 746 | void AdvancedFm::selectAll() |
738 | { | 747 | { |
739 | // if (TabWidget->currentTab() == 0) { | 748 | // if (TabWidget->currentTab() == 0) { |
740 | QListView *thisView = CurrentView(); | 749 | QListView *thisView = CurrentView(); |
741 | thisView->selectAll(true); | 750 | thisView->selectAll(true); |
742 | thisView->setSelected( thisView->firstChild(),false); | 751 | thisView->setSelected( thisView->firstChild(),false); |
743 | // } else { | 752 | // } else { |
744 | // Remote_View->selectAll(true); | 753 | // Remote_View->selectAll(true); |
745 | // Remote_View->setSelected( Remote_View->firstChild(),false); | 754 | // Remote_View->setSelected( Remote_View->firstChild(),false); |
746 | // } | 755 | // } |
747 | } | 756 | } |
748 | 757 | ||
749 | void AdvancedFm::startProcess(const QString & cmd) | 758 | void AdvancedFm::startProcess(const QString & cmd) |
750 | { | 759 | { |
751 | QStringList command; | 760 | QStringList command; |
752 | OProcess *process; | 761 | OProcess *process; |
753 | process = new OProcess(); | 762 | process = new OProcess(); |
754 | connect(process, SIGNAL(processExited(OProcess *)), | 763 | connect(process, SIGNAL(processExited(OProcess *)), |
755 | this, SLOT( processEnded(OProcess *))); | 764 | this, SLOT( processEnded(OProcess *))); |
756 | 765 | ||
757 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), | 766 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), |
758 | this, SLOT( oprocessStderr(OProcess *, char *, int))); | 767 | this, SLOT( oprocessStderr(OProcess *, char *, int))); |
759 | 768 | ||
760 | command << "/bin/sh"; | 769 | command << "/bin/sh"; |
761 | command << "-c"; | 770 | command << "-c"; |
762 | command << cmd.latin1(); | 771 | command << cmd.latin1(); |
763 | *process << command; | 772 | *process << command; |
764 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 773 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
765 | qDebug("could not start process"); | 774 | qDebug("could not start process"); |
766 | } | 775 | } |
767 | 776 | ||
768 | void AdvancedFm::processEnded(OProcess *) | 777 | void AdvancedFm::processEnded(OProcess *) |
769 | { | 778 | { |
770 | // populateLocalView(); | 779 | // populateLocalView(); |
771 | populateView(); | 780 | populateView(); |
772 | } | 781 | } |
773 | 782 | ||
774 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int buflen) { | 783 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int buflen) { |
775 | qWarning("received stderrt %d bytes", buflen); | 784 | qWarning("received stderrt %d bytes", buflen); |
776 | 785 | ||
777 | QString lineStr = buffer; | 786 | QString lineStr = buffer; |
778 | // lineStr=lineStr.left(lineStr.length()-1); | 787 | // lineStr=lineStr.left(lineStr.length()-1); |
779 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 788 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
780 | 789 | ||
781 | // OutputEdit->append(lineStr); | 790 | // OutputEdit->append(lineStr); |
782 | // OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 791 | // OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
783 | } | 792 | } |
784 | 793 | ||
785 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) | 794 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) |
786 | { | 795 | { |
787 | if ( o->inherits( "QLineEdit" ) ) | 796 | if ( o->inherits( "QLineEdit" ) ) |
788 | { | 797 | { |
789 | if ( e->type() == QEvent::KeyPress ) | 798 | if ( e->type() == QEvent::KeyPress ) |
790 | { | 799 | { |
791 | QKeyEvent *ke = (QKeyEvent*)e; | 800 | QKeyEvent *ke = (QKeyEvent*)e; |
792 | if ( ke->key() == Key_Return || | 801 | if ( ke->key() == Key_Return || |
793 | ke->key() == Key_Enter ) | 802 | ke->key() == Key_Enter ) |
794 | { | 803 | { |
795 | okRename(); | 804 | okRename(); |
796 | return true; | 805 | return true; |
797 | } | 806 | } |
798 | else if ( ke->key() == Key_Escape ) | 807 | else if ( ke->key() == Key_Escape ) |
799 | { | 808 | { |
800 | cancelRename(); | 809 | cancelRename(); |
801 | return true; | 810 | return true; |
802 | } | 811 | } |
803 | } | 812 | } |
804 | else if ( e->type() == QEvent::FocusOut ) | 813 | else if ( e->type() == QEvent::FocusOut ) |
805 | { | 814 | { |
806 | cancelRename(); | 815 | cancelRename(); |
807 | return true; | 816 | return true; |
808 | } | 817 | } |
809 | } | 818 | } |
810 | if ( o->inherits( "QListView" ) ) | 819 | if ( o->inherits( "QListView" ) ) |
811 | { | 820 | { |
812 | if ( e->type() == QEvent::FocusOut ) | 821 | if ( e->type() == QEvent::FocusOut ) |
813 | { | 822 | { |
814 | printf("focusIn\n"); | 823 | printf("focusIn\n"); |
815 | 824 | ||
816 | } | 825 | } |
817 | } | 826 | } |
818 | 827 | ||
819 | return QWidget::eventFilter( o, e ); | 828 | return QWidget::eventFilter( o, e ); |
820 | } | 829 | } |
821 | 830 | ||
822 | 831 | ||
823 | void AdvancedFm::cancelRename() | 832 | void AdvancedFm::cancelRename() |
824 | { | 833 | { |
825 | qDebug("cancel rename"); | 834 | qDebug("cancel rename"); |
826 | QListView * view; | 835 | QListView * view; |
827 | view = CurrentView(); | 836 | view = CurrentView(); |
828 | 837 | ||
829 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 838 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
830 | delete renameBox; | 839 | delete renameBox; |
831 | renameBox = 0; | 840 | renameBox = 0; |
832 | if ( resetFocus ) | 841 | if ( resetFocus ) |
833 | { | 842 | { |
834 | view->viewport()->setFocusProxy( view); | 843 | view->viewport()->setFocusProxy( view); |
835 | view->setFocus(); | 844 | view->setFocus(); |
836 | } | 845 | } |
837 | } | 846 | } |
838 | 847 | ||
839 | void AdvancedFm::doRename(QListView * view) | 848 | void AdvancedFm::doRename(QListView * view) |
840 | { | 849 | { |
841 | 850 | ||
842 | QRect r = view->itemRect( view->currentItem( )); | 851 | QRect r = view->itemRect( view->currentItem( )); |
843 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 852 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
844 | r.setX( view->contentsX() ); | 853 | r.setX( view->contentsX() ); |
845 | if ( r.width() > view->visibleWidth() ) | 854 | if ( r.width() > view->visibleWidth() ) |
846 | r.setWidth( view->visibleWidth() ); | 855 | r.setWidth( view->visibleWidth() ); |
847 | 856 | ||
848 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 857 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
849 | renameBox->setFrame(true); | 858 | renameBox->setFrame(true); |
850 | 859 | ||
851 | renameBox->setText( view->currentItem()->text(0) ); | 860 | renameBox->setText( view->currentItem()->text(0) ); |
852 | 861 | ||
853 | renameBox->selectAll(); | 862 | renameBox->selectAll(); |
854 | renameBox->installEventFilter( this ); | 863 | renameBox->installEventFilter( this ); |
855 | view->addChild( renameBox, r.x(), r.y() ); | 864 | view->addChild( renameBox, r.x(), r.y() ); |
856 | renameBox->resize( r.size() ); | 865 | renameBox->resize( r.size() ); |
857 | view->viewport()->setFocusProxy( renameBox ); | 866 | view->viewport()->setFocusProxy( renameBox ); |
858 | renameBox->setFocus(); | 867 | renameBox->setFocus(); |
859 | renameBox->show(); | 868 | renameBox->show(); |
860 | 869 | ||
861 | } | 870 | } |
862 | 871 | ||
863 | 872 | ||
864 | void AdvancedFm::renameIt() | 873 | void AdvancedFm::renameIt() |
865 | { | 874 | { |
866 | QListView *thisView = CurrentView(); | 875 | QListView *thisView = CurrentView(); |
867 | oldName = thisView->currentItem()->text(0); | 876 | oldName = thisView->currentItem()->text(0); |
868 | doRename( thisView ); | 877 | doRename( thisView ); |
869 | populateView(); | 878 | populateView(); |
870 | } | 879 | } |
871 | 880 | ||
872 | void AdvancedFm::okRename() | 881 | void AdvancedFm::okRename() |
873 | { | 882 | { |
874 | QString newName = renameBox->text(); | 883 | QString newName = renameBox->text(); |
875 | cancelRename(); | 884 | cancelRename(); |
876 | // int tabs=0; | 885 | // int tabs=0; |
877 | QListView * view = CurrentView(); | 886 | QListView * view = CurrentView(); |
878 | QString path = CurrentDir()->canonicalPath() + "/"; | 887 | QString path = CurrentDir()->canonicalPath() + "/"; |
879 | oldName = path + oldName; | 888 | oldName = path + oldName; |
880 | newName = path + newName; | 889 | newName = path + newName; |
881 | 890 | ||
882 | if( view->currentItem() == NULL) | 891 | if( view->currentItem() == NULL) |
883 | return; | 892 | return; |
884 | if( rename( oldName.latin1(), newName.latin1())== -1) | 893 | if( rename( oldName.latin1(), newName.latin1())== -1) |
885 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 894 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
886 | else | 895 | else |
887 | oldName = ""; | 896 | oldName = ""; |
888 | 897 | ||
889 | view->takeItem( view->currentItem() ); | 898 | view->takeItem( view->currentItem() ); |
890 | delete view->currentItem(); | 899 | delete view->currentItem(); |
891 | populateView(); | 900 | populateView(); |
892 | } | 901 | } |
893 | 902 | ||
894 | void AdvancedFm::openSearch() { | 903 | void AdvancedFm::openSearch() { |
895 | 904 | ||
896 | } | 905 | } |