author | drw <drw> | 2004-04-22 14:30:24 (UTC) |
---|---|---|
committer | drw <drw> | 2004-04-22 14:30:24 (UTC) |
commit | 00977d309bc991ffb4a84216881b53432c6d0b47 (patch) (side-by-side diff) | |
tree | 7888656814ad09fb8930c198caadc56561687918 | |
parent | 162c71d6528515ea4b28520e9708c8ce9ca7fba2 (diff) | |
download | opie-00977d309bc991ffb4a84216881b53432c6d0b47.zip opie-00977d309bc991ffb4a84216881b53432c6d0b47.tar.gz opie-00977d309bc991ffb4a84216881b53432c6d0b47.tar.bz2 |
Fixed disabling of screen blanking, implemented prev/next page scrolling and fixed search OWait useage
-rw-r--r-- | noncore/apps/dagger/ChangeLog | 7 | ||||
-rw-r--r-- | noncore/apps/dagger/README | 2 | ||||
-rw-r--r-- | noncore/apps/dagger/TODO | 6 | ||||
-rw-r--r-- | noncore/apps/dagger/mainwindow.cpp | 17 | ||||
-rw-r--r-- | noncore/apps/dagger/mainwindow.h | 4 | ||||
-rw-r--r-- | noncore/apps/dagger/navbar.cpp | 16 | ||||
-rw-r--r-- | noncore/apps/dagger/navbar.h | 8 | ||||
-rw-r--r-- | noncore/apps/dagger/opie-dagger.control | 4 | ||||
-rw-r--r-- | noncore/apps/dagger/searchbar.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/dagger/textwidget.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/dagger/textwidget.h | 4 |
11 files changed, 50 insertions, 34 deletions
diff --git a/noncore/apps/dagger/ChangeLog b/noncore/apps/dagger/ChangeLog index feb9a19..108419e 100644 --- a/noncore/apps/dagger/ChangeLog +++ b/noncore/apps/dagger/ChangeLog @@ -1,4 +1,11 @@ +2004-04-22 Dan Williams <drw@handhelds.org> + + * Released version 0.9.1 + * Fixed the disabling of screen blanking + * Implement previous/next page scrolling + * Animate search OWait + 2004-04-06 Dan Williams <drw@handhelds.org> * Released version 0.9.0 * Initial check-in of new application diff --git a/noncore/apps/dagger/README b/noncore/apps/dagger/README index 4a4bb61..00e9eed 100644 --- a/noncore/apps/dagger/README +++ b/noncore/apps/dagger/README @@ -1,53 +1,53 @@ /************************************************************************ /* /* Opie - Dagger /* =============== -/* Version 0.9.0 +/* Version 0.9.1 /* /* A Bible study/reader application /* /************************************************************************ --------------------------------------------- Release Notes for Opie-Dagger - April, 2004 --------------------------------------------- ====================== = To-do = ====================== - See $OPIEDIR/noncore/apps/dagger/TODO for more info. ====================== = Build = ====================== In order to build opie-dagger, libsword needs to be present on the build system along with the appropriate headers. - libsword source (best to use version 1.5.x or greater): - http://www.crosswire.org/sword/ - the Sword library headers need to be located in an appropriate include directory ====================== = Run = ====================== - In order to use opie-dagger, libsword must be installed on the system. - One or more Sword modules need to be installed, see http://www.crosswire.org/sword/ to download modules - When run for the first time, the path needs to be set to the directory where the Sword modules are located. Select 'Edit->Configure' from the menu bar and enter the path on the 'General' tab. Restart Dagger. ====================== = Credits = ====================== - Opie-Dagger is (C) 2004 Dan Williams ====================== diff --git a/noncore/apps/dagger/TODO b/noncore/apps/dagger/TODO index 2548dd3..1530bd6 100644 --- a/noncore/apps/dagger/TODO +++ b/noncore/apps/dagger/TODO @@ -1,27 +1,25 @@ /************************************************************************ /* /* Opie - Dagger /* =============== -/* Version 0.9.0 +/* Version 0.9.1 /* /* A Bible study/reader application /* /************************************************************************ ------------------------------------ To-do for Opie-Dagger - April, 2004 ------------------------------------ ====================== = Current release = ====================== -1. Implement search function callback to animate OWait dialog -2. Implement previous/next page scrolling -3. Fix disablement of screen blanking +1. Implement module installation ====================== = Future releases = ====================== 1. Margin notes
\ No newline at end of file diff --git a/noncore/apps/dagger/mainwindow.cpp b/noncore/apps/dagger/mainwindow.cpp index ace8f36..b2e00e8 100644 --- a/noncore/apps/dagger/mainwindow.cpp +++ b/noncore/apps/dagger/mainwindow.cpp @@ -28,197 +28,200 @@ file; see the file COPYING. If not, write to the Free Software Foundation, Inc., #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() { + // Re-enable screen blanking if it was disabled + QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; + // 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(prevPage()), this, SLOT(slotNavPrevPage()) ); 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(nextPage()), this, SLOT(slotNavNextPage()) ); 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 ); @@ -287,97 +290,97 @@ void MainWindow::openModule( const QString &modulename, const QString &key ) { // 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; + : QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; } 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() ) { @@ -552,148 +555,148 @@ void MainWindow::slotBookmarkRemove() 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() +void MainWindow::slotNavPrevPage() { TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); if ( text ) { - text->prevChapter(); + text->prevPage(); 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() +void MainWindow::slotNavNextPage() { TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget()); if ( text ) { - text->nextChapter(); + text->nextPage(); 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() diff --git a/noncore/apps/dagger/mainwindow.h b/noncore/apps/dagger/mainwindow.h index 0c7f3c8..b114e33 100644 --- a/noncore/apps/dagger/mainwindow.h +++ b/noncore/apps/dagger/mainwindow.h @@ -66,69 +66,69 @@ private: 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 slotNavPrevPage(); void slotNavPrevVerse(); void slotNavKeyChanged( const QString &newKey ); void slotNavNextVerse(); - void slotNavNextChapter(); + void slotNavNextPage(); 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 index 4781af0..212dc36 100644 --- a/noncore/apps/dagger/navbar.cpp +++ b/noncore/apps/dagger/navbar.cpp @@ -1,93 +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" ), + m_actionPrevPage = new QAction( tr( "Previous page" ), Resource::loadPixmap( "fastback" ), QString::null, 0, this, 0 ); - m_actionPrevChapter->addTo( this ); - connect( m_actionPrevChapter, SIGNAL(activated()), this, SIGNAL(prevChapter()) ); + m_actionPrevPage->addTo( this ); + connect( m_actionPrevPage, SIGNAL(activated()), this, SIGNAL(prevPage()) ); 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" ), + m_actionNextPage = new QAction( tr( "Next page" ), Resource::loadPixmap( "fastforward" ), QString::null, 0, this, 0 ); - m_actionNextChapter->addTo( this ); - connect( m_actionNextChapter, SIGNAL(activated()), this, SIGNAL(nextChapter()) ); + m_actionNextPage->addTo( this ); + connect( m_actionNextPage, SIGNAL(activated()), this, SIGNAL(nextPage()) ); 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_actionPrevPage->setEnabled( enabled ); m_actionPrevVerse->setEnabled( enabled ); m_actionNextVerse->setEnabled( enabled ); - m_actionNextChapter->setEnabled( enabled ); + m_actionNextPage->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 index a37d6ff..0df2bf0 100644 --- a/noncore/apps/dagger/navbar.h +++ b/noncore/apps/dagger/navbar.h @@ -1,58 +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_actionPrevPage; // Action for going back 1 page 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 + QAction *m_actionNextPage; // Action for going forward 1 page QSpinBox *m_scrollRate; // Spin box to adjust rate of auto-scrolling QAction *m_actionScroll; // Action to start/stop auto-scrolling signals: - void prevChapter(); + void prevPage(); void prevVerse(); void keyChanged( const QString &newKey ); void nextVerse(); - void nextChapter(); + void nextPage(); void autoScroll( bool enabled ); void scrollRateChanged( int newRate ); }; #endif diff --git a/noncore/apps/dagger/opie-dagger.control b/noncore/apps/dagger/opie-dagger.control index c401f03..4ded1f2 100644 --- a/noncore/apps/dagger/opie-dagger.control +++ b/noncore/apps/dagger/opie-dagger.control @@ -1,11 +1,9 @@ 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 +Version: 0.9.1$EXTRAVERSION diff --git a/noncore/apps/dagger/searchbar.cpp b/noncore/apps/dagger/searchbar.cpp index 747d696..ff434dd 100644 --- a/noncore/apps/dagger/searchbar.cpp +++ b/noncore/apps/dagger/searchbar.cpp @@ -1,159 +1,165 @@ /* 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> +void searchCallback( char /*percent*/, void */*userData*/ ) +{ + qApp->processEvents(); +} + 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 ); + sword::ListKey results = m_currText->getModule()->Search( m_searchText->text().latin1(), 0, REG_ICASE, 0, 0, + &searchCallback ); // 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() ); diff --git a/noncore/apps/dagger/textwidget.cpp b/noncore/apps/dagger/textwidget.cpp index 8ff620d..9f7de66 100644 --- a/noncore/apps/dagger/textwidget.cpp +++ b/noncore/apps/dagger/textwidget.cpp @@ -33,120 +33,124 @@ TextWidget::TextWidget( QWidget *parent, sword::SWModule *module, int numVerses, 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::prevPage() { + (*m_key) -= m_numVerses; + setText(); } 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::nextPage() { + (*m_key) += m_numVerses; + setText(); } 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 ) { diff --git a/noncore/apps/dagger/textwidget.h b/noncore/apps/dagger/textwidget.h index 647eae9..f78ef69 100644 --- a/noncore/apps/dagger/textwidget.h +++ b/noncore/apps/dagger/textwidget.h @@ -1,73 +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 prevPage(); void prevVerse(); void setKey( const QString &newKey ); void nextVerse(); - void nextChapter(); + void nextPage(); 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 |