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 /libopie2/opieui | |
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 | 18 | ||||
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector_p.h | 2 |
2 files changed, 14 insertions, 6 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 @@ -46,50 +46,50 @@ /* QT */ #include <qcombobox.h> #include <qdir.h> #include <qhbox.h> #include <qheader.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qlistview.h> #include <qpopupmenu.h> #include <qwidgetstack.h> #include <qregexp.h> #include <qobjectlist.h> using namespace Opie::Ui::Internal; namespace Opie { namespace Ui { namespace Internal { /* * Create a path by adding a '/'/QDir::seperator in between * base and ending, but only if base is not empty */ static inline QString createNewPath(const QString& base, const QString &ending) { - return base == QString::fromLatin1("/") ? - base + ending : base + "/" + ending; + return base == QString::fromLatin1("/") ? + base + ending : base + "/" + ending; } OFileViewInterface::OFileViewInterface( OFileSelector* _selector ) : m_selector( _selector ) { selector()->registerView( this ); } OFileViewInterface::~OFileViewInterface() {} QString OFileViewInterface::name()const { return m_name; } void OFileViewInterface::setName( const QString& name ) { m_name = name; } OFileSelector* OFileViewInterface::selector()const { @@ -267,68 +267,68 @@ OFileSelectorItem::~OFileSelectorItem() 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'); + 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 ); @@ -342,90 +342,96 @@ OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& st 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() ) 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 @@ -143,52 +143,54 @@ private: }; 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 |