-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 38 | ||||
-rw-r--r-- | noncore/apps/advancedfm/output.cpp | 2 |
2 files changed, 23 insertions, 17 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 23244a2..92804b2 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -1,494 +1,498 @@ | |||
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 <opie/otabwidget.h> | 15 | #include <opie/otabwidget.h> |
16 | // #include <opie/ofileselector.h> | 16 | // #include <opie/ofileselector.h> |
17 | // #include <opie/ofiledialog.h> | 17 | // #include <opie/ofiledialog.h> |
18 | 18 | ||
19 | #include <qpe/filemanager.h> | 19 | #include <qpe/filemanager.h> |
20 | #include <qpe/qcopenvelope_qws.h> | 20 | #include <qpe/qcopenvelope_qws.h> |
21 | #include <qpe/qpemenubar.h> | 21 | #include <qpe/qpemenubar.h> |
22 | #include <qpe/qpetoolbar.h> | 22 | #include <qpe/qpetoolbar.h> |
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <qpe/config.h> | 25 | #include <qpe/config.h> |
26 | #include <qpe/mimetype.h> | 26 | #include <qpe/mimetype.h> |
27 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
28 | #include <qpe/ir.h> | 28 | #include <qpe/ir.h> |
29 | #include <qpe/resource.h> | 29 | #include <qpe/resource.h> |
30 | 30 | ||
31 | #include <qtabwidget.h> | 31 | #include <qtabwidget.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qpushbutton.h> | 33 | #include <qpushbutton.h> |
34 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
35 | #include <qdir.h> | 35 | #include <qdir.h> |
36 | #include <qfile.h> | 36 | #include <qfile.h> |
37 | #include <qstring.h> | 37 | #include <qstring.h> |
38 | #include <qcombobox.h> | 38 | #include <qcombobox.h> |
39 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
40 | #include <qlistview.h> | 40 | #include <qlistview.h> |
41 | #include <qmainwindow.h> | 41 | #include <qmainwindow.h> |
42 | #include <qlabel.h> | 42 | #include <qlabel.h> |
43 | #include <qprogressbar.h> | 43 | #include <qprogressbar.h> |
44 | #include <qspinbox.h> | 44 | #include <qspinbox.h> |
45 | #include <qwidget.h> | 45 | #include <qwidget.h> |
46 | #include <qlayout.h> | 46 | #include <qlayout.h> |
47 | #include <qimage.h> | 47 | #include <qimage.h> |
48 | #include <qpixmap.h> | 48 | #include <qpixmap.h> |
49 | #include <qmessagebox.h> | 49 | #include <qmessagebox.h> |
50 | #include <qlineedit.h> | 50 | #include <qlineedit.h> |
51 | #include <qregexp.h> | 51 | #include <qregexp.h> |
52 | 52 | ||
53 | #include <unistd.h> | 53 | #include <unistd.h> |
54 | #include <stdlib.h> | 54 | #include <stdlib.h> |
55 | #include <sys/stat.h> | 55 | #include <sys/stat.h> |
56 | #include <dirent.h> | 56 | #include <dirent.h> |
57 | #include <stdio.h> | 57 | #include <stdio.h> |
58 | #include <time.h> | 58 | #include <time.h> |
59 | #include <fcntl.h> | 59 | #include <fcntl.h> |
60 | #include <mntent.h> | 60 | #include <mntent.h> |
61 | #include <string.h> | 61 | #include <string.h> |
62 | #include <errno.h> | 62 | #include <errno.h> |
63 | #include <sys/vfs.h> | 63 | #include <sys/vfs.h> |
64 | #include <mntent.h> | 64 | #include <mntent.h> |
65 | #include <sys/utsname.h> | 65 | #include <sys/utsname.h> |
66 | 66 | ||
67 | AdvancedFm::AdvancedFm( ) | 67 | AdvancedFm::AdvancedFm( ) |
68 | : QMainWindow( ) { | 68 | : QMainWindow( ) { |
69 | init(); | 69 | init(); |
70 | initConnections(); | 70 | initConnections(); |
71 | populateLocalView(); | 71 | populateLocalView(); |
72 | populateRemoteView(); | 72 | populateRemoteView(); |
73 | currentPathCombo->setFocus(); | 73 | currentPathCombo->setFocus(); |
74 | } | 74 | } |
75 | 75 | ||
76 | AdvancedFm::~AdvancedFm() { | 76 | AdvancedFm::~AdvancedFm() { |
77 | } | 77 | } |
78 | 78 | ||
79 | void AdvancedFm::cleanUp() { | 79 | void AdvancedFm::cleanUp() { |
80 | QString sfile=QDir::homeDirPath(); | 80 | QString sfile=QDir::homeDirPath(); |
81 | if(sfile.right(1) != "/") | 81 | if(sfile.right(1) != "/") |
82 | sfile+="/._temp"; | 82 | sfile+="/._temp"; |
83 | else | 83 | else |
84 | sfile+="._temp"; | 84 | sfile+="._temp"; |
85 | QFile file( sfile); | 85 | QFile file( sfile); |
86 | if(file.exists()) | 86 | if(file.exists()) |
87 | file.remove(); | 87 | file.remove(); |
88 | } | 88 | } |
89 | 89 | ||
90 | void AdvancedFm::tabChanged(QWidget *) { | 90 | void AdvancedFm::tabChanged(QWidget *w) { |
91 | if (TabWidget->getCurrentTab() == 0) { | 91 | qDebug("tab changed %d",TabWidget->getCurrentTab()); |
92 | |||
93 | if ( w == tab) { | ||
94 | // if (TabWidget->getCurrentTab() == 0) { | ||
92 | // if (TabWidget->currentPageIndex() == 0) { | 95 | // if (TabWidget->currentPageIndex() == 0) { |
93 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 96 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
94 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); | 97 | viewMenu->setItemChecked(viewMenu->idAt(0),TRUE); |
95 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); | 98 | viewMenu->setItemChecked(viewMenu->idAt(1),FALSE); |
96 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 99 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
97 | setCaption("AdvancedFm :: "+fs+" :: " | 100 | setCaption("AdvancedFm :: "+fs+" :: " |
98 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | 101 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); |
99 | 102 | ||
100 | } | 103 | } |
101 | if (TabWidget->getCurrentTab() == 1) { | 104 | if ( w == tab_2) { |
105 | // if (TabWidget->getCurrentTab() == 1) { | ||
102 | 106 | ||
103 | // if (TabWidget->currentPageIndex() == 1) { | 107 | // if (TabWidget->currentPageIndex() == 1) { |
104 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); | 108 | currentPathCombo->lineEdit()->setText( currentRemoteDir.canonicalPath()); |
105 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); | 109 | viewMenu->setItemChecked(viewMenu->idAt(1),TRUE); |
106 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); | 110 | viewMenu->setItemChecked(viewMenu->idAt(0),FALSE); |
107 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 111 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
108 | setCaption("AdvancedFm :: "+fs+" :: " | 112 | setCaption("AdvancedFm :: "+fs+" :: " |
109 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | 113 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); |
110 | } | 114 | } |
111 | } | 115 | } |
112 | 116 | ||
113 | 117 | ||
114 | void AdvancedFm::populateLocalView() { | 118 | void AdvancedFm::populateLocalView() { |
115 | QPixmap pm; | 119 | QPixmap pm; |
116 | Local_View->clear(); | 120 | Local_View->clear(); |
117 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 121 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
118 | currentDir.setMatchAllDirs(TRUE); | 122 | currentDir.setMatchAllDirs(TRUE); |
119 | currentDir.setNameFilter(filterStr); | 123 | currentDir.setNameFilter(filterStr); |
120 | QString fileL, fileS, fileDate; | 124 | QString fileL, fileS, fileDate; |
121 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); | 125 | QString fs= getFileSystemType((const QString &) currentDir.canonicalPath()); |
122 | setCaption("AdvancedFm :: "+fs+" :: " | 126 | setCaption("AdvancedFm :: "+fs+" :: " |
123 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); | 127 | +checkDiskSpace((const QString &) currentDir.canonicalPath())+" kB free" ); |
124 | bool isDir=FALSE; | 128 | bool isDir=FALSE; |
125 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 129 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
126 | QFileInfoListIterator it(*list); | 130 | QFileInfoListIterator it(*list); |
127 | QFileInfo *fi; | 131 | QFileInfo *fi; |
128 | while ( (fi=it.current()) ) { | 132 | while ( (fi=it.current()) ) { |
129 | if (fi->isSymLink() ) { | 133 | if (fi->isSymLink() ) { |
130 | QString symLink=fi->readLink(); | 134 | QString symLink=fi->readLink(); |
131 | QFileInfo sym( symLink); | 135 | QFileInfo sym( symLink); |
132 | fileS.sprintf( "%10i", sym.size() ); | 136 | fileS.sprintf( "%10i", sym.size() ); |
133 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); | 137 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); |
134 | fileDate = sym.lastModified().toString(); | 138 | fileDate = sym.lastModified().toString(); |
135 | } else { | 139 | } else { |
136 | fileS.sprintf( "%10i", fi->size() ); | 140 | fileS.sprintf( "%10i", fi->size() ); |
137 | fileL.sprintf( "%s",fi->fileName().data() ); | 141 | fileL.sprintf( "%s",fi->fileName().data() ); |
138 | fileDate= fi->lastModified().toString(); | 142 | fileDate= fi->lastModified().toString(); |
139 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 143 | if( QDir(QDir::cleanDirPath( currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
140 | fileL+="/"; | 144 | fileL+="/"; |
141 | isDir=TRUE; | 145 | isDir=TRUE; |
142 | } | 146 | } |
143 | } | 147 | } |
144 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); | 148 | QFileInfo fileInfo( currentDir.canonicalPath()+"/"+fileL); |
145 | if(fileL !="./" && fi->exists()) { | 149 | if(fileL !="./" && fi->exists()) { |
146 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); | 150 | item= new QListViewItem( Local_View, fileL, fileS , fileDate); |
147 | 151 | ||
148 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 152 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
149 | 153 | ||
150 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 154 | if( !QDir( fi->filePath() ).isReadable()) //is directory |
151 | pm = Resource::loadPixmap( "lockedfolder" ); | 155 | pm = Resource::loadPixmap( "lockedfolder" ); |
152 | else | 156 | else |
153 | pm= Resource::loadPixmap( "folder" ); | 157 | pm= Resource::loadPixmap( "folder" ); |
154 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 158 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
155 | pm = Resource::loadPixmap( "exec"); | 159 | pm = Resource::loadPixmap( "exec"); |
156 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 160 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
157 | | fileInfo.permission( QFileInfo::ExeGroup) | 161 | | fileInfo.permission( QFileInfo::ExeGroup) |
158 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 162 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
159 | pm = Resource::loadPixmap( "exec"); | 163 | pm = Resource::loadPixmap( "exec"); |
160 | } else if( !fi->isReadable() ) { | 164 | } else if( !fi->isReadable() ) { |
161 | pm = Resource::loadPixmap( "locked" ); | 165 | pm = Resource::loadPixmap( "locked" ); |
162 | } else { //everything else goes by mimetype | 166 | } else { //everything else goes by mimetype |
163 | MimeType mt(fi->filePath()); | 167 | MimeType mt(fi->filePath()); |
164 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 168 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
165 | if(pm.isNull()) | 169 | if(pm.isNull()) |
166 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 170 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
167 | } | 171 | } |
168 | item->setPixmap( 0,pm); | 172 | item->setPixmap( 0,pm); |
169 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 173 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
170 | // overlay link image | 174 | // overlay link image |
171 | pm= Resource::loadPixmap( "folder" ); | 175 | pm= Resource::loadPixmap( "folder" ); |
172 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 176 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
173 | QPainter painter( &pm ); | 177 | QPainter painter( &pm ); |
174 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 178 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
175 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 179 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
176 | item->setPixmap( 0, pm); | 180 | item->setPixmap( 0, pm); |
177 | } | 181 | } |
178 | } | 182 | } |
179 | isDir=FALSE; | 183 | isDir=FALSE; |
180 | ++it; | 184 | ++it; |
181 | } | 185 | } |
182 | 186 | ||
183 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { | 187 | if(currentDir.canonicalPath().find("dev",0,TRUE) != -1) { |
184 | struct stat buf; | 188 | struct stat buf; |
185 | dev_t devT; | 189 | dev_t devT; |
186 | DIR *dir; | 190 | DIR *dir; |
187 | struct dirent *mydirent; | 191 | struct dirent *mydirent; |
188 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) | 192 | if((dir = opendir( currentDir.canonicalPath().latin1())) != NULL) |
189 | while ((mydirent = readdir(dir)) != NULL) { | 193 | while ((mydirent = readdir(dir)) != NULL) { |
190 | lstat( mydirent->d_name, &buf); | 194 | lstat( mydirent->d_name, &buf); |
191 | qDebug(mydirent->d_name); | 195 | qDebug(mydirent->d_name); |
192 | fileL.sprintf("%s", mydirent->d_name); | 196 | fileL.sprintf("%s", mydirent->d_name); |
193 | devT = buf.st_dev; | 197 | devT = buf.st_dev; |
194 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 198 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
195 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 199 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
196 | if( fileL.find(".") == -1 ){ | 200 | if( fileL.find(".") == -1 ){ |
197 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); | 201 | item= new QListViewItem( Local_View, fileL, fileS, fileDate); |
198 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 202 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
199 | item->setPixmap( 0,pm); | 203 | item->setPixmap( 0,pm); |
200 | } | 204 | } |
201 | } | 205 | } |
202 | 206 | ||
203 | closedir(dir); | 207 | closedir(dir); |
204 | } | 208 | } |
205 | 209 | ||
206 | Local_View->setSorting( 3,FALSE); | 210 | Local_View->setSorting( 3,FALSE); |
207 | fillCombo( (const QString &) currentDir.canonicalPath()); | 211 | fillCombo( (const QString &) currentDir.canonicalPath()); |
208 | } | 212 | } |
209 | 213 | ||
210 | 214 | ||
211 | void AdvancedFm::populateRemoteView() { | 215 | void AdvancedFm::populateRemoteView() { |
212 | QPixmap pm; | 216 | QPixmap pm; |
213 | Remote_View->clear(); | 217 | Remote_View->clear(); |
214 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 218 | currentRemoteDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
215 | currentRemoteDir.setMatchAllDirs(TRUE); | 219 | currentRemoteDir.setMatchAllDirs(TRUE); |
216 | currentRemoteDir.setNameFilter(filterStr); | 220 | currentRemoteDir.setNameFilter(filterStr); |
217 | QString fileL, fileS, fileDate; | 221 | QString fileL, fileS, fileDate; |
218 | 222 | ||
219 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); | 223 | QString fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath()); |
220 | setCaption("AdvancedFm :: "+fs+" :: " | 224 | setCaption("AdvancedFm :: "+fs+" :: " |
221 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); | 225 | +checkDiskSpace((const QString &) currentRemoteDir.canonicalPath())+" kB free" ); |
222 | bool isDir=FALSE; | 226 | bool isDir=FALSE; |
223 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 227 | const QFileInfoList *list = currentRemoteDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
224 | QFileInfoListIterator it(*list); | 228 | QFileInfoListIterator it(*list); |
225 | QFileInfo *fi; | 229 | QFileInfo *fi; |
226 | while ( (fi=it.current()) ) { | 230 | while ( (fi=it.current()) ) { |
227 | if (fi->isSymLink() ){ | 231 | if (fi->isSymLink() ){ |
228 | QString symLink=fi->readLink(); | 232 | QString symLink=fi->readLink(); |
229 | // qDebug("Symlink detected "+symLink); | 233 | // qDebug("Symlink detected "+symLink); |
230 | QFileInfo sym( symLink); | 234 | QFileInfo sym( symLink); |
231 | fileS.sprintf( "%10i", sym.size() ); | 235 | fileS.sprintf( "%10i", sym.size() ); |
232 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); | 236 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.filePath().data() ); |
233 | fileDate = sym.lastModified().toString(); | 237 | fileDate = sym.lastModified().toString(); |
234 | } else { | 238 | } else { |
235 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 239 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
236 | fileS.sprintf( "%10i", fi->size() ); | 240 | fileS.sprintf( "%10i", fi->size() ); |
237 | fileL.sprintf( "%s",fi->fileName().data() ); | 241 | fileL.sprintf( "%s",fi->fileName().data() ); |
238 | fileDate= fi->lastModified().toString(); | 242 | fileDate= fi->lastModified().toString(); |
239 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { | 243 | if( QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+fileL)).exists() ) { |
240 | fileL+="/"; | 244 | fileL+="/"; |
241 | isDir=TRUE; | 245 | isDir=TRUE; |
242 | // qDebug( fileL); | 246 | // qDebug( fileL); |
243 | } | 247 | } |
244 | } | 248 | } |
245 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); | 249 | QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+fileL); |
246 | if(fileL !="./" && fi->exists()) { | 250 | if(fileL !="./" && fi->exists()) { |
247 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 251 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
248 | QPixmap pm; | 252 | QPixmap pm; |
249 | 253 | ||
250 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 254 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
251 | if( !QDir( fi->filePath() ).isReadable()) | 255 | if( !QDir( fi->filePath() ).isReadable()) |
252 | pm = Resource::loadPixmap( "lockedfolder" ); | 256 | pm = Resource::loadPixmap( "lockedfolder" ); |
253 | else | 257 | else |
254 | pm= Resource::loadPixmap( "folder" ); | 258 | pm= Resource::loadPixmap( "folder" ); |
255 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 259 | } else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
256 | pm = Resource::loadPixmap( "exec"); | 260 | pm = Resource::loadPixmap( "exec"); |
257 | } else if( (fileInfo.permission( QFileInfo::ExeUser) | 261 | } else if( (fileInfo.permission( QFileInfo::ExeUser) |
258 | | fileInfo.permission( QFileInfo::ExeGroup) | 262 | | fileInfo.permission( QFileInfo::ExeGroup) |
259 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 263 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { |
260 | pm = Resource::loadPixmap( "exec"); | 264 | pm = Resource::loadPixmap( "exec"); |
261 | } else if( !fi->isReadable() ) { | 265 | } else if( !fi->isReadable() ) { |
262 | pm = Resource::loadPixmap( "locked" ); | 266 | pm = Resource::loadPixmap( "locked" ); |
263 | } else { | 267 | } else { |
264 | MimeType mt(fi->filePath()); | 268 | MimeType mt(fi->filePath()); |
265 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 269 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
266 | if(pm.isNull()) | 270 | if(pm.isNull()) |
267 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 271 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
268 | } | 272 | } |
269 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { | 273 | if( fi->isSymLink() && fileL.find("->",0,TRUE) != -1) { |
270 | // overlay link image | 274 | // overlay link image |
271 | pm= Resource::loadPixmap( "folder" ); | 275 | pm= Resource::loadPixmap( "folder" ); |
272 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 276 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
273 | QPainter painter( &pm ); | 277 | QPainter painter( &pm ); |
274 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 278 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
275 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 279 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
276 | } | 280 | } |
277 | item->setPixmap( 0, pm); | 281 | item->setPixmap( 0, pm); |
278 | } | 282 | } |
279 | isDir=FALSE; | 283 | isDir=FALSE; |
280 | ++it; | 284 | ++it; |
281 | } | 285 | } |
282 | 286 | ||
283 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { | 287 | if(currentRemoteDir.canonicalPath().find("dev",0,TRUE) != -1) { |
284 | struct stat buf; | 288 | struct stat buf; |
285 | DIR *dir; | 289 | DIR *dir; |
286 | struct dirent *mydirent; | 290 | struct dirent *mydirent; |
287 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) | 291 | if((dir = opendir( currentRemoteDir.canonicalPath().latin1())) != NULL) |
288 | while ((mydirent = readdir(dir)) != NULL) { | 292 | while ((mydirent = readdir(dir)) != NULL) { |
289 | lstat( mydirent->d_name, &buf); | 293 | lstat( mydirent->d_name, &buf); |
290 | qDebug(mydirent->d_name); | 294 | qDebug(mydirent->d_name); |
291 | fileL.sprintf("%s", mydirent->d_name); | 295 | fileL.sprintf("%s", mydirent->d_name); |
292 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); | 296 | fileS.sprintf("%d,%d", (int) (buf.st_dev>>8)&0xFF, (int) buf.st_dev &0xFF); |
293 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 297 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
294 | if( fileL.find(".") == -1 ){ | 298 | if( fileL.find(".") == -1 ){ |
295 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); | 299 | item= new QListViewItem( Remote_View, fileL, fileS, fileDate); |
296 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 300 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
297 | item->setPixmap( 0,pm); | 301 | item->setPixmap( 0,pm); |
298 | } | 302 | } |
299 | } | 303 | } |
300 | 304 | ||
301 | closedir(dir); | 305 | closedir(dir); |
302 | } | 306 | } |
303 | 307 | ||
304 | Remote_View->setSorting( 3,FALSE); | 308 | Remote_View->setSorting( 3,FALSE); |
305 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); | 309 | fillCombo( (const QString &) currentRemoteDir.canonicalPath() ); |
306 | } | 310 | } |
307 | 311 | ||
308 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) { | 312 | void AdvancedFm::localListClicked(QListViewItem *selectedItem) { |
309 | if(selectedItem) { | 313 | if(selectedItem) { |
310 | QString strItem=selectedItem->text(0); | 314 | QString strItem=selectedItem->text(0); |
311 | QString strSize=selectedItem->text(1); | 315 | QString strSize=selectedItem->text(1); |
312 | strSize=strSize.stripWhiteSpace(); | 316 | strSize=strSize.stripWhiteSpace(); |
313 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 317 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
314 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 318 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
315 | if(QDir(strItem2).exists() ) { | 319 | if(QDir(strItem2).exists() ) { |
316 | currentDir.cd(strItem2, TRUE); | 320 | currentDir.cd(strItem2, TRUE); |
317 | populateLocalView(); | 321 | populateLocalView(); |
318 | 322 | ||
319 | } | 323 | } |
320 | } else { // not a symlink | 324 | } else { // not a symlink |
321 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 325 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
322 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 326 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
323 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 327 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
324 | currentDir.cd(strItem,FALSE); | 328 | currentDir.cd(strItem,FALSE); |
325 | populateLocalView(); | 329 | populateLocalView(); |
326 | Local_View->ensureItemVisible(Local_View->firstChild()); | 330 | Local_View->ensureItemVisible(Local_View->firstChild()); |
327 | 331 | ||
328 | } else { | 332 | } else { |
329 | currentDir.cdUp(); | 333 | currentDir.cdUp(); |
330 | populateLocalView(); | 334 | populateLocalView(); |
331 | Local_View->ensureItemVisible(Local_View->firstChild()); | 335 | Local_View->ensureItemVisible(Local_View->firstChild()); |
332 | } | 336 | } |
333 | if(QDir(strItem).exists()){ | 337 | if(QDir(strItem).exists()){ |
334 | currentDir.cd(strItem, TRUE); | 338 | currentDir.cd(strItem, TRUE); |
335 | Local_View->ensureItemVisible(Local_View->firstChild()); | 339 | Local_View->ensureItemVisible(Local_View->firstChild()); |
336 | populateLocalView(); | 340 | populateLocalView(); |
337 | } | 341 | } |
338 | } else { | 342 | } else { |
339 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 343 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
340 | if( QFile::exists(strItem ) ) { | 344 | if( QFile::exists(strItem ) ) { |
341 | // qDebug("clicked item "+strItem); | 345 | // qDebug("clicked item "+strItem); |
342 | // DocLnk doc( strItem, FALSE ); | 346 | // DocLnk doc( strItem, FALSE ); |
343 | // doc.execute(); | 347 | // doc.execute(); |
344 | // Local_View->clearSelection(); | 348 | // Local_View->clearSelection(); |
345 | } | 349 | } |
346 | } //end not symlink | 350 | } //end not symlink |
347 | chdir(strItem.latin1()); | 351 | chdir(strItem.latin1()); |
348 | } | 352 | } |
349 | 353 | ||
350 | } | 354 | } |
351 | } | 355 | } |
352 | 356 | ||
353 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { | 357 | void AdvancedFm::remoteListClicked(QListViewItem *selectedItem) { |
354 | 358 | ||
355 | if(selectedItem) { | 359 | if(selectedItem) { |
356 | QString strItem=selectedItem->text(0); | 360 | QString strItem=selectedItem->text(0); |
357 | QString strSize=selectedItem->text(1); | 361 | QString strSize=selectedItem->text(1); |
358 | strSize=strSize.stripWhiteSpace(); | 362 | strSize=strSize.stripWhiteSpace(); |
359 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 363 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
360 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 364 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
361 | currentRemoteDir.cd(strItem2, TRUE); | 365 | currentRemoteDir.cd(strItem2, TRUE); |
362 | populateRemoteView(); | 366 | populateRemoteView(); |
363 | } else { // not a symlink | 367 | } else { // not a symlink |
364 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 368 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
365 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { | 369 | if(QDir(QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem)).exists() ) { |
366 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 370 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
367 | currentRemoteDir.cd(strItem,FALSE); | 371 | currentRemoteDir.cd(strItem,FALSE); |
368 | populateRemoteView(); | 372 | populateRemoteView(); |
369 | Remote_View->ensureItemVisible(Remote_View->firstChild()); | 373 | Remote_View->ensureItemVisible(Remote_View->firstChild()); |
370 | } else { | 374 | } else { |
371 | currentRemoteDir.cdUp(); | 375 | currentRemoteDir.cdUp(); |
372 | populateRemoteView(); | 376 | populateRemoteView(); |
373 | Remote_View->ensureItemVisible(Remote_View->firstChild()); | 377 | Remote_View->ensureItemVisible(Remote_View->firstChild()); |
374 | } | 378 | } |
375 | if(QDir(strItem).exists()){ | 379 | if(QDir(strItem).exists()){ |
376 | currentRemoteDir.cd(strItem, TRUE); | 380 | currentRemoteDir.cd(strItem, TRUE); |
377 | populateRemoteView(); | 381 | populateRemoteView(); |
378 | Remote_View->ensureItemVisible(Remote_View->firstChild()); | 382 | Remote_View->ensureItemVisible(Remote_View->firstChild()); |
379 | } | 383 | } |
380 | } else { | 384 | } else { |
381 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); | 385 | strItem=QDir::cleanDirPath( currentRemoteDir.canonicalPath()+"/"+strItem); |
382 | if( QFile::exists(strItem ) ) { | 386 | if( QFile::exists(strItem ) ) { |
383 | // qDebug("clicked item "+strItem); | 387 | // qDebug("clicked item "+strItem); |
384 | // DocLnk doc( strItem, FALSE ); | 388 | // DocLnk doc( strItem, FALSE ); |
385 | // doc.execute(); | 389 | // doc.execute(); |
386 | // Remote_View->clearSelection(); | 390 | // Remote_View->clearSelection(); |
387 | } | 391 | } |
388 | } //end not symlink | 392 | } //end not symlink |
389 | chdir(strItem.latin1()); | 393 | chdir(strItem.latin1()); |
390 | } | 394 | } |
391 | } | 395 | } |
392 | } | 396 | } |
393 | 397 | ||
394 | 398 | ||
395 | void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { | 399 | void AdvancedFm::localListPressed( int mouse, QListViewItem *, const QPoint& , int ) { |
396 | // qDebug("list pressed"); | 400 | // qDebug("list pressed"); |
397 | switch (mouse) { | 401 | switch (mouse) { |
398 | case 1: | 402 | case 1: |
399 | break; | 403 | break; |
400 | case 2: | 404 | case 2: |
401 | menuTimer.start( 500, TRUE ); | 405 | menuTimer.start( 500, TRUE ); |
402 | qDebug("Start menu timer\n"); | 406 | qDebug("Start menu timer\n"); |
403 | break; | 407 | break; |
404 | }; | 408 | }; |
405 | } | 409 | } |
406 | 410 | ||
407 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { | 411 | void AdvancedFm::remoteListPressed( int mouse, QListViewItem*, const QPoint&, int ) { |
408 | 412 | ||
409 | switch (mouse) { | 413 | switch (mouse) { |
410 | case 1: | 414 | case 1: |
411 | break; | 415 | break; |
412 | case 2: | 416 | case 2: |
413 | menuTimer.start( 500, TRUE ); | 417 | menuTimer.start( 500, TRUE ); |
414 | qDebug("Start menu timer"); | 418 | qDebug("Start menu timer"); |
415 | break; | 419 | break; |
416 | }; | 420 | }; |
417 | } | 421 | } |
418 | 422 | ||
419 | 423 | ||
420 | void AdvancedFm::switchToLocalTab() { | 424 | void AdvancedFm::switchToLocalTab() { |
421 | TabWidget->setCurrentTab(0); | 425 | TabWidget->setCurrentTab(0); |
422 | Local_View->setFocus(); | 426 | Local_View->setFocus(); |
423 | } | 427 | } |
424 | 428 | ||
425 | void AdvancedFm::switchToRemoteTab() { | 429 | void AdvancedFm::switchToRemoteTab() { |
426 | TabWidget->setCurrentTab(1); | 430 | TabWidget->setCurrentTab(1); |
427 | Remote_View->setFocus(); | 431 | Remote_View->setFocus(); |
428 | } | 432 | } |
429 | 433 | ||
430 | void AdvancedFm::readConfig() { | 434 | void AdvancedFm::readConfig() { |
431 | Config cfg("AdvancedFm"); | 435 | Config cfg("AdvancedFm"); |
432 | } | 436 | } |
433 | 437 | ||
434 | void AdvancedFm::writeConfig() { | 438 | void AdvancedFm::writeConfig() { |
435 | Config cfg("AdvancedFm"); | 439 | Config cfg("AdvancedFm"); |
436 | } | 440 | } |
437 | 441 | ||
438 | void AdvancedFm::currentPathComboChanged() { | 442 | void AdvancedFm::currentPathComboChanged() { |
439 | if (TabWidget->getCurrentTab() == 0) { | 443 | if (TabWidget->getCurrentTab() == 0) { |
440 | // if (TabWidget->currentPageIndex() == 0) { | 444 | // if (TabWidget->currentPageIndex() == 0) { |
441 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 445 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
442 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 446 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
443 | populateLocalView(); | 447 | populateLocalView(); |
444 | } else { | 448 | } else { |
445 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 449 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
446 | } | 450 | } |
447 | } | 451 | } |
448 | if (TabWidget->getCurrentTab() == 0) { | 452 | if (TabWidget->getCurrentTab() == 0) { |
449 | // if (TabWidget->currentPageIndex() == 0) { | 453 | // if (TabWidget->currentPageIndex() == 0) { |
450 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 454 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
451 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); | 455 | currentRemoteDir.setPath( currentPathCombo->lineEdit()->text() ); |
452 | populateRemoteView(); | 456 | populateRemoteView(); |
453 | } else { | 457 | } else { |
454 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 458 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
455 | } | 459 | } |
456 | } | 460 | } |
457 | } | 461 | } |
458 | 462 | ||
459 | void AdvancedFm::fillCombo(const QString ¤tPath) { | 463 | void AdvancedFm::fillCombo(const QString ¤tPath) { |
460 | 464 | ||
461 | if (TabWidget->getCurrentTab() == 0) { | 465 | if (TabWidget->getCurrentTab() == 0) { |
462 | // if (TabWidget->currentPageIndex() == 0) { | 466 | // if (TabWidget->currentPageIndex() == 0) { |
463 | currentPathCombo->lineEdit()->setText( currentPath); | 467 | currentPathCombo->lineEdit()->setText( currentPath); |
464 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 468 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
465 | currentPathCombo->clear(); | 469 | currentPathCombo->clear(); |
466 | localDirPathStringList.prepend( currentPath ); | 470 | localDirPathStringList.prepend( currentPath ); |
467 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 471 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
468 | } | 472 | } |
469 | } else { | 473 | } else { |
470 | currentPathCombo->lineEdit()->setText( currentPath); | 474 | currentPathCombo->lineEdit()->setText( currentPath); |
471 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { | 475 | if( remoteDirPathStringList.grep( currentPath,TRUE).isEmpty() ) { |
472 | currentPathCombo->clear(); | 476 | currentPathCombo->clear(); |
473 | remoteDirPathStringList.prepend( currentPath ); | 477 | remoteDirPathStringList.prepend( currentPath ); |
474 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 478 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
475 | } | 479 | } |
476 | } | 480 | } |
477 | } | 481 | } |
478 | 482 | ||
479 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { | 483 | void AdvancedFm::currentPathComboActivated(const QString & currentPath) { |
480 | if (TabWidget->getCurrentTab() == 0) { | 484 | if (TabWidget->getCurrentTab() == 0) { |
481 | // if (TabWidget->currentPageIndex() == 0) { | 485 | // if (TabWidget->currentPageIndex() == 0) { |
482 | chdir( currentPath.latin1() ); | 486 | chdir( currentPath.latin1() ); |
483 | currentDir.cd( currentPath, TRUE); | 487 | currentDir.cd( currentPath, TRUE); |
484 | populateLocalView(); | 488 | populateLocalView(); |
485 | update(); | 489 | update(); |
486 | } else { | 490 | } else { |
487 | chdir( currentPath.latin1() ); | 491 | chdir( currentPath.latin1() ); |
488 | currentRemoteDir.cd( currentPath, TRUE); | 492 | currentRemoteDir.cd( currentPath, TRUE); |
489 | populateRemoteView(); | 493 | populateRemoteView(); |
490 | update(); | 494 | update(); |
491 | } | 495 | } |
492 | } | 496 | } |
493 | 497 | ||
494 | QStringList AdvancedFm::getPath() { | 498 | QStringList AdvancedFm::getPath() { |
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp index 946d038..a60cea6 100644 --- a/noncore/apps/advancedfm/output.cpp +++ b/noncore/apps/advancedfm/output.cpp | |||
@@ -1,282 +1,284 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** outputEdit.cpp | 2 | ** outputEdit.cpp |
3 | ** | 3 | ** |
4 | ** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com> | 4 | ** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com> |
5 | ****************************************************************************/ | 5 | ****************************************************************************/ |
6 | #include "output.h" | 6 | #include "output.h" |
7 | 7 | ||
8 | #include <opie/oprocess.h> | 8 | #include <opie/oprocess.h> |
9 | 9 | ||
10 | #include <qpe/filemanager.h> | 10 | #include <qpe/filemanager.h> |
11 | #include <qpe/qpeapplication.h> | 11 | #include <qpe/qpeapplication.h> |
12 | #include <qpe/applnk.h> | 12 | #include <qpe/applnk.h> |
13 | 13 | ||
14 | #include <qmessagebox.h> | 14 | #include <qmessagebox.h> |
15 | #include <qstringlist.h> | 15 | #include <qstringlist.h> |
16 | #include <qfile.h> | 16 | #include <qfile.h> |
17 | #include <qcstring.h> | 17 | #include <qcstring.h> |
18 | #include <qlineedit.h> | 18 | #include <qlineedit.h> |
19 | #include <qmultilineedit.h> | 19 | #include <qmultilineedit.h> |
20 | #include <qpushbutton.h> | 20 | #include <qpushbutton.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qvariant.h> | 22 | #include <qvariant.h> |
23 | 23 | ||
24 | #include <errno.h> | 24 | #include <errno.h> |
25 | 25 | ||
26 | /* XPM */ | 26 | /* XPM */ |
27 | static char * filesave_xpm[] = { | 27 | static char * filesave_xpm[] = { |
28 | "16 16 78 1", | 28 | "16 16 78 1", |
29 | " c None", | 29 | " c None", |
30 | ". c #343434", | 30 | ". c #343434", |
31 | "+ c #A0A0A0", | 31 | "+ c #A0A0A0", |
32 | "@ c #565656", | 32 | "@ c #565656", |
33 | "# c #9E9E9E", | 33 | "# c #9E9E9E", |
34 | "$ c #525252", | 34 | "$ c #525252", |
35 | "% c #929292", | 35 | "% c #929292", |
36 | "& c #676767", | 36 | "& c #676767", |
37 | "* c #848484", | 37 | "* c #848484", |
38 | "= c #666666", | 38 | "= c #666666", |
39 | "- c #D8D8D8", | 39 | "- c #D8D8D8", |
40 | "; c #FFFFFF", | 40 | "; c #FFFFFF", |
41 | "> c #DBDBDB", | 41 | "> c #DBDBDB", |
42 | ", c #636363", | 42 | ", c #636363", |
43 | "' c #989898", | 43 | "' c #989898", |
44 | ") c #2D2D2D", | 44 | ") c #2D2D2D", |
45 | "! c #909090", | 45 | "! c #909090", |
46 | "~ c #AEAEAE", | 46 | "~ c #AEAEAE", |
47 | "{ c #EAEAEA", | 47 | "{ c #EAEAEA", |
48 | "] c #575757", | 48 | "] c #575757", |
49 | "^ c #585858", | 49 | "^ c #585858", |
50 | "/ c #8A8A8A", | 50 | "/ c #8A8A8A", |
51 | "( c #828282", | 51 | "( c #828282", |
52 | "_ c #6F6F6F", | 52 | "_ c #6F6F6F", |
53 | ": c #C9C9C9", | 53 | ": c #C9C9C9", |
54 | "< c #050505", | 54 | "< c #050505", |
55 | "[ c #292929", | 55 | "[ c #292929", |
56 | "} c #777777", | 56 | "} c #777777", |
57 | "| c #616161", | 57 | "| c #616161", |
58 | "1 c #3A3A3A", | 58 | "1 c #3A3A3A", |
59 | "2 c #BEBEBE", | 59 | "2 c #BEBEBE", |
60 | "3 c #2C2C2C", | 60 | "3 c #2C2C2C", |
61 | "4 c #7C7C7C", | 61 | "4 c #7C7C7C", |
62 | "5 c #F6F6F6", | 62 | "5 c #F6F6F6", |
63 | "6 c #FCFCFC", | 63 | "6 c #FCFCFC", |
64 | "7 c #6B6B6B", | 64 | "7 c #6B6B6B", |
65 | "8 c #959595", | 65 | "8 c #959595", |
66 | "9 c #4F4F4F", | 66 | "9 c #4F4F4F", |
67 | "0 c #808080", | 67 | "0 c #808080", |
68 | "a c #767676", | 68 | "a c #767676", |
69 | "b c #818181", | 69 | "b c #818181", |
70 | "c c #B8B8B8", | 70 | "c c #B8B8B8", |
71 | "d c #FBFBFB", | 71 | "d c #FBFBFB", |
72 | "e c #F9F9F9", | 72 | "e c #F9F9F9", |
73 | "f c #CCCCCC", | 73 | "f c #CCCCCC", |
74 | "g c #030303", | 74 | "g c #030303", |
75 | "h c #737373", | 75 | "h c #737373", |
76 | "i c #7A7A7A", | 76 | "i c #7A7A7A", |
77 | "j c #7E7E7E", | 77 | "j c #7E7E7E", |
78 | "k c #6A6A6A", | 78 | "k c #6A6A6A", |
79 | "l c #FAFAFA", | 79 | "l c #FAFAFA", |
80 | "m c #505050", | 80 | "m c #505050", |
81 | "n c #9D9D9D", | 81 | "n c #9D9D9D", |
82 | "o c #333333", | 82 | "o c #333333", |
83 | "p c #7B7B7B", | 83 | "p c #7B7B7B", |
84 | "q c #787878", | 84 | "q c #787878", |
85 | "r c #696969", | 85 | "r c #696969", |
86 | "s c #494949", | 86 | "s c #494949", |
87 | "t c #555555", | 87 | "t c #555555", |
88 | "u c #949494", | 88 | "u c #949494", |
89 | "v c #E6E6E6", | 89 | "v c #E6E6E6", |
90 | "w c #424242", | 90 | "w c #424242", |
91 | "x c #515151", | 91 | "x c #515151", |
92 | "y c #535353", | 92 | "y c #535353", |
93 | "z c #3E3E3E", | 93 | "z c #3E3E3E", |
94 | "A c #D4D4D4", | 94 | "A c #D4D4D4", |
95 | "B c #0C0C0C", | 95 | "B c #0C0C0C", |
96 | "C c #353535", | 96 | "C c #353535", |
97 | "D c #474747", | 97 | "D c #474747", |
98 | "E c #ECECEC", | 98 | "E c #ECECEC", |
99 | "F c #919191", | 99 | "F c #919191", |
100 | "G c #7D7D7D", | 100 | "G c #7D7D7D", |
101 | "H c #000000", | 101 | "H c #000000", |
102 | "I c #404040", | 102 | "I c #404040", |
103 | "J c #858585", | 103 | "J c #858585", |
104 | "K c #323232", | 104 | "K c #323232", |
105 | "L c #D0D0D0", | 105 | "L c #D0D0D0", |
106 | "M c #1C1C1C", | 106 | "M c #1C1C1C", |
107 | " ...+ ", | 107 | " ...+ ", |
108 | " @#$%&..+ ", | 108 | " @#$%&..+ ", |
109 | " .*=-;;>,..+ ", | 109 | " .*=-;;>,..+ ", |
110 | " ')!~;;;;;;{]..", | 110 | " ')!~;;;;;;{]..", |
111 | " ^/(-;;;;;;;_:<", | 111 | " ^/(-;;;;;;;_:<", |
112 | " [}|;;;;;;;{12$", | 112 | " [}|;;;;;;;{12$", |
113 | " #34-55;;;;678$+", | 113 | " #34-55;;;;678$+", |
114 | " 90ab=c;dd;e1fg ", | 114 | " 90ab=c;dd;e1fg ", |
115 | " [ahij((kbl0mn$ ", | 115 | " [ahij((kbl0mn$ ", |
116 | " op^q^^7r&]s/$+ ", | 116 | " op^q^^7r&]s/$+ ", |
117 | "@btu;vbwxy]zAB ", | 117 | "@btu;vbwxy]zAB ", |
118 | "CzDEvEv;;DssF$ ", | 118 | "CzDEvEv;;DssF$ ", |
119 | "G.H{E{E{IxsJ$+ ", | 119 | "G.H{E{E{IxsJ$+ ", |
120 | " +...vEKxzLM ", | 120 | " +...vEKxzLM ", |
121 | " +...z]n$ ", | 121 | " +...z]n$ ", |
122 | " +... "}; | 122 | " +... "}; |
123 | 123 | ||
124 | Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) | 124 | Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) |
125 | : QDialog( parent, name, modal, fl ) | 125 | : QDialog( parent, name, modal, fl ) |
126 | { | 126 | { |
127 | QStringList cmmds; | 127 | QStringList cmmds; |
128 | // cmmds=QStringList::split( " ", commands, false); | 128 | // cmmds=QStringList::split( " ", commands, false); |
129 | cmmds=commands; | 129 | cmmds=commands; |
130 | // qDebug("count %d", cmmds.count()); | 130 | // qDebug("count %d", cmmds.count()); |
131 | if ( !name ) | 131 | if ( !name ) |
132 | setName( tr("Output")); | 132 | setName( tr("Output")); |
133 | resize( 196, 269 ); | 133 | resize( 196, 269 ); |
134 | setCaption( name ); | 134 | setCaption( name ); |
135 | 135 | ||
136 | OutputLayout = new QGridLayout( this ); | 136 | OutputLayout = new QGridLayout( this ); |
137 | OutputLayout->setSpacing( 2); | 137 | OutputLayout->setSpacing( 2); |
138 | OutputLayout->setMargin( 2); | 138 | OutputLayout->setMargin( 2); |
139 | 139 | ||
140 | QPushButton *docButton; | 140 | QPushButton *docButton; |
141 | docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); | 141 | docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); |
142 | docButton->setFixedSize( QSize( 20, 20 ) ); | 142 | docButton->setFixedSize( QSize( 20, 20 ) ); |
143 | connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); | 143 | connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); |
144 | // docButton->setFlat(TRUE); | 144 | // docButton->setFlat(TRUE); |
145 | OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); | 145 | OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); |
146 | 146 | ||
147 | OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); | 147 | OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); |
148 | OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); | 148 | OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); |
149 | 149 | ||
150 | proc = new OProcess(); | 150 | proc = new OProcess(); |
151 | 151 | ||
152 | connect(proc, SIGNAL(processExited(OProcess *)), | 152 | connect(proc, SIGNAL(processExited(OProcess *)), |
153 | this, SLOT( processFinished())); | 153 | this, SLOT( processFinished())); |
154 | 154 | ||
155 | connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), | 155 | connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), |
156 | this, SLOT(commandStdout(OProcess *, char *, int))); | 156 | this, SLOT(commandStdout(OProcess *, char *, int))); |
157 | 157 | ||
158 | connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), | 158 | connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), |
159 | this, SLOT(commandStderr(OProcess *, char *, int))); | 159 | this, SLOT(commandStderr(OProcess *, char *, int))); |
160 | 160 | ||
161 | // connect( , SIGNAL(received(const QByteArray &)), | 161 | // connect( , SIGNAL(received(const QByteArray &)), |
162 | // this, SLOT(commandStdin(const QByteArray &))); | 162 | // this, SLOT(commandStdin(const QByteArray &))); |
163 | 163 | ||
164 | // * proc << commands.latin1(); | 164 | // * proc << commands.latin1(); |
165 | for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { | 165 | for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { |
166 | qDebug( "%s", (*it).latin1() ); | 166 | qDebug( "%s", (*it).latin1() ); |
167 | * proc << (*it).latin1(); | 167 | * proc << (*it).latin1(); |
168 | } | 168 | } |
169 | 169 | ||
170 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { | 170 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { |
171 | 171 | ||
172 | OutputEdit->append("Process could not start"); | 172 | OutputEdit->append("Process could not start"); |
173 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 173 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
174 | perror("Error: "); | 174 | perror("Error: "); |
175 | QString errorMsg="Error\n"+(QString)strerror(errno); | 175 | QString errorMsg="Error\n"+(QString)strerror(errno); |
176 | OutputEdit->append( errorMsg); | 176 | OutputEdit->append( errorMsg); |
177 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 177 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | 180 | ||
181 | Output::~Output() { | 181 | Output::~Output() { |
182 | } | 182 | } |
183 | 183 | ||
184 | void Output::saveOutput() { | 184 | void Output::saveOutput() { |
185 | 185 | ||
186 | InputDialog *fileDlg; | 186 | InputDialog *fileDlg; |
187 | fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); | 187 | fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); |
188 | fileDlg->exec(); | 188 | fileDlg->exec(); |
189 | if( fileDlg->result() == 1 ) { | 189 | if( fileDlg->result() == 1 ) { |
190 | QString filename = QPEApplication::documentDir(); | 190 | QString filename = QPEApplication::documentDir(); |
191 | if(filename.right(1).find('/') == -1) | 191 | if(filename.right(1).find('/') == -1) |
192 | filename+="/"; | 192 | filename+="/"; |
193 | QString name = fileDlg->LineEdit1->text(); | 193 | QString name = fileDlg->LineEdit1->text(); |
194 | filename+="text/plain/"+name; | 194 | filename+="text/plain/"+name; |
195 | qDebug(filename); | 195 | qDebug(filename); |
196 | 196 | ||
197 | QFile f(filename); | 197 | QFile f(filename); |
198 | f.open( IO_WriteOnly); | 198 | f.open( IO_WriteOnly); |
199 | if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { | 199 | if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { |
200 | DocLnk lnk; | 200 | DocLnk lnk; |
201 | lnk.setName(name); //sets file name | 201 | lnk.setName(name); //sets file name |
202 | lnk.setFile(filename); //sets File property | 202 | lnk.setFile(filename); //sets File property |
203 | lnk.setType("text/plain"); | 203 | lnk.setType("text/plain"); |
204 | if(!lnk.writeLink()) { | 204 | if(!lnk.writeLink()) { |
205 | qDebug("Writing doclink did not work"); | 205 | qDebug("Writing doclink did not work"); |
206 | } | 206 | } |
207 | } else | 207 | } else |
208 | qWarning("Could not write file"); | 208 | qWarning("Could not write file"); |
209 | f.close(); | 209 | f.close(); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | 212 | ||
213 | void Output::commandStdout(OProcess*, char *buffer, int buflen) { | 213 | void Output::commandStdout(OProcess*, char *buffer, int buflen) { |
214 | qWarning("received stdout %d bytes", buflen); | 214 | qWarning("received stdout %d bytes", buflen); |
215 | 215 | ||
216 | // QByteArray data(buflen); | 216 | // QByteArray data(buflen); |
217 | // data.fill(*buffer, buflen); | 217 | // data.fill(*buffer, buflen); |
218 | // for (uint i = 0; i < data.count(); i++ ) { | 218 | // for (uint i = 0; i < data.count(); i++ ) { |
219 | // printf("%c", buffer[i] ); | 219 | // printf("%c", buffer[i] ); |
220 | // } | 220 | // } |
221 | // printf("\n"); | 221 | // printf("\n"); |
222 | 222 | ||
223 | QString lineStr = buffer; | 223 | QString lineStr = buffer; |
224 | lineStr=lineStr.left(lineStr.length()-1); | 224 | lineStr=lineStr.left(lineStr.length()-1); |
225 | OutputEdit->append(lineStr); | 225 | OutputEdit->append(lineStr); |
226 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 226 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
227 | } | 227 | } |
228 | 228 | ||
229 | 229 | ||
230 | void Output::commandStdin( const QByteArray &data) { | 230 | void Output::commandStdin( const QByteArray &data) { |
231 | qWarning("received stdin %d bytes", data.size()); | 231 | qWarning("received stdin %d bytes", data.size()); |
232 | // recieved data from the io layer goes to sz | 232 | // recieved data from the io layer goes to sz |
233 | proc->writeStdin(data.data(), data.size()); | 233 | proc->writeStdin(data.data(), data.size()); |
234 | } | 234 | } |
235 | 235 | ||
236 | void Output::commandStderr(OProcess*, char *buffer, int buflen) { | 236 | void Output::commandStderr(OProcess*, char *buffer, int buflen) { |
237 | qWarning("received stderrt %d bytes", buflen); | 237 | qWarning("received stderrt %d bytes", buflen); |
238 | 238 | ||
239 | QString lineStr = buffer; | 239 | QString lineStr = buffer; |
240 | // lineStr=lineStr.left(lineStr.length()-1); | 240 | // lineStr=lineStr.left(lineStr.length()-1); |
241 | OutputEdit->append(lineStr); | 241 | OutputEdit->append(lineStr); |
242 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 242 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
243 | } | 243 | } |
244 | 244 | ||
245 | void Output::processFinished() { | 245 | void Output::processFinished() { |
246 | 246 | ||
247 | delete proc; | 247 | delete proc; |
248 | OutputEdit->append( "\nFinished\n"); | 248 | OutputEdit->append( "\nFinished\n"); |
249 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 249 | OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
250 | // close(); | 250 | // close(); |
251 | // disconnect( layer(), SIGNAL(received(const QByteArray &)), | 251 | // disconnect( layer(), SIGNAL(received(const QByteArray &)), |
252 | // this, SLOT(commandStdin(const QByteArray &))); | 252 | // this, SLOT(commandStdin(const QByteArray &))); |
253 | } | 253 | } |
254 | 254 | ||
255 | //============================== | 255 | //============================== |
256 | 256 | ||
257 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 257 | InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
258 | : QDialog( parent, name, modal, fl ) | 258 | : QDialog( parent, name, modal, fl ) |
259 | { | 259 | { |
260 | if ( !name ) | 260 | if ( !name ) |
261 | setName( "InputDialog" ); | 261 | setName( "InputDialog" ); |
262 | resize( 234, 50 ); | 262 | resize( 234, 50 ); |
263 | setMaximumSize( QSize( 240, 50 ) ); | 263 | setMaximumSize( QSize( 240, 50 ) ); |
264 | setCaption( tr(name ) ); | 264 | setCaption( tr(name ) ); |
265 | 265 | ||
266 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 266 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
267 | LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); | 267 | LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); |
268 | LineEdit1->setFocus(); | ||
269 | LineEdit1->setFocus(); | ||
268 | connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() )); | 270 | connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() )); |
269 | } | 271 | } |
270 | 272 | ||
271 | InputDialog::~InputDialog() { | 273 | InputDialog::~InputDialog() { |
272 | inputText = LineEdit1->text(); | 274 | inputText = LineEdit1->text(); |
273 | } | 275 | } |
274 | 276 | ||
275 | void InputDialog::setInputText(const QString &string) { | 277 | void InputDialog::setInputText(const QString &string) { |
276 | LineEdit1->setText( string); | 278 | LineEdit1->setText( string); |
277 | } | 279 | } |
278 | 280 | ||
279 | void InputDialog::returned() { | 281 | void InputDialog::returned() { |
280 | inputText = LineEdit1->text(); | 282 | inputText = LineEdit1->text(); |
281 | this->accept(); | 283 | this->accept(); |
282 | } | 284 | } |