Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

navbar.cpp

Go to the documentation of this file.
00001 /*
00002 Dagger - A Bible study program utilizing the Sword library.
00003 Copyright (c) 2004 Dan Williams <drw@handhelds.org>
00004 
00005 This file is free software; you can redistribute it and/or modify it under
00006 the terms of the GNU General Public License as published by the Free Software
00007 Foundation; either version 2 of the License, or (at your option) any later version.
00008 
00009 This file is distributed in the hope that it will be useful, but WITHOUT ANY
00010 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
00011 PARTICULAR PURPOSE. See the GNU General Public License for more details.
00012 
00013 You should have received a copy of the GNU General Public License along with this
00014 file; see the file COPYING. If not, write to the Free Software Foundation, Inc.,
00015 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00016 */
00017 
00018 #include "navbar.h"
00019 
00020 #include <opie2/oresource.h>
00021 
00022 #include <qpe/config.h>
00023 
00024 #include <qaction.h>
00025 #include <qlineedit.h>
00026 #include <qwhatsthis.h>
00027 
00028 NavBar::NavBar( QMainWindow *parent )
00029     : QToolBar( QString::null, parent, QMainWindow::Top, true )
00030 {
00031     // Initialize UI
00032     m_actionPrevPage = new QAction( tr( "Previous page" ),
00033                                     Opie::Core::OResource::loadPixmap( "fastback", Opie::Core::OResource::SmallIcon ),
00034                                        QString::null, 0, this, 0 );
00035     m_actionPrevPage->setWhatsThis( tr( "Tap here to scroll backward one page." ) );
00036     m_actionPrevPage->addTo( this );
00037     connect( m_actionPrevPage, SIGNAL(activated()), this, SIGNAL(prevPage()) );
00038 
00039     m_actionPrevVerse = new QAction( tr( "Previous verse" ),
00040                                      Opie::Core::OResource::loadPixmap( "back", Opie::Core::OResource::SmallIcon ),
00041                                      QString::null, 0, this, 0 );
00042     m_actionPrevVerse->setWhatsThis( tr( "Tap here to scroll backward one verse." ) );
00043     m_actionPrevVerse->addTo( this );
00044     connect( m_actionPrevVerse, SIGNAL(activated()), this, SIGNAL(prevVerse()) );
00045 
00046     m_key = new QLineEdit( this );
00047     setStretchableWidget( m_key );
00048     QWhatsThis::add( m_key, tr( "Enter location to display here." ) );
00049     connect(m_key, SIGNAL(textChanged(const QString &)), this, SIGNAL(keyChanged(const QString &)) );
00050 
00051     m_actionNextVerse = new QAction( tr( "Next verse" ),
00052                                      Opie::Core::OResource::loadPixmap( "forward", Opie::Core::OResource::SmallIcon ),
00053                                      QString::null, 0, this, 0 );
00054     m_actionNextVerse->setWhatsThis( tr( "Tap here to scroll forward one verse." ) );
00055     m_actionNextVerse->addTo( this );
00056     connect( m_actionNextVerse, SIGNAL(activated()), this, SIGNAL(nextVerse()) );
00057 
00058     m_actionNextPage = new QAction( tr( "Next page" ),
00059                                     Opie::Core::OResource::loadPixmap( "fastforward", Opie::Core::OResource::SmallIcon ),
00060                                     QString::null, 0, this, 0 );
00061     m_actionNextPage->setWhatsThis( tr( "Tap here to scroll forward one page." ) );
00062     m_actionNextPage->addTo( this );
00063     connect( m_actionNextPage, SIGNAL(activated()), this, SIGNAL(nextPage()) );
00064 
00065     addSeparator();
00066 
00067     m_scrollRate = new QSpinBox( 1, 100, 1, this );
00068     m_scrollRate->setMinimumWidth( 35 );
00069     QWhatsThis::add( m_scrollRate, tr( "Adjust auto-scroll rate here.  A larger value represents a slower scrolling rate." ) );
00070     connect( m_scrollRate, SIGNAL(valueChanged(int)), this, SIGNAL(scrollRateChanged(int)) );
00071 
00072     m_actionScroll = new QAction( tr( "Auto-scroll" ),
00073                                   Opie::Core::OResource::loadPixmap( "dagger/autoscroll", Opie::Core::OResource::SmallIcon ),
00074                                   QString::null, 0, this, 0 );
00075     m_actionScroll->setToggleAction( true );
00076     m_actionScroll->setWhatsThis( tr( "Tap here to start or stop auto-scrolling." ) );
00077     connect( m_actionScroll, SIGNAL(toggled(bool)), this, SIGNAL(autoScroll(bool)) );
00078     m_actionScroll->addTo( this );
00079 
00080     if ( parent )
00081     {
00082         installEventFilter( parent );
00083         m_key->installEventFilter( parent );
00084     }
00085 }
00086 
00087 void NavBar::navBtnsEnable( bool enabled )
00088 {
00089     m_actionPrevPage->setEnabled( enabled );
00090     m_actionPrevVerse->setEnabled( enabled );
00091     m_actionNextVerse->setEnabled( enabled );
00092     m_actionNextPage->setEnabled( enabled );
00093     m_scrollRate->setEnabled( enabled );
00094     m_actionScroll->setEnabled( enabled );
00095 }
00096 
00097 void NavBar::setKey( const QString &newKey )
00098 {
00099     disconnect( m_key, SIGNAL(textChanged(const QString &)), 0, 0 );
00100     m_key->setText( newKey );
00101     connect(m_key, SIGNAL(textChanged(const QString &)), this, SIGNAL(keyChanged(const QString &)) );
00102 }
00103 
00104 void NavBar::setAutoScrollRate( int scrollRate )
00105 {
00106     m_scrollRate->setValue( scrollRate );
00107 }

Generated on Sat Nov 5 16:16:48 2005 for OPIE by  doxygen 1.4.2