author | alwin <alwin> | 2005-03-24 13:28:49 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-24 13:28:49 (UTC) |
commit | 29da9a4477210843435cbea3ede0d520775fe1a5 (patch) (side-by-side diff) | |
tree | 487b26273bcdb8e29cd3f591955e8469d01c0da7 | |
parent | 4fbd94e2fd6432bb15e24e40be59426b309cbb9d (diff) | |
download | opie-29da9a4477210843435cbea3ede0d520775fe1a5.zip opie-29da9a4477210843435cbea3ede0d520775fe1a5.tar.gz opie-29da9a4477210843435cbea3ede0d520775fe1a5.tar.bz2 |
the filesystem-menu will executed when click on the filsystem-button
not when hold the pen on it.
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.cpp | 10 | ||||
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector_p.h | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp index 74aca96..dbba4b9 100644 --- a/libopie2/opieui/fileselector/ofileselector.cpp +++ b/libopie2/opieui/fileselector/ofileselector.cpp @@ -270,234 +270,240 @@ bool OFileSelectorItem::isLocked()const return m_locked; } QString OFileSelectorItem::directory()const { return m_dir; } bool OFileSelectorItem::isDir()const { return m_isDir; } QString OFileSelectorItem::path()const { return text( 1 ); } QString OFileSelectorItem::key( int id, bool )const { QString ke; /* * id = 0 ||id == 1 : Sort By Name but Directories at Top * id = 2 : Sort By Size: Prepend '0' to the key */ if( id == 0 || id == 1 ) { // name if( m_isDir ) { ke.append("0" ); ke.append( text(1) ); } else { ke.append("1" ); ke.append( text(1) ); } return ke; }else if(id == 2) { return text(2).rightJustify(20, '0'); }else return text( id ); } OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) :QWidget( parent ), m_sel( sel ) { m_all = false; QVBoxLayout* lay = new QVBoxLayout( this ); m_currentDir = startDir; /* * now we add a special bar * One Button For Up * Home * Doc * And a dropdown menu with FileSystems * FUTURE: one to change dir with lineedit * Bookmarks * Create Dir */ QHBox* box = new QHBox(this ); box->setBackgroundMode( PaletteButton ); box->setSpacing( 0 ); QToolButton *btn = new QToolButton( box ); btn->setIconSet( Resource::loadIconSet("up") ); connect(btn, SIGNAL(clicked() ), this, SLOT( cdUP() ) ); btn = new QToolButton( box ); btn->setIconSet( Resource::loadIconSet("home") ); connect(btn, SIGNAL(clicked() ), this, SLOT( cdHome() ) ); btn = new QToolButton( box ); btn->setIconSet( Resource::loadIconSet("DocsIcon") ); connect(btn, SIGNAL(clicked() ), this, SLOT(cdDoc() ) ); m_btnNew = new QToolButton( box ); m_btnNew->setIconSet( Resource::loadIconSet("new") ); connect(m_btnNew, SIGNAL(clicked() ), this, SLOT(slotNew() ) ); m_btnClose = new QToolButton( box ); m_btnClose->setIconSet( Resource::loadIconSet("close") ); connect(m_btnClose, SIGNAL(clicked() ), selector(), SIGNAL(closeMe() ) ); btn = new QToolButton( box ); btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") ); + m_fsButton = btn; /* let's fill device parts */ QPopupMenu* pop = new QPopupMenu(this); connect(pop, SIGNAL( activated(int) ), this, SLOT(slotFSActivated(int) ) ); 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_dev.insert( disk, path ); pop->insertItem( disk ); } m_fsPop = pop; - - btn->setPopup( pop ); + connect(btn,SIGNAL(pressed()),this,SLOT(slotFSpressed())); lay->addWidget( box ); m_view = new QListView( this ); m_view->installEventFilter(this); QPEApplication::setStylusOperation( m_view->viewport(), QPEApplication::RightOnHold); m_view->addColumn(" " ); m_view->addColumn(tr("Name"), 135 ); m_view->addColumn(tr("Size"), -1 ); m_view->addColumn(tr("Date"), 60 ); m_view->addColumn(tr("Mime Type"), -1 ); m_view->setSorting( 1 ); m_view->setAllColumnsShowFocus( TRUE ); lay->addWidget( m_view, 1000 ); connectSlots(); } +void OFileViewFileListView::slotFSpressed() +{ + m_fsPop->exec(QPoint( QCursor::pos().x(), QCursor::pos().y())); + m_fsButton->setDown(false); +} + OFileViewFileListView::~OFileViewFileListView() { } void OFileViewFileListView::slotNew() { DocLnk lnk; emit selector()->newSelected( lnk ); } OFileSelectorItem* OFileViewFileListView::currentItem()const { QListViewItem* item = m_view->currentItem(); if (!item ) return 0l; return static_cast<OFileSelectorItem*>(item); } void OFileViewFileListView::reread( bool all ) { m_view->clear(); if (selector()->showClose() ) m_btnClose->show(); else m_btnClose->hide(); if (selector()->showNew() ) m_btnNew->show(); else m_btnNew->hide(); m_mimes = selector()->currentMimeType(); m_all = all; QDir dir( m_currentDir ); if (!dir.exists() ) return; dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); int filter; filter = QDir::Dirs; if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR ) filter = filter | QDir::Files | QDir::All; if ( m_all ) filter = filter | QDir::Hidden; dir.setFilter( filter ); // now go through all files const QFileInfoList *list = dir.entryInfoList(); if (!list) { cdUP(); return; } QFileInfoListIterator it( *list ); QFileInfo *fi; while( (fi=it.current() ) ) { if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) { ++it; continue; } /* * It is a symlink we try to resolve it now but don't let us attack by DOS * */ if( fi->isSymLink() ) { QString file = createNewPath(fi->dirPath( true ),fi->readLink()); for( int i = 0; i<=4; i++) { // 5 tries to prevent dos QFileInfo info( file ); if( !info.exists() ) { addSymlink( fi, TRUE ); break; } else if( info.isDir() ) { addDir( fi, TRUE ); break; } else if( info.isFile() ) { addFile( fi, TRUE ); break; } else if( info.isSymLink() ) { diff --git a/libopie2/opieui/fileselector/ofileselector_p.h b/libopie2/opieui/fileselector/ofileselector_p.h index 15db916..94216a0 100644 --- a/libopie2/opieui/fileselector/ofileselector_p.h +++ b/libopie2/opieui/fileselector/ofileselector_p.h @@ -71,124 +71,126 @@ public: virtual QString directory()const = 0; virtual void reread() = 0; virtual int fileCount()const = 0; virtual DocLnk selectedDocument()const; virtual QWidget* widget( QWidget* parent) = 0; virtual void activate( const QString& ); QString name()const; bool allItem( const QString& )const; protected: OFileSelector* selector()const; void setName( const QString& ); bool showNew()const; bool showClose()const; MimeTypes mimeTypes()const; QStringList currentMimeType()const; QString startDirectory()const; protected: void ok(); void cancel(); void closeMe(); void fileSelected( const QString& ); void fileSelected( const DocLnk& ); void setCurrentFileName( const QString& ); QString currentFileName()const; private: QString m_name; OFileSelector* m_selector; }; /* THE Document View hosting a FileSelector*/ class ODocumentFileView : public OFileViewInterface { public: ODocumentFileView( OFileSelector* selector ); ~ODocumentFileView(); QString selectedName() const; QString selectedPath() const; QString directory() const; void reread(); int fileCount()const; DocLnk selectedDocument()const; QWidget* widget( QWidget* parent ); private: mutable FileSelector* m_selector; }; 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 ); ~OFileSelectorItem(); bool isLocked()const; bool isDir()const; QString directory()const; QString path()const; QString key(int id, bool )const; private: QString m_dir; bool m_isDir : 1; bool m_locked : 1; }; class OFileViewFileListView : public QWidget { Q_OBJECT public: OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector ); ~OFileViewFileListView(); OFileSelectorItem* currentItem()const; void reread( bool all = false ); int fileCount()const; QString currentDir()const; protected: bool eventFilter (QObject *o, QEvent *e); private slots: void slotNew(); // will emit newSelected void cdUP(); void cdHome(); void cdDoc(); void changeDir( const QString& ); void slotCurrentChanged( QListViewItem* ); void slotClicked(int, QListViewItem*, const QPoint&, int ); void slotFSActivated(int); + void slotFSpressed(); protected: OFileSelector* selector(); private: QMap<QString, QString> m_dev; bool m_all : 1; OFileSelector* m_sel; QPopupMenu* m_fsPop; bool compliesMime( const QString& ); QStringList m_mimes; // used in compy mime QString m_currentDir; QToolButton *m_btnNew, *m_btnClose; + QToolButton *m_fsButton; void connectSlots(); void addFile( QFileInfo* info, bool symlink = FALSE ); void addDir ( QFileInfo* info, bool symlink = FALSE ); void addSymlink( QFileInfo* info, bool = FALSE ); private: QListView* m_view; }; } } } #endif |