summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:29 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:29 -0400
commite8a196082586bb68e0bf254a8f6f4b8f39071f32 (patch)
treeb03dbbd1b5be6092ed5e9bcb3806aa2d4938bba3
parentdd2f7ce46df53f2c377c02d1bf4df8adcf092072 (diff)
Imported Upstream version 2.3.3
-rw-r--r--CMakeLists.txt27
-rw-r--r--ChangeLog36
-rw-r--r--docs/handbook/en/html/i_back.pngbin2149 -> 1941 bytes
-rw-r--r--docs/handbook/en/html/i_bible.pngbin2034 -> 2030 bytes
-rw-r--r--docs/handbook/en/html/i_bibletime.pngbin2259 -> 2257 bytes
-rw-r--r--docs/handbook/en/html/i_book.pngbin1738 -> 1734 bytes
-rw-r--r--docs/handbook/en/html/i_cascade.pngbin1233 -> 1227 bytes
-rw-r--r--docs/handbook/en/html/i_commentary.pngbin2087 -> 2084 bytes
-rw-r--r--docs/handbook/en/html/i_configure.pngbin1839 -> 1447 bytes
-rw-r--r--docs/handbook/en/html/i_configuresword.pngbin2067 -> 2047 bytes
-rw-r--r--docs/handbook/en/html/i_contents2.pngbin1698 -> 1627 bytes
-rw-r--r--docs/handbook/en/html/i_displayconfig.pngbin2294 -> 2219 bytes
-rw-r--r--docs/handbook/en/html/i_exit.pngbin1610 -> 1397 bytes
-rw-r--r--docs/handbook/en/html/i_fileclose.pngbin1594 -> 1074 bytes
-rw-r--r--docs/handbook/en/html/i_find.pngbin1758 -> 1608 bytes
-rw-r--r--docs/handbook/en/html/i_forward.pngbin2183 -> 1986 bytes
-rw-r--r--docs/handbook/en/html/i_lexicon.pngbin1947 -> 1946 bytes
-rw-r--r--docs/handbook/en/html/i_tile_horiz.pngbin671 -> 450 bytes
-rw-r--r--docs/handbook/en/html/i_tile_vert.pngbin639 -> 441 bytes
-rw-r--r--docs/handbook/en/html/i_view_index.pngbin435 -> 325 bytes
-rw-r--r--docs/handbook/en/html/i_view_mag.pngbin375 -> 303 bytes
-rw-r--r--docs/handbook/en/html/i_window_fullscreen.pngbin1282 -> 925 bytes
-rw-r--r--docs/handbook/en/html/ss_configfonts.pngbin22247 -> 18561 bytes
-rw-r--r--docs/handbook/en/html/ss_mainterms.pngbin69550 -> 56706 bytes
-rw-r--r--docs/handbook/en/html/ss_searchanal.pngbin17886 -> 14730 bytes
-rw-r--r--docs/handbook/en/html/ss_searchopts.pngbin91674 -> 73568 bytes
-rw-r--r--pics/startuplogo.pngbin24664 -> 23667 bytes
-rw-r--r--src/backend/bookshelfmodel/btbookshelfmodel.cpp92
-rw-r--r--src/backend/bookshelfmodel/btbookshelfmodel.h18
-rw-r--r--src/backend/bookshelfmodel/btbookshelftreemodel.cpp97
-rw-r--r--src/backend/bookshelfmodel/btbookshelftreemodel.h41
-rw-r--r--src/backend/bookshelfmodel/btcheckstatefilterproxymodel.cpp14
-rw-r--r--src/backend/bookshelfmodel/btcheckstatefilterproxymodel.h14
-rw-r--r--src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp9
-rw-r--r--src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h6
-rw-r--r--src/backend/bookshelfmodel/categoryitem.cpp10
-rw-r--r--src/backend/bookshelfmodel/categoryitem.h4
-rw-r--r--src/backend/bookshelfmodel/distributionitem.cpp3
-rw-r--r--src/backend/bookshelfmodel/distributionitem.h10
-rw-r--r--src/backend/bookshelfmodel/item.cpp3
-rw-r--r--src/backend/bookshelfmodel/item.h26
-rw-r--r--src/backend/bookshelfmodel/languageitem.cpp3
-rw-r--r--src/backend/bookshelfmodel/languageitem.h4
-rw-r--r--src/backend/bookshelfmodel/moduleitem.cpp3
-rw-r--r--src/backend/bookshelfmodel/moduleitem.h10
-rw-r--r--src/backend/btmoduletreeitem.cpp431
-rw-r--r--src/backend/btmoduletreeitem.h243
-rw-r--r--src/backend/config/cbtconfig.cpp442
-rw-r--r--src/backend/cswordmodulesearch.cpp102
-rw-r--r--src/backend/cswordmodulesearch.h118
-rw-r--r--src/backend/drivers/cswordbiblemoduleinfo.cpp282
-rw-r--r--src/backend/drivers/cswordbiblemoduleinfo.h160
-rw-r--r--src/backend/drivers/cswordbookmoduleinfo.cpp58
-rw-r--r--src/backend/drivers/cswordbookmoduleinfo.h66
-rw-r--r--src/backend/drivers/cswordcommentarymoduleinfo.cpp16
-rw-r--r--src/backend/drivers/cswordcommentarymoduleinfo.h28
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.cpp254
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.h76
-rw-r--r--src/backend/drivers/cswordmoduleinfo.cpp1328
-rw-r--r--src/backend/drivers/cswordmoduleinfo.h636
-rw-r--r--src/backend/filters/bt_gbfhtml.cpp436
-rw-r--r--src/backend/filters/bt_gbfhtml.h43
-rw-r--r--src/backend/filters/bt_osishtml.cpp1117
-rw-r--r--src/backend/filters/bt_osishtml.h88
-rw-r--r--src/backend/filters/bt_plainhtml.cpp100
-rw-r--r--src/backend/filters/bt_plainhtml.h18
-rw-r--r--src/backend/filters/bt_thmlhtml.cpp646
-rw-r--r--src/backend/filters/bt_thmlhtml.h46
-rw-r--r--src/backend/filters/bt_thmlplain.cpp380
-rw-r--r--src/backend/filters/bt_thmlplain.h12
-rw-r--r--src/backend/filters/osismorphsegmentation.cpp84
-rw-r--r--src/backend/filters/osismorphsegmentation.h16
-rw-r--r--src/backend/keys/cswordkey.cpp237
-rw-r--r--src/backend/keys/cswordkey.h147
-rw-r--r--src/backend/keys/cswordldkey.cpp100
-rw-r--r--src/backend/keys/cswordldkey.h102
-rw-r--r--src/backend/keys/cswordtreekey.cpp94
-rw-r--r--src/backend/keys/cswordtreekey.h94
-rw-r--r--src/backend/keys/cswordversekey.cpp461
-rw-r--r--src/backend/keys/cswordversekey.h140
-rw-r--r--src/backend/managers/btstringmgr.cpp206
-rw-r--r--src/backend/managers/btstringmgr.h50
-rw-r--r--src/backend/managers/cdisplaytemplatemgr.cpp265
-rw-r--r--src/backend/managers/cdisplaytemplatemgr.h92
-rw-r--r--src/backend/managers/clanguagemgr.cpp960
-rw-r--r--src/backend/managers/clanguagemgr.h234
-rw-r--r--src/backend/managers/creferencemanager.cpp666
-rw-r--r--src/backend/managers/creferencemanager.h154
-rw-r--r--src/backend/managers/cswordbackend.cpp842
-rw-r--r--src/backend/managers/cswordbackend.h414
-rw-r--r--src/backend/rendering/cbookdisplay.cpp160
-rw-r--r--src/backend/rendering/cbookdisplay.h32
-rw-r--r--src/backend/rendering/cchapterdisplay.cpp62
-rw-r--r--src/backend/rendering/cchapterdisplay.h16
-rw-r--r--src/backend/rendering/cdisplayrendering.cpp268
-rw-r--r--src/backend/rendering/cdisplayrendering.h18
-rw-r--r--src/backend/rendering/centrydisplay.cpp62
-rw-r--r--src/backend/rendering/centrydisplay.h16
-rw-r--r--src/backend/rendering/chtmlexportrendering.cpp362
-rw-r--r--src/backend/rendering/chtmlexportrendering.h62
-rw-r--r--src/backend/rendering/cplaintextexportrendering.cpp38
-rw-r--r--src/backend/rendering/cplaintextexportrendering.h32
-rw-r--r--src/backend/rendering/ctextrendering.cpp382
-rw-r--r--src/backend/rendering/ctextrendering.h118
-rw-r--r--src/bibletime.cpp374
-rw-r--r--src/bibletime.h497
-rw-r--r--src/bibletime_dbus.cpp276
-rw-r--r--src/bibletime_dbus_adaptor.cpp61
-rw-r--r--src/bibletime_dbus_adaptor.h159
-rw-r--r--src/bibletime_init.cpp714
-rw-r--r--src/bibletime_slots.cpp733
-rw-r--r--src/bibletimeapp.cpp17
-rw-r--r--src/bibletimeapp.h8
-rw-r--r--src/frontend/bookshelfmanager/btconfigdialog.cpp145
-rw-r--r--src/frontend/bookshelfmanager/btconfigdialog.h86
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.cpp88
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.h76
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp84
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.h35
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp237
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h24
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.cpp282
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.h115
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp188
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h29
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.cpp203
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.h67
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp241
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h43
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp340
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h69
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.cpp281
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.h83
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcearea.cpp432
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcearea.h105
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp625
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcewidget.h107
-rw-r--r--src/frontend/bookshelfmanager/instbackend.cpp380
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.cpp320
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.h53
-rw-r--r--src/frontend/btaboutmoduledialog.cpp13
-rw-r--r--src/frontend/btaboutmoduledialog.h11
-rw-r--r--src/frontend/btbookshelfdockwidget.cpp287
-rw-r--r--src/frontend/btbookshelfdockwidget.h43
-rw-r--r--src/frontend/cdragdrop.cpp33
-rw-r--r--src/frontend/cdragdrop.h100
-rw-r--r--src/frontend/cdragdropmgr.cpp326
-rw-r--r--src/frontend/cdragdropmgr.h224
-rw-r--r--src/frontend/cexportmanager.cpp844
-rw-r--r--src/frontend/cexportmanager.h112
-rw-r--r--src/frontend/cinfodisplay.cpp744
-rw-r--r--src/frontend/cinfodisplay.h64
-rw-r--r--src/frontend/cinputdialog.cpp112
-rw-r--r--src/frontend/cinputdialog.h30
-rw-r--r--src/frontend/cmdiarea.cpp363
-rw-r--r--src/frontend/cmdiarea.h158
-rw-r--r--src/frontend/cmodulechooserdialog.cpp177
-rw-r--r--src/frontend/cmodulechooserdialog.h147
-rw-r--r--src/frontend/cmoduleindexdialog.cpp128
-rw-r--r--src/frontend/cmoduleindexdialog.h56
-rw-r--r--src/frontend/cprinter.cpp185
-rw-r--r--src/frontend/cprinter.h38
-rw-r--r--src/frontend/crossrefrendering.cpp111
-rw-r--r--src/frontend/crossrefrendering.h23
-rw-r--r--src/frontend/display/btcolorwidget.cpp68
-rw-r--r--src/frontend/display/btcolorwidget.h31
-rw-r--r--src/frontend/display/btfontsizewidget.cpp51
-rw-r--r--src/frontend/display/btfontsizewidget.h29
-rw-r--r--src/frontend/display/bthtmlfindtext.cpp113
-rw-r--r--src/frontend/display/bthtmlfindtext.h29
-rw-r--r--src/frontend/display/bthtmljsobject.cpp224
-rw-r--r--src/frontend/display/bthtmljsobject.h82
-rw-r--r--src/frontend/display/bthtmlreaddisplay.cpp479
-rw-r--r--src/frontend/display/bthtmlreaddisplay.h147
-rw-r--r--src/frontend/display/cdisplay.cpp137
-rw-r--r--src/frontend/display/cdisplay.h268
-rw-r--r--src/frontend/display/chtmlwritedisplay.cpp404
-rw-r--r--src/frontend/display/chtmlwritedisplay.h148
-rw-r--r--src/frontend/display/cplainwritedisplay.cpp139
-rw-r--r--src/frontend/display/cplainwritedisplay.h112
-rw-r--r--src/frontend/display/creaddisplay.cpp116
-rw-r--r--src/frontend/display/creaddisplay.h78
-rw-r--r--src/frontend/display/cwritedisplay.h46
-rw-r--r--src/frontend/displaywindow/btactioncollection.cpp200
-rw-r--r--src/frontend/displaywindow/btactioncollection.h33
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.cpp78
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.h39
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.cpp624
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.h208
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.cpp186
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.h90
-rw-r--r--src/frontend/displaywindow/cbuttons.cpp230
-rw-r--r--src/frontend/displaywindow/cbuttons.h93
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.cpp216
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.h70
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.cpp694
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.h251
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.cpp52
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.h15
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.cpp202
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.h88
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.cpp520
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.h178
-rw-r--r--src/frontend/displaywindow/cmodulechooserbar.cpp151
-rw-r--r--src/frontend/displaywindow/cmodulechooserbar.h82
-rw-r--r--src/frontend/displaywindow/cmodulechooserbutton.cpp306
-rw-r--r--src/frontend/displaywindow/cmodulechooserbutton.h106
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.cpp209
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.h120
-rw-r--r--src/frontend/displaywindow/creadwindow.cpp259
-rw-r--r--src/frontend/displaywindow/creadwindow.h92
-rw-r--r--src/frontend/displaywindow/cwritewindow.cpp202
-rw-r--r--src/frontend/displaywindow/cwritewindow.h76
-rw-r--r--src/frontend/htmldialogs/btaboutdialog.cpp378
-rw-r--r--src/frontend/htmldialogs/btaboutdialog.h21
-rw-r--r--src/frontend/htmldialogs/bttabhtmldialog.cpp170
-rw-r--r--src/frontend/htmldialogs/bttabhtmldialog.h60
-rw-r--r--src/frontend/keychooser/bthistory.cpp165
-rw-r--r--src/frontend/keychooser/bthistory.h97
-rw-r--r--src/frontend/keychooser/cbookkeychooser.cpp408
-rw-r--r--src/frontend/keychooser/cbookkeychooser.h100
-rw-r--r--src/frontend/keychooser/cbooktreechooser.cpp233
-rw-r--r--src/frontend/keychooser/cbooktreechooser.h94
-rw-r--r--src/frontend/keychooser/ckeychooser.cpp48
-rw-r--r--src/frontend/keychooser/ckeychooser.h152
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.cpp510
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.h258
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.cpp227
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.h94
-rw-r--r--src/frontend/keychooser/cscrollbutton.cpp18
-rw-r--r--src/frontend/keychooser/cscrollbutton.h2
-rw-r--r--src/frontend/keychooser/cscrollerwidgetset.cpp114
-rw-r--r--src/frontend/keychooser/cscrollerwidgetset.h82
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp142
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h92
-rw-r--r--src/frontend/keychooser/versekeychooser/btversekeymenu.cpp51
-rw-r--r--src/frontend/keychooser/versekeychooser/btversekeymenu.h31
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp112
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.h78
-rw-r--r--src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp362
-rw-r--r--src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h126
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp194
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkfolder.h45
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkitem.cpp198
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkitem.h61
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkitembase.cpp21
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkitembase.h53
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkloader.cpp244
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkloader.h39
-rw-r--r--src/frontend/mainindex/bookmarks/cbookmarkindex.cpp1308
-rw-r--r--src/frontend/mainindex/bookmarks/cbookmarkindex.h194
-rw-r--r--src/frontend/mainindex/bookshelf/actionenum.h16
-rw-r--r--src/frontend/mainindex/bookshelf/btindexfolder.cpp7
-rw-r--r--src/frontend/mainindex/bookshelf/btindexfolder.h9
-rw-r--r--src/frontend/mainindex/bookshelf/btindexitem.cpp3
-rw-r--r--src/frontend/mainindex/bookshelf/btindexitem.h37
-rw-r--r--src/frontend/mainindex/bookshelf/btindexmodule.cpp108
-rw-r--r--src/frontend/mainindex/bookshelf/btindexmodule.h19
-rw-r--r--src/frontend/mainindex/bookshelf/cbookshelfindex.cpp1044
-rw-r--r--src/frontend/mainindex/bookshelf/cbookshelfindex.h310
-rw-r--r--src/frontend/mainindex/bookshelf/chidemodulechooserdialog.cpp58
-rw-r--r--src/frontend/mainindex/bookshelf/chidemodulechooserdialog.h31
-rw-r--r--src/frontend/mainindex/btbookshelfview.cpp36
-rw-r--r--src/frontend/mainindex/btbookshelfview.h2
-rw-r--r--src/frontend/profile/cprofile.cpp666
-rw-r--r--src/frontend/profile/cprofile.h174
-rw-r--r--src/frontend/profile/cprofilemgr.cpp146
-rw-r--r--src/frontend/profile/cprofilemgr.h70
-rw-r--r--src/frontend/profile/cprofilewindow.cpp64
-rw-r--r--src/frontend/profile/cprofilewindow.h178
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp82
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.h45
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.cpp188
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.h65
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp67
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.h15
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.cpp403
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.h102
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.cpp15
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.h47
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.cpp770
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.h221
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.cpp1093
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.h250
-rw-r--r--src/frontend/searchdialog/chistorycombobox.cpp41
-rw-r--r--src/frontend/searchdialog/chistorycombobox.h23
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.cpp418
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.h186
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.cpp407
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.h111
-rw-r--r--src/frontend/searchdialog/csearchdialog.cpp383
-rw-r--r--src/frontend/searchdialog/csearchdialog.h182
-rw-r--r--src/frontend/searchdialog/csearchmodulechooserdialog.cpp37
-rw-r--r--src/frontend/searchdialog/csearchmodulechooserdialog.h23
-rw-r--r--src/frontend/searchdialog/csearchresultview.cpp376
-rw-r--r--src/frontend/searchdialog/csearchresultview.h142
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.cpp119
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.h53
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.cpp577
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.h99
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.cpp422
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.h99
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.cpp137
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.h40
-rw-r--r--src/frontend/settingsdialogs/cdisplaysettings.cpp282
-rw-r--r--src/frontend/settingsdialogs/cdisplaysettings.h37
-rw-r--r--src/frontend/settingsdialogs/cfontchooser.cpp428
-rw-r--r--src/frontend/settingsdialogs/cfontchooser.h74
-rw-r--r--src/frontend/settingsdialogs/clanguagesettings.cpp451
-rw-r--r--src/frontend/settingsdialogs/clanguagesettings.h59
-rw-r--r--src/frontend/settingsdialogs/clistwidget.cpp16
-rw-r--r--src/frontend/settingsdialogs/clistwidget.h12
-rw-r--r--src/frontend/settingsdialogs/cswordsettings.cpp704
-rw-r--r--src/frontend/settingsdialogs/cswordsettings.h95
-rw-r--r--src/main.cpp176
-rw-r--r--src/tests/backend/config/cbtconfig_test.cpp37
-rw-r--r--src/tests/bibletime_test.cpp5
-rw-r--r--src/tests/bibletime_test.h17
-rw-r--r--src/util/cpointers.cpp30
-rw-r--r--src/util/cpointers.h144
-rw-r--r--src/util/cresmgr.cpp950
-rw-r--r--src/util/cresmgr.h972
-rw-r--r--src/util/ctoolclass.cpp372
-rw-r--r--src/util/ctoolclass.h110
-rw-r--r--src/util/dialogutil.cpp81
-rw-r--r--src/util/dialogutil.h7
-rw-r--r--src/util/directoryutil.cpp534
-rw-r--r--src/util/directoryutil.h160
-rw-r--r--src/util/migrationutil.cpp124
-rw-r--r--src/util/migrationutil.h36
330 files changed, 28364 insertions, 29166 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e91ccfb..4f4e0d6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@ PROJECT(bibletime CXX C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
#Version
-ADD_DEFINITIONS(-DBT_VERSION="2.3")
+ADD_DEFINITIONS(-DBT_VERSION="2.3.3")
#Non-English locales to be processed and installed for UI, handbook and howto
LIST(APPEND MESSAGE_LOCALE_LANGS af bg cs da de en_GB es et fi fr hu it ko nl nn_NO no pl pt_br ro ru sk sv ua vi zh_CN zh_TW)
@@ -300,6 +300,29 @@ ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/c
######################################################
+# Developer section
+#
+FILE(GLOB_RECURSE ORIG_SOURCE_FILES
+ RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/src/"
+ "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp"
+ "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h"
+)
+FOREACH(FILE ${ORIG_SOURCE_FILES})
+ SET(REFORMAT_FILES "${REFORMAT_FILES} ${FILE}")
+ENDFOREACH(FILE ${ORIG_SOURCE_FILES})
+
+SET(ASTYLE_OPTIONS "--indent=spaces=4 --brackets=attach --indent-classes --indent-switches --brackets=break-closing --pad=oper --suffix=none --options=none")
+
+ADD_CUSTOM_TARGET("reformat_codebase"
+ COMMAND "sh" "-c" "astyle ${ASTYLE_OPTIONS} ${REFORMAT_FILES}"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/"
+ VERBATIM
+)
+######################################################
+
+
+
+######################################################
# This is the CPack section
# Copied and modified from http://www.vtk.org/Wiki/CMake:Packaging_With_CPack
@@ -307,7 +330,7 @@ SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "BibleTime for Windows Beta")
SET(CPACK_PACKAGE_VENDOR "http://www.bibletime.info")
SET(CPACK_PACKAGE_VERSION_MAJOR "2")
SET(CPACK_PACKAGE_VERSION_MINOR "3")
-SET(CPACK_PACKAGE_VERSION_PATCH "0")
+SET(CPACK_PACKAGE_VERSION_PATCH "2")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "BibleTime")
######################################################
diff --git a/ChangeLog b/ChangeLog
index 5f00221..abbeb25 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,39 @@
+2009-10-27 Martin Gruner <mgruner@crosswire.org>
+ * Release 2.3.3
+
+2009-10-26 Jaak Ristioja <ristioja@gmail.com>
+ * Backported showing locked icons in the bookshelf dock.
+ * Backported lexicon category having wrong icon fix.
+
+2009-10-24 Jaak Ristioja <ristioja@gmail.com>
+ * Fixed a crash on module installation/uninstall.
+ * Fixed the wrong icon for lexicons.
+ * Fixed some (not all) memory leaks.
+
+2009-10-14 Martin Gruner <mgruner@crosswire.org>
+ * Release 2.3.2
+
+2009-10-13 Jaak Ristioja <ristioja@gmail.com>
+ * Backported bookshelf model category sorting fix.
+ * Fixed a CSwordModuleInfo bug, which had unknown effects.
+ * Reimplemented saving of bookshelf model grouping state.
+
+2009-10-13 Martin Gruner <mgruner@crosswire.org>
+ * Fixed nasty bug with incorrect footnote display in combination with
+ crossReferences in the same verse.
+
+2009-10-10 Martin Gruner <mgruner@crosswire.org>
+ * Reformatted codebase like in TRUNK a few days ago to be able to apply patches.
+ * Fixed bug #2849728: Lucene Text Fields search not working. Search now
+ correctly includes data from EntryAttributes as well as data from EntryAttributes
+ of entries with verse == 0.
+
+2009-10-06 Martin Gruner <mgruner@crosswire.org>
+ * Release 2.3.1
+
+2009-10-09 Jaak Ristioja <ristioja@gmail.com>
+ * Fixed compilation for Qt 4.4
+
2009-10-06 Martin Gruner <mgruner@crosswire.org>
* Release 2.3
diff --git a/docs/handbook/en/html/i_back.png b/docs/handbook/en/html/i_back.png
index c20edfa..f91595b 100644
--- a/docs/handbook/en/html/i_back.png
+++ b/docs/handbook/en/html/i_back.png
Binary files differ
diff --git a/docs/handbook/en/html/i_bible.png b/docs/handbook/en/html/i_bible.png
index caba77b..39a7013 100644
--- a/docs/handbook/en/html/i_bible.png
+++ b/docs/handbook/en/html/i_bible.png
Binary files differ
diff --git a/docs/handbook/en/html/i_bibletime.png b/docs/handbook/en/html/i_bibletime.png
index 7dcbc90..17a72d2 100644
--- a/docs/handbook/en/html/i_bibletime.png
+++ b/docs/handbook/en/html/i_bibletime.png
Binary files differ
diff --git a/docs/handbook/en/html/i_book.png b/docs/handbook/en/html/i_book.png
index 25cbd5d..f1a72e4 100644
--- a/docs/handbook/en/html/i_book.png
+++ b/docs/handbook/en/html/i_book.png
Binary files differ
diff --git a/docs/handbook/en/html/i_cascade.png b/docs/handbook/en/html/i_cascade.png
index 070f5d1..92c42c2 100644
--- a/docs/handbook/en/html/i_cascade.png
+++ b/docs/handbook/en/html/i_cascade.png
Binary files differ
diff --git a/docs/handbook/en/html/i_commentary.png b/docs/handbook/en/html/i_commentary.png
index e069a60..eecc241 100644
--- a/docs/handbook/en/html/i_commentary.png
+++ b/docs/handbook/en/html/i_commentary.png
Binary files differ
diff --git a/docs/handbook/en/html/i_configure.png b/docs/handbook/en/html/i_configure.png
index 1141564..6d07fbe 100644
--- a/docs/handbook/en/html/i_configure.png
+++ b/docs/handbook/en/html/i_configure.png
Binary files differ
diff --git a/docs/handbook/en/html/i_configuresword.png b/docs/handbook/en/html/i_configuresword.png
index b8f3d30..f701f18 100644
--- a/docs/handbook/en/html/i_configuresword.png
+++ b/docs/handbook/en/html/i_configuresword.png
Binary files differ
diff --git a/docs/handbook/en/html/i_contents2.png b/docs/handbook/en/html/i_contents2.png
index 6f4723c..cac8300 100644
--- a/docs/handbook/en/html/i_contents2.png
+++ b/docs/handbook/en/html/i_contents2.png
Binary files differ
diff --git a/docs/handbook/en/html/i_displayconfig.png b/docs/handbook/en/html/i_displayconfig.png
index 2d98873..69e25b0 100644
--- a/docs/handbook/en/html/i_displayconfig.png
+++ b/docs/handbook/en/html/i_displayconfig.png
Binary files differ
diff --git a/docs/handbook/en/html/i_exit.png b/docs/handbook/en/html/i_exit.png
index 4877f19..07cfe77 100644
--- a/docs/handbook/en/html/i_exit.png
+++ b/docs/handbook/en/html/i_exit.png
Binary files differ
diff --git a/docs/handbook/en/html/i_fileclose.png b/docs/handbook/en/html/i_fileclose.png
index 8acc84d..33cfafb 100644
--- a/docs/handbook/en/html/i_fileclose.png
+++ b/docs/handbook/en/html/i_fileclose.png
Binary files differ
diff --git a/docs/handbook/en/html/i_find.png b/docs/handbook/en/html/i_find.png
index de88913..6595073 100644
--- a/docs/handbook/en/html/i_find.png
+++ b/docs/handbook/en/html/i_find.png
Binary files differ
diff --git a/docs/handbook/en/html/i_forward.png b/docs/handbook/en/html/i_forward.png
index 88f2cb3..91d4f70 100644
--- a/docs/handbook/en/html/i_forward.png
+++ b/docs/handbook/en/html/i_forward.png
Binary files differ
diff --git a/docs/handbook/en/html/i_lexicon.png b/docs/handbook/en/html/i_lexicon.png
index 14abcd6..5244b27 100644
--- a/docs/handbook/en/html/i_lexicon.png
+++ b/docs/handbook/en/html/i_lexicon.png
Binary files differ
diff --git a/docs/handbook/en/html/i_tile_horiz.png b/docs/handbook/en/html/i_tile_horiz.png
index 66a7093..f7ceb87 100644
--- a/docs/handbook/en/html/i_tile_horiz.png
+++ b/docs/handbook/en/html/i_tile_horiz.png
Binary files differ
diff --git a/docs/handbook/en/html/i_tile_vert.png b/docs/handbook/en/html/i_tile_vert.png
index 3bb13b9..0016900 100644
--- a/docs/handbook/en/html/i_tile_vert.png
+++ b/docs/handbook/en/html/i_tile_vert.png
Binary files differ
diff --git a/docs/handbook/en/html/i_view_index.png b/docs/handbook/en/html/i_view_index.png
index a23418b..c90a98e 100644
--- a/docs/handbook/en/html/i_view_index.png
+++ b/docs/handbook/en/html/i_view_index.png
Binary files differ
diff --git a/docs/handbook/en/html/i_view_mag.png b/docs/handbook/en/html/i_view_mag.png
index 6c9ca5e..cb6dc13 100644
--- a/docs/handbook/en/html/i_view_mag.png
+++ b/docs/handbook/en/html/i_view_mag.png
Binary files differ
diff --git a/docs/handbook/en/html/i_window_fullscreen.png b/docs/handbook/en/html/i_window_fullscreen.png
index 3d6b7ef..4e89706 100644
--- a/docs/handbook/en/html/i_window_fullscreen.png
+++ b/docs/handbook/en/html/i_window_fullscreen.png
Binary files differ
diff --git a/docs/handbook/en/html/ss_configfonts.png b/docs/handbook/en/html/ss_configfonts.png
index a8c6a37..0281bca 100644
--- a/docs/handbook/en/html/ss_configfonts.png
+++ b/docs/handbook/en/html/ss_configfonts.png
Binary files differ
diff --git a/docs/handbook/en/html/ss_mainterms.png b/docs/handbook/en/html/ss_mainterms.png
index 6c7955a..e6f2c47 100644
--- a/docs/handbook/en/html/ss_mainterms.png
+++ b/docs/handbook/en/html/ss_mainterms.png
Binary files differ
diff --git a/docs/handbook/en/html/ss_searchanal.png b/docs/handbook/en/html/ss_searchanal.png
index e091c63..0862002 100644
--- a/docs/handbook/en/html/ss_searchanal.png
+++ b/docs/handbook/en/html/ss_searchanal.png
Binary files differ
diff --git a/docs/handbook/en/html/ss_searchopts.png b/docs/handbook/en/html/ss_searchopts.png
index 903713a..c2e47aa 100644
--- a/docs/handbook/en/html/ss_searchopts.png
+++ b/docs/handbook/en/html/ss_searchopts.png
Binary files differ
diff --git a/pics/startuplogo.png b/pics/startuplogo.png
index dcec37e..8d71ab3 100644
--- a/pics/startuplogo.png
+++ b/pics/startuplogo.png
Binary files differ
diff --git a/src/backend/bookshelfmodel/btbookshelfmodel.cpp b/src/backend/bookshelfmodel/btbookshelfmodel.cpp
index 6764a88..99f83ba 100644
--- a/src/backend/bookshelfmodel/btbookshelfmodel.cpp
+++ b/src/backend/bookshelfmodel/btbookshelfmodel.cpp
@@ -17,8 +17,7 @@
#include "util/directoryutil.h"
BtBookshelfModel::BtBookshelfModel(QObject *parent)
- : QAbstractListModel(parent)
-{
+ : QAbstractListModel(parent) {
// Intentionally empty
}
@@ -41,7 +40,7 @@ QVariant BtBookshelfModel::data(const QModelIndex &index, int role) const {
case ModuleNameRole: // Qt::DisplayRole
return m_data.at(row)->name();
case ModuleIconRole: // Qt::DecorationRole
- return categoryIcon(m_data.at(row)->category());
+ return moduleIcon(m_data.at(row));
case ModulePointerRole:
return qVariantFromValue((void*) m_data.at(row));
default:
@@ -50,19 +49,58 @@ QVariant BtBookshelfModel::data(const QModelIndex &index, int role) const {
}
QVariant BtBookshelfModel::headerData(int section, Qt::Orientation orientation,
- int role) const
-{
+ int role) const {
if (role == Qt::DisplayRole && orientation == Qt::Horizontal &&
- section == 0)
- {
+ section == 0) {
return tr("Module");
}
return QVariant();
}
-QIcon BtBookshelfModel::categoryIcon(const CSwordModuleInfo::Category &category)
-{
+QIcon BtBookshelfModel::moduleIcon(const CSwordModuleInfo *m) {
+ typedef util::filesystem::DirectoryUtil DU;
+
+ /// \todo Make CSwordModuleInfo::isLocked() const and remove const_cast:
+ CSwordModuleInfo *module(const_cast<CSwordModuleInfo*>(m));
+
+ CSwordModuleInfo::Category cat(module->category());
+ switch (cat) {
+ case CSwordModuleInfo::Bibles:
+ if (module->isLocked()) {
+ return DU::getIcon(CResMgr::modules::bible::icon_locked);
+ } else {
+ return DU::getIcon(CResMgr::modules::bible::icon_unlocked);
+ }
+ case CSwordModuleInfo::Commentaries:
+ if (module->isLocked()) {
+ return DU::getIcon(CResMgr::modules::commentary::icon_locked);
+ } else {
+ return DU::getIcon(CResMgr::modules::commentary::icon_unlocked);
+ }
+ case CSwordModuleInfo::Lexicons:
+ if (module->isLocked()) {
+ return DU::getIcon(CResMgr::modules::lexicon::icon_locked);
+ } else {
+ return DU::getIcon(CResMgr::modules::lexicon::icon_unlocked);
+ }
+ case CSwordModuleInfo::Books:
+ if (module->isLocked()) {
+ return DU::getIcon(CResMgr::modules::book::icon_locked);
+ } else {
+ return DU::getIcon(CResMgr::modules::book::icon_unlocked);
+ }
+ case CSwordModuleInfo::Cult:
+ case CSwordModuleInfo::Images:
+ case CSwordModuleInfo::DailyDevotional:
+ case CSwordModuleInfo::Glossary:
+ case CSwordModuleInfo::UnknownCategory:
+ default:
+ return categoryIcon(cat);
+ }
+}
+
+QIcon BtBookshelfModel::categoryIcon(const CSwordModuleInfo::Category &category) {
typedef util::filesystem::DirectoryUtil DU;
switch (category) {
@@ -89,8 +127,7 @@ QIcon BtBookshelfModel::categoryIcon(const CSwordModuleInfo::Category &category)
}
QString BtBookshelfModel::categoryName(
- const CSwordModuleInfo::Category &category)
-{
+ const CSwordModuleInfo::Category &category) {
switch (category) {
case CSwordModuleInfo::Bibles:
return tr("Bibles");
@@ -114,13 +151,17 @@ QString BtBookshelfModel::categoryName(
}
QString BtBookshelfModel::languageName(
- const CLanguageMgr::Language *language)
-{
+ const CLanguageMgr::Language *language) {
return language->translatedName();
}
-void BtBookshelfModel::clear() {
+void BtBookshelfModel::clear(bool destroy) {
+ if (m_data.size() <= 0) return;
+
beginRemoveRows(QModelIndex(), 0, m_data.size() - 1);
+ if (destroy) {
+ qDeleteAll(m_data);
+ }
m_data.clear();
endRemoveRows();
}
@@ -152,27 +193,40 @@ void BtBookshelfModel::addModules(const QSet<CSwordModuleInfo *> &modules) {
beginInsertRows(QModelIndex(), m_data.size(),
m_data.size() + newModules.size() - 1);
+#if QT_VERSION >= 0x040500
m_data.append(newModules);
+#else
+ Q_FOREACH(CSwordModuleInfo *module, newModules) {
+ m_data.append(module);
+ }
+#endif
endInsertRows();
}
-void BtBookshelfModel::removeModule(CSwordModuleInfo * const module) {
+void BtBookshelfModel::removeModule(CSwordModuleInfo * const module,
+ bool destroy)
+{
const int index(m_data.indexOf(module));
if (index == -1) return;
beginRemoveRows(QModelIndex(), index, index);
m_data.removeAt(index);
endRemoveRows();
+ if (destroy) delete module;
}
-void BtBookshelfModel::removeModules(const QList<CSwordModuleInfo *> &modules) {
- removeModules(modules.toSet());
+void BtBookshelfModel::removeModules(const QList<CSwordModuleInfo *> &modules,
+ bool destroy)
+{
+ removeModules(modules.toSet(), destroy);
}
-void BtBookshelfModel::removeModules(const QSet<CSwordModuleInfo *> &modules) {
+void BtBookshelfModel::removeModules(const QSet<CSwordModuleInfo *> &modules,
+ bool destroy)
+{
// This is inefficient, since signals are emitted for each removed module:
Q_FOREACH(CSwordModuleInfo *module, modules) {
- removeModule(module);
+ removeModule(module, destroy);
}
}
diff --git a/src/backend/bookshelfmodel/btbookshelfmodel.h b/src/backend/bookshelfmodel/btbookshelfmodel.h
index c268d2c..01fc260 100644
--- a/src/backend/bookshelfmodel/btbookshelfmodel.h
+++ b/src/backend/bookshelfmodel/btbookshelfmodel.h
@@ -18,7 +18,7 @@
#include "backend/drivers/cswordmoduleinfo.h"
class BtBookshelfModel: public QAbstractListModel {
- Q_OBJECT
+ Q_OBJECT
public:
enum ModuleRole {
ModuleNameRole = Qt::DisplayRole,
@@ -39,21 +39,25 @@ class BtBookshelfModel: public QAbstractListModel {
inline CSwordModuleInfo *module(const QModelIndex &index) const {
return (CSwordModuleInfo *)
- data(index, BtBookshelfModel::ModulePointerRole)
- .value<void *>();
+ data(index, BtBookshelfModel::ModulePointerRole)
+ .value<void *>();
}
+ static QIcon moduleIcon(const CSwordModuleInfo *module);
static QIcon categoryIcon(const CSwordModuleInfo::Category &category);
static QString categoryName(const CSwordModuleInfo::Category &category);
static QString languageName(const CLanguageMgr::Language *language);
- void clear();
+ void clear(bool destroy = false);
void addModule(CSwordModuleInfo * const module);
void addModules(const QSet<CSwordModuleInfo *> &modules);
void addModules(const QList<CSwordModuleInfo *> &modules);
- void removeModule(CSwordModuleInfo * const module);
- void removeModules(const QSet<CSwordModuleInfo *> &modules);
- void removeModules(const QList<CSwordModuleInfo *> &modules);
+ void removeModule(CSwordModuleInfo * const module,
+ bool destroy = false);
+ void removeModules(const QSet<CSwordModuleInfo *> &modules,
+ bool destroy = false);
+ void removeModules(const QList<CSwordModuleInfo *> &modules,
+ bool destroy = false);
CSwordModuleInfo* getModule(const QString &name) const;
inline const QList<CSwordModuleInfo *> &modules() const {
diff --git a/src/backend/bookshelfmodel/btbookshelftreemodel.cpp b/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
index 47526e9..8e457e7 100644
--- a/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
+++ b/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
@@ -22,13 +22,18 @@
using namespace BookshelfModel;
BtBookshelfTreeModel::BtBookshelfTreeModel(QObject *parent)
- : QAbstractItemModel(parent), m_sourceModel(0), m_rootItem(new RootItem),
- m_checkable(false), m_defaultChecked(false)
-{
+ : QAbstractItemModel(parent), m_sourceModel(0), m_rootItem(new RootItem),
+ m_checkable(false), m_defaultChecked(false) {
m_groupingOrder.push_back(GROUP_CATEGORY);
m_groupingOrder.push_back(GROUP_LANGUAGE);
}
+BtBookshelfTreeModel::BtBookshelfTreeModel(const Grouping &g, QObject *parent)
+ : QAbstractItemModel(parent), m_sourceModel(0), m_rootItem(new RootItem),
+ m_groupingOrder(g), m_checkable(false), m_defaultChecked(false) {
+ // Intentionally empty
+}
+
BtBookshelfTreeModel::~BtBookshelfTreeModel() {
delete m_rootItem;
}
@@ -46,15 +51,15 @@ bool BtBookshelfTreeModel::hasChildren(const QModelIndex &parent) const {
}
QModelIndex BtBookshelfTreeModel::index(int row, int column,
- const QModelIndex &parent) const
-{
+ const QModelIndex &parent) const {
if (!hasIndex(row, column, parent)) return QModelIndex();
Item *parentItem(getItem(parent));
Item *childItem(parentItem->childAt(row));
if (childItem != 0) {
return createIndex(row, column, childItem);
- } else {
+ }
+ else {
return QModelIndex();
}
}
@@ -107,8 +112,7 @@ QVariant BtBookshelfTreeModel::data(const QModelIndex &index, int role) const {
bool BtBookshelfTreeModel::setData(const QModelIndex &itemIndex,
const QVariant &value,
- int role)
-{
+ int role) {
typedef QPair<Item *, QModelIndex> IP;
if (role == Qt::CheckStateRole) {
@@ -164,9 +168,8 @@ Qt::ItemFlags BtBookshelfTreeModel::flags(const QModelIndex &index) const {
}
QVariant BtBookshelfTreeModel::headerData(int section,
- Qt::Orientation orientation,
- int role) const
-{
+ Qt::Orientation orientation,
+ int role) const {
if (orientation == Qt::Horizontal) {
return m_sourceModel->headerData(section, orientation, role);
}
@@ -177,9 +180,9 @@ void BtBookshelfTreeModel::setSourceModel(QAbstractListModel *sourceModel) {
if (m_sourceModel == sourceModel) return;
if (m_sourceModel != 0) {
- disconnect(this, SLOT(moduleInserted(QModelIndex,int,int)));
- disconnect(this, SLOT(moduleRemoved(QModelIndex,int,int)));
- disconnect(this, SLOT(moduleDataChanged(QModelIndex,QModelIndex)));
+ disconnect(this, SLOT(moduleInserted(QModelIndex, int, int)));
+ disconnect(this, SLOT(moduleRemoved(QModelIndex, int, int)));
+ disconnect(this, SLOT(moduleDataChanged(QModelIndex, QModelIndex)));
beginRemoveRows(QModelIndex(), 0, m_rootItem->children().size() - 1);
delete m_rootItem;
m_modules.clear();
@@ -190,10 +193,10 @@ void BtBookshelfTreeModel::setSourceModel(QAbstractListModel *sourceModel) {
m_sourceModel = sourceModel;
if (sourceModel != 0) {
- connect(sourceModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
- this, SLOT(moduleRemoved(QModelIndex,int,int)));
- connect(sourceModel, SIGNAL(rowsInserted(QModelIndex,int,int)),
- this, SLOT(moduleInserted(QModelIndex,int,int)));
+ connect(sourceModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)),
+ this, SLOT(moduleRemoved(QModelIndex, int, int)));
+ connect(sourceModel, SIGNAL(rowsInserted(QModelIndex, int, int)),
+ this, SLOT(moduleInserted(QModelIndex, int, int)));
connect(sourceModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
this, SLOT(moduleDataChanged(QModelIndex, QModelIndex)));
@@ -202,7 +205,8 @@ void BtBookshelfTreeModel::setSourceModel(QAbstractListModel *sourceModel) {
Q_FOREACH(CSwordModuleInfo *module, m->modules()) {
addModule(module, m_defaultChecked);
}
- } else {
+ }
+ else {
for (int i(0); i < sourceModel->rowCount(); i++) {
CSwordModuleInfo *module(
static_cast<CSwordModuleInfo *>(
@@ -239,7 +243,8 @@ void BtBookshelfTreeModel::setGroupingOrder(const Grouping &groupingOrder) {
Q_FOREACH(CSwordModuleInfo *module, m->modules()) {
addModule(module, checked.contains(module));
}
- } else {
+ }
+ else {
for (int i(0); i < m_sourceModel->rowCount(); i++) {
CSwordModuleInfo *module(
static_cast<CSwordModuleInfo *>(
@@ -273,7 +278,8 @@ void BtBookshelfTreeModel::setCheckable(bool checkable) {
queue.append(childIndex);
}
}
- } while (!queue.isEmpty());
+ }
+ while (!queue.isEmpty());
}
}
@@ -306,8 +312,7 @@ void BtBookshelfTreeModel::addModule(CSwordModuleInfo *module, bool checked) {
void BtBookshelfTreeModel::addModule(CSwordModuleInfo *module,
QModelIndex parentIndex,
Grouping &intermediateGrouping,
- bool checked)
-{
+ bool checked) {
Q_ASSERT(module != 0);
if (!intermediateGrouping.empty()) {
@@ -325,7 +330,8 @@ void BtBookshelfTreeModel::addModule(CSwordModuleInfo *module,
}
intermediateGrouping.pop_front();
addModule(module, newIndex, intermediateGrouping, checked);
- } else {
+ }
+ else {
Item *parentItem(getItem(parentIndex));
ModuleItem *newItem(new ModuleItem(module));
newItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
@@ -376,7 +382,8 @@ Item *BtBookshelfTreeModel::getItem(const QModelIndex &index) const {
Item *item(static_cast<Item*>(index.internalPointer()));
Q_ASSERT(item != 0);
return item;
- } else {
+ }
+ else {
return m_rootItem;
}
}
@@ -395,10 +402,12 @@ void BtBookshelfTreeModel::resetParentCheckStates(QModelIndex parentIndex) {
haveCheckedChildren = true;
haveUncheckedChildren = true;
break;
- } else if (state == Qt::Checked) {
+ }
+ else if (state == Qt::Checked) {
haveCheckedChildren = true;
if (haveUncheckedChildren) break;
- } else if (state == Qt::Unchecked) {
+ }
+ else if (state == Qt::Unchecked) {
haveUncheckedChildren = true;
if (haveCheckedChildren) break;
}
@@ -408,10 +417,12 @@ void BtBookshelfTreeModel::resetParentCheckStates(QModelIndex parentIndex) {
if (haveCheckedChildren) {
if (haveUncheckedChildren) {
newState = Qt::PartiallyChecked;
- } else {
+ }
+ else {
newState = Qt::Checked;
}
- } else {
+ }
+ else {
newState = Qt::Unchecked;
}
if (newState == oldState) break;
@@ -422,8 +433,7 @@ void BtBookshelfTreeModel::resetParentCheckStates(QModelIndex parentIndex) {
}
void BtBookshelfTreeModel::moduleDataChanged(const QModelIndex &topLeft,
- const QModelIndex &bottomRight)
-{
+ const QModelIndex &bottomRight) {
typedef BtBookshelfModel BM;
static const BM::ModuleRole PR(BM::ModulePointerRole);
@@ -444,8 +454,7 @@ void BtBookshelfTreeModel::moduleDataChanged(const QModelIndex &topLeft,
}
void BtBookshelfTreeModel::moduleInserted(const QModelIndex &parent, int start,
- int end)
-{
+ int end) {
typedef BtBookshelfModel BM;
static const BM::ModuleRole PR(BM::ModulePointerRole);
@@ -459,8 +468,7 @@ void BtBookshelfTreeModel::moduleInserted(const QModelIndex &parent, int start,
}
void BtBookshelfTreeModel::moduleRemoved(const QModelIndex &parent, int start,
- int end)
-{
+ int end) {
typedef BtBookshelfModel BM;
static const BM::ModuleRole PR(BM::ModulePointerRole);
@@ -472,3 +480,22 @@ void BtBookshelfTreeModel::moduleRemoved(const QModelIndex &parent, int start,
removeModule(module);
}
}
+
+QDataStream &operator<<(QDataStream &os, const BtBookshelfTreeModel::Grouping &o) {
+ os << o.size();
+ Q_FOREACH(BtBookshelfTreeModel::Group g, o) {
+ os << (int) g;
+ }
+ return os;
+}
+
+QDataStream &operator>>(QDataStream &is, BtBookshelfTreeModel::Grouping &o) {
+ int s;
+ is >> s;
+ for (int i(0); i < s; i++) {
+ int g;
+ is >> g;
+ o.append((BtBookshelfTreeModel::Group) g);
+ }
+ return is;
+}
diff --git a/src/backend/bookshelfmodel/btbookshelftreemodel.h b/src/backend/bookshelfmodel/btbookshelftreemodel.h
index 0a84ac3..84293e1 100644
--- a/src/backend/bookshelfmodel/btbookshelftreemodel.h
+++ b/src/backend/bookshelfmodel/btbookshelftreemodel.h
@@ -20,34 +20,37 @@
#include "backend/bookshelfmodel/item.h"
namespace BookshelfModel {
- class ModuleItem;
+class ModuleItem;
}
class CSwordModuleInfo;
+class QDataStream;
class BtBookshelfTreeModel: public QAbstractItemModel {
- Q_OBJECT
+ Q_OBJECT
+ Q_ENUMS(Group)
- typedef QMap<CSwordModuleInfo*, BookshelfModel::ModuleItem*> ModuleItemMap;
+ typedef QMap<CSwordModuleInfo*, BookshelfModel::ModuleItem*> ModuleItemMap;
public:
enum ModuleRole {
CheckStateRole = BtBookshelfModel::UserRole,
UserRole = BtBookshelfModel::UserRole + 100
};
- enum Group { GROUP_CATEGORY, GROUP_LANGUAGE, GROUP_DISTRIBUTION };
+ enum Group { GROUP_CATEGORY = 0, GROUP_LANGUAGE, GROUP_DISTRIBUTION };
typedef QList<Group> Grouping;
BtBookshelfTreeModel(QObject *parent = 0);
+ BtBookshelfTreeModel(const Grouping &grouping, QObject *parent = 0);
virtual ~BtBookshelfTreeModel();
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex())
- const;
+ const;
virtual bool hasChildren(const QModelIndex &parent = QModelIndex())
- const;
+ const;
virtual QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex())
- const;
+ const;
virtual QModelIndex parent(const QModelIndex &index) const;
virtual QVariant data(const QModelIndex &index, int role) const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
@@ -57,15 +60,23 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
int role);
void setSourceModel(QAbstractListModel *sourceModel);
- inline QAbstractListModel *sourceModel() const { return m_sourceModel; }
+ inline QAbstractListModel *sourceModel() const {
+ return m_sourceModel;
+ }
void setGroupingOrder(const Grouping &groupingOrder);
- inline Grouping groupingOrder() const { return m_groupingOrder; }
+ inline Grouping groupingOrder() const {
+ return m_groupingOrder;
+ }
void setCheckable(bool checkable);
- inline bool checkable() const { return m_checkable; }
+ inline bool checkable() const {
+ return m_checkable;
+ }
inline void setDefaultChecked(bool defaultChecked) {
m_defaultChecked = defaultChecked;
}
- inline bool defaultChecked() const { return m_defaultChecked; }
+ inline bool defaultChecked() const {
+ return m_defaultChecked;
+ }
QList<CSwordModuleInfo*> checkedModules() const;
@@ -80,8 +91,7 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
template <class T>
QModelIndex getGroup(CSwordModuleInfo *module,
- QModelIndex parentIndex)
- {
+ QModelIndex parentIndex) {
BookshelfModel::Item *parentItem(getItem(parentIndex));
int groupIndex;
T *groupItem(parentItem->getGroupItem<T>(module, &groupIndex));
@@ -111,4 +121,9 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
bool m_defaultChecked;
};
+QDataStream &operator<<(QDataStream &os, const BtBookshelfTreeModel::Grouping &o);
+QDataStream &operator>>(QDataStream &is, BtBookshelfTreeModel::Grouping &o);
+
+Q_DECLARE_METATYPE(BtBookshelfTreeModel::Grouping);
+
#endif // BTBOOKSHELFTREEMODEL_H
diff --git a/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.cpp b/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.cpp
index 4d9cfd6..184bd39 100644
--- a/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.cpp
+++ b/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.cpp
@@ -13,9 +13,8 @@
#include "backend/bookshelfmodel/btcheckstatefilterproxymodel.h"
BtCheckStateFilterProxyModel::BtCheckStateFilterProxyModel(QObject *parent)
- : QSortFilterProxyModel(parent), m_enabled(true), m_showChecked(true),
- m_showUnchecked(false), m_showPartiallyChecked(true)
-{
+ : QSortFilterProxyModel(parent), m_enabled(true), m_showChecked(true),
+ m_showUnchecked(false), m_showPartiallyChecked(true) {
setFilterRole(Qt::CheckStateRole);
}
@@ -48,8 +47,7 @@ void BtCheckStateFilterProxyModel::setShowPartiallyChecked(bool show) {
}
bool BtCheckStateFilterProxyModel::filterAcceptsRow(int row,
- const QModelIndex &parent) const
-{
+ const QModelIndex &parent) const {
typedef Qt::CheckState CS;
if (!m_enabled) return true;
@@ -62,9 +60,11 @@ bool BtCheckStateFilterProxyModel::filterAcceptsRow(int row,
state == Qt::PartiallyChecked);
if (state == Qt::Unchecked) {
return m_showUnchecked;
- } else if (state == Qt::Checked) {
+ }
+ else if (state == Qt::Checked) {
return m_showChecked;
- } else {
+ }
+ else {
return m_showPartiallyChecked;
}
}
diff --git a/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.h b/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.h
index b2081f1..78d324d 100644
--- a/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.h
+++ b/src/backend/bookshelfmodel/btcheckstatefilterproxymodel.h
@@ -16,18 +16,24 @@
#include <QSortFilterProxyModel>
class BtCheckStateFilterProxyModel: public QSortFilterProxyModel {
- Q_OBJECT
+ Q_OBJECT
public:
BtCheckStateFilterProxyModel(QObject *parent = 0);
virtual ~BtCheckStateFilterProxyModel();
- inline bool enabled() const { return m_enabled; }
+ inline bool enabled() const {
+ return m_enabled;
+ }
void setEnabled(bool enable);
- inline bool showChecked() const { return m_showChecked; }
+ inline bool showChecked() const {
+ return m_showChecked;
+ }
void setShowChecked(bool show);
- inline bool showUnchecked() const { return m_showUnchecked; }
+ inline bool showUnchecked() const {
+ return m_showUnchecked;
+ }
void setShowUnchecked(bool show);
inline bool showPartiallyChecked() const {
diff --git a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp
index f416175..31b93e1 100644
--- a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp
+++ b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp
@@ -13,8 +13,7 @@
#include "backend/bookshelfmodel/btmodulenamefilterproxymodel.h"
BtModuleNameFilterProxyModel::BtModuleNameFilterProxyModel(QObject *parent)
- : QSortFilterProxyModel(parent), m_enabled(true)
-{
+ : QSortFilterProxyModel(parent), m_enabled(true) {
setFilterCaseSensitivity(Qt::CaseInsensitive);
}
@@ -23,8 +22,7 @@ BtModuleNameFilterProxyModel::~BtModuleNameFilterProxyModel() {
}
bool BtModuleNameFilterProxyModel::filterAcceptsRow(int row,
- const QModelIndex &p) const
-{
+ const QModelIndex &p) const {
if (!m_enabled) return true;
const QAbstractItemModel *m(sourceModel());
@@ -34,7 +32,8 @@ bool BtModuleNameFilterProxyModel::filterAcceptsRow(int row,
int numChildren(m->rowCount(itemIndex));
if (numChildren == 0) {
return QSortFilterProxyModel::filterAcceptsRow(row, p);
- } else {
+ }
+ else {
for (int i(0); i < numChildren; i++) {
if (filterAcceptsRow(i, itemIndex)) return true;
}
diff --git a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h
index dd6f652..e4499be 100644
--- a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h
+++ b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h
@@ -16,12 +16,14 @@
#include <QSortFilterProxyModel>
class BtModuleNameFilterProxyModel: public QSortFilterProxyModel {
- Q_OBJECT
+ Q_OBJECT
public:
BtModuleNameFilterProxyModel(QObject *parent = 0);
virtual ~BtModuleNameFilterProxyModel();
- inline bool enabled() const { return m_enabled; }
+ inline bool enabled() const {
+ return m_enabled;
+ }
void setEnabled(bool enable);
virtual bool filterAcceptsRow(int row, const QModelIndex &parent) const;
diff --git a/src/backend/bookshelfmodel/categoryitem.cpp b/src/backend/bookshelfmodel/categoryitem.cpp
index 0d4b853..3ce6e88 100644
--- a/src/backend/bookshelfmodel/categoryitem.cpp
+++ b/src/backend/bookshelfmodel/categoryitem.cpp
@@ -15,9 +15,15 @@
namespace BookshelfModel {
CategoryItem::CategoryItem(CSwordModuleInfo *module)
- : Item(ITEM_CATEGORY), m_category(module->category())
-{
+ : Item(ITEM_CATEGORY), m_category(module->category()) {
// Intentionally empty
}
+bool CategoryItem::operator<(const Item &other) const {
+ if (other.type() != ITEM_CATEGORY) {
+ return ITEM_CATEGORY < other.type();
+ }
+ return m_category < static_cast<const CategoryItem &>(other).m_category;
+}
+
} // namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/categoryitem.h b/src/backend/bookshelfmodel/categoryitem.h
index 3cf7996..40820a2 100644
--- a/src/backend/bookshelfmodel/categoryitem.h
+++ b/src/backend/bookshelfmodel/categoryitem.h
@@ -22,7 +22,7 @@
namespace BookshelfModel {
class CategoryItem: public Item {
- Q_DECLARE_TR_FUNCTIONS(CategoryItem);
+ Q_DECLARE_TR_FUNCTIONS(CategoryItem);
public:
static const Item::Type GROUP_TYPE = Item::ITEM_CATEGORY;
@@ -45,6 +45,8 @@ class CategoryItem: public Item {
return module->category() == m_category;
}
+ bool operator<(const Item &other) const;
+
protected:
CSwordModuleInfo::Category m_category;
};
diff --git a/src/backend/bookshelfmodel/distributionitem.cpp b/src/backend/bookshelfmodel/distributionitem.cpp
index 411e236..4ae81c5 100644
--- a/src/backend/bookshelfmodel/distributionitem.cpp
+++ b/src/backend/bookshelfmodel/distributionitem.cpp
@@ -15,8 +15,7 @@
namespace BookshelfModel {
DistributionItem::DistributionItem(CSwordModuleInfo *module)
- : Item(ITEM_DISTRIBUTION)
-{
+ : Item(ITEM_DISTRIBUTION) {
m_distribution = module->config(CSwordModuleInfo::DistributionSource);
}
diff --git a/src/backend/bookshelfmodel/distributionitem.h b/src/backend/bookshelfmodel/distributionitem.h
index ac3912d..44ae591 100644
--- a/src/backend/bookshelfmodel/distributionitem.h
+++ b/src/backend/bookshelfmodel/distributionitem.h
@@ -25,13 +25,17 @@ class DistributionItem: public Item {
DistributionItem(CSwordModuleInfo *module);
- inline QString distribution() const { return m_distribution; }
+ inline QString distribution() const {
+ return m_distribution;
+ }
- inline QString name() const { return m_distribution; }
+ inline QString name() const {
+ return m_distribution;
+ }
inline bool fitFor(CSwordModuleInfo *module) {
return module->config(CSwordModuleInfo::DistributionSource)
- == m_distribution;
+ == m_distribution;
}
protected:
diff --git a/src/backend/bookshelfmodel/item.cpp b/src/backend/bookshelfmodel/item.cpp
index 22bed91..8556274 100644
--- a/src/backend/bookshelfmodel/item.cpp
+++ b/src/backend/bookshelfmodel/item.cpp
@@ -19,8 +19,7 @@
namespace BookshelfModel {
Item::Item(Type type)
- : m_type(type), m_parent(0), m_checkState(Qt::Unchecked)
-{
+ : m_type(type), m_parent(0), m_checkState(Qt::Unchecked) {
// Intentionally empty
}
diff --git a/src/backend/bookshelfmodel/item.h b/src/backend/bookshelfmodel/item.h
index cb2e6d9..b24b503 100644
--- a/src/backend/bookshelfmodel/item.h
+++ b/src/backend/bookshelfmodel/item.h
@@ -38,18 +38,24 @@ class Item {
/**
\brief Returns the type of this item.
*/
- inline Type type() const { return m_type; }
+ inline Type type() const {
+ return m_type;
+ }
/**
\brief Returns a pointer to the parent item of this item.
\retval 0 if this item has no parent.
*/
- inline Item *parent() const { return m_parent; }
+ inline Item *parent() const {
+ return m_parent;
+ }
/**
\brief Returns the list of child items of this node.
*/
- inline const QList<Item*> &children() const { return m_children; }
+ inline const QList<Item*> &children() const {
+ return m_children;
+ }
/**
\brief Returns a pointer to the child item at the given index.
@@ -111,17 +117,23 @@ class Item {
/**
\brief Returns the visible name of the item.
*/
- inline virtual QString name() const { return QString::null; }
+ inline virtual QString name() const {
+ return QString::null;
+ }
/**
\brief Returns the visible icon of the item.
*/
- inline virtual QIcon icon() const { return QIcon(); }
+ inline virtual QIcon icon() const {
+ return QIcon();
+ }
/**
\brief Returns the check state of this item.
*/
- inline const Qt::CheckState checkState() const { return m_checkState; }
+ inline const Qt::CheckState checkState() const {
+ return m_checkState;
+ }
/**
\brief Sets the check state of this item.
@@ -145,7 +157,7 @@ class Item {
/**
\brief Comparsion operator used sorting child items.
*/
- bool operator<(const Item &other) const;
+ virtual bool operator<(const Item &other) const;
protected:
inline void setParent(Item *parent) {
diff --git a/src/backend/bookshelfmodel/languageitem.cpp b/src/backend/bookshelfmodel/languageitem.cpp
index 6c2af30..6758178 100644
--- a/src/backend/bookshelfmodel/languageitem.cpp
+++ b/src/backend/bookshelfmodel/languageitem.cpp
@@ -15,8 +15,7 @@
namespace BookshelfModel {
LanguageItem::LanguageItem(CSwordModuleInfo *module)
- : Item(ITEM_LANGUAGE), m_language(module->language())
-{
+ : Item(ITEM_LANGUAGE), m_language(module->language()) {
// Intentionally empty
}
diff --git a/src/backend/bookshelfmodel/languageitem.h b/src/backend/bookshelfmodel/languageitem.h
index 3b329f1..262ca65 100644
--- a/src/backend/bookshelfmodel/languageitem.h
+++ b/src/backend/bookshelfmodel/languageitem.h
@@ -27,7 +27,9 @@ class LanguageItem: public Item {
LanguageItem(CSwordModuleInfo *module);
- inline const CLanguageMgr::Language *language() const { return m_language; }
+ inline const CLanguageMgr::Language *language() const {
+ return m_language;
+ }
inline QString name() const {
return BtBookshelfModel::languageName(m_language);
diff --git a/src/backend/bookshelfmodel/moduleitem.cpp b/src/backend/bookshelfmodel/moduleitem.cpp
index 6a543bc..8d02111 100644
--- a/src/backend/bookshelfmodel/moduleitem.cpp
+++ b/src/backend/bookshelfmodel/moduleitem.cpp
@@ -17,8 +17,7 @@
namespace BookshelfModel {
ModuleItem::ModuleItem(CSwordModuleInfo *module)
- : Item(ITEM_MODULE), m_moduleInfo(module)
-{
+ : Item(ITEM_MODULE), m_moduleInfo(module) {
Q_ASSERT(module != 0);
}
diff --git a/src/backend/bookshelfmodel/moduleitem.h b/src/backend/bookshelfmodel/moduleitem.h
index 7bafc1f..40ecc79 100644
--- a/src/backend/bookshelfmodel/moduleitem.h
+++ b/src/backend/bookshelfmodel/moduleitem.h
@@ -24,12 +24,16 @@ class ModuleItem: public Item {
public:
ModuleItem(CSwordModuleInfo *module);
- CSwordModuleInfo *moduleInfo() const { return m_moduleInfo; }
+ CSwordModuleInfo *moduleInfo() const {
+ return m_moduleInfo;
+ }
- inline QString name() const { return m_moduleInfo->name(); }
+ inline QString name() const {
+ return m_moduleInfo->name();
+ }
inline QIcon icon() const {
- return BtBookshelfModel::categoryIcon(m_moduleInfo->category());
+ return BtBookshelfModel::moduleIcon(m_moduleInfo);
}
protected:
diff --git a/src/backend/btmoduletreeitem.cpp b/src/backend/btmoduletreeitem.cpp
index 275c841..d11ecbd 100644
--- a/src/backend/btmoduletreeitem.cpp
+++ b/src/backend/btmoduletreeitem.cpp
@@ -24,19 +24,19 @@
//This ctor creates the root item and the tree.
BTModuleTreeItem::BTModuleTreeItem(QList<BTModuleTreeItem::Filter*>& filters, BTModuleTreeItem::Grouping grouping, QList<CSwordModuleInfo*>* modules)
- : m_moduleInfo(0),
- m_firstChild(0),
- m_next(0),
- m_type(BTModuleTreeItem::Root),
- m_category(CSwordModuleInfo::UnknownCategory)
-{
- if (modules) {
- m_originalModuleList = *modules;
- } else {
- m_originalModuleList = CPointers::backend()->moduleList();
- }
- //populate the tree with groups/modules
- create_tree(filters, grouping);
+ : m_moduleInfo(0),
+ m_firstChild(0),
+ m_next(0),
+ m_type(BTModuleTreeItem::Root),
+ m_category(CSwordModuleInfo::UnknownCategory) {
+ if (modules) {
+ m_originalModuleList = *modules;
+ }
+ else {
+ m_originalModuleList = CPointers::backend()->moduleList();
+ }
+ //populate the tree with groups/modules
+ create_tree(filters, grouping);
}
/**
@@ -44,229 +44,222 @@ BTModuleTreeItem::BTModuleTreeItem(QList<BTModuleTreeItem::Filter*>& filters, BT
* parent, the previous firstChild will be the next sibling of this.
*/
BTModuleTreeItem::BTModuleTreeItem(BTModuleTreeItem* parentItem, const QString& text, BTModuleTreeItem::Type type, CSwordModuleInfo* info, CSwordModuleInfo::Category category)
- : m_moduleInfo(info),
- m_text(text),
- m_firstChild(0),
- m_next(0),
- m_type(type),
- m_category(category)
-{
- if (info) {
- m_text = info->name();
- m_type = BTModuleTreeItem::Module;
- }
- BTModuleTreeItem* tmp = parentItem->m_firstChild;
- parentItem->m_firstChild = this;
- if (tmp) this->m_next = tmp;
+ : m_moduleInfo(info),
+ m_text(text),
+ m_firstChild(0),
+ m_next(0),
+ m_type(type),
+ m_category(category) {
+ if (info) {
+ m_text = info->name();
+ m_type = BTModuleTreeItem::Module;
+ }
+ BTModuleTreeItem* tmp = parentItem->m_firstChild;
+ parentItem->m_firstChild = this;
+ if (tmp) this->m_next = tmp;
}
-BTModuleTreeItem::~BTModuleTreeItem()
-{
- // this works recursively
- foreach(BTModuleTreeItem* i, children()) {
- delete i;
- }
+BTModuleTreeItem::~BTModuleTreeItem() {
+ // this works recursively
+ foreach(BTModuleTreeItem* i, children()) {
+ delete i;
+ }
}
-QList<BTModuleTreeItem*> BTModuleTreeItem::children() const
-{
- //qDebug("BTModuleTreeItem::children");
- QList<BTModuleTreeItem*> childList;
+QList<BTModuleTreeItem*> BTModuleTreeItem::children() const {
+ //qDebug("BTModuleTreeItem::children");
+ QList<BTModuleTreeItem*> childList;
if (m_firstChild) {
- BTModuleTreeItem* child = m_firstChild;
- while (child) {
- //qDebug() << "child:" << child->text();
- childList.append(child);
- child = child->m_next;
- }
- }
- return childList;
+ BTModuleTreeItem* child = m_firstChild;
+ while (child) {
+ //qDebug() << "child:" << child->text();
+ childList.append(child);
+ child = child->m_next;
+ }
+ }
+ return childList;
}
//TODO
-QString BTModuleTreeItem::iconName() const
-{
- if (m_type == Category) {
- switch ( m_category) {
- case CSwordModuleInfo::Bibles:
- return CResMgr::categories::bibles::icon;
- break;
- case CSwordModuleInfo::Commentaries:
- return CResMgr::categories::commentaries::icon;
- break;
- case CSwordModuleInfo::Books:
- return CResMgr::categories::books::icon;
- break;
- case CSwordModuleInfo::Cult:
- return CResMgr::categories::cults::icon;
- break;
- case CSwordModuleInfo::Images:
- return CResMgr::categories::images::icon;
- break;
- case CSwordModuleInfo::DailyDevotional:
- return CResMgr::categories::dailydevotional::icon;
- break;
- case CSwordModuleInfo::Lexicons:
- return CResMgr::categories::lexicons::icon;
- break;
- case CSwordModuleInfo::Glossary:
- return CResMgr::categories::glossary::icon;
- break;
- default: break;
- }
- }
- else if (m_type == Module) {
- return CToolClass::getIconNameForModule(m_moduleInfo);
- }
- else if (m_type == Language) {
- //TODO: don't hardcode here
- return "flag.svg";
- }
-
- return QString::null;
+QString BTModuleTreeItem::iconName() const {
+ if (m_type == Category) {
+ switch ( m_category) {
+ case CSwordModuleInfo::Bibles:
+ return CResMgr::categories::bibles::icon;
+ break;
+ case CSwordModuleInfo::Commentaries:
+ return CResMgr::categories::commentaries::icon;
+ break;
+ case CSwordModuleInfo::Books:
+ return CResMgr::categories::books::icon;
+ break;
+ case CSwordModuleInfo::Cult:
+ return CResMgr::categories::cults::icon;
+ break;
+ case CSwordModuleInfo::Images:
+ return CResMgr::categories::images::icon;
+ break;
+ case CSwordModuleInfo::DailyDevotional:
+ return CResMgr::categories::dailydevotional::icon;
+ break;
+ case CSwordModuleInfo::Lexicons:
+ return CResMgr::categories::lexicons::icon;
+ break;
+ case CSwordModuleInfo::Glossary:
+ return CResMgr::categories::glossary::icon;
+ break;
+ default:
+ break;
+ }
+ }
+ else if (m_type == Module) {
+ return CToolClass::getIconNameForModule(m_moduleInfo);
+ }
+ else if (m_type == Language) {
+ //TODO: don't hardcode here
+ return "flag.svg";
+ }
+
+ return QString::null;
}
-void BTModuleTreeItem::create_tree(QList<BTModuleTreeItem::Filter*>& filters, BTModuleTreeItem::Grouping grouping)
-{
- qDebug("BTModuleTreeItem::create_tree");
- static bool map_initialized = false;
- static QMap<CSwordModuleInfo::Category, QString> CategoryNamesMap;
- if (!map_initialized) {
- CategoryNamesMap.insert(CSwordModuleInfo::Commentaries, QObject::tr("Commentaries"));
- CategoryNamesMap.insert(CSwordModuleInfo::Cult, QObject::tr("Cults/Unorthodox"));
- CategoryNamesMap.insert(CSwordModuleInfo::Images, QObject::tr("Maps and Images"));
- CategoryNamesMap.insert(CSwordModuleInfo::DailyDevotional, QObject::tr("Daily Devotionals"));
- CategoryNamesMap.insert(CSwordModuleInfo::Lexicons, QObject::tr("Lexicons and Dictionaries"));
- CategoryNamesMap.insert(CSwordModuleInfo::Bibles, QObject::tr("Bibles"));
- CategoryNamesMap.insert(CSwordModuleInfo::Glossary, QObject::tr("Glossaries"));
- CategoryNamesMap.insert(CSwordModuleInfo::Books, QObject::tr("Books"));
-
- map_initialized = true;
- }
-
- //QList<CSwordModuleInfo*> originalInfoList = CPointers::backend()->moduleList();
-
- foreach (CSwordModuleInfo* info, m_originalModuleList) {
- bool included;
- included = true;
- foreach (BTModuleTreeItem::Filter* f, filters) {
- if (!f->filter(info)) {
- included = false;
- break;
- }
- }
- if (included) {
- //qDebug() << "a module will be included: " << info->name();
-
- BTModuleTreeItem* parentGroupForModule = this;
- BTModuleTreeItem* parentGroupForLanguage = this;
- BTModuleTreeItem* parentGroupForCategory = this;
-
- //the order of if(grouping...) clauses is important
- if (grouping == BTModuleTreeItem::LangMod || grouping == BTModuleTreeItem::LangCatMod) {
- BTModuleTreeItem* langItem = create_parent_item(parentGroupForLanguage, info->language()->translatedName(), BTModuleTreeItem::Language);
-
- if (grouping == BTModuleTreeItem::LangMod)
- parentGroupForModule = langItem;
- else
- parentGroupForCategory = langItem;
- }
-
- if (grouping == BTModuleTreeItem::CatMod || grouping == BTModuleTreeItem::CatLangMod) {
- BTModuleTreeItem* catItem = create_parent_item(parentGroupForCategory, CategoryNamesMap.value(info->category()), BTModuleTreeItem::Category, info->category());
-
- if (grouping == BTModuleTreeItem::CatMod)
- parentGroupForModule = catItem;
- else
- parentGroupForLanguage = catItem;
- }
-
- if (grouping == BTModuleTreeItem::CatLangMod) {
- // category is there already, create language and make it the parent for the module
- parentGroupForModule = create_parent_item(parentGroupForLanguage, info->language()->translatedName(), BTModuleTreeItem::Language);
- }
-
- if (grouping == BTModuleTreeItem::LangCatMod) {
- //language is there already, create category and make it the parent for the module
- parentGroupForModule = create_parent_item(parentGroupForCategory, CategoryNamesMap.value(info->category()), BTModuleTreeItem::Category, info->category());
- }
-
- // the parent group for module has been set above, now just add the module to it
- new BTModuleTreeItem(parentGroupForModule, QString::null, BTModuleTreeItem::Module, info);
-
- } // end: if (included)
- }
-
- // Finally sort the items
- sort_children(this);
+void BTModuleTreeItem::create_tree(QList<BTModuleTreeItem::Filter*>& filters, BTModuleTreeItem::Grouping grouping) {
+ qDebug("BTModuleTreeItem::create_tree");
+ static bool map_initialized = false;
+ static QMap<CSwordModuleInfo::Category, QString> CategoryNamesMap;
+ if (!map_initialized) {
+ CategoryNamesMap.insert(CSwordModuleInfo::Commentaries, QObject::tr("Commentaries"));
+ CategoryNamesMap.insert(CSwordModuleInfo::Cult, QObject::tr("Cults/Unorthodox"));
+ CategoryNamesMap.insert(CSwordModuleInfo::Images, QObject::tr("Maps and Images"));
+ CategoryNamesMap.insert(CSwordModuleInfo::DailyDevotional, QObject::tr("Daily Devotionals"));
+ CategoryNamesMap.insert(CSwordModuleInfo::Lexicons, QObject::tr("Lexicons and Dictionaries"));
+ CategoryNamesMap.insert(CSwordModuleInfo::Bibles, QObject::tr("Bibles"));
+ CategoryNamesMap.insert(CSwordModuleInfo::Glossary, QObject::tr("Glossaries"));
+ CategoryNamesMap.insert(CSwordModuleInfo::Books, QObject::tr("Books"));
+
+ map_initialized = true;
+ }
+
+ //QList<CSwordModuleInfo*> originalInfoList = CPointers::backend()->moduleList();
+
+ foreach (CSwordModuleInfo* info, m_originalModuleList) {
+ bool included;
+ included = true;
+ foreach (BTModuleTreeItem::Filter* f, filters) {
+ if (!f->filter(info)) {
+ included = false;
+ break;
+ }
+ }
+ if (included) {
+ //qDebug() << "a module will be included: " << info->name();
+
+ BTModuleTreeItem* parentGroupForModule = this;
+ BTModuleTreeItem* parentGroupForLanguage = this;
+ BTModuleTreeItem* parentGroupForCategory = this;
+
+ //the order of if(grouping...) clauses is important
+ if (grouping == BTModuleTreeItem::LangMod || grouping == BTModuleTreeItem::LangCatMod) {
+ BTModuleTreeItem* langItem = create_parent_item(parentGroupForLanguage, info->language()->translatedName(), BTModuleTreeItem::Language);
+
+ if (grouping == BTModuleTreeItem::LangMod)
+ parentGroupForModule = langItem;
+ else
+ parentGroupForCategory = langItem;
+ }
+
+ if (grouping == BTModuleTreeItem::CatMod || grouping == BTModuleTreeItem::CatLangMod) {
+ BTModuleTreeItem* catItem = create_parent_item(parentGroupForCategory, CategoryNamesMap.value(info->category()), BTModuleTreeItem::Category, info->category());
+
+ if (grouping == BTModuleTreeItem::CatMod)
+ parentGroupForModule = catItem;
+ else
+ parentGroupForLanguage = catItem;
+ }
+
+ if (grouping == BTModuleTreeItem::CatLangMod) {
+ // category is there already, create language and make it the parent for the module
+ parentGroupForModule = create_parent_item(parentGroupForLanguage, info->language()->translatedName(), BTModuleTreeItem::Language);
+ }
+
+ if (grouping == BTModuleTreeItem::LangCatMod) {
+ //language is there already, create category and make it the parent for the module
+ parentGroupForModule = create_parent_item(parentGroupForCategory, CategoryNamesMap.value(info->category()), BTModuleTreeItem::Category, info->category());
+ }
+
+ // the parent group for module has been set above, now just add the module to it
+ new BTModuleTreeItem(parentGroupForModule, QString::null, BTModuleTreeItem::Module, info);
+
+ } // end: if (included)
+ }
+
+ // Finally sort the items
+ sort_children(this);
}
BTModuleTreeItem* BTModuleTreeItem::create_parent_item(
- BTModuleTreeItem* parentGroup,
- const QString& itemText,
- BTModuleTreeItem::Type type,
- CSwordModuleInfo::Category category)
-{
- BTModuleTreeItem* item = 0;
- foreach(BTModuleTreeItem* it, parentGroup->children()) {
- if (it->text() == itemText) {
- item = it;
- break;
- }
- }
- if (!item)
- item = new BTModuleTreeItem(parentGroup, itemText, type, 0, category);
-
- return item;
+ BTModuleTreeItem* parentGroup,
+ const QString& itemText,
+ BTModuleTreeItem::Type type,
+ CSwordModuleInfo::Category category) {
+ BTModuleTreeItem* item = 0;
+ foreach(BTModuleTreeItem* it, parentGroup->children()) {
+ if (it->text() == itemText) {
+ item = it;
+ break;
+ }
+ }
+ if (!item)
+ item = new BTModuleTreeItem(parentGroup, itemText, type, 0, category);
+
+ return item;
}
-void BTModuleTreeItem::sort_children(BTModuleTreeItem* parent)
-{
- //qDebug("BTModuleTreeItem::sort_children");
-
- // sort each child recursively depth-first
- foreach(BTModuleTreeItem* item, parent->children()) {
- sort_children(item);
- }
-
- QList<BTModuleTreeItem*> items = parent->children();
- if (items.size() > 0) {
- // Sort the list of the children according to each item's text
- qSort(items.begin(), items.end(), BTModuleTreeItem::localeAwareLessThan);
- //put the children back to tree in sorted order
- BTModuleTreeItem* first = items.at(0);
- BTModuleTreeItem* prev = first;
- foreach (BTModuleTreeItem* item2, items) {
- prev->m_next = item2;
- prev = item2;
- }
- prev->m_next = 0;
- parent->m_firstChild = first; // attach the partial tree to the parent
- }
+void BTModuleTreeItem::sort_children(BTModuleTreeItem* parent) {
+ //qDebug("BTModuleTreeItem::sort_children");
+
+ // sort each child recursively depth-first
+ foreach(BTModuleTreeItem* item, parent->children()) {
+ sort_children(item);
+ }
+
+ QList<BTModuleTreeItem*> items = parent->children();
+ if (items.size() > 0) {
+ // Sort the list of the children according to each item's text
+ qSort(items.begin(), items.end(), BTModuleTreeItem::localeAwareLessThan);
+ //put the children back to tree in sorted order
+ BTModuleTreeItem* first = items.at(0);
+ BTModuleTreeItem* prev = first;
+ foreach (BTModuleTreeItem* item2, items) {
+ prev->m_next = item2;
+ prev = item2;
+ }
+ prev->m_next = 0;
+ parent->m_firstChild = first; // attach the partial tree to the parent
+ }
}
-bool BTModuleTreeItem::localeAwareLessThan(BTModuleTreeItem* first, BTModuleTreeItem* second)
-{
- static bool map_initialized = false;
- static QMap<QString, int> CategoryNameValueMap;
- if (!map_initialized) {
- //this is the sorting order for categories
- CategoryNameValueMap.insert(QObject::tr("Bibles"), 1);
- CategoryNameValueMap.insert(QObject::tr("Commentaries"), 2);
- CategoryNameValueMap.insert(QObject::tr("Books"), 3);
- CategoryNameValueMap.insert(QObject::tr("Lexicons and Dictionaries"), 4);
- CategoryNameValueMap.insert(QObject::tr("Glossaries"), 5);
- CategoryNameValueMap.insert(QObject::tr("Daily Devotionals"), 6);
- CategoryNameValueMap.insert(QObject::tr("Maps and Images"), 7);
- CategoryNameValueMap.insert(QObject::tr("Cults/Unorthodox"), 8);
- map_initialized = true;
- }
-
- //Categories are always in the same order, not alphabetically
- if (first->type() == BTModuleTreeItem::Category) {
- return (CategoryNameValueMap.value(first->text()) < CategoryNameValueMap.value(second->text()));
- }
- return (QString::localeAwareCompare(first->text(), second->text()) < 0 );
+bool BTModuleTreeItem::localeAwareLessThan(BTModuleTreeItem* first, BTModuleTreeItem* second) {
+ static bool map_initialized = false;
+ static QMap<QString, int> CategoryNameValueMap;
+ if (!map_initialized) {
+ //this is the sorting order for categories
+ CategoryNameValueMap.insert(QObject::tr("Bibles"), 1);
+ CategoryNameValueMap.insert(QObject::tr("Commentaries"), 2);
+ CategoryNameValueMap.insert(QObject::tr("Books"), 3);
+ CategoryNameValueMap.insert(QObject::tr("Lexicons and Dictionaries"), 4);
+ CategoryNameValueMap.insert(QObject::tr("Glossaries"), 5);
+ CategoryNameValueMap.insert(QObject::tr("Daily Devotionals"), 6);
+ CategoryNameValueMap.insert(QObject::tr("Maps and Images"), 7);
+ CategoryNameValueMap.insert(QObject::tr("Cults/Unorthodox"), 8);
+ map_initialized = true;
+ }
+
+ //Categories are always in the same order, not alphabetically
+ if (first->type() == BTModuleTreeItem::Category) {
+ return (CategoryNameValueMap.value(first->text()) < CategoryNameValueMap.value(second->text()));
+ }
+ return (QString::localeAwareCompare(first->text(), second->text()) < 0 );
}
diff --git a/src/backend/btmoduletreeitem.h b/src/backend/btmoduletreeitem.h
index abdfdb7..b159c6f 100644
--- a/src/backend/btmoduletreeitem.h
+++ b/src/backend/btmoduletreeitem.h
@@ -40,127 +40,134 @@ Example:
if (item->type() == BTModuleTreeItem::Category) prepare_category_item(widgetItem, item);
...
}
-
+
@author The BibleTime team <info@bibletime.info>
*/
-class BTModuleTreeItem
-{
-public:
-
- /**
- * A filter which is given to the root constructor. It filters some modules
- * out from the tree. If it returns true when the filter() is called the module will be added,
- * if it returns false the module will be left out.
- *
- * If you want for example to get only unindexed modules in the list you should
- * write a class (possibly a small inner class inside the calling class) which
- * inherits Filter and write the operator() function which returns true if the
- * module is unindexed and false if it's indexed.
- *
- * It's also possible to do arbitrary tasks to modules by using more complex subclasses.
- *
- * The filters will be applied in the order in which they are in the list.
- * A module will be filtered out if even one filter rejects it and testing
- * will stop with the first negative.
- *
- * Example:
- * QList<BTModuleTreeItem::Filter*> filters;
- * MyFilter filter; BTModuleTreeItem::HiddenOff hideFilter;
- * filters.append(&hideFilter); filters.append(&filter);
- * BTModuleTreeItem root(filters, BTModuleTreeItem::CatLangMod);
- */
- struct Filter {
- virtual bool filter(CSwordModuleInfo*) = 0;
- inline virtual ~Filter() {};
- };
-
- /**
- * One example of a filter which can be used with any view. If the module has been
- * set "hidden" it will be filtered out.
- */
- struct HiddenOff : public Filter {
- inline bool filter(CSwordModuleInfo* mi) { return !mi->isHidden(); }
- inline virtual ~HiddenOff() {};
- };
-
- /**
- * Type of the item: root item, category (Bibles, Commentaries etc.), language or module.
- */
- enum Type {Root, Category, Language, Module};
-
- /**
- * Tells how to group the modules. For example:
- * CatLangMod: first category, second language, third module. Mod: don't use
- * Category or Language at all, Module is toplevel and tree is flat.
- */
- enum Grouping {CatLangMod, CatMod, LangCatMod, LangMod, Mod};
-
-
- /**
- * This constructor creates a root item. Create it for example with scoped_ptr or in stack.
- * The root item is populated with the item tree.
- * The constructor takes a list of filters (see Filter), grouping indicator (see Grouping)
- * and optionally the module list from which the tree is constructed
- * (by default CPointers::backend()->moduleList() is used).
- */
- BTModuleTreeItem(QList<BTModuleTreeItem::Filter*>& filters,
- BTModuleTreeItem::Grouping grouping, QList<CSwordModuleInfo*>* modules = 0);
-
- /** When the root item is deleted the whole tree is deleted. */
- ~BTModuleTreeItem();
-
- /**
- * Returns the item type.
- */
- inline BTModuleTreeItem::Type type() const {return m_type;}
- /**
- * Returns the item text (category name, language name or module name).
- */
- inline QString text() const {return m_text;}
- /**
- * Returns the path to the icon which is appropriate for this type of item, or QString::null.
- */
- QString iconName() const;
- /**
- * If the type is Module returns a pointer to the corresponding CSwordModuleInfo object,
- * otherwise returns 0.
- */
- inline CSwordModuleInfo* moduleInfo() const {return m_moduleInfo;}
- /**
- * Returns a list of the direct children of this item.
- */
- QList<BTModuleTreeItem*> children() const;
-
- /**
- * For alphabetical sorting which uses text(). See QString::localeAwareCompare().
- * Categories will always be in the same order regardless of the i18n.
- */
- static bool localeAwareLessThan(BTModuleTreeItem* first, BTModuleTreeItem* second);
-
-
-private:
- /**
- * Private constructor which sets the members.
- */
- BTModuleTreeItem(BTModuleTreeItem* parentItem, const QString& text, Type type, CSwordModuleInfo* info=0, CSwordModuleInfo::Category category=CSwordModuleInfo::UnknownCategory);
- /** Default ctor is private because it is not to be called.*/
- BTModuleTreeItem();
-
- /** Creates the tree under this root item (called only from root ctor). */
- void create_tree(QList<BTModuleTreeItem::Filter*>& filters, BTModuleTreeItem::Grouping grouping);
- /** Sorts recursively the children of of the given item. */
- void sort_children(BTModuleTreeItem* parent);
- /** Helper function for creating a group item while creating the tree. */
- BTModuleTreeItem* create_parent_item(BTModuleTreeItem* parent, const QString& text, BTModuleTreeItem::Type type, CSwordModuleInfo::Category category=CSwordModuleInfo::UnknownCategory);
-
- CSwordModuleInfo* m_moduleInfo;
- QString m_text;
- BTModuleTreeItem* m_firstChild;
- BTModuleTreeItem* m_next;
- Type m_type;
- CSwordModuleInfo::Category m_category;
- QList<CSwordModuleInfo*> m_originalModuleList;
+class BTModuleTreeItem {
+ public:
+
+ /**
+ * A filter which is given to the root constructor. It filters some modules
+ * out from the tree. If it returns true when the filter() is called the module will be added,
+ * if it returns false the module will be left out.
+ *
+ * If you want for example to get only unindexed modules in the list you should
+ * write a class (possibly a small inner class inside the calling class) which
+ * inherits Filter and write the operator() function which returns true if the
+ * module is unindexed and false if it's indexed.
+ *
+ * It's also possible to do arbitrary tasks to modules by using more complex subclasses.
+ *
+ * The filters will be applied in the order in which they are in the list.
+ * A module will be filtered out if even one filter rejects it and testing
+ * will stop with the first negative.
+ *
+ * Example:
+ * QList<BTModuleTreeItem::Filter*> filters;
+ * MyFilter filter; BTModuleTreeItem::HiddenOff hideFilter;
+ * filters.append(&hideFilter); filters.append(&filter);
+ * BTModuleTreeItem root(filters, BTModuleTreeItem::CatLangMod);
+ */
+ struct Filter {
+ virtual bool filter(CSwordModuleInfo*) = 0;
+ inline virtual ~Filter() {};
+ };
+
+ /**
+ * One example of a filter which can be used with any view. If the module has been
+ * set "hidden" it will be filtered out.
+ */
+ struct HiddenOff : public Filter {
+ inline bool filter(CSwordModuleInfo* mi) {
+ return !mi->isHidden();
+ }
+ inline virtual ~HiddenOff() {};
+ };
+
+ /**
+ * Type of the item: root item, category (Bibles, Commentaries etc.), language or module.
+ */
+ enum Type {Root, Category, Language, Module};
+
+ /**
+ * Tells how to group the modules. For example:
+ * CatLangMod: first category, second language, third module. Mod: don't use
+ * Category or Language at all, Module is toplevel and tree is flat.
+ */
+ enum Grouping {CatLangMod, CatMod, LangCatMod, LangMod, Mod};
+
+
+ /**
+ * This constructor creates a root item. Create it for example with scoped_ptr or in stack.
+ * The root item is populated with the item tree.
+ * The constructor takes a list of filters (see Filter), grouping indicator (see Grouping)
+ * and optionally the module list from which the tree is constructed
+ * (by default CPointers::backend()->moduleList() is used).
+ */
+ BTModuleTreeItem(QList<BTModuleTreeItem::Filter*>& filters,
+ BTModuleTreeItem::Grouping grouping, QList<CSwordModuleInfo*>* modules = 0);
+
+ /** When the root item is deleted the whole tree is deleted. */
+ ~BTModuleTreeItem();
+
+ /**
+ * Returns the item type.
+ */
+ inline BTModuleTreeItem::Type type() const {
+ return m_type;
+ }
+ /**
+ * Returns the item text (category name, language name or module name).
+ */
+ inline QString text() const {
+ return m_text;
+ }
+ /**
+ * Returns the path to the icon which is appropriate for this type of item, or QString::null.
+ */
+ QString iconName() const;
+ /**
+ * If the type is Module returns a pointer to the corresponding CSwordModuleInfo object,
+ * otherwise returns 0.
+ */
+ inline CSwordModuleInfo* moduleInfo() const {
+ return m_moduleInfo;
+ }
+ /**
+ * Returns a list of the direct children of this item.
+ */
+ QList<BTModuleTreeItem*> children() const;
+
+ /**
+ * For alphabetical sorting which uses text(). See QString::localeAwareCompare().
+ * Categories will always be in the same order regardless of the i18n.
+ */
+ static bool localeAwareLessThan(BTModuleTreeItem* first, BTModuleTreeItem* second);
+
+
+ private:
+ /**
+ * Private constructor which sets the members.
+ */
+ BTModuleTreeItem(BTModuleTreeItem* parentItem, const QString& text, Type type, CSwordModuleInfo* info = 0, CSwordModuleInfo::Category category = CSwordModuleInfo::UnknownCategory);
+ /** Default ctor is private because it is not to be called.*/
+ BTModuleTreeItem();
+
+ /** Creates the tree under this root item (called only from root ctor). */
+ void create_tree(QList<BTModuleTreeItem::Filter*>& filters, BTModuleTreeItem::Grouping grouping);
+ /** Sorts recursively the children of of the given item. */
+ void sort_children(BTModuleTreeItem* parent);
+ /** Helper function for creating a group item while creating the tree. */
+ BTModuleTreeItem* create_parent_item(BTModuleTreeItem* parent, const QString& text, BTModuleTreeItem::Type type, CSwordModuleInfo::Category category = CSwordModuleInfo::UnknownCategory);
+
+ CSwordModuleInfo* m_moduleInfo;
+ QString m_text;
+ BTModuleTreeItem* m_firstChild;
+ BTModuleTreeItem* m_next;
+ Type m_type;
+ CSwordModuleInfo::Category m_category;
+ QList<CSwordModuleInfo*> m_originalModuleList;
};
#endif
diff --git a/src/backend/config/cbtconfig.cpp b/src/backend/config/cbtconfig.cpp
index 9dff6c1..db62863 100644
--- a/src/backend/config/cbtconfig.cpp
+++ b/src/backend/config/cbtconfig.cpp
@@ -37,10 +37,14 @@ FontCacheMap m_fontCache;
QString getKey(const strings ID) {
switch (ID) {
- case bibletimeVersion: return "bibletimeVersion";
- case language: return "language";
- case displayStyle: return "displayStyle";
- case bookshelfCurrentItem: return "bookshelfCurrentItem";
+ case bibletimeVersion:
+ return "bibletimeVersion";
+ case language:
+ return "language";
+ case displayStyle:
+ return "displayStyle";
+ case bookshelfCurrentItem:
+ return "bookshelfCurrentItem";
}
Q_ASSERT(false);
return QString::null;
@@ -48,14 +52,22 @@ QString getKey(const strings ID) {
QString getKey(const modules ID) {
switch (ID) {
- case standardBible: return "standardBible";
- case standardCommentary: return "standardCommentary";
- case standardLexicon: return "standardLexicon";
- case standardDailyDevotional: return "standardDailyDevotional";
- case standardHebrewStrongsLexicon: return "standardHebrewLexicon";
- case standardGreekStrongsLexicon: return "standardGreekLexicon";
- case standardHebrewMorphLexicon: return "standardHebrewMorphLexicon";
- case standardGreekMorphLexicon: return "standardGreekMorphLexicon";
+ case standardBible:
+ return "standardBible";
+ case standardCommentary:
+ return "standardCommentary";
+ case standardLexicon:
+ return "standardLexicon";
+ case standardDailyDevotional:
+ return "standardDailyDevotional";
+ case standardHebrewStrongsLexicon:
+ return "standardHebrewLexicon";
+ case standardGreekStrongsLexicon:
+ return "standardGreekLexicon";
+ case standardHebrewMorphLexicon:
+ return "standardHebrewMorphLexicon";
+ case standardGreekMorphLexicon:
+ return "standardGreekMorphLexicon";
}
Q_ASSERT(false);
return QString::null;
@@ -63,27 +75,43 @@ QString getKey(const modules ID) {
QString getKey(const bools ID) {
switch (ID) {
- case firstSearchDialog: return "firstSearchDialog";
- case readOldBookmarks: return "readOldBookmarks";
-
- case toolbar: return "toolbar";
- case mainIndex: return "mainIndex";
- case infoDisplay: return "infoDisplay";
-
- case autoTileVertical: return "autoTileVertical";
- case autoTileHorizontal: return "autoTileHorizontal";
- case autoCascade: return "autoCascade";
-
- case lineBreaks: return "lineBreaks";
- case verseNumbers: return "verseNumbers";
-
- case logo: return "logo";
- case autoDeleteOrphanedIndices: return "autoDeleteOrphanedIndices";
- case crashedLastTime: return "crashedLastTime";
- case crashedTwoTimes: return "crashedTwoTimes";
-
- case bookshelfShowHidden: return "bookshelfShowHidden";
- case allowNetworkConnection: return "allowNetworkConnection";
+ case firstSearchDialog:
+ return "firstSearchDialog";
+ case readOldBookmarks:
+ return "readOldBookmarks";
+
+ case toolbar:
+ return "toolbar";
+ case mainIndex:
+ return "mainIndex";
+ case infoDisplay:
+ return "infoDisplay";
+
+ case autoTileVertical:
+ return "autoTileVertical";
+ case autoTileHorizontal:
+ return "autoTileHorizontal";
+ case autoCascade:
+ return "autoCascade";
+
+ case lineBreaks:
+ return "lineBreaks";
+ case verseNumbers:
+ return "verseNumbers";
+
+ case logo:
+ return "logo";
+ case autoDeleteOrphanedIndices:
+ return "autoDeleteOrphanedIndices";
+ case crashedLastTime:
+ return "crashedLastTime";
+ case crashedTwoTimes:
+ return "crashedTwoTimes";
+
+ case bookshelfShowHidden:
+ return "bookshelfShowHidden";
+ case allowNetworkConnection:
+ return "allowNetworkConnection";
}
Q_ASSERT(false);
return false;
@@ -91,36 +119,66 @@ QString getKey(const bools ID) {
QString getKey(const ints ID) {
switch (ID) {
- case footnotes: return "footnotes";
- case strongNumbers: return "strongNumbers";
- case headings: return "headings";
- case morphTags: return "morphTags";
- case lemmas: return "lemmas";
- case hebrewPoints: return "hebrewPoints";
- case hebrewCantillation: return "hebrewCantillation";
- case greekAccents: return "greekAccents";
- case textualVariants: return "textualVariants";
- case scriptureReferences: return "scriptureReferences";
- case morphSegmentation: return "morphSegmentation";
- case bookshelfContentsX: return "bookshelfContentsX";
- case bookshelfContentsY: return "bookshelfContentsY";
- case magDelay: return "magDelay";
- case bookshelfGrouping: return "bookshelfGrouping";
- case mainindexActiveTab: return "mainindexActiveTab";
- case searchDialogWidth: return "searchDialogWidth";
- case searchDialogHeight: return "searchDialogHeight";
- case searchDialogX: return "searchDialogX";
- case searchDialogY: return "searchDialogY";
- case searchType: return "searchType";
- case installPathIndex: return "installPathIndex";
- case bookshelfPosX: return "bookshelfPosX";
- case bookshelfPosY: return "bookshelfPosY";
- case bookshelfHeight: return "bookshelfHeight";
- case bookshelfWidth: return "bookshelfWidth";
- case configDialogPosX: return "configDialogPosX";
- case configDialogPosY: return "configDialogPosY";
- case configDialogHeight: return "configDialogHeight";
- case configDialogWidth: return "configDialogWidth";
+ case footnotes:
+ return "footnotes";
+ case strongNumbers:
+ return "strongNumbers";
+ case headings:
+ return "headings";
+ case morphTags:
+ return "morphTags";
+ case lemmas:
+ return "lemmas";
+ case hebrewPoints:
+ return "hebrewPoints";
+ case hebrewCantillation:
+ return "hebrewCantillation";
+ case greekAccents:
+ return "greekAccents";
+ case textualVariants:
+ return "textualVariants";
+ case scriptureReferences:
+ return "scriptureReferences";
+ case morphSegmentation:
+ return "morphSegmentation";
+ case bookshelfContentsX:
+ return "bookshelfContentsX";
+ case bookshelfContentsY:
+ return "bookshelfContentsY";
+ case magDelay:
+ return "magDelay";
+ case bookshelfGrouping:
+ return "bookshelfGrouping";
+ case mainindexActiveTab:
+ return "mainindexActiveTab";
+ case searchDialogWidth:
+ return "searchDialogWidth";
+ case searchDialogHeight:
+ return "searchDialogHeight";
+ case searchDialogX:
+ return "searchDialogX";
+ case searchDialogY:
+ return "searchDialogY";
+ case searchType:
+ return "searchType";
+ case installPathIndex:
+ return "installPathIndex";
+ case bookshelfPosX:
+ return "bookshelfPosX";
+ case bookshelfPosY:
+ return "bookshelfPosY";
+ case bookshelfHeight:
+ return "bookshelfHeight";
+ case bookshelfWidth:
+ return "bookshelfWidth";
+ case configDialogPosX:
+ return "configDialogPosX";
+ case configDialogPosY:
+ return "configDialogPosY";
+ case configDialogHeight:
+ return "configDialogHeight";
+ case configDialogWidth:
+ return "configDialogWidth";
}
Q_ASSERT(false);
return QString::null;
@@ -128,10 +186,14 @@ QString getKey(const ints ID) {
QString getKey(const intLists ID) {
switch (ID) {
- case leftPaneSplitterSizes: return "leftPaneSplitterSizes";
- case mainSplitterSizes: return "mainSplitterSizes";
- case searchMainSplitterSizes: return "searchMainSplitterSizes";
- case searchResultSplitterSizes: return "searchResultSplitterSizes";
+ case leftPaneSplitterSizes:
+ return "leftPaneSplitterSizes";
+ case mainSplitterSizes:
+ return "mainSplitterSizes";
+ case searchMainSplitterSizes:
+ return "searchMainSplitterSizes";
+ case searchResultSplitterSizes:
+ return "searchResultSplitterSizes";
}
Q_ASSERT(false);
return QString::null;
@@ -139,11 +201,16 @@ QString getKey(const intLists ID) {
QString getKey(const stringLists ID) {
switch (ID) {
- case searchCompletionTexts: return "searchCompletionTexts";
- case searchTexts: return "searchTexts";
- case searchModulesHistory: return "searchModulesHistory";
- case bookshelfOpenGroups: return "bookshelfOpenGroups";
- case hiddenModules: return "hiddenModules";
+ case searchCompletionTexts:
+ return "searchCompletionTexts";
+ case searchTexts:
+ return "searchTexts";
+ case searchModulesHistory:
+ return "searchModulesHistory";
+ case bookshelfOpenGroups:
+ return "bookshelfOpenGroups";
+ case hiddenModules:
+ return "hiddenModules";
}
Q_ASSERT(false);
return QString::null;
@@ -151,7 +218,8 @@ QString getKey(const stringLists ID) {
QString getKey(const stringMaps ID) {
switch (ID) {
- case searchScopes: return "SearchScopes";
+ case searchScopes:
+ return "SearchScopes";
};
Q_ASSERT(false);
return QString::null;
@@ -184,10 +252,14 @@ QList<int> StringToIntList(const QString intListString) {
QString getDefault(const strings ID) {
switch (ID) {
- case bibletimeVersion: return "0.0"; // main() will realize this and set the value to VERSION
- case language: return QLocale::system().name();
- case displayStyle: return CDisplayTemplateMgr::defaultTemplate();
- case bookshelfCurrentItem: return QString();
+ case bibletimeVersion:
+ return "0.0"; // main() will realize this and set the value to VERSION
+ case language:
+ return QLocale::system().name();
+ case displayStyle:
+ return CDisplayTemplateMgr::defaultTemplate();
+ case bookshelfCurrentItem:
+ return QString();
}
return QString::null;
}
@@ -195,15 +267,23 @@ QString getDefault(const strings ID) {
QString getDefault(const modules ID) {
// CSwordBackend *b = CPointers::backend();
switch (ID) {
- case standardBible: return "KJV";
- case standardCommentary: return "MHC";
- case standardLexicon: return "ISBE";
- case standardDailyDevotional: return ""; // No default
-
- case standardHebrewStrongsLexicon: return "StrongsHebrew";
- case standardGreekStrongsLexicon: return "StrongsGreek";
- case standardHebrewMorphLexicon: return "StrongsHebrew";
- case standardGreekMorphLexicon: return "StrongsGreek";
+ case standardBible:
+ return "KJV";
+ case standardCommentary:
+ return "MHC";
+ case standardLexicon:
+ return "ISBE";
+ case standardDailyDevotional:
+ return ""; // No default
+
+ case standardHebrewStrongsLexicon:
+ return "StrongsHebrew";
+ case standardGreekStrongsLexicon:
+ return "StrongsGreek";
+ case standardHebrewMorphLexicon:
+ return "StrongsHebrew";
+ case standardGreekMorphLexicon:
+ return "StrongsGreek";
}
return QString::null;
@@ -211,62 +291,108 @@ QString getDefault(const modules ID) {
bool getDefault(const bools ID) {
switch (ID) {
- case firstSearchDialog: return true;
- case readOldBookmarks: return false;
-
- case toolbar: return true;
- case mainIndex: return true;
- case infoDisplay: return true;
-
- case autoTileVertical: return true;
- case autoTileHorizontal: return false;
- case autoCascade: return false;
-
- case lineBreaks: return false;
- case verseNumbers: return true;
-
- case logo: return true;
- case autoDeleteOrphanedIndices: return true;
- case crashedLastTime: return false;
- case crashedTwoTimes: return false;
- case bookshelfShowHidden: return false;
- case allowNetworkConnection: return false;
+ case firstSearchDialog:
+ return true;
+ case readOldBookmarks:
+ return false;
+
+ case toolbar:
+ return true;
+ case mainIndex:
+ return true;
+ case infoDisplay:
+ return true;
+
+ case autoTileVertical:
+ return true;
+ case autoTileHorizontal:
+ return false;
+ case autoCascade:
+ return false;
+
+ case lineBreaks:
+ return false;
+ case verseNumbers:
+ return true;
+
+ case logo:
+ return true;
+ case autoDeleteOrphanedIndices:
+ return true;
+ case crashedLastTime:
+ return false;
+ case crashedTwoTimes:
+ return false;
+ case bookshelfShowHidden:
+ return false;
+ case allowNetworkConnection:
+ return false;
}
return false;
}
int getDefault(const ints ID) {
switch (ID) {
- case footnotes: return int(true);
- case strongNumbers: return int(true);
- case headings: return int(true);
- case morphTags: return int(true);
- case lemmas: return int(true);
- case hebrewPoints: return int(true);
- case hebrewCantillation: return int(true);
- case greekAccents: return int(true);
- case textualVariants: return int(false);
- case scriptureReferences: return int(true);
- case morphSegmentation: return int(true);
- case bookshelfContentsX: return 0;
- case bookshelfContentsY: return 0;
- case magDelay: return 400;
- case bookshelfGrouping: return BTModuleTreeItem::CatLangMod;
- case searchDialogWidth: return 200;
- case searchDialogHeight: return 400;
- case searchDialogX: return 200;
- case searchDialogY: return 200;
- case searchType: return Search::BtSearchOptionsArea::AndType;
- case mainindexActiveTab: return 0;
- case installPathIndex: return 0;
- case bookshelfPosX: return 1;
- case bookshelfPosY: return 1;
- case bookshelfHeight: return 1;
- case bookshelfWidth: return 1;
- case configDialogPosX: return 1;
- case configDialogPosY: return 1;
- case configDialogHeight: return 1;
- case configDialogWidth: return 1;
+ case footnotes:
+ return int(true);
+ case strongNumbers:
+ return int(true);
+ case headings:
+ return int(true);
+ case morphTags:
+ return int(true);
+ case lemmas:
+ return int(true);
+ case hebrewPoints:
+ return int(true);
+ case hebrewCantillation:
+ return int(true);
+ case greekAccents:
+ return int(true);
+ case textualVariants:
+ return int(false);
+ case scriptureReferences:
+ return int(true);
+ case morphSegmentation:
+ return int(true);
+ case bookshelfContentsX:
+ return 0;
+ case bookshelfContentsY:
+ return 0;
+ case magDelay:
+ return 400;
+ case bookshelfGrouping:
+ return BTModuleTreeItem::CatLangMod;
+ case searchDialogWidth:
+ return 200;
+ case searchDialogHeight:
+ return 400;
+ case searchDialogX:
+ return 200;
+ case searchDialogY:
+ return 200;
+ case searchType:
+ return Search::BtSearchOptionsArea::AndType;
+ case mainindexActiveTab:
+ return 0;
+ case installPathIndex:
+ return 0;
+ case bookshelfPosX:
+ return 1;
+ case bookshelfPosY:
+ return 1;
+ case bookshelfHeight:
+ return 1;
+ case bookshelfWidth:
+ return 1;
+ case configDialogPosX:
+ return 1;
+ case configDialogPosY:
+ return 1;
+ case configDialogHeight:
+ return 1;
+ case configDialogWidth:
+ return 1;
}
return 0;
}
@@ -288,10 +414,14 @@ QStringList getDefault(const stringLists ID) {
list.append(QString::null);
return list;
}
- case searchCompletionTexts: return QStringList();
- case bookshelfOpenGroups: return QStringList();
- case hiddenModules: return QStringList();
- case searchModulesHistory: return QStringList();
+ case searchCompletionTexts:
+ return QStringList();
+ case bookshelfOpenGroups:
+ return QStringList();
+ case hiddenModules:
+ return QStringList();
+ case searchModulesHistory:
+ return QStringList();
}
return QStringList();
}
@@ -349,8 +479,8 @@ QString get(const strings ID) {
CSwordModuleInfo *get(const modules ID) {
getConfig()->beginGroup("modules");
CSwordModuleInfo *result(CPointers::backend()->findModuleByName(
- getConfig()->value(getKey(ID), getDefault(ID)).toString()
- ));
+ getConfig()->value(getKey(ID), getDefault(ID)).toString()
+ ));
getConfig()->endGroup();
return result;
}
@@ -372,9 +502,9 @@ int get(const ints ID) {
QList<int> get(const intLists ID) {
getConfig()->beginGroup("intlists");
QList<int> result(StringToIntList(
- getConfig()->value(getKey(ID), IntListToString(getDefault(ID)))
- .toString()
- ));
+ getConfig()->value(getKey(ID), IntListToString(getDefault(ID)))
+ .toString()
+ ));
getConfig()->endGroup();
return result;
}
@@ -382,8 +512,8 @@ QList<int> get(const intLists ID) {
QStringList get(const stringLists ID) {
getConfig()->beginGroup("stringlists");
QStringList result(
- getConfig()->value(getKey(ID), getDefault(ID)).toStringList()
- );
+ getConfig()->value(getKey(ID), getDefault(ID)).toStringList()
+ );
getConfig()->endGroup();
return result;
}
@@ -414,9 +544,11 @@ StringMap get(const stringMaps ID) {
map[key] = data; // Set the new data
}
}
- default: break;
+ default:
+ break;
}
- } else {
+ }
+ else {
map = getDefault(ID);
}
getConfig()->endGroup();
@@ -438,7 +570,8 @@ FontSettingsPair get(const CLanguageMgr::Language * const language) {
QFont font;
if (settings.first) {
font.fromString(getConfig()->value(getKey(language), getDefault(language)).toString());
- } else {
+ }
+ else {
font = getDefault(language);
}
settings.second = font;
@@ -539,8 +672,7 @@ void set(const stringMaps ID, const StringMap value) {
}
void set(const CLanguageMgr::Language * const language,
- const FontSettingsPair& value)
-{
+ const FontSettingsPair& value) {
getConfig()->beginGroup("fonts");
getConfig()->setValue(getKey(language), value.second.toString());
getConfig()->endGroup();
@@ -579,8 +711,7 @@ CSwordBackend::FilterOptions getFilterOptionDefaults() {
}
void setupAccelSettings(const keys type,
- BtActionCollection * const actionCollection)
-{
+ BtActionCollection * const actionCollection) {
qDebug("CBTConfig::setupAccelSettings begin");
QString groupName;
switch (type) {
@@ -618,8 +749,7 @@ void setupAccelSettings(const keys type,
}
void saveAccelSettings(const keys type,
- BtActionCollection * const actionCollection)
-{
+ BtActionCollection * const actionCollection) {
qDebug("CBTConfig::saveAccelSettings begin");
QString groupName;
switch (type) {
diff --git a/src/backend/cswordmodulesearch.cpp b/src/backend/cswordmodulesearch.cpp
index f57a87a..220cac9 100644
--- a/src/backend/cswordmodulesearch.cpp
+++ b/src/backend/cswordmodulesearch.cpp
@@ -23,101 +23,99 @@
CSwordModuleSearch* CSwordModuleSearch::searcher = 0;
CSwordModuleSearch::CSwordModuleSearch()
- : m_searchedText(QString::null),
- m_searchOptions(0),
- m_foundItems(false)
-{
- searcher = this;
+ : m_searchedText(QString::null),
+ m_searchOptions(0),
+ m_foundItems(false) {
+ searcher = this;
}
CSwordModuleSearch::~CSwordModuleSearch() {
- searcher = 0;
+ searcher = 0;
}
/** This function sets the modules which should be searched. */
void CSwordModuleSearch::setModules( const QList<CSwordModuleInfo*>& list ) {
- m_moduleList = list;
+ m_moduleList = list;
}
/** Starts the search for the search text. */
bool CSwordModuleSearch::startSearch() {
- backend()->setFilterOptions ( CBTConfig::getFilterOptionDefaults() );
- m_foundItems = false;
+ backend()->setFilterOptions ( CBTConfig::getFilterOptionDefaults() );
+ m_foundItems = false;
- bool foundItems = false;
+ bool foundItems = false;
- // for (m_moduleList.first(); m_moduleList.current() && !m_terminateSearch; m_moduleList.next()) {
- QList<CSwordModuleInfo*>::iterator end_it = m_moduleList.end();
+ // for (m_moduleList.first(); m_moduleList.current() && !m_terminateSearch; m_moduleList.next()) {
+ QList<CSwordModuleInfo*>::iterator end_it = m_moduleList.end();
- for (QList<CSwordModuleInfo*>::iterator it = m_moduleList.begin(); it != end_it; ++it) {
- if ( (*it)->searchIndexed(m_searchedText/*, m_searchOptions*/, m_searchScope) ) {
- foundItems = true;
- }
- }
+ for (QList<CSwordModuleInfo*>::iterator it = m_moduleList.begin(); it != end_it; ++it) {
+ if ( (*it)->searchIndexed(m_searchedText/*, m_searchOptions*/, m_searchScope) ) {
+ foundItems = true;
+ }
+ }
- m_foundItems = foundItems;
+ m_foundItems = foundItems;
- //m_finishedSig.activate();
- emit finished();
- return true;
+ //m_finishedSig.activate();
+ emit finished();
+ return true;
}
/** Sets the text which should be search in the modules. */
void CSwordModuleSearch::setSearchedText( const QString& text ) {
- m_searchedText = text;
+ m_searchedText = text;
}
/** Sets the search scope. */
void CSwordModuleSearch::setSearchScope( const sword::ListKey& scope ) {
- m_searchScope.copyFrom( scope );
-
- if (!strlen(scope.getRangeText())) { //we can't search with an empty search scope, would crash
- //reset the scope
- resetSearchScope();
-
- //disable searching with a scope!
- // if (m_searchOptions | useScope) {
- // qWarning("using the scope!");
- //set back the scope flag
- // }
- }
+ m_searchScope.copyFrom( scope );
+
+ if (!strlen(scope.getRangeText())) { //we can't search with an empty search scope, would crash
+ //reset the scope
+ resetSearchScope();
+
+ //disable searching with a scope!
+ // if (m_searchOptions | useScope) {
+ // qWarning("using the scope!");
+ //set back the scope flag
+ // }
+ }
}
/** Sets the search scope back. */
void CSwordModuleSearch::resetSearchScope() {
- m_searchScope.ClearList();
+ m_searchScope.ClearList();
}
/** Returns true if in the last search the searcher found items, if no items were found return false. */
bool CSwordModuleSearch::foundItems() const {
- return m_foundItems;
+ return m_foundItems;
}
/** Returns a copy of the used search scope. */
const sword::ListKey& CSwordModuleSearch::searchScope() const {
- return m_searchScope;
+ return m_searchScope;
}
void CSwordModuleSearch::connectFinished( QObject *receiver, const char *member ) {
- //m_finishedSig.connect(receiver, member);
- QObject::connect(this, SIGNAL(finished()), receiver, member);
+ //m_finishedSig.connect(receiver, member);
+ QObject::connect(this, SIGNAL(finished()), receiver, member);
}
/** Should be called when the search finished. */
void CSwordModuleSearch::searchFinished() {
- //m_finishedSig.activate();
- emit finished();
+ //m_finishedSig.activate();
+ emit finished();
}
-bool CSwordModuleSearch::modulesHaveIndices( const QList<CSwordModuleInfo*>& modules )
-{
- bool hasIndices = true;
- QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
- for( QList<CSwordModuleInfo*>::const_iterator it = modules.begin(); it != end_it; ++it) {
- if (!(*it)->hasIndex()) {
- hasIndices = false;
- break;
- }
- }
- return hasIndices;
+bool CSwordModuleSearch::modulesHaveIndices( const QList<CSwordModuleInfo*>& modules ) {
+ bool hasIndices = true;
+ QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
+ for ( QList<CSwordModuleInfo*>::const_iterator it = modules.begin(); it != end_it; ++it) {
+ if (!(*it)->hasIndex()) {
+ hasIndices = false;
+ break;
+ }
+ }
+ return hasIndices;
}
diff --git a/src/backend/cswordmodulesearch.h b/src/backend/cswordmodulesearch.h
index 7ba6a6f..cc0c8c1 100644
--- a/src/backend/cswordmodulesearch.h
+++ b/src/backend/cswordmodulesearch.h
@@ -34,65 +34,65 @@ class CSwordModuleInfo;
*/
class CSwordModuleSearch: public QObject, CPointers {
- Q_OBJECT
-
-public:
- CSwordModuleSearch();
- /**
- * The destructor of this class. It cleans uop memory before it's deleted.
- */
- virtual ~CSwordModuleSearch();
- /**
- * Sets the text which should be search in the modules.
- */
- void setSearchedText( const QString& );
- /**
- * Starts the search for the search text.
- */
- bool startSearch();
- /**
- * This function sets the modules which should be searched.
- */
- void setModules( const QList<CSwordModuleInfo*>& );
- /**
- * Sets the search scope.
- */
- void setSearchScope( const sword::ListKey& scope );
- /**
- * Sets the seaech scope back.
- */
- void resetSearchScope();
- /**
- * @return "true" if in the last search the searcher found items, if no items were found return "false"
- */
- bool foundItems() const;
- /**
- * Returns a copy of the used search scope.
- */
- const sword::ListKey& searchScope() const;
-
- void connectFinished( QObject * receiver, const char * member );
- void searchFinished();
-
- /**
- * Returns true if all of the specified modules have indices already built.
- */
- bool modulesHaveIndices( const QList<CSwordModuleInfo*>& );
-
-protected:
- QString m_searchedText;
- sword::ListKey m_searchScope;
- QList<CSwordModuleInfo*> m_moduleList;
-
- int m_searchOptions;
-
- bool m_foundItems;
-
-signals:
- void finished();
-
-private:
- static CSwordModuleSearch* searcher;
+ Q_OBJECT
+
+ public:
+ CSwordModuleSearch();
+ /**
+ * The destructor of this class. It cleans uop memory before it's deleted.
+ */
+ virtual ~CSwordModuleSearch();
+ /**
+ * Sets the text which should be search in the modules.
+ */
+ void setSearchedText( const QString& );
+ /**
+ * Starts the search for the search text.
+ */
+ bool startSearch();
+ /**
+ * This function sets the modules which should be searched.
+ */
+ void setModules( const QList<CSwordModuleInfo*>& );
+ /**
+ * Sets the search scope.
+ */
+ void setSearchScope( const sword::ListKey& scope );
+ /**
+ * Sets the seaech scope back.
+ */
+ void resetSearchScope();
+ /**
+ * @return "true" if in the last search the searcher found items, if no items were found return "false"
+ */
+ bool foundItems() const;
+ /**
+ * Returns a copy of the used search scope.
+ */
+ const sword::ListKey& searchScope() const;
+
+ void connectFinished( QObject * receiver, const char * member );
+ void searchFinished();
+
+ /**
+ * Returns true if all of the specified modules have indices already built.
+ */
+ bool modulesHaveIndices( const QList<CSwordModuleInfo*>& );
+
+ protected:
+ QString m_searchedText;
+ sword::ListKey m_searchScope;
+ QList<CSwordModuleInfo*> m_moduleList;
+
+ int m_searchOptions;
+
+ bool m_foundItems;
+
+ signals:
+ void finished();
+
+ private:
+ static CSwordModuleSearch* searcher;
};
#endif
diff --git a/src/backend/drivers/cswordbiblemoduleinfo.cpp b/src/backend/drivers/cswordbiblemoduleinfo.cpp
index a7b89ba..f00a580 100644
--- a/src/backend/drivers/cswordbiblemoduleinfo.cpp
+++ b/src/backend/drivers/cswordbiblemoduleinfo.cpp
@@ -22,204 +22,204 @@
CSwordBibleModuleInfo::CSwordBibleModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend )
-: CSwordModuleInfo(module, usedBackend),
-m_lowerBound(0),
-m_upperBound(0),
-m_bookList(0),
-m_cachedLocale("unknown"),
-m_hasOT(-1),
-m_hasNT(-1) {}
+ : CSwordModuleInfo(module, usedBackend),
+ m_lowerBound(0),
+ m_upperBound(0),
+ m_bookList(0),
+ m_cachedLocale("unknown"),
+ m_hasOT(-1),
+ m_hasNT(-1) {}
CSwordBibleModuleInfo::CSwordBibleModuleInfo( const CSwordBibleModuleInfo& m ) :
-CSwordModuleInfo(m),
-m_lowerBound(0),
-m_upperBound(0),
-m_bookList(0) {
- if (m.m_bookList) {
- m_bookList = new QStringList();
- *m_bookList = *m.m_bookList;
- }
-
- m_hasOT = m.m_hasOT;
- m_hasNT = m.m_hasNT;
- m_cachedLocale = m.m_cachedLocale;
+ CSwordModuleInfo(m),
+ m_lowerBound(0),
+ m_upperBound(0),
+ m_bookList(0) {
+ if (m.m_bookList) {
+ m_bookList = new QStringList();
+ *m_bookList = *m.m_bookList;
+ }
+
+ m_hasOT = m.m_hasOT;
+ m_hasNT = m.m_hasNT;
+ m_cachedLocale = m.m_cachedLocale;
}
CSwordModuleInfo* CSwordBibleModuleInfo::clone() {
- return new CSwordBibleModuleInfo(*this);
+ return new CSwordBibleModuleInfo(*this);
}
CSwordBibleModuleInfo::~CSwordBibleModuleInfo() {
- delete m_bookList;
+ delete m_bookList;
}
void CSwordBibleModuleInfo::initBounds() {
- if (m_hasOT == -1) {
- m_hasOT = hasTestament(OldTestament);
- }
-
- if (m_hasNT == -1) {
- m_hasNT = hasTestament(NewTestament);
- }
-
- if (m_hasOT) {
- m_lowerBound.key("Genesis 1:1");
- }
- else {
- m_lowerBound.key("Matthew 1:1");
- }
-
- if (!m_hasNT) {
- m_upperBound.key("Malachi 4:6");
- }
- else {
- m_upperBound.key("Revelation of John 22:21");
- }
+ if (m_hasOT == -1) {
+ m_hasOT = hasTestament(OldTestament);
+ }
+
+ if (m_hasNT == -1) {
+ m_hasNT = hasTestament(NewTestament);
+ }
+
+ if (m_hasOT) {
+ m_lowerBound.key("Genesis 1:1");
+ }
+ else {
+ m_lowerBound.key("Matthew 1:1");
+ }
+
+ if (!m_hasNT) {
+ m_upperBound.key("Malachi 4:6");
+ }
+ else {
+ m_upperBound.key("Revelation of John 22:21");
+ }
}
/** Returns the books available in this module */
QStringList* CSwordBibleModuleInfo::books() {
- if (m_cachedLocale != backend()->booknameLanguage()) { //if the locale has changed
- delete m_bookList;
- m_bookList = 0;
- }
-
- if (!m_bookList) {
- m_bookList = new QStringList();
-
- initBounds();
- int min = 0;
- int max = 1;
-
- //find out if we have ot and nt, only ot or only nt
-
- if (m_hasOT>0 && m_hasNT>0) { //both
- min = 0;
- max = 1;
- }
- else if (m_hasOT>0 && !m_hasNT) { //only OT
- min = 0;
- max = 0;
- }
- else if (!m_hasOT && m_hasNT>0) { //only NT
- min = 1;
- max = 1;
- }
- else if (!m_hasOT && !m_hasNT) { //somethings wrong here! - no OT and no NT
- qWarning("CSwordBibleModuleInfo (%s) no OT and not NT! Check your config!", module()->Name());
- min = 0;
- max = -1;
- }
-
- boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
- (*key) = sword::TOP;
-
- for (key->Testament(min+1); !key->Error() && (key->Testament()-1) <= max; key->Book(key->Book()+1)) {
- m_bookList->append( QString::fromUtf8(key->getBookName()) );
- }
-
- m_cachedLocale = backend()->booknameLanguage();
- }
-
- return m_bookList;
+ if (m_cachedLocale != backend()->booknameLanguage()) { //if the locale has changed
+ delete m_bookList;
+ m_bookList = 0;
+ }
+
+ if (!m_bookList) {
+ m_bookList = new QStringList();
+
+ initBounds();
+ int min = 0;
+ int max = 1;
+
+ //find out if we have ot and nt, only ot or only nt
+
+ if (m_hasOT > 0 && m_hasNT > 0) { //both
+ min = 0;
+ max = 1;
+ }
+ else if (m_hasOT > 0 && !m_hasNT) { //only OT
+ min = 0;
+ max = 0;
+ }
+ else if (!m_hasOT && m_hasNT > 0) { //only NT
+ min = 1;
+ max = 1;
+ }
+ else if (!m_hasOT && !m_hasNT) { //somethings wrong here! - no OT and no NT
+ qWarning("CSwordBibleModuleInfo (%s) no OT and not NT! Check your config!", module()->Name());
+ min = 0;
+ max = -1;
+ }
+
+ boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ (*key) = sword::TOP;
+
+ for (key->Testament(min + 1); !key->Error() && (key->Testament() - 1) <= max; key->Book(key->Book() + 1)) {
+ m_bookList->append( QString::fromUtf8(key->getBookName()) );
+ }
+
+ m_cachedLocale = backend()->booknameLanguage();
+ }
+
+ return m_bookList;
}
/** Returns the number of chapters for the given book. */
unsigned int CSwordBibleModuleInfo::chapterCount(const unsigned int book) {
- int result = 0;
+ int result = 0;
- boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
- (*key) = sword::TOP;
+ boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ (*key) = sword::TOP;
- // works for old and new versions
- key->Book(book);
- (*key) = sword::MAXCHAPTER;
- result = key->Chapter();
+ // works for old and new versions
+ key->Book(book);
+ (*key) = sword::MAXCHAPTER;
+ result = key->Chapter();
- return result;
+ return result;
}
unsigned int CSwordBibleModuleInfo::chapterCount(const QString& book) {
- return chapterCount( bookNumber(book) );
+ return chapterCount( bookNumber(book) );
}
/** Returns the number of verses for the given chapter. */
unsigned int CSwordBibleModuleInfo::verseCount( const unsigned int book, const unsigned int chapter ) {
- unsigned int result = 0;
+ unsigned int result = 0;
- boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
- (*key) = sword::TOP;
+ boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ (*key) = sword::TOP;
- // works for old and new versions
- key->Book(book);
- key->Chapter(chapter);
- (*key) = sword::MAXVERSE;
- result = key->Verse();
+ // works for old and new versions
+ key->Book(book);
+ key->Chapter(chapter);
+ (*key) = sword::MAXVERSE;
+ result = key->Verse();
- return result;
+ return result;
}
unsigned int CSwordBibleModuleInfo::verseCount( const QString& book, const unsigned int chapter ) {
- return verseCount( bookNumber(book), chapter );
+ return verseCount( bookNumber(book), chapter );
}
unsigned int CSwordBibleModuleInfo::bookNumber(const QString &book) {
- unsigned int bookNumber = 0;
+ unsigned int bookNumber = 0;
- //find out if we have ot and nt, only ot or only nt
- initBounds();
+ //find out if we have ot and nt, only ot or only nt
+ initBounds();
- boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
- (*key) = sword::TOP;
+ boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ (*key) = sword::TOP;
- key->setBookName(book.toUtf8().constData());
+ key->setBookName(book.toUtf8().constData());
- bookNumber = ((key->Testament() > 1) ? key->BMAX[0] : 0) + key->Book();
+ bookNumber = ((key->Testament() > 1) ? key->BMAX[0] : 0) + key->Book();
- return bookNumber;
+ return bookNumber;
}
/** Returns true if his module has the text of desired type of testament */
bool CSwordBibleModuleInfo::hasTestament( CSwordBibleModuleInfo::Testament type ) {
- if (m_hasOT == -1 || m_hasNT == -1) {
- const bool oldStatus = module()->getSkipConsecutiveLinks();
- module()->setSkipConsecutiveLinks(true);
+ if (m_hasOT == -1 || m_hasNT == -1) {
+ const bool oldStatus = module()->getSkipConsecutiveLinks();
+ module()->setSkipConsecutiveLinks(true);
- *module() = sword::TOP; //position to first entry
- sword::VerseKey key( module()->KeyText() );
+ *module() = sword::TOP; //position to first entry
+ sword::VerseKey key( module()->KeyText() );
- if (key.Testament() == 1) { // OT && NT
- m_hasOT = 1;
- }
- else if (key.Testament() == 2) { //no OT
- m_hasOT = 0;
- }
+ if (key.Testament() == 1) { // OT && NT
+ m_hasOT = 1;
+ }
+ else if (key.Testament() == 2) { //no OT
+ m_hasOT = 0;
+ }
- *module() = sword::BOTTOM;
- key = module()->KeyText();
+ *module() = sword::BOTTOM;
+ key = module()->KeyText();
- if (key.Testament() == 1) { // only OT, no NT
- m_hasNT = 0;
- }
- else if (key.Testament() == 2) { //has NT
- m_hasNT = 1;
- }
+ if (key.Testament() == 1) { // only OT, no NT
+ m_hasNT = 0;
+ }
+ else if (key.Testament() == 2) { //has NT
+ m_hasNT = 1;
+ }
- module()->setSkipConsecutiveLinks(oldStatus);
- }
+ module()->setSkipConsecutiveLinks(oldStatus);
+ }
- switch (type) {
+ switch (type) {
- case OldTestament:
- return m_hasOT>0;
+ case OldTestament:
+ return m_hasOT > 0;
- case NewTestament:
- return m_hasNT>0;
+ case NewTestament:
+ return m_hasNT > 0;
- default:
- return false;
- }
+ default:
+ return false;
+ }
}
diff --git a/src/backend/drivers/cswordbiblemoduleinfo.h b/src/backend/drivers/cswordbiblemoduleinfo.h
index c25eb37..10d05bb 100644
--- a/src/backend/drivers/cswordbiblemoduleinfo.h
+++ b/src/backend/drivers/cswordbiblemoduleinfo.h
@@ -26,101 +26,101 @@
class CSwordBibleModuleInfo : public CSwordModuleInfo {
-public:
- enum Testament {
- OldTestament = 1,
- NewTestament = 2
- };
+ public:
+ enum Testament {
+ OldTestament = 1,
+ NewTestament = 2
+ };
- /**
- * The constructor of this class
- */
- CSwordBibleModuleInfo( sword::SWModule* module, CSwordBackend* const );
- /** The copy constructor for this Bible module.
- */
- CSwordBibleModuleInfo( const CSwordBibleModuleInfo& m );
- /**
- * The destructor of this class
- */
- ~CSwordBibleModuleInfo();
- /**
- * Returns the number of avalable verses for the given chapter and book.
- *
- * @param book The number book we should use
- * @param chapter The chapter we should use
- * @return The number of verses for the given book and chapter
- */
- virtual unsigned int verseCount( const unsigned int book, const unsigned int chapter );
- /**
- * Returns the number of avalable verses for the given chapter and book.
- *
- * @param book The name of the book we use
- * @param chapter The number of the chapter we use
- * @return The number of verses for the given book and chapter
- */
- virtual unsigned int verseCount( const QString& book, const unsigned int chapter );
- /** Information about the chapters in a book.
- * @return The number of available chapters of the given book.
- * @return The number of chapters for the given book
- */
- virtual unsigned int chapterCount( const unsigned int book );
- /** Information about the chapters in a book.
- * @return The number of available chapters of the given book.
- */
- virtual unsigned int chapterCount( const QString& book );
- /** Return all book of this module.
- * @return A QStringList containing the books which are available in this module.
- */
- virtual QStringList* books();
- /**
- * Reimplementation, Returns the type
- */
- virtual CSwordModuleInfo::ModuleType type() const;
- /**
- * @return the book number, values starting with 1; 0 if not found
- */
- unsigned int bookNumber(const QString &book);
- /**
- * Returns true if his module has the text of desired type of testament
- */
- bool hasTestament( CSwordBibleModuleInfo::Testament );
- /** Reimplementation to clone this object. */
- virtual CSwordModuleInfo* clone();
- /**
- * Returns the key which represents the lower bound of this module.
- */
- inline const CSwordVerseKey& lowerBound();
- /**
- * Returns the key which represents the upper bound of this module.
- */
- inline const CSwordVerseKey& upperBound();
+ /**
+ * The constructor of this class
+ */
+ CSwordBibleModuleInfo( sword::SWModule* module, CSwordBackend* const );
+ /** The copy constructor for this Bible module.
+ */
+ CSwordBibleModuleInfo( const CSwordBibleModuleInfo& m );
+ /**
+ * The destructor of this class
+ */
+ ~CSwordBibleModuleInfo();
+ /**
+ * Returns the number of avalable verses for the given chapter and book.
+ *
+ * @param book The number book we should use
+ * @param chapter The chapter we should use
+ * @return The number of verses for the given book and chapter
+ */
+ virtual unsigned int verseCount( const unsigned int book, const unsigned int chapter );
+ /**
+ * Returns the number of avalable verses for the given chapter and book.
+ *
+ * @param book The name of the book we use
+ * @param chapter The number of the chapter we use
+ * @return The number of verses for the given book and chapter
+ */
+ virtual unsigned int verseCount( const QString& book, const unsigned int chapter );
+ /** Information about the chapters in a book.
+ * @return The number of available chapters of the given book.
+ * @return The number of chapters for the given book
+ */
+ virtual unsigned int chapterCount( const unsigned int book );
+ /** Information about the chapters in a book.
+ * @return The number of available chapters of the given book.
+ */
+ virtual unsigned int chapterCount( const QString& book );
+ /** Return all book of this module.
+ * @return A QStringList containing the books which are available in this module.
+ */
+ virtual QStringList* books();
+ /**
+ * Reimplementation, Returns the type
+ */
+ virtual CSwordModuleInfo::ModuleType type() const;
+ /**
+ * @return the book number, values starting with 1; 0 if not found
+ */
+ unsigned int bookNumber(const QString &book);
+ /**
+ * Returns true if his module has the text of desired type of testament
+ */
+ bool hasTestament( CSwordBibleModuleInfo::Testament );
+ /** Reimplementation to clone this object. */
+ virtual CSwordModuleInfo* clone();
+ /**
+ * Returns the key which represents the lower bound of this module.
+ */
+ inline const CSwordVerseKey& lowerBound();
+ /**
+ * Returns the key which represents the upper bound of this module.
+ */
+ inline const CSwordVerseKey& upperBound();
-private:
- void initBounds();
+ private:
+ void initBounds();
- CSwordVerseKey m_lowerBound;
- CSwordVerseKey m_upperBound;
+ CSwordVerseKey m_lowerBound;
+ CSwordVerseKey m_upperBound;
- QStringList* m_bookList; //This booklist is cached
- QString m_cachedLocale;
- short int m_hasOT;
- short int m_hasNT;
+ QStringList* m_bookList; //This booklist is cached
+ QString m_cachedLocale;
+ short int m_hasOT;
+ short int m_hasNT;
};
inline CSwordModuleInfo::ModuleType CSwordBibleModuleInfo::type() const {
- return CSwordModuleInfo::Bible;
+ return CSwordModuleInfo::Bible;
}
/** Returns the key which represents the lower bound of this module. */
inline const CSwordVerseKey& CSwordBibleModuleInfo::lowerBound() {
- initBounds();
- return m_lowerBound;
+ initBounds();
+ return m_lowerBound;
}
/** Returns the key which represents the lower bound of this module. */
inline const CSwordVerseKey& CSwordBibleModuleInfo::upperBound() {
- initBounds();
- return m_upperBound;
+ initBounds();
+ return m_upperBound;
}
#endif
diff --git a/src/backend/drivers/cswordbookmoduleinfo.cpp b/src/backend/drivers/cswordbookmoduleinfo.cpp
index 0a8c1e6..b67015b 100644
--- a/src/backend/drivers/cswordbookmoduleinfo.cpp
+++ b/src/backend/drivers/cswordbookmoduleinfo.cpp
@@ -16,53 +16,53 @@
#include <treekey.h>
CSwordBookModuleInfo::CSwordBookModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend )
-: CSwordModuleInfo(module, usedBackend),
-m_depth(-1) {}
+ : CSwordModuleInfo(module, usedBackend),
+ m_depth(-1) {}
CSwordBookModuleInfo::CSwordBookModuleInfo( const CSwordBookModuleInfo& module )
-: CSwordModuleInfo(module) {
- m_depth = module.m_depth;
+ : CSwordModuleInfo(module) {
+ m_depth = module.m_depth;
}
CSwordBookModuleInfo::~CSwordBookModuleInfo() {}
int CSwordBookModuleInfo::depth() {
- if (m_depth == -1) {
- sword::TreeKeyIdx* key = tree();
+ if (m_depth == -1) {
+ sword::TreeKeyIdx* key = tree();
- if (key) {
- key->root();
- computeDepth(key, 0);
- }
- }
+ if (key) {
+ key->root();
+ computeDepth(key, 0);
+ }
+ }
- return m_depth;
+ return m_depth;
}
void CSwordBookModuleInfo::computeDepth(sword::TreeKeyIdx* key, int level ) {
- std::string savedKey;
- // savedKey = key->getFullName(); //sword 1.5.8
- savedKey = key->getText();
+ std::string savedKey;
+ // savedKey = key->getFullName(); //sword 1.5.8
+ savedKey = key->getText();
- if (level > m_depth) {
- m_depth = level;
- }
+ if (level > m_depth) {
+ m_depth = level;
+ }
- if (key->hasChildren()) {
- key->firstChild();
- computeDepth(key, level+1);
+ if (key->hasChildren()) {
+ key->firstChild();
+ computeDepth(key, level + 1);
- key->setText( savedKey.c_str() );//return to the initial value
- }
+ key->setText( savedKey.c_str() );//return to the initial value
+ }
- if (key->nextSibling()) {
- computeDepth(key, level);
- }
+ if (key->nextSibling()) {
+ computeDepth(key, level);
+ }
}
/** Returns a treekey filled with the structure of this module */
sword::TreeKeyIdx* CSwordBookModuleInfo::tree() const {
- sword::TreeKeyIdx* treeKey = dynamic_cast<sword::TreeKeyIdx*>((sword::SWKey*)*(module()));
- Q_ASSERT(treeKey);
- return treeKey;
+ sword::TreeKeyIdx* treeKey = dynamic_cast<sword::TreeKeyIdx*>((sword::SWKey*) * (module()));
+ Q_ASSERT(treeKey);
+ return treeKey;
}
diff --git a/src/backend/drivers/cswordbookmoduleinfo.h b/src/backend/drivers/cswordbookmoduleinfo.h
index f471d61..cd18efc 100644
--- a/src/backend/drivers/cswordbookmoduleinfo.h
+++ b/src/backend/drivers/cswordbookmoduleinfo.h
@@ -21,43 +21,43 @@
class CSwordBookModuleInfo : public CSwordModuleInfo {
-public:
- /** Constructor.
- * @param module The module which belongs to this object
- * @param backend The parent backend for this book module.
- */
- CSwordBookModuleInfo( sword::SWModule* module, CSwordBackend* const backend );
- /** Copy constructor.
- * Copy constructor to copy the passed parameter.
- * @param module The module which should be copied.
- */
- CSwordBookModuleInfo( const CSwordBookModuleInfo& module );
- /** Destructor.
- */
- ~CSwordBookModuleInfo();
- /**
- * Returns the type of the module.
- */
- virtual CSwordModuleInfo::ModuleType type() const;
- /**
- * Returns the maximal depth of sections and subsections.
- */
- int depth();
- /**
- * @return A treekey filled with the structure of this module. Don't delete the returned key because it's casted from the module object.
- */
- sword::TreeKeyIdx* tree() const;
+ public:
+ /** Constructor.
+ * @param module The module which belongs to this object
+ * @param backend The parent backend for this book module.
+ */
+ CSwordBookModuleInfo( sword::SWModule* module, CSwordBackend* const backend );
+ /** Copy constructor.
+ * Copy constructor to copy the passed parameter.
+ * @param module The module which should be copied.
+ */
+ CSwordBookModuleInfo( const CSwordBookModuleInfo& module );
+ /** Destructor.
+ */
+ ~CSwordBookModuleInfo();
+ /**
+ * Returns the type of the module.
+ */
+ virtual CSwordModuleInfo::ModuleType type() const;
+ /**
+ * Returns the maximal depth of sections and subsections.
+ */
+ int depth();
+ /**
+ * @return A treekey filled with the structure of this module. Don't delete the returned key because it's casted from the module object.
+ */
+ sword::TreeKeyIdx* tree() const;
-private:
- /**
- * A recursive helper function to help computng the module depth!
- */
- void computeDepth(sword::TreeKeyIdx* key, int level = 0 );
- int m_depth;
+ private:
+ /**
+ * A recursive helper function to help computng the module depth!
+ */
+ void computeDepth(sword::TreeKeyIdx* key, int level = 0 );
+ int m_depth;
};
inline CSwordBookModuleInfo::ModuleType CSwordBookModuleInfo::type() const {
- return CSwordModuleInfo::GenericBook;
+ return CSwordModuleInfo::GenericBook;
}
diff --git a/src/backend/drivers/cswordcommentarymoduleinfo.cpp b/src/backend/drivers/cswordcommentarymoduleinfo.cpp
index b09e2f3..bb19a23 100644
--- a/src/backend/drivers/cswordcommentarymoduleinfo.cpp
+++ b/src/backend/drivers/cswordcommentarymoduleinfo.cpp
@@ -10,23 +10,23 @@
#include "cswordcommentarymoduleinfo.h"
CSwordCommentaryModuleInfo::CSwordCommentaryModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend)
-: CSwordBibleModuleInfo(module, usedBackend) {}
+ : CSwordBibleModuleInfo(module, usedBackend) {}
CSwordCommentaryModuleInfo::~CSwordCommentaryModuleInfo() {}
/** No descriptions */
CSwordModuleInfo* CSwordCommentaryModuleInfo::clone() {
- return new CSwordCommentaryModuleInfo(*this);
+ return new CSwordCommentaryModuleInfo(*this);
}
/** Returns true if this module may be written by the write display windows. */
bool CSwordCommentaryModuleInfo::isWritable() const {
- // qWarning(module()->getConfigEntry("ModDrv"));
- //a module is only writable if it's a RawFiles module with writable returning true
+ // qWarning(module()->getConfigEntry("ModDrv"));
+ //a module is only writable if it's a RawFiles module with writable returning true
- if ( (std::string(module()->getConfigEntry("ModDrv")) == std::string("RawFiles")) && module()->isWritable()) {
- return true;
- };
+ if ( (std::string(module()->getConfigEntry("ModDrv")) == std::string("RawFiles")) && module()->isWritable()) {
+ return true;
+ };
- return false;
+ return false;
}
diff --git a/src/backend/drivers/cswordcommentarymoduleinfo.h b/src/backend/drivers/cswordcommentarymoduleinfo.h
index 7ebf23f..eb9db83 100644
--- a/src/backend/drivers/cswordcommentarymoduleinfo.h
+++ b/src/backend/drivers/cswordcommentarymoduleinfo.h
@@ -21,23 +21,23 @@
class CSwordCommentaryModuleInfo : public CSwordBibleModuleInfo {
-public:
- CSwordCommentaryModuleInfo( sword::SWModule* module, CSwordBackend* const );
- ~CSwordCommentaryModuleInfo();
- /** Reimplementation to return the commentary type.
- */
- virtual CSwordModuleInfo::ModuleType type() const;
- /** Reimplementation to clone the current object.
- */
- virtual CSwordModuleInfo* clone();
- /**
- * Returns true if this module may be written by the write display windows.
- */
- virtual bool isWritable() const;
+ public:
+ CSwordCommentaryModuleInfo( sword::SWModule* module, CSwordBackend* const );
+ ~CSwordCommentaryModuleInfo();
+ /** Reimplementation to return the commentary type.
+ */
+ virtual CSwordModuleInfo::ModuleType type() const;
+ /** Reimplementation to clone the current object.
+ */
+ virtual CSwordModuleInfo* clone();
+ /**
+ * Returns true if this module may be written by the write display windows.
+ */
+ virtual bool isWritable() const;
};
inline CSwordModuleInfo::ModuleType CSwordCommentaryModuleInfo::type() const {
- return CSwordModuleInfo::Commentary;
+ return CSwordModuleInfo::Commentary;
}
#endif
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.cpp b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
index c84cd07..28874b6 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.cpp
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
@@ -25,151 +25,151 @@
#define CACHE_FORMAT "2"
CSwordLexiconModuleInfo::CSwordLexiconModuleInfo( sword::SWModule* module, CSwordBackend* const backend ) : CSwordModuleInfo(module, backend) {
- m_entryList = 0;
+ m_entryList = 0;
}
CSwordLexiconModuleInfo::CSwordLexiconModuleInfo( const CSwordLexiconModuleInfo& m ) : CSwordModuleInfo(m) {
- delete m_entryList;
- m_entryList = 0;
+ delete m_entryList;
+ m_entryList = 0;
- if (m.m_entryList) {
- m_entryList = new QStringList();
- *m_entryList = *m.m_entryList;//copy list items
- }
+ if (m.m_entryList) {
+ m_entryList = new QStringList();
+ *m_entryList = *m.m_entryList;//copy list items
+ }
}
CSwordLexiconModuleInfo::~CSwordLexiconModuleInfo() {
- delete m_entryList;
- m_entryList = 0;
+ delete m_entryList;
+ m_entryList = 0;
}
/** Returns the entries of the module. */
QStringList* CSwordLexiconModuleInfo::entries() {
- if (!module()) {
- return 0;
- }
-
- sword::SWModule* my_module = module();
- bool is_unicode = isUnicode();
-
- if (!m_entryList) {
- m_entryList = new QStringList();
- bool read = false;
-
- //Check for buggy modules! They will not be loaded any more.
-
- if ( name() == QString("ZhEnglish")) {
- qWarning("Module ZhEnglish is buggy and will not be loaded.");
- return m_entryList;
- }
-
- if ( name() == QString("EReo_en")) {
- qWarning("Module EReo_en is buggy and will not be loaded.");
- return m_entryList;
- }
-
- QString dir(util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath());
- QFile f1(
- QString(dir)
- .append("/")
- .append(name())
- );
-
- if ( f1.open( QIODevice::ReadOnly ) ) {
- QDataStream s( &f1 );
- QString mod_ver, prog_ver;
- s >> mod_ver;
- s >> prog_ver;
-
- if ((mod_ver == config(ModuleVersion)) && (prog_ver == CACHE_FORMAT)) {
- s >> *m_entryList;
- read = true;
- }
-
- f1.close();
- // qWarning("read entries %d",m_entryList->count());
- }
-
- // Q_ASSERT(read);
- // Q_ASSERT(m_entryList->count());
- if (!read || !m_entryList->count()) {
- my_module->setSkipConsecutiveLinks(true);
- (*my_module) = sword::TOP;
- snap(); //snap to top entry
-
- // qWarning("Reading in module" );
- int i = 0;
-
- do {
- if ( is_unicode ) {
- m_entryList->append(QString::fromUtf8(my_module->KeyText()));
- // qWarning("Entry: %s", my_module->KeyText() );
- }
- else { //for latin1 modules use fromLatin1 because of speed
- // m_entryList->append(QString::fromLatin1(my_module->KeyText()));
- QTextCodec* codec = QTextCodec::codecForName("Windows-1252");
- m_entryList->append(codec->toUnicode(my_module->KeyText()));
- }
-
- (*my_module)++;
- i++;
- }
- while ( !my_module->Error() );
-
- // qWarning("Reading finished. Module has %d entries.", i );
-
- (*my_module) = sword::TOP; //back to the first entry
-
- my_module->setSkipConsecutiveLinks(false);
-
- if (m_entryList->count()) {
- m_entryList->first().simplified();
-
- if (m_entryList->first().trimmed().isEmpty()) {
- m_entryList->erase( m_entryList->begin() );
- }
-
- //now sort the list, this is necesssary because Sword doesn't do Unicode ordering
- // qWarning("sorting");
- // QStringList::iterator start(m_entryList->begin());
- // QStringList::iterator end(m_entryList->end());
- // std::sort( start, end, myLocaleAwareCompare() ); //stl sort
- // m_entryList->sort(); //make sure the module is sorted by utf-8
- }
-
- qWarning("Writing cache file.");
-
- if (m_entryList->count()) {
- //create cache
- QString dir = util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath();
- //QFile f2( QString::fromLatin1("%1/%2").arg(dir).arg( name() ) );
- QFile f2( QString(dir).append("/").append(name()) );
-
-
- if (f2.open( QIODevice::WriteOnly )) {
- QDataStream s( &f2 );
- s << config(CSwordModuleInfo::ModuleVersion); //store module version
- s << QString(CACHE_FORMAT); //store BT version -- format may change
- s << *m_entryList;
- f2.close();
- }
- }
- }
- }
-
- return m_entryList;
+ if (!module()) {
+ return 0;
+ }
+
+ sword::SWModule* my_module = module();
+ bool is_unicode = isUnicode();
+
+ if (!m_entryList) {
+ m_entryList = new QStringList();
+ bool read = false;
+
+ //Check for buggy modules! They will not be loaded any more.
+
+ if ( name() == QString("ZhEnglish")) {
+ qWarning("Module ZhEnglish is buggy and will not be loaded.");
+ return m_entryList;
+ }
+
+ if ( name() == QString("EReo_en")) {
+ qWarning("Module EReo_en is buggy and will not be loaded.");
+ return m_entryList;
+ }
+
+ QString dir(util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath());
+ QFile f1(
+ QString(dir)
+ .append("/")
+ .append(name())
+ );
+
+ if ( f1.open( QIODevice::ReadOnly ) ) {
+ QDataStream s( &f1 );
+ QString mod_ver, prog_ver;
+ s >> mod_ver;
+ s >> prog_ver;
+
+ if ((mod_ver == config(ModuleVersion)) && (prog_ver == CACHE_FORMAT)) {
+ s >> *m_entryList;
+ read = true;
+ }
+
+ f1.close();
+ // qWarning("read entries %d",m_entryList->count());
+ }
+
+ // Q_ASSERT(read);
+ // Q_ASSERT(m_entryList->count());
+ if (!read || !m_entryList->count()) {
+ my_module->setSkipConsecutiveLinks(true);
+ (*my_module) = sword::TOP;
+ snap(); //snap to top entry
+
+ // qWarning("Reading in module" );
+ int i = 0;
+
+ do {
+ if ( is_unicode ) {
+ m_entryList->append(QString::fromUtf8(my_module->KeyText()));
+ // qWarning("Entry: %s", my_module->KeyText() );
+ }
+ else { //for latin1 modules use fromLatin1 because of speed
+ // m_entryList->append(QString::fromLatin1(my_module->KeyText()));
+ QTextCodec* codec = QTextCodec::codecForName("Windows-1252");
+ m_entryList->append(codec->toUnicode(my_module->KeyText()));
+ }
+
+ (*my_module)++;
+ i++;
+ }
+ while ( !my_module->Error() );
+
+ // qWarning("Reading finished. Module has %d entries.", i );
+
+ (*my_module) = sword::TOP; //back to the first entry
+
+ my_module->setSkipConsecutiveLinks(false);
+
+ if (m_entryList->count()) {
+ m_entryList->first().simplified();
+
+ if (m_entryList->first().trimmed().isEmpty()) {
+ m_entryList->erase( m_entryList->begin() );
+ }
+
+ //now sort the list, this is necesssary because Sword doesn't do Unicode ordering
+ // qWarning("sorting");
+ // QStringList::iterator start(m_entryList->begin());
+ // QStringList::iterator end(m_entryList->end());
+ // std::sort( start, end, myLocaleAwareCompare() ); //stl sort
+ // m_entryList->sort(); //make sure the module is sorted by utf-8
+ }
+
+ qWarning("Writing cache file.");
+
+ if (m_entryList->count()) {
+ //create cache
+ QString dir = util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath();
+ //QFile f2( QString::fromLatin1("%1/%2").arg(dir).arg( name() ) );
+ QFile f2( QString(dir).append("/").append(name()) );
+
+
+ if (f2.open( QIODevice::WriteOnly )) {
+ QDataStream s( &f2 );
+ s << config(CSwordModuleInfo::ModuleVersion); //store module version
+ s << QString(CACHE_FORMAT); //store BT version -- format may change
+ s << *m_entryList;
+ f2.close();
+ }
+ }
+ }
+ }
+
+ return m_entryList;
}
/** Jumps to the closest entry in the module. */
bool CSwordLexiconModuleInfo::snap() {
- if(module()->getRawEntry()) { // Snap to the current entry
- return true;
- }
+ if (module()->getRawEntry()) { // Snap to the current entry
+ return true;
+ }
- return false;
+ return false;
}
/** No descriptions */
CSwordModuleInfo* CSwordLexiconModuleInfo::clone() {
- return new CSwordLexiconModuleInfo(*this);
+ return new CSwordLexiconModuleInfo(*this);
}
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.h b/src/backend/drivers/cswordlexiconmoduleinfo.h
index 13f72e4..e5a5535 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.h
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.h
@@ -24,48 +24,48 @@
class CSwordLexiconModuleInfo : public CSwordModuleInfo {
-public:
- /**
- * The standard constructor fot this object.
- * A default constructor doesn't exist. Use this one.
- */
- CSwordLexiconModuleInfo( sword::SWModule* module, CSwordBackend* const );
- /**
- * The copy constructor
- */
- CSwordLexiconModuleInfo( const CSwordLexiconModuleInfo& m );
- /** Reimplementation to return a valid clone.
- */
- virtual CSwordModuleInfo* clone();
- /** Destructor.
- */
- virtual ~CSwordLexiconModuleInfo();
- /**
- * Returns the entries of the module.
- * This function returns the entries of the modules represented by this object.
- * If this function is called for the first time the list is load from disk and stored in a list which cahes it.
- * If the function is called again, the cached list is returned so we have a major speed improvement.
- * @return The list of lexicon entries
- */
- QStringList* entries();
- /**
- * Reimplementation, to return the right type for this lexicon.
- */
- virtual CSwordModuleInfo::ModuleType type() const;
- /**
- * Jumps to the closest entry in the module.
- */
- bool snap();
+ public:
+ /**
+ * The standard constructor fot this object.
+ * A default constructor doesn't exist. Use this one.
+ */
+ CSwordLexiconModuleInfo( sword::SWModule* module, CSwordBackend* const );
+ /**
+ * The copy constructor
+ */
+ CSwordLexiconModuleInfo( const CSwordLexiconModuleInfo& m );
+ /** Reimplementation to return a valid clone.
+ */
+ virtual CSwordModuleInfo* clone();
+ /** Destructor.
+ */
+ virtual ~CSwordLexiconModuleInfo();
+ /**
+ * Returns the entries of the module.
+ * This function returns the entries of the modules represented by this object.
+ * If this function is called for the first time the list is load from disk and stored in a list which cahes it.
+ * If the function is called again, the cached list is returned so we have a major speed improvement.
+ * @return The list of lexicon entries
+ */
+ QStringList* entries();
+ /**
+ * Reimplementation, to return the right type for this lexicon.
+ */
+ virtual CSwordModuleInfo::ModuleType type() const;
+ /**
+ * Jumps to the closest entry in the module.
+ */
+ bool snap();
-private:
- /**
- * This is the list which caches the entres of the module.
- */
- QStringList* m_entryList;
+ private:
+ /**
+ * This is the list which caches the entres of the module.
+ */
+ QStringList* m_entryList;
};
inline CSwordModuleInfo::ModuleType CSwordLexiconModuleInfo::type() const {
- return CSwordModuleInfo::Lexicon;
+ return CSwordModuleInfo::Lexicon;
}
#endif
diff --git a/src/backend/drivers/cswordmoduleinfo.cpp b/src/backend/drivers/cswordmoduleinfo.cpp
index c76f5ef..5861a2b 100644
--- a/src/backend/drivers/cswordmoduleinfo.cpp
+++ b/src/backend/drivers/cswordmoduleinfo.cpp
@@ -53,96 +53,96 @@
//Increment this, if the index format changes
//Then indices on the user's systems will be rebuilt
-const unsigned int INDEX_VERSION = 6;
+const unsigned int INDEX_VERSION = 7;
//Maximum index entry size, 1MiB for now
//Lucene default is too small
-const unsigned long BT_MAX_LUCENE_FIELD_LENGTH = 1024*1024;
+const unsigned long BT_MAX_LUCENE_FIELD_LENGTH = 1024 * 1024;
CSwordModuleInfo::CSwordModuleInfo(sword::SWModule * module, CSwordBackend * const usedBackend) {
- m_module = module;
- Q_ASSERT(module);
-
- m_hidden = false;
- m_cancelIndexing = false;
- m_searchResult.ClearList();
- m_backend = usedBackend ? usedBackend : CPointers::backend();
- m_dataCache.name = module ? QString(module->Name()) : QString::null;
- m_dataCache.isUnicode = module ? module->isUnicode() : false;
- m_dataCache.category = UnknownCategory;
- m_dataCache.language = 0;
- m_dataCache.hasVersion = !QString((*m_backend->getConfig())[module->Name()]["Version"]).isEmpty();
-
- if (backend()) {
- if (hasVersion() && (minimumSwordVersion() > sword::SWVersion::currentVersion)) {
- qWarning("The module \"%s\" requires a newer Sword library. Please update to \"Sword %s\".",
- name().toUtf8().constData(), (const char *)minimumSwordVersion());
- }
- }
-}
-
-CSwordModuleInfo::CSwordModuleInfo(const CSwordModuleInfo & m) : QObject(){
- m_module = m.m_module;
- m_backend = m.m_backend;
- m_dataCache = m.m_dataCache;
- m_searchResult = m.m_searchResult;
- m_hidden = m.m_hidden;
- m_cancelIndexing = m.m_cancelIndexing;
+ m_module = module;
+ Q_ASSERT(module);
+
+ m_hidden = false;
+ m_cancelIndexing = false;
+ m_searchResult.ClearList();
+ m_backend = usedBackend ? usedBackend : CPointers::backend();
+ m_dataCache.name = module ? QString(module->Name()) : QString::null;
+ m_dataCache.isUnicode = module ? module->isUnicode() : false;
+ m_dataCache.category = UnknownCategory;
+ m_dataCache.language = 0;
+ m_dataCache.hasVersion = !QString((*m_backend->getConfig())[module->Name()]["Version"]).isEmpty();
+
+ if (backend()) {
+ if (hasVersion() && (minimumSwordVersion() > sword::SWVersion::currentVersion)) {
+ qWarning("The module \"%s\" requires a newer Sword library. Please update to \"Sword %s\".",
+ name().toUtf8().constData(), (const char *)minimumSwordVersion());
+ }
+ }
+}
+
+CSwordModuleInfo::CSwordModuleInfo(const CSwordModuleInfo & m) : QObject() {
+ m_module = m.m_module;
+ m_backend = m.m_backend;
+ m_dataCache = m.m_dataCache;
+ m_searchResult = m.m_searchResult;
+ m_hidden = m.m_hidden;
+ m_cancelIndexing = m.m_cancelIndexing;
}
/** No descriptions */
CSwordModuleInfo *CSwordModuleInfo::clone() {
- return new CSwordModuleInfo(*this);
+ return new CSwordModuleInfo(*this);
}
CSwordModuleInfo::~CSwordModuleInfo() {
- m_searchResult.ClearList();
- m_module = 0; //the Sword module object is deleted by the backend
+ m_searchResult.ClearList();
+ m_module = 0; //the Sword module object is deleted by the backend
}
/** Sets the unlock key of the modules and writes the key into the cofig file.*/
bool CSwordModuleInfo::unlock(const QString & unlockKey) {
- if (!isEncrypted()) {
- return false;
- }
+ if (!isEncrypted()) {
+ return false;
+ }
- CBTConfig::setModuleEncryptionKey(name(), unlockKey);
- backend()->setCipherKey(m_module->Name(), unlockKey.toUtf8().constData());
- //TODO: write to Sword config as well
+ CBTConfig::setModuleEncryptionKey(name(), unlockKey);
+ backend()->setCipherKey(m_module->Name(), unlockKey.toUtf8().constData());
+ //TODO: write to Sword config as well
- return true;
+ return true;
}
/** This function returns true if this module is locked, otherwise return false. */
bool CSwordModuleInfo::isLocked() {
- //still works, but the cipherkey is stored in CBTConfig.
- //Works because it is set in sword on program startup.
+ //still works, but the cipherkey is stored in CBTConfig.
+ //Works because it is set in sword on program startup.
- if (isEncrypted()) {
- if (unlockKeyIsValid()) {
- return false;
- }
- return true;
- }
- return false;
+ if (isEncrypted()) {
+ if (unlockKeyIsValid()) {
+ return false;
+ }
+ return true;
+ }
+ return false;
}
/** This functions returns true if this module is encrypted (locked or unlocked). */
bool CSwordModuleInfo::isEncrypted() const {
- /**
- * If we have the CipherKey entry the module
- * is encrypted but not necessarily locked
- */
+ /**
+ * If we have the CipherKey entry the module
+ * is encrypted but not necessarily locked
+ */
- //This code is still right, though we do no longer write to the module config files any more
- sword::ConfigEntMap config = backend()->getConfig()->Sections.find(name().toUtf8().constData())->second;
- sword::ConfigEntMap::iterator it = config.find("CipherKey");
+ //This code is still right, though we do no longer write to the module config files any more
+ sword::ConfigEntMap config = backend()->getConfig()->Sections.find(name().toUtf8().constData())->second;
+ sword::ConfigEntMap::iterator it = config.find("CipherKey");
- if (it != config.end()) {
- return true;
- }
+ if (it != config.end()) {
+ return true;
+ }
- return false;
+ return false;
}
/** This function makes an estimate if a module was properly unlocked.
@@ -154,757 +154,773 @@ bool CSwordModuleInfo::isEncrypted() const {
*/
bool CSwordModuleInfo::unlockKeyIsValid() {
- (*m_module) = sword::TOP;
+ (*m_module) = sword::TOP;
- // This needs to use ::fromLatin1 because if the text is still locked,
- // a lot of garbage will show up. It will also work with properly decrypted
- // Unicode text, because all non-ASCII Unicode chars consist of bytes >127
- // and therefore contain no control (nonprintable) characters, which are all <127.
- QString test = isUnicode()
- ? QString::fromUtf8(m_module->getRawEntryBuf().c_str())
- : QString::fromLatin1( m_module->getRawEntryBuf().c_str() );
+ // This needs to use ::fromLatin1 because if the text is still locked,
+ // a lot of garbage will show up. It will also work with properly decrypted
+ // Unicode text, because all non-ASCII Unicode chars consist of bytes >127
+ // and therefore contain no control (nonprintable) characters, which are all <127.
+ QString test = isUnicode()
+ ? QString::fromUtf8(m_module->getRawEntryBuf().c_str())
+ : QString::fromLatin1( m_module->getRawEntryBuf().c_str() );
- if (test.isEmpty()) {
- qWarning() << "Unlock key of module" << name() << "is NOT valid!";
- return false;
- }
+ if (test.isEmpty()) {
+ qWarning() << "Unlock key of module" << name() << "is NOT valid!";
+ return false;
+ }
- for (int i = 0; i <= test.length() && i < 100; i++) {
- if ( !test[i].isPrint() && !test[i].isNull() ) {
- qWarning() << "Unlock key of module" << name() << "is NOT valid!";
- return false;
- }
- }
+ for (int i = 0; i <= test.length() && i < 100; i++) {
+ if ( !test[i].isPrint() && !test[i].isNull() ) {
+ qWarning() << "Unlock key of module" << name() << "is NOT valid!";
+ return false;
+ }
+ }
- qDebug() << "Unlock key of module" << name() << "is valid";
- return true;
+ qDebug() << "Unlock key of module" << name() << "is valid";
+ return true;
}
QString CSwordModuleInfo::getGlobalBaseIndexLocation() {
- return util::filesystem::DirectoryUtil::getUserIndexDir().absolutePath();
+ return util::filesystem::DirectoryUtil::getUserIndexDir().absolutePath();
}
QString CSwordModuleInfo::getModuleBaseIndexLocation() const {
- return getGlobalBaseIndexLocation() + QString("/") + name().toLocal8Bit();
+ return getGlobalBaseIndexLocation() + QString("/") + name().toLocal8Bit();
}
QString CSwordModuleInfo::getModuleStandardIndexLocation() const { //this for now returns the location of the main index
- return getModuleBaseIndexLocation() + QString("/standard");
+ return getModuleBaseIndexLocation() + QString("/standard");
}
bool CSwordModuleInfo::hasIndex() {
- //this will return true only
- //if the index exists and has correct version information for both index and module
- QDir d;
- if (!d.exists( getModuleStandardIndexLocation() )) {
- return false;
- }
-
- //first check if the index version and module version are ok
- QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
-
- if (hasVersion()) {
- if (module_config.value("module-version") != QString(config(CSwordModuleInfo::ModuleVersion)) ) {
- return false;
- }
- }
- if (module_config.value("index-version") != QString::number( INDEX_VERSION )) {
- qDebug("%s: INDEX_VERSION is not compatible with this version of BibleTime.", name().toUtf8().constData());
- return false;
- }
-
- //then check if the index is there
- return lucene::index::IndexReader::indexExists(getModuleStandardIndexLocation().toAscii().constData());
-}
-
+ //this will return true only
+ //if the index exists and has correct version information for both index and module
+ QDir d;
+ if (!d.exists( getModuleStandardIndexLocation() )) {
+ return false;
+ }
+
+ //first check if the index version and module version are ok
+ QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
+
+ if (hasVersion()) {
+ if (module_config.value("module-version") != QString(config(CSwordModuleInfo::ModuleVersion)) ) {
+ return false;
+ }
+ }
+ if (module_config.value("index-version") != QString::number( INDEX_VERSION )) {
+ qDebug("%s: INDEX_VERSION is not compatible with this version of BibleTime.", name().toUtf8().constData());
+ return false;
+ }
+
+ //then check if the index is there
+ return lucene::index::IndexReader::indexExists(getModuleStandardIndexLocation().toAscii().constData());
+}
+
+// HELPER Method: this dumps all current EntryAttributes of a module
+//#include <iostream>
+//void dumpEntryAttributes(sword::SWModule *module) {
+// std::cout << "Attributes for key: " << module->getKeyText() << std::endl;
+// sword::AttributeTypeList::iterator i1;
+// sword::AttributeList::iterator i2;
+// sword::AttributeValue::iterator i3;
+// for (i1 = module->getEntryAttributes().begin(); i1 != module->getEntryAttributes().end(); i1++) {
+// std::cout << "[ " << i1->first << " ]\n";
+// for (i2 = i1->second.begin(); i2 != i1->second.end(); i2++) {
+// std::cout << "\t[ " << i2->first << " ]\n";
+// for (i3 = i2->second.begin(); i3 != i2->second.end(); i3++) {
+// std::cout << "\t\t" << i3->first << " = " << i3->second << "\n";
+// }
+// }
+// }
+// std::cout << std::endl;
+//}
void CSwordModuleInfo::buildIndex() {
- m_cancelIndexing = false;
-
- try
- {
- //Without this we don't get strongs, lemmas, etc
- backend()->setFilterOptions ( CBTConfig::getFilterOptionDefaults() );
- //make sure we reset all important filter options which influcence the plain filters.
- backend()->setOption( CSwordModuleInfo::strongNumbers, false );
- backend()->setOption( CSwordModuleInfo::morphTags, false );
- backend()->setOption( CSwordModuleInfo::morphSegmentation, false );
- backend()->setOption( CSwordModuleInfo::footnotes, false );
- backend()->setOption( CSwordModuleInfo::headings, false );
- backend()->setOption( CSwordModuleInfo::scriptureReferences, false );
- backend()->setOption( CSwordModuleInfo::redLetterWords, false );
-
- // do not use any stop words
- const TCHAR* stop_words[] = { NULL };
- lucene::analysis::standard::StandardAnalyzer an( (const TCHAR**)stop_words );
- QString index = getModuleStandardIndexLocation();
-
- QDir dir("/");
- dir.mkpath( getGlobalBaseIndexLocation() );
- dir.mkpath( getModuleBaseIndexLocation() );
- dir.mkpath( getModuleStandardIndexLocation() );
-
- if (lucene::index::IndexReader::indexExists(index.toAscii().constData())) {
- if (lucene::index::IndexReader::isLocked(index.toAscii().constData()) ) {
- lucene::index::IndexReader::unlock(index.toAscii().constData());
- }
- }
-
- boost::scoped_ptr<lucene::index::IndexWriter> writer( new lucene::index::IndexWriter(index.toAscii().constData(), &an, true) ); //always create a new index
- writer->setMaxFieldLength(BT_MAX_LUCENE_FIELD_LENGTH);
- writer->setUseCompoundFile(true); //merge segments into a single file
- writer->setMinMergeDocs(1000);
-
- *m_module = sword::TOP;
- unsigned long verseLowIndex = m_module->Index();
- *m_module = sword::BOTTOM;
- unsigned long verseHighIndex = m_module->Index();
-
- //verseLowIndex is not 0 in all cases (i.e. NT-only modules)
- unsigned long verseIndex = verseLowIndex + 1;
- unsigned long verseSpan = verseHighIndex - verseLowIndex;
-
- //Index() is not implemented properly for lexicons, so we use a
- //workaround.
- if (type() == CSwordModuleInfo::Lexicon){
- verseIndex = 0;
- verseLowIndex = 0;
- verseSpan = ((CSwordLexiconModuleInfo*)this)->entries()->size();
- }
-
- emit indexingProgress(0);
-
- sword::SWKey* key = m_module->getKey();
- //VerseKey for bibles
- sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key);
-
- if (vk) {
- // we have to be sure to insert the english key into the index, otherwise we'd be in trouble if the language changes
- vk->setLocale("en_US");
- //If we have a verse based module, we want to include the pre-chapter etc. headings in the search
- vk->Headings(1);
- }
-
- //holds UTF-8 data and is faster than QString.
- QByteArray textBuffer;
-
- // we start with the first module entry, key is automatically updated
- // because key is a pointer to the modules key
- m_module->setSkipConsecutiveLinks(true);
-
- wchar_t wcharBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
-
- for (*m_module = sword::TOP; !(m_module->Error()) && !m_cancelIndexing; (*m_module)++) {
-
- //If it is a sword-heading, store in buffer and index later in Verse X:1
- if (vk) {
- if (vk->Verse() == 0) {
- textBuffer.append( m_module->StripText() );
- continue;
- }
- }
-
- boost::scoped_ptr<lucene::document::Document> doc(new lucene::document::Document());
-
- //index the key
- lucene_utf8towcs(wcharBuffer, key->getText(), BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnIndexed((const TCHAR*)_T("key"), (const TCHAR*)wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("key"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_NO)));
- // index the main text
- //at this point we have to make sure we disabled the strongs and the other options
- //so the plain filters won't include the numbers somehow.
- lucene_utf8towcs(wcharBuffer, (const char*) textBuffer.append(m_module->StripText()), BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("content"), (const TCHAR*)wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("content"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- textBuffer.resize(0); //clean up
-
- // index attributes
- sword::AttributeList::iterator attListI;
- sword::AttributeValue::iterator attValueI;
- // Footnotes
- for (attListI = m_module->getEntryAttributes()["Footnote"].begin();
- attListI != m_module->getEntryAttributes()["Footnote"].end();
- attListI++) {
- lucene_utf8towcs(wcharBuffer, attListI->second["body"], BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("footnote"), wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("footnote"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- } // for attListI
-
- // Headings
- for (attValueI = m_module->getEntryAttributes()["Heading"]["Preverse"].begin();
- attValueI != m_module->getEntryAttributes()["Heading"]["Preverse"].end();
- attValueI++) {
- lucene_utf8towcs(wcharBuffer, attValueI->second, BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("heading"), wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("heading"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- } // for attValueI
-
- // Strongs/Morphs
- for (attListI = m_module->getEntryAttributes()["Word"].begin();
- attListI != m_module->getEntryAttributes()["Word"].end();
- attListI++) {
- // for each attribute
- if (attListI->second["LemmaClass"] == "strong") {
- lucene_utf8towcs(wcharBuffer, attListI->second["Lemma"], BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("strong"), wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("strong"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- //qWarning("Adding strong %s", attListI->second["Lemma"].c_str());
- }
- if (attListI->second.find("Morph") != attListI->second.end()) {
- lucene_utf8towcs(wcharBuffer, attListI->second["Morph"], BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("morph"), wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("morph"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- }
- } // for attListI
-
- writer->addDocument(doc.get());
- //Index() is not implemented properly for lexicons, so we use a
- //workaround.
- if (type() == CSwordModuleInfo::Lexicon){
- verseIndex++;
- }
- else{
- verseIndex = m_module->Index();
- }
-
- if (verseIndex % 200 == 0) {
- int indexingProgressValue;
- if (verseSpan == 0) { //prevent division by zero
- //m_indexingProgress.setValue( QVariant(0) );
- indexingProgressValue = 0;
- } else {
- //m_indexingProgress.setValue( QVariant((int)((100*(verseIndex-verseLowIndex))/(verseHighIndex-verseLowIndex))) );
- indexingProgressValue = (int)((100*(verseIndex-verseLowIndex)) / (verseSpan));
- }
- //m_indexingProgress.activate();
- emit indexingProgress(indexingProgressValue);
- }
- }
-
- if (!m_cancelIndexing)
- {
- writer->optimize();
- }
- writer->close();
-
- if (m_cancelIndexing){
- deleteIndexForModule(name());
- m_cancelIndexing = false;
- }
- else
- {
- QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
- if (hasVersion()) module_config.setValue("module-version", config(CSwordModuleInfo::ModuleVersion) );
- module_config.setValue("index-version", INDEX_VERSION );
- }
- }
- catch(...)
- {
- qWarning("CLucene exception occurred while indexing");
- QMessageBox::warning(0, QCoreApplication::tr("Indexing aborted"), QCoreApplication::tr("An internal error occurred while building the index."));
- deleteIndexForModule(name());
- m_cancelIndexing = false;
- }
+ m_cancelIndexing = false;
+
+ try {
+ //Without this we don't get strongs, lemmas, etc
+ backend()->setFilterOptions ( CBTConfig::getFilterOptionDefaults() );
+ //make sure we reset all important filter options which influcence the plain filters.
+ // turn on these options, they are needed for the EntryAttributes population
+ backend()->setOption( CSwordModuleInfo::strongNumbers, true );
+ backend()->setOption( CSwordModuleInfo::morphTags, true );
+ backend()->setOption( CSwordModuleInfo::footnotes, true );
+ backend()->setOption( CSwordModuleInfo::headings, true );
+ // we don't want the following in the text, the do not carry searchable information
+ backend()->setOption( CSwordModuleInfo::morphSegmentation, false );
+ backend()->setOption( CSwordModuleInfo::scriptureReferences, false );
+ backend()->setOption( CSwordModuleInfo::redLetterWords, false );
+
+ // do not use any stop words
+ const TCHAR* stop_words[] = { NULL };
+ lucene::analysis::standard::StandardAnalyzer an( (const TCHAR**)stop_words );
+ QString index = getModuleStandardIndexLocation();
+
+ QDir dir("/");
+ dir.mkpath( getGlobalBaseIndexLocation() );
+ dir.mkpath( getModuleBaseIndexLocation() );
+ dir.mkpath( getModuleStandardIndexLocation() );
+
+ if (lucene::index::IndexReader::indexExists(index.toAscii().constData())) {
+ if (lucene::index::IndexReader::isLocked(index.toAscii().constData()) ) {
+ lucene::index::IndexReader::unlock(index.toAscii().constData());
+ }
+ }
+
+ boost::scoped_ptr<lucene::index::IndexWriter> writer( new lucene::index::IndexWriter(index.toAscii().constData(), &an, true) ); //always create a new index
+ writer->setMaxFieldLength(BT_MAX_LUCENE_FIELD_LENGTH);
+ writer->setUseCompoundFile(true); //merge segments into a single file
+ writer->setMinMergeDocs(1000);
+
+ *m_module = sword::TOP;
+ unsigned long verseLowIndex = m_module->Index();
+ *m_module = sword::BOTTOM;
+ unsigned long verseHighIndex = m_module->Index();
+
+ //verseLowIndex is not 0 in all cases (i.e. NT-only modules)
+ unsigned long verseIndex = verseLowIndex + 1;
+ unsigned long verseSpan = verseHighIndex - verseLowIndex;
+
+ //Index() is not implemented properly for lexicons, so we use a
+ //workaround.
+ if (type() == CSwordModuleInfo::Lexicon) {
+ verseIndex = 0;
+ verseLowIndex = 0;
+ verseSpan = ((CSwordLexiconModuleInfo*)this)->entries()->size();
+ }
+
+ emit indexingProgress(0);
+
+ sword::SWKey* key = m_module->getKey();
+ //VerseKey for bibles
+ sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key);
+
+ if (vk) {
+ // we have to be sure to insert the english key into the index, otherwise we'd be in trouble if the language changes
+ vk->setLocale("en_US");
+ //If we have a verse based module, we want to include the pre-chapter etc. headings in the search
+ vk->Headings(1);
+ }
+
+ //holds UTF-8 data and is faster than QString.
+ QByteArray textBuffer;
+
+ // we start with the first module entry, key is automatically updated
+ // because key is a pointer to the modules key
+ m_module->setSkipConsecutiveLinks(true);
+
+ wchar_t wcharBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
+
+ for (*m_module = sword::TOP; !(m_module->Error()) && !m_cancelIndexing; (*m_module)++) {
+
+ // Also index Chapter 0 and Verse 0, because they might have information in the entry attributes
+ // We used to just put their content into the textBuffer and continue to the next verse, but
+ // with entry attributes this doesn't work any more.
+ // Hits in the search dialog will show up as 1:1 (instead of 0)
+
+ boost::scoped_ptr<lucene::document::Document> doc(new lucene::document::Document());
+
+ //index the key
+ lucene_utf8towcs(wcharBuffer, key->getText(), BT_MAX_LUCENE_FIELD_LENGTH);
+
+ //doc->add(*lucene::document::Field::UnIndexed((const TCHAR*)_T("key"), (const TCHAR*)wcharBuffer));
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("key"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_NO)));
+
+ // index the main text
+ //at this point we have to make sure we disabled the strongs and the other options
+ //so the plain filters won't include the numbers somehow.
+ lucene_utf8towcs(wcharBuffer, (const char*) textBuffer.append(m_module->StripText()), BT_MAX_LUCENE_FIELD_LENGTH);
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("content"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
+ textBuffer.resize(0); //clean up
+
+ // index attributes
+ sword::AttributeList::iterator attListI;
+ sword::AttributeValue::iterator attValueI;
+ // Footnotes
+ for (attListI = m_module->getEntryAttributes()["Footnote"].begin();
+ attListI != m_module->getEntryAttributes()["Footnote"].end();
+ attListI++) {
+ lucene_utf8towcs(wcharBuffer, attListI->second["body"], BT_MAX_LUCENE_FIELD_LENGTH);
+ //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("footnote"), wcharBuffer));
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("footnote"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
+ } // for attListI
+
+ // Headings
+ for (attValueI = m_module->getEntryAttributes()["Heading"]["Preverse"].begin();
+ attValueI != m_module->getEntryAttributes()["Heading"]["Preverse"].end();
+ attValueI++) {
+ lucene_utf8towcs(wcharBuffer, attValueI->second, BT_MAX_LUCENE_FIELD_LENGTH);
+ //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("heading"), wcharBuffer));
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("heading"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
+ } // for attValueI
+
+ // Strongs/Morphs
+ for (attListI = m_module->getEntryAttributes()["Word"].begin();
+ attListI != m_module->getEntryAttributes()["Word"].end();
+ attListI++) {
+ // for each attribute
+ if (attListI->second["LemmaClass"] == "strong") {
+ lucene_utf8towcs(wcharBuffer, attListI->second["Lemma"], BT_MAX_LUCENE_FIELD_LENGTH);
+ //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("strong"), wcharBuffer));
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("strong"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
+ //qWarning("Adding strong %s", attListI->second["Lemma"].c_str());
+ }
+ if (attListI->second.find("Morph") != attListI->second.end()) {
+ lucene_utf8towcs(wcharBuffer, attListI->second["Morph"], BT_MAX_LUCENE_FIELD_LENGTH);
+ //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("morph"), wcharBuffer));
+ doc->add(*(new lucene::document::Field((const TCHAR*)_T("morph"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
+ }
+ } // for attListI
+
+ writer->addDocument(doc.get());
+ //Index() is not implemented properly for lexicons, so we use a
+ //workaround.
+ if (type() == CSwordModuleInfo::Lexicon) {
+ verseIndex++;
+ }
+ else {
+ verseIndex = m_module->Index();
+ }
+
+ if (verseIndex % 200 == 0) {
+ int indexingProgressValue;
+ if (verseSpan == 0) { //prevent division by zero
+ //m_indexingProgress.setValue( QVariant(0) );
+ indexingProgressValue = 0;
+ }
+ else {
+ //m_indexingProgress.setValue( QVariant((int)((100*(verseIndex-verseLowIndex))/(verseHighIndex-verseLowIndex))) );
+ indexingProgressValue = (int)((100 * (verseIndex - verseLowIndex)) / (verseSpan));
+ }
+ //m_indexingProgress.activate();
+ emit indexingProgress(indexingProgressValue);
+ }
+ }
+
+ if (!m_cancelIndexing) {
+ writer->optimize();
+ }
+ writer->close();
+
+ if (m_cancelIndexing) {
+ deleteIndexForModule(name());
+ m_cancelIndexing = false;
+ }
+ else {
+ QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
+ if (hasVersion()) module_config.setValue("module-version", config(CSwordModuleInfo::ModuleVersion) );
+ module_config.setValue("index-version", INDEX_VERSION );
+ }
+ }
+ catch (...) {
+ qWarning("CLucene exception occurred while indexing");
+ QMessageBox::warning(0, QCoreApplication::tr("Indexing aborted"), QCoreApplication::tr("An internal error occurred while building the index."));
+ deleteIndexForModule(name());
+ m_cancelIndexing = false;
+ }
}
void CSwordModuleInfo::deleteIndexForModule( QString name ) {
- util::filesystem::DirectoryUtil::removeRecursive( getGlobalBaseIndexLocation() + "/" + name );
+ util::filesystem::DirectoryUtil::removeRecursive( getGlobalBaseIndexLocation() + "/" + name );
}
unsigned long CSwordModuleInfo::indexSize() const {
- return util::filesystem::DirectoryUtil::getDirSizeRecursive( getModuleBaseIndexLocation() );
+ return util::filesystem::DirectoryUtil::getDirSizeRecursive( getModuleBaseIndexLocation() );
}
bool CSwordModuleInfo::searchIndexed(const QString& searchedText, sword::ListKey& scope) {
- char utfBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
- wchar_t wcharBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
+ char utfBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
+ wchar_t wcharBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
- // work around Swords thread insafety for Bibles and Commentaries
- boost::scoped_ptr < CSwordKey > key(CSwordKey::createInstance(this));
- sword::SWKey* s = dynamic_cast < sword::SWKey * >(key.get());
- QList<sword::VerseKey*> list;
+ // work around Swords thread insafety for Bibles and Commentaries
+ boost::scoped_ptr < CSwordKey > key(CSwordKey::createInstance(this));
+ sword::SWKey* s = dynamic_cast < sword::SWKey * >(key.get());
+ QList<sword::VerseKey*> list;
- if (s) {
- m_module->SetKey(*s);
- }
+ if (s) {
+ m_module->SetKey(*s);
+ }
- m_searchResult.ClearList();
+ m_searchResult.ClearList();
- try {
- // do not use any stop words
- const TCHAR* stop_words[] = { NULL };
- lucene::analysis::standard::StandardAnalyzer analyzer( stop_words );
- lucene::search::IndexSearcher searcher(getModuleStandardIndexLocation().toAscii().constData());
- lucene_utf8towcs(wcharBuffer, searchedText.toUtf8().constData(), BT_MAX_LUCENE_FIELD_LENGTH);
- boost::scoped_ptr<lucene::search::Query> q( lucene::queryParser::QueryParser::parse((const TCHAR*)wcharBuffer, (const TCHAR*)_T("content"), &analyzer) );
+ try {
+ // do not use any stop words
+ const TCHAR* stop_words[] = { NULL };
+ lucene::analysis::standard::StandardAnalyzer analyzer( stop_words );
+ lucene::search::IndexSearcher searcher(getModuleStandardIndexLocation().toAscii().constData());
+ lucene_utf8towcs(wcharBuffer, searchedText.toUtf8().constData(), BT_MAX_LUCENE_FIELD_LENGTH);
+ boost::scoped_ptr<lucene::search::Query> q( lucene::queryParser::QueryParser::parse((const TCHAR*)wcharBuffer, (const TCHAR*)_T("content"), &analyzer) );
- boost::scoped_ptr<lucene::search::Hits> h( searcher.search(q.get(), lucene::search::Sort::INDEXORDER) );
+ boost::scoped_ptr<lucene::search::Hits> h( searcher.search(q.get(), lucene::search::Sort::INDEXORDER) );
- const bool useScope = (scope.Count() > 0);
+ const bool useScope = (scope.Count() > 0);
// const bool isVerseModule = (type() == CSwordModuleInfo::Bible) || (type() == CSwordModuleInfo::Commentary);
- lucene::document::Document* doc = 0;
- boost::scoped_ptr<sword::SWKey> swKey( module()->CreateKey() );
+ lucene::document::Document* doc = 0;
+ boost::scoped_ptr<sword::SWKey> swKey( module()->CreateKey() );
- for (int i = 0; i < h->length(); ++i) {
- doc = &h->doc(i);
- lucene_wcstoutf8(utfBuffer, (const wchar_t*)doc->get((const TCHAR*)_T("key")), BT_MAX_LUCENE_FIELD_LENGTH);
+ for (int i = 0; i < h->length(); ++i) {
+ doc = &h->doc(i);
+ lucene_wcstoutf8(utfBuffer, (const wchar_t*)doc->get((const TCHAR*)_T("key")), BT_MAX_LUCENE_FIELD_LENGTH);
- swKey->setText(utfBuffer);
+ swKey->setText(utfBuffer);
- // limit results based on scope
- //if (searchOptions & CSwordModuleSearch::useScope && scope.Count() > 0){
- if (useScope) {
- for (int j = 0; j < scope.Count(); j++) {
- sword::VerseKey* vkey = dynamic_cast<sword::VerseKey*>(scope.getElement(j));
- if (vkey->LowerBound().compare(*swKey) <= 0 && vkey->UpperBound().compare(*swKey) >= 0) {
- m_searchResult.add(*swKey);
- }
- }
- } else { // no scope, give me all buffers
- m_searchResult.add(*swKey);
- }
- }
- }
- catch (...) {
- qWarning("CLucene exception occurred");
- QMessageBox::warning(0, QCoreApplication::tr("Search aborted"), QCoreApplication::tr("An internal error occurred while executing your search."));
- return false;
- }
+ // limit results based on scope
+ //if (searchOptions & CSwordModuleSearch::useScope && scope.Count() > 0){
+ if (useScope) {
+ for (int j = 0; j < scope.Count(); j++) {
+ sword::VerseKey* vkey = dynamic_cast<sword::VerseKey*>(scope.getElement(j));
+ if (vkey->LowerBound().compare(*swKey) <= 0 && vkey->UpperBound().compare(*swKey) >= 0) {
+ m_searchResult.add(*swKey);
+ }
+ }
+ }
+ else { // no scope, give me all buffers
+ m_searchResult.add(*swKey);
+ }
+ }
+ }
+ catch (...) {
+ qWarning("CLucene exception occurred");
+ QMessageBox::warning(0, QCoreApplication::tr("Search aborted"), QCoreApplication::tr("An internal error occurred while executing your search."));
+ return false;
+ }
- qDeleteAll(list);
- list.clear();
+ qDeleteAll(list);
+ list.clear();
- return (m_searchResult.Count() > 0);
+ return (m_searchResult.Count() > 0);
}
/** Returns the last search result for this module. */
sword::ListKey & CSwordModuleInfo::searchResult(const sword::ListKey * newResult) {
- if (newResult) {
- m_searchResult.copyFrom(*newResult);
- }
+ if (newResult) {
+ m_searchResult.copyFrom(*newResult);
+ }
- return m_searchResult;
+ return m_searchResult;
}
/** Clears the last search result. */
void CSwordModuleInfo::clearSearchResult() {
- m_searchResult.ClearList();
+ m_searchResult.ClearList();
}
/** Returns the required Sword version for this module. Returns -1 if no special Sword version is required. */
sword::SWVersion CSwordModuleInfo::minimumSwordVersion() {
- return sword::SWVersion(config(CSwordModuleInfo::MinimumSwordVersion).toUtf8().constData());
+ return sword::SWVersion(config(CSwordModuleInfo::MinimumSwordVersion).toUtf8().constData());
}
QString CSwordModuleInfo::config(const CSwordModuleInfo::ConfigEntry entry) const {
- switch (entry) {
+ switch (entry) {
- case AboutInformation:
- return getFormattedConfigEntry("About");
+ case AboutInformation:
+ return getFormattedConfigEntry("About");
- case CipherKey: {
- if (CBTConfig::getModuleEncryptionKey(name()).isNull()) { //fall back!
- return QString(m_module->getConfigEntry("CipherKey"));
- }
- else {
- return CBTConfig::getModuleEncryptionKey(name());
- }
- }
+ case CipherKey: {
+ if (CBTConfig::getModuleEncryptionKey(name()).isNull()) { //fall back!
+ return QString(m_module->getConfigEntry("CipherKey"));
+ }
+ else {
+ return CBTConfig::getModuleEncryptionKey(name());
+ }
+ }
- case AbsoluteDataPath: {
- QString path( getSimpleConfigEntry("AbsoluteDataPath") );
- path.replace(QRegExp("/./"), "/"); // make /abs/path/./modules/ looking better
- //make sure we have a trailing slash!
+ case AbsoluteDataPath: {
+ QString path( getSimpleConfigEntry("AbsoluteDataPath") );
+ path.replace(QRegExp("/./"), "/"); // make /abs/path/./modules/ looking better
+ //make sure we have a trailing slash!
- if (path.right(1) != "/") {
- path.append('/');
- }
+ if (path.right(1) != "/") {
+ path.append('/');
+ }
- return path;
- }
+ return path;
+ }
- case DataPath: { //make sure we remove the dataFile part if it's a Lexicon
- QString path(getSimpleConfigEntry("DataPath"));
+ case DataPath: { //make sure we remove the dataFile part if it's a Lexicon
+ QString path(getSimpleConfigEntry("DataPath"));
- if ((type() == CSwordModuleInfo::GenericBook) || (type() == CSwordModuleInfo::Lexicon)) {
- int pos = path.lastIndexOf("/"); //last slash in the string
+ if ((type() == CSwordModuleInfo::GenericBook) || (type() == CSwordModuleInfo::Lexicon)) {
+ int pos = path.lastIndexOf("/"); //last slash in the string
- if (pos != -1) {
- path = path.left(pos + 1); //include the slash
- }
- }
+ if (pos != -1) {
+ path = path.left(pos + 1); //include the slash
+ }
+ }
- return path;
- }
+ return path;
+ }
- case Description:
- return getFormattedConfigEntry("Description");
+ case Description:
+ return getFormattedConfigEntry("Description");
- case ModuleVersion: {
- QString version(getSimpleConfigEntry("Version"));
+ case ModuleVersion: {
+ QString version(getSimpleConfigEntry("Version"));
- if (version.isEmpty()) {
- version = "1.0";
- }
+ if (version.isEmpty()) {
+ version = "1.0";
+ }
- return version;
- }
+ return version;
+ }
- case MinimumSwordVersion: {
- const QString minimumVersion(getSimpleConfigEntry("MinimumVersion"));
- return !minimumVersion.isEmpty()? minimumVersion : QString("0.0");
- }
+ case MinimumSwordVersion: {
+ const QString minimumVersion(getSimpleConfigEntry("MinimumVersion"));
+ return !minimumVersion.isEmpty() ? minimumVersion : QString("0.0");
+ }
- case TextDir: {
- const QString dir(getSimpleConfigEntry("Direction"));
- return !dir.isEmpty()? dir : QString("LtoR");
- }
+ case TextDir: {
+ const QString dir(getSimpleConfigEntry("Direction"));
+ return !dir.isEmpty() ? dir : QString("LtoR");
+ }
- case DisplayLevel: {
- const QString level(getSimpleConfigEntry("DisplayLevel"));
- return !level.isEmpty()? level : QString("1");
- }
+ case DisplayLevel: {
+ const QString level(getSimpleConfigEntry("DisplayLevel"));
+ return !level.isEmpty() ? level : QString("1");
+ }
- case GlossaryFrom: {
- if (!category() == Glossary) {
- return QString::null;
- };
+ case GlossaryFrom: {
+ if (category() != Glossary) {
+ return QString::null;
+ };
- const QString lang(getSimpleConfigEntry("GlossaryFrom"));
+ const QString lang(getSimpleConfigEntry("GlossaryFrom"));
- return !lang.isEmpty()? lang : QString::null;
- }
+ return !lang.isEmpty() ? lang : QString::null;
+ }
- case GlossaryTo: {
- if (!category() == Glossary) {
- return QString::null;
- };
+ case GlossaryTo: {
+ if (category() != Glossary) {
+ return QString::null;
+ };
- const QString lang(getSimpleConfigEntry("GlossaryTo"));
+ const QString lang(getSimpleConfigEntry("GlossaryTo"));
- return !lang.isEmpty()? lang : QString::null;
- }
+ return !lang.isEmpty() ? lang : QString::null;
+ }
- case Markup: {
- const QString markup(getSimpleConfigEntry("SourceType"));
- return !markup.isEmpty()? markup : QString("Unknown");
- }
+ case Markup: {
+ const QString markup(getSimpleConfigEntry("SourceType"));
+ return !markup.isEmpty() ? markup : QString("Unknown");
+ }
- case DistributionLicense:
- return getSimpleConfigEntry("DistributionLicense");
+ case DistributionLicense:
+ return getSimpleConfigEntry("DistributionLicense");
- case DistributionSource:
- return getSimpleConfigEntry("DistributionSource");
+ case DistributionSource:
+ return getSimpleConfigEntry("DistributionSource");
- case DistributionNotes:
- return getSimpleConfigEntry("DistributionNotes");
+ case DistributionNotes:
+ return getSimpleConfigEntry("DistributionNotes");
- case TextSource:
- return getSimpleConfigEntry("TextSource");
+ case TextSource:
+ return getSimpleConfigEntry("TextSource");
- case CopyrightNotes:
- return getSimpleConfigEntry("CopyrightNotes");
+ case CopyrightNotes:
+ return getSimpleConfigEntry("CopyrightNotes");
- case CopyrightHolder:
- return getSimpleConfigEntry("CopyrightHolder");
+ case CopyrightHolder:
+ return getSimpleConfigEntry("CopyrightHolder");
- case CopyrightDate:
- return getSimpleConfigEntry("CopyrightDate");
+ case CopyrightDate:
+ return getSimpleConfigEntry("CopyrightDate");
- case CopyrightContactName:
- return getSimpleConfigEntry("CopyrightContactName");
+ case CopyrightContactName:
+ return getSimpleConfigEntry("CopyrightContactName");
- case CopyrightContactAddress:
- return getSimpleConfigEntry("CopyrightContactAddress");
+ case CopyrightContactAddress:
+ return getSimpleConfigEntry("CopyrightContactAddress");
- case CopyrightContactEmail:
- return getSimpleConfigEntry("CopyrightContactEmail");
+ case CopyrightContactEmail:
+ return getSimpleConfigEntry("CopyrightContactEmail");
- default:
- return QString::null;
- }
+ default:
+ return QString::null;
+ }
}
/** Returns true if the module supports the feature given as parameter. */
bool CSwordModuleInfo::has(const CSwordModuleInfo::Feature feature) const {
- switch (feature) {
+ switch (feature) {
- // case StrongsNumbers:
- // return m_module->getConfig().has("Feature", "StrongsNumber");
+ // case StrongsNumbers:
+ // return m_module->getConfig().has("Feature", "StrongsNumber");
- case GreekDef:
- return m_module->getConfig().has("Feature", "GreekDef");
+ case GreekDef:
+ return m_module->getConfig().has("Feature", "GreekDef");
- case HebrewDef:
- return m_module->getConfig().has("Feature", "HebrewDef");
+ case HebrewDef:
+ return m_module->getConfig().has("Feature", "HebrewDef");
- case GreekParse:
- return m_module->getConfig().has("Feature", "GreekParse");
+ case GreekParse:
+ return m_module->getConfig().has("Feature", "GreekParse");
- case HebrewParse:
- return m_module->getConfig().has("Feature", "HebrewParse");
- }
+ case HebrewParse:
+ return m_module->getConfig().has("Feature", "HebrewParse");
+ }
- return false;
+ return false;
}
bool CSwordModuleInfo::has(const CSwordModuleInfo::FilterTypes option) const {
- //BAD workaround to see if the filter is GBF, OSIS or ThML!
- const QString name = backend()->configOptionName(option);
+ //BAD workaround to see if the filter is GBF, OSIS or ThML!
+ const QString name = backend()->configOptionName(option);
- if (m_module->getConfig().has("GlobalOptionFilter", QString("OSIS").append(name).toUtf8().constData())) {
- return true;
- }
+ if (m_module->getConfig().has("GlobalOptionFilter", QString("OSIS").append(name).toUtf8().constData())) {
+ return true;
+ }
- if (m_module->getConfig().has("GlobalOptionFilter", QString("GBF").append(name).toUtf8().constData())) {
- return true;
- }
+ if (m_module->getConfig().has("GlobalOptionFilter", QString("GBF").append(name).toUtf8().constData())) {
+ return true;
+ }
- if (m_module->getConfig().has("GlobalOptionFilter", QString("ThML").append(name).toUtf8().constData())) {
- return true;
- }
+ if (m_module->getConfig().has("GlobalOptionFilter", QString("ThML").append(name).toUtf8().constData())) {
+ return true;
+ }
- if (m_module->getConfig().has("GlobalOptionFilter", QString("UTF8").append(name).toUtf8().constData())) {
- return true;
- }
+ if (m_module->getConfig().has("GlobalOptionFilter", QString("UTF8").append(name).toUtf8().constData())) {
+ return true;
+ }
- if (m_module->getConfig().has("GlobalOptionFilter", name.toUtf8().constData())) {
- return true;
- }
+ if (m_module->getConfig().has("GlobalOptionFilter", name.toUtf8().constData())) {
+ return true;
+ }
- return false;
+ return false;
}
/** Returns the text direction of the module's text., */
CSwordModuleInfo::TextDirection CSwordModuleInfo::textDirection() {
- if (config(TextDir) == "RtoL") {
- return CSwordModuleInfo::RightToLeft;
- }
- else {
- return CSwordModuleInfo::LeftToRight;
- }
+ if (config(TextDir) == "RtoL") {
+ return CSwordModuleInfo::RightToLeft;
+ }
+ else {
+ return CSwordModuleInfo::LeftToRight;
+ }
}
/** Writes the new text at the given position into the module. This does only work for writable modules. */
void CSwordModuleInfo::write(CSwordKey * key, const QString & newText) {
- module()->KeyText(key->key().toUtf8().constData());
+ module()->KeyText(key->key().toUtf8().constData());
- //don't store a pointer to the const char* value somewhere because QCString doesn't keep the value of it
- module()->setEntry(isUnicode()? newText.toUtf8().constData() : newText.toLocal8Bit().constData());
+ //don't store a pointer to the const char* value somewhere because QCString doesn't keep the value of it
+ module()->setEntry(isUnicode() ? newText.toUtf8().constData() : newText.toLocal8Bit().constData());
}
/** Deletes the current entry and removes it from the module. */
bool CSwordModuleInfo::deleteEntry(CSwordKey * const key) {
- module()->KeyText(isUnicode()? key->key().toUtf8().constData() : key->key().toLocal8Bit().constData());
+ module()->KeyText(isUnicode() ? key->key().toUtf8().constData() : key->key().toLocal8Bit().constData());
- if (module()) {
- module()->deleteEntry();
- return true;
- }
+ if (module()) {
+ module()->deleteEntry();
+ return true;
+ }
- return false;
+ return false;
}
/** Returns the category of this module. See CSwordModuleInfo::Category for possible values. */
CSwordModuleInfo::Category CSwordModuleInfo::category() const {
- //qDebug("CSwordModuleInfo::category");
- if (m_dataCache.category == CSwordModuleInfo::UnknownCategory) {
- const QString cat(m_module->getConfigEntry("Category"));
- //qDebug() << "the category was unknown, add a category "<< cat << "for module" << m_module->Name();
-
- if (cat == "Cults / Unorthodox / Questionable Material") {
- m_dataCache.category = Cult;
- }
- else if (cat == "Daily Devotional" || m_module->getConfig().has("Feature", "DailyDevotion")) {
- m_dataCache.category = DailyDevotional;
- }
- else if (cat == "Glossaries" || m_module->getConfig().has("Feature", "Glossary")) { //allow both
- m_dataCache.category = Glossary;
- }
- else if (cat == "Images" || cat == "Maps") {
- m_dataCache.category = Images;
- }
- else if (type() == Commentary) {
- m_dataCache.category = Commentaries;
- }
- else if (type() == Bible) {
- m_dataCache.category = Bibles;
- }
- else if (type() == Lexicon) {
- m_dataCache.category = Lexicons;
- }
- else if (type() == GenericBook) {
- m_dataCache.category = Books;
- }
- }
- //qDebug() << "assigned category: " << m_dataCache.category;
- return m_dataCache.category;
+ //qDebug("CSwordModuleInfo::category");
+ if (m_dataCache.category == CSwordModuleInfo::UnknownCategory) {
+ const QString cat(m_module->getConfigEntry("Category"));
+ //qDebug() << "the category was unknown, add a category "<< cat << "for module" << m_module->Name();
+
+ if (cat == "Cults / Unorthodox / Questionable Material") {
+ m_dataCache.category = Cult;
+ }
+ else if (cat == "Daily Devotional" || m_module->getConfig().has("Feature", "DailyDevotion")) {
+ m_dataCache.category = DailyDevotional;
+ }
+ else if (cat == "Glossaries" || m_module->getConfig().has("Feature", "Glossary")) { //allow both
+ m_dataCache.category = Glossary;
+ }
+ else if (cat == "Images" || cat == "Maps") {
+ m_dataCache.category = Images;
+ }
+ else if (type() == Commentary) {
+ m_dataCache.category = Commentaries;
+ }
+ else if (type() == Bible) {
+ m_dataCache.category = Bibles;
+ }
+ else if (type() == Lexicon) {
+ m_dataCache.category = Lexicons;
+ }
+ else if (type() == GenericBook) {
+ m_dataCache.category = Books;
+ }
+ }
+ //qDebug() << "assigned category: " << m_dataCache.category;
+ return m_dataCache.category;
}
/** Returns the display object for this module. */
Rendering::CEntryDisplay * CSwordModuleInfo::getDisplay() const {
- return dynamic_cast < Rendering::CEntryDisplay * >(m_module->Disp());
+ return dynamic_cast < Rendering::CEntryDisplay * >(m_module->Disp());
}
QString CSwordModuleInfo::aboutText() const {
- QString text;
- text += "<table>";
+ QString text;
+ text += "<table>";
- text += QString("<tr><td><b>%1</b></td><td>%2</td><tr>")
- .arg(tr("Version"))
- .arg(hasVersion()? config(CSwordModuleInfo::ModuleVersion) : tr("unknown"));
+ text += QString("<tr><td><b>%1</b></td><td>%2</td><tr>")
+ .arg(tr("Version"))
+ .arg(hasVersion() ? config(CSwordModuleInfo::ModuleVersion) : tr("unknown"));
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Markup"))
- .arg(!QString(m_module->getConfigEntry("SourceType")).isEmpty()? QString(m_module->
- getConfigEntry("SourceType")) : tr("unknown"));
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Markup"))
+ .arg(!QString(m_module->getConfigEntry("SourceType")).isEmpty() ? QString(m_module->
+ getConfigEntry("SourceType")) : tr("unknown"));
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Location"))
- .arg(config(CSwordModuleInfo::AbsoluteDataPath));
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Location"))
+ .arg(config(CSwordModuleInfo::AbsoluteDataPath));
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Language"))
- .arg(language()->translatedName());
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Language"))
+ .arg(language()->translatedName());
- if (m_module->getConfigEntry("Category"))
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Category"))
- .arg(m_module->getConfigEntry("Category"));
+ if (m_module->getConfigEntry("Category"))
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Category"))
+ .arg(m_module->getConfigEntry("Category"));
- if (m_module->getConfigEntry("LCSH"))
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("LCSH"))
- .arg(m_module->getConfigEntry("LCSH"));
+ if (m_module->getConfigEntry("LCSH"))
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("LCSH"))
+ .arg(m_module->getConfigEntry("LCSH"));
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Writable"))
- .arg(isWritable()? tr("yes") : tr("no"));
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Writable"))
+ .arg(isWritable() ? tr("yes") : tr("no"));
- if (isEncrypted())
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Unlock key"))
- .arg(config(CSwordModuleInfo::CipherKey));
+ if (isEncrypted())
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Unlock key"))
+ .arg(config(CSwordModuleInfo::CipherKey));
- QString options;
+ QString options;
- unsigned int opts;
+ unsigned int opts;
- for (opts = CSwordModuleInfo::filterTypesMIN; opts <= CSwordModuleInfo::filterTypesMAX; ++opts) {
- if (has(static_cast < CSwordModuleInfo::FilterTypes > (opts))) {
- if (!options.isEmpty()) {
- options += QString::fromLatin1(", ");
- }
+ for (opts = CSwordModuleInfo::filterTypesMIN; opts <= CSwordModuleInfo::filterTypesMAX; ++opts) {
+ if (has(static_cast < CSwordModuleInfo::FilterTypes > (opts))) {
+ if (!options.isEmpty()) {
+ options += QString::fromLatin1(", ");
+ }
- options += CSwordBackend::translatedOptionName(static_cast < CSwordModuleInfo::FilterTypes > (opts));
- }
- }
+ options += CSwordBackend::translatedOptionName(static_cast < CSwordModuleInfo::FilterTypes > (opts));
+ }
+ }
- if (!options.isEmpty()) {
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Features"))
- .arg(options);
- }
+ if (!options.isEmpty()) {
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(tr("Features"))
+ .arg(options);
+ }
- text += "</table><hr>";
+ text += "</table><hr>";
- if (category() == Cult) //clearly say the module contains cult/questionable materials
- text += QString("<br/><b>%1</b><br/><br/>")
- .arg(tr("Take care, this work contains cult / questionable material!"));
+ if (category() == Cult) //clearly say the module contains cult/questionable materials
+ text += QString("<br/><b>%1</b><br/><br/>")
+ .arg(tr("Take care, this work contains cult / questionable material!"));
- text += QString("<b>%1:</b><br>%2</font>")
- .arg(tr("About"))
- .arg(config(AboutInformation));
+ text += QString("<b>%1:</b><br>%2</font>")
+ .arg(tr("About"))
+ .arg(config(AboutInformation));
- typedef QList<CSwordModuleInfo::ConfigEntry> ListConfigEntry;
+ typedef QList<CSwordModuleInfo::ConfigEntry> ListConfigEntry;
- ListConfigEntry entries;
+ ListConfigEntry entries;
- entries.append(DistributionLicense);
+ entries.append(DistributionLicense);
- entries.append(DistributionSource);
+ entries.append(DistributionSource);
- entries.append(DistributionNotes);
+ entries.append(DistributionNotes);
- entries.append(TextSource);
+ entries.append(TextSource);
- entries.append(CopyrightNotes);
+ entries.append(CopyrightNotes);
- entries.append(CopyrightHolder);
+ entries.append(CopyrightHolder);
- entries.append(CopyrightDate);
+ entries.append(CopyrightDate);
- entries.append(CopyrightContactName);
+ entries.append(CopyrightContactName);
- entries.append(CopyrightContactAddress);
+ entries.append(CopyrightContactAddress);
- entries.append(CopyrightContactEmail);
+ entries.append(CopyrightContactEmail);
- typedef QMap<CSwordModuleInfo::ConfigEntry, QString> MapConfigEntry;
+ typedef QMap<CSwordModuleInfo::ConfigEntry, QString> MapConfigEntry;
- MapConfigEntry entryMap;
+ MapConfigEntry entryMap;
- entryMap[DistributionLicense] = tr("Distribution license");
+ entryMap[DistributionLicense] = tr("Distribution license");
- entryMap[DistributionSource] = tr("Distribution source");
+ entryMap[DistributionSource] = tr("Distribution source");
- entryMap[DistributionNotes] = tr("Distribution notes");
+ entryMap[DistributionNotes] = tr("Distribution notes");
- entryMap[TextSource] = tr("Text source");
+ entryMap[TextSource] = tr("Text source");
- entryMap[CopyrightNotes] = tr("Copyright notes");
+ entryMap[CopyrightNotes] = tr("Copyright notes");
- entryMap[CopyrightHolder] = tr("Copyright holder");
+ entryMap[CopyrightHolder] = tr("Copyright holder");
- entryMap[CopyrightDate] = tr("Copyright date");
+ entryMap[CopyrightDate] = tr("Copyright date");
- entryMap[CopyrightContactName] = tr("Copyright contact name");
+ entryMap[CopyrightContactName] = tr("Copyright contact name");
- entryMap[CopyrightContactAddress] = tr("Copyright contact address");
+ entryMap[CopyrightContactAddress] = tr("Copyright contact address");
- entryMap[CopyrightContactEmail] = tr("Copyright contact email");
+ entryMap[CopyrightContactEmail] = tr("Copyright contact email");
- text += ("<hr><table>");
+ text += ("<hr><table>");
- for (ListConfigEntry::iterator it(entries.begin()); it != entries.end(); ++it) {
- QString t( config(*it) );
+ for (ListConfigEntry::iterator it(entries.begin()); it != entries.end(); ++it) {
+ QString t( config(*it) );
- if (!t.isEmpty()) {
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(entryMap[*it])
- .arg(config(*it));
- }
+ if (!t.isEmpty()) {
+ text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ .arg(entryMap[*it])
+ .arg(config(*it));
+ }
- }
+ }
- text += "</table></font>";
+ text += "</table></font>";
- return text;
+ return text;
}
/** Returns the language of the module. */
const CLanguageMgr::Language* CSwordModuleInfo::language() const {
- if (!m_dataCache.language) {
- if (module()) {
- if (category() == Glossary) {
- //special handling for glossaries, we use the "from language" as language for the module
- m_dataCache.language = (CPointers::languageMgr())->languageForAbbrev(config(GlossaryFrom));
- }
- else {
- m_dataCache.language = (CPointers::languageMgr())->languageForAbbrev(module()->Lang());
- }
- }
- else {
- m_dataCache.language = (CPointers::languageMgr())->defaultLanguage(); //default language
- }
- }
+ if (!m_dataCache.language) {
+ if (module()) {
+ if (category() == Glossary) {
+ //special handling for glossaries, we use the "from language" as language for the module
+ m_dataCache.language = (CPointers::languageMgr())->languageForAbbrev(config(GlossaryFrom));
+ }
+ else {
+ m_dataCache.language = (CPointers::languageMgr())->languageForAbbrev(module()->Lang());
+ }
+ }
+ else {
+ m_dataCache.language = (CPointers::languageMgr())->defaultLanguage(); //default language
+ }
+ }
- return m_dataCache.language;
+ return m_dataCache.language;
}
@@ -912,44 +928,42 @@ const CLanguageMgr::Language* CSwordModuleInfo::language() const {
\fn CSwordModuleInfo::getSimpleConfigEntry(char* name)
*/
QString CSwordModuleInfo::getSimpleConfigEntry(const QString& name) const {
- QString ret = isUnicode()
- ? QString::fromUtf8(m_module->getConfigEntry(name.toUtf8().constData()))
- : QString::fromLatin1(m_module->getConfigEntry(name.toUtf8().constData()));
+ QString ret = isUnicode()
+ ? QString::fromUtf8(m_module->getConfigEntry(name.toUtf8().constData()))
+ : QString::fromLatin1(m_module->getConfigEntry(name.toUtf8().constData()));
- return ret.isEmpty() ? QString::null : ret;
+ return ret.isEmpty() ? QString::null : ret;
}
QString CSwordModuleInfo::getFormattedConfigEntry(const QString& name) const {
- sword::SWBuf RTF_Buffer(m_module->getConfigEntry(name.toUtf8().constData()));
- sword::RTFHTML RTF_Filter;
- RTF_Filter.processText(RTF_Buffer, 0, 0);
- QString ret = isUnicode()
- ? QString::fromUtf8(RTF_Buffer.c_str())
- : QString::fromLatin1(RTF_Buffer.c_str());
-
- return ret.isEmpty() ? QString::null : ret;
-}
-
-void CSwordModuleInfo::setHidden(bool hidden)
-{
- //qDebug("CSwordModuleInfo::setHidden");
- QStringList hiddenModules = CBTConfig::get(CBTConfig::hiddenModules);
- if (hidden && !hiddenModules.contains(this->name())) {
- hiddenModules.append(this->name());
- CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
- }
- if (!hidden && hiddenModules.contains(this->name()) ) {
- hiddenModules.removeAll(this->name());
- CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
- }
-}
-
-bool CSwordModuleInfo::isHidden() const
-{
- //qDebug("CSwordModuleInfo::isHidden");
- QStringList hiddenModules = CBTConfig::get(CBTConfig::hiddenModules);
- if (hiddenModules.contains(this->name())) {
- return true;
- }
- return false;
+ sword::SWBuf RTF_Buffer(m_module->getConfigEntry(name.toUtf8().constData()));
+ sword::RTFHTML RTF_Filter;
+ RTF_Filter.processText(RTF_Buffer, 0, 0);
+ QString ret = isUnicode()
+ ? QString::fromUtf8(RTF_Buffer.c_str())
+ : QString::fromLatin1(RTF_Buffer.c_str());
+
+ return ret.isEmpty() ? QString::null : ret;
+}
+
+void CSwordModuleInfo::setHidden(bool hidden) {
+ //qDebug("CSwordModuleInfo::setHidden");
+ QStringList hiddenModules = CBTConfig::get(CBTConfig::hiddenModules);
+ if (hidden && !hiddenModules.contains(this->name())) {
+ hiddenModules.append(this->name());
+ CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
+ }
+ if (!hidden && hiddenModules.contains(this->name()) ) {
+ hiddenModules.removeAll(this->name());
+ CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
+ }
+}
+
+bool CSwordModuleInfo::isHidden() const {
+ //qDebug("CSwordModuleInfo::isHidden");
+ QStringList hiddenModules = CBTConfig::get(CBTConfig::hiddenModules);
+ if (hiddenModules.contains(this->name())) {
+ return true;
+ }
+ return false;
}
diff --git a/src/backend/drivers/cswordmoduleinfo.h b/src/backend/drivers/cswordmoduleinfo.h
index 0f612f9..ba4b8f6 100644
--- a/src/backend/drivers/cswordmoduleinfo.h
+++ b/src/backend/drivers/cswordmoduleinfo.h
@@ -28,7 +28,7 @@ class CSwordKey;
namespace Rendering {
- class CEntryDisplay;
+class CEntryDisplay;
}
/**
@@ -40,329 +40,331 @@ namespace Rendering {
* @version $Id: cswordmoduleinfo.h,v 1.83 2007/02/04 23:12:32 joachim Exp $
*/
-class CSwordModuleInfo: public QObject
-{
- Q_OBJECT
-
-public:
- /**
- * These are the options which could be supported by modules and by this backend.
- * It's used in @ref CSwordBackend::setOption.
- */
- enum FilterTypes {
- footnotes, /**< Footnotes embedded in the module's text */
- strongNumbers, /**< strong numbers, usually in the text for the info display */
- headings, /**< additional section headings */
- morphTags, /**< morphology */
- lemmas, /**< lemma tags */
- hebrewPoints,/**< Hebrew vowel points */
- hebrewCantillation, /**<Hewbrew caantillation points */
- greekAccents, /**< Greek accents may be switched on and off */
- scriptureReferences, /**< scripture references may be switched on and off, just makes sense in Bibles */
- redLetterWords, /**< Jesus words in red, color is template specific */
- textualVariants, /**< variants */
- morphSegmentation, /**< morph word segmentation, supported by OSIS */
- filterTypesMIN = footnotes, /**< first entry of this enum */
- filterTypesMAX = morphSegmentation /**< last item in this enum */
- // transliteration /* The following are handled in a special way */
- };
- /** The text direction of a module */
- enum TextDirection { /* The text direction of the modules's text */
- LeftToRight, /**< Left to right text direction, the default setting */
- RightToLeft /**< Right to left text directin, e.g. for hebrew */
- };
- /** The module type.
- */
- enum ModuleType {
- Bible, /**< Bible module */
- Commentary, /**< Commentary module */
- Lexicon, /**< Lexicon module */
- GenericBook, /**< Generic book module */
- Unknown /**< Fall back type for unknown modules */
- };
- /**
- * This enum is used to give
- * back an error code after unlocking the module
- * BibleTime stores the unlock key not in the module's config file but in BibleTime's
- * configuration file.
- */
- enum UnlockErrorCode {
- noError, /**< No error occured, everything worked ok. The key was written to the BibleTime config */
- wrongUnlockKey, /**< The wrong key was used. Module is not unlocked */
- notLocked, /**< The module was not locked so it can't be unlocked */
- noPermission /**< The key was not written to config because we have no permissions */
- };
- enum ConfigEntry {
- AboutInformation, /**< The about information of a module which is stored in the config file*/
- AbsoluteDataPath, /**< The absolute data path stored in the config object */
- CipherKey, /**< The cipher key which was used to unlock the module. Not necessarily set.*/
- DataPath, /**< The relative path. See AbsoluteDataPath*/
- Description, /**< The module description stored in the config file */
- ModuleVersion, /**< The module's version.*/
- MinimumSwordVersion, /**< The required Sword Version of this module. Otherwise some things may not work (compression etc.).*/
- TextDir, /**< The text direction */
- DisplayLevel, /**< Mostly used for books. Gives the level which should contain the connected entries.*/
- GlossaryFrom, /**< lamguage from which the Glosaary tramslates */
- GlossaryTo, /**< lamguages to which the glossary maps to */
- DistributionLicense,
- DistributionSource,
- DistributionNotes,
- TextSource,
- CopyrightNotes,
- CopyrightHolder,
- CopyrightDate,
- CopyrightContactName,
- CopyrightContactAddress,
- CopyrightContactEmail,
- Markup /**< The markup of this module */
- };
- enum Feature {
- //StrongsNumbers, /**< Use for Bibles which have embedded strong numbers */ BT does not use this as a user option
- GreekDef,
- HebrewDef,
- GreekParse,
- HebrewParse,
- featureMin = GreekDef,
- featureMax = HebrewParse
- };
- enum Category {
- UnknownCategory = 0, /**< The category wasn't set or has an unknwon value */
- Bibles,
- Commentaries,
- Books,
- Lexicons,
- Glossary,
- DailyDevotional,
- Images,
- Cult /**< The module is a cult / sect / questionable module */
- };
-
- /**
- * Returns the base directory for search indices
- */
- static QString getGlobalBaseIndexLocation();
- /**
- * Removes search index for this module, even if the module is not there any more
- */
- static void deleteIndexForModule( QString name );
-
-
- /**
- * Returns the config entry which is pecified by the parameter.
- */
- QString config( const CSwordModuleInfo::ConfigEntry entry ) const;
-
- CSwordModuleInfo( sword::SWModule* module, CSwordBackend* const = 0 );
- /** Copy constructor to copy the passed parameter.
- * @param m The module to be copied
- */
- CSwordModuleInfo( const CSwordModuleInfo& m );
- /** Reimplementation to return a valid clone.
- */
- virtual CSwordModuleInfo* clone();
- /** Destructor.
- */
- virtual ~CSwordModuleInfo();
-
- /**
- * Returns the module object so all objects can access the original Sword module.
- */
- sword::SWModule* module() const;
- /**
- * Sets the unlock key of the modules and writes the key into the cofig file.
- * @return True if the unlock process was succesful, if the key was wrong, or if the config file was write protected return false.
- */
- bool unlock( const QString& unlockKey );
- /**
- * Returns the display object for this module. Normally every module should have a Display object.
- * Please don't use module()->Display() because this function does return the Sword display and does
- * render the text, too.
- * This function performs some casts to return the correct display. If it returns 0 there's no valid
- * display object.
- */
- Rendering::CEntryDisplay* getDisplay() const;
- /**
- * This function does return true if the data files of the module are encrypted by the module author
- * (the on who made the module) no matter if it's locked or not.
- * @return True if this module is encryped
- */
- bool isEncrypted() const;
- /**
- * This function returns true if this module is locked (encrypted + correct cipher key),
- * otherwise return false.
- * @return True if this module is locked, i.e. encrypted but without a key set
- */
- bool isLocked();
-
- bool unlockKeyIsValid();
-
- /** The module version.
- * @return true if this module has a version number and false if it doesn't have one.
- */
- inline bool hasVersion() const;
-
- /**
- * Returns true if the module's index has been built.
- */
- virtual bool hasIndex();
- /**
- * Returns the path to this module's index base dir
- */
- virtual QString getModuleBaseIndexLocation() const;
- /**
- * Returns the path to this module's standard index
- */
- virtual QString getModuleStandardIndexLocation() const;
- /**
- * Builds a search index for this module
- */
- virtual void buildIndex();
- /**
- * Returns index size
- */
- virtual unsigned long indexSize() const;
- /**
- * Returns true if something was found, otherwise return false.
- * This function uses CLucene to perform and index based search. It also
- * overwrites the variable containing the last search result.
- */
- virtual bool searchIndexed(const QString& searchedText, sword::ListKey& scope);
- /**
- * Returns the last search result for this module.
- * The last result is cleared by @ref search
- */
- virtual sword::ListKey& searchResult( const sword::ListKey* newResult = 0 );
- /**
- * Clears the last search result.
- * This does immediately clean the last search result,
- * no matter if search is in progress or not.
- */
- void clearSearchResult();
- /**
- * Returns the type of the module.
- */
- virtual CSwordModuleInfo::ModuleType type() const;
- /**
- * Returns the required Sword version for this module.
- * Returns -1 if no special Sword version is required.
- */
- sword::SWVersion minimumSwordVersion();
- /**
- * Returns the name of the module.
- * @return The name of this module.
- */
- QString name() const;
- /**
- * Snaps to the closest entry in the module if the current key is
- * not present in the data files.
- */
- virtual bool snap() {
- return false;
- };
-
- bool has( const CSwordModuleInfo::Feature ) const;
- bool has( const CSwordModuleInfo::FilterTypes ) const;
- /**
- * Returns the text direction of the module's text.,
- */
- virtual CSwordModuleInfo::TextDirection textDirection();
- /**
- * Writes the new text at the given position into the module. This does only work for writabe modules.
- */
- virtual void write( CSwordKey* key, const QString& newText );
- /**
- * Deletes the current entry and removes it from the module.
- */
- bool deleteEntry( CSwordKey* const key );
- /**
- * Returns the language of the module.
- */
- const CLanguageMgr::Language* language() const;
- /**
- * Returns true if this module may be written by the write display windows.
- */
- inline virtual bool isWritable() const;
- /**
- * Returns true if this module is hidden (not to be shown with other modules in certain views).
- */
- bool isHidden() const;
-
- void setHidden(bool hidden);
-
- /**
- * Returns the category of this module. See CSwordModuleInfo::Category for possible values.
- */
- CSwordModuleInfo::Category category() const;
- /**
- * The about text which belongs to this module.
- */
- QString aboutText() const;
- /**
- * Returns true if this module is Unicode encoded. False if the charset is iso8859-1.
- * Protected because it should not be used outside of the CSword*ModuleInfo classes.
- */
- inline bool isUnicode() const {
- return m_dataCache.isUnicode;
- }
-
-public slots:
- inline void cancelIndexing() { m_cancelIndexing = true; };
-
-protected:
- friend class CSwordBackend;
-
- inline CSwordBackend* backend() const {
- return m_backend;
- }
-
- inline void backend( CSwordBackend* newBackend ) {
- if (newBackend) {
- m_backend = newBackend;
- }
- }
-
- QString getSimpleConfigEntry(const QString& name) const;
- QString getFormattedConfigEntry(const QString& name) const;
-
-signals:
- void indexingFinished();
- void indexingProgress(int);
-
-private:
- sword::SWModule* m_module;
- sword::ListKey m_searchResult;
-
- mutable struct DataCache {
- DataCache() {
- language = 0;
- }
-
- QString name;
- bool isUnicode;
- CSwordModuleInfo::Category category;
- const CLanguageMgr::Language* language;
- bool hasVersion;
- }
-
- m_dataCache;
-
- CSwordBackend* m_backend;
-
- bool m_hidden;
-
- bool m_cancelIndexing;
+class CSwordModuleInfo: public QObject {
+ Q_OBJECT
+
+ public:
+ /**
+ * These are the options which could be supported by modules and by this backend.
+ * It's used in @ref CSwordBackend::setOption.
+ */
+ enum FilterTypes {
+ footnotes, /**< Footnotes embedded in the module's text */
+ strongNumbers, /**< strong numbers, usually in the text for the info display */
+ headings, /**< additional section headings */
+ morphTags, /**< morphology */
+ lemmas, /**< lemma tags */
+ hebrewPoints,/**< Hebrew vowel points */
+ hebrewCantillation, /**<Hewbrew caantillation points */
+ greekAccents, /**< Greek accents may be switched on and off */
+ scriptureReferences, /**< scripture references may be switched on and off, just makes sense in Bibles */
+ redLetterWords, /**< Jesus words in red, color is template specific */
+ textualVariants, /**< variants */
+ morphSegmentation, /**< morph word segmentation, supported by OSIS */
+ filterTypesMIN = footnotes, /**< first entry of this enum */
+ filterTypesMAX = morphSegmentation /**< last item in this enum */
+ // transliteration /* The following are handled in a special way */
+ };
+ /** The text direction of a module */
+ enum TextDirection { /* The text direction of the modules's text */
+ LeftToRight, /**< Left to right text direction, the default setting */
+ RightToLeft /**< Right to left text directin, e.g. for hebrew */
+ };
+ /** The module type.
+ */
+ enum ModuleType {
+ Bible, /**< Bible module */
+ Commentary, /**< Commentary module */
+ Lexicon, /**< Lexicon module */
+ GenericBook, /**< Generic book module */
+ Unknown /**< Fall back type for unknown modules */
+ };
+ /**
+ * This enum is used to give
+ * back an error code after unlocking the module
+ * BibleTime stores the unlock key not in the module's config file but in BibleTime's
+ * configuration file.
+ */
+ enum UnlockErrorCode {
+ noError, /**< No error occured, everything worked ok. The key was written to the BibleTime config */
+ wrongUnlockKey, /**< The wrong key was used. Module is not unlocked */
+ notLocked, /**< The module was not locked so it can't be unlocked */
+ noPermission /**< The key was not written to config because we have no permissions */
+ };
+ enum ConfigEntry {
+ AboutInformation, /**< The about information of a module which is stored in the config file*/
+ AbsoluteDataPath, /**< The absolute data path stored in the config object */
+ CipherKey, /**< The cipher key which was used to unlock the module. Not necessarily set.*/
+ DataPath, /**< The relative path. See AbsoluteDataPath*/
+ Description, /**< The module description stored in the config file */
+ ModuleVersion, /**< The module's version.*/
+ MinimumSwordVersion, /**< The required Sword Version of this module. Otherwise some things may not work (compression etc.).*/
+ TextDir, /**< The text direction */
+ DisplayLevel, /**< Mostly used for books. Gives the level which should contain the connected entries.*/
+ GlossaryFrom, /**< lamguage from which the Glosaary tramslates */
+ GlossaryTo, /**< lamguages to which the glossary maps to */
+ DistributionLicense,
+ DistributionSource,
+ DistributionNotes,
+ TextSource,
+ CopyrightNotes,
+ CopyrightHolder,
+ CopyrightDate,
+ CopyrightContactName,
+ CopyrightContactAddress,
+ CopyrightContactEmail,
+ Markup /**< The markup of this module */
+ };
+ enum Feature {
+ //StrongsNumbers, /**< Use for Bibles which have embedded strong numbers */ BT does not use this as a user option
+ GreekDef,
+ HebrewDef,
+ GreekParse,
+ HebrewParse,
+ featureMin = GreekDef,
+ featureMax = HebrewParse
+ };
+ enum Category {
+ Bibles,
+ Commentaries,
+ Books,
+ Lexicons,
+ Glossary,
+ DailyDevotional,
+ Images,
+ Cult, /**< The module is a cult / sect / questionable module */
+ UnknownCategory /**< The category wasn't set or has an unknown value */
+ };
+
+ /**
+ * Returns the base directory for search indices
+ */
+ static QString getGlobalBaseIndexLocation();
+ /**
+ * Removes search index for this module, even if the module is not there any more
+ */
+ static void deleteIndexForModule( QString name );
+
+
+ /**
+ * Returns the config entry which is pecified by the parameter.
+ */
+ QString config( const CSwordModuleInfo::ConfigEntry entry ) const;
+
+ CSwordModuleInfo( sword::SWModule* module, CSwordBackend* const = 0 );
+ /** Copy constructor to copy the passed parameter.
+ * @param m The module to be copied
+ */
+ CSwordModuleInfo( const CSwordModuleInfo& m );
+ /** Reimplementation to return a valid clone.
+ */
+ virtual CSwordModuleInfo* clone();
+ /** Destructor.
+ */
+ virtual ~CSwordModuleInfo();
+
+ /**
+ * Returns the module object so all objects can access the original Sword module.
+ */
+ sword::SWModule* module() const;
+ /**
+ * Sets the unlock key of the modules and writes the key into the cofig file.
+ * @return True if the unlock process was succesful, if the key was wrong, or if the config file was write protected return false.
+ */
+ bool unlock( const QString& unlockKey );
+ /**
+ * Returns the display object for this module. Normally every module should have a Display object.
+ * Please don't use module()->Display() because this function does return the Sword display and does
+ * render the text, too.
+ * This function performs some casts to return the correct display. If it returns 0 there's no valid
+ * display object.
+ */
+ Rendering::CEntryDisplay* getDisplay() const;
+ /**
+ * This function does return true if the data files of the module are encrypted by the module author
+ * (the on who made the module) no matter if it's locked or not.
+ * @return True if this module is encryped
+ */
+ bool isEncrypted() const;
+ /**
+ * This function returns true if this module is locked (encrypted + correct cipher key),
+ * otherwise return false.
+ * \todo Make CSwordModuleInfo::isLocked() const.
+ * @return True if this module is locked, i.e. encrypted but without a key set
+ */
+ bool isLocked();
+
+ bool unlockKeyIsValid();
+
+ /** The module version.
+ * @return true if this module has a version number and false if it doesn't have one.
+ */
+ inline bool hasVersion() const;
+
+ /**
+ * Returns true if the module's index has been built.
+ */
+ virtual bool hasIndex();
+ /**
+ * Returns the path to this module's index base dir
+ */
+ virtual QString getModuleBaseIndexLocation() const;
+ /**
+ * Returns the path to this module's standard index
+ */
+ virtual QString getModuleStandardIndexLocation() const;
+ /**
+ * Builds a search index for this module
+ */
+ virtual void buildIndex();
+ /**
+ * Returns index size
+ */
+ virtual unsigned long indexSize() const;
+ /**
+ * Returns true if something was found, otherwise return false.
+ * This function uses CLucene to perform and index based search. It also
+ * overwrites the variable containing the last search result.
+ */
+ virtual bool searchIndexed(const QString& searchedText, sword::ListKey& scope);
+ /**
+ * Returns the last search result for this module.
+ * The last result is cleared by @ref search
+ */
+ virtual sword::ListKey& searchResult( const sword::ListKey* newResult = 0 );
+ /**
+ * Clears the last search result.
+ * This does immediately clean the last search result,
+ * no matter if search is in progress or not.
+ */
+ void clearSearchResult();
+ /**
+ * Returns the type of the module.
+ */
+ virtual CSwordModuleInfo::ModuleType type() const;
+ /**
+ * Returns the required Sword version for this module.
+ * Returns -1 if no special Sword version is required.
+ */
+ sword::SWVersion minimumSwordVersion();
+ /**
+ * Returns the name of the module.
+ * @return The name of this module.
+ */
+ QString name() const;
+ /**
+ * Snaps to the closest entry in the module if the current key is
+ * not present in the data files.
+ */
+ virtual bool snap() {
+ return false;
+ };
+
+ bool has( const CSwordModuleInfo::Feature ) const;
+ bool has( const CSwordModuleInfo::FilterTypes ) const;
+ /**
+ * Returns the text direction of the module's text.,
+ */
+ virtual CSwordModuleInfo::TextDirection textDirection();
+ /**
+ * Writes the new text at the given position into the module. This does only work for writabe modules.
+ */
+ virtual void write( CSwordKey* key, const QString& newText );
+ /**
+ * Deletes the current entry and removes it from the module.
+ */
+ bool deleteEntry( CSwordKey* const key );
+ /**
+ * Returns the language of the module.
+ */
+ const CLanguageMgr::Language* language() const;
+ /**
+ * Returns true if this module may be written by the write display windows.
+ */
+ inline virtual bool isWritable() const;
+ /**
+ * Returns true if this module is hidden (not to be shown with other modules in certain views).
+ */
+ bool isHidden() const;
+
+ void setHidden(bool hidden);
+
+ /**
+ * Returns the category of this module. See CSwordModuleInfo::Category for possible values.
+ */
+ CSwordModuleInfo::Category category() const;
+ /**
+ * The about text which belongs to this module.
+ */
+ QString aboutText() const;
+ /**
+ * Returns true if this module is Unicode encoded. False if the charset is iso8859-1.
+ * Protected because it should not be used outside of the CSword*ModuleInfo classes.
+ */
+ inline bool isUnicode() const {
+ return m_dataCache.isUnicode;
+ }
+
+ public slots:
+ inline void cancelIndexing() {
+ m_cancelIndexing = true;
+ };
+
+ protected:
+ friend class CSwordBackend;
+
+ inline CSwordBackend* backend() const {
+ return m_backend;
+ }
+
+ inline void backend( CSwordBackend* newBackend ) {
+ if (newBackend) {
+ m_backend = newBackend;
+ }
+ }
+
+ QString getSimpleConfigEntry(const QString& name) const;
+ QString getFormattedConfigEntry(const QString& name) const;
+
+ signals:
+ void indexingFinished();
+ void indexingProgress(int);
+
+ private:
+ sword::SWModule* m_module;
+ sword::ListKey m_searchResult;
+
+ mutable struct DataCache {
+ DataCache() {
+ language = 0;
+ }
+
+ QString name;
+ bool isUnicode;
+ CSwordModuleInfo::Category category;
+ const CLanguageMgr::Language* language;
+ bool hasVersion;
+ }
+
+ m_dataCache;
+
+ CSwordBackend* m_backend;
+
+ bool m_hidden;
+
+ bool m_cancelIndexing;
};
inline CSwordModuleInfo::ModuleType CSwordModuleInfo::type() const {
- return CSwordModuleInfo::Unknown;
+ return CSwordModuleInfo::Unknown;
}
inline sword::SWModule* CSwordModuleInfo::module() const {
- return m_module;
+ return m_module;
}
inline bool CSwordModuleInfo::hasVersion() const {
- return m_dataCache.hasVersion;
+ return m_dataCache.hasVersion;
}
@@ -371,12 +373,12 @@ inline bool CSwordModuleInfo::hasVersion() const {
* The Sword library takes care of the duplicate names: _n is added after each duplicate.
*/
inline QString CSwordModuleInfo::name() const {
- return m_dataCache.name;
+ return m_dataCache.name;
}
/** Returns true if this module may be written by the write display windows. */
inline bool CSwordModuleInfo::isWritable() const {
- return false;
+ return false;
}
//#include "util/cpointers.h"
diff --git a/src/backend/filters/bt_gbfhtml.cpp b/src/backend/filters/bt_gbfhtml.cpp
index 0627cee..6580bcd 100644
--- a/src/backend/filters/bt_gbfhtml.cpp
+++ b/src/backend/filters/bt_gbfhtml.cpp
@@ -25,272 +25,272 @@
Filters::BT_GBFHTML::BT_GBFHTML() : sword::GBFHTML() {
- setEscapeStringCaseSensitive(true);
- setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
+ setEscapeStringCaseSensitive(true);
+ setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
- removeTokenSubstitute("Rf");
- // addTokenSubstitute("RB", "<span>"); //start of a footnote with embedded text
+ removeTokenSubstitute("Rf");
+ // addTokenSubstitute("RB", "<span>"); //start of a footnote with embedded text
- addTokenSubstitute("FI", "<span class=\"italic\">"); // italics begin
- addTokenSubstitute("Fi", "</span>");
+ addTokenSubstitute("FI", "<span class=\"italic\">"); // italics begin
+ addTokenSubstitute("Fi", "</span>");
- addTokenSubstitute("FB", "<span class=\"bold\">"); // bold begin
- addTokenSubstitute("Fb", "</span>");
+ addTokenSubstitute("FB", "<span class=\"bold\">"); // bold begin
+ addTokenSubstitute("Fb", "</span>");
- addTokenSubstitute("FR", "<span class=\"jesuswords\">");
- addTokenSubstitute("Fr", "</span>");
+ addTokenSubstitute("FR", "<span class=\"jesuswords\">");
+ addTokenSubstitute("Fr", "</span>");
- addTokenSubstitute("FU", "<u>"); // underline begin
- addTokenSubstitute("Fu", "</u>");
+ addTokenSubstitute("FU", "<u>"); // underline begin
+ addTokenSubstitute("Fu", "</u>");
- addTokenSubstitute("FO", "<span class=\"quotation\">"); // Old Testament quote begin
- addTokenSubstitute("Fo", "</span>");
+ addTokenSubstitute("FO", "<span class=\"quotation\">"); // Old Testament quote begin
+ addTokenSubstitute("Fo", "</span>");
- addTokenSubstitute("FS", "<span class=\"sup\">"); // Superscript begin// Subscript begin
- addTokenSubstitute("Fs", "</span>");
+ addTokenSubstitute("FS", "<span class=\"sup\">"); // Superscript begin// Subscript begin
+ addTokenSubstitute("Fs", "</span>");
- addTokenSubstitute("FV", "<span class=\"sub\">"); // Subscript begin
- addTokenSubstitute("Fv", "</span>");
+ addTokenSubstitute("FV", "<span class=\"sub\">"); // Subscript begin
+ addTokenSubstitute("Fv", "</span>");
- addTokenSubstitute("TT", "<div class=\"booktitle\">");
- addTokenSubstitute("Tt", "</div>");
+ addTokenSubstitute("TT", "<div class=\"booktitle\">");
+ addTokenSubstitute("Tt", "</div>");
- addTokenSubstitute("TS", "<div class=\"sectiontitle\">");
- addTokenSubstitute("Ts", "</div>");
+ addTokenSubstitute("TS", "<div class=\"sectiontitle\">");
+ addTokenSubstitute("Ts", "</div>");
- //addTokenSubstitute("PP", "<span class=\"poetry\">"); // poetry begin
- //addTokenSubstitute("Pp", "</span>");
+ //addTokenSubstitute("PP", "<span class=\"poetry\">"); // poetry begin
+ //addTokenSubstitute("Pp", "</span>");
- addTokenSubstitute("Fn", "</font>"); // font end
- addTokenSubstitute("CL", "<br/>"); // new line
- addTokenSubstitute("CM", "<br/>"); // paragraph <!P> is a non showing comment that can be changed in the front end to <P> if desired
+ addTokenSubstitute("Fn", "</font>"); // font end
+ addTokenSubstitute("CL", "<br/>"); // new line
+ addTokenSubstitute("CM", "<br/>"); // paragraph <!P> is a non showing comment that can be changed in the front end to <P> if desired
- addTokenSubstitute("CG", "&gt;"); // literal greater-than sign
- addTokenSubstitute("CT", "&lt;"); // literal less-than sign
+ addTokenSubstitute("CG", "&gt;"); // literal greater-than sign
+ addTokenSubstitute("CT", "&lt;"); // literal less-than sign
- addTokenSubstitute("JR", "<span class=\"right\">"); // right align begin
- addTokenSubstitute("JC", "<span class=\"center\">"); // center align begin
- addTokenSubstitute("JL", "</span>"); // align end
+ addTokenSubstitute("JR", "<span class=\"right\">"); // right align begin
+ addTokenSubstitute("JC", "<span class=\"center\">"); // center align begin
+ addTokenSubstitute("JL", "</span>"); // align end
}
/** No descriptions */
char Filters::BT_GBFHTML::processText(sword::SWBuf& buf, const sword::SWKey * key, const sword::SWModule * module) {
- GBFHTML::processText(buf, key, module);
+ GBFHTML::processText(buf, key, module);
- if (!module->isProcessEntryAttributes()) {
- return 1; //no processing should be done, may happen in a search
- }
+ if (!module->isProcessEntryAttributes()) {
+ return 1; //no processing should be done, may happen in a search
+ }
- CSwordModuleInfo* m = CPointers::backend()->findModuleByName( module->Name() );
+ CSwordModuleInfo* m = CPointers::backend()->findModuleByName( module->Name() );
- if (m && !(m->has(CSwordModuleInfo::lemmas) || m->has(CSwordModuleInfo::morphTags) || m->has(CSwordModuleInfo::strongNumbers))) { //only parse if the module has strongs or lemmas
- return 1; //WARNING: Return alread here
- }
+ if (m && !(m->has(CSwordModuleInfo::lemmas) || m->has(CSwordModuleInfo::morphTags) || m->has(CSwordModuleInfo::strongNumbers))) { //only parse if the module has strongs or lemmas
+ return 1; //WARNING: Return alread here
+ }
- //Am Anfang<WH07225> schuf<WH01254><WTH8804> Gott<WH0430> Himmel<WH08064> und<WT> Erde<WH0776>.
- //A simple word<WT> means: No entry for this word "word"
- QString result;
+ //Am Anfang<WH07225> schuf<WH01254><WTH8804> Gott<WH0430> Himmel<WH08064> und<WT> Erde<WH0776>.
+ //A simple word<WT> means: No entry for this word "word"
+ QString result;
- QString t = QString::fromUtf8(buf.c_str());
+ QString t = QString::fromUtf8(buf.c_str());
- QRegExp tag("([.,;:]?<W[HGT][^>]*>\\s*)+");
+ QRegExp tag("([.,;:]?<W[HGT][^>]*>\\s*)+");
- QStringList list;
+ QStringList list;
- int lastMatchEnd = 0;
+ int lastMatchEnd = 0;
- int pos = tag.indexIn(t,0);
+ int pos = tag.indexIn(t, 0);
- if (pos == -1) { //no strong or morph code found in this text
- return 1; //WARNING: Return already here
- }
+ if (pos == -1) { //no strong or morph code found in this text
+ return 1; //WARNING: Return already here
+ }
- //split the text into parts which end with the GBF tag marker for strongs/lemmas
- while (pos != -1) {
- list.append(t.mid(lastMatchEnd, pos+tag.matchedLength()-lastMatchEnd));
+ //split the text into parts which end with the GBF tag marker for strongs/lemmas
+ while (pos != -1) {
+ list.append(t.mid(lastMatchEnd, pos + tag.matchedLength() - lastMatchEnd));
- lastMatchEnd = pos + tag.matchedLength();
- pos = tag.indexIn(t, pos + tag.matchedLength());
- }
+ lastMatchEnd = pos + tag.matchedLength();
+ pos = tag.indexIn(t, pos + tag.matchedLength());
+ }
- //append the trailing text to the list.
- if (!t.right(t.length() - lastMatchEnd).isEmpty()) {
- list.append(t.right(t.length() - lastMatchEnd));
- }
+ //append the trailing text to the list.
+ if (!t.right(t.length() - lastMatchEnd).isEmpty()) {
+ list.append(t.right(t.length() - lastMatchEnd));
+ }
- //list is now a list of words with 1-n Strongs at the end, which belong to this word.
-
- //now create the necessary HTML in list entries and concat them to the result
- tag = QRegExp("<W([HGT])([^>]*)>");
- tag.setMinimal(true);
+ //list is now a list of words with 1-n Strongs at the end, which belong to this word.
- for (QStringList::iterator it = list.begin(); it != list.end(); ++it) {
- QString e = (*it); //current entry to process
- //qWarning(e.latin1());
-
- //check if there is a word to which the strongs info belongs to.
- //If yes, wrap that word with the strongs info
- //If not, leave out the strongs info, because it can't be tight to a text
- //Comparing the first char with < is not enough, because the tokenReplace is done already
- //so there might be html tags already.
- const bool textPresent = (e.trimmed().remove(QRegExp("[.,;:]")).left(2) != "<W");
+ //now create the necessary HTML in list entries and concat them to the result
+ tag = QRegExp("<W([HGT])([^>]*)>");
+ tag.setMinimal(true);
- if (!textPresent) {
- result += (*it);
- continue;
- }
+ for (QStringList::iterator it = list.begin(); it != list.end(); ++it) {
+ QString e = (*it); //current entry to process
+ //qWarning(e.latin1());
- int pos = tag.indexIn(e, 0); //try to find a strong number marker
- bool insertedTag = false;
- bool hasLemmaAttr = false;
- bool hasMorphAttr = false;
+ //check if there is a word to which the strongs info belongs to.
+ //If yes, wrap that word with the strongs info
+ //If not, leave out the strongs info, because it can't be tight to a text
+ //Comparing the first char with < is not enough, because the tokenReplace is done already
+ //so there might be html tags already.
+ const bool textPresent = (e.trimmed().remove(QRegExp("[.,;:]")).left(2) != "<W");
- QString value = QString::null;
- int tagAttributeStart = -1;
+ if (!textPresent) {
+ result += (*it);
+ continue;
+ }
- while (pos != -1) { //work on all strong/lemma tags in this section, should be between 1-3 loops
- const bool isMorph = (tag.cap(1) == "T");
- value = isMorph ? tag.cap(2) : tag.cap(2).prepend( tag.cap(1) );
+ int pos = tag.indexIn(e, 0); //try to find a strong number marker
+ bool insertedTag = false;
+ bool hasLemmaAttr = false;
+ bool hasMorphAttr = false;
- if (value.isEmpty()) {
- break;
- }
+ QString value = QString::null;
+ int tagAttributeStart = -1;
- //insert the span
- if (!insertedTag) { //we have to insert a new tag end and beginning, i.e. our first loop
- e.replace(pos, tag.matchedLength(), "</span>");
- pos += 7;
+ while (pos != -1) { //work on all strong/lemma tags in this section, should be between 1-3 loops
+ const bool isMorph = (tag.cap(1) == "T");
+ value = isMorph ? tag.cap(2) : tag.cap(2).prepend( tag.cap(1) );
- //skip blanks, commas, dots and stuff at the beginning, it doesn't belong to the morph code
- QString rep("<span ");
- rep.append(isMorph ? "morph" : "lemma").append("=\"").append(value).append("\">");
+ if (value.isEmpty()) {
+ break;
+ }
- hasMorphAttr = isMorph;
- hasLemmaAttr = !isMorph;
+ //insert the span
+ if (!insertedTag) { //we have to insert a new tag end and beginning, i.e. our first loop
+ e.replace(pos, tag.matchedLength(), "</span>");
+ pos += 7;
- int startPos = 0;
- QChar c = e[startPos];
+ //skip blanks, commas, dots and stuff at the beginning, it doesn't belong to the morph code
+ QString rep("<span ");
+ rep.append(isMorph ? "morph" : "lemma").append("=\"").append(value).append("\">");
- while ((startPos < pos) && (c.isSpace() || c.isPunct())) {
- ++startPos;
+ hasMorphAttr = isMorph;
+ hasLemmaAttr = !isMorph;
- c = e[startPos];
- }
+ int startPos = 0;
+ QChar c = e[startPos];
- e.insert( startPos, rep );
- tagAttributeStart = startPos + 6; //to point to the start of the attributes
- pos += rep.length();
- }
- else { //add the attribute to the existing tag
- e.remove(pos, tag.matchedLength());
-
- if (tagAttributeStart == -1) {
- continue; //nothing valid found
- }
-
- if ((!isMorph && hasLemmaAttr) || (isMorph && hasMorphAttr)) { //we append another attribute value, e.g. 3000 gets 3000|5000
- //search the existing attribute start
- QRegExp attrRegExp( isMorph ? "morph=\".+(?=\")" : "lemma=\".+(?=\")" );
- attrRegExp.setMinimal(true);
- const int foundPos = e.indexOf(attrRegExp, tagAttributeStart);
-
- if (foundPos != -1) {
- e.insert(foundPos + attrRegExp.matchedLength(), QString("|").append(value));
- pos += value.length() + 1;
-
- hasLemmaAttr = !isMorph;
- hasMorphAttr = isMorph;
- }
- }
- else { //attribute was not yet inserted
- QString attr = QString(isMorph ? "morph" : "lemma").append("=\"").append(value).append("\" ");
-
- e.insert(tagAttributeStart, attr);
- pos += attr.length();
-
- hasMorphAttr = isMorph;
- hasLemmaAttr = !isMorph;
- }
-
- //tagAttributeStart remains the same
- }
-
- insertedTag = true;
- pos = tag.indexIn(e, pos);
- }
-
- result += e;
- }
-
- if (list.count()) {
- buf = (const char*)result.toUtf8().constData();
- }
-
- return 1;
+ while ((startPos < pos) && (c.isSpace() || c.isPunct())) {
+ ++startPos;
+
+ c = e[startPos];
+ }
+
+ e.insert( startPos, rep );
+ tagAttributeStart = startPos + 6; //to point to the start of the attributes
+ pos += rep.length();
+ }
+ else { //add the attribute to the existing tag
+ e.remove(pos, tag.matchedLength());
+
+ if (tagAttributeStart == -1) {
+ continue; //nothing valid found
+ }
+
+ if ((!isMorph && hasLemmaAttr) || (isMorph && hasMorphAttr)) { //we append another attribute value, e.g. 3000 gets 3000|5000
+ //search the existing attribute start
+ QRegExp attrRegExp( isMorph ? "morph=\".+(?=\")" : "lemma=\".+(?=\")" );
+ attrRegExp.setMinimal(true);
+ const int foundPos = e.indexOf(attrRegExp, tagAttributeStart);
+
+ if (foundPos != -1) {
+ e.insert(foundPos + attrRegExp.matchedLength(), QString("|").append(value));
+ pos += value.length() + 1;
+
+ hasLemmaAttr = !isMorph;
+ hasMorphAttr = isMorph;
+ }
+ }
+ else { //attribute was not yet inserted
+ QString attr = QString(isMorph ? "morph" : "lemma").append("=\"").append(value).append("\" ");
+
+ e.insert(tagAttributeStart, attr);
+ pos += attr.length();
+
+ hasMorphAttr = isMorph;
+ hasLemmaAttr = !isMorph;
+ }
+
+ //tagAttributeStart remains the same
+ }
+
+ insertedTag = true;
+ pos = tag.indexIn(e, pos);
+ }
+
+ result += e;
+ }
+
+ if (list.count()) {
+ buf = (const char*)result.toUtf8().constData();
+ }
+
+ return 1;
}
bool Filters::BT_GBFHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) {
- if (!substituteToken(buf, token)) { //more than a simple replace
- const unsigned int tokenLength = strlen(token);
- unsigned long i;
- sword::SWBuf value;
-
- BT_UserData* myUserData = dynamic_cast<BT_UserData*>(userData);
- sword::SWModule* myModule = const_cast<sword::SWModule*>(myUserData->module); //hack to be able to call stuff like Lang()
-
- if ( !strncmp(token, "WG", 2)
- || !strncmp(token, "WH", 2)
- || !strncmp(token, "WT", 2) ) {
- buf.append('<');
- buf.append(token);
- buf.append('>');
- }
- else if (!strncmp(token, "RB", 2)) {
- myUserData->hasFootnotePreTag = true;
- buf.append("<span class=\"footnotepre\">");
- }
- else if (!strncmp(token, "RF", 2)) {
- //we use several append calls because appendFormatted slows down filtering, which should be fast
-
- if (myUserData->hasFootnotePreTag) {
- // qWarning("inserted footnotepre end");
- buf.append("</span>");
- myUserData->hasFootnotePreTag = false;
- }
-
- buf.append(" <span class=\"footnote\" note=\"");
- buf.append(myModule->Name());
- buf.append('/');
- buf.append(myUserData->key->getShortText());
- buf.append('/');
- buf.append( QString::number(myUserData->swordFootnote++).toUtf8().constData() );
- buf.append("\">*</span> ");
-
- userData->suspendTextPassThru = true;
- }
- else if (!strncmp(token, "Rf", 2)) { //end of footnote
- userData->suspendTextPassThru = false;
- }
- else if (!strncmp(token, "FN", 2)) { //the end </font> tag is inserted in addTokenSubsitute
- buf.append("<font face=\"");
-
- for (i = 2; i < tokenLength; i++) {
- if(token[i] != '\"') {
- buf.append( token[i] );
- }
- }
-
- buf.append("\">");
- }
- else if (!strncmp(token, "CA", 2)) { // ASCII value
- buf.append( (char)atoi(&token[2]) );
- }
- else {
- return GBFHTML::handleToken(buf, token, userData);
- }
- }
-
- return true;
+ if (!substituteToken(buf, token)) { //more than a simple replace
+ const unsigned int tokenLength = strlen(token);
+ unsigned long i;
+ sword::SWBuf value;
+
+ BT_UserData* myUserData = dynamic_cast<BT_UserData*>(userData);
+ sword::SWModule* myModule = const_cast<sword::SWModule*>(myUserData->module); //hack to be able to call stuff like Lang()
+
+ if ( !strncmp(token, "WG", 2)
+ || !strncmp(token, "WH", 2)
+ || !strncmp(token, "WT", 2) ) {
+ buf.append('<');
+ buf.append(token);
+ buf.append('>');
+ }
+ else if (!strncmp(token, "RB", 2)) {
+ myUserData->hasFootnotePreTag = true;
+ buf.append("<span class=\"footnotepre\">");
+ }
+ else if (!strncmp(token, "RF", 2)) {
+ //we use several append calls because appendFormatted slows down filtering, which should be fast
+
+ if (myUserData->hasFootnotePreTag) {
+ // qWarning("inserted footnotepre end");
+ buf.append("</span>");
+ myUserData->hasFootnotePreTag = false;
+ }
+
+ buf.append(" <span class=\"footnote\" note=\"");
+ buf.append(myModule->Name());
+ buf.append('/');
+ buf.append(myUserData->key->getShortText());
+ buf.append('/');
+ buf.append( QString::number(myUserData->swordFootnote++).toUtf8().constData() );
+ buf.append("\">*</span> ");
+
+ userData->suspendTextPassThru = true;
+ }
+ else if (!strncmp(token, "Rf", 2)) { //end of footnote
+ userData->suspendTextPassThru = false;
+ }
+ else if (!strncmp(token, "FN", 2)) { //the end </font> tag is inserted in addTokenSubsitute
+ buf.append("<font face=\"");
+
+ for (i = 2; i < tokenLength; i++) {
+ if (token[i] != '\"') {
+ buf.append( token[i] );
+ }
+ }
+
+ buf.append("\">");
+ }
+ else if (!strncmp(token, "CA", 2)) { // ASCII value
+ buf.append( (char)atoi(&token[2]) );
+ }
+ else {
+ return GBFHTML::handleToken(buf, token, userData);
+ }
+ }
+
+ return true;
}
diff --git a/src/backend/filters/bt_gbfhtml.h b/src/backend/filters/bt_gbfhtml.h
index b9118aa..ad23653 100644
--- a/src/backend/filters/bt_gbfhtml.h
+++ b/src/backend/filters/bt_gbfhtml.h
@@ -20,35 +20,34 @@
namespace Filters {
- /** GBF to HTML filter,
- * This filter converts GBF Text into HTML
- */
+/** GBF to HTML filter,
+* This filter converts GBF Text into HTML
+*/
-class BT_GBFHTML : public sword::GBFHTML/*, protected CFilterTool */
- {
+class BT_GBFHTML : public sword::GBFHTML { /*, protected CFilterTool */
-protected:
+ protected:
-class BT_UserData : public sword::GBFHTML::MyUserData {
+ class BT_UserData : public sword::GBFHTML::MyUserData {
-public:
-BT_UserData(const sword::SWModule *module, const sword::SWKey *key) : sword::GBFHTML::MyUserData(module, key) {
- swordFootnote = 1;
- hasFootnotePreTag = false;
- }
+ public:
+ BT_UserData(const sword::SWModule *module, const sword::SWKey *key) : sword::GBFHTML::MyUserData(module, key) {
+ swordFootnote = 1;
+ hasFootnotePreTag = false;
+ }
- short unsigned int swordFootnote;
- };
+ short unsigned int swordFootnote;
+ };
- virtual sword::BasicFilterUserData *createUserData(const sword::SWModule* module, const sword::SWKey* key) {
- return new BT_UserData(module, key);
- }
+ virtual sword::BasicFilterUserData *createUserData(const sword::SWModule* module, const sword::SWKey* key) {
+ return new BT_UserData(module, key);
+ }
-public:
- BT_GBFHTML();
- virtual bool handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData);
- virtual char processText(sword::SWBuf& buf, const sword::SWKey*, const sword::SWModule * = 0);
- };
+ public:
+ BT_GBFHTML();
+ virtual bool handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData);
+ virtual char processText(sword::SWBuf& buf, const sword::SWKey*, const sword::SWModule * = 0);
+};
}
diff --git a/src/backend/filters/bt_osishtml.cpp b/src/backend/filters/bt_osishtml.cpp
index 8ee0b40..9026a94 100644
--- a/src/backend/filters/bt_osishtml.cpp
+++ b/src/backend/filters/bt_osishtml.cpp
@@ -28,590 +28,571 @@
Filters::BT_OSISHTML::BT_OSISHTML() : sword::OSISHTMLHREF() {
- setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
+ setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
- addTokenSubstitute("inscription", "<span class=\"inscription\">");
- addTokenSubstitute("/inscription","</span>");
+ addTokenSubstitute("inscription", "<span class=\"inscription\">");
+ addTokenSubstitute("/inscription", "</span>");
- addTokenSubstitute("mentioned", "<span class=\"mentioned\">");
- addTokenSubstitute("/mentioned", "</span>");
+ addTokenSubstitute("mentioned", "<span class=\"mentioned\">");
+ addTokenSubstitute("/mentioned", "</span>");
// addTokenSubstitute("divineName", "<span class=\"name\"><span class=\"divine\">");
// addTokenSubstitute("/divineName", "</span></span>");
- //TODO Move that down to the real tag handling, segs without the type morph would generate incorrect markup, as the end span is always inserted
+ //TODO Move that down to the real tag handling, segs without the type morph would generate incorrect markup, as the end span is always inserted
// addTokenSubstitute("seg type=\"morph\"", "<span class=\"morphSegmentation\">");
// addTokenSubstitute("/seg", "</span>");
- // OSIS tables
- addTokenSubstitute("table", "<table>");
- addTokenSubstitute("/table", "</table>");
- addTokenSubstitute("row", "<tr>");
- addTokenSubstitute("/row", "</tr>");
- addTokenSubstitute("cell", "<td>");
- addTokenSubstitute("/cell", "</td>");
+ // OSIS tables
+ addTokenSubstitute("table", "<table>");
+ addTokenSubstitute("/table", "</table>");
+ addTokenSubstitute("row", "<tr>");
+ addTokenSubstitute("/row", "</tr>");
+ addTokenSubstitute("cell", "<td>");
+ addTokenSubstitute("/cell", "</td>");
}
bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) {
- // manually process if it wasn't a simple substitution
-
- if (!substituteToken(buf, token)) {
- BT_UserData* myUserData = dynamic_cast<BT_UserData*>(userData);
- sword::SWModule* myModule = const_cast<sword::SWModule*>(myUserData->module); //hack
-
- sword::XMLTag tag(token);
- // qWarning("found %s", token);
- const bool osisQToTick = ((!userData->module->getConfigEntry("OSISqToTick")) || (strcmp(userData->module->getConfigEntry("OSISqToTick"), "false")));
-
- if (!tag.getName()) {
- return false;
- }
-
- // <div> tag
- if (!strcmp(tag.getName(), "div")) {
- //handle intro
-
- if ((!tag.isEmpty()) && (!tag.isEndTag())) { //start tag
- sword::SWBuf type( tag.getAttribute("type") );
-
- if (type == "introduction") {
- buf.append("<div class=\"introduction\">");
- }
- else if (type == "chapter") {
- buf.append("<div class=\"chapter\" />"); //don't open a div here, that would lead to a broken XML structure
- }
- else {
- buf.append("<div>");
- }
- }
- else if (tag.isEndTag()) { //end tag
- buf.append("</div>");
- }
- }
- else if (!strcmp(tag.getName(), "w")) {
- if ((!tag.isEmpty()) && (!tag.isEndTag())) { //start tag
- const char *attrib;
- const char *val;
-
- sword::XMLTag outTag("span");
- sword::SWBuf attrValue;
-
- if ((attrib = tag.getAttribute("xlit"))) {
- val = strchr(attrib, ':');
- val = (val) ? (val + 1) : attrib;
- outTag.setAttribute("xlit", val);
- }
-
- if ((attrib = tag.getAttribute("gloss"))) {
- val = strchr(attrib, ':');
- val = (val) ? (val + 1) : attrib;
- outTag.setAttribute("gloss", val);
- }
-
- if ((attrib = tag.getAttribute("lemma"))) {
- char splitChar = '|';
- const int countSplit1 = tag.getAttributePartCount("lemma", '|');
- const int countSplit2 = tag.getAttributePartCount("lemma", ' '); //TODO: not allowed, remove soon
- int count = 0;
-
- if (countSplit1 > countSplit2) { //| split char
- splitChar = '|'; //TODO: not allowed, remove soon
- count = countSplit1;
- }
- else {
- splitChar = ' ';
- count = countSplit2;
- }
-
- int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0
- attrValue = "";
-
- do {
- if (attrValue.length()) {
- attrValue.append( '|' );
- }
-
- attrib = tag.getAttribute("lemma", i, splitChar);
-
- if (i < 0) { // to handle our -1 condition
- i = 0;
- }
-
- val = strchr(attrib, ':');
- val = (val) ? (val + 1) : attrib;
-
- attrValue.append(val);
- }
- while (++i < count);
-
- if (attrValue.length()) {
- outTag.setAttribute("lemma", attrValue.c_str());
- }
- }
-
- if ((attrib = tag.getAttribute("morph"))) {
- char splitChar = '|';
- const int countSplit1 = tag.getAttributePartCount("morph", '|');
- const int countSplit2 = tag.getAttributePartCount("morph", ' '); //TODO: not allowed, remove soon
- int count = 0;
-
- if (countSplit1 > countSplit2) { //| split char
- splitChar = '|';
- count = countSplit1;
- }
- else {
- splitChar = ' ';
- count = countSplit2;
- }
-
- int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0
-
- attrValue = "";
-
- do {
- if (attrValue.length()) {
- attrValue.append('|');
- }
-
- attrib = tag.getAttribute("morph", i, splitChar);
-
- if (i < 0) {
- i = 0; // to handle our -1 condition
- }
-
- val = strchr(attrib, ':');
-
- if (val) { //the prefix gives the modulename
- //check the prefix
- if (!strncmp("robinson:", attrib, 9)) { //robinson
- attrValue.append( "Robinson:" ); //work is not the same as Sword's module name
- attrValue.append( val+1 );
- }
- //strongs is handled by BibleTime
- /*else if (!strncmp("strongs", attrib, val-atrrib)) {
- attrValue.append( !strncmp(attrib, "x-", 2) ? attrib+2 : attrib );
- }*/
- else {
- attrValue.append( !strncmp(attrib, "x-", 2) ? attrib+2 : attrib );
- }
- }
- else { //no prefix given
- val = attrib;
- const bool skipFirst = ((val[0] == 'T') && ((val[1] == 'H') || (val[1] == 'H')));
- attrValue.append( skipFirst ? val+1 : val );
- }
- }
- while (++i < count);
-
- if (attrValue.length()) {
- outTag.setAttribute("morph", attrValue.c_str());
- }
- }
-
- if ((attrib = tag.getAttribute("POS"))) {
- val = strchr(attrib, ':');
- val = (val) ? (val + 1) : attrib;
- outTag.setAttribute("pos", val);
- }
-
- buf.append( outTag.toString() );
- }
- else if (tag.isEndTag()) { // end or empty <w> tag
- buf.append("</span>");
- }
- }
-
- // <note> tag
- else if (!strcmp(tag.getName(), "note")) {
- if (!tag.isEndTag()) { //start tag
- const sword::SWBuf type( tag.getAttribute("type") );
-
- if (type == "crossReference") { //note containing cross references
- myUserData->inCrossrefNote = true;
- myUserData->noteType = BT_UserData::CrossReference;
- myUserData->swordFootnote++; // cross refs count as notes, too
-
- /* //get the refList value of the right entry attribute
- AttributeList notes = myModule->getEntryAttributes()["Footnote"];
- bool foundNote = false;
-
- SWBuf id( tag.getAttribute("osisID") );
- SWBuf refList;
-
- for (AttributeList::iterator list_it = notes.begin(); (list_it != notes.end()) && !foundNote; ++list_it ) {
- for (AttributeValue::iterator val_it = list_it->second.begin(); (val_it != list_it->second.end()) && !foundNote; ++val_it ) {
- if ((val_it->first == "osisID") && (val_it->second == id)) {
- foundNote = true; //this break the loop
- refList = list_it->second["refList"];
- }
- }
- }
-
- if (refList.length()) {
- buf.append(" <span class=\"crossreference\" crossrefs=\"");
- buf.append(refList.c_str());
- buf.append("\"> ");
-
- myUserData->noteType = BT_UserData::CrossReference;
- }
- else {
- myUserData->noteType = BT_UserData::Unknown;
- }*/
-
- buf.append("<span class=\"crossreference\">");
- sword::SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
- sword::SWBuf footnoteBody = myUserData->entryAttributes["Footnote"][footnoteNumber]["body"];
- buf += myModule->RenderText(footnoteBody);
- }
-
- /* else if (type == "explanation") {
- }
- */
- else if ((type == "strongsMarkup") || (type == "x-strongsMarkup")) {
- /**
- * leave strong's markup notes out, in the future we'll probably have
- * different option filters to turn different note types on or off
- */
-
- myUserData->suspendTextPassThru = true;
- myUserData->noteType = BT_UserData::StrongsMarkup;
- }
-
- else {
- // qWarning("found note in %s", myUserData->key->getShortText());
- buf.append(" <span class=\"footnote\" note=\"");
- buf.append(myModule->Name());
- buf.append('/');
- buf.append(myUserData->key->getShortText());
- buf.append('/');
- buf.append( QString::number(myUserData->swordFootnote++).toUtf8().constData() ); //inefficient
-
- const sword::SWBuf n = tag.getAttribute("n");
-
- buf.append("\">");
- buf.append( (n.length() > 0) ? n.c_str() : "*" );
- buf.append("</span> ");
-
- myUserData->noteType = BT_UserData::Footnote;
- myUserData->suspendTextPassThru = true;
- }
- }
- else { //if (tag.isEndTag()) {
- Q_ASSERT(myUserData->noteType != BT_UserData::Unknown);
-
- if (myUserData->noteType == BT_UserData::CrossReference) {
- buf.append("</span> ");
+ // manually process if it wasn't a simple substitution
+
+ if (!substituteToken(buf, token)) {
+ BT_UserData* myUserData = dynamic_cast<BT_UserData*>(userData);
+ sword::SWModule* myModule = const_cast<sword::SWModule*>(myUserData->module); //hack
+
+ sword::XMLTag tag(token);
+ // qWarning("found %s", token);
+ const bool osisQToTick = ((!userData->module->getConfigEntry("OSISqToTick")) || (strcmp(userData->module->getConfigEntry("OSISqToTick"), "false")));
+
+ if (!tag.getName()) {
+ return false;
+ }
+
+ // <div> tag
+ if (!strcmp(tag.getName(), "div")) {
+ //handle intro
+
+ if ((!tag.isEmpty()) && (!tag.isEndTag())) { //start tag
+ sword::SWBuf type( tag.getAttribute("type") );
+
+ if (type == "introduction") {
+ buf.append("<div class=\"introduction\">");
+ }
+ else if (type == "chapter") {
+ buf.append("<div class=\"chapter\" />"); //don't open a div here, that would lead to a broken XML structure
+ }
+ else {
+ buf.append("<div>");
+ }
+ }
+ else if (tag.isEndTag()) { //end tag
+ buf.append("</div>");
+ }
+ }
+ else if (!strcmp(tag.getName(), "w")) {
+ if ((!tag.isEmpty()) && (!tag.isEndTag())) { //start tag
+ const char *attrib;
+ const char *val;
+
+ sword::XMLTag outTag("span");
+ sword::SWBuf attrValue;
+
+ if ((attrib = tag.getAttribute("xlit"))) {
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+ outTag.setAttribute("xlit", val);
+ }
+
+ if ((attrib = tag.getAttribute("gloss"))) {
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+ outTag.setAttribute("gloss", val);
+ }
+
+ if ((attrib = tag.getAttribute("lemma"))) {
+ char splitChar = '|';
+ const int countSplit1 = tag.getAttributePartCount("lemma", '|');
+ const int countSplit2 = tag.getAttributePartCount("lemma", ' '); //TODO: not allowed, remove soon
+ int count = 0;
+
+ if (countSplit1 > countSplit2) { //| split char
+ splitChar = '|'; //TODO: not allowed, remove soon
+ count = countSplit1;
+ }
+ else {
+ splitChar = ' ';
+ count = countSplit2;
+ }
+
+ int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0
+ attrValue = "";
+
+ do {
+ if (attrValue.length()) {
+ attrValue.append( '|' );
+ }
+
+ attrib = tag.getAttribute("lemma", i, splitChar);
+
+ if (i < 0) { // to handle our -1 condition
+ i = 0;
+ }
+
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+
+ attrValue.append(val);
+ }
+ while (++i < count);
+
+ if (attrValue.length()) {
+ outTag.setAttribute("lemma", attrValue.c_str());
+ }
+ }
+
+ if ((attrib = tag.getAttribute("morph"))) {
+ char splitChar = '|';
+ const int countSplit1 = tag.getAttributePartCount("morph", '|');
+ const int countSplit2 = tag.getAttributePartCount("morph", ' '); //TODO: not allowed, remove soon
+ int count = 0;
+
+ if (countSplit1 > countSplit2) { //| split char
+ splitChar = '|';
+ count = countSplit1;
+ }
+ else {
+ splitChar = ' ';
+ count = countSplit2;
+ }
+
+ int i = (count > 1) ? 0 : -1; // -1 for whole value cuz it's faster, but does the same thing as 0
+
+ attrValue = "";
+
+ do {
+ if (attrValue.length()) {
+ attrValue.append('|');
+ }
+
+ attrib = tag.getAttribute("morph", i, splitChar);
+
+ if (i < 0) {
+ i = 0; // to handle our -1 condition
+ }
+
+ val = strchr(attrib, ':');
+
+ if (val) { //the prefix gives the modulename
+ //check the prefix
+ if (!strncmp("robinson:", attrib, 9)) { //robinson
+ attrValue.append( "Robinson:" ); //work is not the same as Sword's module name
+ attrValue.append( val + 1 );
+ }
+ //strongs is handled by BibleTime
+ /*else if (!strncmp("strongs", attrib, val-atrrib)) {
+ attrValue.append( !strncmp(attrib, "x-", 2) ? attrib+2 : attrib );
+ }*/
+ else {
+ attrValue.append( !strncmp(attrib, "x-", 2) ? attrib + 2 : attrib );
+ }
+ }
+ else { //no prefix given
+ val = attrib;
+ const bool skipFirst = ((val[0] == 'T') && ((val[1] == 'H') || (val[1] == 'H')));
+ attrValue.append( skipFirst ? val + 1 : val );
+ }
+ }
+ while (++i < count);
+
+ if (attrValue.length()) {
+ outTag.setAttribute("morph", attrValue.c_str());
+ }
+ }
+
+ if ((attrib = tag.getAttribute("POS"))) {
+ val = strchr(attrib, ':');
+ val = (val) ? (val + 1) : attrib;
+ outTag.setAttribute("pos", val);
+ }
+
+ buf.append( outTag.toString() );
+ }
+ else if (tag.isEndTag()) { // end or empty <w> tag
+ buf.append("</span>");
+ }
+ }
+
+ // <note> tag
+ else if (!strcmp(tag.getName(), "note")) {
+ if (!tag.isEndTag()) { //start tag
+ const sword::SWBuf type( tag.getAttribute("type") );
+
+ if (type == "crossReference") { //note containing cross references
+ myUserData->inCrossrefNote = true;
+ myUserData->noteType = BT_UserData::CrossReference;
+
+ /*
+ * Do not count crossrefs as footnotes if they are displayed in the text. This will cause problems
+ * with footnote numbering when crossrefs are turned on/off.
+ * When accessing footnotes, crossrefs must be turned off in the filter so that they are not in the entry
+ * attributes of Sword.
+ *
+ * //myUserData->swordFootnote++; // cross refs count as notes, too
+ */
+
+ buf.append("<span class=\"crossreference\">");
+ sword::SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
+ sword::SWBuf footnoteBody = myUserData->entryAttributes["Footnote"][footnoteNumber]["body"];
+ buf += myModule->RenderText(footnoteBody);
+ }
+
+ /* else if (type == "explanation") {
+ }
+ */
+ else if ((type == "strongsMarkup") || (type == "x-strongsMarkup")) {
+ /**
+ * leave strong's markup notes out, in the future we'll probably have
+ * different option filters to turn different note types on or off
+ */
+
+ myUserData->suspendTextPassThru = true;
+ myUserData->noteType = BT_UserData::StrongsMarkup;
+ }
+
+ else {
+ // qWarning("found note in %s", myUserData->key->getShortText());
+ buf.append(" <span class=\"footnote\" note=\"");
+ buf.append(myModule->Name());
+ buf.append('/');
+ buf.append(myUserData->key->getShortText());
+ buf.append('/');
+ buf.append( QString::number(myUserData->swordFootnote++).toUtf8().constData() ); //inefficient
+
+ const sword::SWBuf n = tag.getAttribute("n");
+
+ buf.append("\">");
+ buf.append( (n.length() > 0) ? n.c_str() : "*" );
+ buf.append("</span> ");
+
+ myUserData->noteType = BT_UserData::Footnote;
+ myUserData->suspendTextPassThru = true;
+ }
+ }
+ else { //if (tag.isEndTag()) {
+ Q_ASSERT(myUserData->noteType != BT_UserData::Unknown);
+
+ if (myUserData->noteType == BT_UserData::CrossReference) {
+ buf.append("</span> ");
// myUserData->suspendTextPassThru = false;
- myUserData->inCrossrefNote = false;
- }
-
- myUserData->noteType = BT_UserData::Unknown;
- myUserData->suspendTextPassThru = false;
- }
- }
- // The <p> paragraph tag is handled by OSISHTMLHref
- else if (!strcmp(tag.getName(), "reference")) { // <reference> tag
- if (!tag.isEndTag() && !tag.isEmpty()) {
-
- renderReference(tag.getAttribute("osisRef"), buf, myModule, myUserData);
-
- }
- else if (tag.isEndTag()) {
- buf.append("</a>");
- }
- else { // empty reference marker
- // -- what should we do? nothing for now.
- }
- }
-
- // <l> is handled by OSISHTMLHref
- // <title>
- else if (!strcmp(tag.getName(), "title")) {
- if (!tag.isEndTag() && !tag.isEmpty()) {
- buf.append("<div class=\"sectiontitle\">");
- }
- else if (tag.isEndTag()) {
- buf.append("</div>");
- }
- else { // empty title marker
- // what to do? is this even valid?
- buf.append("<br/>");
- }
- }
-
- // <hi> highlighted text
- else if (!strcmp(tag.getName(), "hi")) {
- const sword::SWBuf type = tag.getAttribute("type");
-
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- if (type == "bold") {
- buf.append("<span class=\"bold\">");
- }
- else if (type == "illuminated") {
- buf.append("<span class=\"illuminated\">");
- }
- else if (type == "italic") {
- buf.append("<span class=\"italic\">");
- }
- else if (type == "line-through") {
- buf.append("<span class=\"line-through\">");
- }
- else if (type == "normal") {
- buf.append("<span class=\"normal\">");
- }
- else if (type == "small-caps") {
- buf.append("<span class=\"small-caps\">");
- }
- else if (type == "underline") {
- buf.append("<span class=\"underline\">");
- }
- else {
- buf.append("<span>"); //don't break markup, </span> is inserted later
- }
- }
- else if (tag.isEndTag()) { //all hi replacements are html spans
- buf.append("</span>");
- }
- }
-
- //name
- else if (!strcmp(tag.getName(), "name")) {
- const sword::SWBuf type = tag.getAttribute("type");
-
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- if (type == "geographic") {
- buf.append("<span class=\"name\"><span class=\"geographic\">");
- }
- else if (type == "holiday") {
- buf.append("<span class=\"name\"><span class=\"holiday\">");
- }
- else if (type == "nonhuman") {
- buf.append("<span class=\"name\"><span class=\"nonhuman\">");
- }
- else if (type == "person") {
- buf.append("<span class=\"name\"><span class=\"person\">");
- }
- else if (type == "ritual") {
- buf.append("<span class=\"name\"><span class=\"ritual\">");
- }
- else {
- buf.append("<span class=\"name\"><span>");
- }
- }
- else if (tag.isEndTag()) { //all hi replacements are html spans
- buf.append("</span></span> ");
- }
- }
- else if (!strcmp(tag.getName(), "transChange")) {
- sword::SWBuf type( tag.getAttribute("type") );
-
- if ( !type.length() ) {
- type = tag.getAttribute("changeType");
- }
-
- if ((!tag.isEndTag()) && (!tag.isEmpty())) {
- if (type == "added") {
- buf.append("<span class=\"transchange\" title=\"");
- buf.append(QObject::tr("Added text").toUtf8().constData());
- buf.append("\"><span class=\"added\">");
- }
- else if (type == "amplified") {
- buf.append("<span class=\"transchange\"><span class=\"amplified\">");
- }
- else if (type == "changed") {
- buf.append("<span class=\"transchange\"><span class=\"changed\">");
- }
- else if (type == "deleted") {
- buf.append("<span class=\"transchange\"><span class=\"deleted\">");
- }
- else if (type == "moved") {
- buf.append("<span class=\"transchange\"><span class=\"moved\">");
- }
- else if (type == "tenseChange") {
- buf.append("<span class=\"transchange\" title=\"");
- buf.append(QObject::tr("Verb tense changed").toUtf8().constData());
- buf.append("\"><span class=\"tenseChange\">");
- }
- else {
- buf.append("<span class=\"transchange\"><span>");
- }
- }
- else if (tag.isEndTag()) { //all hi replacements are html spans
- buf.append("</span></span>");
- }
- }
- else if (!strcmp(tag.getName(), "p")) {
- if (tag.isEmpty()) {
- buf.append("<p/>");
- }
- }
-
- // <q> quote
- else if (!strcmp(tag.getName(), "q")) {
- sword::SWBuf type = tag.getAttribute("type");
- sword::SWBuf who = tag.getAttribute("who");
- const char *lev = tag.getAttribute("level");
- int level = (lev) ? atoi(lev) : 1;
- const char* quoteMarker = tag.getAttribute("marker");
-
- if ((!tag.isEndTag())) {
- myUserData->quote.who = who;
- if (quoteMarker) {
- buf.append(quoteMarker);
- }
- else if(osisQToTick) //alternate " and '
- buf.append((level % 2) ? '\"' : '\'');
-
- if (who == "Jesus") {
- buf.append("<span class=\"jesuswords\">");
- }
- }
- else if (tag.isEndTag()) {
- if (myUserData->quote.who == "Jesus") {
- buf.append("</span>");
- }
- if (quoteMarker) {
- buf.append(quoteMarker);
- }
- else if (osisQToTick) { //alternate " and '
- buf.append((level % 2) ? '\"' : '\'');
- }
-
- myUserData->quote.who = "";
- }
- }
-
- // abbr tag
- else if (!strcmp(tag.getName(), "abbr")) {
- if (!tag.isEndTag() && !tag.isEmpty()) {
- const sword::SWBuf expansion = tag.getAttribute("expansion");
-
- buf.append("<span class=\"abbreviation\" expansion=\"");
- buf.append(expansion);
- buf.append("\">");
- }
- else if (tag.isEndTag()) {
- buf.append("</span>");
- }
- }
-
- // <milestone> tag
- else if (!strcmp(tag.getName(), "milestone")) {
- const sword::SWBuf type = tag.getAttribute("type");
-
- if ((type == "screen") || (type == "line")) {//line break
- buf.append("<br/>");
- userData->supressAdjacentWhitespace = true;
- }
- else if (type == "x-p") { //e.g. occurs in the KJV2006 module
- //buf.append("<br/>");
- const sword::SWBuf marker = tag.getAttribute("marker");
- if (marker.length() > 0) {
- buf.append(marker);
- }
- }
- }
- //seg tag
- else if (!strcmp(tag.getName(), "seg")) {
- if (!tag.isEndTag() && !tag.isEmpty()) {
-
- const sword::SWBuf type = tag.getAttribute("type");
-
- if (type == "morph") {//line break
- //This code is for WLC and MORPH (WHI)
- sword::XMLTag outTag("span");
- outTag.setAttribute("class", "morphSegmentation");
- const char* attrValue;
- //Transfer the values to the span
- //Problem: the data is in hebrew/aramaic, how to encode in HTML/BibleTime?
- if ((attrValue = tag.getAttribute("lemma"))) outTag.setAttribute("lemma", attrValue);
- if ((attrValue = tag.getAttribute("morph"))) outTag.setAttribute("morph", attrValue);
- if ((attrValue = tag.getAttribute("homonym"))) outTag.setAttribute("homonym", attrValue);
-
- buf.append(outTag.toString());
- //buf.append("<span class=\"morphSegmentation\">");
- }
- else{
- buf.append("<span>");
- }
- }
- else { // seg end tag
- buf.append("</span>");
- }
- //qWarning(QString("handled <seg> token. result: %1").arg(buf.c_str()).latin1());
- }
-
- //divine name, don't use simple tag replacing because it may have attributes
- else if (!strcmp(tag.getName(), "divineName")) {
- if (!tag.isEndTag()) {
- buf.append("<span class=\"name\"><span class=\"divine\">");
- }
- else { //all hi replacements are html spans
- buf.append("</span></span>");
- }
- }
-
- else { //all tokens handled by OSISHTMLHref will run through the filter now
- return sword::OSISHTMLHREF::handleToken(buf, token, userData);
- }
- }
-
- return false;
+ myUserData->inCrossrefNote = false;
+ }
+
+ myUserData->noteType = BT_UserData::Unknown;
+ myUserData->suspendTextPassThru = false;
+ }
+ }
+ // The <p> paragraph tag is handled by OSISHTMLHref
+ else if (!strcmp(tag.getName(), "reference")) { // <reference> tag
+ if (!tag.isEndTag() && !tag.isEmpty()) {
+
+ renderReference(tag.getAttribute("osisRef"), buf, myModule, myUserData);
+
+ }
+ else if (tag.isEndTag()) {
+ buf.append("</a>");
+ }
+ else { // empty reference marker
+ // -- what should we do? nothing for now.
+ }
+ }
+
+ // <l> is handled by OSISHTMLHref
+ // <title>
+ else if (!strcmp(tag.getName(), "title")) {
+ if (!tag.isEndTag() && !tag.isEmpty()) {
+ buf.append("<div class=\"sectiontitle\">");
+ }
+ else if (tag.isEndTag()) {
+ buf.append("</div>");
+ }
+ else { // empty title marker
+ // what to do? is this even valid?
+ buf.append("<br/>");
+ }
+ }
+
+ // <hi> highlighted text
+ else if (!strcmp(tag.getName(), "hi")) {
+ const sword::SWBuf type = tag.getAttribute("type");
+
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (type == "bold") {
+ buf.append("<span class=\"bold\">");
+ }
+ else if (type == "illuminated") {
+ buf.append("<span class=\"illuminated\">");
+ }
+ else if (type == "italic") {
+ buf.append("<span class=\"italic\">");
+ }
+ else if (type == "line-through") {
+ buf.append("<span class=\"line-through\">");
+ }
+ else if (type == "normal") {
+ buf.append("<span class=\"normal\">");
+ }
+ else if (type == "small-caps") {
+ buf.append("<span class=\"small-caps\">");
+ }
+ else if (type == "underline") {
+ buf.append("<span class=\"underline\">");
+ }
+ else {
+ buf.append("<span>"); //don't break markup, </span> is inserted later
+ }
+ }
+ else if (tag.isEndTag()) { //all hi replacements are html spans
+ buf.append("</span>");
+ }
+ }
+
+ //name
+ else if (!strcmp(tag.getName(), "name")) {
+ const sword::SWBuf type = tag.getAttribute("type");
+
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (type == "geographic") {
+ buf.append("<span class=\"name\"><span class=\"geographic\">");
+ }
+ else if (type == "holiday") {
+ buf.append("<span class=\"name\"><span class=\"holiday\">");
+ }
+ else if (type == "nonhuman") {
+ buf.append("<span class=\"name\"><span class=\"nonhuman\">");
+ }
+ else if (type == "person") {
+ buf.append("<span class=\"name\"><span class=\"person\">");
+ }
+ else if (type == "ritual") {
+ buf.append("<span class=\"name\"><span class=\"ritual\">");
+ }
+ else {
+ buf.append("<span class=\"name\"><span>");
+ }
+ }
+ else if (tag.isEndTag()) { //all hi replacements are html spans
+ buf.append("</span></span> ");
+ }
+ }
+ else if (!strcmp(tag.getName(), "transChange")) {
+ sword::SWBuf type( tag.getAttribute("type") );
+
+ if ( !type.length() ) {
+ type = tag.getAttribute("changeType");
+ }
+
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (type == "added") {
+ buf.append("<span class=\"transchange\" title=\"");
+ buf.append(QObject::tr("Added text").toUtf8().constData());
+ buf.append("\"><span class=\"added\">");
+ }
+ else if (type == "amplified") {
+ buf.append("<span class=\"transchange\"><span class=\"amplified\">");
+ }
+ else if (type == "changed") {
+ buf.append("<span class=\"transchange\"><span class=\"changed\">");
+ }
+ else if (type == "deleted") {
+ buf.append("<span class=\"transchange\"><span class=\"deleted\">");
+ }
+ else if (type == "moved") {
+ buf.append("<span class=\"transchange\"><span class=\"moved\">");
+ }
+ else if (type == "tenseChange") {
+ buf.append("<span class=\"transchange\" title=\"");
+ buf.append(QObject::tr("Verb tense changed").toUtf8().constData());
+ buf.append("\"><span class=\"tenseChange\">");
+ }
+ else {
+ buf.append("<span class=\"transchange\"><span>");
+ }
+ }
+ else if (tag.isEndTag()) { //all hi replacements are html spans
+ buf.append("</span></span>");
+ }
+ }
+ else if (!strcmp(tag.getName(), "p")) {
+ if (tag.isEmpty()) {
+ buf.append("<p/>");
+ }
+ }
+
+ // <q> quote
+ else if (!strcmp(tag.getName(), "q")) {
+ sword::SWBuf type = tag.getAttribute("type");
+ sword::SWBuf who = tag.getAttribute("who");
+ const char *lev = tag.getAttribute("level");
+ int level = (lev) ? atoi(lev) : 1;
+ const char* quoteMarker = tag.getAttribute("marker");
+
+ if ((!tag.isEndTag())) {
+ myUserData->quote.who = who;
+ if (quoteMarker) {
+ buf.append(quoteMarker);
+ }
+ else if (osisQToTick) //alternate " and '
+ buf.append((level % 2) ? '\"' : '\'');
+
+ if (who == "Jesus") {
+ buf.append("<span class=\"jesuswords\">");
+ }
+ }
+ else if (tag.isEndTag()) {
+ if (myUserData->quote.who == "Jesus") {
+ buf.append("</span>");
+ }
+ if (quoteMarker) {
+ buf.append(quoteMarker);
+ }
+ else if (osisQToTick) { //alternate " and '
+ buf.append((level % 2) ? '\"' : '\'');
+ }
+
+ myUserData->quote.who = "";
+ }
+ }
+
+ // abbr tag
+ else if (!strcmp(tag.getName(), "abbr")) {
+ if (!tag.isEndTag() && !tag.isEmpty()) {
+ const sword::SWBuf expansion = tag.getAttribute("expansion");
+
+ buf.append("<span class=\"abbreviation\" expansion=\"");
+ buf.append(expansion);
+ buf.append("\">");
+ }
+ else if (tag.isEndTag()) {
+ buf.append("</span>");
+ }
+ }
+
+ // <milestone> tag
+ else if (!strcmp(tag.getName(), "milestone")) {
+ const sword::SWBuf type = tag.getAttribute("type");
+
+ if ((type == "screen") || (type == "line")) {//line break
+ buf.append("<br/>");
+ userData->supressAdjacentWhitespace = true;
+ }
+ else if (type == "x-p") { //e.g. occurs in the KJV2006 module
+ //buf.append("<br/>");
+ const sword::SWBuf marker = tag.getAttribute("marker");
+ if (marker.length() > 0) {
+ buf.append(marker);
+ }
+ }
+ }
+ //seg tag
+ else if (!strcmp(tag.getName(), "seg")) {
+ if (!tag.isEndTag() && !tag.isEmpty()) {
+
+ const sword::SWBuf type = tag.getAttribute("type");
+
+ if (type == "morph") {//line break
+ //This code is for WLC and MORPH (WHI)
+ sword::XMLTag outTag("span");
+ outTag.setAttribute("class", "morphSegmentation");
+ const char* attrValue;
+ //Transfer the values to the span
+ //Problem: the data is in hebrew/aramaic, how to encode in HTML/BibleTime?
+ if ((attrValue = tag.getAttribute("lemma"))) outTag.setAttribute("lemma", attrValue);
+ if ((attrValue = tag.getAttribute("morph"))) outTag.setAttribute("morph", attrValue);
+ if ((attrValue = tag.getAttribute("homonym"))) outTag.setAttribute("homonym", attrValue);
+
+ buf.append(outTag.toString());
+ //buf.append("<span class=\"morphSegmentation\">");
+ }
+ else {
+ buf.append("<span>");
+ }
+ }
+ else { // seg end tag
+ buf.append("</span>");
+ }
+ //qWarning(QString("handled <seg> token. result: %1").arg(buf.c_str()).latin1());
+ }
+
+ //divine name, don't use simple tag replacing because it may have attributes
+ else if (!strcmp(tag.getName(), "divineName")) {
+ if (!tag.isEndTag()) {
+ buf.append("<span class=\"name\"><span class=\"divine\">");
+ }
+ else { //all hi replacements are html spans
+ buf.append("</span></span>");
+ }
+ }
+
+ else { //all tokens handled by OSISHTMLHref will run through the filter now
+ return sword::OSISHTMLHREF::handleToken(buf, token, userData);
+ }
+ }
+
+ return false;
}
void Filters::BT_OSISHTML::renderReference(const char *osisRef, sword::SWBuf &buf, sword::SWModule *myModule, BT_UserData *myUserData) {
- QString ref( osisRef );
- QString hrefRef( ref );
- //Q_ASSERT(!ref.isEmpty()); checked later
-
- if (!ref.isEmpty()) {
- //find out the mod, using the current module makes sense if it's a bible or commentary because the refs link into a bible by default.
- //If the osisRef is something like "ModuleID:key comes here" then the
- // modulename is given, so we'll use that one
-
- CSwordModuleInfo* mod = CPointers::backend()->findSwordModuleByPointer(myModule);
- //Q_ASSERT(mod); checked later
- if (!mod || (mod->type() != CSwordModuleInfo::Bible
- && mod->type() != CSwordModuleInfo::Commentary)) {
-
- mod = CBTConfig::get( CBTConfig::standardBible );
- }
-
- // Q_ASSERT(mod); There's no necessarily a module or standard Bible
-
- //if the osisRef like "GerLut:key" contains a module, use that
- int pos = ref.indexOf(":");
-
- if ((pos >= 0) && ref.at(pos-1).isLetter() && ref.at(pos+1).isLetter()) {
- QString newModuleName = ref.left(pos);
- hrefRef = ref.mid(pos+1);
-
- if (CPointers::backend()->findModuleByName(newModuleName)) {
- mod = CPointers::backend()->findModuleByName(newModuleName);
- }
- }
-
- if (mod) {
- CReferenceManager::ParseOptions options;
- options.refBase = QString::fromUtf8(myUserData->key->getText());
- options.refDestinationModule = QString(mod->name());
- options.sourceLanguage = QString(myModule->Lang());
- options.destinationLanguage = QString("en");
-
- buf.append("<a href=\"");
- buf.append( //create the hyperlink with key and mod
- CReferenceManager::encodeHyperlink(
- mod->name(),
- CReferenceManager::parseVerseReference(hrefRef, options),
- CReferenceManager::typeFromModule(mod->type())
- ).toUtf8().constData()
- );
- buf.append("\" crossrefs=\"");
- buf.append((const char*)CReferenceManager::parseVerseReference(ref, options).toUtf8().constData()); //ref must contain the osisRef module marker if there was any
- buf.append("\">");
- }
- // should we add something if there were no referenced module available?
- }
+ QString ref( osisRef );
+ QString hrefRef( ref );
+ //Q_ASSERT(!ref.isEmpty()); checked later
+
+ if (!ref.isEmpty()) {
+ //find out the mod, using the current module makes sense if it's a bible or commentary because the refs link into a bible by default.
+ //If the osisRef is something like "ModuleID:key comes here" then the
+ // modulename is given, so we'll use that one
+
+ CSwordModuleInfo* mod = CPointers::backend()->findSwordModuleByPointer(myModule);
+ //Q_ASSERT(mod); checked later
+ if (!mod || (mod->type() != CSwordModuleInfo::Bible
+ && mod->type() != CSwordModuleInfo::Commentary)) {
+
+ mod = CBTConfig::get( CBTConfig::standardBible );
+ }
+
+ // Q_ASSERT(mod); There's no necessarily a module or standard Bible
+
+ //if the osisRef like "GerLut:key" contains a module, use that
+ int pos = ref.indexOf(":");
+
+ if ((pos >= 0) && ref.at(pos - 1).isLetter() && ref.at(pos + 1).isLetter()) {
+ QString newModuleName = ref.left(pos);
+ hrefRef = ref.mid(pos + 1);
+
+ if (CPointers::backend()->findModuleByName(newModuleName)) {
+ mod = CPointers::backend()->findModuleByName(newModuleName);
+ }
+ }
+
+ if (mod) {
+ CReferenceManager::ParseOptions options;
+ options.refBase = QString::fromUtf8(myUserData->key->getText());
+ options.refDestinationModule = QString(mod->name());
+ options.sourceLanguage = QString(myModule->Lang());
+ options.destinationLanguage = QString("en");
+
+ buf.append("<a href=\"");
+ buf.append( //create the hyperlink with key and mod
+ CReferenceManager::encodeHyperlink(
+ mod->name(),
+ CReferenceManager::parseVerseReference(hrefRef, options),
+ CReferenceManager::typeFromModule(mod->type())
+ ).toUtf8().constData()
+ );
+ buf.append("\" crossrefs=\"");
+ buf.append((const char*)CReferenceManager::parseVerseReference(ref, options).toUtf8().constData()); //ref must contain the osisRef module marker if there was any
+ buf.append("\">");
+ }
+ // should we add something if there were no referenced module available?
+ }
}
diff --git a/src/backend/filters/bt_osishtml.h b/src/backend/filters/bt_osishtml.h
index 175ee4b..04b68ec 100644
--- a/src/backend/filters/bt_osishtml.h
+++ b/src/backend/filters/bt_osishtml.h
@@ -17,53 +17,53 @@
namespace Filters {
- /** BibleTime's OSIS to HTMl filter.
- * This filter works on OSIS tags and outputs HTML in the structure supported by BibleTime.
- */
+/** BibleTime's OSIS to HTMl filter.
+* This filter works on OSIS tags and outputs HTML in the structure supported by BibleTime.
+*/
class BT_OSISHTML : public sword::OSISHTMLHREF {
-protected:
-
-class BT_UserData : public sword::OSISHTMLHREF::MyUserData {
-
-public:
-BT_UserData(const sword::SWModule *module, const sword::SWKey *key) : sword::OSISHTMLHREF::MyUserData(module, key) {
- noteType = Unknown;
- swordFootnote = 1;
- inCrossrefNote = false;
- entryAttributes = module->getEntryAttributes();
- }
-
- unsigned short int swordFootnote;
- bool inCrossrefNote;
- sword::AttributeTypeList entryAttributes;
-
- enum NoteType {
- Unknown,
- Alternative,
- CrossReference,
- Footnote,
- StrongsMarkup
- } noteType;
-
- struct {
- sword::SWBuf who;
- }
-
- quote;
- };
-
- virtual sword::BasicFilterUserData *createUserData(const sword::SWModule* module, const sword::SWKey* key) {
- return new BT_UserData(module, key);
- }
-
-public:
- BT_OSISHTML();
- virtual bool handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData);
-private:
- void renderReference(const char *osisRef, sword::SWBuf &buf, sword::SWModule *myModule, BT_UserData *myUserData);
- };
+ protected:
+
+ class BT_UserData : public sword::OSISHTMLHREF::MyUserData {
+
+ public:
+ BT_UserData(const sword::SWModule *module, const sword::SWKey *key) : sword::OSISHTMLHREF::MyUserData(module, key) {
+ noteType = Unknown;
+ swordFootnote = 1;
+ inCrossrefNote = false;
+ entryAttributes = module->getEntryAttributes();
+ }
+
+ unsigned short int swordFootnote;
+ bool inCrossrefNote;
+ sword::AttributeTypeList entryAttributes;
+
+ enum NoteType {
+ Unknown,
+ Alternative,
+ CrossReference,
+ Footnote,
+ StrongsMarkup
+ } noteType;
+
+ struct {
+ sword::SWBuf who;
+ }
+
+ quote;
+ };
+
+ virtual sword::BasicFilterUserData *createUserData(const sword::SWModule* module, const sword::SWKey* key) {
+ return new BT_UserData(module, key);
+ }
+
+ public:
+ BT_OSISHTML();
+ virtual bool handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData);
+ private:
+ void renderReference(const char *osisRef, sword::SWBuf &buf, sword::SWModule *myModule, BT_UserData *myUserData);
+};
} //end of Filters namespace
diff --git a/src/backend/filters/bt_plainhtml.cpp b/src/backend/filters/bt_plainhtml.cpp
index 4ee98b4..d26d8ed 100644
--- a/src/backend/filters/bt_plainhtml.cpp
+++ b/src/backend/filters/bt_plainhtml.cpp
@@ -14,59 +14,55 @@ Filters::BT_PLAINHTML::BT_PLAINHTML() : sword::SWFilter() {
/** No descriptions */
char Filters::BT_PLAINHTML::processText(sword::SWBuf& text, const sword::SWKey* /*key*/, const sword::SWModule* /*module*/) {
- int count = 0;
+ int count = 0;
- sword::SWBuf orig = text;
- const char *from = orig.c_str();
- for (text = ""; *from; from++)
- {
- if ((*from == '\n') && (from[1] == '\n')) // two newlinea are a paragraph
- {
- text += "<P>";
- from++;
- continue;
- }
- //This is a special case: Newlines in the plaintext editor are stored as <br />, not as \n
- //we need to let them through
- else if ((*from == '<') && (from[1] == 'b') && (from[2] == 'r') && (from[3] == ' ') && (from[4] == '/') && (from[5] == '>')){
- text += "<br />";
- from += 5;
- continue;
- }
- else if ((*from == '\n')){ // only one new line
- text += "<BR>";
- continue;
- }
- else if (*from == '<') {
- text += "&lt;";
- continue;
- }
- else if (*from == '>') {
- text += "&gt;";
- continue;
- }
- else if (*from == '&'){
- text += "&amp;";
- continue;
- }
- else if (*from == '{') { //footnote start
+ sword::SWBuf orig = text;
+ const char *from = orig.c_str();
+ for (text = ""; *from; from++) {
+ if ((*from == '\n') && (from[1] == '\n')) { // two newlinea are a paragraph
+ text += "<P>";
+ from++;
+ continue;
+ }
+ //This is a special case: Newlines in the plaintext editor are stored as <br />, not as \n
+ //we need to let them through
+ else if ((*from == '<') && (from[1] == 'b') && (from[2] == 'r') && (from[3] == ' ') && (from[4] == '/') && (from[5] == '>')) {
+ text += "<br />";
+ from += 5;
+ continue;
+ }
+ else if ((*from == '\n')) { // only one new line
+ text += "<BR>";
+ continue;
+ }
+ else if (*from == '<') {
+ text += "&lt;";
+ continue;
+ }
+ else if (*from == '>') {
+ text += "&gt;";
+ continue;
+ }
+ else if (*from == '&') {
+ text += "&amp;";
+ continue;
+ }
+ else if (*from == '{') { //footnote start
text += "<FONT COLOR=\"#800000\"><SMALL> ("; /// \bug Possible color conflict
- continue;
- }
- else if (*from == '}') //footnote end
- {
- text += ") </SMALL></FONT>";
- continue;
- }
- else if ((*from == ' ') && (count > 5000))
- {
- text += "<WBR>";
- count = 0;
- continue;
- }
+ continue;
+ }
+ else if (*from == '}') { //footnote end
+ text += ") </SMALL></FONT>";
+ continue;
+ }
+ else if ((*from == ' ') && (count > 5000)) {
+ text += "<WBR>";
+ count = 0;
+ continue;
+ }
- text += *from;
- count++;
- }
- return 0;
+ text += *from;
+ count++;
+ }
+ return 0;
}
diff --git a/src/backend/filters/bt_plainhtml.h b/src/backend/filters/bt_plainhtml.h
index ce1ef36..0430e51 100644
--- a/src/backend/filters/bt_plainhtml.h
+++ b/src/backend/filters/bt_plainhtml.h
@@ -19,15 +19,15 @@ class SWModule;
namespace Filters {
- /** Plain to HTML filter,
- * This filter converts Plain Text into HTML
- */
-class BT_PLAINHTML : public sword::SWFilter{
-protected:
- virtual char processText(sword::SWBuf& buf, const sword::SWKey*, const sword::SWModule * = 0);
-public:
- BT_PLAINHTML();
- };
+/** Plain to HTML filter,
+* This filter converts Plain Text into HTML
+*/
+class BT_PLAINHTML : public sword::SWFilter {
+ protected:
+ virtual char processText(sword::SWBuf& buf, const sword::SWKey*, const sword::SWModule * = 0);
+ public:
+ BT_PLAINHTML();
+};
}
#endif
diff --git a/src/backend/filters/bt_thmlhtml.cpp b/src/backend/filters/bt_thmlhtml.cpp
index a5f17d2..4ee333d 100644
--- a/src/backend/filters/bt_thmlhtml.cpp
+++ b/src/backend/filters/bt_thmlhtml.cpp
@@ -28,358 +28,358 @@
#include <QRegExp>
Filters::BT_ThMLHTML::BT_ThMLHTML() {
- setEscapeStringCaseSensitive(true);
- setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
+ setEscapeStringCaseSensitive(true);
+ setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
- setTokenStart("<");
- setTokenEnd(">");
- setTokenCaseSensitive(true);
+ setTokenStart("<");
+ setTokenEnd(">");
+ setTokenCaseSensitive(true);
- addTokenSubstitute("/foreign", "</span>");
+ addTokenSubstitute("/foreign", "</span>");
- removeTokenSubstitute("note");
- removeTokenSubstitute("/note");
+ removeTokenSubstitute("note");
+ removeTokenSubstitute("/note");
}
char Filters::BT_ThMLHTML::processText(sword::SWBuf& buf, const sword::SWKey* key, const sword::SWModule* module) {
- sword::ThMLHTML::processText(buf, key, module);
+ sword::ThMLHTML::processText(buf, key, module);
- CSwordModuleInfo* m = CPointers::backend()->findModuleByName( module->Name() );
+ CSwordModuleInfo* m = CPointers::backend()->findModuleByName( module->Name() );
- if (m && !(m->has(CSwordModuleInfo::lemmas) || m->has(CSwordModuleInfo::strongNumbers))) { //only parse if the module has strongs or lemmas
- return 1;
- }
+ if (m && !(m->has(CSwordModuleInfo::lemmas) || m->has(CSwordModuleInfo::strongNumbers))) { //only parse if the module has strongs or lemmas
+ return 1;
+ }
- QString result;
+ QString result;
- QString t = QString::fromUtf8(buf.c_str());
- QRegExp tag("([.,;]?<sync[^>]+(type|value)=\"([^\"]+)\"[^>]+(type|value)=\"([^\"]+)\"([^<]*)>)+");
+ QString t = QString::fromUtf8(buf.c_str());
+ QRegExp tag("([.,;]?<sync[^>]+(type|value)=\"([^\"]+)\"[^>]+(type|value)=\"([^\"]+)\"([^<]*)>)+");
- QStringList list;
- int lastMatchEnd = 0;
- int pos = tag.indexIn(t,0);
+ QStringList list;
+ int lastMatchEnd = 0;
+ int pos = tag.indexIn(t, 0);
- if (pos == -1) { //no strong or morph code found in this text
- return 1; //WARNING: Return alread here
- }
+ if (pos == -1) { //no strong or morph code found in this text
+ return 1; //WARNING: Return alread here
+ }
- while (pos != -1) {
- list.append(t.mid(lastMatchEnd, pos+tag.matchedLength()-lastMatchEnd));
-
- lastMatchEnd = pos+tag.matchedLength();
- pos = tag.indexIn(t,pos+tag.matchedLength());
- }
-
- if (!t.right(t.length() - lastMatchEnd).isEmpty()) {
- list.append(t.right(t.length() - lastMatchEnd));
- }
-
- tag = QRegExp("<sync[^>]+(type|value|class)=\"([^\"]+)\"[^>]+(type|value|class)=\"([^\"]+)\"[^>]+((type|value|class)=\"([^\"]+)\")*([^<]*)>");
+ while (pos != -1) {
+ list.append(t.mid(lastMatchEnd, pos + tag.matchedLength() - lastMatchEnd));
+
+ lastMatchEnd = pos + tag.matchedLength();
+ pos = tag.indexIn(t, pos + tag.matchedLength());
+ }
+
+ if (!t.right(t.length() - lastMatchEnd).isEmpty()) {
+ list.append(t.right(t.length() - lastMatchEnd));
+ }
+
+ tag = QRegExp("<sync[^>]+(type|value|class)=\"([^\"]+)\"[^>]+(type|value|class)=\"([^\"]+)\"[^>]+((type|value|class)=\"([^\"]+)\")*([^<]*)>");
- for (QStringList::iterator it = list.begin(); it != list.end(); ++it) {
- QString e( *it );
-
- const bool textPresent = (e.trimmed().remove(QRegExp("[.,;:]")).left(1) != "<");
+ for (QStringList::iterator it = list.begin(); it != list.end(); ++it) {
+ QString e( *it );
+
+ const bool textPresent = (e.trimmed().remove(QRegExp("[.,;:]")).left(1) != "<");
- if (!textPresent) {
- continue;
- }
+ if (!textPresent) {
+ continue;
+ }
- bool hasLemmaAttr = false;
- bool hasMorphAttr = false;
-
- int pos = tag.indexIn(e, 0);
- bool insertedTag = false;
- QString value;
- QString valueClass;
+ bool hasLemmaAttr = false;
+ bool hasMorphAttr = false;
+
+ int pos = tag.indexIn(e, 0);
+ bool insertedTag = false;
+ QString value;
+ QString valueClass;
- while (pos != -1) {
- bool isMorph = false;
- bool isStrongs = false;
- value = QString::null;
- valueClass = QString::null;
+ while (pos != -1) {
+ bool isMorph = false;
+ bool isStrongs = false;
+ value = QString::null;
+ valueClass = QString::null;
- // check 3 attribute/value pairs
+ // check 3 attribute/value pairs
- for (int i = 1; i < 6; i += 2) {
- if (i > 4)
- i++;
+ for (int i = 1; i < 6; i += 2) {
+ if (i > 4)
+ i++;
- if (tag.cap(i) == "type") {
- isMorph = (tag.cap(i+1) == "morph");
- isStrongs = (tag.cap(i+1) == "Strongs");
- }
- else if (tag.cap(i) == "value") {
- value = tag.cap(i+1);
- }
- else if (tag.cap(i) == "class") {
- valueClass = tag.cap(i+1);
- }
- }
+ if (tag.cap(i) == "type") {
+ isMorph = (tag.cap(i + 1) == "morph");
+ isStrongs = (tag.cap(i + 1) == "Strongs");
+ }
+ else if (tag.cap(i) == "value") {
+ value = tag.cap(i + 1);
+ }
+ else if (tag.cap(i) == "class") {
+ valueClass = tag.cap(i + 1);
+ }
+ }
- // prepend the class qualifier to the value
- if (!valueClass.isEmpty()) {
- value = valueClass + ":" + value;
- // value.append(":").append(value);
- }
+ // prepend the class qualifier to the value
+ if (!valueClass.isEmpty()) {
+ value = valueClass + ":" + value;
+ // value.append(":").append(value);
+ }
- if (value.isEmpty()) {
- break;
- }
+ if (value.isEmpty()) {
+ break;
+ }
- //insert the span
- if (!insertedTag) {
- e.replace(pos, tag.matchedLength(), "</span>");
- pos += 7;
+ //insert the span
+ if (!insertedTag) {
+ e.replace(pos, tag.matchedLength(), "</span>");
+ pos += 7;
- QString rep = QString("<span lemma=\"").append(value).append("\">");
- int startPos = 0;
- QChar c = e[startPos];
+ QString rep = QString("<span lemma=\"").append(value).append("\">");
+ int startPos = 0;
+ QChar c = e[startPos];
- while ((startPos < pos) && (c.isSpace() || c.isPunct())) {
- ++startPos;
- c = e[startPos];
- }
+ while ((startPos < pos) && (c.isSpace() || c.isPunct())) {
+ ++startPos;
+ c = e[startPos];
+ }
- hasLemmaAttr = isStrongs;
- hasMorphAttr = isMorph;
-
- e.insert( startPos, rep );
- pos += rep.length();
- }
- else { //add the attribute to the existing tag
- e.remove(pos, tag.matchedLength());
-
- if ((!isMorph && hasLemmaAttr) || (isMorph && hasMorphAttr)) { //we append another attribute value, e.g. 3000 gets 3000|5000
- //search the existing attribute start
- QRegExp attrRegExp( isMorph ? "morph=\".+(?=\")" : "lemma=\".+(?=\")" );
- attrRegExp.setMinimal(true);
- const int foundAttrPos = e.indexOf(attrRegExp, pos);
-
- if (foundAttrPos != -1) {
- e.insert(foundAttrPos + attrRegExp.matchedLength(), QString("|").append(value));
- pos += value.length() + 1;
-
- hasLemmaAttr = !isMorph;
- hasMorphAttr = isMorph;
- }
- }
- else { //attribute was not yet inserted
- const int attrPos = e.indexOf(QRegExp("morph=|lemma="), 0);
-
- if (attrPos >= 0) {
- QString attr;
- attr.append(isMorph ? "morph" : "lemma").append("=\"").append(value).append("\" ");
- e.insert(attrPos, attr);
-
- hasMorphAttr = isMorph;
- hasLemmaAttr = !isMorph;
-
- pos += attr.length();
- }
- }
- }
-
- insertedTag = true;
- pos = tag.indexIn(e, pos);
- }
-
- result.append( e );
- }
-
- if (list.count()) {
- buf = (const char*)result.toUtf8();
- }
-
- return 1;
+ hasLemmaAttr = isStrongs;
+ hasMorphAttr = isMorph;
+
+ e.insert( startPos, rep );
+ pos += rep.length();
+ }
+ else { //add the attribute to the existing tag
+ e.remove(pos, tag.matchedLength());
+
+ if ((!isMorph && hasLemmaAttr) || (isMorph && hasMorphAttr)) { //we append another attribute value, e.g. 3000 gets 3000|5000
+ //search the existing attribute start
+ QRegExp attrRegExp( isMorph ? "morph=\".+(?=\")" : "lemma=\".+(?=\")" );
+ attrRegExp.setMinimal(true);
+ const int foundAttrPos = e.indexOf(attrRegExp, pos);
+
+ if (foundAttrPos != -1) {
+ e.insert(foundAttrPos + attrRegExp.matchedLength(), QString("|").append(value));
+ pos += value.length() + 1;
+
+ hasLemmaAttr = !isMorph;
+ hasMorphAttr = isMorph;
+ }
+ }
+ else { //attribute was not yet inserted
+ const int attrPos = e.indexOf(QRegExp("morph=|lemma="), 0);
+
+ if (attrPos >= 0) {
+ QString attr;
+ attr.append(isMorph ? "morph" : "lemma").append("=\"").append(value).append("\" ");
+ e.insert(attrPos, attr);
+
+ hasMorphAttr = isMorph;
+ hasLemmaAttr = !isMorph;
+
+ pos += attr.length();
+ }
+ }
+ }
+
+ insertedTag = true;
+ pos = tag.indexIn(e, pos);
+ }
+
+ result.append( e );
+ }
+
+ if (list.count()) {
+ buf = (const char*)result.toUtf8();
+ }
+
+ return 1;
}
bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) {
- if (!substituteToken(buf, token) && !substituteEscapeString(buf, token)) {
- sword::XMLTag tag(token);
- BT_UserData* myUserData = dynamic_cast<BT_UserData*>(userData);
- sword::SWModule* myModule = const_cast<sword::SWModule*>(myUserData->module); //hack to be able to call stuff like Lang()
-
- if ( tag.getName() && !sword::stricmp(tag.getName(), "foreign") ) { // a text part in another language, we have to set the right font
-
- if (tag.getAttribute("lang")) {
- const char* abbrev = tag.getAttribute("lang");
- //const CLanguageMgr::Language* const language = CPointers::languageMgr()->languageForAbbrev( QString::fromLatin1(abbrev) );
-
- buf.append("<span class=\"foreign\" lang=\"");
- buf.append(abbrev);
- buf.append("\">");
- }
- }
- else if (tag.getName() && !sword::stricmp(tag.getName(), "sync")) { //lemmas, morph codes or strongs
-
- if (tag.getAttribute("type") && (!sword::stricmp(tag.getAttribute("type"), "morph") || !sword::stricmp(tag.getAttribute("type"), "Strongs") || !sword::stricmp(tag.getAttribute("type"), "lemma"))) { // Morph or Strong
- buf.append('<');
- buf.append(token);
- buf.append('>');
- }
- }
- else if (tag.getName() && !sword::stricmp(tag.getName(), "note")) { // <note> tag
-
- if (!tag.isEndTag() && !tag.isEmpty()) {
- //appending is faster than appendFormatted
- buf.append(" <span class=\"footnote\" note=\"");
- buf.append(myModule->Name());
- buf.append('/');
- buf.append(myUserData->key->getShortText());
- buf.append('/');
- buf.append( QString::number(myUserData->swordFootnote++).toUtf8().constData() );
- buf.append("\">*</span> ");
-
- myUserData->suspendTextPassThru = true;
- myUserData->inFootnoteTag = true;
- }
- else if (tag.isEndTag() && !tag.isEmpty()) { //end tag
- //buf += ")</span>";
- myUserData->suspendTextPassThru = false;
- myUserData->inFootnoteTag = false;
- }
- }
- else if (tag.getName() && !sword::stricmp(tag.getName(), "scripRef")) { // a scripRef
- //scrip refs which are embeded in footnotes may not be displayed!
-
- if (!myUserData->inFootnoteTag) {
- if (tag.isEndTag()) {
- if (myUserData->inscriptRef) { // like "<scripRef passage="John 3:16">See John 3:16</scripRef>"
- buf.append("</a></span>");
-
- myUserData->inscriptRef = false;
- myUserData->suspendTextPassThru = false;
- }
- else { // like "<scripRef>John 3:16</scripRef>"
-
- CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
- //Q_ASSERT(mod); tested later
- if (mod) {
- CReferenceManager::ParseOptions options;
- options.refBase = QString::fromUtf8(myUserData->key->getText()); //current module key
- options.refDestinationModule = QString(mod->name());
- options.sourceLanguage = QString(myModule->Lang());
- options.destinationLanguage = QString("en");
-
- //it's ok to split the reference, because to descriptive text is given
- bool insertSemicolon = false;
- buf.append("<span class=\"crossreference\">");
- QStringList refs = QString::fromUtf8(myUserData->lastTextNode.c_str()).split(";");
- QString oldRef; //the previous reference to use as a base for the next refs
- for (QStringList::iterator it(refs.begin()); it != refs.end(); ++it) {
-
- if (! oldRef.isEmpty() ){
- options.refBase = oldRef; //use the last ref as a base, e.g. Rom 1,2-3, when the next ref is only 3:3-10
- }
- const QString completeRef( CReferenceManager::parseVerseReference((*it), options) );
-
- oldRef = completeRef; //use the parsed result as the base for the next ref.
-
- if (insertSemicolon) { //prepend a ref divider if we're after the first one
- buf.append("; ");
- }
-
- buf.append("<a href=\"");
- buf.append(
- CReferenceManager::encodeHyperlink(
- mod->name(),
- completeRef,
- CReferenceManager::typeFromModule(mod->type())
- ).toUtf8().constData()
- );
-
- buf.append("\" crossrefs=\"");
- buf.append((const char*)completeRef.toUtf8());
- buf.append("\">");
-
- buf.append((const char*)(*it).toUtf8());
-
- buf.append("</a>");
-
- insertSemicolon = true;
- }
- buf.append("</span>"); //crossref end
- }
-
- myUserData->suspendTextPassThru = false;
- }
- }
- else if (tag.getAttribute("passage") ) { //the passage was given as a parameter value
- myUserData->inscriptRef = true;
- myUserData->suspendTextPassThru = false;
-
- const char* ref = tag.getAttribute("passage");
- Q_ASSERT(ref);
-
- CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
- //Q_ASSERT(mod); tested later
-
- CReferenceManager::ParseOptions options;
- options.refBase = QString::fromUtf8(myUserData->key->getText());
-
- options.sourceLanguage = myModule->Lang();
- options.destinationLanguage = QString("en");
-
- const QString completeRef = CReferenceManager::parseVerseReference(QString::fromUtf8(ref), options);
-
- if (mod) {
- options.refDestinationModule = QString(mod->name());
- buf.append("<span class=\"crossreference\">");
- buf.append("<a href=\"");
- buf.append(
- CReferenceManager::encodeHyperlink(
- mod->name(),
- completeRef,
- CReferenceManager::typeFromModule(mod->type())
- ).toUtf8().constData()
- );
- buf.append("\" crossrefs=\"");
- buf.append((const char*)completeRef.toUtf8());
- buf.append("\">");
- }
- else {
- buf.append("<span><a>");
- }
- }
- else if ( !tag.getAttribute("passage") ) { // we're starting a scripRef like "<scripRef>John 3:16</scripRef>"
- myUserData->inscriptRef = false;
-
- // let's stop text from going to output, the text get's added in the -tag handler
- myUserData->suspendTextPassThru = true;
- }
- }
- }
- else if (tag.getName() && !sword::stricmp(tag.getName(), "div")) {
- if (tag.isEndTag()) {
- buf.append("</div>");
- }
- else if ( tag.getAttribute("class") && !sword::stricmp(tag.getAttribute("class"),"sechead") ) {
- buf.append("<div class=\"sectiontitle\">");
- }
- else if (tag.getAttribute("class") && !sword::stricmp(tag.getAttribute("class"), "title")) {
- buf.append("<div class=\"booktitle\">");
- }
- }
- else if (tag.getName() && !sword::stricmp(tag.getName(), "img") && tag.getAttribute("src")) {
- const char* value = tag.getAttribute("src");
-
- if (value[0] == '/') {
- value++; //strip the first /
- }
-
- buf.append("<img src=\"file:");
- buf.append(myUserData->module->getConfigEntry("AbsoluteDataPath"));
- buf.append('/');
- buf.append(value);
- buf.append("\" />");
- }
- else { // let unknown token pass thru
- return sword::ThMLHTML::handleToken(buf, token, userData);
- }
- }
-
- return true;
+ if (!substituteToken(buf, token) && !substituteEscapeString(buf, token)) {
+ sword::XMLTag tag(token);
+ BT_UserData* myUserData = dynamic_cast<BT_UserData*>(userData);
+ sword::SWModule* myModule = const_cast<sword::SWModule*>(myUserData->module); //hack to be able to call stuff like Lang()
+
+ if ( tag.getName() && !sword::stricmp(tag.getName(), "foreign") ) { // a text part in another language, we have to set the right font
+
+ if (tag.getAttribute("lang")) {
+ const char* abbrev = tag.getAttribute("lang");
+ //const CLanguageMgr::Language* const language = CPointers::languageMgr()->languageForAbbrev( QString::fromLatin1(abbrev) );
+
+ buf.append("<span class=\"foreign\" lang=\"");
+ buf.append(abbrev);
+ buf.append("\">");
+ }
+ }
+ else if (tag.getName() && !sword::stricmp(tag.getName(), "sync")) { //lemmas, morph codes or strongs
+
+ if (tag.getAttribute("type") && (!sword::stricmp(tag.getAttribute("type"), "morph") || !sword::stricmp(tag.getAttribute("type"), "Strongs") || !sword::stricmp(tag.getAttribute("type"), "lemma"))) { // Morph or Strong
+ buf.append('<');
+ buf.append(token);
+ buf.append('>');
+ }
+ }
+ else if (tag.getName() && !sword::stricmp(tag.getName(), "note")) { // <note> tag
+
+ if (!tag.isEndTag() && !tag.isEmpty()) {
+ //appending is faster than appendFormatted
+ buf.append(" <span class=\"footnote\" note=\"");
+ buf.append(myModule->Name());
+ buf.append('/');
+ buf.append(myUserData->key->getShortText());
+ buf.append('/');
+ buf.append( QString::number(myUserData->swordFootnote++).toUtf8().constData() );
+ buf.append("\">*</span> ");
+
+ myUserData->suspendTextPassThru = true;
+ myUserData->inFootnoteTag = true;
+ }
+ else if (tag.isEndTag() && !tag.isEmpty()) { //end tag
+ //buf += ")</span>";
+ myUserData->suspendTextPassThru = false;
+ myUserData->inFootnoteTag = false;
+ }
+ }
+ else if (tag.getName() && !sword::stricmp(tag.getName(), "scripRef")) { // a scripRef
+ //scrip refs which are embeded in footnotes may not be displayed!
+
+ if (!myUserData->inFootnoteTag) {
+ if (tag.isEndTag()) {
+ if (myUserData->inscriptRef) { // like "<scripRef passage="John 3:16">See John 3:16</scripRef>"
+ buf.append("</a></span>");
+
+ myUserData->inscriptRef = false;
+ myUserData->suspendTextPassThru = false;
+ }
+ else { // like "<scripRef>John 3:16</scripRef>"
+
+ CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
+ //Q_ASSERT(mod); tested later
+ if (mod) {
+ CReferenceManager::ParseOptions options;
+ options.refBase = QString::fromUtf8(myUserData->key->getText()); //current module key
+ options.refDestinationModule = QString(mod->name());
+ options.sourceLanguage = QString(myModule->Lang());
+ options.destinationLanguage = QString("en");
+
+ //it's ok to split the reference, because to descriptive text is given
+ bool insertSemicolon = false;
+ buf.append("<span class=\"crossreference\">");
+ QStringList refs = QString::fromUtf8(myUserData->lastTextNode.c_str()).split(";");
+ QString oldRef; //the previous reference to use as a base for the next refs
+ for (QStringList::iterator it(refs.begin()); it != refs.end(); ++it) {
+
+ if (! oldRef.isEmpty() ) {
+ options.refBase = oldRef; //use the last ref as a base, e.g. Rom 1,2-3, when the next ref is only 3:3-10
+ }
+ const QString completeRef( CReferenceManager::parseVerseReference((*it), options) );
+
+ oldRef = completeRef; //use the parsed result as the base for the next ref.
+
+ if (insertSemicolon) { //prepend a ref divider if we're after the first one
+ buf.append("; ");
+ }
+
+ buf.append("<a href=\"");
+ buf.append(
+ CReferenceManager::encodeHyperlink(
+ mod->name(),
+ completeRef,
+ CReferenceManager::typeFromModule(mod->type())
+ ).toUtf8().constData()
+ );
+
+ buf.append("\" crossrefs=\"");
+ buf.append((const char*)completeRef.toUtf8());
+ buf.append("\">");
+
+ buf.append((const char*)(*it).toUtf8());
+
+ buf.append("</a>");
+
+ insertSemicolon = true;
+ }
+ buf.append("</span>"); //crossref end
+ }
+
+ myUserData->suspendTextPassThru = false;
+ }
+ }
+ else if (tag.getAttribute("passage") ) { //the passage was given as a parameter value
+ myUserData->inscriptRef = true;
+ myUserData->suspendTextPassThru = false;
+
+ const char* ref = tag.getAttribute("passage");
+ Q_ASSERT(ref);
+
+ CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
+ //Q_ASSERT(mod); tested later
+
+ CReferenceManager::ParseOptions options;
+ options.refBase = QString::fromUtf8(myUserData->key->getText());
+
+ options.sourceLanguage = myModule->Lang();
+ options.destinationLanguage = QString("en");
+
+ const QString completeRef = CReferenceManager::parseVerseReference(QString::fromUtf8(ref), options);
+
+ if (mod) {
+ options.refDestinationModule = QString(mod->name());
+ buf.append("<span class=\"crossreference\">");
+ buf.append("<a href=\"");
+ buf.append(
+ CReferenceManager::encodeHyperlink(
+ mod->name(),
+ completeRef,
+ CReferenceManager::typeFromModule(mod->type())
+ ).toUtf8().constData()
+ );
+ buf.append("\" crossrefs=\"");
+ buf.append((const char*)completeRef.toUtf8());
+ buf.append("\">");
+ }
+ else {
+ buf.append("<span><a>");
+ }
+ }
+ else if ( !tag.getAttribute("passage") ) { // we're starting a scripRef like "<scripRef>John 3:16</scripRef>"
+ myUserData->inscriptRef = false;
+
+ // let's stop text from going to output, the text get's added in the -tag handler
+ myUserData->suspendTextPassThru = true;
+ }
+ }
+ }
+ else if (tag.getName() && !sword::stricmp(tag.getName(), "div")) {
+ if (tag.isEndTag()) {
+ buf.append("</div>");
+ }
+ else if ( tag.getAttribute("class") && !sword::stricmp(tag.getAttribute("class"), "sechead") ) {
+ buf.append("<div class=\"sectiontitle\">");
+ }
+ else if (tag.getAttribute("class") && !sword::stricmp(tag.getAttribute("class"), "title")) {
+ buf.append("<div class=\"booktitle\">");
+ }
+ }
+ else if (tag.getName() && !sword::stricmp(tag.getName(), "img") && tag.getAttribute("src")) {
+ const char* value = tag.getAttribute("src");
+
+ if (value[0] == '/') {
+ value++; //strip the first /
+ }
+
+ buf.append("<img src=\"file:");
+ buf.append(myUserData->module->getConfigEntry("AbsoluteDataPath"));
+ buf.append('/');
+ buf.append(value);
+ buf.append("\" />");
+ }
+ else { // let unknown token pass thru
+ return sword::ThMLHTML::handleToken(buf, token, userData);
+ }
+ }
+
+ return true;
}
diff --git a/src/backend/filters/bt_thmlhtml.h b/src/backend/filters/bt_thmlhtml.h
index df20472..25b168c 100644
--- a/src/backend/filters/bt_thmlhtml.h
+++ b/src/backend/filters/bt_thmlhtml.h
@@ -16,37 +16,37 @@
namespace Filters {
- /** ThML to HTML filter.
- * This filter converts ThML text to HTML text
- */
+/** ThML to HTML filter.
+* This filter converts ThML text to HTML text
+*/
class BT_ThMLHTML : public sword::ThMLHTML {
-protected:
+ protected:
-class BT_UserData : public sword::ThMLHTML::MyUserData {
+ class BT_UserData : public sword::ThMLHTML::MyUserData {
-public:
-BT_UserData(const sword::SWModule *module, const sword::SWKey *key) : sword::ThMLHTML::MyUserData(module, key) {
- inscriptRef = false;
- swordFootnote = 1;
- inFootnoteTag = false;
- }
+ public:
+ BT_UserData(const sword::SWModule *module, const sword::SWKey *key) : sword::ThMLHTML::MyUserData(module, key) {
+ inscriptRef = false;
+ swordFootnote = 1;
+ inFootnoteTag = false;
+ }
- bool inscriptRef;
- bool inFootnoteTag;
- unsigned short int swordFootnote;
- };
+ bool inscriptRef;
+ bool inFootnoteTag;
+ unsigned short int swordFootnote;
+ };
- virtual sword::BasicFilterUserData *createUserData(const sword::SWModule* module, const sword::SWKey* key) {
- return new BT_UserData(module, key);
- }
+ virtual sword::BasicFilterUserData *createUserData(const sword::SWModule* module, const sword::SWKey* key) {
+ return new BT_UserData(module, key);
+ }
-public:
- BT_ThMLHTML ();
- virtual bool handleToken(sword::SWBuf& buf, const char *token, sword::BasicFilterUserData *userData);
- virtual char processText(sword::SWBuf& buf, const sword::SWKey*, const sword::SWModule* = 0);
- };
+ public:
+ BT_ThMLHTML ();
+ virtual bool handleToken(sword::SWBuf& buf, const char *token, sword::BasicFilterUserData *userData);
+ virtual char processText(sword::SWBuf& buf, const sword::SWKey*, const sword::SWModule* = 0);
+};
}
diff --git a/src/backend/filters/bt_thmlplain.cpp b/src/backend/filters/bt_thmlplain.cpp
index e08afb7..2cd3cf9 100644
--- a/src/backend/filters/bt_thmlplain.cpp
+++ b/src/backend/filters/bt_thmlplain.cpp
@@ -18,204 +18,202 @@
Filters::BT_ThMLPlain::BT_ThMLPlain() {
}
-char Filters::BT_ThMLPlain::processText(sword::SWBuf &text, const sword::SWKey* /*key*/, const sword::SWModule* /*module*/)
-{
- char token[2048];
- int tokpos = 0;
- bool intoken = false;
- bool ampersand = false;
+char Filters::BT_ThMLPlain::processText(sword::SWBuf &text, const sword::SWKey* /*key*/, const sword::SWModule* /*module*/) {
+ char token[2048];
+ int tokpos = 0;
+ bool intoken = false;
+ bool ampersand = false;
- const char *from;
- sword::SWBuf orig = text;
- from = orig.c_str();
- for (text = ""; *from; from++)
- {
- if (*from == 10 || *from == 13)
- from++;
- if (*from == '<') {
- intoken = true;
- tokpos = 0;
- token[0] = 0;
- token[1] = 0;
- token[2] = 0;
- ampersand = false;
- continue;
- }
- else if (*from == '&') {
- intoken = true;
- tokpos = 0;
- token[0] = 0;
- token[1] = 0;
- token[2] = 0;
- ampersand = true;
- continue;
- }
- if (*from == ';' && ampersand) {
- intoken = false;
- ampersand = false;
+ const char *from;
+ sword::SWBuf orig = text;
+ from = orig.c_str();
+ for (text = ""; *from; from++) {
+ if (*from == 10 || *from == 13)
+ from++;
+ if (*from == '<') {
+ intoken = true;
+ tokpos = 0;
+ token[0] = 0;
+ token[1] = 0;
+ token[2] = 0;
+ ampersand = false;
+ continue;
+ }
+ else if (*from == '&') {
+ intoken = true;
+ tokpos = 0;
+ token[0] = 0;
+ token[1] = 0;
+ token[2] = 0;
+ ampersand = true;
+ continue;
+ }
+ if (*from == ';' && ampersand) {
+ intoken = false;
+ ampersand = false;
- if (!strncmp("nbsp", token, 4)) text += " ";
- else if (!strncmp("quot", token, 4)) text += "\"";
- else if (!strncmp("amp", token, 3)) text += "&";
- else if (!strncmp("lt", token, 2)) text += "<";
- else if (!strncmp("gt", token, 2)) text += ">";
- else if (!strncmp("brvbar", token, 6)) text += "¦";
- else if (!strncmp("sect", token, 4)) text += "§";
- else if (!strncmp("copy", token, 4)) text += "©";
- else if (!strncmp("laquo", token, 5)) text += "«";
- else if (!strncmp("reg", token, 3)) text += "®";
- else if (!strncmp("acute", token, 5)) text += "´";
- else if (!strncmp("para", token, 4)) text += "¶";
- else if (!strncmp("raquo", token, 5)) text += "»";
+ if (!strncmp("nbsp", token, 4)) text += " ";
+ else if (!strncmp("quot", token, 4)) text += "\"";
+ else if (!strncmp("amp", token, 3)) text += "&";
+ else if (!strncmp("lt", token, 2)) text += "<";
+ else if (!strncmp("gt", token, 2)) text += ">";
+ else if (!strncmp("brvbar", token, 6)) text += "¦";
+ else if (!strncmp("sect", token, 4)) text += "§";
+ else if (!strncmp("copy", token, 4)) text += "©";
+ else if (!strncmp("laquo", token, 5)) text += "«";
+ else if (!strncmp("reg", token, 3)) text += "®";
+ else if (!strncmp("acute", token, 5)) text += "´";
+ else if (!strncmp("para", token, 4)) text += "¶";
+ else if (!strncmp("raquo", token, 5)) text += "»";
- else if (!strncmp("Aacute", token, 6)) text += "Á";
- else if (!strncmp("Agrave", token, 6)) text += "À";
- else if (!strncmp("Acirc", token, 5)) text += "Â";
- else if (!strncmp("Auml", token, 4)) text += "Ä";
- else if (!strncmp("Atilde", token, 6)) text += "Ã";
- else if (!strncmp("Aring", token, 5)) text += "Å";
- else if (!strncmp("aacute", token, 6)) text += "á";
- else if (!strncmp("agrave", token, 6)) text += "à";
- else if (!strncmp("acirc", token, 5)) text += "â";
- else if (!strncmp("auml", token, 4)) text += "ä";
- else if (!strncmp("atilde", token, 6)) text += "ã";
- else if (!strncmp("aring", token, 5)) text += "å";
- else if (!strncmp("Eacute", token, 6)) text += "É";
- else if (!strncmp("Egrave", token, 6)) text += "È";
- else if (!strncmp("Ecirc", token, 5)) text += "Ê";
- else if (!strncmp("Euml", token, 4)) text += "Ë";
- else if (!strncmp("eacute", token, 6)) text += "é";
- else if (!strncmp("egrave", token, 6)) text += "è";
- else if (!strncmp("ecirc", token, 5)) text += "ê";
- else if (!strncmp("euml", token, 4)) text += "ë";
- else if (!strncmp("Iacute", token, 6)) text += "Í";
- else if (!strncmp("Igrave", token, 6)) text += "Ì";
- else if (!strncmp("Icirc", token, 5)) text += "Î";
- else if (!strncmp("Iuml", token, 4)) text += "Ï";
- else if (!strncmp("iacute", token, 6)) text += "í";
- else if (!strncmp("igrave", token, 6)) text += "ì";
- else if (!strncmp("icirc", token, 5)) text += "î";
- else if (!strncmp("iuml", token, 4)) text += "ï";
- else if (!strncmp("Oacute", token, 6)) text += "Ó";
- else if (!strncmp("Ograve", token, 6)) text += "Ò";
- else if (!strncmp("Ocirc", token, 5)) text += "Ô";
- else if (!strncmp("Ouml", token, 4)) text += "Ö";
- else if (!strncmp("Otilde", token, 6)) text += "Õ";
- else if (!strncmp("oacute", token, 6)) text += "ó";
- else if (!strncmp("ograve", token, 6)) text += "ò";
- else if (!strncmp("ocirc", token, 5)) text += "ô";
- else if (!strncmp("ouml", token, 4)) text += "ö";
- else if (!strncmp("otilde", token, 6)) text += "õ";
- else if (!strncmp("Uacute", token, 6)) text += "Ú";
- else if (!strncmp("Ugrave", token, 6)) text += "Ù";
- else if (!strncmp("Ucirc", token, 5)) text += "Û";
- else if (!strncmp("Uuml", token, 4)) text += "Ü";
- else if (!strncmp("uacute", token, 6)) text += "ú";
- else if (!strncmp("ugrave", token, 6)) text += "ù";
- else if (!strncmp("ucirc", token, 5)) text += "û";
- else if (!strncmp("uuml", token, 4)) text += "ü";
- else if (!strncmp("Yacute", token, 6)) text += "Ý";
- else if (!strncmp("yacute", token, 6)) text += "ý";
- else if (!strncmp("yuml", token, 4)) text += "ÿ";
+ else if (!strncmp("Aacute", token, 6)) text += "Á";
+ else if (!strncmp("Agrave", token, 6)) text += "À";
+ else if (!strncmp("Acirc", token, 5)) text += "Â";
+ else if (!strncmp("Auml", token, 4)) text += "Ä";
+ else if (!strncmp("Atilde", token, 6)) text += "Ã";
+ else if (!strncmp("Aring", token, 5)) text += "Å";
+ else if (!strncmp("aacute", token, 6)) text += "á";
+ else if (!strncmp("agrave", token, 6)) text += "à";
+ else if (!strncmp("acirc", token, 5)) text += "â";
+ else if (!strncmp("auml", token, 4)) text += "ä";
+ else if (!strncmp("atilde", token, 6)) text += "ã";
+ else if (!strncmp("aring", token, 5)) text += "å";
+ else if (!strncmp("Eacute", token, 6)) text += "É";
+ else if (!strncmp("Egrave", token, 6)) text += "È";
+ else if (!strncmp("Ecirc", token, 5)) text += "Ê";
+ else if (!strncmp("Euml", token, 4)) text += "Ë";
+ else if (!strncmp("eacute", token, 6)) text += "é";
+ else if (!strncmp("egrave", token, 6)) text += "è";
+ else if (!strncmp("ecirc", token, 5)) text += "ê";
+ else if (!strncmp("euml", token, 4)) text += "ë";
+ else if (!strncmp("Iacute", token, 6)) text += "Í";
+ else if (!strncmp("Igrave", token, 6)) text += "Ì";
+ else if (!strncmp("Icirc", token, 5)) text += "Î";
+ else if (!strncmp("Iuml", token, 4)) text += "Ï";
+ else if (!strncmp("iacute", token, 6)) text += "í";
+ else if (!strncmp("igrave", token, 6)) text += "ì";
+ else if (!strncmp("icirc", token, 5)) text += "î";
+ else if (!strncmp("iuml", token, 4)) text += "ï";
+ else if (!strncmp("Oacute", token, 6)) text += "Ó";
+ else if (!strncmp("Ograve", token, 6)) text += "Ò";
+ else if (!strncmp("Ocirc", token, 5)) text += "Ô";
+ else if (!strncmp("Ouml", token, 4)) text += "Ö";
+ else if (!strncmp("Otilde", token, 6)) text += "Õ";
+ else if (!strncmp("oacute", token, 6)) text += "ó";
+ else if (!strncmp("ograve", token, 6)) text += "ò";
+ else if (!strncmp("ocirc", token, 5)) text += "ô";
+ else if (!strncmp("ouml", token, 4)) text += "ö";
+ else if (!strncmp("otilde", token, 6)) text += "õ";
+ else if (!strncmp("Uacute", token, 6)) text += "Ú";
+ else if (!strncmp("Ugrave", token, 6)) text += "Ù";
+ else if (!strncmp("Ucirc", token, 5)) text += "Û";
+ else if (!strncmp("Uuml", token, 4)) text += "Ü";
+ else if (!strncmp("uacute", token, 6)) text += "ú";
+ else if (!strncmp("ugrave", token, 6)) text += "ù";
+ else if (!strncmp("ucirc", token, 5)) text += "û";
+ else if (!strncmp("uuml", token, 4)) text += "ü";
+ else if (!strncmp("Yacute", token, 6)) text += "Ý";
+ else if (!strncmp("yacute", token, 6)) text += "ý";
+ else if (!strncmp("yuml", token, 4)) text += "ÿ";
- else if (!strncmp("deg", token, 3)) text += "°";
- else if (!strncmp("plusmn", token, 6)) text += "±";
- else if (!strncmp("sup2", token, 4)) text += "²";
- else if (!strncmp("sup3", token, 4)) text += "³";
- else if (!strncmp("sup1", token, 4)) text += "¹";
- else if (!strncmp("nbsp", token, 4)) text += "º";
- else if (!strncmp("pound", token, 5)) text += "£";
- else if (!strncmp("cent", token, 4)) text += "¢";
- else if (!strncmp("frac14", token, 6)) text += "¼";
- else if (!strncmp("frac12", token, 6)) text += "½";
- else if (!strncmp("frac34", token, 6)) text += "¾";
- else if (!strncmp("iquest", token, 6)) text += "¿";
- else if (!strncmp("iexcl", token, 5)) text += "¡";
- else if (!strncmp("ETH", token, 3)) text += "Ð";
- else if (!strncmp("eth", token, 3)) text += "ð";
- else if (!strncmp("THORN", token, 5)) text += "Þ";
- else if (!strncmp("thorn", token, 5)) text += "þ";
- else if (!strncmp("AElig", token, 5)) text += "Æ";
- else if (!strncmp("aelig", token, 5)) text += "æ";
- else if (!strncmp("Oslash", token, 6)) text += "Ø";
- else if (!strncmp("curren", token, 6)) text += "¤";
- else if (!strncmp("Ccedil", token, 6)) text += "Ç";
- else if (!strncmp("ccedil", token, 6)) text += "ç";
- else if (!strncmp("szlig", token, 5)) text += "ß";
- else if (!strncmp("Ntilde", token, 6)) text += "Ñ";
- else if (!strncmp("ntilde", token, 6)) text += "ñ";
- else if (!strncmp("yen", token, 3)) text += "¥";
- else if (!strncmp("not", token, 3)) text += "¬";
- else if (!strncmp("ordf", token, 4)) text += "ª";
- else if (!strncmp("uml", token, 3)) text += "¨";
- else if (!strncmp("shy", token, 3)) text += "­";
- else if (!strncmp("macr", token, 4)) text += "¯";
- else if (!strncmp("micro", token, 5)) text += "µ";
- else if (!strncmp("middot", token, 6)) text +="·";
- else if (!strncmp("cedil", token, 5)) text += "¸";
- else if (!strncmp("ordm", token, 4)) text += "º";
- else if (!strncmp("times", token, 5)) text += "×";
- else if (!strncmp("divide", token, 6)) text +="÷";
- else if (!strncmp("oslash", token, 6)) text +="ø";
- continue;
+ else if (!strncmp("deg", token, 3)) text += "°";
+ else if (!strncmp("plusmn", token, 6)) text += "±";
+ else if (!strncmp("sup2", token, 4)) text += "²";
+ else if (!strncmp("sup3", token, 4)) text += "³";
+ else if (!strncmp("sup1", token, 4)) text += "¹";
+ else if (!strncmp("nbsp", token, 4)) text += "º";
+ else if (!strncmp("pound", token, 5)) text += "£";
+ else if (!strncmp("cent", token, 4)) text += "¢";
+ else if (!strncmp("frac14", token, 6)) text += "¼";
+ else if (!strncmp("frac12", token, 6)) text += "½";
+ else if (!strncmp("frac34", token, 6)) text += "¾";
+ else if (!strncmp("iquest", token, 6)) text += "¿";
+ else if (!strncmp("iexcl", token, 5)) text += "¡";
+ else if (!strncmp("ETH", token, 3)) text += "Ð";
+ else if (!strncmp("eth", token, 3)) text += "ð";
+ else if (!strncmp("THORN", token, 5)) text += "Þ";
+ else if (!strncmp("thorn", token, 5)) text += "þ";
+ else if (!strncmp("AElig", token, 5)) text += "Æ";
+ else if (!strncmp("aelig", token, 5)) text += "æ";
+ else if (!strncmp("Oslash", token, 6)) text += "Ø";
+ else if (!strncmp("curren", token, 6)) text += "¤";
+ else if (!strncmp("Ccedil", token, 6)) text += "Ç";
+ else if (!strncmp("ccedil", token, 6)) text += "ç";
+ else if (!strncmp("szlig", token, 5)) text += "ß";
+ else if (!strncmp("Ntilde", token, 6)) text += "Ñ";
+ else if (!strncmp("ntilde", token, 6)) text += "ñ";
+ else if (!strncmp("yen", token, 3)) text += "¥";
+ else if (!strncmp("not", token, 3)) text += "¬";
+ else if (!strncmp("ordf", token, 4)) text += "ª";
+ else if (!strncmp("uml", token, 3)) text += "¨";
+ else if (!strncmp("shy", token, 3)) text += "­";
+ else if (!strncmp("macr", token, 4)) text += "¯";
+ else if (!strncmp("micro", token, 5)) text += "µ";
+ else if (!strncmp("middot", token, 6)) text += "·";
+ else if (!strncmp("cedil", token, 5)) text += "¸";
+ else if (!strncmp("ordm", token, 4)) text += "º";
+ else if (!strncmp("times", token, 5)) text += "×";
+ else if (!strncmp("divide", token, 6)) text += "÷";
+ else if (!strncmp("oslash", token, 6)) text += "ø";
+ continue;
- }
- else if (*from == '>' && !ampersand) {
- intoken = false;
- // process desired tokens
- if (!strncmp(token, "sync type=\"Strongs\" value=\"", 27)) {
- text += ' ';
- text += '<';
- for (unsigned int i = 27; token[i] != '\"'; i++)
- text += token[i];
- text += '>';
- continue;
- }
- if (!strncmp(token, "sync type=\"morph\" value=\"", 25)) {
- text += ' ';
- text += '(';
- for (unsigned int i = 25; token[i] != '\"'; i++)
- text += token[i];
- text += ')';
- continue;
- }
- if (!strncmp("note", token, 4)) {
- text += ' ';
- text += '(';
- }
- else if (!strncmp("br", token, 2))
- text += '\n';
- else if (!strncmp("/p", token, 2))
- text += '\n';
- else if (!strncmp("/note", token, 5)) {
- text += ')';
- text += ' ';
- }
- continue;
- }
- if (intoken) {
- if (tokpos < 2045)
- token[tokpos++] = *from;
- token[tokpos+2] = 0;
- }
- else text += *from;
- }
+ }
+ else if (*from == '>' && !ampersand) {
+ intoken = false;
+ // process desired tokens
+ if (!strncmp(token, "sync type=\"Strongs\" value=\"", 27)) {
+ text += ' ';
+ text += '<';
+ for (unsigned int i = 27; token[i] != '\"'; i++)
+ text += token[i];
+ text += '>';
+ continue;
+ }
+ if (!strncmp(token, "sync type=\"morph\" value=\"", 25)) {
+ text += ' ';
+ text += '(';
+ for (unsigned int i = 25; token[i] != '\"'; i++)
+ text += token[i];
+ text += ')';
+ continue;
+ }
+ if (!strncmp("note", token, 4)) {
+ text += ' ';
+ text += '(';
+ }
+ else if (!strncmp("br", token, 2))
+ text += '\n';
+ else if (!strncmp("/p", token, 2))
+ text += '\n';
+ else if (!strncmp("/note", token, 5)) {
+ text += ')';
+ text += ' ';
+ }
+ continue;
+ }
+ if (intoken) {
+ if (tokpos < 2045)
+ token[tokpos++] = *from;
+ token[tokpos+2] = 0;
+ }
+ else text += *from;
+ }
- orig = text;
- from = orig.c_str();
- for (text = ""; *from; from++) { //loop to remove extra spaces
- if ((strchr(" \t\n\r", *from))) {
- while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) {
- from++;
- }
- text += " ";
- }
- else {
- text += *from;
- }
+ orig = text;
+ from = orig.c_str();
+ for (text = ""; *from; from++) { //loop to remove extra spaces
+ if ((strchr(" \t\n\r", *from))) {
+ while (*(from + 1) && (strchr(" \t\n\r", *(from + 1)))) {
+ from++;
+ }
+ text += " ";
+ }
+ else {
+ text += *from;
}
- text += (char)0;
+ }
+ text += (char)0;
- return 0;
+ return 0;
}
diff --git a/src/backend/filters/bt_thmlplain.h b/src/backend/filters/bt_thmlplain.h
index 9d0a0c5..7ef82d6 100644
--- a/src/backend/filters/bt_thmlplain.h
+++ b/src/backend/filters/bt_thmlplain.h
@@ -15,13 +15,13 @@
namespace Filters {
- /** This filter converts ThML text to plain text
- */
+/** This filter converts ThML text to plain text
+*/
class BT_ThMLPlain : public sword::SWFilter {
-protected:
- virtual char processText(sword::SWBuf &text, const sword::SWKey *key = 0, const sword::SWModule *module = 0);
-public:
- BT_ThMLPlain();
+ protected:
+ virtual char processText(sword::SWBuf &text, const sword::SWKey *key = 0, const sword::SWModule *module = 0);
+ public:
+ BT_ThMLPlain();
};
}
diff --git a/src/backend/filters/osismorphsegmentation.cpp b/src/backend/filters/osismorphsegmentation.cpp
index 9ec00f7..26e7470 100644
--- a/src/backend/filters/osismorphsegmentation.cpp
+++ b/src/backend/filters/osismorphsegmentation.cpp
@@ -19,65 +19,65 @@ const sword::SWBuf Filters::OSISMorphSegmentation::choices[3] = {"Off", "On", ""
const sword::StringList Filters::OSISMorphSegmentation::oValues(&choices[0], &choices[2]);
Filters::OSISMorphSegmentation::OSISMorphSegmentation() : sword::SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
- }
+ setOptionValue("Off");
+}
Filters::OSISMorphSegmentation::~OSISMorphSegmentation() {}
char Filters::OSISMorphSegmentation::processText(sword::SWBuf &text, const sword::SWKey */*key*/, const sword::SWModule */*module*/) {
- sword::SWBuf token;
- bool intoken = false;
- bool hide = false;
+ sword::SWBuf token;
+ bool intoken = false;
+ bool hide = false;
- sword::SWBuf orig( text );
- const char *from = orig.c_str();
+ sword::SWBuf orig( text );
+ const char *from = orig.c_str();
- sword::XMLTag tag;
+ sword::XMLTag tag;
- for (text = ""; *from; ++from) {
- if (*from == '<') {
- intoken = true;
- token = "";
- continue;
- }
+ for (text = ""; *from; ++from) {
+ if (*from == '<') {
+ intoken = true;
+ token = "";
+ continue;
+ }
- if (*from == '>') { // process tokens
- intoken = false;
+ if (*from == '>') { // process tokens
+ intoken = false;
- if (!strncmp(token.c_str(), "seg ", 4) || !strncmp(token.c_str(), "/seg", 4)) {
- tag = token;
+ if (!strncmp(token.c_str(), "seg ", 4) || !strncmp(token.c_str(), "/seg", 4)) {
+ tag = token;
- if (!tag.isEndTag() && tag.getAttribute("type") && !strcmp("morph", tag.getAttribute("type"))) { //<seg type="morph"> start tag
- hide = (option == 0); //only hide if option is Off
- }
+ if (!tag.isEndTag() && tag.getAttribute("type") && !strcmp("morph", tag.getAttribute("type"))) { //<seg type="morph"> start tag
+ hide = (option == 0); //only hide if option is Off
+ }
- if (hide) { //hides start and end tags as long as hide is set
+ if (hide) { //hides start and end tags as long as hide is set
- if (tag.isEndTag()) { //</seg>
- hide = false;
- }
+ if (tag.isEndTag()) { //</seg>
+ hide = false;
+ }
- continue; //leave out the current token
- }
- } //end of seg tag handling
+ continue; //leave out the current token
+ }
+ } //end of seg tag handling
- text.append('<');
- text.append(token);
- text.append('>');
+ text.append('<');
+ text.append(token);
+ text.append('>');
- // hide = false; //not right, because there may be child tags in seg. Only /seg may disable the seg hiding.
+ // hide = false; //not right, because there may be child tags in seg. Only /seg may disable the seg hiding.
- continue;
- } //end of intoken part
+ continue;
+ } //end of intoken part
- if (intoken) { //copy token
- token.append(*from);
- }
- else { //copy text which is not inside of a tag
- text.append(*from);
- }
- }
+ if (intoken) { //copy token
+ token.append(*from);
+ }
+ else { //copy text which is not inside of a tag
+ text.append(*from);
+ }
+ }
- return 0;
+ return 0;
}
diff --git a/src/backend/filters/osismorphsegmentation.h b/src/backend/filters/osismorphsegmentation.h
index e419fe2..bc405f5 100644
--- a/src/backend/filters/osismorphsegmentation.h
+++ b/src/backend/filters/osismorphsegmentation.h
@@ -19,16 +19,16 @@ namespace Filters {
* @author Martin Gruner
*/
class OSISMorphSegmentation : public sword::SWOptionFilter {
- static const char oName[];
- static const char oTip[];
- static const sword::SWBuf choices[3];
- static const sword::StringList oValues;
+ static const char oName[];
+ static const char oTip[];
+ static const sword::SWBuf choices[3];
+ static const sword::StringList oValues;
-public:
- OSISMorphSegmentation();
- virtual ~OSISMorphSegmentation();
+ public:
+ OSISMorphSegmentation();
+ virtual ~OSISMorphSegmentation();
- virtual char processText(sword::SWBuf &text, const sword::SWKey *key = 0, const sword::SWModule *module = 0);
+ virtual char processText(sword::SWBuf &text, const sword::SWKey *key = 0, const sword::SWModule *module = 0);
};
}
diff --git a/src/backend/keys/cswordkey.cpp b/src/backend/keys/cswordkey.cpp
index acb6da9..546c55e 100644
--- a/src/backend/keys/cswordkey.cpp
+++ b/src/backend/keys/cswordkey.cpp
@@ -32,154 +32,147 @@
CSwordKey::CSwordKey(CSwordModuleInfo* const module) : m_module(module) {}
CSwordKey::CSwordKey(const CSwordKey& k) {
- m_module = k.m_module;
+ m_module = k.m_module;
}
QString CSwordKey::rawText() {
- if (!m_module) return QString::null;
+ if (!m_module) return QString::null;
- if (dynamic_cast<sword::SWKey*>(this)) {
- char * buffer = new char[strlen(rawKey()) + 1];
- strcpy(buffer, rawKey());
- m_module->module()->getKey()->setText( buffer );
- delete [] buffer;
- }
+ if (dynamic_cast<sword::SWKey*>(this)) {
+ m_module->module()->getKey()->setText( rawKey() );
+ }
- if (key().isNull()) return QString::null;
+ if (key().isNull()) return QString::null;
- return QString::fromUtf8( m_module->module()->getRawEntry() );
+ return QString::fromUtf8( m_module->module()->getRawEntry() );
}
QString CSwordKey::renderedText( const CSwordKey::TextRenderType mode ) {
- Q_ASSERT(m_module);
- if (!m_module) {
- return QString::null;
- }
-
- sword::SWKey* const k = dynamic_cast<sword::SWKey*>(this);
-
- if (k) {
- char * keyBuffer = new char[strlen(rawKey()) + 1];
- strcpy(keyBuffer, rawKey());
- sword::VerseKey* vk_mod = dynamic_cast<sword::VerseKey*>(m_module->module()->getKey());
-
- if (vk_mod) {
- vk_mod->Headings(1);
- }
-
- m_module->module()->getKey()->setText( keyBuffer );
-
- if (m_module->type() == CSwordModuleInfo::Lexicon) {
- m_module->snap();
- /* In lexicons make sure that our key (e.g. 123) was successfully set to the module,
- i.e. the module key contains this key (e.g. 0123 contains 123) */
-
- if ( sword::stricmp(m_module->module()->getKey()->getText(), keyBuffer)
- && !strstr(m_module->module()->getKey()->getText(), keyBuffer)
- ) {
- qDebug("return an empty key for %s", m_module->module()->getKey()->getText());
- return QString::null;
- }
- }
- delete [] keyBuffer;
- }
-
- //Q_ASSERT(!key().isNull());
- if (!key().isNull()) { //we have valid text
- QString text = QString::fromUtf8( m_module->module()->RenderText() );
-
- // This is yucky, but if we want strong lexicon refs we have to do it here.
- if (m_module->type() == CSwordModuleInfo::Lexicon) {
- QString t(text);
- QRegExp rx("(GREEK|HEBREW) for 0*([1-9]\\d*)"); // ignore 0's before number
- int pos = 0;
- while( (pos = rx.indexIn(t, pos)) != -1 ) {
- QString language = rx.cap(1);
- QString langcode = QString(language.at(0)); // "G" or "H"
- QString number = rx.cap(2);
- QString paddednumber = number.rightJustified(5, '0'); // Form 00123
-
- text.replace(
- QRegExp( QString(
- "(>[^<>]+)" // Avoid replacing inside tags
- "\\b(0*%1)\\b").arg(number) ), // And span around 0's
- QString("\\1<span lemma=\"%1%2\"><a href=\"strongs://%3/%4\">\\2</a></span>")
- .arg(langcode, paddednumber, language, paddednumber)
- );
- pos += rx.matchedLength();
- }
- }
-
- if (mode == HTMLEscaped) {
- //we have to encode all UTF-8 in HTML escapes
- // go though every character and write down the escaped HTML unicode entity
- // form is &#<decimal unicode value here>;
- QString ret;
- QChar c;
- const unsigned int length = text.length();
-
- for (unsigned int i = 0; i < length; ++i) {
- c = text.at(i);
-
- if (c.toLatin1()) { //normal latin1 character
- ret.append(c);
- }
- else {//unicode character, needs to be escaped
- ret.append("&#")
- .append(c.unicode())
- .append(";");
- }
- }
-
- return ret;
- }
- else {
- return text;
- }
- }
-
- return QString::null;
+ Q_ASSERT(m_module);
+
+ sword::SWKey* const k = dynamic_cast<sword::SWKey*>(this);
+
+ if (k) {
+ sword::VerseKey* vk_mod = dynamic_cast<sword::VerseKey*>(m_module->module()->getKey());
+
+ if (vk_mod) {
+ vk_mod->Headings(1);
+ }
+
+ m_module->module()->getKey()->setText( rawKey() );
+
+ if (m_module->type() == CSwordModuleInfo::Lexicon) {
+ m_module->snap();
+ /* In lexicons make sure that our key (e.g. 123) was successfully set to the module,
+ i.e. the module key contains this key (e.g. 0123 contains 123) */
+
+ if ( sword::stricmp(m_module->module()->getKey()->getText(), rawKey())
+ && !strstr(m_module->module()->getKey()->getText(), rawKey())
+ ) {
+ qDebug("return an empty key for %s", m_module->module()->getKey()->getText());
+ return QString::null;
+ }
+ }
+ }
+
+ //Q_ASSERT(!key().isNull());
+ if (!key().isNull()) { //we have valid text
+ bool DoRender = (mode == ProcessEntryAttributesOnly) ? 0 : 1;
+ QString text = QString::fromUtf8( m_module->module()->RenderText(0, -1, DoRender) );
+ if (!DoRender) return QString::null;
+
+ // This is yucky, but if we want strong lexicon refs we have to do it here.
+ if (m_module->type() == CSwordModuleInfo::Lexicon) {
+ QString t(text);
+ QRegExp rx("(GREEK|HEBREW) for 0*([1-9]\\d*)"); // ignore 0's before number
+ int pos = 0;
+ while ( (pos = rx.indexIn(t, pos)) != -1 ) {
+ QString language = rx.cap(1);
+ QString langcode = QString(language.at(0)); // "G" or "H"
+ QString number = rx.cap(2);
+ QString paddednumber = number.rightJustified(5, '0'); // Form 00123
+
+ text.replace(
+ QRegExp( QString(
+ "(>[^<>]+)" // Avoid replacing inside tags
+ "\\b(0*%1)\\b").arg(number) ), // And span around 0's
+ QString("\\1<span lemma=\"%1%2\"><a href=\"strongs://%3/%4\">\\2</a></span>")
+ .arg(langcode, paddednumber, language, paddednumber)
+ );
+ pos += rx.matchedLength();
+ }
+ }
+
+ if (mode == HTMLEscaped) {
+ //we have to encode all UTF-8 in HTML escapes
+ // go though every character and write down the escaped HTML unicode entity
+ // form is &#<decimal unicode value here>;
+ QString ret;
+ QChar c;
+ const unsigned int length = text.length();
+
+ for (unsigned int i = 0; i < length; ++i) {
+ c = text.at(i);
+
+ if (c.toLatin1()) { //normal latin1 character
+ ret.append(c);
+ }
+ else {//unicode character, needs to be escaped
+ ret.append("&#")
+ .append(c.unicode())
+ .append(";");
+ }
+ }
+
+ return ret;
+ }
+ else {
+ return text;
+ }
+ }
+
+ return QString::null;
}
QString CSwordKey::strippedText() {
- if (!m_module) return QString::null;
+ if (!m_module) return QString::null;
- if (dynamic_cast<sword::SWKey*>(this)) {
- char * buffer = new char[strlen(rawKey()) + 1];
- strcpy(buffer, rawKey());
- m_module->module()->getKey()->setText( buffer );
- delete [] buffer;
- }
+ if (dynamic_cast<sword::SWKey*>(this)) {
+ char * buffer = new char[strlen(rawKey()) + 1];
+ strcpy(buffer, rawKey());
+ m_module->module()->getKey()->setText( buffer );
+ delete [] buffer;
+ }
- return QString::fromUtf8( m_module->module()->StripText() );
+ return QString::fromUtf8( m_module->module()->StripText() );
}
const QTextCodec* CSwordKey::cp1252Codec() {
- static QTextCodec * codec = QTextCodec::codecForName("Windows-1252");
- return codec;
+ static QTextCodec * codec = QTextCodec::codecForName("Windows-1252");
+ return codec;
}
/** This will create a proper key object from a given module */
CSwordKey* CSwordKey::createInstance( CSwordModuleInfo* const module ) {
- if (!module) {
- return 0;
- }
+ if (!module) {
+ return 0;
+ }
- switch( module->type() ) {
+ switch ( module->type() ) {
- case CSwordModuleInfo::Bible://fall through
+ case CSwordModuleInfo::Bible://fall through
- case CSwordModuleInfo::Commentary:
- return new CSwordVerseKey( (sword::VerseKey *) ( (sword::SWKey *)(*module->module()) ), module );
+ case CSwordModuleInfo::Commentary:
+ return new CSwordVerseKey( (sword::VerseKey *) ( (sword::SWKey *)(*module->module()) ), module );
- case CSwordModuleInfo::Lexicon:
- return new CSwordLDKey( (sword::SWKey *)(*module->module()), module);
+ case CSwordModuleInfo::Lexicon:
+ return new CSwordLDKey( (sword::SWKey *)(*module->module()), module);
- case CSwordModuleInfo::GenericBook:
- return new CSwordTreeKey( (sword::TreeKeyIdx*)((sword::SWKey *)(*module->module())), module );
+ case CSwordModuleInfo::GenericBook:
+ return new CSwordTreeKey( (sword::TreeKeyIdx*)((sword::SWKey *)(*module->module())), module );
- default:
- return 0;
- }
+ default:
+ return 0;
+ }
}
diff --git a/src/backend/keys/cswordkey.h b/src/backend/keys/cswordkey.h
index e0e6300..af0075a 100644
--- a/src/backend/keys/cswordkey.h
+++ b/src/backend/keys/cswordkey.h
@@ -24,88 +24,89 @@ class QTextCodec;
class CSwordKey {
-protected:
- /** Constructor. May only be called from sublasses because this class contains pure virtual methods.
- * @param module The module which belongs to this key, may be NULL
- */
- CSwordKey(CSwordModuleInfo* const module = 0); //protected constructor, because CSwordKey shouldn't be used (it's an abstract base class).
- /** Copy constructor.
- */
- CSwordKey(const CSwordKey&); //copy constructor
+ protected:
+ /** Constructor. May only be called from sublasses because this class contains pure virtual methods.
+ * @param module The module which belongs to this key, may be NULL
+ */
+ CSwordKey(CSwordModuleInfo* const module = 0); //protected constructor, because CSwordKey shouldn't be used (it's an abstract base class).
+ /** Copy constructor.
+ */
+ CSwordKey(const CSwordKey&); //copy constructor
-public:
- enum TextRenderType {
- Normal = 0,
- HTMLEscaped
- };
- /** Destructor.
- * Public, not protected like the constructor, because CSwordKey pointers may be deleted by all others.
- */
- virtual ~CSwordKey() {};
+ public:
+ enum TextRenderType {
+ Normal = 0,
+ HTMLEscaped = 1,
+ ProcessEntryAttributesOnly = 2 // in this case, renderText() will not return text, but only cause EntryAttribute processing
+ };
+ /** Destructor.
+ * Public, not protected like the constructor, because CSwordKey pointers may be deleted by all others.
+ */
+ virtual ~CSwordKey() {};
- //pure virtual functions
- /** Returns the current key.
- * @return The current key which belongs to the current object.
- */
- virtual QString key() const = 0;
- /** Sets the current key. Sets the key using a utf8 enabled QString.
- * @param key The key which should be used to set the current one
- */
- virtual bool key(const QString& key) = 0;
- /** Set the key using a utf8-decoded c-string
- * @param key The key which should be used to set the current one
- */
- virtual bool key(const char* key) = 0;
- /** Clone this object. Clone this current object and return it.
- * @return A clone of the current object.
- */
- virtual CSwordKey* copy() const = 0;
+ //pure virtual functions
+ /** Returns the current key.
+ * @return The current key which belongs to the current object.
+ */
+ virtual QString key() const = 0;
+ /** Sets the current key. Sets the key using a utf8 enabled QString.
+ * @param key The key which should be used to set the current one
+ */
+ virtual bool key(const QString& key) = 0;
+ /** Set the key using a utf8-decoded c-string
+ * @param key The key which should be used to set the current one
+ */
+ virtual bool key(const char* key) = 0;
+ /** Clone this object. Clone this current object and return it.
+ * @return A clone of the current object.
+ */
+ virtual CSwordKey* copy() const = 0;
- //implemented functions
- /** Set/get the module. Set and get the module which belongs to this key.
- * @return The module which belongs to this key.
- */
- inline virtual CSwordModuleInfo* module(CSwordModuleInfo* const newModule = 0);
- /** Returns the raw, unchanged text. Returns the text without any filter modifications,
- * just in the way it comes out of the module.
- */
- virtual QString rawText();
- /** Returns the rendered text. Returns the text of the current key after passign it through the
- * modules filters.
- */
- virtual QString renderedText( const CSwordKey::TextRenderType mode = CSwordKey::Normal );
- /** Stripped down text. Returns the text after removing all markup tags from it.
- */
- virtual QString strippedText();
- /**
- * This returns a new object of the right CSwordKey* implementation
- * (e.g. CSwordVerseKey or CSwordLDKey)
- * The type is determined by the type of the module.
- * @see CSwordModuleInfo, CSwordBibleModuleInfo, CSwordCommentaryModuleInfo, CSwordLexiconModukleInfo
- */
- static CSwordKey* createInstance(CSwordModuleInfo * const module);
+ //implemented functions
+ /** Set/get the module. Set and get the module which belongs to this key.
+ * @return The module which belongs to this key.
+ */
+ inline virtual CSwordModuleInfo* module(CSwordModuleInfo* const newModule = 0);
+ /** Returns the raw, unchanged text. Returns the text without any filter modifications,
+ * just in the way it comes out of the module.
+ */
+ virtual QString rawText();
+ /** Returns the rendered text. Returns the text of the current key after passign it through the
+ * modules filters.
+ */
+ virtual QString renderedText( const CSwordKey::TextRenderType mode = CSwordKey::Normal );
+ /** Stripped down text. Returns the text after removing all markup tags from it.
+ */
+ virtual QString strippedText();
+ /**
+ * This returns a new object of the right CSwordKey* implementation
+ * (e.g. CSwordVerseKey or CSwordLDKey)
+ * The type is determined by the type of the module.
+ * @see CSwordModuleInfo, CSwordBibleModuleInfo, CSwordCommentaryModuleInfo, CSwordLexiconModukleInfo
+ */
+ static CSwordKey* createInstance(CSwordModuleInfo * const module);
-protected:
- /**
- * Returns the encoded key appropriate for use directly with Sword.
- */
- virtual const char * rawKey() const = 0;
- static const QTextCodec* cp1252Codec();
- CSwordModuleInfo* m_module; //module pointer used by all keys
+ protected:
+ /**
+ * Returns the encoded key appropriate for use directly with Sword.
+ */
+ virtual const char * rawKey() const = 0;
+ static const QTextCodec* cp1252Codec();
+ CSwordModuleInfo* m_module; //module pointer used by all keys
-private:
- /**
- * Disable the assignment operator
- */
- CSwordKey& operator= ( const CSwordKey & );
+ private:
+ /**
+ * Disable the assignment operator
+ */
+ CSwordKey& operator= ( const CSwordKey & );
};
inline CSwordModuleInfo* CSwordKey::module(CSwordModuleInfo* const newModule) {
- if (newModule) {
- m_module = newModule;
- }
- return m_module;
+ if (newModule) {
+ m_module = newModule;
+ }
+ return m_module;
}
#endif
diff --git a/src/backend/keys/cswordldkey.cpp b/src/backend/keys/cswordldkey.cpp
index 3205827..4aa95cb 100644
--- a/src/backend/keys/cswordldkey.cpp
+++ b/src/backend/keys/cswordldkey.cpp
@@ -19,11 +19,11 @@
#include <QTextCodec>
CSwordLDKey::CSwordLDKey( CSwordModuleInfo* module ) {
- if ((m_module = dynamic_cast<CSwordLexiconModuleInfo*>(module))) {
- // *(m_module->module()) = TOP;
- }
+ if ((m_module = dynamic_cast<CSwordLexiconModuleInfo*>(module))) {
+ // *(m_module->module()) = TOP;
+ }
- SWKey::operator= (" ");
+ SWKey::operator= (" ");
}
/** No descriptions */
@@ -34,85 +34,87 @@ CSwordLDKey::CSwordLDKey( const SWKey *k, CSwordModuleInfo* module) : CSwordKey(
/** Clones this object by copying the members. */
CSwordLDKey* CSwordLDKey::copy() const {
- return new CSwordLDKey(*this);
+ return new CSwordLDKey(*this);
}
/** Sets the module of this key. */
CSwordModuleInfo* CSwordLDKey::module(CSwordModuleInfo* const newModule) {
- if (newModule && newModule->type() == CSwordModuleInfo::Lexicon) {
- const QString oldKey = key();
- m_module = newModule;
- key(oldKey);
- }
+ if (newModule && newModule->type() == CSwordModuleInfo::Lexicon) {
+ const QString oldKey = key();
+ m_module = newModule;
+ key(oldKey);
+ }
- return m_module;
+ return m_module;
}
QString CSwordLDKey::key() const {
- //return QString::fromUtf8((const char*)*this);
- Q_ASSERT(m_module);
-
- if (m_module->isUnicode()) {
- return QString::fromUtf8((const char*)*this);
- } else {
- return cp1252Codec()->toUnicode((const char*)*this);
- }
+ //return QString::fromUtf8((const char*)*this);
+ Q_ASSERT(m_module);
+
+ if (m_module->isUnicode()) {
+ return QString::fromUtf8((const char*)*this);
+ }
+ else {
+ return cp1252Codec()->toUnicode((const char*)*this);
+ }
}
const char * CSwordLDKey::rawKey() const {
- return (const char*)*this;
+ return (const char*)*this;
}
bool CSwordLDKey::key( const QString& newKey ) {
- Q_ASSERT(m_module);
-
- if (m_module->isUnicode()) {
- return key(newKey.toUtf8().constData());
- } else {
- return key((const char*)cp1252Codec()->fromUnicode(newKey));
- }
+ Q_ASSERT(m_module);
+
+ if (m_module->isUnicode()) {
+ return key(newKey.toUtf8().constData());
+ }
+ else {
+ return key((const char*)cp1252Codec()->fromUnicode(newKey));
+ }
}
/** Sets the key of this instance */
bool CSwordLDKey::key( const char* newKey ) {
- Q_ASSERT(newKey);
+ Q_ASSERT(newKey);
- if (newKey) {
- SWKey::operator = (newKey); //set the key
- m_module->module()->SetKey(this);
- m_module->snap();
- }
+ if (newKey) {
+ SWKey::operator = (newKey); //set the key
+ m_module->module()->SetKey(this);
+ m_module->snap();
+ }
- return !Error();
+ return !Error();
}
/** Uses the parameter to returns the next entry afer this key. */
CSwordLDKey* CSwordLDKey::NextEntry() {
- m_module->module()->SetKey(this); //use this key as base for the next one!
- // m_module->module()->getKey()->setText( (const char*)key().utf8() );
+ m_module->module()->SetKey(this); //use this key as base for the next one!
+ // m_module->module()->getKey()->setText( (const char*)key().utf8() );
- m_module->module()->setSkipConsecutiveLinks(true);
- ( *( m_module->module() ) )++;
- m_module->module()->setSkipConsecutiveLinks(false);
+ m_module->module()->setSkipConsecutiveLinks(true);
+ ( *( m_module->module() ) )++;
+ m_module->module()->setSkipConsecutiveLinks(false);
- key(m_module->module()->KeyText());
- SWKey::operator = (m_module->module()->KeyText());
+ key(m_module->module()->KeyText());
+ SWKey::operator = (m_module->module()->KeyText());
- return this;
+ return this;
}
/** Uses the parameter to returns the next entry afer this key. */
CSwordLDKey* CSwordLDKey::PreviousEntry() {
- m_module->module()->SetKey(this); //use this key as base for the next one!
- // m_module->module()->getKey()->setText( (const char*)key().utf8() );
+ m_module->module()->SetKey(this); //use this key as base for the next one!
+ // m_module->module()->getKey()->setText( (const char*)key().utf8() );
- m_module->module()->setSkipConsecutiveLinks(true);
- ( *( m_module->module() ) )--;
- m_module->module()->setSkipConsecutiveLinks(false);
+ m_module->module()->setSkipConsecutiveLinks(true);
+ ( *( m_module->module() ) )--;
+ m_module->module()->setSkipConsecutiveLinks(false);
- SWKey::operator = (m_module->module()->KeyText());
+ SWKey::operator = (m_module->module()->KeyText());
- return this;
+ return this;
}
diff --git a/src/backend/keys/cswordldkey.h b/src/backend/keys/cswordldkey.h
index 0349597..1cb3382 100644
--- a/src/backend/keys/cswordldkey.h
+++ b/src/backend/keys/cswordldkey.h
@@ -49,59 +49,59 @@ class CSwordModuleInfo;
class CSwordLDKey : public CSwordKey, public sword::SWKey {
-public:
- /**
- * Constructor of CSwordLDKey
- */
- CSwordLDKey( CSwordModuleInfo* module );
- /**
- * Copy constructor for this key class.
- */
- CSwordLDKey( const CSwordLDKey &k );
- /**
- * Copy constructor for this key class.
- */
- CSwordLDKey( const sword::SWKey *k, CSwordModuleInfo* module);
- /**
- * Clones this object by copying the members.
- */
- virtual CSwordLDKey* copy() const;
- /**
- * Uses the parameter to returns the next entry afer this key.
- */
- CSwordLDKey* NextEntry( void );
- /**
- * Uses the parameter to returns the previous entry afer this key.
- */
- CSwordLDKey* PreviousEntry( void );
- /**
- * Sets the module of this key.
- */
- virtual CSwordModuleInfo* module( CSwordModuleInfo* const module = 0 );
- /**
- * Returns the current key as a QString
- */
- virtual QString key() const;
- /**
- * Set the current key using unicode decoded QString.
- */
- virtual bool key( const QString& newKey );
- /**
- * Set the current key from char*. To avoid encoding problems use key(QString) instead.
- */
- virtual bool key( const char* );
+ public:
+ /**
+ * Constructor of CSwordLDKey
+ */
+ CSwordLDKey( CSwordModuleInfo* module );
+ /**
+ * Copy constructor for this key class.
+ */
+ CSwordLDKey( const CSwordLDKey &k );
+ /**
+ * Copy constructor for this key class.
+ */
+ CSwordLDKey( const sword::SWKey *k, CSwordModuleInfo* module);
+ /**
+ * Clones this object by copying the members.
+ */
+ virtual CSwordLDKey* copy() const;
+ /**
+ * Uses the parameter to returns the next entry afer this key.
+ */
+ CSwordLDKey* NextEntry( void );
+ /**
+ * Uses the parameter to returns the previous entry afer this key.
+ */
+ CSwordLDKey* PreviousEntry( void );
+ /**
+ * Sets the module of this key.
+ */
+ virtual CSwordModuleInfo* module( CSwordModuleInfo* const module = 0 );
+ /**
+ * Returns the current key as a QString
+ */
+ virtual QString key() const;
+ /**
+ * Set the current key using unicode decoded QString.
+ */
+ virtual bool key( const QString& newKey );
+ /**
+ * Set the current key from char*. To avoid encoding problems use key(QString) instead.
+ */
+ virtual bool key( const char* );
-protected:
- /**
- * Returns the raw key appropriate for use directly with Sword.
- */
- virtual const char* rawKey() const;
+ protected:
+ /**
+ * Returns the raw key appropriate for use directly with Sword.
+ */
+ virtual const char* rawKey() const;
-private:
- /**
- * Disable assignment operator
- */
- CSwordLDKey& operator= (const CSwordLDKey& );
+ private:
+ /**
+ * Disable assignment operator
+ */
+ CSwordLDKey& operator= (const CSwordLDKey& );
};
diff --git a/src/backend/keys/cswordtreekey.cpp b/src/backend/keys/cswordtreekey.cpp
index 6e02806..e845bf6 100644
--- a/src/backend/keys/cswordtreekey.cpp
+++ b/src/backend/keys/cswordtreekey.cpp
@@ -19,75 +19,77 @@ CSwordTreeKey::CSwordTreeKey( const CSwordTreeKey& k ) : CSwordKey(k), TreeKeyId
CSwordTreeKey::CSwordTreeKey( const TreeKeyIdx *k, CSwordModuleInfo* module ) : CSwordKey(module), TreeKeyIdx(*k) {}
CSwordTreeKey* CSwordTreeKey::copy() const {
- return new CSwordTreeKey(*this);
+ return new CSwordTreeKey(*this);
}
/** Sets the key of this instance */
QString CSwordTreeKey::key() const {
- //return getTextUnicode();
- Q_ASSERT(m_module);
- if (m_module->isUnicode()) {
- return QString::fromUtf8(getText());
- } else {
- return cp1252Codec()->toUnicode(getText());
- }
+ //return getTextUnicode();
+ Q_ASSERT(m_module);
+ if (m_module->isUnicode()) {
+ return QString::fromUtf8(getText());
+ }
+ else {
+ return cp1252Codec()->toUnicode(getText());
+ }
}
const char * CSwordTreeKey::rawKey() const {
- return getText();
+ return getText();
}
bool CSwordTreeKey::key( const QString& newKey ) {
- //return key( newKey.toLocal8Bit().constData() );
- //return key(m_module->getTextCodec()->fromUnicode(newKey).constData());
- Q_ASSERT(m_module);
- if (m_module->isUnicode()) {
- return key(newKey.toUtf8().constData());
- } else {
- return key((const char*)cp1252Codec()->fromUnicode(newKey));
- }
+ //return key( newKey.toLocal8Bit().constData() );
+ //return key(m_module->getTextCodec()->fromUnicode(newKey).constData());
+ Q_ASSERT(m_module);
+ if (m_module->isUnicode()) {
+ return key(newKey.toUtf8().constData());
+ }
+ else {
+ return key((const char*)cp1252Codec()->fromUnicode(newKey));
+ }
}
bool CSwordTreeKey::key( const char* newKey ) {
- Q_ASSERT(newKey);
+ Q_ASSERT(newKey);
- if (newKey) {
- TreeKeyIdx::operator = (newKey);
- }
- else {
- root();
- }
+ if (newKey) {
+ TreeKeyIdx::operator = (newKey);
+ }
+ else {
+ root();
+ }
- return !Error();
+ return !Error();
}
-QString CSwordTreeKey::getLocalNameUnicode()
-{
- //return m_module->getTextCodec()->toUnicode(getLocalName());
- //Only UTF-8 and latin1 are legal Sword module encodings
- Q_ASSERT(m_module);
- if (m_module->isUnicode()) {
- return QString::fromUtf8(getLocalName());
- } else {
- return cp1252Codec()->toUnicode(getLocalName());
- }
+QString CSwordTreeKey::getLocalNameUnicode() {
+ //return m_module->getTextCodec()->toUnicode(getLocalName());
+ //Only UTF-8 and latin1 are legal Sword module encodings
+ Q_ASSERT(m_module);
+ if (m_module->isUnicode()) {
+ return QString::fromUtf8(getLocalName());
+ }
+ else {
+ return cp1252Codec()->toUnicode(getLocalName());
+ }
}
CSwordModuleInfo* CSwordTreeKey::module( CSwordModuleInfo* const newModule ) {
- if (newModule && (newModule != m_module) && (newModule->type() == CSwordModuleInfo::GenericBook) ) {
- m_module = newModule;
+ if (newModule && (newModule != m_module) && (newModule->type() == CSwordModuleInfo::GenericBook) ) {
+ m_module = newModule;
- const QString oldKey = key();
+ const QString oldKey = key();
- CSwordBookModuleInfo* newBook = dynamic_cast<CSwordBookModuleInfo*>(newModule);
- copyFrom( *(newBook->tree()) );
+ CSwordBookModuleInfo* newBook = dynamic_cast<CSwordBookModuleInfo*>(newModule);
+ copyFrom( *(newBook->tree()) );
- key(oldKey); //try to restore our old key
+ key(oldKey); //try to restore our old key
- //set the key to the root node
- root();
- firstChild();
- }
+ //set the key to the root node
+ root();
+ firstChild();
+ }
- return m_module;
+ return m_module;
}
diff --git a/src/backend/keys/cswordtreekey.h b/src/backend/keys/cswordtreekey.h
index 4114652..c0c9e45 100644
--- a/src/backend/keys/cswordtreekey.h
+++ b/src/backend/keys/cswordtreekey.h
@@ -25,55 +25,57 @@ class CSwordModuleInfo;
class CSwordTreeKey : public CSwordKey, public sword::TreeKeyIdx {
-public:
- /** Constructor of this CSwordKey implementation.
- * @param k The Sword tree key which belongs to this key
- * @param module The module which belongs to this key
- */
- CSwordTreeKey( const sword::TreeKeyIdx *k, CSwordModuleInfo* module );
- /** Copy constructor.
- */
- CSwordTreeKey( const CSwordTreeKey& k );
- /** The module which belongs to this key.
- * @return The module.
- */
- virtual CSwordModuleInfo* module( CSwordModuleInfo* const newModule );
- /** Copy method.
- * @return A new copy of this object.
- */
- virtual CSwordTreeKey* copy() const;
+ public:
+ /** Constructor of this CSwordKey implementation.
+ * @param k The Sword tree key which belongs to this key
+ * @param module The module which belongs to this key
+ */
+ CSwordTreeKey( const sword::TreeKeyIdx *k, CSwordModuleInfo* module );
+ /** Copy constructor.
+ */
+ CSwordTreeKey( const CSwordTreeKey& k );
+ /** The module which belongs to this key.
+ * @return The module.
+ */
+ virtual CSwordModuleInfo* module( CSwordModuleInfo* const newModule );
+ /** Copy method.
+ * @return A new copy of this object.
+ */
+ virtual CSwordTreeKey* copy() const;
- /**
- * Returns the TreeKeyIdx::getLocalKey value in unicode.
- * Local key is the last part of the tree key, for example "Subsection1" from "/Section1/Subsection1".
- * Use this instead of getLocalKey() to avoid encoding problems.
- */
- QString getLocalNameUnicode();
- /**
- * Returns the current key as unicode decoded QString.
- */
- virtual QString key() const;
- /**
- * Set the key. If the parameter is empty or null, the key will be set to "/"
- */
- virtual bool key( const QString& key );
- /**
- * Set the key from char* To avoid encoding problems use key(QString instead),
- * otherwise it is caller's responsibility to ensure the correct encoding (utf8/latin1).
- */
- virtual bool key( const char* key );
+ /**
+ * Returns the TreeKeyIdx::getLocalKey value in unicode.
+ * Local key is the last part of the tree key, for example "Subsection1" from "/Section1/Subsection1".
+ * Use this instead of getLocalKey() to avoid encoding problems.
+ */
+ QString getLocalNameUnicode();
+ /**
+ * Returns the current key as unicode decoded QString.
+ */
+ virtual QString key() const;
+ /**
+ * Set the key. If the parameter is empty or null, the key will be set to "/"
+ */
+ virtual bool key( const QString& key );
+ /**
+ * Set the key from char* To avoid encoding problems use key(QString instead),
+ * otherwise it is caller's responsibility to ensure the correct encoding (utf8/latin1).
+ */
+ virtual bool key( const char* key );
-protected:
- /**
- * Returns the raw key appropriate for use directly with Sword.
- */
- virtual const char * rawKey() const;
+ protected:
+ /**
+ * Returns the raw key appropriate for use directly with Sword.
+ */
+ virtual const char * rawKey() const;
-private:
- /** Disable assignment operator */
- CSwordTreeKey& operator= (const CSwordTreeKey&);
- /** Disable from base class to prevent compiler warnings */
- inline virtual CSwordTreeKey& operator= (const sword::TreeKeyIdx&) { return (*this); };
+ private:
+ /** Disable assignment operator */
+ CSwordTreeKey& operator= (const CSwordTreeKey&);
+ /** Disable from base class to prevent compiler warnings */
+ inline virtual CSwordTreeKey& operator= (const sword::TreeKeyIdx&) {
+ return (*this);
+ };
};
#endif
diff --git a/src/backend/keys/cswordversekey.cpp b/src/backend/keys/cswordversekey.cpp
index 8008a7f..01cfd31 100644
--- a/src/backend/keys/cswordversekey.cpp
+++ b/src/backend/keys/cswordversekey.cpp
@@ -19,14 +19,13 @@
#include <localemgr.h>
CSwordVerseKey::CSwordVerseKey( CSwordModuleInfo* const module ) :
- CSwordKey(module)
-{
- if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module) ) {
- // Copy important settings like versification system
- copyFrom((sword::VerseKey*) bible->module()->getKey());
-
- key( bible->lowerBound().key() );
- }
+ CSwordKey(module) {
+ if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module) ) {
+ // Copy important settings like versification system
+ copyFrom((sword::VerseKey*) bible->module()->getKey());
+
+ key( bible->lowerBound().key() );
+ }
}
CSwordVerseKey::CSwordVerseKey( const CSwordVerseKey& k ) : CSwordKey(k), VerseKey(k) {}
@@ -35,258 +34,258 @@ CSwordVerseKey::CSwordVerseKey( const VerseKey* const k, CSwordModuleInfo* const
/** Clones this object. */
CSwordKey* CSwordVerseKey::copy() const {
- return new CSwordVerseKey(*this);
+ return new CSwordVerseKey(*this);
}
/** Sets the module for this key */
CSwordModuleInfo* CSwordVerseKey::module( CSwordModuleInfo* const newModule ) {
- if (newModule && ((newModule->type() == CSwordModuleInfo::Bible) || (newModule->type() == CSwordModuleInfo::Commentary) ) ) {
- m_module = newModule;
+ if (newModule && ((newModule->type() == CSwordModuleInfo::Bible) || (newModule->type() == CSwordModuleInfo::Commentary) ) ) {
+ m_module = newModule;
- //check if the module contains the key we present
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(newModule);
+ //check if the module contains the key we present
+ CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(newModule);
- if (_compare(bible->lowerBound()) < 0) {
- key( bible->lowerBound() );
- }
+ if (_compare(bible->lowerBound()) < 0) {
+ key( bible->lowerBound() );
+ }
- if (_compare(bible->upperBound()) > 0) {
- key( bible->upperBound() );
- }
- }
+ if (_compare(bible->upperBound()) > 0) {
+ key( bible->upperBound() );
+ }
+ }
- return dynamic_cast<CSwordBibleModuleInfo*>(m_module);
+ return dynamic_cast<CSwordBibleModuleInfo*>(m_module);
}
/** Returns the current book as Text, not as integer. */
QString CSwordVerseKey::book( const QString& newBook ) {
- int min = 0;
- int max = 1;
-
- if (CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module())) {
- const bool hasOT = bible->hasTestament(CSwordBibleModuleInfo::OldTestament);
- const bool hasNT = bible->hasTestament(CSwordBibleModuleInfo::NewTestament);
-
- if (hasOT && hasNT) {
- min = 0;
- max = 1;
- }
- else if (hasOT && !hasNT) {
- min = 0;
- max = 0;
- }
- else if (!hasOT && hasNT) {
- min = 1;
- max = 1;
- }
- else if (!hasOT && !hasNT) {
- min = 0;
- max = -1; //no loop
- }
- }
-
- if (!newBook.isEmpty()) {
- setBookName(newBook.toUtf8().constData());
- }
-
- if ( (Testament() >= min+1) && (Testament() <= max+1) && (Book() <= BMAX[min]) ) {
- return QString::fromUtf8( getBookName() );
- }
-
- //return QString::fromUtf8( books[min][0].name ); //return the first book, i.e. Genesis
- return QString::null;
+ int min = 0;
+ int max = 1;
+
+ if (CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module())) {
+ const bool hasOT = bible->hasTestament(CSwordBibleModuleInfo::OldTestament);
+ const bool hasNT = bible->hasTestament(CSwordBibleModuleInfo::NewTestament);
+
+ if (hasOT && hasNT) {
+ min = 0;
+ max = 1;
+ }
+ else if (hasOT && !hasNT) {
+ min = 0;
+ max = 0;
+ }
+ else if (!hasOT && hasNT) {
+ min = 1;
+ max = 1;
+ }
+ else if (!hasOT && !hasNT) {
+ min = 0;
+ max = -1; //no loop
+ }
+ }
+
+ if (!newBook.isEmpty()) {
+ setBookName(newBook.toUtf8().constData());
+ }
+
+ if ( (Testament() >= min + 1) && (Testament() <= max + 1) && (Book() <= BMAX[min]) ) {
+ return QString::fromUtf8( getBookName() );
+ }
+
+ //return QString::fromUtf8( books[min][0].name ); //return the first book, i.e. Genesis
+ return QString::null;
}
/** Sets the key we use to the parameter. */
QString CSwordVerseKey::key() const {
- return QString::fromUtf8(getText());
+ return QString::fromUtf8(getText());
}
const char * CSwordVerseKey::rawKey() const {
- return getText();
+ return getText();
}
bool CSwordVerseKey::key( const QString& newKey ) {
- return key( newKey.toUtf8().constData() );
+ return key( newKey.toUtf8().constData() );
}
bool CSwordVerseKey::key( const char* newKey ) {
- if (newKey && (strlen(newKey)>0) ) {
- VerseKey::operator = (newKey);
- }
- else if (newKey && !strlen(newKey)) {
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module());
-
- if ( bible ) {
- VerseKey::operator = (bible->lowerBound().key().toUtf8().constData());
- }
- }
-
- return !Error();
+ if (newKey && (strlen(newKey) > 0) ) {
+ VerseKey::operator = (newKey);
+ }
+ else if (newKey && !strlen(newKey)) {
+ CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module());
+
+ if ( bible ) {
+ VerseKey::operator = (bible->lowerBound().key().toUtf8().constData());
+ }
+ }
+
+ return !Error();
}
bool CSwordVerseKey::next( const JumpType type ) {
- Error(); //clear Error status
- bool ret = true;
-
- switch (type) {
-
- case UseBook: {
- const int currentTestament = Testament();
- const int currentBook = Book();
-
- if ((currentTestament == 2) && (currentBook >= BMAX[currentTestament-1])) { //Revelation, i.e. end of navigation
- return false;
- }
- else if ((currentTestament == 1) && (currentBook >= BMAX[currentTestament-1])) { //Malachi, switch to the NT
- Testament(currentTestament+1);
- Book(1);
- }
- else {
- Book(Book()+1);
- }
- break;
- }
-
- case UseChapter: {
- Chapter(Chapter()+1);
- break;
- }
-
- case UseVerse: {
- if (m_module && m_module->module()) {
- const bool oldStatus = m_module->module()->getSkipConsecutiveLinks();
- m_module->module()->setSkipConsecutiveLinks(true);
-
- //disable headings for next verse
- const bool useHeaders = (Verse() == 0);
- const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders );
- //don't use setKey(), that would create a new key without Headings set
- m_module->module()->getKey()->setText( key().toUtf8().constData() );
-
- (*(m_module->module()) )++;
-
- ((VerseKey*)(m_module->module()->getKey()))->Headings(oldHeadingsStatus);
- m_module->module()->setSkipConsecutiveLinks(oldStatus);
-
- if (!m_module->module()->Error()) {
- key( QString::fromUtf8(m_module->module()->KeyText()) );
- }
- else {
- // Verse(Verse()+1);
- //don't change the key, restore the module's position
- m_module->module()->getKey()->setText( key().toUtf8().constData() );
- ret = false;
- break;
- }
-
- }
- else {
- Verse(Verse()+1);
- }
-
- break;
- }
-
- default:
- return false;
- }
-
- if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()) ) {
- if (_compare(bible->lowerBound()) < 0 ) {
- key( bible->lowerBound() );
- ret = false;
- }
-
- if (_compare(bible->upperBound()) > 0 ) {
- key( bible->upperBound() );
- ret = false;
- }
-
- return ret;
- }
- else if (Error()) { //we have no module, so take care of VerseKey::Error()
- return false;
- }
-
- return ret;
+ Error(); //clear Error status
+ bool ret = true;
+
+ switch (type) {
+
+ case UseBook: {
+ const int currentTestament = Testament();
+ const int currentBook = Book();
+
+ if ((currentTestament == 2) && (currentBook >= BMAX[currentTestament-1])) { //Revelation, i.e. end of navigation
+ return false;
+ }
+ else if ((currentTestament == 1) && (currentBook >= BMAX[currentTestament-1])) { //Malachi, switch to the NT
+ Testament(currentTestament + 1);
+ Book(1);
+ }
+ else {
+ Book(Book() + 1);
+ }
+ break;
+ }
+
+ case UseChapter: {
+ Chapter(Chapter() + 1);
+ break;
+ }
+
+ case UseVerse: {
+ if (m_module && m_module->module()) {
+ const bool oldStatus = m_module->module()->getSkipConsecutiveLinks();
+ m_module->module()->setSkipConsecutiveLinks(true);
+
+ //disable headings for next verse
+ const bool useHeaders = (Verse() == 0);
+ const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders );
+ //don't use setKey(), that would create a new key without Headings set
+ m_module->module()->getKey()->setText( key().toUtf8().constData() );
+
+ (*(m_module->module()) )++;
+
+ ((VerseKey*)(m_module->module()->getKey()))->Headings(oldHeadingsStatus);
+ m_module->module()->setSkipConsecutiveLinks(oldStatus);
+
+ if (!m_module->module()->Error()) {
+ key( QString::fromUtf8(m_module->module()->KeyText()) );
+ }
+ else {
+ // Verse(Verse()+1);
+ //don't change the key, restore the module's position
+ m_module->module()->getKey()->setText( key().toUtf8().constData() );
+ ret = false;
+ break;
+ }
+
+ }
+ else {
+ Verse(Verse() + 1);
+ }
+
+ break;
+ }
+
+ default:
+ return false;
+ }
+
+ if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()) ) {
+ if (_compare(bible->lowerBound()) < 0 ) {
+ key( bible->lowerBound() );
+ ret = false;
+ }
+
+ if (_compare(bible->upperBound()) > 0 ) {
+ key( bible->upperBound() );
+ ret = false;
+ }
+
+ return ret;
+ }
+ else if (Error()) { //we have no module, so take care of VerseKey::Error()
+ return false;
+ }
+
+ return ret;
}
bool CSwordVerseKey::previous( const JumpType type ) {
- bool ret = true;
-
- switch (type) {
-
- case UseBook: {
- if ( (Book() == 1) && (Testament() == 1) ) { //Genesis
- return false;
- }
- else if ( (Book() == 1) && (Testament() == 2) ){ //Matthew
- Testament(1);
- Book(BMAX[0]);
- }
- else{
- Book( Book()-1 );
- }
-
- break;
- }
-
- case UseChapter: {
- Chapter(Chapter()-1);
- break;
- }
-
- case UseVerse: {
- if (m_module && m_module->module()) {
- const bool useHeaders = (Verse() == 0);
- const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders );
-
- m_module->module()->getKey()->setText( key().toUtf8().constData() );
-
- const bool oldStatus = m_module->module()->getSkipConsecutiveLinks();
- m_module->module()->setSkipConsecutiveLinks(true);
- ( *( m_module->module() ) )--;
-
- ((VerseKey*)(m_module->module()->getKey()))->Headings( oldHeadingsStatus );
- m_module->module()->setSkipConsecutiveLinks(oldStatus);
-
- if (!m_module->module()->Error()) {
- key( QString::fromUtf8(m_module->module()->KeyText()) );//don't use fromUtf8
- }
- else {
- ret = false;
- // Verse(Verse()-1);
- m_module->module()->getKey()->setText( key().toUtf8().constData() ); //restore module's key
- }
- }
- else {
- Verse(Verse()-1);
- }
-
- break;
- }
-
- default:
- return false;
- }
-
- if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()) ) {
- if (_compare(bible->lowerBound()) < 0 ) {
- key( bible->lowerBound() );
- ret = false;
- }
-
- if (_compare(bible->upperBound()) > 0 ) {
- key( bible->upperBound() );
- ret = false;
- }
-
- return ret;
- }
- else if (Error()) {
- return false;
- }
-
- return ret;
+ bool ret = true;
+
+ switch (type) {
+
+ case UseBook: {
+ if ( (Book() == 1) && (Testament() == 1) ) { //Genesis
+ return false;
+ }
+ else if ( (Book() == 1) && (Testament() == 2) ) { //Matthew
+ Testament(1);
+ Book(BMAX[0]);
+ }
+ else {
+ Book( Book() - 1 );
+ }
+
+ break;
+ }
+
+ case UseChapter: {
+ Chapter(Chapter() - 1);
+ break;
+ }
+
+ case UseVerse: {
+ if (m_module && m_module->module()) {
+ const bool useHeaders = (Verse() == 0);
+ const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders );
+
+ m_module->module()->getKey()->setText( key().toUtf8().constData() );
+
+ const bool oldStatus = m_module->module()->getSkipConsecutiveLinks();
+ m_module->module()->setSkipConsecutiveLinks(true);
+ ( *( m_module->module() ) )--;
+
+ ((VerseKey*)(m_module->module()->getKey()))->Headings( oldHeadingsStatus );
+ m_module->module()->setSkipConsecutiveLinks(oldStatus);
+
+ if (!m_module->module()->Error()) {
+ key( QString::fromUtf8(m_module->module()->KeyText()) );//don't use fromUtf8
+ }
+ else {
+ ret = false;
+ // Verse(Verse()-1);
+ m_module->module()->getKey()->setText( key().toUtf8().constData() ); //restore module's key
+ }
+ }
+ else {
+ Verse(Verse() - 1);
+ }
+
+ break;
+ }
+
+ default:
+ return false;
+ }
+
+ if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()) ) {
+ if (_compare(bible->lowerBound()) < 0 ) {
+ key( bible->lowerBound() );
+ ret = false;
+ }
+
+ if (_compare(bible->upperBound()) > 0 ) {
+ key( bible->upperBound() );
+ ret = false;
+ }
+
+ return ret;
+ }
+ else if (Error()) {
+ return false;
+ }
+
+ return ret;
}
diff --git a/src/backend/keys/cswordversekey.h b/src/backend/keys/cswordversekey.h
index e421b6c..0f286dc 100644
--- a/src/backend/keys/cswordversekey.h
+++ b/src/backend/keys/cswordversekey.h
@@ -44,79 +44,81 @@ class CSwordModuleInfo;
class CSwordVerseKey : public CSwordKey, public sword::VerseKey {
-public:
- enum JumpType {
- UseBook,
- UseChapter,
- UseVerse
- };
+ public:
+ enum JumpType {
+ UseBook,
+ UseChapter,
+ UseVerse
+ };
- /**
- * Constructor of this class.
- *
- * This function will construct a versekey with the current module position
- * and it will setup the m_module members.
- *
- */
- CSwordVerseKey( CSwordModuleInfo* const module );
- /**
- * Copy constructor.
- */
- CSwordVerseKey( const CSwordVerseKey& k );
- /**
- * VerseKey based constructor.
- */
- CSwordVerseKey( const sword::VerseKey* const k, CSwordModuleInfo* const module );
- /**
- * Clones this object.
- */
- virtual CSwordKey* copy() const;
- /**
- * Set/get the key. If the parameter is not set (means equal to QString::null)
- * the used key is returned. Otherwise the key is set and the new on ei returned.
- */
- virtual QString key() const;
- /**
- * Set the current key.
- */
- virtual bool key( const QString& );
- /**
- * Set/get the key. If the parameter is not set (means equal to QString::null)
- * the used key is returned. Otherwise the key is set and the new on ei returned.
- */
- virtual bool key( const char* key );
+ /**
+ * Constructor of this class.
+ *
+ * This function will construct a versekey with the current module position
+ * and it will setup the m_module members.
+ *
+ */
+ CSwordVerseKey( CSwordModuleInfo* const module );
+ /**
+ * Copy constructor.
+ */
+ CSwordVerseKey( const CSwordVerseKey& k );
+ /**
+ * VerseKey based constructor.
+ */
+ CSwordVerseKey( const sword::VerseKey* const k, CSwordModuleInfo* const module );
+ /**
+ * Clones this object.
+ */
+ virtual CSwordKey* copy() const;
+ /**
+ * Set/get the key. If the parameter is not set (means equal to QString::null)
+ * the used key is returned. Otherwise the key is set and the new on ei returned.
+ */
+ virtual QString key() const;
+ /**
+ * Set the current key.
+ */
+ virtual bool key( const QString& );
+ /**
+ * Set/get the key. If the parameter is not set (means equal to QString::null)
+ * the used key is returned. Otherwise the key is set and the new on ei returned.
+ */
+ virtual bool key( const char* key );
- /**
- * Jumps to the next entry of the given type
- */
- bool next( const JumpType type );
- /**
- * Jumps to the previous entry of the given type
- */
- bool previous ( const JumpType type );
- /**
- * This functions returns the current book as localised text, not as book numer.
- *
- * Use "char Book()" to retrieve the book number of the current book.
- * @return The name of the current book
- */
- QString book(const QString& newBook = QString::null);
- /**
- * Sets the module for this key
- */
- virtual CSwordModuleInfo* module( CSwordModuleInfo* const newModule = 0 );
+ /**
+ * Jumps to the next entry of the given type
+ */
+ bool next( const JumpType type );
+ /**
+ * Jumps to the previous entry of the given type
+ */
+ bool previous ( const JumpType type );
+ /**
+ * This functions returns the current book as localised text, not as book numer.
+ *
+ * Use "char Book()" to retrieve the book number of the current book.
+ * @return The name of the current book
+ */
+ QString book(const QString& newBook = QString::null);
+ /**
+ * Sets the module for this key
+ */
+ virtual CSwordModuleInfo* module( CSwordModuleInfo* const newModule = 0 );
-protected:
- /**
- * Returns the raw key appropriate for use directly with Sword.
- */
- virtual const char * rawKey() const;
+ protected:
+ /**
+ * Returns the raw key appropriate for use directly with Sword.
+ */
+ virtual const char * rawKey() const;
-private:
- /** Disable assignment operator */
- CSwordVerseKey& operator= (const CSwordVerseKey&);
- /** Disable from base class to prevent compiler warnings */
- inline virtual CSwordVerseKey& operator= (const sword::VerseKey&) { return (*this); };
+ private:
+ /** Disable assignment operator */
+ CSwordVerseKey& operator= (const CSwordVerseKey&);
+ /** Disable from base class to prevent compiler warnings */
+ inline virtual CSwordVerseKey& operator= (const sword::VerseKey&) {
+ return (*this);
+ };
};
#endif
diff --git a/src/backend/managers/btstringmgr.cpp b/src/backend/managers/btstringmgr.cpp
index 9f57258..a4fe381 100644
--- a/src/backend/managers/btstringmgr.cpp
+++ b/src/backend/managers/btstringmgr.cpp
@@ -10,127 +10,127 @@
#include "btstringmgr.h"
char* BTStringMgr::upperUTF8(char* text, unsigned int maxlen) const {
- const int max = (maxlen>0) ? maxlen : strlen(text);
+ const int max = (maxlen > 0) ? maxlen : strlen(text);
- if (isUtf8(text)) {
- strncpy(text, (const char*)QString::fromUtf8(text).toUpper().toUtf8(), max);
+ if (isUtf8(text)) {
+ strncpy(text, (const char*)QString::fromUtf8(text).toUpper().toUtf8(), max);
- return text;
- }
- else {
- char* ret = text;
+ return text;
+ }
+ else {
+ char* ret = text;
- while (*text) {
- *text = toupper(*text);
- text++;
- }
+ while (*text) {
+ *text = toupper(*text);
+ text++;
+ }
- return ret;
- }
+ return ret;
+ }
- return text;
+ return text;
}
char* BTStringMgr::upperLatin1(char* text, unsigned int /*max*/) const {
- char* ret = text;
+ char* ret = text;
- while (*text) {
- *text = toupper(*text);
- text++;
- }
+ while (*text) {
+ *text = toupper(*text);
+ text++;
+ }
- return ret;
+ return ret;
}
bool BTStringMgr::supportsUnicode() const {
- return true;
+ return true;
}
bool BTStringMgr::isUtf8(const char *buf) const {
- int i, n;
- register unsigned char c;
- bool gotone = false;
-
- #define F 0 /* character never appears in text */
- #define T 1 /* character appears in plain ASCII text */
- #define I 2 /* character appears in ISO-8859 text */
- #define X 3 /* character appears in non-ISO extended ASCII (Mac, IBM PC) */
-
- static const unsigned char text_chars[256] = {
- /* BEL BS HT LF FF CR */
- F, F, F, F, F, F, F, T, T, T, T, F, T, T, F, F, /* 0x0X */
- /* ESC */
- F, F, F, F, F, F, F, F, F, F, F, T, F, F, F, F, /* 0x1X */
- T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x2X */
- T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x3X */
- T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x4X */
- T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x5X */
- T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x6X */
- T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, F, /* 0x7X */
- /* NEL */
- X, X, X, X, X, T, X, X, X, X, X, X, X, X, X, X, /* 0x8X */
- X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, /* 0x9X */
- I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xaX */
- I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xbX */
- I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xcX */
- I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xdX */
- I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xeX */
- I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I /* 0xfX */
- };
-
- /* *ulen = 0; */
-
- for (i = 0; (c = buf[i]); i++) {
- if ((c & 0x80) == 0) { /* 0xxxxxxx is plain ASCII */
- /*
- * Even if the whole file is valid UTF-8 sequences,
- * still reject it if it uses weird control characters.
- */
-
- if (text_chars[c] != T)
- return false;
-
- }
- else if ((c & 0x40) == 0) { /* 10xxxxxx never 1st byte */
- return false;
- }
- else { /* 11xxxxxx begins UTF-8 */
- int following;
-
- if ((c & 0x20) == 0) { /* 110xxxxx */
- following = 1;
- }
- else if ((c & 0x10) == 0) { /* 1110xxxx */
- following = 2;
- }
- else if ((c & 0x08) == 0) { /* 11110xxx */
- following = 3;
- }
- else if ((c & 0x04) == 0) { /* 111110xx */
- following = 4;
- }
- else if ((c & 0x02) == 0) { /* 1111110x */
- following = 5;
- }
- else
- return false;
-
- for (n = 0; n < following; n++) {
- i++;
-
- if (!(c = buf[i]))
- goto done;
-
- if ((c & 0x80) == 0 || (c & 0x40))
- return false;
- }
-
- gotone = true;
- }
- }
+ int i, n;
+ register unsigned char c;
+ bool gotone = false;
+
+#define F 0 /* character never appears in text */
+#define T 1 /* character appears in plain ASCII text */
+#define I 2 /* character appears in ISO-8859 text */
+#define X 3 /* character appears in non-ISO extended ASCII (Mac, IBM PC) */
+
+ static const unsigned char text_chars[256] = {
+ /* BEL BS HT LF FF CR */
+ F, F, F, F, F, F, F, T, T, T, T, F, T, T, F, F, /* 0x0X */
+ /* ESC */
+ F, F, F, F, F, F, F, F, F, F, F, T, F, F, F, F, /* 0x1X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x2X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x3X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x4X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x5X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, /* 0x6X */
+ T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, F, /* 0x7X */
+ /* NEL */
+ X, X, X, X, X, T, X, X, X, X, X, X, X, X, X, X, /* 0x8X */
+ X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, /* 0x9X */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xaX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xbX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xcX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xdX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, /* 0xeX */
+ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I /* 0xfX */
+ };
+
+ /* *ulen = 0; */
+
+ for (i = 0; (c = buf[i]); i++) {
+ if ((c & 0x80) == 0) { /* 0xxxxxxx is plain ASCII */
+ /*
+ * Even if the whole file is valid UTF-8 sequences,
+ * still reject it if it uses weird control characters.
+ */
+
+ if (text_chars[c] != T)
+ return false;
+
+ }
+ else if ((c & 0x40) == 0) { /* 10xxxxxx never 1st byte */
+ return false;
+ }
+ else { /* 11xxxxxx begins UTF-8 */
+ int following;
+
+ if ((c & 0x20) == 0) { /* 110xxxxx */
+ following = 1;
+ }
+ else if ((c & 0x10) == 0) { /* 1110xxxx */
+ following = 2;
+ }
+ else if ((c & 0x08) == 0) { /* 11110xxx */
+ following = 3;
+ }
+ else if ((c & 0x04) == 0) { /* 111110xx */
+ following = 4;
+ }
+ else if ((c & 0x02) == 0) { /* 1111110x */
+ following = 5;
+ }
+ else
+ return false;
+
+ for (n = 0; n < following; n++) {
+ i++;
+
+ if (!(c = buf[i]))
+ goto done;
+
+ if ((c & 0x80) == 0 || (c & 0x40))
+ return false;
+ }
+
+ gotone = true;
+ }
+ }
done:
- return gotone; /* don't claim it's UTF-8 if it's all 7-bit */
+ return gotone; /* don't claim it's UTF-8 if it's all 7-bit */
}
#undef F
diff --git a/src/backend/managers/btstringmgr.h b/src/backend/managers/btstringmgr.h
index d202c7f..73b784d 100644
--- a/src/backend/managers/btstringmgr.h
+++ b/src/backend/managers/btstringmgr.h
@@ -23,31 +23,31 @@
class BTStringMgr : public sword::StringMgr {
-public:
- /** Converts the param to an upper case Utf8 string
- * @param The text encoded in utf8 which should be turned into an upper case string
- */
- virtual char *upperUTF8(char *text, unsigned int max = 0) const;
-
- /** Converts the param to an uppercase latin1 string
- * @param The text encoded in latin1 which should be turned into an upper case string
- */
- virtual char *upperLatin1(char *text, unsigned int max = 0) const;
-
-protected:
- /** Enable Unicode support.
- * Reimplementation to show unicode support.
- */
- virtual bool supportsUnicode() const;
-
- /** CODE TAKEN FROM KDELIBS 3.2, which is licensed under the LGPL 2.
- *
- * This code was taken from KStringHandler, which is part of the KDE libraries.
- *
- * This function checks whether a string is utf8 or not.
- * It was taken from kdelibs so we do not depend on KDE 3.2.
- */
- bool isUtf8(const char *buf) const;
+ public:
+ /** Converts the param to an upper case Utf8 string
+ * @param The text encoded in utf8 which should be turned into an upper case string
+ */
+ virtual char *upperUTF8(char *text, unsigned int max = 0) const;
+
+ /** Converts the param to an uppercase latin1 string
+ * @param The text encoded in latin1 which should be turned into an upper case string
+ */
+ virtual char *upperLatin1(char *text, unsigned int max = 0) const;
+
+ protected:
+ /** Enable Unicode support.
+ * Reimplementation to show unicode support.
+ */
+ virtual bool supportsUnicode() const;
+
+ /** CODE TAKEN FROM KDELIBS 3.2, which is licensed under the LGPL 2.
+ *
+ * This code was taken from KStringHandler, which is part of the KDE libraries.
+ *
+ * This function checks whether a string is utf8 or not.
+ * It was taken from kdelibs so we do not depend on KDE 3.2.
+ */
+ bool isUtf8(const char *buf) const;
};
#endif
diff --git a/src/backend/managers/cdisplaytemplatemgr.cpp b/src/backend/managers/cdisplaytemplatemgr.cpp
index 6ddd6b7..4722734 100644
--- a/src/backend/managers/cdisplaytemplatemgr.cpp
+++ b/src/backend/managers/cdisplaytemplatemgr.cpp
@@ -23,148 +23,145 @@
#include <QDebug>
CDisplayTemplateMgr::CDisplayTemplateMgr() {
- loadTemplates();
+ loadTemplates();
}
CDisplayTemplateMgr::~CDisplayTemplateMgr() {
}
-const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QString& content, Settings& settings )
-{
- qDebug() << "CDisplayTemplateMgr::fillTemplate";
-
- const QString templateName = m_templateMap.contains(name) ? name : defaultTemplate();
-
- QString displayTypeString;
-
- if (!settings.pageCSS_ID.isEmpty()) {
- displayTypeString = settings.pageCSS_ID;
- }
- else {
- if (settings.modules.count()) {
- switch (settings.modules.first()->type()) {
-
- case CSwordModuleInfo::Bible:
- displayTypeString = "bible";
- break;
-
- case CSwordModuleInfo::GenericBook:
- displayTypeString = "book";
- break;
-
- case CSwordModuleInfo::Commentary:
- case CSwordModuleInfo::Lexicon:
- default:
- displayTypeString = "singleentry";
- break;
- };
- }
- else { //use bible as default type if no modules are set
- displayTypeString = "bible";
- };
- }
-
- QString newContent = content;
- const int moduleCount = settings.modules.count();
-
- if (moduleCount >= 2) {
- //create header for the modules
- qDebug("There were more than 1 module, create headers");
- QString header;
-
- QList<CSwordModuleInfo*>::iterator end_it = settings.modules.end();
-
- for (QList<CSwordModuleInfo*>::iterator it(settings.modules.begin()); it != end_it; ++it) {
- header.append("<th style=\"width:")
- .append(QString::number(int( 100.0 / (float)moduleCount )))
- .append("%;\">")
- .append((*it)->name())
- .append("</th>");
- }
-
- newContent = QString("<table><tr>")
- .append(header)
- .append("</tr>")
- .append(content)
- .append("</table>");
- }
-
- QString langCSS;
- CLanguageMgr::LangMap langMap = CPointers::languageMgr()->availableLanguages();
-
- qDebug() << "langMap length:" << langMap.count();
- qDebug("loop through langMap");
- foreach(const CLanguageMgr::Language* lang, langMap) {
- //const CLanguageMgr::Language* lang = *it;
- //qDebug() << "foreach, lang: ";
- //qDebug() << lang;
-
- //if (lang->isValid() && CBTConfig::get(lang).first) {
- if (!lang->abbrev().isEmpty() && CBTConfig::get(lang).first) {
- const QFont f = CBTConfig::get(lang).second;
-
- //don't use important, because it would reset the title formatting, etc. to the setup font
- QString css("{ ");
- css.append("font-family:").append(f.family())/*.append(" !important")*/;
- css.append("; font-size:").append(QString::number(f.pointSize())).append("pt /*!important*/");
- css.append("; font-weight:").append(f.bold() ? "bold" : "normal /*!important*/");
- css.append("; font-style:").append(f.italic() ? "italic" : "normal /*!important*/");
- css.append("; }\n");
-
- langCSS +=
- QString("\n*[lang=%1] %2")
- .arg(lang->abbrev())
- .arg(css);
- }
- }
-
- //at first append the font standard settings for all languages without configured font
- // Create a dummy language (the langmap may be empty)
- CLanguageMgr::Language lang_v(QString("en"), QString("English"), QString());
- CLanguageMgr::Language* lang = &lang_v;
-
- if (lang && !lang->abbrev().isEmpty()/*&& lang->isValid()*/) {
- const QFont standardFont = CBTConfig::getDefault(lang); //we just need a dummy lang param
- langCSS.prepend(
- QString("\n#content {font-family:%1; font-size:%2pt; font-weight:%3; font-style: %4;}\n")
- .arg(standardFont.family())
- .arg(standardFont.pointSize())
- .arg(standardFont.bold() ? "bold" : "normal")
- .arg(standardFont.italic() ? "italic" : "normal")
- );
- }
+const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QString& content, Settings& settings ) {
+ qDebug() << "CDisplayTemplateMgr::fillTemplate";
+
+ const QString templateName = m_templateMap.contains(name) ? name : defaultTemplate();
+
+ QString displayTypeString;
+
+ if (!settings.pageCSS_ID.isEmpty()) {
+ displayTypeString = settings.pageCSS_ID;
+ }
+ else {
+ if (settings.modules.count()) {
+ switch (settings.modules.first()->type()) {
+
+ case CSwordModuleInfo::Bible:
+ displayTypeString = "bible";
+ break;
+
+ case CSwordModuleInfo::GenericBook:
+ displayTypeString = "book";
+ break;
+
+ case CSwordModuleInfo::Commentary:
+ case CSwordModuleInfo::Lexicon:
+ default:
+ displayTypeString = "singleentry";
+ break;
+ };
+ }
+ else { //use bible as default type if no modules are set
+ displayTypeString = "bible";
+ };
+ }
+
+ QString newContent = content;
+ const int moduleCount = settings.modules.count();
+
+ if (moduleCount >= 2) {
+ //create header for the modules
+ qDebug("There were more than 1 module, create headers");
+ QString header;
+
+ QList<CSwordModuleInfo*>::iterator end_it = settings.modules.end();
+
+ for (QList<CSwordModuleInfo*>::iterator it(settings.modules.begin()); it != end_it; ++it) {
+ header.append("<th style=\"width:")
+ .append(QString::number(int( 100.0 / (float)moduleCount )))
+ .append("%;\">")
+ .append((*it)->name())
+ .append("</th>");
+ }
+
+ newContent = QString("<table><tr>")
+ .append(header)
+ .append("</tr>")
+ .append(content)
+ .append("</table>");
+ }
+
+ QString langCSS;
+ CLanguageMgr::LangMap langMap = CPointers::languageMgr()->availableLanguages();
+
+ qDebug() << "langMap length:" << langMap.count();
+ qDebug("loop through langMap");
+ foreach(const CLanguageMgr::Language* lang, langMap) {
+ //const CLanguageMgr::Language* lang = *it;
+ //qDebug() << "foreach, lang: ";
+ //qDebug() << lang;
+
+ //if (lang->isValid() && CBTConfig::get(lang).first) {
+ if (!lang->abbrev().isEmpty() && CBTConfig::get(lang).first) {
+ const QFont f = CBTConfig::get(lang).second;
+
+ //don't use important, because it would reset the title formatting, etc. to the setup font
+ QString css("{ ");
+ css.append("font-family:").append(f.family())/*.append(" !important")*/;
+ css.append("; font-size:").append(QString::number(f.pointSize())).append("pt /*!important*/");
+ css.append("; font-weight:").append(f.bold() ? "bold" : "normal /*!important*/");
+ css.append("; font-style:").append(f.italic() ? "italic" : "normal /*!important*/");
+ css.append("; }\n");
+
+ langCSS +=
+ QString("\n*[lang=%1] %2")
+ .arg(lang->abbrev())
+ .arg(css);
+ }
+ }
+
+ //at first append the font standard settings for all languages without configured font
+ // Create a dummy language (the langmap may be empty)
+ CLanguageMgr::Language lang_v(QString("en"), QString("English"), QString());
+ CLanguageMgr::Language* lang = &lang_v;
+
+ if (lang && !lang->abbrev().isEmpty()/*&& lang->isValid()*/) {
+ const QFont standardFont = CBTConfig::getDefault(lang); //we just need a dummy lang param
+ langCSS.prepend(
+ QString("\n#content {font-family:%1; font-size:%2pt; font-weight:%3; font-style: %4;}\n")
+ .arg(standardFont.family())
+ .arg(standardFont.pointSize())
+ .arg(standardFont.bold() ? "bold" : "normal")
+ .arg(standardFont.italic() ? "italic" : "normal")
+ );
+ }
// qWarning("Outputing unformated text");
- const QString t = QString(m_templateMap[ templateName ]) //don't change the map's content directly, use a copy
- .replace("#TITLE#", settings.title)
- .replace("#LANG_ABBREV#", settings.langAbbrev.isEmpty() ? QString("en") : settings.langAbbrev)
- .replace("#DISPLAYTYPE#", displayTypeString)
- .replace("#LANG_CSS#", langCSS)
- .replace("#PAGE_DIRECTION#", settings.pageDirection)
- .replace("#CONTENT#", newContent);
-
- return t;
+ const QString t = QString(m_templateMap[ templateName ]) //don't change the map's content directly, use a copy
+ .replace("#TITLE#", settings.title)
+ .replace("#LANG_ABBREV#", settings.langAbbrev.isEmpty() ? QString("en") : settings.langAbbrev)
+ .replace("#DISPLAYTYPE#", displayTypeString)
+ .replace("#LANG_CSS#", langCSS)
+ .replace("#PAGE_DIRECTION#", settings.pageDirection)
+ .replace("#CONTENT#", newContent);
+
+ return t;
}
void CDisplayTemplateMgr::loadTemplates() {
- QStringList files;
- foreach (QString file, util::filesystem::DirectoryUtil::getDisplayTemplatesDir().entryList(QStringList("*.tmpl")))
- {
- files += util::filesystem::DirectoryUtil::getDisplayTemplatesDir().canonicalPath() + "/" + file;
- }
- foreach (QString file, util::filesystem::DirectoryUtil::getUserDisplayTemplatesDir().entryList(QStringList("*.tmpl")))
- {
- files += util::filesystem::DirectoryUtil::getUserDisplayTemplatesDir().canonicalPath() + "/" + file;
- }
-
- foreach (QString file, files) {
- QFile f(file);
- if (f.exists() && f.open( QIODevice::ReadOnly )) {
- QString fileContent = QTextStream( &f ).readAll();
-
- if (!fileContent.isEmpty()) {
- m_templateMap[ QFileInfo(file).fileName() ] = fileContent;
- }
- }
- }
+ QStringList files;
+ foreach (QString file, util::filesystem::DirectoryUtil::getDisplayTemplatesDir().entryList(QStringList("*.tmpl"))) {
+ files += util::filesystem::DirectoryUtil::getDisplayTemplatesDir().canonicalPath() + "/" + file;
+ }
+ foreach (QString file, util::filesystem::DirectoryUtil::getUserDisplayTemplatesDir().entryList(QStringList("*.tmpl"))) {
+ files += util::filesystem::DirectoryUtil::getUserDisplayTemplatesDir().canonicalPath() + "/" + file;
+ }
+
+ foreach (QString file, files) {
+ QFile f(file);
+ if (f.exists() && f.open( QIODevice::ReadOnly )) {
+ QString fileContent = QTextStream( &f ).readAll();
+
+ if (!fileContent.isEmpty()) {
+ m_templateMap[ QFileInfo(file).fileName() ] = fileContent;
+ }
+ }
+ }
}
diff --git a/src/backend/managers/cdisplaytemplatemgr.h b/src/backend/managers/cdisplaytemplatemgr.h
index c791e16..d048ecd 100644
--- a/src/backend/managers/cdisplaytemplatemgr.h
+++ b/src/backend/managers/cdisplaytemplatemgr.h
@@ -25,54 +25,54 @@ class CSwordModuleInfo;
class CDisplayTemplateMgr {
-public:
- /** Settings which are used to fill the content into the template.
- */
-
- struct Settings {
- /** Constructor. Constructs the new settings object. The default values are empty.
- */
- Settings() {
- title = QString::null;
- langAbbrev = QString::null;
- pageCSS_ID = QString::null;
- pageDirection = QString("ltr");
+ public:
+ /** Settings which are used to fill the content into the template.
+ */
+
+ struct Settings {
+ /** Constructor. Constructs the new settings object. The default values are empty.
+ */
+ Settings() {
+ title = QString::null;
+ langAbbrev = QString::null;
+ pageCSS_ID = QString::null;
+ pageDirection = QString("ltr");
+ };
+
+ QList<CSwordModuleInfo*> modules; /**< the list of modules */
+ QString title; /**< the title which is used for the new processed HTML page */
+ QString langAbbrev; /**< the language for the HTML page. */
+ QString pageDirection; /**< the language for the HTML page. */
+ QString pageCSS_ID; /**< the CSS ID which is used in the content part of the page */
};
- QList<CSwordModuleInfo*> modules; /**< the list of modules */
- QString title; /**< the title which is used for the new processed HTML page */
- QString langAbbrev; /**< the language for the HTML page. */
- QString pageDirection; /**< the language for the HTML page. */
- QString pageCSS_ID; /**< the CSS ID which is used in the content part of the page */
- };
-
- /** Available templates.
- * @return The list of templates, which are available.
- */
- inline const QStringList availableTemplates();
- /** Fill template. Fill rendered content into the template given by the name.
- * @param name The name of the template
- * @param content The content which should be filled into the template
- * @param settings The settings which are used to process the templating process
- * @return The full HTML template HTML code including the CSS data.
- */
- const QString fillTemplate( const QString& name, const QString& content, Settings& settings);
- /** Default template.
- * @return The i18n'ed name of the default template
- */
- inline static const QString defaultTemplate();
-
-protected:
- friend class CPointers;
- /** Display template manager constructor. Protected to just allow CPointers to create objects. */
- CDisplayTemplateMgr();
- /** Destructor. */
- ~CDisplayTemplateMgr();
- /** Does the actual work of loading templates from disk */
- void loadTemplates();
-
-private:
- QMap<QString, QString> m_templateMap;
+ /** Available templates.
+ * @return The list of templates, which are available.
+ */
+ inline const QStringList availableTemplates();
+ /** Fill template. Fill rendered content into the template given by the name.
+ * @param name The name of the template
+ * @param content The content which should be filled into the template
+ * @param settings The settings which are used to process the templating process
+ * @return The full HTML template HTML code including the CSS data.
+ */
+ const QString fillTemplate( const QString& name, const QString& content, Settings& settings);
+ /** Default template.
+ * @return The i18n'ed name of the default template
+ */
+ inline static const QString defaultTemplate();
+
+ protected:
+ friend class CPointers;
+ /** Display template manager constructor. Protected to just allow CPointers to create objects. */
+ CDisplayTemplateMgr();
+ /** Destructor. */
+ ~CDisplayTemplateMgr();
+ /** Does the actual work of loading templates from disk */
+ void loadTemplates();
+
+ private:
+ QMap<QString, QString> m_templateMap;
};
inline const QString CDisplayTemplateMgr::defaultTemplate() {
diff --git a/src/backend/managers/clanguagemgr.cpp b/src/backend/managers/clanguagemgr.cpp
index 4dcc411..e7245e5 100644
--- a/src/backend/managers/clanguagemgr.cpp
+++ b/src/backend/managers/clanguagemgr.cpp
@@ -20,17 +20,17 @@
CLanguageMgr::Language::Language() {}
CLanguageMgr::Language::Language(const Language& l) {
- m_abbrev = l.m_abbrev;
- m_englishName = l.m_englishName;
- m_translatedName = l.m_translatedName;
- m_altAbbrevs = l.m_altAbbrevs;
+ m_abbrev = l.m_abbrev;
+ m_englishName = l.m_englishName;
+ m_translatedName = l.m_translatedName;
+ m_altAbbrevs = l.m_altAbbrevs;
}
CLanguageMgr::Language::Language( const QString& abbrev, const QString& name, const QString& translatedName, const QStringList& altAbbrevs ) {
- m_abbrev = abbrev;
- m_englishName = name;
- m_translatedName = translatedName;
- m_altAbbrevs = altAbbrevs;
+ m_abbrev = abbrev;
+ m_englishName = name;
+ m_translatedName = translatedName;
+ m_altAbbrevs = altAbbrevs;
}
CLanguageMgr::Language::~Language() {
@@ -41,506 +41,506 @@ CLanguageMgr::Language::~Language() {
/******************** CLanguageMgr ******************/
/****************************************************/
CLanguageMgr::CLanguageMgr() : m_langMap() {
- m_availableModulesCache.moduleCount = 0;
- init();
+ m_availableModulesCache.moduleCount = 0;
+ init();
}
CLanguageMgr::~CLanguageMgr() {
- qDeleteAll(m_cleanupLangPtrs);
- m_cleanupLangPtrs.clear();
- qDeleteAll(m_langList);
- m_langList.clear();
+ qDeleteAll(m_cleanupLangPtrs);
+ m_cleanupLangPtrs.clear();
+ qDeleteAll(m_langList);
+ m_langList.clear();
}
const CLanguageMgr::LangMap& CLanguageMgr::availableLanguages() {
- QList<CSwordModuleInfo*> mods = CPointers::backend()->moduleList();
+ QList<CSwordModuleInfo*> mods = CPointers::backend()->moduleList();
- if ( m_availableModulesCache.moduleCount != (unsigned int)mods.count() ) { //we have to refill the cached map
- m_availableModulesCache.availableLanguages.clear();
- m_availableModulesCache.moduleCount = mods.count();
+ if ( m_availableModulesCache.moduleCount != (unsigned int)mods.count() ) { //we have to refill the cached map
+ m_availableModulesCache.availableLanguages.clear();
+ m_availableModulesCache.moduleCount = mods.count();
- //collect the languages abbrevs of all modules
- QStringList abbrevs;
+ //collect the languages abbrevs of all modules
+ QStringList abbrevs;
- foreach (const CSwordModuleInfo* mod, mods) {
- if (!abbrevs.contains(mod->module()->Lang())){
- abbrevs.append(mod->module()->Lang());
- }
- }
+ foreach (const CSwordModuleInfo* mod, mods) {
+ if (!abbrevs.contains(mod->module()->Lang())) {
+ abbrevs.append(mod->module()->Lang());
+ }
+ }
- //now create a map of available langs
- foreach ( QString abbrev, abbrevs ) {
- const Language* const lang = languageForAbbrev(abbrev);
+ //now create a map of available langs
+ foreach ( QString abbrev, abbrevs ) {
+ const Language* const lang = languageForAbbrev(abbrev);
- if (lang->isValid()) {
- m_availableModulesCache.availableLanguages.insert( abbrev, lang );
- }
- else { //invalid lang used by a module, create a new language using the abbrev
- Language* newLang = new Language(abbrev, abbrev, abbrev);
- m_cleanupLangPtrs.append(newLang);
- m_availableModulesCache.availableLanguages.insert( abbrev, newLang );
- }
- }
- }
- return m_availableModulesCache.availableLanguages;
+ if (lang->isValid()) {
+ m_availableModulesCache.availableLanguages.insert( abbrev, lang );
+ }
+ else { //invalid lang used by a module, create a new language using the abbrev
+ Language* newLang = new Language(abbrev, abbrev, abbrev);
+ m_cleanupLangPtrs.append(newLang);
+ m_availableModulesCache.availableLanguages.insert( abbrev, newLang );
+ }
+ }
+ }
+ return m_availableModulesCache.availableLanguages;
}
const CLanguageMgr::Language* CLanguageMgr::languageForAbbrev( const QString& abbrev ) const {
- LangMapIterator it = m_langMap.find(abbrev);
- if (it != m_langMap.constEnd()) return *it; //Language is already here
-
- //try to search in the alternative abbrevs
- foreach (const Language* lang, m_langList ) {
- if (lang->alternativeAbbrevs().contains(abbrev)) return lang;
- }
-
- // Invalid lang used by a modules, create a new language using the abbrev
- Language* newLang = new Language(abbrev, abbrev, abbrev); //return a language which holds the valid abbrev
- m_cleanupLangPtrs.append(newLang);
+ LangMapIterator it = m_langMap.find(abbrev);
+ if (it != m_langMap.constEnd()) return *it; //Language is already here
- return newLang;
+ //try to search in the alternative abbrevs
+ foreach (const Language* lang, m_langList ) {
+ if (lang->alternativeAbbrevs().contains(abbrev)) return lang;
+ }
+
+ // Invalid lang used by a modules, create a new language using the abbrev
+ Language* newLang = new Language(abbrev, abbrev, abbrev); //return a language which holds the valid abbrev
+ m_cleanupLangPtrs.append(newLang);
+
+ return newLang;
}
const CLanguageMgr::Language* CLanguageMgr::languageForName( const QString& name ) const {
- foreach ( const Language* lang, m_langList ) {
- if (lang->name() == name) return lang;
- }
- return &m_defaultLanguage;//invalid language
+ foreach ( const Language* lang, m_langList ) {
+ if (lang->name() == name) return lang;
+ }
+ return &m_defaultLanguage;//invalid language
}
const CLanguageMgr::Language* CLanguageMgr::languageForTranslatedName( const QString& name ) const {
- foreach ( const Language* lang, m_langList ) {
- if (lang->translatedName() == name) return lang;
- }
- return &m_defaultLanguage; //invalid language
+ foreach ( const Language* lang, m_langList ) {
+ if (lang->translatedName() == name) return lang;
+ }
+ return &m_defaultLanguage; //invalid language
}
void CLanguageMgr::init() {
- // The main() sets string literal codec to utf8:
- // QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
- // The language names include escape sequences \uxxxx
+ // The main() sets string literal codec to utf8:
+ // QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
+ // The language names include escape sequences \uxxxx
- //if we've already inserted all items we do not proceed
- if (m_langMap.count() > 0) return;
+ //if we've already inserted all items we do not proceed
+ if (m_langMap.count() > 0) return;
- // Developers: It's easy to get a list of used language codes from all modules:
- // Refresh all sources; go to .sword/InstallMgr/; run:
- // grep -R -hs Lang= *|cut -c 6-|sort|uniq
- // Don't remove unused languages from the source code unless you know it won't be used
- // anymore.in any module ever.
+ // Developers: It's easy to get a list of used language codes from all modules:
+ // Refresh all sources; go to .sword/InstallMgr/; run:
+ // grep -R -hs Lang= *|cut -c 6-|sort|uniq
+ // Don't remove unused languages from the source code unless you know it won't be used
+ // anymore.in any module ever.
- /*:
- The string "Names of languages" doesn't actually need translation.
- It is put here to help translators notice this help text.
- -------
- The names of the languages should follow the conventions of your
- language. You can write the names with a capital first letter even if your language
- uses non-capitalized language names (they look better with capital
- first letter when they are listed).
- -------
- To find the names of all languages from internet try searching for
- "names of languages in language_x" but in your own language, e.g.
- "kielten nimet suomeksi" in Finnish or "names of languages in english"
- in English.
- -------
- You can find the language codes and names by googling for the standards
- mentioned below.
- -------
- Preference order for locale codes are:
- -------
- ISO 639-1 -------
- ISO 639-2 -------
- ISO 639-3
- -------
- x-E-XXX form is deprecated and no modules in repositories use it.
- If you find a module with x-E-XXX language, update the module.
- */
- QObject::tr("Names of languages", "No need to translate - see the longer comment (If there is no longer comment, it doesn't work yet :)) ------ ");
- // m_langList.append( new Language("aa", "Afar", QObject::tr("Afar")) );
- // m_langList.append( new Language("ab", "Abkhazian", QObject::tr("Abkhazian")) );
- // m_langList.append( new Language("ae", "Avestan", QObject::tr("Avestan")) );
- //: Language name af
- m_langList.append( new Language("af", "Afrikaans", QObject::tr("Afrikaans")) );
- // m_langList.append( new Language("am", "Amharic", QObject::tr("Amharic")) );
- //: Language name amu
- m_langList.append( new Language("amu", "Amuzgo, Guerrero", QObject::tr("Amuzgo, Guerrero")) );
- //: Language name ang
- m_langList.append( new Language("ang", "English, Old (ca.450-1100)", QObject::tr("English, Old (ca.450-1100)")) );
- //: Language name ar
- m_langList.append( new Language("ar", "Arabic", QObject::tr("Arabic")) );
- // m_langList.append( new Language("as", "Assamese", QObject::tr("Assamese")) );
- //: Language name az
- m_langList.append( new Language("az", "Azerbaijani", QObject::tr("Azerbaijani")) );
- //: Language name azb
- m_langList.append( new Language("azb", "Azerbaijani, South", QObject::tr("Azerbaijani, South")) );
- // m_langList.append( new Language("ba", "Bashkir", QObject::tr("Bashkir")) );
- //: Language name bar
- m_langList.append( new Language("bar", "Bavarian", QObject::tr("Bavarian")) );
- //: Language name be
- m_langList.append( new Language("be", "Belarusian", QObject::tr("Belarusian")) );
- //: Language name bg
- m_langList.append( new Language("bg", "Bulgarian", QObject::tr("Bulgarian")) );
- // m_langList.append( new Language("bh", "Bihari", QObject::tr("Bihari")) );
- // m_langList.append( new Language("bi", "Bislama", QObject::tr("Bislama")) );
- // m_langList.append( new Language("bn", "Bengali", QObject::tr("Bengali")) );
- // m_langList.append( new Language("bo", "Tibetan", QObject::tr("Tibetan")) );
- //: Language name br
- m_langList.append( new Language("br", "Breton", QObject::tr("Breton")) );
- //: Language name bs
- m_langList.append( new Language("bs", "Bosnian", QObject::tr("Bosnian")) );
- //: Language name ca
- m_langList.append( new Language("ca", "Catalan", QObject::tr("Catalan")) );
- // m_langList.append( new Language("ce", "Chechen", QObject::tr("Chechen")) );
- //: Language name cco
- m_langList.append( new Language("cco", "Chinantec, Comaltepec", QObject::tr("Chinantec, Comaltepec")) );
- //: Language name ceb
- m_langList.append( new Language("ceb", "Cebuano", QObject::tr("Cebuano")) );
- //: Language name ch
- m_langList.append( new Language("ch", "Chamorro", QObject::tr("Chamorro")) );
- //: Language name chd
- m_langList.append( new Language("chd", "Chontal, Highland Oaxaca", QObject::tr("Chontal, Highland Oaxaca")) );
- //: Language name chq
- m_langList.append( new Language("chq", "Chinantec, Quiotepec", QObject::tr("Chinantec, Quiotepec")) );
- //: Language name chz
- m_langList.append( new Language("chz", "Chinantec, Ozumac\u00edn", QObject::tr("Chinantec, Ozumac\u00edn")) );
- // m_langList.append( new Language("co", "Corsican", QObject::tr("Corsican")) );
- //: Language name ckw
- m_langList.append( new Language("ckw", "Cakchiquel, Western", QObject::tr("Cakchiquel, Western")) );
- //: Language name cnl
- m_langList.append( new Language("cnl", "Chinantec, Lalana", QObject::tr("Chinantec, Lalana")) );
- //: Language name cnt
- m_langList.append( new Language("cnt", "Chinantec, Tepetotutla", QObject::tr("Chinantec, Tepetotutla")) );
- //: Language name cop
- m_langList.append( new Language("cop", "Coptic", QObject::tr("Coptic")) );
- //: Language name cs
- m_langList.append( new Language("cs", "Czech", QObject::tr("Czech")) );
- //: Language name cso
- m_langList.append( new Language("cso", "Chinantec, Sochiapan", QObject::tr("Chinantec, Sochiapan")) );
- //: Language name cti
- m_langList.append( new Language("cti", "Chol, Tila", QObject::tr("Chol, Tila")) );
- //: Language name ctp
- m_langList.append( new Language("ctp", "Chatino, Western Highland", QObject::tr("Chatino, Western Highland")) );
- //: Language name cu
- m_langList.append( new Language("cu", "Church Slavic", QObject::tr("Church Slavic")) );
- // m_langList.append( new Language("cv", "Chuvash", QObject::tr("Chuvash")) );
- //: Language name cy
- m_langList.append( new Language("cy", "Welsh", QObject::tr("Welsh")) );
- //: Language name da
- m_langList.append( new Language("da", "Danish", QObject::tr("Danish")) );
- //: Language name de
- m_langList.append( new Language("de", "German", QObject::tr("German")) );
- //: Language name dug
- m_langList.append( new Language("dug", "Duruma", QObject::tr("Duruma")) );
- // m_langList.append( new Language("dz", "Dzongkha", QObject::tr("Dzongkha")) );
- //: Language name el
- m_langList.append( new Language("el", "Greek, Modern (1453-)", QObject::tr("Greek, Modern (1453-)"), makeStringList("gre;ell")) );
- //: Language name en
- m_langList.append( new Language("en", "English", QObject::tr("English")) );
- //: Language name en_US
- m_langList.append( new Language("en_US","American English", QObject::tr("American English")) );
- //: Language name enm
- m_langList.append( new Language("enm", "English, Middle (1100-1500)", QObject::tr("English, Middle (1100-1500)")) );
- //: Language name eo
- m_langList.append( new Language("eo", "Esperanto", QObject::tr("Esperanto")) );
- //: Language name es
- m_langList.append( new Language("es", "Spanish", QObject::tr("Spanish")) );
- //: Language name et
- m_langList.append( new Language("et", "Estonian", QObject::tr("Estonian")) );
- //: Language name eu
- m_langList.append( new Language("eu", "Basque", QObject::tr("Basque")) );
- //: Language name fa
- m_langList.append( new Language("fa", "Persian", QObject::tr("Persian")) );
- //: Language name fi
- m_langList.append( new Language("fi", "Finnish", QObject::tr("Finnish")) );
- // m_langList.append( new Language("fj", "Fijian", QObject::tr("Fijian")) );
- // m_langList.append( new Language("fo", "Faroese", QObject::tr("Faroese")) );
- //: Language name fr
- m_langList.append( new Language("fr", "French", QObject::tr("French")) );
- //: Language name fy
- m_langList.append( new Language("fy", "Frisian", QObject::tr("Frisian")) );
- //: Language name ga
- m_langList.append( new Language("ga", "Irish", QObject::tr("Irish")) );
- //: Language name gd
- m_langList.append( new Language("gd", "Gaelic (Scots)", QObject::tr("Gaelic (Scots)")) );
- //: Language name gez
- m_langList.append( new Language("gez", "Geez", QObject::tr("Geez")) );
- // m_langList.append( new Language("gl", "Gallegan", QObject::tr("Gallegan")) );
- // m_langList.append( new Language("gn", "Guarani", QObject::tr("Guarani")) );
- // m_langList.append( new Language("gn", "Gujarati", QObject::tr("Gujarati")) );
- //: Language name got
- m_langList.append( new Language("got", "Gothic", QObject::tr("Gothic")) );
- //: Language name gv
- m_langList.append( new Language("gv", "Manx", QObject::tr("Manx")) );
- //: Language name grc
- m_langList.append( new Language("grc", "Greek, Ancient (to 1453)", QObject::tr("Greek, Ancient (to 1453)")) );
- //: Language name he
- m_langList.append( new Language("he", "Hebrew", QObject::tr("Hebrew")) );
- //: Language name hau
- m_langList.append( new Language("hau", "Hausa", QObject::tr("Hausa")) );
- //: Language name haw
- m_langList.append( new Language("haw", "Hawaiian", QObject::tr("Hawaiian")) );
- //: Language name hi
- m_langList.append( new Language("hi", "Hindi", QObject::tr("Hindi")) );
- // m_langList.append( new Language("ho", "Hiri Motu", QObject::tr("Hiri Motu")) );
- //: Language name hr
- m_langList.append( new Language("hr", "Croatian", QObject::tr("Croatian")) );
- //: Language name ht
- m_langList.append( new Language("ht", "Haitian Creole", QObject::tr("Haitian Creole")) );
- //: Language name hu
- m_langList.append( new Language("hu", "Hungarian", QObject::tr("Hungarian")) );
- //: Language name huv
- m_langList.append( new Language("huv", "Huave, San Mateo Del Mar", QObject::tr("Huave, San Mateo Del Mar")) );
- //: Language name hy
- m_langList.append( new Language("hy", "Armenian", QObject::tr("Armenian")) );
- // m_langList.append( new Language("hz", "Herero", QObject::tr("Herero")) );
- // m_langList.append( new Language("ia", "Interlingua", QObject::tr("Interlingua")) );
- //: Language name id
- m_langList.append( new Language("id", "Indonesian", QObject::tr("Indonesian")) );
- // m_langList.append( new Language("ie", "Interlingue", QObject::tr("Interlingue")) );
- // m_langList.append( new Language("ik", "Inupiaq", QObject::tr("Inupiaq")) );
- //: Language name is
- m_langList.append( new Language("is", "Icelandic", QObject::tr("Icelandic")) );
- //: Language name it
- m_langList.append( new Language("it", "Italian", QObject::tr("Italian")) );
- //: Language name itz
- m_langList.append( new Language("itz", "Itz\u00e1", QObject::tr("Itz\u00e1")) );
- //: Language name ixl
- m_langList.append( new Language("ixl", "Ixil, San Juan Cotzal", QObject::tr("Ixil, San Juan Cotzal")) );
- // m_langList.append( new Language("iu", "Inuktitut", QObject::tr("Inuktitut")) );
- //: Language name ja
- m_langList.append( new Language("ja", "Japanese", QObject::tr("Japanese")) );
- //: Language name jac
- m_langList.append( new Language("jac", "Jacalteco, Eastern", QObject::tr("Jacalteco, Eastern")) );
- //: Language name jvn
- m_langList.append( new Language("jvn", "Javanese, Caribbean", QObject::tr("Javanese, Caribbean")) );
- //: Language name ka
- m_langList.append( new Language("ka", "Georgian", QObject::tr("Georgian")) );
- //: Language name kek
- m_langList.append( new Language("kek", "Kekch\u00ed", QObject::tr("Kekch\u00ed", "kek")) );
- // m_langList.append( new Language("ki", "Kikuyu", QObject::tr("Kikuyu")) );
- // m_langList.append( new Language("kj", "Kuanyama", QObject::tr("Kuanyama")) );
- // m_langList.append( new Language("kk", "Kazakh", QObject::tr("Kazakh")) );
- // m_langList.append( new Language("kl", "Kalaallisut", QObject::tr("Kalaallisut")) );
- // m_langList.append( new Language("km", "Khmer", QObject::tr("Khmer")) );
- // m_langList.append( new Language("kn", "Kannada", QObject::tr("Kannada")) );
- //: Language name ko
- m_langList.append( new Language("ko", "Korean", QObject::tr("Korean")) );
- // m_langList.append( new Language("ks", "Kashmiri", QObject::tr("Kashmiri")) );
- //: Language name ku
- m_langList.append( new Language("ku", "Kurdish", QObject::tr("Kurdish")) );
- // m_langList.append( new Language("kv", "Komi", QObject::tr("Komi")) );
- // m_langList.append( new Language("kw", "Cornish", QObject::tr("Cornish")) );
- //: Language name ky
- m_langList.append( new Language("ky", "Kirghiz", QObject::tr("Kirghiz")) );
- //: Language name la
- m_langList.append( new Language("la", "Latin", QObject::tr("Latin")) );
- //: Language name lac
- m_langList.append( new Language("lac", "Lacandon", QObject::tr("Lacandon")) );
- // m_langList.append( new Language("lb", "Letzeburgesch", QObject::tr("Letzeburgesch")) );
- //: Language name lmo
- m_langList.append( new Language("lmo", "Lombard", QObject::tr("Lombard")) );
- // m_langList.append( new Language("ln", "Lingala", QObject::tr("Lingala")) );
- // m_langList.append( new Language("lo", "Lao", QObject::tr("Lao")) );
- //: Language name lt
- m_langList.append( new Language("lt", "Lithuanian", QObject::tr("Lithuanian")) );
- //: Language name lv
- m_langList.append( new Language("lv", "Latvian", QObject::tr("Latvian")) );
- //: Language name mg
- m_langList.append( new Language("mg", "Malagasy", QObject::tr("Malagasy")) );
- // m_langList.append( new Language("mh", "Marshall", QObject::tr("Marshall")) );
- //: Language name mi
- m_langList.append( new Language("mi", "Maori", QObject::tr("Maori")) );
- //: Language name mir
- m_langList.append( new Language("mir", "Mixe, Isthmus", QObject::tr("Mixe, Isthmus")) );
- //: Language name miz
- m_langList.append( new Language("miz", "Mixtec, Coatzospan", QObject::tr("Mixtec, Coatzospan")) );
- //: Language name mk
- m_langList.append( new Language("mk", "Macedonian", QObject::tr("Macedonian")) );
- //: Language name mks
- m_langList.append( new Language("mks", "Mixtec, Silacayoapan", QObject::tr("Mixtec, Silacayoapan")) );
- // m_langList.append( new Language("ml", "Malayalam", QObject::tr("Malayalam")) );
- // m_langList.append( new Language("mn", "Mongolian", QObject::tr("Mongolian")) );
- // m_langList.append( new Language("mo", "Moldavian", QObject::tr("Moldavian")) );
- //: Language name mos
- m_langList.append( new Language("mos", "More", QObject::tr("More")) );
- // m_langList.append( new Language("mr", "Marathi", QObject::tr("Marathi")) );
- //: Language name ms
- m_langList.append( new Language("ms", "Malay", QObject::tr("Malay")) );
- //: Language name mt
- m_langList.append( new Language("mt", "Maltese", QObject::tr("Maltese")) );
- //: Language name mul (meaning that the work has multiple languages)
- m_langList.append( new Language("mul", "(Multiple languages)", QObject::tr("(Multiple languages)")) );
- //: Language name mvc
- m_langList.append( new Language("mvc", "Mam, Central", QObject::tr("Mam, Central")) );
- //: Language name mvj
- m_langList.append( new Language("mvj", "Mam, Todos Santos Cuchumat\u00e1n", QObject::tr("Mam, Todos Santos Cuchumat\u00e1n")) );
- //: Language name mxq
- m_langList.append( new Language("mxq", "Mixe, Juquila", QObject::tr("Mixe, Juquila")) );
- //: Language name mxt
- m_langList.append( new Language("mxt", "Mixtec, Jamiltepec", QObject::tr("Mixtec, Jamiltepec")) );
- //: Language name my
- m_langList.append( new Language("my", "Burmese", QObject::tr("Burmese")) );
- // m_langList.append( new Language("na", "Nauru", QObject::tr("Nauru")) );
- //: Language name nb
- m_langList.append( new Language("nb", "Norwegian Bokm\u00e5l", QObject::tr("Norwegian Bokm\u00e5l")) );
- //: Language name ncl
- m_langList.append( new Language("ncl", "Nahuatl, Michoac\u00e1n", QObject::tr("Nahuatl, Michoac\u00e1n")) );
- // m_langList.append( new Language("nd", "Ndebele, North", QObject::tr("Ndebele, North")) );
- //: Language name nds
- m_langList.append( new Language("nds", "Low German; Low Saxon", QObject::tr("Low German; Low Saxon")) );
- //: Language name ne
- m_langList.append( new Language("ne", "Nepali", QObject::tr("Nepali")) );
- //: Language name ngu
- m_langList.append( new Language("ngu", "Nahuatl, Guerrero", QObject::tr("Nahuatl, Guerrero")) );
- //: Language name nhy
- m_langList.append( new Language("nhy", "Nahuatl, Northern Oaxaca", QObject::tr("Nahuatl, Northern Oaxaca")) );
- // m_langList.append( new Language("ng", "Ndonga", QObject::tr("Ndonga")) );
- //: Language name nl
- m_langList.append( new Language("nl", "Dutch", QObject::tr("Dutch")) );
- //: Language name nn
- m_langList.append( new Language("nn", "Norwegian Nynorsk", QObject::tr("Norwegian Nynorsk")) );
- //: Language name no
- m_langList.append( new Language("no", "Norwegian", QObject::tr("Norwegian")) );
- // m_langList.append( new Language("nr", "Ndebele, South", QObject::tr("Ndebele, South")) );
- // m_langList.append( new Language("nv", "Navajo", QObject::tr("Navajo")) );
- // m_langList.append( new Language("ny", "Chichewa; Nyanja", QObject::tr("Chichewa; Nyanja")) );
- // m_langList.append( new Language("oc", "Occitan (post 1500); Provençal", QObject::tr("Occitan (post 1500); Provençal")) );
- // m_langList.append( new Language("om", "Oromo", QObject::tr("Oromo")) );
- // m_langList.append( new Language("or", "Oriya", QObject::tr("Oriya")) );
- // m_langList.append( new Language("os", "Ossetian; Ossetic", QObject::tr("Ossetian; Ossetic")) );
- //: Language name otq
- m_langList.append( new Language("otq", "Otomi, Quer\u00e9taro", QObject::tr("Otomi, Quer\u00e9taro")) );
- // m_langList.append( new Language("pa", "Panjabi", QObject::tr("Panjabi")) );
- //: Language name pap
- m_langList.append( new Language("pap", "Papiamento", QObject::tr("Papiamento")) );
- // m_langList.append( new Language("pi", "Pali", QObject::tr("Pali")) );
- //: Language name ppk
- m_langList.append( new Language("ppk", "Uma", QObject::tr("Uma")) );
- //: Language name pl
- m_langList.append( new Language("pl", "Polish", QObject::tr("Polish")) );
- //: Language name pot
- m_langList.append( new Language("pot", "Potawatomi", QObject::tr("Potawatomi")) );
- //: Language name ppk
- m_langList.append( new Language("ppk", "Uma", QObject::tr("Uma")) );
- //: Language name prs
- m_langList.append( new Language("prs", "Persian (Dari)", QObject::tr("Persian (Dari)")) );
+ /*:
+ The string "Names of languages" doesn't actually need translation.
+ It is put here to help translators notice this help text.
+ -------
+ The names of the languages should follow the conventions of your
+ language. You can write the names with a capital first letter even if your language
+ uses non-capitalized language names (they look better with capital
+ first letter when they are listed).
+ -------
+ To find the names of all languages from internet try searching for
+ "names of languages in language_x" but in your own language, e.g.
+ "kielten nimet suomeksi" in Finnish or "names of languages in english"
+ in English.
+ -------
+ You can find the language codes and names by googling for the standards
+ mentioned below.
+ -------
+ Preference order for locale codes are:
+ -------
+ ISO 639-1 -------
+ ISO 639-2 -------
+ ISO 639-3
+ -------
+ x-E-XXX form is deprecated and no modules in repositories use it.
+ If you find a module with x-E-XXX language, update the module.
+ */
+ QObject::tr("Names of languages", "No need to translate - see the longer comment (If there is no longer comment, it doesn't work yet :)) ------ ");
+ // m_langList.append( new Language("aa", "Afar", QObject::tr("Afar")) );
+ // m_langList.append( new Language("ab", "Abkhazian", QObject::tr("Abkhazian")) );
+ // m_langList.append( new Language("ae", "Avestan", QObject::tr("Avestan")) );
+ //: Language name af
+ m_langList.append( new Language("af", "Afrikaans", QObject::tr("Afrikaans")) );
+ // m_langList.append( new Language("am", "Amharic", QObject::tr("Amharic")) );
+ //: Language name amu
+ m_langList.append( new Language("amu", "Amuzgo, Guerrero", QObject::tr("Amuzgo, Guerrero")) );
+ //: Language name ang
+ m_langList.append( new Language("ang", "English, Old (ca.450-1100)", QObject::tr("English, Old (ca.450-1100)")) );
+ //: Language name ar
+ m_langList.append( new Language("ar", "Arabic", QObject::tr("Arabic")) );
+ // m_langList.append( new Language("as", "Assamese", QObject::tr("Assamese")) );
+ //: Language name az
+ m_langList.append( new Language("az", "Azerbaijani", QObject::tr("Azerbaijani")) );
+ //: Language name azb
+ m_langList.append( new Language("azb", "Azerbaijani, South", QObject::tr("Azerbaijani, South")) );
+ // m_langList.append( new Language("ba", "Bashkir", QObject::tr("Bashkir")) );
+ //: Language name bar
+ m_langList.append( new Language("bar", "Bavarian", QObject::tr("Bavarian")) );
+ //: Language name be
+ m_langList.append( new Language("be", "Belarusian", QObject::tr("Belarusian")) );
+ //: Language name bg
+ m_langList.append( new Language("bg", "Bulgarian", QObject::tr("Bulgarian")) );
+ // m_langList.append( new Language("bh", "Bihari", QObject::tr("Bihari")) );
+ // m_langList.append( new Language("bi", "Bislama", QObject::tr("Bislama")) );
+ // m_langList.append( new Language("bn", "Bengali", QObject::tr("Bengali")) );
+ // m_langList.append( new Language("bo", "Tibetan", QObject::tr("Tibetan")) );
+ //: Language name br
+ m_langList.append( new Language("br", "Breton", QObject::tr("Breton")) );
+ //: Language name bs
+ m_langList.append( new Language("bs", "Bosnian", QObject::tr("Bosnian")) );
+ //: Language name ca
+ m_langList.append( new Language("ca", "Catalan", QObject::tr("Catalan")) );
+ // m_langList.append( new Language("ce", "Chechen", QObject::tr("Chechen")) );
+ //: Language name cco
+ m_langList.append( new Language("cco", "Chinantec, Comaltepec", QObject::tr("Chinantec, Comaltepec")) );
+ //: Language name ceb
+ m_langList.append( new Language("ceb", "Cebuano", QObject::tr("Cebuano")) );
+ //: Language name ch
+ m_langList.append( new Language("ch", "Chamorro", QObject::tr("Chamorro")) );
+ //: Language name chd
+ m_langList.append( new Language("chd", "Chontal, Highland Oaxaca", QObject::tr("Chontal, Highland Oaxaca")) );
+ //: Language name chq
+ m_langList.append( new Language("chq", "Chinantec, Quiotepec", QObject::tr("Chinantec, Quiotepec")) );
+ //: Language name chz
+ m_langList.append( new Language("chz", "Chinantec, Ozumac\u00edn", QObject::tr("Chinantec, Ozumac\u00edn")) );
+ // m_langList.append( new Language("co", "Corsican", QObject::tr("Corsican")) );
+ //: Language name ckw
+ m_langList.append( new Language("ckw", "Cakchiquel, Western", QObject::tr("Cakchiquel, Western")) );
+ //: Language name cnl
+ m_langList.append( new Language("cnl", "Chinantec, Lalana", QObject::tr("Chinantec, Lalana")) );
+ //: Language name cnt
+ m_langList.append( new Language("cnt", "Chinantec, Tepetotutla", QObject::tr("Chinantec, Tepetotutla")) );
+ //: Language name cop
+ m_langList.append( new Language("cop", "Coptic", QObject::tr("Coptic")) );
+ //: Language name cs
+ m_langList.append( new Language("cs", "Czech", QObject::tr("Czech")) );
+ //: Language name cso
+ m_langList.append( new Language("cso", "Chinantec, Sochiapan", QObject::tr("Chinantec, Sochiapan")) );
+ //: Language name cti
+ m_langList.append( new Language("cti", "Chol, Tila", QObject::tr("Chol, Tila")) );
+ //: Language name ctp
+ m_langList.append( new Language("ctp", "Chatino, Western Highland", QObject::tr("Chatino, Western Highland")) );
+ //: Language name cu
+ m_langList.append( new Language("cu", "Church Slavic", QObject::tr("Church Slavic")) );
+ // m_langList.append( new Language("cv", "Chuvash", QObject::tr("Chuvash")) );
+ //: Language name cy
+ m_langList.append( new Language("cy", "Welsh", QObject::tr("Welsh")) );
+ //: Language name da
+ m_langList.append( new Language("da", "Danish", QObject::tr("Danish")) );
+ //: Language name de
+ m_langList.append( new Language("de", "German", QObject::tr("German")) );
+ //: Language name dug
+ m_langList.append( new Language("dug", "Duruma", QObject::tr("Duruma")) );
+ // m_langList.append( new Language("dz", "Dzongkha", QObject::tr("Dzongkha")) );
+ //: Language name el
+ m_langList.append( new Language("el", "Greek, Modern (1453-)", QObject::tr("Greek, Modern (1453-)"), makeStringList("gre;ell")) );
+ //: Language name en
+ m_langList.append( new Language("en", "English", QObject::tr("English")) );
+ //: Language name en_US
+ m_langList.append( new Language("en_US", "American English", QObject::tr("American English")) );
+ //: Language name enm
+ m_langList.append( new Language("enm", "English, Middle (1100-1500)", QObject::tr("English, Middle (1100-1500)")) );
+ //: Language name eo
+ m_langList.append( new Language("eo", "Esperanto", QObject::tr("Esperanto")) );
+ //: Language name es
+ m_langList.append( new Language("es", "Spanish", QObject::tr("Spanish")) );
+ //: Language name et
+ m_langList.append( new Language("et", "Estonian", QObject::tr("Estonian")) );
+ //: Language name eu
+ m_langList.append( new Language("eu", "Basque", QObject::tr("Basque")) );
+ //: Language name fa
+ m_langList.append( new Language("fa", "Persian", QObject::tr("Persian")) );
+ //: Language name fi
+ m_langList.append( new Language("fi", "Finnish", QObject::tr("Finnish")) );
+ // m_langList.append( new Language("fj", "Fijian", QObject::tr("Fijian")) );
+ // m_langList.append( new Language("fo", "Faroese", QObject::tr("Faroese")) );
+ //: Language name fr
+ m_langList.append( new Language("fr", "French", QObject::tr("French")) );
+ //: Language name fy
+ m_langList.append( new Language("fy", "Frisian", QObject::tr("Frisian")) );
+ //: Language name ga
+ m_langList.append( new Language("ga", "Irish", QObject::tr("Irish")) );
+ //: Language name gd
+ m_langList.append( new Language("gd", "Gaelic (Scots)", QObject::tr("Gaelic (Scots)")) );
+ //: Language name gez
+ m_langList.append( new Language("gez", "Geez", QObject::tr("Geez")) );
+ // m_langList.append( new Language("gl", "Gallegan", QObject::tr("Gallegan")) );
+ // m_langList.append( new Language("gn", "Guarani", QObject::tr("Guarani")) );
+ // m_langList.append( new Language("gn", "Gujarati", QObject::tr("Gujarati")) );
+ //: Language name got
+ m_langList.append( new Language("got", "Gothic", QObject::tr("Gothic")) );
+ //: Language name gv
+ m_langList.append( new Language("gv", "Manx", QObject::tr("Manx")) );
+ //: Language name grc
+ m_langList.append( new Language("grc", "Greek, Ancient (to 1453)", QObject::tr("Greek, Ancient (to 1453)")) );
+ //: Language name he
+ m_langList.append( new Language("he", "Hebrew", QObject::tr("Hebrew")) );
+ //: Language name hau
+ m_langList.append( new Language("hau", "Hausa", QObject::tr("Hausa")) );
+ //: Language name haw
+ m_langList.append( new Language("haw", "Hawaiian", QObject::tr("Hawaiian")) );
+ //: Language name hi
+ m_langList.append( new Language("hi", "Hindi", QObject::tr("Hindi")) );
+ // m_langList.append( new Language("ho", "Hiri Motu", QObject::tr("Hiri Motu")) );
+ //: Language name hr
+ m_langList.append( new Language("hr", "Croatian", QObject::tr("Croatian")) );
+ //: Language name ht
+ m_langList.append( new Language("ht", "Haitian Creole", QObject::tr("Haitian Creole")) );
+ //: Language name hu
+ m_langList.append( new Language("hu", "Hungarian", QObject::tr("Hungarian")) );
+ //: Language name huv
+ m_langList.append( new Language("huv", "Huave, San Mateo Del Mar", QObject::tr("Huave, San Mateo Del Mar")) );
+ //: Language name hy
+ m_langList.append( new Language("hy", "Armenian", QObject::tr("Armenian")) );
+ // m_langList.append( new Language("hz", "Herero", QObject::tr("Herero")) );
+ // m_langList.append( new Language("ia", "Interlingua", QObject::tr("Interlingua")) );
+ //: Language name id
+ m_langList.append( new Language("id", "Indonesian", QObject::tr("Indonesian")) );
+ // m_langList.append( new Language("ie", "Interlingue", QObject::tr("Interlingue")) );
+ // m_langList.append( new Language("ik", "Inupiaq", QObject::tr("Inupiaq")) );
+ //: Language name is
+ m_langList.append( new Language("is", "Icelandic", QObject::tr("Icelandic")) );
+ //: Language name it
+ m_langList.append( new Language("it", "Italian", QObject::tr("Italian")) );
+ //: Language name itz
+ m_langList.append( new Language("itz", "Itz\u00e1", QObject::tr("Itz\u00e1")) );
+ //: Language name ixl
+ m_langList.append( new Language("ixl", "Ixil, San Juan Cotzal", QObject::tr("Ixil, San Juan Cotzal")) );
+ // m_langList.append( new Language("iu", "Inuktitut", QObject::tr("Inuktitut")) );
+ //: Language name ja
+ m_langList.append( new Language("ja", "Japanese", QObject::tr("Japanese")) );
+ //: Language name jac
+ m_langList.append( new Language("jac", "Jacalteco, Eastern", QObject::tr("Jacalteco, Eastern")) );
+ //: Language name jvn
+ m_langList.append( new Language("jvn", "Javanese, Caribbean", QObject::tr("Javanese, Caribbean")) );
+ //: Language name ka
+ m_langList.append( new Language("ka", "Georgian", QObject::tr("Georgian")) );
+ //: Language name kek
+ m_langList.append( new Language("kek", "Kekch\u00ed", QObject::tr("Kekch\u00ed", "kek")) );
+ // m_langList.append( new Language("ki", "Kikuyu", QObject::tr("Kikuyu")) );
+ // m_langList.append( new Language("kj", "Kuanyama", QObject::tr("Kuanyama")) );
+ // m_langList.append( new Language("kk", "Kazakh", QObject::tr("Kazakh")) );
+ // m_langList.append( new Language("kl", "Kalaallisut", QObject::tr("Kalaallisut")) );
+ // m_langList.append( new Language("km", "Khmer", QObject::tr("Khmer")) );
+ // m_langList.append( new Language("kn", "Kannada", QObject::tr("Kannada")) );
+ //: Language name ko
+ m_langList.append( new Language("ko", "Korean", QObject::tr("Korean")) );
+ // m_langList.append( new Language("ks", "Kashmiri", QObject::tr("Kashmiri")) );
+ //: Language name ku
+ m_langList.append( new Language("ku", "Kurdish", QObject::tr("Kurdish")) );
+ // m_langList.append( new Language("kv", "Komi", QObject::tr("Komi")) );
+ // m_langList.append( new Language("kw", "Cornish", QObject::tr("Cornish")) );
+ //: Language name ky
+ m_langList.append( new Language("ky", "Kirghiz", QObject::tr("Kirghiz")) );
+ //: Language name la
+ m_langList.append( new Language("la", "Latin", QObject::tr("Latin")) );
+ //: Language name lac
+ m_langList.append( new Language("lac", "Lacandon", QObject::tr("Lacandon")) );
+ // m_langList.append( new Language("lb", "Letzeburgesch", QObject::tr("Letzeburgesch")) );
+ //: Language name lmo
+ m_langList.append( new Language("lmo", "Lombard", QObject::tr("Lombard")) );
+ // m_langList.append( new Language("ln", "Lingala", QObject::tr("Lingala")) );
+ // m_langList.append( new Language("lo", "Lao", QObject::tr("Lao")) );
+ //: Language name lt
+ m_langList.append( new Language("lt", "Lithuanian", QObject::tr("Lithuanian")) );
+ //: Language name lv
+ m_langList.append( new Language("lv", "Latvian", QObject::tr("Latvian")) );
+ //: Language name mg
+ m_langList.append( new Language("mg", "Malagasy", QObject::tr("Malagasy")) );
+ // m_langList.append( new Language("mh", "Marshall", QObject::tr("Marshall")) );
+ //: Language name mi
+ m_langList.append( new Language("mi", "Maori", QObject::tr("Maori")) );
+ //: Language name mir
+ m_langList.append( new Language("mir", "Mixe, Isthmus", QObject::tr("Mixe, Isthmus")) );
+ //: Language name miz
+ m_langList.append( new Language("miz", "Mixtec, Coatzospan", QObject::tr("Mixtec, Coatzospan")) );
+ //: Language name mk
+ m_langList.append( new Language("mk", "Macedonian", QObject::tr("Macedonian")) );
+ //: Language name mks
+ m_langList.append( new Language("mks", "Mixtec, Silacayoapan", QObject::tr("Mixtec, Silacayoapan")) );
+ // m_langList.append( new Language("ml", "Malayalam", QObject::tr("Malayalam")) );
+ // m_langList.append( new Language("mn", "Mongolian", QObject::tr("Mongolian")) );
+ // m_langList.append( new Language("mo", "Moldavian", QObject::tr("Moldavian")) );
+ //: Language name mos
+ m_langList.append( new Language("mos", "More", QObject::tr("More")) );
+ // m_langList.append( new Language("mr", "Marathi", QObject::tr("Marathi")) );
+ //: Language name ms
+ m_langList.append( new Language("ms", "Malay", QObject::tr("Malay")) );
+ //: Language name mt
+ m_langList.append( new Language("mt", "Maltese", QObject::tr("Maltese")) );
+ //: Language name mul (meaning that the work has multiple languages)
+ m_langList.append( new Language("mul", "(Multiple languages)", QObject::tr("(Multiple languages)")) );
+ //: Language name mvc
+ m_langList.append( new Language("mvc", "Mam, Central", QObject::tr("Mam, Central")) );
+ //: Language name mvj
+ m_langList.append( new Language("mvj", "Mam, Todos Santos Cuchumat\u00e1n", QObject::tr("Mam, Todos Santos Cuchumat\u00e1n")) );
+ //: Language name mxq
+ m_langList.append( new Language("mxq", "Mixe, Juquila", QObject::tr("Mixe, Juquila")) );
+ //: Language name mxt
+ m_langList.append( new Language("mxt", "Mixtec, Jamiltepec", QObject::tr("Mixtec, Jamiltepec")) );
+ //: Language name my
+ m_langList.append( new Language("my", "Burmese", QObject::tr("Burmese")) );
+ // m_langList.append( new Language("na", "Nauru", QObject::tr("Nauru")) );
+ //: Language name nb
+ m_langList.append( new Language("nb", "Norwegian Bokm\u00e5l", QObject::tr("Norwegian Bokm\u00e5l")) );
+ //: Language name ncl
+ m_langList.append( new Language("ncl", "Nahuatl, Michoac\u00e1n", QObject::tr("Nahuatl, Michoac\u00e1n")) );
+ // m_langList.append( new Language("nd", "Ndebele, North", QObject::tr("Ndebele, North")) );
+ //: Language name nds
+ m_langList.append( new Language("nds", "Low German; Low Saxon", QObject::tr("Low German; Low Saxon")) );
+ //: Language name ne
+ m_langList.append( new Language("ne", "Nepali", QObject::tr("Nepali")) );
+ //: Language name ngu
+ m_langList.append( new Language("ngu", "Nahuatl, Guerrero", QObject::tr("Nahuatl, Guerrero")) );
+ //: Language name nhy
+ m_langList.append( new Language("nhy", "Nahuatl, Northern Oaxaca", QObject::tr("Nahuatl, Northern Oaxaca")) );
+ // m_langList.append( new Language("ng", "Ndonga", QObject::tr("Ndonga")) );
+ //: Language name nl
+ m_langList.append( new Language("nl", "Dutch", QObject::tr("Dutch")) );
+ //: Language name nn
+ m_langList.append( new Language("nn", "Norwegian Nynorsk", QObject::tr("Norwegian Nynorsk")) );
+ //: Language name no
+ m_langList.append( new Language("no", "Norwegian", QObject::tr("Norwegian")) );
+ // m_langList.append( new Language("nr", "Ndebele, South", QObject::tr("Ndebele, South")) );
+ // m_langList.append( new Language("nv", "Navajo", QObject::tr("Navajo")) );
+ // m_langList.append( new Language("ny", "Chichewa; Nyanja", QObject::tr("Chichewa; Nyanja")) );
+ // m_langList.append( new Language("oc", "Occitan (post 1500); Provençal", QObject::tr("Occitan (post 1500); Provençal")) );
+ // m_langList.append( new Language("om", "Oromo", QObject::tr("Oromo")) );
+ // m_langList.append( new Language("or", "Oriya", QObject::tr("Oriya")) );
+ // m_langList.append( new Language("os", "Ossetian; Ossetic", QObject::tr("Ossetian; Ossetic")) );
+ //: Language name otq
+ m_langList.append( new Language("otq", "Otomi, Quer\u00e9taro", QObject::tr("Otomi, Quer\u00e9taro")) );
+ // m_langList.append( new Language("pa", "Panjabi", QObject::tr("Panjabi")) );
+ //: Language name pap
+ m_langList.append( new Language("pap", "Papiamento", QObject::tr("Papiamento")) );
+ // m_langList.append( new Language("pi", "Pali", QObject::tr("Pali")) );
+ //: Language name ppk
+ m_langList.append( new Language("ppk", "Uma", QObject::tr("Uma")) );
+ //: Language name pl
+ m_langList.append( new Language("pl", "Polish", QObject::tr("Polish")) );
+ //: Language name pot
+ m_langList.append( new Language("pot", "Potawatomi", QObject::tr("Potawatomi")) );
+ //: Language name ppk
+ m_langList.append( new Language("ppk", "Uma", QObject::tr("Uma")) );
+ //: Language name prs
+ m_langList.append( new Language("prs", "Persian (Dari)", QObject::tr("Persian (Dari)")) );
- // m_langList.append( new Language("ps", "Pushto", QObject::tr("Pushto")) );
- //: Language name pt
- m_langList.append( new Language("pt", "Portuguese", QObject::tr("Portuguese")) );
- //: Language name pt_BR
- m_langList.append( new Language("pt_BR", "Brasilian Portuguese", QObject::tr("Brasilian Portuguese")) );//added by ourself
- // m_langList.append( new Language("qu", "Quechua", QObject::tr("Quechua")) );
- //: Language name qut
- m_langList.append( new Language("qut", "Quich\u00e9, West Central", QObject::tr("Quich\u00e9, West Central")) );
- // m_langList.append( new Language("rm", "Raeto-Romance", QObject::tr("Raeto-Romance")) );
- // m_langList.append( new Language("rn", "Rundi", QObject::tr("Rundi")) );
- //: Language name ro
- m_langList.append( new Language("ro", "Romanian", QObject::tr("Romanian")) );
- //: Language name ru
- m_langList.append( new Language("ru", "Russian", QObject::tr("Russian")) );
- // m_langList.append( new Language("rw", "Kinyarwanda", QObject::tr("Kinyarwanda")) );
- // m_langList.append( new Language("sa", "Sanskrit", QObject::tr("Sanskrit")) );
- // m_langList.append( new Language("sc", "Sardinian", QObject::tr("Sardinian")) );
- //: Language name sco
- m_langList.append( new Language("sco", "Scots", QObject::tr("Scots")) );
- // m_langList.append( new Language("sd", "Sindhi", QObject::tr("Sindhi")) );
- // m_langList.append( new Language("se", "Northern Sami", QObject::tr("Northern Sami")) );
- // m_langList.append( new Language("sg", "Sango", QObject::tr("Sango")) );
- // m_langList.append( new Language("si", "Sinhalese", QObject::tr("Sinhalese")) );
- //: Language name sk
- m_langList.append( new Language("sk", "Slovak", QObject::tr("Slovak")) );
- //: Language name sl
- m_langList.append( new Language("sl", "Slovenian", QObject::tr("Slovenian")) );
- // m_langList.append( new Language("sm", "Samoan", QObject::tr("Samoan")) );
- // m_langList.append( new Language("sn", "Shona", QObject::tr("Shona")) );
- //: Language name so
- m_langList.append( new Language("so", "Somali", QObject::tr("Somali")) );
- //: Language name sq
- m_langList.append( new Language("sq", "Albanian", QObject::tr("Albanian")) );
- // m_langList.append( new Language("sr", "Serbian", QObject::tr("Serbian")) );
- //: Language name srn
- m_langList.append( new Language("srn", "Sranan", QObject::tr("Sranan")) );
- // m_langList.append( new Language("ss", "Swati", QObject::tr("Swati")) );
- // m_langList.append( new Language("st", "Sotho, Southern", QObject::tr("Sotho, Southern")) );
- // m_langList.append( new Language("su", "Sundanese", QObject::tr("Sundanese")) );
- //: Language name sv
- m_langList.append( new Language("sv", "Swedish", QObject::tr("Swedish")) );
- //: Language name sw
- m_langList.append( new Language("sw", "Swahili", QObject::tr("Swahili")) );
- //: Language name syr
- m_langList.append( new Language("syr", "Syriac", QObject::tr("Syriac")) );
- //: Language name ta
- m_langList.append( new Language("ta", "Tamil", QObject::tr("Tamil")) );
- // m_langList.append( new Language("te", "Telugu", QObject::tr("Telugu")) );
- // m_langList.append( new Language("tg", "Tajik", QObject::tr("Tajik")) );
- //: Language name th
- m_langList.append( new Language("th", "Thai", QObject::tr("Thai")) );
- // m_langList.append( new Language("tk", "Turkmen", QObject::tr("Turkmen")) );
- //: Language name tl
- m_langList.append( new Language("tl", "Tagalog", QObject::tr("Tagalog")) );
- //: Language name tlh
- m_langList.append( new Language("tlh", "Klingon", QObject::tr("Klingon")) );
- //: Language name tn
- m_langList.append( new Language("tn", "Tswana", QObject::tr("Tswana")) );
- //: Language name tr
- m_langList.append( new Language("tr", "Turkish", QObject::tr("Turkish")) );
- // m_langList.append( new Language("ts", "Tsonga", QObject::tr("Tsonga")) );
- // m_langList.append( new Language("tt", "Tatar", QObject::tr("Tatar")) );
- //: Language name ttc
- m_langList.append( new Language("ttc", "Tektiteko", QObject::tr("Tektiteko")) );
- // m_langList.append( new Language("tw", "Twi", QObject::tr("Twi")) );
- //: Language name ty
- m_langList.append( new Language("ty", "Tahitian", QObject::tr("Tahitian")) );
- //: Language name tzz
- m_langList.append( new Language("tzz", "Tzotzil, Zinacant\u00e1n", QObject::tr("Tzotzil, Zinacant\u00e1n")) );
- // m_langList.append( new Language("ug", "Uighur", QObject::tr("Uighur")) );
- //: Language name uk
- m_langList.append( new Language("uk", "Ukrainian", QObject::tr("Ukrainian")) );
- // m_langList.append( new Language("ur", "Urdu", QObject::tr("Urdu")) );
- //: Language name ury
- m_langList.append( new Language("ury", "Orya", QObject::tr("Orya")) );
- //: Language name usp
- m_langList.append( new Language("usp", "Uspanteco", QObject::tr("Uspanteco")) );
- // m_langList.append( new Language("uz", "Uzbek", QObject::tr("Uzbek")) );
- //: Language name vi
- m_langList.append( new Language("vi", "Vietnamese", QObject::tr("Vietnamese")) );
- // m_langList.append( new Language("vo", "Volapük", QObject::tr("Volapük")) );
- // m_langList.append( new Language("wo", "Wolof", QObject::tr("Wolof")) );
- //: Language name xh
- m_langList.append( new Language("xh", "Xhosa", QObject::tr("Xhosa")) );
- //: Language name xtd
- m_langList.append( new Language("xtd", "Mixtec, Diuxi-Tilantongo", QObject::tr("Mixtec, Diuxi-Tilantongo")) );
- //: Language name yi
- m_langList.append( new Language("yi", "Yiddish", QObject::tr("Yiddish")) );
- //: Language name yo
- m_langList.append( new Language("yo", "Yoruba", QObject::tr("Yoryba")) );
- // m_langList.append( new Language("za", "Zhuang", QObject::tr("Zhuang")) );
- //: Language name zab
- m_langList.append( new Language("zab", "Zapotec, San Juan Guelav\u00eda", QObject::tr("Zapotec, San Juan Guelav\u00eda")) );
- //: Language name zaw
- m_langList.append( new Language("zaw", "Zapotec, Mitla", QObject::tr("Zapotec, Mitla")) );
- //: Language name zh
- m_langList.append( new Language("zh", "Chinese", QObject::tr("Chinese")) );
- //: Language name zpo
- m_langList.append( new Language("zpo", "Zapotec, Amatl\u00e1n", QObject::tr("Zapotec, Amatl\u00e1n")) );
- //: Language name zpq
- m_langList.append( new Language("zpq", "Zapotec, Zoogocho", QObject::tr("Zapotec, Zoogocho")) );
- //: Language name zpu
- m_langList.append( new Language("zpu", "Zapotec, Yal\u00e1lag", QObject::tr("Zapotec, Yal\u00e1lag")) );
- //: Language name zpv
- m_langList.append( new Language("zpv", "Zapotec, Chichicapan", QObject::tr("Zapotec, Chichicapan")) );
- //: Language name zsr
- m_langList.append( new Language("zsr", "Zapotec, Southern Rincon", QObject::tr("Zapotec, Southern Rincon")) );
- //: Language name ztq
- m_langList.append( new Language("ztq", "Zapotec, Quioquitani-Quier\u00ed", QObject::tr("Zapotec, Quioquitani-Quier\u00ed")) );
- //: Language name zty
- m_langList.append( new Language("zty", "Zapotec, Yatee", QObject::tr("Zapotec, Yatee")) );
- //: Language name zu
- m_langList.append( new Language("zu", "Zulu", QObject::tr("Zulu")) );
+ // m_langList.append( new Language("ps", "Pushto", QObject::tr("Pushto")) );
+ //: Language name pt
+ m_langList.append( new Language("pt", "Portuguese", QObject::tr("Portuguese")) );
+ //: Language name pt_BR
+ m_langList.append( new Language("pt_BR", "Brasilian Portuguese", QObject::tr("Brasilian Portuguese")) );//added by ourself
+ // m_langList.append( new Language("qu", "Quechua", QObject::tr("Quechua")) );
+ //: Language name qut
+ m_langList.append( new Language("qut", "Quich\u00e9, West Central", QObject::tr("Quich\u00e9, West Central")) );
+ // m_langList.append( new Language("rm", "Raeto-Romance", QObject::tr("Raeto-Romance")) );
+ // m_langList.append( new Language("rn", "Rundi", QObject::tr("Rundi")) );
+ //: Language name ro
+ m_langList.append( new Language("ro", "Romanian", QObject::tr("Romanian")) );
+ //: Language name ru
+ m_langList.append( new Language("ru", "Russian", QObject::tr("Russian")) );
+ // m_langList.append( new Language("rw", "Kinyarwanda", QObject::tr("Kinyarwanda")) );
+ // m_langList.append( new Language("sa", "Sanskrit", QObject::tr("Sanskrit")) );
+ // m_langList.append( new Language("sc", "Sardinian", QObject::tr("Sardinian")) );
+ //: Language name sco
+ m_langList.append( new Language("sco", "Scots", QObject::tr("Scots")) );
+ // m_langList.append( new Language("sd", "Sindhi", QObject::tr("Sindhi")) );
+ // m_langList.append( new Language("se", "Northern Sami", QObject::tr("Northern Sami")) );
+ // m_langList.append( new Language("sg", "Sango", QObject::tr("Sango")) );
+ // m_langList.append( new Language("si", "Sinhalese", QObject::tr("Sinhalese")) );
+ //: Language name sk
+ m_langList.append( new Language("sk", "Slovak", QObject::tr("Slovak")) );
+ //: Language name sl
+ m_langList.append( new Language("sl", "Slovenian", QObject::tr("Slovenian")) );
+ // m_langList.append( new Language("sm", "Samoan", QObject::tr("Samoan")) );
+ // m_langList.append( new Language("sn", "Shona", QObject::tr("Shona")) );
+ //: Language name so
+ m_langList.append( new Language("so", "Somali", QObject::tr("Somali")) );
+ //: Language name sq
+ m_langList.append( new Language("sq", "Albanian", QObject::tr("Albanian")) );
+ // m_langList.append( new Language("sr", "Serbian", QObject::tr("Serbian")) );
+ //: Language name srn
+ m_langList.append( new Language("srn", "Sranan", QObject::tr("Sranan")) );
+ // m_langList.append( new Language("ss", "Swati", QObject::tr("Swati")) );
+ // m_langList.append( new Language("st", "Sotho, Southern", QObject::tr("Sotho, Southern")) );
+ // m_langList.append( new Language("su", "Sundanese", QObject::tr("Sundanese")) );
+ //: Language name sv
+ m_langList.append( new Language("sv", "Swedish", QObject::tr("Swedish")) );
+ //: Language name sw
+ m_langList.append( new Language("sw", "Swahili", QObject::tr("Swahili")) );
+ //: Language name syr
+ m_langList.append( new Language("syr", "Syriac", QObject::tr("Syriac")) );
+ //: Language name ta
+ m_langList.append( new Language("ta", "Tamil", QObject::tr("Tamil")) );
+ // m_langList.append( new Language("te", "Telugu", QObject::tr("Telugu")) );
+ // m_langList.append( new Language("tg", "Tajik", QObject::tr("Tajik")) );
+ //: Language name th
+ m_langList.append( new Language("th", "Thai", QObject::tr("Thai")) );
+ // m_langList.append( new Language("tk", "Turkmen", QObject::tr("Turkmen")) );
+ //: Language name tl
+ m_langList.append( new Language("tl", "Tagalog", QObject::tr("Tagalog")) );
+ //: Language name tlh
+ m_langList.append( new Language("tlh", "Klingon", QObject::tr("Klingon")) );
+ //: Language name tn
+ m_langList.append( new Language("tn", "Tswana", QObject::tr("Tswana")) );
+ //: Language name tr
+ m_langList.append( new Language("tr", "Turkish", QObject::tr("Turkish")) );
+ // m_langList.append( new Language("ts", "Tsonga", QObject::tr("Tsonga")) );
+ // m_langList.append( new Language("tt", "Tatar", QObject::tr("Tatar")) );
+ //: Language name ttc
+ m_langList.append( new Language("ttc", "Tektiteko", QObject::tr("Tektiteko")) );
+ // m_langList.append( new Language("tw", "Twi", QObject::tr("Twi")) );
+ //: Language name ty
+ m_langList.append( new Language("ty", "Tahitian", QObject::tr("Tahitian")) );
+ //: Language name tzz
+ m_langList.append( new Language("tzz", "Tzotzil, Zinacant\u00e1n", QObject::tr("Tzotzil, Zinacant\u00e1n")) );
+ // m_langList.append( new Language("ug", "Uighur", QObject::tr("Uighur")) );
+ //: Language name uk
+ m_langList.append( new Language("uk", "Ukrainian", QObject::tr("Ukrainian")) );
+ // m_langList.append( new Language("ur", "Urdu", QObject::tr("Urdu")) );
+ //: Language name ury
+ m_langList.append( new Language("ury", "Orya", QObject::tr("Orya")) );
+ //: Language name usp
+ m_langList.append( new Language("usp", "Uspanteco", QObject::tr("Uspanteco")) );
+ // m_langList.append( new Language("uz", "Uzbek", QObject::tr("Uzbek")) );
+ //: Language name vi
+ m_langList.append( new Language("vi", "Vietnamese", QObject::tr("Vietnamese")) );
+ // m_langList.append( new Language("vo", "Volapük", QObject::tr("Volapük")) );
+ // m_langList.append( new Language("wo", "Wolof", QObject::tr("Wolof")) );
+ //: Language name xh
+ m_langList.append( new Language("xh", "Xhosa", QObject::tr("Xhosa")) );
+ //: Language name xtd
+ m_langList.append( new Language("xtd", "Mixtec, Diuxi-Tilantongo", QObject::tr("Mixtec, Diuxi-Tilantongo")) );
+ //: Language name yi
+ m_langList.append( new Language("yi", "Yiddish", QObject::tr("Yiddish")) );
+ //: Language name yo
+ m_langList.append( new Language("yo", "Yoruba", QObject::tr("Yoryba")) );
+ // m_langList.append( new Language("za", "Zhuang", QObject::tr("Zhuang")) );
+ //: Language name zab
+ m_langList.append( new Language("zab", "Zapotec, San Juan Guelav\u00eda", QObject::tr("Zapotec, San Juan Guelav\u00eda")) );
+ //: Language name zaw
+ m_langList.append( new Language("zaw", "Zapotec, Mitla", QObject::tr("Zapotec, Mitla")) );
+ //: Language name zh
+ m_langList.append( new Language("zh", "Chinese", QObject::tr("Chinese")) );
+ //: Language name zpo
+ m_langList.append( new Language("zpo", "Zapotec, Amatl\u00e1n", QObject::tr("Zapotec, Amatl\u00e1n")) );
+ //: Language name zpq
+ m_langList.append( new Language("zpq", "Zapotec, Zoogocho", QObject::tr("Zapotec, Zoogocho")) );
+ //: Language name zpu
+ m_langList.append( new Language("zpu", "Zapotec, Yal\u00e1lag", QObject::tr("Zapotec, Yal\u00e1lag")) );
+ //: Language name zpv
+ m_langList.append( new Language("zpv", "Zapotec, Chichicapan", QObject::tr("Zapotec, Chichicapan")) );
+ //: Language name zsr
+ m_langList.append( new Language("zsr", "Zapotec, Southern Rincon", QObject::tr("Zapotec, Southern Rincon")) );
+ //: Language name ztq
+ m_langList.append( new Language("ztq", "Zapotec, Quioquitani-Quier\u00ed", QObject::tr("Zapotec, Quioquitani-Quier\u00ed")) );
+ //: Language name zty
+ m_langList.append( new Language("zty", "Zapotec, Yatee", QObject::tr("Zapotec, Yatee")) );
+ //: Language name zu
+ m_langList.append( new Language("zu", "Zulu", QObject::tr("Zulu")) );
- foreach (Language* lang, m_langList) {
- m_langMap.insert( lang->abbrev(), lang);
- }
+ foreach (Language* lang, m_langList) {
+ m_langMap.insert( lang->abbrev(), lang);
+ }
}
diff --git a/src/backend/managers/clanguagemgr.h b/src/backend/managers/clanguagemgr.h
index f421e62..6d3a5c3 100644
--- a/src/backend/managers/clanguagemgr.h
+++ b/src/backend/managers/clanguagemgr.h
@@ -22,129 +22,129 @@
class CLanguageMgr {
-public:
- /** Language container.
- * This class (Language) contains the information about the chosen language.
- */
- class Language {
- public:
- /** Default constructor of a language object.
- * Uses the abbreviation parameter to lookup the
- * language name and to be able to return the name, flag etc.
- * Possible values for abbrev are de, en, fr, it etc.
- */
- Language();
- /** Copy constructor.
- */
- Language(const Language&);
- /** Constructor which takes all necessary data.
- */
- Language(const QString& abbrev, const QString& englishName, const QString& translatedName, const QStringList& altAbbrevs = QStringList());
- /** Destructor.
- */
- ~Language();
- /** Returns the abbreviation.
- * @return The abbreviation of the chosen language.
- */
- inline const QString& abbrev() const {
- if (m_abbrev.isEmpty() && m_altAbbrevs.count()) { //no standard abbrev but alternative ones
- return m_altAbbrevs.first();
- }
- return m_abbrev;
- }
- /** Returns the translated name.
- * @return The translated name of the language.
- */
- inline const QString& translatedName() const {
- return m_translatedName;
- }
- /** The english name of the language.
- * @return The english name of the chosen language.
- */
- inline const QString& name() const {
- return m_englishName;
- }
- /** The alternative abbreviations which are avalable for this language.
- * @return The List of alternate abbreviations
- */
- inline const QStringList alternativeAbbrevs() const {
- return m_altAbbrevs;
- }
- /**
- * Returns true if this language object is valid, i.e. has an abbrev and name.
- * @return True if the data is valid for this language.
- */
- inline bool isValid() const {
- return (!abbrev().isEmpty() && !name().isEmpty());
- }
+ public:
+ /** Language container.
+ * This class (Language) contains the information about the chosen language.
+ */
+ class Language {
+ public:
+ /** Default constructor of a language object.
+ * Uses the abbreviation parameter to lookup the
+ * language name and to be able to return the name, flag etc.
+ * Possible values for abbrev are de, en, fr, it etc.
+ */
+ Language();
+ /** Copy constructor.
+ */
+ Language(const Language&);
+ /** Constructor which takes all necessary data.
+ */
+ Language(const QString& abbrev, const QString& englishName, const QString& translatedName, const QStringList& altAbbrevs = QStringList());
+ /** Destructor.
+ */
+ ~Language();
+ /** Returns the abbreviation.
+ * @return The abbreviation of the chosen language.
+ */
+ inline const QString& abbrev() const {
+ if (m_abbrev.isEmpty() && m_altAbbrevs.count()) { //no standard abbrev but alternative ones
+ return m_altAbbrevs.first();
+ }
+ return m_abbrev;
+ }
+ /** Returns the translated name.
+ * @return The translated name of the language.
+ */
+ inline const QString& translatedName() const {
+ return m_translatedName;
+ }
+ /** The english name of the language.
+ * @return The english name of the chosen language.
+ */
+ inline const QString& name() const {
+ return m_englishName;
+ }
+ /** The alternative abbreviations which are avalable for this language.
+ * @return The List of alternate abbreviations
+ */
+ inline const QStringList alternativeAbbrevs() const {
+ return m_altAbbrevs;
+ }
+ /**
+ * Returns true if this language object is valid, i.e. has an abbrev and name.
+ * @return True if the data is valid for this language.
+ */
+ inline bool isValid() const {
+ return (!abbrev().isEmpty() && !name().isEmpty());
+ }
- private:
- QString m_abbrev;
- QString m_englishName;
- QString m_translatedName;
- QStringList m_altAbbrevs;
- };
+ private:
+ QString m_abbrev;
+ QString m_englishName;
+ QString m_translatedName;
+ QStringList m_altAbbrevs;
+ };
- typedef QList<Language*> LanguageList;
- typedef QHash<QString, const Language*> LangMap;
- typedef QHash<QString, const Language*>::const_iterator LangMapIterator;
+ typedef QList<Language*> LanguageList;
+ typedef QHash<QString, const Language*> LangMap;
+ typedef QHash<QString, const Language*>::const_iterator LangMapIterator;
- /** Constructor.
- */
- CLanguageMgr();
- /** Destructor
- */
- virtual ~CLanguageMgr();
- /**
- * Returns the standard languages available as standard. Does nothing for Sword.
- * @return A LangMap map which contains all known languages
- */
- inline const CLanguageMgr::LangMap* languages() const {
- return &m_langMap;
- }
- /**
- * Returns the languages which are available. The languages cover all available modules, but nothing more.
- * @return A map of all languages with modules available for them
- */
- const CLanguageMgr::LangMap& availableLanguages();
- /** Language for abbreviation.
- * @param abbrev The language abbreviation
- * @return Pointer to a language for the given string abbreviation.
- */
- const CLanguageMgr::Language* languageForAbbrev( const QString& abbrev ) const;
- /** Language for english name.
- * @param abbrev The english language name.
- * @return Pointer to a language for the given name
- */
- const CLanguageMgr::Language* languageForName( const QString& language ) const;
- /** Language for translated language name.
- * @param abbrev The translated language name
- * @return Pointer to a language for the given translated language name
- */
- const CLanguageMgr::Language* languageForTranslatedName( const QString& language ) const;
- /** Default language so we don't return NULL pointers.
- * @return Pointer to the default language
- */
- inline const CLanguageMgr::Language* defaultLanguage() const {
- return &m_defaultLanguage;
- }
+ /** Constructor.
+ */
+ CLanguageMgr();
+ /** Destructor
+ */
+ virtual ~CLanguageMgr();
+ /**
+ * Returns the standard languages available as standard. Does nothing for Sword.
+ * @return A LangMap map which contains all known languages
+ */
+ inline const CLanguageMgr::LangMap* languages() const {
+ return &m_langMap;
+ }
+ /**
+ * Returns the languages which are available. The languages cover all available modules, but nothing more.
+ * @return A map of all languages with modules available for them
+ */
+ const CLanguageMgr::LangMap& availableLanguages();
+ /** Language for abbreviation.
+ * @param abbrev The language abbreviation
+ * @return Pointer to a language for the given string abbreviation.
+ */
+ const CLanguageMgr::Language* languageForAbbrev( const QString& abbrev ) const;
+ /** Language for english name.
+ * @param abbrev The english language name.
+ * @return Pointer to a language for the given name
+ */
+ const CLanguageMgr::Language* languageForName( const QString& language ) const;
+ /** Language for translated language name.
+ * @param abbrev The translated language name
+ * @return Pointer to a language for the given translated language name
+ */
+ const CLanguageMgr::Language* languageForTranslatedName( const QString& language ) const;
+ /** Default language so we don't return NULL pointers.
+ * @return Pointer to the default language
+ */
+ inline const CLanguageMgr::Language* defaultLanguage() const {
+ return &m_defaultLanguage;
+ }
-private:
- void init();
- inline const QStringList makeStringList(const QString& abbrevs) {
- return abbrevs.split( ";", QString::KeepEmptyParts, Qt::CaseSensitive );
- }
+ private:
+ void init();
+ inline const QStringList makeStringList(const QString& abbrevs) {
+ return abbrevs.split( ";", QString::KeepEmptyParts, Qt::CaseSensitive );
+ }
- Language m_defaultLanguage;
- mutable LanguageList m_langList;
- mutable LangMap m_langMap;
- mutable LanguageList m_cleanupLangPtrs;
+ Language m_defaultLanguage;
+ mutable LanguageList m_langList;
+ mutable LangMap m_langMap;
+ mutable LanguageList m_cleanupLangPtrs;
- struct ModuleCache {
- unsigned int moduleCount;
- LangMap availableLanguages;
- }
- m_availableModulesCache;
+ struct ModuleCache {
+ unsigned int moduleCount;
+ LangMap availableLanguages;
+ }
+ m_availableModulesCache;
};
#endif
diff --git a/src/backend/managers/creferencemanager.cpp b/src/backend/managers/creferencemanager.cpp
index adae180..41f8954 100644
--- a/src/backend/managers/creferencemanager.cpp
+++ b/src/backend/managers/creferencemanager.cpp
@@ -21,402 +21,402 @@
/** Returns a hyperlink used to be imbedded in the display windows. At the moment the format is sword://module/key */
const QString CReferenceManager::encodeHyperlink( const QString moduleName, const QString key, const CReferenceManager::Type type) {
- QString ret = QString::null;
-
- switch (type) {
-
- case Bible:
- ret = QString("sword://Bible/");
- break;
- case Commentary:
- ret = QString("sword://Commentary/");
- break;
- case Lexicon:
- ret = QString("sword://Lexicon/");
- break;
- case GenericBook:
- ret = QString("sword://Book/");
- break;
- case MorphHebrew:
- ret = QString("morph://Hebrew/");
- break;
- case MorphGreek:
- ret = QString("morph://Greek/");
- break;
- case StrongsHebrew:
- ret = QString("strongs://Hebrew/");
- break;
- case StrongsGreek:
- ret = QString("strongs://Greek/");
- break;
- default:
- break;
- }
-
- if (!moduleName.isEmpty()) {
- ret.append( moduleName ).append('/');
- }
- else { //if module is empty use fallback module
- ret.append( preferredModule(type) ).append('/');
- }
-
- if (type == GenericBook) {
- const QString s = (!key.isEmpty() ? key : QString::null);
- QString newKey = QString::null;
- //replace all / of the key (e.g. of a CSwordTreeKey) with
- // the escape sequence \/ so we know it's a link internal divider (e.g. of CSwordTreeKey)!
-
- QChar c;
-
- for(int i = 0; i < s.length(); ++i) {
- c = s.at(i);
-
- if (c == '/') {
- newKey.append("\\/");
- }
- else {
- newKey.append(c);
- }
- }
-
- ret.append( newKey );
- }
- else { //slashes do not appear in verses and dictionary entries
-
- switch (type) {
-
- case Bible: //bibles or commentary keys need parsing
-
- case Commentary: {
-/* CSwordModuleInfo* mod = CPointers::backend()->findModuleByName(moduleName);
-
- ParseOptions options;
- options.refDestinationModule = mod->name();
- options.refBase =
- options.sourceLanguage = mod->module()->Lang();
- options.destinationLanguage = "en";
-
- ret.append( parseVerseReference(key, options) ); //we add the english key, so drag and drop will work in all cases*/
- ret.append(key);
- break;
- }
-
- default:
- ret.append( key ); //use the standard key, no parsing required
- break;
- }
- }
-
- return ret;
+ QString ret = QString::null;
+
+ switch (type) {
+
+ case Bible:
+ ret = QString("sword://Bible/");
+ break;
+ case Commentary:
+ ret = QString("sword://Commentary/");
+ break;
+ case Lexicon:
+ ret = QString("sword://Lexicon/");
+ break;
+ case GenericBook:
+ ret = QString("sword://Book/");
+ break;
+ case MorphHebrew:
+ ret = QString("morph://Hebrew/");
+ break;
+ case MorphGreek:
+ ret = QString("morph://Greek/");
+ break;
+ case StrongsHebrew:
+ ret = QString("strongs://Hebrew/");
+ break;
+ case StrongsGreek:
+ ret = QString("strongs://Greek/");
+ break;
+ default:
+ break;
+ }
+
+ if (!moduleName.isEmpty()) {
+ ret.append( moduleName ).append('/');
+ }
+ else { //if module is empty use fallback module
+ ret.append( preferredModule(type) ).append('/');
+ }
+
+ if (type == GenericBook) {
+ const QString s = (!key.isEmpty() ? key : QString::null);
+ QString newKey = QString::null;
+ //replace all / of the key (e.g. of a CSwordTreeKey) with
+ // the escape sequence \/ so we know it's a link internal divider (e.g. of CSwordTreeKey)!
+
+ QChar c;
+
+ for (int i = 0; i < s.length(); ++i) {
+ c = s.at(i);
+
+ if (c == '/') {
+ newKey.append("\\/");
+ }
+ else {
+ newKey.append(c);
+ }
+ }
+
+ ret.append( newKey );
+ }
+ else { //slashes do not appear in verses and dictionary entries
+
+ switch (type) {
+
+ case Bible: //bibles or commentary keys need parsing
+
+ case Commentary: {
+ /* CSwordModuleInfo* mod = CPointers::backend()->findModuleByName(moduleName);
+
+ ParseOptions options;
+ options.refDestinationModule = mod->name();
+ options.refBase =
+ options.sourceLanguage = mod->module()->Lang();
+ options.destinationLanguage = "en";
+
+ ret.append( parseVerseReference(key, options) ); //we add the english key, so drag and drop will work in all cases*/
+ ret.append(key);
+ break;
+ }
+
+ default:
+ ret.append( key ); //use the standard key, no parsing required
+ break;
+ }
+ }
+
+ return ret;
}
/** Decodes the given hyperlink to module and key. */
bool CReferenceManager::decodeHyperlink( const QString& hyperlink, QString& module, QString& key, CReferenceManager::Type& type ) {
- /**
- * We have to decide between three types of URLS: sword://Type/Module/Key, morph://Testament/key and strongs://Testament/Key
- */
- module = QString::null;
- key = QString::null;
-
- type = Unknown; //not yet known
- QString ref = hyperlink;
- //remove the trailing slash
-
- if (ref.right(1)=="/" && ref.right(2) != "\\/") //trailing slash, but not escaped
- ref = ref.left(ref.length()-1);
-
- //find out which type we have by looking at the beginning (protocoll section of URL)
- if (ref.left(8).toLower() == "sword://") { //Bible, Commentary or Lexicon
- ref = ref.mid(8);
-
- if (ref.left(5).toLower() == "bible") { //a bible hyperlink
- type = CReferenceManager::Bible;
- ref = ref.mid(6); //inclusive trailing slash
- }
- else if (ref.left(10).toLower() == "commentary") { // a Commentary hyperlink
- type = CReferenceManager::Commentary;
- ref = ref.mid(11); //inclusive trailing slash
- }
- else if (ref.left(7).toLower() == "lexicon") { // a Lexicon hyperlink
- type = CReferenceManager::Lexicon;
- ref = ref.mid(8); //inclusive trailing slash
- }
- else if (ref.left(4).toLower() == "book") { // a Book hyperlink
- type = CReferenceManager::GenericBook;
- ref = ref.mid(5); //inclusive trailing slash
- }
-
- // string up to next slash is the modulename
- if (ref.at(0) != '/' ) { //we have a module given
-
- while (true) {
- const int pos = ref.indexOf("/");
-
- if ((pos>0) && ref.at(pos-1) != '\\') { //found a slash which is not escaped
- module = ref.mid(0,pos);
- ref = ref.mid(pos+1);
- break;
- }
- else if (pos == -1) {
- break;
- }
- }
-
- // the rest is the key
- key = ref;
- }
- else {
- key = ref.mid(1);
- }
-
- //the key may be an osis key like "NASBLex:Moses", which sets the module, too
- // const int modPos = key.find(":");
- // if (modPos != -1 && key.at(modPos-1).isLetter() && key.at(modPos+1).isLetter()) {
- // module = key.left(modPos);
- // key = key.mid(modPos+1);
- //
- // qWarning("found the module name %s with key %s", module.latin1(), key.latin1());
- // }
-
- //replace \/ escapes with /
- key.replace(QRegExp("\\\\/"), "/");
- }
- else if (ref.left(8).toLower() == "morph://" || ref.left(10).toLower() == "strongs://") { //strongs or morph URL have the same format
- enum PreType {IsMorph, IsStrongs};
- PreType preType = IsMorph;
-
- if (ref.left(8).toLower() == "morph://") { //morph code hyperlink
- ref = ref.mid(8);
- preType = IsMorph;
- }
- else if (ref.left(10).toLower() == "strongs://") {
- ref = ref.mid(10);
- preType = IsStrongs;
- }
-
- //part up to next slash is the language
- const int pos = ref.indexOf("/");
-
- if (pos>0) { //found
- const QString language = ref.mid(0,pos);
-
- if (language.toLower() == "hebrew") {
- switch (preType) {
-
- case IsMorph:
- type = CReferenceManager::MorphHebrew;
- break;
-
- case IsStrongs:
- type = CReferenceManager::StrongsHebrew;
- break;
- }
- }
- else if (language.toLower() == "greek") {
- switch (preType) {
-
- case IsMorph:
- type = CReferenceManager::MorphGreek;
- break;
-
- case IsStrongs:
- type = CReferenceManager::StrongsGreek;
- break;
- }
- }
-
- ref = ref.mid(pos+1);
- key = ref; //the remaining part is the key
-
- module = preferredModule(type);
- }
- }
-
- if (key.isEmpty() && module.isEmpty())
- return false;
-
- return true;
+ /**
+ * We have to decide between three types of URLS: sword://Type/Module/Key, morph://Testament/key and strongs://Testament/Key
+ */
+ module = QString::null;
+ key = QString::null;
+
+ type = Unknown; //not yet known
+ QString ref = hyperlink;
+ //remove the trailing slash
+
+ if (ref.right(1) == "/" && ref.right(2) != "\\/") //trailing slash, but not escaped
+ ref = ref.left(ref.length() - 1);
+
+ //find out which type we have by looking at the beginning (protocoll section of URL)
+ if (ref.left(8).toLower() == "sword://") { //Bible, Commentary or Lexicon
+ ref = ref.mid(8);
+
+ if (ref.left(5).toLower() == "bible") { //a bible hyperlink
+ type = CReferenceManager::Bible;
+ ref = ref.mid(6); //inclusive trailing slash
+ }
+ else if (ref.left(10).toLower() == "commentary") { // a Commentary hyperlink
+ type = CReferenceManager::Commentary;
+ ref = ref.mid(11); //inclusive trailing slash
+ }
+ else if (ref.left(7).toLower() == "lexicon") { // a Lexicon hyperlink
+ type = CReferenceManager::Lexicon;
+ ref = ref.mid(8); //inclusive trailing slash
+ }
+ else if (ref.left(4).toLower() == "book") { // a Book hyperlink
+ type = CReferenceManager::GenericBook;
+ ref = ref.mid(5); //inclusive trailing slash
+ }
+
+ // string up to next slash is the modulename
+ if (ref.at(0) != '/' ) { //we have a module given
+
+ while (true) {
+ const int pos = ref.indexOf("/");
+
+ if ((pos > 0) && ref.at(pos - 1) != '\\') { //found a slash which is not escaped
+ module = ref.mid(0, pos);
+ ref = ref.mid(pos + 1);
+ break;
+ }
+ else if (pos == -1) {
+ break;
+ }
+ }
+
+ // the rest is the key
+ key = ref;
+ }
+ else {
+ key = ref.mid(1);
+ }
+
+ //the key may be an osis key like "NASBLex:Moses", which sets the module, too
+ // const int modPos = key.find(":");
+ // if (modPos != -1 && key.at(modPos-1).isLetter() && key.at(modPos+1).isLetter()) {
+ // module = key.left(modPos);
+ // key = key.mid(modPos+1);
+ //
+ // qWarning("found the module name %s with key %s", module.latin1(), key.latin1());
+ // }
+
+ //replace \/ escapes with /
+ key.replace(QRegExp("\\\\/"), "/");
+ }
+ else if (ref.left(8).toLower() == "morph://" || ref.left(10).toLower() == "strongs://") { //strongs or morph URL have the same format
+ enum PreType {IsMorph, IsStrongs};
+ PreType preType = IsMorph;
+
+ if (ref.left(8).toLower() == "morph://") { //morph code hyperlink
+ ref = ref.mid(8);
+ preType = IsMorph;
+ }
+ else if (ref.left(10).toLower() == "strongs://") {
+ ref = ref.mid(10);
+ preType = IsStrongs;
+ }
+
+ //part up to next slash is the language
+ const int pos = ref.indexOf("/");
+
+ if (pos > 0) { //found
+ const QString language = ref.mid(0, pos);
+
+ if (language.toLower() == "hebrew") {
+ switch (preType) {
+
+ case IsMorph:
+ type = CReferenceManager::MorphHebrew;
+ break;
+
+ case IsStrongs:
+ type = CReferenceManager::StrongsHebrew;
+ break;
+ }
+ }
+ else if (language.toLower() == "greek") {
+ switch (preType) {
+
+ case IsMorph:
+ type = CReferenceManager::MorphGreek;
+ break;
+
+ case IsStrongs:
+ type = CReferenceManager::StrongsGreek;
+ break;
+ }
+ }
+
+ ref = ref.mid(pos + 1);
+ key = ref; //the remaining part is the key
+
+ module = preferredModule(type);
+ }
+ }
+
+ if (key.isEmpty() && module.isEmpty())
+ return false;
+
+ return true;
}
const QString CReferenceManager::encodeReference(const QString &module, const QString &reference) {
- //return QString("(%1)%2").arg(module).arg(reference);
- return QString("(").append(module).append(")").append(reference);
+ //return QString("(%1)%2").arg(module).arg(reference);
+ return QString("(").append(module).append(")").append(reference);
}
void CReferenceManager::decodeReference(QString &dragreference, QString &module, QString &reference) {
- const int pos = dragreference.indexOf(")");
- const QString fallbackModule = dragreference.mid( 1, pos - 1);
- dragreference = dragreference.mid(pos+1);
+ const int pos = dragreference.indexOf(")");
+ const QString fallbackModule = dragreference.mid( 1, pos - 1);
+ dragreference = dragreference.mid(pos + 1);
- module = fallbackModule;
- reference = dragreference;
+ module = fallbackModule;
+ reference = dragreference;
}
/** Returns true if the parameter is a hyperlink. */
bool CReferenceManager::isHyperlink( const QString& hyperlink ) {
- return ( hyperlink.left(8) == "sword://")
- || (hyperlink.left(10) == "strongs://")
- || (hyperlink.left(8) == "morph://");
+ return ( hyperlink.left(8) == "sword://")
+ || (hyperlink.left(10) == "strongs://")
+ || (hyperlink.left(8) == "morph://");
}
/** Returns the preferred module name for the given type. */
const QString CReferenceManager::preferredModule( const CReferenceManager::Type type ) {
- QString moduleName = QString::null;
- CSwordModuleInfo* module = 0;
+ QString moduleName = QString::null;
+ CSwordModuleInfo* module = 0;
- switch (type) {
+ switch (type) {
- case CReferenceManager::Bible:
+ case CReferenceManager::Bible:
- module = CBTConfig::get
- ( CBTConfig::standardBible );
+ module = CBTConfig::get
+ ( CBTConfig::standardBible );
- break;
+ break;
- case CReferenceManager::Commentary:
- module = CBTConfig::get
- ( CBTConfig::standardCommentary );
+ case CReferenceManager::Commentary:
+ module = CBTConfig::get
+ ( CBTConfig::standardCommentary );
- break;
+ break;
- case CReferenceManager::Lexicon:
- module = CBTConfig::get
- ( CBTConfig::standardLexicon );
+ case CReferenceManager::Lexicon:
+ module = CBTConfig::get
+ ( CBTConfig::standardLexicon );
- break;
+ break;
- case CReferenceManager::StrongsHebrew:
- module = CBTConfig::get
- ( CBTConfig::standardHebrewStrongsLexicon );
+ case CReferenceManager::StrongsHebrew:
+ module = CBTConfig::get
+ ( CBTConfig::standardHebrewStrongsLexicon );
- break;
+ break;
- case CReferenceManager::StrongsGreek:
- module = CBTConfig::get
- ( CBTConfig::standardGreekStrongsLexicon );
+ case CReferenceManager::StrongsGreek:
+ module = CBTConfig::get
+ ( CBTConfig::standardGreekStrongsLexicon );
- break;
+ break;
- case CReferenceManager::MorphHebrew:
- module = CBTConfig::get
- ( CBTConfig::standardHebrewMorphLexicon );
+ case CReferenceManager::MorphHebrew:
+ module = CBTConfig::get
+ ( CBTConfig::standardHebrewMorphLexicon );
- break;
+ break;
- case CReferenceManager::MorphGreek:
- module = CBTConfig::get
- ( CBTConfig::standardGreekMorphLexicon );
+ case CReferenceManager::MorphGreek:
+ module = CBTConfig::get
+ ( CBTConfig::standardGreekMorphLexicon );
- break;
+ break;
- default:
- module = 0;
+ default:
+ module = 0;
- break;
- }
+ break;
+ }
- return module ? module->name() : QString::null;
+ return module ? module->name() : QString::null;
}
/** No descriptions */
CReferenceManager::Type CReferenceManager::typeFromModule( const CSwordModuleInfo::ModuleType type) {
- switch (type) {
+ switch (type) {
- case CSwordModuleInfo::Bible:
- return CReferenceManager::Bible;
+ case CSwordModuleInfo::Bible:
+ return CReferenceManager::Bible;
- case CSwordModuleInfo::Commentary:
- return CReferenceManager::Commentary;
+ case CSwordModuleInfo::Commentary:
+ return CReferenceManager::Commentary;
- case CSwordModuleInfo::Lexicon:
- return CReferenceManager::Lexicon;
+ case CSwordModuleInfo::Lexicon:
+ return CReferenceManager::Lexicon;
- case CSwordModuleInfo::GenericBook:
- return CReferenceManager::GenericBook;
+ case CSwordModuleInfo::GenericBook:
+ return CReferenceManager::GenericBook;
- default:
- return CReferenceManager::Unknown;
- }
+ default:
+ return CReferenceManager::Unknown;
+ }
}
/** Parses the given verse references using the given language and the module.*/
const QString CReferenceManager::parseVerseReference( const QString& ref, const CReferenceManager::ParseOptions& options) {
- CSwordModuleInfo* const mod = CPointers::backend()->findModuleByName(options.refDestinationModule);
- //Q_ASSERT(mod); tested later
+ CSwordModuleInfo* const mod = CPointers::backend()->findModuleByName(options.refDestinationModule);
+ //Q_ASSERT(mod); tested later
- if (!mod) {
- //parsing of non-verse based references is not supported
- return ref;
- }
+ if (!mod) {
+ //parsing of non-verse based references is not supported
+ return ref;
+ }
- if ((mod->type() != CSwordModuleInfo::Bible) && (mod->type() != CSwordModuleInfo::Commentary)) {
- qDebug("CReferenceManager: Only verse based modules are supported as ref destination module");
- return QString::null;
- }
+ if ((mod->type() != CSwordModuleInfo::Bible) && (mod->type() != CSwordModuleInfo::Commentary)) {
+ qDebug("CReferenceManager: Only verse based modules are supported as ref destination module");
+ return QString::null;
+ }
- QString sourceLanguage = options.sourceLanguage;
- QString destinationLanguage = options.destinationLanguage;
+ QString sourceLanguage = options.sourceLanguage;
+ QString destinationLanguage = options.destinationLanguage;
- sword::StringList locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
- if (/*options.sourceLanguage == "en" ||*/ std::find(locales.begin(), locales.end(), sourceLanguage.toUtf8().constData()) == locales.end()) { //sourceLanguage not available
- sourceLanguage = "en_US";
- }
+ sword::StringList locales = sword::LocaleMgr::getSystemLocaleMgr()->getAvailableLocales();
+ if (/*options.sourceLanguage == "en" ||*/ std::find(locales.begin(), locales.end(), sourceLanguage.toUtf8().constData()) == locales.end()) { //sourceLanguage not available
+ sourceLanguage = "en_US";
+ }
- if (/*options.destinationLanguage == "en" ||*/ std::find(locales.begin(), locales.end(), sourceLanguage.toUtf8().constData()) == locales.end()) { //destination not available
- destinationLanguage = "en_US";
- }
+ if (/*options.destinationLanguage == "en" ||*/ std::find(locales.begin(), locales.end(), sourceLanguage.toUtf8().constData()) == locales.end()) { //destination not available
+ destinationLanguage = "en_US";
+ }
- QString ret;
- QStringList refList = ref.split(";");
+ QString ret;
+ QStringList refList = ref.split(";");
- CSwordVerseKey baseKey(0);
- baseKey.setLocale( sourceLanguage.toUtf8().constData() );
- baseKey.key( options.refBase ); //probably in the sourceLanguage
- baseKey.setLocale( "en_US" ); //english works in all environments as base
+ CSwordVerseKey baseKey(0);
+ baseKey.setLocale( sourceLanguage.toUtf8().constData() );
+ baseKey.key( options.refBase ); //probably in the sourceLanguage
+ baseKey.setLocale( "en_US" ); //english works in all environments as base
// CSwordVerseKey dummy(0);
- //HACK: We have to workaround a Sword bug, we have to set the default locale to the same as the sourceLanguage !
- const QString oldLocaleName = CPointers::backend()->booknameLanguage();
- CPointers::backend()->booknameLanguage(sourceLanguage);
+ //HACK: We have to workaround a Sword bug, we have to set the default locale to the same as the sourceLanguage !
+ const QString oldLocaleName = CPointers::backend()->booknameLanguage();
+ CPointers::backend()->booknameLanguage(sourceLanguage);
- sword::VerseKey dummy;
- dummy.setLocale( sourceLanguage.toUtf8().constData() );
- Q_ASSERT( !strcmp(dummy.getLocale(), sourceLanguage.toUtf8().constData()) );
+ sword::VerseKey dummy;
+ dummy.setLocale( sourceLanguage.toUtf8().constData() );
+ Q_ASSERT( !strcmp(dummy.getLocale(), sourceLanguage.toUtf8().constData()) );
// qDebug("Parsing '%s' in '%s' using '%s' as base, source lang '%s', dest lang '%s'", ref.latin1(), options.refDestinationModule.latin1(), baseKey.key().latin1(), sourceLanguage.latin1(), destinationLanguage.latin1());
- for (QStringList::iterator it = refList.begin(); it != refList.end(); it++) {
- //The listkey may contain more than one item, because a ref lik "Gen 1:3,5" is parsed into two single refs
- sword::ListKey lk = dummy.ParseVerseList((*it).toUtf8().constData(), baseKey.key().toUtf8().constData(), true);
- Q_ASSERT(!dummy.Error());
-
- //Q_ASSERT(lk.Count());
- if (!lk.Count()) {
- ret.append( *it ); //don't change the original
- continue;
- }
-
- for (int i = 0; i < lk.Count(); ++i) {
- if (dynamic_cast<sword::VerseKey*>(lk.getElement(i))) { // a range
- sword::VerseKey* k = dynamic_cast<sword::VerseKey*>(lk.getElement(i));
- Q_ASSERT(k);
- k->setLocale( destinationLanguage.toUtf8().constData() );
-
- ret.append( QString::fromUtf8(k->getRangeText()) ).append("; ");
- }
- else { // a single ref
- sword::VerseKey vk;
- vk.setLocale( sourceLanguage.toUtf8().constData() );
- vk = lk.getElement(i)->getText();
- vk.setLocale( destinationLanguage.toUtf8().constData() );
-
- ret.append( QString::fromUtf8(vk.getText()) ).append("; ");
- }
- }
-
- }
-
- CPointers::backend()->booknameLanguage(oldLocaleName);
- return ret;
+ for (QStringList::iterator it = refList.begin(); it != refList.end(); it++) {
+ //The listkey may contain more than one item, because a ref lik "Gen 1:3,5" is parsed into two single refs
+ sword::ListKey lk = dummy.ParseVerseList((*it).toUtf8().constData(), baseKey.key().toUtf8().constData(), true);
+ Q_ASSERT(!dummy.Error());
+
+ //Q_ASSERT(lk.Count());
+ if (!lk.Count()) {
+ ret.append( *it ); //don't change the original
+ continue;
+ }
+
+ for (int i = 0; i < lk.Count(); ++i) {
+ if (dynamic_cast<sword::VerseKey*>(lk.getElement(i))) { // a range
+ sword::VerseKey* k = dynamic_cast<sword::VerseKey*>(lk.getElement(i));
+ Q_ASSERT(k);
+ k->setLocale( destinationLanguage.toUtf8().constData() );
+
+ ret.append( QString::fromUtf8(k->getRangeText()) ).append("; ");
+ }
+ else { // a single ref
+ sword::VerseKey vk;
+ vk.setLocale( sourceLanguage.toUtf8().constData() );
+ vk = lk.getElement(i)->getText();
+ vk.setLocale( destinationLanguage.toUtf8().constData() );
+
+ ret.append( QString::fromUtf8(vk.getText()) ).append("; ");
+ }
+ }
+
+ }
+
+ CPointers::backend()->booknameLanguage(oldLocaleName);
+ return ret;
}
diff --git a/src/backend/managers/creferencemanager.h b/src/backend/managers/creferencemanager.h
index 19baae7..85131d6 100644
--- a/src/backend/managers/creferencemanager.h
+++ b/src/backend/managers/creferencemanager.h
@@ -22,88 +22,88 @@
class CReferenceManager {
-public:
- enum Type {
- Bible, /**< Bibles */
- Commentary, /**< Commentary */
- Lexicon, /**< Lexicon */
- GenericBook, /**< Generic Book */
- MorphHebrew, /**< Module for hebrew morphology*/
- MorphGreek, /**< Module for greek morphology */
- StrongsHebrew, /**< Module for hebrew strongs */
- StrongsGreek, /**< Module for greek strongs */
- Unknown /**< Unknown */
- };
+ public:
+ enum Type {
+ Bible, /**< Bibles */
+ Commentary, /**< Commentary */
+ Lexicon, /**< Lexicon */
+ GenericBook, /**< Generic Book */
+ MorphHebrew, /**< Module for hebrew morphology*/
+ MorphGreek, /**< Module for greek morphology */
+ StrongsHebrew, /**< Module for hebrew strongs */
+ StrongsGreek, /**< Module for greek strongs */
+ Unknown /**< Unknown */
+ };
- /** Turn a hyperlink into module, key and type.
- * Decodes the given hyperlink into module, key and type.
- * @param hyperlink The hyperlink to decode
- * @param module The string which will contain the module name after decoding
- * @param key The string which will contain the key after decoding
- * @param type The type param will contain the reference type after decoding
- */
- static bool decodeHyperlink( const QString& hyperlink, QString& module, QString& key, Type& type);
- /**
- * Returns a hyperlink used to be embedded in the display windows.
- * At the moment the format is sword://module/key
- * @param module The module which is used to encode the hyperlink
- * @param key The key which is used to encode the hyperlink
- * @param type The type which is used to encode the hyperlink
- * @return The encoded hyperlink
- */
- static const QString encodeHyperlink( const QString module, const QString key, const Type type);
- /**
- * Puts a module Name and a Reference together in the 'draggable' form
- * (module)reference
- * @param module The name of the module
- * @param reference The key reference as text
- * @return The encoded reference using module and reference
- * @author Martin Gruner
- */
- static const QString encodeReference(const QString &module, const QString &reference);
- /**
- * decodes a 'draggable' reference into a modulename and a reference
- * @author Martin Gruner
- */
- static void decodeReference(QString &dragreference, QString &module, QString &reference);
- /**
- * Returns true if the parameter is a hyperlink.
- * @param hyperlink The string which is tested
- * @return True if the passed string is a hyperlink
- */
- static bool isHyperlink( const QString& hyperlink );
- /**
- * Returns the preferred module name for the given type.
- * @param type The type which is used to find the module
- * @return The default module name for the passed type
- */
- static const QString preferredModule( const Type type );
- /**
- * Returns the type of the passed module type
- * @param type The CSwordModuleInfo module typpe
- * @return The ReferenceManager type
- */
- static CReferenceManager::Type typeFromModule( const CSwordModuleInfo::ModuleType type );
+ /** Turn a hyperlink into module, key and type.
+ * Decodes the given hyperlink into module, key and type.
+ * @param hyperlink The hyperlink to decode
+ * @param module The string which will contain the module name after decoding
+ * @param key The string which will contain the key after decoding
+ * @param type The type param will contain the reference type after decoding
+ */
+ static bool decodeHyperlink( const QString& hyperlink, QString& module, QString& key, Type& type);
+ /**
+ * Returns a hyperlink used to be embedded in the display windows.
+ * At the moment the format is sword://module/key
+ * @param module The module which is used to encode the hyperlink
+ * @param key The key which is used to encode the hyperlink
+ * @param type The type which is used to encode the hyperlink
+ * @return The encoded hyperlink
+ */
+ static const QString encodeHyperlink( const QString module, const QString key, const Type type);
+ /**
+ * Puts a module Name and a Reference together in the 'draggable' form
+ * (module)reference
+ * @param module The name of the module
+ * @param reference The key reference as text
+ * @return The encoded reference using module and reference
+ * @author Martin Gruner
+ */
+ static const QString encodeReference(const QString &module, const QString &reference);
+ /**
+ * decodes a 'draggable' reference into a modulename and a reference
+ * @author Martin Gruner
+ */
+ static void decodeReference(QString &dragreference, QString &module, QString &reference);
+ /**
+ * Returns true if the parameter is a hyperlink.
+ * @param hyperlink The string which is tested
+ * @return True if the passed string is a hyperlink
+ */
+ static bool isHyperlink( const QString& hyperlink );
+ /**
+ * Returns the preferred module name for the given type.
+ * @param type The type which is used to find the module
+ * @return The default module name for the passed type
+ */
+ static const QString preferredModule( const Type type );
+ /**
+ * Returns the type of the passed module type
+ * @param type The CSwordModuleInfo module typpe
+ * @return The ReferenceManager type
+ */
+ static CReferenceManager::Type typeFromModule( const CSwordModuleInfo::ModuleType type );
- struct ParseOptions {
- QString refDestinationModule;
- QString refBase; /* only valid for verse based destination modules*/
- QString sourceLanguage; /* only valid for verse based destination modules*/
- QString destinationLanguage; /* only valid for verse based destination modules*/
+ struct ParseOptions {
+ QString refDestinationModule;
+ QString refBase; /* only valid for verse based destination modules*/
+ QString sourceLanguage; /* only valid for verse based destination modules*/
+ QString destinationLanguage; /* only valid for verse based destination modules*/
- ParseOptions() {
- destinationLanguage = "en";
- };
- };
+ ParseOptions() {
+ destinationLanguage = "en";
+ };
+ };
- /** Parses the given verse references using the given language and the module.
- * @param moduleName The name of the module to use. Required for the language checking before parsing the key.
- * @param ref The verse reference.
- * @param lang The language of the verse reference
- * @param newLang The language of the reference, which will be returned. For example: If BibleTime using an english environment parses a spanish ref (lang=es) the returned ref should be in english (newLang=en), because his english standard module only understands en.
- */
- static const QString parseVerseReference( const QString& ref, const ParseOptions& options);
+ /** Parses the given verse references using the given language and the module.
+ * @param moduleName The name of the module to use. Required for the language checking before parsing the key.
+ * @param ref The verse reference.
+ * @param lang The language of the verse reference
+ * @param newLang The language of the reference, which will be returned. For example: If BibleTime using an english environment parses a spanish ref (lang=es) the returned ref should be in english (newLang=en), because his english standard module only understands en.
+ */
+ static const QString parseVerseReference( const QString& ref, const ParseOptions& options);
};
#endif
diff --git a/src/backend/managers/cswordbackend.cpp b/src/backend/managers/cswordbackend.cpp
index f17538a..6420627 100644
--- a/src/backend/managers/cswordbackend.cpp
+++ b/src/backend/managers/cswordbackend.cpp
@@ -49,503 +49,523 @@ using namespace Filters;
using namespace Rendering;
CSwordBackend::CSwordBackend()
- : sword::SWMgr(0, 0, false, new sword::EncodingFilterMgr( sword::ENC_UTF8 ), true)
+ : sword::SWMgr(0, 0, false, new sword::EncodingFilterMgr( sword::ENC_UTF8 ), true),
+ m_dataModel(this)
{
- m_filters.gbf = new BT_GBFHTML();
- m_filters.plain = new BT_PLAINHTML();
- m_filters.thml = new BT_ThMLHTML();
- m_filters.osis = new BT_OSISHTML();
+ m_filters.gbf = new BT_GBFHTML();
+ m_filters.plain = new BT_PLAINHTML();
+ m_filters.thml = new BT_ThMLHTML();
+ m_filters.osis = new BT_OSISHTML();
- m_displays.entry = new CEntryDisplay();
- m_displays.chapter = new CChapterDisplay();
- m_displays.book = new CBookDisplay();
+ m_displays.entry = new CEntryDisplay();
+ m_displays.chapter = new CChapterDisplay();
+ m_displays.book = new CBookDisplay();
- filterInit();
+ filterInit();
}
CSwordBackend::CSwordBackend(const QString& path, const bool augmentHome)
- : sword::SWMgr(!path.isEmpty() ? path.toLocal8Bit().constData() : 0, false, new sword::EncodingFilterMgr( sword::ENC_UTF8 ), false, augmentHome) // don't allow module renaming, because we load from a path
-{
- m_filters.gbf = new BT_GBFHTML();
- m_filters.plain = new BT_PLAINHTML();
- m_filters.thml = new BT_ThMLHTML();
- m_filters.osis = new BT_OSISHTML();
+ : sword::SWMgr(!path.isEmpty() ? path.toLocal8Bit().constData() : 0, false, new sword::EncodingFilterMgr( sword::ENC_UTF8 ), false, augmentHome) { // don't allow module renaming, because we load from a path
+ m_filters.gbf = new BT_GBFHTML();
+ m_filters.plain = new BT_PLAINHTML();
+ m_filters.thml = new BT_ThMLHTML();
+ m_filters.osis = new BT_OSISHTML();
- m_displays.entry = new CEntryDisplay();
- m_displays.chapter = new CChapterDisplay();
- m_displays.book = new CBookDisplay();
+ m_displays.entry = new CEntryDisplay();
+ m_displays.chapter = new CChapterDisplay();
+ m_displays.book = new CBookDisplay();
- filterInit();
+ filterInit();
}
CSwordBackend::~CSwordBackend() {
- shutdownModules();
+ shutdownModules();
- delete m_filters.gbf;
- delete m_filters.plain;
- delete m_filters.thml;
- delete m_filters.osis;
+ delete m_filters.gbf;
+ delete m_filters.plain;
+ delete m_filters.thml;
+ delete m_filters.osis;
- delete m_displays.book;
- delete m_displays.chapter;
- delete m_displays.entry;
+ delete m_displays.book;
+ delete m_displays.chapter;
+ delete m_displays.entry;
}
void CSwordBackend::filterInit() {
- //HACK: replace Sword's OSISMorphSegmentation filter, seems to be buggy, ours works
- if (sword::SWOptionFilter* filter = optionFilters["OSISMorphSegmentation"])
- {
- cleanupFilters.remove(filter);
- optionFilters.erase("OSISMorphSegmentation");
- delete filter;
- }
- sword::SWOptionFilter* tmpFilter = new OSISMorphSegmentation();
- optionFilters.insert(sword::OptionFilterMap::value_type("OSISMorphSegmentation", tmpFilter));
- cleanupFilters.push_back(tmpFilter);
-
- //HACK: replace Sword's ThML strip filter with our own version
- //remove this hack as soon as Sword is fixed
- cleanupFilters.remove(thmlplain);
- delete thmlplain;
- thmlplain = new BT_ThMLPlain();
- cleanupFilters.push_back(thmlplain);
+ //HACK: replace Sword's OSISMorphSegmentation filter, seems to be buggy, ours works
+ if (sword::SWOptionFilter* filter = optionFilters["OSISMorphSegmentation"]) {
+ cleanupFilters.remove(filter);
+ optionFilters.erase("OSISMorphSegmentation");
+ delete filter;
+ }
+ sword::SWOptionFilter* tmpFilter = new OSISMorphSegmentation();
+ optionFilters.insert(sword::OptionFilterMap::value_type("OSISMorphSegmentation", tmpFilter));
+ cleanupFilters.push_back(tmpFilter);
+
+ //HACK: replace Sword's ThML strip filter with our own version
+ //remove this hack as soon as Sword is fixed
+ cleanupFilters.remove(thmlplain);
+ delete thmlplain;
+ thmlplain = new BT_ThMLPlain();
+ cleanupFilters.push_back(thmlplain);
}
-QList<CSwordModuleInfo*> CSwordBackend::takeModulesFromList(QStringList names)
-{
- int numberOfRemoved = 0;
- QList<CSwordModuleInfo*> list;
- foreach(QString name, names) {
- CSwordModuleInfo* mInfo = findModuleByName(name);
- if (mInfo) {
- m_moduleList.removeAll(mInfo);
- ++numberOfRemoved;
- list.append(mInfo);
- }
- }
- if (numberOfRemoved > 0)
- emit sigSwordSetupChanged(RemovedModules);
- return list;
+QList<CSwordModuleInfo*> CSwordBackend::takeModulesFromList(QStringList names) {
+ int numberOfRemoved = 0;
+ QList<CSwordModuleInfo*> list;
+ foreach(QString name, names) {
+ CSwordModuleInfo* mInfo = findModuleByName(name);
+ if (mInfo) {
+ m_dataModel.removeModule(mInfo);
+ ++numberOfRemoved;
+ list.append(mInfo);
+ }
+ }
+ if (numberOfRemoved > 0)
+ emit sigSwordSetupChanged(RemovedModules);
+ return list;
}
/** Initializes the Sword modules. */
CSwordBackend::LoadError CSwordBackend::initModules(SetupChangedReason reason) {
- // qWarning("globalSwordConfigPath is %s", globalConfPath);
- LoadError ret = NoError;
-
- shutdownModules(); //remove previous modules
- m_moduleList.clear();
-
- sword::ModMap::iterator end = Modules.end();
- ret = LoadError( Load() );
-
- for (sword::ModMap::iterator it = Modules.begin(); it != end; it++) {
- sword::SWModule* const curMod = (*it).second;
- CSwordModuleInfo* newModule = 0;
-
- if (!strcmp(curMod->Type(), "Biblical Texts")) {
- newModule = new CSwordBibleModuleInfo(curMod, this);
- newModule->module()->Disp(m_displays.chapter);
- }
- else if (!strcmp(curMod->Type(), "Commentaries")) {
- newModule = new CSwordCommentaryModuleInfo(curMod, this);
- newModule->module()->Disp(m_displays.entry);
- }
- else if (!strcmp(curMod->Type(), "Lexicons / Dictionaries")) {
- newModule = new CSwordLexiconModuleInfo(curMod, this);
- newModule->module()->Disp(m_displays.entry);
- }
- else if (!strcmp(curMod->Type(), "Generic Books")) {
- newModule = new CSwordBookModuleInfo(curMod, this);
- newModule->module()->Disp(m_displays.book);
- }
-
- if (newModule) {
- //Append the new modules to our list, but only if it's supported
- //The constructor of CSwordModuleInfo prints a warning on stdout
- if (!newModule->hasVersion() || (newModule->minimumSwordVersion() <= sword::SWVersion::currentVersion)) {
- m_moduleList.append( newModule );
- }
- else
- {
- delete newModule;
- }
- }
- }
-
- QList<CSwordModuleInfo*>::iterator end_it = m_moduleList.end();
-
- foreach (CSwordModuleInfo* mod, m_moduleList) {
- m_moduleDescriptionMap.insert( mod->config(CSwordModuleInfo::Description), mod->name() );
- //unlock modules if keys are present
- if ( mod->isEncrypted() ) {
- const QString unlockKey = CBTConfig::getModuleEncryptionKey( mod->name() );
- if (!unlockKey.isNull()) {
- setCipherKey( mod->name().toUtf8().constData(), unlockKey.toUtf8().constData() );
- }
- }
- }
-
- emit sigSwordSetupChanged(reason);
- return ret;
+ // qWarning("globalSwordConfigPath is %s", globalConfPath);
+ LoadError ret = NoError;
+
+ shutdownModules(); //remove previous modules
+ m_dataModel.clear();
+
+ sword::ModMap::iterator end = Modules.end();
+ ret = LoadError( Load() );
+
+ for (sword::ModMap::iterator it = Modules.begin(); it != end; it++) {
+ sword::SWModule* const curMod = (*it).second;
+ CSwordModuleInfo* newModule = 0;
+
+ if (!strcmp(curMod->Type(), "Biblical Texts")) {
+ newModule = new CSwordBibleModuleInfo(curMod, this);
+ newModule->module()->Disp(m_displays.chapter);
+ }
+ else if (!strcmp(curMod->Type(), "Commentaries")) {
+ newModule = new CSwordCommentaryModuleInfo(curMod, this);
+ newModule->module()->Disp(m_displays.entry);
+ }
+ else if (!strcmp(curMod->Type(), "Lexicons / Dictionaries")) {
+ newModule = new CSwordLexiconModuleInfo(curMod, this);
+ newModule->module()->Disp(m_displays.entry);
+ }
+ else if (!strcmp(curMod->Type(), "Generic Books")) {
+ newModule = new CSwordBookModuleInfo(curMod, this);
+ newModule->module()->Disp(m_displays.book);
+ }
+
+ if (newModule) {
+ //Append the new modules to our list, but only if it's supported
+ //The constructor of CSwordModuleInfo prints a warning on stdout
+ if (!newModule->hasVersion() || (newModule->minimumSwordVersion() <= sword::SWVersion::currentVersion)) {
+ m_dataModel.addModule(newModule);
+ }
+ else {
+ delete newModule;
+ }
+ }
+ }
+
+ Q_FOREACH(CSwordModuleInfo* mod, m_dataModel.modules()) {
+ m_moduleDescriptionMap.insert( mod->config(CSwordModuleInfo::Description), mod->name() );
+ //unlock modules if keys are present
+ if ( mod->isEncrypted() ) {
+ const QString unlockKey = CBTConfig::getModuleEncryptionKey( mod->name() );
+ if (!unlockKey.isNull()) {
+ setCipherKey( mod->name().toUtf8().constData(), unlockKey.toUtf8().constData() );
+ }
+ }
+ }
+
+ emit sigSwordSetupChanged(reason);
+ return ret;
}
void CSwordBackend::AddRenderFilters(sword::SWModule *module, sword::ConfigEntMap &section) {
- sword::SWBuf moduleDriver;
- sword::SWBuf sourceformat;
- sword::ConfigEntMap::iterator entry;
- bool noDriver = true;
-
- sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
- moduleDriver = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
-
- if (sourceformat == "GBF") {
- module->AddRenderFilter(m_filters.gbf);
- noDriver = false;
- }
- else if (sourceformat == "PLAIN") {
- module->AddRenderFilter(m_filters.plain);
- noDriver = false;
- }
- else if (sourceformat == "ThML") {
- module->AddRenderFilter(m_filters.thml);
- noDriver = false;
- }
- else if (sourceformat == "OSIS") {
- module->AddRenderFilter(m_filters.osis);
- noDriver = false;
- }
-
- if (noDriver) { //no driver found
- if ( (moduleDriver == "RawCom") || (moduleDriver == "RawLD") ) {
- module->AddRenderFilter(m_filters.plain);
- noDriver = false;
- }
- }
+ sword::SWBuf moduleDriver;
+ sword::SWBuf sourceformat;
+ sword::ConfigEntMap::iterator entry;
+ bool noDriver = true;
+
+ sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
+ moduleDriver = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
+
+ if (sourceformat == "GBF") {
+ module->AddRenderFilter(m_filters.gbf);
+ noDriver = false;
+ }
+ else if (sourceformat == "PLAIN") {
+ module->AddRenderFilter(m_filters.plain);
+ noDriver = false;
+ }
+ else if (sourceformat == "ThML") {
+ module->AddRenderFilter(m_filters.thml);
+ noDriver = false;
+ }
+ else if (sourceformat == "OSIS") {
+ module->AddRenderFilter(m_filters.osis);
+ noDriver = false;
+ }
+
+ if (noDriver) { //no driver found
+ if ( (moduleDriver == "RawCom") || (moduleDriver == "RawLD") ) {
+ module->AddRenderFilter(m_filters.plain);
+ noDriver = false;
+ }
+ }
}
/** This function deinitializes the modules and deletes them. */
bool CSwordBackend::shutdownModules() {
- QList<CSwordModuleInfo*>::iterator it = m_moduleList.begin();
- QList<CSwordModuleInfo*>::iterator end = m_moduleList.end();
-
- while (it != end) {
- CSwordModuleInfo* current = (*it);
- it = m_moduleList.erase(it);
- delete current;
- }
-
- Q_ASSERT(m_moduleList.count() == 0);
- //BT mods are deleted now, delete Sword mods, too.
- DeleteMods();
-
- /* Cipher filters must be handled specially, because SWMgr creates them,
- * stores them in cipherFilters and cleanupFilters and attaches them to locked
- * modules. If these modules are removed, the filters need to be removed as well,
- * so that they are re-created for the new module objects.
- */
- sword::FilterMap::iterator cipher_it;
- for (cipher_it = cipherFilters.begin(); cipher_it != cipherFilters.end(); cipher_it++)
- {
- //Delete the Filter and remove it from the cleanup list
- cleanupFilters.remove(cipher_it->second);
- delete cipher_it->second;
- }
- cipherFilters.clear();
-
- return true;
+ m_dataModel.clear(true);
+ //BT mods are deleted now, delete Sword mods, too.
+ DeleteMods();
+
+ /* Cipher filters must be handled specially, because SWMgr creates them,
+ * stores them in cipherFilters and cleanupFilters and attaches them to locked
+ * modules. If these modules are removed, the filters need to be removed as well,
+ * so that they are re-created for the new module objects.
+ */
+ sword::FilterMap::iterator cipher_it;
+ for (cipher_it = cipherFilters.begin(); cipher_it != cipherFilters.end(); cipher_it++) {
+ //Delete the Filter and remove it from the cleanup list
+ cleanupFilters.remove(cipher_it->second);
+ delete cipher_it->second;
+ }
+ cipherFilters.clear();
+
+ return true;
}
void CSwordBackend::setOption( const CSwordModuleInfo::FilterTypes type, const int state ) {
- sword::SWBuf value;
+ sword::SWBuf value;
- switch (type) {
+ switch (type) {
- case CSwordModuleInfo::textualVariants:
+ case CSwordModuleInfo::textualVariants:
- if (state == 0) {
- value = "Primary Reading";
- }
- else if (state == 1) {
- value = "Secondary Reading";
- }
- else {
- value = "All Readings";
- }
+ if (state == 0) {
+ value = "Primary Reading";
+ }
+ else if (state == 1) {
+ value = "Secondary Reading";
+ }
+ else {
+ value = "All Readings";
+ }
- break;
+ break;
- default:
- value = state ? "On": "Off";
- break;
- };
+ default:
+ value = state ? "On" : "Off";
+ break;
+ };
- if (value.length())
- setGlobalOption(optionName(type).toUtf8().constData(), value.c_str());
+ if (value.length())
+ setGlobalOption(optionName(type).toUtf8().constData(), value.c_str());
}
void CSwordBackend::setFilterOptions( const CSwordBackend::FilterOptions options) {
- setOption( CSwordModuleInfo::footnotes, options.footnotes );
- setOption( CSwordModuleInfo::strongNumbers, options.strongNumbers );
- setOption( CSwordModuleInfo::headings, options.headings );
- setOption( CSwordModuleInfo::morphTags, options.morphTags );
- setOption( CSwordModuleInfo::lemmas, options.lemmas );
- setOption( CSwordModuleInfo::hebrewPoints, options.hebrewPoints );
- setOption( CSwordModuleInfo::hebrewCantillation, options.hebrewCantillation );
- setOption( CSwordModuleInfo::greekAccents, options.greekAccents );
- setOption( CSwordModuleInfo::redLetterWords, options.redLetterWords );
- setOption( CSwordModuleInfo::textualVariants, options.textualVariants );
- setOption( CSwordModuleInfo::morphSegmentation, options.morphSegmentation );
- // setOption( CSwordModuleInfo::transliteration, options.transliteration );
- setOption( CSwordModuleInfo::scriptureReferences, options.scriptureReferences);
+ setOption( CSwordModuleInfo::footnotes, options.footnotes );
+ setOption( CSwordModuleInfo::strongNumbers, options.strongNumbers );
+ setOption( CSwordModuleInfo::headings, options.headings );
+ setOption( CSwordModuleInfo::morphTags, options.morphTags );
+ setOption( CSwordModuleInfo::lemmas, options.lemmas );
+ setOption( CSwordModuleInfo::hebrewPoints, options.hebrewPoints );
+ setOption( CSwordModuleInfo::hebrewCantillation, options.hebrewCantillation );
+ setOption( CSwordModuleInfo::greekAccents, options.greekAccents );
+ setOption( CSwordModuleInfo::redLetterWords, options.redLetterWords );
+ setOption( CSwordModuleInfo::textualVariants, options.textualVariants );
+ setOption( CSwordModuleInfo::morphSegmentation, options.morphSegmentation );
+ // setOption( CSwordModuleInfo::transliteration, options.transliteration );
+ setOption( CSwordModuleInfo::scriptureReferences, options.scriptureReferences);
}
/** This function searches for a module with the specified description */
CSwordModuleInfo* CSwordBackend::findModuleByDescription(const QString& description) {
- foreach(CSwordModuleInfo* mod, m_moduleList) {
- if (mod->config(CSwordModuleInfo::Description) == description) return mod;
- }
- return 0;
+ Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.modules()) {
+ if (mod->config(CSwordModuleInfo::Description) == description) return mod;
+ }
+ return 0;
}
/** This function searches for a module with the specified description */
const QString CSwordBackend::findModuleNameByDescription(const QString& description) {
- if (m_moduleDescriptionMap.contains(description)) {
- return m_moduleDescriptionMap[description];
- }
- return QString::null;
+ if (m_moduleDescriptionMap.contains(description)) {
+ return m_moduleDescriptionMap[description];
+ }
+ return QString::null;
}
/** This function searches for a module with the specified name */
CSwordModuleInfo* CSwordBackend::findModuleByName(const QString& name) {
- foreach(CSwordModuleInfo* mod, m_moduleList) {
- if (mod->name() == name) return mod;
- }
- return 0;
+ Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.modules()) {
+ if (mod->name() == name) return mod;
+ }
+ return 0;
}
CSwordModuleInfo* CSwordBackend::findSwordModuleByPointer(const sword::SWModule* const swmodule) {
- foreach(CSwordModuleInfo* mod, m_moduleList) {
- if (mod->module() == swmodule ) return mod;
- }
- return 0;
+ Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.modules()) {
+ if (mod->module() == swmodule ) return mod;
+ }
+ return 0;
}
CSwordModuleInfo* CSwordBackend::findModuleByPointer(const CSwordModuleInfo* const module) {
- foreach(CSwordModuleInfo* mod, m_moduleList) {
- if (mod == module) return mod;
- }
- return 0;
+ Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.modules()) {
+ if (mod == module) return mod;
+ }
+ return 0;
}
/** Returns our local config object to store the cipher keys etc. locally for each user. The values of the config are merged with the global config. */
bool CSwordBackend::moduleConfig(const QString& module, sword::SWConfig& moduleConfig) {
- sword::SectionMap::iterator section;
- DIR *dir = opendir(configPath);
-
- struct dirent *ent;
-
- bool foundConfig = false;
- QString modFile;
-
- if (dir) { // find and update .conf file
- rewinddir(dir);
-
- while ((ent = readdir(dir)) && !foundConfig) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- modFile = QString(configPath);
- modFile.append("/");
- modFile.append( QString::fromLocal8Bit(ent->d_name) );
-
- moduleConfig = sword::SWConfig( modFile.toLocal8Bit().constData() );
- section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
- foundConfig = ( section != moduleConfig.Sections.end() );
- }
- }
-
- closedir(dir);
- }
- else { //try to read mods.conf
- moduleConfig = sword::SWConfig("");//global config
- section = config->Sections.find( module.toLocal8Bit().constData() );
- foundConfig = ( section != config->Sections.end() );
-
- sword::ConfigEntMap::iterator entry;
-
- if (foundConfig) { //copy module section
-
- for (entry = section->second.begin(); entry != section->second.end(); entry++) {
- moduleConfig.Sections[section->first].insert(sword::ConfigEntMap::value_type(entry->first, entry->second));
- }
- }
- }
-
- if (!foundConfig && configType != 2) { //search in $HOME/.sword/
-
- QString myPath = util::filesystem::DirectoryUtil::getUserHomeDir().absolutePath();
- myPath.append("/.sword/mods.d");
- dir = opendir(myPath.toUtf8().constData());
-
- if (dir) {
- rewinddir(dir);
-
- while ((ent = readdir(dir)) && !foundConfig) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- modFile = myPath;
- modFile.append('/');
- modFile.append(ent->d_name);
- moduleConfig = sword::SWConfig( modFile.toLocal8Bit().constData() );
- section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
- foundConfig = ( section != moduleConfig.Sections.end() );
- }
- }
-
- closedir(dir);
- }
- }
-
- return foundConfig;
+ sword::SectionMap::iterator section;
+ DIR *dir = opendir(configPath);
+
+ struct dirent *ent;
+
+ bool foundConfig = false;
+ QString modFile;
+
+ if (dir) { // find and update .conf file
+ rewinddir(dir);
+
+ while ((ent = readdir(dir)) && !foundConfig) {
+ if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+ modFile = QString(configPath);
+ modFile.append("/");
+ modFile.append( QString::fromLocal8Bit(ent->d_name) );
+
+ moduleConfig = sword::SWConfig( modFile.toLocal8Bit().constData() );
+ section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
+ foundConfig = ( section != moduleConfig.Sections.end() );
+ }
+ }
+
+ closedir(dir);
+ }
+ else { //try to read mods.conf
+ moduleConfig = sword::SWConfig("");//global config
+ section = config->Sections.find( module.toLocal8Bit().constData() );
+ foundConfig = ( section != config->Sections.end() );
+
+ sword::ConfigEntMap::iterator entry;
+
+ if (foundConfig) { //copy module section
+
+ for (entry = section->second.begin(); entry != section->second.end(); entry++) {
+ moduleConfig.Sections[section->first].insert(sword::ConfigEntMap::value_type(entry->first, entry->second));
+ }
+ }
+ }
+
+ if (!foundConfig && configType != 2) { //search in $HOME/.sword/
+
+ QString myPath = util::filesystem::DirectoryUtil::getUserHomeDir().absolutePath();
+ myPath.append("/.sword/mods.d");
+ dir = opendir(myPath.toUtf8().constData());
+
+ if (dir) {
+ rewinddir(dir);
+
+ while ((ent = readdir(dir)) && !foundConfig) {
+ if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+ modFile = myPath;
+ modFile.append('/');
+ modFile.append(ent->d_name);
+ moduleConfig = sword::SWConfig( modFile.toLocal8Bit().constData() );
+ section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
+ foundConfig = ( section != moduleConfig.Sections.end() );
+ }
+ }
+
+ closedir(dir);
+ }
+ }
+
+ return foundConfig;
}
/** Returns the text used for the option given as parameter. */
const QString CSwordBackend::optionName( const CSwordModuleInfo::FilterTypes option ) {
- switch (option) {
- case CSwordModuleInfo::footnotes: return QString("Footnotes");
- case CSwordModuleInfo::strongNumbers: return QString("Strong's Numbers");
- case CSwordModuleInfo::headings: return QString("Headings");
- case CSwordModuleInfo::morphTags: return QString("Morphological Tags");
- case CSwordModuleInfo::lemmas: return QString("Lemmas");
- case CSwordModuleInfo::hebrewPoints: return QString("Hebrew Vowel Points");
- case CSwordModuleInfo::hebrewCantillation: return QString("Hebrew Cantillation");
- case CSwordModuleInfo::greekAccents: return QString("Greek Accents");
- case CSwordModuleInfo::redLetterWords: return QString("Words of Christ in Red");
- case CSwordModuleInfo::textualVariants: return QString("Textual Variants");
- case CSwordModuleInfo::scriptureReferences: return QString("Cross-references");
- case CSwordModuleInfo::morphSegmentation: return QString("Morph Segmentation");
- }
- return QString::null;
+ switch (option) {
+ case CSwordModuleInfo::footnotes:
+ return QString("Footnotes");
+ case CSwordModuleInfo::strongNumbers:
+ return QString("Strong's Numbers");
+ case CSwordModuleInfo::headings:
+ return QString("Headings");
+ case CSwordModuleInfo::morphTags:
+ return QString("Morphological Tags");
+ case CSwordModuleInfo::lemmas:
+ return QString("Lemmas");
+ case CSwordModuleInfo::hebrewPoints:
+ return QString("Hebrew Vowel Points");
+ case CSwordModuleInfo::hebrewCantillation:
+ return QString("Hebrew Cantillation");
+ case CSwordModuleInfo::greekAccents:
+ return QString("Greek Accents");
+ case CSwordModuleInfo::redLetterWords:
+ return QString("Words of Christ in Red");
+ case CSwordModuleInfo::textualVariants:
+ return QString("Textual Variants");
+ case CSwordModuleInfo::scriptureReferences:
+ return QString("Cross-references");
+ case CSwordModuleInfo::morphSegmentation:
+ return QString("Morph Segmentation");
+ }
+ return QString::null;
}
/** Returns the translated name of the option given as parameter. */
const QString CSwordBackend::translatedOptionName(const CSwordModuleInfo::FilterTypes option) {
- switch (option) {
- case CSwordModuleInfo::footnotes: return QObject::tr("Footnotes");
- case CSwordModuleInfo::strongNumbers: return QObject::tr