summaryrefslogtreecommitdiff
path: root/libopie/ofileselector.cc
authorzecke <zecke>2002-03-30 01:52:05 (UTC)
committer zecke <zecke>2002-03-30 01:52:05 (UTC)
commite49717bf2fa15791c2437a3ac69058ac909f0c6b (patch) (unidiff)
treeb1dc8c0b9a429518f90182f8ab3a2fdbfd760838 /libopie/ofileselector.cc
parent06063167a17f44b51295cf13d5c453b61b2c2a66 (diff)
downloadopie-e49717bf2fa15791c2437a3ac69058ac909f0c6b.zip
opie-e49717bf2fa15791c2437a3ac69058ac909f0c6b.tar.gz
opie-e49717bf2fa15791c2437a3ac69058ac909f0c6b.tar.bz2
nightly commits
A improved interface thanks to jowenn and some more implementation Actually I don't understand why it's not yet finished ;)
Diffstat (limited to 'libopie/ofileselector.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc168
1 files changed, 142 insertions, 26 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index b911d37..61ab2c4 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -40,2 +40,3 @@
40#include <qdir.h> 40#include <qdir.h>
41#include <qpainter.h>
41 42
@@ -46,2 +47,3 @@
46#include <qpe/mimetype.h> 47#include <qpe/mimetype.h>
48#include <qpe/resource.h>
47 49
@@ -49,2 +51,3 @@
49 51
52QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0;
50 53
@@ -91,2 +94,8 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString
91 94
95 m_dir = true;
96 m_files = true;
97
98 if(m_pixmaps == 0 ) // init the pixmaps
99 initPics();
100
92 m_lay = new QVBoxLayout(this); 101 m_lay = new QVBoxLayout(this);
@@ -95,3 +104,13 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString
95} 104}
105void OFileSelector::initPics()
106{
107 m_pixmaps = new QMap<QString,QPixmap>;
108 QPixmap pm = Resource::loadPixmap( "folder " );
109 QPixmap lnk = Resource::loadPixmap( "symlink" );
110 QPainter painter( &pm );
111 painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
112 pm.setMask( pm.createHeuristicMask( FALSE ) );
113 m_pixmaps->insert("dirsymlink", pm );
96 114
115};
97// let's initialize the gui 116// let's initialize the gui
@@ -151,3 +170,3 @@ void OFileSelector::init()
151 170
152void OFileSelector::setShowYesCancel( bool show ) 171void OFileSelector::setYesCancelVisible( bool show )
153{ 172{
@@ -166,3 +185,3 @@ void OFileSelector::setShowYesCancel( bool show )
166 185
167void OFileSelector::setShowToolbar( bool show ) 186void OFileSelector::setToolbarVisible( bool show )
168{ 187{
@@ -177,3 +196,3 @@ void OFileSelector::setShowToolbar( bool show )
177 196
178void OFileSelector::setShowPermissionBar( bool show ) 197void OFileSelector::setPermissionBarVisible( bool show )
179{ 198{
@@ -186,3 +205,3 @@ void OFileSelector::setShowPermissionBar( bool show )
186} 205}
187void OFileSelector::setShowLineEdit( bool show ) 206void OFileSelector::setLineEditVisible( bool show )
188{ 207{
@@ -201,3 +220,3 @@ void OFileSelector::setShowLineEdit( bool show )
201} 220}
202void OFileSelector::setShowChooser( bool show ) 221void OFileSelector::setChooserVisible( bool show )
203{ 222{
@@ -218,2 +237,16 @@ QCheckBox* OFileSelector::permissionCheckbox( )
218} 237}
238void OFileSelector::setCaseSensetive( bool caSe )
239{
240 m_case = caSe;
241 reparse();
242}
243void OFileSelector::setShowFiles(bool files ){
244 m_files = files;
245 reparse();
246}
247void OFileSelector::setPopupMenu(const QPopupMenu * )
248{
249 //delete oldpopup;
250
251}
219bool OFileSelector::setPermission( ) const 252bool OFileSelector::setPermission( ) const
@@ -231,10 +264,25 @@ void OFileSelector::setPermissionChecked( bool check )
231} 264}
232QString OFileSelector::selectedName( ) 265QString OFileSelector::selectedName( )const
233{ 266{
234 QString string; 267 QString string;
268 if( m_selector == NORMAL ){
269 const DocLnk *lnk = m_select->selected();
270 string = lnk->file();
271 }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) {
272 QListViewItem *item = m_View->currentItem();
273 if(item != 0 ){
274 string = item->text( 1 );
275 }
276 }
235 return string; 277 return string;
236} 278}
237const DocLnk* OFileSelector::selectedDocument( )const 279QStringList OFileSelector::selectedNames()const
238{ 280{
239 return 0; 281 QStringList list;
282
283}
284DocLnk OFileSelector::selectedDocument( )const
285{
286 DocLnk lnk;
287 return lnk;
240} 288}
@@ -288,3 +336,3 @@ void OFileSelector::reparse()
288{ 336{
289 if(m_View== 0) 337 if(m_View== 0 || m_selector == NORMAL)
290 return; 338 return;
@@ -293,3 +341,3 @@ void OFileSelector::reparse()
293 341
294 QDir dir( m_currentDir ); 342
295 QString currMime =m_mimeCheck->currentText(); 343 QString currMime =m_mimeCheck->currentText();
@@ -297,2 +345,3 @@ void OFileSelector::reparse()
297 if( m_autoMime ) { 345 if( m_autoMime ) {
346 QDir dir( m_currentDir );
298 m_mimetypes.clear(); 347 m_mimetypes.clear();
@@ -315,2 +364,3 @@ void OFileSelector::reparse()
315 } 364 }
365 m_mimetypes.prepend("All" );
316 m_mimeCheck->insertStringList(m_mimetypes ); 366 m_mimeCheck->insertStringList(m_mimetypes );
@@ -318,4 +368,5 @@ void OFileSelector::reparse()
318 }; 368 };
319 dir.setFilter(QDir::All ); 369 QDir dir( m_currentDir );
320 dir.setSorting(QDir::Name | QDir::DirsFirst ); 370 //dir.setFilter(-1 );
371 dir.setSorting(QDir::Name | QDir::DirsFirst | QDir::Reversed | QDir::IgnoreCase );
321 const QFileInfoList *list = dir.entryInfoList(); 372 const QFileInfoList *list = dir.entryInfoList();
@@ -324,17 +375,31 @@ void OFileSelector::reparse()
324 while( (fi=it.current()) ){ 375 while( (fi=it.current()) ){
376 if(fi->fileName() == ".." || fi->fileName() == "." ){
377 ++it;
378 continue;
379 }
380 qWarning("Test: %s", fi->fileName().latin1() );
325 if(fi->isSymLink() ){ 381 if(fi->isSymLink() ){
382 qWarning("Symlink %s", fi->fileName().latin1() );
326 QString file = fi->readLink(); 383 QString file = fi->readLink();
384 qWarning("File ->%s", file.latin1() );
327 for(int i=0; i<=4; i++ ){ // prepend from dos 385 for(int i=0; i<=4; i++ ){ // prepend from dos
328 QFileInfo info( file ); 386 QFileInfo info( fi->dirPath()+ "/"+file );
329 if( !info.exists() ){ 387 if( !info.exists() ){
330 addSymlink(m_currentDir, info.fileName(), TRUE ); 388 qWarning("does not exist" );
389 addSymlink(currMime, fi, TRUE );
331 break; 390 break;
332 }else if( info.isDir() ){ 391 }else if( info.isDir() ){
333 //addDir( ); 392 qWarning("isDir" );
393 addDir(currMime, fi, TRUE );
394 break;
334 }else if( info.isFile() ){ 395 }else if( info.isFile() ){
335 396 qWarning("isFile" );
397 addFile(currMime, fi, TRUE );
398 break;
336 }else if( info.isSymLink() ){ 399 }else if( info.isSymLink() ){
337 file = info.readLink(); 400 file = info.readLink();
401 qWarning("isSymlink again %s", file.latin1() );
338 }else if( i == 4 ){ // just insert it and have the symlink symbol 402 }else if( i == 4 ){ // just insert it and have the symlink symbol
339 addSymlink(m_currentDir, info.fileName() ); 403 addSymlink(currMime, fi );
404 qWarning("level too deep" );
340 } 405 }
@@ -342,6 +407,5 @@ void OFileSelector::reparse()
342 }else if( fi->isDir() ){ 407 }else if( fi->isDir() ){
343 408 addDir(currMime, fi );
344 }else if( fi->isFile() ) { // file ? 409 }else if( fi->isFile() ) { // file ?
345 410 addFile(currMime, fi );
346
347 } 411 }
@@ -349,7 +413,7 @@ void OFileSelector::reparse()
349 } 413 }
414 m_View->sort();
350} 415}
351QString OFileSelector::directory() 416QString OFileSelector::directory()const
352{ 417{
353 QString string; 418 return m_currentDir;
354 return string;
355} 419}
@@ -450,4 +514,8 @@ void OFileSelector::slotViewCheck(const QString &view ){
450 m_stack->addWidget( m_select, NORMAL ); 514 m_stack->addWidget( m_select, NORMAL );
451 m_stack->raiseWidget( NORMAL ); 515 m_mimeCheck->clear();
452 m_selector = NORMAL; 516 m_selector = NORMAL;
517 updateMimes();
518 m_mimeCheck->insertStringList( m_mimetypes );
519 m_stack->raiseWidget( NORMAL );
520
453 521
@@ -512,8 +580,56 @@ void OFileSelector::initializeListView()
512 header->hide(); 580 header->hide();
581 m_View->setSorting(1 );
513}; 582};
514 583
584void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ){
585 qWarning("Add Files" );
586 if( !m_files ){
587 qWarning("not mfiles" );
588 return;
589 }
515 590
591 MimeType type( info->filePath() );
592 if(mime == "All" ){
593 ;
594 }else if( type.id() != mime ) {
595 return;
596 }
597 QPixmap pix = type.pixmap();
598 if(pix.isNull() )
599 pix = Resource::loadPixmap( "UnknownDocument-14" );
600 if( symlink ) // have a blended pic sometime
601 new OFileSelectorItem( m_View, pix, info->fileName(),
602 info->lastModified().toString(),
603 QString::number(info->size() ),
604 info->dirPath(true) );
605 else
606 new OFileSelectorItem( m_View, pix, info->fileName(),
607 info->lastModified().toString(),
608 QString::number(info->size() ),
609 info->dirPath(true) );
610}
611void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
612{
613 if(!m_dir )
614 return;
615 //if( showDirs )
616 {
617 if( symlink){
618 QPixmap map = (*m_pixmaps)["dirsymlink" ];
619 qWarning("Symlink" );
620 new OFileSelectorItem(m_View, map,
621 info->fileName(), info->lastModified().toString() ,
622 QString::number(info->size() ),info->dirPath(true), true );
623 }else
624 new OFileSelectorItem(m_View, Resource::loadPixmap("folder" ),
625 info->fileName(), info->lastModified().toString(),
626 QString::number(info->size() ),info->dirPath(true), true );
516 627
517 628 }
518 629}
630void OFileSelector::setShowDirs(bool dir )
631{
632 m_dir = dir;
633 reparse();
634}
519 635