Diffstat (limited to 'libopie/ofileselector/ofilelistview.cpp') (more/less context) (show 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 @@ | |||
1 | 1 | ||
2 | #include <qheader.h> | ||
3 | |||
2 | #include <qpe/mimetype.h> | 4 | #include <qpe/mimetype.h> |
3 | #include <qpe/resource.h> | 5 | #include <qpe/resource.h> |
6 | #include <qpe/qpeapplication.h> | ||
4 | 7 | ||
5 | #include "ofileselector.h" | 8 | #include "ofileselector.h" |
6 | #include "ofileselectoritem.h" | 9 | #include "ofileselectoritem.h" |
7 | #include "ofilelistview.h" | 10 | #include "ofilelistview.h" |
8 | 11 | ||
9 | 12 | ||
10 | OFileListView::OFileListView( QWidget* parent, OFileSelector* sel) | 13 | OFileListView::OFileListView( QWidget* parent, OFileSelector* sel) |
11 | : QListView( parent ), OFileView( sel ) | 14 | : QListView( parent ), OFileView( sel ) |
12 | { | 15 | { |
13 | 16 | QPEApplication::setStylusOperation( viewport(), | |
17 | QPEApplication::RightOnHold); | ||
18 | addColumn(" " ); | ||
19 | addColumn(tr("Name"), 135 ); | ||
20 | addColumn(tr("Size"), -1 ); | ||
21 | addColumn(tr("Date"), 60 ); | ||
22 | addColumn(tr("Mime Type"), -1 ); | ||
23 | QHeader *head = header(); | ||
24 | head->hide(); | ||
25 | setSorting( 1 ); | ||
26 | setAllColumnsShowFocus( TRUE ); | ||
27 | |||
28 | connect(this, SIGNAL(selectionChanged() ), | ||
29 | this, SLOT(slotSelectionChanged() ) ); | ||
30 | |||
31 | connect(this, SIGNAL(currentChanged(QListViewItem *) ), | ||
32 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); | ||
33 | |||
34 | connect(this, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), | ||
35 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); | ||
36 | |||
37 | connect(this, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), | ||
38 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); | ||
14 | } | 39 | } |
15 | OFileListView::~OFileListView() { | 40 | OFileListView::~OFileListView() { |
16 | 41 | ||
17 | } | 42 | } |
18 | void OFileListView::clear() { | 43 | void OFileListView::clear() { |
19 | QListView::clear(); | 44 | QListView::clear(); |
20 | } | 45 | } |
21 | void OFileListView::addFile( const QString&, | 46 | void OFileListView::addFile( const QString&, |
22 | QFileInfo* info, | 47 | QFileInfo* info, |
23 | bool isSymlink ) { | 48 | bool isSymlink ) { |
24 | MimeType type( info->absFilePath() ); | 49 | MimeType type( info->absFilePath() ); |
25 | QPixmap pix = type.pixmap(); | 50 | QPixmap pix = type.pixmap(); |
@@ -114,12 +139,70 @@ QStringList OFileListView::selectedNames()const { | |||
114 | } | 139 | } |
115 | QString OFileListView::selectedPath()const { | 140 | QString OFileListView::selectedPath()const { |
116 | return QString::null; | 141 | return QString::null; |
117 | } | 142 | } |
118 | QStringList OFileListView::selectedPaths()const { | 143 | QStringList OFileListView::selectedPaths()const { |
119 | QStringList list; | 144 | QStringList list; |
120 | list << selectedPath(); | 145 | list << selectedPath(); |
121 | return list; | 146 | return list; |
122 | } | 147 | } |
123 | int OFileListView::fileCount() { | 148 | int OFileListView::fileCount() { |
124 | return childCount(); | 149 | return childCount(); |
125 | } | 150 | } |
151 | void OFileListView::sort() { | ||
152 | QListView::sort(); | ||
153 | } | ||
154 | void OFileListView::slotSelectionChanged() { | ||
155 | |||
156 | } | ||
157 | void OFileListView::slotCurrentChanged( QListViewItem* item) { | ||
158 | if (!item ) | ||
159 | return; | ||
160 | |||
161 | OFileSelectorItem* sel = (OFileSelectorItem*) item; | ||
162 | |||
163 | qWarning("current changed"); | ||
164 | if(!sel->isDir() ){ | ||
165 | updateLine( sel->text(1) ); | ||
166 | |||
167 | if (selector()->mode() == OFileSelector::Fileselector ) { | ||
168 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
169 | QString path =sel->directory() + "/" + str[0].stripWhiteSpace(); | ||
170 | DocLnk lnk( path ); | ||
171 | fileSelected(lnk ); | ||
172 | fileSelected( path ); | ||
173 | } | ||
174 | } | ||
175 | } | ||
176 | void OFileListView::slotClicked( int button, QListViewItem* item, | ||
177 | const QPoint&, int ) { | ||
178 | if ( !item ) | ||
179 | return; | ||
180 | |||
181 | if( button != Qt::LeftButton ) | ||
182 | return; | ||
183 | |||
184 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | ||
185 | |||
186 | if(!sel->isLocked() ){ | ||
187 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
188 | if( sel->isDir() ){ | ||
189 | changedDir( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
190 | }else{ | ||
191 | updateLine( str[0].stripWhiteSpace() ); | ||
192 | QString path = sel->directory(); | ||
193 | path += "/"; | ||
194 | path += str[0].stripWhiteSpace(); | ||
195 | |||
196 | DocLnk lnk( path ); | ||
197 | fileSelected( path ); | ||
198 | fileSelected( lnk ); | ||
199 | } | ||
200 | } | ||
201 | } | ||
202 | void OFileListView::slotRightButton( int button, QListViewItem* item, | ||
203 | const QPoint&, int ) { | ||
204 | if (!item || (button != Qt::RightButton )) | ||
205 | return; | ||
206 | |||
207 | /* raise contextmenu */ | ||
208 | } | ||