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