author | llornkcor <llornkcor> | 2004-09-25 06:21:43 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-09-25 06:21:43 (UTC) |
commit | 448e2835ff7b84162022b62f8570935739a167bb (patch) (unidiff) | |
tree | 57cbbc4e2a6a87119df7240a346b256314e99910 | |
parent | c47a2d0e8ec283737f7c43474be4cf8070cde046 (diff) | |
download | opie-448e2835ff7b84162022b62f8570935739a167bb.zip opie-448e2835ff7b84162022b62f8570935739a167bb.tar.gz opie-448e2835ff7b84162022b62f8570935739a167bb.tar.bz2 |
change message
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 6f017b4..ec7a08a 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1,684 +1,685 @@ | |||
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 | rePopulate(); | 47 | rePopulate(); |
48 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); | 48 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); |
49 | 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&))); |
50 | switchToLocalTab(); | 50 | switchToLocalTab(); |
51 | } | 51 | } |
52 | 52 | ||
53 | AdvancedFm::~AdvancedFm() { | 53 | AdvancedFm::~AdvancedFm() { |
54 | } | 54 | } |
55 | 55 | ||
56 | 56 | ||
57 | void AdvancedFm::cleanUp() { | 57 | void AdvancedFm::cleanUp() { |
58 | QString sfile=QDir::homeDirPath(); | 58 | QString sfile=QDir::homeDirPath(); |
59 | if(sfile.right(1) != "/") | 59 | if(sfile.right(1) != "/") |
60 | sfile+="/._temp"; | 60 | sfile+="/._temp"; |
61 | else | 61 | else |
62 | sfile+="._temp"; | 62 | sfile+="._temp"; |
63 | QFile file( sfile); | 63 | QFile file( sfile); |
64 | if(file.exists()) | 64 | if(file.exists()) |
65 | file.remove(); | 65 | file.remove(); |
66 | } | 66 | } |
67 | 67 | ||
68 | void AdvancedFm::tabChanged(QWidget *wd) { | 68 | void AdvancedFm::tabChanged(QWidget *wd) { |
69 | // qDebug("tabChanged"); | 69 | // qDebug("tabChanged"); |
70 | if(wd == tab) { | 70 | if(wd == tab) { |
71 | whichTab = 1; | 71 | whichTab = 1; |
72 | // qDebug("tabchanged: LOCAL VIEW SHOWN"); | 72 | // qDebug("tabchanged: LOCAL VIEW SHOWN"); |
73 | } | 73 | } |
74 | else if(wd == tab_2) { | 74 | else if(wd == tab_2) { |
75 | whichTab = 2; | 75 | whichTab = 2; |
76 | // qDebug("tabchanged: REMOTE VIEW SHOWN"); | 76 | // qDebug("tabchanged: REMOTE VIEW SHOWN"); |
77 | } | 77 | } |
78 | qApp->processEvents(); | 78 | qApp->processEvents(); |
79 | QString path = CurrentDir()->canonicalPath(); | 79 | QString path = CurrentDir()->canonicalPath(); |
80 | // qDebug(path); | 80 | // qDebug(path); |
81 | if ( TabWidget->currentWidget() == tab) { | 81 | if ( TabWidget->currentWidget() == tab) { |
82 | viewMenu->setItemChecked(viewMenu->idAt(0), true); | 82 | viewMenu->setItemChecked(viewMenu->idAt(0), true); |
83 | viewMenu->setItemChecked(viewMenu->idAt(1), false); | 83 | viewMenu->setItemChecked(viewMenu->idAt(1), false); |
84 | } else { | 84 | } else { |
85 | viewMenu->setItemChecked(viewMenu->idAt(0), false); | 85 | viewMenu->setItemChecked(viewMenu->idAt(0), false); |
86 | viewMenu->setItemChecked(viewMenu->idAt(1), true); | 86 | viewMenu->setItemChecked(viewMenu->idAt(1), true); |
87 | } | 87 | } |
88 | 88 | ||
89 | QString fs= getFileSystemType( (const QString &) path); | 89 | QString fs= getFileSystemType( (const QString &) path); |
90 | 90 | ||
91 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | 91 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
92 | +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); | 92 | +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); |
93 | chdir( path.latin1()); | 93 | chdir( path.latin1()); |
94 | currentPathCombo->lineEdit()->setText(path); | 94 | currentPathCombo->lineEdit()->setText(path); |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | void AdvancedFm::populateView() { | 98 | void AdvancedFm::populateView() { |
99 | 99 | ||
100 | QPixmap pm; | 100 | QPixmap pm; |
101 | QListView *thisView = CurrentView(); | 101 | QListView *thisView = CurrentView(); |
102 | QDir *thisDir = CurrentDir(); | 102 | QDir *thisDir = CurrentDir(); |
103 | QString path = thisDir->canonicalPath(); | 103 | QString path = thisDir->canonicalPath(); |
104 | 104 | ||
105 | thisView->clear(); | 105 | thisView->clear(); |
106 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 106 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
107 | thisDir->setMatchAllDirs(TRUE); | 107 | thisDir->setMatchAllDirs(TRUE); |
108 | thisDir->setNameFilter(filterStr); | 108 | thisDir->setNameFilter(filterStr); |
109 | QString fileL, fileS, fileDate; | 109 | QString fileL, fileS, fileDate; |
110 | QString fs= getFileSystemType((const QString &) path); | 110 | QString fs= getFileSystemType((const QString &) path); |
111 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | 111 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
112 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); | 112 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); |
113 | bool isDir=FALSE; | 113 | bool isDir=FALSE; |
114 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 114 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
115 | QFileInfoListIterator it(*list); | 115 | QFileInfoListIterator it(*list); |
116 | QFileInfo *fi; | 116 | QFileInfo *fi; |
117 | while ( (fi=it.current()) ) { | 117 | while ( (fi=it.current()) ) { |
118 | if (fi->isSymLink() ) { | 118 | if (fi->isSymLink() ) { |
119 | QString symLink=fi->readLink(); | 119 | QString symLink=fi->readLink(); |
120 | QFileInfo sym( symLink); | 120 | QFileInfo sym( symLink); |
121 | fileS.sprintf( "%10i", sym.size() ); | 121 | fileS.sprintf( "%10i", sym.size() ); |
122 | fileL = fi->fileName() +" -> " + sym.filePath().data(); | 122 | fileL = fi->fileName() +" -> " + sym.filePath().data(); |
123 | fileDate = sym.lastModified().toString(); | 123 | fileDate = sym.lastModified().toString(); |
124 | } else { | 124 | } else { |
125 | fileS.sprintf( "%10i", fi->size() ); | 125 | fileS.sprintf( "%10i", fi->size() ); |
126 | fileL = fi->fileName(); | 126 | fileL = fi->fileName(); |
127 | fileDate= fi->lastModified().toString(); | 127 | fileDate= fi->lastModified().toString(); |
128 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { | 128 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { |
129 | // if(fileL == "..") | 129 | // if(fileL == "..") |
130 | fileL += "/"; | 130 | fileL += "/"; |
131 | isDir=TRUE; | 131 | isDir=TRUE; |
132 | } | 132 | } |
133 | } | 133 | } |
134 | QFileInfo fileInfo( path + "/" + fileL); | 134 | QFileInfo fileInfo( path + "/" + fileL); |
135 | 135 | ||
136 | if(fileL !="./" && fi->exists()) { | 136 | if(fileL !="./" && fi->exists()) { |
137 | item = new QListViewItem( thisView, fileL, fileS , fileDate); | 137 | item = new QListViewItem( thisView, fileL, fileS , fileDate); |
138 | 138 | ||
139 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 139 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
140 | 140 | ||
141 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 141 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
142 | pm = Resource::loadPixmap( "lockedfolder" ); | 142 | pm = Resource::loadPixmap( "lockedfolder" ); |
143 | else | 143 | else |
144 | pm= Resource::loadPixmap( "folder" ); | 144 | pm= Resource::loadPixmap( "folder" ); |
145 | } | 145 | } |
146 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 146 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
147 | pm = Resource::loadPixmap( "exec"); | 147 | pm = Resource::loadPixmap( "exec"); |
148 | } | 148 | } |
149 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 149 | else if( (fileInfo.permission( QFileInfo::ExeUser) |
150 | | fileInfo.permission( QFileInfo::ExeGroup) | 150 | | fileInfo.permission( QFileInfo::ExeGroup) |
151 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 151 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
152 | pm = Resource::loadPixmap( "exec"); | 152 | pm = Resource::loadPixmap( "exec"); |
153 | } | 153 | } |
154 | else if( !fi->isReadable() ) { | 154 | else if( !fi->isReadable() ) { |
155 | pm = Resource::loadPixmap( "locked" ); | 155 | pm = Resource::loadPixmap( "locked" ); |
156 | } | 156 | } |
157 | else { //everything else goes by mimetype | 157 | else { //everything else goes by mimetype |
158 | MimeType mt(fi->filePath()); | 158 | MimeType mt(fi->filePath()); |
159 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 159 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
160 | if(pm.isNull()) { | 160 | if(pm.isNull()) { |
161 | pm = unknownXpm; | 161 | pm = unknownXpm; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { | 164 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { |
165 | // odebug << " overlay link image" << oendl; | 165 | // odebug << " overlay link image" << oendl; |
166 | pm= Resource::loadPixmap( "advancedfm/symlink" ); | 166 | pm= Resource::loadPixmap( "advancedfm/symlink" ); |
167 | // pm= Resource::loadPixmap( "folder" ); | 167 | // pm= Resource::loadPixmap( "folder" ); |
168 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 168 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
169 | // QPainter painter( &pm ); | 169 | // QPainter painter( &pm ); |
170 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 170 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
171 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); | 171 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); |
172 | } | 172 | } |
173 | item->setPixmap( 0,pm); | 173 | item->setPixmap( 0,pm); |
174 | 174 | ||
175 | } | 175 | } |
176 | isDir=FALSE; | 176 | isDir=FALSE; |
177 | ++it; | 177 | ++it; |
178 | } | 178 | } |
179 | 179 | ||
180 | if( path.find("dev",0,TRUE) != -1) { | 180 | if( path.find("dev",0,TRUE) != -1) { |
181 | struct stat buf; | 181 | struct stat buf; |
182 | dev_t devT; | 182 | dev_t devT; |
183 | DIR *dir; | 183 | DIR *dir; |
184 | struct dirent *mydirent; | 184 | struct dirent *mydirent; |
185 | 185 | ||
186 | if((dir = opendir( path.latin1())) != NULL) | 186 | if((dir = opendir( path.latin1())) != NULL) |
187 | while ((mydirent = readdir(dir)) != NULL) { | 187 | while ((mydirent = readdir(dir)) != NULL) { |
188 | lstat( mydirent->d_name, &buf); | 188 | lstat( mydirent->d_name, &buf); |
189 | // odebug << mydirent->d_name << oendl; | 189 | // odebug << mydirent->d_name << oendl; |
190 | fileL.sprintf("%s", mydirent->d_name); | 190 | fileL.sprintf("%s", mydirent->d_name); |
191 | devT = buf.st_dev; | 191 | devT = buf.st_dev; |
192 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 192 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
193 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 193 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
194 | if( fileL.find(".") == -1 ) { | 194 | if( fileL.find(".") == -1 ) { |
195 | item= new QListViewItem( thisView, fileL, fileS, fileDate); | 195 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
196 | pm = unknownXpm; | 196 | pm = unknownXpm; |
197 | item->setPixmap( 0,pm); | 197 | item->setPixmap( 0,pm); |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | closedir(dir); | 201 | closedir(dir); |
202 | } | 202 | } |
203 | 203 | ||
204 | thisView->setSorting( 3,FALSE); | 204 | thisView->setSorting( 3,FALSE); |
205 | fillCombo( (const QString &) path ); | 205 | fillCombo( (const QString &) path ); |
206 | } | 206 | } |
207 | 207 | ||
208 | void AdvancedFm::rePopulate() { | 208 | void AdvancedFm::rePopulate() { |
209 | // qDebug("repopulate views"); | 209 | // qDebug("repopulate views"); |
210 | populateView(); | 210 | populateView(); |
211 | setOtherTabCurrent(); | 211 | setOtherTabCurrent(); |
212 | populateView(); | 212 | populateView(); |
213 | 213 | ||
214 | // int tmpTab = whichTab; | 214 | // int tmpTab = whichTab; |
215 | // // odebug << "" << tmpTab << "" << oendl; | 215 | // // odebug << "" << tmpTab << "" << oendl; |
216 | 216 | ||
217 | // for(int i =1; i < 3; i++) { | 217 | // for(int i =1; i < 3; i++) { |
218 | // TabWidget->setCurrentWidget(i - 1); | 218 | // TabWidget->setCurrentWidget(i - 1); |
219 | // populateView(); | 219 | // populateView(); |
220 | // } | 220 | // } |
221 | // TabWidget->setCurrentWidget( tmpTab - 1); | 221 | // TabWidget->setCurrentWidget( tmpTab - 1); |
222 | } | 222 | } |
223 | 223 | ||
224 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { | 224 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { |
225 | // if ( TabWidget->currentWidget() == tab) | 225 | // if ( TabWidget->currentWidget() == tab) |
226 | // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked local"); | 226 | // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked local"); |
227 | // else | 227 | // else |
228 | // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked remote"); | 228 | // qDebug("XXXXXXXXXXXXXXXXXXXXXXXX ListClicked remote"); |
229 | 229 | ||
230 | 230 | ||
231 | if(selectedItem) { | 231 | if(selectedItem) { |
232 | QString strItem=selectedItem->text(0); | 232 | QString strItem=selectedItem->text(0); |
233 | // owarn << strItem << oendl; | 233 | // owarn << strItem << oendl; |
234 | QString strSize=selectedItem->text(1); | 234 | QString strSize=selectedItem->text(1); |
235 | strSize=strSize.stripWhiteSpace(); | 235 | strSize=strSize.stripWhiteSpace(); |
236 | bool isDirectory = false; | 236 | bool isDirectory = false; |
237 | QString strItem2; | 237 | QString strItem2; |
238 | 238 | ||
239 | 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 |
240 | strItem2 = dealWithSymName((const QString&)strItem); | 240 | strItem2 = dealWithSymName((const QString&)strItem); |
241 | if(QDir(strItem2).exists() ) | 241 | if(QDir(strItem2).exists() ) |
242 | strItem = strItem2; | 242 | strItem = strItem2; |
243 | } | 243 | } |
244 | 244 | ||
245 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 245 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
246 | 246 | ||
247 | if(QDir(strItem).exists()) | 247 | if(QDir(strItem).exists()) |
248 | isDirectory = true; | 248 | isDirectory = true; |
249 | } | 249 | } |
250 | 250 | ||
251 | if( isDirectory ) { | 251 | if( isDirectory ) { |
252 | CurrentDir()->cd( strItem, TRUE); | 252 | CurrentDir()->cd( strItem, TRUE); |
253 | populateView(); | 253 | populateView(); |
254 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); | 254 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); |
255 | } | 255 | } |
256 | chdir( strItem.latin1()); | 256 | chdir( strItem.latin1()); |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { | 260 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { |
261 | Q_UNUSED(item); | 261 | Q_UNUSED(item); |
262 | switch (mouse) { | 262 | switch (mouse) { |
263 | case 1: | 263 | case 1: |
264 | { | 264 | { |
265 | if(renameBox != 0 ) { | 265 | if(renameBox != 0 ) { |
266 | cancelRename(); | 266 | cancelRename(); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | break; | 269 | break; |
270 | // case 2: | 270 | // case 2: |
271 | // menuTimer.start( 50, TRUE ); | 271 | // menuTimer.start( 50, TRUE ); |
272 | // break; | 272 | // break; |
273 | }; | 273 | }; |
274 | } | 274 | } |
275 | 275 | ||
276 | 276 | ||
277 | void AdvancedFm::refreshCurrentTab() { | 277 | void AdvancedFm::refreshCurrentTab() { |
278 | populateView(); | 278 | populateView(); |
279 | // if ( TabWidget->currentWidget() == tab) { | 279 | // if ( TabWidget->currentWidget() == tab) { |
280 | 280 | ||
281 | } | 281 | } |
282 | 282 | ||
283 | void AdvancedFm::switchToLocalTab() { | 283 | void AdvancedFm::switchToLocalTab() { |
284 | TabWidget->setCurrentWidget(0); | 284 | TabWidget->setCurrentWidget(0); |
285 | // Local_View->setFocus(); | 285 | // Local_View->setFocus(); |
286 | whichTab = 1; | 286 | whichTab = 1; |
287 | } | 287 | } |
288 | 288 | ||
289 | void AdvancedFm::switchToRemoteTab() { | 289 | void AdvancedFm::switchToRemoteTab() { |
290 | TabWidget->setCurrentWidget(1); | 290 | TabWidget->setCurrentWidget(1); |
291 | // Remote_View->setFocus(); | 291 | // Remote_View->setFocus(); |
292 | whichTab = 2; | 292 | whichTab = 2; |
293 | } | 293 | } |
294 | 294 | ||
295 | void AdvancedFm::currentPathComboChanged() { | 295 | void AdvancedFm::currentPathComboChanged() { |
296 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 296 | QString pDir = currentPathCombo->lineEdit()->text(); |
297 | CurrentDir()->setPath( currentPathCombo->lineEdit()->text() ); | 297 | if(QDir(pDir).exists()) { |
298 | CurrentDir()->setPath(pDir ); | ||
298 | populateView(); | 299 | populateView(); |
299 | } else { | 300 | } else { |
300 | QMessageBox::message(tr("Note"),tr("<p>That directory does not exist</p>")); | 301 | QMessageBox::message(tr("Note"),tr("<p>%1 does not exist</p>").arg(pDir)); |
301 | } | 302 | } |
302 | } | 303 | } |
303 | 304 | ||
304 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 305 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
305 | 306 | ||
306 | if ( TabWidget->currentWidget() == tab) { | 307 | if ( TabWidget->currentWidget() == tab) { |
307 | // if ( whichTab == 1) { | 308 | // if ( whichTab == 1) { |
308 | currentPathCombo->lineEdit()->setText( currentPath); | 309 | currentPathCombo->lineEdit()->setText( currentPath); |
309 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 310 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
310 | currentPathCombo->clear(); | 311 | currentPathCombo->clear(); |
311 | localDirPathStringList.prepend( currentPath ); | 312 | localDirPathStringList.prepend( currentPath ); |
312 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 313 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
313 | } | 314 | } |
314 | } else { | 315 | } else { |
315 | currentPathCombo->lineEdit()->setText( currentPath); | 316 | currentPathCombo->lineEdit()->setText( currentPath); |
316 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 317 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
317 | currentPathCombo->clear(); | 318 | currentPathCombo->clear(); |
318 | remoteDirPathStringList.prepend( currentPath ); | 319 | remoteDirPathStringList.prepend( currentPath ); |
319 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 320 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
320 | } | 321 | } |
321 | } | 322 | } |
322 | } | 323 | } |
323 | 324 | ||
324 | QStringList AdvancedFm::getPath() { | 325 | QStringList AdvancedFm::getPath() { |
325 | QStringList strList; | 326 | QStringList strList; |
326 | QListView *thisView=CurrentView(); | 327 | QListView *thisView=CurrentView(); |
327 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); | 328 | QList<QListViewItem> * getSelectedItems( QListView * thisView ); |
328 | QListViewItemIterator it( thisView ); | 329 | QListViewItemIterator it( thisView ); |
329 | for ( ; it.current(); ++it ) { | 330 | for ( ; it.current(); ++it ) { |
330 | if ( it.current()->isSelected() ) { | 331 | if ( it.current()->isSelected() ) { |
331 | strList << it.current()->text(0); | 332 | strList << it.current()->text(0); |
332 | // odebug << it.current()->text(0) << oendl; | 333 | // odebug << it.current()->text(0) << oendl; |
333 | } | 334 | } |
334 | } | 335 | } |
335 | return strList; | 336 | return strList; |
336 | } | 337 | } |
337 | 338 | ||
338 | void AdvancedFm::changeTo(const QString dir) { | 339 | void AdvancedFm::changeTo(const QString dir) { |
339 | chdir( dir.latin1()); | 340 | chdir( dir.latin1()); |
340 | CurrentDir()->cd(dir, TRUE); | 341 | CurrentDir()->cd(dir, TRUE); |
341 | populateView(); | 342 | populateView(); |
342 | update(); | 343 | update(); |
343 | } | 344 | } |
344 | 345 | ||
345 | void AdvancedFm::homeButtonPushed() { | 346 | void AdvancedFm::homeButtonPushed() { |
346 | changeTo(QDir::homeDirPath()); | 347 | changeTo(QDir::homeDirPath()); |
347 | } | 348 | } |
348 | 349 | ||
349 | void AdvancedFm::docButtonPushed() { | 350 | void AdvancedFm::docButtonPushed() { |
350 | changeTo(QPEApplication::documentDir()); | 351 | changeTo(QPEApplication::documentDir()); |
351 | } | 352 | } |
352 | 353 | ||
353 | void AdvancedFm::SDButtonPushed() { | 354 | void AdvancedFm::SDButtonPushed() { |
354 | changeTo("/mnt/card");// this can change so fix | 355 | changeTo("/mnt/card");// this can change so fix |
355 | } | 356 | } |
356 | 357 | ||
357 | void AdvancedFm::CFButtonPushed() { | 358 | void AdvancedFm::CFButtonPushed() { |
358 | if(zaurusDevice) | 359 | if(zaurusDevice) |
359 | changeTo("/mnt/cf"); //zaurus | 360 | changeTo("/mnt/cf"); //zaurus |
360 | else | 361 | else |
361 | changeTo("/mnt/hda"); //ipaq | 362 | changeTo("/mnt/hda"); //ipaq |
362 | } | 363 | } |
363 | 364 | ||
364 | void AdvancedFm::QPEButtonPushed() { | 365 | void AdvancedFm::QPEButtonPushed() { |
365 | changeTo(QPEApplication::qpeDir()); | 366 | changeTo(QPEApplication::qpeDir()); |
366 | } | 367 | } |
367 | 368 | ||
368 | void AdvancedFm::doAbout() { | 369 | void AdvancedFm::doAbout() { |
369 | 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>")); | 370 | 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>")); |
370 | } | 371 | } |
371 | 372 | ||
372 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { | 373 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { |
373 | Q_UNUSED(e); | 374 | Q_UNUSED(e); |
374 | } | 375 | } |
375 | 376 | ||
376 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | 377 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
377 | // if( CurrentView()->hasFocus() ) | 378 | // if( CurrentView()->hasFocus() ) |
378 | // e->ignore(); | 379 | // e->ignore(); |
379 | if( currentPathCombo->lineEdit()->hasFocus()) { | 380 | if( currentPathCombo->lineEdit()->hasFocus()) { |
380 | // qDebug("shout!"); | 381 | // qDebug("shout!"); |
381 | } | 382 | } |
382 | 383 | ||
383 | else if( e->key() == Key_Left ) | 384 | else if( e->key() == Key_Left ) |
384 | upDir(); | 385 | upDir(); |
385 | else if( e->key() == Key_Return || e->key() == Key_Enter) | 386 | else if( e->key() == Key_Return || e->key() == Key_Enter) |
386 | navigateToSelected(); | 387 | navigateToSelected(); |
387 | else if( e->key() == Key_Tab) | 388 | else if( e->key() == Key_Tab) |
388 | setOtherTabCurrent(); | 389 | setOtherTabCurrent(); |
389 | else if( e->key() == Key_Delete ) | 390 | else if( e->key() == Key_Delete ) |
390 | del(); | 391 | del(); |
391 | else if( e->key() == Key_A) | 392 | else if( e->key() == Key_A) |
392 | copyAs(); | 393 | copyAs(); |
393 | else if( e->key() == Key_C) | 394 | else if( e->key() == Key_C) |
394 | copy(); | 395 | copy(); |
395 | else if( e->key() == Key_E) | 396 | else if( e->key() == Key_E) |
396 | runThis(); | 397 | runThis(); |
397 | else if( e->key() == Key_G) | 398 | else if( e->key() == Key_G) |
398 | currentPathCombo->lineEdit()->setFocus(); | 399 | currentPathCombo->lineEdit()->setFocus(); |
399 | else if( e->key() == Key_H ) | 400 | else if( e->key() == Key_H ) |
400 | showHidden(); | 401 | showHidden(); |
401 | else if( e->key() == Key_I) | 402 | else if( e->key() == Key_I) |
402 | fileStatus(); | 403 | fileStatus(); |
403 | else if( e->key() == Key_M) | 404 | else if( e->key() == Key_M) |
404 | move(); | 405 | move(); |
405 | else if( e->key() == Key_N ) | 406 | else if( e->key() == Key_N ) |
406 | mkDir(); | 407 | mkDir(); |
407 | else if( e->key() == Key_P) | 408 | else if( e->key() == Key_P) |
408 | filePerms(); | 409 | filePerms(); |
409 | else if( e->key() == Key_R ) | 410 | else if( e->key() == Key_R ) |
410 | rn(); | 411 | rn(); |
411 | else if( e->key() == Key_U ) | 412 | else if( e->key() == Key_U ) |
412 | upDir(); | 413 | upDir(); |
413 | else if( e->key() == Key_1) | 414 | else if( e->key() == Key_1) |
414 | switchToLocalTab(); | 415 | switchToLocalTab(); |
415 | else if( e->key() == Key_2) | 416 | else if( e->key() == Key_2) |
416 | switchToRemoteTab(); | 417 | switchToRemoteTab(); |
417 | else if( e->key() == Key_3) | 418 | else if( e->key() == Key_3) |
418 | CFButtonPushed(); | 419 | CFButtonPushed(); |
419 | else if( e->key() == Key_4) | 420 | else if( e->key() == Key_4) |
420 | SDButtonPushed(); | 421 | SDButtonPushed(); |
421 | else if( e->key() == Key_5 ) | 422 | else if( e->key() == Key_5 ) |
422 | homeButtonPushed(); | 423 | homeButtonPushed(); |
423 | else if( e->key() == Key_6 ) | 424 | else if( e->key() == Key_6 ) |
424 | docButtonPushed(); | 425 | docButtonPushed(); |
425 | else | 426 | else |
426 | e->accept(); | 427 | e->accept(); |
427 | } | 428 | } |
428 | 429 | ||
429 | 430 | ||
430 | void AdvancedFm::parsetab(const QString &fileName) { | 431 | void AdvancedFm::parsetab(const QString &fileName) { |
431 | 432 | ||
432 | fileSystemTypeList.clear(); | 433 | fileSystemTypeList.clear(); |
433 | fsList.clear(); | 434 | fsList.clear(); |
434 | struct mntent *me; | 435 | struct mntent *me; |
435 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 436 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
436 | if ( mntfp ) { | 437 | if ( mntfp ) { |
437 | while ( (me = getmntent( mntfp )) != 0 ) { | 438 | while ( (me = getmntent( mntfp )) != 0 ) { |
438 | QString deviceName = me->mnt_fsname; | 439 | QString deviceName = me->mnt_fsname; |
439 | QString filesystemType = me->mnt_type; | 440 | QString filesystemType = me->mnt_type; |
440 | QString mountDir = me->mnt_dir; | 441 | QString mountDir = me->mnt_dir; |
441 | if(deviceName != "none") { | 442 | if(deviceName != "none") { |
442 | if( fsList.contains(filesystemType) == 0 | 443 | if( fsList.contains(filesystemType) == 0 |
443 | & filesystemType.find("proc",0,TRUE) == -1 | 444 | & filesystemType.find("proc",0,TRUE) == -1 |
444 | & filesystemType.find("cramfs",0,TRUE) == -1 | 445 | & filesystemType.find("cramfs",0,TRUE) == -1 |
445 | & filesystemType.find("auto",0,TRUE) == -1) | 446 | & filesystemType.find("auto",0,TRUE) == -1) |
446 | fsList << filesystemType; | 447 | fsList << filesystemType; |
447 | fileSystemTypeList << mountDir+"::"+filesystemType; | 448 | fileSystemTypeList << mountDir+"::"+filesystemType; |
448 | } | 449 | } |
449 | } | 450 | } |
450 | } | 451 | } |
451 | endmntent( mntfp ); | 452 | endmntent( mntfp ); |
452 | } | 453 | } |
453 | 454 | ||
454 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 455 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
455 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 456 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
456 | QString current = currentText;//.right( currentText.length()-1); | 457 | QString current = currentText;//.right( currentText.length()-1); |
457 | QString baseFs; | 458 | QString baseFs; |
458 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 459 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
459 | QString temp = (*it); | 460 | QString temp = (*it); |
460 | QString path = temp.left(temp.find("::",0,TRUE) ); | 461 | QString path = temp.left(temp.find("::",0,TRUE) ); |
461 | path = path.right( path.length()-1); | 462 | path = path.right( path.length()-1); |
462 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 463 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
463 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 464 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
464 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 465 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
465 | } | 466 | } |
466 | } | 467 | } |
467 | return baseFs; | 468 | return baseFs; |
468 | } | 469 | } |
469 | 470 | ||
470 | QString AdvancedFm::getDiskSpace( const QString &path) { | 471 | QString AdvancedFm::getDiskSpace( const QString &path) { |
471 | struct statfs fss; | 472 | struct statfs fss; |
472 | if ( !statfs( path.latin1(), &fss ) ) { | 473 | if ( !statfs( path.latin1(), &fss ) ) { |
473 | int blkSize = fss.f_bsize; | 474 | int blkSize = fss.f_bsize; |
474 | // int totalBlks = fs.f_blocks; | 475 | // int totalBlks = fs.f_blocks; |
475 | int availBlks = fss.f_bavail; | 476 | int availBlks = fss.f_bavail; |
476 | 477 | ||
477 | long mult = blkSize / 1024; | 478 | long mult = blkSize / 1024; |
478 | long div = 1024 / blkSize; | 479 | long div = 1024 / blkSize; |
479 | if ( !mult ) mult = 1; | 480 | if ( !mult ) mult = 1; |
480 | if ( !div ) div = 1; | 481 | if ( !div ) div = 1; |
481 | 482 | ||
482 | return QString::number(availBlks * mult / div); | 483 | return QString::number(availBlks * mult / div); |
483 | } | 484 | } |
484 | return ""; | 485 | return ""; |
485 | } | 486 | } |
486 | 487 | ||
487 | 488 | ||
488 | void AdvancedFm::showFileMenu() { | 489 | void AdvancedFm::showFileMenu() { |
489 | QString curApp; | 490 | QString curApp; |
490 | curApp = CurrentView()->currentItem()->text(0); | 491 | curApp = CurrentView()->currentItem()->text(0); |
491 | 492 | ||
492 | MimeType mt(curApp); | 493 | MimeType mt(curApp); |
493 | const AppLnk* app = mt.application(); | 494 | const AppLnk* app = mt.application(); |
494 | QFile fi(curApp); | 495 | QFile fi(curApp); |
495 | QPopupMenu *m = new QPopupMenu(0); | 496 | QPopupMenu *m = new QPopupMenu(0); |
496 | QPopupMenu *n = new QPopupMenu(0); | 497 | QPopupMenu *n = new QPopupMenu(0); |
497 | // QPopupMenu *o = new QPopupMenu(0); | 498 | // QPopupMenu *o = new QPopupMenu(0); |
498 | m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); | 499 | m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); |
499 | 500 | ||
500 | if ( QFileInfo(fi).isDir()) { | 501 | if ( QFileInfo(fi).isDir()) { |
501 | m->insertSeparator(); | 502 | m->insertSeparator(); |
502 | m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); | 503 | m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); |
503 | } else { | 504 | } else { |
504 | 505 | ||
505 | if (app) | 506 | if (app) |
506 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); | 507 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); |
507 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 508 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
508 | m->insertItem(tr("Execute"),this,SLOT(runThis())); | 509 | m->insertItem(tr("Execute"),this,SLOT(runThis())); |
509 | m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText())); | 510 | m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText())); |
510 | } | 511 | } |
511 | 512 | ||
512 | m->insertItem(tr("Actions"),n); | 513 | m->insertItem(tr("Actions"),n); |
513 | n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); | 514 | n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); |
514 | 515 | ||
515 | n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); | 516 | n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); |
516 | 517 | ||
517 | n->insertSeparator(); | 518 | n->insertSeparator(); |
518 | n->insertItem(tr("Rename"),this,SLOT(renameIt())); | 519 | n->insertItem(tr("Rename"),this,SLOT(renameIt())); |
519 | 520 | ||
520 | n->insertItem(tr("Copy"),this,SLOT(copyTimer())); | 521 | n->insertItem(tr("Copy"),this,SLOT(copyTimer())); |
521 | n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); | 522 | n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); |
522 | n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); | 523 | n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); |
523 | n->insertItem(tr("Move"),this,SLOT(moveTimer())); | 524 | n->insertItem(tr("Move"),this,SLOT(moveTimer())); |
524 | 525 | ||
525 | n->insertSeparator(); | 526 | n->insertSeparator(); |
526 | n->insertItem(tr("Delete"),this,SLOT(doDelete())); | 527 | n->insertItem(tr("Delete"),this,SLOT(doDelete())); |
527 | m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); | 528 | m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); |
528 | 529 | ||
529 | m->insertItem(tr("Run Command"),this,SLOT(runCommand())); | 530 | m->insertItem(tr("Run Command"),this,SLOT(runCommand())); |
530 | m->insertItem(tr("File Info"),this,SLOT(fileStatus())); | 531 | m->insertItem(tr("File Info"),this,SLOT(fileStatus())); |
531 | 532 | ||
532 | m->insertSeparator(); | 533 | m->insertSeparator(); |
533 | m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); | 534 | m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); |
534 | 535 | ||
535 | #if defined(QT_QWS_OPIE) | 536 | #if defined(QT_QWS_OPIE) |
536 | m->insertItem(tr("Properties"),this,SLOT(doProperties())); | 537 | m->insertItem(tr("Properties"),this,SLOT(doProperties())); |
537 | #endif | 538 | #endif |
538 | m->setCheckable(TRUE); | 539 | m->setCheckable(TRUE); |
539 | if (!b) | 540 | if (!b) |
540 | m->setItemChecked(m->idAt(0),TRUE); | 541 | m->setItemChecked(m->idAt(0),TRUE); |
541 | else | 542 | else |
542 | m->setItemChecked(m->idAt(0),FALSE); | 543 | m->setItemChecked(m->idAt(0),FALSE); |
543 | 544 | ||
544 | if(Ir::supported()) | 545 | if(Ir::supported()) |
545 | m->insertItem(tr("Beam File"),this,SLOT(doBeam())); | 546 | m->insertItem(tr("Beam File"),this,SLOT(doBeam())); |
546 | m->setFocus(); | 547 | m->setFocus(); |
547 | 548 | ||
548 | m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); | 549 | m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); |
549 | 550 | ||
550 | if(m) delete m; | 551 | if(m) delete m; |
551 | } | 552 | } |
552 | 553 | ||
553 | 554 | ||
554 | QString AdvancedFm::checkDiskSpace(const QString &path) { | 555 | QString AdvancedFm::checkDiskSpace(const QString &path) { |
555 | struct statfs fss; | 556 | struct statfs fss; |
556 | if ( !statfs( path.latin1(), &fss ) ) { | 557 | if ( !statfs( path.latin1(), &fss ) ) { |
557 | int blkSize = fss.f_bsize; | 558 | int blkSize = fss.f_bsize; |
558 | // int totalBlks = fs.f_blocks; | 559 | // int totalBlks = fs.f_blocks; |
559 | int availBlks = fss.f_bavail; | 560 | int availBlks = fss.f_bavail; |
560 | 561 | ||
561 | long mult = blkSize / 1024; | 562 | long mult = blkSize / 1024; |
562 | long div = 1024 / blkSize; | 563 | long div = 1024 / blkSize; |
563 | if ( !mult ) mult = 1; | 564 | if ( !mult ) mult = 1; |
564 | if ( !div ) div = 1; | 565 | if ( !div ) div = 1; |
565 | 566 | ||
566 | 567 | ||
567 | return QString::number(availBlks * mult / div); | 568 | return QString::number(availBlks * mult / div); |
568 | } | 569 | } |
569 | return ""; | 570 | return ""; |
570 | } | 571 | } |
571 | 572 | ||
572 | void AdvancedFm::addToDocs() { | 573 | void AdvancedFm::addToDocs() { |
573 | QStringList strListPaths = getPath(); | 574 | QStringList strListPaths = getPath(); |
574 | QDir *thisDir = CurrentDir(); | 575 | QDir *thisDir = CurrentDir(); |
575 | 576 | ||
576 | if( strListPaths.count() > 0) { | 577 | if( strListPaths.count() > 0) { |
577 | QString curFile; | 578 | QString curFile; |
578 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { | 579 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { |
579 | curFile = thisDir->canonicalPath()+"/"+(*it); | 580 | curFile = thisDir->canonicalPath()+"/"+(*it); |
580 | // odebug << curFile << oendl; | 581 | // odebug << curFile << oendl; |
581 | QFileInfo fi(curFile); | 582 | QFileInfo fi(curFile); |
582 | DocLnk f; | 583 | DocLnk f; |
583 | // curFile.replace(QRegExp("\\..*"),""); | 584 | // curFile.replace(QRegExp("\\..*"),""); |
584 | f.setName(fi.baseName() ); | 585 | f.setName(fi.baseName() ); |
585 | f.setFile( curFile); | 586 | f.setFile( curFile); |
586 | f.writeLink(); | 587 | f.writeLink(); |
587 | } | 588 | } |
588 | } | 589 | } |
589 | } | 590 | } |
590 | 591 | ||
591 | 592 | ||
592 | void AdvancedFm::customDirsToMenu() { | 593 | void AdvancedFm::customDirsToMenu() { |
593 | 594 | ||
594 | Config cfg("AdvancedFm"); | 595 | Config cfg("AdvancedFm"); |
595 | cfg.setGroup("Menu"); | 596 | cfg.setGroup("Menu"); |
596 | 597 | ||
597 | QStringList list = cfg.readListEntry( "CustomDir", ','); | 598 | QStringList list = cfg.readListEntry( "CustomDir", ','); |
598 | menuButton->insertItems(list ); | 599 | menuButton->insertItems(list ); |
599 | 600 | ||
600 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 601 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
601 | // { | 602 | // { |
602 | // customDirMenu->insertItem(*it ); | 603 | // customDirMenu->insertItem(*it ); |
603 | // } | 604 | // } |
604 | } | 605 | } |
605 | 606 | ||
606 | void AdvancedFm::dirMenuSelected(int item) { | 607 | void AdvancedFm::dirMenuSelected(int item) { |
607 | switch(item) | 608 | switch(item) |
608 | { | 609 | { |
609 | 610 | ||
610 | case -21: | 611 | case -21: |
611 | case 0: | 612 | case 0: |
612 | addCustomDir(); | 613 | addCustomDir(); |
613 | break; | 614 | break; |
614 | case -22: | 615 | case -22: |
615 | case 1: | 616 | case 1: |
616 | removeCustomDir(); | 617 | removeCustomDir(); |
617 | break; | 618 | break; |
618 | default: | 619 | default: |
619 | { | 620 | { |
620 | // gotoCustomDir( menuButton->text(item)); | 621 | // gotoCustomDir( menuButton->text(item)); |
621 | // gotoCustomDir( customDirMenu->text(item)); | 622 | // gotoCustomDir( customDirMenu->text(item)); |
622 | } | 623 | } |
623 | break; | 624 | break; |
624 | 625 | ||
625 | }; | 626 | }; |
626 | } | 627 | } |
627 | 628 | ||
628 | void AdvancedFm::addCustomDir() { | 629 | void AdvancedFm::addCustomDir() { |
629 | Config cfg("AdvancedFm"); | 630 | Config cfg("AdvancedFm"); |
630 | cfg.setGroup("Menu"); | 631 | cfg.setGroup("Menu"); |
631 | QString dir; | 632 | QString dir; |
632 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 633 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
633 | 634 | ||
634 | dir = CurrentDir()->canonicalPath(); | 635 | dir = CurrentDir()->canonicalPath(); |
635 | 636 | ||
636 | bool addIt=true; | 637 | bool addIt=true; |
637 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 638 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
638 | if( dir == (*it)) { | 639 | if( dir == (*it)) { |
639 | addIt=false; | 640 | addIt=false; |
640 | } | 641 | } |
641 | } | 642 | } |
642 | if(addIt) { | 643 | if(addIt) { |
643 | menuButton->insertItem(dir); | 644 | menuButton->insertItem(dir); |
644 | // customDirMenu->insertItem(dir); | 645 | // customDirMenu->insertItem(dir); |
645 | list << dir; | 646 | list << dir; |
646 | } | 647 | } |
647 | 648 | ||
648 | cfg.writeEntry("CustomDir", list, ','); | 649 | cfg.writeEntry("CustomDir", list, ','); |
649 | cfg.write(); | 650 | cfg.write(); |
650 | } | 651 | } |
651 | 652 | ||
652 | void AdvancedFm::removeCustomDir() { | 653 | void AdvancedFm::removeCustomDir() { |
653 | // odebug << "remove custom dir" << oendl; | 654 | // odebug << "remove custom dir" << oendl; |
654 | Config cfg("AdvancedFm"); | 655 | Config cfg("AdvancedFm"); |
655 | cfg.setGroup("Menu"); | 656 | cfg.setGroup("Menu"); |
656 | QString dir; | 657 | QString dir; |
657 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 658 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
658 | QStringList list2; | 659 | QStringList list2; |
659 | dir = CurrentDir()->canonicalPath(); | 660 | dir = CurrentDir()->canonicalPath(); |
660 | int ramble=2; | 661 | int ramble=2; |
661 | // int ramble=-24; | 662 | // int ramble=-24; |
662 | //first remove list | 663 | //first remove list |
663 | if(list.grep(dir,true).isEmpty()) { | 664 | if(list.grep(dir,true).isEmpty()) { |
664 | QMessageBox::message(tr( "AdvancedFm" ), | 665 | QMessageBox::message(tr( "AdvancedFm" ), |
665 | tr("<p>Cannot remove current directory from bookmarks. It is not bookmarked!</p>")); | 666 | tr("<p>Cannot remove current directory from bookmarks. It is not bookmarked!</p>")); |
666 | } else { | 667 | } else { |
667 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 668 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
668 | if((*it) != dir) { | 669 | if((*it) != dir) { |
669 | //current item is not our current dir, so add it to temp list | 670 | //current item is not our current dir, so add it to temp list |
670 | list2 <<(*it); | 671 | list2 <<(*it); |
671 | } else { | 672 | } else { |
672 | // customDirMenu->removeItem( ramble); | 673 | // customDirMenu->removeItem( ramble); |
673 | menuButton->remove( ramble); | 674 | menuButton->remove( ramble); |
674 | 675 | ||
675 | } | 676 | } |
676 | ramble++; | 677 | ramble++; |
677 | // ramble--; | 678 | // ramble--; |
678 | } | 679 | } |
679 | 680 | ||
680 | cfg.writeEntry("CustomDir", list2, ','); | 681 | cfg.writeEntry("CustomDir", list2, ','); |
681 | cfg.write(); | 682 | cfg.write(); |
682 | } | 683 | } |
683 | // customDirsToMenu(); | 684 | // customDirsToMenu(); |
684 | 685 | ||