author | drw <drw> | 2005-01-03 21:04:08 (UTC) |
---|---|---|
committer | drw <drw> | 2005-01-03 21:04:08 (UTC) |
commit | 3344a34b7c5aadeb82fc7151bb6b2677ebd2f732 (patch) (unidiff) | |
tree | 14fb68ead17d159a03f7935fb335068ef16917d5 | |
parent | 310c7dce0c9043f66725bc79449fe958a12ad459 (diff) | |
download | opie-3344a34b7c5aadeb82fc7151bb6b2677ebd2f732.zip opie-3344a34b7c5aadeb82fc7151bb6b2677ebd2f732.tar.gz opie-3344a34b7c5aadeb82fc7151bb6b2677ebd2f732.tar.bz2 |
Fix crash when trying to display open text dialog when there are no modules in configured directory
-rw-r--r-- | noncore/apps/dagger/opentextdlg.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/noncore/apps/dagger/opentextdlg.cpp b/noncore/apps/dagger/opentextdlg.cpp index f7893a9..8c94a4b 100644 --- a/noncore/apps/dagger/opentextdlg.cpp +++ b/noncore/apps/dagger/opentextdlg.cpp | |||
@@ -40,59 +40,62 @@ OpenTextDlg::OpenTextDlg( QWidget *parent, sword::SWMgr *swordMgr, QPixmap *bibl | |||
40 | m_textList.header()->hide(); | 40 | m_textList.header()->hide(); |
41 | m_textList.setAllColumnsShowFocus( true ); | 41 | m_textList.setAllColumnsShowFocus( true ); |
42 | m_textList.setSorting( 1 ); | 42 | m_textList.setSorting( 1 ); |
43 | 43 | ||
44 | m_commentaries = new QListViewItem( &m_textList, QString::null, tr( "Commentaries" ) ); | 44 | m_commentaries = new QListViewItem( &m_textList, QString::null, tr( "Commentaries" ) ); |
45 | m_commentaries->setPixmap( 0, *commentaryIcon ); | 45 | m_commentaries->setPixmap( 0, *commentaryIcon ); |
46 | m_textList.insertItem( m_commentaries ); | 46 | m_textList.insertItem( m_commentaries ); |
47 | m_lexicons = new QListViewItem( &m_textList, QString::null, tr( "Lexicons/Dictionaries" ) ); | 47 | m_lexicons = new QListViewItem( &m_textList, QString::null, tr( "Lexicons/Dictionaries" ) ); |
48 | m_lexicons->setPixmap( 0, *lexiconIcon ); | 48 | m_lexicons->setPixmap( 0, *lexiconIcon ); |
49 | m_textList.insertItem( m_lexicons ); | 49 | m_textList.insertItem( m_lexicons ); |
50 | m_bibles = new QListViewItem( &m_textList, QString::null, tr( "Biblical Texts" ) ); | 50 | m_bibles = new QListViewItem( &m_textList, QString::null, tr( "Biblical Texts" ) ); |
51 | m_bibles->setPixmap( 0, *bibleIcon ); | 51 | m_bibles->setPixmap( 0, *bibleIcon ); |
52 | m_textList.insertItem( m_bibles ); | 52 | m_textList.insertItem( m_bibles ); |
53 | connect( &m_textList, SIGNAL(clicked(QListViewItem*)), this, SLOT(slotItemClicked(QListViewItem*)) ); | 53 | connect( &m_textList, SIGNAL(clicked(QListViewItem*)), this, SLOT(slotItemClicked(QListViewItem*)) ); |
54 | 54 | ||
55 | if ( swordMgr ) | 55 | if ( swordMgr ) |
56 | { | 56 | { |
57 | sword::ModMap::iterator it; | 57 | sword::ModMap::iterator it; |
58 | QString type; | 58 | QString type; |
59 | QPixmap *icon = 0x0; | 59 | QPixmap *icon = 0x0; |
60 | QListViewItem *parent = 0x0; | 60 | QListViewItem *parent = 0x0; |
61 | 61 | ||
62 | for ( it = swordMgr->Modules.begin(); it != swordMgr->Modules.end(); it++ ) | 62 | for ( it = swordMgr->Modules.begin(); it != swordMgr->Modules.end(); it++ ) |
63 | { | 63 | { |
64 | type = it->second->Type(); | 64 | if ( it->second ) |
65 | if ( type == "Biblical Texts" ) | ||
66 | { | 65 | { |
67 | icon = bibleIcon; | 66 | type = it->second->Type(); |
68 | parent = m_bibles; | 67 | if ( type == "Biblical Texts" ) |
68 | { | ||
69 | icon = bibleIcon; | ||
70 | parent = m_bibles; | ||
71 | } | ||
72 | else if ( type == "Commentaries" ) | ||
73 | { | ||
74 | icon = commentaryIcon; | ||
75 | parent = m_commentaries; | ||
76 | } | ||
77 | else if ( type == "Lexicons / Dictionaries" ) | ||
78 | { | ||
79 | icon = lexiconIcon; | ||
80 | parent = m_lexicons; | ||
81 | } | ||
82 | |||
83 | parent->insertItem( new QListViewItem( parent, QString::null, it->first.c_str() ) ); | ||
69 | } | 84 | } |
70 | else if ( type == "Commentaries" ) | ||
71 | { | ||
72 | icon = commentaryIcon; | ||
73 | parent = m_commentaries; | ||
74 | } | ||
75 | else if ( type == "Lexicons / Dictionaries" ) | ||
76 | { | ||
77 | icon = lexiconIcon; | ||
78 | parent = m_lexicons; | ||
79 | } | ||
80 | |||
81 | parent->insertItem( new QListViewItem( parent, QString::null, it->first.c_str() ) ); | ||
82 | } | 85 | } |
83 | } | 86 | } |
84 | 87 | ||
85 | m_textList.sort(); | 88 | m_textList.sort(); |
86 | } | 89 | } |
87 | 90 | ||
88 | void OpenTextDlg::slotItemClicked( QListViewItem *item ) | 91 | void OpenTextDlg::slotItemClicked( QListViewItem *item ) |
89 | { | 92 | { |
90 | if ( item == m_bibles || item == m_lexicons || item == m_commentaries ) | 93 | if ( item == m_bibles || item == m_lexicons || item == m_commentaries ) |
91 | { | 94 | { |
92 | m_textList.clearSelection(); | 95 | m_textList.clearSelection(); |
93 | if ( item->childCount() > 0 ) | 96 | if ( item->childCount() > 0 ) |
94 | { | 97 | { |
95 | item->setOpen( !item->isOpen() ); | 98 | item->setOpen( !item->isOpen() ); |
96 | } | 99 | } |
97 | } | 100 | } |
98 | } | 101 | } |