summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-16 15:30:56 (UTC)
committer llornkcor <llornkcor>2002-11-16 15:30:56 (UTC)
commit88435a3192f09453e035a7f1cf73bbc8c24245c9 (patch) (unidiff)
treeb6209349129bd2f0051c6b0cc9856893efcee7ad
parent1fde54b44ba888094fc47201567ea9454857f5a1 (diff)
downloadopie-88435a3192f09453e035a7f1cf73bbc8c24245c9.zip
opie-88435a3192f09453e035a7f1cf73bbc8c24245c9.tar.gz
opie-88435a3192f09453e035a7f1cf73bbc8c24245c9.tar.bz2
fix tab switches, and inputdialog focus on edit
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp38
-rw-r--r--noncore/apps/advancedfm/output.cpp2
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
@@ -26,149 +26,153 @@
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
67AdvancedFm::AdvancedFm( ) 67AdvancedFm::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
76AdvancedFm::~AdvancedFm() { 76AdvancedFm::~AdvancedFm() {
77} 77}
78 78
79void AdvancedFm::cleanUp() { 79void 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
90void AdvancedFm::tabChanged(QWidget *) { 90void 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
114void AdvancedFm::populateLocalView() { 118void 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 );
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
@@ -204,79 +204,81 @@ void Output::saveOutput() {
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
213void Output::commandStdout(OProcess*, char *buffer, int buflen) { 213void 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
230void Output::commandStdin( const QByteArray &data) { 230void 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
236void Output::commandStderr(OProcess*, char *buffer, int buflen) { 236void 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
245void Output::processFinished() { 245void 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
257InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 257InputDialog::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
271InputDialog::~InputDialog() { 273InputDialog::~InputDialog() {
272 inputText = LineEdit1->text(); 274 inputText = LineEdit1->text();
273} 275}
274 276
275void InputDialog::setInputText(const QString &string) { 277void InputDialog::setInputText(const QString &string) {
276 LineEdit1->setText( string); 278 LineEdit1->setText( string);
277} 279}
278 280
279void InputDialog::returned() { 281void InputDialog::returned() {
280 inputText = LineEdit1->text(); 282 inputText = LineEdit1->text();
281 this->accept(); 283 this->accept();
282} 284}