summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/dagger/opentextdlg.cpp35
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
@@ -1,98 +1,101 @@
1/* 1/*
2Dagger - A Bible study program utilizing the Sword library. 2Dagger - A Bible study program utilizing the Sword library.
3Copyright (c) 2004 Dan Williams <drw@handhelds.org> 3Copyright (c) 2004 Dan Williams <drw@handhelds.org>
4 4
5This file is free software; you can redistribute it and/or modify it under 5This file is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free Software 6the terms of the GNU General Public License as published by the Free Software
7Foundation; either version 2 of the License, or (at your option) any later version. 7Foundation; either version 2 of the License, or (at your option) any later version.
8 8
9This file is distributed in the hope that it will be useful, but WITHOUT ANY 9This file is distributed in the hope that it will be useful, but WITHOUT ANY
10WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11PARTICULAR PURPOSE. See the GNU General Public License for more details. 11PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 12
13You should have received a copy of the GNU General Public License along with this 13You should have received a copy of the GNU General Public License along with this
14file; see the file COPYING. If not, write to the Free Software Foundation, Inc., 14file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
1559 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 1559 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16*/ 16*/
17 17
18#include "opentextdlg.h" 18#include "opentextdlg.h"
19 19
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21 21
22#include <qheader.h> 22#include <qheader.h>
23#include <qlayout.h> 23#include <qlayout.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25 25
26OpenTextDlg::OpenTextDlg( QWidget *parent, sword::SWMgr *swordMgr, QPixmap *bibleIcon, 26OpenTextDlg::OpenTextDlg( QWidget *parent, sword::SWMgr *swordMgr, QPixmap *bibleIcon,
27 QPixmap *commentaryIcon, QPixmap *lexiconIcon ) 27 QPixmap *commentaryIcon, QPixmap *lexiconIcon )
28 : QDialog( parent, QString::null, true ) 28 : QDialog( parent, QString::null, true )
29 , m_textList( this ) 29 , m_textList( this )
30{ 30{
31 setCaption( tr( "Open text" ) ); 31 setCaption( tr( "Open text" ) );
32 32
33 QVBoxLayout *layout = new QVBoxLayout( this ); 33 QVBoxLayout *layout = new QVBoxLayout( this );
34 layout->setMargin( 4 ); 34 layout->setMargin( 4 );
35 layout->addWidget( &m_textList ); 35 layout->addWidget( &m_textList );
36 36
37 m_textList.setRootIsDecorated( true ); 37 m_textList.setRootIsDecorated( true );
38 m_textList.addColumn( tr( "Icon" ),35 ); 38 m_textList.addColumn( tr( "Icon" ),35 );
39 m_textList.addColumn( tr( "Text" ) ); 39 m_textList.addColumn( tr( "Text" ) );
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
88void OpenTextDlg::slotItemClicked( QListViewItem *item ) 91void 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}