summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-25 02:46:56 (UTC)
committer llornkcor <llornkcor>2002-03-25 02:46:56 (UTC)
commitb43c59f2f8da6edfa37042e0838b38702636f4d1 (patch) (unidiff)
tree31913b2d26759d404c570c2164949da5b0796027
parentd8820a9f2bdf9bc98c99542e3613ca9b5d2c6e0c (diff)
downloadopie-b43c59f2f8da6edfa37042e0838b38702636f4d1.zip
opie-b43c59f2f8da6edfa37042e0838b38702636f4d1.tar.gz
opie-b43c59f2f8da6edfa37042e0838b38702636f4d1.tar.bz2
added more icon stuff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp53
1 files changed, 30 insertions, 23 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index acd50c2..ebb78d1 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -1,412 +1,419 @@
1/**************************************************************************** 1/****************************************************************************
2** copyright 2001 ljp ljp@llornkcor.com 2** copyright 2001 ljp ljp@llornkcor.com
3** Created: Fri Dec 14 08:16:46 2001 3** Created: Fri Dec 14 08:16:46 2001
4** 4**
5** This file may be distributed and/or modified under the terms of the 5** This file may be distributed and/or modified under the terms of the
6** GNU General Public License version 2 as published by the Free Software 6** GNU General Public License version 2 as published by the Free Software
7** Foundation and appearing in the file LICENSE.GPL included in the 7** Foundation and appearing in the file LICENSE.GPL included in the
8** packaging of this file. 8** packaging of this file.
9** 9**
10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 11** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12** 12**
13****************************************************************************/ 13****************************************************************************/
14#include "fileBrowser.h" 14#include "fileBrowser.h"
15#include "inputDialog.h" 15#include "inputDialog.h"
16 16
17#include <qpe/config.h> 17#include <qpe/config.h>
18#include <qpe/resource.h> 18#include <qpe/resource.h>
19#include <qpe/fileselector.h> 19#include <qpe/fileselector.h>
20#include <qpe/qpeapplication.h> 20#include <qpe/qpeapplication.h>
21#include <qpe/menubutton.h> 21#include <qpe/menubutton.h>
22#include <qpe/mimetype.h>
22 23
23#include <qdict.h> 24#include <qdict.h>
24#include <qwidgetstack.h> 25#include <qwidgetstack.h>
25#include <qlistview.h> 26#include <qlistview.h>
26#include <qcombo.h> 27#include <qcombo.h>
27#include <qpushbutton.h> 28#include <qpushbutton.h>
28#include <qfile.h> 29#include <qfile.h>
29#include <qmessagebox.h> 30#include <qmessagebox.h>
30#include <qlayout.h> 31#include <qlayout.h>
31#include <unistd.h> 32#include <unistd.h>
32#include <qpopupmenu.h> 33#include <qpopupmenu.h>
33#include <qlineedit.h> 34#include <qlineedit.h>
34#include <qstringlist.h> 35#include <qstringlist.h>
35 36
36#include <unistd.h> 37#include <unistd.h>
37#include <stdlib.h> 38#include <stdlib.h>
38 39
39static int u_id = 1; 40static int u_id = 1;
40static int get_unique_id() 41static int get_unique_id()
41{ 42{
42 return u_id++; 43 return u_id++;
43} 44}
44 45
45fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter ) 46fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter )
46 : QDialog( parent, name, modal, fl ) 47 : QDialog( parent, name, modal, fl )
47{ 48{
48 if ( !name ) 49 if ( !name )
49 setName( "fileBrowser" ); 50 setName( "fileBrowser" );
50 setCaption(tr( name ) ); 51 setCaption(tr( name ) );
51 filterStr=filter; 52 filterStr=filter;
52 53
53// channel = new QCopChannel( "QPE/fileDialog", this ); 54// channel = new QCopChannel( "QPE/fileDialog", this );
54// connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 55// connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
55// this, SLOT(receive(const QCString&, const QByteArray&)) ); 56// this, SLOT(receive(const QCString&, const QByteArray&)) );
56 57
57 QGridLayout *layout = new QGridLayout( this ); 58 QGridLayout *layout = new QGridLayout( this );
58 layout->setSpacing( 4 ); 59 layout->setSpacing( 4 );
59 layout->setMargin( 4 ); 60 layout->setMargin( 4 );
60 61
61 dirPathCombo = new QComboBox( FALSE, this, "dorPathCombo" ); 62 dirPathCombo = new QComboBox( FALSE, this, "dorPathCombo" );
62 dirPathCombo->setEditable(TRUE); 63 dirPathCombo->setEditable(TRUE);
63 64
64 connect( dirPathCombo, SIGNAL( activated( const QString & ) ), 65 connect( dirPathCombo, SIGNAL( activated( const QString & ) ),
65 this, SLOT( dirPathComboActivated( const QString & ) ) ); 66 this, SLOT( dirPathComboActivated( const QString & ) ) );
66 67
67 connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ), 68 connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ),
68 this, SLOT( dirPathEditPressed( ) ) ); 69 this, SLOT( dirPathEditPressed( ) ) );
69 70
70 dirPathStringList << "/"; 71 dirPathStringList << "/";
71// we can get the storage here 72// we can get the storage here
72 73
73 layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 ); 74 layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 );
74 75
75 cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton"); 76 cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton");
76 cdUpButton ->setMinimumSize( QSize( 20, 20 ) ); 77 cdUpButton ->setMinimumSize( QSize( 20, 20 ) );
77 cdUpButton ->setMaximumSize( QSize( 20, 20 ) ); 78 cdUpButton ->setMaximumSize( QSize( 20, 20 ) );
78 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) ); 79 connect( cdUpButton ,SIGNAL(released()),this,SLOT( upDir()) );
79 cdUpButton ->setFlat(TRUE); 80 cdUpButton ->setFlat(TRUE);
80 layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 ); 81 layout->addMultiCellWidget( cdUpButton, 0, 0, 5, 5 );
81 82
82 83
83 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); 84 docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton");
84 docButton->setMinimumSize( QSize( 20, 20 ) ); 85 docButton->setMinimumSize( QSize( 20, 20 ) );
85 docButton->setMaximumSize( QSize( 20, 20 ) ); 86 docButton->setMaximumSize( QSize( 20, 20 ) );
86 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); 87 connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) );
87 docButton->setFlat(TRUE); 88 docButton->setFlat(TRUE);
88 layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); 89 layout->addMultiCellWidget( docButton, 0, 0, 6, 6 );
89 90
90 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); 91 homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton");
91 homeButton->setMinimumSize( QSize( 20, 20 ) ); 92 homeButton->setMinimumSize( QSize( 20, 20 ) );
92 homeButton->setMaximumSize( QSize( 20, 20 ) ); 93 homeButton->setMaximumSize( QSize( 20, 20 ) );
93 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); 94 connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) );
94 homeButton->setFlat(TRUE); 95 homeButton->setFlat(TRUE);
95 layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); 96 layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 );
96 97
97 FileStack = new QWidgetStack( this ); 98 FileStack = new QWidgetStack( this );
98 99
99 100
100 ListView = new QListView( this, "ListView" ); 101 ListView = new QListView( this, "ListView" );
101// ListView->setMinimumSize( QSize( 100, 25 ) ); 102// ListView->setMinimumSize( QSize( 100, 25 ) );
102 ListView->addColumn( tr( "Name" ) ); 103 ListView->addColumn( tr( "Name" ) );
103 ListView->setColumnWidth(0,120); 104 ListView->setColumnWidth(0,120);
104 ListView->setSorting( 2, FALSE); 105 ListView->setSorting( 2, FALSE);
105 ListView->addColumn( tr( "Size" ) ); 106 ListView->addColumn( tr( "Size" ) );
106 ListView->setColumnWidth(1,-1); 107 ListView->setColumnWidth(1,-1);
107 ListView->addColumn( "Date",-1); 108 ListView->addColumn( "Date",-1);
108 109
109 ListView->setColumnWidthMode(0,QListView::Manual); 110 ListView->setColumnWidthMode(0,QListView::Manual);
110 ListView->setColumnAlignment(1,QListView::AlignRight); 111 ListView->setColumnAlignment(1,QListView::AlignRight);
111 ListView->setColumnAlignment(2,QListView::AlignRight); 112 ListView->setColumnAlignment(2,QListView::AlignRight);
112 ListView->setAllColumnsShowFocus( TRUE ); 113 ListView->setAllColumnsShowFocus( TRUE );
113 114
114 QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); 115 QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold);
115 connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), 116 connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)),
116 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); 117 this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) );
117 118
118 connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); 119 connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
119 120
120 FileStack->addWidget( ListView, get_unique_id() ); 121 FileStack->addWidget( ListView, get_unique_id() );
121 mimeType="text/*"; 122mimeType="text/*";
122 fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy 123 fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy
123// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); 124// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
124// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); 125// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
125 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); 126 connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) );
126 layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); 127 layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 );
127 128
128 SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); 129 SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" );
129 SelectionCombo->insertItem( tr( "Documents" ) ); 130 SelectionCombo->insertItem( tr( "Documents" ) );
130 SelectionCombo->insertItem( tr( "All files" ) ); 131 SelectionCombo->insertItem( tr( "All files" ) );
131 SelectionCombo->insertItem( tr( "Hidden files" ) ); 132 SelectionCombo->insertItem( tr( "Hidden files" ) );
132// SelectionCombo->setMaximumWidth(120); 133// SelectionCombo->setMaximumWidth(120);
133 layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 ); 134 layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 );
134 135
135 connect( SelectionCombo, SIGNAL( activated( const QString & ) ), 136 connect( SelectionCombo, SIGNAL( activated( const QString & ) ),
136 this, SLOT( selectionChanged( const QString & ) ) ); 137 this, SLOT( selectionChanged( const QString & ) ) );
137 138
138 typemb = new MenuButton(this); 139 typemb = new MenuButton(this);
139 typemb->setLabel(tr("Type: %1")); 140 typemb->setLabel(tr("Type: %1"));
140 typemb->setMinimumWidth(110); 141 typemb->setMinimumWidth(110);
141 typemb->setFixedHeight(22); 142 typemb->setFixedHeight(22);
142 layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); 143 layout->addMultiCellWidget( typemb, 2, 2, 4, 7 );
143 updateMimeTypeMenu() ; 144 updateMimeTypeMenu() ;
144 145
145 currentDir.setPath(QDir::currentDirPath()); 146 currentDir.setPath(QDir::currentDirPath());
146 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); 147 currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All);
147 148
148 populateList(); 149 populateList();
149 move(0,15); 150 move(0,15);
150} 151}
151 152
152fileBrowser::~fileBrowser() 153fileBrowser::~fileBrowser()
153{ 154{
154} 155}
155 156
156void fileBrowser::setFileView( int selection ) 157void fileBrowser::setFileView( int selection )
157{ 158{
158 SelectionCombo->setCurrentItem( selection ); 159 SelectionCombo->setCurrentItem( selection );
159 selectionChanged( SelectionCombo->currentText() ); 160 selectionChanged( SelectionCombo->currentText() );
160} 161}
161 162
162void fileBrowser::populateList() 163void fileBrowser::populateList()
163{ 164{
164 ListView->clear(); 165 ListView->clear();
165 bool isDir=FALSE; 166 bool isDir=FALSE;
166//qDebug(currentDir.canonicalPath()); 167//qDebug(currentDir.canonicalPath());
167 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); 168 currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
168 currentDir.setMatchAllDirs(TRUE); 169 currentDir.setMatchAllDirs(TRUE);
169 170
170 currentDir.setNameFilter(filterStr); 171 currentDir.setNameFilter(filterStr);
171// currentDir.setNameFilter("*.txt;*.etx"); 172// currentDir.setNameFilter("*.txt;*.etx");
172 QString fileL, fileS, fileDate; 173 QString fileL, fileS, fileDate;
173 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); 174 const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/);
174 QFileInfoListIterator it(*list); 175 QFileInfoListIterator it(*list);
175 QFileInfo *fi; 176 QFileInfo *fi;
176 while ( (fi=it.current()) ) { 177 while ( (fi=it.current()) ) {
177 178
178 if (fi->isSymLink() ){ 179 if (fi->isSymLink() ){
179 QString symLink=fi->readLink(); 180 QString symLink=fi->readLink();
180// qDebug("Symlink detected "+symLink); 181// qDebug("Symlink detected "+symLink);
181 QFileInfo sym( symLink); 182 QFileInfo sym( symLink);
182 fileS.sprintf( "%10li", sym.size() ); 183 fileS.sprintf( "%10li", sym.size() );
183 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); 184 fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
184 fileDate = sym.lastModified().toString(); 185 fileDate = sym.lastModified().toString();
185 } else { 186 } else {
186// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); 187// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
187 fileS.sprintf( "%10li", fi->size() ); 188 fileS.sprintf( "%10li", fi->size() );
188 fileL.sprintf( "%s",fi->fileName().data() ); 189 fileL.sprintf( "%s",fi->fileName().data() );
189 fileDate= fi->lastModified().toString(); 190 fileDate= fi->lastModified().toString();
190 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { 191 if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
191 fileL+="/"; 192 fileL+="/";
192 isDir=TRUE; 193 isDir=TRUE;
193// qDebug( fileL); 194// qDebug( fileL);
194 } 195 }
195 } 196 }
196 if(fileL !="./") { 197 if(fileL !="./") {
197 item= new QListViewItem( ListView,fileL,fileS , fileDate); 198 item= new QListViewItem( ListView,fileL,fileS , fileDate);
198 QPixmap pm; 199 QPixmap pm;
199 pm= Resource::loadPixmap( "folder" );
200 200
201 if(isDir || fileL.find("/",0,TRUE) != -1) { 201 if(isDir || fileL.find("/",0,TRUE) != -1) {
202 if( !QDir( fi->filePath() ).isReadable()) 202 if( !QDir( fi->filePath() ).isReadable())
203 pm = Resource::loadPixmap( "lockedfolder" ); 203 pm = Resource::loadPixmap( "lockedfolder" );
204 item->setPixmap( 0,pm ); 204 else
205 } else { 205 pm= Resource::loadPixmap( "folder" );
206 if( !fi->isReadable() ) 206 item->setPixmap( 0,pm );
207 pm = Resource::loadPixmap( "locked" ); 207 } else {
208 else 208 if( !fi->isReadable() )
209 pm = Resource::loadPixmap( "fileopen" ); 209 pm = Resource::loadPixmap( "locked" );
210 item->setPixmap( 0,pm); 210 else {
211 } 211 MimeType mt(fi->filePath());
212 if( fileL.find("->",0,TRUE) != -1) { 212 pm=mt.pixmap();
213 // overlay link image 213 if(pm.isNull())
214 QPixmap lnk = Resource::loadPixmap( "symlink" ); 214 pm = Resource::loadPixmap( "UnknownDocument-14" );
215 QPainter painter( &pm ); 215 item->setPixmap( 0,pm);
216 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); 216 }
217 pm.setMask( pm.createHeuristicMask( FALSE ) ); 217 }
218 item->setPixmap( 0, pm); 218 if( fileL.find("->",0,TRUE) != -1) {
219 // overlay link image
220 pm= Resource::loadPixmap( "folder" );
221 QPixmap lnk = Resource::loadPixmap( "symlink" );
222 QPainter painter( &pm );
223 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
224 pm.setMask( pm.createHeuristicMask( FALSE ) );
225 item->setPixmap( 0, pm);
226 }
219 } 227 }
220 }
221 isDir=FALSE; 228 isDir=FALSE;
222 ++it; 229 ++it;
223 } 230 }
224 ListView->setSorting( 3, FALSE); 231 ListView->setSorting( 3, FALSE);
225 QString currentPath = currentDir.canonicalPath(); 232 QString currentPath = currentDir.canonicalPath();
226 233
227 fillCombo( (const QString &)currentPath); 234 fillCombo( (const QString &)currentPath);
228// dirPathCombo->lineEdit()->setText(currentPath); 235// dirPathCombo->lineEdit()->setText(currentPath);
229 236
230// if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { 237// if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
231// dirPathCombo->clear(); 238// dirPathCombo->clear();
232// dirPathStringList.prepend(currentPath ); 239// dirPathStringList.prepend(currentPath );
233// dirPathCombo->insertStringList( dirPathStringList,-1); 240// dirPathCombo->insertStringList( dirPathStringList,-1);
234// } 241// }
235} 242}
236 243
237void fileBrowser::upDir() 244void fileBrowser::upDir()
238{ 245{
239 QString current = currentDir.canonicalPath(); 246 QString current = currentDir.canonicalPath();
240 QDir dir(current); 247 QDir dir(current);
241 dir.cdUp(); 248 dir.cdUp();
242 current = dir.canonicalPath(); 249 current = dir.canonicalPath();
243 chdir( current.latin1() ); 250 chdir( current.latin1() );
244 currentDir.cd( current, TRUE); 251 currentDir.cd( current, TRUE);
245 populateList(); 252 populateList();
246 update(); 253 update();
247} 254}
248 255
249// you may want to switch these 2 functions. I like single clicks 256// you may want to switch these 2 functions. I like single clicks
250void fileBrowser::listClicked(QListViewItem *selectedItem) 257void fileBrowser::listClicked(QListViewItem *selectedItem)
251{ 258{
252 QString strItem=selectedItem->text(0); 259 QString strItem=selectedItem->text(0);
253 QString strSize=selectedItem->text(1); 260 QString strSize=selectedItem->text(1);
254// qDebug("strItem is "+strItem); 261// qDebug("strItem is "+strItem);
255 strSize.stripWhiteSpace(); 262 strSize.stripWhiteSpace();
256// qDebug(strSize); 263// qDebug(strSize);
257 264
258 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink 265 if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
259 // is symlink 266 // is symlink
260 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); 267 QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
261// qDebug("strItem symlink is "+strItem2); 268// qDebug("strItem symlink is "+strItem2);
262 if(QDir(strItem2).exists() ) { 269 if(QDir(strItem2).exists() ) {
263 currentDir.cd(strItem2, TRUE); 270 currentDir.cd(strItem2, TRUE);
264 populateList(); 271 populateList();
265 } 272 }
266 } else { // not a symlink 273 } else { // not a symlink
267 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { 274 if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
268 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { 275 if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
269 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 276 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
270 currentDir.cd(strItem,FALSE); 277 currentDir.cd(strItem,FALSE);
271// qDebug("Path is "+strItem); 278// qDebug("Path is "+strItem);
272 populateList(); 279 populateList();
273 } else { 280 } else {
274 currentDir.cdUp(); 281 currentDir.cdUp();
275 populateList(); 282 populateList();
276 } 283 }
277 if(QDir(strItem).exists()){ 284 if(QDir(strItem).exists()){
278 currentDir.cd(strItem, TRUE); 285 currentDir.cd(strItem, TRUE);
279 populateList(); 286 populateList();
280 } 287 }
281 } else { 288 } else {
282 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); 289 strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
283 if( QFile::exists(strItem ) ) { 290 if( QFile::exists(strItem ) ) {
284//currentDir.canonicalPath() 291//currentDir.canonicalPath()
285 qDebug("We found our files!!"+strItem); 292 qDebug("We found our files!!"+strItem);
286 OnOK(); 293 OnOK();
287 } 294 }
288 } //end not symlink 295 } //end not symlink
289 chdir(strItem.latin1()); 296 chdir(strItem.latin1());
290 } 297 }
291} 298}
292 299
293void fileBrowser::OnOK() 300void fileBrowser::OnOK()
294{ 301{
295 QListViewItemIterator it1( ListView); 302 QListViewItemIterator it1( ListView);
296 for ( ; it1.current(); ++it1 ) { 303 for ( ; it1.current(); ++it1 ) {
297 if ( it1.current()->isSelected() ) { 304 if ( it1.current()->isSelected() ) {
298 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); 305 selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0));
299 qDebug("selected filename is "+selectedFileName); 306 qDebug("selected filename is "+selectedFileName);
300 fileList.append( selectedFileName ); 307 fileList.append( selectedFileName );
301 } 308 }
302 } 309 }
303 accept(); 310 accept();
304} 311}
305 312
306void fileBrowser::homeButtonPushed() { 313void fileBrowser::homeButtonPushed() {
307 QString current = QDir::homeDirPath(); 314 QString current = QDir::homeDirPath();
308 chdir( current.latin1() ); 315 chdir( current.latin1() );
309 currentDir.cd( current, TRUE); 316 currentDir.cd( current, TRUE);
310 populateList(); 317 populateList();
311 update(); 318 update();
312} 319}
313 320
314void fileBrowser::docButtonPushed() { 321void fileBrowser::docButtonPushed() {
315 QString current = QPEApplication::documentDir(); 322 QString current = QPEApplication::documentDir();
316 chdir( current.latin1() ); 323 chdir( current.latin1() );
317 currentDir.cd( current, TRUE); 324 currentDir.cd( current, TRUE);
318 populateList(); 325 populateList();
319 update(); 326 update();
320 327
321} 328}
322 329
323void fileBrowser::selectionChanged( const QString &select ) 330void fileBrowser::selectionChanged( const QString &select )
324{ 331{
325 if ( select == "Documents") { 332 if ( select == "Documents") {
326 FileStack->raiseWidget( fileSelector ); 333 FileStack->raiseWidget( fileSelector );
327 dirPathCombo->hide(); 334 dirPathCombo->hide();
328 cdUpButton->hide(); 335 cdUpButton->hide();
329 docButton->hide(); 336 docButton->hide();
330 homeButton->hide(); 337 homeButton->hide();
331 } else { 338 } else {
332 if ( select == "All files" ) 339 if ( select == "All files" )
333 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All); 340 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::All);
334 else 341 else
335 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); 342 currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
336 343
337 populateList(); 344 populateList();
338 update(); 345 update();
339 dirPathCombo->show(); 346 dirPathCombo->show();
340 cdUpButton->show(); 347 cdUpButton->show();
341 docButton->show(); 348 docButton->show();
342 homeButton->show(); 349 homeButton->show();
343 FileStack->raiseWidget( ListView ); 350 FileStack->raiseWidget( ListView );
344 } 351 }
345} 352}
346 353
347void fileBrowser::docOpen( const DocLnk &doc ) 354void fileBrowser::docOpen( const DocLnk &doc )
348{ 355{
349 fileList.append( doc.file().latin1() ); 356 fileList.append( doc.file().latin1() );
350 accept(); 357 accept();
351} 358}
352 359
353void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) 360void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i)
354{ 361{
355 switch (mouse) { 362 switch (mouse) {
356 case 1: 363 case 1:
357 break; 364 break;
358 case 2: 365 case 2:
359 showListMenu(item); 366 showListMenu(item);
360 break; 367 break;
361 }; 368 };
362} 369}
363 370
364void fileBrowser::showListMenu(QListViewItem *item) { 371void fileBrowser::showListMenu(QListViewItem *item) {
365 372
366 QPopupMenu m;// = new QPopupMenu( Local_View ); 373 QPopupMenu m;// = new QPopupMenu( Local_View );
367 if( item->text(0).find("/",0,TRUE)) 374 if( item->text(0).find("/",0,TRUE))
368 m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); 375 m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() ));
369 else 376 else
370 m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); 377 m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() ));
371 m.insertItem( tr( "Rescan" ), this, SLOT( populateList()() )); 378 m.insertItem( tr( "Rescan" ), this, SLOT( populateList()() ));
372 m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); 379 m.insertItem( tr( "Rename" ), this, SLOT( localRename() ));
373 m.insertSeparator(); 380 m.insertSeparator();
374 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); 381 m.insertItem( tr( "Delete" ), this, SLOT( localDelete() ));
375 m.exec( QCursor::pos() ); 382 m.exec( QCursor::pos() );
376 383
377} 384}
378 385
379void fileBrowser::doCd() { 386void fileBrowser::doCd() {
380 listClicked( ListView->currentItem()); 387 listClicked( ListView->currentItem());
381} 388}
382 389
383void fileBrowser::makDir() { 390void fileBrowser::makDir() {
384 InputDialog *fileDlg; 391 InputDialog *fileDlg;
385 fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); 392 fileDlg = new InputDialog(this,"Make Directory",TRUE, 0);
386 fileDlg->exec(); 393 fileDlg->exec();
387 if( fileDlg->result() == 1 ) { 394 if( fileDlg->result() == 1 ) {
388 QString filename = fileDlg->LineEdit1->text(); 395 QString filename = fileDlg->LineEdit1->text();
389 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); 396 currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
390 } 397 }
391 populateList(); 398 populateList();
392} 399}
393 400
394void fileBrowser::localRename() { 401void fileBrowser::localRename() {
395 QString curFile = ListView->currentItem()->text(0); 402 QString curFile = ListView->currentItem()->text(0);
396 InputDialog *fileDlg; 403 InputDialog *fileDlg;
397 fileDlg = new InputDialog(this,"Rename",TRUE, 0); 404 fileDlg = new InputDialog(this,"Rename",TRUE, 0);
398 fileDlg->inputText = curFile; 405 fileDlg->inputText = curFile;
399 fileDlg->exec(); 406 fileDlg->exec();
400 if( fileDlg->result() == 1 ) { 407 if( fileDlg->result() == 1 ) {
401 QString oldname = currentDir.canonicalPath() + "/" + curFile; 408 QString oldname = currentDir.canonicalPath() + "/" + curFile;
402 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; 409 QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist";
403 if( rename(oldname.latin1(), newName.latin1())== -1) 410 if( rename(oldname.latin1(), newName.latin1())== -1)
404 QMessageBox::message("Note","Could not rename"); 411 QMessageBox::message("Note","Could not rename");
405 } 412 }
406 populateList(); 413 populateList();
407} 414}
408 415
409void fileBrowser::localDelete() { 416void fileBrowser::localDelete() {
410 QString f = ListView->currentItem()->text(0); 417 QString f = ListView->currentItem()->text(0);
411 if(QDir(f).exists() ) { 418 if(QDir(f).exists() ) {
412 switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ 419 switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+