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