author | drw <drw> | 2004-04-06 16:00:07 (UTC) |
---|---|---|
committer | drw <drw> | 2004-04-06 16:00:07 (UTC) |
commit | 76406c20db58f6007539db80e0f7b27e7cc3e83f (patch) (unidiff) | |
tree | 0f19911a7ec644bb40e0e4650b312ddccffb5ad3 /noncore/apps/dagger/opentextdlg.cpp | |
parent | 31a82304d62ab4943c0926c35cce552e2164eaf4 (diff) | |
download | opie-76406c20db58f6007539db80e0f7b27e7cc3e83f.zip opie-76406c20db58f6007539db80e0f7b27e7cc3e83f.tar.gz opie-76406c20db58f6007539db80e0f7b27e7cc3e83f.tar.bz2 |
New Bible reader app
Diffstat (limited to 'noncore/apps/dagger/opentextdlg.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/dagger/opentextdlg.cpp | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/noncore/apps/dagger/opentextdlg.cpp b/noncore/apps/dagger/opentextdlg.cpp new file mode 100644 index 0000000..f7893a9 --- a/dev/null +++ b/noncore/apps/dagger/opentextdlg.cpp | |||
@@ -0,0 +1,98 @@ | |||
1 | /* | ||
2 | Dagger - A Bible study program utilizing the Sword library. | ||
3 | Copyright (c) 2004 Dan Williams <drw@handhelds.org> | ||
4 | |||
5 | This file is free software; you can redistribute it and/or modify it under | ||
6 | the terms of the GNU General Public License as published by the Free Software | ||
7 | Foundation; either version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This file is distributed in the hope that it will be useful, but WITHOUT ANY | ||
10 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
11 | PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License along with this | ||
14 | file; see the file COPYING. If not, write to the Free Software Foundation, Inc., | ||
15 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
16 | */ | ||
17 | |||
18 | #include "opentextdlg.h" | ||
19 | |||
20 | #include <qpe/resource.h> | ||
21 | |||
22 | #include <qheader.h> | ||
23 | #include <qlayout.h> | ||
24 | #include <qpixmap.h> | ||
25 | |||
26 | OpenTextDlg::OpenTextDlg( QWidget *parent, sword::SWMgr *swordMgr, QPixmap *bibleIcon, | ||
27 | QPixmap *commentaryIcon, QPixmap *lexiconIcon ) | ||
28 | : QDialog( parent, QString::null, true ) | ||
29 | , m_textList( this ) | ||
30 | { | ||
31 | setCaption( tr( "Open text" ) ); | ||
32 | |||
33 | QVBoxLayout *layout = new QVBoxLayout( this ); | ||
34 | layout->setMargin( 4 ); | ||
35 | layout->addWidget( &m_textList ); | ||
36 | |||
37 | m_textList.setRootIsDecorated( true ); | ||
38 | m_textList.addColumn( tr( "Icon" ),35 ); | ||
39 | m_textList.addColumn( tr( "Text" ) ); | ||
40 | m_textList.header()->hide(); | ||
41 | m_textList.setAllColumnsShowFocus( true ); | ||
42 | m_textList.setSorting( 1 ); | ||
43 | |||
44 | m_commentaries = new QListViewItem( &m_textList, QString::null, tr( "Commentaries" ) ); | ||
45 | m_commentaries->setPixmap( 0, *commentaryIcon ); | ||
46 | m_textList.insertItem( m_commentaries ); | ||
47 | m_lexicons = new QListViewItem( &m_textList, QString::null, tr( "Lexicons/Dictionaries" ) ); | ||
48 | m_lexicons->setPixmap( 0, *lexiconIcon ); | ||
49 | m_textList.insertItem( m_lexicons ); | ||
50 | m_bibles = new QListViewItem( &m_textList, QString::null, tr( "Biblical Texts" ) ); | ||
51 | m_bibles->setPixmap( 0, *bibleIcon ); | ||
52 | m_textList.insertItem( m_bibles ); | ||
53 | connect( &m_textList, SIGNAL(clicked(QListViewItem*)), this, SLOT(slotItemClicked(QListViewItem*)) ); | ||
54 | |||
55 | if ( swordMgr ) | ||
56 | { | ||
57 | sword::ModMap::iterator it; | ||
58 | QString type; | ||
59 | QPixmap *icon = 0x0; | ||
60 | QListViewItem *parent = 0x0; | ||
61 | |||
62 | for ( it = swordMgr->Modules.begin(); it != swordMgr->Modules.end(); it++ ) | ||
63 | { | ||
64 | type = it->second->Type(); | ||
65 | if ( type == "Biblical Texts" ) | ||
66 | { | ||
67 | icon = bibleIcon; | ||
68 | parent = m_bibles; | ||
69 | } | ||
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 | } | ||
83 | } | ||
84 | |||
85 | m_textList.sort(); | ||
86 | } | ||
87 | |||
88 | void OpenTextDlg::slotItemClicked( QListViewItem *item ) | ||
89 | { | ||
90 | if ( item == m_bibles || item == m_lexicons || item == m_commentaries ) | ||
91 | { | ||
92 | m_textList.clearSelection(); | ||
93 | if ( item->childCount() > 0 ) | ||
94 | { | ||
95 | item->setOpen( !item->isOpen() ); | ||
96 | } | ||
97 | } | ||
98 | } | ||