author | drw <drw> | 2005-05-16 20:38:10 (UTC) |
---|---|---|
committer | drw <drw> | 2005-05-16 20:38:10 (UTC) |
commit | 28503944437feb62c0f2c0a8314385bbca3e9eaf (patch) (unidiff) | |
tree | 2b613d2b1bde21bf3e002bb4dc8c474c4d781fe1 | |
parent | 348314c7411500e23ca467289ed92e446be9121b (diff) | |
download | opie-28503944437feb62c0f2c0a8314385bbca3e9eaf.zip opie-28503944437feb62c0f2c0a8314385bbca3e9eaf.tar.gz opie-28503944437feb62c0f2c0a8314385bbca3e9eaf.tar.bz2 |
Resource -> OResource
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 27 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmData.cpp | 29 |
2 files changed, 26 insertions, 30 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 979549d..828f5a1 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1,296 +1,290 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #define DEVELOPERS_VERSION | 12 | #define DEVELOPERS_VERSION |
13 | #include "advancedfm.h" | 13 | #include "advancedfm.h" |
14 | 14 | ||
15 | #include <opie2/odebug.h> | 15 | #include <opie2/odebug.h> |
16 | 16 | #include <opie2/oresource.h> | |
17 | #include <opie2/ostorageinfo.h> | 17 | #include <opie2/ostorageinfo.h> |
18 | 18 | ||
19 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
20 | #include <qpe/config.h> | 20 | #include <qpe/config.h> |
21 | #include <qpe/mimetype.h> | 21 | #include <qpe/mimetype.h> |
22 | #include <qpe/applnk.h> | 22 | #include <qpe/applnk.h> |
23 | #include <qpe/resource.h> | ||
24 | #include <qpe/menubutton.h> | 23 | #include <qpe/menubutton.h> |
25 | 24 | ||
26 | #include <qcombobox.h> | 25 | #include <qcombobox.h> |
27 | #include <qpopupmenu.h> | 26 | #include <qpopupmenu.h> |
28 | #include <qlistview.h> | 27 | #include <qlistview.h> |
29 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
30 | #include <qlineedit.h> | 29 | #include <qlineedit.h> |
31 | 30 | ||
32 | 31 | ||
33 | #include <sys/stat.h> | 32 | #include <sys/stat.h> |
34 | #include <time.h> | 33 | #include <time.h> |
35 | #include <dirent.h> | 34 | #include <dirent.h> |
36 | #include <fcntl.h> | 35 | #include <fcntl.h> |
37 | #include <sys/vfs.h> | 36 | #include <sys/vfs.h> |
38 | #include <mntent.h> | 37 | #include <mntent.h> |
39 | 38 | ||
40 | using namespace Opie::Ui; | 39 | using namespace Opie::Ui; |
41 | 40 | ||
42 | AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) | 41 | AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) |
43 | : QMainWindow( ) { | 42 | : QMainWindow( ) { |
44 | init(); | 43 | init(); |
45 | renameBox = 0; | 44 | renameBox = 0; |
46 | whichTab = 1; | 45 | whichTab = 1; |
47 | unknownXpm = Resource::loadImage("UnknownDocument").smoothScale(AppLnk::smallIconSize(),AppLnk::smallIconSize() ); | 46 | unknownXpm = Opie::Core::OResource::loadImage("UnknownDocument", Opie::Core::OResource::SmallIcon); |
48 | 47 | ||
49 | initConnections(); | 48 | initConnections(); |
50 | rePopulate(); | 49 | rePopulate(); |
51 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); | 50 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); |
52 | connect(channel,SIGNAL(received(const QCString&,const QByteArray&)),this,SLOT(qcopReceive(const QCString&,const QByteArray&))); | 51 | connect(channel,SIGNAL(received(const QCString&,const QByteArray&)),this,SLOT(qcopReceive(const QCString&,const QByteArray&))); |
53 | switchToLocalTab(); | 52 | switchToLocalTab(); |
54 | } | 53 | } |
55 | 54 | ||
56 | AdvancedFm::~AdvancedFm() { | 55 | AdvancedFm::~AdvancedFm() { |
57 | } | 56 | } |
58 | 57 | ||
59 | 58 | ||
60 | void AdvancedFm::cleanUp() { | 59 | void AdvancedFm::cleanUp() { |
61 | QString sfile=QDir::homeDirPath(); | 60 | QString sfile=QDir::homeDirPath(); |
62 | if(sfile.right(1) != "/") | 61 | if(sfile.right(1) != "/") |
63 | sfile+="/._temp"; | 62 | sfile+="/._temp"; |
64 | else | 63 | else |
65 | sfile+="._temp"; | 64 | sfile+="._temp"; |
66 | QFile file( sfile); | 65 | QFile file( sfile); |
67 | if(file.exists()) | 66 | if(file.exists()) |
68 | file.remove(); | 67 | file.remove(); |
69 | } | 68 | } |
70 | 69 | ||
71 | void AdvancedFm::tabChanged(QWidget *wd) { | 70 | void AdvancedFm::tabChanged(QWidget *wd) { |
72 | if(wd == tab) { | 71 | if(wd == tab) { |
73 | whichTab = 1; | 72 | whichTab = 1; |
74 | viewMenu->setItemChecked(viewMenu->idAt(0), true); | 73 | viewMenu->setItemChecked(viewMenu->idAt(0), true); |
75 | viewMenu->setItemChecked(viewMenu->idAt(1), false); | 74 | viewMenu->setItemChecked(viewMenu->idAt(1), false); |
76 | // qDebug("tabchanged: LOCAL VIEW SHOWN"); | 75 | // qDebug("tabchanged: LOCAL VIEW SHOWN"); |
77 | } | 76 | } |
78 | 77 | ||
79 | else if(wd == tab_2) { | 78 | else if(wd == tab_2) { |
80 | whichTab = 2; | 79 | whichTab = 2; |
81 | viewMenu->setItemChecked(viewMenu->idAt(0), false); | 80 | viewMenu->setItemChecked(viewMenu->idAt(0), false); |
82 | viewMenu->setItemChecked(viewMenu->idAt(1), true); | 81 | viewMenu->setItemChecked(viewMenu->idAt(1), true); |
83 | // qDebug("tabchanged: REMOTE VIEW SHOWN"); | 82 | // qDebug("tabchanged: REMOTE VIEW SHOWN"); |
84 | } | 83 | } |
85 | qApp->processEvents(); | 84 | qApp->processEvents(); |
86 | QString path = CurrentDir()->canonicalPath(); | 85 | QString path = CurrentDir()->canonicalPath(); |
87 | 86 | ||
88 | chdir( path.latin1()); | 87 | chdir( path.latin1()); |
89 | currentPathCombo->lineEdit()->setText(path); | 88 | currentPathCombo->lineEdit()->setText(path); |
90 | } | 89 | } |
91 | 90 | ||
92 | 91 | ||
93 | void AdvancedFm::populateView() { | 92 | void AdvancedFm::populateView() { |
94 | 93 | ||
95 | QPixmap pm; | 94 | QPixmap pm; |
96 | QListView *thisView = CurrentView(); | 95 | QListView *thisView = CurrentView(); |
97 | QDir *thisDir = CurrentDir(); | 96 | QDir *thisDir = CurrentDir(); |
98 | QString path = thisDir->canonicalPath(); | 97 | QString path = thisDir->canonicalPath(); |
99 | 98 | ||
100 | thisView->clear(); | 99 | thisView->clear(); |
101 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 100 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
102 | thisDir->setMatchAllDirs(TRUE); | 101 | thisDir->setMatchAllDirs(TRUE); |
103 | thisDir->setNameFilter(filterStr); | 102 | thisDir->setNameFilter(filterStr); |
104 | QString fileL, fileS, fileDate; | 103 | QString fileL, fileS, fileDate; |
105 | 104 | ||
106 | QString fs = getFileSystemType((const QString &) path); | 105 | QString fs = getFileSystemType((const QString &) path); |
107 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | 106 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
108 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); | 107 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); |
109 | bool isDir = FALSE; | 108 | bool isDir = FALSE; |
110 | 109 | ||
111 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 110 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
112 | QFileInfoListIterator it(*list); | 111 | QFileInfoListIterator it(*list); |
113 | QFileInfo *fi; | 112 | QFileInfo *fi; |
114 | while ( (fi=it.current()) ) { | 113 | while ( (fi=it.current()) ) { |
115 | if (fi->isSymLink() ) { | 114 | if (fi->isSymLink() ) { |
116 | QString symLink = fi->readLink(); | 115 | QString symLink = fi->readLink(); |
117 | QFileInfo sym( symLink); | 116 | QFileInfo sym( symLink); |
118 | fileS.sprintf( "%10i", sym.size() ); | 117 | fileS.sprintf( "%10i", sym.size() ); |
119 | fileL = fi->fileName() +" -> " + sym.filePath().data(); | 118 | fileL = fi->fileName() +" -> " + sym.filePath().data(); |
120 | fileDate = sym.lastModified().toString(); | 119 | fileDate = sym.lastModified().toString(); |
121 | } else { | 120 | } else { |
122 | fileS.sprintf( "%10i", fi->size() ); | 121 | fileS.sprintf( "%10i", fi->size() ); |
123 | fileL = fi->fileName(); | 122 | fileL = fi->fileName(); |
124 | fileDate= fi->lastModified().toString(); | 123 | fileDate= fi->lastModified().toString(); |
125 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { | 124 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { |
126 | // if(fileL == "..") | 125 | // if(fileL == "..") |
127 | fileL += "/"; | 126 | fileL += "/"; |
128 | isDir=TRUE; | 127 | isDir=TRUE; |
129 | } | 128 | } |
130 | } | 129 | } |
131 | QFileInfo fileInfo( path + "/" + fileL); | 130 | QFileInfo fileInfo( path + "/" + fileL); |
132 | 131 | ||
133 | if(fileL !="./" && fi->exists()) { | 132 | if(fileL !="./" && fi->exists()) { |
134 | item = new QListViewItem( thisView, fileL, fileS , fileDate); | 133 | item = new QListViewItem( thisView, fileL, fileS , fileDate); |
135 | 134 | ||
136 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 135 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
137 | 136 | ||
138 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 137 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
139 | pm.convertFromImage( Resource::loadImage( "lockedfolder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 138 | pm = Opie::Core::OResource::loadPixmap( "lockedfolder", Opie::Core::OResource::SmallIcon ); |
140 | else | 139 | else |
141 | pm.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 140 | pm = Opie::Core::OResource::loadPixmap( "folder", Opie::Core::OResource::SmallIcon ); |
142 | } | 141 | } |
143 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 142 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
144 | pm.convertFromImage( Resource::loadImage( "exec" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 143 | pm = Opie::Core::OResource::loadPixmap( "exec", Opie::Core::OResource::SmallIcon ); |
145 | } | 144 | } |
146 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 145 | else if( (fileInfo.permission( QFileInfo::ExeUser) |
147 | | fileInfo.permission( QFileInfo::ExeGroup) | 146 | | fileInfo.permission( QFileInfo::ExeGroup) |
148 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 147 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
149 | pm.convertFromImage( Resource::loadImage( "exec" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 148 | pm = Opie::Core::OResource::loadPixmap( "exec", Opie::Core::OResource::SmallIcon ); |
150 | } | 149 | } |
151 | else if( !fi->isReadable() ) { | 150 | else if( !fi->isReadable() ) { |
152 | pm.convertFromImage( Resource::loadImage( "locked" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 151 | pm = Opie::Core::OResource::loadPixmap( "locked", Opie::Core::OResource::SmallIcon ); |
153 | } | 152 | } |
154 | else { //everything else goes by mimetype | 153 | else { //everything else goes by mimetype |
155 | MimeType mt(fi->filePath()); | 154 | MimeType mt(fi->filePath()); |
156 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 155 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
157 | if(pm.isNull()) { | 156 | if(pm.isNull()) { |
158 | pm = unknownXpm; | 157 | pm = unknownXpm; |
159 | } | 158 | } |
160 | } | 159 | } |
161 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { | 160 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { |
162 | // odebug << " overlay link image" << oendl; | 161 | // odebug << " overlay link image" << oendl; |
163 | pm.convertFromImage( Resource::loadImage( "advancedfm/symlink" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 162 | pm = Opie::Core::OResource::loadPixmap( "advancedfm/symlink", Opie::Core::OResource::SmallIcon ); |
164 | // pm= Resource::loadPixmap( "folder" ); | ||
165 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | ||
166 | // QPainter painter( &pm ); | ||
167 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | ||
168 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); | ||
169 | } | 163 | } |
170 | item->setPixmap( 0, pm ); | 164 | item->setPixmap( 0, pm ); |
171 | 165 | ||
172 | } | 166 | } |
173 | isDir=FALSE; | 167 | isDir=FALSE; |
174 | ++it; | 168 | ++it; |
175 | } | 169 | } |
176 | 170 | ||
177 | if( path.find("dev",0,TRUE) != -1) { | 171 | if( path.find("dev",0,TRUE) != -1) { |
178 | struct stat buf; | 172 | struct stat buf; |
179 | dev_t devT; | 173 | dev_t devT; |
180 | DIR *dir; | 174 | DIR *dir; |
181 | struct dirent *mydirent; | 175 | struct dirent *mydirent; |
182 | 176 | ||
183 | if((dir = opendir( path.latin1())) != NULL) | 177 | if((dir = opendir( path.latin1())) != NULL) |
184 | while ((mydirent = readdir(dir)) != NULL) { | 178 | while ((mydirent = readdir(dir)) != NULL) { |
185 | lstat( mydirent->d_name, &buf); | 179 | lstat( mydirent->d_name, &buf); |
186 | // odebug << mydirent->d_name << oendl; | 180 | // odebug << mydirent->d_name << oendl; |
187 | fileL.sprintf("%s", mydirent->d_name); | 181 | fileL.sprintf("%s", mydirent->d_name); |
188 | devT = buf.st_dev; | 182 | devT = buf.st_dev; |
189 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 183 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
190 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 184 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
191 | if( fileL.find(".") == -1 ) { | 185 | if( fileL.find(".") == -1 ) { |
192 | item= new QListViewItem( thisView, fileL, fileS, fileDate); | 186 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
193 | pm = unknownXpm; | 187 | pm = unknownXpm; |
194 | item->setPixmap( 0,pm); | 188 | item->setPixmap( 0,pm); |
195 | } | 189 | } |
196 | } | 190 | } |
197 | 191 | ||
198 | closedir(dir); | 192 | closedir(dir); |
199 | } | 193 | } |
200 | 194 | ||
201 | thisView->setSorting( 3,FALSE); | 195 | thisView->setSorting( 3,FALSE); |
202 | fillCombo( (const QString &) path ); | 196 | fillCombo( (const QString &) path ); |
203 | } | 197 | } |
204 | 198 | ||
205 | void AdvancedFm::rePopulate() { | 199 | void AdvancedFm::rePopulate() { |
206 | // qDebug("repopulate views"); | 200 | // qDebug("repopulate views"); |
207 | populateView(); | 201 | populateView(); |
208 | setOtherTabCurrent(); | 202 | setOtherTabCurrent(); |
209 | populateView(); | 203 | populateView(); |
210 | } | 204 | } |
211 | 205 | ||
212 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { | 206 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { |
213 | if(selectedItem) { | 207 | if(selectedItem) { |
214 | QString strItem=selectedItem->text(0); | 208 | QString strItem=selectedItem->text(0); |
215 | // owarn << strItem << oendl; | 209 | // owarn << strItem << oendl; |
216 | QString strSize=selectedItem->text(1); | 210 | QString strSize=selectedItem->text(1); |
217 | strSize=strSize.stripWhiteSpace(); | 211 | strSize=strSize.stripWhiteSpace(); |
218 | bool isDirectory = false; | 212 | bool isDirectory = false; |
219 | QString strItem2; | 213 | QString strItem2; |
220 | 214 | ||
221 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink | 215 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) {//if symlink |
222 | strItem2 = dealWithSymName((const QString&)strItem); | 216 | strItem2 = dealWithSymName((const QString&)strItem); |
223 | if(QDir(strItem2).exists() ) | 217 | if(QDir(strItem2).exists() ) |
224 | strItem = strItem2; | 218 | strItem = strItem2; |
225 | } | 219 | } |
226 | 220 | ||
227 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 221 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
228 | 222 | ||
229 | if(QDir(strItem).exists()) | 223 | if(QDir(strItem).exists()) |
230 | isDirectory = true; | 224 | isDirectory = true; |
231 | } | 225 | } |
232 | 226 | ||
233 | if( isDirectory ) { | 227 | if( isDirectory ) { |
234 | CurrentDir()->cd( strItem, TRUE); | 228 | CurrentDir()->cd( strItem, TRUE); |
235 | populateView(); | 229 | populateView(); |
236 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); | 230 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); |
237 | } | 231 | } |
238 | chdir( strItem.latin1()); | 232 | chdir( strItem.latin1()); |
239 | } | 233 | } |
240 | } | 234 | } |
241 | 235 | ||
242 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { | 236 | void AdvancedFm::ListPressed( int mouse, QListViewItem *item, const QPoint& , int ) { |
243 | Q_UNUSED(item); | 237 | Q_UNUSED(item); |
244 | switch (mouse) { | 238 | switch (mouse) { |
245 | case 1: | 239 | case 1: |
246 | { | 240 | { |
247 | if(renameBox != 0 ) { | 241 | if(renameBox != 0 ) { |
248 | cancelRename(); | 242 | cancelRename(); |
249 | } | 243 | } |
250 | } | 244 | } |
251 | break; | 245 | break; |
252 | // case 2: | 246 | // case 2: |
253 | // menuTimer.start( 50, TRUE ); | 247 | // menuTimer.start( 50, TRUE ); |
254 | // break; | 248 | // break; |
255 | }; | 249 | }; |
256 | } | 250 | } |
257 | 251 | ||
258 | 252 | ||
259 | void AdvancedFm::refreshCurrentTab() { | 253 | void AdvancedFm::refreshCurrentTab() { |
260 | populateView(); | 254 | populateView(); |
261 | // if ( TabWidget->currentWidget() == tab) { | 255 | // if ( TabWidget->currentWidget() == tab) { |
262 | } | 256 | } |
263 | 257 | ||
264 | void AdvancedFm::switchToLocalTab() { | 258 | void AdvancedFm::switchToLocalTab() { |
265 | TabWidget->setCurrentWidget(tab); | 259 | TabWidget->setCurrentWidget(tab); |
266 | Local_View->setFocus(); | 260 | Local_View->setFocus(); |
267 | // whichTab = 1; | 261 | // whichTab = 1; |
268 | } | 262 | } |
269 | 263 | ||
270 | void AdvancedFm::switchToRemoteTab() { | 264 | void AdvancedFm::switchToRemoteTab() { |
271 | TabWidget->setCurrentWidget(tab_2); | 265 | TabWidget->setCurrentWidget(tab_2); |
272 | Remote_View->setFocus(); | 266 | Remote_View->setFocus(); |
273 | // whichTab = 2; | 267 | // whichTab = 2; |
274 | } | 268 | } |
275 | 269 | ||
276 | void AdvancedFm::currentPathComboChanged() { | 270 | void AdvancedFm::currentPathComboChanged() { |
277 | QString pDir = currentPathCombo->lineEdit()->text(); | 271 | QString pDir = currentPathCombo->lineEdit()->text(); |
278 | if(QDir(pDir).exists()) { | 272 | if(QDir(pDir).exists()) { |
279 | CurrentDir()->setPath(pDir ); | 273 | CurrentDir()->setPath(pDir ); |
280 | populateView(); | 274 | populateView(); |
281 | } else { | 275 | } else { |
282 | QMessageBox::message(tr("Note"),tr("<p>%1 does not exist</p>").arg(pDir)); | 276 | QMessageBox::message(tr("Note"),tr("<p>%1 does not exist</p>").arg(pDir)); |
283 | } | 277 | } |
284 | } | 278 | } |
285 | 279 | ||
286 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 280 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
287 | 281 | ||
288 | if ( TabWidget->currentWidget() == tab) { | 282 | if ( TabWidget->currentWidget() == tab) { |
289 | // if ( whichTab == 1) { | 283 | // if ( whichTab == 1) { |
290 | currentPathCombo->lineEdit()->setText( currentPath); | 284 | currentPathCombo->lineEdit()->setText( currentPath); |
291 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 285 | if( localDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
292 | currentPathCombo->clear(); | 286 | currentPathCombo->clear(); |
293 | localDirPathStringList.prepend( currentPath ); | 287 | localDirPathStringList.prepend( currentPath ); |
294 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 288 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
295 | } | 289 | } |
296 | } else { | 290 | } else { |
@@ -335,257 +329,258 @@ void AdvancedFm::docButtonPushed() { | |||
335 | void AdvancedFm::SDButtonPushed() { | 329 | void AdvancedFm::SDButtonPushed() { |
336 | Opie::Core::OStorageInfo info; | 330 | Opie::Core::OStorageInfo info; |
337 | if(StorageInfo::hasSd() ) { | 331 | if(StorageInfo::hasSd() ) { |
338 | changeTo(info.sdPath()); | 332 | changeTo(info.sdPath()); |
339 | } | 333 | } |
340 | else if(StorageInfo::hasMmc()) { | 334 | else if(StorageInfo::hasMmc()) { |
341 | changeTo(info.mmcPath()); | 335 | changeTo(info.mmcPath()); |
342 | } | 336 | } |
343 | } | 337 | } |
344 | 338 | ||
345 | void AdvancedFm::CFButtonPushed() { | 339 | void AdvancedFm::CFButtonPushed() { |
346 | Opie::Core::OStorageInfo info; | 340 | Opie::Core::OStorageInfo info; |
347 | changeTo(info.cfPath()); | 341 | changeTo(info.cfPath()); |
348 | } | 342 | } |
349 | 343 | ||
350 | void AdvancedFm::QPEButtonPushed() { | 344 | void AdvancedFm::QPEButtonPushed() { |
351 | changeTo(QPEApplication::qpeDir()); | 345 | changeTo(QPEApplication::qpeDir()); |
352 | } | 346 | } |
353 | 347 | ||
354 | void AdvancedFm::doAbout() { | 348 | void AdvancedFm::doAbout() { |
355 | 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>")); | 349 | 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>")); |
356 | } | 350 | } |
357 | 351 | ||
358 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { | 352 | void AdvancedFm::keyPressEvent( QKeyEvent *e) { |
359 | Q_UNUSED(e); | 353 | Q_UNUSED(e); |
360 | } | 354 | } |
361 | 355 | ||
362 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { | 356 | void AdvancedFm::keyReleaseEvent( QKeyEvent *e) { |
363 | // if( CurrentView()->hasFocus() ) | 357 | // if( CurrentView()->hasFocus() ) |
364 | // e->ignore(); | 358 | // e->ignore(); |
365 | 359 | ||
366 | if( currentPathCombo->lineEdit()->hasFocus()) { | 360 | if( currentPathCombo->lineEdit()->hasFocus()) { |
367 | // qDebug("shout!"); | 361 | // qDebug("shout!"); |
368 | } | 362 | } |
369 | 363 | ||
370 | else if( e->key() == Key_Left ) | 364 | else if( e->key() == Key_Left ) |
371 | upDir(); | 365 | upDir(); |
372 | else if( e->key() == Key_Return || e->key() == Key_Enter) | 366 | else if( e->key() == Key_Return || e->key() == Key_Enter) |
373 | navigateToSelected(); | 367 | navigateToSelected(); |
374 | else if( e->key() == Key_Tab) | 368 | else if( e->key() == Key_Tab) |
375 | setOtherTabCurrent(); | 369 | setOtherTabCurrent(); |
376 | else if( e->key() == Key_Delete ) | 370 | else if( e->key() == Key_Delete ) |
377 | del(); | 371 | del(); |
378 | else | 372 | else |
379 | e->accept(); | 373 | e->accept(); |
380 | 374 | ||
381 | } | 375 | } |
382 | 376 | ||
383 | 377 | ||
384 | void AdvancedFm::parsetab(const QString &fileName) { | 378 | void AdvancedFm::parsetab(const QString &fileName) { |
385 | 379 | ||
386 | fileSystemTypeList.clear(); | 380 | fileSystemTypeList.clear(); |
387 | fsList.clear(); | 381 | fsList.clear(); |
388 | struct mntent *me; | 382 | struct mntent *me; |
389 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); | 383 | FILE *mntfp = setmntent( fileName.latin1(), "r" ); |
390 | if ( mntfp ) { | 384 | if ( mntfp ) { |
391 | while ( (me = getmntent( mntfp )) != 0 ) { | 385 | while ( (me = getmntent( mntfp )) != 0 ) { |
392 | QString deviceName = me->mnt_fsname; | 386 | QString deviceName = me->mnt_fsname; |
393 | QString filesystemType = me->mnt_type; | 387 | QString filesystemType = me->mnt_type; |
394 | QString mountDir = me->mnt_dir; | 388 | QString mountDir = me->mnt_dir; |
395 | if(deviceName != "none") { | 389 | if(deviceName != "none") { |
396 | if( fsList.contains(filesystemType) == 0 | 390 | if( fsList.contains(filesystemType) == 0 |
397 | & filesystemType.find("proc",0,TRUE) == -1 | 391 | & filesystemType.find("proc",0,TRUE) == -1 |
398 | & filesystemType.find("cramfs",0,TRUE) == -1 | 392 | & filesystemType.find("cramfs",0,TRUE) == -1 |
399 | & filesystemType.find("auto",0,TRUE) == -1) | 393 | & filesystemType.find("auto",0,TRUE) == -1) |
400 | fsList << filesystemType; | 394 | fsList << filesystemType; |
401 | fileSystemTypeList << mountDir+"::"+filesystemType; | 395 | fileSystemTypeList << mountDir+"::"+filesystemType; |
402 | } | 396 | } |
403 | } | 397 | } |
404 | } | 398 | } |
405 | endmntent( mntfp ); | 399 | endmntent( mntfp ); |
406 | } | 400 | } |
407 | 401 | ||
408 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { | 402 | QString AdvancedFm::getFileSystemType(const QString ¤tText) { |
409 | parsetab("/etc/mtab"); //why did TT forget filesystem type? | 403 | parsetab("/etc/mtab"); //why did TT forget filesystem type? |
410 | QString current = currentText;//.right( currentText.length()-1); | 404 | QString current = currentText;//.right( currentText.length()-1); |
411 | QString baseFs; | 405 | QString baseFs; |
412 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { | 406 | for ( QStringList::Iterator it = fileSystemTypeList.begin(); it != fileSystemTypeList.end(); ++it ) { |
413 | QString temp = (*it); | 407 | QString temp = (*it); |
414 | QString path = temp.left(temp.find("::",0,TRUE) ); | 408 | QString path = temp.left(temp.find("::",0,TRUE) ); |
415 | path = path.right( path.length()-1); | 409 | path = path.right( path.length()-1); |
416 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 410 | if(path.isEmpty()) baseFs = temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
417 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { | 411 | if( current.find( path,0,TRUE) != -1 && !path.isEmpty()) { |
418 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); | 412 | return temp.right( temp.length() - temp.find("::",0,TRUE) - 2); |
419 | } | 413 | } |
420 | } | 414 | } |
421 | return baseFs; | 415 | return baseFs; |
422 | } | 416 | } |
423 | 417 | ||
424 | QString AdvancedFm::getDiskSpace( const QString &path) { | 418 | QString AdvancedFm::getDiskSpace( const QString &path) { |
425 | struct statfs fss; | 419 | struct statfs fss; |
426 | if ( !statfs( path.latin1(), &fss ) ) { | 420 | if ( !statfs( path.latin1(), &fss ) ) { |
427 | int blkSize = fss.f_bsize; | 421 | int blkSize = fss.f_bsize; |
428 | // int totalBlks = fs.f_blocks; | 422 | // int totalBlks = fs.f_blocks; |
429 | int availBlks = fss.f_bavail; | 423 | int availBlks = fss.f_bavail; |
430 | 424 | ||
431 | long mult = blkSize / 1024; | 425 | long mult = blkSize / 1024; |
432 | long div = 1024 / blkSize; | 426 | long div = 1024 / blkSize; |
433 | if ( !mult ) mult = 1; | 427 | if ( !mult ) mult = 1; |
434 | if ( !div ) div = 1; | 428 | if ( !div ) div = 1; |
435 | 429 | ||
436 | return QString::number(availBlks * mult / div); | 430 | return QString::number(availBlks * mult / div); |
437 | } | 431 | } |
438 | return ""; | 432 | return ""; |
439 | } | 433 | } |
440 | 434 | ||
441 | 435 | ||
442 | void AdvancedFm::showFileMenu() { | 436 | void AdvancedFm::showFileMenu() { |
443 | QString curApp; | 437 | QString curApp; |
444 | curApp = CurrentView()->currentItem()->text(0); | 438 | curApp = CurrentView()->currentItem()->text(0); |
445 | 439 | ||
446 | MimeType mt(curApp); | 440 | MimeType mt(curApp); |
447 | const AppLnk* app = mt.application(); | 441 | const AppLnk* app = mt.application(); |
448 | QFile fi(curApp); | 442 | QFile fi(curApp); |
449 | QPopupMenu *m = new QPopupMenu(0); | 443 | QPopupMenu *m = new QPopupMenu(0); |
450 | QPopupMenu *n = new QPopupMenu(0); | 444 | QPopupMenu *n = new QPopupMenu(0); |
451 | // QPopupMenu *o = new QPopupMenu(0); | 445 | // QPopupMenu *o = new QPopupMenu(0); |
452 | m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); | 446 | m->insertItem(tr("Show Hidden Files"),this,SLOT(showHidden())); |
453 | 447 | ||
454 | if ( QFileInfo(fi).isDir()) { | 448 | if ( QFileInfo(fi).isDir()) { |
455 | m->insertSeparator(); | 449 | m->insertSeparator(); |
456 | m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); | 450 | m->insertItem(tr("Change Directory"),this,SLOT(doDirChange())); |
457 | } else { | 451 | } else { |
458 | 452 | ||
459 | if (app) | 453 | if (app) |
460 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); | 454 | m->insertItem(app->pixmap(),tr("Open in " + app->name()),this,SLOT(runThis())); |
461 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this | 455 | else if(QFileInfo(fi).isExecutable() ) //damn opie doesnt like this |
462 | m->insertItem(tr("Execute"),this,SLOT(runThis())); | 456 | m->insertItem(tr("Execute"),this,SLOT(runThis())); |
463 | m->insertItem(Resource::loadPixmap("txt"),tr("Open as text"),this,SLOT(runText())); | 457 | m->insertItem( Opie::Core::OResource::loadPixmap( "txt", Opie::Core::OResource::SmallIcon ), |
458 | tr("Open as text"),this,SLOT(runText())); | ||
464 | } | 459 | } |
465 | 460 | ||
466 | m->insertItem(tr("Actions"),n); | 461 | m->insertItem(tr("Actions"),n); |
467 | n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); | 462 | n->insertItem(tr("Make Directory"),this,SLOT(makeDir())); |
468 | 463 | ||
469 | n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); | 464 | n->insertItem(tr("Make Symlink"),this,SLOT(mkSym())); |
470 | 465 | ||
471 | n->insertSeparator(); | 466 | n->insertSeparator(); |
472 | n->insertItem(tr("Rename"),this,SLOT(renameIt())); | 467 | n->insertItem(tr("Rename"),this,SLOT(renameIt())); |
473 | 468 | ||
474 | n->insertItem(tr("Copy"),this,SLOT(copyTimer())); | 469 | n->insertItem(tr("Copy"),this,SLOT(copyTimer())); |
475 | n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); | 470 | n->insertItem(tr("Copy As"),this,SLOT(copyAsTimer())); |
476 | n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); | 471 | n->insertItem(tr("Copy Same Dir"),this,SLOT(copySameDirTimer())); |
477 | n->insertItem(tr("Move"),this,SLOT(moveTimer())); | 472 | n->insertItem(tr("Move"),this,SLOT(moveTimer())); |
478 | 473 | ||
479 | n->insertSeparator(); | 474 | n->insertSeparator(); |
480 | n->insertItem(tr("Delete"),this,SLOT(doDelete())); | 475 | n->insertItem(tr("Delete"),this,SLOT(doDelete())); |
481 | m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); | 476 | m->insertItem(tr("Add To Documents"),this,SLOT(addToDocs())); |
482 | 477 | ||
483 | m->insertItem(tr("Run Command"),this,SLOT(runCommand())); | 478 | m->insertItem(tr("Run Command"),this,SLOT(runCommand())); |
484 | m->insertItem(tr("File Info"),this,SLOT(fileStatus())); | 479 | m->insertItem(tr("File Info"),this,SLOT(fileStatus())); |
485 | 480 | ||
486 | m->insertSeparator(); | 481 | m->insertSeparator(); |
487 | m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); | 482 | m->insertItem(tr("Set Permissions"),this,SLOT(filePerms())); |
488 | 483 | ||
489 | #if defined(QT_QWS_OPIE) | 484 | #if defined(QT_QWS_OPIE) |
490 | m->insertItem(tr("Properties"),this,SLOT(doProperties())); | 485 | m->insertItem(tr("Properties"),this,SLOT(doProperties())); |
491 | #endif | 486 | #endif |
492 | m->setCheckable(TRUE); | 487 | m->setCheckable(TRUE); |
493 | if (!b) | 488 | if (!b) |
494 | m->setItemChecked(m->idAt(0),TRUE); | 489 | m->setItemChecked(m->idAt(0),TRUE); |
495 | else | 490 | else |
496 | m->setItemChecked(m->idAt(0),FALSE); | 491 | m->setItemChecked(m->idAt(0),FALSE); |
497 | 492 | ||
498 | if(Ir::supported()) | 493 | if(Ir::supported()) |
499 | m->insertItem(tr("Beam File"),this,SLOT(doBeam())); | 494 | m->insertItem(tr("Beam File"),this,SLOT(doBeam())); |
500 | m->setFocus(); | 495 | m->setFocus(); |
501 | 496 | ||
502 | m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); | 497 | m->exec(QPoint(QCursor::pos().x(),QCursor::pos().y())); |
503 | 498 | ||
504 | if(m) delete m; | 499 | if(m) delete m; |
505 | } | 500 | } |
506 | 501 | ||
507 | 502 | ||
508 | QString AdvancedFm::checkDiskSpace(const QString &path) { | 503 | QString AdvancedFm::checkDiskSpace(const QString &path) { |
509 | struct statfs fss; | 504 | struct statfs fss; |
510 | if ( !statfs( path.latin1(), &fss ) ) { | 505 | if ( !statfs( path.latin1(), &fss ) ) { |
511 | int blkSize = fss.f_bsize; | 506 | int blkSize = fss.f_bsize; |
512 | // int totalBlks = fs.f_blocks; | 507 | // int totalBlks = fs.f_blocks; |
513 | int availBlks = fss.f_bavail; | 508 | int availBlks = fss.f_bavail; |
514 | 509 | ||
515 | long mult = blkSize / 1024; | 510 | long mult = blkSize / 1024; |
516 | long div = 1024 / blkSize; | 511 | long div = 1024 / blkSize; |
517 | if ( !mult ) mult = 1; | 512 | if ( !mult ) mult = 1; |
518 | if ( !div ) div = 1; | 513 | if ( !div ) div = 1; |
519 | 514 | ||
520 | 515 | ||
521 | return QString::number(availBlks * mult / div); | 516 | return QString::number(availBlks * mult / div); |
522 | } | 517 | } |
523 | return ""; | 518 | return ""; |
524 | } | 519 | } |
525 | 520 | ||
526 | void AdvancedFm::addToDocs() { | 521 | void AdvancedFm::addToDocs() { |
527 | QStringList strListPaths = getPath(); | 522 | QStringList strListPaths = getPath(); |
528 | QDir *thisDir = CurrentDir(); | 523 | QDir *thisDir = CurrentDir(); |
529 | 524 | ||
530 | if( strListPaths.count() > 0) { | 525 | if( strListPaths.count() > 0) { |
531 | QString curFile; | 526 | QString curFile; |
532 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { | 527 | for ( QStringList::Iterator it = strListPaths.begin(); it != strListPaths.end(); ++it ) { |
533 | curFile = thisDir->canonicalPath()+"/"+(*it); | 528 | curFile = thisDir->canonicalPath()+"/"+(*it); |
534 | // odebug << curFile << oendl; | 529 | // odebug << curFile << oendl; |
535 | QFileInfo fi(curFile); | 530 | QFileInfo fi(curFile); |
536 | DocLnk f; | 531 | DocLnk f; |
537 | // curFile.replace(QRegExp("\\..*"),""); | 532 | // curFile.replace(QRegExp("\\..*"),""); |
538 | f.setName(fi.baseName() ); | 533 | f.setName(fi.baseName() ); |
539 | f.setFile( curFile); | 534 | f.setFile( curFile); |
540 | f.writeLink(); | 535 | f.writeLink(); |
541 | } | 536 | } |
542 | } | 537 | } |
543 | } | 538 | } |
544 | 539 | ||
545 | 540 | ||
546 | void AdvancedFm::customDirsToMenu() { | 541 | void AdvancedFm::customDirsToMenu() { |
547 | 542 | ||
548 | Config cfg("AdvancedFm"); | 543 | Config cfg("AdvancedFm"); |
549 | cfg.setGroup("Menu"); | 544 | cfg.setGroup("Menu"); |
550 | 545 | ||
551 | QStringList list = cfg.readListEntry( "CustomDir", ','); | 546 | QStringList list = cfg.readListEntry( "CustomDir", ','); |
552 | menuButton->insertItems(list ); | 547 | menuButton->insertItems(list ); |
553 | 548 | ||
554 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) | 549 | // for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
555 | // { | 550 | // { |
556 | // customDirMenu->insertItem(*it ); | 551 | // customDirMenu->insertItem(*it ); |
557 | // } | 552 | // } |
558 | } | 553 | } |
559 | 554 | ||
560 | void AdvancedFm::dirMenuSelected(int item) { | 555 | void AdvancedFm::dirMenuSelected(int item) { |
561 | switch(item) | 556 | switch(item) |
562 | { | 557 | { |
563 | 558 | ||
564 | case -21: | 559 | case -21: |
565 | case 0: | 560 | case 0: |
566 | addCustomDir(); | 561 | addCustomDir(); |
567 | break; | 562 | break; |
568 | case -22: | 563 | case -22: |
569 | case 1: | 564 | case 1: |
570 | removeCustomDir(); | 565 | removeCustomDir(); |
571 | break; | 566 | break; |
572 | default: | 567 | default: |
573 | { | 568 | { |
574 | // gotoCustomDir( menuButton->text(item)); | 569 | // gotoCustomDir( menuButton->text(item)); |
575 | // gotoCustomDir( customDirMenu->text(item)); | 570 | // gotoCustomDir( customDirMenu->text(item)); |
576 | } | 571 | } |
577 | break; | 572 | break; |
578 | 573 | ||
579 | }; | 574 | }; |
580 | } | 575 | } |
581 | 576 | ||
582 | void AdvancedFm::addCustomDir() { | 577 | void AdvancedFm::addCustomDir() { |
583 | Config cfg("AdvancedFm"); | 578 | Config cfg("AdvancedFm"); |
584 | cfg.setGroup("Menu"); | 579 | cfg.setGroup("Menu"); |
585 | QString dir; | 580 | QString dir; |
586 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); | 581 | QStringList list = cfg.readListEntry( (const QString &)"CustomDir", (const QChar)','); |
587 | 582 | ||
588 | dir = CurrentDir()->canonicalPath(); | 583 | dir = CurrentDir()->canonicalPath(); |
589 | 584 | ||
590 | bool addIt=true; | 585 | bool addIt=true; |
591 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 586 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp index b43d2ba..aa9db52 100644 --- a/noncore/apps/advancedfm/advancedfmData.cpp +++ b/noncore/apps/advancedfm/advancedfmData.cpp | |||
@@ -1,216 +1,217 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | advancedfmData.cpp | 2 | advancedfmData.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Mon 09-23-2002 13:24:11 | 4 | ** Created: Mon 09-23-2002 13:24:11 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | 13 | ||
14 | /* OPIE */ | 14 | /* OPIE */ |
15 | #include <opie2/odebug.h> | 15 | #include <opie2/odebug.h> |
16 | #include <opie2/oresource.h> | ||
16 | #include <qpe/applnk.h> | 17 | #include <qpe/applnk.h> |
17 | #include <qpe/storage.h> | 18 | #include <qpe/storage.h> |
18 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
19 | #include <qpe/resource.h> | ||
20 | #include <qpe/menubutton.h> | 20 | #include <qpe/menubutton.h> |
21 | using namespace Opie::Core; | 21 | using namespace Opie::Core; |
22 | using namespace Opie::Ui; | 22 | using namespace Opie::Ui; |
23 | 23 | ||
24 | /* QT */ | 24 | /* QT */ |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qhbox.h> | 26 | #include <qhbox.h> |
27 | #include <qmenubar.h> | 27 | #include <qmenubar.h> |
28 | #include <qcombobox.h> | 28 | #include <qcombobox.h> |
29 | #include <qtoolbutton.h> | 29 | #include <qtoolbutton.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qlistview.h> | 31 | #include <qlistview.h> |
32 | 32 | ||
33 | /* STD */ | 33 | /* STD */ |
34 | #include <sys/utsname.h> | 34 | #include <sys/utsname.h> |
35 | 35 | ||
36 | void AdvancedFm::init() { | 36 | void AdvancedFm::init() { |
37 | b = false; | 37 | b = false; |
38 | setCaption( tr( "AdvancedFm" ) ); | 38 | setCaption( tr( "AdvancedFm" ) ); |
39 | 39 | ||
40 | QVBoxLayout *layout = new QVBoxLayout( this ); | 40 | QVBoxLayout *layout = new QVBoxLayout( this ); |
41 | layout->setSpacing( 2); | 41 | layout->setSpacing( 2); |
42 | layout->setMargin( 0); // squeeze | 42 | layout->setMargin( 0); // squeeze |
43 | 43 | ||
44 | QMenuBar *menuBar = new QMenuBar(this); | 44 | QMenuBar *menuBar = new QMenuBar(this); |
45 | menuBar->setMargin( 0 ); // squeeze | 45 | menuBar->setMargin( 0 ); // squeeze |
46 | fileMenu = new QPopupMenu( this ); | 46 | fileMenu = new QPopupMenu( this ); |
47 | viewMenu = new QPopupMenu( this ); | 47 | viewMenu = new QPopupMenu( this ); |
48 | // customDirMenu = new QPopupMenu( this ); | 48 | // customDirMenu = new QPopupMenu( this ); |
49 | 49 | ||
50 | layout->addWidget( menuBar ); | 50 | layout->addWidget( menuBar ); |
51 | 51 | ||
52 | menuBar->insertItem( tr( "File" ), fileMenu); | 52 | menuBar->insertItem( tr( "File" ), fileMenu); |
53 | menuBar->insertItem( tr( "View" ), viewMenu); | 53 | menuBar->insertItem( tr( "View" ), viewMenu); |
54 | 54 | ||
55 | QPixmap pm; | 55 | bool useBigIcon = qApp->desktop()->size().width() > 330; |
56 | |||
56 | cdUpButton = new QToolButton( 0,"cdUpButton"); | 57 | cdUpButton = new QToolButton( 0,"cdUpButton"); |
57 | pm.convertFromImage( Resource::loadImage( "up" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 58 | cdUpButton->setUsesBigPixmap( useBigIcon ); |
58 | cdUpButton->setPixmap( pm ); | 59 | cdUpButton->setPixmap( Opie::Core::OResource::loadPixmap( "up", Opie::Core::OResource::SmallIcon ) ); |
59 | cdUpButton->setAutoRaise( true ); | 60 | cdUpButton->setAutoRaise( true ); |
60 | menuBar->insertItem( cdUpButton ); | 61 | menuBar->insertItem( cdUpButton ); |
61 | 62 | ||
62 | qpeDirButton= new QToolButton( 0,"QPEButton"); | 63 | qpeDirButton= new QToolButton( 0,"QPEButton"); |
63 | pm.convertFromImage( Resource::loadImage( "logo/opielogo" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 64 | qpeDirButton->setUsesBigPixmap( useBigIcon ); |
64 | qpeDirButton->setPixmap( pm );//,"",this,"QPEButton"); | 65 | qpeDirButton->setPixmap( Opie::Core::OResource::loadPixmap( "logo/opielogo", Opie::Core::OResource::SmallIcon ) ); |
65 | qpeDirButton->setAutoRaise( true ); | 66 | qpeDirButton->setAutoRaise( true ); |
66 | menuBar->insertItem( qpeDirButton ); | 67 | menuBar->insertItem( qpeDirButton ); |
67 | 68 | ||
68 | cfButton = new QToolButton( 0, "CFButton"); | 69 | cfButton = new QToolButton( 0, "CFButton"); |
69 | pm.convertFromImage( Resource::loadImage( "cardmon/pcmcia" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 70 | cfButton->setUsesBigPixmap( useBigIcon ); |
70 | cfButton->setPixmap( pm ); | 71 | cfButton->setPixmap( Opie::Core::OResource::loadPixmap( "cardmon/pcmcia", Opie::Core::OResource::SmallIcon ) ); |
71 | cfButton->setAutoRaise( true ); | 72 | cfButton->setAutoRaise( true ); |
72 | menuBar->insertItem( cfButton ); | 73 | menuBar->insertItem( cfButton ); |
73 | 74 | ||
74 | sdButton = new QToolButton( 0, "SDButton"); | 75 | sdButton = new QToolButton( 0, "SDButton"); |
75 | pm.convertFromImage( Resource::loadImage( "advancedfm/sdcard" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 76 | sdButton->setUsesBigPixmap( useBigIcon ); |
76 | sdButton->setPixmap( pm ); | 77 | sdButton->setPixmap( Opie::Core::OResource::loadPixmap( "advancedfm/sdcard", Opie::Core::OResource::SmallIcon ) ); |
77 | sdButton->setAutoRaise( true ); | 78 | sdButton->setAutoRaise( true ); |
78 | menuBar->insertItem( sdButton ); | 79 | menuBar->insertItem( sdButton ); |
79 | 80 | ||
80 | docButton = new QToolButton( 0,"docsButton"); | 81 | docButton = new QToolButton( 0,"docsButton"); |
81 | pm.convertFromImage( Resource::loadImage( "DocsIcon" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 82 | docButton->setUsesBigPixmap( useBigIcon ); |
82 | docButton->setPixmap( pm ); | 83 | docButton->setPixmap( Opie::Core::OResource::loadPixmap( "DocsIcon", Opie::Core::OResource::SmallIcon ) ); |
83 | docButton->setAutoRaise( true ); | 84 | docButton->setAutoRaise( true ); |
84 | menuBar->insertItem( docButton ); | 85 | menuBar->insertItem( docButton ); |
85 | 86 | ||
86 | homeButton = new QToolButton( 0, "homeButton"); | 87 | homeButton = new QToolButton( 0, "homeButton"); |
87 | pm.convertFromImage( Resource::loadImage( "home" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); | 88 | homeButton->setUsesBigPixmap( useBigIcon ); |
88 | homeButton->setPixmap( pm ); | 89 | homeButton->setPixmap( Opie::Core::OResource::loadPixmap( "home", Opie::Core::OResource::SmallIcon ) ); |
89 | homeButton->setAutoRaise( true ); | 90 | homeButton->setAutoRaise( true ); |
90 | menuBar->insertItem( homeButton ); | 91 | menuBar->insertItem( homeButton ); |
91 | 92 | ||
92 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); | 93 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); |
93 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 94 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
94 | fileMenu->insertSeparator(); | 95 | fileMenu->insertSeparator(); |
95 | fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() )); | 96 | fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() )); |
96 | fileMenu->insertSeparator(); | 97 | fileMenu->insertSeparator(); |
97 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); | 98 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); |
98 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); | 99 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); |
99 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); | 100 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); |
100 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); | 101 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); |
101 | fileMenu->insertSeparator(); | 102 | fileMenu->insertSeparator(); |
102 | fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 103 | fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
103 | fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() )); | 104 | fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() )); |
104 | fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 105 | fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
105 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); | 106 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); |
106 | fileMenu->setCheckable(TRUE); | 107 | fileMenu->setCheckable(TRUE); |
107 | 108 | ||
108 | viewMenu->insertItem( tr( "Switch to View 1" ), this, SLOT( switchToLocalTab())); | 109 | viewMenu->insertItem( tr( "Switch to View 1" ), this, SLOT( switchToLocalTab())); |
109 | viewMenu->insertItem( tr( "Switch to View 2" ), this, SLOT( switchToRemoteTab())); | 110 | viewMenu->insertItem( tr( "Switch to View 2" ), this, SLOT( switchToRemoteTab())); |
110 | viewMenu->insertItem( tr( "Refresh" ), this, SLOT( refreshCurrentTab())); | 111 | viewMenu->insertItem( tr( "Refresh" ), this, SLOT( refreshCurrentTab())); |
111 | // viewMenu->insertSeparator(); | 112 | // viewMenu->insertSeparator(); |
112 | // viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); | 113 | // viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); |
113 | viewMenu->setCheckable(true); | 114 | viewMenu->setCheckable(true); |
114 | viewMenu->setItemChecked( viewMenu->idAt(0), true); | 115 | viewMenu->setItemChecked( viewMenu->idAt(0), true); |
115 | viewMenu->setItemChecked( viewMenu->idAt(1), false); | 116 | viewMenu->setItemChecked( viewMenu->idAt(1), false); |
116 | 117 | ||
117 | s_addBookmark = tr("Bookmark Directory"); | 118 | s_addBookmark = tr("Bookmark Directory"); |
118 | s_removeBookmark = tr("Remove Current Directory from Bookmarks"); | 119 | s_removeBookmark = tr("Remove Current Directory from Bookmarks"); |
119 | 120 | ||
120 | // menuButton->insertItem(""); | 121 | // menuButton->insertItem(""); |
121 | 122 | ||
122 | // customDirMenu->insertItem(tr("Add This Directory")); | 123 | // customDirMenu->insertItem(tr("Add This Directory")); |
123 | // customDirMenu->insertItem(tr("Remove This Directory")); | 124 | // customDirMenu->insertItem(tr("Remove This Directory")); |
124 | // customDirMenu->insertSeparator(); | 125 | // customDirMenu->insertSeparator(); |
125 | 126 | ||
126 | QHBoxLayout *CBHB = new QHBoxLayout(); // parent layout will be set later | 127 | QHBoxLayout *CBHB = new QHBoxLayout(); // parent layout will be set later |
127 | CBHB->setMargin( 0 ); | 128 | CBHB->setMargin( 0 ); |
128 | CBHB->setSpacing( 1 ); | 129 | CBHB->setSpacing( 1 ); |
129 | 130 | ||
130 | menuButton = new MenuButton( this ); | 131 | menuButton = new MenuButton( this ); |
131 | 132 | ||
132 | menuButton->setUseLabel(false); | 133 | menuButton->setUseLabel(false); |
133 | menuButton->setMaximumWidth( 20 ); | 134 | menuButton->setMaximumWidth( 20 ); |
134 | menuButton->insertItem( s_addBookmark); | 135 | menuButton->insertItem( s_addBookmark); |
135 | menuButton->insertItem( s_removeBookmark); | 136 | menuButton->insertItem( s_removeBookmark); |
136 | menuButton->insertSeparator(); | 137 | menuButton->insertSeparator(); |
137 | // menuButton->setFocusPolicy(NoFocus); | 138 | // menuButton->setFocusPolicy(NoFocus); |
138 | CBHB->addWidget( menuButton ); | 139 | CBHB->addWidget( menuButton ); |
139 | 140 | ||
140 | customDirsToMenu(); | 141 | customDirsToMenu(); |
141 | 142 | ||
142 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); | 143 | currentPathCombo = new QComboBox( FALSE, this, "currentPathCombo" ); |
143 | currentPathCombo->setEditable(TRUE); | 144 | currentPathCombo->setEditable(TRUE); |
144 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 145 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
145 | // currentPathCombo->setFocusPolicy(NoFocus); | 146 | // currentPathCombo->setFocusPolicy(NoFocus); |
146 | CBHB->addWidget( currentPathCombo ); | 147 | CBHB->addWidget( currentPathCombo ); |
147 | 148 | ||
148 | layout->addLayout( CBHB ); | 149 | layout->addLayout( CBHB ); |
149 | 150 | ||
150 | TabWidget = new OSplitter( Horizontal, this, "TabWidget" ); | 151 | TabWidget = new OSplitter( Horizontal, this, "TabWidget" ); |
151 | // TabWidget = new QTabWidget( this, "TabWidget" ); | 152 | // TabWidget = new QTabWidget( this, "TabWidget" ); |
152 | layout->addWidget( TabWidget, 4 ); | 153 | layout->addWidget( TabWidget, 4 ); |
153 | 154 | ||
154 | tab = new QWidget( TabWidget, "tab" ); | 155 | tab = new QWidget( TabWidget, "tab" ); |
155 | tabLayout = new QGridLayout( tab ); | 156 | tabLayout = new QGridLayout( tab ); |
156 | tabLayout->setSpacing( 2); | 157 | tabLayout->setSpacing( 2); |
157 | tabLayout->setMargin( 2); | 158 | tabLayout->setMargin( 2); |
158 | 159 | ||
159 | Local_View = new QListView( tab, "Local_View" ); | 160 | Local_View = new QListView( tab, "Local_View" ); |
160 | Local_View->addColumn( tr("File"),130); | 161 | Local_View->addColumn( tr("File"),130); |
161 | Local_View->addColumn( tr("Size"),-1); | 162 | Local_View->addColumn( tr("Size"),-1); |
162 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 163 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
163 | Local_View->addColumn( tr("Date"),-1); | 164 | Local_View->addColumn( tr("Date"),-1); |
164 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 165 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
165 | Local_View->setAllColumnsShowFocus(TRUE); | 166 | Local_View->setAllColumnsShowFocus(TRUE); |
166 | Local_View->setMultiSelection( TRUE ); | 167 | Local_View->setMultiSelection( TRUE ); |
167 | Local_View->setSelectionMode(QListView::Extended); | 168 | Local_View->setSelectionMode(QListView::Extended); |
168 | Local_View->setFocusPolicy(StrongFocus); | 169 | Local_View->setFocusPolicy(StrongFocus); |
169 | Local_View->installEventFilter( this ); | 170 | Local_View->installEventFilter( this ); |
170 | 171 | ||
171 | QPEApplication::setStylusOperation( Local_View->viewport() , QPEApplication::RightOnHold); | 172 | QPEApplication::setStylusOperation( Local_View->viewport() , QPEApplication::RightOnHold); |
172 | 173 | ||
173 | tabLayout->addWidget( Local_View, 0, 0 ); | 174 | tabLayout->addWidget( Local_View, 0, 0 ); |
174 | 175 | ||
175 | TabWidget->addWidget( tab,"advancedfm/smFileBrowser.png", tr("1")); | 176 | TabWidget->addWidget( tab,"advancedfm/smFileBrowser.png", tr("1")); |
176 | // TabWidget->insertTab( tab, tr("1")); | 177 | // TabWidget->insertTab( tab, tr("1")); |
177 | 178 | ||
178 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 179 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
179 | tabLayout_2 = new QGridLayout( tab_2 ); | 180 | tabLayout_2 = new QGridLayout( tab_2 ); |
180 | tabLayout_2->setSpacing( 2); | 181 | tabLayout_2->setSpacing( 2); |
181 | tabLayout_2->setMargin( 2); | 182 | tabLayout_2->setMargin( 2); |
182 | 183 | ||
183 | Remote_View = new QListView( tab_2, "Remote_View" ); | 184 | Remote_View = new QListView( tab_2, "Remote_View" ); |
184 | Remote_View->addColumn( tr("File"),130); | 185 | Remote_View->addColumn( tr("File"),130); |
185 | Remote_View->addColumn( tr("Size"),-1); | 186 | Remote_View->addColumn( tr("Size"),-1); |
186 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 187 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
187 | Remote_View->addColumn( tr("Date"),-1); | 188 | Remote_View->addColumn( tr("Date"),-1); |
188 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 189 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
189 | Remote_View->setAllColumnsShowFocus(TRUE); | 190 | Remote_View->setAllColumnsShowFocus(TRUE); |
190 | Remote_View->setMultiSelection( TRUE ); | 191 | Remote_View->setMultiSelection( TRUE ); |
191 | Remote_View->setSelectionMode(QListView::Extended); | 192 | Remote_View->setSelectionMode(QListView::Extended); |
192 | Remote_View->setFocusPolicy(StrongFocus); | 193 | Remote_View->setFocusPolicy(StrongFocus); |
193 | Remote_View->installEventFilter( this ); | 194 | Remote_View->installEventFilter( this ); |
194 | 195 | ||
195 | QPEApplication::setStylusOperation( Remote_View->viewport(), QPEApplication::RightOnHold); | 196 | QPEApplication::setStylusOperation( Remote_View->viewport(), QPEApplication::RightOnHold); |
196 | 197 | ||
197 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 198 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
198 | 199 | ||
199 | TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); | 200 | TabWidget->addWidget( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); |
200 | TabWidget->setSizeChange( 370 ); | 201 | TabWidget->setSizeChange( 370 ); |
201 | // TabWidget->insertTab( tab_2, tr( "2")); | 202 | // TabWidget->insertTab( tab_2, tr( "2")); |
202 | 203 | ||
203 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); | 204 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); |
204 | tabLayout_3 = new QGridLayout( tab_3 ); | 205 | tabLayout_3 = new QGridLayout( tab_3 ); |
205 | tabLayout_3->setSpacing( 2); | 206 | tabLayout_3->setSpacing( 2); |
206 | tabLayout_3->setMargin( 2); | 207 | tabLayout_3->setMargin( 2); |
207 | 208 | ||
208 | 209 | ||
209 | // OFileDialog fileDialog; | 210 | // OFileDialog fileDialog; |
210 | // fileDialog; | 211 | // fileDialog; |
211 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy | 212 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy |
212 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); | 213 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); |
213 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); | 214 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); |
214 | 215 | ||
215 | QListView *fileTree; | 216 | QListView *fileTree; |
216 | fileTree = new QListView( tab_3, "tree" ); | 217 | fileTree = new QListView( tab_3, "tree" ); |