-rw-r--r-- | libopie/ofileselector.cc | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index 824acf2..3c3a6c4 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc @@ -301,67 +301,71 @@ void OFileSelector::setSelector(int mode ) { QString text; switch( mode ){ case NORMAL: text = tr("Documents"); break; case EXTENDED: text = tr("Files"); break; case EXTENDED_ALL: text = tr("All Files"); break; } slotViewCheck( text ); } void OFileSelector::setPopupMenu(QPopupMenu *popup ) { m_custom = popup; m_showPopup = true; } //void OFileSelector::updateL QString OFileSelector::selectedName() const { QString name; if( m_selector == NORMAL ){ const DocLnk *lnk = m_select->selected(); name = lnk->file(); delete lnk; }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ - QListViewItem *item = m_View->currentItem(); - if( item != 0 ) - name = m_currentDir + "/" + item->text( 1 ); + if ( m_shLne ) { + name = m_currentDir + "/" +m_edit->text(); + }else{ + QListViewItem *item = m_View->currentItem(); + if( item != 0 ) + name = m_currentDir + "/" + item->text( 1 ); + } }else { // installed view ; } return name; } QStringList OFileSelector::selectedNames()const { QStringList list; if( m_selector == NORMAL ){ list << selectedName(); }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { list << selectedName(); // FIXME implement multiple Selections } return list; } /** If mode is set to the Dir selection this will return the selected path. * * */ QString OFileSelector::selectedPath()const { QString path; if( m_selector == NORMAL ){ path = QPEApplication::documentDir(); }else if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ ; } return path; } QStringList OFileSelector::selectedPaths() const { QStringList list; @@ -492,91 +496,112 @@ void OFileSelector::slotMimeCheck(const QString &mime) if ( it != m_mimetypes.end() ) { newMimeType = it.data().join(";"); }else{ newMimeType = mime; } } delete m_select; m_select = new FileSelector( newMimeType, m_stack, "fileselector", m_shNew, m_shClose); connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); connect(m_select, SIGNAL(closeMe() ), this, SIGNAL(closeMe() ) ); //connect to close me and other signals as well m_stack->addWidget( m_select, NORMAL ); m_stack->raiseWidget( NORMAL ); updateMimes(); updateMimeCheck(); m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); //} }else{ // others qWarning("Mime %s", mime.latin1() ); if(m_shChooser ){ qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); } reparse(); } } +/* + * Ok if a non dir gets inserted into this combobox + * we need to change it + * QFileInfo and dirPath will give us the right Dir + */ void OFileSelector::slotLocationActivated(const QString &file) { - cd(file.left(file.find("<-",0,TRUE))); - reparse(); + qWarning("slotLocationActivated"); + QString name = file.left( file.find("<-", 0, TRUE ) ); + QFileInfo info( name ); + if ( info.isFile() ) + cd(info.dirPath( TRUE ) ); //absolute + else + cd(name ); + reparse(); } void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) { QStringList pathList; bool underDog = FALSE; for(int i=0;i<count;i++) { pathList << m_location->text(i); if( m_location->text(i) == currentPath) underDog = TRUE; } if( !underDog) { m_location->clear(); if( currentPath.left(2)=="//") pathList.append( currentPath.right(currentPath.length()-1) ); else pathList.append( currentPath ); m_location->insertStringList( pathList,-1); } } +/* + * Do not crash anymore + * don't try to change dir to a file + */ void OFileSelector::locationComboChanged() { - cd( m_location->lineEdit()->text()); - reparse(); + QFileInfo info( m_location->lineEdit()->text() ); + qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); + if (info.isFile() ) + cd(info.dirPath(TRUE) ); //absolute path + else + cd( m_location->lineEdit()->text() ); + + reparse(); } void OFileSelector::init() { m_lay = new QVBoxLayout( this ); m_lay->setSpacing(0 ); m_stack = new QWidgetStack( this ); if( m_selector == NORMAL ){ QString mime; if (!m_autoMime) { if (!m_mimetypes.isEmpty() ) { QMap<QString, QStringList>::Iterator it; it = m_mimetypes.begin(); // cause we're in the init mime = it.data().join(";"); } } m_select = new FileSelector(mime, m_stack, "fileselector", m_shNew, m_shClose); connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); connect(m_select, SIGNAL(closeMe() ), this, SIGNAL( closeMe() ) ); //connect to close me and other signals as well m_stack->addWidget( m_select, NORMAL ); m_stack->raiseWidget( NORMAL ); }else{ // we're in init so it will be EXTENDED or EXTENDED_ALL // and initializeListview will take care of those // toolbar get's generade in initializeListView initializeListView( ); // will raise the widget as well |