summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/dagger/.cvsignore5
-rw-r--r--noncore/apps/dagger/config.in4
-rw-r--r--noncore/apps/dagger/configuredlg.cpp139
-rw-r--r--noncore/apps/dagger/configuredlg.h75
-rw-r--r--noncore/apps/dagger/dagger.pro24
-rw-r--r--noncore/apps/dagger/main.cpp22
-rw-r--r--noncore/apps/dagger/mainwindow.cpp710
-rw-r--r--noncore/apps/dagger/mainwindow.h134
-rw-r--r--noncore/apps/dagger/navbar.cpp93
-rw-r--r--noncore/apps/dagger/navbar.h58
-rw-r--r--noncore/apps/dagger/opentextdlg.cpp98
-rw-r--r--noncore/apps/dagger/opentextdlg.h49
-rw-r--r--noncore/apps/dagger/opie-dagger.control11
-rw-r--r--noncore/apps/dagger/searchbar.cpp167
-rw-r--r--noncore/apps/dagger/searchbar.h57
-rw-r--r--noncore/apps/dagger/swordoptionlist.h44
-rw-r--r--noncore/apps/dagger/textwidget.cpp183
-rw-r--r--noncore/apps/dagger/textwidget.h73
-rw-r--r--pics/dagger/autoscroll.pngbin0 -> 919 bytes
-rw-r--r--pics/dagger/bibletext.pngbin0 -> 821 bytes
-rw-r--r--pics/dagger/bookmarkadd.pngbin0 -> 752 bytes
-rw-r--r--pics/dagger/bookmarkremove.pngbin0 -> 620 bytes
-rw-r--r--pics/dagger/commentary.pngbin0 -> 812 bytes
-rw-r--r--pics/dagger/dagger.pngbin0 -> 2101 bytes
-rw-r--r--pics/dagger/lexicon.pngbin0 -> 776 bytes
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 @@
+Makefile*
+moc*
+.moc*
+.obj
+.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 @@
+ config DAGGER
+ boolean "opie-dagger (Bible study/reader application - requires libsword)"
+ default "n"
+ 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 @@
+/*
+Dagger - A Bible study program utilizing the Sword library.
+Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+
+This file is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this
+file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "configuredlg.h"
+
+#include <qvbuttongroup.h>
+#include <qlabel.h>
+#include <qlayout.h>
+
+ConfigureDlg::ConfigureDlg( QWidget *parent, const QString &swordPath, bool alwaysOpenNew, int numVerses,
+ bool disableBlanking, int copyFormat, const QFont *font )
+ : QDialog( parent, QString::null, true )
+ , m_tabs( this )
+{
+ setCaption( tr( "Configure Dagger" ) );
+
+ QVBoxLayout *layout = new QVBoxLayout( this );
+ layout->setMargin( 4 );
+ layout->addWidget( &m_tabs );
+
+ // General tab
+ QWidget *widget = new QWidget( this );
+ QGridLayout *grid = new QGridLayout( widget, 1, 2, 4, 2 );
+ grid->setRowStretch( 9, 5 );
+ grid->setColStretch( 0, 2 );
+
+ QLabel *label = new QLabel( tr( "Path where Sword modules are located:" ), widget );
+ label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak );
+ grid->addMultiCellWidget( label, 0, 0, 0, 1 );
+ m_swordPath = new QLineEdit( swordPath, widget );
+ grid->addMultiCellWidget( m_swordPath, 1, 1, 0, 1 );
+ label = new QLabel( tr( "(Note: Dagger must be restarted for this option to take affect.)" ), widget );
+ label->setAlignment( Qt::AlignHCenter | Qt::AlignTop | Qt::WordBreak );
+ grid->addMultiCellWidget( label, 2, 2, 0, 1 );
+
+ grid->addRowSpacing( 3, 15 );
+
+ m_alwaysOpenNew = new QCheckBox( tr( "Always open texts in new window?" ), widget );
+ m_alwaysOpenNew->setChecked( alwaysOpenNew );
+ grid->addMultiCellWidget( m_alwaysOpenNew, 4, 4, 0, 1 );
+
+ grid->addRowSpacing( 5, 15 );
+
+ label = new QLabel( tr( "Number of verses to display at a time:" ), widget );
+ label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak );
+ grid->addWidget( label, 6, 0 );
+ m_numVerses = new QSpinBox( 1, 20, 1, widget );
+ m_numVerses->setValue( numVerses );
+ grid->addWidget( m_numVerses, 6, 1 );
+
+ grid->addRowSpacing( 7, 15 );
+
+ m_disableScreenBlank = new QCheckBox( tr( "Disable automatic screen power-down?" ), widget );
+ m_disableScreenBlank->setChecked( disableBlanking );
+ grid->addMultiCellWidget( m_disableScreenBlank, 8, 8, 0, 1 );
+
+ m_tabs.addTab( widget, "SettingsIcon", tr( "General" ) );
+
+ // Copy tab
+ widget = new QWidget( this );
+ layout = new QVBoxLayout( widget );
+ layout->setMargin( 4 );
+
+ QVButtonGroup *bg = new QVButtonGroup( tr( "Select copy format" ), widget );
+ m_copyTextFull = new QRadioButton( tr( "\"Verse (Book cc:vv, text)\"" ), bg );
+ connect( m_copyTextFull, SIGNAL(clicked()), this, SLOT(slotCopyFormatSelected()) );
+ m_copyFull = new QRadioButton( tr( "\"Verse (Book cc:vv)\"" ), bg );
+ connect( m_copyFull, SIGNAL(clicked()), this, SLOT(slotCopyFormatSelected()) );
+ m_copyVerse = new QRadioButton( tr( "\"Verse\"" ), bg );
+ connect( m_copyVerse, SIGNAL(clicked()), this, SLOT(slotCopyFormatSelected()) );
+ m_copyKey = new QRadioButton( tr( "\"Book cc:vv\"" ), bg );
+ connect( m_copyKey, SIGNAL(clicked()), this, SLOT(slotCopyFormatSelected()) );
+ layout->addWidget( bg );
+
+ layout->addSpacing( 15 );
+
+ label = new QLabel( tr( "Example:" ), widget );
+ label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak );
+ layout->addWidget( label );
+
+ layout->addSpacing( 15 );
+
+ m_copyExample = new QLabel( widget );
+ m_copyExample->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak );
+ layout->addWidget( m_copyExample );
+
+ if ( copyFormat == 0 )
+ m_copyTextFull->animateClick();
+ else if ( copyFormat == 1 )
+ m_copyFull->animateClick();
+ else if ( copyFormat == 2 )
+ m_copyVerse->animateClick();
+ else if ( copyFormat == 3 )
+ m_copyKey->animateClick();
+
+ layout->addStretch();
+
+ m_tabs.addTab( widget, "copy", tr( "Copy" ) );
+
+ // Font tab
+ m_font = new Opie::Ui::OFontSelector( true, this );
+ if ( font )
+ m_font->setSelectedFont( *font );
+ m_tabs.addTab( m_font, "font", tr( "Font" ) );
+
+ m_tabs.setCurrentTab( tr( "General" ) );
+}
+
+void ConfigureDlg::slotCopyFormatSelected()
+{
+ const QObject *option = sender();
+
+ QString text = tr( "KJV" );
+ QString verse = tr( "In the beginning God created the heaven and the earth." );
+ QString key = tr( "Gen 1:1" );
+
+ if ( option == m_copyTextFull && m_copyTextFull->isChecked() )
+ m_copyExample->setText( QString( "%1 (%2, %3)" ).arg( verse ).arg( key ).arg( text ) );
+ else if ( option == m_copyFull && m_copyFull->isChecked() )
+ m_copyExample->setText( QString( "%1 (%2)" ).arg( verse ).arg( key ) );
+ else if ( option == m_copyVerse && m_copyVerse->isChecked() )
+ m_copyExample->setText( verse );
+ else if ( option == m_copyKey && m_copyKey->isChecked() )
+ m_copyExample->setText( key );
+}
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 @@
+/*
+Dagger - A Bible study program utilizing the Sword library.
+Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+
+This file is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this
+file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef CONFIGUREDLG_H
+#define CONFIGUREDLG_H
+
+#include <opie2/ofontselector.h>
+#include <opie2/otabwidget.h>
+
+#include <qcheckbox.h>
+#include <qdialog.h>
+#include <qlineedit.h>
+#include <qradiobutton.h>
+#include <qspinbox.h>
+
+class QLabel;
+
+class ConfigureDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ ConfigureDlg( QWidget *parent = 0x0, const QString &swordPath = 0x0, bool alwaysOpenNew = true,
+ int numVerses = 5, bool disableBlanking = false, int copyFormat = 0, const QFont *font = 0x0 );
+
+ QString swordPath() { return m_swordPath->text(); }
+ bool alwaysOpenNew() { return m_alwaysOpenNew->isChecked(); }
+ int numVerses() { return m_numVerses->value(); }
+ bool screenBlank() { return m_disableScreenBlank->isChecked(); }
+ int copyFormat() { if ( m_copyFull->isChecked() )
+ return 1;
+ else if ( m_copyVerse->isChecked() )
+ return 2;
+ else if ( m_copyKey->isChecked() )
+ return 3;
+ else
+ return 0; }
+ QFont selectedFont() { return m_font->selectedFont(); }
+
+private:
+ Opie::Ui::OTabWidget m_tabs; // Main widget
+ Opie::Ui::OFontSelector *m_font; // Font selection widget
+
+ // General tab's UI controls
+ QLineEdit *m_swordPath; // Contains path to Sword modules
+ QCheckBox *m_alwaysOpenNew; // Indicates whether to always open modules in a new tab
+ QSpinBox *m_numVerses; // Contains number of verses to display for Bible modules
+ QCheckBox *m_disableScreenBlank; // Indicates whether to disable automatic screen blanking
+
+ // Copy tab's UI controls
+ QRadioButton *m_copyTextFull; // Verse (Text, Book cc:vv)
+ QRadioButton *m_copyFull; // Verse (Book cc:vv)
+ QRadioButton *m_copyVerse; // Verse
+ QRadioButton *m_copyKey; // Book cc:vv
+ QLabel *m_copyExample; // Text of copy format example
+
+private slots:
+ void slotCopyFormatSelected();
+};
+
+#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 @@
+CONFIG = qt warn_on release quick-app
+
+SOURCES = mainwindow.cpp \
+ navbar.cpp \
+ searchbar.cpp \
+ opentextdlg.cpp \
+ configuredlg.cpp \
+ textwidget.cpp \
+ main.cpp
+HEADERS = mainwindow.h \
+ navbar.h \
+ searchbar.h \
+ opentextdlg.h \
+ configuredlg.h \
+ textwidget.h \
+ swordoptionlist.h
+
+TARGET = dagger
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lopiecore2 -lopieui2 -lqpe -lsword
+
+include ( $(OPIEDIR)/include.pro )
+
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 @@
+/*
+Dagger - A Bible study program utilizing the Sword library.
+Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+
+This file is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this
+file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "mainwindow.h"
+
+#include <opie2/oapplicationfactory.h>
+
+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 @@
+/*
+Dagger - A Bible study program utilizing the Sword library.
+Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+
+This file is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this
+file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "mainwindow.h"
+#include "navbar.h"
+#include "searchbar.h"
+#include "opentextdlg.h"
+#include "configuredlg.h"
+#include "textwidget.h"
+
+#include <opie2/odebug.h>
+
+#include <qpe/qcopenvelope_qws.h>
+#include <qpe/qpeapplication.h>
+#include <qpe/resource.h>
+
+#include <qaction.h>
+#include <qclipboard.h>
+#include <qmenubar.h>
+#include <qobjectlist.h>
+#include <qpopupmenu.h>
+#include <qtimer.h>
+#include <qtoolbar.h>
+
+#include <markupfiltmgr.h>
+
+MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ )
+ : QMainWindow( parent, name, WStyle_ContextHelp )
+ , m_config( "dagger" )
+ , m_tabs( this )
+ , m_autoScrollTimer( this )
+{
+ // Initialize sword library manager
+ m_config.setGroup( "Sword" );
+ m_modulePath = m_config.readEntry( "ModPath", "/usr/local/share/sword" );
+ m_swordMgr = new sword::SWMgr( m_modulePath.latin1(), true,
+ new sword::MarkupFilterMgr( sword::FMT_HTMLHREF ) );
+
+ // Retrieve list of available Sword module options (e.g. footnotes, Strong's numbers, etc.)
+ sword::OptionsList swordOpts = m_swordMgr->getGlobalOptions();
+ for ( sword::OptionsList::iterator it = swordOpts.begin(); it != swordOpts.end(); it++ )
+ m_actionSwordOpts.append( new QAction( (*it).c_str(), QString::null, 0, this, 0 ) );
+ m_actionSwordOpts.sort();
+
+ // Initialize user interface
+ setCaption( tr( "Dagger" ) );
+ initUI();
+
+ connect( &m_tabs, SIGNAL(currentChanged(QWidget *)), this, SLOT( slotTextDisplayed(QWidget *)) );
+ connect( &m_autoScrollTimer, SIGNAL(timeout()), this, SLOT(slotNavNextVerse()) );
+
+ m_bibleIcon = new QPixmap( Resource::loadPixmap( "dagger/bibletext" ) );
+ m_commentaryIcon = new QPixmap( Resource::loadPixmap( "dagger/commentary" ) );
+ m_lexiconIcon = new QPixmap( Resource::loadPixmap( "dagger/lexicon" ) );
+
+ // Load initial configuration
+ QTimer::singleShot( 100, this, SLOT( initConfig() ) );
+}
+
+MainWindow::~MainWindow()
+{
+ // Save Sword options
+ m_config.setGroup( "Sword" );
+ m_config.writeEntry( "ModPath", m_modulePath );
+
+ for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() )
+ m_config.writeEntry( a->text(), a->isOn() );
+
+ // Save configuration options
+ m_config.setGroup( "Config" );
+ m_config.writeEntry( "AlwaysOpenNew", m_alwaysOpenNew );
+ m_config.writeEntry( "AutoScroll", m_navToolbar->autoScrollRate() );
+ m_config.writeEntry( "DisableScreenBlanking", m_disableScreenBlank );
+ m_config.writeEntry( "CopyFormat", m_copyFormat );
+ m_config.writeEntry( "NavBar", m_actionViewNavToolbar->isOn() );
+ m_config.writeEntry( "NumVerses", m_numVerses );
+ m_config.writeEntry( "SearchBar", m_actionViewSearchToolbar->isOn() );
+
+ // Save text font
+ m_config.setGroup( "Font");
+ m_config.writeEntry( "Family", m_textFont.family() );
+ m_config.writeEntry( "Italic", m_textFont.italic() );
+ m_config.writeEntry( "Size", m_textFont.pointSize() );
+ m_config.writeEntry( "Weight", m_textFont.weight() );
+
+ // Save bookmarks
+ m_config.setGroup( "Bookmarks");
+ m_config.clearGroup();
+ int index = 3;
+ int id = m_bookmarkMenu->idAt( index );
+ while ( id != -1 )
+ {
+ QString bookmark = m_bookmarkMenu->text( id );
+ int pos = bookmark.find( " (" );
+ QString key = bookmark.left( pos );
+ pos += 2;
+ QString module = bookmark.mid( pos, bookmark.find( ")", pos ) - pos );
+ QString modkey;
+ modkey.sprintf( "%s/%s", module.latin1(), key.latin1() );
+ m_config.writeEntry( QString::number( index - 2 ), modkey );
+
+ ++index;
+ id = m_bookmarkMenu->idAt( index );
+ }
+
+ // Save opened modules
+ m_config.setGroup( "Session");
+ m_config.clearGroup();
+ QObjectList *childlist = queryList( "TextWidget" );
+ QObjectListIt it( *childlist );
+ TextWidget *module;
+ int count = 1;
+ while ( ( module = reinterpret_cast<TextWidget *>(it.current()) ) != 0 )
+ {
+ QString modkey;
+ modkey.sprintf( "%s/%s", module->getModuleName().latin1(), module->getAbbrevKey().latin1() );
+ m_config.writeEntry( QString::number( count ), modkey );
+ ++count;
+ ++it;
+ }
+}
+
+bool MainWindow::eventFilter( QObject *obj, QEvent *event )
+{
+ if ( event->type() == QEvent::KeyPress )
+ {
+ QKeyEvent *keyev = reinterpret_cast<QKeyEvent *>(event);
+ if ( keyev->key() == Key_Up )
+ {
+ slotNavPrevVerse();
+ return true;
+ }
+ else if ( keyev->key() == Key_Down )
+ {
+ slotNavNextVerse();
+ return true;
+ }
+ }
+
+ return QWidget::eventFilter( obj, event );
+}
+
+void MainWindow::initUI()
+{
+ setCentralWidget( &m_tabs );
+ m_tabs.installEventFilter( this );
+
+ setToolBarsMovable( false );
+ m_barDock = new QToolBar( this );
+ m_barDock->setHorizontalStretchable( true );
+
+ m_menuBar = new QMenuBar( m_barDock );
+ m_menuBar->setMargin( 0 );
+
+ // Allocate toolbars
+ m_navToolbar = new NavBar( this );
+ m_navToolbar->navBtnsEnable( false );
+ connect( m_navToolbar, SIGNAL(prevChapter()), this, SLOT(slotNavPrevChapter()) );
+ connect( m_navToolbar, SIGNAL(prevVerse()), this, SLOT(slotNavPrevVerse()) );
+ connect( m_navToolbar, SIGNAL(keyChanged(const QString &)), this, SLOT(slotNavKeyChanged(const QString &)) );
+ connect( m_navToolbar, SIGNAL(nextVerse()), this, SLOT(slotNavNextVerse()) );
+ connect( m_navToolbar, SIGNAL(nextChapter()), this, SLOT(slotNavNextChapter()) );
+ connect( m_navToolbar, SIGNAL(autoScroll(bool)), this, SLOT(slotNavAutoScroll(bool)) );
+ connect( m_navToolbar, SIGNAL(scrollRateChanged(int)), this, SLOT(slotNavScrollRateChanged(int)) );
+
+ m_searchToolbar = new SearchBar( this );
+ connect( m_searchToolbar, SIGNAL(sigResultClicked(const QString &)), this, SLOT(slotSearchResultClicked(const QString &)) );
+
+ // Text menu
+ QPopupMenu *popup = new QPopupMenu( this );
+
+ QAction *a = new QAction( tr( "Open..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
+ connect( a, SIGNAL(activated()), this, SLOT(slotTextOpen()) );
+ a->addTo( popup );
+
+ m_actionTextClose = new QAction( tr( "Close" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
+ connect( m_actionTextClose, SIGNAL(activated()), this, SLOT(slotTextClose()) );
+ m_actionTextClose->addTo( popup );
+
+ popup->insertSeparator();
+
+ // TODO - need to implent
+ a = new QAction( tr( "Install..." ), Resource::loadPixmap( "install" ), QString::null, 0, this, 0 );
+ a->setEnabled( false );
+ connect( a, SIGNAL(activated()), this, SLOT(slotTextInstall()) );
+ a->addTo( popup );
+
+ m_menuBar->insertItem( tr( "Text" ), popup );
+
+ // Edit menu
+ popup = new QPopupMenu( this );
+
+ m_actionEditCopy = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 );
+ connect( m_actionEditCopy, SIGNAL(activated()), this, SLOT(slotEditCopy()) );
+ m_actionEditCopy->addTo( popup );
+
+ popup->insertSeparator();
+
+ a = new QAction( tr( "Configure..." ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
+ connect( a, SIGNAL(activated()), this, SLOT(slotEditConfigure()) );
+ a->addTo( popup );
+
+ m_menuBar->insertItem( tr( "Edit" ), popup );
+
+ // Bookmark menu
+ m_bookmarkMenu = new QPopupMenu( this );
+
+ m_actionBookmarkAdd = new QAction( tr( "Add" ), Resource::loadPixmap( "dagger/bookmarkadd" ), QString::null, 0, this, 0 );
+ connect( m_actionBookmarkAdd, SIGNAL(activated()), this, SLOT(slotBookmarkAdd()) );
+ m_actionBookmarkAdd->addTo( m_bookmarkMenu );
+
+ m_actionBookmarkRemove = new QAction( tr( "Remove" ), Resource::loadPixmap( "dagger/bookmarkremove" ), QString::null, 0, this, 0 );
+ connect( m_actionBookmarkRemove, SIGNAL(activated()), this, SLOT(slotBookmarkRemove()) );
+ m_actionBookmarkRemove->addTo( m_bookmarkMenu );
+
+ m_bookmarkMenu->insertSeparator();
+
+ m_menuBar->insertItem( tr( "Bookmark" ), m_bookmarkMenu );
+
+ // View menu
+ popup = new QPopupMenu( this );
+
+ // Retrieve list of available Sword module options (e.g. footnotes, Strong's numbers, etc.)
+ for ( a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() )
+ {
+ a->setToggleAction( true );
+ connect( a, SIGNAL(toggled(bool)), this, SLOT(slotViewSwordOption(bool)) );
+ a->addTo( popup );
+ }
+
+ popup->insertSeparator();
+
+ m_actionViewNavToolbar = new QAction( tr( "Navigation toolbar" ), QString::null, 0, this, 0 );
+ m_actionViewNavToolbar->setToggleAction( true );
+ connect( m_actionViewNavToolbar, SIGNAL(toggled(bool)), this, SLOT(slotViewNavToolbar(bool)) );
+ m_actionViewNavToolbar->addTo( popup );
+
+ m_actionViewSearchToolbar = new QAction( tr( "Search toolbar" ), QString::null, 0, this, 0 );
+ m_actionViewSearchToolbar->setToggleAction( true );
+ connect( m_actionViewSearchToolbar, SIGNAL(toggled(bool)), this, SLOT(slotViewSearchToolbar(bool)) );
+ m_actionViewSearchToolbar->addTo( popup );
+
+ m_menuBar->insertItem( tr( "View" ), popup );
+}
+
+void MainWindow::openModule( const QString &modulename, const QString &key )
+{
+ sword::SWModule *module = m_swordMgr->Modules[ modulename.latin1() ];
+ if ( module )
+ {
+ TextWidget *tw = 0x0;
+
+ if ( !m_alwaysOpenNew )
+ {
+ // Try to find if the module is already opened, if so will use that TextWidget
+ QObjectList *childlist = queryList( "TextWidget" );
+ QObjectListIt it( *childlist );
+ while ( ( tw = reinterpret_cast<TextWidget *>(it.current()) ) != 0 &&
+ tw->getModuleName() != modulename )
+ ++it;
+ if ( tw && tw->getModuleName() == modulename )
+ {
+ // Set key if one is present
+ if ( !key.isNull() )
+ tw->setKey( key );
+
+ // Raise tab
+ m_tabs.setCurrentTab( tw );
+ }
+ }
+
+ if ( m_alwaysOpenNew || !tw )
+ {
+ // Open module in new tab
+ QString icon;
+ QString type = module->Type();
+
+ if ( type == "Biblical Texts" )
+ icon = "dagger/bibletext";
+ else if ( type == "Commentaries" )
+ icon = "dagger/commentary";
+ else if ( type == "Lexicons / Dictionaries" )
+ icon = "dagger/lexicon";
+
+ tw = new TextWidget( this, module, m_numVerses, &m_textFont );
+ connect( tw, SIGNAL(sigRefClicked(const QString &)),
+ this, SLOT(slotTextRefClicked(const QString &)) );
+ connect( this, SIGNAL(sigNumVersesChanged(int)), tw, SLOT(slotNumVersesChanged(int)) );
+ connect( this, SIGNAL(sigFontChanged(const QFont *)), tw, SLOT(slotFontChanged(const QFont *)) );
+ connect( this, SIGNAL(sigOptionChanged()), tw, SLOT(slotOptionChanged()) );
+
+ m_tabs.addTab( tw, icon, modulename );
+
+ m_actionTextClose->setEnabled( true );
+ m_actionEditCopy->setEnabled( true );
+ m_actionBookmarkAdd->setEnabled( true );
+
+ // Set key if one is present
+ if ( !key.isNull() )
+ tw->setKey( key );
+ }
+ }
+}
+
+int MainWindow::findBookmark( const QString &bookmark )
+{
+ int index = 3;
+ int id = m_bookmarkMenu->idAt( index );
+ while ( ( id != -1 ) && ( m_bookmarkMenu->text( id ) != bookmark ) )
+ {
+ ++index;
+ id = m_bookmarkMenu->idAt( index );
+ }
+
+ return id;
+}
+
+void MainWindow::enableScreenBlanking( bool enable )
+{
+ enable ? QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable
+ : QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Disable;
+}
+
+void MainWindow::initConfig()
+{
+ bool show;
+
+ m_config.setGroup( "Sword" );
+ for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() )
+ {
+ show = m_config.readBoolEntry( a->text(), false );
+ a->setOn( show );
+ m_swordMgr->setGlobalOption ( a->text(), show ? "On" : "Off" );
+ }
+
+ // Display/hide toolbars based on last run
+ m_config.setGroup( "Config" );
+
+ m_alwaysOpenNew = m_config.readBoolEntry( "AlwaysOpenNew", false );
+ m_navToolbar->setAutoScrollRate( m_config.readNumEntry( "AutoScroll", 50 ) );
+ m_disableScreenBlank = m_config.readBoolEntry( "DisableScreenBlanking", false );
+ enableScreenBlanking( !m_disableScreenBlank );
+ m_copyFormat = m_config.readNumEntry( "CopyFormat", 0 );
+
+ show = m_config.readBoolEntry( "NavBar", false );
+ m_actionViewNavToolbar->setOn( show );
+ slotViewNavToolbar( show );
+
+ m_numVerses = m_config.readNumEntry( "NumVerses", 5 );
+
+ show = m_config.readBoolEntry( "SearchBar", false );
+ m_actionViewSearchToolbar->setOn( show );
+ slotViewSearchToolbar( show );
+
+ // Set text font
+ m_config.setGroup( "Font" );
+ QString fontFamily = m_config.readEntry( "Family", QString::null );
+ !fontFamily.isNull() ? m_textFont = QFont( fontFamily,
+ m_config.readNumEntry( "Size", -1 ),
+ m_config.readNumEntry( "Weight", QFont::Normal ),
+ m_config.readBoolEntry( "Italic", false ) )
+ : m_textFont = font(); // If font is not configured, set to default widget font
+
+ // Load bookmarks
+ m_config.setGroup( "Bookmarks");
+ int count = 1;
+ QString key = m_config.readEntry( QString::number( count ), QString::null );
+ while ( !key.isNull() )
+ {
+ int pos = key.find( "/" );
+ if ( pos > -1 )
+ {
+ QString bookmark;
+ bookmark.sprintf( "%s (%s)", key.right( key.length() - ( pos + 1 ) ).latin1(),
+ key.left( pos ).latin1() );
+ QAction *a = new QAction( bookmark, QString::null, 0, this, 0 );
+ a->addTo( m_bookmarkMenu );
+ connect( a, SIGNAL(activated()), this, SLOT(slotBookmarkSelected()) );
+ }
+
+ ++count;
+ key = m_config.readEntry( QString::number( count ), QString::null );
+ }
+ m_actionBookmarkRemove->setEnabled( count > 1 );
+
+ // Load opened modules
+ m_config.setGroup( "Session");
+ QString first;
+ count = 1;
+ key = m_config.readEntry( QString::number( count ), QString::null );
+ while ( !key.isNull() )
+ {
+ int pos = key.find( "/" );
+ if ( pos > -1 )
+ {
+ if ( count == 1 )
+ first = key.left( pos );
+ openModule( key.left( pos ), key.right( key.length() - ( pos + 1 ) ) );
+ }
+
+ ++count;
+ key = m_config.readEntry( QString::number( count ), QString::null );
+ }
+ m_tabs.setCurrentTab( first );
+ TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
+ if ( text )
+ {
+ setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
+ m_navToolbar->setKey( text->getAbbrevKey() );
+ }
+ m_actionTextClose->setEnabled( count > 1 );
+ m_actionEditCopy->setEnabled( count > 1 );
+}
+
+void MainWindow::slotTextDisplayed( QWidget *textWidget )
+{
+ TextWidget *text = reinterpret_cast<TextWidget *>(textWidget);
+ setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
+
+ m_navToolbar->setKey( text->getAbbrevKey() );
+ m_navToolbar->navBtnsEnable( text->isBibleText() );
+
+ m_searchToolbar->setCurrModule( text );
+}
+
+void MainWindow::slotTextOpen()
+{
+ OpenTextDlg dlg( this, m_swordMgr, m_bibleIcon, m_commentaryIcon, m_lexiconIcon );
+ if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
+ {
+ openModule( dlg.selectedText() );
+ }
+}
+
+void MainWindow::slotTextClose()
+{
+ TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
+ if ( text )
+ {
+ m_tabs.removePage( text );
+ delete text;
+
+ // If no other modules are open, disable appropriate UI items
+ if ( !m_tabs.currentWidget() )
+ {
+ m_navToolbar->navBtnsEnable( false );
+ m_navToolbar->setKey( QString::null );
+ m_searchToolbar->setCurrModule( 0x0 );
+ m_actionTextClose->setEnabled( false );
+ m_actionEditCopy->setEnabled( false );
+ m_actionBookmarkAdd->setEnabled( false );
+ m_actionBookmarkRemove->setEnabled( false );
+ }
+ }
+}
+
+void MainWindow::slotTextInstall()
+{
+}
+
+void MainWindow::slotEditCopy()
+{
+ TextWidget *currModule = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
+ if ( currModule )
+ {
+ QString text;
+
+ switch( m_copyFormat )
+ {
+ case 0: text.sprintf( "%s (%s, %s)", currModule->getCurrVerse().latin1(),
+ currModule->getAbbrevKey().latin1(),
+ currModule->getModuleName().latin1() );
+ break;
+ case 1: text.sprintf( "%s (%s)", currModule->getCurrVerse().latin1(),
+ currModule->getAbbrevKey().latin1() );
+ break;
+ case 2: text = currModule->getCurrVerse();
+ break;
+ case 3: text = currModule->getAbbrevKey();
+ break;
+ default: text = QString::null;
+ };
+
+ if ( !text.isNull() )
+ QPEApplication::clipboard()->setText( text );
+ }
+}
+
+void MainWindow::slotEditConfigure()
+{
+ ConfigureDlg dlg( this, m_modulePath, m_alwaysOpenNew, m_numVerses, m_disableScreenBlank, m_copyFormat,
+ &m_textFont );
+ if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
+ {
+ m_modulePath = dlg.swordPath();
+ m_alwaysOpenNew = dlg.alwaysOpenNew();
+ if ( dlg.numVerses() != m_numVerses )
+ {
+ m_numVerses = dlg.numVerses();
+ emit sigNumVersesChanged( m_numVerses );
+ }
+ m_disableScreenBlank = dlg.screenBlank();
+ enableScreenBlanking( !m_disableScreenBlank );
+ m_copyFormat = dlg.copyFormat();
+ m_textFont = dlg.selectedFont();
+ emit sigFontChanged( &m_textFont );
+ }
+}
+
+void MainWindow::slotBookmarkAdd()
+{
+ TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
+ if ( text )
+ {
+ // See if bookmark doesn't already exists
+ QString bookmark = text->getFullKey();
+ int menuId = findBookmark( bookmark );
+ if ( menuId == -1 )
+ {
+ // Bookmark not found, add
+ QAction *a = new QAction( bookmark, QString::null, 0, this, 0 );
+ a->addTo( m_bookmarkMenu );
+ connect( a, SIGNAL(activated()), this, SLOT(slotBookmarkSelected()) );
+
+ // Make sure remove option is enabled
+ m_actionBookmarkRemove->setEnabled( true );
+
+ }
+ }
+}
+
+void MainWindow::slotBookmarkRemove()
+{
+ TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
+ if ( text )
+ {
+ // See if bookmark exists for current module key
+ int menuId = findBookmark( text->getFullKey() );
+ if ( menuId != -1 )
+ {
+ // Bookmark found, remove
+ m_bookmarkMenu->removeItem( menuId );
+
+ //If this was the last bookmark, disable the remove option
+ if ( m_bookmarkMenu->idAt( 3 ) == -1 )
+ m_actionBookmarkRemove->setEnabled( false );
+ }
+ }
+}
+
+void MainWindow::slotBookmarkSelected()
+{
+ const QAction *action = reinterpret_cast<const QAction *>(sender());
+ if ( action )
+ {
+ QString bookmark = action->text();
+ int pos = bookmark.find( " (" );
+ QString key = bookmark.left( pos );
+ pos += 2;
+ QString module = bookmark.mid( pos, bookmark.find( ")", pos ) - pos );
+
+ openModule( module, key );
+ }
+}
+
+void MainWindow::slotViewSwordOption( bool enabled )
+{
+ const QAction *action = reinterpret_cast<const QAction*>(sender());
+ m_swordMgr->setGlobalOption ( action->text(), enabled ? "On" : "Off" );
+
+ emit sigOptionChanged();
+}
+
+void MainWindow::slotViewNavToolbar( bool enabled )
+{
+ enabled ? m_navToolbar->show()
+ : m_navToolbar->hide();
+}
+
+void MainWindow::slotViewSearchToolbar( bool enabled )
+{
+ enabled ? m_searchToolbar->show()
+ : m_searchToolbar->hide();
+}
+
+void MainWindow::slotNavPrevChapter()
+{
+ TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
+ if ( text )
+ {
+ text->prevChapter();
+ setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
+ m_navToolbar->setKey( text->getAbbrevKey() );
+ }
+}
+
+void MainWindow::slotNavPrevVerse()
+{
+ TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
+ if ( text )
+ {
+ text->prevVerse();
+ setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
+ m_navToolbar->setKey( text->getAbbrevKey() );
+ }
+}
+
+void MainWindow::slotNavKeyChanged( const QString &newKey )
+{
+ QString key = newKey;
+ key.replace( QRegExp( "[-=.]" ), ":" );
+
+ TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
+ if ( text )
+ {
+ text->setKey( key );
+ setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
+ }
+}
+
+void MainWindow::slotNavNextVerse()
+{
+ TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
+ if ( text )
+ {
+ text->nextVerse();
+ setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
+ m_navToolbar->setKey( text->getAbbrevKey() );
+ }
+}
+
+void MainWindow::slotNavNextChapter()
+{
+ TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
+ if ( text )
+ {
+ text->nextChapter();
+ setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
+ m_navToolbar->setKey( text->getAbbrevKey() );
+ }
+}
+
+void MainWindow::slotNavAutoScroll( bool enabled )
+{
+ m_autoScrollTimer.stop();
+
+ if ( enabled )
+ m_autoScrollTimer.start( m_navToolbar->autoScrollRate() * 100 );
+}
+
+void MainWindow::slotNavScrollRateChanged( int newRate )
+{
+ if ( m_autoScrollTimer.isActive() )
+ {
+ m_autoScrollTimer.stop();
+ m_autoScrollTimer.start( newRate * 100 );
+ }
+}
+
+void MainWindow::slotSearchResultClicked( const QString &key )
+{
+ TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
+ if ( text )
+ {
+ text->setKey( key );
+ setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
+ m_navToolbar->setKey( text->getAbbrevKey() );
+ }
+}
+
+void MainWindow::slotTextRefClicked( const QString &ref )
+{
+ //owarn << "Reference: " << ref << oendl;
+ if ( !ref.isNull() )
+ {
+ TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
+ if ( text )
+ {
+ QString module;
+ QString key( ref );
+ key.remove( 0, 2 );
+
+ QChar book = ref.at( 1 );
+ // TODO- this is ugly, need better way to determine type of reference
+ // take a look at SWModule::getRawEntry()
+ int keyValue = key.toInt();
+ if ( book == 'H' && keyValue <= 8674 )
+ module = "StrongsHebrew";
+ else if ( book == 'G' && keyValue <= 5624 )
+ module = "StrongsGreek";
+
+ if ( !module.isEmpty() )
+ openModule( module, key );
+ }
+ }
+}
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 @@
+/*
+Dagger - A Bible study program utilizing the Sword library.
+Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+
+This file is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this
+file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include "swordoptionlist.h"
+
+#include <opie2/otabwidget.h>
+
+#include <qpe/config.h>
+
+#include <qmainwindow.h>
+#include <qtimer.h>
+
+#include <swmgr.h>
+
+class QAction;
+class QMenuBar;
+class QPixmap;
+class QToolBar;
+
+class NavBar;
+class SearchBar;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow( QWidget *parent = 0x0, const char *name = 0x0, WFlags fl = 0 );
+ ~MainWindow();
+
+ static QString appName() { return QString::fromLatin1( "dagger" ); };
+
+protected:
+ bool eventFilter( QObject *obj, QEvent *event );
+
+private:
+ sword::SWMgr *m_swordMgr; // Sword library module manager
+ Config m_config; // Application configuration
+
+ // Configuration items
+ QString m_modulePath; // Directory where sword modules are located
+ bool m_alwaysOpenNew; // Whether or not open modules as new window/tab (or re-use existing)
+ int m_numVerses; // Number of verses to display at a time for Bible modules
+ bool m_disableScreenBlank; // Whether or not to disable automatic screen blanking
+ int m_copyFormat; // Format used when copying
+ QFont m_textFont; // Font used for module text
+
+ // UI components
+ QToolBar *m_barDock; // Main toolbar which contains menu and all other toolbars
+ QMenuBar *m_menuBar; // Application menu bar
+ QPopupMenu *m_bookmarkMenu; // Pointer to bookmark menu
+ NavBar *m_navToolbar; // Text navigation toolbar
+ SearchBar *m_searchToolbar; // Text search toolbar
+ Opie::Ui::OTabWidget m_tabs; // Main widget in which all texts, notes, etc. will be displayed
+
+ // Other visual items
+ QPixmap *m_bibleIcon; // Icon used for bible modules
+ QPixmap *m_commentaryIcon; // Icon used for commentary modules
+ QPixmap *m_lexiconIcon; // Icon used for lexicon modules
+
+ QTimer m_autoScrollTimer; // Timer for auto-scrolling of bible texts
+
+ // Menubar/toolbar actions
+ SwordOptionList m_actionSwordOpts; // List of actions for sword options
+ // (e.g. footnotes, Strong's numbers, etc.)
+ QAction *m_actionTextClose; // Action for closing currently opened module
+ QAction *m_actionEditCopy; // Action for copying text from current module
+ QAction *m_actionBookmarkAdd; // Action for adding a bookmark
+ QAction *m_actionBookmarkRemove; // Action for removing a bookmark
+ QAction *m_actionViewNavToolbar; // Action for displaying/hiding the navigation toolbar
+ QAction *m_actionViewSearchToolbar; // Action for displaying/hiding the search toolbar
+
+ void initUI();
+ void openModule( const QString &modulename, const QString &key = 0x0 );
+ int findBookmark( const QString &bookmark );
+ void enableScreenBlanking( bool enable );
+
+private slots:
+ void initConfig();
+
+ void slotTextDisplayed( QWidget *textWidget );
+
+ // Menubar/toolbar action slots
+ void slotTextOpen();
+ void slotTextClose();
+ void slotTextInstall();
+ void slotEditCopy();
+ void slotEditConfigure();
+ void slotBookmarkAdd();
+ void slotBookmarkRemove();
+ void slotBookmarkSelected();
+ void slotViewSwordOption( bool enabled );
+ void slotViewNavToolbar( bool enabled );
+ void slotViewSearchToolbar( bool enabled );
+
+ // Navigation toolbar slots
+ void slotNavPrevChapter();
+ void slotNavPrevVerse();
+ void slotNavKeyChanged( const QString &newKey );
+ void slotNavNextVerse();
+ void slotNavNextChapter();
+ void slotNavAutoScroll( bool enabled );
+ void slotNavScrollRateChanged( int newRate );
+
+ // Search toolbar slots
+ void slotSearchResultClicked( const QString &key );
+
+ // Text widget slots
+ void slotTextRefClicked( const QString &ref );
+
+signals:
+ void sigNumVersesChanged( int numVerses );
+ void sigFontChanged( const QFont *newFont );
+ void sigOptionChanged();
+};
+
+#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 @@
+/*
+Dagger - A Bible study program utilizing the Sword library.
+Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+
+This file is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this
+file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "navbar.h"
+
+#include <qpe/config.h>
+#include <qpe/resource.h>
+
+#include <qaction.h>
+#include <qlineedit.h>
+
+NavBar::NavBar( QMainWindow *parent )
+ : QToolBar( QString::null, parent, QMainWindow::Top, true )
+{
+ // Initialize UI
+ m_actionPrevChapter = new QAction( tr( "Previous chapter" ), Resource::loadPixmap( "fastback" ),
+ QString::null, 0, this, 0 );
+ m_actionPrevChapter->addTo( this );
+ connect( m_actionPrevChapter, SIGNAL(activated()), this, SIGNAL(prevChapter()) );
+
+ m_actionPrevVerse = new QAction( tr( "Previous verse" ), Resource::loadPixmap( "back" ),
+ QString::null, 0, this, 0 );
+ m_actionPrevVerse->addTo( this );
+ connect( m_actionPrevVerse, SIGNAL(activated()), this, SIGNAL(prevVerse()) );
+
+ m_key = new QLineEdit( this );
+ setStretchableWidget( m_key );
+ connect(m_key, SIGNAL(textChanged(const QString &)), this, SIGNAL(keyChanged(const QString &)) );
+
+ m_actionNextVerse = new QAction( tr( "Next verse" ), Resource::loadPixmap( "forward" ),
+ QString::null, 0, this, 0 );
+ m_actionNextVerse->addTo( this );
+ connect( m_actionNextVerse, SIGNAL(activated()), this, SIGNAL(nextVerse()) );
+
+ m_actionNextChapter = new QAction( tr( "Next chapter" ), Resource::loadPixmap( "fastforward" ),
+ QString::null, 0, this, 0 );
+ m_actionNextChapter->addTo( this );
+ connect( m_actionNextChapter, SIGNAL(activated()), this, SIGNAL(nextChapter()) );
+
+ addSeparator();
+
+ m_scrollRate = new QSpinBox( 1, 100, 1, this );
+ m_scrollRate->setMinimumWidth( 35 );
+ connect( m_scrollRate, SIGNAL(valueChanged(int)), this, SIGNAL(scrollRateChanged(int)) );
+
+ m_actionScroll = new QAction( tr( "Auto-scroll" ), Resource::loadPixmap( "dagger/autoscroll" ),
+ QString::null, 0, this, 0 );
+ m_actionScroll->setToggleAction( true );
+ connect( m_actionScroll, SIGNAL(toggled(bool)), this, SIGNAL(autoScroll(bool)) );
+ m_actionScroll->addTo( this );
+
+ if ( parent )
+ {
+ installEventFilter( parent );
+ m_key->installEventFilter( parent );
+ }
+}
+
+void NavBar::navBtnsEnable( bool enabled )
+{
+ m_actionPrevChapter->setEnabled( enabled );
+ m_actionPrevVerse->setEnabled( enabled );
+ m_actionNextVerse->setEnabled( enabled );
+ m_actionNextChapter->setEnabled( enabled );
+ m_scrollRate->setEnabled( enabled );
+ m_actionScroll->setEnabled( enabled );
+}
+
+void NavBar::setKey( const QString &newKey )
+{
+ disconnect( m_key, SIGNAL(textChanged(const QString &)), 0, 0 );
+ m_key->setText( newKey );
+ connect(m_key, SIGNAL(textChanged(const QString &)), this, SIGNAL(keyChanged(const QString &)) );
+}
+
+void NavBar::setAutoScrollRate( int scrollRate )
+{
+ m_scrollRate->setValue( scrollRate );
+}
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 @@
+/*
+Dagger - A Bible study program utilizing the Sword library.
+Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+
+This file is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this
+file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef NAVBAR_H
+#define NAVBAR_H
+
+#include <qspinbox.h>
+#include <qtoolbar.h>
+
+class QAction;
+class QLineEdit;
+
+class NavBar : public QToolBar
+{
+ Q_OBJECT
+
+public:
+ NavBar( QMainWindow *parent = 0x0 );
+
+ void navBtnsEnable( bool enabled );
+ void setKey( const QString &newKey );
+ void setAutoScrollRate( int scrollRate );
+ const int autoScrollRate() { return m_scrollRate->value(); }
+
+private:
+ QAction *m_actionPrevChapter; // Action for going back 1 chapter
+ QAction *m_actionPrevVerse; // Action for going back 1 verse
+ QLineEdit *m_key; // Edit box to enter key to goto
+ QAction *m_actionNextVerse; // Action for going forward 1 verse
+ QAction *m_actionNextChapter; // Action for going forward 1 chapter
+ QSpinBox *m_scrollRate; // Spin box to adjust rate of auto-scrolling
+ QAction *m_actionScroll; // Action to start/stop auto-scrolling
+
+signals:
+ void prevChapter();
+ void prevVerse();
+ void keyChanged( const QString &newKey );
+ void nextVerse();
+ void nextChapter();
+ void autoScroll( bool enabled );
+ void scrollRateChanged( int newRate );
+};
+
+#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 @@
+/*
+Dagger - A Bible study program utilizing the Sword library.
+Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+
+This file is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this
+file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "opentextdlg.h"
+
+#include <qpe/resource.h>
+
+#include <qheader.h>
+#include <qlayout.h>
+#include <qpixmap.h>
+
+OpenTextDlg::OpenTextDlg( QWidget *parent, sword::SWMgr *swordMgr, QPixmap *bibleIcon,
+ QPixmap *commentaryIcon, QPixmap *lexiconIcon )
+ : QDialog( parent, QString::null, true )
+ , m_textList( this )
+{
+ setCaption( tr( "Open text" ) );
+
+ QVBoxLayout *layout = new QVBoxLayout( this );
+ layout->setMargin( 4 );
+ layout->addWidget( &m_textList );
+
+ m_textList.setRootIsDecorated( true );
+ m_textList.addColumn( tr( "Icon" ),35 );
+ m_textList.addColumn( tr( "Text" ) );
+ m_textList.header()->hide();
+ m_textList.setAllColumnsShowFocus( true );
+ m_textList.setSorting( 1 );
+
+ m_commentaries = new QListViewItem( &m_textList, QString::null, tr( "Commentaries" ) );
+ m_commentaries->setPixmap( 0, *commentaryIcon );
+ m_textList.insertItem( m_commentaries );
+ m_lexicons = new QListViewItem( &m_textList, QString::null, tr( "Lexicons/Dictionaries" ) );
+ m_lexicons->setPixmap( 0, *lexiconIcon );
+ m_textList.insertItem( m_lexicons );
+ m_bibles = new QListViewItem( &m_textList, QString::null, tr( "Biblical Texts" ) );
+ m_bibles->setPixmap( 0, *bibleIcon );
+ m_textList.insertItem( m_bibles );
+ connect( &m_textList, SIGNAL(clicked(QListViewItem*)), this, SLOT(slotItemClicked(QListViewItem*)) );
+
+ if ( swordMgr )
+ {
+ sword::ModMap::iterator it;
+ QString type;
+ QPixmap *icon = 0x0;
+ QListViewItem *parent = 0x0;
+
+ for ( it = swordMgr->Modules.begin(); it != swordMgr->Modules.end(); it++ )
+ {
+ type = it->second->Type();
+ if ( type == "Biblical Texts" )
+ {
+ icon = bibleIcon;
+ parent = m_bibles;
+ }
+ else if ( type == "Commentaries" )
+ {
+ icon = commentaryIcon;
+ parent = m_commentaries;
+ }
+ else if ( type == "Lexicons / Dictionaries" )
+ {
+ icon = lexiconIcon;
+ parent = m_lexicons;
+ }
+
+ parent->insertItem( new QListViewItem( parent, QString::null, it->first.c_str() ) );
+ }
+ }
+
+ m_textList.sort();
+}
+
+void OpenTextDlg::slotItemClicked( QListViewItem *item )
+{
+ if ( item == m_bibles || item == m_lexicons || item == m_commentaries )
+ {
+ m_textList.clearSelection();
+ if ( item->childCount() > 0 )
+ {
+ item->setOpen( !item->isOpen() );
+ }
+ }
+}
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 @@
+/*
+Dagger - A Bible study program utilizing the Sword library.
+Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+
+This file is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this
+file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef OPENTEXTDLG_H
+#define OPENTEXTDLG_H
+
+#include <qdialog.h>
+#include <qlistview.h>
+
+#include <swmgr.h>
+
+class QPixmap;
+
+class OpenTextDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ OpenTextDlg( QWidget *parent = 0x0, sword::SWMgr *swordMgr = 0x0, QPixmap *bibleIcon = 0x0,
+ QPixmap *commentaryIcon = 0x0, QPixmap *lexiconIcon = 0x0 );
+
+ QString selectedText() { return m_textList.currentItem()->text( 1 ); };
+
+private:
+ QListView m_textList; // List of available texts/modules
+
+ QListViewItem *m_bibles; // Pointer to bible section header
+ QListViewItem *m_lexicons; // Pointer to lexicon/dictionary section header
+ QListViewItem *m_commentaries; // Pointer to commentary section header
+
+private slots:
+ void slotItemClicked( QListViewItem *item );
+};
+
+#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 @@
+Package: opie-dagger
+Files: plugins/application/libdagger.so* bin/dagger pics/dagger apps/Applications/dagger.desktop
+Priority: optional
+Section: opie/applications
+Depends: task-opie-minimal, libopiecore2, libopieui2
+Replaces: dagger
+Architecture: arm
+Source: http://draknor.net/dagger/
+Maintainer: Dan Williams (drw@handhelds.org)
+Description: A Bible study program utilizing the Sword library.
+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 @@
+/*
+Dagger - A Bible study program utilizing the Sword library.
+Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+
+This file is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this
+file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "searchbar.h"
+#include "textwidget.h"
+
+#include <opie2/owait.h>
+
+#include <qpe/qpeapplication.h>
+#include <qpe/resource.h>
+
+#include <qaction.h>
+#include <qcombobox.h>
+#include <qlineedit.h>
+
+#include <listkey.h>
+#include <regex.h>
+#include <versekey.h>
+
+SearchBar::SearchBar( QMainWindow *parent )
+ : QToolBar( QString::null, parent, QMainWindow::Top, true )
+ , m_currText( 0x0 )
+{
+ // Initialize UI
+ m_searchText = new QLineEdit( this );
+ setStretchableWidget( m_searchText );
+ connect(m_searchText, SIGNAL(textChanged(const QString &)),
+ this, SLOT(slotTextChanged(const QString &)) );
+
+ m_actionFind = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null,
+ 0, this, 0 );
+ m_actionFind->setEnabled( false );
+ m_actionFind->addTo( this );
+ connect( m_actionFind, SIGNAL(activated()), this, SLOT(slotFind()) );
+
+ addSeparator();
+
+ m_actionPrev = new QAction( tr( "Previous result" ), Resource::loadPixmap( "back" ),
+ QString::null, 0, this, 0 );
+ m_actionPrev->setEnabled( false );
+ m_actionPrev->addTo( this );
+ connect( m_actionPrev, SIGNAL(activated()), this, SLOT(slotPrev()) );
+
+ m_resultList = new QComboBox( this );
+ m_resultList->setEnabled( false );
+ connect( m_resultList, SIGNAL(activated(const QString &)), this, SIGNAL(sigResultClicked(const QString &)) );
+
+ m_actionNext = new QAction( tr( "Next result" ), Resource::loadPixmap( "forward" ),
+ QString::null, 0, this, 0 );
+ m_actionNext->setEnabled( false );
+ m_actionNext->addTo( this );
+ connect( m_actionNext, SIGNAL(activated()), this, SLOT(slotNext()) );
+
+ if ( parent )
+ {
+ installEventFilter( parent );
+ // TODO - install for all controls
+ m_searchText->installEventFilter( parent );
+ }
+}
+
+void SearchBar::setCurrModule( TextWidget *currText )
+{
+ m_actionFind->setEnabled( ( m_searchText->text() != "" ) && currText );
+
+ if ( !m_currText || ( currText->getModuleName() != m_currText->getModuleName() ) )
+ {
+ m_actionPrev->setEnabled( false );
+ m_resultList->clear();
+ m_resultList->setEnabled( false );
+ m_actionNext->setEnabled( false );
+ }
+
+ m_currText = currText;
+}
+
+void SearchBar::slotTextChanged( const QString &newText )
+{
+ m_actionFind->setEnabled( ( newText != "" ) && m_currText );
+}
+
+void SearchBar::slotFind()
+{
+ m_resultList->clear();
+
+ // Change application title and display Opie wait dialog to indicate search is beginning
+ QWidget *pWidget = reinterpret_cast<QWidget *>(parent());
+ QString caption = pWidget->caption();
+ pWidget->setCaption( "Searching..." );
+
+ Opie::Ui::OWait wait( pWidget );
+ wait.show();
+ qApp->processEvents();
+
+ // Perform search
+ // TODO - implement search callback function to animate wait cursor
+ sword::ListKey results = m_currText->getModule()->Search( m_searchText->text().latin1(), REG_ICASE, 0 );
+
+ // Process results
+ int count = results.Count();
+ bool found = count > 0;
+ if ( found )
+ {
+ // Populate results combo box
+ sword::VerseKey key;
+ for ( int i = 0; i < count; i++ )
+ {
+ key.setText( results.GetElement( i )->getText() );
+ m_resultList->insertItem( key.getShortText() );
+ }
+
+ // Goto first result in list
+ m_resultList->setCurrentItem( 0 );
+ emit sigResultClicked( m_resultList->currentText() );
+ }
+ else
+ {
+ // Reset application title
+ pWidget->setCaption( caption );
+ }
+
+ // UI clean-up
+ wait.hide();
+
+ m_actionPrev->setEnabled( false );
+ m_resultList->setEnabled( found );
+ m_actionNext->setEnabled( count > 1 );
+}
+
+void SearchBar::slotPrev()
+{
+ int item = m_resultList->currentItem() - 1;
+ m_resultList->setCurrentItem( item );
+ emit sigResultClicked( m_resultList->currentText() );
+
+ m_actionPrev->setEnabled( item > 0 );
+ m_actionNext->setEnabled( item < m_resultList->count() - 1 );
+}
+
+void SearchBar::slotNext()
+{
+ int item = m_resultList->currentItem() + 1;
+ m_resultList->setCurrentItem( item );
+ emit sigResultClicked( m_resultList->currentText() );
+
+ m_actionPrev->setEnabled( true );
+ m_actionNext->setEnabled( item < m_resultList->count() - 1 );
+}
+
+void SearchBar::slotCloseBtn()
+{
+ hide();
+}
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 @@
+/*
+Dagger - A Bible study program utilizing the Sword library.
+Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+
+This file is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this
+file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef SEARCHBAR_H
+#define SEARCHBAR_H
+
+#include <qtoolbar.h>
+
+class QAction;
+class QComboBox;
+class QLineEdit;
+class TextWidget;
+
+class SearchBar : public QToolBar
+{
+ Q_OBJECT
+
+public:
+ SearchBar( QMainWindow *parent = 0x0 );
+
+ void setCurrModule( TextWidget *currText );
+
+private:
+ TextWidget *m_currText; // Pointer to current text
+
+ QLineEdit *m_searchText; // Edit box to enter text to search for
+ QAction *m_actionFind; // Button to press to initiate search
+ QAction *m_actionPrev; // Button to view previous search result
+ QComboBox *m_resultList; // List of results
+ QAction *m_actionNext; // Button to view next search result
+
+private slots:
+ void slotTextChanged( const QString &newText );
+ void slotFind();
+ void slotPrev();
+ void slotNext();
+ void slotCloseBtn();
+
+signals:
+ void sigResultClicked( const QString &key );
+};
+
+#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 @@
+/*
+Dagger - A Bible study program utilizing the Sword library.
+Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+
+This file is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this
+file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef SWORDOPTIONLIST_H
+#define SWORDOPTIONLIST_H
+
+#include <qaction.h>
+#include <qlist.h>
+
+class SwordOptionList : public QList<QAction>
+{
+private:
+
+ int compareItems( QCollection::Item item1, QCollection::Item item2 )
+ {
+ // Sort by QAction text
+ QString act1 = reinterpret_cast<QAction*>(item1)->text();
+ QString act2 = reinterpret_cast<QAction*>(item2)->text();
+ if ( act1 < act2 )
+ return -1;
+ else if ( act1 == act2 )
+ return 0;
+ else
+ return 1;
+ }
+};
+
+typedef QListIterator<QAction> SwordOptionListIterator;
+
+#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 @@
+/*
+Dagger - A Bible study program utilizing the Sword library.
+Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+
+This file is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this
+file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "textwidget.h"
+
+#include <qlayout.h>
+#include <qtextbrowser.h>
+
+#include <versekey.h>
+
+TextWidget::TextWidget( QWidget *parent, sword::SWModule *module, int numVerses, const QFont *font )
+ : QWidget( parent, 0x0, 0x0 )
+ , m_module( module )
+ , m_numVerses( numVerses )
+{
+ if ( parent )
+ installEventFilter( parent );
+
+ QVBoxLayout *layout = new QVBoxLayout( this, 2, 2 );
+
+ m_textView = new QTextBrowser( this );
+ m_textView->installEventFilter( parent );
+ m_textView->setMinimumHeight( 20 );
+ m_textView->setHScrollBarMode( QTextView::AlwaysOff );
+ m_textView->setTextFormat( QTextView::RichText );
+ connect( m_textView, SIGNAL(highlighted(const QString &)),
+ this, SIGNAL(sigRefClicked(const QString &)) );
+ layout->addWidget( m_textView );
+
+ // Set font
+ if ( font )
+ setFont( *font );
+
+ // Set initial text
+ if ( m_module )
+ {
+ m_isBibleText = !strcmp( module->Type(), "Biblical Texts" );
+ if ( m_isBibleText )
+ {
+ m_key = new sword::VerseKey( "g" );
+
+ //connect( m_textView, SIGNAL(highlighted(const QString&)),
+ // this, SLOT(slotReferenceClicked(const QString&)) );
+ //connect( parent, SIGNAL( strongsNumbers( bool ) ), this, SLOT( slotStrongsNumbers( bool ) ) );
+ }
+ else
+ {
+ m_key = new sword::SWKey( "" );
+ }
+ m_module->SetKey( m_key );
+ setText();
+ }
+}
+
+TextWidget::~TextWidget()
+{
+ // TODO - why does this cause a SIGSEV???
+ //delete m_key;
+}
+
+QString TextWidget::getCurrVerse()
+{
+ m_module->SetKey( m_key->getText() );
+ return ( QString ) m_module->StripText();
+}
+
+void TextWidget::prevChapter()
+{
+}
+
+void TextWidget::prevVerse()
+{
+ (*m_key)--;
+ setText();
+}
+
+void TextWidget::setKey( const QString &newKey )
+{
+ m_key->setText( newKey.latin1() );
+ setText();
+}
+
+void TextWidget::nextVerse()
+{
+ (*m_key)++;
+ setText();
+}
+
+void TextWidget::nextChapter()
+{
+}
+
+void TextWidget::slotNumVersesChanged( int numVerses )
+{
+ m_numVerses = numVerses;
+ setText();
+}
+
+void TextWidget::slotFontChanged( const QFont *newFont )
+{
+ setFont( *newFont );
+ // TODO - shouldn't have to reset text, but couldn't get repaint() to work
+ setText();
+}
+
+void TextWidget::slotOptionChanged()
+{
+ setText();
+}
+
+void TextWidget::setText()
+{
+ if ( m_key->Error() )
+ return;
+
+ m_module->SetKey( m_key->getText() );
+ m_fullKey = QString( "%1 (%2)" ).arg( m_key->getShortText() ).arg( m_module->Name() );
+
+ if ( m_isBibleText )
+ {
+ m_textView->setVScrollBarMode( QTextView::AlwaysOff );
+
+ m_abbrevKey = m_key->getShortText();
+
+ QString fullText;
+
+ for ( int i = 0; i < m_numVerses; i++ )
+ {
+ QString key = ( QString ) m_module->KeyText();
+ QString verseStr = ( QString ) *m_module;
+
+ // Format current verse (adding chapter and/or book headings if necessary)
+ int verse = static_cast<sword::VerseKey>(m_module->Key()).Verse();
+ if ( verse == 1 )
+ {
+ int chapter = static_cast<sword::VerseKey>(m_module->Key()).Chapter();
+ if ( chapter == 1 )
+ {
+ QString book = static_cast<sword::VerseKey>(m_module->Key()).getBookName();
+ verseStr = QString( "<p><center><big><b>%1</b></big></center><br><center><b>Chapter %1</b></center><p><b>%2</b>&nbsp;%3<p>" )
+ .arg( book ).arg( chapter ).arg( verse ).arg( verseStr );
+ }
+ else
+ {
+ verseStr = QString( "<center><b>Chapter %1</b></center><p><b>%2</b>&nbsp;%3<p>" )
+ .arg( chapter ).arg( verse ).arg( verseStr );
+ }
+ }
+ else
+ {
+ verseStr = QString( "<b>%1</b>&nbsp;%2<p>" ).arg( verse ).arg( verseStr );
+ }
+
+ fullText.append( verseStr );
+
+ m_module->Key()++;
+
+ if ( m_module->Key().Error() )
+ break;
+ }
+
+ m_textView->setText( fullText );
+ }
+ else // !isBibleText
+ {
+ m_abbrevKey = m_key->getText();
+ m_textView->setText( ( QString ) *m_module );
+ }
+}
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 @@
+/*
+Dagger - A Bible study program utilizing the Sword library.
+Copyright (c) 2004 Dan Williams <drw@handhelds.org>
+
+This file is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later version.
+
+This file is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this
+file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
+59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef TEXTWIDGET_H
+#define TEXTWIDGET_H
+
+#include <qwidget.h>
+
+#include <swkey.h>
+#include <swmodule.h>
+
+class QTextBrowser;
+
+class TextWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ TextWidget( QWidget *parent = 0x0, sword::SWModule *module = 0x0, int numVerses = 5,
+ const QFont *font = 0x0 );
+ ~TextWidget();
+
+ const QString &getFullKey() { return m_fullKey; }
+ const QString &getAbbrevKey() { return m_abbrevKey; }
+ QString getModuleName() { return QString( m_module->Name() ); }
+ sword::SWModule *getModule() { return m_module; }
+ QString getCurrVerse();
+
+ bool isBibleText() const { return m_isBibleText; }
+
+ void prevChapter();
+ void prevVerse();
+ void setKey( const QString &newKey );
+ void nextVerse();
+ void nextChapter();
+
+public slots:
+ void slotNumVersesChanged( int numVerses );
+ void slotFontChanged( const QFont *newFont );
+ void slotOptionChanged();
+
+private:
+ sword::SWModule *m_module; // Sword module to display in this widget
+ sword::SWKey *m_key; // Current module key
+ bool m_isBibleText; // Indicates whether module is a Bible or not
+
+ QTextBrowser *m_textView; // Displays module's text
+ QString m_fullKey; // Contains full key text in format 'key (module)'
+ QString m_abbrevKey; // Contains abbreviated key text
+
+ int m_numVerses; // Number of verses to display at a time for Bible modules
+
+ void setText();
+
+signals:
+ void sigRefClicked( const QString &ref );
+};
+
+#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