25 files changed, 1946 insertions, 0 deletions
diff --git a/noncore/apps/dagger/.cvsignore b/noncore/apps/dagger/.cvsignore new file mode 100644 index 0000000..9f2b524 --- a/dev/null +++ b/noncore/apps/dagger/.cvsignore | |||
@@ -0,0 +1,5 @@ | |||
1 | Makefile* | ||
2 | moc* | ||
3 | .moc* | ||
4 | .obj | ||
5 | .moc | ||
diff --git a/noncore/apps/dagger/config.in b/noncore/apps/dagger/config.in new file mode 100644 index 0000000..eb2326b --- a/dev/null +++ b/noncore/apps/dagger/config.in | |||
@@ -0,0 +1,4 @@ | |||
1 | config DAGGER | ||
2 | boolean "opie-dagger (Bible study/reader application - requires libsword)" | ||
3 | default "n" | ||
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI | ||
diff --git a/noncore/apps/dagger/configuredlg.cpp b/noncore/apps/dagger/configuredlg.cpp new file mode 100644 index 0000000..e4dd60f --- a/dev/null +++ b/noncore/apps/dagger/configuredlg.cpp | |||
@@ -0,0 +1,139 @@ | |||
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 "configuredlg.h" | ||
19 | |||
20 | #include <qvbuttongroup.h> | ||
21 | #include <qlabel.h> | ||
22 | #include <qlayout.h> | ||
23 | |||
24 | ConfigureDlg::ConfigureDlg( QWidget *parent, const QString &swordPath, bool alwaysOpenNew, int numVerses, | ||
25 | bool disableBlanking, int copyFormat, const QFont *font ) | ||
26 | : QDialog( parent, QString::null, true ) | ||
27 | , m_tabs( this ) | ||
28 | { | ||
29 | setCaption( tr( "Configure Dagger" ) ); | ||
30 | |||
31 | QVBoxLayout *layout = new QVBoxLayout( this ); | ||
32 | layout->setMargin( 4 ); | ||
33 | layout->addWidget( &m_tabs ); | ||
34 | |||
35 | // General tab | ||
36 | QWidget *widget = new QWidget( this ); | ||
37 | QGridLayout *grid = new QGridLayout( widget, 1, 2, 4, 2 ); | ||
38 | grid->setRowStretch( 9, 5 ); | ||
39 | grid->setColStretch( 0, 2 ); | ||
40 | |||
41 | QLabel *label = new QLabel( tr( "Path where Sword modules are located:" ), widget ); | ||
42 | label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak ); | ||
43 | grid->addMultiCellWidget( label, 0, 0, 0, 1 ); | ||
44 | m_swordPath = new QLineEdit( swordPath, widget ); | ||
45 | grid->addMultiCellWidget( m_swordPath, 1, 1, 0, 1 ); | ||
46 | label = new QLabel( tr( "(Note: Dagger must be restarted for this option to take affect.)" ), widget ); | ||
47 | label->setAlignment( Qt::AlignHCenter | Qt::AlignTop | Qt::WordBreak ); | ||
48 | grid->addMultiCellWidget( label, 2, 2, 0, 1 ); | ||
49 | |||
50 | grid->addRowSpacing( 3, 15 ); | ||
51 | |||
52 | m_alwaysOpenNew = new QCheckBox( tr( "Always open texts in new window?" ), widget ); | ||
53 | m_alwaysOpenNew->setChecked( alwaysOpenNew ); | ||
54 | grid->addMultiCellWidget( m_alwaysOpenNew, 4, 4, 0, 1 ); | ||
55 | |||
56 | grid->addRowSpacing( 5, 15 ); | ||
57 | |||
58 | label = new QLabel( tr( "Number of verses to display at a time:" ), widget ); | ||
59 | label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak ); | ||
60 | grid->addWidget( label, 6, 0 ); | ||
61 | m_numVerses = new QSpinBox( 1, 20, 1, widget ); | ||
62 | m_numVerses->setValue( numVerses ); | ||
63 | grid->addWidget( m_numVerses, 6, 1 ); | ||
64 | |||
65 | grid->addRowSpacing( 7, 15 ); | ||
66 | |||
67 | m_disableScreenBlank = new QCheckBox( tr( "Disable automatic screen power-down?" ), widget ); | ||
68 | m_disableScreenBlank->setChecked( disableBlanking ); | ||
69 | grid->addMultiCellWidget( m_disableScreenBlank, 8, 8, 0, 1 ); | ||
70 | |||
71 | m_tabs.addTab( widget, "SettingsIcon", tr( "General" ) ); | ||
72 | |||
73 | // Copy tab | ||
74 | widget = new QWidget( this ); | ||
75 | layout = new QVBoxLayout( widget ); | ||
76 | layout->setMargin( 4 ); | ||
77 | |||
78 | QVButtonGroup *bg = new QVButtonGroup( tr( "Select copy format" ), widget ); | ||
79 | m_copyTextFull = new QRadioButton( tr( "\"Verse (Book cc:vv, text)\"" ), bg ); | ||
80 | connect( m_copyTextFull, SIGNAL(clicked()), this, SLOT(slotCopyFormatSelected()) ); | ||
81 | m_copyFull = new QRadioButton( tr( "\"Verse (Book cc:vv)\"" ), bg ); | ||
82 | connect( m_copyFull, SIGNAL(clicked()), this, SLOT(slotCopyFormatSelected()) ); | ||
83 | m_copyVerse = new QRadioButton( tr( "\"Verse\"" ), bg ); | ||
84 | connect( m_copyVerse, SIGNAL(clicked()), this, SLOT(slotCopyFormatSelected()) ); | ||
85 | m_copyKey = new QRadioButton( tr( "\"Book cc:vv\"" ), bg ); | ||
86 | connect( m_copyKey, SIGNAL(clicked()), this, SLOT(slotCopyFormatSelected()) ); | ||
87 | layout->addWidget( bg ); | ||
88 | |||
89 | layout->addSpacing( 15 ); | ||
90 | |||
91 | label = new QLabel( tr( "Example:" ), widget ); | ||
92 | label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak ); | ||
93 | layout->addWidget( label ); | ||
94 | |||
95 | layout->addSpacing( 15 ); | ||
96 | |||
97 | m_copyExample = new QLabel( widget ); | ||
98 | m_copyExample->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak ); | ||
99 | layout->addWidget( m_copyExample ); | ||
100 | |||
101 | if ( copyFormat == 0 ) | ||
102 | m_copyTextFull->animateClick(); | ||
103 | else if ( copyFormat == 1 ) | ||
104 | m_copyFull->animateClick(); | ||
105 | else if ( copyFormat == 2 ) | ||
106 | m_copyVerse->animateClick(); | ||
107 | else if ( copyFormat == 3 ) | ||
108 | m_copyKey->animateClick(); | ||
109 | |||
110 | layout->addStretch(); | ||
111 | |||
112 | m_tabs.addTab( widget, "copy", tr( "Copy" ) ); | ||
113 | |||
114 | // Font tab | ||
115 | m_font = new Opie::Ui::OFontSelector( true, this ); | ||
116 | if ( font ) | ||
117 | m_font->setSelectedFont( *font ); | ||
118 | m_tabs.addTab( m_font, "font", tr( "Font" ) ); | ||
119 | |||
120 | m_tabs.setCurrentTab( tr( "General" ) ); | ||
121 | } | ||
122 | |||
123 | void ConfigureDlg::slotCopyFormatSelected() | ||
124 | { | ||
125 | const QObject *option = sender(); | ||
126 | |||
127 | QString text = tr( "KJV" ); | ||
128 | QString verse = tr( "In the beginning God created the heaven and the earth." ); | ||
129 | QString key = tr( "Gen 1:1" ); | ||
130 | |||
131 | if ( option == m_copyTextFull && m_copyTextFull->isChecked() ) | ||
132 | m_copyExample->setText( QString( "%1 (%2, %3)" ).arg( verse ).arg( key ).arg( text ) ); | ||
133 | else if ( option == m_copyFull && m_copyFull->isChecked() ) | ||
134 | m_copyExample->setText( QString( "%1 (%2)" ).arg( verse ).arg( key ) ); | ||
135 | else if ( option == m_copyVerse && m_copyVerse->isChecked() ) | ||
136 | m_copyExample->setText( verse ); | ||
137 | else if ( option == m_copyKey && m_copyKey->isChecked() ) | ||
138 | m_copyExample->setText( key ); | ||
139 | } | ||
diff --git a/noncore/apps/dagger/configuredlg.h b/noncore/apps/dagger/configuredlg.h new file mode 100644 index 0000000..a91da12 --- a/dev/null +++ b/noncore/apps/dagger/configuredlg.h | |||
@@ -0,0 +1,75 @@ | |||
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 | #ifndef CONFIGUREDLG_H | ||
19 | #define CONFIGUREDLG_H | ||
20 | |||
21 | #include <opie2/ofontselector.h> | ||
22 | #include <opie2/otabwidget.h> | ||
23 | |||
24 | #include <qcheckbox.h> | ||
25 | #include <qdialog.h> | ||
26 | #include <qlineedit.h> | ||
27 | #include <qradiobutton.h> | ||
28 | #include <qspinbox.h> | ||
29 | |||
30 | class QLabel; | ||
31 | |||
32 | class ConfigureDlg : public QDialog | ||
33 | { | ||
34 | Q_OBJECT | ||
35 | |||
36 | public: | ||
37 | ConfigureDlg( QWidget *parent = 0x0, const QString &swordPath = 0x0, bool alwaysOpenNew = true, | ||
38 | int numVerses = 5, bool disableBlanking = false, int copyFormat = 0, const QFont *font = 0x0 ); | ||
39 | |||
40 | QString swordPath() { return m_swordPath->text(); } | ||
41 | bool alwaysOpenNew() { return m_alwaysOpenNew->isChecked(); } | ||
42 | int numVerses() { return m_numVerses->value(); } | ||
43 | bool screenBlank() { return m_disableScreenBlank->isChecked(); } | ||
44 | int copyFormat() { if ( m_copyFull->isChecked() ) | ||
45 | return 1; | ||
46 | else if ( m_copyVerse->isChecked() ) | ||
47 | return 2; | ||
48 | else if ( m_copyKey->isChecked() ) | ||
49 | return 3; | ||
50 | else | ||
51 | return 0; } | ||
52 | QFont selectedFont() { return m_font->selectedFont(); } | ||
53 | |||
54 | private: | ||
55 | Opie::Ui::OTabWidget m_tabs; // Main widget | ||
56 | Opie::Ui::OFontSelector *m_font; // Font selection widget | ||
57 | |||
58 | // General tab's UI controls | ||
59 | QLineEdit *m_swordPath; // Contains path to Sword modules | ||
60 | QCheckBox *m_alwaysOpenNew; // Indicates whether to always open modules in a new tab | ||
61 | QSpinBox *m_numVerses; // Contains number of verses to display for Bible modules | ||
62 | QCheckBox *m_disableScreenBlank; // Indicates whether to disable automatic screen blanking | ||
63 | |||
64 | // Copy tab's UI controls | ||
65 | QRadioButton *m_copyTextFull; // Verse (Text, Book cc:vv) | ||
66 | QRadioButton *m_copyFull; // Verse (Book cc:vv) | ||
67 | QRadioButton *m_copyVerse; // Verse | ||
68 | QRadioButton *m_copyKey; // Book cc:vv | ||
69 | QLabel *m_copyExample; // Text of copy format example | ||
70 | |||
71 | private slots: | ||
72 | void slotCopyFormatSelected(); | ||
73 | }; | ||
74 | |||
75 | #endif | ||
diff --git a/noncore/apps/dagger/dagger.pro b/noncore/apps/dagger/dagger.pro new file mode 100644 index 0000000..4038f25 --- a/dev/null +++ b/noncore/apps/dagger/dagger.pro | |||
@@ -0,0 +1,24 @@ | |||
1 | CONFIG = qt warn_on release quick-app | ||
2 | |||
3 | SOURCES = mainwindow.cpp \ | ||
4 | navbar.cpp \ | ||
5 | searchbar.cpp \ | ||
6 | opentextdlg.cpp \ | ||
7 | configuredlg.cpp \ | ||
8 | textwidget.cpp \ | ||
9 | main.cpp | ||
10 | HEADERS = mainwindow.h \ | ||
11 | navbar.h \ | ||
12 | searchbar.h \ | ||
13 | opentextdlg.h \ | ||
14 | configuredlg.h \ | ||
15 | textwidget.h \ | ||
16 | swordoptionlist.h | ||
17 | |||
18 | TARGET = dagger | ||
19 | INCLUDEPATH += $(OPIEDIR)/include | ||
20 | DEPENDPATH += $(OPIEDIR)/include | ||
21 | LIBS += -lopiecore2 -lopieui2 -lqpe -lsword | ||
22 | |||
23 | include ( $(OPIEDIR)/include.pro ) | ||
24 | |||
diff --git a/noncore/apps/dagger/main.cpp b/noncore/apps/dagger/main.cpp new file mode 100644 index 0000000..1c7bc41 --- a/dev/null +++ b/noncore/apps/dagger/main.cpp | |||
@@ -0,0 +1,22 @@ | |||
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 "mainwindow.h" | ||
19 | |||
20 | #include <opie2/oapplicationfactory.h> | ||
21 | |||
22 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<MainWindow> ) | ||
diff --git a/noncore/apps/dagger/mainwindow.cpp b/noncore/apps/dagger/mainwindow.cpp new file mode 100644 index 0000000..ace8f36 --- a/dev/null +++ b/noncore/apps/dagger/mainwindow.cpp | |||
@@ -0,0 +1,710 @@ | |||
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 "mainwindow.h" | ||
19 | #include "navbar.h" | ||
20 | #include "searchbar.h" | ||
21 | #include "opentextdlg.h" | ||
22 | #include "configuredlg.h" | ||
23 | #include "textwidget.h" | ||
24 | |||
25 | #include <opie2/odebug.h> | ||
26 | |||
27 | #include <qpe/qcopenvelope_qws.h> | ||
28 | #include <qpe/qpeapplication.h> | ||
29 | #include <qpe/resource.h> | ||
30 | |||
31 | #include <qaction.h> | ||
32 | #include <qclipboard.h> | ||
33 | #include <qmenubar.h> | ||
34 | #include <qobjectlist.h> | ||
35 | #include <qpopupmenu.h> | ||
36 | #include <qtimer.h> | ||
37 | #include <qtoolbar.h> | ||
38 | |||
39 | #include <markupfiltmgr.h> | ||
40 | |||
41 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) | ||
42 | : QMainWindow( parent, name, WStyle_ContextHelp ) | ||
43 | , m_config( "dagger" ) | ||
44 | , m_tabs( this ) | ||
45 | , m_autoScrollTimer( this ) | ||
46 | { | ||
47 | // Initialize sword library manager | ||
48 | m_config.setGroup( "Sword" ); | ||
49 | m_modulePath = m_config.readEntry( "ModPath", "/usr/local/share/sword" ); | ||
50 | m_swordMgr = new sword::SWMgr( m_modulePath.latin1(), true, | ||
51 | new sword::MarkupFilterMgr( sword::FMT_HTMLHREF ) ); | ||
52 | |||
53 | // Retrieve list of available Sword module options (e.g. footnotes, Strong's numbers, etc.) | ||
54 | sword::OptionsList swordOpts = m_swordMgr->getGlobalOptions(); | ||
55 | for ( sword::OptionsList::iterator it = swordOpts.begin(); it != swordOpts.end(); it++ ) | ||
56 | m_actionSwordOpts.append( new QAction( (*it).c_str(), QString::null, 0, this, 0 ) ); | ||
57 | m_actionSwordOpts.sort(); | ||
58 | |||
59 | // Initialize user interface | ||
60 | setCaption( tr( "Dagger" ) ); | ||
61 | initUI(); | ||
62 | |||
63 | connect( &m_tabs, SIGNAL(currentChanged(QWidget *)), this, SLOT( slotTextDisplayed(QWidget *)) ); | ||
64 | connect( &m_autoScrollTimer, SIGNAL(timeout()), this, SLOT(slotNavNextVerse()) ); | ||
65 | |||
66 | m_bibleIcon = new QPixmap( Resource::loadPixmap( "dagger/bibletext" ) ); | ||
67 | m_commentaryIcon = new QPixmap( Resource::loadPixmap( "dagger/commentary" ) ); | ||
68 | m_lexiconIcon = new QPixmap( Resource::loadPixmap( "dagger/lexicon" ) ); | ||
69 | |||
70 | // Load initial configuration | ||
71 | QTimer::singleShot( 100, this, SLOT( initConfig() ) ); | ||
72 | } | ||
73 | |||
74 | MainWindow::~MainWindow() | ||
75 | { | ||
76 | // Save Sword options | ||
77 | m_config.setGroup( "Sword" ); | ||
78 | m_config.writeEntry( "ModPath", m_modulePath ); | ||
79 | |||
80 | for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) | ||
81 | m_config.writeEntry( a->text(), a->isOn() ); | ||
82 | |||
83 | // Save configuration options | ||
84 | m_config.setGroup( "Config" ); | ||
85 | m_config.writeEntry( "AlwaysOpenNew", m_alwaysOpenNew ); | ||
86 | m_config.writeEntry( "AutoScroll", m_navToolbar->autoScrollRate() ); | ||
87 | m_config.writeEntry( "DisableScreenBlanking", m_disableScreenBlank ); | ||
88 | m_config.writeEntry( "CopyFormat", m_copyFormat ); | ||
89 | m_config.writeEntry( "NavBar", m_actionViewNavToolbar->isOn() ); | ||
90 | m_config.writeEntry( "NumVerses", m_numVerses ); | ||
91 | m_config.writeEntry( "SearchBar", m_actionViewSearchToolbar->isOn() ); | ||
92 | |||
93 | // Save text font | ||
94 | m_config.setGroup( "Font"); | ||
95 | m_config.writeEntry( "Family", m_textFont.family() ); | ||
96 | m_config.writeEntry( "Italic", m_textFont.italic() ); | ||
97 | m_config.writeEntry( "Size", m_textFont.pointSize() ); | ||
98 | m_config.writeEntry( "Weight", m_textFont.weight() ); | ||
99 | |||
100 | // Save bookmarks | ||
101 | m_config.setGroup( "Bookmarks"); | ||
102 | m_config.clearGroup(); | ||
103 | int index = 3; | ||
104 | int id = m_bookmarkMenu->idAt( index ); | ||
105 | while ( id != -1 ) | ||
106 | { | ||
107 | QString bookmark = m_bookmarkMenu->text( id ); | ||
108 | int pos = bookmark.find( " (" ); | ||
109 | QString key = bookmark.left( pos ); | ||
110 | pos += 2; | ||
111 | QString module = bookmark.mid( pos, bookmark.find( ")", pos ) - pos ); | ||
112 | QString modkey; | ||
113 | modkey.sprintf( "%s/%s", module.latin1(), key.latin1() ); | ||
114 | m_config.writeEntry( QString::number( index - 2 ), modkey ); | ||
115 | |||
116 | ++index; | ||
117 | id = m_bookmarkMenu->idAt( index ); | ||
118 | } | ||
119 | |||
120 | // Save opened modules | ||
121 | m_config.setGroup( "Session"); | ||
122 | m_config.clearGroup(); | ||
123 | QObjectList *childlist = queryList( "TextWidget" ); | ||
124 | QObjectListIt it( *childlist ); | ||
125 | TextWidget *module; | ||
126 | int count = 1; | ||
127 | while ( ( module = reinterpret_cast<TextWidget *>(it.current()) ) != 0 ) | ||
128 | { | ||
129 | QString modkey; | ||
130 | modkey.sprintf( "%s/%s", module->getModuleName().latin1(), module->getAbbrevKey().latin1() ); | ||
131 | m_config.writeEntry( QString::number( count ), modkey ); | ||
132 | ++count; | ||
133 | ++it; | ||
134 | } | ||
135 | } | ||
136 | |||
137 | bool MainWindow::eventFilter( QObject *obj, QEvent *event ) | ||
138 | { | ||
139 | if ( event->type() == QEvent::KeyPress ) | ||
140 | { | ||
141 | QKeyEvent *keyev = reinterpret_cast<QKeyEvent *>(event); | ||
142 | if ( keyev->key() == Key_Up ) | ||
143 | { | ||
144 | slotNavPrevVerse(); | ||
145 | return true; | ||
146 | } | ||
147 | else if ( keyev->key() == Key_Down ) | ||
148 | { | ||
149 | slotNavNextVerse(); | ||
150 | return true; | ||
151 | } | ||
152 | } | ||
153 | |||
154 | return QWidget::eventFilter( obj, event ); | ||
155 | } | ||
156 | |||
157 | void MainWindow::initUI() | ||
158 | { | ||
159 | setCentralWidget( &m_tabs ); | ||
160 | m_tabs.installEventFilter( this ); | ||
161 | |||
162 | setToolBarsMovable( false ); | ||
163 | m_barDock = new QToolBar( this ); | ||
164 | m_barDock->setHorizontalStretchable( true ); | ||
165 | |||
166 | m_menuBar = new QMenuBar( m_barDock ); | ||
167 | m_menuBar->setMargin( 0 ); | ||
168 | |||
169 | // Allocate toolbars | ||
170 | m_navToolbar = new NavBar( this ); | ||
171 | m_navToolbar->navBtnsEnable( false ); | ||
172 | connect( m_navToolbar, SIGNAL(prevChapter()), this, SLOT(slotNavPrevChapter()) ); | ||
173 | connect( m_navToolbar, SIGNAL(prevVerse()), this, SLOT(slotNavPrevVerse()) ); | ||
174 | connect( m_navToolbar, SIGNAL(keyChanged(const QString &)), this, SLOT(slotNavKeyChanged(const QString &)) ); | ||
175 | connect( m_navToolbar, SIGNAL(nextVerse()), this, SLOT(slotNavNextVerse()) ); | ||
176 | connect( m_navToolbar, SIGNAL(nextChapter()), this, SLOT(slotNavNextChapter()) ); | ||
177 | connect( m_navToolbar, SIGNAL(autoScroll(bool)), this, SLOT(slotNavAutoScroll(bool)) ); | ||
178 | connect( m_navToolbar, SIGNAL(scrollRateChanged(int)), this, SLOT(slotNavScrollRateChanged(int)) ); | ||
179 | |||
180 | m_searchToolbar = new SearchBar( this ); | ||
181 | connect( m_searchToolbar, SIGNAL(sigResultClicked(const QString &)), this, SLOT(slotSearchResultClicked(const QString &)) ); | ||
182 | |||
183 | // Text menu | ||
184 | QPopupMenu *popup = new QPopupMenu( this ); | ||
185 | |||
186 | QAction *a = new QAction( tr( "Open..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | ||
187 | connect( a, SIGNAL(activated()), this, SLOT(slotTextOpen()) ); | ||
188 | a->addTo( popup ); | ||
189 | |||
190 | m_actionTextClose = new QAction( tr( "Close" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | ||
191 | connect( m_actionTextClose, SIGNAL(activated()), this, SLOT(slotTextClose()) ); | ||
192 | m_actionTextClose->addTo( popup ); | ||
193 | |||
194 | popup->insertSeparator(); | ||
195 | |||
196 | // TODO - need to implent | ||
197 | a = new QAction( tr( "Install..." ), Resource::loadPixmap( "install" ), QString::null, 0, this, 0 ); | ||
198 | a->setEnabled( false ); | ||
199 | connect( a, SIGNAL(activated()), this, SLOT(slotTextInstall()) ); | ||
200 | a->addTo( popup ); | ||
201 | |||
202 | m_menuBar->insertItem( tr( "Text" ), popup ); | ||
203 | |||
204 | // Edit menu | ||
205 | popup = new QPopupMenu( this ); | ||
206 | |||
207 | m_actionEditCopy = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 ); | ||
208 | connect( m_actionEditCopy, SIGNAL(activated()), this, SLOT(slotEditCopy()) ); | ||
209 | m_actionEditCopy->addTo( popup ); | ||
210 | |||
211 | popup->insertSeparator(); | ||
212 | |||
213 | a = new QAction( tr( "Configure..." ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | ||
214 | connect( a, SIGNAL(activated()), this, SLOT(slotEditConfigure()) ); | ||
215 | a->addTo( popup ); | ||
216 | |||
217 | m_menuBar->insertItem( tr( "Edit" ), popup ); | ||
218 | |||
219 | // Bookmark menu | ||
220 | m_bookmarkMenu = new QPopupMenu( this ); | ||
221 | |||
222 | m_actionBookmarkAdd = new QAction( tr( "Add" ), Resource::loadPixmap( "dagger/bookmarkadd" ), QString::null, 0, this, 0 ); | ||
223 | connect( m_actionBookmarkAdd, SIGNAL(activated()), this, SLOT(slotBookmarkAdd()) ); | ||
224 | m_actionBookmarkAdd->addTo( m_bookmarkMenu ); | ||
225 | |||
226 | m_actionBookmarkRemove = new QAction( tr( "Remove" ), Resource::loadPixmap( "dagger/bookmarkremove" ), QString::null, 0, this, 0 ); | ||
227 | connect( m_actionBookmarkRemove, SIGNAL(activated()), this, SLOT(slotBookmarkRemove()) ); | ||
228 | m_actionBookmarkRemove->addTo( m_bookmarkMenu ); | ||
229 | |||
230 | m_bookmarkMenu->insertSeparator(); | ||
231 | |||
232 | m_menuBar->insertItem( tr( "Bookmark" ), m_bookmarkMenu ); | ||
233 | |||
234 | // View menu | ||
235 | popup = new QPopupMenu( this ); | ||
236 | |||
237 | // Retrieve list of available Sword module options (e.g. footnotes, Strong's numbers, etc.) | ||
238 | for ( a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) | ||
239 | { | ||
240 | a->setToggleAction( true ); | ||
241 | connect( a, SIGNAL(toggled(bool)), this, SLOT(slotViewSwordOption(bool)) ); | ||
242 | a->addTo( popup ); | ||
243 | } | ||
244 | |||
245 | popup->insertSeparator(); | ||
246 | |||
247 | m_actionViewNavToolbar = new QAction( tr( "Navigation toolbar" ), QString::null, 0, this, 0 ); | ||
248 | m_actionViewNavToolbar->setToggleAction( true ); | ||
249 | connect( m_actionViewNavToolbar, SIGNAL(toggled(bool)), this, SLOT(slotViewNavToolbar(bool)) ); | ||
250 | m_actionViewNavToolbar->addTo( popup ); | ||
251 | |||
252 | m_actionViewSearchToolbar = new QAction( tr( "Search toolbar" ), QString::null, 0, this, 0 ); | ||
253 | m_actionViewSearchToolbar->setToggleAction( true ); | ||
254 | connect( m_actionViewSearchToolbar, SIGNAL(toggled(bool)), this, SLOT(slotViewSearchToolbar(bool)) ); | ||
255 | m_actionViewSearchToolbar->addTo( popup ); | ||
256 | |||
257 | m_menuBar->insertItem( tr( "View" ), popup ); | ||
258 | } | ||
259 | |||
260 | void MainWindow::openModule( const QString &modulename, const QString &key ) | ||
261 | { | ||
262 | sword::SWModule *module = m_swordMgr->Modules[ modulename.latin1() ]; | ||
263 | if ( module ) | ||
264 | { | ||
265 | TextWidget *tw = 0x0; | ||
266 | |||
267 | if ( !m_alwaysOpenNew ) | ||
268 | { | ||
269 | // Try to find if the module is already opened, if so will use that TextWidget | ||
270 | QObjectList *childlist = queryList( "TextWidget" ); | ||
271 | QObjectListIt it( *childlist ); | ||
272 | while ( ( tw = reinterpret_cast<TextWidget *>(it.current()) ) != 0 && | ||
273 | tw->getModuleName() != modulename ) | ||
274 | ++it; | ||
275 | if ( tw && tw->getModuleName() == modulename ) | ||
276 | { | ||
277 | // Set key if one is present | ||
278 | if ( !key.isNull() ) | ||
279 | tw->setKey( key ); | ||
280 | |||
281 | // Raise tab | ||
282 | m_tabs.setCurrentTab( tw ); | ||
283 | } | ||
284 | } | ||
285 | |||
286 | if ( m_alwaysOpenNew || !tw ) | ||
287 | { | ||
288 | // Open module in new tab | ||
289 | QString icon; | ||
290 | QString type = module->Type(); | ||
291 | |||
292 | if ( type == "Biblical Texts" ) | ||
293 | icon = "dagger/bibletext"; | ||
294 | else if ( type == "Commentaries" ) | ||
295 | icon = "dagger/commentary"; | ||
296 | else if ( type == "Lexicons / Dictionaries" ) | ||
297 | icon = "dagger/lexicon"; | ||
298 | |||
299 | tw = new TextWidget( this, module, m_numVerses, &m_textFont ); | ||
300 | connect( tw, SIGNAL(sigRefClicked(const QString &)), | ||
301 | this, SLOT(slotTextRefClicked(const QString &)) ); | ||
302 | connect( this, SIGNAL(sigNumVersesChanged(int)), tw, SLOT(slotNumVersesChanged(int)) ); | ||
303 | connect( this, SIGNAL(sigFontChanged(const QFont *)), tw, SLOT(slotFontChanged(const QFont *)) ); | ||
304 | connect( this, SIGNAL(sigOptionChanged()), tw, SLOT(slotOptionChanged()) ); | ||
305 | |||
306 | m_tabs.addTab( tw, icon, modulename ); | ||
307 | |||
308 | m_actionTextClose->setEnabled( true ); | ||
309 | m_actionEditCopy->setEnabled( true ); | ||
310 | m_actionBookmarkAdd->setEnabled( true ); | ||
311 | |||
312 | // Set key if one is present | ||
313 | if ( !key.isNull() ) | ||
314 | tw->setKey( key ); | ||
315 | } | ||
316 | } | ||
317 | } | ||
318 | |||
319 | int MainWindow::findBookmark( const QString &bookmark ) | ||
320 | { | ||
321 | int index = 3; | ||
322 | int id = m_bookmarkMenu->idAt( index ); | ||
323 | while ( ( id != -1 ) && ( m_bookmarkMenu->text( id ) != bookmark ) ) | ||
324 | { | ||
325 | ++index; | ||
326 | id = m_bookmarkMenu->idAt( index ); | ||
327 | } | ||
328 | |||
329 | return id; | ||
330 | } | ||
331 | |||
332 | void MainWindow::enableScreenBlanking( bool enable ) | ||
333 | { | ||
334 | enable ? QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable | ||
335 | : QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable; | ||
336 | } | ||
337 | |||
338 | void MainWindow::initConfig() | ||
339 | { | ||
340 | bool show; | ||
341 | |||
342 | m_config.setGroup( "Sword" ); | ||
343 | for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() ) | ||
344 | { | ||
345 | show = m_config.readBoolEntry( a->text(), false ); | ||
346 | a->setOn( show ); | ||
347 | m_swordMgr->setGlobalOption ( a->text(), show ? "On" : "Off" ); | ||
348 | } | ||
349 | |||
350 | // Display/hide toolbars based on last run | ||
351 | m_config.setGroup( "Config" ); | ||
352 | |||
353 | m_alwaysOpenNew = m_config.readBoolEntry( "AlwaysOpenNew", false ); | ||
354 | m_navToolbar->setAutoScrollRate( m_config.readNumEntry( "AutoScroll", 50 ) ); | ||
355 | m_disableScreenBlank = m_config.readBoolEntry( "DisableScreenBlanking", false ); | ||
356 | enableScreenBlanking( !m_disableScreenBlank ); | ||
357 | m_copyFormat = m_config.readNumEntry( "CopyFormat", 0 ); | ||
358 | |||
359 | show = m_config.readBoolEntry( "NavBar", false ); | ||
360 | m_actionViewNavToolbar->setOn( show ); | ||
361 | slotViewNavToolbar( show ); | ||
362 | |||
363 | m_numVerses = m_config.readNumEntry( "NumVerses", 5 ); | ||
364 | |||
365 | show = m_config.readBoolEntry( "SearchBar", false ); | ||
366 | m_actionViewSearchToolbar->setOn( show ); | ||
367 | slotViewSearchToolbar( show ); | ||
368 | |||
369 | // Set text font | ||
370 | m_config.setGroup( "Font" ); | ||
371 | QString fontFamily = m_config.readEntry( "Family", QString::null ); | ||
372 | !fontFamily.isNull() ? m_textFont = QFont( fontFamily, | ||
373 | m_config.readNumEntry( "Size", -1 ), | ||
374 | m_config.readNumEntry( "Weight", QFont::Normal ), | ||
375 | m_config.readBoolEntry( "Italic", false ) ) | ||
376 | : m_textFont = font(); // If font is not configured, set to default widget font | ||
377 | |||
378 | // Load bookmarks | ||
379 | m_config.setGroup( "Bookmarks"); | ||
380 | int count = 1; | ||
381 | QString key = m_config.readEntry( QString::number( count ), QString::null ); | ||
382 | while ( !key.isNull() ) | ||
383 | { | ||
384 | int pos = key.find( "/" ); | ||
385 | if ( pos > -1 ) | ||
386 | { | ||
387 | QString bookmark; | ||
388 | bookmark.sprintf( "%s (%s)", key.right( key.length() - ( pos + 1 ) ).latin1(), | ||
389 | key.left( pos ).latin1() ); | ||
390 | QAction *a = new QAction( bookmark, QString::null, 0, this, 0 ); | ||
391 | a->addTo( m_bookmarkMenu ); | ||
392 | connect( a, SIGNAL(activated()), this, SLOT(slotBookmarkSelected()) ); | ||
393 | } | ||
394 | |||
395 | ++count; | ||
396 | key = m_config.readEntry( QString::number( count ), QString::null ); | ||
397 | } | ||
398 | m_actionBookmarkRemove->setEnabled( count > 1 ); | ||
399 | |||
400 | // Load opened modules | ||
401 | m_config.setGroup( "Session"); | ||
402 | QString first; | ||
403 | count = 1; | ||
404 | key = m_config.readEntry( QString::number( count ), QString::null ); | ||
405 | while ( !key.isNull() ) | ||
406 | { | ||
407 | int pos = key.find( "/" ); | ||
408 | if ( pos > -1 ) | ||
409 | { | ||
410 | if ( count == 1 ) | ||
411 | first = key.left( pos ); | ||
412 | openModule( key.left( pos ), key.right( key.length() - ( pos + 1 ) ) ); | ||
413 | } | ||
414 | |||
415 | ++count; | ||
416 | key = m_config.readEntry( QString::number( count ), QString::null ); | ||
417 | } | ||
418 | m_tabs.setCurrentTab( first ); | ||
419 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | ||
420 | if ( text ) | ||
421 | { | ||
422 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); | ||
423 | m_navToolbar->setKey( text->getAbbrevKey() ); | ||
424 | } | ||
425 | m_actionTextClose->setEnabled( count > 1 ); | ||
426 | m_actionEditCopy->setEnabled( count > 1 ); | ||
427 | } | ||
428 | |||
429 | void MainWindow::slotTextDisplayed( QWidget *textWidget ) | ||
430 | { | ||
431 | TextWidget *text = reinterpret_cast<TextWidget *>(textWidget); | ||
432 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); | ||
433 | |||
434 | m_navToolbar->setKey( text->getAbbrevKey() ); | ||
435 | m_navToolbar->navBtnsEnable( text->isBibleText() ); | ||
436 | |||
437 | m_searchToolbar->setCurrModule( text ); | ||
438 | } | ||
439 | |||
440 | void MainWindow::slotTextOpen() | ||
441 | { | ||
442 | OpenTextDlg dlg( this, m_swordMgr, m_bibleIcon, m_commentaryIcon, m_lexiconIcon ); | ||
443 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | ||
444 | { | ||
445 | openModule( dlg.selectedText() ); | ||
446 | } | ||
447 | } | ||
448 | |||
449 | void MainWindow::slotTextClose() | ||
450 | { | ||
451 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | ||
452 | if ( text ) | ||
453 | { | ||
454 | m_tabs.removePage( text ); | ||
455 | delete text; | ||
456 | |||
457 | // If no other modules are open, disable appropriate UI items | ||
458 | if ( !m_tabs.currentWidget() ) | ||
459 | { | ||
460 | m_navToolbar->navBtnsEnable( false ); | ||
461 | m_navToolbar->setKey( QString::null ); | ||
462 | m_searchToolbar->setCurrModule( 0x0 ); | ||
463 | m_actionTextClose->setEnabled( false ); | ||
464 | m_actionEditCopy->setEnabled( false ); | ||
465 | m_actionBookmarkAdd->setEnabled( false ); | ||
466 | m_actionBookmarkRemove->setEnabled( false ); | ||
467 | } | ||
468 | } | ||
469 | } | ||
470 | |||
471 | void MainWindow::slotTextInstall() | ||
472 | { | ||
473 | } | ||
474 | |||
475 | void MainWindow::slotEditCopy() | ||
476 | { | ||
477 | TextWidget *currModule = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | ||
478 | if ( currModule ) | ||
479 | { | ||
480 | QString text; | ||
481 | |||
482 | switch( m_copyFormat ) | ||
483 | { | ||
484 | case 0: text.sprintf( "%s (%s, %s)", currModule->getCurrVerse().latin1(), | ||
485 | currModule->getAbbrevKey().latin1(), | ||
486 | currModule->getModuleName().latin1() ); | ||
487 | break; | ||
488 | case 1: text.sprintf( "%s (%s)", currModule->getCurrVerse().latin1(), | ||
489 | currModule->getAbbrevKey().latin1() ); | ||
490 | break; | ||
491 | case 2: text = currModule->getCurrVerse(); | ||
492 | break; | ||
493 | case 3: text = currModule->getAbbrevKey(); | ||
494 | break; | ||
495 | default: text = QString::null; | ||
496 | }; | ||
497 | |||
498 | if ( !text.isNull() ) | ||
499 | QPEApplication::clipboard()->setText( text ); | ||
500 | } | ||
501 | } | ||
502 | |||
503 | void MainWindow::slotEditConfigure() | ||
504 | { | ||
505 | ConfigureDlg dlg( this, m_modulePath, m_alwaysOpenNew, m_numVerses, m_disableScreenBlank, m_copyFormat, | ||
506 | &m_textFont ); | ||
507 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | ||
508 | { | ||
509 | m_modulePath = dlg.swordPath(); | ||
510 | m_alwaysOpenNew = dlg.alwaysOpenNew(); | ||
511 | if ( dlg.numVerses() != m_numVerses ) | ||
512 | { | ||
513 | m_numVerses = dlg.numVerses(); | ||
514 | emit sigNumVersesChanged( m_numVerses ); | ||
515 | } | ||
516 | m_disableScreenBlank = dlg.screenBlank(); | ||
517 | enableScreenBlanking( !m_disableScreenBlank ); | ||
518 | m_copyFormat = dlg.copyFormat(); | ||
519 | m_textFont = dlg.selectedFont(); | ||
520 | emit sigFontChanged( &m_textFont ); | ||
521 | } | ||
522 | } | ||
523 | |||
524 | void MainWindow::slotBookmarkAdd() | ||
525 | { | ||
526 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | ||
527 | if ( text ) | ||
528 | { | ||
529 | // See if bookmark doesn't already exists | ||
530 | QString bookmark = text->getFullKey(); | ||
531 | int menuId = findBookmark( bookmark ); | ||
532 | if ( menuId == -1 ) | ||
533 | { | ||
534 | // Bookmark not found, add | ||
535 | QAction *a = new QAction( bookmark, QString::null, 0, this, 0 ); | ||
536 | a->addTo( m_bookmarkMenu ); | ||
537 | connect( a, SIGNAL(activated()), this, SLOT(slotBookmarkSelected()) ); | ||
538 | |||
539 | // Make sure remove option is enabled | ||
540 | m_actionBookmarkRemove->setEnabled( true ); | ||
541 | |||
542 | } | ||
543 | } | ||
544 | } | ||
545 | |||
546 | void MainWindow::slotBookmarkRemove() | ||
547 | { | ||
548 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | ||
549 | if ( text ) | ||
550 | { | ||
551 | // See if bookmark exists for current module key | ||
552 | int menuId = findBookmark( text->getFullKey() ); | ||
553 | if ( menuId != -1 ) | ||
554 | { | ||
555 | // Bookmark found, remove | ||
556 | m_bookmarkMenu->removeItem( menuId ); | ||
557 | |||
558 | //If this was the last bookmark, disable the remove option | ||
559 | if ( m_bookmarkMenu->idAt( 3 ) == -1 ) | ||
560 | m_actionBookmarkRemove->setEnabled( false ); | ||
561 | } | ||
562 | } | ||
563 | } | ||
564 | |||
565 | void MainWindow::slotBookmarkSelected() | ||
566 | { | ||
567 | const QAction *action = reinterpret_cast<const QAction *>(sender()); | ||
568 | if ( action ) | ||
569 | { | ||
570 | QString bookmark = action->text(); | ||
571 | int pos = bookmark.find( " (" ); | ||
572 | QString key = bookmark.left( pos ); | ||
573 | pos += 2; | ||
574 | QString module = bookmark.mid( pos, bookmark.find( ")", pos ) - pos ); | ||
575 | |||
576 | openModule( module, key ); | ||
577 | } | ||
578 | } | ||
579 | |||
580 | void MainWindow::slotViewSwordOption( bool enabled ) | ||
581 | { | ||
582 | const QAction *action = reinterpret_cast<const QAction*>(sender()); | ||
583 | m_swordMgr->setGlobalOption ( action->text(), enabled ? "On" : "Off" ); | ||
584 | |||
585 | emit sigOptionChanged(); | ||
586 | } | ||
587 | |||
588 | void MainWindow::slotViewNavToolbar( bool enabled ) | ||
589 | { | ||
590 | enabled ? m_navToolbar->show() | ||
591 | : m_navToolbar->hide(); | ||
592 | } | ||
593 | |||
594 | void MainWindow::slotViewSearchToolbar( bool enabled ) | ||
595 | { | ||
596 | enabled ? m_searchToolbar->show() | ||
597 | : m_searchToolbar->hide(); | ||
598 | } | ||
599 | |||
600 | void MainWindow::slotNavPrevChapter() | ||
601 | { | ||
602 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | ||
603 | if ( text ) | ||
604 | { | ||
605 | text->prevChapter(); | ||
606 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); | ||
607 | m_navToolbar->setKey( text->getAbbrevKey() ); | ||
608 | } | ||
609 | } | ||
610 | |||
611 | void MainWindow::slotNavPrevVerse() | ||
612 | { | ||
613 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | ||
614 | if ( text ) | ||
615 | { | ||
616 | text->prevVerse(); | ||
617 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); | ||
618 | m_navToolbar->setKey( text->getAbbrevKey() ); | ||
619 | } | ||
620 | } | ||
621 | |||
622 | void MainWindow::slotNavKeyChanged( const QString &newKey ) | ||
623 | { | ||
624 | QString key = newKey; | ||
625 | key.replace( QRegExp( "[-=.]" ), ":" ); | ||
626 | |||
627 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | ||
628 | if ( text ) | ||
629 | { | ||
630 | text->setKey( key ); | ||
631 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); | ||
632 | } | ||
633 | } | ||
634 | |||
635 | void MainWindow::slotNavNextVerse() | ||
636 | { | ||
637 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | ||
638 | if ( text ) | ||
639 | { | ||
640 | text->nextVerse(); | ||
641 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); | ||
642 | m_navToolbar->setKey( text->getAbbrevKey() ); | ||
643 | } | ||
644 | } | ||
645 | |||
646 | void MainWindow::slotNavNextChapter() | ||
647 | { | ||
648 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | ||
649 | if ( text ) | ||
650 | { | ||
651 | text->nextChapter(); | ||
652 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); | ||
653 | m_navToolbar->setKey( text->getAbbrevKey() ); | ||
654 | } | ||
655 | } | ||
656 | |||
657 | void MainWindow::slotNavAutoScroll( bool enabled ) | ||
658 | { | ||
659 | m_autoScrollTimer.stop(); | ||
660 | |||
661 | if ( enabled ) | ||
662 | m_autoScrollTimer.start( m_navToolbar->autoScrollRate() * 100 ); | ||
663 | } | ||
664 | |||
665 | void MainWindow::slotNavScrollRateChanged( int newRate ) | ||
666 | { | ||
667 | if ( m_autoScrollTimer.isActive() ) | ||
668 | { | ||
669 | m_autoScrollTimer.stop(); | ||
670 | m_autoScrollTimer.start( newRate * 100 ); | ||
671 | } | ||
672 | } | ||
673 | |||
674 | void MainWindow::slotSearchResultClicked( const QString &key ) | ||
675 | { | ||
676 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | ||
677 | if ( text ) | ||
678 | { | ||
679 | text->setKey( key ); | ||
680 | setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) ); | ||
681 | m_navToolbar->setKey( text->getAbbrevKey() ); | ||
682 | } | ||
683 | } | ||
684 | |||
685 | void MainWindow::slotTextRefClicked( const QString &ref ) | ||
686 | { | ||
687 | //owarn << "Reference: " << ref << oendl; | ||
688 | if ( !ref.isNull() ) | ||
689 | { | ||
690 | TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); | ||
691 | if ( text ) | ||
692 | { | ||
693 | QString module; | ||
694 | QString key( ref ); | ||
695 | key.remove( 0, 2 ); | ||
696 | |||
697 | QChar book = ref.at( 1 ); | ||
698 | // TODO- this is ugly, need better way to determine type of reference | ||
699 | // take a look at SWModule::getRawEntry() | ||
700 | int keyValue = key.toInt(); | ||
701 | if ( book == 'H' && keyValue <= 8674 ) | ||
702 | module = "StrongsHebrew"; | ||
703 | else if ( book == 'G' && keyValue <= 5624 ) | ||
704 | module = "StrongsGreek"; | ||
705 | |||
706 | if ( !module.isEmpty() ) | ||
707 | openModule( module, key ); | ||
708 | } | ||
709 | } | ||
710 | } | ||
diff --git a/noncore/apps/dagger/mainwindow.h b/noncore/apps/dagger/mainwindow.h new file mode 100644 index 0000000..0c7f3c8 --- a/dev/null +++ b/noncore/apps/dagger/mainwindow.h | |||
@@ -0,0 +1,134 @@ | |||
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 | #ifndef MAINWINDOW_H | ||
19 | #define MAINWINDOW_H | ||
20 | |||
21 | #include "swordoptionlist.h" | ||
22 | |||
23 | #include <opie2/otabwidget.h> | ||
24 | |||
25 | #include <qpe/config.h> | ||
26 | |||
27 | #include <qmainwindow.h> | ||
28 | #include <qtimer.h> | ||
29 | |||
30 | #include <swmgr.h> | ||
31 | |||
32 | class QAction; | ||
33 | class QMenuBar; | ||
34 | class QPixmap; | ||
35 | class QToolBar; | ||
36 | |||
37 | class NavBar; | ||
38 | class SearchBar; | ||
39 | |||
40 | class MainWindow : public QMainWindow | ||
41 | { | ||
42 | Q_OBJECT | ||
43 | |||
44 | public: | ||
45 | MainWindow( QWidget *parent = 0x0, const char *name = 0x0, WFlags fl = 0 ); | ||
46 | ~MainWindow(); | ||
47 | |||
48 | static QString appName() { return QString::fromLatin1( "dagger" ); }; | ||
49 | |||
50 | protected: | ||
51 | bool eventFilter( QObject *obj, QEvent *event ); | ||
52 | |||
53 | private: | ||
54 | sword::SWMgr *m_swordMgr; // Sword library module manager | ||
55 | Config m_config; // Application configuration | ||
56 | |||
57 | // Configuration items | ||
58 | QString m_modulePath; // Directory where sword modules are located | ||
59 | bool m_alwaysOpenNew; // Whether or not open modules as new window/tab (or re-use existing) | ||
60 | int m_numVerses; // Number of verses to display at a time for Bible modules | ||
61 | bool m_disableScreenBlank; // Whether or not to disable automatic screen blanking | ||
62 | int m_copyFormat; // Format used when copying | ||
63 | QFont m_textFont; // Font used for module text | ||
64 | |||
65 | // UI components | ||
66 | QToolBar *m_barDock; // Main toolbar which contains menu and all other toolbars | ||
67 | QMenuBar *m_menuBar; // Application menu bar | ||
68 | QPopupMenu *m_bookmarkMenu; // Pointer to bookmark menu | ||
69 | NavBar *m_navToolbar; // Text navigation toolbar | ||
70 | SearchBar *m_searchToolbar; // Text search toolbar | ||
71 | Opie::Ui::OTabWidget m_tabs; // Main widget in which all texts, notes, etc. will be displayed | ||
72 | |||
73 | // Other visual items | ||
74 | QPixmap *m_bibleIcon; // Icon used for bible modules | ||
75 | QPixmap *m_commentaryIcon; // Icon used for commentary modules | ||
76 | QPixmap *m_lexiconIcon; // Icon used for lexicon modules | ||
77 | |||
78 | QTimer m_autoScrollTimer; // Timer for auto-scrolling of bible texts | ||
79 | |||
80 | // Menubar/toolbar actions | ||
81 | SwordOptionList m_actionSwordOpts; // List of actions for sword options | ||
82 | // (e.g. footnotes, Strong's numbers, etc.) | ||
83 | QAction *m_actionTextClose; // Action for closing currently opened module | ||
84 | QAction *m_actionEditCopy; // Action for copying text from current module | ||
85 | QAction *m_actionBookmarkAdd; // Action for adding a bookmark | ||
86 | QAction *m_actionBookmarkRemove; // Action for removing a bookmark | ||
87 | QAction *m_actionViewNavToolbar; // Action for displaying/hiding the navigation toolbar | ||
88 | QAction *m_actionViewSearchToolbar; // Action for displaying/hiding the search toolbar | ||
89 | |||
90 | void initUI(); | ||
91 | void openModule( const QString &modulename, const QString &key = 0x0 ); | ||
92 | int findBookmark( const QString &bookmark ); | ||
93 | void enableScreenBlanking( bool enable ); | ||
94 | |||
95 | private slots: | ||
96 | void initConfig(); | ||
97 | |||
98 | void slotTextDisplayed( QWidget *textWidget ); | ||
99 | |||
100 | // Menubar/toolbar action slots | ||
101 | void slotTextOpen(); | ||
102 | void slotTextClose(); | ||
103 | void slotTextInstall(); | ||
104 | void slotEditCopy(); | ||
105 | void slotEditConfigure(); | ||
106 | void slotBookmarkAdd(); | ||
107 | void slotBookmarkRemove(); | ||
108 | void slotBookmarkSelected(); | ||
109 | void slotViewSwordOption( bool enabled ); | ||
110 | void slotViewNavToolbar( bool enabled ); | ||
111 | void slotViewSearchToolbar( bool enabled ); | ||
112 | |||
113 | // Navigation toolbar slots | ||
114 | void slotNavPrevChapter(); | ||
115 | void slotNavPrevVerse(); | ||
116 | void slotNavKeyChanged( const QString &newKey ); | ||
117 | void slotNavNextVerse(); | ||
118 | void slotNavNextChapter(); | ||
119 | void slotNavAutoScroll( bool enabled ); | ||
120 | void slotNavScrollRateChanged( int newRate ); | ||
121 | |||
122 | // Search toolbar slots | ||
123 | void slotSearchResultClicked( const QString &key ); | ||
124 | |||
125 | // Text widget slots | ||
126 | void slotTextRefClicked( const QString &ref ); | ||
127 | |||
128 | signals: | ||
129 | void sigNumVersesChanged( int numVerses ); | ||
130 | void sigFontChanged( const QFont *newFont ); | ||
131 | void sigOptionChanged(); | ||
132 | }; | ||
133 | |||
134 | #endif | ||
diff --git a/noncore/apps/dagger/navbar.cpp b/noncore/apps/dagger/navbar.cpp new file mode 100644 index 0000000..4781af0 --- a/dev/null +++ b/noncore/apps/dagger/navbar.cpp | |||
@@ -0,0 +1,93 @@ | |||
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 "navbar.h" | ||
19 | |||
20 | #include <qpe/config.h> | ||
21 | #include <qpe/resource.h> | ||
22 | |||
23 | #include <qaction.h> | ||
24 | #include <qlineedit.h> | ||
25 | |||
26 | NavBar::NavBar( QMainWindow *parent ) | ||
27 | : QToolBar( QString::null, parent, QMainWindow::Top, true ) | ||
28 | { | ||
29 | // Initialize UI | ||
30 | m_actionPrevChapter = new QAction( tr( "Previous chapter" ), Resource::loadPixmap( "fastback" ), | ||
31 | QString::null, 0, this, 0 ); | ||
32 | m_actionPrevChapter->addTo( this ); | ||
33 | connect( m_actionPrevChapter, SIGNAL(activated()), this, SIGNAL(prevChapter()) ); | ||
34 | |||
35 | m_actionPrevVerse = new QAction( tr( "Previous verse" ), Resource::loadPixmap( "back" ), | ||
36 | QString::null, 0, this, 0 ); | ||
37 | m_actionPrevVerse->addTo( this ); | ||
38 | connect( m_actionPrevVerse, SIGNAL(activated()), this, SIGNAL(prevVerse()) ); | ||
39 | |||
40 | m_key = new QLineEdit( this ); | ||
41 | setStretchableWidget( m_key ); | ||
42 | connect(m_key, SIGNAL(textChanged(const QString &)), this, SIGNAL(keyChanged(const QString &)) ); | ||
43 | |||
44 | m_actionNextVerse = new QAction( tr( "Next verse" ), Resource::loadPixmap( "forward" ), | ||
45 | QString::null, 0, this, 0 ); | ||
46 | m_actionNextVerse->addTo( this ); | ||
47 | connect( m_actionNextVerse, SIGNAL(activated()), this, SIGNAL(nextVerse()) ); | ||
48 | |||
49 | m_actionNextChapter = new QAction( tr( "Next chapter" ), Resource::loadPixmap( "fastforward" ), | ||
50 | QString::null, 0, this, 0 ); | ||
51 | m_actionNextChapter->addTo( this ); | ||
52 | connect( m_actionNextChapter, SIGNAL(activated()), this, SIGNAL(nextChapter()) ); | ||
53 | |||
54 | addSeparator(); | ||
55 | |||
56 | m_scrollRate = new QSpinBox( 1, 100, 1, this ); | ||
57 | m_scrollRate->setMinimumWidth( 35 ); | ||
58 | connect( m_scrollRate, SIGNAL(valueChanged(int)), this, SIGNAL(scrollRateChanged(int)) ); | ||
59 | |||
60 | m_actionScroll = new QAction( tr( "Auto-scroll" ), Resource::loadPixmap( "dagger/autoscroll" ), | ||
61 | QString::null, 0, this, 0 ); | ||
62 | m_actionScroll->setToggleAction( true ); | ||
63 | connect( m_actionScroll, SIGNAL(toggled(bool)), this, SIGNAL(autoScroll(bool)) ); | ||
64 | m_actionScroll->addTo( this ); | ||
65 | |||
66 | if ( parent ) | ||
67 | { | ||
68 | installEventFilter( parent ); | ||
69 | m_key->installEventFilter( parent ); | ||
70 | } | ||
71 | } | ||
72 | |||
73 | void NavBar::navBtnsEnable( bool enabled ) | ||
74 | { | ||
75 | m_actionPrevChapter->setEnabled( enabled ); | ||
76 | m_actionPrevVerse->setEnabled( enabled ); | ||
77 | m_actionNextVerse->setEnabled( enabled ); | ||
78 | m_actionNextChapter->setEnabled( enabled ); | ||
79 | m_scrollRate->setEnabled( enabled ); | ||
80 | m_actionScroll->setEnabled( enabled ); | ||
81 | } | ||
82 | |||
83 | void NavBar::setKey( const QString &newKey ) | ||
84 | { | ||
85 | disconnect( m_key, SIGNAL(textChanged(const QString &)), 0, 0 ); | ||
86 | m_key->setText( newKey ); | ||
87 | connect(m_key, SIGNAL(textChanged(const QString &)), this, SIGNAL(keyChanged(const QString &)) ); | ||
88 | } | ||
89 | |||
90 | void NavBar::setAutoScrollRate( int scrollRate ) | ||
91 | { | ||
92 | m_scrollRate->setValue( scrollRate ); | ||
93 | } | ||
diff --git a/noncore/apps/dagger/navbar.h b/noncore/apps/dagger/navbar.h new file mode 100644 index 0000000..a37d6ff --- a/dev/null +++ b/noncore/apps/dagger/navbar.h | |||
@@ -0,0 +1,58 @@ | |||
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 | #ifndef NAVBAR_H | ||
19 | #define NAVBAR_H | ||
20 | |||
21 | #include <qspinbox.h> | ||
22 | #include <qtoolbar.h> | ||
23 | |||
24 | class QAction; | ||
25 | class QLineEdit; | ||
26 | |||
27 | class NavBar : public QToolBar | ||
28 | { | ||
29 | Q_OBJECT | ||
30 | |||
31 | public: | ||
32 | NavBar( QMainWindow *parent = 0x0 ); | ||
33 | |||
34 | void navBtnsEnable( bool enabled ); | ||
35 | void setKey( const QString &newKey ); | ||
36 | void setAutoScrollRate( int scrollRate ); | ||
37 | const int autoScrollRate() { return m_scrollRate->value(); } | ||
38 | |||
39 | private: | ||
40 | QAction *m_actionPrevChapter; // Action for going back 1 chapter | ||
41 | QAction *m_actionPrevVerse; // Action for going back 1 verse | ||
42 | QLineEdit *m_key; // Edit box to enter key to goto | ||
43 | QAction *m_actionNextVerse; // Action for going forward 1 verse | ||
44 | QAction *m_actionNextChapter; // Action for going forward 1 chapter | ||
45 | QSpinBox *m_scrollRate; // Spin box to adjust rate of auto-scrolling | ||
46 | QAction *m_actionScroll; // Action to start/stop auto-scrolling | ||
47 | |||
48 | signals: | ||
49 | void prevChapter(); | ||
50 | void prevVerse(); | ||
51 | void keyChanged( const QString &newKey ); | ||
52 | void nextVerse(); | ||
53 | void nextChapter(); | ||
54 | void autoScroll( bool enabled ); | ||
55 | void scrollRateChanged( int newRate ); | ||
56 | }; | ||
57 | |||
58 | #endif | ||
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 | } | ||
diff --git a/noncore/apps/dagger/opentextdlg.h b/noncore/apps/dagger/opentextdlg.h new file mode 100644 index 0000000..2b53410 --- a/dev/null +++ b/noncore/apps/dagger/opentextdlg.h | |||
@@ -0,0 +1,49 @@ | |||
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 | #ifndef OPENTEXTDLG_H | ||
19 | #define OPENTEXTDLG_H | ||
20 | |||
21 | #include <qdialog.h> | ||
22 | #include <qlistview.h> | ||
23 | |||
24 | #include <swmgr.h> | ||
25 | |||
26 | class QPixmap; | ||
27 | |||
28 | class OpenTextDlg : public QDialog | ||
29 | { | ||
30 | Q_OBJECT | ||
31 | |||
32 | public: | ||
33 | OpenTextDlg( QWidget *parent = 0x0, sword::SWMgr *swordMgr = 0x0, QPixmap *bibleIcon = 0x0, | ||
34 | QPixmap *commentaryIcon = 0x0, QPixmap *lexiconIcon = 0x0 ); | ||
35 | |||
36 | QString selectedText() { return m_textList.currentItem()->text( 1 ); }; | ||
37 | |||
38 | private: | ||
39 | QListView m_textList; // List of available texts/modules | ||
40 | |||
41 | QListViewItem *m_bibles; // Pointer to bible section header | ||
42 | QListViewItem *m_lexicons; // Pointer to lexicon/dictionary section header | ||
43 | QListViewItem *m_commentaries; // Pointer to commentary section header | ||
44 | |||
45 | private slots: | ||
46 | void slotItemClicked( QListViewItem *item ); | ||
47 | }; | ||
48 | |||
49 | #endif | ||
diff --git a/noncore/apps/dagger/opie-dagger.control b/noncore/apps/dagger/opie-dagger.control new file mode 100644 index 0000000..c401f03 --- a/dev/null +++ b/noncore/apps/dagger/opie-dagger.control | |||
@@ -0,0 +1,11 @@ | |||
1 | Package: opie-dagger | ||
2 | Files: plugins/application/libdagger.so* bin/dagger pics/dagger apps/Applications/dagger.desktop | ||
3 | Priority: optional | ||
4 | Section: opie/applications | ||
5 | Depends: task-opie-minimal, libopiecore2, libopieui2 | ||
6 | Replaces: dagger | ||
7 | Architecture: arm | ||
8 | Source: http://draknor.net/dagger/ | ||
9 | Maintainer: Dan Williams (drw@handhelds.org) | ||
10 | Description: A Bible study program utilizing the Sword library. | ||
11 | Version: 0.9.0 | ||
diff --git a/noncore/apps/dagger/searchbar.cpp b/noncore/apps/dagger/searchbar.cpp new file mode 100644 index 0000000..747d696 --- a/dev/null +++ b/noncore/apps/dagger/searchbar.cpp | |||
@@ -0,0 +1,167 @@ | |||
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 "searchbar.h" | ||
19 | #include "textwidget.h" | ||
20 | |||
21 | #include <opie2/owait.h> | ||
22 | |||
23 | #include <qpe/qpeapplication.h> | ||
24 | #include <qpe/resource.h> | ||
25 | |||
26 | #include <qaction.h> | ||
27 | #include <qcombobox.h> | ||
28 | #include <qlineedit.h> | ||
29 | |||
30 | #include <listkey.h> | ||
31 | #include <regex.h> | ||
32 | #include <versekey.h> | ||
33 | |||
34 | SearchBar::SearchBar( QMainWindow *parent ) | ||
35 | : QToolBar( QString::null, parent, QMainWindow::Top, true ) | ||
36 | , m_currText( 0x0 ) | ||
37 | { | ||
38 | // Initialize UI | ||
39 | m_searchText = new QLineEdit( this ); | ||
40 | setStretchableWidget( m_searchText ); | ||
41 | connect(m_searchText, SIGNAL(textChanged(const QString &)), | ||
42 | this, SLOT(slotTextChanged(const QString &)) ); | ||
43 | |||
44 | m_actionFind = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, | ||
45 | 0, this, 0 ); | ||
46 | m_actionFind->setEnabled( false ); | ||
47 | m_actionFind->addTo( this ); | ||
48 | connect( m_actionFind, SIGNAL(activated()), this, SLOT(slotFind()) ); | ||
49 | |||
50 | addSeparator(); | ||
51 | |||
52 | m_actionPrev = new QAction( tr( "Previous result" ), Resource::loadPixmap( "back" ), | ||
53 | QString::null, 0, this, 0 ); | ||
54 | m_actionPrev->setEnabled( false ); | ||
55 | m_actionPrev->addTo( this ); | ||
56 | connect( m_actionPrev, SIGNAL(activated()), this, SLOT(slotPrev()) ); | ||
57 | |||
58 | m_resultList = new QComboBox( this ); | ||
59 | m_resultList->setEnabled( false ); | ||
60 | connect( m_resultList, SIGNAL(activated(const QString &)), this, SIGNAL(sigResultClicked(const QString &)) ); | ||
61 | |||
62 | m_actionNext = new QAction( tr( "Next result" ), Resource::loadPixmap( "forward" ), | ||
63 | QString::null, 0, this, 0 ); | ||
64 | m_actionNext->setEnabled( false ); | ||
65 | m_actionNext->addTo( this ); | ||
66 | connect( m_actionNext, SIGNAL(activated()), this, SLOT(slotNext()) ); | ||
67 | |||
68 | if ( parent ) | ||
69 | { | ||
70 | installEventFilter( parent ); | ||
71 | // TODO - install for all controls | ||
72 | m_searchText->installEventFilter( parent ); | ||
73 | } | ||
74 | } | ||
75 | |||
76 | void SearchBar::setCurrModule( TextWidget *currText ) | ||
77 | { | ||
78 | m_actionFind->setEnabled( ( m_searchText->text() != "" ) && currText ); | ||
79 | |||
80 | if ( !m_currText || ( currText->getModuleName() != m_currText->getModuleName() ) ) | ||
81 | { | ||
82 | m_actionPrev->setEnabled( false ); | ||
83 | m_resultList->clear(); | ||
84 | m_resultList->setEnabled( false ); | ||
85 | m_actionNext->setEnabled( false ); | ||
86 | } | ||
87 | |||
88 | m_currText = currText; | ||
89 | } | ||
90 | |||
91 | void SearchBar::slotTextChanged( const QString &newText ) | ||
92 | { | ||
93 | m_actionFind->setEnabled( ( newText != "" ) && m_currText ); | ||
94 | } | ||
95 | |||
96 | void SearchBar::slotFind() | ||
97 | { | ||
98 | m_resultList->clear(); | ||
99 | |||
100 | // Change application title and display Opie wait dialog to indicate search is beginning | ||
101 | QWidget *pWidget = reinterpret_cast<QWidget *>(parent()); | ||
102 | QString caption = pWidget->caption(); | ||
103 | pWidget->setCaption( "Searching..." ); | ||
104 | |||
105 | Opie::Ui::OWait wait( pWidget ); | ||
106 | wait.show(); | ||
107 | qApp->processEvents(); | ||
108 | |||
109 | // Perform search | ||
110 | // TODO - implement search callback function to animate wait cursor | ||
111 | sword::ListKey results = m_currText->getModule()->Search( m_searchText->text().latin1(), REG_ICASE, 0 ); | ||
112 | |||
113 | // Process results | ||
114 | int count = results.Count(); | ||
115 | bool found = count > 0; | ||
116 | if ( found ) | ||
117 | { | ||
118 | // Populate results combo box | ||
119 | sword::VerseKey key; | ||
120 | for ( int i = 0; i < count; i++ ) | ||
121 | { | ||
122 | key.setText( results.GetElement( i )->getText() ); | ||
123 | m_resultList->insertItem( key.getShortText() ); | ||
124 | } | ||
125 | |||
126 | // Goto first result in list | ||
127 | m_resultList->setCurrentItem( 0 ); | ||
128 | emit sigResultClicked( m_resultList->currentText() ); | ||
129 | } | ||
130 | else | ||
131 | { | ||
132 | // Reset application title | ||
133 | pWidget->setCaption( caption ); | ||
134 | } | ||
135 | |||
136 | // UI clean-up | ||
137 | wait.hide(); | ||
138 | |||
139 | m_actionPrev->setEnabled( false ); | ||
140 | m_resultList->setEnabled( found ); | ||
141 | m_actionNext->setEnabled( count > 1 ); | ||
142 | } | ||
143 | |||
144 | void SearchBar::slotPrev() | ||
145 | { | ||
146 | int item = m_resultList->currentItem() - 1; | ||
147 | m_resultList->setCurrentItem( item ); | ||
148 | emit sigResultClicked( m_resultList->currentText() ); | ||
149 | |||
150 | m_actionPrev->setEnabled( item > 0 ); | ||
151 | m_actionNext->setEnabled( item < m_resultList->count() - 1 ); | ||
152 | } | ||
153 | |||
154 | void SearchBar::slotNext() | ||
155 | { | ||
156 | int item = m_resultList->currentItem() + 1; | ||
157 | m_resultList->setCurrentItem( item ); | ||
158 | emit sigResultClicked( m_resultList->currentText() ); | ||
159 | |||
160 | m_actionPrev->setEnabled( true ); | ||
161 | m_actionNext->setEnabled( item < m_resultList->count() - 1 ); | ||
162 | } | ||
163 | |||
164 | void SearchBar::slotCloseBtn() | ||
165 | { | ||
166 | hide(); | ||
167 | } | ||
diff --git a/noncore/apps/dagger/searchbar.h b/noncore/apps/dagger/searchbar.h new file mode 100644 index 0000000..ce2ab99 --- a/dev/null +++ b/noncore/apps/dagger/searchbar.h | |||
@@ -0,0 +1,57 @@ | |||
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 | #ifndef SEARCHBAR_H | ||
19 | #define SEARCHBAR_H | ||
20 | |||
21 | #include <qtoolbar.h> | ||
22 | |||
23 | class QAction; | ||
24 | class QComboBox; | ||
25 | class QLineEdit; | ||
26 | class TextWidget; | ||
27 | |||
28 | class SearchBar : public QToolBar | ||
29 | { | ||
30 | Q_OBJECT | ||
31 | |||
32 | public: | ||
33 | SearchBar( QMainWindow *parent = 0x0 ); | ||
34 | |||
35 | void setCurrModule( TextWidget *currText ); | ||
36 | |||
37 | private: | ||
38 | TextWidget *m_currText; // Pointer to current text | ||
39 | |||
40 | QLineEdit *m_searchText; // Edit box to enter text to search for | ||
41 | QAction *m_actionFind; // Button to press to initiate search | ||
42 | QAction *m_actionPrev; // Button to view previous search result | ||
43 | QComboBox *m_resultList; // List of results | ||
44 | QAction *m_actionNext; // Button to view next search result | ||
45 | |||
46 | private slots: | ||
47 | void slotTextChanged( const QString &newText ); | ||
48 | void slotFind(); | ||
49 | void slotPrev(); | ||
50 | void slotNext(); | ||
51 | void slotCloseBtn(); | ||
52 | |||
53 | signals: | ||
54 | void sigResultClicked( const QString &key ); | ||
55 | }; | ||
56 | |||
57 | #endif | ||
diff --git a/noncore/apps/dagger/swordoptionlist.h b/noncore/apps/dagger/swordoptionlist.h new file mode 100644 index 0000000..ea492bf --- a/dev/null +++ b/noncore/apps/dagger/swordoptionlist.h | |||
@@ -0,0 +1,44 @@ | |||
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 | #ifndef SWORDOPTIONLIST_H | ||
19 | #define SWORDOPTIONLIST_H | ||
20 | |||
21 | #include <qaction.h> | ||
22 | #include <qlist.h> | ||
23 | |||
24 | class SwordOptionList : public QList<QAction> | ||
25 | { | ||
26 | private: | ||
27 | |||
28 | int compareItems( QCollection::Item item1, QCollection::Item item2 ) | ||
29 | { | ||
30 | // Sort by QAction text | ||
31 | QString act1 = reinterpret_cast<QAction*>(item1)->text(); | ||
32 | QString act2 = reinterpret_cast<QAction*>(item2)->text(); | ||
33 | if ( act1 < act2 ) | ||
34 | return -1; | ||
35 | else if ( act1 == act2 ) | ||
36 | return 0; | ||
37 | else | ||
38 | return 1; | ||
39 | } | ||
40 | }; | ||
41 | |||
42 | typedef QListIterator<QAction> SwordOptionListIterator; | ||
43 | |||
44 | #endif | ||
diff --git a/noncore/apps/dagger/textwidget.cpp b/noncore/apps/dagger/textwidget.cpp new file mode 100644 index 0000000..8ff620d --- a/dev/null +++ b/noncore/apps/dagger/textwidget.cpp | |||
@@ -0,0 +1,183 @@ | |||
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 "textwidget.h" | ||
19 | |||
20 | #include <qlayout.h> | ||
21 | #include <qtextbrowser.h> | ||
22 | |||
23 | #include <versekey.h> | ||
24 | |||
25 | TextWidget::TextWidget( QWidget *parent, sword::SWModule *module, int numVerses, const QFont *font ) | ||
26 | : QWidget( parent, 0x0, 0x0 ) | ||
27 | , m_module( module ) | ||
28 | , m_numVerses( numVerses ) | ||
29 | { | ||
30 | if ( parent ) | ||
31 | installEventFilter( parent ); | ||
32 | |||
33 | QVBoxLayout *layout = new QVBoxLayout( this, 2, 2 ); | ||
34 | |||
35 | m_textView = new QTextBrowser( this ); | ||
36 | m_textView->installEventFilter( parent ); | ||
37 | m_textView->setMinimumHeight( 20 ); | ||
38 | m_textView->setHScrollBarMode( QTextView::AlwaysOff ); | ||
39 | m_textView->setTextFormat( QTextView::RichText ); | ||
40 | connect( m_textView, SIGNAL(highlighted(const QString &)), | ||
41 | this, SIGNAL(sigRefClicked(const QString &)) ); | ||
42 | layout->addWidget( m_textView ); | ||
43 | |||
44 | // Set font | ||
45 | if ( font ) | ||
46 | setFont( *font ); | ||
47 | |||
48 | // Set initial text | ||
49 | if ( m_module ) | ||
50 | { | ||
51 | m_isBibleText = !strcmp( module->Type(), "Biblical Texts" ); | ||
52 | if ( m_isBibleText ) | ||
53 | { | ||
54 | m_key = new sword::VerseKey( "g" ); | ||
55 | |||
56 | //connect( m_textView, SIGNAL(highlighted(const QString&)), | ||
57 | // this, SLOT(slotReferenceClicked(const QString&)) ); | ||
58 | //connect( parent, SIGNAL( strongsNumbers( bool ) ), this, SLOT( slotStrongsNumbers( bool ) ) ); | ||
59 | } | ||
60 | else | ||
61 | { | ||
62 | m_key = new sword::SWKey( "" ); | ||
63 | } | ||
64 | m_module->SetKey( m_key ); | ||
65 | setText(); | ||
66 | } | ||
67 | } | ||
68 | |||
69 | TextWidget::~TextWidget() | ||
70 | { | ||
71 | // TODO - why does this cause a SIGSEV??? | ||
72 | //delete m_key; | ||
73 | } | ||
74 | |||
75 | QString TextWidget::getCurrVerse() | ||
76 | { | ||
77 | m_module->SetKey( m_key->getText() ); | ||
78 | return ( QString ) m_module->StripText(); | ||
79 | } | ||
80 | |||
81 | void TextWidget::prevChapter() | ||
82 | { | ||
83 | } | ||
84 | |||
85 | void TextWidget::prevVerse() | ||
86 | { | ||
87 | (*m_key)--; | ||
88 | setText(); | ||
89 | } | ||
90 | |||
91 | void TextWidget::setKey( const QString &newKey ) | ||
92 | { | ||
93 | m_key->setText( newKey.latin1() ); | ||
94 | setText(); | ||
95 | } | ||
96 | |||
97 | void TextWidget::nextVerse() | ||
98 | { | ||
99 | (*m_key)++; | ||
100 | setText(); | ||
101 | } | ||
102 | |||
103 | void TextWidget::nextChapter() | ||
104 | { | ||
105 | } | ||
106 | |||
107 | void TextWidget::slotNumVersesChanged( int numVerses ) | ||
108 | { | ||
109 | m_numVerses = numVerses; | ||
110 | setText(); | ||
111 | } | ||
112 | |||
113 | void TextWidget::slotFontChanged( const QFont *newFont ) | ||
114 | { | ||
115 | setFont( *newFont ); | ||
116 | // TODO - shouldn't have to reset text, but couldn't get repaint() to work | ||
117 | setText(); | ||
118 | } | ||
119 | |||
120 | void TextWidget::slotOptionChanged() | ||
121 | { | ||
122 | setText(); | ||
123 | } | ||
124 | |||
125 | void TextWidget::setText() | ||
126 | { | ||
127 | if ( m_key->Error() ) | ||
128 | return; | ||
129 | |||
130 | m_module->SetKey( m_key->getText() ); | ||
131 | m_fullKey = QString( "%1 (%2)" ).arg( m_key->getShortText() ).arg( m_module->Name() ); | ||
132 | |||
133 | if ( m_isBibleText ) | ||
134 | { | ||
135 | m_textView->setVScrollBarMode( QTextView::AlwaysOff ); | ||
136 | |||
137 | m_abbrevKey = m_key->getShortText(); | ||
138 | |||
139 | QString fullText; | ||
140 | |||
141 | for ( int i = 0; i < m_numVerses; i++ ) | ||
142 | { | ||
143 | QString key = ( QString ) m_module->KeyText(); | ||
144 | QString verseStr = ( QString ) *m_module; | ||
145 | |||
146 | // Format current verse (adding chapter and/or book headings if necessary) | ||
147 | int verse = static_cast<sword::VerseKey>(m_module->Key()).Verse(); | ||
148 | if ( verse == 1 ) | ||
149 | { | ||
150 | int chapter = static_cast<sword::VerseKey>(m_module->Key()).Chapter(); | ||
151 | if ( chapter == 1 ) | ||
152 | { | ||
153 | QString book = static_cast<sword::VerseKey>(m_module->Key()).getBookName(); | ||
154 | verseStr = QString( "<p><center><big><b>%1</b></big></center><br><center><b>Chapter %1</b></center><p><b>%2</b> %3<p>" ) | ||
155 | .arg( book ).arg( chapter ).arg( verse ).arg( verseStr ); | ||
156 | } | ||
157 | else | ||
158 | { | ||
159 | verseStr = QString( "<center><b>Chapter %1</b></center><p><b>%2</b> %3<p>" ) | ||
160 | .arg( chapter ).arg( verse ).arg( verseStr ); | ||
161 | } | ||
162 | } | ||
163 | else | ||
164 | { | ||
165 | verseStr = QString( "<b>%1</b> %2<p>" ).arg( verse ).arg( verseStr ); | ||
166 | } | ||
167 | |||
168 | fullText.append( verseStr ); | ||
169 | |||
170 | m_module->Key()++; | ||
171 | |||
172 | if ( m_module->Key().Error() ) | ||
173 | break; | ||
174 | } | ||
175 | |||
176 | m_textView->setText( fullText ); | ||
177 | } | ||
178 | else // !isBibleText | ||
179 | { | ||
180 | m_abbrevKey = m_key->getText(); | ||
181 | m_textView->setText( ( QString ) *m_module ); | ||
182 | } | ||
183 | } | ||
diff --git a/noncore/apps/dagger/textwidget.h b/noncore/apps/dagger/textwidget.h new file mode 100644 index 0000000..647eae9 --- a/dev/null +++ b/noncore/apps/dagger/textwidget.h | |||
@@ -0,0 +1,73 @@ | |||
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 | #ifndef TEXTWIDGET_H | ||
19 | #define TEXTWIDGET_H | ||
20 | |||
21 | #include <qwidget.h> | ||
22 | |||
23 | #include <swkey.h> | ||
24 | #include <swmodule.h> | ||
25 | |||
26 | class QTextBrowser; | ||
27 | |||
28 | class TextWidget : public QWidget | ||
29 | { | ||
30 | Q_OBJECT | ||
31 | |||
32 | public: | ||
33 | TextWidget( QWidget *parent = 0x0, sword::SWModule *module = 0x0, int numVerses = 5, | ||
34 | const QFont *font = 0x0 ); | ||
35 | ~TextWidget(); | ||
36 | |||
37 | const QString &getFullKey() { return m_fullKey; } | ||
38 | const QString &getAbbrevKey() { return m_abbrevKey; } | ||
39 | QString getModuleName() { return QString( m_module->Name() ); } | ||
40 | sword::SWModule *getModule() { return m_module; } | ||
41 | QString getCurrVerse(); | ||
42 | |||
43 | bool isBibleText() const { return m_isBibleText; } | ||
44 | |||
45 | void prevChapter(); | ||
46 | void prevVerse(); | ||
47 | void setKey( const QString &newKey ); | ||
48 | void nextVerse(); | ||
49 | void nextChapter(); | ||
50 | |||
51 | public slots: | ||
52 | void slotNumVersesChanged( int numVerses ); | ||
53 | void slotFontChanged( const QFont *newFont ); | ||
54 | void slotOptionChanged(); | ||
55 | |||
56 | private: | ||
57 | sword::SWModule *m_module; // Sword module to display in this widget | ||
58 | sword::SWKey *m_key; // Current module key | ||
59 | bool m_isBibleText; // Indicates whether module is a Bible or not | ||
60 | |||
61 | QTextBrowser *m_textView; // Displays module's text | ||
62 | QString m_fullKey; // Contains full key text in format 'key (module)' | ||
63 | QString m_abbrevKey; // Contains abbreviated key text | ||
64 | |||
65 | int m_numVerses; // Number of verses to display at a time for Bible modules | ||
66 | |||
67 | void setText(); | ||
68 | |||
69 | signals: | ||
70 | void sigRefClicked( const QString &ref ); | ||
71 | }; | ||
72 | |||
73 | #endif | ||
diff --git a/pics/dagger/autoscroll.png b/pics/dagger/autoscroll.png new file mode 100644 index 0000000..489daf8 --- a/dev/null +++ b/pics/dagger/autoscroll.png | |||
Binary files differ | |||
diff --git a/pics/dagger/bibletext.png b/pics/dagger/bibletext.png new file mode 100644 index 0000000..59e09c2 --- a/dev/null +++ b/pics/dagger/bibletext.png | |||
Binary files differ | |||
diff --git a/pics/dagger/bookmarkadd.png b/pics/dagger/bookmarkadd.png new file mode 100644 index 0000000..9e0054f --- a/dev/null +++ b/pics/dagger/bookmarkadd.png | |||
Binary files differ | |||
diff --git a/pics/dagger/bookmarkremove.png b/pics/dagger/bookmarkremove.png new file mode 100644 index 0000000..85a5645 --- a/dev/null +++ b/pics/dagger/bookmarkremove.png | |||
Binary files differ | |||
diff --git a/pics/dagger/commentary.png b/pics/dagger/commentary.png new file mode 100644 index 0000000..b9f198e --- a/dev/null +++ b/pics/dagger/commentary.png | |||
Binary files differ | |||
diff --git a/pics/dagger/dagger.png b/pics/dagger/dagger.png new file mode 100644 index 0000000..fa3a053 --- a/dev/null +++ b/pics/dagger/dagger.png | |||
Binary files differ | |||
diff --git a/pics/dagger/lexicon.png b/pics/dagger/lexicon.png new file mode 100644 index 0000000..4a0fe15 --- a/dev/null +++ b/pics/dagger/lexicon.png | |||
Binary files differ | |||