-rw-r--r-- | libopie/TODO | 4 | ||||
-rw-r--r-- | libopie/ofileselector.cc | 187 | ||||
-rw-r--r-- | libopie/ofileselector.h | 9 |
3 files changed, 183 insertions, 17 deletions
diff --git a/libopie/TODO b/libopie/TODO index c1bf6d1..a4e1ada 100644 --- a/libopie/TODO +++ b/libopie/TODO @@ -8,3 +8,4 @@ - OFileSelector - - DocLnk when not in Document Mode + - DocLnk when not in Document Mode ( and vice versa ) + - MultipleDocuments - TreeView have a own OFileSelectorItem for this @@ -14,2 +15,3 @@ - debug + - new Dirs created inside the listview diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index b583125..14f035e 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc @@ -51,2 +51,3 @@ #include <qpe/resource.h> +#include <qpe/storage.h> @@ -118,2 +119,5 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString + m_pseudo = 0; + m_pseudoLayout = 0; + m_dir = true; @@ -121,2 +125,3 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString m_custom = 0; + m_showPopup = true; @@ -231,7 +236,15 @@ void OFileSelector::setToolbarVisible( bool show ) return; - /* if( show ){ - - }else { - - }*/ + if(!m_shTool ){ + delete m_boxToolbar; + delete m_homeButton; + delete m_docButton; + delete m_location; + delete m_up; + m_boxToolbar = 0; + m_homeButton = 0; + m_docButton = 0; + m_location = 0; + m_up = 0; + }; + updateLay();// overkill fix it } @@ -420,3 +433,21 @@ void OFileSelector::reparse() //dir.setFilter(-1 ); - dir.setSorting(QDir::Name | QDir::DirsFirst | QDir::Reversed | QDir::IgnoreCase ); + int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; + if( m_case ) + sort = QDir::IgnoreCase; + dir.setSorting( sort ); + + int filter; + /* if( m_dir && !m_files) + filter |= QDir::Dirs; + else if( !m_dir && m_files ) + filter |= QDir::Files; + else + filter |= QDir::All; + */ + if( m_selector == EXTENDED_ALL ) + filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; + else + filter = QDir::Files | QDir::Dirs | QDir::All; + dir.setFilter( filter ); + const QFileInfoList *list = dir.entryInfoList(); @@ -556,5 +587,21 @@ void OFileSelector::slotViewCheck(const QString &view ){ // check if we're the current widget and return - if( m_View != 0) // delete 0 shouldn't crash but it did :( + if( m_View != 0) { // delete 0 shouldn't crash but it did :( delete m_View; + delete m_boxToolbar; + delete m_homeButton; + delete m_docButton; + delete m_location; + delete m_up; + delete m_pseudo; + delete m_pseudoLayout; + } m_View = 0; + m_boxToolbar = 0; + m_homeButton = 0; + m_docButton = 0; + m_location = 0; + m_up = 0; + m_pseudo = 0; + m_pseudoLayout = 0; + delete m_select; @@ -576,2 +623,18 @@ void OFileSelector::slotViewCheck(const QString &view ){ m_View = 0; + + delete m_boxToolbar; + delete m_homeButton; + delete m_docButton; + delete m_location; + delete m_up; + delete m_pseudo; + delete m_pseudoLayout; + m_boxToolbar = 0; + m_homeButton = 0; + m_docButton = 0; + m_location = 0; + m_up = 0; + m_pseudo = 0; + m_pseudoLayout = 0; + m_selector = EXTENDED; @@ -587,2 +650,17 @@ void OFileSelector::slotViewCheck(const QString &view ){ m_View = 0; + delete m_boxToolbar; + delete m_homeButton; + delete m_docButton; + delete m_location; + delete m_up; + delete m_pseudo; + delete m_pseudoLayout; + m_boxToolbar = 0; + m_homeButton = 0; + m_docButton = 0; + m_location = 0; + m_up = 0; + m_pseudo = 0; + m_pseudoLayout = 0; + m_selector = EXTENDED_ALL; @@ -613,6 +691,65 @@ void OFileSelector::updateMimes() // lets check which mode is active void OFileSelector::initializeListView() -{ - m_View = new QListView(m_stack, "Extended view" ); - m_stack->addWidget( m_View, EXTENDED ); +{ + // just to make sure but clean it up better FIXME + delete m_View; + m_View = 0; + delete m_boxToolbar; + delete m_homeButton; + delete m_docButton; + delete m_location; + delete m_up; + delete m_pseudo; + delete m_pseudoLayout; + m_boxToolbar = 0; + m_homeButton = 0; + m_docButton = 0; + m_location = 0; + m_up = 0; + m_pseudo = 0; + m_pseudoLayout = 0; + // time for the toolbar + m_pseudo = new QWidget(m_stack, "Pseudo Widget"); + m_pseudoLayout = new QVBoxLayout(m_pseudo ); + if(m_shTool ){ + m_boxToolbar = new QHBoxLayout( ); + m_boxToolbar->setAutoAdd( true ); + m_location = new QComboBox(m_pseudo ); + + m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton"); + m_up->setMinimumSize( QSize( 20, 20 ) ); + m_up->setMaximumSize( QSize( 20, 20 ) ); + connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); + m_up->setFlat(TRUE); + + m_homeButton = new QPushButton(Resource::loadIconSet("home") , "", m_pseudo); + m_homeButton->setMinimumSize( QSize( 20, 20 ) ); + m_homeButton->setMaximumSize( QSize( 20, 20 ) ); + connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); + m_homeButton->setFlat(TRUE); + + m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", m_pseudo,"docsButton"); + m_docButton->setMinimumSize( QSize( 20, 20 ) ); + m_docButton->setMaximumSize( QSize( 20, 20 ) ); + connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); + m_docButton->setFlat(TRUE); + + m_boxToolbar->addWidget(m_location ); + m_boxToolbar->addWidget(m_up ); + m_boxToolbar->addWidget(m_homeButton ); + m_boxToolbar->addWidget(m_docButton ); + m_pseudoLayout->addLayout(m_boxToolbar ); + // lets fill the combobox + StorageInfo storage; + const QList<FileSystem> &fs = storage.fileSystems(); + QListIterator<FileSystem> it ( fs ); + for( ; it.current(); ++it ){ + const QString disk = (*it)->name(); + const QString path = (*it)->path(); + m_location->insertItem(path+ "<-"+disk ); + } + }; + m_View = new QListView(m_pseudo, "Extended view" ); + m_stack->addWidget( m_pseudo, EXTENDED ); m_stack->raiseWidget( EXTENDED ); + m_pseudoLayout->addWidget(m_View ); QPEApplication::setStylusOperation( m_View->viewport(),QPEApplication::RightOnHold); @@ -637,2 +774,4 @@ void OFileSelector::initializeListView() this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); + + }; @@ -799,2 +938,5 @@ void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoin { + if (item == 0 ) + return; + if( button != Qt::RightButton ) @@ -807,2 +949,5 @@ void OFileSelector::slotContextMenu(QListViewItem *item) qWarning("context menu" ); + if( item ==0 || !m_showPopup ) + return; + if( m_custom !=0){ @@ -811,2 +956,8 @@ void OFileSelector::slotContextMenu(QListViewItem *item) QPopupMenu menu; + QAction up; + up.setText("cd up"); + up.addTo( &menu ); + connect(&up, SIGNAL(activated() ), + this, SLOT(cdUP() ) ); + QAction act; @@ -827,3 +978,3 @@ void OFileSelector::slotContextMenu(QListViewItem *item) rescan.addTo( &menu ); - connect(&act, SIGNAL(activated() ), + connect(&rescan, SIGNAL(activated() ), this, SLOT(slotRescan() ) ); @@ -833,3 +984,3 @@ void OFileSelector::slotContextMenu(QListViewItem *item) rename.addTo( &menu ); - connect(&act, SIGNAL(activated() ), + connect(&rename, SIGNAL(activated() ), this, SLOT(slotRename() ) ); @@ -840,3 +991,3 @@ void OFileSelector::slotContextMenu(QListViewItem *item) delItem.addTo(&menu ); - connect(&act, SIGNAL(activated() ), + connect(&delItem, SIGNAL(activated() ), this, SLOT(slotDelete() ) ); @@ -897,3 +1048,11 @@ void OFileSelector::slotDelete() - +void OFileSelector::cdUP() +{ + QDir dir( m_currentDir ); + dir.cdUp(); + if(dir.exists() ){ + m_currentDir = dir.absPath(); + reparse(); + } +} diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index 458e552..b91c0ea 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h @@ -157,3 +157,4 @@ class OFileSelector : public QWidget { - + bool showPopup()const { return m_showPopup; }; + void setShowPopup( bool pop ) { m_showPopup = pop; }; void setPopupMenu( QPopupMenu * ); @@ -197,3 +198,3 @@ class OFileSelector : public QWidget { private: -int m_mode, m_selector; + int m_mode, m_selector; QComboBox *m_location, *m_mimeCheck, *m_viewCheck; @@ -203,2 +204,4 @@ int m_mode, m_selector; QCheckBox *m_checkPerm; + QWidget *m_pseudo; + QVBoxLayout *m_pseudoLayout; @@ -232,2 +235,3 @@ int m_mode, m_selector; bool m_files:1; + bool m_showPopup:1; @@ -264,2 +268,3 @@ private slots: virtual void slotDelete(); + virtual void cdUP(); |