summaryrefslogtreecommitdiff
path: root/libopie2/opieui/fileselector/ofileselector.cpp
Unidiff
Diffstat (limited to 'libopie2/opieui/fileselector/ofileselector.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index 346eeae..e8d502f 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -521,24 +521,32 @@ bool OFileViewFileListView::eventFilter (QObject *, QEvent *e)
521 if ( e->type() == QEvent::KeyPress ) 521 if ( e->type() == QEvent::KeyPress )
522 { 522 {
523 QKeyEvent *k = (QKeyEvent *)e; 523 QKeyEvent *k = (QKeyEvent *)e;
524 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) 524 if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
525 { 525 {
526 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); 526 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0);
527 return true; 527 return true;
528 } 528 }
529 } 529 }
530 return false; 530 return false;
531} 531}
532 532
533/**
534 * @return true if the item show all files or directories
535 */
536bool OFileViewFileListView::allItem( const QString& item )const
537{
538 return m_sel->allItem( item );
539}
540
533void OFileViewFileListView::connectSlots() 541void OFileViewFileListView::connectSlots()
534{ 542{
535 connect(m_view, SIGNAL(clicked(QListViewItem*) ), 543 connect(m_view, SIGNAL(clicked(QListViewItem*) ),
536 this, SLOT(slotCurrentChanged(QListViewItem*) ) ); 544 this, SLOT(slotCurrentChanged(QListViewItem*) ) );
537 connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), 545 connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),
538 this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); 546 this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) );
539} 547}
540 548
541void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) 549void OFileViewFileListView::slotCurrentChanged( QListViewItem* item)
542{ 550{
543 if (!item) 551 if (!item)
544 return; 552 return;
@@ -808,25 +816,25 @@ int OFileViewFileSystem::fileCount()const
808 816
809QWidget* OFileViewFileSystem::widget( QWidget* parent ) 817QWidget* OFileViewFileSystem::widget( QWidget* parent )
810{ 818{
811 if (!m_view ) 819 if (!m_view )
812 { 820 {
813 m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); 821 m_view = new OFileViewFileListView( parent, startDirectory(), selector() );
814 } 822 }
815 return m_view; 823 return m_view;
816} 824}
817 825
818void OFileViewFileSystem::activate( const QString& str) 826void OFileViewFileSystem::activate( const QString& str)
819{ 827{
820 m_all = ( str.find( "All" ) != -1 ); 828 m_all = m_view->allItem( str );
821} 829}
822 830
823 831
824} 832}
825/* Selector */ 833/* Selector */
826/** 834/**
827 * @short new and complete c'tor 835 * @short new and complete c'tor
828 * 836 *
829 * Create a OFileSelector to let the user select a file. It can 837 * Create a OFileSelector to let the user select a file. It can
830 * either be used to open a file, select a save name in a dir or 838 * either be used to open a file, select a save name in a dir or
831 * as a dropin for the FileSelector. 839 * as a dropin for the FileSelector.
832 * 840 *
@@ -858,24 +866,26 @@ OFileSelector::OFileSelector( QWidget* parent, int mode, int sel,
858 bool showNew, bool showClose) 866 bool showNew, bool showClose)
859 :QWidget( parent, "OFileSelector" ) 867 :QWidget( parent, "OFileSelector" )
860{ 868{
861 m_current = 0; 869 m_current = 0;
862 m_shNew = showNew; 870 m_shNew = showNew;
863 m_shClose = showClose; 871 m_shClose = showClose;
864 m_mimeType = mimetypes; 872 m_mimeType = mimetypes;
865 m_startDir = dirName; 873 m_startDir = dirName;
866 874
867 m_mode = mode; 875 m_mode = mode;
868 m_selector = sel; 876 m_selector = sel;
869 877
878 m_allList = new QStringList();
879
870 initUI(); 880 initUI();
871 m_lneEdit->setText( fileName ); 881 m_lneEdit->setText( fileName );
872 initMime(); 882 initMime();
873 initViews(); 883 initViews();
874 884
875 QString str; 885 QString str;
876 switch ( m_selector ) 886 switch ( m_selector )
877 { 887 {
878 default: 888 default:
879 case Normal: 889 case Normal:
880 if ( m_mode == DIRECTORYSELECTOR ) 890 if ( m_mode == DIRECTORYSELECTOR )
881 str = QObject::tr("Directories"); 891 str = QObject::tr("Directories");
@@ -1014,28 +1024,30 @@ void OFileSelector::initViews()
1014 } 1024 }
1015 1025
1016 connect(m_cmbView, SIGNAL(activated(const QString&) ), 1026 connect(m_cmbView, SIGNAL(activated(const QString&) ),
1017 this, SLOT(slotViewChange(const QString&) ) ); 1027 this, SLOT(slotViewChange(const QString&) ) );
1018 1028
1019 /* see above why add both */ 1029 /* see above why add both */
1020 OFileViewInterface* in = new OFileViewFileSystem( this ); 1030 OFileViewInterface* in = new OFileViewFileSystem( this );
1021 1031
1022 if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) 1032 if ( m_mode == OFileSelector::DIRECTORYSELECTOR )
1023 { 1033 {
1024 m_views.insert( QObject::tr("Directories"), in ); 1034 m_views.insert( QObject::tr("Directories"), in );
1025 m_views.insert( QObject::tr("All Directories"), in ); 1035 m_views.insert( QObject::tr("All Directories"), in );
1036 m_allList->append( QObject::tr("All Directories") );
1026 } else { 1037 } else {
1027 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); 1038 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) );
1028 m_views.insert( QObject::tr("Files"), in ); 1039 m_views.insert( QObject::tr("Files"), in );
1029 m_views.insert( QObject::tr("All Files"), in ); 1040 m_views.insert( QObject::tr("All Files"), in );
1041 m_allList->append( QObject::tr("All Files") );
1030 } 1042 }
1031} 1043}
1032 1044
1033void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) { 1045void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) {
1034 m_viewsPtr.append( iface ); 1046 m_viewsPtr.append( iface );
1035} 1047}
1036 1048
1037 1049
1038/** 1050/**
1039 * d'tor 1051 * d'tor
1040 */ 1052 */
1041OFileSelector::~OFileSelector() 1053OFileSelector::~OFileSelector()
@@ -1137,24 +1149,32 @@ int OFileSelector::mode()const
1137 return m_mode; 1149 return m_mode;
1138} 1150}
1139 1151
1140 1152
1141/** 1153/**
1142 * @return the Selector of the OFileSelector 1154 * @return the Selector of the OFileSelector
1143 */ 1155 */
1144int OFileSelector::selector()const 1156int OFileSelector::selector()const
1145{ 1157{
1146 return m_selector; 1158 return m_selector;
1147} 1159}
1148 1160
1161/**
1162 * @return true if the item show all files or directories
1163 */
1164bool OFileSelector::allItem( const QString& item )const
1165{
1166 return ( m_allList->findIndex( item ) != -1 );
1167}
1168
1149QStringList OFileSelector::currentMimeType()const 1169QStringList OFileSelector::currentMimeType()const
1150{ 1170{
1151 return m_mimeType[m_cmbMime->currentText()]; 1171 return m_mimeType[m_cmbMime->currentText()];
1152} 1172}
1153 1173
1154void OFileSelector::slotMimeTypeChanged() 1174void OFileSelector::slotMimeTypeChanged()
1155{ 1175{
1156 reread(); 1176 reread();
1157} 1177}
1158 1178
1159void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) 1179void OFileSelector::slotDocLnkBridge( const DocLnk& lnk)
1160{ 1180{
@@ -1166,33 +1186,33 @@ void OFileSelector::slotDocLnkBridge( const DocLnk& lnk)
1166void OFileSelector::slotFileBridge( const QString& str) 1186void OFileSelector::slotFileBridge( const QString& str)
1167{ 1187{
1168 DocLnk lnk( str ); 1188 DocLnk lnk( str );
1169 emit fileSelected( lnk ); 1189 emit fileSelected( lnk );
1170} 1190}
1171 1191
1172void OFileSelector::slotViewChange( const QString& view ) 1192void OFileSelector::slotViewChange( const QString& view )
1173{ 1193{
1174 OFileViewInterface* interface = m_views[view]; 1194 OFileViewInterface* interface = m_views[view];
1175 if (!interface) 1195 if (!interface)
1176 return; 1196 return;
1177 1197
1178 interface->activate( view );
1179 if (m_current) 1198 if (m_current)
1180 m_stack->removeWidget( m_current->widget( m_stack ) ); 1199 m_stack->removeWidget( m_current->widget( m_stack ) );
1181 1200
1182 static int id = 1; 1201 static int id = 1;
1183 1202
1184 m_stack->addWidget( interface->widget(m_stack), id ); 1203 m_stack->addWidget( interface->widget(m_stack), id );
1185 m_stack->raiseWidget( id ); 1204 m_stack->raiseWidget( id );
1186 1205
1206 interface->activate( view );
1187 interface->reread(); 1207 interface->reread();
1188 m_current = interface; 1208 m_current = interface;
1189 1209
1190 id++; 1210 id++;
1191} 1211}
1192 1212
1193void OFileSelector::setNewVisible( bool b ) 1213void OFileSelector::setNewVisible( bool b )
1194{ 1214{
1195 m_shNew = b; 1215 m_shNew = b;
1196 currentView()->reread(); 1216 currentView()->reread();
1197} 1217}
1198 1218