author | zecke <zecke> | 2002-09-15 21:22:18 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-15 21:22:18 (UTC) |
commit | 568c816cc66f1566b8be6ff8d246e7b1465ae61e (patch) (unidiff) | |
tree | 3c1d1f9ac7421ae27b18f580670ac1e1b8bf8a92 /libopie/ofileselector/ofilelistview.cpp | |
parent | f2594358208bb2ea826bbea6afb0b3aa35947378 (diff) | |
download | opie-568c816cc66f1566b8be6ff8d246e7b1465ae61e.zip opie-568c816cc66f1566b8be6ff8d246e7b1465ae61e.tar.gz opie-568c816cc66f1566b8be6ff8d246e7b1465ae61e.tar.bz2 |
ok basicly all old functions are available again
what's now missing is the code switching Listers
and views
toggling the toolbar
filter
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,37 +1,62 @@ | |||
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(); |
26 | QString dir; | 51 | QString dir; |
27 | QString name; | 52 | QString name; |
28 | bool locked = false; | 53 | bool locked = false; |
29 | 54 | ||
30 | if( pix.isNull() ) | 55 | if( pix.isNull() ) |
31 | pix = Resource::loadPixmap( "UnknownDocument-14"); | 56 | pix = Resource::loadPixmap( "UnknownDocument-14"); |
32 | 57 | ||
33 | dir = info->dirPath( true ); | 58 | dir = info->dirPath( true ); |
34 | 59 | ||
35 | if( isSymlink ) | 60 | if( isSymlink ) |
36 | name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); | 61 | name = info->fileName() + " -> " +info->dirPath() + "/" + info->readLink(); |
37 | else { | 62 | else { |
@@ -102,24 +127,82 @@ QWidget* OFileListView::widget() { | |||
102 | } | 127 | } |
103 | QString OFileListView::selectedName()const{ | 128 | QString OFileListView::selectedName()const{ |
104 | QListViewItem *item = currentItem(); | 129 | QListViewItem *item = currentItem(); |
105 | if (!item ) | 130 | if (!item ) |
106 | return QString::null; | 131 | return QString::null; |
107 | 132 | ||
108 | return item->text( 1 ); | 133 | return item->text( 1 ); |
109 | } | 134 | } |
110 | QStringList OFileListView::selectedNames()const { | 135 | QStringList OFileListView::selectedNames()const { |
111 | QStringList list; | 136 | QStringList list; |
112 | list << selectedName(); | 137 | list << selectedName(); |
113 | return list; | 138 | return list; |
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 | } | ||