summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc36
1 files changed, 30 insertions, 6 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index 98290e0..824acf2 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -112,62 +112,64 @@ OFileSelector::OFileSelector( QWidget *wid, int mode, int selector,
112 m_currentDir = dirName; 112 m_currentDir = dirName;
113 init(); 113 init();
114 //QTimer::singleShot(6*1000, this, SLOT( slotTest() ) ); 114 //QTimer::singleShot(6*1000, this, SLOT( slotTest() ) );
115} 115}
116 116
117OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, 117OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent,
118 const char *name, bool newVisible, 118 const char *name, bool newVisible,
119 bool closeVisible ) 119 bool closeVisible )
120 : QWidget( parent, name ) 120 : QWidget( parent, name )
121{ 121{
122 if (!mimeFilter.isEmpty() ) { 122 if (!mimeFilter.isEmpty() ) {
123 QStringList list = QStringList::split(";", mimeFilter ); 123 QStringList list = QStringList::split(";", mimeFilter );
124 m_mimetypes.insert(mimeFilter, list ); 124 m_mimetypes.insert(mimeFilter, list );
125 } 125 }
126 initVars(); 126 initVars();
127 m_currentDir = QPEApplication::documentDir(); 127 m_currentDir = QPEApplication::documentDir();
128 m_mode = OPEN; 128 m_mode = FILESELECTOR;
129 m_selector = NORMAL; 129 m_selector = NORMAL;
130 m_shClose = closeVisible; 130 m_shClose = closeVisible;
131 m_shNew = newVisible; 131 m_shNew = newVisible;
132 m_shLne = false; 132 m_shLne = false;
133 m_shPerm = false; 133 m_shPerm = false;
134 m_shYesNo = false; 134 m_shYesNo = false;
135 init(); 135 init();
136 136
137 137
138} 138}
139 139
140OFileSelector::~OFileSelector() 140OFileSelector::~OFileSelector()
141{ 141{
142 142
143 143
144} 144}
145 145
146void OFileSelector::setNewVisible( bool visible ) 146void OFileSelector::setNewVisible( bool visible )
147{ 147{
148 m_shNew = visible; 148 m_shNew = visible;
149 if( m_selector == NORMAL ){ 149 if( m_selector == NORMAL ){
150 delete m_select; 150 delete m_select;
151 // we need to initialize but keep the selected mimetype 151 // we need to initialize but keep the selected mimetype
152 QString mime = currentMimeType(); 152 QString mime = currentMimeType();
153 m_select = new FileSelector( mime , 153 m_select = new FileSelector( mime ,
154 m_stack, "fileselector", 154 m_stack, "fileselector",
155 m_shNew, m_shClose); 155 m_shNew, m_shClose);
156 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), 156 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
157 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); 157 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
158 connect(m_select, SIGNAL(closeMe() ),
159 this, SIGNAL(closeMe() ) );
158 //connect to close me and other signals as well 160 //connect to close me and other signals as well
159 m_stack->addWidget( m_select, NORMAL ); 161 m_stack->addWidget( m_select, NORMAL );
160 }else{ 162 }else{
161 m_new->show(); 163 m_new->show();
162 } 164 }
163} 165}
164void OFileSelector::setCloseVisible( bool visible ) 166void OFileSelector::setCloseVisible( bool visible )
165{ 167{
166 m_shClose = visible; 168 m_shClose = visible;
167 if( m_selector == NORMAL ){ 169 if( m_selector == NORMAL ){
168 setNewVisible( m_shNew ); // yeah baby 170 setNewVisible( m_shNew ); // yeah baby
169 }else{ 171 }else{
170 m_close->show(); 172 m_close->show();
171 } 173 }
172} 174}
173void OFileSelector::reread() 175void OFileSelector::reread()
@@ -422,35 +424,37 @@ void OFileSelector::slotOk()
422{ 424{
423 emit ok(); 425 emit ok();
424} 426}
425void OFileSelector::slotCancel() 427void OFileSelector::slotCancel()
426{ 428{
427 emit cancel(); 429 emit cancel();
428} 430}
429void OFileSelector::slotViewCheck(const QString &sel) 431void OFileSelector::slotViewCheck(const QString &sel)
430{ 432{
431 if( sel == tr("Documents" ) ){ 433 if( sel == tr("Documents" ) ){
432 if( m_select == 0 ){ 434 if( m_select == 0 ){
433 // autMime? fix cause now we use All and not the current 435 // autMime? fix cause now we use All and not the current
434 // yes currentMime fixes that for us 436 // yes currentMime fixes that for us
435 QString mime = currentMimeType(); 437 QString mime = currentMimeType();
436 m_select = new FileSelector(mime, 438 m_select = new FileSelector(mime,
437 m_stack, "fileselector", 439 m_stack, "fileselector",
438 FALSE, FALSE); 440 m_shNew, m_shClose);
439 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), 441 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
440 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); 442 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
443 connect(m_select, SIGNAL(closeMe() ),
444 this, SIGNAL(closeMe() ) );
441 //connect to close me and other signals as well 445 //connect to close me and other signals as well
442 446
443 m_stack->addWidget( m_select, NORMAL ); 447 m_stack->addWidget( m_select, NORMAL );
444 } 448 }
445 m_stack->raiseWidget( NORMAL ); 449 m_stack->raiseWidget( NORMAL );
446 m_selector = NORMAL; 450 m_selector = NORMAL;
447 }else if( sel == tr("Files") ){ 451 }else if( sel == tr("Files") ){
448 m_selector = EXTENDED; 452 m_selector = EXTENDED;
449 initializeListView(); 453 initializeListView();
450 reparse(); 454 reparse();
451 m_stack->raiseWidget( EXTENDED ); 455 m_stack->raiseWidget( EXTENDED );
452 }else if( sel == tr("All Files") ){ 456 }else if( sel == tr("All Files") ){
453 m_selector = EXTENDED_ALL; 457 m_selector = EXTENDED_ALL;
454 initializeListView(); 458 initializeListView();
455 reparse(); 459 reparse();
456 m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter 460 m_stack->raiseWidget( EXTENDED ); // same widget other QFileFilter
@@ -481,36 +485,38 @@ void OFileSelector::slotMimeCheck(const QString &mime)
481{ 485{
482 if( m_selector == NORMAL ){ 486 if( m_selector == NORMAL ){
483 //if( m_autoMime ){ 487 //if( m_autoMime ){
484 QString newMimeType; 488 QString newMimeType;
485 if (mime != tr("All") ) { 489 if (mime != tr("All") ) {
486 QMap<QString, QStringList>::Iterator it; 490 QMap<QString, QStringList>::Iterator it;
487 it = m_mimetypes.find(mime); 491 it = m_mimetypes.find(mime);
488 if ( it != m_mimetypes.end() ) { 492 if ( it != m_mimetypes.end() ) {
489 newMimeType = it.data().join(";"); 493 newMimeType = it.data().join(";");
490 }else{ 494 }else{
491 newMimeType = mime; 495 newMimeType = mime;
492 } 496 }
493 } 497 }
494 delete m_select; 498 delete m_select;
495 m_select = new FileSelector( newMimeType, 499 m_select = new FileSelector( newMimeType,
496 m_stack, "fileselector", 500 m_stack, "fileselector",
497 FALSE, FALSE); 501 m_shNew, m_shClose);
498 502
499 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), 503 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
500 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); 504 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
505 connect(m_select, SIGNAL(closeMe() ),
506 this, SIGNAL(closeMe() ) );
501 //connect to close me and other signals as well 507 //connect to close me and other signals as well
502 m_stack->addWidget( m_select, NORMAL ); 508 m_stack->addWidget( m_select, NORMAL );
503 m_stack->raiseWidget( NORMAL ); 509 m_stack->raiseWidget( NORMAL );
504 updateMimes(); 510 updateMimes();
505 updateMimeCheck(); 511 updateMimeCheck();
506 m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); 512 m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
507 //} 513 //}
508 }else{ // others 514 }else{ // others
509 qWarning("Mime %s", mime.latin1() ); 515 qWarning("Mime %s", mime.latin1() );
510 if(m_shChooser ){ 516 if(m_shChooser ){
511 qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); 517 qWarning("Current Text %s", m_mimeCheck->currentText().latin1() );
512 //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); 518 //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) );
513 } 519 }
514 reparse(); 520 reparse();
515 } 521 }
516 522
@@ -547,36 +553,38 @@ void OFileSelector::init()
547{ 553{
548 m_lay = new QVBoxLayout( this ); 554 m_lay = new QVBoxLayout( this );
549 m_lay->setSpacing(0 ); 555 m_lay->setSpacing(0 );
550 556
551 m_stack = new QWidgetStack( this ); 557 m_stack = new QWidgetStack( this );
552 if( m_selector == NORMAL ){ 558 if( m_selector == NORMAL ){
553 QString mime; 559 QString mime;
554 if (!m_autoMime) { 560 if (!m_autoMime) {
555 if (!m_mimetypes.isEmpty() ) { 561 if (!m_mimetypes.isEmpty() ) {
556 QMap<QString, QStringList>::Iterator it; 562 QMap<QString, QStringList>::Iterator it;
557 it = m_mimetypes.begin(); // cause we're in the init 563 it = m_mimetypes.begin(); // cause we're in the init
558 mime = it.data().join(";"); 564 mime = it.data().join(";");
559 } 565 }
560 } 566 }
561 m_select = new FileSelector(mime, 567 m_select = new FileSelector(mime,
562 m_stack, "fileselector", 568 m_stack, "fileselector",
563 FALSE, FALSE); 569 m_shNew, m_shClose);
564 570
565 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), 571 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
566 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); 572 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
573 connect(m_select, SIGNAL(closeMe() ),
574 this, SIGNAL( closeMe() ) );
567 //connect to close me and other signals as well 575 //connect to close me and other signals as well
568 576
569 m_stack->addWidget( m_select, NORMAL ); 577 m_stack->addWidget( m_select, NORMAL );
570 m_stack->raiseWidget( NORMAL ); 578 m_stack->raiseWidget( NORMAL );
571 }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL 579 }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL
572 // and initializeListview will take care of those 580 // and initializeListview will take care of those
573 // toolbar get's generade in initializeListView 581 // toolbar get's generade in initializeListView
574 initializeListView( ); // will raise the widget as well 582 initializeListView( ); // will raise the widget as well
575 m_stack->raiseWidget( EXTENDED ); 583 m_stack->raiseWidget( EXTENDED );
576 } 584 }
577 m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch 585 m_lay->addWidget( m_stack, 100 ); // add to the layout 10 = stretch
578 586
579 if( m_shLne ) // the LineEdit with the current FileName 587 if( m_shLne ) // the LineEdit with the current FileName
580 initializeName(); 588 initializeName();
581 589
582 if( m_shPerm ) // the Permission QCheckBox 590 if( m_shPerm ) // the Permission QCheckBox
@@ -861,34 +869,34 @@ void OFileSelector::initializeListView()
861 const QString disk = (*it)->name(); 869 const QString disk = (*it)->name();
862 const QString path = (*it)->path(); 870 const QString path = (*it)->path();
863 m_location->insertItem(path+ "<-"+disk ); 871 m_location->insertItem(path+ "<-"+disk );
864 } 872 }
865 int count = m_location->count(); 873 int count = m_location->count();
866 m_location->insertItem( m_currentDir ); 874 m_location->insertItem( m_currentDir );
867 m_location->setCurrentItem( count ); 875 m_location->setCurrentItem( count );
868 // due to the New and Close button we can not simply hide m_boxToolBar to not show it 876 // due to the New and Close button we can not simply hide m_boxToolBar to not show it
869 if( !m_shTool ){ 877 if( !m_shTool ){
870 m_location->hide( ); 878 m_location->hide( );
871 m_up->hide( ); 879 m_up->hide( );
872 m_homeButton->hide( ); 880 m_homeButton->hide( );
873 m_docButton->hide( ); 881 m_docButton->hide( );
874 } 882 }
875 if(!m_shClose ) 883 if(!m_shClose )
876 m_close->hide(); 884 m_close->hide();
877 if(!m_shNew) 885 //if(!m_shNew)
878 m_close->hide(); 886 //m_close->hide();
879 887
880 } // off toolbar 888 } // off toolbar
881 // the Main ListView 889 // the Main ListView
882 // make a QWidgetStack first so Views can share the Toolbar 890 // make a QWidgetStack first so Views can share the Toolbar
883 m_View = new QListView( m_pseudo, "Extended view"); 891 m_View = new QListView( m_pseudo, "Extended view");
884 QPEApplication::setStylusOperation( m_View->viewport(), 892 QPEApplication::setStylusOperation( m_View->viewport(),
885 QPEApplication::RightOnHold); 893 QPEApplication::RightOnHold);
886 m_View->addColumn(" " ); 894 m_View->addColumn(" " );
887 m_View->addColumn(tr("Name"), 135 ); 895 m_View->addColumn(tr("Name"), 135 );
888 m_View->addColumn(tr("Size"), -1 ); 896 m_View->addColumn(tr("Size"), -1 );
889 m_View->addColumn(tr("Date"), 60 ); 897 m_View->addColumn(tr("Date"), 60 );
890 m_View->addColumn(tr("Mime Type"), -1 ); 898 m_View->addColumn(tr("Mime Type"), -1 );
891 QHeader *header = m_View->header(); 899 QHeader *header = m_View->header();
892 header->hide(); 900 header->hide();
893 m_View->setSorting( 1 ); 901 m_View->setSorting( 1 );
894 m_View->setAllColumnsShowFocus( TRUE ); 902 m_View->setAllColumnsShowFocus( TRUE );
@@ -1009,61 +1017,74 @@ void OFileSelector::slotFileSelected( const QString &string )
1009} 1017}
1010void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) 1018void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
1011{ 1019{
1012 slotFileSelected( lnk.name() ); 1020 slotFileSelected( lnk.name() );
1013 // emit fileSelected( lnk ); 1021 // emit fileSelected( lnk );
1014} 1022}
1015void OFileSelector::slotSelectionChanged() 1023void OFileSelector::slotSelectionChanged()
1016{ 1024{
1017 1025
1018} 1026}
1019void OFileSelector::slotCurrentChanged(QListViewItem* item ) 1027void OFileSelector::slotCurrentChanged(QListViewItem* item )
1020{ 1028{
1021 if( item == 0 ) 1029 if( item == 0 )
1022 return; 1030 return;
1023 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { 1031 if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) {
1024 OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;) 1032 OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;)
1033 qWarning("current changed");
1025 if(!sel->isDir() ){ 1034 if(!sel->isDir() ){
1026 if( m_shLne ) 1035 if( m_shLne )
1027 m_edit->setText( sel->text(1) ); 1036 m_edit->setText( sel->text(1) );
1037
1038 if (m_mode == FILESELECTOR ) {
1039 QStringList str = QStringList::split("->", sel->text(1) );
1040 QString path =sel->directory() + "/" + str[0].stripWhiteSpace();
1041 emit fileSelected(path );
1042 DocLnk lnk( path );
1043 emit fileSelected(lnk );
1044 }
1028 } 1045 }
1029 } 1046 }
1030} 1047}
1031void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int) 1048void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &, int)
1032{ 1049{
1033 if ( item == 0 ) 1050 if ( item == 0 )
1034 return; 1051 return;
1035 1052
1036 if( button != Qt::LeftButton ) 1053 if( button != Qt::LeftButton )
1037 return; 1054 return;
1038 1055
1039 switch( m_selector ){ 1056 switch( m_selector ){
1040 default: 1057 default:
1041 break; 1058 break;
1042 case EXTENDED: // fall through 1059 case EXTENDED: // fall through
1043 case EXTENDED_ALL:{ 1060 case EXTENDED_ALL:{
1044 OFileSelectorItem *sel = (OFileSelectorItem*)item; 1061 OFileSelectorItem *sel = (OFileSelectorItem*)item;
1045 if(!sel->isLocked() ){ 1062 if(!sel->isLocked() ){
1046 QStringList str = QStringList::split("->", sel->text(1) ); 1063 QStringList str = QStringList::split("->", sel->text(1) );
1047 if( sel->isDir() ){ 1064 if( sel->isDir() ){
1048 cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); 1065 cd( sel->directory() + "/" + str[0].stripWhiteSpace() );
1049 // if MODE Dir m_shLne set the Text 1066 // if MODE Dir m_shLne set the Text
1050 }else{ 1067 }else{
1051 if( m_shLne ) 1068 if( m_shLne )
1052 m_edit->setText( str[0].stripWhiteSpace() ); 1069 m_edit->setText( str[0].stripWhiteSpace() );
1070 qWarning("selected here in slot clicked");
1053 emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() ); 1071 emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() );
1072 DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() );
1073 qWarning("file selected");
1074 emit fileSelected( lnk );
1054 } 1075 }
1055 } 1076 }
1056 break; 1077 break;
1057 } 1078 }
1058 } 1079 }
1059} 1080}
1060void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) 1081void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int )
1061{ 1082{
1062 if( item == 0 ) 1083 if( item == 0 )
1063 return; 1084 return;
1064 1085
1065 if( button != Qt::RightButton ) 1086 if( button != Qt::RightButton )
1066 return; 1087 return;
1067 slotContextMenu( item ); 1088 slotContextMenu( item );
1068} 1089}
1069void OFileSelector::slotContextMenu( QListViewItem *item) 1090void OFileSelector::slotContextMenu( QListViewItem *item)
@@ -1071,32 +1092,35 @@ void OFileSelector::slotContextMenu( QListViewItem *item)
1071 1092
1072} 1093}
1073void OFileSelector::slotChangedDir() 1094void OFileSelector::slotChangedDir()
1074{ 1095{
1075 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1096 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1076 if(sel->isDir() ){ 1097 if(sel->isDir() ){
1077 QStringList str = QStringList::split("->", sel->text(1) ); 1098 QStringList str = QStringList::split("->", sel->text(1) );
1078 cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); 1099 cd( sel->directory() + "/" + str[0].stripWhiteSpace() );
1079 } 1100 }
1080} 1101}
1081void OFileSelector::slotOpen() 1102void OFileSelector::slotOpen()
1082{ 1103{
1083 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1104 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1084 if(!sel->isDir() ){ 1105 if(!sel->isDir() ){
1085 QStringList str = QStringList::split("->", sel->text(1) ); 1106 QStringList str = QStringList::split("->", sel->text(1) );
1086 slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() ); 1107 slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() );
1108 qWarning("slot open");
1109 // DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() );
1110 //emit fileSelected( lnk );
1087 } 1111 }
1088} 1112}
1089void OFileSelector::slotRescan() 1113void OFileSelector::slotRescan()
1090{ 1114{
1091 1115
1092} 1116}
1093void OFileSelector::slotRename() 1117void OFileSelector::slotRename()
1094{ 1118{
1095 reparse(); 1119 reparse();
1096} 1120}
1097void OFileSelector::slotDelete() 1121void OFileSelector::slotDelete()
1098{ 1122{
1099 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); 1123 OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem();
1100 QStringList list = QStringList::split("->", sel->text(1) ); 1124 QStringList list = QStringList::split("->", sel->text(1) );
1101 if( sel->isDir() ){ 1125 if( sel->isDir() ){
1102 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry 1126 QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry