Diffstat (limited to 'libopie/ofileselector/ofilelistview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/ofileselector/ofilelistview.cpp | 85 |
1 files changed, 84 insertions, 1 deletions
diff --git a/libopie/ofileselector/ofilelistview.cpp b/libopie/ofileselector/ofilelistview.cpp index 7108a5b..bb15764 100644 --- a/libopie/ofileselector/ofilelistview.cpp +++ b/libopie/ofileselector/ofilelistview.cpp @@ -1,25 +1,50 @@ +#include <qheader.h> + #include <qpe/mimetype.h> #include <qpe/resource.h> +#include <qpe/qpeapplication.h> #include "ofileselector.h" #include "ofileselectoritem.h" #include "ofilelistview.h" OFileListView::OFileListView( QWidget* parent, OFileSelector* sel) : QListView( parent ), OFileView( sel ) { - + QPEApplication::setStylusOperation( viewport(), + QPEApplication::RightOnHold); + addColumn(" " ); + addColumn(tr("Name"), 135 ); + addColumn(tr("Size"), -1 ); + addColumn(tr("Date"), 60 ); + addColumn(tr("Mime Type"), -1 ); + QHeader *head = header(); + head->hide(); + setSorting( 1 ); + setAllColumnsShowFocus( TRUE ); + + connect(this, SIGNAL(selectionChanged() ), + this, SLOT(slotSelectionChanged() ) ); + + connect(this, SIGNAL(currentChanged(QListViewItem *) ), + this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); + + connect(this, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), + this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); + + connect(this, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), + this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); } OFileListView::~OFileListView() { } void OFileListView::clear() { QListView::clear(); } void OFileListView::addFile( const QString&, QFileInfo* info, bool isSymlink ) { MimeType type( info->absFilePath() ); QPixmap pix = type.pixmap(); @@ -114,12 +139,70 @@ QStringList OFileListView::selectedNames()const { } QString OFileListView::selectedPath()const { return QString::null; } QStringList OFileListView::selectedPaths()const { QStringList list; list << selectedPath(); return list; } int OFileListView::fileCount() { return childCount(); } +void OFileListView::sort() { + QListView::sort(); +} +void OFileListView::slotSelectionChanged() { + +} +void OFileListView::slotCurrentChanged( QListViewItem* item) { + if (!item ) + return; + + OFileSelectorItem* sel = (OFileSelectorItem*) item; + + qWarning("current changed"); + if(!sel->isDir() ){ + updateLine( sel->text(1) ); + + if (selector()->mode() == OFileSelector::Fileselector ) { + QStringList str = QStringList::split("->", sel->text(1) ); + QString path =sel->directory() + "/" + str[0].stripWhiteSpace(); + DocLnk lnk( path ); + fileSelected(lnk ); + fileSelected( path ); + } + } +} +void OFileListView::slotClicked( int button, QListViewItem* item, + const QPoint&, int ) { + if ( !item ) + return; + + if( button != Qt::LeftButton ) + return; + + OFileSelectorItem *sel = (OFileSelectorItem*)item; + + if(!sel->isLocked() ){ + QStringList str = QStringList::split("->", sel->text(1) ); + if( sel->isDir() ){ + changedDir( sel->directory() + "/" + str[0].stripWhiteSpace() ); + }else{ + updateLine( str[0].stripWhiteSpace() ); + QString path = sel->directory(); + path += "/"; + path += str[0].stripWhiteSpace(); + + DocLnk lnk( path ); + fileSelected( path ); + fileSelected( lnk ); + } + } +} +void OFileListView::slotRightButton( int button, QListViewItem* item, + const QPoint&, int ) { + if (!item || (button != Qt::RightButton )) + return; + + /* raise contextmenu */ +} |