author | alwin <alwin> | 2005-03-24 13:28:49 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-24 13:28:49 (UTC) |
commit | 29da9a4477210843435cbea3ede0d520775fe1a5 (patch) (unidiff) | |
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 | 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 | |||
@@ -1,1237 +1,1243 @@ | |||
1 | 1 | ||
2 | /* | 2 | /* |
3 | =. This file is part of the OPIE Project | 3 | =. This file is part of the OPIE Project |
4 | .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> | 4 | .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This library is free software; you can | 6 | _;:, .> :=|. This library is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This library is distributed in the hope that | 13 | .i_,=:_. -<s. This library is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | /* hacky but we need to get FileSelector::filter */ | 30 | /* hacky but we need to get FileSelector::filter */ |
31 | #define private public | 31 | #define private public |
32 | #include <qpe/fileselector.h> | 32 | #include <qpe/fileselector.h> |
33 | #undef private | 33 | #undef private |
34 | 34 | ||
35 | #include "ofileselector_p.h" | 35 | #include "ofileselector_p.h" |
36 | 36 | ||
37 | /* OPIE */ | 37 | /* OPIE */ |
38 | #include <opie2/ofileselector.h> | 38 | #include <opie2/ofileselector.h> |
39 | #include <opie2/odebug.h> | 39 | #include <opie2/odebug.h> |
40 | 40 | ||
41 | #include <qpe/qpeapplication.h> | 41 | #include <qpe/qpeapplication.h> |
42 | #include <qpe/mimetype.h> | 42 | #include <qpe/mimetype.h> |
43 | #include <qpe/resource.h> | 43 | #include <qpe/resource.h> |
44 | #include <qpe/storage.h> | 44 | #include <qpe/storage.h> |
45 | 45 | ||
46 | /* QT */ | 46 | /* QT */ |
47 | #include <qcombobox.h> | 47 | #include <qcombobox.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #include <qhbox.h> | 49 | #include <qhbox.h> |
50 | #include <qheader.h> | 50 | #include <qheader.h> |
51 | #include <qlabel.h> | 51 | #include <qlabel.h> |
52 | #include <qlayout.h> | 52 | #include <qlayout.h> |
53 | #include <qlineedit.h> | 53 | #include <qlineedit.h> |
54 | #include <qlistview.h> | 54 | #include <qlistview.h> |
55 | #include <qpopupmenu.h> | 55 | #include <qpopupmenu.h> |
56 | #include <qwidgetstack.h> | 56 | #include <qwidgetstack.h> |
57 | #include <qregexp.h> | 57 | #include <qregexp.h> |
58 | #include <qobjectlist.h> | 58 | #include <qobjectlist.h> |
59 | 59 | ||
60 | using namespace Opie::Ui::Internal; | 60 | using namespace Opie::Ui::Internal; |
61 | 61 | ||
62 | namespace Opie { | 62 | namespace Opie { |
63 | namespace Ui { | 63 | namespace Ui { |
64 | namespace Internal { | 64 | namespace Internal { |
65 | /* | 65 | /* |
66 | * Create a path by adding a '/'/QDir::seperator in between | 66 | * Create a path by adding a '/'/QDir::seperator in between |
67 | * base and ending, but only if base is not empty | 67 | * base and ending, but only if base is not empty |
68 | */ | 68 | */ |
69 | static inline QString createNewPath(const QString& base, const QString &ending) { | 69 | static inline QString createNewPath(const QString& base, const QString &ending) { |
70 | return base == QString::fromLatin1("/") ? | 70 | return base == QString::fromLatin1("/") ? |
71 | base + ending : base + "/" + ending; | 71 | base + ending : base + "/" + ending; |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | OFileViewInterface::OFileViewInterface( OFileSelector* _selector ) | 75 | OFileViewInterface::OFileViewInterface( OFileSelector* _selector ) |
76 | : m_selector( _selector ) | 76 | : m_selector( _selector ) |
77 | { | 77 | { |
78 | selector()->registerView( this ); | 78 | selector()->registerView( this ); |
79 | } | 79 | } |
80 | 80 | ||
81 | OFileViewInterface::~OFileViewInterface() | 81 | OFileViewInterface::~OFileViewInterface() |
82 | {} | 82 | {} |
83 | 83 | ||
84 | QString OFileViewInterface::name()const | 84 | QString OFileViewInterface::name()const |
85 | { | 85 | { |
86 | return m_name; | 86 | return m_name; |
87 | } | 87 | } |
88 | 88 | ||
89 | void OFileViewInterface::setName( const QString& name ) | 89 | void OFileViewInterface::setName( const QString& name ) |
90 | { | 90 | { |
91 | m_name = name; | 91 | m_name = name; |
92 | } | 92 | } |
93 | 93 | ||
94 | OFileSelector* OFileViewInterface::selector()const | 94 | OFileSelector* OFileViewInterface::selector()const |
95 | { | 95 | { |
96 | return m_selector; | 96 | return m_selector; |
97 | } | 97 | } |
98 | 98 | ||
99 | DocLnk OFileViewInterface::selectedDocument()const | 99 | DocLnk OFileViewInterface::selectedDocument()const |
100 | { | 100 | { |
101 | return DocLnk( selectedName() ); | 101 | return DocLnk( selectedName() ); |
102 | } | 102 | } |
103 | 103 | ||
104 | bool OFileViewInterface::showNew()const | 104 | bool OFileViewInterface::showNew()const |
105 | { | 105 | { |
106 | return selector()->showNew(); | 106 | return selector()->showNew(); |
107 | } | 107 | } |
108 | 108 | ||
109 | bool OFileViewInterface::showClose()const | 109 | bool OFileViewInterface::showClose()const |
110 | { | 110 | { |
111 | return selector()->showClose(); | 111 | return selector()->showClose(); |
112 | } | 112 | } |
113 | 113 | ||
114 | MimeTypes OFileViewInterface::mimeTypes()const | 114 | MimeTypes OFileViewInterface::mimeTypes()const |
115 | { | 115 | { |
116 | return selector()->mimeTypes(); | 116 | return selector()->mimeTypes(); |
117 | } | 117 | } |
118 | 118 | ||
119 | QStringList OFileViewInterface::currentMimeType()const | 119 | QStringList OFileViewInterface::currentMimeType()const |
120 | { | 120 | { |
121 | return selector()->currentMimeType(); | 121 | return selector()->currentMimeType(); |
122 | } | 122 | } |
123 | 123 | ||
124 | void OFileViewInterface::activate( const QString& ) | 124 | void OFileViewInterface::activate( const QString& ) |
125 | { | 125 | { |
126 | // not implemented here | 126 | // not implemented here |
127 | } | 127 | } |
128 | 128 | ||
129 | void OFileViewInterface::ok() | 129 | void OFileViewInterface::ok() |
130 | { | 130 | { |
131 | emit selector()->ok(); | 131 | emit selector()->ok(); |
132 | } | 132 | } |
133 | 133 | ||
134 | void OFileViewInterface::cancel() | 134 | void OFileViewInterface::cancel() |
135 | { | 135 | { |
136 | emit selector()->cancel(); | 136 | emit selector()->cancel(); |
137 | } | 137 | } |
138 | 138 | ||
139 | void OFileViewInterface::closeMe() | 139 | void OFileViewInterface::closeMe() |
140 | { | 140 | { |
141 | emit selector()->closeMe(); | 141 | emit selector()->closeMe(); |
142 | } | 142 | } |
143 | 143 | ||
144 | void OFileViewInterface::fileSelected( const QString& str) | 144 | void OFileViewInterface::fileSelected( const QString& str) |
145 | { | 145 | { |
146 | emit selector()->fileSelected( str); | 146 | emit selector()->fileSelected( str); |
147 | } | 147 | } |
148 | 148 | ||
149 | void OFileViewInterface::fileSelected( const DocLnk& lnk) | 149 | void OFileViewInterface::fileSelected( const DocLnk& lnk) |
150 | { | 150 | { |
151 | emit selector()->fileSelected( lnk ); | 151 | emit selector()->fileSelected( lnk ); |
152 | } | 152 | } |
153 | 153 | ||
154 | void OFileViewInterface::setCurrentFileName( const QString& str ) | 154 | void OFileViewInterface::setCurrentFileName( const QString& str ) |
155 | { | 155 | { |
156 | selector()->m_lneEdit->setText( str ); | 156 | selector()->m_lneEdit->setText( str ); |
157 | } | 157 | } |
158 | 158 | ||
159 | QString OFileViewInterface::currentFileName()const | 159 | QString OFileViewInterface::currentFileName()const |
160 | { | 160 | { |
161 | return selector()->m_lneEdit->text(); | 161 | return selector()->m_lneEdit->text(); |
162 | } | 162 | } |
163 | 163 | ||
164 | QString OFileViewInterface::startDirectory()const | 164 | QString OFileViewInterface::startDirectory()const |
165 | { | 165 | { |
166 | return selector()->m_startDir; | 166 | return selector()->m_startDir; |
167 | } | 167 | } |
168 | 168 | ||
169 | bool OFileViewInterface::allItem( const QString& item )const | 169 | bool OFileViewInterface::allItem( const QString& item )const |
170 | { | 170 | { |
171 | return selector()->m_allList.contains( item ); | 171 | return selector()->m_allList.contains( item ); |
172 | } | 172 | } |
173 | 173 | ||
174 | 174 | ||
175 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) | 175 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) |
176 | :OFileViewInterface( selector ) | 176 | :OFileViewInterface( selector ) |
177 | { | 177 | { |
178 | m_selector = 0; | 178 | m_selector = 0; |
179 | setName( QObject::tr("Documents") ); | 179 | setName( QObject::tr("Documents") ); |
180 | } | 180 | } |
181 | 181 | ||
182 | ODocumentFileView::~ODocumentFileView() | 182 | ODocumentFileView::~ODocumentFileView() |
183 | { | 183 | { |
184 | } | 184 | } |
185 | 185 | ||
186 | QString ODocumentFileView::selectedName()const | 186 | QString ODocumentFileView::selectedName()const |
187 | { | 187 | { |
188 | if (!m_selector) | 188 | if (!m_selector) |
189 | return QString::null; | 189 | return QString::null; |
190 | 190 | ||
191 | return m_selector->selectedDocument().file(); | 191 | return m_selector->selectedDocument().file(); |
192 | } | 192 | } |
193 | 193 | ||
194 | QString ODocumentFileView::selectedPath()const | 194 | QString ODocumentFileView::selectedPath()const |
195 | { | 195 | { |
196 | return QPEApplication::documentDir(); | 196 | return QPEApplication::documentDir(); |
197 | } | 197 | } |
198 | 198 | ||
199 | QString ODocumentFileView::directory()const | 199 | QString ODocumentFileView::directory()const |
200 | { | 200 | { |
201 | return selectedPath(); | 201 | return selectedPath(); |
202 | } | 202 | } |
203 | 203 | ||
204 | void ODocumentFileView::reread() | 204 | void ODocumentFileView::reread() |
205 | { | 205 | { |
206 | if (!m_selector) | 206 | if (!m_selector) |
207 | return; | 207 | return; |
208 | 208 | ||
209 | m_selector->setNewVisible( showNew() ); | 209 | m_selector->setNewVisible( showNew() ); |
210 | m_selector->setCloseVisible( showClose() ); | 210 | m_selector->setCloseVisible( showClose() ); |
211 | m_selector->filter = currentMimeType().join(";"); | 211 | m_selector->filter = currentMimeType().join(";"); |
212 | m_selector->reread(); | 212 | m_selector->reread(); |
213 | } | 213 | } |
214 | 214 | ||
215 | int ODocumentFileView::fileCount()const | 215 | int ODocumentFileView::fileCount()const |
216 | { | 216 | { |
217 | if (!m_selector) | 217 | if (!m_selector) |
218 | return -1; | 218 | return -1; |
219 | 219 | ||
220 | return m_selector->fileCount(); | 220 | return m_selector->fileCount(); |
221 | } | 221 | } |
222 | 222 | ||
223 | DocLnk ODocumentFileView::selectedDocument()const | 223 | DocLnk ODocumentFileView::selectedDocument()const |
224 | { | 224 | { |
225 | if (!m_selector) | 225 | if (!m_selector) |
226 | return DocLnk(); | 226 | return DocLnk(); |
227 | 227 | ||
228 | return m_selector->selectedDocument(); | 228 | return m_selector->selectedDocument(); |
229 | } | 229 | } |
230 | 230 | ||
231 | QWidget* ODocumentFileView::widget( QWidget* parent ) | 231 | QWidget* ODocumentFileView::widget( QWidget* parent ) |
232 | { | 232 | { |
233 | if (!m_selector ) | 233 | if (!m_selector ) |
234 | { | 234 | { |
235 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); | 235 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); |
236 | QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ), | 236 | QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ), |
237 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); | 237 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); |
238 | QObject::connect(m_selector, SIGNAL(closeMe() ), | 238 | QObject::connect(m_selector, SIGNAL(closeMe() ), |
239 | selector(), SIGNAL(closeMe() ) ); | 239 | selector(), SIGNAL(closeMe() ) ); |
240 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ), | 240 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ), |
241 | selector(), SIGNAL(newSelected(const DocLnk&) ) ); | 241 | selector(), SIGNAL(newSelected(const DocLnk&) ) ); |
242 | } | 242 | } |
243 | 243 | ||
244 | return m_selector; | 244 | return m_selector; |
245 | } | 245 | } |
246 | 246 | ||
247 | /* | 247 | /* |
248 | * This is the file system view used | 248 | * This is the file system view used |
249 | * we use a QListView + QListViewItems for it | 249 | * we use a QListView + QListViewItems for it |
250 | */ | 250 | */ |
251 | 251 | ||
252 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, | 252 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, |
253 | const QString& path, const QString& date, | 253 | const QString& path, const QString& date, |
254 | const QString& size, const QString& dir, | 254 | const QString& size, const QString& dir, |
255 | bool isLocked, bool isDir ) | 255 | bool isLocked, bool isDir ) |
256 | : QListViewItem( view ), m_dir(dir), m_isDir(isDir), m_locked(isLocked) | 256 | : QListViewItem( view ), m_dir(dir), m_isDir(isDir), m_locked(isLocked) |
257 | { | 257 | { |
258 | setPixmap(0, pixmap ); | 258 | setPixmap(0, pixmap ); |
259 | setText(1, path ); | 259 | setText(1, path ); |
260 | setText(2, size ); | 260 | setText(2, size ); |
261 | setText(3, date ); | 261 | setText(3, date ); |
262 | } | 262 | } |
263 | 263 | ||
264 | OFileSelectorItem::~OFileSelectorItem() | 264 | OFileSelectorItem::~OFileSelectorItem() |
265 | { | 265 | { |
266 | } | 266 | } |
267 | 267 | ||
268 | bool OFileSelectorItem::isLocked()const | 268 | bool OFileSelectorItem::isLocked()const |
269 | { | 269 | { |
270 | return m_locked; | 270 | return m_locked; |
271 | } | 271 | } |
272 | 272 | ||
273 | QString OFileSelectorItem::directory()const | 273 | QString OFileSelectorItem::directory()const |
274 | { | 274 | { |
275 | return m_dir; | 275 | return m_dir; |
276 | } | 276 | } |
277 | 277 | ||
278 | bool OFileSelectorItem::isDir()const | 278 | bool OFileSelectorItem::isDir()const |
279 | { | 279 | { |
280 | return m_isDir; | 280 | return m_isDir; |
281 | } | 281 | } |
282 | 282 | ||
283 | QString OFileSelectorItem::path()const | 283 | QString OFileSelectorItem::path()const |
284 | { | 284 | { |
285 | return text( 1 ); | 285 | return text( 1 ); |
286 | } | 286 | } |
287 | 287 | ||
288 | QString OFileSelectorItem::key( int id, bool )const | 288 | QString OFileSelectorItem::key( int id, bool )const |
289 | { | 289 | { |
290 | QString ke; | 290 | QString ke; |
291 | 291 | ||
292 | /* | 292 | /* |
293 | * id = 0 ||id == 1 : Sort By Name but Directories at Top | 293 | * id = 0 ||id == 1 : Sort By Name but Directories at Top |
294 | * id = 2 : Sort By Size: Prepend '0' to the key | 294 | * id = 2 : Sort By Size: Prepend '0' to the key |
295 | */ | 295 | */ |
296 | if( id == 0 || id == 1 ) | 296 | if( id == 0 || id == 1 ) |
297 | { // name | 297 | { // name |
298 | if( m_isDir ) | 298 | if( m_isDir ) |
299 | { | 299 | { |
300 | ke.append("0" ); | 300 | ke.append("0" ); |
301 | ke.append( text(1) ); | 301 | ke.append( text(1) ); |
302 | } | 302 | } |
303 | else | 303 | else |
304 | { | 304 | { |
305 | ke.append("1" ); | 305 | ke.append("1" ); |
306 | ke.append( text(1) ); | 306 | ke.append( text(1) ); |
307 | } | 307 | } |
308 | return ke; | 308 | return ke; |
309 | }else if(id == 2) { | 309 | }else if(id == 2) { |
310 | return text(2).rightJustify(20, '0'); | 310 | return text(2).rightJustify(20, '0'); |
311 | }else | 311 | }else |
312 | return text( id ); | 312 | return text( id ); |
313 | 313 | ||
314 | } | 314 | } |
315 | 315 | ||
316 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) | 316 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) |
317 | :QWidget( parent ), m_sel( sel ) | 317 | :QWidget( parent ), m_sel( sel ) |
318 | { | 318 | { |
319 | m_all = false; | 319 | m_all = false; |
320 | QVBoxLayout* lay = new QVBoxLayout( this ); | 320 | QVBoxLayout* lay = new QVBoxLayout( this ); |
321 | m_currentDir = startDir; | 321 | m_currentDir = startDir; |
322 | 322 | ||
323 | /* | 323 | /* |
324 | * now we add a special bar | 324 | * now we add a special bar |
325 | * One Button For Up | 325 | * One Button For Up |
326 | * Home | 326 | * Home |
327 | * Doc | 327 | * Doc |
328 | * And a dropdown menu with FileSystems | 328 | * And a dropdown menu with FileSystems |
329 | * FUTURE: one to change dir with lineedit | 329 | * FUTURE: one to change dir with lineedit |
330 | * Bookmarks | 330 | * Bookmarks |
331 | * Create Dir | 331 | * Create Dir |
332 | */ | 332 | */ |
333 | QHBox* box = new QHBox(this ); | 333 | QHBox* box = new QHBox(this ); |
334 | box->setBackgroundMode( PaletteButton ); | 334 | box->setBackgroundMode( PaletteButton ); |
335 | box->setSpacing( 0 ); | 335 | box->setSpacing( 0 ); |
336 | 336 | ||
337 | QToolButton *btn = new QToolButton( box ); | 337 | QToolButton *btn = new QToolButton( box ); |
338 | btn->setIconSet( Resource::loadIconSet("up") ); | 338 | btn->setIconSet( Resource::loadIconSet("up") ); |
339 | connect(btn, SIGNAL(clicked() ), | 339 | connect(btn, SIGNAL(clicked() ), |
340 | this, SLOT( cdUP() ) ); | 340 | this, SLOT( cdUP() ) ); |
341 | 341 | ||
342 | btn = new QToolButton( box ); | 342 | btn = new QToolButton( box ); |
343 | btn->setIconSet( Resource::loadIconSet("home") ); | 343 | btn->setIconSet( Resource::loadIconSet("home") ); |
344 | connect(btn, SIGNAL(clicked() ), | 344 | connect(btn, SIGNAL(clicked() ), |
345 | this, SLOT( cdHome() ) ); | 345 | this, SLOT( cdHome() ) ); |
346 | 346 | ||
347 | btn = new QToolButton( box ); | 347 | btn = new QToolButton( box ); |
348 | btn->setIconSet( Resource::loadIconSet("DocsIcon") ); | 348 | btn->setIconSet( Resource::loadIconSet("DocsIcon") ); |
349 | connect(btn, SIGNAL(clicked() ), | 349 | connect(btn, SIGNAL(clicked() ), |
350 | this, SLOT(cdDoc() ) ); | 350 | this, SLOT(cdDoc() ) ); |
351 | 351 | ||
352 | m_btnNew = new QToolButton( box ); | 352 | m_btnNew = new QToolButton( box ); |
353 | m_btnNew->setIconSet( Resource::loadIconSet("new") ); | 353 | m_btnNew->setIconSet( Resource::loadIconSet("new") ); |
354 | connect(m_btnNew, SIGNAL(clicked() ), | 354 | connect(m_btnNew, SIGNAL(clicked() ), |
355 | this, SLOT(slotNew() ) ); | 355 | this, SLOT(slotNew() ) ); |
356 | 356 | ||
357 | 357 | ||
358 | m_btnClose = new QToolButton( box ); | 358 | m_btnClose = new QToolButton( box ); |
359 | m_btnClose->setIconSet( Resource::loadIconSet("close") ); | 359 | m_btnClose->setIconSet( Resource::loadIconSet("close") ); |
360 | connect(m_btnClose, SIGNAL(clicked() ), | 360 | connect(m_btnClose, SIGNAL(clicked() ), |
361 | selector(), SIGNAL(closeMe() ) ); | 361 | selector(), SIGNAL(closeMe() ) ); |
362 | 362 | ||
363 | btn = new QToolButton( box ); | 363 | btn = new QToolButton( box ); |
364 | btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") ); | 364 | btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") ); |
365 | 365 | ||
366 | m_fsButton = btn; | ||
366 | /* let's fill device parts */ | 367 | /* let's fill device parts */ |
367 | QPopupMenu* pop = new QPopupMenu(this); | 368 | QPopupMenu* pop = new QPopupMenu(this); |
368 | connect(pop, SIGNAL( activated(int) ), | 369 | connect(pop, SIGNAL( activated(int) ), |
369 | this, SLOT(slotFSActivated(int) ) ); | 370 | this, SLOT(slotFSActivated(int) ) ); |
370 | 371 | ||
371 | StorageInfo storage; | 372 | StorageInfo storage; |
372 | const QList<FileSystem> &fs = storage.fileSystems(); | 373 | const QList<FileSystem> &fs = storage.fileSystems(); |
373 | QListIterator<FileSystem> it(fs); | 374 | QListIterator<FileSystem> it(fs); |
374 | for ( ; it.current(); ++it ) | 375 | for ( ; it.current(); ++it ) |
375 | { | 376 | { |
376 | const QString disk = (*it)->name(); | 377 | const QString disk = (*it)->name(); |
377 | const QString path = (*it)->path(); | 378 | const QString path = (*it)->path(); |
378 | m_dev.insert( disk, path ); | 379 | m_dev.insert( disk, path ); |
379 | pop->insertItem( disk ); | 380 | pop->insertItem( disk ); |
380 | } | 381 | } |
381 | m_fsPop = pop; | 382 | m_fsPop = pop; |
382 | 383 | ||
383 | 384 | connect(btn,SIGNAL(pressed()),this,SLOT(slotFSpressed())); | |
384 | btn->setPopup( pop ); | ||
385 | 385 | ||
386 | lay->addWidget( box ); | 386 | lay->addWidget( box ); |
387 | 387 | ||
388 | m_view = new QListView( this ); | 388 | m_view = new QListView( this ); |
389 | 389 | ||
390 | m_view->installEventFilter(this); | 390 | m_view->installEventFilter(this); |
391 | 391 | ||
392 | QPEApplication::setStylusOperation( m_view->viewport(), | 392 | QPEApplication::setStylusOperation( m_view->viewport(), |
393 | QPEApplication::RightOnHold); | 393 | QPEApplication::RightOnHold); |
394 | m_view->addColumn(" " ); | 394 | m_view->addColumn(" " ); |
395 | m_view->addColumn(tr("Name"), 135 ); | 395 | m_view->addColumn(tr("Name"), 135 ); |
396 | m_view->addColumn(tr("Size"), -1 ); | 396 | m_view->addColumn(tr("Size"), -1 ); |
397 | m_view->addColumn(tr("Date"), 60 ); | 397 | m_view->addColumn(tr("Date"), 60 ); |
398 | m_view->addColumn(tr("Mime Type"), -1 ); | 398 | m_view->addColumn(tr("Mime Type"), -1 ); |
399 | 399 | ||
400 | 400 | ||
401 | m_view->setSorting( 1 ); | 401 | m_view->setSorting( 1 ); |
402 | m_view->setAllColumnsShowFocus( TRUE ); | 402 | m_view->setAllColumnsShowFocus( TRUE ); |
403 | 403 | ||
404 | lay->addWidget( m_view, 1000 ); | 404 | lay->addWidget( m_view, 1000 ); |
405 | connectSlots(); | 405 | connectSlots(); |
406 | } | 406 | } |
407 | 407 | ||
408 | void OFileViewFileListView::slotFSpressed() | ||
409 | { | ||
410 | m_fsPop->exec(QPoint( QCursor::pos().x(), QCursor::pos().y())); | ||
411 | m_fsButton->setDown(false); | ||
412 | } | ||
413 | |||
408 | OFileViewFileListView::~OFileViewFileListView() | 414 | OFileViewFileListView::~OFileViewFileListView() |
409 | { | 415 | { |
410 | } | 416 | } |
411 | 417 | ||
412 | void OFileViewFileListView::slotNew() | 418 | void OFileViewFileListView::slotNew() |
413 | { | 419 | { |
414 | DocLnk lnk; | 420 | DocLnk lnk; |
415 | emit selector()->newSelected( lnk ); | 421 | emit selector()->newSelected( lnk ); |
416 | } | 422 | } |
417 | 423 | ||
418 | OFileSelectorItem* OFileViewFileListView::currentItem()const | 424 | OFileSelectorItem* OFileViewFileListView::currentItem()const |
419 | { | 425 | { |
420 | QListViewItem* item = m_view->currentItem(); | 426 | QListViewItem* item = m_view->currentItem(); |
421 | if (!item ) | 427 | if (!item ) |
422 | return 0l; | 428 | return 0l; |
423 | 429 | ||
424 | return static_cast<OFileSelectorItem*>(item); | 430 | return static_cast<OFileSelectorItem*>(item); |
425 | } | 431 | } |
426 | 432 | ||
427 | void OFileViewFileListView::reread( bool all ) | 433 | void OFileViewFileListView::reread( bool all ) |
428 | { | 434 | { |
429 | m_view->clear(); | 435 | m_view->clear(); |
430 | 436 | ||
431 | if (selector()->showClose() ) | 437 | if (selector()->showClose() ) |
432 | m_btnClose->show(); | 438 | m_btnClose->show(); |
433 | else | 439 | else |
434 | m_btnClose->hide(); | 440 | m_btnClose->hide(); |
435 | 441 | ||
436 | if (selector()->showNew() ) | 442 | if (selector()->showNew() ) |
437 | m_btnNew->show(); | 443 | m_btnNew->show(); |
438 | else | 444 | else |
439 | m_btnNew->hide(); | 445 | m_btnNew->hide(); |
440 | 446 | ||
441 | m_mimes = selector()->currentMimeType(); | 447 | m_mimes = selector()->currentMimeType(); |
442 | m_all = all; | 448 | m_all = all; |
443 | 449 | ||
444 | QDir dir( m_currentDir ); | 450 | QDir dir( m_currentDir ); |
445 | if (!dir.exists() ) | 451 | if (!dir.exists() ) |
446 | return; | 452 | return; |
447 | 453 | ||
448 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 454 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
449 | int filter; | 455 | int filter; |
450 | filter = QDir::Dirs; | 456 | filter = QDir::Dirs; |
451 | if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR ) | 457 | if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR ) |
452 | filter = filter | QDir::Files | QDir::All; | 458 | filter = filter | QDir::Files | QDir::All; |
453 | 459 | ||
454 | if ( m_all ) | 460 | if ( m_all ) |
455 | filter = filter | QDir::Hidden; | 461 | filter = filter | QDir::Hidden; |
456 | 462 | ||
457 | dir.setFilter( filter ); | 463 | dir.setFilter( filter ); |
458 | 464 | ||
459 | // now go through all files | 465 | // now go through all files |
460 | const QFileInfoList *list = dir.entryInfoList(); | 466 | const QFileInfoList *list = dir.entryInfoList(); |
461 | if (!list) | 467 | if (!list) |
462 | { | 468 | { |
463 | cdUP(); | 469 | cdUP(); |
464 | return; | 470 | return; |
465 | } | 471 | } |
466 | 472 | ||
467 | QFileInfoListIterator it( *list ); | 473 | QFileInfoListIterator it( *list ); |
468 | QFileInfo *fi; | 474 | QFileInfo *fi; |
469 | while( (fi=it.current() ) ) | 475 | while( (fi=it.current() ) ) |
470 | { | 476 | { |
471 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) | 477 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) |
472 | { | 478 | { |
473 | ++it; | 479 | ++it; |
474 | continue; | 480 | continue; |
475 | } | 481 | } |
476 | 482 | ||
477 | /* | 483 | /* |
478 | * It is a symlink we try to resolve it now but don't let us attack by DOS | 484 | * It is a symlink we try to resolve it now but don't let us attack by DOS |
479 | * | 485 | * |
480 | */ | 486 | */ |
481 | if( fi->isSymLink() ) | 487 | if( fi->isSymLink() ) |
482 | { | 488 | { |
483 | QString file = createNewPath(fi->dirPath( true ),fi->readLink()); | 489 | QString file = createNewPath(fi->dirPath( true ),fi->readLink()); |
484 | for( int i = 0; i<=4; i++) | 490 | for( int i = 0; i<=4; i++) |
485 | { // 5 tries to prevent dos | 491 | { // 5 tries to prevent dos |
486 | QFileInfo info( file ); | 492 | QFileInfo info( file ); |
487 | if( !info.exists() ) | 493 | if( !info.exists() ) |
488 | { | 494 | { |
489 | addSymlink( fi, TRUE ); | 495 | addSymlink( fi, TRUE ); |
490 | break; | 496 | break; |
491 | } | 497 | } |
492 | else if( info.isDir() ) | 498 | else if( info.isDir() ) |
493 | { | 499 | { |
494 | addDir( fi, TRUE ); | 500 | addDir( fi, TRUE ); |
495 | break; | 501 | break; |
496 | } | 502 | } |
497 | else if( info.isFile() ) | 503 | else if( info.isFile() ) |
498 | { | 504 | { |
499 | addFile( fi, TRUE ); | 505 | addFile( fi, TRUE ); |
500 | break; | 506 | break; |
501 | } | 507 | } |
502 | else if( info.isSymLink() ) | 508 | else if( info.isSymLink() ) |
503 | { | 509 | { |
504 | file = createNewPath(info.dirPath(true ),info.readLink()); | 510 | file = createNewPath(info.dirPath(true ),info.readLink()); |
505 | break; | 511 | break; |
506 | } | 512 | } |
507 | else if( i == 4) | 513 | else if( i == 4) |
508 | { // couldn't resolve symlink add it as symlink | 514 | { // couldn't resolve symlink add it as symlink |
509 | addSymlink( fi ); | 515 | addSymlink( fi ); |
510 | } | 516 | } |
511 | } // off for loop for symlink resolving | 517 | } // off for loop for symlink resolving |
512 | } | 518 | } |
513 | else if( fi->isDir() ) | 519 | else if( fi->isDir() ) |
514 | addDir( fi ); | 520 | addDir( fi ); |
515 | else if( fi->isFile() ) | 521 | else if( fi->isFile() ) |
516 | addFile( fi ); | 522 | addFile( fi ); |
517 | 523 | ||
518 | ++it; | 524 | ++it; |
519 | } // of while loop | 525 | } // of while loop |
520 | m_view->sort(); | 526 | m_view->sort(); |
521 | 527 | ||
522 | } | 528 | } |
523 | int OFileViewFileListView::fileCount()const | 529 | int OFileViewFileListView::fileCount()const |
524 | { | 530 | { |
525 | return m_view->childCount(); | 531 | return m_view->childCount(); |
526 | } | 532 | } |
527 | 533 | ||
528 | QString OFileViewFileListView::currentDir()const | 534 | QString OFileViewFileListView::currentDir()const |
529 | { | 535 | { |
530 | return m_currentDir; | 536 | return m_currentDir; |
531 | } | 537 | } |
532 | 538 | ||
533 | OFileSelector* OFileViewFileListView::selector() | 539 | OFileSelector* OFileViewFileListView::selector() |
534 | { | 540 | { |
535 | return m_sel; | 541 | return m_sel; |
536 | } | 542 | } |
537 | 543 | ||
538 | bool OFileViewFileListView::eventFilter (QObject *, QEvent *e) | 544 | bool OFileViewFileListView::eventFilter (QObject *, QEvent *e) |
539 | { | 545 | { |
540 | if ( e->type() == QEvent::KeyPress ) | 546 | if ( e->type() == QEvent::KeyPress ) |
541 | { | 547 | { |
542 | QKeyEvent *k = (QKeyEvent *)e; | 548 | QKeyEvent *k = (QKeyEvent *)e; |
543 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) | 549 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) |
544 | { | 550 | { |
545 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); | 551 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); |
546 | return true; | 552 | return true; |
547 | } | 553 | } |
548 | } | 554 | } |
549 | return false; | 555 | return false; |
550 | } | 556 | } |
551 | 557 | ||
552 | void OFileViewFileListView::connectSlots() | 558 | void OFileViewFileListView::connectSlots() |
553 | { | 559 | { |
554 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), | 560 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), |
555 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); | 561 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); |
556 | connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), | 562 | connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), |
557 | this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); | 563 | this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); |
558 | } | 564 | } |
559 | 565 | ||
560 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) | 566 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) |
561 | { | 567 | { |
562 | if (!item) | 568 | if (!item) |
563 | return; | 569 | return; |
564 | #if 0 | 570 | #if 0 |
565 | 571 | ||
566 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 572 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
567 | 573 | ||
568 | if (!sel->isDir() ) | 574 | if (!sel->isDir() ) |
569 | { | 575 | { |
570 | selector()->m_lneEdit->setText( sel->text(1) ); | 576 | selector()->m_lneEdit->setText( sel->text(1) ); |
571 | // if in fileselector mode we will emit selected | 577 | // if in fileselector mode we will emit selected |
572 | if ( selector()->mode() == OFileSelector::FileSelector ) | 578 | if ( selector()->mode() == OFileSelector::FileSelector ) |
573 | { | 579 | { |
574 | odebug << "slot Current Changed" << oendl; | 580 | odebug << "slot Current Changed" << oendl; |
575 | QStringList str = QStringList::split("->", sel->text(1) ); | 581 | QStringList str = QStringList::split("->", sel->text(1) ); |
576 | QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace()); | 582 | QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace()); |
577 | emit selector()->fileSelected( path ); | 583 | emit selector()->fileSelected( path ); |
578 | DocLnk lnk( path ); | 584 | DocLnk lnk( path ); |
579 | emit selector()->fileSelected( lnk ); | 585 | emit selector()->fileSelected( lnk ); |
580 | } | 586 | } |
581 | } | 587 | } |
582 | #endif | 588 | #endif |
583 | } | 589 | } |
584 | 590 | ||
585 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) | 591 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) |
586 | { | 592 | { |
587 | if (!item || ( button != Qt::LeftButton) ) | 593 | if (!item || ( button != Qt::LeftButton) ) |
588 | return; | 594 | return; |
589 | 595 | ||
590 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 596 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
591 | if (!sel->isLocked() ) | 597 | if (!sel->isLocked() ) |
592 | { | 598 | { |
593 | QStringList str = QStringList::split("->", sel->text(1) ); | 599 | QStringList str = QStringList::split("->", sel->text(1) ); |
594 | if (sel->isDir() ) | 600 | if (sel->isDir() ) |
595 | { | 601 | { |
596 | m_currentDir = createNewPath(sel->directory(),str[0].stripWhiteSpace()); | 602 | m_currentDir = createNewPath(sel->directory(),str[0].stripWhiteSpace()); |
597 | emit selector()->dirSelected( m_currentDir ); | 603 | emit selector()->dirSelected( m_currentDir ); |
598 | reread( m_all ); | 604 | reread( m_all ); |
599 | } | 605 | } |
600 | else | 606 | else |
601 | { // file | 607 | { // file |
602 | odebug << "slot Clicked" << oendl; | 608 | odebug << "slot Clicked" << oendl; |
603 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); | 609 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); |
604 | QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace()); | 610 | QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace()); |
605 | emit selector()->fileSelected( path ); | 611 | emit selector()->fileSelected( path ); |
606 | DocLnk lnk( path ); | 612 | DocLnk lnk( path ); |
607 | emit selector()->fileSelected( lnk ); | 613 | emit selector()->fileSelected( lnk ); |
608 | } | 614 | } |
609 | } // not locked | 615 | } // not locked |
610 | } | 616 | } |
611 | 617 | ||
612 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) | 618 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) |
613 | { | 619 | { |
614 | MimeType type( info->absFilePath() ); | 620 | MimeType type( info->absFilePath() ); |
615 | if (!compliesMime( type.id() ) ) | 621 | if (!compliesMime( type.id() ) ) |
616 | return; | 622 | return; |
617 | 623 | ||
618 | QPixmap pix = type.pixmap(); | 624 | QPixmap pix = type.pixmap(); |
619 | QString dir, name; bool locked; | 625 | QString dir, name; bool locked; |
620 | if ( pix.isNull() ) | 626 | if ( pix.isNull() ) |
621 | { | 627 | { |
622 | QWMatrix matrix; | 628 | QWMatrix matrix; |
623 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); | 629 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); |
624 | matrix.scale( .4, .4 ); | 630 | matrix.scale( .4, .4 ); |
625 | pix = pixer.xForm( matrix ); | 631 | pix = pixer.xForm( matrix ); |
626 | } | 632 | } |
627 | dir = info->dirPath( true ); | 633 | dir = info->dirPath( true ); |
628 | locked = false; | 634 | locked = false; |
629 | if ( symlink ) | 635 | if ( symlink ) |
630 | name = info->fileName() + " -> " + createNewPath(info->dirPath(),info->readLink()); | 636 | name = info->fileName() + " -> " + createNewPath(info->dirPath(),info->readLink()); |
631 | else | 637 | else |
632 | { | 638 | { |
633 | name = info->fileName(); | 639 | name = info->fileName(); |
634 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || | 640 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || |
635 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) | 641 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) |
636 | { | 642 | { |
637 | locked = true; pix = Resource::loadPixmap("locked"); | 643 | locked = true; pix = Resource::loadPixmap("locked"); |
638 | } | 644 | } |
639 | } | 645 | } |
640 | (void)new OFileSelectorItem( m_view, pix, name, | 646 | (void)new OFileSelectorItem( m_view, pix, name, |
641 | info->lastModified().toString(), QString::number( info->size() ), | 647 | info->lastModified().toString(), QString::number( info->size() ), |
642 | dir, locked ); | 648 | dir, locked ); |
643 | } | 649 | } |
644 | 650 | ||
645 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) | 651 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) |
646 | { | 652 | { |
647 | bool locked = false; QString name; QPixmap pix; | 653 | bool locked = false; QString name; QPixmap pix; |
648 | 654 | ||
649 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || | 655 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || |
650 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) | 656 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) |
651 | { | 657 | { |
652 | locked = true; | 658 | locked = true; |
653 | if ( symlink ) | 659 | if ( symlink ) |
654 | pix = Resource::loadPixmap( "opie/symlink" ); | 660 | pix = Resource::loadPixmap( "opie/symlink" ); |
655 | else | 661 | else |
656 | pix = Resource::loadPixmap( "lockedfolder" ); | 662 | pix = Resource::loadPixmap( "lockedfolder" ); |
657 | } | 663 | } |
658 | else | 664 | else |
659 | pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); | 665 | pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); |
660 | 666 | ||
661 | name = symlink ? info->fileName() + " -> " + createNewPath(info->dirPath(true),info->readLink()) : | 667 | name = symlink ? info->fileName() + " -> " + createNewPath(info->dirPath(true),info->readLink()) : |
662 | info->fileName(); | 668 | info->fileName(); |
663 | 669 | ||
664 | (void)new OFileSelectorItem( m_view, pix, name, | 670 | (void)new OFileSelectorItem( m_view, pix, name, |
665 | info->lastModified().toString(), | 671 | info->lastModified().toString(), |
666 | QString::number( info->size() ), | 672 | QString::number( info->size() ), |
667 | info->dirPath( true ), locked, true ); | 673 | info->dirPath( true ), locked, true ); |
668 | 674 | ||
669 | 675 | ||
670 | } | 676 | } |
671 | 677 | ||
672 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) | 678 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) |
673 | { | 679 | { |
674 | } | 680 | } |
675 | 681 | ||
676 | void OFileViewFileListView::cdUP() | 682 | void OFileViewFileListView::cdUP() |
677 | { | 683 | { |
678 | QDir dir( m_currentDir ); | 684 | QDir dir( m_currentDir ); |
679 | dir.cdUp(); | 685 | dir.cdUp(); |
680 | 686 | ||
681 | if (!dir.exists() ) | 687 | if (!dir.exists() ) |
682 | m_currentDir = "/"; | 688 | m_currentDir = "/"; |
683 | else | 689 | else |
684 | m_currentDir = dir.absPath(); | 690 | m_currentDir = dir.absPath(); |
685 | 691 | ||
686 | emit selector()->dirSelected( m_currentDir ); | 692 | emit selector()->dirSelected( m_currentDir ); |
687 | reread( m_all ); | 693 | reread( m_all ); |
688 | } | 694 | } |
689 | 695 | ||
690 | void OFileViewFileListView::cdHome() | 696 | void OFileViewFileListView::cdHome() |
691 | { | 697 | { |
692 | m_currentDir = QDir::homeDirPath(); | 698 | m_currentDir = QDir::homeDirPath(); |
693 | emit selector()->dirSelected( m_currentDir ); | 699 | emit selector()->dirSelected( m_currentDir ); |
694 | reread( m_all ); | 700 | reread( m_all ); |
695 | } | 701 | } |
696 | 702 | ||
697 | void OFileViewFileListView::cdDoc() | 703 | void OFileViewFileListView::cdDoc() |
698 | { | 704 | { |
699 | m_currentDir = QPEApplication::documentDir(); | 705 | m_currentDir = QPEApplication::documentDir(); |
700 | emit selector()->dirSelected( m_currentDir ); | 706 | emit selector()->dirSelected( m_currentDir ); |
701 | reread( m_all ); | 707 | reread( m_all ); |
702 | } | 708 | } |
703 | 709 | ||
704 | void OFileViewFileListView::changeDir( const QString& dir ) | 710 | void OFileViewFileListView::changeDir( const QString& dir ) |
705 | { | 711 | { |
706 | m_currentDir = dir; | 712 | m_currentDir = dir; |
707 | emit selector()->dirSelected( m_currentDir ); | 713 | emit selector()->dirSelected( m_currentDir ); |
708 | reread( m_all ); | 714 | reread( m_all ); |
709 | } | 715 | } |
710 | 716 | ||
711 | void OFileViewFileListView::slotFSActivated( int id ) | 717 | void OFileViewFileListView::slotFSActivated( int id ) |
712 | { | 718 | { |
713 | changeDir ( m_dev[m_fsPop->text(id)] ); | 719 | changeDir ( m_dev[m_fsPop->text(id)] ); |
714 | } | 720 | } |
715 | 721 | ||
716 | /* check if the mimetype in mime | 722 | /* check if the mimetype in mime |
717 | * complies with the one which is current | 723 | * complies with the one which is current |
718 | */ | 724 | */ |
719 | /* | 725 | /* |
720 | * We've the mimetype of the file | 726 | * We've the mimetype of the file |
721 | * We need to get the stringlist of the current mimetype | 727 | * We need to get the stringlist of the current mimetype |
722 | * | 728 | * |
723 | * mime = image@slashjpeg | 729 | * mime = image@slashjpeg |
724 | * QStringList = 'image@slash*' | 730 | * QStringList = 'image@slash*' |
725 | * or QStringList = image/jpeg;image/png;application/x-ogg | 731 | * or QStringList = image/jpeg;image/png;application/x-ogg |
726 | * or QStringList = application/x-ogg;image@slash*; | 732 | * or QStringList = application/x-ogg;image@slash*; |
727 | * with all these mime filters it should get acceptes | 733 | * with all these mime filters it should get acceptes |
728 | * to do so we need to look if mime is contained inside | 734 | * to do so we need to look if mime is contained inside |
729 | * the stringlist | 735 | * the stringlist |
730 | * if it's contained return true | 736 | * if it's contained return true |
731 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' | 737 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' |
732 | * is contained in the mimefilter and then we will | 738 | * is contained in the mimefilter and then we will |
733 | * look if both are equal until the '/' | 739 | * look if both are equal until the '/' |
734 | */ | 740 | */ |
735 | 741 | ||
736 | bool OFileViewFileListView::compliesMime( const QString& str) | 742 | bool OFileViewFileListView::compliesMime( const QString& str) |
737 | { | 743 | { |
738 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) | 744 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) |
739 | return true; | 745 | return true; |
740 | 746 | ||
741 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) | 747 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) |
742 | { | 748 | { |
743 | QRegExp reg( (*it) ); | 749 | QRegExp reg( (*it) ); |
744 | reg.setWildcard( true ); | 750 | reg.setWildcard( true ); |
745 | if ( str.find( reg ) != -1 ) | 751 | if ( str.find( reg ) != -1 ) |
746 | return true; | 752 | return true; |
747 | 753 | ||
748 | } | 754 | } |
749 | return false; | 755 | return false; |
750 | } | 756 | } |
751 | /* | 757 | /* |
752 | * The listView giving access to the file system! | 758 | * The listView giving access to the file system! |
753 | */ | 759 | */ |
754 | 760 | ||
755 | class OFileViewFileSystem : public OFileViewInterface | 761 | class OFileViewFileSystem : public OFileViewInterface |
756 | { | 762 | { |
757 | public: | 763 | public: |
758 | OFileViewFileSystem( OFileSelector* ); | 764 | OFileViewFileSystem( OFileSelector* ); |
759 | ~OFileViewFileSystem(); | 765 | ~OFileViewFileSystem(); |
760 | 766 | ||
761 | QString selectedName() const; | 767 | QString selectedName() const; |
762 | QString selectedPath() const; | 768 | QString selectedPath() const; |
763 | 769 | ||
764 | QString directory()const; | 770 | QString directory()const; |
765 | void reread(); | 771 | void reread(); |
766 | int fileCount()const; | 772 | int fileCount()const; |
767 | 773 | ||
768 | QWidget* widget( QWidget* parent ); | 774 | QWidget* widget( QWidget* parent ); |
769 | void activate( const QString& ); | 775 | void activate( const QString& ); |
770 | private: | 776 | private: |
771 | OFileViewFileListView* m_view; | 777 | OFileViewFileListView* m_view; |
772 | bool m_all : 1; | 778 | bool m_all : 1; |
773 | }; | 779 | }; |
774 | 780 | ||
775 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) | 781 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) |
776 | : OFileViewInterface( sel ) | 782 | : OFileViewInterface( sel ) |
777 | { | 783 | { |
778 | m_view = 0; | 784 | m_view = 0; |
779 | m_all = false; | 785 | m_all = false; |
780 | } | 786 | } |
781 | 787 | ||
782 | OFileViewFileSystem::~OFileViewFileSystem() | 788 | OFileViewFileSystem::~OFileViewFileSystem() |
783 | { | 789 | { |
784 | } | 790 | } |
785 | 791 | ||
786 | QString OFileViewFileSystem::selectedName()const | 792 | QString OFileViewFileSystem::selectedName()const |
787 | { | 793 | { |
788 | if (!m_view ) | 794 | if (!m_view ) |
789 | return QString::null; | 795 | return QString::null; |
790 | 796 | ||
791 | QString cFN=currentFileName(); | 797 | QString cFN=currentFileName(); |
792 | if (cFN.startsWith("/")) return cFN; | 798 | if (cFN.startsWith("/")) return cFN; |
793 | return createNewPath(m_view->currentDir(),cFN); | 799 | return createNewPath(m_view->currentDir(),cFN); |
794 | } | 800 | } |
795 | 801 | ||
796 | QString OFileViewFileSystem::selectedPath()const | 802 | QString OFileViewFileSystem::selectedPath()const |
797 | { | 803 | { |
798 | return QString::null; | 804 | return QString::null; |
799 | } | 805 | } |
800 | 806 | ||
801 | QString OFileViewFileSystem::directory()const | 807 | QString OFileViewFileSystem::directory()const |
802 | { | 808 | { |
803 | if (!m_view) | 809 | if (!m_view) |
804 | return QString::null; | 810 | return QString::null; |
805 | 811 | ||
806 | OFileSelectorItem* item = m_view->currentItem(); | 812 | OFileSelectorItem* item = m_view->currentItem(); |
807 | if (!item ) | 813 | if (!item ) |
808 | return QString::null; | 814 | return QString::null; |
809 | 815 | ||
810 | return QDir(item->directory() ).absPath(); | 816 | return QDir(item->directory() ).absPath(); |
811 | } | 817 | } |
812 | 818 | ||
813 | void OFileViewFileSystem::reread() | 819 | void OFileViewFileSystem::reread() |
814 | { | 820 | { |
815 | if (!m_view) | 821 | if (!m_view) |
816 | return; | 822 | return; |
817 | 823 | ||
818 | m_view->reread( m_all ); | 824 | m_view->reread( m_all ); |
819 | } | 825 | } |
820 | 826 | ||
821 | int OFileViewFileSystem::fileCount()const | 827 | int OFileViewFileSystem::fileCount()const |
822 | { | 828 | { |
823 | if (!m_view ) | 829 | if (!m_view ) |
824 | return -1; | 830 | return -1; |
825 | return m_view->fileCount(); | 831 | return m_view->fileCount(); |
826 | } | 832 | } |
827 | 833 | ||
828 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) | 834 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) |
829 | { | 835 | { |
830 | if (!m_view ) | 836 | if (!m_view ) |
831 | { | 837 | { |
832 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); | 838 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); |
833 | } | 839 | } |
834 | return m_view; | 840 | return m_view; |
835 | } | 841 | } |
836 | 842 | ||
837 | void OFileViewFileSystem::activate( const QString& str ) | 843 | void OFileViewFileSystem::activate( const QString& str ) |
838 | { | 844 | { |
839 | m_all = allItem( str ); | 845 | m_all = allItem( str ); |
840 | } | 846 | } |
841 | 847 | ||
842 | 848 | ||
843 | } | 849 | } |
844 | /* Selector */ | 850 | /* Selector */ |
845 | /** | 851 | /** |
846 | * @short new and complete c'tor | 852 | * @short new and complete c'tor |
847 | * | 853 | * |
848 | * Create a OFileSelector to let the user select a file. It can | 854 | * Create a OFileSelector to let the user select a file. It can |
849 | * either be used to open a file, select a save name in a dir or | 855 | * either be used to open a file, select a save name in a dir or |
850 | * as a dropin for the FileSelector. | 856 | * as a dropin for the FileSelector. |
851 | * | 857 | * |
852 | * <pre> | 858 | * <pre> |
853 | * QMap<QString, QStringList> mimeTypes; | 859 | * QMap<QString, QStringList> mimeTypes; |
854 | * QStringList types; | 860 | * QStringList types; |
855 | * types << "text@slash* "; | 861 | * types << "text@slash* "; |
856 | * types << "audio@slash*"; | 862 | * types << "audio@slash*"; |
857 | * mimeTypes.insert( tr("Audio and Text"), types ); | 863 | * mimeTypes.insert( tr("Audio and Text"), types ); |
858 | * mimeTypes.insert( tr("All"), "*@slash*); | 864 | * mimeTypes.insert( tr("All"), "*@slash*); |
859 | * | 865 | * |
860 | * now you could create your fileselector | 866 | * now you could create your fileselector |
861 | * </pre> | 867 | * </pre> |
862 | * | 868 | * |
863 | * | 869 | * |
864 | * @param parent the parent of this widget | 870 | * @param parent the parent of this widget |
865 | * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) | 871 | * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) |
866 | * @param sel The selector to be used | 872 | * @param sel The selector to be used |
867 | * @param dirName The name of the dir to start int | 873 | * @param dirName The name of the dir to start int |
868 | * @param fileName The fileName placed in the fileselector lineedit | 874 | * @param fileName The fileName placed in the fileselector lineedit |
869 | * @param mimetypes The MimeType map of used mimetypes | 875 | * @param mimetypes The MimeType map of used mimetypes |
870 | * @param showNew Show a New Button. Most likely to be used in the FileSelector view. | 876 | * @param showNew Show a New Button. Most likely to be used in the FileSelector view. |
871 | * @param showClose Show a Close Button. Most likely to be used in FileSelector view. | 877 | * @param showClose Show a Close Button. Most likely to be used in FileSelector view. |
872 | * | 878 | * |
873 | */ | 879 | */ |
874 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, | 880 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, |
875 | const QString& dirName, const QString& fileName, | 881 | const QString& dirName, const QString& fileName, |
876 | const MimeTypes& mimetypes, | 882 | const MimeTypes& mimetypes, |
877 | bool showNew, bool showClose) | 883 | bool showNew, bool showClose) |
878 | :QWidget( parent, "OFileSelector" ) | 884 | :QWidget( parent, "OFileSelector" ) |
879 | { | 885 | { |
880 | m_current = 0; | 886 | m_current = 0; |
881 | m_shNew = showNew; | 887 | m_shNew = showNew; |
882 | m_shClose = showClose; | 888 | m_shClose = showClose; |
883 | m_mimeType = mimetypes; | 889 | m_mimeType = mimetypes; |
884 | m_startDir = dirName; | 890 | m_startDir = dirName; |
885 | 891 | ||
886 | m_mode = mode; | 892 | m_mode = mode; |
887 | m_selector = sel; | 893 | m_selector = sel; |
888 | 894 | ||
889 | m_allList = QStringList(); | 895 | m_allList = QStringList(); |
890 | 896 | ||
891 | initUI(); | 897 | initUI(); |
892 | m_lneEdit->setText( fileName ); | 898 | m_lneEdit->setText( fileName ); |
893 | initMime(); | 899 | initMime(); |
894 | initViews(); | 900 | initViews(); |
895 | 901 | ||
896 | QString str; | 902 | QString str; |
897 | switch ( m_selector ) | 903 | switch ( m_selector ) |
898 | { | 904 | { |
899 | default: | 905 | default: |
900 | case Normal: | 906 | case Normal: |
901 | if ( m_mode == DIRECTORYSELECTOR ) | 907 | if ( m_mode == DIRECTORYSELECTOR ) |
902 | str = QObject::tr("Directories"); | 908 | str = QObject::tr("Directories"); |
903 | else | 909 | else |
904 | str = QObject::tr("Documents"); | 910 | str = QObject::tr("Documents"); |
905 | m_cmbView->setCurrentItem( 0 ); | 911 | m_cmbView->setCurrentItem( 0 ); |
906 | break; | 912 | break; |
907 | case Extended: | 913 | case Extended: |
908 | if ( m_mode == DIRECTORYSELECTOR ) | 914 | if ( m_mode == DIRECTORYSELECTOR ) |
909 | { | 915 | { |
910 | str = QObject::tr("Directories"); | 916 | str = QObject::tr("Directories"); |
911 | m_cmbView->setCurrentItem( 0 ); | 917 | m_cmbView->setCurrentItem( 0 ); |
912 | } else { | 918 | } else { |
913 | str = QObject::tr("Files"); | 919 | str = QObject::tr("Files"); |
914 | m_cmbView->setCurrentItem( 1 ); | 920 | m_cmbView->setCurrentItem( 1 ); |
915 | } | 921 | } |
916 | break; | 922 | break; |
917 | case ExtendedAll: | 923 | case ExtendedAll: |
918 | if ( m_mode == DIRECTORYSELECTOR ) | 924 | if ( m_mode == DIRECTORYSELECTOR ) |
919 | { | 925 | { |
920 | str = QObject::tr("All Directories"); | 926 | str = QObject::tr("All Directories"); |
921 | m_cmbView->setCurrentItem( 1 ); | 927 | m_cmbView->setCurrentItem( 1 ); |
922 | } else { | 928 | } else { |
923 | str = QObject::tr("All Files"); | 929 | str = QObject::tr("All Files"); |
924 | m_cmbView->setCurrentItem( 2 ); | 930 | m_cmbView->setCurrentItem( 2 ); |
925 | } | 931 | } |
926 | break; | 932 | break; |
927 | } | 933 | } |
928 | slotViewChange( str ); | 934 | slotViewChange( str ); |
929 | 935 | ||
930 | } | 936 | } |
931 | 937 | ||
932 | 938 | ||
933 | /** | 939 | /** |
934 | * This a convience c'tor to just substitute the use of FileSelector | 940 | * This a convience c'tor to just substitute the use of FileSelector |
935 | */ | 941 | */ |
936 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, | 942 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, |
937 | bool showNew, bool showClose ) | 943 | bool showNew, bool showClose ) |
938 | : QWidget( parent, name ) | 944 | : QWidget( parent, name ) |
939 | { | 945 | { |
940 | m_current = 0; | 946 | m_current = 0; |
941 | m_shNew = showNew; | 947 | m_shNew = showNew; |
942 | m_shClose = showClose; | 948 | m_shClose = showClose; |
943 | m_startDir = QPEApplication::documentDir(); | 949 | m_startDir = QPEApplication::documentDir(); |
944 | 950 | ||
945 | if (!mimeFilter.isEmpty() ) | 951 | if (!mimeFilter.isEmpty() ) |
946 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); | 952 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); |
947 | 953 | ||
948 | m_mode = OFileSelector::FileSelector; | 954 | m_mode = OFileSelector::FileSelector; |
949 | m_selector = OFileSelector::Normal; | 955 | m_selector = OFileSelector::Normal; |
950 | 956 | ||
951 | initUI(); | 957 | initUI(); |
952 | initMime(); | 958 | initMime(); |
953 | initViews(); | 959 | initViews(); |
954 | m_cmbView->setCurrentItem( 0 ); | 960 | m_cmbView->setCurrentItem( 0 ); |
955 | slotViewChange( QObject::tr("Documents") ); | 961 | slotViewChange( QObject::tr("Documents") ); |
956 | } | 962 | } |
957 | 963 | ||
958 | /* | 964 | /* |
959 | * INIT UI will set up the basic GUI | 965 | * INIT UI will set up the basic GUI |
960 | * Layout: Simple VBoxLayout | 966 | * Layout: Simple VBoxLayout |
961 | * On top a WidgetStack containing the Views... | 967 | * On top a WidgetStack containing the Views... |
962 | * - List View | 968 | * - List View |
963 | * - Document View | 969 | * - Document View |
964 | * Below we will have a Label + LineEdit | 970 | * Below we will have a Label + LineEdit |
965 | * Below we will have two ComoBoxes one for choosing the view one for | 971 | * Below we will have two ComoBoxes one for choosing the view one for |
966 | * choosing the mimetype | 972 | * choosing the mimetype |
967 | */ | 973 | */ |
968 | void OFileSelector::initUI() | 974 | void OFileSelector::initUI() |
969 | { | 975 | { |
970 | QVBoxLayout* lay = new QVBoxLayout( this ); | 976 | QVBoxLayout* lay = new QVBoxLayout( this ); |
971 | 977 | ||
972 | m_stack = new QWidgetStack( this ); | 978 | m_stack = new QWidgetStack( this ); |
973 | lay->addWidget( m_stack, 1000 ); | 979 | lay->addWidget( m_stack, 1000 ); |
974 | 980 | ||
975 | m_nameBox = new QHBox( this ); | 981 | m_nameBox = new QHBox( this ); |
976 | (void)new QLabel( tr("Name:"), m_nameBox ); | 982 | (void)new QLabel( tr("Name:"), m_nameBox ); |
977 | m_lneEdit = new QLineEdit( m_nameBox ); | 983 | m_lneEdit = new QLineEdit( m_nameBox ); |
978 | m_lneEdit ->installEventFilter(this); | 984 | m_lneEdit ->installEventFilter(this); |
979 | lay->addWidget( m_nameBox ); | 985 | lay->addWidget( m_nameBox ); |
980 | 986 | ||
981 | m_cmbBox = new QHBox( this ); | 987 | m_cmbBox = new QHBox( this ); |
982 | m_cmbView = new QComboBox( m_cmbBox ); | 988 | m_cmbView = new QComboBox( m_cmbBox ); |
983 | m_cmbMime = new QComboBox( m_cmbBox ); | 989 | m_cmbMime = new QComboBox( m_cmbBox ); |
984 | lay->addWidget( m_cmbBox ); | 990 | lay->addWidget( m_cmbBox ); |
985 | } | 991 | } |
986 | 992 | ||
987 | /* | 993 | /* |
988 | * This will make sure that the return key in the name edit causes dialogs to close | 994 | * This will make sure that the return key in the name edit causes dialogs to close |
989 | */ | 995 | */ |
990 | 996 | ||
991 | bool OFileSelector::eventFilter (QObject *, QEvent *e) | 997 | bool OFileSelector::eventFilter (QObject *, QEvent *e) |
992 | { | 998 | { |
993 | if ( e->type() == QEvent::KeyPress ) | 999 | if ( e->type() == QEvent::KeyPress ) |
994 | { | 1000 | { |
995 | QKeyEvent *k = (QKeyEvent *)e; | 1001 | QKeyEvent *k = (QKeyEvent *)e; |
996 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) | 1002 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) |
997 | { | 1003 | { |
998 | emit ok(); | 1004 | emit ok(); |
999 | return true; | 1005 | return true; |
1000 | } | 1006 | } |
1001 | } | 1007 | } |
1002 | return false; | 1008 | return false; |
1003 | } | 1009 | } |
1004 | 1010 | ||
1005 | /* | 1011 | /* |
1006 | * This will insert the MimeTypes into the Combo Box | 1012 | * This will insert the MimeTypes into the Combo Box |
1007 | * And also connect the changed signal | 1013 | * And also connect the changed signal |
1008 | * | 1014 | * |
1009 | * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes | 1015 | * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes |
1010 | */ | 1016 | */ |
1011 | void OFileSelector::initMime() | 1017 | void OFileSelector::initMime() |
1012 | { | 1018 | { |
1013 | MimeTypes::Iterator it; | 1019 | MimeTypes::Iterator it; |
1014 | for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) | 1020 | for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) |
1015 | { | 1021 | { |
1016 | m_cmbMime->insertItem( it.key() ); | 1022 | m_cmbMime->insertItem( it.key() ); |
1017 | } | 1023 | } |
1018 | m_cmbMime->setCurrentItem( 0 ); | 1024 | m_cmbMime->setCurrentItem( 0 ); |
1019 | 1025 | ||
1020 | connect( m_cmbMime, SIGNAL(activated(int) ), | 1026 | connect( m_cmbMime, SIGNAL(activated(int) ), |
1021 | this, SLOT(slotMimeTypeChanged() ) ); | 1027 | this, SLOT(slotMimeTypeChanged() ) ); |
1022 | 1028 | ||
1023 | } | 1029 | } |
1024 | 1030 | ||
1025 | void OFileSelector::initViews() | 1031 | void OFileSelector::initViews() |
1026 | { | 1032 | { |
1027 | if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) | 1033 | if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) |
1028 | { | 1034 | { |
1029 | m_cmbView->insertItem( QObject::tr("Directories") ); | 1035 | m_cmbView->insertItem( QObject::tr("Directories") ); |
1030 | m_cmbView->insertItem( QObject::tr("All Directories") ); | 1036 | m_cmbView->insertItem( QObject::tr("All Directories") ); |
1031 | } else { | 1037 | } else { |
1032 | m_cmbView->insertItem( QObject::tr("Documents") ); | 1038 | m_cmbView->insertItem( QObject::tr("Documents") ); |
1033 | m_cmbView->insertItem( QObject::tr("Files") ); | 1039 | m_cmbView->insertItem( QObject::tr("Files") ); |
1034 | m_cmbView->insertItem( QObject::tr("All Files") ); | 1040 | m_cmbView->insertItem( QObject::tr("All Files") ); |
1035 | } | 1041 | } |
1036 | 1042 | ||
1037 | connect(m_cmbView, SIGNAL(activated(const QString&) ), | 1043 | connect(m_cmbView, SIGNAL(activated(const QString&) ), |
1038 | this, SLOT(slotViewChange(const QString&) ) ); | 1044 | this, SLOT(slotViewChange(const QString&) ) ); |
1039 | 1045 | ||
1040 | /* see above why add both */ | 1046 | /* see above why add both */ |
1041 | OFileViewInterface* in = new OFileViewFileSystem( this ); | 1047 | OFileViewInterface* in = new OFileViewFileSystem( this ); |
1042 | 1048 | ||
1043 | if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) | 1049 | if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) |
1044 | { | 1050 | { |
1045 | m_views.insert( QObject::tr("Directories"), in ); | 1051 | m_views.insert( QObject::tr("Directories"), in ); |
1046 | m_views.insert( QObject::tr("All Directories"), in ); | 1052 | m_views.insert( QObject::tr("All Directories"), in ); |
1047 | m_allList.append( QObject::tr("All Directories") ); | 1053 | m_allList.append( QObject::tr("All Directories") ); |
1048 | } else { | 1054 | } else { |
1049 | m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); | 1055 | m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); |
1050 | m_views.insert( QObject::tr("Files"), in ); | 1056 | m_views.insert( QObject::tr("Files"), in ); |
1051 | m_views.insert( QObject::tr("All Files"), in ); | 1057 | m_views.insert( QObject::tr("All Files"), in ); |
1052 | m_allList.append( QObject::tr("All Files") ); | 1058 | m_allList.append( QObject::tr("All Files") ); |
1053 | } | 1059 | } |
1054 | } | 1060 | } |
1055 | 1061 | ||
1056 | void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) { | 1062 | void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) { |
1057 | m_viewsPtr.append( iface ); | 1063 | m_viewsPtr.append( iface ); |
1058 | } | 1064 | } |
1059 | 1065 | ||
1060 | 1066 | ||
1061 | /** | 1067 | /** |
1062 | * d'tor | 1068 | * d'tor |
1063 | */ | 1069 | */ |
1064 | OFileSelector::~OFileSelector() | 1070 | OFileSelector::~OFileSelector() |
1065 | { | 1071 | { |
1066 | m_viewsPtr.setAutoDelete( true ); | 1072 | m_viewsPtr.setAutoDelete( true ); |
1067 | m_viewsPtr.clear(); | 1073 | m_viewsPtr.clear(); |
1068 | } | 1074 | } |
1069 | 1075 | ||
1070 | 1076 | ||
1071 | 1077 | ||
1072 | /** | 1078 | /** |
1073 | * Convience function for the fileselector | 1079 | * Convience function for the fileselector |
1074 | * make sure to delete the DocLnk | 1080 | * make sure to delete the DocLnk |
1075 | * | 1081 | * |
1076 | * @see DocLnk | 1082 | * @see DocLnk |
1077 | * @todo remove in ODP | 1083 | * @todo remove in ODP |
1078 | */ | 1084 | */ |
1079 | const DocLnk* OFileSelector::selected() | 1085 | const DocLnk* OFileSelector::selected() |
1080 | { | 1086 | { |
1081 | DocLnk* lnk = new DocLnk( currentView()->selectedDocument() ); | 1087 | DocLnk* lnk = new DocLnk( currentView()->selectedDocument() ); |
1082 | return lnk; | 1088 | return lnk; |
1083 | } | 1089 | } |
1084 | 1090 | ||
1085 | /** | 1091 | /** |
1086 | * | 1092 | * |
1087 | * @return the name of the selected file | 1093 | * @return the name of the selected file |
1088 | */ | 1094 | */ |
1089 | QString OFileSelector::selectedName()const | 1095 | QString OFileSelector::selectedName()const |
1090 | { | 1096 | { |
1091 | return currentView()->selectedName(); | 1097 | return currentView()->selectedName(); |
1092 | } | 1098 | } |
1093 | 1099 | ||
1094 | 1100 | ||
1095 | /** | 1101 | /** |
1096 | * @return the selected path | 1102 | * @return the selected path |
1097 | */ | 1103 | */ |
1098 | QString OFileSelector::selectedPath()const | 1104 | QString OFileSelector::selectedPath()const |
1099 | { | 1105 | { |
1100 | return currentView()->selectedPath(); | 1106 | return currentView()->selectedPath(); |
1101 | } | 1107 | } |
1102 | 1108 | ||
1103 | /** | 1109 | /** |
1104 | * @return the directory name | 1110 | * @return the directory name |
1105 | */ | 1111 | */ |
1106 | QString OFileSelector::directory()const | 1112 | QString OFileSelector::directory()const |
1107 | { | 1113 | { |
1108 | return currentView()->directory(); | 1114 | return currentView()->directory(); |
1109 | } | 1115 | } |
1110 | 1116 | ||
1111 | /** | 1117 | /** |
1112 | * @return a DocLnk for the selected document | 1118 | * @return a DocLnk for the selected document |
1113 | */ | 1119 | */ |
1114 | DocLnk OFileSelector::selectedDocument()const | 1120 | DocLnk OFileSelector::selectedDocument()const |
1115 | { | 1121 | { |
1116 | return currentView()->selectedDocument(); | 1122 | return currentView()->selectedDocument(); |
1117 | } | 1123 | } |
1118 | 1124 | ||
1119 | /** | 1125 | /** |
1120 | * @return the number of items for the current view | 1126 | * @return the number of items for the current view |
1121 | */ | 1127 | */ |
1122 | int OFileSelector::fileCount()const | 1128 | int OFileSelector::fileCount()const |
1123 | { | 1129 | { |
1124 | return currentView()->fileCount(); | 1130 | return currentView()->fileCount(); |
1125 | } | 1131 | } |
1126 | 1132 | ||
1127 | /** | 1133 | /** |
1128 | * @return reparse the file content | 1134 | * @return reparse the file content |
1129 | */ | 1135 | */ |
1130 | void OFileSelector::reread() | 1136 | void OFileSelector::reread() |
1131 | { | 1137 | { |
1132 | return currentView()->reread(); | 1138 | return currentView()->reread(); |
1133 | } | 1139 | } |
1134 | 1140 | ||
1135 | OFileViewInterface* OFileSelector::currentView()const | 1141 | OFileViewInterface* OFileSelector::currentView()const |
1136 | { | 1142 | { |
1137 | return m_current; | 1143 | return m_current; |
1138 | } | 1144 | } |
1139 | 1145 | ||
1140 | bool OFileSelector::showNew()const | 1146 | bool OFileSelector::showNew()const |
1141 | { | 1147 | { |
1142 | return m_shNew; | 1148 | return m_shNew; |
1143 | } | 1149 | } |
1144 | 1150 | ||
1145 | bool OFileSelector::showClose()const | 1151 | bool OFileSelector::showClose()const |
1146 | { | 1152 | { |
1147 | return m_shClose; | 1153 | return m_shClose; |
1148 | } | 1154 | } |
1149 | 1155 | ||
1150 | MimeTypes OFileSelector::mimeTypes()const | 1156 | MimeTypes OFileSelector::mimeTypes()const |
1151 | { | 1157 | { |
1152 | return m_mimeType; | 1158 | return m_mimeType; |
1153 | } | 1159 | } |
1154 | 1160 | ||
1155 | /** | 1161 | /** |
1156 | * @return the Mode of the OFileSelector | 1162 | * @return the Mode of the OFileSelector |
1157 | */ | 1163 | */ |
1158 | int OFileSelector::mode()const | 1164 | int OFileSelector::mode()const |
1159 | { | 1165 | { |
1160 | return m_mode; | 1166 | return m_mode; |
1161 | } | 1167 | } |
1162 | 1168 | ||
1163 | 1169 | ||
1164 | /** | 1170 | /** |
1165 | * @return the Selector of the OFileSelector | 1171 | * @return the Selector of the OFileSelector |
1166 | */ | 1172 | */ |
1167 | int OFileSelector::selector()const | 1173 | int OFileSelector::selector()const |
1168 | { | 1174 | { |
1169 | return m_selector; | 1175 | return m_selector; |
1170 | } | 1176 | } |
1171 | 1177 | ||
1172 | QStringList OFileSelector::currentMimeType()const | 1178 | QStringList OFileSelector::currentMimeType()const |
1173 | { | 1179 | { |
1174 | return m_mimeType[m_cmbMime->currentText()]; | 1180 | return m_mimeType[m_cmbMime->currentText()]; |
1175 | } | 1181 | } |
1176 | 1182 | ||
1177 | void OFileSelector::slotMimeTypeChanged() | 1183 | void OFileSelector::slotMimeTypeChanged() |
1178 | { | 1184 | { |
1179 | reread(); | 1185 | reread(); |
1180 | } | 1186 | } |
1181 | 1187 | ||
1182 | void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) | 1188 | void OFileSelector::slotDocLnkBridge( const DocLnk& lnk) |
1183 | { | 1189 | { |
1184 | m_lneEdit->setText( lnk.name() ); | 1190 | m_lneEdit->setText( lnk.name() ); |
1185 | emit fileSelected( lnk ); | 1191 | emit fileSelected( lnk ); |
1186 | emit fileSelected( lnk.name() ); | 1192 | emit fileSelected( lnk.name() ); |
1187 | } | 1193 | } |
1188 | 1194 | ||
1189 | void OFileSelector::slotFileBridge( const QString& str) | 1195 | void OFileSelector::slotFileBridge( const QString& str) |
1190 | { | 1196 | { |
1191 | DocLnk lnk( str ); | 1197 | DocLnk lnk( str ); |
1192 | emit fileSelected( lnk ); | 1198 | emit fileSelected( lnk ); |
1193 | } | 1199 | } |
1194 | 1200 | ||
1195 | void OFileSelector::slotViewChange( const QString& view ) | 1201 | void OFileSelector::slotViewChange( const QString& view ) |
1196 | { | 1202 | { |
1197 | OFileViewInterface* interface = m_views[view]; | 1203 | OFileViewInterface* interface = m_views[view]; |
1198 | if (!interface) | 1204 | if (!interface) |
1199 | return; | 1205 | return; |
1200 | 1206 | ||
1201 | if (m_current) | 1207 | if (m_current) |
1202 | m_stack->removeWidget( m_current->widget( m_stack ) ); | 1208 | m_stack->removeWidget( m_current->widget( m_stack ) ); |
1203 | 1209 | ||
1204 | static int id = 1; | 1210 | static int id = 1; |
1205 | 1211 | ||
1206 | m_stack->addWidget( interface->widget(m_stack), id ); | 1212 | m_stack->addWidget( interface->widget(m_stack), id ); |
1207 | m_stack->raiseWidget( id ); | 1213 | m_stack->raiseWidget( id ); |
1208 | 1214 | ||
1209 | interface->activate( view ); | 1215 | interface->activate( view ); |
1210 | interface->reread(); | 1216 | interface->reread(); |
1211 | m_current = interface; | 1217 | m_current = interface; |
1212 | 1218 | ||
1213 | id++; | 1219 | id++; |
1214 | } | 1220 | } |
1215 | 1221 | ||
1216 | void OFileSelector::setNewVisible( bool b ) | 1222 | void OFileSelector::setNewVisible( bool b ) |
1217 | { | 1223 | { |
1218 | m_shNew = b; | 1224 | m_shNew = b; |
1219 | currentView()->reread(); | 1225 | currentView()->reread(); |
1220 | } | 1226 | } |
1221 | 1227 | ||
1222 | void OFileSelector::setCloseVisible( bool b ) | 1228 | void OFileSelector::setCloseVisible( bool b ) |
1223 | { | 1229 | { |
1224 | m_shClose = b; | 1230 | m_shClose = b; |
1225 | currentView()->reread(); | 1231 | currentView()->reread(); |
1226 | } | 1232 | } |
1227 | 1233 | ||
1228 | void OFileSelector::setNameVisible( bool b ) | 1234 | void OFileSelector::setNameVisible( bool b ) |
1229 | { | 1235 | { |
1230 | if ( b ) | 1236 | if ( b ) |
1231 | m_nameBox->show(); | 1237 | m_nameBox->show(); |
1232 | else | 1238 | else |
1233 | m_nameBox->hide(); | 1239 | m_nameBox->hide(); |
1234 | } | 1240 | } |
1235 | 1241 | ||
1236 | } | 1242 | } |
1237 | } | 1243 | } |
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 | |||
@@ -1,194 +1,196 @@ | |||
1 | /* | 1 | /* |
2 | =. This file is part of the OPIE Project | 2 | =. This file is part of the OPIE Project |
3 | .=l. Copyright (C) Holger Freyther <zecke@handhelds.org> | 3 | .=l. Copyright (C) Holger Freyther <zecke@handhelds.org> |
4 | .>+-= | 4 | .>+-= |
5 | _;:, .> :=|. This library is free software; you can | 5 | _;:, .> :=|. This library is free software; you can |
6 | .> <`_, > . <= redistribute it and/or modify it under | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | .="- .-=="i, .._ License as published by the Free Software | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ._= =} : or (at your option) any later version. | 10 | ._= =} : or (at your option) any later version. |
11 | .%`+i> _;_. | 11 | .%`+i> _;_. |
12 | .i_,=:_. -<s. This library is distributed in the hope that | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | : .. .:, . . . without even the implied warranty of | 14 | : .. .:, . . . without even the implied warranty of |
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ..}^=.= = ; Library General Public License for more | 17 | ..}^=.= = ; Library General Public License for more |
18 | ++= -. .` .: details. | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | -_. . . )=. = Library General Public License along with | 21 | -_. . . )=. = Library General Public License along with |
22 | -- :-=` this library; see the file COPYING.LIB. | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | If not, write to the Free Software Foundation, | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | 24 | Inc., 59 Temple Place - Suite 330, |
25 | Boston, MA 02111-1307, USA. | 25 | Boston, MA 02111-1307, USA. |
26 | 26 | ||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifndef OFILESELECTOR_PRIVATE_H | 29 | #ifndef OFILESELECTOR_PRIVATE_H |
30 | #define OFILESELECTOR_PRIVATE_H | 30 | #define OFILESELECTOR_PRIVATE_H |
31 | 31 | ||
32 | /* OPIE */ | 32 | /* OPIE */ |
33 | #include <qpe/applnk.h> | 33 | #include <qpe/applnk.h> |
34 | #include <qpe/fileselector.h> | 34 | #include <qpe/fileselector.h> |
35 | 35 | ||
36 | /* QT */ | 36 | /* QT */ |
37 | #include <qmap.h> | 37 | #include <qmap.h> |
38 | #include <qstringlist.h> | 38 | #include <qstringlist.h> |
39 | #include <qwidget.h> | 39 | #include <qwidget.h> |
40 | #include <qlistview.h> | 40 | #include <qlistview.h> |
41 | 41 | ||
42 | /* | 42 | /* |
43 | * How to avoid having really two different objects | 43 | * How to avoid having really two different objects |
44 | * for Extended and ExtendedAll | 44 | * for Extended and ExtendedAll |
45 | * The only difference is the Lister... | 45 | * The only difference is the Lister... |
46 | * a) static object? | 46 | * a) static object? |
47 | * b) leave some object inside the OFileSelector which can be used? | 47 | * b) leave some object inside the OFileSelector which can be used? |
48 | * c) when switching views tell which view we want o have.. internally we can switch then | 48 | * c) when switching views tell which view we want o have.. internally we can switch then |
49 | * | 49 | * |
50 | * I'll take c) -zecke | 50 | * I'll take c) -zecke |
51 | */ | 51 | */ |
52 | 52 | ||
53 | typedef QMap<QString, QStringList> MimeTypes; | 53 | typedef QMap<QString, QStringList> MimeTypes; |
54 | 54 | ||
55 | /* the View Interface */ | 55 | /* the View Interface */ |
56 | class QFileInfo; | 56 | class QFileInfo; |
57 | class QToolButton; | 57 | class QToolButton; |
58 | 58 | ||
59 | namespace Opie{ | 59 | namespace Opie{ |
60 | namespace Ui{ | 60 | namespace Ui{ |
61 | class OFileSelector; | 61 | class OFileSelector; |
62 | namespace Internal { | 62 | namespace Internal { |
63 | 63 | ||
64 | class OFileViewInterface | 64 | class OFileViewInterface |
65 | { | 65 | { |
66 | public: | 66 | public: |
67 | OFileViewInterface( OFileSelector* selector ); | 67 | OFileViewInterface( OFileSelector* selector ); |
68 | virtual ~OFileViewInterface(); | 68 | virtual ~OFileViewInterface(); |
69 | virtual QString selectedName()const = 0; | 69 | virtual QString selectedName()const = 0; |
70 | virtual QString selectedPath()const = 0; | 70 | virtual QString selectedPath()const = 0; |
71 | virtual QString directory()const = 0; | 71 | virtual QString directory()const = 0; |
72 | virtual void reread() = 0; | 72 | virtual void reread() = 0; |
73 | virtual int fileCount()const = 0; | 73 | virtual int fileCount()const = 0; |
74 | virtual DocLnk selectedDocument()const; | 74 | virtual DocLnk selectedDocument()const; |
75 | virtual QWidget* widget( QWidget* parent) = 0; | 75 | virtual QWidget* widget( QWidget* parent) = 0; |
76 | virtual void activate( const QString& ); | 76 | virtual void activate( const QString& ); |
77 | QString name()const; | 77 | QString name()const; |
78 | bool allItem( const QString& )const; | 78 | bool allItem( const QString& )const; |
79 | protected: | 79 | protected: |
80 | OFileSelector* selector()const; | 80 | OFileSelector* selector()const; |
81 | void setName( const QString& ); | 81 | void setName( const QString& ); |
82 | bool showNew()const; | 82 | bool showNew()const; |
83 | bool showClose()const; | 83 | bool showClose()const; |
84 | MimeTypes mimeTypes()const; | 84 | MimeTypes mimeTypes()const; |
85 | QStringList currentMimeType()const; | 85 | QStringList currentMimeType()const; |
86 | QString startDirectory()const; | 86 | QString startDirectory()const; |
87 | protected: | 87 | protected: |
88 | void ok(); | 88 | void ok(); |
89 | void cancel(); | 89 | void cancel(); |
90 | void closeMe(); | 90 | void closeMe(); |
91 | void fileSelected( const QString& ); | 91 | void fileSelected( const QString& ); |
92 | void fileSelected( const DocLnk& ); | 92 | void fileSelected( const DocLnk& ); |
93 | void setCurrentFileName( const QString& ); | 93 | void setCurrentFileName( const QString& ); |
94 | QString currentFileName()const; | 94 | QString currentFileName()const; |
95 | 95 | ||
96 | private: | 96 | private: |
97 | QString m_name; | 97 | QString m_name; |
98 | OFileSelector* m_selector; | 98 | OFileSelector* m_selector; |
99 | }; | 99 | }; |
100 | 100 | ||
101 | 101 | ||
102 | /* THE Document View hosting a FileSelector*/ | 102 | /* THE Document View hosting a FileSelector*/ |
103 | class ODocumentFileView : public OFileViewInterface | 103 | class ODocumentFileView : public OFileViewInterface |
104 | { | 104 | { |
105 | public: | 105 | public: |
106 | ODocumentFileView( OFileSelector* selector ); | 106 | ODocumentFileView( OFileSelector* selector ); |
107 | ~ODocumentFileView(); | 107 | ~ODocumentFileView(); |
108 | 108 | ||
109 | QString selectedName() const; | 109 | QString selectedName() const; |
110 | QString selectedPath() const; | 110 | QString selectedPath() const; |
111 | 111 | ||
112 | QString directory() const; | 112 | QString directory() const; |
113 | void reread(); | 113 | void reread(); |
114 | int fileCount()const; | 114 | int fileCount()const; |
115 | DocLnk selectedDocument()const; | 115 | DocLnk selectedDocument()const; |
116 | 116 | ||
117 | QWidget* widget( QWidget* parent ); | 117 | QWidget* widget( QWidget* parent ); |
118 | 118 | ||
119 | private: | 119 | private: |
120 | mutable FileSelector* m_selector; | 120 | mutable FileSelector* m_selector; |
121 | 121 | ||
122 | }; | 122 | }; |
123 | 123 | ||
124 | 124 | ||
125 | class OFileSelectorItem : public QListViewItem | 125 | class OFileSelectorItem : public QListViewItem |
126 | { | 126 | { |
127 | public: | 127 | public: |
128 | OFileSelectorItem( QListView* view, const QPixmap& pixmap, | 128 | OFileSelectorItem( QListView* view, const QPixmap& pixmap, |
129 | const QString& path, const QString& date, | 129 | const QString& path, const QString& date, |
130 | const QString& size, const QString& mDir, | 130 | const QString& size, const QString& mDir, |
131 | bool isLocked = false, bool isDir = false ); | 131 | bool isLocked = false, bool isDir = false ); |
132 | ~OFileSelectorItem(); | 132 | ~OFileSelectorItem(); |
133 | bool isLocked()const; | 133 | bool isLocked()const; |
134 | bool isDir()const; | 134 | bool isDir()const; |
135 | QString directory()const; | 135 | QString directory()const; |
136 | QString path()const; | 136 | QString path()const; |
137 | QString key(int id, bool )const; | 137 | QString key(int id, bool )const; |
138 | 138 | ||
139 | private: | 139 | private: |
140 | QString m_dir; | 140 | QString m_dir; |
141 | bool m_isDir : 1; | 141 | bool m_isDir : 1; |
142 | bool m_locked : 1; | 142 | bool m_locked : 1; |
143 | }; | 143 | }; |
144 | 144 | ||
145 | class OFileViewFileListView : public QWidget | 145 | class OFileViewFileListView : public QWidget |
146 | { | 146 | { |
147 | Q_OBJECT | 147 | Q_OBJECT |
148 | public: | 148 | public: |
149 | OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector ); | 149 | OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector ); |
150 | ~OFileViewFileListView(); | 150 | ~OFileViewFileListView(); |
151 | 151 | ||
152 | OFileSelectorItem* currentItem()const; | 152 | OFileSelectorItem* currentItem()const; |
153 | void reread( bool all = false ); | 153 | void reread( bool all = false ); |
154 | int fileCount()const; | 154 | int fileCount()const; |
155 | QString currentDir()const; | 155 | QString currentDir()const; |
156 | protected: | 156 | protected: |
157 | bool eventFilter (QObject *o, QEvent *e); | 157 | bool eventFilter (QObject *o, QEvent *e); |
158 | private slots: | 158 | private slots: |
159 | void slotNew(); // will emit newSelected | 159 | void slotNew(); // will emit newSelected |
160 | void cdUP(); | 160 | void cdUP(); |
161 | void cdHome(); | 161 | void cdHome(); |
162 | void cdDoc(); | 162 | void cdDoc(); |
163 | void changeDir( const QString& ); | 163 | void changeDir( const QString& ); |
164 | void slotCurrentChanged( QListViewItem* ); | 164 | void slotCurrentChanged( QListViewItem* ); |
165 | void slotClicked(int, QListViewItem*, const QPoint&, int ); | 165 | void slotClicked(int, QListViewItem*, const QPoint&, int ); |
166 | void slotFSActivated(int); | 166 | void slotFSActivated(int); |
167 | void slotFSpressed(); | ||
167 | 168 | ||
168 | protected: | 169 | protected: |
169 | OFileSelector* selector(); | 170 | OFileSelector* selector(); |
170 | 171 | ||
171 | private: | 172 | private: |
172 | QMap<QString, QString> m_dev; | 173 | QMap<QString, QString> m_dev; |
173 | bool m_all : 1; | 174 | bool m_all : 1; |
174 | OFileSelector* m_sel; | 175 | OFileSelector* m_sel; |
175 | QPopupMenu* m_fsPop; | 176 | QPopupMenu* m_fsPop; |
176 | bool compliesMime( const QString& ); | 177 | bool compliesMime( const QString& ); |
177 | QStringList m_mimes; // used in compy mime | 178 | QStringList m_mimes; // used in compy mime |
178 | QString m_currentDir; | 179 | QString m_currentDir; |
179 | QToolButton *m_btnNew, *m_btnClose; | 180 | QToolButton *m_btnNew, *m_btnClose; |
181 | QToolButton *m_fsButton; | ||
180 | void connectSlots(); | 182 | void connectSlots(); |
181 | void addFile( QFileInfo* info, bool symlink = FALSE ); | 183 | void addFile( QFileInfo* info, bool symlink = FALSE ); |
182 | void addDir ( QFileInfo* info, bool symlink = FALSE ); | 184 | void addDir ( QFileInfo* info, bool symlink = FALSE ); |
183 | void addSymlink( QFileInfo* info, bool = FALSE ); | 185 | void addSymlink( QFileInfo* info, bool = FALSE ); |
184 | 186 | ||
185 | 187 | ||
186 | private: | 188 | private: |
187 | QListView* m_view; | 189 | QListView* m_view; |
188 | }; | 190 | }; |
189 | 191 | ||
190 | } | 192 | } |
191 | } | 193 | } |
192 | } | 194 | } |
193 | 195 | ||
194 | #endif | 196 | #endif |