00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "mainwindow.h"
00019 #include "navbar.h"
00020 #include "searchbar.h"
00021 #include "opentextdlg.h"
00022 #include "configuredlg.h"
00023 #include "textwidget.h"
00024
00025 #include <opie2/odebug.h>
00026 #include <opie2/oresource.h>
00027
00028 #include <qpe/qcopenvelope_qws.h>
00029 #include <qpe/qpeapplication.h>
00030
00031 #include <qaction.h>
00032 #include <qclipboard.h>
00033 #include <qmenubar.h>
00034 #include <qmessagebox.h>
00035 #include <qobjectlist.h>
00036 #include <qpopupmenu.h>
00037 #include <qtimer.h>
00038 #include <qtoolbar.h>
00039
00040 #include <markupfiltmgr.h>
00041
00042 MainWindow::MainWindow( QWidget *parent, const char *name, WFlags )
00043 : QMainWindow( parent, name, WStyle_ContextHelp )
00044 , m_config( "dagger" )
00045 , m_tabs( this )
00046 , m_autoScrollTimer( this )
00047 {
00048
00049 m_config.setGroup( "Sword" );
00050 m_modulePath = m_config.readEntry( "ModPath", "/usr/local/share/sword" );
00051 m_swordMgr = new sword::SWMgr( m_modulePath.latin1(), true,
00052 new sword::MarkupFilterMgr( sword::FMT_HTMLHREF ) );
00053
00054
00055 sword::StringList swordOpts = m_swordMgr->getGlobalOptions();
00056 for ( sword::StringList::iterator it = swordOpts.begin(); it != swordOpts.end(); it++ )
00057 m_actionSwordOpts.append( new QAction( (*it).c_str(), QString::null, 0, this, 0 ) );
00058 m_actionSwordOpts.sort();
00059
00060
00061 setCaption( tr( "Dagger" ) );
00062 initUI();
00063
00064 connect( &m_tabs, SIGNAL(currentChanged(QWidget *)), this, SLOT( slotTextDisplayed(QWidget *)) );
00065 connect( &m_autoScrollTimer, SIGNAL(timeout()), this, SLOT(slotNavNextVerse()) );
00066
00067 m_bibleIcon = new QPixmap( Opie::Core::OResource::loadPixmap( "dagger/bibletext", Opie::Core::OResource::SmallIcon ) );
00068 m_commentaryIcon = new QPixmap( Opie::Core::OResource::loadPixmap( "dagger/commentary", Opie::Core::OResource::SmallIcon ) );
00069 m_lexiconIcon = new QPixmap( Opie::Core::OResource::loadPixmap( "dagger/lexicon", Opie::Core::OResource::SmallIcon ) );
00070
00071
00072 QTimer::singleShot( 100, this, SLOT( initConfig() ) );
00073 }
00074
00075 MainWindow::~MainWindow()
00076 {
00077
00078 QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
00079
00080
00081 m_config.setGroup( "Sword" );
00082 m_config.writeEntry( "ModPath", m_modulePath );
00083
00084 for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() )
00085 m_config.writeEntry( a->text(), a->isOn() );
00086
00087
00088 m_config.setGroup( "Config" );
00089 m_config.writeEntry( "AlwaysOpenNew", m_alwaysOpenNew );
00090 m_config.writeEntry( "AutoScroll", m_navToolbar->autoScrollRate() );
00091 m_config.writeEntry( "DisableScreenBlanking", m_disableScreenBlank );
00092 m_config.writeEntry( "CopyFormat", m_copyFormat );
00093 m_config.writeEntry( "NavBar", m_actionViewNavToolbar->isOn() );
00094 m_config.writeEntry( "NumVerses", m_numVerses );
00095 m_config.writeEntry( "SearchBar", m_actionViewSearchToolbar->isOn() );
00096
00097
00098 m_config.setGroup( "Font");
00099 m_config.writeEntry( "Family", m_textFont.family() );
00100 m_config.writeEntry( "Italic", m_textFont.italic() );
00101 m_config.writeEntry( "Size", m_textFont.pointSize() );
00102 m_config.writeEntry( "Weight", m_textFont.weight() );
00103
00104
00105 m_config.setGroup( "Bookmarks");
00106 m_config.clearGroup();
00107 int index = 3;
00108 int id = m_bookmarkMenu->idAt( index );
00109 while ( id != -1 )
00110 {
00111 QString bookmark = m_bookmarkMenu->text( id );
00112 int pos = bookmark.find( " (" );
00113 QString key = bookmark.left( pos );
00114 pos += 2;
00115 QString module = bookmark.mid( pos, bookmark.find( ")", pos ) - pos );
00116 QString modkey;
00117 modkey.sprintf( "%s/%s", module.latin1(), key.latin1() );
00118 m_config.writeEntry( QString::number( index - 2 ), modkey );
00119
00120 ++index;
00121 id = m_bookmarkMenu->idAt( index );
00122 }
00123
00124
00125 m_config.setGroup( "Session");
00126 m_config.clearGroup();
00127 QObjectList *childlist = queryList( "TextWidget" );
00128 QObjectListIt it( *childlist );
00129 TextWidget *module;
00130 int count = 1;
00131 while ( ( module = reinterpret_cast<TextWidget *>(it.current()) ) != 0 )
00132 {
00133 QString modkey;
00134 modkey.sprintf( "%s/%s", module->getModuleName().latin1(), module->getAbbrevKey().latin1() );
00135 m_config.writeEntry( QString::number( count ), modkey );
00136 ++count;
00137 ++it;
00138 }
00139 }
00140
00141 bool MainWindow::eventFilter( QObject *obj, QEvent *event )
00142 {
00143 if ( event->type() == QEvent::KeyPress )
00144 {
00145 QKeyEvent *keyev = reinterpret_cast<QKeyEvent *>(event);
00146 if ( keyev->key() == Key_Up )
00147 {
00148 slotNavPrevVerse();
00149 return true;
00150 }
00151 else if ( keyev->key() == Key_Down )
00152 {
00153 slotNavNextVerse();
00154 return true;
00155 }
00156 }
00157
00158 return QWidget::eventFilter( obj, event );
00159 }
00160
00161 void MainWindow::initUI()
00162 {
00163 setCentralWidget( &m_tabs );
00164 m_tabs.installEventFilter( this );
00165
00166 setToolBarsMovable( false );
00167 m_barDock = new QToolBar( this );
00168 m_barDock->setHorizontalStretchable( true );
00169
00170 m_menuBar = new QMenuBar( m_barDock );
00171 m_menuBar->setMargin( 0 );
00172
00173
00174 m_navToolbar = new NavBar( this );
00175 m_navToolbar->navBtnsEnable( false );
00176 connect( m_navToolbar, SIGNAL(prevPage()), this, SLOT(slotNavPrevPage()) );
00177 connect( m_navToolbar, SIGNAL(prevVerse()), this, SLOT(slotNavPrevVerse()) );
00178 connect( m_navToolbar, SIGNAL(keyChanged(const QString &)), this, SLOT(slotNavKeyChanged(const QString &)) );
00179 connect( m_navToolbar, SIGNAL(nextVerse()), this, SLOT(slotNavNextVerse()) );
00180 connect( m_navToolbar, SIGNAL(nextPage()), this, SLOT(slotNavNextPage()) );
00181 connect( m_navToolbar, SIGNAL(autoScroll(bool)), this, SLOT(slotNavAutoScroll(bool)) );
00182 connect( m_navToolbar, SIGNAL(scrollRateChanged(int)), this, SLOT(slotNavScrollRateChanged(int)) );
00183
00184 m_searchToolbar = new SearchBar( this );
00185 connect( m_searchToolbar, SIGNAL(sigResultClicked(const QString &)), this, SLOT(slotSearchResultClicked(const QString &)) );
00186
00187
00188 QPopupMenu *popup = new QPopupMenu( this );
00189
00190 QAction *a = new QAction( tr( "Open..." ), Opie::Core::OResource::loadPixmap( "fileopen", Opie::Core::OResource::SmallIcon ),
00191 QString::null, 0, this, 0 );
00192 connect( a, SIGNAL(activated()), this, SLOT(slotTextOpen()) );
00193 a->addTo( popup );
00194
00195 m_actionTextClose = new QAction( tr( "Close" ), Opie::Core::OResource::loadPixmap( "close", Opie::Core::OResource::SmallIcon ),
00196 QString::null, 0, this, 0 );
00197 connect( m_actionTextClose, SIGNAL(activated()), this, SLOT(slotTextClose()) );
00198 m_actionTextClose->addTo( popup );
00199
00200 popup->insertSeparator();
00201
00202
00203 a = new QAction( tr( "Install" ), Opie::Core::OResource::loadPixmap( "install", Opie::Core::OResource::SmallIcon ),
00204 QString::null, 0, this, 0 );
00205 a->setEnabled( false );
00206 connect( a, SIGNAL(activated()), this, SLOT(slotTextInstall()) );
00207 a->addTo( popup );
00208
00209 m_menuBar->insertItem( tr( "Text" ), popup );
00210
00211
00212 popup = new QPopupMenu( this );
00213
00214 m_actionEditCopy = new QAction( tr( "Copy" ), Opie::Core::OResource::loadPixmap( "copy", Opie::Core::OResource::SmallIcon ),
00215 QString::null, 0, this, 0 );
00216 connect( m_actionEditCopy, SIGNAL(activated()), this, SLOT(slotEditCopy()) );
00217 m_actionEditCopy->addTo( popup );
00218
00219 popup->insertSeparator();
00220
00221 a = new QAction( tr( "Configure" ), Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ),
00222 QString::null, 0, this, 0 );
00223 connect( a, SIGNAL(activated()), this, SLOT(slotEditConfigure()) );
00224 a->addTo( popup );
00225
00226 m_menuBar->insertItem( tr( "Edit" ), popup );
00227
00228
00229 m_bookmarkMenu = new QPopupMenu( this );
00230
00231 m_actionBookmarkAdd = new QAction( tr( "Add" ),
00232 Opie::Core::OResource::loadPixmap( "dagger/bookmarkadd", Opie::Core::OResource::SmallIcon ),
00233 QString::null, 0, this, 0 );
00234 connect( m_actionBookmarkAdd, SIGNAL(activated()), this, SLOT(slotBookmarkAdd()) );
00235 m_actionBookmarkAdd->addTo( m_bookmarkMenu );
00236
00237 m_actionBookmarkRemove = new QAction( tr( "Remove" ),
00238 Opie::Core::OResource::loadPixmap( "dagger/bookmarkremove", Opie::Core::OResource::SmallIcon ),
00239 QString::null, 0, this, 0 );
00240 connect( m_actionBookmarkRemove, SIGNAL(activated()), this, SLOT(slotBookmarkRemove()) );
00241 m_actionBookmarkRemove->addTo( m_bookmarkMenu );
00242
00243 m_bookmarkMenu->insertSeparator();
00244
00245 m_menuBar->insertItem( tr( "Bookmark" ), m_bookmarkMenu );
00246
00247
00248 popup = new QPopupMenu( this );
00249
00250
00251 for ( a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() )
00252 {
00253 a->setToggleAction( true );
00254 connect( a, SIGNAL(toggled(bool)), this, SLOT(slotViewSwordOption(bool)) );
00255 a->addTo( popup );
00256 }
00257
00258 popup->insertSeparator();
00259
00260 m_actionViewNavToolbar = new QAction( tr( "Navigation toolbar" ), QString::null, 0, this, 0 );
00261 m_actionViewNavToolbar->setToggleAction( true );
00262 connect( m_actionViewNavToolbar, SIGNAL(toggled(bool)), this, SLOT(slotViewNavToolbar(bool)) );
00263 m_actionViewNavToolbar->addTo( popup );
00264
00265 m_actionViewSearchToolbar = new QAction( tr( "Search toolbar" ), QString::null, 0, this, 0 );
00266 m_actionViewSearchToolbar->setToggleAction( true );
00267 connect( m_actionViewSearchToolbar, SIGNAL(toggled(bool)), this, SLOT(slotViewSearchToolbar(bool)) );
00268 m_actionViewSearchToolbar->addTo( popup );
00269
00270 m_menuBar->insertItem( tr( "View" ), popup );
00271 }
00272
00273 void MainWindow::openModule( const QString &modulename, const QString &key )
00274 {
00275 sword::SWModule *module = m_swordMgr->Modules[ modulename.latin1() ];
00276 if ( module )
00277 {
00278 TextWidget *tw = 0x0;
00279
00280 if ( !m_alwaysOpenNew )
00281 {
00282
00283 QObjectList *childlist = queryList( "TextWidget" );
00284 QObjectListIt it( *childlist );
00285 while ( ( tw = reinterpret_cast<TextWidget *>(it.current()) ) != 0 &&
00286 tw->getModuleName() != modulename )
00287 ++it;
00288 if ( tw && tw->getModuleName() == modulename )
00289 {
00290
00291 if ( !key.isNull() )
00292 tw->setKey( key );
00293
00294
00295 m_tabs.setCurrentTab( tw );
00296 }
00297 }
00298
00299 if ( m_alwaysOpenNew || !tw )
00300 {
00301
00302 QString icon;
00303 QString type = module->Type();
00304
00305 if ( type == "Biblical Texts" )
00306 icon = "dagger/bibletext";
00307 else if ( type == "Commentaries" )
00308 icon = "dagger/commentary";
00309 else if ( type == "Lexicons / Dictionaries" )
00310 icon = "dagger/lexicon";
00311
00312 tw = new TextWidget( this, module, m_numVerses, &m_textFont );
00313 connect( tw, SIGNAL(sigRefClicked(const QString &)),
00314 this, SLOT(slotTextRefClicked(const QString &)) );
00315 connect( this, SIGNAL(sigNumVersesChanged(int)), tw, SLOT(slotNumVersesChanged(int)) );
00316 connect( this, SIGNAL(sigFontChanged(const QFont *)), tw, SLOT(slotFontChanged(const QFont *)) );
00317 connect( this, SIGNAL(sigOptionChanged()), tw, SLOT(slotOptionChanged()) );
00318
00319 m_tabs.addTab( tw, icon, modulename );
00320
00321 m_actionTextClose->setEnabled( true );
00322 m_actionEditCopy->setEnabled( true );
00323 m_actionBookmarkAdd->setEnabled( true );
00324
00325
00326 if ( !key.isNull() )
00327 tw->setKey( key );
00328 setCaption( QString( "%1 - Dagger" ).arg( tw->getFullKey() ) );
00329 m_navToolbar->setKey( tw->getAbbrevKey() );
00330 }
00331 }
00332 }
00333
00334 int MainWindow::findBookmark( const QString &bookmark )
00335 {
00336 int index = 3;
00337 int id = m_bookmarkMenu->idAt( index );
00338 while ( ( id != -1 ) && ( m_bookmarkMenu->text( id ) != bookmark ) )
00339 {
00340 ++index;
00341 id = m_bookmarkMenu->idAt( index );
00342 }
00343
00344 return id;
00345 }
00346
00347 void MainWindow::enableScreenBlanking( bool enable )
00348 {
00349 enable ? QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable
00350 : QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend;
00351 }
00352
00353 void MainWindow::initConfig()
00354 {
00355 bool show;
00356
00357 m_config.setGroup( "Sword" );
00358 for ( QAction *a = m_actionSwordOpts.first(); a; a = m_actionSwordOpts.next() )
00359 {
00360 show = m_config.readBoolEntry( a->text(), false );
00361 a->setOn( show );
00362 m_swordMgr->setGlobalOption ( a->text(), show ? "On" : "Off" );
00363 }
00364
00365
00366 m_config.setGroup( "Config" );
00367
00368 m_alwaysOpenNew = m_config.readBoolEntry( "AlwaysOpenNew", false );
00369 m_navToolbar->setAutoScrollRate( m_config.readNumEntry( "AutoScroll", 50 ) );
00370 m_disableScreenBlank = m_config.readBoolEntry( "DisableScreenBlanking", false );
00371 enableScreenBlanking( !m_disableScreenBlank );
00372 m_copyFormat = m_config.readNumEntry( "CopyFormat", 0 );
00373
00374 show = m_config.readBoolEntry( "NavBar", false );
00375 m_actionViewNavToolbar->setOn( show );
00376 slotViewNavToolbar( show );
00377
00378 m_numVerses = m_config.readNumEntry( "NumVerses", 5 );
00379
00380 show = m_config.readBoolEntry( "SearchBar", false );
00381 m_actionViewSearchToolbar->setOn( show );
00382 slotViewSearchToolbar( show );
00383
00384
00385 m_config.setGroup( "Font" );
00386 QString fontFamily = m_config.readEntry( "Family", QString::null );
00387 !fontFamily.isNull() ? m_textFont = QFont( fontFamily,
00388 m_config.readNumEntry( "Size", -1 ),
00389 m_config.readNumEntry( "Weight", QFont::Normal ),
00390 m_config.readBoolEntry( "Italic", false ) )
00391 : m_textFont = font();
00392
00393
00394 m_config.setGroup( "Bookmarks");
00395 int count = 1;
00396 QString key = m_config.readEntry( QString::number( count ), QString::null );
00397 while ( !key.isNull() )
00398 {
00399 int pos = key.find( "/" );
00400 if ( pos > -1 )
00401 {
00402 QString bookmark;
00403 bookmark.sprintf( "%s (%s)", key.right( key.length() - ( pos + 1 ) ).latin1(),
00404 key.left( pos ).latin1() );
00405 QAction *a = new QAction( bookmark, QString::null, 0, this, 0 );
00406 a->addTo( m_bookmarkMenu );
00407 connect( a, SIGNAL(activated()), this, SLOT(slotBookmarkSelected()) );
00408 }
00409
00410 ++count;
00411 key = m_config.readEntry( QString::number( count ), QString::null );
00412 }
00413 m_actionBookmarkRemove->setEnabled( count > 1 );
00414
00415
00416 m_config.setGroup( "Session");
00417 QString first;
00418 count = 1;
00419 key = m_config.readEntry( QString::number( count ), QString::null );
00420 while ( !key.isNull() )
00421 {
00422 int pos = key.find( "/" );
00423 if ( pos > -1 )
00424 {
00425 if ( count == 1 )
00426 first = key.left( pos );
00427 openModule( key.left( pos ), key.right( key.length() - ( pos + 1 ) ) );
00428 }
00429
00430 ++count;
00431 key = m_config.readEntry( QString::number( count ), QString::null );
00432 }
00433 m_tabs.setCurrentTab( first );
00434 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
00435 if ( text )
00436 {
00437 setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
00438 m_navToolbar->setKey( text->getAbbrevKey() );
00439 }
00440 m_actionTextClose->setEnabled( count > 1 );
00441 m_actionEditCopy->setEnabled( count > 1 );
00442 }
00443
00444 void MainWindow::slotTextDisplayed( QWidget *textWidget )
00445 {
00446 TextWidget *text = reinterpret_cast<TextWidget *>(textWidget);
00447 setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
00448
00449 m_navToolbar->setKey( text->getAbbrevKey() );
00450 m_navToolbar->navBtnsEnable( text->isBibleText() );
00451
00452 m_searchToolbar->setCurrModule( text );
00453 }
00454
00455 void MainWindow::slotTextOpen()
00456 {
00457 OpenTextDlg dlg( this, m_swordMgr, m_bibleIcon, m_commentaryIcon, m_lexiconIcon );
00458 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
00459 {
00460 openModule( dlg.selectedText() );
00461 }
00462 }
00463
00464 void MainWindow::slotTextClose()
00465 {
00466 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
00467 if ( text )
00468 {
00469 m_tabs.removePage( text );
00470 delete text;
00471
00472
00473 if ( !m_tabs.currentWidget() )
00474 {
00475 m_navToolbar->navBtnsEnable( false );
00476 m_navToolbar->setKey( QString::null );
00477 m_searchToolbar->setCurrModule( 0x0 );
00478 m_actionTextClose->setEnabled( false );
00479 m_actionEditCopy->setEnabled( false );
00480 m_actionBookmarkAdd->setEnabled( false );
00481 m_actionBookmarkRemove->setEnabled( false );
00482 }
00483 }
00484 }
00485
00486 void MainWindow::slotTextInstall()
00487 {
00488 }
00489
00490 void MainWindow::slotEditCopy()
00491 {
00492 TextWidget *currModule = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
00493 if ( currModule )
00494 {
00495 QString text;
00496
00497 switch( m_copyFormat )
00498 {
00499 case 0: text.sprintf( "%s (%s, %s)", currModule->getCurrVerse().latin1(),
00500 currModule->getAbbrevKey().latin1(),
00501 currModule->getModuleName().latin1() );
00502 break;
00503 case 1: text.sprintf( "%s (%s)", currModule->getCurrVerse().latin1(),
00504 currModule->getAbbrevKey().latin1() );
00505 break;
00506 case 2: text = currModule->getCurrVerse();
00507 break;
00508 case 3: text = currModule->getAbbrevKey();
00509 break;
00510 default: text = QString::null;
00511 };
00512
00513 if ( !text.isNull() )
00514 QPEApplication::clipboard()->setText( text );
00515 }
00516 }
00517
00518 void MainWindow::slotEditConfigure()
00519 {
00520 ConfigureDlg dlg( this, m_modulePath, m_alwaysOpenNew, m_numVerses, m_disableScreenBlank, m_copyFormat,
00521 &m_textFont );
00522 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
00523 {
00524 m_modulePath = dlg.swordPath();
00525 m_alwaysOpenNew = dlg.alwaysOpenNew();
00526 if ( dlg.numVerses() != m_numVerses )
00527 {
00528 m_numVerses = dlg.numVerses();
00529 emit sigNumVersesChanged( m_numVerses );
00530 }
00531 m_disableScreenBlank = dlg.screenBlank();
00532 enableScreenBlanking( !m_disableScreenBlank );
00533 m_copyFormat = dlg.copyFormat();
00534 m_textFont = dlg.selectedFont();
00535 emit sigFontChanged( &m_textFont );
00536 }
00537 }
00538
00539 void MainWindow::slotBookmarkAdd()
00540 {
00541 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
00542 if ( text )
00543 {
00544
00545 QString bookmark = text->getFullKey();
00546 int menuId = findBookmark( bookmark );
00547 if ( menuId == -1 )
00548 {
00549
00550 QAction *a = new QAction( bookmark, QString::null, 0, this, 0 );
00551 a->addTo( m_bookmarkMenu );
00552 connect( a, SIGNAL(activated()), this, SLOT(slotBookmarkSelected()) );
00553
00554
00555 m_actionBookmarkRemove->setEnabled( true );
00556
00557 }
00558 }
00559 }
00560
00561 void MainWindow::slotBookmarkRemove()
00562 {
00563 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
00564 if ( text )
00565 {
00566
00567 int menuId = findBookmark( text->getFullKey() );
00568 if ( menuId != -1 )
00569 {
00570
00571 m_bookmarkMenu->removeItem( menuId );
00572
00573
00574 if ( m_bookmarkMenu->idAt( 3 ) == -1 )
00575 m_actionBookmarkRemove->setEnabled( false );
00576 }
00577 }
00578 }
00579
00580 void MainWindow::slotBookmarkSelected()
00581 {
00582 const QAction *action = reinterpret_cast<const QAction *>(sender());
00583 if ( action )
00584 {
00585 QString bookmark = action->text();
00586 int pos = bookmark.find( " (" );
00587 QString key = bookmark.left( pos );
00588 pos += 2;
00589 QString module = bookmark.mid( pos, bookmark.find( ")", pos ) - pos );
00590
00591 openModule( module, key );
00592 }
00593 }
00594
00595 void MainWindow::slotViewSwordOption( bool enabled )
00596 {
00597 const QAction *action = reinterpret_cast<const QAction*>(sender());
00598 m_swordMgr->setGlobalOption ( action->text(), enabled ? "On" : "Off" );
00599
00600 emit sigOptionChanged();
00601 }
00602
00603 void MainWindow::slotViewNavToolbar( bool enabled )
00604 {
00605 enabled ? m_navToolbar->show()
00606 : m_navToolbar->hide();
00607 }
00608
00609 void MainWindow::slotViewSearchToolbar( bool enabled )
00610 {
00611 enabled ? m_searchToolbar->show()
00612 : m_searchToolbar->hide();
00613 }
00614
00615 void MainWindow::slotNavPrevPage()
00616 {
00617 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
00618 if ( text )
00619 {
00620 text->prevPage();
00621 setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
00622 m_navToolbar->setKey( text->getAbbrevKey() );
00623 }
00624 }
00625
00626 void MainWindow::slotNavPrevVerse()
00627 {
00628 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
00629 if ( text )
00630 {
00631 text->prevVerse();
00632 setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
00633 m_navToolbar->setKey( text->getAbbrevKey() );
00634 }
00635 }
00636
00637 void MainWindow::slotNavKeyChanged( const QString &newKey )
00638 {
00639 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
00640 if ( text )
00641 {
00642 QString key = newKey;
00643 if ( text->isBibleText() )
00644 key.replace( QRegExp( "[-=.]" ), ":" );
00645
00646 text->setKey( key );
00647 setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
00648 }
00649 }
00650
00651 void MainWindow::slotNavNextVerse()
00652 {
00653 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
00654 if ( text )
00655 {
00656 text->nextVerse();
00657 setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
00658 m_navToolbar->setKey( text->getAbbrevKey() );
00659 }
00660 }
00661
00662 void MainWindow::slotNavNextPage()
00663 {
00664 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
00665 if ( text )
00666 {
00667 text->nextPage();
00668 setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
00669 m_navToolbar->setKey( text->getAbbrevKey() );
00670 }
00671 }
00672
00673 void MainWindow::slotNavAutoScroll( bool enabled )
00674 {
00675 m_autoScrollTimer.stop();
00676
00677 if ( enabled )
00678 m_autoScrollTimer.start( m_navToolbar->autoScrollRate() * 100 );
00679 }
00680
00681 void MainWindow::slotNavScrollRateChanged( int newRate )
00682 {
00683 if ( m_autoScrollTimer.isActive() )
00684 {
00685 m_autoScrollTimer.stop();
00686 m_autoScrollTimer.start( newRate * 100 );
00687 }
00688 }
00689
00690 void MainWindow::slotSearchResultClicked( const QString &key )
00691 {
00692 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
00693 if ( text )
00694 {
00695 text->setKey( key );
00696 setCaption( QString( "%1 - Dagger" ).arg( text->getFullKey() ) );
00697 m_navToolbar->setKey( text->getAbbrevKey() );
00698 }
00699 }
00700
00701 void MainWindow::slotTextRefClicked( const QString &ref )
00702 {
00703
00704
00705
00706
00707
00708
00709
00710
00711 if ( !ref.isNull() )
00712 {
00713 TextWidget *text = reinterpret_cast<TextWidget *>(m_tabs.currentWidget());
00714 if ( text )
00715 {
00716
00717 int pos = ref.find( '&', 28 );
00718 QString actionStr = ref.mid( 28, pos - 28 );
00719
00720
00721 pos = ref.find( "type=", pos, false ) + 5;
00722 QString typeStr = ref.mid( pos, ref.find( '&', pos ) - pos );
00723
00724
00725 pos = ref.find( "value=", 0, false ) + 6;
00726 QString valueStr = ref.mid( pos, ref.find( ' ', pos ) - pos );
00727
00728 if ( actionStr == "Strongs" )
00729 {
00730 QString module = actionStr;
00731 module.append( typeStr );
00732
00733
00734 openModule( module, valueStr );
00735 }
00736 else if ( actionStr == "Morph" )
00737 {
00738 QString module = typeStr.mid( 2, typeStr.find( '%', 2 ) - 2 );
00739
00740
00741 openModule( module, valueStr );
00742 }
00743 else if ( actionStr == "Note" )
00744 {
00745
00746 }
00747 }
00748 }
00749 }