Diffstat (limited to 'noncore/apps/advancedfm/advancedfm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 206 |
1 files changed, 100 insertions, 106 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 9c13e53..5148172 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1,265 +1,259 @@ | |||
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 | |||
16 | // #include <opie/ofileselector.h> | ||
17 | // #include <opie/ofiledialog.h> | ||
18 | |||
19 | #include <opie/osplitter.h> | ||
20 | |||
21 | #include <qpe/filemanager.h> | 15 | #include <qpe/filemanager.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 16 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/qpeapplication.h> | 17 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
25 | #include <qpe/mimetype.h> | 19 | #include <qpe/mimetype.h> |
26 | #include <qpe/applnk.h> | 20 | #include <qpe/applnk.h> |
27 | #include <qpe/ir.h> | 21 | #include <qpe/ir.h> |
28 | #include <qpe/resource.h> | 22 | #include <qpe/resource.h> |
29 | #include <qpe/menubutton.h> | 23 | #include <qpe/menubutton.h> |
30 | 24 | ||
31 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
32 | #include <qfile.h> | 26 | #include <qfile.h> |
33 | #include <qcombobox.h> | 27 | #include <qcombobox.h> |
34 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
35 | #include <qlistview.h> | 29 | #include <qlistview.h> |
36 | #include <qlabel.h> | 30 | #include <qlabel.h> |
37 | #include <qwidget.h> | 31 | #include <qwidget.h> |
38 | #include <qlayout.h> | 32 | #include <qlayout.h> |
39 | #include <qimage.h> | 33 | #include <qimage.h> |
40 | #include <qmessagebox.h> | 34 | #include <qmessagebox.h> |
41 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
42 | 36 | ||
43 | #include <qpe/qpemessagebox.h> | 37 | #include <qpe/qpemessagebox.h> |
44 | 38 | ||
45 | #include <sys/stat.h> | 39 | #include <sys/stat.h> |
46 | #include <time.h> | 40 | #include <time.h> |
47 | #include <dirent.h> | 41 | #include <dirent.h> |
48 | #include <fcntl.h> | 42 | #include <fcntl.h> |
49 | #include <sys/vfs.h> | 43 | #include <sys/vfs.h> |
50 | #include <mntent.h> | 44 | #include <mntent.h> |
51 | 45 | ||
52 | #ifdef NOQUICKLAUNCH | 46 | #ifdef NOQUICKLAUNCH |
53 | AdvancedFm::AdvancedFm( ) | 47 | AdvancedFm::AdvancedFm( ) |
54 | #else | 48 | #else |
55 | AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) | 49 | AdvancedFm::AdvancedFm(QWidget *,const char*, WFlags ) |
56 | #endif | 50 | #endif |
57 | : QMainWindow( ) { | 51 | : QMainWindow( ) { |
58 | init(); | 52 | init(); |
59 | renameBox = 0; | 53 | renameBox = 0; |
60 | 54 | ||
61 | unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); | 55 | unknownXpm = Resource::loadImage( "UnknownDocument" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); |
62 | 56 | ||
63 | initConnections(); | 57 | initConnections(); |
64 | whichTab=1; | 58 | whichTab=1; |
65 | rePopulate(); | 59 | rePopulate(); |
66 | currentPathCombo->setFocus(); | 60 | currentPathCombo->setFocus(); |
67 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); | 61 | channel = new QCopChannel( "QPE/Application/advancedfm", this ); |
68 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 62 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
69 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); | 63 | this, SLOT( qcopReceive(const QCString&, const QByteArray&)) ); |
70 | } | 64 | } |
71 | 65 | ||
72 | AdvancedFm::~AdvancedFm() { | 66 | AdvancedFm::~AdvancedFm() { |
73 | } | 67 | } |
74 | 68 | ||
75 | 69 | ||
76 | void AdvancedFm::cleanUp() { | 70 | void AdvancedFm::cleanUp() { |
77 | QString sfile=QDir::homeDirPath(); | 71 | QString sfile=QDir::homeDirPath(); |
78 | if(sfile.right(1) != "/") | 72 | if(sfile.right(1) != "/") |
79 | sfile+="/._temp"; | 73 | sfile+="/._temp"; |
80 | else | 74 | else |
81 | sfile+="._temp"; | 75 | sfile+="._temp"; |
82 | QFile file( sfile); | 76 | QFile file( sfile); |
83 | if(file.exists()) | 77 | if(file.exists()) |
84 | file.remove(); | 78 | file.remove(); |
85 | } | 79 | } |
86 | 80 | ||
87 | void AdvancedFm::tabChanged(QWidget *) { | 81 | void AdvancedFm::tabChanged(QWidget *) { |
88 | // qWarning("tab changed"); | 82 | // qWarning("tab changed"); |
89 | QString path = CurrentDir()->canonicalPath(); | 83 | QString path = CurrentDir()->canonicalPath(); |
90 | currentPathCombo->lineEdit()->setText( path ); | 84 | currentPathCombo->lineEdit()->setText( path ); |
91 | 85 | ||
92 | if(whichTab == 1) { | 86 | if(whichTab == 1) { |
93 | viewMenu->setItemChecked(viewMenu->idAt(0), true); | 87 | viewMenu->setItemChecked(viewMenu->idAt(0), true); |
94 | viewMenu->setItemChecked(viewMenu->idAt(1), false); | 88 | viewMenu->setItemChecked(viewMenu->idAt(1), false); |
95 | } else { | 89 | } else { |
96 | viewMenu->setItemChecked(viewMenu->idAt(0), false); | 90 | viewMenu->setItemChecked(viewMenu->idAt(0), false); |
97 | viewMenu->setItemChecked(viewMenu->idAt(1), true); | 91 | viewMenu->setItemChecked(viewMenu->idAt(1), true); |
98 | } | 92 | } |
99 | 93 | ||
100 | QString fs= getFileSystemType( (const QString &) path); | 94 | QString fs= getFileSystemType( (const QString &) path); |
101 | 95 | ||
102 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | 96 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
103 | +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); | 97 | +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); |
104 | chdir( path.latin1()); | 98 | chdir( path.latin1()); |
105 | } | 99 | } |
106 | 100 | ||
107 | 101 | ||
108 | void AdvancedFm::populateView() { | 102 | void AdvancedFm::populateView() { |
109 | 103 | ||
110 | // qWarning("PopulateView"); | 104 | // qWarning("PopulateView"); |
111 | QPixmap pm; | 105 | QPixmap pm; |
112 | QListView *thisView = CurrentView(); | 106 | QListView *thisView = CurrentView(); |
113 | QDir *thisDir = CurrentDir(); | 107 | QDir *thisDir = CurrentDir(); |
114 | QString path = thisDir->canonicalPath(); | 108 | QString path = thisDir->canonicalPath(); |
115 | 109 | ||
116 | //qWarning("path is "+path); | 110 | //qWarning("path is "+path); |
117 | thisView->clear(); | 111 | thisView->clear(); |
118 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 112 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
119 | thisDir->setMatchAllDirs(TRUE); | 113 | thisDir->setMatchAllDirs(TRUE); |
120 | thisDir->setNameFilter(filterStr); | 114 | thisDir->setNameFilter(filterStr); |
121 | QString fileL, fileS, fileDate; | 115 | QString fileL, fileS, fileDate; |
122 | QString fs= getFileSystemType((const QString &) path); | 116 | QString fs= getFileSystemType((const QString &) path); |
123 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | 117 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
124 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); | 118 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); |
125 | bool isDir=FALSE; | 119 | bool isDir=FALSE; |
126 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 120 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
127 | QFileInfoListIterator it(*list); | 121 | QFileInfoListIterator it(*list); |
128 | QFileInfo *fi; | 122 | QFileInfo *fi; |
129 | while ( (fi=it.current()) ) { | 123 | while ( (fi=it.current()) ) { |
130 | if (fi->isSymLink() ) { | 124 | if (fi->isSymLink() ) { |
131 | QString symLink=fi->readLink(); | 125 | QString symLink=fi->readLink(); |
132 | QFileInfo sym( symLink); | 126 | QFileInfo sym( symLink); |
133 | fileS.sprintf( "%10i", sym.size() ); | 127 | fileS.sprintf( "%10i", sym.size() ); |
134 | fileL = fi->fileName() +" -> " + sym.filePath().data(); | 128 | fileL = fi->fileName() +" -> " + sym.filePath().data(); |
135 | fileDate = sym.lastModified().toString(); | 129 | fileDate = sym.lastModified().toString(); |
136 | } else { | 130 | } else { |
137 | fileS.sprintf( "%10i", fi->size() ); | 131 | fileS.sprintf( "%10i", fi->size() ); |
138 | fileL = fi->fileName(); | 132 | fileL = fi->fileName(); |
139 | fileDate= fi->lastModified().toString(); | 133 | fileDate= fi->lastModified().toString(); |
140 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { | 134 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { |
141 | // if(fileL == "..") | 135 | // if(fileL == "..") |
142 | fileL += "/"; | 136 | fileL += "/"; |
143 | isDir=TRUE; | 137 | isDir=TRUE; |
144 | } | 138 | } |
145 | } | 139 | } |
146 | QFileInfo fileInfo( path + "/" + fileL); | 140 | QFileInfo fileInfo( path + "/" + fileL); |
147 | 141 | ||
148 | if(fileL !="./" && fi->exists()) { | 142 | if(fileL !="./" && fi->exists()) { |
149 | item = new QListViewItem( thisView, fileL, fileS , fileDate); | 143 | item = new QListViewItem( thisView, fileL, fileS , fileDate); |
150 | 144 | ||
151 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 145 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
152 | 146 | ||
153 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 147 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
154 | pm = Resource::loadPixmap( "lockedfolder" ); | 148 | pm = Resource::loadPixmap( "lockedfolder" ); |
155 | else | 149 | else |
156 | pm= Resource::loadPixmap( "folder" ); | 150 | pm= Resource::loadPixmap( "folder" ); |
157 | } | 151 | } |
158 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 152 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
159 | pm = Resource::loadPixmap( "exec"); | 153 | pm = Resource::loadPixmap( "exec"); |
160 | } | 154 | } |
161 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 155 | else if( (fileInfo.permission( QFileInfo::ExeUser) |
162 | | fileInfo.permission( QFileInfo::ExeGroup) | 156 | | fileInfo.permission( QFileInfo::ExeGroup) |
163 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 157 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
164 | pm = Resource::loadPixmap( "exec"); | 158 | pm = Resource::loadPixmap( "exec"); |
165 | } | 159 | } |
166 | else if( !fi->isReadable() ) { | 160 | else if( !fi->isReadable() ) { |
167 | pm = Resource::loadPixmap( "locked" ); | 161 | pm = Resource::loadPixmap( "locked" ); |
168 | } | 162 | } |
169 | else { //everything else goes by mimetype | 163 | else { //everything else goes by mimetype |
170 | MimeType mt(fi->filePath()); | 164 | MimeType mt(fi->filePath()); |
171 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 165 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
172 | if(pm.isNull()) { | 166 | if(pm.isNull()) { |
173 | pm = unknownXpm; | 167 | pm = unknownXpm; |
174 | } | 168 | } |
175 | } | 169 | } |
176 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { | 170 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { |
177 | // qDebug(" overlay link image"); | 171 | // qDebug(" overlay link image"); |
178 | pm= Resource::loadPixmap( "advancedfm/symlink" ); | 172 | pm= Resource::loadPixmap( "advancedfm/symlink" ); |
179 | // pm= Resource::loadPixmap( "folder" ); | 173 | // pm= Resource::loadPixmap( "folder" ); |
180 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 174 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
181 | // QPainter painter( &pm ); | 175 | // QPainter painter( &pm ); |
182 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 176 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
183 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); | 177 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); |
184 | } | 178 | } |
185 | item->setPixmap( 0,pm); | 179 | item->setPixmap( 0,pm); |
186 | 180 | ||
187 | } | 181 | } |
188 | isDir=FALSE; | 182 | isDir=FALSE; |
189 | ++it; | 183 | ++it; |
190 | } | 184 | } |
191 | 185 | ||
192 | if( path.find("dev",0,TRUE) != -1) { | 186 | if( path.find("dev",0,TRUE) != -1) { |
193 | struct stat buf; | 187 | struct stat buf; |
194 | dev_t devT; | 188 | dev_t devT; |
195 | DIR *dir; | 189 | DIR *dir; |
196 | struct dirent *mydirent; | 190 | struct dirent *mydirent; |
197 | 191 | ||
198 | if((dir = opendir( path.latin1())) != NULL) | 192 | if((dir = opendir( path.latin1())) != NULL) |
199 | while ((mydirent = readdir(dir)) != NULL) { | 193 | while ((mydirent = readdir(dir)) != NULL) { |
200 | lstat( mydirent->d_name, &buf); | 194 | lstat( mydirent->d_name, &buf); |
201 | // qDebug(mydirent->d_name); | 195 | // qDebug(mydirent->d_name); |
202 | fileL.sprintf("%s", mydirent->d_name); | 196 | fileL.sprintf("%s", mydirent->d_name); |
203 | devT = buf.st_dev; | 197 | devT = buf.st_dev; |
204 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 198 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
205 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 199 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
206 | if( fileL.find(".") == -1 ) { | 200 | if( fileL.find(".") == -1 ) { |
207 | item= new QListViewItem( thisView, fileL, fileS, fileDate); | 201 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
208 | pm = unknownXpm; | 202 | pm = unknownXpm; |
209 | item->setPixmap( 0,pm); | 203 | item->setPixmap( 0,pm); |
210 | } | 204 | } |
211 | } | 205 | } |
212 | 206 | ||
213 | closedir(dir); | 207 | closedir(dir); |
214 | } | 208 | } |
215 | 209 | ||
216 | thisView->setSorting( 3,FALSE); | 210 | thisView->setSorting( 3,FALSE); |
217 | fillCombo( (const QString &) path ); | 211 | fillCombo( (const QString &) path ); |
218 | } | 212 | } |
219 | 213 | ||
220 | void AdvancedFm::rePopulate() { | 214 | void AdvancedFm::rePopulate() { |
221 | populateView(); | 215 | populateView(); |
222 | setOtherTabCurrent(); | 216 | setOtherTabCurrent(); |
223 | populateView(); | 217 | populateView(); |
224 | 218 | ||
225 | // int tmpTab = whichTab; | 219 | // int tmpTab = whichTab; |
226 | // // qDebug("%d", tmpTab); | 220 | // // qDebug("%d", tmpTab); |
227 | 221 | ||
228 | // for(int i =1; i < 3; i++) { | 222 | // for(int i =1; i < 3; i++) { |
229 | // TabWidget->setCurrentWidget(i - 1); | 223 | // TabWidget->setCurrentWidget(i - 1); |
230 | // populateView(); | 224 | // populateView(); |
231 | // } | 225 | // } |
232 | // TabWidget->setCurrentWidget( tmpTab - 1); | 226 | // TabWidget->setCurrentWidget( tmpTab - 1); |
233 | } | 227 | } |
234 | 228 | ||
235 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { | 229 | void AdvancedFm::ListClicked(QListViewItem *selectedItem) { |
236 | //qWarning("listclicked"); | 230 | //qWarning("listclicked"); |
237 | if(selectedItem) { | 231 | if(selectedItem) { |
238 | QString strItem=selectedItem->text(0); | 232 | QString strItem=selectedItem->text(0); |
239 | // qWarning(strItem); | 233 | // qWarning(strItem); |
240 | QString strSize=selectedItem->text(1); | 234 | QString strSize=selectedItem->text(1); |
241 | strSize=strSize.stripWhiteSpace(); | 235 | strSize=strSize.stripWhiteSpace(); |
242 | bool isDirectory = false; | 236 | bool isDirectory = false; |
243 | QString strItem2; | 237 | QString strItem2; |
244 | 238 | ||
245 | 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 |
246 | strItem2 = dealWithSymName((const QString&)strItem); | 240 | strItem2 = dealWithSymName((const QString&)strItem); |
247 | if(QDir(strItem2).exists() ) | 241 | if(QDir(strItem2).exists() ) |
248 | strItem = strItem2; | 242 | strItem = strItem2; |
249 | } | 243 | } |
250 | 244 | ||
251 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 245 | if( strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
252 | 246 | ||
253 | if(QDir(strItem).exists()) | 247 | if(QDir(strItem).exists()) |
254 | isDirectory = true; | 248 | isDirectory = true; |
255 | } | 249 | } |
256 | 250 | ||
257 | if( isDirectory ) { | 251 | if( isDirectory ) { |
258 | CurrentDir()->cd( strItem, TRUE); | 252 | CurrentDir()->cd( strItem, TRUE); |
259 | populateView(); | 253 | populateView(); |
260 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); | 254 | CurrentView()->ensureItemVisible( CurrentView()->firstChild()); |
261 | } | 255 | } |
262 | chdir( strItem.latin1()); | 256 | chdir( strItem.latin1()); |
263 | } | 257 | } |
264 | } | 258 | } |
265 | 259 | ||
@@ -738,162 +732,162 @@ void AdvancedFm::removeCustomDir() { | |||
738 | if(list.grep(dir,true).isEmpty()) { | 732 | if(list.grep(dir,true).isEmpty()) { |
739 | QMessageBox::message(tr( "AdvancedFm" ), | 733 | QMessageBox::message(tr( "AdvancedFm" ), |
740 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); | 734 | tr("Cannot remove current directory\nfrom bookmarks.\nIt is not bookmarked!")); |
741 | } else { | 735 | } else { |
742 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 736 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
743 | if((*it) != dir) { | 737 | if((*it) != dir) { |
744 | //current item is not our current dir, so add it to temp list | 738 | //current item is not our current dir, so add it to temp list |
745 | list2 <<(*it); | 739 | list2 <<(*it); |
746 | } else { | 740 | } else { |
747 | // customDirMenu->removeItem( ramble); | 741 | // customDirMenu->removeItem( ramble); |
748 | menuButton->remove( ramble); | 742 | menuButton->remove( ramble); |
749 | 743 | ||
750 | } | 744 | } |
751 | ramble++; | 745 | ramble++; |
752 | // ramble--; | 746 | // ramble--; |
753 | } | 747 | } |
754 | 748 | ||
755 | cfg.writeEntry("CustomDir", list2, ','); | 749 | cfg.writeEntry("CustomDir", list2, ','); |
756 | cfg.write(); | 750 | cfg.write(); |
757 | } | 751 | } |
758 | // customDirsToMenu(); | 752 | // customDirsToMenu(); |
759 | 753 | ||
760 | } | 754 | } |
761 | 755 | ||
762 | void AdvancedFm::gotoCustomDir(const QString &dir) { | 756 | void AdvancedFm::gotoCustomDir(const QString &dir) { |
763 | // qDebug("gotoCustomDir(const QString &dir) " +dir ); | 757 | // qDebug("gotoCustomDir(const QString &dir) " +dir ); |
764 | // QString curDir = dir; | 758 | // QString curDir = dir; |
765 | // QDir *thisDir = CurrentDir(); | 759 | // QDir *thisDir = CurrentDir(); |
766 | // if( curDir.isEmpty()) { | 760 | // if( curDir.isEmpty()) { |
767 | // } | 761 | // } |
768 | if( dir == s_addBookmark) { | 762 | if( dir == s_addBookmark) { |
769 | addCustomDir(); | 763 | addCustomDir(); |
770 | } | 764 | } |
771 | if( dir == s_removeBookmark) { | 765 | if( dir == s_removeBookmark) { |
772 | removeCustomDir( ); | 766 | removeCustomDir( ); |
773 | } else { | 767 | } else { |
774 | gotoDirectory( dir); | 768 | gotoDirectory( dir); |
775 | // if(QDir( curDir).exists() ) | 769 | // if(QDir( curDir).exists() ) |
776 | // { | 770 | // { |
777 | // thisDir->setPath( curDir ); | 771 | // thisDir->setPath( curDir ); |
778 | // chdir( curDir.latin1() ); | 772 | // chdir( curDir.latin1() ); |
779 | // thisDir->cd( curDir, TRUE); | 773 | // thisDir->cd( curDir, TRUE); |
780 | // populateView(); | 774 | // populateView(); |
781 | // } | 775 | // } |
782 | } | 776 | } |
783 | } | 777 | } |
784 | 778 | ||
785 | QDir *AdvancedFm::CurrentDir() { | 779 | QDir *AdvancedFm::CurrentDir() { |
786 | 780 | ||
787 | if ( whichTab == 1) { | 781 | if ( whichTab == 1) { |
788 | return ¤tDir; | 782 | return ¤tDir; |
789 | } else { | 783 | } else { |
790 | return ¤tRemoteDir; | 784 | return ¤tRemoteDir; |
791 | } | 785 | } |
792 | } | 786 | } |
793 | 787 | ||
794 | QDir *AdvancedFm::OtherDir() { | 788 | QDir *AdvancedFm::OtherDir() { |
795 | if ( whichTab == 1) { | 789 | if ( whichTab == 1) { |
796 | return ¤tRemoteDir; | 790 | return ¤tRemoteDir; |
797 | } else { | 791 | } else { |
798 | return ¤tDir; | 792 | return ¤tDir; |
799 | } | 793 | } |
800 | } | 794 | } |
801 | 795 | ||
802 | QListView * AdvancedFm::CurrentView() { | 796 | QListView * AdvancedFm::CurrentView() { |
803 | if ( whichTab == 1) { | 797 | if ( whichTab == 1) { |
804 | // qWarning("CurrentView Tab 1"); | 798 | // qWarning("CurrentView Tab 1"); |
805 | return Local_View; | 799 | return Local_View; |
806 | } else { | 800 | } else { |
807 | // qWarning("CurrentView Tab 2"); | 801 | // qWarning("CurrentView Tab 2"); |
808 | return Remote_View; | 802 | return Remote_View; |
809 | } | 803 | } |
810 | } | 804 | } |
811 | 805 | ||
812 | QListView * AdvancedFm::OtherView() { | 806 | QListView * AdvancedFm::OtherView() { |
813 | if ( whichTab == 1) | 807 | if ( whichTab == 1) |
814 | return Remote_View; | 808 | return Remote_View; |
815 | else | 809 | else |
816 | return Local_View; | 810 | return Local_View; |
817 | } | 811 | } |
818 | 812 | ||
819 | void AdvancedFm::setOtherTabCurrent() { | 813 | void AdvancedFm::setOtherTabCurrent() { |
820 | // qWarning("setOtherTabCurrent() %d", whichTab); | 814 | // qWarning("setOtherTabCurrent() %d", whichTab); |
821 | if ( whichTab == 1) { | 815 | if ( whichTab == 1) { |
822 | TabWidget->setCurrentWidget(1); | 816 | TabWidget->setCurrentWidget(1); |
823 | } else { | 817 | } else { |
824 | TabWidget->setCurrentWidget(0); | 818 | TabWidget->setCurrentWidget(0); |
825 | } | 819 | } |
826 | OtherView()->setFocus(); | 820 | OtherView()->setFocus(); |
827 | OtherView()->setSelected( CurrentView()->firstChild(), true); | 821 | OtherView()->setSelected( CurrentView()->firstChild(), true); |
828 | } | 822 | } |
829 | 823 | ||
830 | void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { | 824 | void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { |
831 | // qDebug("qcop message "+msg ); | 825 | // qDebug("qcop message "+msg ); |
832 | QDataStream stream ( data, IO_ReadOnly ); | 826 | QDataStream stream ( data, IO_ReadOnly ); |
833 | if ( msg == "openDirectory(QString)" ) { | 827 | if ( msg == "openDirectory(QString)" ) { |
834 | // qDebug("received"); | 828 | // qDebug("received"); |
835 | QString file; | 829 | QString file; |
836 | stream >> file; | 830 | stream >> file; |
837 | gotoDirectory( (const QString &) file); | 831 | gotoDirectory( (const QString &) file); |
838 | } | 832 | } |
839 | } | 833 | } |
840 | 834 | ||
841 | void AdvancedFm::setDocument(const QString &file) { | 835 | void AdvancedFm::setDocument(const QString &file) { |
842 | gotoDirectory( file); | 836 | gotoDirectory( file); |
843 | 837 | ||
844 | } | 838 | } |
845 | 839 | ||
846 | void AdvancedFm::gotoDirectory(const QString &file) { | 840 | void AdvancedFm::gotoDirectory(const QString &file) { |
847 | // qWarning("goto dir "+file); | 841 | // qWarning("goto dir "+file); |
848 | QString curDir = file; | 842 | QString curDir = file; |
849 | QDir *thisDir = CurrentDir(); | 843 | QDir *thisDir = CurrentDir(); |
850 | if(QDir( curDir).exists() ) { | 844 | if(QDir( curDir).exists() ) { |
851 | thisDir->setPath( curDir ); | 845 | thisDir->setPath( curDir ); |
852 | chdir( curDir.latin1() ); | 846 | chdir( curDir.latin1() ); |
853 | thisDir->cd( curDir, TRUE); | 847 | thisDir->cd( curDir, TRUE); |
854 | populateView(); | 848 | populateView(); |
855 | } | 849 | } |
856 | else if(QFileInfo(curDir).exists()) { | 850 | else if(QFileInfo(curDir).exists()) { |
857 | QFileInfo fileInfo(curDir); | 851 | QFileInfo fileInfo(curDir); |
858 | curDir=fileInfo.dirPath(); | 852 | curDir=fileInfo.dirPath(); |
859 | if(QDir( curDir).exists() ) { | 853 | if(QDir( curDir).exists() ) { |
860 | thisDir->setPath( curDir ); | 854 | thisDir->setPath( curDir ); |
861 | chdir( curDir.latin1() ); | 855 | chdir( curDir.latin1() ); |
862 | thisDir->cd( curDir, TRUE); | 856 | thisDir->cd( curDir, TRUE); |
863 | populateView(); | 857 | populateView(); |
864 | } | 858 | } |
865 | findFile(file); | 859 | findFile(file); |
866 | } | 860 | } |
867 | 861 | ||
868 | } | 862 | } |
869 | 863 | ||
870 | void AdvancedFm::findFile(const QString &fileName) { | 864 | void AdvancedFm::findFile(const QString &fileName) { |
871 | QFileInfo fi(fileName); | 865 | QFileInfo fi(fileName); |
872 | QListView *thisView = CurrentView(); | 866 | QListView *thisView = CurrentView(); |
873 | QListViewItemIterator it( thisView ); | 867 | QListViewItemIterator it( thisView ); |
874 | for ( ; it.current(); ++it ) { | 868 | for ( ; it.current(); ++it ) { |
875 | if(it.current()->text(0) == fi.fileName()) { | 869 | if(it.current()->text(0) == fi.fileName()) { |
876 | it.current()->setSelected(true); | 870 | it.current()->setSelected(true); |
877 | thisView->ensureItemVisible(it.current()); | 871 | thisView->ensureItemVisible(it.current()); |
878 | } | 872 | } |
879 | } | 873 | } |
880 | } | 874 | } |
881 | 875 | ||
882 | void AdvancedFm::slotSwitchMenu(int ) { | 876 | void AdvancedFm::slotSwitchMenu(int ) { |
883 | // qDebug("Switch %d", item); | 877 | // qDebug("Switch %d", item); |
884 | // viewMenu->setItemChecked(item, true); | 878 | // viewMenu->setItemChecked(item, true); |
885 | } | 879 | } |
886 | 880 | ||
887 | void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) { | 881 | void AdvancedFm::dealWithSchmooSchmaa(QWidget *w) { |
888 | tabChanged( w); | 882 | tabChanged( w); |
889 | if( w == Local_View) { | 883 | if( w == Local_View) { |
890 | Remote_View->clearFocus(); | 884 | Remote_View->clearFocus(); |
891 | } else { | 885 | } else { |
892 | Local_View->clearFocus(); | 886 | Local_View->clearFocus(); |
893 | } | 887 | } |
894 | } | 888 | } |
895 | 889 | ||
896 | void AdvancedFm::navigateToSelected() { | 890 | void AdvancedFm::navigateToSelected() { |
897 | if( !CurrentView()->currentItem()) return; | 891 | if( !CurrentView()->currentItem()) return; |
898 | doDirChange(); | 892 | doDirChange(); |
899 | } | 893 | } |