author | llornkcor <llornkcor> | 2002-04-24 03:22:24 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-24 03:22:24 (UTC) |
commit | 219994e9d1de70b44c994ccee57060741f22d428 (patch) (side-by-side diff) | |
tree | 2acfcae2a6bfc432266ee1d0cb76285a95fe683f | |
parent | c9159a3d5192799f5b2911d13337f04f50b1ac5a (diff) | |
download | opie-219994e9d1de70b44c994ccee57060741f22d428.zip opie-219994e9d1de70b44c994ccee57060741f22d428.tar.gz opie-219994e9d1de70b44c994ccee57060741f22d428.tar.bz2 |
fixed location combo showing redundant directories and multiple seperators
-rw-r--r-- | libopie/ofileselector.cc | 123 | ||||
-rw-r--r-- | libopie/ofileselector.h | 15 |
2 files changed, 111 insertions, 27 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index cb18039..d1f1e1f 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc @@ -43,4 +43,6 @@ #include <qpopupmenu.h> #include <qcursor.h> +#include <qstringlist.h> +#include <qmessagebox.h> #include <qpe/qpeapplication.h> @@ -135,4 +137,5 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString m_edit->setText( fileName ); } + void OFileSelector::initPics() { @@ -152,5 +155,6 @@ void OFileSelector::initPics() m_pixmaps->insert("symlinkedlocked", pm2 ); -}; +} + // let's initialize the gui /** @@ -180,4 +184,5 @@ void OFileSelector::delItems() } } + void OFileSelector::init() { @@ -217,5 +222,5 @@ void OFileSelector::init() -}; +} void OFileSelector::setYesCancelVisible( bool show ) @@ -262,4 +267,5 @@ void OFileSelector::setPermissionBarVisible( bool show ) updateLay(); } + void OFileSelector::setLineEditVisible( bool show ) { @@ -277,4 +283,5 @@ void OFileSelector::setLineEditVisible( bool show ) updateLay(); } + void OFileSelector::setChooserVisible( bool show ) { @@ -290,8 +297,10 @@ void OFileSelector::setChooserVisible( bool show ) updateLay(); } + QCheckBox* OFileSelector::permissionCheckbox( ) { return m_checkPerm; } + void OFileSelector::setCaseSensetive( bool caSe ) { @@ -299,8 +308,10 @@ void OFileSelector::setCaseSensetive( bool caSe ) reparse(); } + void OFileSelector::setShowFiles(bool files ){ m_files = files; reparse(); } + void OFileSelector::setPopupMenu(QPopupMenu *pop ) { @@ -308,4 +319,5 @@ void OFileSelector::setPopupMenu(QPopupMenu *pop ) m_custom = pop; } + bool OFileSelector::setPermission( ) const { @@ -315,4 +327,5 @@ bool OFileSelector::setPermission( ) const return m_checkPerm->isChecked(); } + void OFileSelector::setPermissionChecked( bool check ) { @@ -321,4 +334,5 @@ void OFileSelector::setPermissionChecked( bool check ) m_checkPerm->setChecked( check ); } + QString OFileSelector::selectedName( )const { @@ -335,4 +349,5 @@ QString OFileSelector::selectedName( )const return string; } + QStringList OFileSelector::selectedNames()const { @@ -340,4 +355,5 @@ QStringList OFileSelector::selectedNames()const return list; } + DocLnk OFileSelector::selectedDocument( )const { @@ -386,4 +402,5 @@ void OFileSelector::updateLay() m_checkPerm->setChecked(check ); } + // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve // insert QListViewItems with the right options @@ -433,4 +450,5 @@ void OFileSelector::reparse() m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); }; + QDir dir( m_currentDir ); //dir.setFilter(-1 ); @@ -498,16 +516,21 @@ void OFileSelector::reparse() m_View->sort(); } + QString OFileSelector::directory()const { - return m_currentDir; + QDir d( m_currentDir); + return d.absPath(); } + int OFileSelector::fileCount() { return 0; } + void OFileSelector::slotOk( ) { emit ok(); } + void OFileSelector::slotCancel( ) { @@ -527,4 +550,5 @@ void OFileSelector::initializeName() m_lay->addLayout(m_boxName); } + void OFileSelector::initializeYes() { @@ -542,4 +566,5 @@ void OFileSelector::initializeYes() } + void OFileSelector::initializeChooser() { @@ -571,4 +596,5 @@ void OFileSelector::initializeChooser() this, SLOT(slotMimeCheck(const QString & ) ) ); } + void OFileSelector::slotMimeCheck(const QString &view ){ if(m_selector == NORMAL ){ @@ -646,5 +672,5 @@ void OFileSelector::slotViewCheck(const QString &view ){ reparse(); }; -}; +} @@ -666,5 +692,6 @@ void OFileSelector::updateMimes() // lets check which mode is active ; } -}; +} + void OFileSelector::initializeListView() { @@ -694,4 +721,5 @@ void OFileSelector::initializeListView() m_boxToolbar->setAutoAdd( true ); m_location = new QComboBox(m_pseudo ); + connect( m_location, SIGNAL(activated(const QString &) ), this, SLOT( locationComboActivated(const QString & ) ) ); m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton"); @@ -806,4 +834,5 @@ void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ) dir, locked ); } + void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) { @@ -843,4 +872,5 @@ void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) } } + void OFileSelector::setShowDirs(bool dir ) { @@ -857,4 +887,5 @@ void OFileSelector::slotFileSelected(const QString &string ) // do AppLnk stuff } + void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) { @@ -862,4 +893,5 @@ void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) emit fileSelected( lnk ); } + void OFileSelector::slotSelectionChanged() // get the current items // fixme @@ -867,4 +899,5 @@ void OFileSelector::slotSelectionChanged() // get the current items qWarning("selection changed" ); } + void OFileSelector::slotCurrentChanged(QListViewItem *item ) { @@ -886,4 +919,5 @@ void OFileSelector::slotCurrentChanged(QListViewItem *item ) } } + // either select or change dir void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int ) @@ -902,17 +936,18 @@ void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint & QStringList str = QStringList::split("->", sel->text(1) ); if(sel->isDir() ){ - cd( sel->directory() + "/" + str[0] ); - }else{ - qWarning("file" ); - if(m_shLne ) - m_edit->setText(str[0] ); - emit fileSelected(str[0] ); - // emit DocLnk need to do it + cd( sel->directory() + "/" + str[0] ); + } else { + qWarning("file" ); + if(m_shLne ) + m_edit->setText(str[0] ); + emit fileSelected(str[0] ); + // emit DocLnk need to do it } - }else{ + } else { qWarning( "locked" ); } }; } + void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) { @@ -925,4 +960,5 @@ void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoin slotContextMenu(item); } + void OFileSelector::slotContextMenu(QListViewItem *item) { @@ -976,4 +1012,5 @@ void OFileSelector::slotContextMenu(QListViewItem *item) } } + bool OFileSelector::cd(const QString &str ) { @@ -981,9 +1018,9 @@ bool OFileSelector::cd(const QString &str ) QDir dir( str); if(dir.exists() ){ - m_currentDir = str; + m_currentDir = dir.absPath(); reparse(); if(m_shTool ){ - int count = m_location->count(); - m_location->insertItem(str ); + int count = m_location->count(); + insertLocationPath( str ,count ); m_location->setCurrentItem( count ); } @@ -993,4 +1030,19 @@ bool OFileSelector::cd(const QString &str ) } +void OFileSelector::insertLocationPath(const QString ¤tPath, int count) { + QStringList pathList; + for(int i=0;i<count;i++) { + pathList << m_location->text(i); + } + if( pathList.grep( currentPath,TRUE).isEmpty() ) { + m_location->clear(); + if( currentPath.left(2)=="//") + pathList.append( currentPath.right(currentPath.length()-1) ); + else + pathList.append( currentPath ); + m_location->insertStringList( pathList,-1); + } +} + void OFileSelector::slotChangedDir() { @@ -999,6 +1051,8 @@ void OFileSelector::slotChangedDir() QStringList str = QStringList::split("->", sel->text(1) ); cd( sel->directory() + "/" + str[0] ); + } } + void OFileSelector::slotOpen() { @@ -1009,12 +1063,15 @@ void OFileSelector::slotOpen() } } + void OFileSelector::slotRescan() { reparse(); } + void OFileSelector::slotRename() { // rename inline } + void OFileSelector::slotDelete() { @@ -1023,7 +1080,12 @@ void OFileSelector::slotDelete() QStringList list = QStringList::split("->", sel->text(1) ); if( sel->isDir() ){ - QString str = QString::fromLatin1("rm -rf ") + list[0]; - ::system(str.utf8().data() ); - }else{ + QString str = QString::fromLatin1("rm -rf ") + list[0]; //better safe than sorry + switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], + tr("Yes"),tr("No"),0,1,1) ) { + case 0: + ::system(str.utf8().data() ); + break; + } + } else { QFile::remove( list[0] ); } @@ -1040,18 +1102,37 @@ void OFileSelector::cdUP() reparse(); int count = m_location->count(); - m_location->insertItem(m_currentDir ); - m_location->setCurrentItem( count ); + insertLocationPath( m_currentDir,count ); + m_location->setCurrentItem( indexFromString(m_currentDir )); +//this wont work in all instances + // FIXME } } + +int OFileSelector::indexFromString(const QString &str) { + + for(int i=0;i< m_location->count();i++) { + if(str == m_location->text(i)) + return i; + } + return 0; +} + void OFileSelector::slotHome() { cd(QDir::homeDirPath() ); } + void OFileSelector::slotDoc() { cd(QDir::homeDirPath() + "/Documents" ); } + void OFileSelector::slotNavigate() { } + +void OFileSelector::locationComboActivated(const QString & file ) { + cd(file.left(file.find("<-",0,TRUE))); + reparse(); +} diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index 5e98a1e..81a9e63 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h @@ -68,6 +68,6 @@ class OFileSelectorItem : public QListViewItem { public: OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, - const QString &date, const QString &size, const QString &mDir, - bool isLocked=false, bool isDir=false ): QListViewItem(view) { + const QString &date, const QString &size, const QString &mDir, + bool isLocked=false, bool isDir=false ): QListViewItem(view) { setPixmap(0, pixmap ); setText(1, path ); @@ -95,9 +95,9 @@ class OFileSelectorItem : public QListViewItem { if( id == 0 || id == 1 ){ // name if( dir ){ - ke.append("0" ); - ke.append( text(1) ); + ke.append("0" ); + ke.append( text(1) ); }else{ - ke.append("1" ); - ke.append( text(1) ); + ke.append("1" ); + ke.append( text(1) ); } }else if( id == 2 ){ // size @@ -191,4 +191,7 @@ class OFileSelector : public QWidget { void slotViewCheck(const QString & ); void slotMimeCheck(const QString & ); + void locationComboActivated(const QString & ); + void insertLocationPath(const QString &, int); + int indexFromString(const QString &); protected: void init(); |