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