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