author | zecke <zecke> | 2005-02-07 22:41:59 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-07 22:41:59 (UTC) |
commit | f112fe72adcfb8d3c6745c6ff878cbfbbdfbfa24 (patch) (unidiff) | |
tree | 95f03410ad60ed5d04486821e9bc76cf1e3664ec | |
parent | 2e4fd59ce900490ccbbb6c0f7b2fcd4811ac8a07 (diff) | |
download | opie-f112fe72adcfb8d3c6745c6ff878cbfbbdfbfa24.zip opie-f112fe72adcfb8d3c6745c6ff878cbfbbdfbfa24.tar.gz opie-f112fe72adcfb8d3c6745c6ff878cbfbbdfbfa24.tar.bz2 |
Fix for #1482, do not start a path with "//". We do that by having
a method to assemble paths to avoid adding a second "/"
-rw-r--r-- | libopie2/opieui/fileselector/ofileselector.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp index 718f743..74aca96 100644 --- a/libopie2/opieui/fileselector/ofileselector.cpp +++ b/libopie2/opieui/fileselector/ofileselector.cpp | |||
@@ -1,1039 +1,1049 @@ | |||
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 | /* | ||
66 | * Create a path by adding a '/'/QDir::seperator in between | ||
67 | * base and ending, but only if base is not empty | ||
68 | */ | ||
69 | static inline QString createNewPath(const QString& base, const QString &ending) { | ||
70 | return base == QString::fromLatin1("/") ? | ||
71 | base + ending : base + "/" + ending; | ||
72 | } | ||
73 | |||
74 | |||
65 | OFileViewInterface::OFileViewInterface( OFileSelector* _selector ) | 75 | OFileViewInterface::OFileViewInterface( OFileSelector* _selector ) |
66 | : m_selector( _selector ) | 76 | : m_selector( _selector ) |
67 | { | 77 | { |
68 | selector()->registerView( this ); | 78 | selector()->registerView( this ); |
69 | } | 79 | } |
70 | 80 | ||
71 | OFileViewInterface::~OFileViewInterface() | 81 | OFileViewInterface::~OFileViewInterface() |
72 | {} | 82 | {} |
73 | 83 | ||
74 | QString OFileViewInterface::name()const | 84 | QString OFileViewInterface::name()const |
75 | { | 85 | { |
76 | return m_name; | 86 | return m_name; |
77 | } | 87 | } |
78 | 88 | ||
79 | void OFileViewInterface::setName( const QString& name ) | 89 | void OFileViewInterface::setName( const QString& name ) |
80 | { | 90 | { |
81 | m_name = name; | 91 | m_name = name; |
82 | } | 92 | } |
83 | 93 | ||
84 | OFileSelector* OFileViewInterface::selector()const | 94 | OFileSelector* OFileViewInterface::selector()const |
85 | { | 95 | { |
86 | return m_selector; | 96 | return m_selector; |
87 | } | 97 | } |
88 | 98 | ||
89 | DocLnk OFileViewInterface::selectedDocument()const | 99 | DocLnk OFileViewInterface::selectedDocument()const |
90 | { | 100 | { |
91 | return DocLnk( selectedName() ); | 101 | return DocLnk( selectedName() ); |
92 | } | 102 | } |
93 | 103 | ||
94 | bool OFileViewInterface::showNew()const | 104 | bool OFileViewInterface::showNew()const |
95 | { | 105 | { |
96 | return selector()->showNew(); | 106 | return selector()->showNew(); |
97 | } | 107 | } |
98 | 108 | ||
99 | bool OFileViewInterface::showClose()const | 109 | bool OFileViewInterface::showClose()const |
100 | { | 110 | { |
101 | return selector()->showClose(); | 111 | return selector()->showClose(); |
102 | } | 112 | } |
103 | 113 | ||
104 | MimeTypes OFileViewInterface::mimeTypes()const | 114 | MimeTypes OFileViewInterface::mimeTypes()const |
105 | { | 115 | { |
106 | return selector()->mimeTypes(); | 116 | return selector()->mimeTypes(); |
107 | } | 117 | } |
108 | 118 | ||
109 | QStringList OFileViewInterface::currentMimeType()const | 119 | QStringList OFileViewInterface::currentMimeType()const |
110 | { | 120 | { |
111 | return selector()->currentMimeType(); | 121 | return selector()->currentMimeType(); |
112 | } | 122 | } |
113 | 123 | ||
114 | void OFileViewInterface::activate( const QString& ) | 124 | void OFileViewInterface::activate( const QString& ) |
115 | { | 125 | { |
116 | // not implemented here | 126 | // not implemented here |
117 | } | 127 | } |
118 | 128 | ||
119 | void OFileViewInterface::ok() | 129 | void OFileViewInterface::ok() |
120 | { | 130 | { |
121 | emit selector()->ok(); | 131 | emit selector()->ok(); |
122 | } | 132 | } |
123 | 133 | ||
124 | void OFileViewInterface::cancel() | 134 | void OFileViewInterface::cancel() |
125 | { | 135 | { |
126 | emit selector()->cancel(); | 136 | emit selector()->cancel(); |
127 | } | 137 | } |
128 | 138 | ||
129 | void OFileViewInterface::closeMe() | 139 | void OFileViewInterface::closeMe() |
130 | { | 140 | { |
131 | emit selector()->closeMe(); | 141 | emit selector()->closeMe(); |
132 | } | 142 | } |
133 | 143 | ||
134 | void OFileViewInterface::fileSelected( const QString& str) | 144 | void OFileViewInterface::fileSelected( const QString& str) |
135 | { | 145 | { |
136 | emit selector()->fileSelected( str); | 146 | emit selector()->fileSelected( str); |
137 | } | 147 | } |
138 | 148 | ||
139 | void OFileViewInterface::fileSelected( const DocLnk& lnk) | 149 | void OFileViewInterface::fileSelected( const DocLnk& lnk) |
140 | { | 150 | { |
141 | emit selector()->fileSelected( lnk ); | 151 | emit selector()->fileSelected( lnk ); |
142 | } | 152 | } |
143 | 153 | ||
144 | void OFileViewInterface::setCurrentFileName( const QString& str ) | 154 | void OFileViewInterface::setCurrentFileName( const QString& str ) |
145 | { | 155 | { |
146 | selector()->m_lneEdit->setText( str ); | 156 | selector()->m_lneEdit->setText( str ); |
147 | } | 157 | } |
148 | 158 | ||
149 | QString OFileViewInterface::currentFileName()const | 159 | QString OFileViewInterface::currentFileName()const |
150 | { | 160 | { |
151 | return selector()->m_lneEdit->text(); | 161 | return selector()->m_lneEdit->text(); |
152 | } | 162 | } |
153 | 163 | ||
154 | QString OFileViewInterface::startDirectory()const | 164 | QString OFileViewInterface::startDirectory()const |
155 | { | 165 | { |
156 | return selector()->m_startDir; | 166 | return selector()->m_startDir; |
157 | } | 167 | } |
158 | 168 | ||
159 | bool OFileViewInterface::allItem( const QString& item )const | 169 | bool OFileViewInterface::allItem( const QString& item )const |
160 | { | 170 | { |
161 | return selector()->m_allList.contains( item ); | 171 | return selector()->m_allList.contains( item ); |
162 | } | 172 | } |
163 | 173 | ||
164 | 174 | ||
165 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) | 175 | ODocumentFileView::ODocumentFileView( OFileSelector* selector ) |
166 | :OFileViewInterface( selector ) | 176 | :OFileViewInterface( selector ) |
167 | { | 177 | { |
168 | m_selector = 0; | 178 | m_selector = 0; |
169 | setName( QObject::tr("Documents") ); | 179 | setName( QObject::tr("Documents") ); |
170 | } | 180 | } |
171 | 181 | ||
172 | ODocumentFileView::~ODocumentFileView() | 182 | ODocumentFileView::~ODocumentFileView() |
173 | { | 183 | { |
174 | } | 184 | } |
175 | 185 | ||
176 | QString ODocumentFileView::selectedName()const | 186 | QString ODocumentFileView::selectedName()const |
177 | { | 187 | { |
178 | if (!m_selector) | 188 | if (!m_selector) |
179 | return QString::null; | 189 | return QString::null; |
180 | 190 | ||
181 | return m_selector->selectedDocument().file(); | 191 | return m_selector->selectedDocument().file(); |
182 | } | 192 | } |
183 | 193 | ||
184 | QString ODocumentFileView::selectedPath()const | 194 | QString ODocumentFileView::selectedPath()const |
185 | { | 195 | { |
186 | return QPEApplication::documentDir(); | 196 | return QPEApplication::documentDir(); |
187 | } | 197 | } |
188 | 198 | ||
189 | QString ODocumentFileView::directory()const | 199 | QString ODocumentFileView::directory()const |
190 | { | 200 | { |
191 | return selectedPath(); | 201 | return selectedPath(); |
192 | } | 202 | } |
193 | 203 | ||
194 | void ODocumentFileView::reread() | 204 | void ODocumentFileView::reread() |
195 | { | 205 | { |
196 | if (!m_selector) | 206 | if (!m_selector) |
197 | return; | 207 | return; |
198 | 208 | ||
199 | m_selector->setNewVisible( showNew() ); | 209 | m_selector->setNewVisible( showNew() ); |
200 | m_selector->setCloseVisible( showClose() ); | 210 | m_selector->setCloseVisible( showClose() ); |
201 | m_selector->filter = currentMimeType().join(";"); | 211 | m_selector->filter = currentMimeType().join(";"); |
202 | m_selector->reread(); | 212 | m_selector->reread(); |
203 | } | 213 | } |
204 | 214 | ||
205 | int ODocumentFileView::fileCount()const | 215 | int ODocumentFileView::fileCount()const |
206 | { | 216 | { |
207 | if (!m_selector) | 217 | if (!m_selector) |
208 | return -1; | 218 | return -1; |
209 | 219 | ||
210 | return m_selector->fileCount(); | 220 | return m_selector->fileCount(); |
211 | } | 221 | } |
212 | 222 | ||
213 | DocLnk ODocumentFileView::selectedDocument()const | 223 | DocLnk ODocumentFileView::selectedDocument()const |
214 | { | 224 | { |
215 | if (!m_selector) | 225 | if (!m_selector) |
216 | return DocLnk(); | 226 | return DocLnk(); |
217 | 227 | ||
218 | return m_selector->selectedDocument(); | 228 | return m_selector->selectedDocument(); |
219 | } | 229 | } |
220 | 230 | ||
221 | QWidget* ODocumentFileView::widget( QWidget* parent ) | 231 | QWidget* ODocumentFileView::widget( QWidget* parent ) |
222 | { | 232 | { |
223 | if (!m_selector ) | 233 | if (!m_selector ) |
224 | { | 234 | { |
225 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); | 235 | m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); |
226 | QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ), | 236 | QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ), |
227 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); | 237 | selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); |
228 | QObject::connect(m_selector, SIGNAL(closeMe() ), | 238 | QObject::connect(m_selector, SIGNAL(closeMe() ), |
229 | selector(), SIGNAL(closeMe() ) ); | 239 | selector(), SIGNAL(closeMe() ) ); |
230 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ), | 240 | QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ), |
231 | selector(), SIGNAL(newSelected(const DocLnk&) ) ); | 241 | selector(), SIGNAL(newSelected(const DocLnk&) ) ); |
232 | } | 242 | } |
233 | 243 | ||
234 | return m_selector; | 244 | return m_selector; |
235 | } | 245 | } |
236 | 246 | ||
237 | /* | 247 | /* |
238 | * This is the file system view used | 248 | * This is the file system view used |
239 | * we use a QListView + QListViewItems for it | 249 | * we use a QListView + QListViewItems for it |
240 | */ | 250 | */ |
241 | 251 | ||
242 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, | 252 | OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, |
243 | const QString& path, const QString& date, | 253 | const QString& path, const QString& date, |
244 | const QString& size, const QString& dir, | 254 | const QString& size, const QString& dir, |
245 | bool isLocked, bool isDir ) | 255 | bool isLocked, bool isDir ) |
246 | : QListViewItem( view ), m_dir(dir), m_isDir(isDir), m_locked(isLocked) | 256 | : QListViewItem( view ), m_dir(dir), m_isDir(isDir), m_locked(isLocked) |
247 | { | 257 | { |
248 | setPixmap(0, pixmap ); | 258 | setPixmap(0, pixmap ); |
249 | setText(1, path ); | 259 | setText(1, path ); |
250 | setText(2, size ); | 260 | setText(2, size ); |
251 | setText(3, date ); | 261 | setText(3, date ); |
252 | } | 262 | } |
253 | 263 | ||
254 | OFileSelectorItem::~OFileSelectorItem() | 264 | OFileSelectorItem::~OFileSelectorItem() |
255 | { | 265 | { |
256 | } | 266 | } |
257 | 267 | ||
258 | bool OFileSelectorItem::isLocked()const | 268 | bool OFileSelectorItem::isLocked()const |
259 | { | 269 | { |
260 | return m_locked; | 270 | return m_locked; |
261 | } | 271 | } |
262 | 272 | ||
263 | QString OFileSelectorItem::directory()const | 273 | QString OFileSelectorItem::directory()const |
264 | { | 274 | { |
265 | return m_dir; | 275 | return m_dir; |
266 | } | 276 | } |
267 | 277 | ||
268 | bool OFileSelectorItem::isDir()const | 278 | bool OFileSelectorItem::isDir()const |
269 | { | 279 | { |
270 | return m_isDir; | 280 | return m_isDir; |
271 | } | 281 | } |
272 | 282 | ||
273 | QString OFileSelectorItem::path()const | 283 | QString OFileSelectorItem::path()const |
274 | { | 284 | { |
275 | return text( 1 ); | 285 | return text( 1 ); |
276 | } | 286 | } |
277 | 287 | ||
278 | QString OFileSelectorItem::key( int id, bool )const | 288 | QString OFileSelectorItem::key( int id, bool )const |
279 | { | 289 | { |
280 | QString ke; | 290 | QString ke; |
281 | 291 | ||
282 | /* | 292 | /* |
283 | * id = 0 ||id == 1 : Sort By Name but Directories at Top | 293 | * id = 0 ||id == 1 : Sort By Name but Directories at Top |
284 | * id = 2 : Sort By Size: Prepend '0' to the key | 294 | * id = 2 : Sort By Size: Prepend '0' to the key |
285 | */ | 295 | */ |
286 | if( id == 0 || id == 1 ) | 296 | if( id == 0 || id == 1 ) |
287 | { // name | 297 | { // name |
288 | if( m_isDir ) | 298 | if( m_isDir ) |
289 | { | 299 | { |
290 | ke.append("0" ); | 300 | ke.append("0" ); |
291 | ke.append( text(1) ); | 301 | ke.append( text(1) ); |
292 | } | 302 | } |
293 | else | 303 | else |
294 | { | 304 | { |
295 | ke.append("1" ); | 305 | ke.append("1" ); |
296 | ke.append( text(1) ); | 306 | ke.append( text(1) ); |
297 | } | 307 | } |
298 | return ke; | 308 | return ke; |
299 | }else if(id == 2) { | 309 | }else if(id == 2) { |
300 | return text(2).rightJustify(20, '0'); | 310 | return text(2).rightJustify(20, '0'); |
301 | }else | 311 | }else |
302 | return text( id ); | 312 | return text( id ); |
303 | 313 | ||
304 | } | 314 | } |
305 | 315 | ||
306 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) | 316 | OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) |
307 | :QWidget( parent ), m_sel( sel ) | 317 | :QWidget( parent ), m_sel( sel ) |
308 | { | 318 | { |
309 | m_all = false; | 319 | m_all = false; |
310 | QVBoxLayout* lay = new QVBoxLayout( this ); | 320 | QVBoxLayout* lay = new QVBoxLayout( this ); |
311 | m_currentDir = startDir; | 321 | m_currentDir = startDir; |
312 | 322 | ||
313 | /* | 323 | /* |
314 | * now we add a special bar | 324 | * now we add a special bar |
315 | * One Button For Up | 325 | * One Button For Up |
316 | * Home | 326 | * Home |
317 | * Doc | 327 | * Doc |
318 | * And a dropdown menu with FileSystems | 328 | * And a dropdown menu with FileSystems |
319 | * FUTURE: one to change dir with lineedit | 329 | * FUTURE: one to change dir with lineedit |
320 | * Bookmarks | 330 | * Bookmarks |
321 | * Create Dir | 331 | * Create Dir |
322 | */ | 332 | */ |
323 | QHBox* box = new QHBox(this ); | 333 | QHBox* box = new QHBox(this ); |
324 | box->setBackgroundMode( PaletteButton ); | 334 | box->setBackgroundMode( PaletteButton ); |
325 | box->setSpacing( 0 ); | 335 | box->setSpacing( 0 ); |
326 | 336 | ||
327 | QToolButton *btn = new QToolButton( box ); | 337 | QToolButton *btn = new QToolButton( box ); |
328 | btn->setIconSet( Resource::loadIconSet("up") ); | 338 | btn->setIconSet( Resource::loadIconSet("up") ); |
329 | connect(btn, SIGNAL(clicked() ), | 339 | connect(btn, SIGNAL(clicked() ), |
330 | this, SLOT( cdUP() ) ); | 340 | this, SLOT( cdUP() ) ); |
331 | 341 | ||
332 | btn = new QToolButton( box ); | 342 | btn = new QToolButton( box ); |
333 | btn->setIconSet( Resource::loadIconSet("home") ); | 343 | btn->setIconSet( Resource::loadIconSet("home") ); |
334 | connect(btn, SIGNAL(clicked() ), | 344 | connect(btn, SIGNAL(clicked() ), |
335 | this, SLOT( cdHome() ) ); | 345 | this, SLOT( cdHome() ) ); |
336 | 346 | ||
337 | btn = new QToolButton( box ); | 347 | btn = new QToolButton( box ); |
338 | btn->setIconSet( Resource::loadIconSet("DocsIcon") ); | 348 | btn->setIconSet( Resource::loadIconSet("DocsIcon") ); |
339 | connect(btn, SIGNAL(clicked() ), | 349 | connect(btn, SIGNAL(clicked() ), |
340 | this, SLOT(cdDoc() ) ); | 350 | this, SLOT(cdDoc() ) ); |
341 | 351 | ||
342 | m_btnNew = new QToolButton( box ); | 352 | m_btnNew = new QToolButton( box ); |
343 | m_btnNew->setIconSet( Resource::loadIconSet("new") ); | 353 | m_btnNew->setIconSet( Resource::loadIconSet("new") ); |
344 | connect(m_btnNew, SIGNAL(clicked() ), | 354 | connect(m_btnNew, SIGNAL(clicked() ), |
345 | this, SLOT(slotNew() ) ); | 355 | this, SLOT(slotNew() ) ); |
346 | 356 | ||
347 | 357 | ||
348 | m_btnClose = new QToolButton( box ); | 358 | m_btnClose = new QToolButton( box ); |
349 | m_btnClose->setIconSet( Resource::loadIconSet("close") ); | 359 | m_btnClose->setIconSet( Resource::loadIconSet("close") ); |
350 | connect(m_btnClose, SIGNAL(clicked() ), | 360 | connect(m_btnClose, SIGNAL(clicked() ), |
351 | selector(), SIGNAL(closeMe() ) ); | 361 | selector(), SIGNAL(closeMe() ) ); |
352 | 362 | ||
353 | btn = new QToolButton( box ); | 363 | btn = new QToolButton( box ); |
354 | btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") ); | 364 | btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") ); |
355 | 365 | ||
356 | /* let's fill device parts */ | 366 | /* let's fill device parts */ |
357 | QPopupMenu* pop = new QPopupMenu(this); | 367 | QPopupMenu* pop = new QPopupMenu(this); |
358 | connect(pop, SIGNAL( activated(int) ), | 368 | connect(pop, SIGNAL( activated(int) ), |
359 | this, SLOT(slotFSActivated(int) ) ); | 369 | this, SLOT(slotFSActivated(int) ) ); |
360 | 370 | ||
361 | StorageInfo storage; | 371 | StorageInfo storage; |
362 | const QList<FileSystem> &fs = storage.fileSystems(); | 372 | const QList<FileSystem> &fs = storage.fileSystems(); |
363 | QListIterator<FileSystem> it(fs); | 373 | QListIterator<FileSystem> it(fs); |
364 | for ( ; it.current(); ++it ) | 374 | for ( ; it.current(); ++it ) |
365 | { | 375 | { |
366 | const QString disk = (*it)->name(); | 376 | const QString disk = (*it)->name(); |
367 | const QString path = (*it)->path(); | 377 | const QString path = (*it)->path(); |
368 | m_dev.insert( disk, path ); | 378 | m_dev.insert( disk, path ); |
369 | pop->insertItem( disk ); | 379 | pop->insertItem( disk ); |
370 | } | 380 | } |
371 | m_fsPop = pop; | 381 | m_fsPop = pop; |
372 | 382 | ||
373 | 383 | ||
374 | btn->setPopup( pop ); | 384 | btn->setPopup( pop ); |
375 | 385 | ||
376 | lay->addWidget( box ); | 386 | lay->addWidget( box ); |
377 | 387 | ||
378 | m_view = new QListView( this ); | 388 | m_view = new QListView( this ); |
379 | 389 | ||
380 | m_view->installEventFilter(this); | 390 | m_view->installEventFilter(this); |
381 | 391 | ||
382 | QPEApplication::setStylusOperation( m_view->viewport(), | 392 | QPEApplication::setStylusOperation( m_view->viewport(), |
383 | QPEApplication::RightOnHold); | 393 | QPEApplication::RightOnHold); |
384 | m_view->addColumn(" " ); | 394 | m_view->addColumn(" " ); |
385 | m_view->addColumn(tr("Name"), 135 ); | 395 | m_view->addColumn(tr("Name"), 135 ); |
386 | m_view->addColumn(tr("Size"), -1 ); | 396 | m_view->addColumn(tr("Size"), -1 ); |
387 | m_view->addColumn(tr("Date"), 60 ); | 397 | m_view->addColumn(tr("Date"), 60 ); |
388 | m_view->addColumn(tr("Mime Type"), -1 ); | 398 | m_view->addColumn(tr("Mime Type"), -1 ); |
389 | 399 | ||
390 | 400 | ||
391 | m_view->setSorting( 1 ); | 401 | m_view->setSorting( 1 ); |
392 | m_view->setAllColumnsShowFocus( TRUE ); | 402 | m_view->setAllColumnsShowFocus( TRUE ); |
393 | 403 | ||
394 | lay->addWidget( m_view, 1000 ); | 404 | lay->addWidget( m_view, 1000 ); |
395 | connectSlots(); | 405 | connectSlots(); |
396 | } | 406 | } |
397 | 407 | ||
398 | OFileViewFileListView::~OFileViewFileListView() | 408 | OFileViewFileListView::~OFileViewFileListView() |
399 | { | 409 | { |
400 | } | 410 | } |
401 | 411 | ||
402 | void OFileViewFileListView::slotNew() | 412 | void OFileViewFileListView::slotNew() |
403 | { | 413 | { |
404 | DocLnk lnk; | 414 | DocLnk lnk; |
405 | emit selector()->newSelected( lnk ); | 415 | emit selector()->newSelected( lnk ); |
406 | } | 416 | } |
407 | 417 | ||
408 | OFileSelectorItem* OFileViewFileListView::currentItem()const | 418 | OFileSelectorItem* OFileViewFileListView::currentItem()const |
409 | { | 419 | { |
410 | QListViewItem* item = m_view->currentItem(); | 420 | QListViewItem* item = m_view->currentItem(); |
411 | if (!item ) | 421 | if (!item ) |
412 | return 0l; | 422 | return 0l; |
413 | 423 | ||
414 | return static_cast<OFileSelectorItem*>(item); | 424 | return static_cast<OFileSelectorItem*>(item); |
415 | } | 425 | } |
416 | 426 | ||
417 | void OFileViewFileListView::reread( bool all ) | 427 | void OFileViewFileListView::reread( bool all ) |
418 | { | 428 | { |
419 | m_view->clear(); | 429 | m_view->clear(); |
420 | 430 | ||
421 | if (selector()->showClose() ) | 431 | if (selector()->showClose() ) |
422 | m_btnClose->show(); | 432 | m_btnClose->show(); |
423 | else | 433 | else |
424 | m_btnClose->hide(); | 434 | m_btnClose->hide(); |
425 | 435 | ||
426 | if (selector()->showNew() ) | 436 | if (selector()->showNew() ) |
427 | m_btnNew->show(); | 437 | m_btnNew->show(); |
428 | else | 438 | else |
429 | m_btnNew->hide(); | 439 | m_btnNew->hide(); |
430 | 440 | ||
431 | m_mimes = selector()->currentMimeType(); | 441 | m_mimes = selector()->currentMimeType(); |
432 | m_all = all; | 442 | m_all = all; |
433 | 443 | ||
434 | QDir dir( m_currentDir ); | 444 | QDir dir( m_currentDir ); |
435 | if (!dir.exists() ) | 445 | if (!dir.exists() ) |
436 | return; | 446 | return; |
437 | 447 | ||
438 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 448 | dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
439 | int filter; | 449 | int filter; |
440 | filter = QDir::Dirs; | 450 | filter = QDir::Dirs; |
441 | if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR ) | 451 | if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR ) |
442 | filter = filter | QDir::Files | QDir::All; | 452 | filter = filter | QDir::Files | QDir::All; |
443 | 453 | ||
444 | if ( m_all ) | 454 | if ( m_all ) |
445 | filter = filter | QDir::Hidden; | 455 | filter = filter | QDir::Hidden; |
446 | 456 | ||
447 | dir.setFilter( filter ); | 457 | dir.setFilter( filter ); |
448 | 458 | ||
449 | // now go through all files | 459 | // now go through all files |
450 | const QFileInfoList *list = dir.entryInfoList(); | 460 | const QFileInfoList *list = dir.entryInfoList(); |
451 | if (!list) | 461 | if (!list) |
452 | { | 462 | { |
453 | cdUP(); | 463 | cdUP(); |
454 | return; | 464 | return; |
455 | } | 465 | } |
456 | 466 | ||
457 | QFileInfoListIterator it( *list ); | 467 | QFileInfoListIterator it( *list ); |
458 | QFileInfo *fi; | 468 | QFileInfo *fi; |
459 | while( (fi=it.current() ) ) | 469 | while( (fi=it.current() ) ) |
460 | { | 470 | { |
461 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) | 471 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) |
462 | { | 472 | { |
463 | ++it; | 473 | ++it; |
464 | continue; | 474 | continue; |
465 | } | 475 | } |
466 | 476 | ||
467 | /* | 477 | /* |
468 | * It is a symlink we try to resolve it now but don't let us attack by DOS | 478 | * It is a symlink we try to resolve it now but don't let us attack by DOS |
469 | * | 479 | * |
470 | */ | 480 | */ |
471 | if( fi->isSymLink() ) | 481 | if( fi->isSymLink() ) |
472 | { | 482 | { |
473 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | 483 | QString file = createNewPath(fi->dirPath( true ),fi->readLink()); |
474 | for( int i = 0; i<=4; i++) | 484 | for( int i = 0; i<=4; i++) |
475 | { // 5 tries to prevent dos | 485 | { // 5 tries to prevent dos |
476 | QFileInfo info( file ); | 486 | QFileInfo info( file ); |
477 | if( !info.exists() ) | 487 | if( !info.exists() ) |
478 | { | 488 | { |
479 | addSymlink( fi, TRUE ); | 489 | addSymlink( fi, TRUE ); |
480 | break; | 490 | break; |
481 | } | 491 | } |
482 | else if( info.isDir() ) | 492 | else if( info.isDir() ) |
483 | { | 493 | { |
484 | addDir( fi, TRUE ); | 494 | addDir( fi, TRUE ); |
485 | break; | 495 | break; |
486 | } | 496 | } |
487 | else if( info.isFile() ) | 497 | else if( info.isFile() ) |
488 | { | 498 | { |
489 | addFile( fi, TRUE ); | 499 | addFile( fi, TRUE ); |
490 | break; | 500 | break; |
491 | } | 501 | } |
492 | else if( info.isSymLink() ) | 502 | else if( info.isSymLink() ) |
493 | { | 503 | { |
494 | file = info.dirPath(true ) + "/" + info.readLink() ; | 504 | file = createNewPath(info.dirPath(true ),info.readLink()); |
495 | break; | 505 | break; |
496 | } | 506 | } |
497 | else if( i == 4) | 507 | else if( i == 4) |
498 | { // couldn't resolve symlink add it as symlink | 508 | { // couldn't resolve symlink add it as symlink |
499 | addSymlink( fi ); | 509 | addSymlink( fi ); |
500 | } | 510 | } |
501 | } // off for loop for symlink resolving | 511 | } // off for loop for symlink resolving |
502 | } | 512 | } |
503 | else if( fi->isDir() ) | 513 | else if( fi->isDir() ) |
504 | addDir( fi ); | 514 | addDir( fi ); |
505 | else if( fi->isFile() ) | 515 | else if( fi->isFile() ) |
506 | addFile( fi ); | 516 | addFile( fi ); |
507 | 517 | ||
508 | ++it; | 518 | ++it; |
509 | } // of while loop | 519 | } // of while loop |
510 | m_view->sort(); | 520 | m_view->sort(); |
511 | 521 | ||
512 | } | 522 | } |
513 | int OFileViewFileListView::fileCount()const | 523 | int OFileViewFileListView::fileCount()const |
514 | { | 524 | { |
515 | return m_view->childCount(); | 525 | return m_view->childCount(); |
516 | } | 526 | } |
517 | 527 | ||
518 | QString OFileViewFileListView::currentDir()const | 528 | QString OFileViewFileListView::currentDir()const |
519 | { | 529 | { |
520 | return m_currentDir; | 530 | return m_currentDir; |
521 | } | 531 | } |
522 | 532 | ||
523 | OFileSelector* OFileViewFileListView::selector() | 533 | OFileSelector* OFileViewFileListView::selector() |
524 | { | 534 | { |
525 | return m_sel; | 535 | return m_sel; |
526 | } | 536 | } |
527 | 537 | ||
528 | bool OFileViewFileListView::eventFilter (QObject *, QEvent *e) | 538 | bool OFileViewFileListView::eventFilter (QObject *, QEvent *e) |
529 | { | 539 | { |
530 | if ( e->type() == QEvent::KeyPress ) | 540 | if ( e->type() == QEvent::KeyPress ) |
531 | { | 541 | { |
532 | QKeyEvent *k = (QKeyEvent *)e; | 542 | QKeyEvent *k = (QKeyEvent *)e; |
533 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) | 543 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) |
534 | { | 544 | { |
535 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); | 545 | slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); |
536 | return true; | 546 | return true; |
537 | } | 547 | } |
538 | } | 548 | } |
539 | return false; | 549 | return false; |
540 | } | 550 | } |
541 | 551 | ||
542 | void OFileViewFileListView::connectSlots() | 552 | void OFileViewFileListView::connectSlots() |
543 | { | 553 | { |
544 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), | 554 | connect(m_view, SIGNAL(clicked(QListViewItem*) ), |
545 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); | 555 | this, SLOT(slotCurrentChanged(QListViewItem*) ) ); |
546 | connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), | 556 | connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), |
547 | this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); | 557 | this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); |
548 | } | 558 | } |
549 | 559 | ||
550 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) | 560 | void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) |
551 | { | 561 | { |
552 | if (!item) | 562 | if (!item) |
553 | return; | 563 | return; |
554 | #if 0 | 564 | #if 0 |
555 | 565 | ||
556 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 566 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
557 | 567 | ||
558 | if (!sel->isDir() ) | 568 | if (!sel->isDir() ) |
559 | { | 569 | { |
560 | selector()->m_lneEdit->setText( sel->text(1) ); | 570 | selector()->m_lneEdit->setText( sel->text(1) ); |
561 | // if in fileselector mode we will emit selected | 571 | // if in fileselector mode we will emit selected |
562 | if ( selector()->mode() == OFileSelector::FileSelector ) | 572 | if ( selector()->mode() == OFileSelector::FileSelector ) |
563 | { | 573 | { |
564 | odebug << "slot Current Changed" << oendl; | 574 | odebug << "slot Current Changed" << oendl; |
565 | QStringList str = QStringList::split("->", sel->text(1) ); | 575 | QStringList str = QStringList::split("->", sel->text(1) ); |
566 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 576 | QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace()); |
567 | emit selector()->fileSelected( path ); | 577 | emit selector()->fileSelected( path ); |
568 | DocLnk lnk( path ); | 578 | DocLnk lnk( path ); |
569 | emit selector()->fileSelected( lnk ); | 579 | emit selector()->fileSelected( lnk ); |
570 | } | 580 | } |
571 | } | 581 | } |
572 | #endif | 582 | #endif |
573 | } | 583 | } |
574 | 584 | ||
575 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) | 585 | void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) |
576 | { | 586 | { |
577 | if (!item || ( button != Qt::LeftButton) ) | 587 | if (!item || ( button != Qt::LeftButton) ) |
578 | return; | 588 | return; |
579 | 589 | ||
580 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); | 590 | OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); |
581 | if (!sel->isLocked() ) | 591 | if (!sel->isLocked() ) |
582 | { | 592 | { |
583 | QStringList str = QStringList::split("->", sel->text(1) ); | 593 | QStringList str = QStringList::split("->", sel->text(1) ); |
584 | if (sel->isDir() ) | 594 | if (sel->isDir() ) |
585 | { | 595 | { |
586 | m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); | 596 | m_currentDir = createNewPath(sel->directory(),str[0].stripWhiteSpace()); |
587 | emit selector()->dirSelected( m_currentDir ); | 597 | emit selector()->dirSelected( m_currentDir ); |
588 | reread( m_all ); | 598 | reread( m_all ); |
589 | } | 599 | } |
590 | else | 600 | else |
591 | { // file | 601 | { // file |
592 | odebug << "slot Clicked" << oendl; | 602 | odebug << "slot Clicked" << oendl; |
593 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); | 603 | selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); |
594 | QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); | 604 | QString path = createNewPath(sel->directory(),str[0].stripWhiteSpace()); |
595 | emit selector()->fileSelected( path ); | 605 | emit selector()->fileSelected( path ); |
596 | DocLnk lnk( path ); | 606 | DocLnk lnk( path ); |
597 | emit selector()->fileSelected( lnk ); | 607 | emit selector()->fileSelected( lnk ); |
598 | } | 608 | } |
599 | } // not locked | 609 | } // not locked |
600 | } | 610 | } |
601 | 611 | ||
602 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) | 612 | void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) |
603 | { | 613 | { |
604 | MimeType type( info->absFilePath() ); | 614 | MimeType type( info->absFilePath() ); |
605 | if (!compliesMime( type.id() ) ) | 615 | if (!compliesMime( type.id() ) ) |
606 | return; | 616 | return; |
607 | 617 | ||
608 | QPixmap pix = type.pixmap(); | 618 | QPixmap pix = type.pixmap(); |
609 | QString dir, name; bool locked; | 619 | QString dir, name; bool locked; |
610 | if ( pix.isNull() ) | 620 | if ( pix.isNull() ) |
611 | { | 621 | { |
612 | QWMatrix matrix; | 622 | QWMatrix matrix; |
613 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); | 623 | QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); |
614 | matrix.scale( .4, .4 ); | 624 | matrix.scale( .4, .4 ); |
615 | pix = pixer.xForm( matrix ); | 625 | pix = pixer.xForm( matrix ); |
616 | } | 626 | } |
617 | dir = info->dirPath( true ); | 627 | dir = info->dirPath( true ); |
618 | locked = false; | 628 | locked = false; |
619 | if ( symlink ) | 629 | if ( symlink ) |
620 | name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); | 630 | name = info->fileName() + " -> " + createNewPath(info->dirPath(),info->readLink()); |
621 | else | 631 | else |
622 | { | 632 | { |
623 | name = info->fileName(); | 633 | name = info->fileName(); |
624 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || | 634 | if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || |
625 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) | 635 | ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) |
626 | { | 636 | { |
627 | locked = true; pix = Resource::loadPixmap("locked"); | 637 | locked = true; pix = Resource::loadPixmap("locked"); |
628 | } | 638 | } |
629 | } | 639 | } |
630 | (void)new OFileSelectorItem( m_view, pix, name, | 640 | (void)new OFileSelectorItem( m_view, pix, name, |
631 | info->lastModified().toString(), QString::number( info->size() ), | 641 | info->lastModified().toString(), QString::number( info->size() ), |
632 | dir, locked ); | 642 | dir, locked ); |
633 | } | 643 | } |
634 | 644 | ||
635 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) | 645 | void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) |
636 | { | 646 | { |
637 | bool locked = false; QString name; QPixmap pix; | 647 | bool locked = false; QString name; QPixmap pix; |
638 | 648 | ||
639 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || | 649 | if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || |
640 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) | 650 | ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) |
641 | { | 651 | { |
642 | locked = true; | 652 | locked = true; |
643 | if ( symlink ) | 653 | if ( symlink ) |
644 | pix = Resource::loadPixmap( "opie/symlink" ); | 654 | pix = Resource::loadPixmap( "opie/symlink" ); |
645 | else | 655 | else |
646 | pix = Resource::loadPixmap( "lockedfolder" ); | 656 | pix = Resource::loadPixmap( "lockedfolder" ); |
647 | } | 657 | } |
648 | else | 658 | else |
649 | pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); | 659 | pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); |
650 | 660 | ||
651 | name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : | 661 | name = symlink ? info->fileName() + " -> " + createNewPath(info->dirPath(true),info->readLink()) : |
652 | info->fileName(); | 662 | info->fileName(); |
653 | 663 | ||
654 | (void)new OFileSelectorItem( m_view, pix, name, | 664 | (void)new OFileSelectorItem( m_view, pix, name, |
655 | info->lastModified().toString(), | 665 | info->lastModified().toString(), |
656 | QString::number( info->size() ), | 666 | QString::number( info->size() ), |
657 | info->dirPath( true ), locked, true ); | 667 | info->dirPath( true ), locked, true ); |
658 | 668 | ||
659 | 669 | ||
660 | } | 670 | } |
661 | 671 | ||
662 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) | 672 | void OFileViewFileListView::addSymlink( QFileInfo* , bool ) |
663 | { | 673 | { |
664 | } | 674 | } |
665 | 675 | ||
666 | void OFileViewFileListView::cdUP() | 676 | void OFileViewFileListView::cdUP() |
667 | { | 677 | { |
668 | QDir dir( m_currentDir ); | 678 | QDir dir( m_currentDir ); |
669 | dir.cdUp(); | 679 | dir.cdUp(); |
670 | 680 | ||
671 | if (!dir.exists() ) | 681 | if (!dir.exists() ) |
672 | m_currentDir = "/"; | 682 | m_currentDir = "/"; |
673 | else | 683 | else |
674 | m_currentDir = dir.absPath(); | 684 | m_currentDir = dir.absPath(); |
675 | 685 | ||
676 | emit selector()->dirSelected( m_currentDir ); | 686 | emit selector()->dirSelected( m_currentDir ); |
677 | reread( m_all ); | 687 | reread( m_all ); |
678 | } | 688 | } |
679 | 689 | ||
680 | void OFileViewFileListView::cdHome() | 690 | void OFileViewFileListView::cdHome() |
681 | { | 691 | { |
682 | m_currentDir = QDir::homeDirPath(); | 692 | m_currentDir = QDir::homeDirPath(); |
683 | emit selector()->dirSelected( m_currentDir ); | 693 | emit selector()->dirSelected( m_currentDir ); |
684 | reread( m_all ); | 694 | reread( m_all ); |
685 | } | 695 | } |
686 | 696 | ||
687 | void OFileViewFileListView::cdDoc() | 697 | void OFileViewFileListView::cdDoc() |
688 | { | 698 | { |
689 | m_currentDir = QPEApplication::documentDir(); | 699 | m_currentDir = QPEApplication::documentDir(); |
690 | emit selector()->dirSelected( m_currentDir ); | 700 | emit selector()->dirSelected( m_currentDir ); |
691 | reread( m_all ); | 701 | reread( m_all ); |
692 | } | 702 | } |
693 | 703 | ||
694 | void OFileViewFileListView::changeDir( const QString& dir ) | 704 | void OFileViewFileListView::changeDir( const QString& dir ) |
695 | { | 705 | { |
696 | m_currentDir = dir; | 706 | m_currentDir = dir; |
697 | emit selector()->dirSelected( m_currentDir ); | 707 | emit selector()->dirSelected( m_currentDir ); |
698 | reread( m_all ); | 708 | reread( m_all ); |
699 | } | 709 | } |
700 | 710 | ||
701 | void OFileViewFileListView::slotFSActivated( int id ) | 711 | void OFileViewFileListView::slotFSActivated( int id ) |
702 | { | 712 | { |
703 | changeDir ( m_dev[m_fsPop->text(id)] ); | 713 | changeDir ( m_dev[m_fsPop->text(id)] ); |
704 | } | 714 | } |
705 | 715 | ||
706 | /* check if the mimetype in mime | 716 | /* check if the mimetype in mime |
707 | * complies with the one which is current | 717 | * complies with the one which is current |
708 | */ | 718 | */ |
709 | /* | 719 | /* |
710 | * We've the mimetype of the file | 720 | * We've the mimetype of the file |
711 | * We need to get the stringlist of the current mimetype | 721 | * We need to get the stringlist of the current mimetype |
712 | * | 722 | * |
713 | * mime = image@slashjpeg | 723 | * mime = image@slashjpeg |
714 | * QStringList = 'image@slash*' | 724 | * QStringList = 'image@slash*' |
715 | * or QStringList = image/jpeg;image/png;application/x-ogg | 725 | * or QStringList = image/jpeg;image/png;application/x-ogg |
716 | * or QStringList = application/x-ogg;image@slash*; | 726 | * or QStringList = application/x-ogg;image@slash*; |
717 | * with all these mime filters it should get acceptes | 727 | * with all these mime filters it should get acceptes |
718 | * to do so we need to look if mime is contained inside | 728 | * to do so we need to look if mime is contained inside |
719 | * the stringlist | 729 | * the stringlist |
720 | * if it's contained return true | 730 | * if it's contained return true |
721 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' | 731 | * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' |
722 | * is contained in the mimefilter and then we will | 732 | * is contained in the mimefilter and then we will |
723 | * look if both are equal until the '/' | 733 | * look if both are equal until the '/' |
724 | */ | 734 | */ |
725 | 735 | ||
726 | bool OFileViewFileListView::compliesMime( const QString& str) | 736 | bool OFileViewFileListView::compliesMime( const QString& str) |
727 | { | 737 | { |
728 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) | 738 | if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) |
729 | return true; | 739 | return true; |
730 | 740 | ||
731 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) | 741 | for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) |
732 | { | 742 | { |
733 | QRegExp reg( (*it) ); | 743 | QRegExp reg( (*it) ); |
734 | reg.setWildcard( true ); | 744 | reg.setWildcard( true ); |
735 | if ( str.find( reg ) != -1 ) | 745 | if ( str.find( reg ) != -1 ) |
736 | return true; | 746 | return true; |
737 | 747 | ||
738 | } | 748 | } |
739 | return false; | 749 | return false; |
740 | } | 750 | } |
741 | /* | 751 | /* |
742 | * The listView giving access to the file system! | 752 | * The listView giving access to the file system! |
743 | */ | 753 | */ |
744 | 754 | ||
745 | class OFileViewFileSystem : public OFileViewInterface | 755 | class OFileViewFileSystem : public OFileViewInterface |
746 | { | 756 | { |
747 | public: | 757 | public: |
748 | OFileViewFileSystem( OFileSelector* ); | 758 | OFileViewFileSystem( OFileSelector* ); |
749 | ~OFileViewFileSystem(); | 759 | ~OFileViewFileSystem(); |
750 | 760 | ||
751 | QString selectedName() const; | 761 | QString selectedName() const; |
752 | QString selectedPath() const; | 762 | QString selectedPath() const; |
753 | 763 | ||
754 | QString directory()const; | 764 | QString directory()const; |
755 | void reread(); | 765 | void reread(); |
756 | int fileCount()const; | 766 | int fileCount()const; |
757 | 767 | ||
758 | QWidget* widget( QWidget* parent ); | 768 | QWidget* widget( QWidget* parent ); |
759 | void activate( const QString& ); | 769 | void activate( const QString& ); |
760 | private: | 770 | private: |
761 | OFileViewFileListView* m_view; | 771 | OFileViewFileListView* m_view; |
762 | bool m_all : 1; | 772 | bool m_all : 1; |
763 | }; | 773 | }; |
764 | 774 | ||
765 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) | 775 | OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) |
766 | : OFileViewInterface( sel ) | 776 | : OFileViewInterface( sel ) |
767 | { | 777 | { |
768 | m_view = 0; | 778 | m_view = 0; |
769 | m_all = false; | 779 | m_all = false; |
770 | } | 780 | } |
771 | 781 | ||
772 | OFileViewFileSystem::~OFileViewFileSystem() | 782 | OFileViewFileSystem::~OFileViewFileSystem() |
773 | { | 783 | { |
774 | } | 784 | } |
775 | 785 | ||
776 | QString OFileViewFileSystem::selectedName()const | 786 | QString OFileViewFileSystem::selectedName()const |
777 | { | 787 | { |
778 | if (!m_view ) | 788 | if (!m_view ) |
779 | return QString::null; | 789 | return QString::null; |
780 | 790 | ||
781 | QString cFN=currentFileName(); | 791 | QString cFN=currentFileName(); |
782 | if (cFN.startsWith("/")) return cFN; | 792 | if (cFN.startsWith("/")) return cFN; |
783 | return m_view->currentDir() + "/" + cFN; | 793 | return createNewPath(m_view->currentDir(),cFN); |
784 | } | 794 | } |
785 | 795 | ||
786 | QString OFileViewFileSystem::selectedPath()const | 796 | QString OFileViewFileSystem::selectedPath()const |
787 | { | 797 | { |
788 | return QString::null; | 798 | return QString::null; |
789 | } | 799 | } |
790 | 800 | ||
791 | QString OFileViewFileSystem::directory()const | 801 | QString OFileViewFileSystem::directory()const |
792 | { | 802 | { |
793 | if (!m_view) | 803 | if (!m_view) |
794 | return QString::null; | 804 | return QString::null; |
795 | 805 | ||
796 | OFileSelectorItem* item = m_view->currentItem(); | 806 | OFileSelectorItem* item = m_view->currentItem(); |
797 | if (!item ) | 807 | if (!item ) |
798 | return QString::null; | 808 | return QString::null; |
799 | 809 | ||
800 | return QDir(item->directory() ).absPath(); | 810 | return QDir(item->directory() ).absPath(); |
801 | } | 811 | } |
802 | 812 | ||
803 | void OFileViewFileSystem::reread() | 813 | void OFileViewFileSystem::reread() |
804 | { | 814 | { |
805 | if (!m_view) | 815 | if (!m_view) |
806 | return; | 816 | return; |
807 | 817 | ||
808 | m_view->reread( m_all ); | 818 | m_view->reread( m_all ); |
809 | } | 819 | } |
810 | 820 | ||
811 | int OFileViewFileSystem::fileCount()const | 821 | int OFileViewFileSystem::fileCount()const |
812 | { | 822 | { |
813 | if (!m_view ) | 823 | if (!m_view ) |
814 | return -1; | 824 | return -1; |
815 | return m_view->fileCount(); | 825 | return m_view->fileCount(); |
816 | } | 826 | } |
817 | 827 | ||
818 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) | 828 | QWidget* OFileViewFileSystem::widget( QWidget* parent ) |
819 | { | 829 | { |
820 | if (!m_view ) | 830 | if (!m_view ) |
821 | { | 831 | { |
822 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); | 832 | m_view = new OFileViewFileListView( parent, startDirectory(), selector() ); |
823 | } | 833 | } |
824 | return m_view; | 834 | return m_view; |
825 | } | 835 | } |
826 | 836 | ||
827 | void OFileViewFileSystem::activate( const QString& str ) | 837 | void OFileViewFileSystem::activate( const QString& str ) |
828 | { | 838 | { |
829 | m_all = allItem( str ); | 839 | m_all = allItem( str ); |
830 | } | 840 | } |
831 | 841 | ||
832 | 842 | ||
833 | } | 843 | } |
834 | /* Selector */ | 844 | /* Selector */ |
835 | /** | 845 | /** |
836 | * @short new and complete c'tor | 846 | * @short new and complete c'tor |
837 | * | 847 | * |
838 | * Create a OFileSelector to let the user select a file. It can | 848 | * Create a OFileSelector to let the user select a file. It can |
839 | * either be used to open a file, select a save name in a dir or | 849 | * either be used to open a file, select a save name in a dir or |
840 | * as a dropin for the FileSelector. | 850 | * as a dropin for the FileSelector. |
841 | * | 851 | * |
842 | * <pre> | 852 | * <pre> |
843 | * QMap<QString, QStringList> mimeTypes; | 853 | * QMap<QString, QStringList> mimeTypes; |
844 | * QStringList types; | 854 | * QStringList types; |
845 | * types << "text@slash* "; | 855 | * types << "text@slash* "; |
846 | * types << "audio@slash*"; | 856 | * types << "audio@slash*"; |
847 | * mimeTypes.insert( tr("Audio and Text"), types ); | 857 | * mimeTypes.insert( tr("Audio and Text"), types ); |
848 | * mimeTypes.insert( tr("All"), "*@slash*); | 858 | * mimeTypes.insert( tr("All"), "*@slash*); |
849 | * | 859 | * |
850 | * now you could create your fileselector | 860 | * now you could create your fileselector |
851 | * </pre> | 861 | * </pre> |
852 | * | 862 | * |
853 | * | 863 | * |
854 | * @param parent the parent of this widget | 864 | * @param parent the parent of this widget |
855 | * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) | 865 | * @param mode The mode from the enum Mode (Open,Save,FILESELECTOR) |
856 | * @param sel The selector to be used | 866 | * @param sel The selector to be used |
857 | * @param dirName The name of the dir to start int | 867 | * @param dirName The name of the dir to start int |
858 | * @param fileName The fileName placed in the fileselector lineedit | 868 | * @param fileName The fileName placed in the fileselector lineedit |
859 | * @param mimetypes The MimeType map of used mimetypes | 869 | * @param mimetypes The MimeType map of used mimetypes |
860 | * @param showNew Show a New Button. Most likely to be used in the FileSelector view. | 870 | * @param showNew Show a New Button. Most likely to be used in the FileSelector view. |
861 | * @param showClose Show a Close Button. Most likely to be used in FileSelector view. | 871 | * @param showClose Show a Close Button. Most likely to be used in FileSelector view. |
862 | * | 872 | * |
863 | */ | 873 | */ |
864 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, | 874 | OFileSelector::OFileSelector( QWidget* parent, int mode, int sel, |
865 | const QString& dirName, const QString& fileName, | 875 | const QString& dirName, const QString& fileName, |
866 | const MimeTypes& mimetypes, | 876 | const MimeTypes& mimetypes, |
867 | bool showNew, bool showClose) | 877 | bool showNew, bool showClose) |
868 | :QWidget( parent, "OFileSelector" ) | 878 | :QWidget( parent, "OFileSelector" ) |
869 | { | 879 | { |
870 | m_current = 0; | 880 | m_current = 0; |
871 | m_shNew = showNew; | 881 | m_shNew = showNew; |
872 | m_shClose = showClose; | 882 | m_shClose = showClose; |
873 | m_mimeType = mimetypes; | 883 | m_mimeType = mimetypes; |
874 | m_startDir = dirName; | 884 | m_startDir = dirName; |
875 | 885 | ||
876 | m_mode = mode; | 886 | m_mode = mode; |
877 | m_selector = sel; | 887 | m_selector = sel; |
878 | 888 | ||
879 | m_allList = QStringList(); | 889 | m_allList = QStringList(); |
880 | 890 | ||
881 | initUI(); | 891 | initUI(); |
882 | m_lneEdit->setText( fileName ); | 892 | m_lneEdit->setText( fileName ); |
883 | initMime(); | 893 | initMime(); |
884 | initViews(); | 894 | initViews(); |
885 | 895 | ||
886 | QString str; | 896 | QString str; |
887 | switch ( m_selector ) | 897 | switch ( m_selector ) |
888 | { | 898 | { |
889 | default: | 899 | default: |
890 | case Normal: | 900 | case Normal: |
891 | if ( m_mode == DIRECTORYSELECTOR ) | 901 | if ( m_mode == DIRECTORYSELECTOR ) |
892 | str = QObject::tr("Directories"); | 902 | str = QObject::tr("Directories"); |
893 | else | 903 | else |
894 | str = QObject::tr("Documents"); | 904 | str = QObject::tr("Documents"); |
895 | m_cmbView->setCurrentItem( 0 ); | 905 | m_cmbView->setCurrentItem( 0 ); |
896 | break; | 906 | break; |
897 | case Extended: | 907 | case Extended: |
898 | if ( m_mode == DIRECTORYSELECTOR ) | 908 | if ( m_mode == DIRECTORYSELECTOR ) |
899 | { | 909 | { |
900 | str = QObject::tr("Directories"); | 910 | str = QObject::tr("Directories"); |
901 | m_cmbView->setCurrentItem( 0 ); | 911 | m_cmbView->setCurrentItem( 0 ); |
902 | } else { | 912 | } else { |
903 | str = QObject::tr("Files"); | 913 | str = QObject::tr("Files"); |
904 | m_cmbView->setCurrentItem( 1 ); | 914 | m_cmbView->setCurrentItem( 1 ); |
905 | } | 915 | } |
906 | break; | 916 | break; |
907 | case ExtendedAll: | 917 | case ExtendedAll: |
908 | if ( m_mode == DIRECTORYSELECTOR ) | 918 | if ( m_mode == DIRECTORYSELECTOR ) |
909 | { | 919 | { |
910 | str = QObject::tr("All Directories"); | 920 | str = QObject::tr("All Directories"); |
911 | m_cmbView->setCurrentItem( 1 ); | 921 | m_cmbView->setCurrentItem( 1 ); |
912 | } else { | 922 | } else { |
913 | str = QObject::tr("All Files"); | 923 | str = QObject::tr("All Files"); |
914 | m_cmbView->setCurrentItem( 2 ); | 924 | m_cmbView->setCurrentItem( 2 ); |
915 | } | 925 | } |
916 | break; | 926 | break; |
917 | } | 927 | } |
918 | slotViewChange( str ); | 928 | slotViewChange( str ); |
919 | 929 | ||
920 | } | 930 | } |
921 | 931 | ||
922 | 932 | ||
923 | /** | 933 | /** |
924 | * This a convience c'tor to just substitute the use of FileSelector | 934 | * This a convience c'tor to just substitute the use of FileSelector |
925 | */ | 935 | */ |
926 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, | 936 | OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, |
927 | bool showNew, bool showClose ) | 937 | bool showNew, bool showClose ) |
928 | : QWidget( parent, name ) | 938 | : QWidget( parent, name ) |
929 | { | 939 | { |
930 | m_current = 0; | 940 | m_current = 0; |
931 | m_shNew = showNew; | 941 | m_shNew = showNew; |
932 | m_shClose = showClose; | 942 | m_shClose = showClose; |
933 | m_startDir = QPEApplication::documentDir(); | 943 | m_startDir = QPEApplication::documentDir(); |
934 | 944 | ||
935 | if (!mimeFilter.isEmpty() ) | 945 | if (!mimeFilter.isEmpty() ) |
936 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); | 946 | m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); |
937 | 947 | ||
938 | m_mode = OFileSelector::FileSelector; | 948 | m_mode = OFileSelector::FileSelector; |
939 | m_selector = OFileSelector::Normal; | 949 | m_selector = OFileSelector::Normal; |
940 | 950 | ||
941 | initUI(); | 951 | initUI(); |
942 | initMime(); | 952 | initMime(); |
943 | initViews(); | 953 | initViews(); |
944 | m_cmbView->setCurrentItem( 0 ); | 954 | m_cmbView->setCurrentItem( 0 ); |
945 | slotViewChange( QObject::tr("Documents") ); | 955 | slotViewChange( QObject::tr("Documents") ); |
946 | } | 956 | } |
947 | 957 | ||
948 | /* | 958 | /* |
949 | * INIT UI will set up the basic GUI | 959 | * INIT UI will set up the basic GUI |
950 | * Layout: Simple VBoxLayout | 960 | * Layout: Simple VBoxLayout |
951 | * On top a WidgetStack containing the Views... | 961 | * On top a WidgetStack containing the Views... |
952 | * - List View | 962 | * - List View |
953 | * - Document View | 963 | * - Document View |
954 | * Below we will have a Label + LineEdit | 964 | * Below we will have a Label + LineEdit |
955 | * Below we will have two ComoBoxes one for choosing the view one for | 965 | * Below we will have two ComoBoxes one for choosing the view one for |
956 | * choosing the mimetype | 966 | * choosing the mimetype |
957 | */ | 967 | */ |
958 | void OFileSelector::initUI() | 968 | void OFileSelector::initUI() |
959 | { | 969 | { |
960 | QVBoxLayout* lay = new QVBoxLayout( this ); | 970 | QVBoxLayout* lay = new QVBoxLayout( this ); |
961 | 971 | ||
962 | m_stack = new QWidgetStack( this ); | 972 | m_stack = new QWidgetStack( this ); |
963 | lay->addWidget( m_stack, 1000 ); | 973 | lay->addWidget( m_stack, 1000 ); |
964 | 974 | ||
965 | m_nameBox = new QHBox( this ); | 975 | m_nameBox = new QHBox( this ); |
966 | (void)new QLabel( tr("Name:"), m_nameBox ); | 976 | (void)new QLabel( tr("Name:"), m_nameBox ); |
967 | m_lneEdit = new QLineEdit( m_nameBox ); | 977 | m_lneEdit = new QLineEdit( m_nameBox ); |
968 | m_lneEdit ->installEventFilter(this); | 978 | m_lneEdit ->installEventFilter(this); |
969 | lay->addWidget( m_nameBox ); | 979 | lay->addWidget( m_nameBox ); |
970 | 980 | ||
971 | m_cmbBox = new QHBox( this ); | 981 | m_cmbBox = new QHBox( this ); |
972 | m_cmbView = new QComboBox( m_cmbBox ); | 982 | m_cmbView = new QComboBox( m_cmbBox ); |
973 | m_cmbMime = new QComboBox( m_cmbBox ); | 983 | m_cmbMime = new QComboBox( m_cmbBox ); |
974 | lay->addWidget( m_cmbBox ); | 984 | lay->addWidget( m_cmbBox ); |
975 | } | 985 | } |
976 | 986 | ||
977 | /* | 987 | /* |
978 | * This will make sure that the return key in the name edit causes dialogs to close | 988 | * This will make sure that the return key in the name edit causes dialogs to close |
979 | */ | 989 | */ |
980 | 990 | ||
981 | bool OFileSelector::eventFilter (QObject *, QEvent *e) | 991 | bool OFileSelector::eventFilter (QObject *, QEvent *e) |
982 | { | 992 | { |
983 | if ( e->type() == QEvent::KeyPress ) | 993 | if ( e->type() == QEvent::KeyPress ) |
984 | { | 994 | { |
985 | QKeyEvent *k = (QKeyEvent *)e; | 995 | QKeyEvent *k = (QKeyEvent *)e; |
986 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) | 996 | if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) |
987 | { | 997 | { |
988 | emit ok(); | 998 | emit ok(); |
989 | return true; | 999 | return true; |
990 | } | 1000 | } |
991 | } | 1001 | } |
992 | return false; | 1002 | return false; |
993 | } | 1003 | } |
994 | 1004 | ||
995 | /* | 1005 | /* |
996 | * This will insert the MimeTypes into the Combo Box | 1006 | * This will insert the MimeTypes into the Combo Box |
997 | * And also connect the changed signal | 1007 | * And also connect the changed signal |
998 | * | 1008 | * |
999 | * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes | 1009 | * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes |
1000 | */ | 1010 | */ |
1001 | void OFileSelector::initMime() | 1011 | void OFileSelector::initMime() |
1002 | { | 1012 | { |
1003 | MimeTypes::Iterator it; | 1013 | MimeTypes::Iterator it; |
1004 | for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) | 1014 | for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) |
1005 | { | 1015 | { |
1006 | m_cmbMime->insertItem( it.key() ); | 1016 | m_cmbMime->insertItem( it.key() ); |
1007 | } | 1017 | } |
1008 | m_cmbMime->setCurrentItem( 0 ); | 1018 | m_cmbMime->setCurrentItem( 0 ); |
1009 | 1019 | ||
1010 | connect( m_cmbMime, SIGNAL(activated(int) ), | 1020 | connect( m_cmbMime, SIGNAL(activated(int) ), |
1011 | this, SLOT(slotMimeTypeChanged() ) ); | 1021 | this, SLOT(slotMimeTypeChanged() ) ); |
1012 | 1022 | ||
1013 | } | 1023 | } |
1014 | 1024 | ||
1015 | void OFileSelector::initViews() | 1025 | void OFileSelector::initViews() |
1016 | { | 1026 | { |
1017 | if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) | 1027 | if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) |
1018 | { | 1028 | { |
1019 | m_cmbView->insertItem( QObject::tr("Directories") ); | 1029 | m_cmbView->insertItem( QObject::tr("Directories") ); |
1020 | m_cmbView->insertItem( QObject::tr("All Directories") ); | 1030 | m_cmbView->insertItem( QObject::tr("All Directories") ); |
1021 | } else { | 1031 | } else { |
1022 | m_cmbView->insertItem( QObject::tr("Documents") ); | 1032 | m_cmbView->insertItem( QObject::tr("Documents") ); |
1023 | m_cmbView->insertItem( QObject::tr("Files") ); | 1033 | m_cmbView->insertItem( QObject::tr("Files") ); |
1024 | m_cmbView->insertItem( QObject::tr("All Files") ); | 1034 | m_cmbView->insertItem( QObject::tr("All Files") ); |
1025 | } | 1035 | } |
1026 | 1036 | ||
1027 | connect(m_cmbView, SIGNAL(activated(const QString&) ), | 1037 | connect(m_cmbView, SIGNAL(activated(const QString&) ), |
1028 | this, SLOT(slotViewChange(const QString&) ) ); | 1038 | this, SLOT(slotViewChange(const QString&) ) ); |
1029 | 1039 | ||
1030 | /* see above why add both */ | 1040 | /* see above why add both */ |
1031 | OFileViewInterface* in = new OFileViewFileSystem( this ); | 1041 | OFileViewInterface* in = new OFileViewFileSystem( this ); |
1032 | 1042 | ||
1033 | if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) | 1043 | if ( m_mode == OFileSelector::DIRECTORYSELECTOR ) |
1034 | { | 1044 | { |
1035 | m_views.insert( QObject::tr("Directories"), in ); | 1045 | m_views.insert( QObject::tr("Directories"), in ); |
1036 | m_views.insert( QObject::tr("All Directories"), in ); | 1046 | m_views.insert( QObject::tr("All Directories"), in ); |
1037 | m_allList.append( QObject::tr("All Directories") ); | 1047 | m_allList.append( QObject::tr("All Directories") ); |
1038 | } else { | 1048 | } else { |
1039 | m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); | 1049 | m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); |