-rw-r--r-- | libopie/ofileselector/ofileselector.cpp | 15 | ||||
-rw-r--r-- | libopie/ofileselector/olister.cpp | 10 | ||||
-rw-r--r-- | libopie/ofileselector/olister.h | 18 | ||||
-rw-r--r-- | libopie/ofileselector/olocallister.cpp | 29 | ||||
-rw-r--r-- | libopie/ofileselector/olocallister.h | 5 |
5 files changed, 62 insertions, 15 deletions
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp index 255e79e..9ce07dd 100644 --- a/libopie/ofileselector/ofileselector.cpp +++ b/libopie/ofileselector/ofileselector.cpp | |||
@@ -73,578 +73,569 @@ OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, | |||
73 | 73 | ||
74 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, | 74 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, |
75 | const char *name, bool newVisible, | 75 | const char *name, bool newVisible, |
76 | bool closeVisible ) | 76 | bool closeVisible ) |
77 | : QWidget( parent, name ) | 77 | : QWidget( parent, name ) |
78 | { | 78 | { |
79 | /* update the mimefilter */ | 79 | /* update the mimefilter */ |
80 | if (!mimeFilter.isEmpty() ) { | 80 | if (!mimeFilter.isEmpty() ) { |
81 | QStringList list = QStringList::split(";", mimeFilter ); | 81 | QStringList list = QStringList::split(";", mimeFilter ); |
82 | m_mimetypes.insert(mimeFilter, list ); | 82 | m_mimetypes.insert(mimeFilter, list ); |
83 | } | 83 | } |
84 | initVars(); | 84 | initVars(); |
85 | m_currentDir = QPEApplication::documentDir(); | 85 | m_currentDir = QPEApplication::documentDir(); |
86 | m_mode = Fileselector; | 86 | m_mode = Fileselector; |
87 | m_selector = Normal; | 87 | m_selector = Normal; |
88 | m_shClose = closeVisible; | 88 | m_shClose = closeVisible; |
89 | m_shNew = newVisible; | 89 | m_shNew = newVisible; |
90 | m_shLne = false; | 90 | m_shLne = false; |
91 | m_shPerm = false; | 91 | m_shPerm = false; |
92 | m_shYesNo = false; | 92 | m_shYesNo = false; |
93 | init(); | 93 | init(); |
94 | 94 | ||
95 | 95 | ||
96 | } | 96 | } |
97 | 97 | ||
98 | OFileSelector::~OFileSelector() | 98 | OFileSelector::~OFileSelector() |
99 | { | 99 | { |
100 | 100 | ||
101 | 101 | ||
102 | } | 102 | } |
103 | 103 | ||
104 | void OFileSelector::setNewVisible( bool visible ) | 104 | void OFileSelector::setNewVisible( bool visible ) |
105 | { | 105 | { |
106 | m_shNew = visible; | 106 | m_shNew = visible; |
107 | if (m_new ) | 107 | if (m_new ) |
108 | m_new->show(); | 108 | m_new->show(); |
109 | } | 109 | } |
110 | void OFileSelector::setCloseVisible( bool visible ) | 110 | void OFileSelector::setCloseVisible( bool visible ) |
111 | { | 111 | { |
112 | m_shClose = visible; | 112 | m_shClose = visible; |
113 | 113 | ||
114 | if( m_close ) | 114 | if( m_close ) |
115 | m_close->show(); | 115 | m_close->show(); |
116 | } | 116 | } |
117 | void OFileSelector::reread() | 117 | void OFileSelector::reread() |
118 | { | 118 | { |
119 | if( m_selector == Normal ) | 119 | if( m_selector == Normal ) |
120 | initializeOldSelector(); | 120 | initializeOldSelector(); |
121 | else | 121 | else |
122 | reparse(); | 122 | reparse(); |
123 | } | 123 | } |
124 | 124 | ||
125 | const DocLnk *OFileSelector::selected() | 125 | const DocLnk *OFileSelector::selected() |
126 | { | 126 | { |
127 | DocLnk *lnk = new DocLnk(selectedDocument() ); | 127 | DocLnk *lnk = new DocLnk(selectedDocument() ); |
128 | return lnk; | 128 | return lnk; |
129 | } | 129 | } |
130 | 130 | ||
131 | void OFileSelector::setYesCancelVisible( bool show ) | 131 | void OFileSelector::setYesCancelVisible( bool show ) |
132 | { | 132 | { |
133 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( | 133 | initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( |
134 | m_shYesNo = show; | 134 | m_shYesNo = show; |
135 | 135 | ||
136 | if( m_shYesNo ) | 136 | if( m_shYesNo ) |
137 | m_boxOk->show(); | 137 | m_boxOk->show(); |
138 | else | 138 | else |
139 | m_boxOk->hide(); | 139 | m_boxOk->hide(); |
140 | 140 | ||
141 | } | 141 | } |
142 | void OFileSelector::setToolbarVisible( bool show ) | 142 | void OFileSelector::setToolbarVisible( bool show ) |
143 | { | 143 | { |
144 | m_shTool = show; | 144 | m_shTool = show; |
145 | 145 | ||
146 | if(!m_shTool ){ | 146 | if(!m_shTool ){ |
147 | m_location->hide(); | 147 | m_location->hide(); |
148 | m_up->hide(); | 148 | m_up->hide(); |
149 | m_homeButton->hide(); | 149 | m_homeButton->hide(); |
150 | m_docButton->hide(); | 150 | m_docButton->hide(); |
151 | }else{ | 151 | }else{ |
152 | m_location->show(); | 152 | m_location->show(); |
153 | m_up->show(); | 153 | m_up->show(); |
154 | m_homeButton->show(); | 154 | m_homeButton->show(); |
155 | m_docButton->show(); | 155 | m_docButton->show(); |
156 | } | 156 | } |
157 | } | 157 | } |
158 | void OFileSelector::setPermissionBarVisible( bool show ) | 158 | void OFileSelector::setPermissionBarVisible( bool show ) |
159 | { | 159 | { |
160 | m_shPerm = show; | 160 | m_shPerm = show; |
161 | initializePerm(); | 161 | initializePerm(); |
162 | 162 | ||
163 | if( m_shPerm ) | 163 | if( m_shPerm ) |
164 | m_checkPerm->show(); | 164 | m_checkPerm->show(); |
165 | else | 165 | else |
166 | m_checkPerm->hide(); | 166 | m_checkPerm->hide(); |
167 | } | 167 | } |
168 | void OFileSelector::setLineEditVisible( bool show ) | 168 | void OFileSelector::setLineEditVisible( bool show ) |
169 | { | 169 | { |
170 | if( show ){ | 170 | if( show ){ |
171 | initializeName(); | 171 | initializeName(); |
172 | m_boxName->show(); | 172 | m_boxName->show(); |
173 | }else{ | 173 | }else{ |
174 | // check if we showed before this is the way to go | 174 | // check if we showed before this is the way to go |
175 | if( m_shLne && m_boxName != 0 ) | 175 | if( m_shLne && m_boxName != 0 ) |
176 | m_boxName->hide(); | 176 | m_boxName->hide(); |
177 | } | 177 | } |
178 | m_shLne = show; | 178 | m_shLne = show; |
179 | } | 179 | } |
180 | 180 | ||
181 | void OFileSelector::setChooserVisible( bool show ) | 181 | void OFileSelector::setChooserVisible( bool show ) |
182 | { | 182 | { |
183 | m_shChooser = show; | 183 | m_shChooser = show; |
184 | initializeChooser(); | 184 | initializeChooser(); |
185 | 185 | ||
186 | if( m_shChooser ) | 186 | if( m_shChooser ) |
187 | m_boxView->hide(); | 187 | m_boxView->hide(); |
188 | else | 188 | else |
189 | m_boxView->show(); | 189 | m_boxView->show(); |
190 | 190 | ||
191 | } | 191 | } |
192 | 192 | ||
193 | QCheckBox* OFileSelector::permissionCheckbox() | 193 | QCheckBox* OFileSelector::permissionCheckbox() |
194 | { | 194 | { |
195 | if( m_selector == Normal ) | 195 | if( m_selector == Normal ) |
196 | return 0l; | 196 | return 0l; |
197 | else | 197 | else |
198 | return m_checkPerm; | 198 | return m_checkPerm; |
199 | } | 199 | } |
200 | bool OFileSelector::setPermission()const | 200 | bool OFileSelector::setPermission()const |
201 | { | 201 | { |
202 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); | 202 | return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); |
203 | } | 203 | } |
204 | void OFileSelector::setPermissionChecked( bool check ) | 204 | void OFileSelector::setPermissionChecked( bool check ) |
205 | { | 205 | { |
206 | if( m_checkPerm ) | 206 | if( m_checkPerm ) |
207 | m_checkPerm->setChecked( check ); | 207 | m_checkPerm->setChecked( check ); |
208 | } | 208 | } |
209 | 209 | ||
210 | void OFileSelector::setMode(int mode) // FIXME do direct raising | 210 | void OFileSelector::setMode(int mode) // FIXME do direct raising |
211 | { | 211 | { |
212 | m_mode = mode; | 212 | m_mode = mode; |
213 | if( m_selector == Normal ) | 213 | if( m_selector == Normal ) |
214 | return; | 214 | return; |
215 | } | 215 | } |
216 | void OFileSelector::setShowDirs(bool dir) | 216 | void OFileSelector::setShowDirs(bool dir) |
217 | { | 217 | { |
218 | m_dir = dir; | 218 | m_dir = dir; |
219 | if ( m_selector != Fileselector ) | 219 | if ( m_selector != Fileselector ) |
220 | reparse(); | 220 | reparse(); |
221 | } | 221 | } |
222 | void OFileSelector::setCaseSensetive(bool caSe ) | 222 | void OFileSelector::setCaseSensetive(bool caSe ) |
223 | { | 223 | { |
224 | m_case = caSe; | 224 | m_case = caSe; |
225 | 225 | ||
226 | if ( m_selector != Fileselector ) | 226 | if ( m_selector != Fileselector ) |
227 | reparse(); | 227 | reparse(); |
228 | } | 228 | } |
229 | void OFileSelector::setShowFiles(bool show ) | 229 | void OFileSelector::setShowFiles(bool show ) |
230 | { | 230 | { |
231 | m_files = show; | 231 | m_files = show; |
232 | reparse(); | 232 | reparse(); |
233 | } | 233 | } |
234 | /// | 234 | /// |
235 | bool OFileSelector::cd(const QString &path ) | 235 | bool OFileSelector::cd(const QString &path ) |
236 | { | 236 | { |
237 | m_currentDir = path; | 237 | m_currentDir = path; |
238 | reparse(); | 238 | reparse(); |
239 | return true; | 239 | return true; |
240 | } | 240 | } |
241 | void OFileSelector::setSelector(int mode ) | 241 | void OFileSelector::setSelector(int mode ) |
242 | { | 242 | { |
243 | QString text; | 243 | QString text; |
244 | switch( mode ){ | 244 | switch( mode ){ |
245 | case Normal: | 245 | case Normal: |
246 | text = tr("Documents"); | 246 | text = tr("Documents"); |
247 | break; | 247 | break; |
248 | case Extended: | 248 | case Extended: |
249 | text = tr("List View"); | 249 | text = tr("List View"); |
250 | break; | 250 | break; |
251 | case ExtendedAll: | 251 | case ExtendedAll: |
252 | text = tr("All List View"); | 252 | text = tr("All List View"); |
253 | break; | 253 | break; |
254 | } | 254 | } |
255 | slotViewCheck( text ); | 255 | slotViewCheck( text ); |
256 | } | 256 | } |
257 | 257 | ||
258 | void OFileSelector::setPopupFactory(OPopupMenuFactory */*popup*/ ) | 258 | void OFileSelector::setPopupFactory(OPopupMenuFactory */*popup*/ ) |
259 | { | 259 | { |
260 | /* m_custom = popup; | 260 | /* m_custom = popup; |
261 | m_showPopup = true; | 261 | m_showPopup = true; |
262 | */ | 262 | */ |
263 | } | 263 | } |
264 | 264 | ||
265 | //void OFileSelector::updateL | ||
266 | |||
267 | QString OFileSelector::selectedName() const | 265 | QString OFileSelector::selectedName() const |
268 | { | 266 | { |
269 | QString name; | 267 | QString name; |
270 | if( m_selector == Normal ){ | 268 | if( m_selector == Normal ){ |
271 | DocLnk lnk = m_select->selectedDocument(); | 269 | DocLnk lnk = m_select->selectedDocument(); |
272 | name = lnk.file(); | 270 | name = lnk.file(); |
273 | }else { | 271 | }else { |
274 | if ( m_shLne ) { | 272 | name = currentLister()->selectedName(); |
275 | name = m_currentDir + "/" +m_edit->text(); | ||
276 | }else{ | ||
277 | name = m_currentDir + "/" + currentView()->selectedName(); | ||
278 | } | ||
279 | } | 273 | } |
280 | return name; | 274 | return name; |
281 | } | 275 | } |
282 | QStringList OFileSelector::selectedNames()const | 276 | QStringList OFileSelector::selectedNames()const |
283 | { | 277 | { |
284 | QStringList list; | 278 | QStringList list; |
285 | if( m_selector == Normal ){ | 279 | if( m_selector == Normal ){ |
286 | list << selectedName(); | 280 | list << selectedName(); |
287 | }else { | 281 | }else { |
288 | list << selectedName(); // FIXME implement multiple Selections | 282 | list << selectedName(); // FIXME implement multiple Selections |
289 | } | 283 | } |
290 | return list; | 284 | return list; |
291 | } | 285 | } |
292 | /** If mode is set to the Dir selection this will return the selected path. | 286 | /** If mode is set to the Dir selection this will return the selected path. |
293 | * | 287 | * |
294 | * | 288 | * |
295 | */ | 289 | */ |
296 | QString OFileSelector::selectedPath()const | 290 | QString OFileSelector::selectedPath()const |
297 | { | 291 | { |
298 | QString path; | 292 | QString path; |
299 | if( m_selector == Normal ){ | 293 | if( m_selector == Normal ){ |
300 | path = QPEApplication::documentDir(); | 294 | path = QPEApplication::documentDir(); |
301 | } /* normal case to do */ | 295 | } /* normal case to do */ |
302 | return path; | 296 | return path; |
303 | } | 297 | } |
304 | QStringList OFileSelector::selectedPaths() const | 298 | QStringList OFileSelector::selectedPaths() const |
305 | { | 299 | { |
306 | QStringList list; | 300 | QStringList list; |
307 | list << selectedPath(); | 301 | list << selectedPath(); |
308 | return list; | 302 | return list; |
309 | } | 303 | } |
310 | QString OFileSelector::directory()const | 304 | QString OFileSelector::directory()const |
311 | { | 305 | { |
312 | if( m_selector == Normal ) | 306 | if( m_selector == Normal ) |
313 | return QPEApplication::documentDir(); | 307 | return QPEApplication::documentDir(); |
314 | 308 | ||
315 | return QDir(m_currentDir).absPath(); | 309 | return QDir(m_currentDir).absPath(); |
316 | } | 310 | } |
317 | 311 | ||
318 | int OFileSelector::fileCount() | 312 | int OFileSelector::fileCount() |
319 | { | 313 | { |
320 | int count; | 314 | int count; |
321 | switch( m_selector ){ | 315 | switch( m_selector ){ |
322 | case Normal: | 316 | case Normal: |
323 | count = m_select->fileCount(); | 317 | count = m_select->fileCount(); |
324 | break; | 318 | break; |
325 | case Extended: | 319 | case Extended: |
326 | case ExtendedAll: | 320 | case ExtendedAll: |
327 | default: | 321 | default: |
328 | count = currentView()->fileCount(); | 322 | count = currentView()->fileCount(); |
329 | break; | 323 | break; |
330 | } | 324 | } |
331 | return count; | 325 | return count; |
332 | } | 326 | } |
333 | DocLnk OFileSelector::selectedDocument() const | 327 | DocLnk OFileSelector::selectedDocument() const |
334 | { | 328 | { |
335 | DocLnk lnk; | 329 | DocLnk lnk; |
336 | switch( m_selector ){ | 330 | switch( m_selector ){ |
337 | case Normal:{ | 331 | case Normal:{ |
338 | lnk = m_select->selectedDocument(); | 332 | lnk = m_select->selectedDocument(); |
339 | break; | 333 | break; |
340 | } | 334 | } |
341 | case Extended: | 335 | case Extended: |
342 | case ExtendedAll: | 336 | case ExtendedAll: |
343 | default: | 337 | default: |
344 | lnk = DocLnk( selectedName() ); | 338 | lnk = DocLnk( selectedName() ); |
345 | break; | 339 | break; |
346 | } | 340 | } |
347 | return lnk; | 341 | return lnk; |
348 | } | 342 | } |
349 | QValueList<DocLnk> OFileSelector::selectedDocuments() const | 343 | QValueList<DocLnk> OFileSelector::selectedDocuments() const |
350 | { | 344 | { |
351 | QValueList<DocLnk> docs; | 345 | QValueList<DocLnk> docs; |
352 | docs.append( selectedDocument() ); | 346 | docs.append( selectedDocument() ); |
353 | return docs; | 347 | return docs; |
354 | } | 348 | } |
355 | 349 | ||
356 | 350 | ||
357 | // slots internal | 351 | // slots internal |
358 | 352 | ||
359 | void OFileSelector::slotOk() | 353 | void OFileSelector::slotOk() |
360 | { | 354 | { |
361 | emit ok(); | 355 | emit ok(); |
362 | } | 356 | } |
363 | void OFileSelector::slotCancel() | 357 | void OFileSelector::slotCancel() |
364 | { | 358 | { |
365 | emit cancel(); | 359 | emit cancel(); |
366 | } | 360 | } |
367 | /* switch the views */ | 361 | /* switch the views */ |
368 | void OFileSelector::slotViewCheck(const QString &sel) | 362 | void OFileSelector::slotViewCheck(const QString &sel) |
369 | { | 363 | { |
370 | setView( sel ); | 364 | setView( sel ); |
371 | } | 365 | } |
372 | 366 | ||
373 | QString OFileSelector::currentMimeType() const{ | 367 | QString OFileSelector::currentMimeType() const{ |
374 | QString mime; | 368 | QString mime; |
375 | QString currentText; | 369 | QString currentText; |
376 | if (m_shChooser && m_mimeCheck ) | 370 | if (m_shChooser && m_mimeCheck ) |
377 | currentText = m_mimeCheck->currentText(); | 371 | currentText = m_mimeCheck->currentText(); |
378 | 372 | ||
379 | qWarning("CurrentText" + currentText ); | 373 | qWarning("CurrentText" + currentText ); |
380 | if (tr("All") == currentText ) return QString::null; | 374 | if (tr("All") == currentText ) return QString::null; |
381 | else if (currentText.isEmpty() ) { | 375 | else if (currentText.isEmpty() ) { |
382 | ; | 376 | ; |
383 | }else { | 377 | }else { |
384 | QMap<QString, QStringList>::ConstIterator it; | 378 | QMap<QString, QStringList>::ConstIterator it; |
385 | it = m_mimetypes.find( currentText ); | 379 | it = m_mimetypes.find( currentText ); |
386 | if ( it != m_mimetypes.end() ) { | 380 | if ( it != m_mimetypes.end() ) { |
387 | mime = it.data().join(";"); | 381 | mime = it.data().join(";"); |
388 | }else{ | 382 | }else{ |
389 | mime = currentText; | 383 | mime = currentText; |
390 | } | 384 | } |
391 | } | 385 | } |
392 | return mime; | 386 | return mime; |
393 | } | 387 | } |
394 | void OFileSelector::slotMimeCheck(const QString &mime) | 388 | void OFileSelector::slotMimeCheck(const QString &mime) |
395 | { | 389 | { |
396 | if( m_selector == Normal ){ | 390 | if( m_selector == Normal ){ |
397 | initializeOldSelector(); | 391 | initializeOldSelector(); |
398 | 392 | ||
399 | updateMimes(); | 393 | updateMimes(); |
400 | updateMimeCheck(); | 394 | updateMimeCheck(); |
401 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 395 | m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
402 | }else{ // others | 396 | }else{ // others |
403 | qWarning("Mime %s", mime.latin1() ); | 397 | qWarning("Mime %s", mime.latin1() ); |
404 | if(m_shChooser ){ | 398 | if(m_shChooser ){ |
405 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); | 399 | qWarning("Current Text %s", m_mimeCheck->currentText().latin1() ); |
406 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); | 400 | //m_mimeCheck->setCurrentItem(indexByString( m_mimeCheck, mime) ); |
407 | } | 401 | } |
408 | reparse(); | 402 | reparse(); |
409 | } | 403 | } |
410 | } | 404 | } |
411 | /* | 405 | /* |
412 | * Ok if a non dir gets inserted into this combobox | 406 | * Ok if a non dir gets inserted into this combobox |
413 | * we need to change it | 407 | * we need to change it |
414 | * QFileInfo and dirPath will give us the right Dir | 408 | * QFileInfo and dirPath will give us the right Dir |
415 | */ | 409 | */ |
416 | void OFileSelector::slotLocationActivated(const QString &file) | 410 | void OFileSelector::slotLocationActivated(const QString &file) |
417 | { | 411 | { |
418 | qWarning("slotLocationActivated"); | 412 | qWarning("slotLocationActivated"); |
419 | QString name = file.left( file.find("<-", 0, TRUE ) ); | 413 | QString name = file.left( file.find("<-", 0, TRUE ) ); |
420 | QFileInfo info( name ); | 414 | QFileInfo info( name ); |
421 | if ( info.isFile() ) | 415 | if ( info.isFile() ) |
422 | cd(info.dirPath( TRUE ) ); //absolute | 416 | cd(info.dirPath( TRUE ) ); //absolute |
423 | else | 417 | else |
424 | cd(name ); | 418 | cd(name ); |
425 | reparse(); | ||
426 | } | 419 | } |
427 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) | 420 | void OFileSelector::slotInsertLocationPath(const QString ¤tPath, int count) |
428 | { | 421 | { |
429 | QStringList pathList; | 422 | QStringList pathList; |
430 | bool underDog = FALSE; | 423 | bool underDog = FALSE; |
431 | for(int i=0;i<count;i++) { | 424 | for(int i=0;i<count;i++) { |
432 | pathList << m_location->text(i); | 425 | pathList << m_location->text(i); |
433 | if( m_location->text(i) == currentPath) | 426 | if( m_location->text(i) == currentPath) |
434 | underDog = TRUE; | 427 | underDog = TRUE; |
435 | } | 428 | } |
436 | if( !underDog) { | 429 | if( !underDog) { |
437 | m_location->clear(); | 430 | m_location->clear(); |
438 | if( currentPath.left(2)=="//") | 431 | if( currentPath.left(2)=="//") |
439 | pathList.append( currentPath.right(currentPath.length()-1) ); | 432 | pathList.append( currentPath.right(currentPath.length()-1) ); |
440 | else | 433 | else |
441 | pathList.append( currentPath ); | 434 | pathList.append( currentPath ); |
442 | m_location->insertStringList( pathList,-1); | 435 | m_location->insertStringList( pathList,-1); |
443 | } | 436 | } |
444 | } | 437 | } |
445 | /* | 438 | /* |
446 | * Do not crash anymore | 439 | * Do not crash anymore |
447 | * don't try to change dir to a file | 440 | * don't try to change dir to a file |
448 | */ | 441 | */ |
449 | void OFileSelector::locationComboChanged() | 442 | void OFileSelector::locationComboChanged() |
450 | { | 443 | { |
451 | QFileInfo info( m_location->lineEdit()->text() ); | 444 | QFileInfo info( m_location->lineEdit()->text() ); |
452 | qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); | 445 | qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); |
453 | if (info.isFile() ) | 446 | if (info.isFile() ) |
454 | cd(info.dirPath(TRUE) ); //absolute path | 447 | cd(info.dirPath(TRUE) ); //absolute path |
455 | else | 448 | else |
456 | cd( m_location->lineEdit()->text() ); | 449 | cd( m_location->lineEdit()->text() ); |
457 | |||
458 | reparse(); | ||
459 | } | 450 | } |
460 | void OFileSelector::init() | 451 | void OFileSelector::init() |
461 | { | 452 | { |
462 | initFactory(); | 453 | initFactory(); |
463 | m_lay = new QVBoxLayout( this ); | 454 | m_lay = new QVBoxLayout( this ); |
464 | m_lay->setSpacing(0 ); | 455 | m_lay->setSpacing(0 ); |
465 | 456 | ||
466 | /* take care of the main view... */ | 457 | /* take care of the main view... */ |
467 | initToolbar(); | 458 | initToolbar(); |
468 | //if( m_shChooser ) // the Chooser for the view and Mimetypes | 459 | //if( m_shChooser ) // the Chooser for the view and Mimetypes |
469 | initializeChooser(); | 460 | initializeChooser(); |
470 | 461 | ||
471 | /* initialize the file lister */ | 462 | /* initialize the file lister */ |
472 | if( m_selector == Normal ){ | 463 | if( m_selector == Normal ){ |
473 | QString mime; | 464 | QString mime; |
474 | if (!m_autoMime) { | 465 | if (!m_autoMime) { |
475 | if (!m_mimetypes.isEmpty() ) { | 466 | if (!m_mimetypes.isEmpty() ) { |
476 | QMap<QString, QStringList>::Iterator it; | 467 | QMap<QString, QStringList>::Iterator it; |
477 | it = m_mimetypes.begin(); // cause we're in the init | 468 | it = m_mimetypes.begin(); // cause we're in the init |
478 | mime = it.data().join(";"); | 469 | mime = it.data().join(";"); |
479 | } | 470 | } |
480 | } | 471 | } |
481 | initializeOldSelector(); | 472 | initializeOldSelector(); |
482 | }else{ | 473 | }else{ |
483 | initializeView(); | 474 | initializeView(); |
484 | } | 475 | } |
485 | 476 | ||
486 | if( m_shLne ) // the LineEdit with the current FileName | 477 | if( m_shLne ) // the LineEdit with the current FileName |
487 | initializeName(); | 478 | initializeName(); |
488 | 479 | ||
489 | if( m_shPerm ) // the Permission QCheckBox | 480 | if( m_shPerm ) // the Permission QCheckBox |
490 | initializePerm(); | 481 | initializePerm(); |
491 | 482 | ||
492 | if( m_shYesNo ) // the Yes No button row | 483 | if( m_shYesNo ) // the Yes No button row |
493 | initializeYes( ); | 484 | initializeYes( ); |
494 | 485 | ||
495 | if (m_selector != Normal ) | 486 | if (m_selector != Normal ) |
496 | reparse(); | 487 | reparse(); |
497 | } | 488 | } |
498 | void OFileSelector::updateMimes() | 489 | void OFileSelector::updateMimes() |
499 | { | 490 | { |
500 | if( m_autoMime ){ | 491 | if( m_autoMime ){ |
501 | m_mimetypes.clear(); | 492 | m_mimetypes.clear(); |
502 | m_mimetypes.insert( tr("All"), QString::null ); | 493 | m_mimetypes.insert( tr("All"), QString::null ); |
503 | if( m_selector == Normal ){ | 494 | if( m_selector == Normal ){ |
504 | DocLnkSet set; | 495 | DocLnkSet set; |
505 | Global::findDocuments(&set, QString::null ); | 496 | Global::findDocuments(&set, QString::null ); |
506 | QListIterator<DocLnk> dit( set.children() ); | 497 | QListIterator<DocLnk> dit( set.children() ); |
507 | for( ; dit.current(); ++dit ){ | 498 | for( ; dit.current(); ++dit ){ |
508 | if( !m_mimetypes.contains( (*dit)->type() ) ) | 499 | if( !m_mimetypes.contains( (*dit)->type() ) ) |
509 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); | 500 | m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); |
510 | } | 501 | } |
511 | }// else done in reparse | 502 | }// else done in reparse |
512 | } | 503 | } |
513 | } | 504 | } |
514 | void OFileSelector::initVars() | 505 | void OFileSelector::initVars() |
515 | { | 506 | { |
516 | if( m_mimetypes.isEmpty() ) | 507 | if( m_mimetypes.isEmpty() ) |
517 | m_autoMime = true; | 508 | m_autoMime = true; |
518 | else | 509 | else |
519 | m_autoMime = false; | 510 | m_autoMime = false; |
520 | 511 | ||
521 | m_shClose = false; | 512 | m_shClose = false; |
522 | m_shNew = false; | 513 | m_shNew = false; |
523 | m_shTool = true; | 514 | m_shTool = true; |
524 | m_shPerm = false; | 515 | m_shPerm = false; |
525 | m_shLne = true; | 516 | m_shLne = true; |
526 | m_shChooser = true; | 517 | m_shChooser = true; |
527 | m_shYesNo = true; | 518 | m_shYesNo = true; |
528 | m_case = false; | 519 | m_case = false; |
529 | m_dir = true; | 520 | m_dir = true; |
530 | m_files = true; | 521 | m_files = true; |
531 | m_showPopup = false; | 522 | m_showPopup = false; |
532 | m_mainView = 0l; | 523 | m_mainView = 0l; |
533 | m_fileView = 0l; | 524 | m_fileView = 0l; |
534 | m_lister = 0l; | 525 | m_lister = 0l; |
535 | 526 | ||
536 | if(m_pixmaps == 0 ) // init the pixmaps | 527 | if(m_pixmaps == 0 ) // init the pixmaps |
537 | initPics(); | 528 | initPics(); |
538 | 529 | ||
539 | // pointers | 530 | // pointers |
540 | m_location = 0; | 531 | m_location = 0; |
541 | m_mimeCheck = 0; | 532 | m_mimeCheck = 0; |
542 | m_viewCheck = 0; | 533 | m_viewCheck = 0; |
543 | m_homeButton = 0; | 534 | m_homeButton = 0; |
544 | m_docButton = 0; | 535 | m_docButton = 0; |
545 | m_hideButton = 0; | 536 | m_hideButton = 0; |
546 | m_ok = 0; | 537 | m_ok = 0; |
547 | m_cancel = 0; | 538 | m_cancel = 0; |
548 | m_reread = 0; | 539 | m_reread = 0; |
549 | m_up = 0; | 540 | m_up = 0; |
550 | m_View = 0; | 541 | m_View = 0; |
551 | m_checkPerm = 0; | 542 | m_checkPerm = 0; |
552 | m_pseudo = 0; | 543 | m_pseudo = 0; |
553 | m_pseudoLayout = 0; | 544 | m_pseudoLayout = 0; |
554 | m_select = 0; | 545 | m_select = 0; |
555 | m_lay = 0; | 546 | m_lay = 0; |
556 | m_Oselector = 0; | 547 | m_Oselector = 0; |
557 | m_boxToolbar = 0; | 548 | m_boxToolbar = 0; |
558 | m_boxOk = 0; | 549 | m_boxOk = 0; |
559 | m_boxName = 0; | 550 | m_boxName = 0; |
560 | m_boxView = 0; | 551 | m_boxView = 0; |
561 | m_edit = 0; | 552 | m_edit = 0; |
562 | m_fnLabel = 0; | 553 | m_fnLabel = 0; |
563 | m_new = 0; | 554 | m_new = 0; |
564 | m_close = 0; | 555 | m_close = 0; |
565 | } | 556 | } |
566 | void OFileSelector::initializeName() | 557 | void OFileSelector::initializeName() |
567 | { | 558 | { |
568 | /** Name Layout Line | 559 | /** Name Layout Line |
569 | * This is the Layout line arranged in | 560 | * This is the Layout line arranged in |
570 | * horizontal way each components | 561 | * horizontal way each components |
571 | * are next to each other | 562 | * are next to each other |
572 | * but we will only do this if | 563 | * but we will only do this if |
573 | * we didn't initialize a while ago. | 564 | * we didn't initialize a while ago. |
574 | */ | 565 | */ |
575 | if( m_boxName == 0 ){ | 566 | if( m_boxName == 0 ){ |
576 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox | 567 | m_boxName = new QHBox( this ); // remove this this? or use a QHBox |
577 | m_fnLabel = new QLabel( m_boxName ); | 568 | m_fnLabel = new QLabel( m_boxName ); |
578 | m_fnLabel->setText( tr("Name:") ); | 569 | m_fnLabel->setText( tr("Name:") ); |
579 | m_edit = new QLineEdit( m_boxName ); | 570 | m_edit = new QLineEdit( m_boxName ); |
580 | m_edit->setText( m_name ); | 571 | m_edit->setText( m_name ); |
581 | //m_boxName->addWidget( m_fnLabel ); | 572 | //m_boxName->addWidget( m_fnLabel ); |
582 | m_boxName->setMargin( 5 ); | 573 | m_boxName->setMargin( 5 ); |
583 | m_boxName->setSpacing( 8 ); | 574 | m_boxName->setSpacing( 8 ); |
584 | //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor | 575 | //m_boxName->setStretchFactor(m_edit, 100 ); // 100 is stretch factor |
585 | 576 | ||
586 | m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout | 577 | m_lay->addWidget( m_boxName, 0 ); // add it to the topLevel layout |
587 | }// else we already initialized | 578 | }// else we already initialized |
588 | // maybe show the components? | 579 | // maybe show the components? |
589 | // | 580 | // |
590 | } | 581 | } |
591 | void OFileSelector::initializeYes() | 582 | void OFileSelector::initializeYes() |
592 | { | 583 | { |
593 | /** The Save Cancel bar | 584 | /** The Save Cancel bar |
594 | * | 585 | * |
595 | */ | 586 | */ |
596 | if( m_boxOk == 0 ){ | 587 | if( m_boxOk == 0 ){ |
597 | m_boxOk = new QHBox( this ); | 588 | m_boxOk = new QHBox( this ); |
598 | m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); | 589 | m_ok = new QPushButton( tr("&Save"),m_boxOk , "save" ); |
599 | m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); | 590 | m_cancel = new QPushButton( tr("C&ancel"), m_boxOk, "cancel" ); |
600 | 591 | ||
601 | //m_boxOk->addWidget( m_ok ); | 592 | //m_boxOk->addWidget( m_ok ); |
602 | //m_boxOk->addWidget( m_cancel ); | 593 | //m_boxOk->addWidget( m_cancel ); |
603 | m_boxOk->setMargin( 5 ); | 594 | m_boxOk->setMargin( 5 ); |
604 | m_boxOk->setSpacing( 10 ); | 595 | m_boxOk->setSpacing( 10 ); |
605 | m_lay->addWidget( m_boxOk, 0 ); | 596 | m_lay->addWidget( m_boxOk, 0 ); |
606 | 597 | ||
607 | connect( m_ok, SIGNAL( clicked() ), | 598 | connect( m_ok, SIGNAL( clicked() ), |
608 | this, SLOT(slotOk() ) ); | 599 | this, SLOT(slotOk() ) ); |
609 | connect( m_cancel, SIGNAL( clicked() ), | 600 | connect( m_cancel, SIGNAL( clicked() ), |
610 | this, SLOT( slotCancel() ) ); | 601 | this, SLOT( slotCancel() ) ); |
611 | } | 602 | } |
612 | } | 603 | } |
613 | /* | 604 | /* |
614 | * OK m_mimeCheck is a QComboBox we now want to fill | 605 | * OK m_mimeCheck is a QComboBox we now want to fill |
615 | * out that combobox | 606 | * out that combobox |
616 | * if automime we need to update the mimetypes | 607 | * if automime we need to update the mimetypes |
617 | */ | 608 | */ |
618 | void OFileSelector::updateMimeCheck() { | 609 | void OFileSelector::updateMimeCheck() { |
619 | m_mimeCheck->clear(); | 610 | m_mimeCheck->clear(); |
620 | if (m_autoMime ) { | 611 | if (m_autoMime ) { |
621 | //m_mimeCheck->insertItem( tr("All") ); | 612 | //m_mimeCheck->insertItem( tr("All") ); |
622 | updateMimes(); | 613 | updateMimes(); |
623 | } | 614 | } |
624 | 615 | ||
625 | QMap<QString, QStringList>::Iterator it; | 616 | QMap<QString, QStringList>::Iterator it; |
626 | for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { | 617 | for (it = m_mimetypes.begin(); it != m_mimetypes.end(); ++it ) { |
627 | m_mimeCheck->insertItem( it.key() ); | 618 | m_mimeCheck->insertItem( it.key() ); |
628 | } | 619 | } |
629 | } | 620 | } |
630 | 621 | ||
631 | void OFileSelector::initializeChooser() | 622 | void OFileSelector::initializeChooser() |
632 | { | 623 | { |
633 | if( m_boxView == 0 ){ | 624 | if( m_boxView == 0 ){ |
634 | m_boxView = new QHBox( this ); | 625 | m_boxView = new QHBox( this ); |
635 | m_viewCheck = new QComboBox( m_boxView, "view check"); | 626 | m_viewCheck = new QComboBox( m_boxView, "view check"); |
636 | m_mimeCheck = new QComboBox( m_boxView, "mime check"); | 627 | m_mimeCheck = new QComboBox( m_boxView, "mime check"); |
637 | m_boxView->setSpacing( 8 ); | 628 | m_boxView->setSpacing( 8 ); |
638 | m_lay->addWidget(m_boxView, 0 ); | 629 | m_lay->addWidget(m_boxView, 0 ); |
639 | 630 | ||
640 | 631 | ||
641 | updateMimeCheck(); | 632 | updateMimeCheck(); |
642 | fillList(); | 633 | fillList(); |
643 | 634 | ||
644 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), | 635 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), |
645 | this, SLOT( slotViewCheck(const QString & ) ) ); | 636 | this, SLOT( slotViewCheck(const QString & ) ) ); |
646 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), | 637 | connect( m_mimeCheck, SIGNAL( activated(const QString & ) ), |
647 | this, SLOT( slotMimeCheck( const QString & ) ) ); | 638 | this, SLOT( slotMimeCheck( const QString & ) ) ); |
648 | } | 639 | } |
649 | } | 640 | } |
650 | /* generate the buttons for the toolbar */ | 641 | /* generate the buttons for the toolbar */ |
@@ -665,394 +656,394 @@ void OFileSelector::initToolbar() { | |||
665 | m_location->setDuplicatesEnabled( FALSE ); | 656 | m_location->setDuplicatesEnabled( FALSE ); |
666 | connect( m_location, SIGNAL(activated(const QString& ) ), | 657 | connect( m_location, SIGNAL(activated(const QString& ) ), |
667 | this, SLOT(slotLocationActivated(const QString& )) ); | 658 | this, SLOT(slotLocationActivated(const QString& )) ); |
668 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ) , | 659 | connect( m_location->lineEdit(), SIGNAL(returnPressed() ) , |
669 | this, SLOT(locationComboChanged() ) ); | 660 | this, SLOT(locationComboChanged() ) ); |
670 | 661 | ||
671 | // UP Button | 662 | // UP Button |
672 | m_up = new QPushButton( Resource::loadIconSet("up"), QString::null, | 663 | m_up = new QPushButton( Resource::loadIconSet("up"), QString::null, |
673 | m_boxToolbar, "cdUpButton" ); | 664 | m_boxToolbar, "cdUpButton" ); |
674 | m_up->setFixedSize( QSize(20, 20 ) ); | 665 | m_up->setFixedSize( QSize(20, 20 ) ); |
675 | connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) ); | 666 | connect( m_up, SIGNAL( clicked() ), this, SLOT(cdUP() ) ); |
676 | m_up->setFlat( TRUE ); | 667 | m_up->setFlat( TRUE ); |
677 | 668 | ||
678 | // Home Button | 669 | // Home Button |
679 | m_homeButton = new QPushButton(Resource::loadIconSet("home"), | 670 | m_homeButton = new QPushButton(Resource::loadIconSet("home"), |
680 | QString::null, m_boxToolbar ); | 671 | QString::null, m_boxToolbar ); |
681 | m_homeButton->setFixedSize( QSize(20, 20 ) ); | 672 | m_homeButton->setFixedSize( QSize(20, 20 ) ); |
682 | connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) ); | 673 | connect(m_homeButton, SIGNAL(clicked() ), this, SLOT(slotHome() ) ); |
683 | m_homeButton->setFlat( TRUE ); | 674 | m_homeButton->setFlat( TRUE ); |
684 | 675 | ||
685 | // Documents Button | 676 | // Documents Button |
686 | m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"), | 677 | m_docButton = new QPushButton( Resource::loadIconSet("DocsIcon"), |
687 | QString::null, m_boxToolbar, | 678 | QString::null, m_boxToolbar, |
688 | "docsButton" ); | 679 | "docsButton" ); |
689 | m_docButton->setFixedSize( QSize(20, 20 ) ); | 680 | m_docButton->setFixedSize( QSize(20, 20 ) ); |
690 | m_docButton->setFlat( true ); | 681 | m_docButton->setFlat( true ); |
691 | connect( m_docButton, SIGNAL(clicked() ), | 682 | connect( m_docButton, SIGNAL(clicked() ), |
692 | this, SLOT(slotDoc() ) ); | 683 | this, SLOT(slotDoc() ) ); |
693 | 684 | ||
694 | // close button | 685 | // close button |
695 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", | 686 | m_close = new QPushButton( Resource::loadIconSet( "close"), "", |
696 | m_boxToolbar ); | 687 | m_boxToolbar ); |
697 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); | 688 | connect( m_close, SIGNAL(clicked() ), this, SIGNAL(closeMe() ) ); |
698 | m_close->setFixedSize( 20, 20 ); | 689 | m_close->setFixedSize( 20, 20 ); |
699 | 690 | ||
700 | m_boxToolbar->setFixedHeight( 20 ); | 691 | m_boxToolbar->setFixedHeight( 20 ); |
701 | m_pseudoLayout->addWidget(m_boxToolbar ); | 692 | m_pseudoLayout->addWidget(m_boxToolbar ); |
702 | 693 | ||
703 | /* init the locations */ | 694 | /* init the locations */ |
704 | initLocations(); | 695 | initLocations(); |
705 | 696 | ||
706 | if( !m_shTool ){ | 697 | if( !m_shTool ){ |
707 | m_location->hide( ); | 698 | m_location->hide( ); |
708 | m_up->hide( ); | 699 | m_up->hide( ); |
709 | m_homeButton->hide( ); | 700 | m_homeButton->hide( ); |
710 | m_docButton->hide( ); | 701 | m_docButton->hide( ); |
711 | } | 702 | } |
712 | if(!m_shClose ) | 703 | if(!m_shClose ) |
713 | m_close->hide(); | 704 | m_close->hide(); |
714 | 705 | ||
715 | m_mainView->setToolbar( m_pseudo ); | 706 | m_mainView->setToolbar( m_pseudo ); |
716 | m_lay->addWidget( m_mainView, 100 ); | 707 | m_lay->addWidget( m_mainView, 100 ); |
717 | } | 708 | } |
718 | /* put default locations into the bar */ | 709 | /* put default locations into the bar */ |
719 | void OFileSelector::initLocations () { | 710 | void OFileSelector::initLocations () { |
720 | 711 | ||
721 | // let;s fill the Location ComboBox | 712 | // let;s fill the Location ComboBox |
722 | StorageInfo storage; | 713 | StorageInfo storage; |
723 | const QList<FileSystem> &fs = storage.fileSystems(); | 714 | const QList<FileSystem> &fs = storage.fileSystems(); |
724 | QListIterator<FileSystem> it ( fs ); | 715 | QListIterator<FileSystem> it ( fs ); |
725 | for( ; it.current(); ++it ){ | 716 | for( ; it.current(); ++it ){ |
726 | const QString disk = (*it)->name(); | 717 | const QString disk = (*it)->name(); |
727 | const QString path = (*it)->path(); | 718 | const QString path = (*it)->path(); |
728 | m_location->insertItem(path+ "<-"+disk ); | 719 | m_location->insertItem(path+ "<-"+disk ); |
729 | } | 720 | } |
730 | int count = m_location->count(); | 721 | int count = m_location->count(); |
731 | m_location->insertItem( m_currentDir ); | 722 | m_location->insertItem( m_currentDir ); |
732 | m_location->setCurrentItem( count ); | 723 | m_location->setCurrentItem( count ); |
733 | 724 | ||
734 | } | 725 | } |
735 | void OFileSelector::initializePerm() | 726 | void OFileSelector::initializePerm() |
736 | { | 727 | { |
737 | if( m_checkPerm == 0 ){ | 728 | if( m_checkPerm == 0 ){ |
738 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm"); | 729 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm"); |
739 | m_checkPerm->setChecked( false ); | 730 | m_checkPerm->setChecked( false ); |
740 | m_lay->addWidget( m_checkPerm ); | 731 | m_lay->addWidget( m_checkPerm ); |
741 | } | 732 | } |
742 | } | 733 | } |
743 | void OFileSelector::initPics() | 734 | void OFileSelector::initPics() |
744 | { | 735 | { |
745 | m_pixmaps = new QMap<QString,QPixmap>; | 736 | m_pixmaps = new QMap<QString,QPixmap>; |
746 | QPixmap pm = Resource::loadPixmap( "folder" ); | 737 | QPixmap pm = Resource::loadPixmap( "folder" ); |
747 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 738 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
748 | 739 | ||
749 | QPainter painter( &pm ); | 740 | QPainter painter( &pm ); |
750 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 741 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
751 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 742 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
752 | m_pixmaps->insert("dirsymlink", pm ); | 743 | m_pixmaps->insert("dirsymlink", pm ); |
753 | 744 | ||
754 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 745 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
755 | QPainter pen(&pm2 ); | 746 | QPainter pen(&pm2 ); |
756 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 747 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
757 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 748 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
758 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 749 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
759 | } | 750 | } |
760 | // if a mime complies with the m_mimeCheck->currentItem | 751 | // if a mime complies with the m_mimeCheck->currentItem |
761 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) | 752 | bool OFileSelector::compliesMime( const QString &path, const QString &mime ) |
762 | { | 753 | { |
763 | if( mime == "All" ) | 754 | if( mime == "All" ) |
764 | return true; | 755 | return true; |
765 | MimeType type( path ); | 756 | MimeType type( path ); |
766 | if( type.id() == mime ) | 757 | if( type.id() == mime ) |
767 | return true; | 758 | return true; |
768 | return false; | 759 | return false; |
769 | } | 760 | } |
770 | /* check if the mimetype in mime | 761 | /* check if the mimetype in mime |
771 | * complies with the one which is current | 762 | * complies with the one which is current |
772 | */ | 763 | */ |
773 | /* | 764 | /* |
774 | * We've the mimetype of the file | 765 | * We've the mimetype of the file |
775 | * We need to get the stringlist of the current mimetype | 766 | * We need to get the stringlist of the current mimetype |
776 | * | 767 | * |
777 | * mime = image/jpeg | 768 | * mime = image/jpeg |
778 | * QStringList = 'image/*' | 769 | * QStringList = 'image/*' |
779 | * or QStringList = image/jpeg;image/png;application/x-ogg | 770 | * or QStringList = image/jpeg;image/png;application/x-ogg |
780 | * or QStringList = application/x-ogg;image/*; | 771 | * or QStringList = application/x-ogg;image/*; |
781 | * with all these mime filters it should get acceptes | 772 | * with all these mime filters it should get acceptes |
782 | * to do so we need to look if mime is contained inside | 773 | * to do so we need to look if mime is contained inside |
783 | * the stringlist | 774 | * the stringlist |
784 | * if it's contained return true | 775 | * if it's contained return true |
785 | * if not ( I'm no RegExp expert at all ) we'll look if a '/*' | 776 | * if not ( I'm no RegExp expert at all ) we'll look if a '/*' |
786 | * is contained in the mimefilter and then we will | 777 | * is contained in the mimefilter and then we will |
787 | * look if both are equal until the '/' | 778 | * look if both are equal until the '/' |
788 | */ | 779 | */ |
789 | bool OFileSelector::compliesMime( const QString& mime ) { | 780 | bool OFileSelector::compliesMime( const QString& mime ) { |
790 | qWarning("mimetype is %s", mime.latin1() ); | 781 | qWarning("mimetype is %s", mime.latin1() ); |
791 | QString currentText; | 782 | QString currentText; |
792 | if (m_shChooser ) | 783 | if (m_shChooser ) |
793 | currentText = m_mimeCheck->currentText(); | 784 | currentText = m_mimeCheck->currentText(); |
794 | 785 | ||
795 | qWarning("current text is %s", currentText.latin1() ); | 786 | qWarning("current text is %s", currentText.latin1() ); |
796 | QMap<QString, QStringList>::Iterator it; | 787 | QMap<QString, QStringList>::Iterator it; |
797 | QStringList list; | 788 | QStringList list; |
798 | if ( currentText == tr("All") ) return true; | 789 | if ( currentText == tr("All") ) return true; |
799 | else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { | 790 | else if ( currentText.isEmpty() && !m_mimetypes.isEmpty() ) { |
800 | it = m_mimetypes.begin(); | 791 | it = m_mimetypes.begin(); |
801 | list = it.data(); | 792 | list = it.data(); |
802 | }else if ( currentText.isEmpty() ) return true; | 793 | }else if ( currentText.isEmpty() ) return true; |
803 | else{ | 794 | else{ |
804 | it = m_mimetypes.find(currentText ); | 795 | it = m_mimetypes.find(currentText ); |
805 | if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; | 796 | if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; |
806 | else qWarning("found"), list = it.data(); | 797 | else qWarning("found"), list = it.data(); |
807 | } | 798 | } |
808 | 799 | ||
809 | 800 | ||
810 | if ( list.contains(mime) ) return true; | 801 | if ( list.contains(mime) ) return true; |
811 | qWarning("list doesn't contain it "); | 802 | qWarning("list doesn't contain it "); |
812 | QStringList::Iterator it2; | 803 | QStringList::Iterator it2; |
813 | int pos; | 804 | int pos; |
814 | for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { | 805 | for ( it2 = list.begin(); it2 != list.end(); ++it2 ) { |
815 | pos = (*it2).findRev("/*"); | 806 | pos = (*it2).findRev("/*"); |
816 | if ( pos >= 0 ) { | 807 | if ( pos >= 0 ) { |
817 | if ( mime.contains( (*it2).left(pos) ) ) return true; | 808 | if ( mime.contains( (*it2).left(pos) ) ) return true; |
818 | } | 809 | } |
819 | } | 810 | } |
820 | return false; | 811 | return false; |
821 | } | 812 | } |
822 | void OFileSelector::slotFileSelected( const QString &string ) | 813 | void OFileSelector::slotFileSelected( const QString &string ) |
823 | { | 814 | { |
824 | if( m_shLne ) | 815 | if( m_shLne ) |
825 | m_edit->setText( string ); | 816 | m_edit->setText( string ); |
826 | emit fileSelected( string ); | 817 | emit fileSelected( string ); |
827 | } | 818 | } |
828 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) | 819 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) |
829 | { | 820 | { |
830 | slotFileSelected( lnk.name() ); | 821 | slotFileSelected( lnk.name() ); |
831 | // emit fileSelected( lnk ); | 822 | // emit fileSelected( lnk ); |
832 | } | 823 | } |
833 | 824 | ||
834 | 825 | ||
835 | void OFileSelector::slotDelete() | 826 | void OFileSelector::slotDelete() |
836 | { | 827 | { |
837 | /* | 828 | /* |
838 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 829 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
839 | QStringList list = QStringList::split("->", sel->text(1) ); | 830 | QStringList list = QStringList::split("->", sel->text(1) ); |
840 | if( sel->isDir() ){ | 831 | if( sel->isDir() ){ |
841 | QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry | 832 | QString str = QString::fromLatin1("rm -rf ") + sel->directory() +"/" + list[0]; //better safe than sorry |
842 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], | 833 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], |
843 | tr("Yes"),tr("No"),0,1,1) ) { | 834 | tr("Yes"),tr("No"),0,1,1) ) { |
844 | case 0: | 835 | case 0: |
845 | ::system(str.utf8().data() ); | 836 | ::system(str.utf8().data() ); |
846 | break; | 837 | break; |
847 | } | 838 | } |
848 | } else { | 839 | } else { |
849 | QFile::remove( list[0] ); | 840 | QFile::remove( list[0] ); |
850 | } | 841 | } |
851 | m_View->takeItem( sel ); | 842 | m_View->takeItem( sel ); |
852 | delete sel; | 843 | delete sel; |
853 | */ | 844 | */ |
854 | } | 845 | } |
855 | void OFileSelector::cdUP() | 846 | void OFileSelector::cdUP() |
856 | { | 847 | { |
848 | // FIXME won't work on non filesystem based systems | ||
849 | // better call the Olister | ||
857 | QDir dir( m_currentDir ); | 850 | QDir dir( m_currentDir ); |
858 | dir.cdUp(); | 851 | dir.cdUp(); |
859 | if(dir.exists() ){ | 852 | if(dir.exists() ){ |
860 | m_currentDir = dir.absPath(); | 853 | m_currentDir = dir.absPath(); |
861 | reparse(); | 854 | reparse(); |
862 | int count = m_location->count(); | 855 | int count = m_location->count(); |
863 | slotInsertLocationPath( m_currentDir, count); | 856 | slotInsertLocationPath( m_currentDir, count); |
864 | m_location->setCurrentItem( indexByString( m_location, m_currentDir)); | 857 | m_location->setCurrentItem( indexByString( m_location, m_currentDir)); |
865 | //this wont work in all instances | ||
866 | // FIXME | ||
867 | } | 858 | } |
868 | } | 859 | } |
869 | void OFileSelector::slotHome() | 860 | void OFileSelector::slotHome() |
870 | { | 861 | { |
871 | cd(QDir::homeDirPath() ); | 862 | cd(QDir::homeDirPath() ); |
872 | } | 863 | } |
873 | void OFileSelector::slotDoc() | 864 | void OFileSelector::slotDoc() |
874 | { | 865 | { |
875 | cd(QPEApplication::documentDir() ); | 866 | cd(QPEApplication::documentDir() ); |
876 | } | 867 | } |
877 | void OFileSelector::slotNavigate( ) | 868 | void OFileSelector::slotNavigate( ) |
878 | { | 869 | { |
879 | 870 | ||
880 | } | 871 | } |
881 | // fill the View with life | 872 | // fill the View with life |
882 | void OFileSelector::reparse() | 873 | void OFileSelector::reparse() |
883 | { | 874 | { |
884 | if( m_selector == Normal ) | 875 | if( m_selector == Normal ) |
885 | return; | 876 | return; |
886 | 877 | ||
887 | currentView()->clear(); | 878 | currentView()->clear(); |
888 | 879 | ||
889 | if( m_shChooser) | 880 | if( m_shChooser) |
890 | qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); | 881 | qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); |
891 | 882 | ||
892 | QString currentMimeType; | 883 | QString currentMimeType; |
893 | 884 | ||
894 | // let's update the mimetype | 885 | // let's update the mimetype |
895 | if( m_autoMime ){ | 886 | if( m_autoMime ){ |
896 | m_mimetypes.clear(); | 887 | m_mimetypes.clear(); |
897 | // ok we can change mimetype so we need to be able to give a selection | 888 | // ok we can change mimetype so we need to be able to give a selection |
898 | if( m_shChooser ) { | 889 | if( m_shChooser ) { |
899 | currentMimeType = m_mimeCheck->currentText(); | 890 | currentMimeType = m_mimeCheck->currentText(); |
900 | m_mimeCheck->clear(); | 891 | m_mimeCheck->clear(); |
901 | 892 | ||
902 | // let's find possible mimetypes | 893 | // let's find possible mimetypes |
903 | m_mimetypes = currentLister()->mimeTypes( m_currentDir ); | 894 | m_mimetypes = currentLister()->mimeTypes( m_currentDir ); |
904 | 895 | ||
905 | // add them to the chooser | 896 | // add them to the chooser |
906 | updateMimeCheck(); | 897 | updateMimeCheck(); |
907 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); | 898 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); |
908 | currentMimeType = m_mimeCheck->currentText(); | 899 | currentMimeType = m_mimeCheck->currentText(); |
909 | } | 900 | } |
910 | }else { // no autoMime | 901 | }else { // no autoMime |
911 | // let the mimetype be set from out side the m_mimeCheck FEATURE | 902 | // let the mimetype be set from out side the m_mimeCheck FEATURE |
912 | 903 | ||
913 | if( m_shChooser ) | 904 | if( m_shChooser ) |
914 | currentMimeType = m_mimeCheck->currentText(); | 905 | currentMimeType = m_mimeCheck->currentText(); |
915 | 906 | ||
916 | } | 907 | } |
917 | // now we got our mimetypes we can add the files | 908 | // now we got our mimetypes we can add the files |
918 | 909 | ||
919 | currentLister()->reparse( m_currentDir ); | 910 | currentLister()->reparse( m_currentDir ); |
920 | /* we're done with adding let's sort */ | 911 | /* we're done with adding let's sort */ |
921 | currentView()->sort(); | 912 | currentView()->sort(); |
922 | 913 | ||
923 | 914 | ||
924 | if( m_shTool ){ | 915 | if( m_shTool ){ |
925 | m_location->insertItem( m_currentDir ); | 916 | m_location->insertItem( m_currentDir ); |
926 | 917 | ||
927 | } | 918 | } |
928 | // reenable painting and updates | 919 | // reenable painting and updates |
929 | } | 920 | } |
930 | /* switch lister to @param lister */ | 921 | /* switch lister to @param lister */ |
931 | void OFileSelector::setLister(const QString& lister) { | 922 | void OFileSelector::setLister(const QString& lister) { |
932 | QStringList listerList = factory()->lister(); | 923 | QStringList listerList = factory()->lister(); |
933 | 924 | ||
934 | if (listerList.contains(lister) ) { | 925 | if (listerList.contains(lister) ) { |
935 | delete (OLister*) m_lister; | 926 | delete (OLister*) m_lister; |
936 | m_lister = factory()->lister( lister, this ); | 927 | m_lister = factory()->lister( lister, this ); |
937 | }else if (!m_lister ) { | 928 | }else if (!m_lister ) { |
938 | /* | 929 | /* |
939 | * if we do not have a lister | 930 | * if we do not have a lister |
940 | * we need to take the default one | 931 | * we need to take the default one |
941 | */ | 932 | */ |
942 | m_lister = new OLocalLister(this); | 933 | m_lister = new OLocalLister(this); |
943 | } | 934 | } |
944 | m_listerName = lister; | 935 | m_listerName = lister; |
945 | } | 936 | } |
946 | void OFileSelector::setView( const QString& lis ) { | 937 | void OFileSelector::setView( const QString& lis ) { |
947 | qWarning("setView "); | 938 | qWarning("setView "); |
948 | fillList(); | 939 | fillList(); |
949 | if ( lis == tr("Documents") ) { | 940 | if ( lis == tr("Documents") ) { |
950 | m_selector = Normal; | 941 | m_selector = Normal; |
951 | delete m_lister; | 942 | delete m_lister; |
952 | delete m_fileView; | 943 | delete m_fileView; |
953 | m_lister = 0l; | 944 | m_lister = 0l; |
954 | m_fileView = 0l; | 945 | m_fileView = 0l; |
955 | initializeOldSelector(); | 946 | initializeOldSelector(); |
956 | }else { | 947 | }else { |
957 | qWarning("lis %s", lis.latin1() ); | 948 | qWarning("lis %s", lis.latin1() ); |
958 | QString list; | 949 | QString list; |
959 | 950 | ||
960 | delete m_lister; | 951 | delete m_lister; |
961 | delete m_fileView; | 952 | delete m_fileView; |
962 | delete m_select; | 953 | delete m_select; |
963 | m_lister =0l; | 954 | m_lister =0l; |
964 | m_fileView = 0l; | 955 | m_fileView = 0l; |
965 | m_select = 0l; | 956 | m_select = 0l; |
966 | if ( lis.startsWith("All") ) { | 957 | if ( lis.startsWith("All") ) { |
967 | m_selector = ExtendedAll; | 958 | m_selector = ExtendedAll; |
968 | list = lis.mid(4 ).stripWhiteSpace(); | 959 | list = lis.mid(4 ).stripWhiteSpace(); |
969 | } else{ | 960 | } else{ |
970 | list = lis; | 961 | list = lis; |
971 | m_selector = Extended; | 962 | m_selector = Extended; |
972 | } | 963 | } |
973 | setLister(m_listerName); | 964 | setLister(m_listerName); |
974 | m_fileView = factory()->view( list, this, m_mainView ); | 965 | m_fileView = factory()->view( list, this, m_mainView ); |
975 | m_mainView->setWidget( m_fileView->widget() ); | 966 | m_mainView->setWidget( m_fileView->widget() ); |
976 | reparse(); | 967 | reparse(); |
977 | } | 968 | } |
978 | } | 969 | } |
979 | /* | 970 | /* |
980 | * the factory | 971 | * the factory |
981 | */ | 972 | */ |
982 | void OFileSelector::initFactory() { | 973 | void OFileSelector::initFactory() { |
983 | m_fileFactory = new OFileFactory(); | 974 | m_fileFactory = new OFileFactory(); |
984 | m_fileFactory->addLister(tr("Files"), newLocalLister ); | 975 | m_fileFactory->addLister(tr("Files"), newLocalLister ); |
985 | m_fileFactory->addView(tr("List View"), newFileListView ); | 976 | m_fileFactory->addView(tr("List View"), newFileListView ); |
986 | /* the factory is just a dummy */ | 977 | /* the factory is just a dummy */ |
987 | m_fileFactory->addView(tr("Documents"), newFileListView ); | 978 | m_fileFactory->addView(tr("Documents"), newFileListView ); |
988 | } | 979 | } |
989 | void OFileSelector::fillList() { | 980 | void OFileSelector::fillList() { |
990 | qWarning("fill list"); | 981 | qWarning("fill list"); |
991 | if (!m_viewCheck ) | 982 | if (!m_viewCheck ) |
992 | return; | 983 | return; |
993 | 984 | ||
994 | m_viewCheck->clear(); | 985 | m_viewCheck->clear(); |
995 | QStringList list = factory()->views(); | 986 | QStringList list = factory()->views(); |
996 | qWarning("views: " + list.join(";") ); | 987 | qWarning("views: " + list.join(";") ); |
997 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 988 | for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { |
998 | qWarning( (*it) ); | 989 | qWarning( (*it) ); |
999 | if ( (*it) == tr("Documents") ) { | 990 | if ( (*it) == tr("Documents") ) { |
1000 | m_viewCheck->insertItem( (*it) ); | 991 | m_viewCheck->insertItem( (*it) ); |
1001 | }else{ | 992 | }else{ |
1002 | m_viewCheck->insertItem( (*it) ); | 993 | m_viewCheck->insertItem( (*it) ); |
1003 | m_viewCheck->insertItem( tr("All ") + (*it) ); | 994 | m_viewCheck->insertItem( tr("All ") + (*it) ); |
1004 | } | 995 | } |
1005 | } | 996 | } |
1006 | } | 997 | } |
1007 | OFileFactory* OFileSelector::factory() { | 998 | OFileFactory* OFileSelector::factory() { |
1008 | return m_fileFactory; | 999 | return m_fileFactory; |
1009 | } | 1000 | } |
1010 | 1001 | ||
1011 | 1002 | ||
1012 | OFileView* OFileSelector::currentView() { | 1003 | OFileView* OFileSelector::currentView() { |
1013 | return m_fileView; | 1004 | return m_fileView; |
1014 | } | 1005 | } |
1015 | OFileView* OFileSelector::currentView() const{ | 1006 | OFileView* OFileSelector::currentView() const{ |
1016 | return m_fileView; | 1007 | return m_fileView; |
1017 | } | 1008 | } |
1018 | int OFileSelector::filter() { | 1009 | int OFileSelector::filter() { |
1019 | int filter; | 1010 | int filter; |
1020 | if ( m_selector == ExtendedAll ) | 1011 | if ( m_selector == ExtendedAll ) |
1021 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | 1012 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; |
1022 | else | 1013 | else |
1023 | filter = QDir::Files | QDir::Dirs | QDir::All ; | 1014 | filter = QDir::Files | QDir::Dirs | QDir::All ; |
1024 | 1015 | ||
1025 | return filter; | 1016 | return filter; |
1026 | } | 1017 | } |
1027 | int OFileSelector::sorting() { | 1018 | int OFileSelector::sorting() { |
1028 | int sort; | 1019 | int sort; |
1029 | 1020 | ||
1030 | if (m_case ) | 1021 | if (m_case ) |
1031 | sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 1022 | sort = ( QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
1032 | else | 1023 | else |
1033 | sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed ); | 1024 | sort = ( QDir::Name | QDir::DirsFirst | QDir::Reversed ); |
1034 | 1025 | ||
1035 | return sort; | 1026 | return sort; |
1036 | } | 1027 | } |
1037 | void OFileSelector::internFileSelected( const QString& s) { | 1028 | void OFileSelector::internFileSelected( const QString& s) { |
1038 | emit fileSelected( s ); | 1029 | emit fileSelected( s ); |
1039 | DocLnk lnk( s ); | 1030 | DocLnk lnk( s ); |
1040 | internFileSelected( lnk ); | 1031 | internFileSelected( lnk ); |
1041 | } | 1032 | } |
1042 | void OFileSelector::internFileSelected( const DocLnk& d ) { | 1033 | void OFileSelector::internFileSelected( const DocLnk& d ) { |
1043 | emit fileSelected( d ); | 1034 | emit fileSelected( d ); |
1044 | } | 1035 | } |
1045 | void OFileSelector::internContextMenu() { | 1036 | void OFileSelector::internContextMenu() { |
1046 | emit contextMenu(); | 1037 | emit contextMenu(); |
1047 | } | 1038 | } |
1048 | void OFileSelector::internChangedDir( const QString& s) { | 1039 | void OFileSelector::internChangedDir( const QString& s) { |
1049 | emit dirSelected( s ); | 1040 | emit dirSelected( s ); |
1050 | cd(s ); | 1041 | cd(s ); |
1051 | } | 1042 | } |
1052 | void OFileSelector::internChangedDir( const QDir& s) { | 1043 | void OFileSelector::internChangedDir( const QDir& s) { |
1053 | emit dirSelected( s ); | 1044 | emit dirSelected( s ); |
1054 | } | 1045 | } |
1055 | QPixmap OFileSelector::pixmap( const QString& s ) { | 1046 | QPixmap OFileSelector::pixmap( const QString& s ) { |
1056 | 1047 | ||
1057 | return (*m_pixmaps)[s]; | 1048 | return (*m_pixmaps)[s]; |
1058 | } | 1049 | } |
diff --git a/libopie/ofileselector/olister.cpp b/libopie/ofileselector/olister.cpp index ea09940..aaaf6a2 100644 --- a/libopie/ofileselector/olister.cpp +++ b/libopie/ofileselector/olister.cpp | |||
@@ -1,171 +1,181 @@ | |||
1 | #include <qcombobox.h> | 1 | #include <qcombobox.h> |
2 | #include <qlineedit.h> | ||
2 | 3 | ||
3 | #include "olister.h" | 4 | #include "olister.h" |
4 | #include "ofileview.h" | 5 | #include "ofileview.h" |
5 | #include "opixmapprovider.h" | 6 | #include "opixmapprovider.h" |
6 | #include "ofileselector.h" | 7 | #include "ofileselector.h" |
7 | 8 | ||
8 | 9 | ||
9 | OLister::OLister( OFileSelector* view) | 10 | OLister::OLister( OFileSelector* view) |
10 | : m_view( view ), m_acc( 0l ) | 11 | : m_view( view ), m_acc( 0l ) |
11 | { | 12 | { |
12 | m_prov = new OPixmapProvider( view ); | 13 | m_prov = new OPixmapProvider( view ); |
13 | } | 14 | } |
14 | OLister::~OLister() { | 15 | OLister::~OLister() { |
15 | delete m_prov; | 16 | delete m_prov; |
16 | } | 17 | } |
17 | void OLister::setPixmapProvider( OPixmapProvider* prov ) { | 18 | void OLister::setPixmapProvider( OPixmapProvider* prov ) { |
18 | delete m_prov; | 19 | delete m_prov; |
19 | m_prov = prov; | 20 | m_prov = prov; |
20 | } | 21 | } |
21 | bool OLister::showFiles()const { | 22 | bool OLister::showFiles()const { |
22 | return m_view->showFiles(); | 23 | return m_view->showFiles(); |
23 | } | 24 | } |
24 | bool OLister::showDirs()const { | 25 | bool OLister::showDirs()const { |
25 | return m_view->showDirs(); | 26 | return m_view->showDirs(); |
26 | } | 27 | } |
27 | void OLister::addFile( const QString& mine, | 28 | void OLister::addFile( const QString& mine, |
28 | QFileInfo* info, | 29 | QFileInfo* info, |
29 | const QString& extra, | 30 | const QString& extra, |
30 | bool isSymlink ) { | 31 | bool isSymlink ) { |
31 | int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink : | 32 | int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink : |
32 | OPixmapProvider::File; | 33 | OPixmapProvider::File; |
33 | QPixmap pix = provider()->pixmap(t, mine, | 34 | QPixmap pix = provider()->pixmap(t, mine, |
34 | info); | 35 | info); |
35 | view()->currentView()->addFile( pix, | 36 | view()->currentView()->addFile( pix, |
36 | mine, | 37 | mine, |
37 | info, | 38 | info, |
38 | extra, | 39 | extra, |
39 | isSymlink ); | 40 | isSymlink ); |
40 | } | 41 | } |
41 | void OLister::addFile( const QString& mine, | 42 | void OLister::addFile( const QString& mine, |
42 | const QString& path, | 43 | const QString& path, |
43 | const QString& file, | 44 | const QString& file, |
44 | const QString& extra, | 45 | const QString& extra, |
45 | bool isSymlink ) { | 46 | bool isSymlink ) { |
46 | int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink : | 47 | int t = isSymlink ? OPixmapProvider::File | OPixmapProvider::Symlink : |
47 | OPixmapProvider::File; | 48 | OPixmapProvider::File; |
48 | 49 | ||
49 | QPixmap pix = provider()->pixmap(t, mine, path, file ); | 50 | QPixmap pix = provider()->pixmap(t, mine, path, file ); |
50 | view()->currentView()->addFile( pix, | 51 | view()->currentView()->addFile( pix, |
51 | mine, | 52 | mine, |
52 | path, | 53 | path, |
53 | file, | 54 | file, |
54 | extra, | 55 | extra, |
55 | isSymlink ); | 56 | isSymlink ); |
56 | } | 57 | } |
57 | void OLister::addDir( const QString& mine, | 58 | void OLister::addDir( const QString& mine, |
58 | QFileInfo* info, | 59 | QFileInfo* info, |
59 | const QString& extra, | 60 | const QString& extra, |
60 | bool isSymlink ) { | 61 | bool isSymlink ) { |
61 | int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink : | 62 | int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink : |
62 | OPixmapProvider::Dir; | 63 | OPixmapProvider::Dir; |
63 | QPixmap pix = provider()->pixmap(t, mine, info ); | 64 | QPixmap pix = provider()->pixmap(t, mine, info ); |
64 | view()->currentView()->addDir( pix, | 65 | view()->currentView()->addDir( pix, |
65 | mine, | 66 | mine, |
66 | info, | 67 | info, |
67 | extra, | 68 | extra, |
68 | isSymlink ); | 69 | isSymlink ); |
69 | } | 70 | } |
70 | void OLister::addDir( const QString& mine, | 71 | void OLister::addDir( const QString& mine, |
71 | const QString& path, | 72 | const QString& path, |
72 | const QString& dir, | 73 | const QString& dir, |
73 | const QString& extra, | 74 | const QString& extra, |
74 | bool isSymlink ) { | 75 | bool isSymlink ) { |
75 | 76 | ||
76 | int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink : | 77 | int t = isSymlink ? OPixmapProvider::Dir | OPixmapProvider::Symlink : |
77 | OPixmapProvider::Dir; | 78 | OPixmapProvider::Dir; |
78 | QPixmap pix = provider()->pixmap(t, mine, path, dir ); | 79 | QPixmap pix = provider()->pixmap(t, mine, path, dir ); |
79 | 80 | ||
80 | view()->currentView()->addDir( pix, | 81 | view()->currentView()->addDir( pix, |
81 | mine, | 82 | mine, |
82 | path, | 83 | path, |
83 | dir, | 84 | dir, |
84 | extra, | 85 | extra, |
85 | isSymlink ); | 86 | isSymlink ); |
86 | } | 87 | } |
87 | void OLister::addSymlink( const QString& mine, | 88 | void OLister::addSymlink( const QString& mine, |
88 | QFileInfo* info, | 89 | QFileInfo* info, |
89 | const QString& extra, | 90 | const QString& extra, |
90 | bool isSymlink ) { | 91 | bool isSymlink ) { |
91 | QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, info ); | 92 | QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, info ); |
92 | view()->currentView()->addSymlink( pix, | 93 | view()->currentView()->addSymlink( pix, |
93 | mine, | 94 | mine, |
94 | info, | 95 | info, |
95 | extra, | 96 | extra, |
96 | isSymlink ); | 97 | isSymlink ); |
97 | } | 98 | } |
98 | void OLister::addSymlink( const QString& mine, | 99 | void OLister::addSymlink( const QString& mine, |
99 | const QString& path, | 100 | const QString& path, |
100 | const QString& name, | 101 | const QString& name, |
101 | const QString& extra, | 102 | const QString& extra, |
102 | bool isSymlink ) { | 103 | bool isSymlink ) { |
103 | QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, | 104 | QPixmap pix = provider()->pixmap( OPixmapProvider::Symlink, mine, |
104 | path, name ); | 105 | path, name ); |
105 | view()->currentView()->addSymlink( pix, | 106 | view()->currentView()->addSymlink( pix, |
106 | mine, | 107 | mine, |
107 | path, | 108 | path, |
108 | name, | 109 | name, |
109 | extra, | 110 | extra, |
110 | isSymlink ); | 111 | isSymlink ); |
111 | } | 112 | } |
112 | OFileSelector* OLister::view() { | 113 | OFileSelector* OLister::view() { |
113 | return m_view; | 114 | return m_view; |
114 | } | 115 | } |
116 | OFileSelector* OLister::view()const { | ||
117 | return m_view; | ||
118 | } | ||
115 | OPixmapProvider* OLister::provider() { | 119 | OPixmapProvider* OLister::provider() { |
116 | return m_prov; | 120 | return m_prov; |
117 | } | 121 | } |
118 | bool OLister::compliesMime( const QString& mime ) { | 122 | bool OLister::compliesMime( const QString& mime ) { |
119 | return view()->compliesMime( mime ); | 123 | return view()->compliesMime( mime ); |
120 | } | 124 | } |
121 | void OLister::internFileSelected( const QString& dir ) { | 125 | void OLister::internFileSelected( const QString& dir ) { |
122 | view()->internFileSelected( dir ); | 126 | view()->internFileSelected( dir ); |
123 | } | 127 | } |
124 | void OLister::internChangedDir( const QString& dir ) { | 128 | void OLister::internChangedDir( const QString& dir ) { |
125 | view()->internChangedDir( dir ); | 129 | view()->internChangedDir( dir ); |
126 | } | 130 | } |
127 | OListerCmbAccess* OLister::comboBox() { | 131 | OListerCmbAccess* OLister::comboBox() { |
128 | if (!m_acc ) | 132 | if (!m_acc ) |
129 | m_acc = new OListerCmbAccess( view()->m_location ); | 133 | m_acc = new OListerCmbAccess( view()->m_location ); |
130 | 134 | ||
131 | return m_acc; | 135 | return m_acc; |
132 | } | 136 | } |
133 | 137 | ||
134 | 138 | ||
135 | OListerCmbAccess::OListerCmbAccess(QComboBox* cmb ) | 139 | OListerCmbAccess::OListerCmbAccess(QComboBox* cmb ) |
136 | : m_cmb( cmb ) | 140 | : m_cmb( cmb ) |
137 | {} | 141 | {} |
138 | OListerCmbAccess::~OListerCmbAccess() { | 142 | OListerCmbAccess::~OListerCmbAccess() { |
139 | } | 143 | } |
140 | void OListerCmbAccess::clear() { | 144 | void OListerCmbAccess::clear() { |
141 | if ( m_cmb ) | 145 | if ( m_cmb ) |
142 | m_cmb->clear(); | 146 | m_cmb->clear(); |
143 | } | 147 | } |
144 | void OListerCmbAccess::setCurrentItem( const QString& add, bool FORCE_ADD) { | 148 | void OListerCmbAccess::setCurrentItem( const QString& add, bool FORCE_ADD) { |
145 | if ( !m_cmb ) return; | 149 | if ( !m_cmb ) return; |
146 | 150 | ||
147 | 151 | ||
148 | int c = m_cmb->count(); | 152 | int c = m_cmb->count(); |
149 | for ( int i = 0; i < m_cmb->count(); i++ ) { | 153 | for ( int i = 0; i < m_cmb->count(); i++ ) { |
150 | if ( m_cmb->text(i) == add ) { | 154 | if ( m_cmb->text(i) == add ) { |
151 | m_cmb->setCurrentItem( i ); | 155 | m_cmb->setCurrentItem( i ); |
152 | return; | 156 | return; |
153 | } | 157 | } |
154 | } | 158 | } |
155 | if (!FORCE_ADD ) return; | 159 | if (!FORCE_ADD ) return; |
156 | 160 | ||
157 | 161 | ||
158 | m_cmb->insertItem(add ); | 162 | m_cmb->insertItem(add ); |
159 | m_cmb->setCurrentItem( c ); | 163 | m_cmb->setCurrentItem( c ); |
160 | } | 164 | } |
161 | void OListerCmbAccess::insert( const QString& str ) { | 165 | void OListerCmbAccess::insert( const QString& str ) { |
162 | if ( m_cmb ) | 166 | if ( m_cmb ) |
163 | m_cmb->insertItem( str ); | 167 | m_cmb->insertItem( str ); |
164 | } | 168 | } |
165 | QString OListerCmbAccess::currentText()const { | 169 | QString OListerCmbAccess::currentText()const { |
166 | QString str; | 170 | QString str; |
167 | if (m_cmb ) | 171 | if (m_cmb ) |
168 | str = m_cmb->currentText(); | 172 | str = m_cmb->currentText(); |
169 | 173 | ||
170 | return str; | 174 | return str; |
171 | } | 175 | } |
176 | QString OLister::lineEdit()const { | ||
177 | if ( view()->m_shLne ) | ||
178 | return view()->m_edit->text(); | ||
179 | |||
180 | return QString::null; | ||
181 | } | ||
diff --git a/libopie/ofileselector/olister.h b/libopie/ofileselector/olister.h index cd84316..4adb9f8 100644 --- a/libopie/ofileselector/olister.h +++ b/libopie/ofileselector/olister.h | |||
@@ -1,128 +1,144 @@ | |||
1 | #ifndef OPIE_FILE_LISTER_H | 1 | #ifndef OPIE_FILE_LISTER_H |
2 | #define OPIE_FILE_LISTER_H | 2 | #define OPIE_FILE_LISTER_H |
3 | 3 | ||
4 | #include <qfileinfo.h> | 4 | #include <qfileinfo.h> |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <qstringlist.h> | 7 | #include <qstringlist.h> |
8 | 8 | ||
9 | class QComboBox; | 9 | class QComboBox; |
10 | class OPixmapProvider; | 10 | class OPixmapProvider; |
11 | class OFileSelector; | 11 | class OFileSelector; |
12 | 12 | ||
13 | class OListerCmbAccess; | 13 | class OListerCmbAccess; |
14 | /** | 14 | /** |
15 | * lister is something like KIO but very | 15 | * lister is something like KIO but very |
16 | * very basic and currently only for | 16 | * very basic and currently only for |
17 | * populating our views. | 17 | * populating our views. |
18 | * This is a base class which needs to be implemented. | 18 | * This is a base class which needs to be implemented. |
19 | * @see OLocalLister for a filesystem based implementation | 19 | * @see OLocalLister for a filesystem based implementation |
20 | */ | 20 | */ |
21 | 21 | ||
22 | class OLister { | 22 | class OLister { |
23 | public: | 23 | public: |
24 | OLister( OFileSelector* ); | 24 | OLister( OFileSelector* ); |
25 | virtual ~OLister(); | 25 | virtual ~OLister(); |
26 | virtual void reparse(const QString& path) = 0; | 26 | |
27 | /** | ||
28 | * if path == QString::null reread current dir | ||
29 | */ | ||
30 | virtual void reparse(const QString& path = QString::null ) = 0; | ||
27 | 31 | ||
28 | /** | 32 | /** |
29 | * return a list of available mimetypes | 33 | * return a list of available mimetypes |
30 | */ | 34 | */ |
31 | virtual QMap<QString, QStringList> mimeTypes( const QString& dir ) = 0; | 35 | virtual QMap<QString, QStringList> mimeTypes( const QString& dir ) = 0; |
32 | void setPixmapProvider( OPixmapProvider* ); | 36 | void setPixmapProvider( OPixmapProvider* ); |
33 | 37 | ||
34 | 38 | ||
35 | /* some way a slot */ | 39 | /* some way a slot */ |
36 | virtual void fileSelected( const QString& dir, const QString& file, const QString& extra ) = 0; | 40 | virtual void fileSelected( const QString& dir, const QString& file, const QString& extra ) = 0; |
37 | virtual void changedDir( const QString& dir, const QString& file, const QString& extra ) = 0; | 41 | virtual void changedDir( const QString& dir, const QString& file, const QString& extra ) = 0; |
42 | virtual QString selectedName()const = 0; | ||
43 | virtual QStringList selectedNames()const = 0; | ||
38 | protected: | 44 | protected: |
39 | /** | 45 | /** |
40 | * I hate too big classes | 46 | * I hate too big classes |
41 | * this is a way to group | 47 | * this is a way to group |
42 | * access to a ComboBox | 48 | * access to a ComboBox |
43 | * which might exist or | 49 | * which might exist or |
44 | * not in a secure way | 50 | * not in a secure way |
45 | */ | 51 | */ |
46 | OListerCmbAccess* comboBox(); | 52 | OListerCmbAccess* comboBox(); |
47 | 53 | ||
48 | bool showFiles()const; | 54 | bool showFiles()const; |
49 | bool showDirs()const; | 55 | bool showDirs()const; |
50 | bool compliesMime( const QString& mime ); | 56 | bool compliesMime( const QString& mime ); |
51 | void addFile( const QString& mine, | 57 | void addFile( const QString& mine, |
52 | QFileInfo*, | 58 | QFileInfo*, |
53 | const QString& extra = QString::null, | 59 | const QString& extra = QString::null, |
54 | bool isSymlink = FALSE ); | 60 | bool isSymlink = FALSE ); |
55 | 61 | ||
56 | void addFile( const QString& mine, | 62 | void addFile( const QString& mine, |
57 | const QString& path, | 63 | const QString& path, |
58 | const QString& file, | 64 | const QString& file, |
59 | const QString& extra = QString::null, | 65 | const QString& extra = QString::null, |
60 | bool isSymlink = FALSE ); | 66 | bool isSymlink = FALSE ); |
61 | void addDir( const QString& mine, | 67 | void addDir( const QString& mine, |
62 | QFileInfo*, | 68 | QFileInfo*, |
63 | const QString& extra = QString::null, | 69 | const QString& extra = QString::null, |
64 | bool isSymlink = FALSE ); | 70 | bool isSymlink = FALSE ); |
65 | void addDir( const QString& mine, | 71 | void addDir( const QString& mine, |
66 | const QString& path, | 72 | const QString& path, |
67 | const QString& dir, | 73 | const QString& dir, |
68 | const QString& extra = QString::null, | 74 | const QString& extra = QString::null, |
69 | bool isSymlink = FALSE ); | 75 | bool isSymlink = FALSE ); |
70 | void addSymlink( const QString& mine, | 76 | void addSymlink( const QString& mine, |
71 | QFileInfo* info, | 77 | QFileInfo* info, |
72 | const QString& extra = QString::null, | 78 | const QString& extra = QString::null, |
73 | bool isSymlink = FALSE); | 79 | bool isSymlink = FALSE); |
74 | void addSymlink( const QString& mine, | 80 | void addSymlink( const QString& mine, |
75 | const QString& path, | 81 | const QString& path, |
76 | const QString& name, | 82 | const QString& name, |
77 | const QString& extra = QString::null, | 83 | const QString& extra = QString::null, |
78 | bool isSymlink = FALSE ); | 84 | bool isSymlink = FALSE ); |
79 | OFileSelector* view(); | 85 | OFileSelector* view(); |
86 | OFileSelector* view()const; | ||
80 | OPixmapProvider* provider(); | 87 | OPixmapProvider* provider(); |
81 | void internFileSelected( const QString& file ); | 88 | void internFileSelected( const QString& file ); |
82 | void internChangedDir( const QString& dir ); | 89 | void internChangedDir( const QString& dir ); |
90 | |||
91 | /** | ||
92 | * try to take | ||
93 | * the text from the mainwindows | ||
94 | * lineedit | ||
95 | * if it's not available QString::null | ||
96 | * will be returned | ||
97 | */ | ||
98 | QString lineEdit()const; | ||
83 | private: | 99 | private: |
84 | OFileSelector* m_view; | 100 | OFileSelector* m_view; |
85 | OPixmapProvider* m_prov; | 101 | OPixmapProvider* m_prov; |
86 | OListerCmbAccess* m_acc; | 102 | OListerCmbAccess* m_acc; |
87 | 103 | ||
88 | class Private; | 104 | class Private; |
89 | Private *d; | 105 | Private *d; |
90 | }; | 106 | }; |
91 | 107 | ||
92 | class OListerCmbAccess { | 108 | class OListerCmbAccess { |
93 | friend class OLister; | 109 | friend class OLister; |
94 | public: | 110 | public: |
95 | OListerCmbAccess( QComboBox* = 0l); | 111 | OListerCmbAccess( QComboBox* = 0l); |
96 | ~OListerCmbAccess(); | 112 | ~OListerCmbAccess(); |
97 | 113 | ||
98 | /** | 114 | /** |
99 | * clears the combobox | 115 | * clears the combobox |
100 | */ | 116 | */ |
101 | void clear(); | 117 | void clear(); |
102 | 118 | ||
103 | /** | 119 | /** |
104 | * set's @param add to be the current Item | 120 | * set's @param add to be the current Item |
105 | * if the item is not present it'll be removed | 121 | * if the item is not present it'll be removed |
106 | */ | 122 | */ |
107 | void setCurrentItem( const QString& add, bool FORECE_ADD = TRUE ); | 123 | void setCurrentItem( const QString& add, bool FORECE_ADD = TRUE ); |
108 | 124 | ||
109 | /** | 125 | /** |
110 | * inserts the the String at | 126 | * inserts the the String at |
111 | * a non predictable position... The position is determined | 127 | * a non predictable position... The position is determined |
112 | * by the QComboBox code | 128 | * by the QComboBox code |
113 | */ | 129 | */ |
114 | void insert( const QString& ); | 130 | void insert( const QString& ); |
115 | 131 | ||
116 | /** | 132 | /** |
117 | * | 133 | * |
118 | */ | 134 | */ |
119 | QString currentText()const; | 135 | QString currentText()const; |
120 | 136 | ||
121 | private: | 137 | private: |
122 | class Private; | 138 | class Private; |
123 | Private* d; | 139 | Private* d; |
124 | QComboBox* m_cmb; | 140 | QComboBox* m_cmb; |
125 | 141 | ||
126 | }; | 142 | }; |
127 | 143 | ||
128 | #endif | 144 | #endif |
diff --git a/libopie/ofileselector/olocallister.cpp b/libopie/ofileselector/olocallister.cpp index 5d7884d..4d36d64 100644 --- a/libopie/ofileselector/olocallister.cpp +++ b/libopie/ofileselector/olocallister.cpp | |||
@@ -1,125 +1,150 @@ | |||
1 | #include <qdir.h> | 1 | #include <qdir.h> |
2 | #include <qfileinfo.h> | 2 | #include <qfileinfo.h> |
3 | #include <qmap.h> | 3 | #include <qmap.h> |
4 | 4 | ||
5 | #include <qpe/mimetype.h> | 5 | #include <qpe/mimetype.h> |
6 | 6 | ||
7 | #include "ofileselector.h" | 7 | #include "ofileselector.h" |
8 | #include "ofileview.h" | ||
8 | #include "olocallister.h" | 9 | #include "olocallister.h" |
9 | 10 | ||
10 | OLocalLister::OLocalLister( OFileSelector* file ) | 11 | OLocalLister::OLocalLister( OFileSelector* file ) |
11 | : OLister( file ) | 12 | : OLister( file ) |
12 | { | 13 | { |
14 | m_dir = QDir::homeDirPath(); | ||
13 | } | 15 | } |
14 | OLocalLister::~OLocalLister() { | 16 | OLocalLister::~OLocalLister() { |
15 | } | 17 | } |
16 | 18 | ||
17 | QMap<QString, QStringList> OLocalLister::mimeTypes( const QString& curDir ) { | 19 | QMap<QString, QStringList> OLocalLister::mimeTypes( const QString& curDir ) { |
18 | QMap<QString, QStringList> mimes; | 20 | QMap<QString, QStringList> mimes; |
19 | 21 | ||
20 | // let's find possible mimetypes | 22 | // let's find possible mimetypes |
21 | QDir dir( curDir ); | 23 | QDir dir( curDir ); |
22 | dir.setFilter( QDir::Files | QDir::Readable ); | 24 | dir.setFilter( QDir::Files | QDir::Readable ); |
23 | dir.setSorting( QDir::Size ); | 25 | dir.setSorting( QDir::Size ); |
24 | 26 | ||
25 | const QFileInfoList *list = dir.entryInfoList(); | 27 | const QFileInfoList *list = dir.entryInfoList(); |
26 | QFileInfoListIterator it( *list ); | 28 | QFileInfoListIterator it( *list ); |
27 | QFileInfo *fi; | 29 | QFileInfo *fi; |
28 | 30 | ||
29 | while( (fi=it.current() ) ) { | 31 | while( (fi=it.current() ) ) { |
30 | /* skip .desktop */ | 32 | /* skip .desktop */ |
31 | if( fi->extension() == QString::fromLatin1("desktop") ){ | 33 | if( fi->extension() == QString::fromLatin1("desktop") ){ |
32 | ++it; | 34 | ++it; |
33 | continue; | 35 | continue; |
34 | } | 36 | } |
35 | MimeType type( fi->absFilePath() ); | 37 | MimeType type( fi->absFilePath() ); |
36 | 38 | ||
37 | if( !mimes.contains( type.id() ) ){ | 39 | if( !mimes.contains( type.id() ) ){ |
38 | mimes.insert( type.id(), type.id() ); | 40 | mimes.insert( type.id(), type.id() ); |
39 | } | 41 | } |
40 | 42 | ||
41 | ++it; | 43 | ++it; |
42 | } | 44 | } |
43 | 45 | ||
44 | return mimes; | 46 | return mimes; |
45 | } | 47 | } |
46 | /** | 48 | /** |
47 | * FIXME mimecheck | 49 | * FIXME mimecheck |
48 | * use mime check for that | 50 | * use mime check for that |
49 | * filter dirs | 51 | * filter dirs |
50 | * filter filters | 52 | * filter filters |
51 | * filter files | 53 | * filter files |
52 | * filter mimetypes | 54 | * filter mimetypes |
53 | */ | 55 | */ |
54 | void OLocalLister::reparse( const QString& path ) { | 56 | void OLocalLister::reparse( const QString& pa ) { |
57 | if (!pa.isEmpty() ) | ||
58 | m_dir = pa; | ||
59 | |||
55 | QString currentMimeType; | 60 | QString currentMimeType; |
56 | QDir dir( path ); | 61 | QDir dir( m_dir ); |
57 | 62 | ||
58 | dir.setSorting( view()->sorting() ); | 63 | dir.setSorting( view()->sorting() ); |
59 | dir.setFilter( view()->filter() ); | 64 | dir.setFilter( view()->filter() ); |
60 | 65 | ||
61 | 66 | ||
62 | const QFileInfoList *list = dir.entryInfoList(); | 67 | const QFileInfoList *list = dir.entryInfoList(); |
63 | QFileInfoListIterator it( *list ); | 68 | QFileInfoListIterator it( *list ); |
64 | QFileInfo *fi; | 69 | QFileInfo *fi; |
65 | 70 | ||
66 | while( (fi=it.current() ) ){ | 71 | while( (fi=it.current() ) ){ |
67 | 72 | ||
68 | if( fi->fileName() == QString::fromLatin1("..") || | 73 | if( fi->fileName() == QString::fromLatin1("..") || |
69 | fi->fileName() == QString::fromLatin1(".") ){ | 74 | fi->fileName() == QString::fromLatin1(".") ){ |
70 | ++it; | 75 | ++it; |
71 | continue; | 76 | continue; |
72 | } | 77 | } |
73 | if( fi->isSymLink() ){ | 78 | if( fi->isSymLink() ){ |
74 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | 79 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); |
75 | /* | 80 | /* |
76 | * 5 tries to prevent dos attack | 81 | * 5 tries to prevent dos attack |
77 | */ | 82 | */ |
78 | for( int i = 0; i<=4; i++) { | 83 | for( int i = 0; i<=4; i++) { |
79 | QFileInfo info( file ); | 84 | QFileInfo info( file ); |
80 | if( !info.exists() ){ | 85 | if( !info.exists() ){ |
81 | addSymlink( currentMimeType, fi, QString::null, TRUE ); | 86 | addSymlink( currentMimeType, fi, QString::null, TRUE ); |
82 | break; | 87 | break; |
83 | }else if( info.isDir() ){ | 88 | }else if( info.isDir() ){ |
84 | if (!showDirs() ) | 89 | if (!showDirs() ) |
85 | break; | 90 | break; |
86 | 91 | ||
87 | addDir( currentMimeType, fi, QString::null, | 92 | addDir( currentMimeType, fi, QString::null, |
88 | TRUE ); | 93 | TRUE ); |
89 | break; | 94 | break; |
90 | }else if( info.isFile() ){ | 95 | }else if( info.isFile() ){ |
91 | /* if not show files skip it */ | 96 | /* if not show files skip it */ |
92 | if (!showFiles() ) | 97 | if (!showFiles() ) |
93 | break; | 98 | break; |
94 | 99 | ||
95 | /* check if we comply to the mimetype */ | 100 | /* check if we comply to the mimetype */ |
96 | MimeType type( info.absFilePath() ); | 101 | MimeType type( info.absFilePath() ); |
97 | if (compliesMime( type.id() ) ) | 102 | if (compliesMime( type.id() ) ) |
98 | addFile( currentMimeType, fi, QString::null, TRUE ); | 103 | addFile( currentMimeType, fi, QString::null, TRUE ); |
99 | 104 | ||
100 | break; | 105 | break; |
101 | }else if( info.isSymLink() ){ | 106 | }else if( info.isSymLink() ){ |
102 | file = info.dirPath(true ) + "/" + info.readLink() ; | 107 | file = info.dirPath(true ) + "/" + info.readLink() ; |
103 | break; | 108 | break; |
104 | }else if( i == 4){ | 109 | }else if( i == 4){ |
105 | addSymlink( currentMimeType, fi ); | 110 | addSymlink( currentMimeType, fi ); |
106 | } | 111 | } |
107 | } | 112 | } |
108 | 113 | ||
109 | }else if( fi->isDir() ){ | 114 | }else if( fi->isDir() ){ |
110 | if (showDirs() ) | 115 | if (showDirs() ) |
111 | addDir( currentMimeType, fi ); | 116 | addDir( currentMimeType, fi ); |
112 | }else if( fi->isFile() ){ | 117 | }else if( fi->isFile() ){ |
113 | if ( showFiles() ) | 118 | if ( showFiles() ) |
114 | addFile( currentMimeType, fi ); | 119 | addFile( currentMimeType, fi ); |
115 | } | 120 | } |
116 | ++it; | 121 | ++it; |
117 | } // of while loop | 122 | } // of while loop |
118 | } | 123 | } |
119 | /* more accepting it code */ | 124 | /* more accepting it code */ |
120 | void OLocalLister::fileSelected( const QString& dir, const QString& file, const QString& ) { | 125 | void OLocalLister::fileSelected( const QString& dir, const QString& file, const QString& ) { |
121 | internFileSelected( dir + "/" + file ); | 126 | internFileSelected( dir + "/" + file ); |
122 | } | 127 | } |
123 | void OLocalLister::changedDir( const QString& dir, const QString& file, const QString& ) { | 128 | void OLocalLister::changedDir( const QString& dir, const QString& file, const QString& ) { |
124 | internChangedDir( dir + "/" + file ); | 129 | internChangedDir( dir + "/" + file ); |
125 | } | 130 | } |
131 | /* | ||
132 | * assemble the the Url now | ||
133 | */ | ||
134 | QString OLocalLister::selectedName()const { | ||
135 | QString str = m_dir; | ||
136 | QString name = lineEdit(); | ||
137 | |||
138 | if ( name.isEmpty() ) | ||
139 | name = view()->currentView()->selectedName(); | ||
140 | |||
141 | str += "/" + name; | ||
142 | |||
143 | return str; | ||
144 | } | ||
145 | QStringList OLocalLister::selectedNames()const { | ||
146 | QStringList list; | ||
147 | list << selectedName(); | ||
148 | |||
149 | return list; | ||
150 | } | ||
diff --git a/libopie/ofileselector/olocallister.h b/libopie/ofileselector/olocallister.h index 01e6f3c..0cdf51f 100644 --- a/libopie/ofileselector/olocallister.h +++ b/libopie/ofileselector/olocallister.h | |||
@@ -1,16 +1,21 @@ | |||
1 | #ifndef OPIE_LOCAL_LISTER | 1 | #ifndef OPIE_LOCAL_LISTER |
2 | #define OPIE_LOCAL_LISTER | 2 | #define OPIE_LOCAL_LISTER |
3 | 3 | ||
4 | #include "olister.h" | 4 | #include "olister.h" |
5 | 5 | ||
6 | class OLocalLister : public OLister { | 6 | class OLocalLister : public OLister { |
7 | public: | 7 | public: |
8 | OLocalLister( OFileSelector* ); | 8 | OLocalLister( OFileSelector* ); |
9 | ~OLocalLister(); | 9 | ~OLocalLister(); |
10 | void reparse( const QString& path ); | 10 | void reparse( const QString& path ); |
11 | QMap<QString, QStringList> mimeTypes(const QString& dir ); | 11 | QMap<QString, QStringList> mimeTypes(const QString& dir ); |
12 | void fileSelected( const QString& dir, const QString& file, const QString& ); | 12 | void fileSelected( const QString& dir, const QString& file, const QString& ); |
13 | void changedDir( const QString& dir, const QString& file,const QString& ); | 13 | void changedDir( const QString& dir, const QString& file,const QString& ); |
14 | QString selectedName()const; | ||
15 | QStringList selectedNames()const; | ||
16 | |||
17 | private: | ||
18 | QString m_dir; | ||
14 | }; | 19 | }; |
15 | 20 | ||
16 | #endif | 21 | #endif |