author | llornkcor <llornkcor> | 2002-04-24 03:22:24 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-24 03:22:24 (UTC) |
commit | 219994e9d1de70b44c994ccee57060741f22d428 (patch) (unidiff) | |
tree | 2acfcae2a6bfc432266ee1d0cb76285a95fe683f | |
parent | c9159a3d5192799f5b2911d13337f04f50b1ac5a (diff) | |
download | opie-219994e9d1de70b44c994ccee57060741f22d428.zip opie-219994e9d1de70b44c994ccee57060741f22d428.tar.gz opie-219994e9d1de70b44c994ccee57060741f22d428.tar.bz2 |
fixed location combo showing redundant directories and multiple seperators
-rw-r--r-- | libopie/ofileselector.cc | 123 | ||||
-rw-r--r-- | libopie/ofileselector.h | 15 |
2 files changed, 111 insertions, 27 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index cb18039..d1f1e1f 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -29,32 +29,34 @@ | |||
29 | #include <qnamespace.h> | 29 | #include <qnamespace.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
32 | #include <qhbox.h> | 32 | #include <qhbox.h> |
33 | #include <qvbox.h> | 33 | #include <qvbox.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
35 | #include <qwidgetstack.h> | 35 | #include <qwidgetstack.h> |
36 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
37 | #include <qcheckbox.h> | 37 | #include <qcheckbox.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qheader.h> | 39 | #include <qheader.h> |
40 | #include <qdir.h> | 40 | #include <qdir.h> |
41 | #include <qpainter.h> | 41 | #include <qpainter.h> |
42 | #include <qaction.h> | 42 | #include <qaction.h> |
43 | #include <qpopupmenu.h> | 43 | #include <qpopupmenu.h> |
44 | #include <qcursor.h> | 44 | #include <qcursor.h> |
45 | #include <qstringlist.h> | ||
46 | #include <qmessagebox.h> | ||
45 | 47 | ||
46 | #include <qpe/qpeapplication.h> | 48 | #include <qpe/qpeapplication.h> |
47 | #include <qpe/fileselector.h> | 49 | #include <qpe/fileselector.h> |
48 | #include <qpe/applnk.h> | 50 | #include <qpe/applnk.h> |
49 | #include <qpe/global.h> | 51 | #include <qpe/global.h> |
50 | #include <qpe/mimetype.h> | 52 | #include <qpe/mimetype.h> |
51 | #include <qpe/resource.h> | 53 | #include <qpe/resource.h> |
52 | #include <qpe/storage.h> | 54 | #include <qpe/storage.h> |
53 | 55 | ||
54 | #include <unistd.h> | 56 | #include <unistd.h> |
55 | #include <stdlib.h> | 57 | #include <stdlib.h> |
56 | #include <sys/stat.h> | 58 | #include <sys/stat.h> |
57 | 59 | ||
58 | #include "ofileselector.h" | 60 | #include "ofileselector.h" |
59 | 61 | ||
60 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 62 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
@@ -121,77 +123,80 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString | |||
121 | 123 | ||
122 | m_pseudo = 0; | 124 | m_pseudo = 0; |
123 | m_pseudoLayout = 0; | 125 | m_pseudoLayout = 0; |
124 | 126 | ||
125 | m_dir = true; | 127 | m_dir = true; |
126 | m_files = true; | 128 | m_files = true; |
127 | m_custom = 0; | 129 | m_custom = 0; |
128 | m_showPopup = true; | 130 | m_showPopup = true; |
129 | 131 | ||
130 | if(m_pixmaps == 0 ) // init the pixmaps | 132 | if(m_pixmaps == 0 ) // init the pixmaps |
131 | initPics(); | 133 | initPics(); |
132 | 134 | ||
133 | m_lay = new QVBoxLayout(this); | 135 | m_lay = new QVBoxLayout(this); |
134 | init(); | 136 | init(); |
135 | m_edit->setText( fileName ); | 137 | m_edit->setText( fileName ); |
136 | } | 138 | } |
139 | |||
137 | void OFileSelector::initPics() | 140 | void OFileSelector::initPics() |
138 | { | 141 | { |
139 | qWarning("init pics" ); | 142 | qWarning("init pics" ); |
140 | m_pixmaps = new QMap<QString,QPixmap>; | 143 | m_pixmaps = new QMap<QString,QPixmap>; |
141 | QPixmap pm = Resource::loadPixmap( "folder" ); | 144 | QPixmap pm = Resource::loadPixmap( "folder" ); |
142 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 145 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
143 | QPainter painter( &pm ); | 146 | QPainter painter( &pm ); |
144 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 147 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
145 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 148 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
146 | m_pixmaps->insert("dirsymlink", pm ); | 149 | m_pixmaps->insert("dirsymlink", pm ); |
147 | 150 | ||
148 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); | 151 | QPixmap pm2 = Resource::loadPixmap( "lockedfolder" ); |
149 | QPainter pen(&pm2 ); | 152 | QPainter pen(&pm2 ); |
150 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); | 153 | pen.drawPixmap(pm2.width()-lnk.width(), pm2.height()-lnk.height(), lnk ); |
151 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); | 154 | pm2.setMask( pm2.createHeuristicMask( FALSE ) ); |
152 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 155 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
153 | 156 | ||
154 | }; | 157 | } |
158 | |||
155 | // let's initialize the gui | 159 | // let's initialize the gui |
156 | /** | 160 | /** |
157 | -------------------- | 161 | -------------------- |
158 | | cmbBox Button | | 162 | | cmbBox Button | |
159 | -------------------- | 163 | -------------------- |
160 | | FileSlector | | 164 | | FileSlector | |
161 | | or | | 165 | | or | |
162 | | OSelector | | 166 | | OSelector | |
163 | | | | 167 | | | |
164 | | | | 168 | | | |
165 | ____________________ | 169 | ____________________ |
166 | | LineEdit | | 170 | | LineEdit | |
167 | ____________________ | 171 | ____________________ |
168 | | Permission Bar | | 172 | | Permission Bar | |
169 | ____________________ | 173 | ____________________ |
170 | | ViewChoose | | 174 | | ViewChoose | |
171 | ____________________ | 175 | ____________________ |
172 | | Save Cancel| | 176 | | Save Cancel| |
173 | ____________________ | 177 | ____________________ |
174 | */ | 178 | */ |
175 | void OFileSelector::delItems() | 179 | void OFileSelector::delItems() |
176 | { | 180 | { |
177 | QLayoutIterator it = m_lay->iterator(); | 181 | QLayoutIterator it = m_lay->iterator(); |
178 | while ( it.current() != 0 ){ | 182 | while ( it.current() != 0 ){ |
179 | it.deleteCurrent(); | 183 | it.deleteCurrent(); |
180 | } | 184 | } |
181 | } | 185 | } |
186 | |||
182 | void OFileSelector::init() | 187 | void OFileSelector::init() |
183 | { | 188 | { |
184 | 189 | ||
185 | m_stack = new QWidgetStack(this, "wstack" ); | 190 | m_stack = new QWidgetStack(this, "wstack" ); |
186 | if( m_selector == NORMAL ){ | 191 | if( m_selector == NORMAL ){ |
187 | QString currMime; | 192 | QString currMime; |
188 | if( m_mimeCheck != 0 ) | 193 | if( m_mimeCheck != 0 ) |
189 | currMime = m_mimeCheck->currentText(); | 194 | currMime = m_mimeCheck->currentText(); |
190 | 195 | ||
191 | updateMimes(); | 196 | updateMimes(); |
192 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); | 197 | m_select = new FileSelector( currMime == "All" ? QString::null : currMime , m_stack, "fileselector", FALSE, FALSE ); |
193 | m_stack->addWidget(m_select, NORMAL ); | 198 | m_stack->addWidget(m_select, NORMAL ); |
194 | m_lay->addWidget(m_stack ); | 199 | m_lay->addWidget(m_stack ); |
195 | m_stack->raiseWidget(NORMAL ); | 200 | m_stack->raiseWidget(NORMAL ); |
196 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); | 201 | connect(m_select, SIGNAL(fileSelected( const DocLnk &) ), this, SLOT(slotFileBridgeSelected(const DocLnk &) ) ); |
197 | m_pseudoLayout = 0l; | 202 | m_pseudoLayout = 0l; |
@@ -203,33 +208,33 @@ void OFileSelector::init() | |||
203 | initializeName(); | 208 | initializeName(); |
204 | } | 209 | } |
205 | 210 | ||
206 | if(m_shPerm ){ | 211 | if(m_shPerm ){ |
207 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); | 212 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" ); |
208 | m_checkPerm->setChecked( false ); | 213 | m_checkPerm->setChecked( false ); |
209 | m_lay->addWidget(m_checkPerm ); | 214 | m_lay->addWidget(m_checkPerm ); |
210 | } | 215 | } |
211 | 216 | ||
212 | if( m_shChooser ) | 217 | if( m_shChooser ) |
213 | initializeChooser(); | 218 | initializeChooser(); |
214 | 219 | ||
215 | if(m_shYesNo ) | 220 | if(m_shYesNo ) |
216 | initializeYes(); | 221 | initializeYes(); |
217 | 222 | ||
218 | 223 | ||
219 | }; | 224 | } |
220 | 225 | ||
221 | void OFileSelector::setYesCancelVisible( bool show ) | 226 | void OFileSelector::setYesCancelVisible( bool show ) |
222 | { | 227 | { |
223 | if ( show == m_shYesNo ) | 228 | if ( show == m_shYesNo ) |
224 | return; | 229 | return; |
225 | m_shYesNo = show; | 230 | m_shYesNo = show; |
226 | if( !show ){ | 231 | if( !show ){ |
227 | delete m_ok; | 232 | delete m_ok; |
228 | delete m_cancel; | 233 | delete m_cancel; |
229 | m_ok = 0; | 234 | m_ok = 0; |
230 | m_cancel = 0; | 235 | m_cancel = 0; |
231 | // delete m_boxOk; all ready deleted in delItems | 236 | // delete m_boxOk; all ready deleted in delItems |
232 | } | 237 | } |
233 | updateLay(); // recreate it and save the other states | 238 | updateLay(); // recreate it and save the other states |
234 | } | 239 | } |
235 | 240 | ||
@@ -248,110 +253,121 @@ void OFileSelector::setToolbarVisible( bool show ) | |||
248 | m_docButton = 0; | 253 | m_docButton = 0; |
249 | m_location = 0; | 254 | m_location = 0; |
250 | m_up = 0; | 255 | m_up = 0; |
251 | }; | 256 | }; |
252 | updateLay();// overkill fix it | 257 | updateLay();// overkill fix it |
253 | } | 258 | } |
254 | 259 | ||
255 | void OFileSelector::setPermissionBarVisible( bool show ) | 260 | void OFileSelector::setPermissionBarVisible( bool show ) |
256 | { | 261 | { |
257 | if( show == m_shPerm ) | 262 | if( show == m_shPerm ) |
258 | return; | 263 | return; |
259 | 264 | ||
260 | m_shPerm = show; | 265 | m_shPerm = show; |
261 | 266 | ||
262 | updateLay(); | 267 | updateLay(); |
263 | } | 268 | } |
269 | |||
264 | void OFileSelector::setLineEditVisible( bool show ) | 270 | void OFileSelector::setLineEditVisible( bool show ) |
265 | { | 271 | { |
266 | if( show == m_shLne ) | 272 | if( show == m_shLne ) |
267 | return; | 273 | return; |
268 | 274 | ||
269 | m_shLne = show; | 275 | m_shLne = show; |
270 | if( !show ){ | 276 | if( !show ){ |
271 | delete m_edit; | 277 | delete m_edit; |
272 | delete m_fnLabel; | 278 | delete m_fnLabel; |
273 | m_edit = 0; | 279 | m_edit = 0; |
274 | m_fnLabel = 0; | 280 | m_fnLabel = 0; |
275 | //delete m_boxName; will be deleted | 281 | //delete m_boxName; will be deleted |
276 | } | 282 | } |
277 | updateLay(); | 283 | updateLay(); |
278 | } | 284 | } |
285 | |||
279 | void OFileSelector::setChooserVisible( bool show ) | 286 | void OFileSelector::setChooserVisible( bool show ) |
280 | { | 287 | { |
281 | if( show = m_shChooser ) | 288 | if( show = m_shChooser ) |
282 | return; | 289 | return; |
283 | m_shChooser = show; | 290 | m_shChooser = show; |
284 | if( !show ){ | 291 | if( !show ){ |
285 | delete m_mimeCheck; | 292 | delete m_mimeCheck; |
286 | delete m_viewCheck; | 293 | delete m_viewCheck; |
287 | m_mimeCheck = 0; | 294 | m_mimeCheck = 0; |
288 | m_viewCheck = 0; | 295 | m_viewCheck = 0; |
289 | } | 296 | } |
290 | updateLay(); | 297 | updateLay(); |
291 | } | 298 | } |
299 | |||
292 | QCheckBox* OFileSelector::permissionCheckbox( ) | 300 | QCheckBox* OFileSelector::permissionCheckbox( ) |
293 | { | 301 | { |
294 | return m_checkPerm; | 302 | return m_checkPerm; |
295 | } | 303 | } |
304 | |||
296 | void OFileSelector::setCaseSensetive( bool caSe ) | 305 | void OFileSelector::setCaseSensetive( bool caSe ) |
297 | { | 306 | { |
298 | m_case = caSe; | 307 | m_case = caSe; |
299 | reparse(); | 308 | reparse(); |
300 | } | 309 | } |
310 | |||
301 | void OFileSelector::setShowFiles(bool files ){ | 311 | void OFileSelector::setShowFiles(bool files ){ |
302 | m_files = files; | 312 | m_files = files; |
303 | reparse(); | 313 | reparse(); |
304 | } | 314 | } |
315 | |||
305 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) | 316 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) |
306 | { | 317 | { |
307 | //delete oldpopup; | 318 | //delete oldpopup; |
308 | m_custom = pop; | 319 | m_custom = pop; |
309 | } | 320 | } |
321 | |||
310 | bool OFileSelector::setPermission( ) const | 322 | bool OFileSelector::setPermission( ) const |
311 | { | 323 | { |
312 | if( m_checkPerm == 0 ) | 324 | if( m_checkPerm == 0 ) |
313 | return false; | 325 | return false; |
314 | else | 326 | else |
315 | return m_checkPerm->isChecked(); | 327 | return m_checkPerm->isChecked(); |
316 | } | 328 | } |
329 | |||
317 | void OFileSelector::setPermissionChecked( bool check ) | 330 | void OFileSelector::setPermissionChecked( bool check ) |
318 | { | 331 | { |
319 | if( m_checkPerm == 0 ) | 332 | if( m_checkPerm == 0 ) |
320 | return; | 333 | return; |
321 | m_checkPerm->setChecked( check ); | 334 | m_checkPerm->setChecked( check ); |
322 | } | 335 | } |
336 | |||
323 | QString OFileSelector::selectedName( )const | 337 | QString OFileSelector::selectedName( )const |
324 | { | 338 | { |
325 | QString string; | 339 | QString string; |
326 | if( m_selector == NORMAL ){ | 340 | if( m_selector == NORMAL ){ |
327 | const DocLnk *lnk = m_select->selected(); | 341 | const DocLnk *lnk = m_select->selected(); |
328 | string = lnk->file(); | 342 | string = lnk->file(); |
329 | }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { | 343 | }else if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ) { |
330 | QListViewItem *item = m_View->currentItem(); | 344 | QListViewItem *item = m_View->currentItem(); |
331 | if(item != 0 ){ | 345 | if(item != 0 ){ |
332 | string = m_currentDir + "/" + item->text( 1 ); | 346 | string = m_currentDir + "/" + item->text( 1 ); |
333 | } | 347 | } |
334 | } | 348 | } |
335 | return string; | 349 | return string; |
336 | } | 350 | } |
351 | |||
337 | QStringList OFileSelector::selectedNames()const | 352 | QStringList OFileSelector::selectedNames()const |
338 | { | 353 | { |
339 | QStringList list; | 354 | QStringList list; |
340 | return list; | 355 | return list; |
341 | } | 356 | } |
357 | |||
342 | DocLnk OFileSelector::selectedDocument( )const | 358 | DocLnk OFileSelector::selectedDocument( )const |
343 | { | 359 | { |
344 | DocLnk lnk; | 360 | DocLnk lnk; |
345 | return lnk; | 361 | return lnk; |
346 | } | 362 | } |
347 | void OFileSelector::updateLay() | 363 | void OFileSelector::updateLay() |
348 | { | 364 | { |
349 | /* if( m_shTool ) | 365 | /* if( m_shTool ) |
350 | // | 366 | // |
351 | else | 367 | else |
352 | // hide | 368 | // hide |
353 | */ | 369 | */ |
354 | // save the state | 370 | // save the state |
355 | bool check = false; | 371 | bool check = false; |
356 | if( m_checkPerm != 0 ) | 372 | if( m_checkPerm != 0 ) |
357 | check = m_checkPerm->isChecked(); | 373 | check = m_checkPerm->isChecked(); |
@@ -372,32 +388,33 @@ void OFileSelector::updateLay() | |||
372 | m_ok = 0; | 388 | m_ok = 0; |
373 | delete m_cancel; | 389 | delete m_cancel; |
374 | m_cancel = 0; | 390 | m_cancel = 0; |
375 | delete m_mimeCheck; | 391 | delete m_mimeCheck; |
376 | m_mimeCheck = 0; | 392 | m_mimeCheck = 0; |
377 | delete m_viewCheck; | 393 | delete m_viewCheck; |
378 | m_viewCheck = 0; | 394 | m_viewCheck = 0; |
379 | delete m_select; // test | 395 | delete m_select; // test |
380 | delete m_stack; | 396 | delete m_stack; |
381 | //delete m_list; | 397 | //delete m_list; |
382 | init(); | 398 | init(); |
383 | if( m_shLne ) | 399 | if( m_shLne ) |
384 | m_edit->setText(text ); | 400 | m_edit->setText(text ); |
385 | if( m_shPerm ) | 401 | if( m_shPerm ) |
386 | m_checkPerm->setChecked(check ); | 402 | m_checkPerm->setChecked(check ); |
387 | } | 403 | } |
404 | |||
388 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve | 405 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve |
389 | // insert QListViewItems with the right options | 406 | // insert QListViewItems with the right options |
390 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) | 407 | bool OFileSelector::compliesMime(const QString &path, const QString &mime ) |
391 | { | 408 | { |
392 | if( mime == "All" ) | 409 | if( mime == "All" ) |
393 | return true; | 410 | return true; |
394 | MimeType type( path ); | 411 | MimeType type( path ); |
395 | if( type.id() == mime ) | 412 | if( type.id() == mime ) |
396 | return true; | 413 | return true; |
397 | return false; | 414 | return false; |
398 | } | 415 | } |
399 | 416 | ||
400 | void OFileSelector::reparse() | 417 | void OFileSelector::reparse() |
401 | { | 418 | { |
402 | if(m_View== 0 || m_selector == NORMAL) | 419 | if(m_View== 0 || m_selector == NORMAL) |
403 | return; | 420 | return; |
@@ -419,32 +436,33 @@ void OFileSelector::reparse() | |||
419 | while( (fi=it.current()) ){ | 436 | while( (fi=it.current()) ){ |
420 | if(fi->extension() == QString::fromLatin1("desktop") ){ | 437 | if(fi->extension() == QString::fromLatin1("desktop") ){ |
421 | ++it; | 438 | ++it; |
422 | continue; | 439 | continue; |
423 | } | 440 | } |
424 | MimeType type(fi->filePath() ); | 441 | MimeType type(fi->filePath() ); |
425 | if( !m_mimetypes.contains( type.id() ) ) | 442 | if( !m_mimetypes.contains( type.id() ) ) |
426 | m_mimetypes.append( type.id() ); | 443 | m_mimetypes.append( type.id() ); |
427 | 444 | ||
428 | ++it; | 445 | ++it; |
429 | } | 446 | } |
430 | m_mimetypes.prepend("All" ); | 447 | m_mimetypes.prepend("All" ); |
431 | m_mimeCheck->insertStringList(m_mimetypes ); | 448 | m_mimeCheck->insertStringList(m_mimetypes ); |
432 | // set it to the current mimetype | 449 | // set it to the current mimetype |
433 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); | 450 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); |
434 | }; | 451 | }; |
452 | |||
435 | QDir dir( m_currentDir ); | 453 | QDir dir( m_currentDir ); |
436 | //dir.setFilter(-1 ); | 454 | //dir.setFilter(-1 ); |
437 | int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; | 455 | int sort = QDir::Name | QDir::DirsFirst | QDir::Reversed; |
438 | if( m_case ) | 456 | if( m_case ) |
439 | sort = QDir::IgnoreCase; | 457 | sort = QDir::IgnoreCase; |
440 | dir.setSorting( sort ); | 458 | dir.setSorting( sort ); |
441 | 459 | ||
442 | int filter; | 460 | int filter; |
443 | /* if( m_dir && !m_files) | 461 | /* if( m_dir && !m_files) |
444 | filter |= QDir::Dirs; | 462 | filter |= QDir::Dirs; |
445 | else if( !m_dir && m_files ) | 463 | else if( !m_dir && m_files ) |
446 | filter |= QDir::Files; | 464 | filter |= QDir::Files; |
447 | else | 465 | else |
448 | filter |= QDir::All; | 466 | filter |= QDir::All; |
449 | */ | 467 | */ |
450 | if( m_selector == EXTENDED_ALL ) | 468 | if( m_selector == EXTENDED_ALL ) |
@@ -484,105 +502,113 @@ void OFileSelector::reparse() | |||
484 | file = info.dirPath(true)+ "/"+ info.readLink(); | 502 | file = info.dirPath(true)+ "/"+ info.readLink(); |
485 | qWarning("isSymlink again %s", file.latin1() ); | 503 | qWarning("isSymlink again %s", file.latin1() ); |
486 | }else if( i == 4 ){ // just insert it and have the symlink symbol | 504 | }else if( i == 4 ){ // just insert it and have the symlink symbol |
487 | addSymlink(currMime, fi ); | 505 | addSymlink(currMime, fi ); |
488 | qWarning("level too deep" ); | 506 | qWarning("level too deep" ); |
489 | } | 507 | } |
490 | } | 508 | } |
491 | }else if( fi->isDir() ){ | 509 | }else if( fi->isDir() ){ |
492 | addDir(currMime, fi ); | 510 | addDir(currMime, fi ); |
493 | }else if( fi->isFile() ) { // file ? | 511 | }else if( fi->isFile() ) { // file ? |
494 | addFile(currMime, fi ); | 512 | addFile(currMime, fi ); |
495 | } | 513 | } |
496 | ++it; | 514 | ++it; |
497 | } | 515 | } |
498 | m_View->sort(); | 516 | m_View->sort(); |
499 | } | 517 | } |
518 | |||
500 | QString OFileSelector::directory()const | 519 | QString OFileSelector::directory()const |
501 | { | 520 | { |
502 | return m_currentDir; | 521 | QDir d( m_currentDir); |
522 | return d.absPath(); | ||
503 | } | 523 | } |
524 | |||
504 | int OFileSelector::fileCount() | 525 | int OFileSelector::fileCount() |
505 | { | 526 | { |
506 | return 0; | 527 | return 0; |
507 | } | 528 | } |
529 | |||
508 | void OFileSelector::slotOk( ) | 530 | void OFileSelector::slotOk( ) |
509 | { | 531 | { |
510 | emit ok(); | 532 | emit ok(); |
511 | } | 533 | } |
534 | |||
512 | void OFileSelector::slotCancel( ) | 535 | void OFileSelector::slotCancel( ) |
513 | { | 536 | { |
514 | emit cancel(); | 537 | emit cancel(); |
515 | } | 538 | } |
516 | 539 | ||
517 | void OFileSelector::initializeName() | 540 | void OFileSelector::initializeName() |
518 | { | 541 | { |
519 | m_boxName = new QHBoxLayout(this ); | 542 | m_boxName = new QHBoxLayout(this ); |
520 | m_edit = new QLineEdit(this ); | 543 | m_edit = new QLineEdit(this ); |
521 | m_fnLabel = new QLabel(this ); | 544 | m_fnLabel = new QLabel(this ); |
522 | m_fnLabel->setText(tr("Name:") ); | 545 | m_fnLabel->setText(tr("Name:") ); |
523 | m_boxName->addWidget(m_fnLabel ); | 546 | m_boxName->addWidget(m_fnLabel ); |
524 | m_boxName->insertSpacing(1, 8 ); | 547 | m_boxName->insertSpacing(1, 8 ); |
525 | m_boxName->addWidget(m_edit, 100 ); | 548 | m_boxName->addWidget(m_edit, 100 ); |
526 | 549 | ||
527 | m_lay->addLayout(m_boxName); | 550 | m_lay->addLayout(m_boxName); |
528 | } | 551 | } |
552 | |||
529 | void OFileSelector::initializeYes() | 553 | void OFileSelector::initializeYes() |
530 | { | 554 | { |
531 | m_ok = new QPushButton("&Save", this, "save" ); | 555 | m_ok = new QPushButton("&Save", this, "save" ); |
532 | m_cancel = new QPushButton("C&ancel", this, "cancel" ); | 556 | m_cancel = new QPushButton("C&ancel", this, "cancel" ); |
533 | m_boxOk = new QHBoxLayout(this ); | 557 | m_boxOk = new QHBoxLayout(this ); |
534 | m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); | 558 | m_boxOk->addWidget( m_ok, Qt::AlignHCenter ); |
535 | m_boxOk->insertSpacing(1, 8 ); | 559 | m_boxOk->insertSpacing(1, 8 ); |
536 | m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); | 560 | m_boxOk->addWidget( m_cancel, Qt::AlignHCenter); |
537 | m_lay->addLayout(m_boxOk ); | 561 | m_lay->addLayout(m_boxOk ); |
538 | connect(m_ok, SIGNAL(clicked() ), | 562 | connect(m_ok, SIGNAL(clicked() ), |
539 | this, SLOT(slotOk() ) ); | 563 | this, SLOT(slotOk() ) ); |
540 | connect(m_cancel, SIGNAL(clicked() ), | 564 | connect(m_cancel, SIGNAL(clicked() ), |
541 | this, SLOT(slotCancel() ) ); | 565 | this, SLOT(slotCancel() ) ); |
542 | 566 | ||
543 | } | 567 | } |
568 | |||
544 | void OFileSelector::initializeChooser() | 569 | void OFileSelector::initializeChooser() |
545 | { | 570 | { |
546 | m_boxView = new QHBoxLayout(this ); | 571 | m_boxView = new QHBoxLayout(this ); |
547 | 572 | ||
548 | m_mimeCheck = new QComboBox(this, "mime check"); | 573 | m_mimeCheck = new QComboBox(this, "mime check"); |
549 | m_viewCheck = new QComboBox(this, "view check"); | 574 | m_viewCheck = new QComboBox(this, "view check"); |
550 | m_boxView->addWidget(m_viewCheck, 0 ); | 575 | m_boxView->addWidget(m_viewCheck, 0 ); |
551 | m_boxView->insertSpacing(2, 8 ); | 576 | m_boxView->insertSpacing(2, 8 ); |
552 | m_boxView->addWidget(m_mimeCheck, 0 ); | 577 | m_boxView->addWidget(m_mimeCheck, 0 ); |
553 | m_lay->addLayout(m_boxView ); | 578 | m_lay->addLayout(m_boxView ); |
554 | m_lay->insertSpacing( 4, 8); | 579 | m_lay->insertSpacing( 4, 8); |
555 | 580 | ||
556 | m_viewCheck->insertItem(tr("Documents") ); | 581 | m_viewCheck->insertItem(tr("Documents") ); |
557 | m_viewCheck->insertItem(tr("Files") ); | 582 | m_viewCheck->insertItem(tr("Files") ); |
558 | m_viewCheck->insertItem(tr("All Files") ); | 583 | m_viewCheck->insertItem(tr("All Files") ); |
559 | 584 | ||
560 | // if(!m_autoMime ) | 585 | // if(!m_autoMime ) |
561 | // m_mimeCheck->insertItem(m_mimetypes.join("," ) ); | 586 | // m_mimeCheck->insertItem(m_mimetypes.join("," ) ); |
562 | // else{ // check | 587 | // else{ // check |
563 | updateMimes(); | 588 | updateMimes(); |
564 | m_mimeCheck->insertStringList( m_mimetypes ); | 589 | m_mimeCheck->insertStringList( m_mimetypes ); |
565 | // } | 590 | // } |
566 | 591 | ||
567 | connect( m_viewCheck, SIGNAL(activated(const QString &) ), | 592 | connect( m_viewCheck, SIGNAL(activated(const QString &) ), |
568 | this, SLOT(slotViewCheck(const QString & ) ) ); | 593 | this, SLOT(slotViewCheck(const QString & ) ) ); |
569 | 594 | ||
570 | connect( m_mimeCheck, SIGNAL(activated(const QString &) ), | 595 | connect( m_mimeCheck, SIGNAL(activated(const QString &) ), |
571 | this, SLOT(slotMimeCheck(const QString & ) ) ); | 596 | this, SLOT(slotMimeCheck(const QString & ) ) ); |
572 | } | 597 | } |
598 | |||
573 | void OFileSelector::slotMimeCheck(const QString &view ){ | 599 | void OFileSelector::slotMimeCheck(const QString &view ){ |
574 | if(m_selector == NORMAL ){ | 600 | if(m_selector == NORMAL ){ |
575 | delete m_select; | 601 | delete m_select; |
576 | m_select = new FileSelector(view == "All" ? QString::null : view | 602 | m_select = new FileSelector(view == "All" ? QString::null : view |
577 | , m_stack, "fileselector", FALSE, FALSE ); | 603 | , m_stack, "fileselector", FALSE, FALSE ); |
578 | m_stack->addWidget( m_select, NORMAL ); | 604 | m_stack->addWidget( m_select, NORMAL ); |
579 | m_stack->raiseWidget( NORMAL ); | 605 | m_stack->raiseWidget( NORMAL ); |
580 | }else{ | 606 | }else{ |
581 | reparse(); | 607 | reparse(); |
582 | } | 608 | } |
583 | } | 609 | } |
584 | 610 | ||
585 | void OFileSelector::slotViewCheck(const QString &view ){ | 611 | void OFileSelector::slotViewCheck(const QString &view ){ |
586 | qWarning("changed: show %s", view.latin1() ); | 612 | qWarning("changed: show %s", view.latin1() ); |
587 | // if the current view is the one | 613 | // if the current view is the one |
588 | QString currMime = m_mimeCheck->currentText(); | 614 | QString currMime = m_mimeCheck->currentText(); |
@@ -632,80 +658,82 @@ void OFileSelector::slotViewCheck(const QString &view ){ | |||
632 | m_selector = EXTENDED; | 658 | m_selector = EXTENDED; |
633 | // create the ListView or IconView | 659 | // create the ListView or IconView |
634 | initializeListView(); | 660 | initializeListView(); |
635 | 661 | ||
636 | reparse(); | 662 | reparse(); |
637 | }else if(view == QString::fromLatin1("All Files") ) { | 663 | }else if(view == QString::fromLatin1("All Files") ) { |
638 | // remove from the stack | 664 | // remove from the stack |
639 | delete m_select; | 665 | delete m_select; |
640 | m_select = 0; | 666 | m_select = 0; |
641 | delete m_View; | 667 | delete m_View; |
642 | m_View = 0; | 668 | m_View = 0; |
643 | 669 | ||
644 | m_selector = EXTENDED_ALL; | 670 | m_selector = EXTENDED_ALL; |
645 | initializeListView(); | 671 | initializeListView(); |
646 | reparse(); | 672 | reparse(); |
647 | }; | 673 | }; |
648 | }; | 674 | } |
649 | 675 | ||
650 | 676 | ||
651 | void OFileSelector::updateMimes() // lets check which mode is active | 677 | void OFileSelector::updateMimes() // lets check which mode is active |
652 | // check the current dir for items then | 678 | // check the current dir for items then |
653 | { | 679 | { |
654 | m_mimetypes.clear(); | 680 | m_mimetypes.clear(); |
655 | m_mimetypes.append("All" ); | 681 | m_mimetypes.append("All" ); |
656 | if( m_selector == NORMAL ){ | 682 | if( m_selector == NORMAL ){ |
657 | DocLnkSet set; | 683 | DocLnkSet set; |
658 | Global::findDocuments(&set, QString::null ); | 684 | Global::findDocuments(&set, QString::null ); |
659 | QListIterator<DocLnk> dit( set.children() ); | 685 | QListIterator<DocLnk> dit( set.children() ); |
660 | for ( ; dit.current(); ++dit ) { | 686 | for ( ; dit.current(); ++dit ) { |
661 | if( !m_mimetypes.contains((*dit)->type() ) ) | 687 | if( !m_mimetypes.contains((*dit)->type() ) ) |
662 | m_mimetypes.append( (*dit)->type() ); | 688 | m_mimetypes.append( (*dit)->type() ); |
663 | } | 689 | } |
664 | }else{ | 690 | }else{ |
665 | // should be allreday updatet | 691 | // should be allreday updatet |
666 | ; | 692 | ; |
667 | } | 693 | } |
668 | }; | 694 | } |
695 | |||
669 | void OFileSelector::initializeListView() | 696 | void OFileSelector::initializeListView() |
670 | { | 697 | { |
671 | // just to make sure but clean it up better FIXME | 698 | // just to make sure but clean it up better FIXME |
672 | delete m_View; | 699 | delete m_View; |
673 | m_View = 0; | 700 | m_View = 0; |
674 | delete m_boxToolbar; | 701 | delete m_boxToolbar; |
675 | delete m_homeButton; | 702 | delete m_homeButton; |
676 | delete m_docButton; | 703 | delete m_docButton; |
677 | delete m_location; | 704 | delete m_location; |
678 | delete m_up; | 705 | delete m_up; |
679 | //delete m_pseudo; | 706 | //delete m_pseudo; |
680 | //if(m_pseudoLayout!=0 ) // why did you overload malloc | 707 | //if(m_pseudoLayout!=0 ) // why did you overload malloc |
681 | //delete m_pseudoLayout; | 708 | //delete m_pseudoLayout; |
682 | m_boxToolbar = 0; | 709 | m_boxToolbar = 0; |
683 | m_homeButton = 0; | 710 | m_homeButton = 0; |
684 | m_docButton = 0; | 711 | m_docButton = 0; |
685 | m_location = 0; | 712 | m_location = 0; |
686 | m_up = 0; | 713 | m_up = 0; |
687 | m_pseudo = 0; | 714 | m_pseudo = 0; |
688 | m_pseudoLayout = 0; | 715 | m_pseudoLayout = 0; |
689 | // time for the toolbar | 716 | // time for the toolbar |
690 | m_pseudo = new QWidget(m_stack, "Pseudo Widget"); | 717 | m_pseudo = new QWidget(m_stack, "Pseudo Widget"); |
691 | m_pseudoLayout = new QVBoxLayout(m_pseudo ); | 718 | m_pseudoLayout = new QVBoxLayout(m_pseudo ); |
692 | if(m_shTool ){ | 719 | if(m_shTool ){ |
693 | m_boxToolbar = new QHBoxLayout( ); | 720 | m_boxToolbar = new QHBoxLayout( ); |
694 | m_boxToolbar->setAutoAdd( true ); | 721 | m_boxToolbar->setAutoAdd( true ); |
695 | m_location = new QComboBox(m_pseudo ); | 722 | m_location = new QComboBox(m_pseudo ); |
723 | connect( m_location, SIGNAL(activated(const QString &) ), this, SLOT( locationComboActivated(const QString & ) ) ); | ||
696 | 724 | ||
697 | m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton"); | 725 | m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton"); |
698 | m_up->setFixedSize( QSize( 20, 20 ) ); | 726 | m_up->setFixedSize( QSize( 20, 20 ) ); |
699 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); | 727 | connect(m_up ,SIGNAL(clicked()),this,SLOT(cdUP() ) ); |
700 | m_up->setFlat(TRUE); | 728 | m_up->setFlat(TRUE); |
701 | 729 | ||
702 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , "", m_pseudo); | 730 | m_homeButton = new QPushButton(Resource::loadIconSet("home") , "", m_pseudo); |
703 | m_homeButton->setFixedSize( QSize( 20, 20 ) ); | 731 | m_homeButton->setFixedSize( QSize( 20, 20 ) ); |
704 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); | 732 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotHome() ) ); |
705 | m_homeButton->setFlat(TRUE); | 733 | m_homeButton->setFlat(TRUE); |
706 | 734 | ||
707 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", m_pseudo,"docsButton"); | 735 | m_docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"", m_pseudo,"docsButton"); |
708 | m_docButton->setFixedSize( QSize( 20, 20 ) ); | 736 | m_docButton->setFixedSize( QSize( 20, 20 ) ); |
709 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); | 737 | connect(m_homeButton,SIGNAL(clicked()),this,SLOT(slotDoc() ) ); |
710 | m_docButton->setFlat(TRUE); | 738 | m_docButton->setFlat(TRUE); |
711 | 739 | ||
@@ -792,32 +820,33 @@ void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ) | |||
792 | if( !info->isReadable() ){ | 820 | if( !info->isReadable() ){ |
793 | locked = true; | 821 | locked = true; |
794 | pix = Resource::loadPixmap("locked" ); | 822 | pix = Resource::loadPixmap("locked" ); |
795 | } | 823 | } |
796 | }else if( m_mode == SAVE ){ | 824 | }else if( m_mode == SAVE ){ |
797 | if( !info->isWritable() ){ | 825 | if( !info->isWritable() ){ |
798 | locked = true; | 826 | locked = true; |
799 | pix = Resource::loadPixmap("locked" ); | 827 | pix = Resource::loadPixmap("locked" ); |
800 | } | 828 | } |
801 | } | 829 | } |
802 | } | 830 | } |
803 | new OFileSelectorItem( m_View, pix, name, | 831 | new OFileSelectorItem( m_View, pix, name, |
804 | info->lastModified().toString(), | 832 | info->lastModified().toString(), |
805 | QString::number( info->size() ), | 833 | QString::number( info->size() ), |
806 | dir, locked ); | 834 | dir, locked ); |
807 | } | 835 | } |
836 | |||
808 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) | 837 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) |
809 | { | 838 | { |
810 | if(!m_dir ) | 839 | if(!m_dir ) |
811 | return; | 840 | return; |
812 | //if( showDirs ) | 841 | //if( showDirs ) |
813 | { | 842 | { |
814 | bool locked=false; | 843 | bool locked=false; |
815 | QString name; | 844 | QString name; |
816 | QPixmap pix; | 845 | QPixmap pix; |
817 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ | 846 | if( ( m_mode == OPEN && !info->isReadable() ) || ( m_mode == SAVE && !info->isWritable() ) ){ |
818 | locked = true; | 847 | locked = true; |
819 | if( symlink ){ | 848 | if( symlink ){ |
820 | pix = (*m_pixmaps)["symlinkedlocked"]; | 849 | pix = (*m_pixmaps)["symlinkedlocked"]; |
821 | }else{ | 850 | }else{ |
822 | pix = Resource::loadPixmap("lockedfolder" ); | 851 | pix = Resource::loadPixmap("lockedfolder" ); |
823 | } | 852 | } |
@@ -829,114 +858,121 @@ void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) | |||
829 | } | 858 | } |
830 | } | 859 | } |
831 | if( symlink){ | 860 | if( symlink){ |
832 | name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink(); | 861 | name = info->fileName()+ "->"+ info->dirPath(true) +"/" +info->readLink(); |
833 | 862 | ||
834 | }else{ | 863 | }else{ |
835 | //if(info->isReadable() ) | 864 | //if(info->isReadable() ) |
836 | name = info->fileName(); | 865 | name = info->fileName(); |
837 | } | 866 | } |
838 | 867 | ||
839 | new OFileSelectorItem(m_View, pix, | 868 | new OFileSelectorItem(m_View, pix, |
840 | name, info->lastModified().toString(), | 869 | name, info->lastModified().toString(), |
841 | QString::number(info->size() ),info->dirPath(true), locked, true ); | 870 | QString::number(info->size() ),info->dirPath(true), locked, true ); |
842 | 871 | ||
843 | } | 872 | } |
844 | } | 873 | } |
874 | |||
845 | void OFileSelector::setShowDirs(bool dir ) | 875 | void OFileSelector::setShowDirs(bool dir ) |
846 | { | 876 | { |
847 | m_dir = dir; | 877 | m_dir = dir; |
848 | reparse(); | 878 | reparse(); |
849 | } | 879 | } |
850 | 880 | ||
851 | void OFileSelector::slotFileSelected(const QString &string ) | 881 | void OFileSelector::slotFileSelected(const QString &string ) |
852 | { | 882 | { |
853 | if(m_shLne ) | 883 | if(m_shLne ) |
854 | m_edit->setText( string ); | 884 | m_edit->setText( string ); |
855 | 885 | ||
856 | emit fileSelected( string ); | 886 | emit fileSelected( string ); |
857 | // do AppLnk stuff | 887 | // do AppLnk stuff |
858 | } | 888 | } |
889 | |||
859 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) | 890 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) |
860 | { | 891 | { |
861 | slotFileSelected(lnk.name() ); | 892 | slotFileSelected(lnk.name() ); |
862 | emit fileSelected( lnk ); | 893 | emit fileSelected( lnk ); |
863 | } | 894 | } |
895 | |||
864 | void OFileSelector::slotSelectionChanged() // get the current items | 896 | void OFileSelector::slotSelectionChanged() // get the current items |
865 | // fixme | 897 | // fixme |
866 | { | 898 | { |
867 | qWarning("selection changed" ); | 899 | qWarning("selection changed" ); |
868 | } | 900 | } |
901 | |||
869 | void OFileSelector::slotCurrentChanged(QListViewItem *item ) | 902 | void OFileSelector::slotCurrentChanged(QListViewItem *item ) |
870 | { | 903 | { |
871 | qWarning("current changed" ); | 904 | qWarning("current changed" ); |
872 | if( item == 0 ) | 905 | if( item == 0 ) |
873 | return; | 906 | return; |
874 | 907 | ||
875 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 908 | if( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
876 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | 909 | OFileSelectorItem *sel = (OFileSelectorItem*)item; |
877 | if(!sel->isDir() ){ | 910 | if(!sel->isDir() ){ |
878 | qWarning("is not dir" ); | 911 | qWarning("is not dir" ); |
879 | if(m_shLne ){ | 912 | if(m_shLne ){ |
880 | m_edit->setText(sel->text(1) ); | 913 | m_edit->setText(sel->text(1) ); |
881 | qWarning("setTexy" ); | 914 | qWarning("setTexy" ); |
882 | } | 915 | } |
883 | } | 916 | } |
884 | }else { | 917 | }else { |
885 | qWarning("mode not extended" ); | 918 | qWarning("mode not extended" ); |
886 | } | 919 | } |
887 | } | 920 | } |
921 | |||
888 | // either select or change dir | 922 | // either select or change dir |
889 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int ) | 923 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int ) |
890 | { | 924 | { |
891 | if( item == 0 ) | 925 | if( item == 0 ) |
892 | return; | 926 | return; |
893 | 927 | ||
894 | if( button != Qt::LeftButton ) | 928 | if( button != Qt::LeftButton ) |
895 | return; | 929 | return; |
896 | 930 | ||
897 | qWarning("clicked" ); | 931 | qWarning("clicked" ); |
898 | if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ | 932 | if(m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ |
899 | qWarning("inside" ); | 933 | qWarning("inside" ); |
900 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | 934 | OFileSelectorItem *sel = (OFileSelectorItem*)item; |
901 | if(!sel->isLocked() ){ // not locked either changedir or open | 935 | if(!sel->isLocked() ){ // not locked either changedir or open |
902 | QStringList str = QStringList::split("->", sel->text(1) ); | 936 | QStringList str = QStringList::split("->", sel->text(1) ); |
903 | if(sel->isDir() ){ | 937 | if(sel->isDir() ){ |
904 | cd( sel->directory() + "/" + str[0] ); | 938 | cd( sel->directory() + "/" + str[0] ); |
905 | }else{ | 939 | } else { |
906 | qWarning("file" ); | 940 | qWarning("file" ); |
907 | if(m_shLne ) | 941 | if(m_shLne ) |
908 | m_edit->setText(str[0] ); | 942 | m_edit->setText(str[0] ); |
909 | emit fileSelected(str[0] ); | 943 | emit fileSelected(str[0] ); |
910 | // emit DocLnk need to do it | 944 | // emit DocLnk need to do it |
911 | } | 945 | } |
912 | }else{ | 946 | } else { |
913 | qWarning( "locked" ); | 947 | qWarning( "locked" ); |
914 | } | 948 | } |
915 | }; | 949 | }; |
916 | } | 950 | } |
951 | |||
917 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) | 952 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) |
918 | { | 953 | { |
919 | if (item == 0 ) | 954 | if (item == 0 ) |
920 | return; | 955 | return; |
921 | 956 | ||
922 | if( button != Qt::RightButton ) | 957 | if( button != Qt::RightButton ) |
923 | return; | 958 | return; |
924 | qWarning("right button" ); | 959 | qWarning("right button" ); |
925 | slotContextMenu(item); | 960 | slotContextMenu(item); |
926 | } | 961 | } |
962 | |||
927 | void OFileSelector::slotContextMenu(QListViewItem *item) | 963 | void OFileSelector::slotContextMenu(QListViewItem *item) |
928 | { | 964 | { |
929 | qWarning("context menu" ); | 965 | qWarning("context menu" ); |
930 | if( item ==0 || !m_showPopup ) | 966 | if( item ==0 || !m_showPopup ) |
931 | return; | 967 | return; |
932 | 968 | ||
933 | if( m_custom !=0){ | 969 | if( m_custom !=0){ |
934 | m_custom->exec(); | 970 | m_custom->exec(); |
935 | }else{ | 971 | }else{ |
936 | QPopupMenu menu; | 972 | QPopupMenu menu; |
937 | QAction up; | 973 | QAction up; |
938 | up.setText("cd up"); | 974 | up.setText("cd up"); |
939 | up.addTo( &menu ); | 975 | up.addTo( &menu ); |
940 | connect(&up, SIGNAL(activated() ), | 976 | connect(&up, SIGNAL(activated() ), |
941 | this, SLOT(cdUP() ) ); | 977 | this, SLOT(cdUP() ) ); |
942 | 978 | ||
@@ -962,96 +998,141 @@ void OFileSelector::slotContextMenu(QListViewItem *item) | |||
962 | QAction rename; | 998 | QAction rename; |
963 | rename.setText( tr("Rename") ); | 999 | rename.setText( tr("Rename") ); |
964 | rename.addTo( &menu ); | 1000 | rename.addTo( &menu ); |
965 | connect(&rename, SIGNAL(activated() ), | 1001 | connect(&rename, SIGNAL(activated() ), |
966 | this, SLOT(slotRename() ) ); | 1002 | this, SLOT(slotRename() ) ); |
967 | 1003 | ||
968 | menu.insertSeparator(); | 1004 | menu.insertSeparator(); |
969 | QAction delItem; | 1005 | QAction delItem; |
970 | delItem.setText( tr("Delete") ); | 1006 | delItem.setText( tr("Delete") ); |
971 | delItem.addTo(&menu ); | 1007 | delItem.addTo(&menu ); |
972 | connect(&delItem, SIGNAL(activated() ), | 1008 | connect(&delItem, SIGNAL(activated() ), |
973 | this, SLOT(slotDelete() ) ); | 1009 | this, SLOT(slotDelete() ) ); |
974 | 1010 | ||
975 | menu.exec(QCursor::pos() ); | 1011 | menu.exec(QCursor::pos() ); |
976 | } | 1012 | } |
977 | } | 1013 | } |
1014 | |||
978 | bool OFileSelector::cd(const QString &str ) | 1015 | bool OFileSelector::cd(const QString &str ) |
979 | { | 1016 | { |
980 | qWarning(" dir %s", str.latin1() ); | 1017 | qWarning(" dir %s", str.latin1() ); |
981 | QDir dir( str); | 1018 | QDir dir( str); |
982 | if(dir.exists() ){ | 1019 | if(dir.exists() ){ |
983 | m_currentDir = str; | 1020 | m_currentDir = dir.absPath(); |
984 | reparse(); | 1021 | reparse(); |
985 | if(m_shTool ){ | 1022 | if(m_shTool ){ |
986 | int count = m_location->count(); | 1023 | int count = m_location->count(); |
987 | m_location->insertItem(str ); | 1024 | insertLocationPath( str ,count ); |
988 | m_location->setCurrentItem( count ); | 1025 | m_location->setCurrentItem( count ); |
989 | } | 1026 | } |
990 | return true; | 1027 | return true; |
991 | } | 1028 | } |
992 | return false; | 1029 | return false; |
993 | } | 1030 | } |
994 | 1031 | ||
1032 | void OFileSelector::insertLocationPath(const QString ¤tPath, int count) { | ||
1033 | QStringList pathList; | ||
1034 | for(int i=0;i<count;i++) { | ||
1035 | pathList << m_location->text(i); | ||
1036 | } | ||
1037 | if( pathList.grep( currentPath,TRUE).isEmpty() ) { | ||
1038 | m_location->clear(); | ||
1039 | if( currentPath.left(2)=="//") | ||
1040 | pathList.append( currentPath.right(currentPath.length()-1) ); | ||
1041 | else | ||
1042 | pathList.append( currentPath ); | ||
1043 | m_location->insertStringList( pathList,-1); | ||
1044 | } | ||
1045 | } | ||
1046 | |||
995 | void OFileSelector::slotChangedDir() | 1047 | void OFileSelector::slotChangedDir() |
996 | { | 1048 | { |
997 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 1049 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
998 | if(sel->isDir() ){ | 1050 | if(sel->isDir() ){ |
999 | QStringList str = QStringList::split("->", sel->text(1) ); | 1051 | QStringList str = QStringList::split("->", sel->text(1) ); |
1000 | cd( sel->directory() + "/" + str[0] ); | 1052 | cd( sel->directory() + "/" + str[0] ); |
1053 | |||
1001 | } | 1054 | } |
1002 | } | 1055 | } |
1056 | |||
1003 | void OFileSelector::slotOpen() | 1057 | void OFileSelector::slotOpen() |
1004 | { | 1058 | { |
1005 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 1059 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
1006 | if(!sel->isDir() ){ | 1060 | if(!sel->isDir() ){ |
1007 | QStringList str = QStringList::split("->", sel->text(1) ); | 1061 | QStringList str = QStringList::split("->", sel->text(1) ); |
1008 | slotFileSelected( str[0] ); | 1062 | slotFileSelected( str[0] ); |
1009 | } | 1063 | } |
1010 | } | 1064 | } |
1065 | |||
1011 | void OFileSelector::slotRescan() | 1066 | void OFileSelector::slotRescan() |
1012 | { | 1067 | { |
1013 | reparse(); | 1068 | reparse(); |
1014 | } | 1069 | } |
1070 | |||
1015 | void OFileSelector::slotRename() | 1071 | void OFileSelector::slotRename() |
1016 | { | 1072 | { |
1017 | // rename inline | 1073 | // rename inline |
1018 | } | 1074 | } |
1075 | |||
1019 | void OFileSelector::slotDelete() | 1076 | void OFileSelector::slotDelete() |
1020 | { | 1077 | { |
1021 | qWarning("delete slot" ); | 1078 | qWarning("delete slot" ); |
1022 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | 1079 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); |
1023 | QStringList list = QStringList::split("->", sel->text(1) ); | 1080 | QStringList list = QStringList::split("->", sel->text(1) ); |
1024 | if( sel->isDir() ){ | 1081 | if( sel->isDir() ){ |
1025 | QString str = QString::fromLatin1("rm -rf ") + list[0]; | 1082 | QString str = QString::fromLatin1("rm -rf ") + list[0]; //better safe than sorry |
1026 | ::system(str.utf8().data() ); | 1083 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], |
1027 | }else{ | 1084 | tr("Yes"),tr("No"),0,1,1) ) { |
1085 | case 0: | ||
1086 | ::system(str.utf8().data() ); | ||
1087 | break; | ||
1088 | } | ||
1089 | } else { | ||
1028 | QFile::remove( list[0] ); | 1090 | QFile::remove( list[0] ); |
1029 | } | 1091 | } |
1030 | m_View->takeItem( sel ); | 1092 | m_View->takeItem( sel ); |
1031 | delete sel; | 1093 | delete sel; |
1032 | } | 1094 | } |
1033 | 1095 | ||
1034 | void OFileSelector::cdUP() | 1096 | void OFileSelector::cdUP() |
1035 | { | 1097 | { |
1036 | QDir dir( m_currentDir ); | 1098 | QDir dir( m_currentDir ); |
1037 | dir.cdUp(); | 1099 | dir.cdUp(); |
1038 | if(dir.exists() ){ | 1100 | if(dir.exists() ){ |
1039 | m_currentDir = dir.absPath(); | 1101 | m_currentDir = dir.absPath(); |
1040 | reparse(); | 1102 | reparse(); |
1041 | int count = m_location->count(); | 1103 | int count = m_location->count(); |
1042 | m_location->insertItem(m_currentDir ); | 1104 | insertLocationPath( m_currentDir,count ); |
1043 | m_location->setCurrentItem( count ); | 1105 | m_location->setCurrentItem( indexFromString(m_currentDir )); |
1106 | //this wont work in all instances | ||
1107 | // FIXME | ||
1044 | } | 1108 | } |
1045 | } | 1109 | } |
1110 | |||
1111 | int OFileSelector::indexFromString(const QString &str) { | ||
1112 | |||
1113 | for(int i=0;i< m_location->count();i++) { | ||
1114 | if(str == m_location->text(i)) | ||
1115 | return i; | ||
1116 | } | ||
1117 | return 0; | ||
1118 | } | ||
1119 | |||
1046 | void OFileSelector::slotHome() | 1120 | void OFileSelector::slotHome() |
1047 | { | 1121 | { |
1048 | cd(QDir::homeDirPath() ); | 1122 | cd(QDir::homeDirPath() ); |
1049 | } | 1123 | } |
1124 | |||
1050 | void OFileSelector::slotDoc() | 1125 | void OFileSelector::slotDoc() |
1051 | { | 1126 | { |
1052 | cd(QDir::homeDirPath() + "/Documents" ); | 1127 | cd(QDir::homeDirPath() + "/Documents" ); |
1053 | } | 1128 | } |
1129 | |||
1054 | void OFileSelector::slotNavigate() | 1130 | void OFileSelector::slotNavigate() |
1055 | { | 1131 | { |
1056 | 1132 | ||
1057 | } | 1133 | } |
1134 | |||
1135 | void OFileSelector::locationComboActivated(const QString & file ) { | ||
1136 | cd(file.left(file.find("<-",0,TRUE))); | ||
1137 | reparse(); | ||
1138 | } | ||
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index 5e98a1e..81a9e63 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h | |||
@@ -54,64 +54,64 @@ class DocLnk; | |||
54 | class QCheckBox; | 54 | class QCheckBox; |
55 | class QComboBox; | 55 | class QComboBox; |
56 | class QPushButton; | 56 | class QPushButton; |
57 | class FileSelector; | 57 | class FileSelector; |
58 | class QGridLayout; | 58 | class QGridLayout; |
59 | class QLineEdit; | 59 | class QLineEdit; |
60 | class QLabel; | 60 | class QLabel; |
61 | class QWidgetStack; | 61 | class QWidgetStack; |
62 | class QHBoxLayout; | 62 | class QHBoxLayout; |
63 | class QVBoxLayout; | 63 | class QVBoxLayout; |
64 | class QPopupMenu; | 64 | class QPopupMenu; |
65 | class QFileInfo; | 65 | class QFileInfo; |
66 | // | 66 | // |
67 | class OFileSelectorItem : public QListViewItem { | 67 | class OFileSelectorItem : public QListViewItem { |
68 | public: | 68 | public: |
69 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | 69 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, |
70 | const QString &date, const QString &size, const QString &mDir, | 70 | const QString &date, const QString &size, const QString &mDir, |
71 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { | 71 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { |
72 | setPixmap(0, pixmap ); | 72 | setPixmap(0, pixmap ); |
73 | setText(1, path ); | 73 | setText(1, path ); |
74 | setText(2, size ); | 74 | setText(2, size ); |
75 | setText(3, date ); | 75 | setText(3, date ); |
76 | //setText(4, mDir ); | 76 | //setText(4, mDir ); |
77 | m_dir = mDir; | 77 | m_dir = mDir; |
78 | dir = isDir; | 78 | dir = isDir; |
79 | mLocked = isLocked; | 79 | mLocked = isLocked; |
80 | } | 80 | } |
81 | bool isLocked() const{ | 81 | bool isLocked() const{ |
82 | return mLocked; | 82 | return mLocked; |
83 | } | 83 | } |
84 | QString directory()const{ | 84 | QString directory()const{ |
85 | return m_dir; | 85 | return m_dir; |
86 | } | 86 | } |
87 | bool isDir()const{ | 87 | bool isDir()const{ |
88 | return dir; | 88 | return dir; |
89 | } | 89 | } |
90 | QString path()const{ | 90 | QString path()const{ |
91 | return text(1 ); | 91 | return text(1 ); |
92 | } | 92 | } |
93 | QString key(int id, bool )const { | 93 | QString key(int id, bool )const { |
94 | QString ke; | 94 | QString ke; |
95 | if( id == 0 || id == 1 ){ // name | 95 | if( id == 0 || id == 1 ){ // name |
96 | if( dir ){ | 96 | if( dir ){ |
97 | ke.append("0" ); | 97 | ke.append("0" ); |
98 | ke.append( text(1) ); | 98 | ke.append( text(1) ); |
99 | }else{ | 99 | }else{ |
100 | ke.append("1" ); | 100 | ke.append("1" ); |
101 | ke.append( text(1) ); | 101 | ke.append( text(1) ); |
102 | } | 102 | } |
103 | }else if( id == 2 ){ // size | 103 | }else if( id == 2 ){ // size |
104 | return text(2); | 104 | return text(2); |
105 | }else if( id == 3 ){ // date | 105 | }else if( id == 3 ){ // date |
106 | return text(3); | 106 | return text(3); |
107 | } | 107 | } |
108 | return ke; | 108 | return ke; |
109 | }; | 109 | }; |
110 | private: | 110 | private: |
111 | bool mLocked:1; | 111 | bool mLocked:1; |
112 | bool dir:1; | 112 | bool dir:1; |
113 | QString m_dir; | 113 | QString m_dir; |
114 | }; | 114 | }; |
115 | 115 | ||
116 | class OFileSelector : public QWidget { | 116 | class OFileSelector : public QWidget { |
117 | Q_OBJECT | 117 | Q_OBJECT |
@@ -177,32 +177,35 @@ class OFileSelector : public QWidget { | |||
177 | /* the user needs to delete it */ | 177 | /* the user needs to delete it */ |
178 | QValueList<DocLnk> selectedDocuments()const; | 178 | QValueList<DocLnk> selectedDocuments()const; |
179 | 179 | ||
180 | signals: | 180 | signals: |
181 | void fileSelected( const DocLnk & ); | 181 | void fileSelected( const DocLnk & ); |
182 | void fileSelected( const QString & ); | 182 | void fileSelected( const QString & ); |
183 | void dirSelected(const QString &dir ); | 183 | void dirSelected(const QString &dir ); |
184 | void closeMe(); | 184 | void closeMe(); |
185 | void ok(); | 185 | void ok(); |
186 | void cancel(); | 186 | void cancel(); |
187 | 187 | ||
188 | protected slots: | 188 | protected slots: |
189 | void slotOk(); | 189 | void slotOk(); |
190 | void slotCancel(); | 190 | void slotCancel(); |
191 | void slotViewCheck(const QString & ); | 191 | void slotViewCheck(const QString & ); |
192 | void slotMimeCheck(const QString & ); | 192 | void slotMimeCheck(const QString & ); |
193 | void locationComboActivated(const QString & ); | ||
194 | void insertLocationPath(const QString &, int); | ||
195 | int indexFromString(const QString &); | ||
193 | protected: | 196 | protected: |
194 | void init(); | 197 | void init(); |
195 | void updateMimes(); | 198 | void updateMimes(); |
196 | 199 | ||
197 | protected: | 200 | protected: |
198 | 201 | ||
199 | private: | 202 | private: |
200 | int m_mode, m_selector; | 203 | int m_mode, m_selector; |
201 | QComboBox *m_location, *m_mimeCheck, *m_viewCheck; | 204 | QComboBox *m_location, *m_mimeCheck, *m_viewCheck; |
202 | QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; | 205 | QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; |
203 | QPushButton *m_reread, *m_up; | 206 | QPushButton *m_reread, *m_up; |
204 | QListView *m_View; | 207 | QListView *m_View; |
205 | QCheckBox *m_checkPerm; | 208 | QCheckBox *m_checkPerm; |
206 | QWidget *m_pseudo; | 209 | QWidget *m_pseudo; |
207 | QVBoxLayout *m_pseudoLayout; | 210 | QVBoxLayout *m_pseudoLayout; |
208 | 211 | ||