summaryrefslogtreecommitdiff
path: root/libopie
authorzecke <zecke>2002-10-13 19:02:48 (UTC)
committer zecke <zecke>2002-10-13 19:02:48 (UTC)
commita469689def798954c0f571a00cc52e87d6b008ce (patch) (unidiff)
tree410514b96d2951c6a8c29c26e21660094dd14bbd /libopie
parent130ae6144e031b4de2244990c53df8654bd840ae (diff)
downloadopie-a469689def798954c0f571a00cc52e87d6b008ce.zip
opie-a469689def798954c0f571a00cc52e87d6b008ce.tar.gz
opie-a469689def798954c0f571a00cc52e87d6b008ce.tar.bz2
Fix a Crash when using All Files.. as name and default() returns 0l
Fix a Crash in reparse when the chooser is not yet initialized
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector/ofileselector.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp
index 7f38f5b..4ab744c 100644
--- a/libopie/ofileselector/ofileselector.cpp
+++ b/libopie/ofileselector/ofileselector.cpp
@@ -201,100 +201,100 @@ 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}
204void OFileSelector::setPermissionChecked( bool check ) 204void 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
210void OFileSelector::setMode(int mode) // FIXME do direct raising 210void 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}
216void OFileSelector::setShowDirs(bool dir) 216void 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}
222void OFileSelector::setCaseSensetive(bool caSe ) 222void 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}
229void OFileSelector::setShowFiles(bool show ) 229void OFileSelector::setShowFiles(bool show )
230{ 230{
231 m_files = show; 231 m_files = show;
232 reparse(); 232 reparse();
233} 233}
234/// 234///
235bool OFileSelector::cd(const QString &path ) 235bool 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}
241void OFileSelector::setSelector(int mode ) 241void 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("Files"); 249 text = tr("List View");
250 break; 250 break;
251 case ExtendedAll: 251 case ExtendedAll:
252 text = tr("All Files"); 252 text = tr("All List View");
253 break; 253 break;
254 } 254 }
255 slotViewCheck( text ); 255 slotViewCheck( text );
256} 256}
257 257
258void OFileSelector::setPopupFactory(OPopupMenuFactory */*popup*/ ) 258void 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 265//void OFileSelector::updateL
266 266
267QString OFileSelector::selectedName() const 267QString OFileSelector::selectedName() const
268{ 268{
269 QString name; 269 QString name;
270 if( m_selector == Normal ){ 270 if( m_selector == Normal ){
271 DocLnk lnk = m_select->selectedDocument(); 271 DocLnk lnk = m_select->selectedDocument();
272 name = lnk.file(); 272 name = lnk.file();
273 }else { 273 }else {
274 if ( m_shLne ) { 274 if ( m_shLne ) {
275 name = m_currentDir + "/" +m_edit->text(); 275 name = m_currentDir + "/" +m_edit->text();
276 }else{ 276 }else{
277 name = m_currentDir + "/" + currentView()->selectedName(); 277 name = m_currentDir + "/" + currentView()->selectedName();
278 } 278 }
279 } 279 }
280 return name; 280 return name;
281} 281}
282QStringList OFileSelector::selectedNames()const 282QStringList OFileSelector::selectedNames()const
283{ 283{
284 QStringList list; 284 QStringList list;
285 if( m_selector == Normal ){ 285 if( m_selector == Normal ){
286 list << selectedName(); 286 list << selectedName();
287 }else { 287 }else {
288 list << selectedName(); // FIXME implement multiple Selections 288 list << selectedName(); // FIXME implement multiple Selections
289 } 289 }
290 return list; 290 return list;
291} 291}
292/** If mode is set to the Dir selection this will return the selected path. 292/** If mode is set to the Dir selection this will return the selected path.
293 * 293 *
294 * 294 *
295 */ 295 */
296QString OFileSelector::selectedPath()const 296QString OFileSelector::selectedPath()const
297{ 297{
298 QString path; 298 QString path;
299 if( m_selector == Normal ){ 299 if( m_selector == Normal ){
300 path = QPEApplication::documentDir(); 300 path = QPEApplication::documentDir();
@@ -421,121 +421,120 @@ void OFileSelector::slotLocationActivated(const QString &file)
421 QFileInfo info( name ); 421 QFileInfo info( name );
422 if ( info.isFile() ) 422 if ( info.isFile() )
423 cd(info.dirPath( TRUE ) ); //absolute 423 cd(info.dirPath( TRUE ) ); //absolute
424 else 424 else
425 cd(name ); 425 cd(name );
426 reparse(); 426 reparse();
427} 427}
428void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count) 428void OFileSelector::slotInsertLocationPath(const QString &currentPath, int count)
429{ 429{
430 QStringList pathList; 430 QStringList pathList;
431 bool underDog = FALSE; 431 bool underDog = FALSE;
432 for(int i=0;i<count;i++) { 432 for(int i=0;i<count;i++) {
433 pathList << m_location->text(i); 433 pathList << m_location->text(i);
434 if( m_location->text(i) == currentPath) 434 if( m_location->text(i) == currentPath)
435 underDog = TRUE; 435 underDog = TRUE;
436 } 436 }
437 if( !underDog) { 437 if( !underDog) {
438 m_location->clear(); 438 m_location->clear();
439 if( currentPath.left(2)=="//") 439 if( currentPath.left(2)=="//")
440 pathList.append( currentPath.right(currentPath.length()-1) ); 440 pathList.append( currentPath.right(currentPath.length()-1) );
441 else 441 else
442 pathList.append( currentPath ); 442 pathList.append( currentPath );
443 m_location->insertStringList( pathList,-1); 443 m_location->insertStringList( pathList,-1);
444 } 444 }
445} 445}
446/* 446/*
447 * Do not crash anymore 447 * Do not crash anymore
448 * don't try to change dir to a file 448 * don't try to change dir to a file
449 */ 449 */
450void OFileSelector::locationComboChanged() 450void OFileSelector::locationComboChanged()
451{ 451{
452 QFileInfo info( m_location->lineEdit()->text() ); 452 QFileInfo info( m_location->lineEdit()->text() );
453 qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() ); 453 qWarning("info %s %s", info.dirPath(true).latin1(), m_location->lineEdit()->text().latin1() );
454 if (info.isFile() ) 454 if (info.isFile() )
455 cd(info.dirPath(TRUE) ); //absolute path 455 cd(info.dirPath(TRUE) ); //absolute path
456 else 456 else
457 cd( m_location->lineEdit()->text() ); 457 cd( m_location->lineEdit()->text() );
458 458
459 reparse(); 459 reparse();
460} 460}
461void OFileSelector::init() 461void OFileSelector::init()
462{ 462{
463 initFactory(); 463 initFactory();
464 m_lay = new QVBoxLayout( this ); 464 m_lay = new QVBoxLayout( this );
465 m_lay->setSpacing(0 ); 465 m_lay->setSpacing(0 );
466 466
467 /* take care of the main view... */ 467 /* take care of the main view... */
468 initToolbar(); 468 initToolbar();
469 //if( m_shChooser ) // the Chooser for the view and Mimetypes
470 initializeChooser();
469 471
470 /* initialize the file lister */ 472 /* initialize the file lister */
471 if( m_selector == Normal ){ 473 if( m_selector == Normal ){
472 QString mime; 474 QString mime;
473 if (!m_autoMime) { 475 if (!m_autoMime) {
474 if (!m_mimetypes.isEmpty() ) { 476 if (!m_mimetypes.isEmpty() ) {
475 QMap<QString, QStringList>::Iterator it; 477 QMap<QString, QStringList>::Iterator it;
476 it = m_mimetypes.begin(); // cause we're in the init 478 it = m_mimetypes.begin(); // cause we're in the init
477 mime = it.data().join(";"); 479 mime = it.data().join(";");
478 } 480 }
479 } 481 }
480 initializeOldSelector(); 482 initializeOldSelector();
481 }else{ 483 }else{
482 initializeView(); 484 initializeView();
483 } 485 }
484 486
485 if( m_shLne ) // the LineEdit with the current FileName 487 if( m_shLne ) // the LineEdit with the current FileName
486 initializeName(); 488 initializeName();
487 489
488 if( m_shPerm ) // the Permission QCheckBox 490 if( m_shPerm ) // the Permission QCheckBox
489 initializePerm(); 491 initializePerm();
490 492
491 if( m_shChooser ) // the Chooser for the view and Mimetypes
492 initializeChooser();
493
494 if( m_shYesNo ) // the Yes No button row 493 if( m_shYesNo ) // the Yes No button row
495 initializeYes( ); 494 initializeYes( );
496 495
497 if (m_selector != Normal ) 496 if (m_selector != Normal )
498 reparse(); 497 reparse();
499} 498}
500void OFileSelector::updateMimes() 499void OFileSelector::updateMimes()
501{ 500{
502 if( m_autoMime ){ 501 if( m_autoMime ){
503 m_mimetypes.clear(); 502 m_mimetypes.clear();
504 m_mimetypes.insert( tr("All"), QString::null ); 503 m_mimetypes.insert( tr("All"), QString::null );
505 if( m_selector == Normal ){ 504 if( m_selector == Normal ){
506 DocLnkSet set; 505 DocLnkSet set;
507 Global::findDocuments(&set, QString::null ); 506 Global::findDocuments(&set, QString::null );
508 QListIterator<DocLnk> dit( set.children() ); 507 QListIterator<DocLnk> dit( set.children() );
509 for( ; dit.current(); ++dit ){ 508 for( ; dit.current(); ++dit ){
510 if( !m_mimetypes.contains( (*dit)->type() ) ) 509 if( !m_mimetypes.contains( (*dit)->type() ) )
511 m_mimetypes.insert( (*dit)->type(), (*dit)->type() ); 510 m_mimetypes.insert( (*dit)->type(), (*dit)->type() );
512 } 511 }
513 }// else done in reparse 512 }// else done in reparse
514 } 513 }
515} 514}
516void OFileSelector::initVars() 515void OFileSelector::initVars()
517{ 516{
518 if( m_mimetypes.isEmpty() ) 517 if( m_mimetypes.isEmpty() )
519 m_autoMime = true; 518 m_autoMime = true;
520 else 519 else
521 m_autoMime = false; 520 m_autoMime = false;
522 521
523 m_shClose = false; 522 m_shClose = false;
524 m_shNew = false; 523 m_shNew = false;
525 m_shTool = true; 524 m_shTool = true;
526 m_shPerm = false; 525 m_shPerm = false;
527 m_shLne = true; 526 m_shLne = true;
528 m_shChooser = true; 527 m_shChooser = true;
529 m_shYesNo = true; 528 m_shYesNo = true;
530 m_case = false; 529 m_case = false;
531 m_dir = true; 530 m_dir = true;
532 m_files = true; 531 m_files = true;
533 m_showPopup = false; 532 m_showPopup = false;
534 m_mainView = 0l; 533 m_mainView = 0l;
535 m_fileView = 0l; 534 m_fileView = 0l;
536 m_lister = 0l; 535 m_lister = 0l;
537 536
538 if(m_pixmaps == 0 ) // init the pixmaps 537 if(m_pixmaps == 0 ) // init the pixmaps
539 initPics(); 538 initPics();
540 539
541 // pointers 540 // pointers
@@ -911,96 +910,97 @@ void OFileSelector::reparse()
911 } 910 }
912 }else { // no autoMime 911 }else { // no autoMime
913 // let the mimetype be set from out side the m_mimeCheck FEATURE 912 // let the mimetype be set from out side the m_mimeCheck FEATURE
914 913
915 if( m_shChooser ) 914 if( m_shChooser )
916 currentMimeType = m_mimeCheck->currentText(); 915 currentMimeType = m_mimeCheck->currentText();
917 916
918 } 917 }
919 // now we got our mimetypes we can add the files 918 // now we got our mimetypes we can add the files
920 919
921 currentLister()->reparse( m_currentDir ); 920 currentLister()->reparse( m_currentDir );
922 /* we're done with adding let's sort */ 921 /* we're done with adding let's sort */
923 currentView()->sort(); 922 currentView()->sort();
924 923
925 924
926 if( m_shTool ){ 925 if( m_shTool ){
927 m_location->insertItem( m_currentDir ); 926 m_location->insertItem( m_currentDir );
928 927
929 } 928 }
930 // reenable painting and updates 929 // reenable painting and updates
931} 930}
932/* switch lister to @param lister */ 931/* switch lister to @param lister */
933void OFileSelector::setLister(const QString& lister) { 932void OFileSelector::setLister(const QString& lister) {
934 QStringList listerList = factory()->lister(); 933 QStringList listerList = factory()->lister();
935 934
936 if (listerList.contains(lister) ) { 935 if (listerList.contains(lister) ) {
937 delete (OLister*) m_lister; 936 delete (OLister*) m_lister;
938 m_lister = factory()->lister( lister, this ); 937 m_lister = factory()->lister( lister, this );
939 }else if (!m_lister ) { 938 }else if (!m_lister ) {
940 /* 939 /*
941 * if we do not have a lister 940 * if we do not have a lister
942 * we need to take the default one 941 * we need to take the default one
943 */ 942 */
944 m_lister = new OLocalLister(this); 943 m_lister = new OLocalLister(this);
945 } 944 }
946 m_listerName = lister; 945 m_listerName = lister;
947} 946}
948void OFileSelector::setView( const QString& lis ) { 947void OFileSelector::setView( const QString& lis ) {
949 qWarning("setView "); 948 qWarning("setView ");
950 fillList(); 949 fillList();
951 if ( lis == tr("Documents") ) { 950 if ( lis == tr("Documents") ) {
952 m_selector = Normal; 951 m_selector = Normal;
953 delete m_lister; 952 delete m_lister;
954 delete m_fileView; 953 delete m_fileView;
955 m_lister = 0l; 954 m_lister = 0l;
956 m_fileView = 0l; 955 m_fileView = 0l;
957 initializeOldSelector(); 956 initializeOldSelector();
958 }else { 957 }else {
958 qWarning("lis %s", lis.latin1() );
959 QString list; 959 QString list;
960 960
961 delete m_lister; 961 delete m_lister;
962 delete m_fileView; 962 delete m_fileView;
963 delete m_select; 963 delete m_select;
964 m_lister =0l; 964 m_lister =0l;
965 m_fileView = 0l; 965 m_fileView = 0l;
966 m_select = 0l; 966 m_select = 0l;
967 if ( lis.startsWith("All") ) { 967 if ( lis.startsWith("All") ) {
968 m_selector = ExtendedAll; 968 m_selector = ExtendedAll;
969 list = lis.mid(4 ).stripWhiteSpace(); 969 list = lis.mid(4 ).stripWhiteSpace();
970 } else{ 970 } else{
971 list = lis; 971 list = lis;
972 m_selector = Extended; 972 m_selector = Extended;
973 } 973 }
974 setLister(m_listerName); 974 setLister(m_listerName);
975 m_fileView = factory()->view( list, this, m_mainView ); 975 m_fileView = factory()->view( list, this, m_mainView );
976 m_mainView->setWidget( m_fileView->widget() ); 976 m_mainView->setWidget( m_fileView->widget() );
977 reparse(); 977 reparse();
978 } 978 }
979} 979}
980/* 980/*
981 * the factory 981 * the factory
982 */ 982 */
983void OFileSelector::initFactory() { 983void OFileSelector::initFactory() {
984 m_fileFactory = new OFileFactory(); 984 m_fileFactory = new OFileFactory();
985 m_fileFactory->addLister(tr("Files"), newLocalLister ); 985 m_fileFactory->addLister(tr("Files"), newLocalLister );
986 m_fileFactory->addView(tr("List View"), newFileListView ); 986 m_fileFactory->addView(tr("List View"), newFileListView );
987 /* the factory is just a dummy */ 987 /* the factory is just a dummy */
988 m_fileFactory->addView(tr("Documents"), newFileListView ); 988 m_fileFactory->addView(tr("Documents"), newFileListView );
989} 989}
990void OFileSelector::fillList() { 990void OFileSelector::fillList() {
991 qWarning("fill list"); 991 qWarning("fill list");
992 if (!m_viewCheck ) 992 if (!m_viewCheck )
993 return; 993 return;
994 994
995 m_viewCheck->clear(); 995 m_viewCheck->clear();
996 QStringList list = factory()->views(); 996 QStringList list = factory()->views();
997 qWarning("views: " + list.join(";") ); 997 qWarning("views: " + list.join(";") );
998 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 998 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
999 qWarning( (*it) ); 999 qWarning( (*it) );
1000 if ( (*it) == tr("Documents") ) { 1000 if ( (*it) == tr("Documents") ) {
1001 m_viewCheck->insertItem( (*it) ); 1001 m_viewCheck->insertItem( (*it) );
1002 }else{ 1002 }else{
1003 m_viewCheck->insertItem( (*it) ); 1003 m_viewCheck->insertItem( (*it) );
1004 m_viewCheck->insertItem( tr("All ") + (*it) ); 1004 m_viewCheck->insertItem( tr("All ") + (*it) );
1005 } 1005 }
1006 } 1006 }
@@ -1047,54 +1047,54 @@ void OFileSelector::internContextMenu() {
1047void OFileSelector::internChangedDir( const QString& s) { 1047void OFileSelector::internChangedDir( const QString& s) {
1048 emit dirSelected( s ); 1048 emit dirSelected( s );
1049 cd(s ); 1049 cd(s );
1050} 1050}
1051void OFileSelector::internChangedDir( const QDir& s) { 1051void OFileSelector::internChangedDir( const QDir& s) {
1052 emit dirSelected( s ); 1052 emit dirSelected( s );
1053} 1053}
1054QPixmap OFileSelector::pixmap( const QString& s ) { 1054QPixmap OFileSelector::pixmap( const QString& s ) {
1055 1055
1056 return (*m_pixmaps)[s]; 1056 return (*m_pixmaps)[s];
1057} 1057}
1058OLister* OFileSelector::currentLister()const { 1058OLister* OFileSelector::currentLister()const {
1059 return m_lister; 1059 return m_lister;
1060} 1060}
1061void OFileSelector::initializeOldSelector() { 1061void OFileSelector::initializeOldSelector() {
1062 qWarning("initializeOldSelector"); 1062 qWarning("initializeOldSelector");
1063 1063
1064 delete m_select; 1064 delete m_select;
1065 1065
1066 // we need to initialize but keep the selected mimetype 1066 // we need to initialize but keep the selected mimetype
1067 /* we default not to show close and new buttons */ 1067 /* we default not to show close and new buttons */
1068 QString mime = currentMimeType(); 1068 QString mime = currentMimeType();
1069 qWarning("MimeType " + mime ); 1069 qWarning("MimeType " + mime );
1070 m_select = new FileSelector( mime , 1070 m_select = new FileSelector( mime ,
1071 m_mainView, "fileselector", 1071 m_mainView, "fileselector",
1072 FALSE, FALSE); 1072 FALSE, FALSE);
1073 m_select->setCategorySelectVisible( FALSE ); 1073 m_select->setCategorySelectVisible( FALSE );
1074 m_select->setTypeComboVisible( FALSE ); 1074 m_select->setTypeComboVisible( FALSE );
1075 1075
1076 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), 1076 connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ),
1077 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); 1077 this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) );
1078 connect(m_select, SIGNAL(closeMe() ), 1078 connect(m_select, SIGNAL(closeMe() ),
1079 this, SIGNAL(closeMe() ) ); 1079 this, SIGNAL(closeMe() ) );
1080 //connect to close me and other signals as well 1080 //connect to close me and other signals as well
1081 m_mainView->setWidget( m_select ); 1081 m_mainView->setWidget( m_select );
1082} 1082}
1083/* 1083/*
1084 * initialize the listview 1084 * initialize the listview
1085 * we will call fillList 1085 * we will call fillList
1086 * setLister 1086 * setLister
1087 * with QString::null to get the default 1087 * with QString::null to get the default
1088 * setView with either Files or All Files 1088 * setView with either Files or All Files
1089 * depending on Extended 1089 * depending on Extended
1090 */ 1090 */
1091void OFileSelector::initializeView() { 1091void OFileSelector::initializeView() {
1092 setLister(QString::null); 1092 setLister(QString::null);
1093 fillList(); 1093 fillList();
1094 if (m_selector == Extended ) { 1094 if (m_selector == Extended ) {
1095 setView( tr("Files") ); 1095 setView( tr("List View") );
1096 }else{ 1096 }else{
1097 setView( tr("All Files") ); 1097 setView( tr("All List View") );
1098 } 1098 }
1099} 1099}
1100 1100