summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:35 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:35 -0400
commitdf8f1d512c60a96f9041f9663b3fdc2db51cba33 (patch)
tree3d2bdbd4732d417aca73be022ae9044eac96b7d3 /src
parent4885bfcef4d89cf0cb391e00af617b9fd19c9cbb (diff)
Imported Upstream version 2.8.1
Diffstat (limited to 'src')
-rw-r--r--src/backend/bookshelfmodel/btbookshelffiltermodel.cpp23
-rw-r--r--src/backend/bookshelfmodel/btbookshelffiltermodel.h2
-rw-r--r--src/backend/bookshelfmodel/btbookshelfmodel.cpp125
-rw-r--r--src/backend/bookshelfmodel/btbookshelfmodel.h110
-rw-r--r--src/backend/bookshelfmodel/btbookshelftreemodel.cpp79
-rw-r--r--src/backend/bookshelfmodel/btbookshelftreemodel.h64
-rw-r--r--src/backend/bookshelfmodel/categoryitem.cpp6
-rw-r--r--src/backend/bookshelfmodel/categoryitem.h2
-rw-r--r--src/backend/bookshelfmodel/indexingitem.cpp2
-rw-r--r--src/backend/bookshelfmodel/indexingitem.h2
-rw-r--r--src/backend/bookshelfmodel/item.cpp2
-rw-r--r--src/backend/bookshelfmodel/item.h2
-rw-r--r--src/backend/bookshelfmodel/languageitem.cpp4
-rw-r--r--src/backend/bookshelfmodel/languageitem.h2
-rw-r--r--src/backend/bookshelfmodel/moduleitem.cpp2
-rw-r--r--src/backend/bookshelfmodel/moduleitem.h8
-rw-r--r--src/backend/btinstallbackend.cpp (renamed from src/frontend/bookshelfmanager/instbackend.cpp)43
-rw-r--r--src/backend/btinstallbackend.h (renamed from src/frontend/bookshelfmanager/instbackend.h)25
-rw-r--r--src/backend/btmoduletreeitem.cpp7
-rw-r--r--src/backend/btmoduletreeitem.h42
-rw-r--r--src/backend/config/cbtconfig.cpp50
-rw-r--r--src/backend/config/cbtconfig.h19
-rw-r--r--src/backend/cswordmodulesearch.cpp101
-rw-r--r--src/backend/cswordmodulesearch.h99
-rw-r--r--src/backend/drivers/cswordbiblemoduleinfo.cpp190
-rw-r--r--src/backend/drivers/cswordbiblemoduleinfo.h140
-rw-r--r--src/backend/drivers/cswordbookmoduleinfo.cpp37
-rw-r--r--src/backend/drivers/cswordbookmoduleinfo.h64
-rw-r--r--src/backend/drivers/cswordcommentarymoduleinfo.cpp27
-rw-r--r--src/backend/drivers/cswordcommentarymoduleinfo.h46
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.cpp92
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.h73
-rw-r--r--src/backend/drivers/cswordmoduleinfo.cpp422
-rw-r--r--src/backend/drivers/cswordmoduleinfo.h275
-rw-r--r--src/backend/filters/bt_gbfhtml.h50
-rw-r--r--src/backend/filters/bt_osishtml.h70
-rw-r--r--src/backend/filters/bt_plainhtml.h34
-rw-r--r--src/backend/filters/bt_teihtml.h34
-rw-r--r--src/backend/filters/bt_thmlhtml.h54
-rw-r--r--src/backend/filters/bt_thmlplain.h30
-rw-r--r--src/backend/filters/gbftohtml.cpp (renamed from src/backend/filters/bt_gbfhtml.cpp)19
-rw-r--r--src/backend/filters/gbftohtml.h61
-rw-r--r--src/backend/filters/osismorphsegmentation.cpp4
-rw-r--r--src/backend/filters/osismorphsegmentation.h2
-rw-r--r--src/backend/filters/osistohtml.cpp (renamed from src/backend/filters/bt_osishtml.cpp)56
-rw-r--r--src/backend/filters/osistohtml.h75
-rw-r--r--src/backend/filters/plaintohtml.cpp (renamed from src/backend/filters/bt_plainhtml.cpp)8
-rw-r--r--src/backend/filters/plaintohtml.h40
-rw-r--r--src/backend/filters/teitohtml.cpp (renamed from src/backend/filters/bt_teihtml.cpp)25
-rw-r--r--src/backend/filters/teitohtml.h37
-rw-r--r--src/backend/filters/thmltohtml.cpp (renamed from src/backend/filters/bt_thmlhtml.cpp)25
-rw-r--r--src/backend/filters/thmltohtml.h62
-rw-r--r--src/backend/filters/thmltoplain.cpp (renamed from src/backend/filters/bt_thmlplain.cpp)24
-rw-r--r--src/backend/filters/thmltoplain.h33
-rw-r--r--src/backend/keys/cswordkey.cpp74
-rw-r--r--src/backend/keys/cswordkey.h91
-rw-r--r--src/backend/keys/cswordldkey.cpp40
-rw-r--r--src/backend/keys/cswordldkey.h36
-rw-r--r--src/backend/keys/cswordtreekey.cpp41
-rw-r--r--src/backend/keys/cswordtreekey.h35
-rw-r--r--src/backend/keys/cswordversekey.cpp112
-rw-r--r--src/backend/keys/cswordversekey.h55
-rw-r--r--src/backend/managers/btstringmgr.cpp2
-rw-r--r--src/backend/managers/btstringmgr.h2
-rw-r--r--src/backend/managers/cdisplaytemplatemgr.cpp69
-rw-r--r--src/backend/managers/cdisplaytemplatemgr.h119
-rw-r--r--src/backend/managers/clanguagemgr.cpp28
-rw-r--r--src/backend/managers/clanguagemgr.h57
-rw-r--r--src/backend/managers/cswordbackend.cpp197
-rw-r--r--src/backend/managers/cswordbackend.h173
-rw-r--r--src/backend/managers/referencemanager.cpp46
-rw-r--r--src/backend/managers/referencemanager.h17
-rw-r--r--src/backend/rendering/cbookdisplay.cpp32
-rw-r--r--src/backend/rendering/cbookdisplay.h39
-rw-r--r--src/backend/rendering/cchapterdisplay.cpp21
-rw-r--r--src/backend/rendering/cchapterdisplay.h29
-rw-r--r--src/backend/rendering/cdisplayrendering.cpp24
-rw-r--r--src/backend/rendering/cdisplayrendering.h10
-rw-r--r--src/backend/rendering/centrydisplay.cpp16
-rw-r--r--src/backend/rendering/centrydisplay.h27
-rw-r--r--src/backend/rendering/chtmlexportrendering.cpp85
-rw-r--r--src/backend/rendering/chtmlexportrendering.h18
-rw-r--r--src/backend/rendering/cplaintextexportrendering.cpp32
-rw-r--r--src/backend/rendering/cplaintextexportrendering.h10
-rw-r--r--src/backend/rendering/ctextrendering.cpp90
-rw-r--r--src/backend/rendering/ctextrendering.h49
-rw-r--r--src/bibletime.cpp204
-rw-r--r--src/bibletime.h277
-rw-r--r--src/bibletime_dbus.cpp21
-rw-r--r--src/bibletime_dbus_adaptor.cpp2
-rw-r--r--src/bibletime_dbus_adaptor.h12
-rw-r--r--src/bibletime_init.cpp800
-rw-r--r--src/bibletime_slots.cpp276
-rw-r--r--src/bibletimeapp.cpp32
-rw-r--r--src/bibletimeapp.h21
-rw-r--r--src/btglobal.h53
-rw-r--r--src/frontend/bookmarks/btbookmarkfolder.cpp (renamed from src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp)22
-rw-r--r--src/frontend/bookmarks/btbookmarkfolder.h (renamed from src/frontend/mainindex/bookmarks/btbookmarkfolder.h)8
-rw-r--r--src/frontend/bookmarks/btbookmarkitem.cpp149
-rw-r--r--src/frontend/bookmarks/btbookmarkitem.h (renamed from src/frontend/mainindex/bookmarks/btbookmarkitem.h)30
-rw-r--r--src/frontend/bookmarks/btbookmarkitembase.cpp21
-rw-r--r--src/frontend/bookmarks/btbookmarkitembase.h (renamed from src/frontend/mainindex/bookmarks/btbookmarkitembase.h)9
-rw-r--r--src/frontend/bookmarks/btbookmarkloader.cpp (renamed from src/frontend/mainindex/bookmarks/btbookmarkloader.cpp)19
-rw-r--r--src/frontend/bookmarks/btbookmarkloader.h (renamed from src/frontend/mainindex/bookmarks/btbookmarkloader.h)2
-rw-r--r--src/frontend/bookmarks/bteditbookmarkdialog.cpp78
-rw-r--r--src/frontend/bookmarks/bteditbookmarkdialog.h62
-rw-r--r--src/frontend/bookmarks/cbookmarkindex.cpp (renamed from src/frontend/mainindex/bookmarks/cbookmarkindex.cpp)88
-rw-r--r--src/frontend/bookmarks/cbookmarkindex.h (renamed from src/frontend/mainindex/bookmarks/cbookmarkindex.h)17
-rw-r--r--src/frontend/bookshelfmanager/btconfigdialog.cpp48
-rw-r--r--src/frontend/bookshelfmanager/btconfigdialog.h33
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.cpp9
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.h41
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp12
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.h4
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp15
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h2
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.cpp59
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.h27
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp164
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h50
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp136
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h44
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.cpp423
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.h65
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp87
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h33
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp140
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h59
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp21
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h2
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp117
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h9
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.cpp28
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.h12
-rw-r--r--src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp62
-rw-r--r--src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h38
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcearea.cpp282
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcearea.h96
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp399
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcewidget.h86
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.cpp143
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.h33
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp7
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h4
-rw-r--r--src/frontend/btaboutdialog.cpp274
-rw-r--r--src/frontend/btaboutdialog.h49
-rw-r--r--src/frontend/btaboutmoduledialog.cpp38
-rw-r--r--src/frontend/btaboutmoduledialog.h18
-rw-r--r--src/frontend/btbookshelfdockwidget.cpp323
-rw-r--r--src/frontend/btbookshelfdockwidget.h67
-rw-r--r--src/frontend/btbookshelfgroupingmenu.cpp113
-rw-r--r--src/frontend/btbookshelfgroupingmenu.h53
-rw-r--r--src/frontend/btbookshelfview.cpp (renamed from src/frontend/mainindex/btbookshelfview.cpp)10
-rw-r--r--src/frontend/btbookshelfview.h (renamed from src/frontend/mainindex/btbookshelfview.h)2
-rw-r--r--src/frontend/btbookshelfwidget.cpp203
-rw-r--r--src/frontend/btbookshelfwidget.h116
-rw-r--r--src/frontend/btmenuview.cpp227
-rw-r--r--src/frontend/btmenuview.h107
-rw-r--r--src/frontend/btmodulechooserdialog.cpp65
-rw-r--r--src/frontend/btmodulechooserdialog.h48
-rw-r--r--src/frontend/btmoduleindexdialog.cpp103
-rw-r--r--src/frontend/btmoduleindexdialog.h65
-rw-r--r--src/frontend/btopenworkaction.cpp111
-rw-r--r--src/frontend/btopenworkaction.h82
-rw-r--r--src/frontend/cdragdrop.cpp11
-rw-r--r--src/frontend/cdragdrop.h34
-rw-r--r--src/frontend/cexportmanager.cpp165
-rw-r--r--src/frontend/cexportmanager.h76
-rw-r--r--src/frontend/cinfodisplay.cpp82
-rw-r--r--src/frontend/cinfodisplay.h4
-rw-r--r--src/frontend/cinputdialog.cpp88
-rw-r--r--src/frontend/cinputdialog.h41
-rw-r--r--src/frontend/cmdiarea.cpp91
-rw-r--r--src/frontend/cmdiarea.h16
-rw-r--r--src/frontend/cmodulechooserdialog.cpp147
-rw-r--r--src/frontend/cmodulechooserdialog.h107
-rw-r--r--src/frontend/cmoduleindexdialog.cpp99
-rw-r--r--src/frontend/cmoduleindexdialog.h56
-rw-r--r--src/frontend/cprinter.cpp25
-rw-r--r--src/frontend/cprinter.h11
-rw-r--r--src/frontend/crossrefrendering.cpp18
-rw-r--r--src/frontend/crossrefrendering.h10
-rw-r--r--src/frontend/display/btcolorwidget.cpp2
-rw-r--r--src/frontend/display/btcolorwidget.h5
-rw-r--r--src/frontend/display/btfontsizewidget.cpp6
-rw-r--r--src/frontend/display/btfontsizewidget.h6
-rw-r--r--src/frontend/display/bthtml.js2
-rw-r--r--src/frontend/display/bthtmlfindtext.cpp6
-rw-r--r--src/frontend/display/bthtmlfindtext.h3
-rw-r--r--src/frontend/display/bthtmlfindtext.ui2
-rw-r--r--src/frontend/display/bthtmljsobject.cpp26
-rw-r--r--src/frontend/display/bthtmljsobject.h7
-rw-r--r--src/frontend/display/bthtmlreaddisplay.cpp102
-rw-r--r--src/frontend/display/bthtmlreaddisplay.h7
-rw-r--r--src/frontend/display/cdisplay.cpp13
-rw-r--r--src/frontend/display/cdisplay.h22
-rw-r--r--src/frontend/display/chtmlwritedisplay.cpp176
-rw-r--r--src/frontend/display/chtmlwritedisplay.h16
-rw-r--r--src/frontend/display/cplainwritedisplay.cpp25
-rw-r--r--src/frontend/display/cplainwritedisplay.h20
-rw-r--r--src/frontend/display/creaddisplay.cpp12
-rw-r--r--src/frontend/display/creaddisplay.h8
-rw-r--r--src/frontend/display/cwritedisplay.cpp2
-rw-r--r--src/frontend/display/cwritedisplay.h2
-rw-r--r--src/frontend/displaywindow/btactioncollection.cpp20
-rw-r--r--src/frontend/displaywindow/btactioncollection.h2
-rw-r--r--src/frontend/displaywindow/btdisplaysettingsbutton.cpp14
-rw-r--r--src/frontend/displaywindow/btdisplaysettingsbutton.h22
-rw-r--r--src/frontend/displaywindow/btmodulechooserbar.cpp39
-rw-r--r--src/frontend/displaywindow/btmodulechooserbar.h21
-rw-r--r--src/frontend/displaywindow/btmodulechooserbutton.cpp3
-rw-r--r--src/frontend/displaywindow/btmodulechooserbutton.h2
-rw-r--r--src/frontend/displaywindow/bttextwindowheader.cpp19
-rw-r--r--src/frontend/displaywindow/bttextwindowheader.h19
-rw-r--r--src/frontend/displaywindow/bttextwindowheaderwidget.cpp3
-rw-r--r--src/frontend/displaywindow/bttextwindowheaderwidget.h2
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.cpp15
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.h5
-rw-r--r--src/frontend/displaywindow/btwindowmodulechooser.h12
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.cpp47
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.h4
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.cpp59
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.h4
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.cpp35
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.h4
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.cpp161
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.h120
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.cpp33
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.h6
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.cpp105
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.h35
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.cpp68
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.h27
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.cpp172
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.h28
-rw-r--r--src/frontend/displaywindow/creadwindow.cpp15
-rw-r--r--src/frontend/displaywindow/creadwindow.h18
-rw-r--r--src/frontend/displaywindow/cwritewindow.cpp10
-rw-r--r--src/frontend/displaywindow/cwritewindow.h33
-rw-r--r--src/frontend/htmldialogs/btaboutdialog.cpp249
-rw-r--r--src/frontend/htmldialogs/btaboutdialog.h29
-rw-r--r--src/frontend/htmldialogs/bttabhtmldialog.cpp125
-rw-r--r--src/frontend/htmldialogs/bttabhtmldialog.h87
-rw-r--r--src/frontend/keychooser/bthistory.cpp4
-rw-r--r--src/frontend/keychooser/bthistory.h2
-rw-r--r--src/frontend/keychooser/cbookkeychooser.cpp34
-rw-r--r--src/frontend/keychooser/cbookkeychooser.h16
-rw-r--r--src/frontend/keychooser/cbooktreechooser.cpp34
-rw-r--r--src/frontend/keychooser/cbooktreechooser.h35
-rw-r--r--src/frontend/keychooser/ckeychooser.cpp52
-rw-r--r--src/frontend/keychooser/ckeychooser.h57
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.cpp12
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.h23
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.cpp67
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.h34
-rw-r--r--src/frontend/keychooser/cscrollbutton.cpp2
-rw-r--r--src/frontend/keychooser/cscrollbutton.h8
-rw-r--r--src/frontend/keychooser/cscrollerwidgetset.cpp2
-rw-r--r--src/frontend/keychooser/cscrollerwidgetset.h7
-rw-r--r--src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp (renamed from src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp)84
-rw-r--r--src/frontend/keychooser/versekeychooser/btbiblekeywidget.h (renamed from src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h)28
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp14
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h16
-rw-r--r--src/frontend/keychooser/versekeychooser/btversekeymenu.cpp2
-rw-r--r--src/frontend/keychooser/versekeychooser/btversekeymenu.h2
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp51
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.h33
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkitem.cpp150
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkitembase.cpp39
-rw-r--r--src/frontend/profile/cprofile.cpp2
-rw-r--r--src/frontend/profile/cprofile.h2
-rw-r--r--src/frontend/profile/cprofilemgr.cpp4
-rw-r--r--src/frontend/profile/cprofilemgr.h4
-rw-r--r--src/frontend/profile/cprofilewindow.cpp2
-rw-r--r--src/frontend/profile/cprofilewindow.h2
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp14
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.h13
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.cpp36
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.h13
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp13
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.h19
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.cpp80
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.h22
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.cpp2
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.h12
-rw-r--r--src/frontend/searchdialog/btsearchmodulechooserdialog.cpp58
-rw-r--r--src/frontend/searchdialog/btsearchmodulechooserdialog.h45
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.cpp188
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.h15
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.cpp245
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.h145
-rw-r--r--src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp229
-rw-r--r--src/frontend/searchdialog/btsearchsyntaxhelpdialog.h40
-rw-r--r--src/frontend/searchdialog/chistorycombobox.cpp2
-rw-r--r--src/frontend/searchdialog/chistorycombobox.h2
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.cpp130
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.h22
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.cpp2
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.h2
-rw-r--r--src/frontend/searchdialog/csearchdialog.cpp135
-rw-r--r--src/frontend/searchdialog/csearchdialog.h62
-rw-r--r--src/frontend/searchdialog/csearchmodulechooserdialog.cpp56
-rw-r--r--src/frontend/searchdialog/csearchmodulechooserdialog.h38
-rw-r--r--src/frontend/searchdialog/csearchresultview.cpp61
-rw-r--r--src/frontend/searchdialog/csearchresultview.h27
-rw-r--r--src/frontend/settingsdialogs/btfontsettings.cpp164
-rw-r--r--src/frontend/settingsdialogs/btfontsettings.h (renamed from src/frontend/settingsdialogs/clanguagesettings.h)30
-rw-r--r--src/frontend/settingsdialogs/btlanguagesettings.cpp145
-rw-r--r--src/frontend/settingsdialogs/btlanguagesettings.h60
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.cpp3
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.h2
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.cpp6
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.h4
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.cpp41
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.h16
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.cpp16
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.h8
-rw-r--r--src/frontend/settingsdialogs/cdisplaysettings.cpp37
-rw-r--r--src/frontend/settingsdialogs/cdisplaysettings.h13
-rw-r--r--src/frontend/settingsdialogs/cfontchooser.cpp2
-rw-r--r--src/frontend/settingsdialogs/cfontchooser.h2
-rw-r--r--src/frontend/settingsdialogs/clanguagesettings.cpp266
-rw-r--r--src/frontend/settingsdialogs/clistwidget.cpp2
-rw-r--r--src/frontend/settingsdialogs/clistwidget.h2
-rw-r--r--src/frontend/settingsdialogs/cswordsettings.cpp50
-rw-r--r--src/frontend/settingsdialogs/cswordsettings.h17
-rw-r--r--src/frontend/tips/bttipdialog.cpp193
-rw-r--r--src/frontend/tips/bttipdialog.h62
-rw-r--r--src/main.cpp187
-rw-r--r--src/tests/backend/config/cbtconfig_test.cpp34
-rw-r--r--src/tests/bibletime_test.cpp20
-rw-r--r--src/tests/bibletime_test.h28
-rw-r--r--src/util/btsignal.h40
-rw-r--r--src/util/cpointers.cpp53
-rw-r--r--src/util/cpointers.h115
-rw-r--r--src/util/cresmgr.cpp59
-rw-r--r--src/util/cresmgr.h24
-rw-r--r--src/util/dialogutil.cpp3
-rw-r--r--src/util/dialogutil.h2
-rw-r--r--src/util/directory.cpp122
-rw-r--r--src/util/directory.h58
-rw-r--r--src/util/exceptions.h2
-rw-r--r--src/util/macros.h61
-rw-r--r--src/util/migrationutil.cpp92
-rw-r--r--src/util/migrationutil.h38
-rw-r--r--src/util/tool.cpp185
-rw-r--r--src/util/tool.h51
347 files changed, 10941 insertions, 8822 deletions
diff --git a/src/backend/bookshelfmodel/btbookshelffiltermodel.cpp b/src/backend/bookshelfmodel/btbookshelffiltermodel.cpp
index b896556..182d337 100644
--- a/src/backend/bookshelfmodel/btbookshelffiltermodel.cpp
+++ b/src/backend/bookshelfmodel/btbookshelffiltermodel.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -25,7 +25,7 @@ BtBookshelfFilterModel::BtBookshelfFilterModel(QObject *parent)
m_categoryFilterRole(BtBookshelfModel::ModuleCategoryRole),
m_categoryFilterColumn(0)
{
- // Intentionally empty
+ setDynamicSortFilter(true);
}
BtBookshelfFilterModel::~BtBookshelfFilterModel() {
@@ -125,16 +125,13 @@ bool BtBookshelfFilterModel::filterAcceptsRow(int row,
return true;
}
-bool BtBookshelfFilterModel::nameFilterAcceptsRow(int row, const QModelIndex &p)
- const
-{
- if (!m_enabled) return true;
+bool BtBookshelfFilterModel::nameFilterAcceptsRow(int row, const QModelIndex &parent) const {
if (m_nameFilter.isEmpty()) return true;
const QAbstractItemModel *m(sourceModel());
Q_ASSERT(m != 0);
- QModelIndex itemIndex(m->index(row, m_nameFilterColumn, p));
+ QModelIndex itemIndex(m->index(row, m_nameFilterColumn, parent));
int numChildren(m->rowCount(itemIndex));
if (numChildren == 0) {
QVariant data(m->data(itemIndex, m_nameFilterRole));
@@ -148,14 +145,14 @@ bool BtBookshelfFilterModel::nameFilterAcceptsRow(int row, const QModelIndex &p)
}
}
-bool BtBookshelfFilterModel::hiddenFilterAcceptsRow(int row,
- const QModelIndex &parent) const
+bool BtBookshelfFilterModel::hiddenFilterAcceptsRow(int row, const QModelIndex &parent) const
{
if (m_showHidden && m_showShown) return true;
typedef Qt::CheckState CS;
QAbstractItemModel *m(sourceModel());
+ Q_ASSERT(m != 0);
QModelIndex itemIndex(m->index(row, m_hiddenFilterColumn, parent));
int numChildren(m->rowCount(itemIndex));
@@ -181,17 +178,13 @@ bool BtBookshelfFilterModel::categoryFilterAcceptsRow(int row,
if (m_categoryFilter == CSwordModuleInfo::AllCategories) return true;
QAbstractItemModel *m(sourceModel());
+ Q_ASSERT(m != 0);
QModelIndex itemIndex(m->index(row, m_categoryFilterColumn, parent));
int numChildren(m->rowCount(itemIndex));
if (numChildren == 0) {
int cat = m->data(itemIndex, m_categoryFilterRole).toInt();
- if (m_categoryFilter.testFlag((CSwordModuleInfo::Category) cat)) {
- return true;
- }
- else {
- return false;
- }
+ return m_categoryFilter.testFlag((CSwordModuleInfo::Category) cat);
}
else {
for (int i(0); i < numChildren; i++) {
diff --git a/src/backend/bookshelfmodel/btbookshelffiltermodel.h b/src/backend/bookshelfmodel/btbookshelffiltermodel.h
index e440c69..55322ed 100644
--- a/src/backend/bookshelfmodel/btbookshelffiltermodel.h
+++ b/src/backend/bookshelfmodel/btbookshelffiltermodel.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/backend/bookshelfmodel/btbookshelfmodel.cpp b/src/backend/bookshelfmodel/btbookshelfmodel.cpp
index ccbb5a5..c6aab1b 100644
--- a/src/backend/bookshelfmodel/btbookshelfmodel.cpp
+++ b/src/backend/bookshelfmodel/btbookshelfmodel.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -12,9 +12,9 @@
#include "backend/bookshelfmodel/btbookshelfmodel.h"
+#include <QIcon>
#include <QSet>
-#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/macros.h"
BtBookshelfModel::BtBookshelfModel(QObject *parent)
@@ -37,7 +37,7 @@ QVariant BtBookshelfModel::data(CSwordModuleInfo *module, int role) const {
case ModuleNameRole: // Qt::DisplayRole
return module->name();
case ModuleIconRole: // Qt::DecorationRole
- return moduleIcon(module);
+ return CSwordModuleInfo::moduleIcon(module);
case ModulePointerRole:
return qVariantFromValue((void*) module);
case ModuleCategoryRole:
@@ -52,6 +52,8 @@ QVariant BtBookshelfModel::data(CSwordModuleInfo *module, int role) const {
return module->hasIndex();
case ModuleIndexSizeRole:
return (qulonglong) module->indexSize();
+ case ModuleDescriptionRole:
+ return module->config(CSwordModuleInfo::Description);
default:
return QVariant();
}
@@ -93,107 +95,6 @@ bool BtBookshelfModel::setData(const QModelIndex &index, const QVariant &value,
return false;
}
-QIcon BtBookshelfModel::moduleIcon(const CSwordModuleInfo *m) {
- namespace DU = util::directory;
-
- /// \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) {
- namespace DU = util::directory;
-
- switch (category) {
- case CSwordModuleInfo::Bibles:
- return DU::getIcon(CResMgr::categories::bibles::icon);
- case CSwordModuleInfo::Commentaries:
- return DU::getIcon(CResMgr::categories::commentaries::icon);
- case CSwordModuleInfo::Books:
- return DU::getIcon(CResMgr::categories::books::icon);
- case CSwordModuleInfo::Cult:
- return DU::getIcon(CResMgr::categories::cults::icon);
- case CSwordModuleInfo::Images:
- return DU::getIcon(CResMgr::categories::images::icon);
- case CSwordModuleInfo::DailyDevotional:
- return DU::getIcon(CResMgr::categories::dailydevotional::icon);
- case CSwordModuleInfo::Lexicons:
- return DU::getIcon(CResMgr::categories::lexicons::icon);
- case CSwordModuleInfo::Glossary:
- return DU::getIcon(CResMgr::categories::glossary::icon);
- case CSwordModuleInfo::UnknownCategory:
- default:
- return QIcon();
- }
-}
-
-QString BtBookshelfModel::categoryName(
- const CSwordModuleInfo::Category &category) {
- switch (category) {
- case CSwordModuleInfo::Bibles:
- return tr("Bibles");
- case CSwordModuleInfo::Commentaries:
- return tr("Commentaries");
- case CSwordModuleInfo::Books:
- return tr("Books");
- case CSwordModuleInfo::Cult:
- return tr("Cults/Unorthodox");
- case CSwordModuleInfo::Images:
- return tr("Maps and Images");
- case CSwordModuleInfo::DailyDevotional:
- return tr("Daily Devotionals");
- case CSwordModuleInfo::Lexicons:
- return tr("Lexicons and Dictionaries");
- case CSwordModuleInfo::Glossary:
- return tr("Glossaries");
- default:
- return tr("Unknown");
- }
-}
-
-QString BtBookshelfModel::languageName(
- const CLanguageMgr::Language *language) {
- return language->translatedName();
-}
-
void BtBookshelfModel::clear(bool destroy) {
if (m_data.size() <= 0) return;
@@ -217,6 +118,8 @@ void BtBookshelfModel::addModule(CSwordModuleInfo * const module) {
this, SLOT(moduleHidden(bool)));
connect(module, SIGNAL(hasIndexChanged(bool)),
this, SLOT(moduleIndexed(bool)));
+ connect(module, SIGNAL(unlockedChanged(bool)),
+ this, SLOT(moduleUnlocked(bool)));
endInsertRows();
}
@@ -242,6 +145,8 @@ void BtBookshelfModel::addModules(const QSet<CSwordModuleInfo *> &modules) {
this, SLOT(moduleHidden(bool)));
connect(module, SIGNAL(hasIndexChanged(bool)),
this, SLOT(moduleIndexed(bool)));
+ connect(module, SIGNAL(unlockedChanged(bool)),
+ this, SLOT(moduleUnlocked(bool)));
}
endInsertRows();
}
@@ -256,6 +161,8 @@ void BtBookshelfModel::removeModule(CSwordModuleInfo * const module,
this, SLOT(moduleHidden(bool)));
disconnect(module, SIGNAL(hasIndexChanged(bool)),
this, SLOT(moduleIndexed(bool)));
+ disconnect(module, SIGNAL(unlockedChanged(bool)),
+ this, SLOT(moduleUnlocked(bool)));
m_data.removeAt(index);
endRemoveRows();
if (destroy) delete module;
@@ -276,7 +183,7 @@ void BtBookshelfModel::removeModules(const QSet<CSwordModuleInfo *> &modules,
CSwordModuleInfo* BtBookshelfModel::getModule(const QString &name) const {
Q_FOREACH(CSwordModuleInfo *module, m_data) {
- if (module->name() == name) return module;
+ if (UNLIKELY(module->name() == name)) return module;
}
return 0;
}
@@ -293,6 +200,12 @@ void BtBookshelfModel::moduleIndexed(bool) {
moduleDataChanged(static_cast<CSwordModuleInfo*>(sender()));
}
+void BtBookshelfModel::moduleUnlocked(bool) {
+ Q_ASSERT(qobject_cast<CSwordModuleInfo*>(sender()) != 0);
+
+ moduleDataChanged(static_cast<CSwordModuleInfo*>(sender()));
+}
+
void BtBookshelfModel::moduleDataChanged(CSwordModuleInfo *module) {
Q_ASSERT(m_data.count(module) == 1);
diff --git a/src/backend/bookshelfmodel/btbookshelfmodel.h b/src/backend/bookshelfmodel/btbookshelfmodel.h
index 735c655..20f2b3d 100644
--- a/src/backend/bookshelfmodel/btbookshelfmodel.h
+++ b/src/backend/bookshelfmodel/btbookshelfmodel.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -18,6 +18,12 @@
#include "backend/drivers/cswordmoduleinfo.h"
+/**
+ Implements a simple list model projecting CSwordModuleInfo instances. This model is mostly
+ implemented to provide an interface the the underlying data and to provide notifications
+ when modules are added, removed or changed. If you want to use a model for widgets, the
+ BtBookshelfTreeModel might be a better choice, since it also provides sorting and grouping.
+*/
class BtBookshelfModel: public QAbstractListModel {
Q_OBJECT
public:
@@ -31,55 +37,135 @@ class BtBookshelfModel: public QAbstractListModel {
ModuleInstallPathRole = Qt::UserRole + 4,
ModuleHasIndexRole = Qt::UserRole + 5,
ModuleIndexSizeRole = Qt::UserRole + 6,
+ ModuleDescriptionRole = Qt::UserRole + 7,
UserRole = Qt::UserRole + 100
};
+ public:
BtBookshelfModel(QObject *parent = 0);
- virtual ~BtBookshelfModel();
+ ~BtBookshelfModel();
- virtual int rowCount(const QModelIndex &parent) const;
- virtual QVariant data(CSwordModuleInfo *module, int role) const;
- virtual QVariant data(const QModelIndex &index, int role) const;
- virtual QVariant headerData(int section, Qt::Orientation orientation,
+ // Virtual methods implemented from QAbstractListModel:
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(CSwordModuleInfo *module, int role) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value,
int role = ModuleHiddenRole);
+ /**
+ Given an index of this model, this method returns a pointer to the underlying
+ CSwordModuleInfo instance corresponding to the given index.
+ \param[in] index An index to this model.
+ */
inline CSwordModuleInfo *module(const QModelIndex &index) const {
return (CSwordModuleInfo *)
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);
-
+ /**
+ Clears the data of the whole model by removing all items.
+ \param[in] destroy If true, all CSwordModuleInfo instances in this model are also
+ destroyed.
+ */
void clear(bool destroy = false);
+
+ /**
+ Appends the given module to this model.
+ \param[in] module Module to add.
+ */
void addModule(CSwordModuleInfo * const module);
+
+ /**
+ Appends the all the modules in the given set to this model.
+ \param[in] modules Set of modules to add.
+ */
void addModules(const QSet<CSwordModuleInfo *> &modules);
+
+ /**
+ Appends the all the modules in the given list to this model.
+ \param[in] modules Set of modules to add.
+ */
void addModules(const QList<CSwordModuleInfo *> &modules);
+
+ /**
+ Removes the given module from this model and optionally destroys it.
+ \param[in] module The module to remove from this model.
+ \param[in] destroy If true, the given CSwordModuleInfo instance is destroyed.
+ */
void removeModule(CSwordModuleInfo * const module,
bool destroy = false);
+
+ /**
+ Removes all modules from the given set from this model and optionally destroys
+ them.
+ \param[in] modules The set of modules to remove from this model.
+ \param[in] destroy If true, the given CSwordModuleInfo instances are destroyed.
+ */
void removeModules(const QSet<CSwordModuleInfo *> &modules,
bool destroy = false);
+
+ /**
+ Removes all modules from the given list from this model and optionally destroys
+ them.
+ \param[in] modules The list of modules to remove from this model.
+ \param[in] destroy If true, the given CSwordModuleInfo instances are destroyed.
+ */
void removeModules(const QList<CSwordModuleInfo *> &modules,
bool destroy = false);
+ /**
+ Returns the first module found with the given name.
+ \param[in] name Name of the module to find.
+ */
CSwordModuleInfo* getModule(const QString &name) const;
- inline const QList<CSwordModuleInfo *> &modules() const {
+
+ /**
+ Returns the list of handled modules as a list of CSwordModuleInfo* pointers.
+ */
+ inline const QList<CSwordModuleInfo *> &moduleList() const {
return m_data;
}
protected slots:
+ /**
+ Slot DIRECTLY called by CSwordModuleInfo when the hidden status of the respective
+ module changes.
+ \param[in] hidden True, if the module was hidden; false, if the module was shown.
+ */
void moduleHidden(bool hidden);
+
+ /**
+ Slot DIRECTLY called by CSwordModuleInfo when the indexed status of the respective
+ module changes.
+ \param[in] indexed True, if the module was indexed; false if the index was deleted.
+ */
void moduleIndexed(bool indexed);
+ /**
+ Slot DIRECTLY called by CSwordModuleInfo when the locked status of the respective
+ module changes.
+ \param[in] unlocked True, if the module was unlocked; false if the module was
+ locked.
+ */
+ void moduleUnlocked(bool unlocked);
+
protected:
+ /**
+ Called internally when module data changes. This method emits any neccessary
+ signals for this model.
+ \pre The givem module is handled by this model.
+ \param[in] module The module that changed status.
+ */
void moduleDataChanged(CSwordModuleInfo *module);
protected:
+ /**
+ The underlying data as a list of pointers to the respective CSwordModuleInfo
+ instances.
+ */
QList<CSwordModuleInfo *> m_data;
};
diff --git a/src/backend/bookshelfmodel/btbookshelftreemodel.cpp b/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
index a2a988c..6444a81 100644
--- a/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
+++ b/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -13,24 +13,50 @@
#include "backend/bookshelfmodel/btbookshelftreemodel.h"
#include <QSet>
+#include <QSettings>
#include "backend/bookshelfmodel/categoryitem.h"
#include "backend/bookshelfmodel/indexingitem.h"
#include "backend/bookshelfmodel/languageitem.h"
#include "backend/bookshelfmodel/moduleitem.h"
+#include "backend/config/cbtconfig.h"
+#include "util/macros.h"
using namespace BookshelfModel;
+bool BtBookshelfTreeModel::Grouping::loadFrom(const QString &configKey) {
+ Q_ASSERT(!configKey.isNull());
+ QVariant v = CBTConfig::getConfig()->value(configKey);
+ (*this) = v.value<Grouping>();
+ return v.canConvert<Grouping>();
+}
+
+void BtBookshelfTreeModel::Grouping::saveTo(const QString &configKey) const {
+ Q_ASSERT(!configKey.isNull());
+ CBTConfig::getConfig()->setValue(configKey, QVariant::fromValue(*this));
+}
+
+
BtBookshelfTreeModel::BtBookshelfTreeModel(QObject *parent)
- : QAbstractItemModel(parent), m_sourceModel(0), m_rootItem(new RootItem),
- m_defaultChecked(MODULE_HIDDEN), m_checkable(false) {
- m_groupingOrder.push_back(GROUP_CATEGORY);
- m_groupingOrder.push_back(GROUP_LANGUAGE);
+ : QAbstractItemModel(parent), m_sourceModel(0), m_rootItem(new RootItem),
+ m_defaultChecked(MODULE_HIDDEN), m_checkable(false)
+{
+ // Intentionally empty
+}
+
+BtBookshelfTreeModel::BtBookshelfTreeModel(const QString &configKey,
+ QObject *parent)
+ : QAbstractItemModel(parent), m_sourceModel(0), m_rootItem(new RootItem),
+ m_groupingOrder(configKey), m_defaultChecked(MODULE_HIDDEN),
+ m_checkable(false)
+{
+ // Intentionally empty
}
BtBookshelfTreeModel::BtBookshelfTreeModel(const Grouping &g, QObject *parent)
: QAbstractItemModel(parent), m_sourceModel(0), m_rootItem(new RootItem),
- m_groupingOrder(g), m_defaultChecked(MODULE_HIDDEN), m_checkable(false) {
+ m_groupingOrder(g), m_defaultChecked(MODULE_HIDDEN), m_checkable(false)
+{
// Intentionally empty
}
@@ -123,13 +149,14 @@ QVariant BtBookshelfTreeModel::data(CSwordModuleInfo *module, int role) const {
bool BtBookshelfTreeModel::setData(const QModelIndex &itemIndex,
const QVariant &value,
int role) {
+ Q_ASSERT(itemIndex.isValid());
typedef QPair<Item *, QModelIndex> IP;
Qt::CheckState newState;
- if (role == Qt::CheckStateRole) {
+ if (LIKELY(role == Qt::CheckStateRole)) {
bool ok;
newState = (Qt::CheckState) value.toInt(&ok);
- if (!ok) return false;
+ if (UNLIKELY(!ok)) return false;
}
else {
return false;
@@ -262,7 +289,9 @@ void BtBookshelfTreeModel::setSourceModel(QAbstractItemModel *sourceModel) {
}
}
-void BtBookshelfTreeModel::setGroupingOrder(const Grouping &groupingOrder) {
+void BtBookshelfTreeModel::setGroupingOrder(const Grouping &groupingOrder,
+ bool emitSignal)
+{
if (m_groupingOrder == groupingOrder) return;
m_groupingOrder = groupingOrder;
@@ -291,6 +320,8 @@ void BtBookshelfTreeModel::setGroupingOrder(const Grouping &groupingOrder) {
addModule(module, checked.contains(module));
}
}
+
+ if (emitSignal) emit groupingOrderChanged(groupingOrder);
}
void BtBookshelfTreeModel::setCheckable(bool checkable) {
@@ -299,14 +330,29 @@ void BtBookshelfTreeModel::setCheckable(bool checkable) {
if (m_sourceModel == 0) return;
// Notify views that flags changed for all items:
+ resetData();
+}
+
+void BtBookshelfTreeModel::setCheckedModules(const QSet<CSwordModuleInfo*> &modules) {
+ typedef ModuleItemMap::const_iterator MIMCI;
+
+ for (MIMCI it(m_modules.constBegin()); it != m_modules.constEnd(); it++) {
+ if (modules.contains(it.key())) {
+ setData(getIndex(it.value()), Qt::Checked, Qt::CheckStateRole);
+ } else {
+ setData(getIndex(it.value()), Qt::Unchecked, Qt::CheckStateRole);
+ }
+ }
+}
+
+void BtBookshelfTreeModel::resetData() {
QModelIndexList queue;
queue.append(QModelIndex());
do {
QModelIndex parent(queue.takeFirst());
- int numChildren(rowCount(parent));
emit dataChanged(index(0, 0, parent),
- index(numChildren - 1, 0, parent));
- for (int i(0); i < numChildren; i++) {
+ index(rowCount(parent) - 1, columnCount() - 1, parent));
+ for (int i(0); i < rowCount(parent); i++) {
QModelIndex childIndex(index(i, 0, parent));
if (rowCount(childIndex) > 0) {
queue.append(childIndex);
@@ -402,7 +448,7 @@ void BtBookshelfTreeModel::removeModule(CSwordModuleInfo *module) {
}
Item *BtBookshelfTreeModel::getItem(const QModelIndex &index) const {
- if (index.isValid()) {
+ if (LIKELY(index.isValid())) {
Item *item(static_cast<Item*>(index.internalPointer()));
Q_ASSERT(item != 0);
return item;
@@ -504,8 +550,7 @@ void BtBookshelfTreeModel::moduleDataChanged(const QModelIndex &topLeft,
}
}
-void BtBookshelfTreeModel::moduleInserted(const QModelIndex &parent, int start,
- int end) {
+void BtBookshelfTreeModel::moduleInserted(const QModelIndex &parent, int start, int end) {
typedef BtBookshelfModel BM;
static const BM::ModuleRole PR(BM::ModulePointerRole);
static const BM::ModuleRole HR(BM::ModuleHiddenRole);
@@ -531,8 +576,7 @@ void BtBookshelfTreeModel::moduleInserted(const QModelIndex &parent, int start,
}
}
-void BtBookshelfTreeModel::moduleRemoved(const QModelIndex &parent, int start,
- int end) {
+void BtBookshelfTreeModel::moduleRemoved(const QModelIndex &parent, int start, int end) {
typedef BtBookshelfModel BM;
static const BM::ModuleRole PR(BM::ModulePointerRole);
@@ -557,6 +601,7 @@ QDataStream &operator<<(QDataStream &os, const BtBookshelfTreeModel::Grouping &o
QDataStream &operator>>(QDataStream &is, BtBookshelfTreeModel::Grouping &o) {
int s;
is >> s;
+ o.clear();
for (int i(0); i < s; i++) {
int g;
is >> g;
diff --git a/src/backend/bookshelfmodel/btbookshelftreemodel.h b/src/backend/bookshelfmodel/btbookshelftreemodel.h
index 47ce672..2a28dd8 100644
--- a/src/backend/bookshelfmodel/btbookshelftreemodel.h
+++ b/src/backend/bookshelfmodel/btbookshelftreemodel.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -36,7 +36,7 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
typedef QMap<CSwordModuleInfo*, BookshelfModel::ModuleItem*> ModuleItemMap;
typedef QMap<CSwordModuleInfo*, QPersistentModelIndex> SourceIndexMap;
- public:
+ public: /* Types: */
enum ModuleRole {
CheckStateRole = BtBookshelfModel::UserRole,
UserRole = BtBookshelfModel::UserRole + 100
@@ -52,9 +52,31 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
MODULE_HIDDEN, /**< By default, check only added modules that are not hidden. */
MODULE_INDEXED /**< By default, check only added modules that are indexed. */
};
- typedef QList<Group> Grouping;
+ class Grouping: public QList<Group> {
+ public:
+ /**
+ \warning Be careful using this constructor!
+ */
+ explicit inline Grouping(bool empty = false) {
+ if (empty) return;
+ push_back(GROUP_CATEGORY);
+ push_back(GROUP_LANGUAGE);
+ }
+ explicit inline Grouping(Group group) { push_back(group); }
+ explicit inline Grouping(const QString &configKey) {
+ loadFrom(configKey);
+ }
+ inline Grouping(const Grouping &copy)
+ : QList<Group>(copy) {}
+
+ bool loadFrom(const QString &configKey);
+ void saveTo(const QString &configKey) const;
+ };
+
+ public: /* Methods: */
BtBookshelfTreeModel(QObject *parent = 0);
+ BtBookshelfTreeModel(const QString &configKey, QObject *parent = 0);
BtBookshelfTreeModel(const Grouping &grouping, QObject *parent = 0);
virtual ~BtBookshelfTreeModel();
@@ -75,30 +97,31 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
virtual bool setData(const QModelIndex &index, const QVariant &value,
int role);
- void setSourceModel(QAbstractItemModel *sourceModel);
- inline QAbstractItemModel *sourceModel() const {
- return m_sourceModel;
- }
- void setGroupingOrder(const Grouping &groupingOrder);
- inline Grouping groupingOrder() const {
- return m_groupingOrder;
+ inline QAbstractItemModel *sourceModel() const { return m_sourceModel; }
+ inline const Grouping &groupingOrder() const { return m_groupingOrder; }
+ inline bool checkable() const { return m_checkable; }
+ inline CheckedBehavior defaultChecked() const { return m_defaultChecked; }
+ inline QList<CSwordModuleInfo*> modules() const { return m_modules.keys(); }
+ inline const QSet<CSwordModuleInfo*> &checkedModules() const {
+ return m_checkedModulesCache;
}
+
+ public slots:
+ void setSourceModel(QAbstractItemModel *sourceModel);
+ void setGroupingOrder(const BtBookshelfTreeModel::Grouping &groupingOrder,
+ bool emitSignal = true);
void setCheckable(bool checkable);
- inline bool checkable() const {
- return m_checkable;
- }
inline void setDefaultChecked(CheckedBehavior b) {
m_defaultChecked = b;
}
- inline CheckedBehavior defaultChecked() const {
- return m_defaultChecked;
- }
+ void setCheckedModules(const QSet<CSwordModuleInfo*> &modules);
- inline const QSet<CSwordModuleInfo*> &checkedModules() const {
- return m_checkedModulesCache;
- }
+ signals:
+ void groupingOrderChanged(BtBookshelfTreeModel::Grouping newGrouping);
+ void moduleChecked(CSwordModuleInfo *module, bool checked);
protected:
+ void resetData();
QVariant parentData(BookshelfModel::ModuleItem *item, int role) const;
void addModule(CSwordModuleInfo *module, bool checked);
void addModule(CSwordModuleInfo *module, QModelIndex parentIndex,
@@ -132,9 +155,6 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
void moduleInserted(const QModelIndex &parent, int start, int end);
void moduleRemoved(const QModelIndex &parent, int start, int end);
- signals:
- void moduleChecked(CSwordModuleInfo *module, bool checked);
-
protected:
QAbstractItemModel *m_sourceModel;
BookshelfModel::Item *m_rootItem;
diff --git a/src/backend/bookshelfmodel/categoryitem.cpp b/src/backend/bookshelfmodel/categoryitem.cpp
index 46905d7..aaf5566 100644
--- a/src/backend/bookshelfmodel/categoryitem.cpp
+++ b/src/backend/bookshelfmodel/categoryitem.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -23,9 +23,9 @@ CategoryItem::CategoryItem(CSwordModuleInfo *module)
QVariant CategoryItem::data(int role) const {
switch (role) {
case Qt::DisplayRole:
- return BtBookshelfModel::categoryName(m_category);
+ return CSwordModuleInfo::categoryName(m_category);
case Qt::DecorationRole:
- return BtBookshelfModel::categoryIcon(m_category);
+ return CSwordModuleInfo::categoryIcon(m_category);
default:
return Item::data(role);
}
diff --git a/src/backend/bookshelfmodel/categoryitem.h b/src/backend/bookshelfmodel/categoryitem.h
index 879895f..75d5a7c 100644
--- a/src/backend/bookshelfmodel/categoryitem.h
+++ b/src/backend/bookshelfmodel/categoryitem.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/backend/bookshelfmodel/indexingitem.cpp b/src/backend/bookshelfmodel/indexingitem.cpp
index 898096f..5491ca5 100644
--- a/src/backend/bookshelfmodel/indexingitem.cpp
+++ b/src/backend/bookshelfmodel/indexingitem.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/backend/bookshelfmodel/indexingitem.h b/src/backend/bookshelfmodel/indexingitem.h
index f30fb2d..a1eb812 100644
--- a/src/backend/bookshelfmodel/indexingitem.h
+++ b/src/backend/bookshelfmodel/indexingitem.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/backend/bookshelfmodel/item.cpp b/src/backend/bookshelfmodel/item.cpp
index 809021b..02cd991 100644
--- a/src/backend/bookshelfmodel/item.cpp
+++ b/src/backend/bookshelfmodel/item.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/backend/bookshelfmodel/item.h b/src/backend/bookshelfmodel/item.h
index f10da04..652120b 100644
--- a/src/backend/bookshelfmodel/item.h
+++ b/src/backend/bookshelfmodel/item.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/backend/bookshelfmodel/languageitem.cpp b/src/backend/bookshelfmodel/languageitem.cpp
index 547c953..2fdab8b 100644
--- a/src/backend/bookshelfmodel/languageitem.cpp
+++ b/src/backend/bookshelfmodel/languageitem.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -23,7 +23,7 @@ LanguageItem::LanguageItem(CSwordModuleInfo *module)
QVariant LanguageItem::data(int role) const {
switch (role) {
case Qt::DisplayRole:
- return BtBookshelfModel::languageName(m_language);
+ return m_language->translatedName();
case Qt::DecorationRole:
return util::directory::getIcon("flag.svg");
default:
diff --git a/src/backend/bookshelfmodel/languageitem.h b/src/backend/bookshelfmodel/languageitem.h
index c6e4417..03a9ce3 100644
--- a/src/backend/bookshelfmodel/languageitem.h
+++ b/src/backend/bookshelfmodel/languageitem.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/backend/bookshelfmodel/moduleitem.cpp b/src/backend/bookshelfmodel/moduleitem.cpp
index e7aff92..ca9c3fb 100644
--- a/src/backend/bookshelfmodel/moduleitem.cpp
+++ b/src/backend/bookshelfmodel/moduleitem.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/backend/bookshelfmodel/moduleitem.h b/src/backend/bookshelfmodel/moduleitem.h
index 006ae97..5e6e1ba 100644
--- a/src/backend/bookshelfmodel/moduleitem.h
+++ b/src/backend/bookshelfmodel/moduleitem.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -28,10 +28,10 @@ class ModuleItem: public Item {
ModuleItem(CSwordModuleInfo *module, BtBookshelfTreeModel *parentModel);
/**
- Reimplementation of \ref Item::data which dispatches all requests to
- the \ref BtBookshelfTreeModel parent model.
+ Reimplementation of Item::data() which dispatches all
+ requests to the parent model (BtBookshelfTreeModel).
*/
- QVariant data(int role = Qt::DisplayRole) const;
+ virtual QVariant data(int role = Qt::DisplayRole) const;
inline CSwordModuleInfo *moduleInfo() const {
return m_moduleInfo;
diff --git a/src/frontend/bookshelfmanager/instbackend.cpp b/src/backend/btinstallbackend.cpp
index 463a6e5..67f8945 100644
--- a/src/frontend/bookshelfmanager/instbackend.cpp
+++ b/src/backend/btinstallbackend.cpp
@@ -2,23 +2,19 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "frontend/bookshelfmanager/instbackend.h"
+#include "backend/btinstallbackend.h"
-#include <functional>
-#include <map>
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QFileInfo>
-#include <utility>
#include "backend/managers/cswordbackend.h"
#include "frontend/bookshelfmanager/btinstallmgr.h"
-#include "util/cpointers.h"
#include "util/directory.h"
#include "util/dialogutil.h"
@@ -30,7 +26,7 @@
using namespace sword;
-namespace instbackend {
+namespace BtInstallBackend {
/** Adds the source described by Source to the backend. */
bool addSource(sword::InstallSource& source) {
@@ -52,7 +48,7 @@ bool addSource(sword::InstallSource& source) {
}
/** Returns the Source struct. */
-sword::InstallSource source(QString name) {
+sword::InstallSource source(const QString &name) {
qDebug() << "backend::source";
BtInstallMgr mgr;
InstallSourceMap::iterator source = mgr.sources.find(name.toLatin1().data());
@@ -87,7 +83,7 @@ sword::InstallSource source(QString name) {
}
/** Deletes the source. */
-bool deleteSource(QString name) {
+bool deleteSource(const QString &name) {
qDebug() << "backend::deleteSource";
sword::InstallSource is = source(name );
@@ -133,12 +129,6 @@ bool deleteSource(QString name) {
return true; /// \todo dummy
}
-/** Refreshes the remote source module list. */
-bool refreshSource(QString /*name*/) {
- // not possible until manager and progressdialog work together
- return true; /// \todo dummy
-}
-
/** Returns the moduleinfo list for the source. Delete the pointer after using. IS THIS POSSIBLE?*/
QList<CSwordModuleInfo*> moduleList(QString /*name*/) {
QList<CSwordModuleInfo*> list; /// \todo dummy
@@ -149,19 +139,17 @@ bool isRemote(const sword::InstallSource& source) {
return !strcmp(source.type, "FTP");
}
-const QString configPath() {
- QString confPath = util::directory::getUserHomeSwordDir().absolutePath();
- confPath.append("/InstallMgr");
- return confPath;
+QString configPath() {
+ return util::directory::getUserHomeSwordDir().absolutePath().append("/InstallMgr");
}
-const QString configFilename() {
- return (configPath() + "/InstallMgr.conf");
+QString configFilename() {
+ return configPath().append("/InstallMgr.conf");
}
QStringList targetList() {
qDebug() << "backend::targetList";
- QStringList names = CPointers::backend()->swordDirList();
+ QStringList names = CSwordBackend::instance()->swordDirList();
return names;
}
@@ -227,11 +215,11 @@ bool setTargetList( const QStringList& targets ) {
}
qDebug() << "save the sword conf...";
conf.Save();
- CPointers::backend()->reloadModules(CSwordBackend::PathChanged);
+ CSwordBackend::instance()->reloadModules(CSwordBackend::PathChanged);
return true;
}
-QStringList sourceList() {
+QStringList sourceNameList() {
qDebug() << "backend::sourceList";
BtInstallMgr mgr;
Q_ASSERT(mgr.installConf);
@@ -268,7 +256,7 @@ void initPassiveFtpMode() {
config["General"]["PassiveFTP"] = "true";
config.Save();
}
-const QString swordConfigFilename() {
+QString swordConfigFilename() {
namespace DU = util::directory;
qDebug() << "backend::swordConfigFilename";
@@ -282,7 +270,7 @@ const QString swordConfigFilename() {
#endif
}
-const QDir swordDir() {
+QDir swordDir() {
namespace DU = util::directory;
#ifdef Q_WS_WIN
@@ -295,6 +283,7 @@ const QDir swordDir() {
CSwordBackend* backend( const sword::InstallSource& is) {
qDebug() << "backend::backend";
CSwordBackend* ret = 0;
+ /// \anchor BackendNotSingleton
if (isRemote(is)) {
ret = new CSwordBackend( QString(is.localShadow.c_str()), false );
}
@@ -309,4 +298,4 @@ CSwordBackend* backend( const sword::InstallSource& is) {
return ret;
}
-}
+} // namespace BtInstallBackend
diff --git a/src/frontend/bookshelfmanager/instbackend.h b/src/backend/btinstallbackend.h
index 3a98e5a..fc71697 100644
--- a/src/frontend/bookshelfmanager/instbackend.h
+++ b/src/backend/btinstallbackend.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,22 +20,19 @@
class CSwordModuleInfo;
-namespace instbackend {
+namespace BtInstallBackend {
/** Adds the source to the backend. */
bool addSource(sword::InstallSource& source);
/** Returns the source struct. */
-sword::InstallSource source(QString name);
+sword::InstallSource source(const QString &name);
/** Deletes the source. */
-bool deleteSource(QString name);
-
-/** Refreshes the remote source module list. */
-bool refreshSource(QString name);
+bool deleteSource(const QString &name);
/** Returns the moduleinfo list for the source. */
-QList<CSwordModuleInfo*> moduleList(QString name);
+QList<CSwordModuleInfo*> moduleList(const QString &name);
/** Tells if the source is remote or local. */
bool isRemote(const sword::InstallSource& source);
@@ -46,13 +43,13 @@ QStringList targetList();
/** Saves the list of available install target paths to the sword config. Return success indicator.*/
bool setTargetList( const QStringList& targets );
-QStringList sourceList();
+QStringList sourceNameList();
/** Returns the path of the sword installer configuration file. */
-const QString configPath();
+QString configPath();
/** Returns the name of the sword installer configuration file. */
-const QString configFilename();
+QString configFilename();
/** Sets the passive mode for as default.
* \todo see if we can en/disable this per source.
@@ -60,15 +57,15 @@ const QString configFilename();
void initPassiveFtpMode();
/** Returns the file name for the Sword config file. */
-const QString swordConfigFilename();
+QString swordConfigFilename();
/** Returns the Sword directory ($HOME/.sword/) as a QDir, created with absolute path (not canonical).
*/
-const QDir swordDir();
+QDir swordDir();
/** Returns backend Sword manager for the source. */
CSwordBackend* backend( const sword::InstallSource& is);
-}
+} // namespace BtInstallBackend
#endif
diff --git a/src/backend/btmoduletreeitem.cpp b/src/backend/btmoduletreeitem.cpp
index 01e4446..c57d094 100644
--- a/src/backend/btmoduletreeitem.cpp
+++ b/src/backend/btmoduletreeitem.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,7 +14,6 @@
#include <QString>
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
-#include "util/cpointers.h"
#include "util/cresmgr.h"
#include "util/tool.h"
@@ -30,7 +29,7 @@ BTModuleTreeItem::BTModuleTreeItem(QList<BTModuleTreeItem::Filter*>& filters, BT
m_originalModuleList = *modules;
}
else {
- m_originalModuleList = CPointers::backend()->moduleList();
+ m_originalModuleList = CSwordBackend::instance()->moduleList();
}
//populate the tree with groups/modules
create_tree(filters, grouping);
@@ -139,7 +138,7 @@ void BTModuleTreeItem::create_tree(QList<BTModuleTreeItem::Filter*>& filters, BT
map_initialized = true;
}
- //QList<CSwordModuleInfo*> originalInfoList = CPointers::backend()->moduleList();
+ //QList<CSwordModuleInfo*> originalInfoList = CSwordBackend::instance()()->moduleList();
foreach (CSwordModuleInfo* info, m_originalModuleList) {
bool included;
diff --git a/src/backend/btmoduletreeitem.h b/src/backend/btmoduletreeitem.h
index 5bcebf8..6ee6868 100644
--- a/src/backend/btmoduletreeitem.h
+++ b/src/backend/btmoduletreeitem.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -27,21 +27,21 @@ different set of filters you have to create a new tree - it's not possible to mo
Example:
- ...
- QList<BTModuleTreeItem::Filter*> noFilters
- BTModuleTreeItem root(noFilters, BTModuleTreeItem::CatLangMod);
- add_to_view(&root, qtreewidget->invisibleRootItem());
- ...
- void add_to_view(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem) {
- foreach (BTModuleTreeItem* i, item->children()) {
- add_to_view(i, new QTreeWidgetItem(widgetItem));
- }
- if (item->type() == BTModuleTreeItem::Category) prepare_category_item(widgetItem, item);
- ...
- }
-
-
- @author The BibleTime team <info@bibletime.info>
+ ...
+ QList<BTModuleTreeItem::Filter*> noFilters
+ BTModuleTreeItem root(noFilters, BTModuleTreeItem::CatLangMod);
+ add_to_view(&root, qtreewidget->invisibleRootItem());
+ ...
+ void add_to_view(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem) {
+ foreach (BTModuleTreeItem* i, item->children()) {
+ add_to_view(i, new QTreeWidgetItem(widgetItem));
+ }
+ if (item->type() == BTModuleTreeItem::Category) prepare_category_item(widgetItem, item);
+ ...
+ }
+
+
+ @author The BibleTime team <info@bibletime.info>
*/
class BTModuleTreeItem {
public:
@@ -63,10 +63,10 @@ class BTModuleTreeItem {
* 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);
+ * 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;
@@ -102,7 +102,7 @@ class BTModuleTreeItem {
* 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).
+ * (by default CSwordBackend::instance()()->moduleList() is used).
*/
BTModuleTreeItem(QList<BTModuleTreeItem::Filter*>& filters,
BTModuleTreeItem::Grouping grouping, QList<CSwordModuleInfo*>* modules = 0);
diff --git a/src/backend/config/cbtconfig.cpp b/src/backend/config/cbtconfig.cpp
index 39c3e0c..883f41f 100644
--- a/src/backend/config/cbtconfig.cpp
+++ b/src/backend/config/cbtconfig.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,9 +16,9 @@
#include <QWebSettings>
#include "backend/btmoduletreeitem.h"
#include "backend/managers/cdisplaytemplatemgr.h"
+#include "btglobal.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/searchdialog/btsearchoptionsarea.h"
-#include "util/cpointers.h"
#include "util/directory.h"
// Sword includes:
@@ -91,6 +91,8 @@ QString getKey(const bools ID) {
return "autoTileHorizontal";
case autoTile:
return "autoTile";
+ case autoTabbed:
+ return "autoTabbed";
case autoCascade:
return "autoCascade";
@@ -112,18 +114,24 @@ QString getKey(const bools ID) {
return "bookshelfShowHidden";
case allowNetworkConnection:
return "allowNetworkConnection";
-
+
case showTextWindowHeaders:
return "showTextWindowHeaders";
case showTextWindowNavigator:
return "showTextWindowNavigator";
case showTextWindowModuleSelectorButtons:
return "showTextWindowModuleSelectorButtons";
+ case showFormatToolbarButtons:
+ return "showFormatToolbarButtons";
case showTextWindowToolButtons:
return "showTextWindowToolButtons";
+ case showToolbarsInEachWindow:
+ return "showToolbarsInEachWindow";
+ case showTipAtStartup:
+ return "showTipAtStartup";
}
Q_ASSERT(false);
- return false;
+ return QString::null;
}
QString getKey(const ints ID) {
@@ -188,6 +196,8 @@ QString getKey(const ints ID) {
return "configDialogHeight";
case configDialogWidth:
return "configDialogWidth";
+ case tipNumber:
+ return "tipNumber";
}
Q_ASSERT(false);
return QString::null;
@@ -249,7 +259,7 @@ QString IntListToString(const QList<int> intList) {
return intStrings.join(",");
}
-QList<int> StringToIntList(const QString intListString) {
+QList<int> StringToIntList(const QString &intListString) {
QList<int> intList;
if (!intListString.isEmpty() && intListString.contains(',')) {
foreach(QString intString, intListString.split(',')) {
@@ -268,13 +278,13 @@ QString getDefault(const strings ID) {
case displayStyle:
return CDisplayTemplateMgr::defaultTemplate();
case bookshelfCurrentItem:
- return QString();
+ return QString::null;
}
return QString::null;
}
QString getDefault(const modules ID) {
- // CSwordBackend *b = CPointers::backend();
+ // CSwordBackend *b = CSwordBackend::instance()();
switch (ID) {
case standardBible:
return "KJV";
@@ -318,6 +328,8 @@ bool getDefault(const bools ID) {
return false;
case autoTile:
return false;
+ case autoTabbed:
+ return false;
case autoCascade:
return false;
@@ -338,7 +350,7 @@ bool getDefault(const bools ID) {
return false;
case allowNetworkConnection:
return false;
-
+
case showTextWindowHeaders:
return true;
case showTextWindowNavigator:
@@ -347,6 +359,12 @@ bool getDefault(const bools ID) {
return true;
case showTextWindowToolButtons:
return true;
+ case showFormatToolbarButtons:
+ return true;
+ case showToolbarsInEachWindow:
+ return true;
+ case showTipAtStartup:
+ return true;
}
return false;
}
@@ -413,6 +431,8 @@ int getDefault(const ints ID) {
return 1;
case configDialogWidth:
return 1;
+ case tipNumber:
+ return 0;
}
return 0;
}
@@ -498,7 +518,7 @@ QString get(const strings ID) {
CSwordModuleInfo *get(const modules ID) {
getConfig()->beginGroup("modules");
- CSwordModuleInfo *result(CPointers::backend()->findModuleByName(
+ CSwordModuleInfo *result(CSwordBackend::instance()->findModuleByName(
getConfig()->value(getKey(ID), getDefault(ID)).toString()
));
getConfig()->endGroup();
@@ -603,7 +623,7 @@ FontSettingsPair get(const CLanguageMgr::Language * const language) {
return settings;
}
-void set(const strings ID, const QString value) {
+void set(const strings ID, const QString &value) {
// KConfigGroup cg = getConfig()->group("strings");
// cg.writeEntry(getKey(ID), value);
getConfig()->beginGroup("strings");
@@ -620,7 +640,7 @@ void set(const modules ID, CSwordModuleInfo * const value) {
}
void set(const modules ID, const QString& value) {
- CSwordModuleInfo *module(CPointers::backend()->findModuleByName(value));
+ CSwordModuleInfo *module(CSwordBackend::instance()->findModuleByName(value));
if (module) {
set(ID, module);
}
@@ -704,15 +724,15 @@ void set(const CLanguageMgr::Language * const language,
m_fontCache.remove(language);
}
-CSwordBackend::DisplayOptions getDisplayOptionDefaults() {
- CSwordBackend::DisplayOptions options;
+DisplayOptions getDisplayOptionDefaults() {
+ DisplayOptions options;
options.lineBreaks = get(lineBreaks);
options.verseNumbers = get(verseNumbers);
return options;
}
-CSwordBackend::FilterOptions getFilterOptionDefaults() {
- CSwordBackend::FilterOptions options;
+FilterOptions getFilterOptionDefaults() {
+ FilterOptions options;
options.footnotes = true; // Required for the info display
options.strongNumbers = true; // get(strongNumbers);
diff --git a/src/backend/config/cbtconfig.h b/src/backend/config/cbtconfig.h
index 9f3a850..ef618a2 100644
--- a/src/backend/config/cbtconfig.h
+++ b/src/backend/config/cbtconfig.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -56,6 +56,7 @@ enum bools {
autoTileVertical,
autoTileHorizontal,
autoTile,
+ autoTabbed,
autoCascade,
lineBreaks,
@@ -73,7 +74,10 @@ enum bools {
showTextWindowHeaders,
showTextWindowNavigator,
showTextWindowToolButtons,
- showTextWindowModuleSelectorButtons
+ showTextWindowModuleSelectorButtons,
+ showFormatToolbarButtons,
+ showToolbarsInEachWindow,
+ showTipAtStartup
};
enum ints {
footnotes,
@@ -110,7 +114,8 @@ enum ints {
configDialogPosX,
configDialogPosY,
configDialogHeight,
- configDialogWidth
+ configDialogWidth,
+ tipNumber
};
enum intLists {
leftPaneSplitterSizes,
@@ -140,7 +145,7 @@ enum stringMaps {
};
QString IntListToString(const QList<int> intList);
-QList<int> StringToIntList(const QString intListString);
+QList<int> StringToIntList(const QString &intListString);
QString getDefault(const strings);
QString getDefault(const modules);
@@ -160,7 +165,7 @@ QStringList get(const stringLists);
StringMap get(const stringMaps);
FontSettingsPair get(const CLanguageMgr::Language * const);
-void set(const strings, const QString value);
+void set(const strings, const QString &value);
void set(const modules, CSwordModuleInfo * const module);
void set(const modules, const QString& moduleName);
void set(const bools, const bool value);
@@ -171,8 +176,8 @@ void set(const stringMaps, const StringMap value);
void set(const CLanguageMgr::Language * const language,
const FontSettingsPair &fontSettings);
-CSwordBackend::FilterOptions getFilterOptionDefaults();
-CSwordBackend::DisplayOptions getDisplayOptionDefaults();
+FilterOptions getFilterOptionDefaults();
+DisplayOptions getDisplayOptionDefaults();
void setupAccelSettings(const keys type,
BtActionCollection * const actionCollection);
diff --git a/src/backend/cswordmodulesearch.cpp b/src/backend/cswordmodulesearch.cpp
index 9348295..694151d 100644
--- a/src/backend/cswordmodulesearch.cpp
+++ b/src/backend/cswordmodulesearch.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,63 +10,32 @@
#include "backend/cswordmodulesearch.h"
#include "backend/config/cbtconfig.h"
-#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
+#include "btglobal.h"
-// Sword includes:
-#include <listkey.h>
-#include <swkey.h>
-#include <swmodule.h>
+void CSwordModuleSearch::startSearch() {
+ // Clear old search results:
+ m_results.clear();
+ m_foundItems = 0;
-CSwordModuleSearch* CSwordModuleSearch::searcher = 0;
+ /// \todo What is the purpose of the following statement?
+ CSwordBackend::instance()->setFilterOptions(CBTConfig::getFilterOptionDefaults());
-CSwordModuleSearch::CSwordModuleSearch()
- : m_searchedText(QString::null),
- m_searchOptions(0),
- m_foundItems(false) {
- searcher = this;
-}
-
-CSwordModuleSearch::~CSwordModuleSearch() {
- searcher = 0;
-}
-
-/** This function sets the modules which should be searched. */
-void CSwordModuleSearch::setModules( const QList<CSwordModuleInfo*>& list ) {
- m_moduleList = list;
-}
-
-/** Starts the search for the search text. */
-bool CSwordModuleSearch::startSearch() {
- backend()->setFilterOptions ( CBTConfig::getFilterOptionDefaults() );
- m_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 (QList<CSwordModuleInfo*>::iterator it = m_moduleList.begin(); it != end_it; ++it) {
- if ( (*it)->searchIndexed(m_searchedText/*, m_searchOptions*/, m_searchScope) ) {
- foundItems = true;
+ // Search module-by-module:
+ Q_FOREACH(const CSwordModuleInfo *m, m_searchModules) {
+ sword::ListKey results;
+ int found = m->searchIndexed(m_searchText, m_searchScope, results);
+ if (found > 0) {
+ m_results.insert(m, results);
+ m_foundItems += found;
}
}
-
- m_foundItems = foundItems;
-
- //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;
-}
+void CSwordModuleSearch::setSearchScope(const sword::ListKey &scope) {
+ /// \todo Properly examine and document the inner workings of this method.
-/** 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
@@ -81,34 +50,14 @@ void CSwordModuleSearch::setSearchScope( const sword::ListKey& scope ) {
}
}
-/** Sets the search scope back. */
-void CSwordModuleSearch::resetSearchScope() {
- 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;
-}
-
-/** Returns a copy of the used search scope. */
-const sword::ListKey& CSwordModuleSearch::searchScope() const {
- return m_searchScope;
-}
-
-void CSwordModuleSearch::connectFinished( QObject *receiver, const char *member ) {
- //m_finishedSig.connect(receiver, member);
- QObject::connect(this, SIGNAL(finished()), receiver, member);
-}
-
-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;
+QList<const CSwordModuleInfo*> CSwordModuleSearch::unindexedModules(
+ const QList<const CSwordModuleInfo*> &modules)
+{
+ QList<const CSwordModuleInfo*> unindexed;
+ Q_FOREACH (const CSwordModuleInfo *m, modules) {
+ if (!m->hasIndex()) {
+ unindexed.append(m);
}
}
- return hasIndices;
+ return unindexed;
}
diff --git a/src/backend/cswordmodulesearch.h b/src/backend/cswordmodulesearch.h
index d40e9fa..bc0d37c 100644
--- a/src/backend/cswordmodulesearch.h
+++ b/src/backend/cswordmodulesearch.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,8 +11,8 @@
#define CSWORDMODULESEARCH_H
#include <QObject>
-#include <QString>
-#include "util/cpointers.h"
+
+#include <QHash>
// Sword includes:
#include <listkey.h>
@@ -28,65 +28,86 @@ class CSwordModuleInfo;
* @version $Id: cswordmodulesearch.h,v 1.34 2006/08/08 19:32:48 joachim Exp $
*/
-class CSwordModuleSearch: public QObject, CPointers {
+class CSwordModuleSearch: public QObject {
Q_OBJECT
- public:
- CSwordModuleSearch();
+ public: /* Types: */
+ typedef QHash<const CSwordModuleInfo*, sword::ListKey> Results;
+
+ public: /* Methods: */
+ inline CSwordModuleSearch()
+ : m_foundItems(0) {}
+
/**
- * The destructor of this class. It cleans uop memory before it's deleted.
+ Sets the text which should be search in the modules.
+ \param[in] text the text to search.
*/
- virtual ~CSwordModuleSearch();
+ inline void setSearchedText(const QString &text) {
+ m_searchText = text;
+ }
+
/**
- * Sets the text which should be search in the modules.
+ Set the modules which should be searched.
+ \param[in] modules the modules to search in.
*/
- void setSearchedText( const QString& );
+ inline void setModules(const QList<const CSwordModuleInfo*> &modules) {
+ Q_ASSERT(!modules.empty());
+ Q_ASSERT(unindexedModules(modules).empty());
+ m_searchModules = modules;
+ }
+
/**
- * Starts the search for the search text.
+ Sets the search scope.
+ \param[in] scope the scope used for the search.
*/
- bool startSearch();
+ void setSearchScope(const sword::ListKey &scope);
+
/**
- * This function sets the modules which should be searched.
+ Resets the search scope.
*/
- void setModules( const QList<CSwordModuleInfo*>& );
+ inline void resetSearchScope() {
+ m_searchScope.ClearList();
+ }
+
/**
- * Sets the search scope.
+ \returns the search scope.
*/
- void setSearchScope( const sword::ListKey& scope );
+ const sword::ListKey &searchScope() const {
+ return m_searchScope;
+ }
+
/**
- * Sets the seaech scope back.
+ Starts the search for the search text.
*/
- void resetSearchScope();
+ void startSearch();
+
/**
- * @return "true" if in the last search the searcher found items, if no items were found return "false"
+ \returns the number of found items in the last search.
*/
- bool foundItems() const;
+ inline unsigned long foundItems() const {
+ return m_foundItems;
+ }
+
/**
- * Returns a copy of the used search scope.
+ \returns the results of the search.
*/
- const sword::ListKey& searchScope() const;
-
- void connectFinished( QObject * receiver, const char * member );
+ const Results &results() const {
+ return m_results;
+ }
/**
- * Returns true if all of the specified modules have indices already built.
+ \returns the list of unindexed modules in the given list.
*/
- bool modulesHaveIndices( const QList<CSwordModuleInfo*>& );
-
- protected:
- QString m_searchedText;
- sword::ListKey m_searchScope;
- QList<CSwordModuleInfo*> m_moduleList;
-
- int m_searchOptions;
-
- bool m_foundItems;
+ static QList<const CSwordModuleInfo*> unindexedModules(
+ const QList<const CSwordModuleInfo*> &modules);
- signals:
- void finished();
+ private: /* Fields: */
+ QString m_searchText;
+ sword::ListKey m_searchScope;
+ QList<const CSwordModuleInfo*> m_searchModules;
- private:
- static CSwordModuleSearch* searcher;
+ Results m_results;
+ unsigned long m_foundItems;
};
#endif
diff --git a/src/backend/drivers/cswordbiblemoduleinfo.cpp b/src/backend/drivers/cswordbiblemoduleinfo.cpp
index 4a65c4d..a81430f 100644
--- a/src/backend/drivers/cswordbiblemoduleinfo.cpp
+++ b/src/backend/drivers/cswordbiblemoduleinfo.cpp
@@ -2,14 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "backend/drivers/cswordbiblemoduleinfo.h"
-#include <boost/scoped_ptr.hpp>
+#include <QSharedPointer>
#include <QFile>
#include "backend/managers/cswordbackend.h"
#include "backend/keys/cswordversekey.h"
@@ -18,65 +18,55 @@
#include <versekey.h>
-CSwordBibleModuleInfo::CSwordBibleModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend )
- : CSwordModuleInfo(module, usedBackend),
+CSwordBibleModuleInfo::CSwordBibleModuleInfo(sword::SWModule *module,
+ CSwordBackend * const usedBackend,
+ ModuleType type)
+ : CSwordModuleInfo(module, usedBackend, type),
m_lowerBound(0),
m_upperBound(0),
m_bookList(0),
- m_cachedLocale("unknown"),
- m_hasOT(-1),
- m_hasNT(-1) {}
+ m_cachedLocale("unknown")
+{
+ initBounds();
+}
-CSwordBibleModuleInfo::CSwordBibleModuleInfo( const CSwordBibleModuleInfo& m ) :
- CSwordModuleInfo(m),
+CSwordBibleModuleInfo::CSwordBibleModuleInfo(const CSwordBibleModuleInfo &copy) :
+ CSwordModuleInfo(copy),
m_lowerBound(0),
m_upperBound(0),
- m_bookList(0) {
- if (m.m_bookList) {
+ m_bookList(0),
+ m_cachedLocale(copy.m_cachedLocale),
+ m_hasOT(copy.m_hasOT),
+ m_hasNT(copy.m_hasNT)
+{
+ if (copy.m_bookList) {
m_bookList = new QStringList();
- *m_bookList = *m.m_bookList;
+ *m_bookList = *copy.m_bookList;
}
-
- m_hasOT = m.m_hasOT;
- m_hasNT = m.m_hasNT;
- m_cachedLocale = m.m_cachedLocale;
-}
-
-CSwordModuleInfo* CSwordBibleModuleInfo::clone() {
- return new CSwordBibleModuleInfo(*this);
-}
-
-CSwordBibleModuleInfo::~CSwordBibleModuleInfo() {
- delete m_bookList;
+ initBounds();
}
void CSwordBibleModuleInfo::initBounds() {
- if (m_hasOT == -1) {
- m_hasOT = hasTestament(OldTestament);
- }
+ const bool oldStatus = module()->getSkipConsecutiveLinks();
+ module()->setSkipConsecutiveLinks(true);
- if (m_hasNT == -1) {
- m_hasNT = hasTestament(NewTestament);
- }
+ module()->setPosition(sword::TOP); // position to first entry
+ sword::VerseKey key(module()->KeyText());
+ m_hasOT = (key.Testament() == 1);
- if (m_hasOT) {
- m_lowerBound.key("Genesis 1:1");
- }
- else {
- m_lowerBound.key("Matthew 1:1");
- }
+ module()->setPosition(sword::BOTTOM);
+ key = module()->KeyText();
+ m_hasNT = (key.Testament() == 2);
- if (!m_hasNT) {
- m_upperBound.key("Malachi 4:6");
- }
- else {
- m_upperBound.key("Revelation of John 22:21");
- }
+ module()->setSkipConsecutiveLinks(oldStatus);
+
+ m_lowerBound.setKey(m_hasOT ? "Genesis 1:1" : "Matthew 1:1");
+ m_upperBound.setKey(!m_hasNT ? "Malachi 4:6" : "Revelation of John 22:21");
}
/** Returns the books available in this module */
-QStringList* CSwordBibleModuleInfo::books() {
+QStringList *CSwordBibleModuleInfo::books() const {
if (m_cachedLocale != backend()->booknameLanguage()) { //if the locale has changed
delete m_bookList;
m_bookList = 0;
@@ -85,34 +75,33 @@ QStringList* CSwordBibleModuleInfo::books() {
if (!m_bookList) {
m_bookList = new QStringList();
- initBounds();
- int min = 0;
- int max = 1;
+ int min = 1; // 1 = OT
+ int max = 2; // 2 = NT
//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;
+ if (m_hasOT && m_hasNT) { //both
+ min = 1;
+ max = 2;
}
- else if (!m_hasOT && m_hasNT > 0) { //only NT
+ else if (m_hasOT && !m_hasNT) { //only OT
min = 1;
max = 1;
}
+ else if (!m_hasOT && m_hasNT) { //only NT
+ min = 2;
+ max = 2;
+ }
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;
+ min = 1;
+ max = 0;
}
- boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
- (*key) = sword::TOP;
+ QSharedPointer<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ key->setPosition(sword::TOP);
- for (key->Testament(min + 1); !key->Error() && (key->Testament() - 1) <= max; key->Book(key->Book() + 1)) {
+ for (key->setTestament(min); !key->Error() && key->getTestament() <= max; key->Book(key->Book() + 1)) {
m_bookList->append( QString::fromUtf8(key->getBookName()) );
}
@@ -122,101 +111,58 @@ QStringList* CSwordBibleModuleInfo::books() {
return m_bookList;
}
-/** Returns the number of chapters for the given book. */
-unsigned int CSwordBibleModuleInfo::chapterCount(const unsigned int book) {
+unsigned int CSwordBibleModuleInfo::chapterCount(const unsigned int book) const {
int result = 0;
- boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
- (*key) = sword::TOP;
+ QSharedPointer<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ key->setPosition(sword::TOP);
// works for old and new versions
key->Book(book);
- (*key) = sword::MAXCHAPTER;
+ key->setPosition(sword::MAXCHAPTER);
result = key->Chapter();
return result;
}
-unsigned int CSwordBibleModuleInfo::chapterCount(const QString& book) {
- return chapterCount( bookNumber(book) );
+unsigned int CSwordBibleModuleInfo::chapterCount(const QString &book) const {
+ 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 CSwordBibleModuleInfo::verseCount(const unsigned int book,
+ const unsigned int chapter) const
+{
unsigned int result = 0;
- boost::scoped_ptr<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
- (*key) = sword::TOP;
+ QSharedPointer<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ key->setPosition(sword::TOP);
// works for old and new versions
key->Book(book);
key->Chapter(chapter);
- (*key) = sword::MAXVERSE;
+ key->setPosition(sword::MAXVERSE);
result = key->Verse();
return result;
}
-unsigned int CSwordBibleModuleInfo::verseCount( const QString& book, const unsigned int chapter ) {
- return verseCount( bookNumber(book), chapter );
+unsigned int CSwordBibleModuleInfo::verseCount(const QString &book,
+ const unsigned int chapter) const
+{
+ return verseCount(bookNumber(book), chapter);
}
-unsigned int CSwordBibleModuleInfo::bookNumber(const QString &book) {
+unsigned int CSwordBibleModuleInfo::bookNumber(const QString &book) const {
unsigned int bookNumber = 0;
- //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;
+ QSharedPointer<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ key->setPosition(sword::TOP);
key->setBookName(book.toUtf8().constData());
- bookNumber = ((key->Testament() > 1) ? key->BMAX[0] : 0) + key->Book();
+ bookNumber = ((key->getTestament() > 1) ? key->BMAX[0] : 0) + key->Book();
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);
-
- *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;
- }
-
- *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;
- }
-
- module()->setSkipConsecutiveLinks(oldStatus);
- }
-
- switch (type) {
-
- case OldTestament:
- return m_hasOT > 0;
-
- case NewTestament:
- return m_hasNT > 0;
-
- default:
- return false;
- }
-}
-
diff --git a/src/backend/drivers/cswordbiblemoduleinfo.h b/src/backend/drivers/cswordbiblemoduleinfo.h
index 2780558..40ec8cb 100644
--- a/src/backend/drivers/cswordbiblemoduleinfo.h
+++ b/src/backend/drivers/cswordbiblemoduleinfo.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,110 +17,102 @@
/**
- * This is the CModuleInfo imlementation for Bible modules managed by Sword.
- *
- * @short Implementation for Sword Bibles
- * @author The BibleTime team
- * @version $Id: cswordbiblemoduleinfo.h,v 1.18 2006/02/25 11:38:15 joachim Exp $
- */
+ \brief Implementation for Sword Bibles.
-class CSwordBibleModuleInfo : public CSwordModuleInfo {
+ This is the CModuleInfo imlementation for Bible modules managed by Sword.
+*/
+class CSwordBibleModuleInfo: public CSwordModuleInfo {
+ Q_OBJECT
- public:
+ public: /* Types: */
enum Testament {
OldTestament = 1,
NewTestament = 2
};
+ public: /* Methods: */
+ CSwordBibleModuleInfo(sword::SWModule *module, CSwordBackend * const,
+ ModuleType type = Bible);
+ CSwordBibleModuleInfo(const CSwordBibleModuleInfo &copy);
+
+ /* Reimplementation of CSwordModuleInfo::clone(). */
+ virtual inline CSwordModuleInfo *clone() const {
+ return new CSwordBibleModuleInfo(*this);
+ }
+
+ inline ~CSwordBibleModuleInfo() {
+ delete m_bookList;
+ }
+
/**
- * The constructor of this class
+ \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
*/
- CSwordBibleModuleInfo( sword::SWModule* module, CSwordBackend* const );
- /** The copy constructor for this Bible module.
- */
- CSwordBibleModuleInfo( const CSwordBibleModuleInfo& m );
+ unsigned int verseCount(const unsigned int book,
+ const unsigned int chapter) const;
+
/**
- * The destructor of this class
+ \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
*/
- ~CSwordBibleModuleInfo();
+ unsigned int verseCount(const QString &book,
+ const unsigned int chapter) const;
+
/**
- * 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
+ \returns the number of available chapters in the given book.
*/
- virtual unsigned int verseCount( const unsigned int book, const unsigned int chapter );
+ unsigned int chapterCount(const unsigned int book) const;
+
/**
- * 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.
+ \returns the number of available chapters in 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();
+ unsigned int chapterCount(const QString &book) const;
+
/**
- * Reimplementation, Returns the type
+ \returns a QStringList containing the books available in this module.
*/
- virtual CSwordModuleInfo::ModuleType type() const;
+ QStringList *books() const;
+
/**
- * @return the book number, values starting with 1; 0 if not found
+ \returns the index of the book given by its name.
+ \retval 0 if a book with the given name was not found.
*/
- unsigned int bookNumber(const QString &book);
+ unsigned int bookNumber(const QString &book) const;
+
/**
- * Returns true if his module has the text of desired type of testament
+ \returns whether this module has the text of desired type of testament
*/
- bool hasTestament( CSwordBibleModuleInfo::Testament );
- /** Reimplementation to clone this object. */
- virtual CSwordModuleInfo* clone();
+ bool hasTestament(CSwordBibleModuleInfo::Testament type) const {
+ return type == OldTestament ? m_hasOT : m_hasNT;
+ }
+
/**
- * Returns the key which represents the lower bound of this module.
+ \returns the key which represents the lower bound of this module.
*/
- inline const CSwordVerseKey& lowerBound();
+ inline const CSwordVerseKey &lowerBound() const {
+ return m_lowerBound;
+ }
+
/**
- * Returns the key which represents the upper bound of this module.
+ \returns the key which represents the upper bound of this module.
*/
- inline const CSwordVerseKey& upperBound();
+ inline const CSwordVerseKey &upperBound() const {
+ return m_upperBound;
+ }
- private:
+ private: /* Methods: */
void initBounds();
+ private:
CSwordVerseKey m_lowerBound;
CSwordVerseKey m_upperBound;
- QStringList* m_bookList; //This booklist is cached
- QString m_cachedLocale;
- short int m_hasOT;
- short int m_hasNT;
+ mutable QStringList *m_bookList; //This booklist is cached
+ mutable QString m_cachedLocale;
+ bool m_hasOT;
+ bool m_hasNT;
};
-inline CSwordModuleInfo::ModuleType CSwordBibleModuleInfo::type() const {
- return CSwordModuleInfo::Bible;
-}
-
-/** Returns the key which represents the lower bound of this module. */
-inline const CSwordVerseKey& CSwordBibleModuleInfo::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;
-}
-
#endif
diff --git a/src/backend/drivers/cswordbookmoduleinfo.cpp b/src/backend/drivers/cswordbookmoduleinfo.cpp
index 6371de1..8c6b8b1 100644
--- a/src/backend/drivers/cswordbookmoduleinfo.cpp
+++ b/src/backend/drivers/cswordbookmoduleinfo.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,33 +16,22 @@
#include <treekeyidx.h>
-CSwordBookModuleInfo::CSwordBookModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend )
- : CSwordModuleInfo(module, usedBackend),
- m_depth(-1) {}
-
-CSwordBookModuleInfo::CSwordBookModuleInfo( const CSwordBookModuleInfo& module )
- : CSwordModuleInfo(module) {
- m_depth = module.m_depth;
-}
-
-CSwordBookModuleInfo::~CSwordBookModuleInfo() {}
-
-int CSwordBookModuleInfo::depth() {
- if (m_depth == -1) {
- sword::TreeKeyIdx* key = tree();
-
- if (key) {
- key->root();
- computeDepth(key, 0);
- }
+CSwordBookModuleInfo::CSwordBookModuleInfo(sword::SWModule *module,
+ CSwordBackend * const usedBackend)
+ : CSwordModuleInfo(module, usedBackend,
+ CSwordModuleInfo::GenericBook),
+ m_depth(-1)
+{
+ sword::TreeKeyIdx *key = tree();
+ if (key) {
+ key->root();
+ computeDepth(key, 0);
}
-
- return m_depth;
}
-void CSwordBookModuleInfo::computeDepth(sword::TreeKeyIdx* key, int level ) {
+void CSwordBookModuleInfo::computeDepth(sword::TreeKeyIdx *key, int level) {
std::string savedKey;
- // savedKey = key->getFullName(); //sword 1.5.8
+ // savedKey = key->getFullName(); //sword 1.5.8
savedKey = key->getText();
if (level > m_depth) {
diff --git a/src/backend/drivers/cswordbookmoduleinfo.h b/src/backend/drivers/cswordbookmoduleinfo.h
index 77adb29..12a3d01 100644
--- a/src/backend/drivers/cswordbookmoduleinfo.h
+++ b/src/backend/drivers/cswordbookmoduleinfo.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,50 +16,48 @@
#include <treekeyidx.h>
-/** Class for generic book support
- * @author The BibleTime team
- */
+/**
+ \brief Class for generic book support
+*/
+class CSwordBookModuleInfo: public CSwordModuleInfo {
+ Q_OBJECT
-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();
+ public: /* Methods: */
/**
- * Returns the type of the module.
+ \param module The module which belongs to this object
+ \param backend The parent backend for this book module.
*/
- virtual CSwordModuleInfo::ModuleType type() const;
+ CSwordBookModuleInfo(sword::SWModule *module,
+ CSwordBackend * const usedBackend);
+
+ inline CSwordBookModuleInfo(const CSwordBookModuleInfo &copy)
+ : CSwordModuleInfo(copy), m_depth(copy.m_depth) {}
+
+ /* Reimplementation of CSwordModuleInfo::clone(). */
+ virtual inline CSwordModuleInfo *clone() const {
+ return new CSwordBookModuleInfo(*this);
+ }
+
/**
- * Returns the maximal depth of sections and subsections.
+ \returns the maximal depth of sections and subsections.
*/
- int depth();
+ inline int depth() const { return m_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.
+ \returns 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;
+ sword::TreeKeyIdx *tree() const;
- private:
+ private: /* Methods: */
/**
* A recursive helper function to help computng the module depth!
*/
- void computeDepth(sword::TreeKeyIdx* key, int level = 0 );
+ void computeDepth(sword::TreeKeyIdx *key, int level = 0);
+
+ private: /* Fields: */
int m_depth;
};
-inline CSwordBookModuleInfo::ModuleType CSwordBookModuleInfo::type() const {
- return CSwordModuleInfo::GenericBook;
-}
-
-
#endif
diff --git a/src/backend/drivers/cswordcommentarymoduleinfo.cpp b/src/backend/drivers/cswordcommentarymoduleinfo.cpp
index 8b74ffa..07e09d2 100644
--- a/src/backend/drivers/cswordcommentarymoduleinfo.cpp
+++ b/src/backend/drivers/cswordcommentarymoduleinfo.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,24 +10,11 @@
#include "backend/drivers/cswordcommentarymoduleinfo.h"
-CSwordCommentaryModuleInfo::CSwordCommentaryModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend)
- : CSwordBibleModuleInfo(module, usedBackend) {}
-
-CSwordCommentaryModuleInfo::~CSwordCommentaryModuleInfo() {}
-
-/** No descriptions */
-CSwordModuleInfo* CSwordCommentaryModuleInfo::clone() {
- 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
-
- if ( (std::string(module()->getConfigEntry("ModDrv")) == std::string("RawFiles")) && module()->isWritable()) {
- return true;
- };
-
- return false;
+ /*
+ A module is only writable if it's a RawFiles module with writable
+ returning true.
+ */
+ return std::string(module()->getConfigEntry("ModDrv")) == "RawFiles"
+ && module()->isWritable();
}
diff --git a/src/backend/drivers/cswordcommentarymoduleinfo.h b/src/backend/drivers/cswordcommentarymoduleinfo.h
index a297538..60640a2 100644
--- a/src/backend/drivers/cswordcommentarymoduleinfo.h
+++ b/src/backend/drivers/cswordcommentarymoduleinfo.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,31 +13,27 @@
#include "backend/drivers/cswordbiblemoduleinfo.h"
-/** Commentary module implementation.
- * This CSwordModule implementation provides access to Sword's commentary modules.
- * @author The BibleTime team
- * @version $Id: cswordcommentarymoduleinfo.h,v 1.13 2006/02/25 11:38:15 joachim Exp $
- */
-
-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.
- */
+/**
+ \brief Commentary module implementation.
+
+ This CSwordModule implementation provides access to Sword's commentary modules.
+*/
+class CSwordCommentaryModuleInfo: public CSwordBibleModuleInfo {
+ Q_OBJECT
+
+ public: /* Methods: */
+ inline CSwordCommentaryModuleInfo(sword::SWModule *module,
+ CSwordBackend * const usedBackend)
+ : CSwordBibleModuleInfo(module, usedBackend,
+ CSwordModuleInfo::Commentary) {}
+
+ /* Reimplementation of CSwordModuleInfo::clone(). */
+ virtual inline CSwordModuleInfo* clone() const {
+ return new CSwordCommentaryModuleInfo(*this);
+ }
+
+ /* Reimplementation of CSwordModuleInfo::isWritable(). */
virtual bool isWritable() const;
};
-inline CSwordModuleInfo::ModuleType CSwordCommentaryModuleInfo::type() const {
- return CSwordModuleInfo::Commentary;
-}
-
#endif
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.cpp b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
index c4a04de..d6515be 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.cpp
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
@@ -2,14 +2,13 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "backend/drivers/cswordlexiconmoduleinfo.h"
-#include <algorithm>
#include <QFile>
#include <QDataStream>
#include <QTextCodec>
@@ -24,45 +23,23 @@
//Change it once the format changed to make all systems rebuild their caches
#define CACHE_FORMAT "3"
-CSwordLexiconModuleInfo::CSwordLexiconModuleInfo( sword::SWModule* module, CSwordBackend* const backend ) : CSwordModuleInfo(module, backend) {
- m_entryList = 0;
-}
-
-CSwordLexiconModuleInfo::CSwordLexiconModuleInfo( const CSwordLexiconModuleInfo& m ) : CSwordModuleInfo(m) {
- delete m_entryList;
- m_entryList = 0;
-
- if (m.m_entryList) {
- m_entryList = new QStringList();
- *m_entryList = *m.m_entryList;//copy list items
- }
-}
-
-CSwordLexiconModuleInfo::~CSwordLexiconModuleInfo() {
- delete m_entryList;
- m_entryList = 0;
-}
-
-/** Returns the entries of the module. */
-QStringList* CSwordLexiconModuleInfo::entries() {
+const QStringList &CSwordLexiconModuleInfo::entries() const {
namespace DU = util::directory;
- if (!module()) {
- return 0;
+ // If cache is ok, just return it:
+ if (!m_entries.empty()) {
+ return m_entries;
}
- if (m_entryList) return m_entryList;
-
- m_entryList = new QStringList();
-
+ // Initialize cache:
//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;
+ return m_entries;
}
if ( name() == QString("EReo_en")) {
qWarning() << "Module EReo_en is buggy and will not be loaded.";
- return m_entryList;
+ return m_entries;
}
QString dir(DU::getUserCacheDir().absolutePath());
@@ -88,11 +65,11 @@ QStringList* CSwordLexiconModuleInfo::entries() {
if (ModuleVersion == config(CSwordModuleInfo::ModuleVersion)
&& CacheVersion == CACHE_FORMAT
&& QDataStreamVersion == QString::number(s.version())) {
- s >> *m_entryList;
+ s >> m_entries;
f1.close();
- qDebug() << "Read" << m_entryList->count() << "entries from lexicon cache for module" << name();
- return m_entryList;
+ qDebug() << "Read" << m_entries.count() << "entries from lexicon cache for module" << name();
+ return m_entries;
}
f1.close();
@@ -103,40 +80,37 @@ QStringList* CSwordLexiconModuleInfo::entries() {
*/
qDebug() << "Read all entries of lexicon" << name();
- sword::SWModule* my_module = module();
- my_module->setSkipConsecutiveLinks(true);
- (*my_module) = sword::TOP;
+ module()->setSkipConsecutiveLinks(true);
+ module()->setPosition(sword::TOP);
snap(); //snap to top entry
do {
if ( isUnicode() ) {
- m_entryList->append(QString::fromUtf8(my_module->KeyText()));
+ m_entries.append(QString::fromUtf8(module()->KeyText()));
}
else {
//for latin1 modules use fromLatin1 because of speed
QTextCodec* codec = QTextCodec::codecForName("Windows-1252");
- m_entryList->append(codec->toUnicode(my_module->KeyText()));
+ m_entries.append(codec->toUnicode(module()->KeyText()));
}
- (*my_module)++;
- }
- while ( !my_module->Error() );
-
- (*my_module) = sword::TOP; //back to the first entry
+ module()->increment();
+ } while (!module()->Error());
- my_module->setSkipConsecutiveLinks(false);
+ module()->setPosition(sword::TOP); // back to the first entry
+ module()->setSkipConsecutiveLinks(false);
- if (m_entryList->count()) {
- m_entryList->first().simplified();
+ if (m_entries.count()) {
+ m_entries.first().simplified();
- if (m_entryList->first().trimmed().isEmpty()) {
- m_entryList->erase( m_entryList->begin() );
+ if (m_entries.first().trimmed().isEmpty()) {
+ m_entries.erase( m_entries.begin() );
}
}
qDebug() << "Writing cache file for lexicon module" << name();
- if (m_entryList->count()) {
+ if (m_entries.count()) {
//create cache
QString dir(DU::getUserCacheDir().absolutePath());
QFile f2( QString(dir).append("/").append(name()) );
@@ -146,24 +120,10 @@ QStringList* CSwordLexiconModuleInfo::entries() {
s << config(CSwordModuleInfo::ModuleVersion) //store module version
<< QString(CACHE_FORMAT) //store BT version -- format may change
<< QString::number(s.version()) //store QDataStream version -- format may change
- << *m_entryList;
+ << m_entries;
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;
- }
-
- return false;
-}
-
-/** No descriptions */
-CSwordModuleInfo* CSwordLexiconModuleInfo::clone() {
- return new CSwordLexiconModuleInfo(*this);
+ return m_entries;
}
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.h b/src/backend/drivers/cswordlexiconmoduleinfo.h
index 36d30fb..d75e106 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.h
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,55 +16,46 @@
/**
- * The implementation of CModuleInfo for the Sword lexiccons and citionaries.
- * @author The BibleTime team
- * @version $Id: cswordlexiconmoduleinfo.h,v 1.12 2006/02/25 11:38:15 joachim Exp $
- */
+ The implementation of CModuleInfo for the Sword lexiccons and citionaries.
+*/
+class CSwordLexiconModuleInfo: public CSwordModuleInfo {
+ Q_OBJECT
-class CSwordLexiconModuleInfo : public CSwordModuleInfo {
+ public: /* Methods: */
+ inline CSwordLexiconModuleInfo(sword::SWModule *module,
+ CSwordBackend * const backend)
+ : CSwordModuleInfo(module, backend, Lexicon) {}
+
+ inline CSwordLexiconModuleInfo(const CSwordLexiconModuleInfo &copy)
+ : CSwordModuleInfo(copy), m_entries(copy.m_entries) {}
+
+ /* Reimplementation of CSwordModuleInfo::clone(). */
+ virtual inline CSwordModuleInfo *clone() const {
+ return new CSwordLexiconModuleInfo(*this);
+ }
- 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.
+ This method 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.
+ \returns the list of lexicon entries in the module.
*/
- virtual CSwordModuleInfo::ModuleType type() const;
+ const QStringList &entries() const;
+
/**
- * Jumps to the closest entry in the module.
+ Jumps to the closest entry in the module.
*/
- bool snap();
+ virtual inline bool snap() const {
+ return module()->getRawEntry();
+ }
- private:
+ private: /* Fields: */
/**
- * This is the list which caches the entres of the module.
+ This is the list which caches the entres of the module.
*/
- QStringList* m_entryList;
+ mutable QStringList m_entries;
};
-inline CSwordModuleInfo::ModuleType CSwordLexiconModuleInfo::type() const {
- return CSwordModuleInfo::Lexicon;
-}
-
#endif
diff --git a/src/backend/drivers/cswordmoduleinfo.cpp b/src/backend/drivers/cswordmoduleinfo.cpp
index 6096af2..b1e646f 100644
--- a/src/backend/drivers/cswordmoduleinfo.cpp
+++ b/src/backend/drivers/cswordmoduleinfo.cpp
@@ -2,14 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "backend/drivers/cswordmoduleinfo.h"
-#include <boost/scoped_ptr.hpp>
+#include <QSharedPointer>
#include <CLucene.h>
#include <CLucene/util/Misc.h>
#include <CLucene/util/Reader.h>
@@ -28,8 +28,9 @@
#include "backend/managers/cswordbackend.h"
#include "backend/rendering/centrydisplay.h"
#include "backend/cswordmodulesearch.h"
+#include "btglobal.h"
+#include "util/cresmgr.h"
#include "util/directory.h"
-#include "util/cpointers.h"
#include "util/exceptions.h"
#include "util/dialogutil.h"
@@ -42,6 +43,29 @@
#include <versekey.h>
+#ifdef BT_DEBUG
+namespace {
+
+/** HELPER Method to dump all current EntryAttributes of a module. */
+void dumpEntryAttributes(sword::SWModule *m) {
+ qDebug() << "Attributes for key: " << m->getKeyText();
+ sword::AttributeTypeList::iterator i1;
+ sword::AttributeList::iterator i2;
+ sword::AttributeValue::iterator i3;
+ for (i1 = m->getEntryAttributes().begin(); i1 != m->getEntryAttributes().end(); i1++) {
+ qDebug() << "[ " << i1->first << " ]";
+ for (i2 = i1->second.begin(); i2 != i1->second.end(); i2++) {
+ qDebug() << "\t[ " << i2->first << " ]";
+ for (i3 = i2->second.begin(); i3 != i2->second.end(); i3++) {
+ qDebug() << "\t\t" << i3->first << " = " << i3->second;
+ }
+ }
+ }
+}
+
+} // anonymous namespace
+#endif
+
//Increment this, if the index format changes
//Then indices on the user's systems will be rebuilt
const unsigned int INDEX_VERSION = 7;
@@ -50,69 +74,76 @@ const unsigned int INDEX_VERSION = 7;
//Lucene default is too small
const unsigned long BT_MAX_LUCENE_FIELD_LENGTH = 1024 * 1024;
-CSwordModuleInfo::CSwordModuleInfo(sword::SWModule * module, CSwordBackend * const usedBackend) {
- m_module = module;
- Q_ASSERT(module);
+CSwordModuleInfo::CSwordModuleInfo(sword::SWModule *module,
+ CSwordBackend * const usedBackend,
+ ModuleType type)
+ : m_module(module),
+ m_backend(usedBackend ? usedBackend : CSwordBackend::instance()),
+ m_type(type),
+ m_cancelIndexing(false),
+ m_cachedName(QString::fromUtf8(module->Name())),
+ m_cachedHasVersion(!QString((*m_backend->getConfig())[module->Name()]["Version"]).isEmpty())
+{
+ Q_ASSERT(module != 0);
+ Q_ASSERT(usedBackend != 0);
+
+ initCachedCategory();
+ initCachedLanguage();
- 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();
m_hidden = CBTConfig::get(CBTConfig::hiddenModules).contains(name());
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());
+
+ /// \todo if this is the case, can we use the module at all?
}
}
}
-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;
+CSwordModuleInfo::CSwordModuleInfo(const CSwordModuleInfo &o)
+ : QObject(0), m_module(o.m_module), m_backend(o.m_backend),
+ m_type(o.m_type), m_hidden(o.m_hidden),
+ m_cancelIndexing(o.m_cancelIndexing), m_cachedName(o.m_cachedName),
+ m_cachedCategory(o.m_cachedCategory),
+ m_cachedLanguage(o.m_cachedLanguage),
+ m_cachedHasVersion(o.m_cachedHasVersion)
+{
+ // Intentionally empty
}
-/** No descriptions */
-CSwordModuleInfo *CSwordModuleInfo::clone() {
- return new CSwordModuleInfo(*this);
-}
-
-CSwordModuleInfo::~CSwordModuleInfo() {
- 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;
}
+ bool unlocked = unlockKeyIsValid();
+
CBTConfig::setModuleEncryptionKey(name(), unlockKey);
+
+ /// \todo remove this comment once it is no longer needed
+ /* There is currently a deficiency in sword 1.6.1 in that backend->setCipherKey() does
+ * not work correctly for modules from which data was already fetched. Therefore we have to
+ * reload the modules in bibletime.cpp
+ */
backend()->setCipherKey(m_module->Name(), unlockKey.toUtf8().constData());
+
/// \todo write to Sword config as well
+ if (unlockKeyIsValid() != unlocked) {
+ emit unlockedChanged(!unlocked);
+ }
return true;
}
-/** This function returns true if this module is locked, otherwise return false. */
-bool CSwordModuleInfo::isLocked() {
+bool CSwordModuleInfo::isLocked() const {
//still works, but the cipherkey is stored in CBTConfig.
//Works because it is set in sword on program startup.
return isEncrypted() && !unlockKeyIsValid();
}
-/** This functions returns true if this module is encrypted (locked or unlocked). */
bool CSwordModuleInfo::isEncrypted() const {
/**
* If we have the CipherKey entry the module
@@ -120,22 +151,18 @@ bool CSwordModuleInfo::isEncrypted() const {
*/
//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;
+ std::map < sword::SWBuf, sword::ConfigEntMap, std::less < sword::SWBuf > >::iterator SectionMapIter;
+ SectionMapIter = backend()->getConfig()->Sections.find(name().toUtf8().constData());
+ if (SectionMapIter == backend()->getConfig()->Sections.end())
+ return false;
+ sword::ConfigEntMap config = SectionMapIter->second;
sword::ConfigEntMap::iterator it = config.find("CipherKey");
return it != config.end();
}
-/** This function makes an estimate if a module was properly unlocked.
-* It returns true if the first entry of the module is not empty and
-* contains only printable characters (for the first 100 chars or so).
-* If that is the case, we can safely assume that a) the module was properly
-* unlocked and b) no buffer overflows will occur, which can happen when
-* Sword filters process garbage text which was not properly decrypted.
-*/
-bool CSwordModuleInfo::unlockKeyIsValid() {
-
- (*m_module) = sword::TOP;
+bool CSwordModuleInfo::unlockKeyIsValid() const {
+ m_module->setPosition(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
@@ -146,18 +173,15 @@ bool CSwordModuleInfo::unlockKeyIsValid() {
: QString::fromLatin1( m_module->getRawEntryBuf().c_str() );
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;
}
}
- qDebug() << "Unlock key of module" << name() << "is valid";
return true;
}
@@ -173,7 +197,7 @@ QString CSwordModuleInfo::getModuleStandardIndexLocation() const { //this for no
return getModuleBaseIndexLocation() + QString("/standard");
}
-bool CSwordModuleInfo::hasIndex() {
+bool CSwordModuleInfo::hasIndex() const {
//this will return true only
//if the index exists and has correct version information for both index and module
QDir d;
@@ -199,25 +223,6 @@ bool CSwordModuleInfo::hasIndex() {
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;
@@ -252,14 +257,14 @@ void CSwordModuleInfo::buildIndex() {
}
}
- boost::scoped_ptr<lucene::index::IndexWriter> writer( new lucene::index::IndexWriter(index.toAscii().constData(), &an, true) ); //always create a new index
+ QSharedPointer<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;
+ m_module->setPosition(sword::TOP);
unsigned long verseLowIndex = m_module->Index();
- *m_module = sword::BOTTOM;
+ m_module->setPosition(sword::BOTTOM);
unsigned long verseHighIndex = m_module->Index();
//verseLowIndex is not 0 in all cases (i.e. NT-only modules)
@@ -271,7 +276,7 @@ void CSwordModuleInfo::buildIndex() {
if (type() == CSwordModuleInfo::Lexicon) {
verseIndex = 0;
verseLowIndex = 0;
- verseSpan = ((CSwordLexiconModuleInfo*)this)->entries()->size();
+ verseSpan = ((CSwordLexiconModuleInfo*)this)->entries().size();
}
emit indexingProgress(0);
@@ -296,14 +301,15 @@ void CSwordModuleInfo::buildIndex() {
wchar_t wcharBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
- for (*m_module = sword::TOP; !(m_module->Error()) && !m_cancelIndexing; (*m_module)++) {
+ m_module->setPosition(sword::TOP);
+ while (!(m_module->Error()) && !m_cancelIndexing) {
// 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());
+ QSharedPointer<lucene::document::Document> doc(new lucene::document::Document());
//index the key
lucene_utf8towcs(wcharBuffer, key->getText(), BT_MAX_LUCENE_FIELD_LENGTH);
@@ -357,7 +363,7 @@ void CSwordModuleInfo::buildIndex() {
}
} // for attListI
- writer->addDocument(doc.get());
+ writer->addDocument(doc.data());
//Index() is not implemented properly for lexicons, so we use a
//workaround.
if (type() == CSwordModuleInfo::Lexicon) {
@@ -380,7 +386,9 @@ void CSwordModuleInfo::buildIndex() {
//m_indexingProgress.activate();
emit indexingProgress(indexingProgressValue);
}
- }
+
+ m_module->increment();
+ } // while (!(m_module->Error()) && !m_cancelIndexing)
if (!m_cancelIndexing) {
writer->optimize();
@@ -421,20 +429,23 @@ unsigned long CSwordModuleInfo::indexSize() const {
}
-bool CSwordModuleInfo::searchIndexed(const QString& searchedText, sword::ListKey& scope) {
+int CSwordModuleInfo::searchIndexed(const QString &searchedText,
+ const sword::ListKey &scope,
+ sword::ListKey &results) const
+{
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());
+ QSharedPointer < CSwordKey > key(CSwordKey::createInstance(this));
+ sword::SWKey* s = dynamic_cast < sword::SWKey * >(key.data());
QList<sword::VerseKey*> list;
if (s) {
m_module->SetKey(*s);
}
- m_searchResult.ClearList();
+ results.ClearList();
try {
// do not use any stop words
@@ -442,15 +453,16 @@ bool CSwordModuleInfo::searchIndexed(const QString& searchedText, sword::ListKey
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) );
+ QSharedPointer<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) );
+ QSharedPointer<lucene::search::Hits> h( searcher.search(q.data(), lucene::search::Sort::INDEXORDER) );
- const bool useScope = (scope.Count() > 0);
-// const bool isVerseModule = (type() == CSwordModuleInfo::Bible) || (type() == CSwordModuleInfo::Commentary);
+ /// \warning This is a workaround for Sword constness
+ const bool useScope = (const_cast<sword::ListKey&>(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() );
+ QSharedPointer<sword::SWKey> swKey( module()->CreateKey() );
for (int i = 0; i < h->length(); ++i) {
@@ -462,46 +474,34 @@ bool CSwordModuleInfo::searchIndexed(const QString& searchedText, sword::ListKey
// 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));
+ /// \warning This is a workaround for sword constness
+ for (int j = 0; j < const_cast<sword::ListKey&>(scope).Count(); j++) {
+ /// \warning This is a workaround for sword constness
+ sword::ListKey &scope2 = const_cast<sword::ListKey&>(scope);
+ sword::VerseKey* vkey = dynamic_cast<sword::VerseKey*>(scope2.getElement(j));
if (vkey->LowerBound().compare(*swKey) <= 0 && vkey->UpperBound().compare(*swKey) >= 0) {
- m_searchResult.add(*swKey);
+ results.add(*swKey);
}
}
}
else { // no scope, give me all buffers
- m_searchResult.add(*swKey);
+ results.add(*swKey);
}
}
}
catch (...) {
qWarning("CLucene exception occurred");
util::showWarning(0, QCoreApplication::tr("Search aborted"), QCoreApplication::tr("An internal error occurred while executing your search."));
- return false;
+ return 0;
}
qDeleteAll(list);
list.clear();
- 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);
- }
-
- return m_searchResult;
-}
-
-/** Clears the last search result. */
-void CSwordModuleInfo::clearSearchResult() {
- m_searchResult.ClearList();
+ return results.Count();
}
-/** Returns the required Sword version for this module. Returns -1 if no special Sword version is required. */
-sword::SWVersion CSwordModuleInfo::minimumSwordVersion() {
+sword::SWVersion CSwordModuleInfo::minimumSwordVersion() const {
return sword::SWVersion(config(CSwordModuleInfo::MinimumSwordVersion).toUtf8().constData());
}
@@ -634,12 +634,11 @@ QString CSwordModuleInfo::config(const CSwordModuleInfo::ConfigEntry entry) cons
}
}
-/** Returns true if the module supports the feature given as parameter. */
bool CSwordModuleInfo::has(const CSwordModuleInfo::Feature feature) const {
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");
@@ -684,25 +683,20 @@ bool CSwordModuleInfo::has(const CSwordModuleInfo::FilterTypes option) const {
return false;
}
-/** Returns the text direction of the module's text., */
-CSwordModuleInfo::TextDirection CSwordModuleInfo::textDirection() {
- if (config(TextDir) == "RtoL") {
+CSwordModuleInfo::TextDirection CSwordModuleInfo::textDirection() const {
+ if (config(TextDir) == "RtoL")
return CSwordModuleInfo::RightToLeft;
- }
- else {
- return CSwordModuleInfo::LeftToRight;
- }
+
+ 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) {
+void CSwordModuleInfo::write(CSwordKey *key, const QString &newText) {
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());
}
-/** 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());
@@ -714,43 +708,48 @@ bool CSwordModuleInfo::deleteEntry(CSwordKey * const key) {
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();
+void CSwordModuleInfo::initCachedCategory() {
+ /// \todo Maybe we can use raw string comparsion instead of QString?
+ const QString cat(m_module->getConfigEntry("Category"));
- 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;
+ /// \warning cat has to be checked before type() !!!
+ if (cat == "Cults / Unorthodox / Questionable Material") {
+ m_cachedCategory = Cult;
+ } else if (cat == "Daily Devotional"
+ || m_module->getConfig().has("Feature","DailyDevotion"))
+ {
+ m_cachedCategory = DailyDevotional;
+ } else if (cat == "Glossaries"
+ || m_module->getConfig().has("Feature", "Glossary"))
+ {
+ m_cachedCategory = Glossary;
+ } else if (cat == "Images" || cat == "Maps") {
+ m_cachedCategory = Images;
+ } else {
+ switch (type()) {
+ case Bible: m_cachedCategory = Bibles; break;
+ case Commentary: m_cachedCategory = Commentaries; break;
+ case Lexicon: m_cachedCategory = Lexicons; break;
+ case GenericBook: m_cachedCategory = Books; break;
+ case Unknown: // Fall thru
+ default: m_cachedCategory = UnknownCategory; break;
}
}
- //qDebug() << "assigned category: " << m_dataCache.category;
- return m_dataCache.category;
}
-/** Returns the display object for this module. */
+void CSwordModuleInfo::initCachedLanguage() {
+ CLanguageMgr *lm = CLanguageMgr::instance();
+ if (category() == Glossary) {
+ /*
+ Special handling for glossaries, we use the "from language" as
+ language for the module.
+ */
+ m_cachedLanguage = lm->languageForAbbrev(config(GlossaryFrom));
+ } else {
+ m_cachedLanguage = lm->languageForAbbrev(m_module->Lang());
+ }
+}
+
Rendering::CEntryDisplay * CSwordModuleInfo::getDisplay() const {
return dynamic_cast < Rendering::CEntryDisplay * >(m_module->Disp());
}
@@ -873,30 +872,114 @@ QString CSwordModuleInfo::aboutText() const {
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));
+QIcon CSwordModuleInfo::moduleIcon(const CSwordModuleInfo *module) {
+ const QString &filename = moduleIconFilename(module);
+ if (filename.isEmpty()) return QIcon();
+ return util::directory::getIcon(filename);
+}
+
+const QString &CSwordModuleInfo::moduleIconFilename(
+ const CSwordModuleInfo *module)
+{
+ const CSwordModuleInfo::Category cat(module->category());
+ switch (cat) {
+ case CSwordModuleInfo::Bibles:
+ if (module->isLocked()) {
+ return CResMgr::modules::bible::icon_locked;
}
else {
- m_dataCache.language = (CPointers::languageMgr())->languageForAbbrev(module()->Lang());
+ return CResMgr::modules::bible::icon_unlocked;
}
- }
- else {
- m_dataCache.language = (CPointers::languageMgr())->defaultLanguage(); //default language
- }
+ case CSwordModuleInfo::Commentaries:
+ if (module->isLocked()) {
+ return CResMgr::modules::commentary::icon_locked;
+ }
+ else {
+ return CResMgr::modules::commentary::icon_unlocked;
+ }
+ case CSwordModuleInfo::Lexicons:
+ if (module->isLocked()) {
+ return CResMgr::modules::lexicon::icon_locked;
+ }
+ else {
+ return CResMgr::modules::lexicon::icon_unlocked;
+ }
+ case CSwordModuleInfo::Books:
+ if (module->isLocked()) {
+ return CResMgr::modules::book::icon_locked;
+ }
+ else {
+ return CResMgr::modules::book::icon_unlocked;
+ }
+ case CSwordModuleInfo::Cult:
+ case CSwordModuleInfo::Images:
+ case CSwordModuleInfo::DailyDevotional:
+ case CSwordModuleInfo::Glossary:
+ case CSwordModuleInfo::UnknownCategory:
+ default:
+ return categoryIconFilename(cat);
}
+}
- return m_dataCache.language;
+QIcon CSwordModuleInfo::categoryIcon(const CSwordModuleInfo::Category &category)
+{
+ QString filename = categoryIconFilename(category);
+ if (filename.isEmpty()) return QIcon();
+ return util::directory::getIcon(filename);
+}
+
+const QString &CSwordModuleInfo::categoryIconFilename(
+ const CSwordModuleInfo::Category &category)
+{
+ static const QString noFilename;
+
+ switch (category) {
+ case CSwordModuleInfo::Bibles:
+ return CResMgr::categories::bibles::icon;
+ case CSwordModuleInfo::Commentaries:
+ return CResMgr::categories::commentaries::icon;
+ case CSwordModuleInfo::Books:
+ return CResMgr::categories::books::icon;
+ case CSwordModuleInfo::Cult:
+ return CResMgr::categories::cults::icon;
+ case CSwordModuleInfo::Images:
+ return CResMgr::categories::images::icon;
+ case CSwordModuleInfo::DailyDevotional:
+ return CResMgr::categories::dailydevotional::icon;
+ case CSwordModuleInfo::Lexicons:
+ return CResMgr::categories::lexicons::icon;
+ case CSwordModuleInfo::Glossary:
+ return CResMgr::categories::glossary::icon;
+ case CSwordModuleInfo::UnknownCategory:
+ default:
+ return noFilename;
+ }
}
+QString CSwordModuleInfo::categoryName(
+ const CSwordModuleInfo::Category &category) {
+ switch (category) {
+ case CSwordModuleInfo::Bibles:
+ return tr("Bibles");
+ case CSwordModuleInfo::Commentaries:
+ return tr("Commentaries");
+ case CSwordModuleInfo::Books:
+ return tr("Books");
+ case CSwordModuleInfo::Cult:
+ return tr("Cults/Unorthodox");
+ case CSwordModuleInfo::Images:
+ return tr("Maps and Images");
+ case CSwordModuleInfo::DailyDevotional:
+ return tr("Daily Devotionals");
+ case CSwordModuleInfo::Lexicons:
+ return tr("Lexicons and Dictionaries");
+ case CSwordModuleInfo::Glossary:
+ return tr("Glossaries");
+ default:
+ return tr("Unknown");
+ }
+}
-/*!
- \fn CSwordModuleInfo::getSimpleConfigEntry(char* name)
-*/
QString CSwordModuleInfo::getSimpleConfigEntry(const QString& name) const {
QString ret = isUnicode()
? QString::fromUtf8(m_module->getConfigEntry(name.toUtf8().constData()))
@@ -933,3 +1016,4 @@ bool CSwordModuleInfo::setHidden(bool hide) {
emit hiddenChanged(hide);
return true;
}
+
diff --git a/src/backend/drivers/cswordmoduleinfo.h b/src/backend/drivers/cswordmoduleinfo.h
index a767c41..d7397de 100644
--- a/src/backend/drivers/cswordmoduleinfo.h
+++ b/src/backend/drivers/cswordmoduleinfo.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -162,25 +162,28 @@ class CSwordModuleInfo: public QObject {
*/
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();
+ CSwordModuleInfo(sword::SWModule *module,
+ CSwordBackend * const = 0,
+ ModuleType type = Unknown);
+
+ CSwordModuleInfo(const CSwordModuleInfo &copy);
+
+ virtual CSwordModuleInfo *clone() const = 0;
+
+ virtual inline ~CSwordModuleInfo() {}
+
/**
* Returns the module object so all objects can access the original Sword module.
*/
- sword::SWModule* module() const;
+ inline sword::SWModule *module() const {
+ return m_module;
+ }
+
/**
- * 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.
+ * Sets the unlock key of the modules and writes the key into the config 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 );
/**
@@ -200,99 +203,130 @@ class CSwordModuleInfo: public QObject {
/**
* 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 isLocked() const;
- bool unlockKeyIsValid();
- /** The module version.
- * @return true if this module has a version number and false if it doesn't have one.
+ /**
+ This function makes an estimate if a module was properly unlocked. It
+ returns true if the first entry of the module is not empty and
+ contains only printable characters (for the first 100 chars or so). If
+ that is the case, we can safely assume that a) the module was properly
+ unlocked and b) no buffer overflows will occur, which can happen when
+ Sword filters process garbage text which was not properly decrypted.
*/
- inline bool hasVersion() const;
+ bool unlockKeyIsValid() const;
/**
- * Returns true if the module's index has been built.
+ \retval true if this module has a version number
+ \retval false if it doesn't have a version number
*/
- virtual bool hasIndex();
+ inline bool hasVersion() const {
+ return m_cachedHasVersion;
+ }
+
/**
- * Returns the path to this module's index base dir
+ \returns true if the module's index has been built.
*/
- virtual QString getModuleBaseIndexLocation() const;
+ bool hasIndex() const;
+
/**
- * Returns the path to this module's standard index
+ \returns the path to this module's index base dir
*/
- virtual QString getModuleStandardIndexLocation() const;
- /**
- * Builds a search index for this module
- */
- virtual void buildIndex();
+ QString getModuleBaseIndexLocation() const;
+
/**
- * Returns index size
+ \returns the path to this module's standard index
*/
- virtual unsigned long indexSize() const;
+ QString getModuleStandardIndexLocation() 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.
+ Builds a search index for this module
*/
- virtual bool searchIndexed(const QString& searchedText, sword::ListKey& scope);
+ void buildIndex();
+
/**
- * Returns the last search result for this module.
- * The last result is cleared by @ref search
+ \returns index size
*/
- virtual sword::ListKey& searchResult( const sword::ListKey* newResult = 0 );
+ unsigned long indexSize() const;
+
/**
- * Clears the last search result.
- * This does immediately clean the last search result,
- * no matter if search is in progress or not.
+ This function uses CLucene to perform and index based search. It also
+ overwrites the variable containing the last search result.
+ \returns the number of results found
*/
- void clearSearchResult();
+ int searchIndexed(const QString &searchedText,
+ const sword::ListKey &scope,
+ sword::ListKey &results) const;
+
/**
- * Returns the type of the module.
+ \returns the type of the module.
*/
- virtual CSwordModuleInfo::ModuleType type() const;
+ inline ModuleType type() const {
+ return m_type;
+ }
+
/**
* Returns the required Sword version for this module.
* Returns -1 if no special Sword version is required.
*/
- sword::SWVersion minimumSwordVersion();
+ sword::SWVersion minimumSwordVersion() const;
+
/**
- * Returns the name of the module.
- * @return The name of this module.
+ \note The Sword library takes care of the duplicate names: _n is added
+ after each duplicate.
+ \returns The name of this module.
*/
- QString name() const;
+ inline const QString &name() const {
+ return m_cachedName;
+ }
+
/**
* Snaps to the closest entry in the module if the current key is
* not present in the data files.
*/
- virtual bool snap() {
+ virtual inline bool snap() const {
return false;
}
- bool has( const CSwordModuleInfo::Feature ) const;
- bool has( const CSwordModuleInfo::FilterTypes ) const;
/**
- * Returns the text direction of the module's text.,
+ \returns whether the module supports the feature given as parameter.
+ */
+ 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();
+ CSwordModuleInfo::TextDirection textDirection() const;
+
/**
- * Writes the new text at the given position into the module. This does only work for writabe modules.
+ 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 );
+ void write(CSwordKey *key, const QString &newText);
+
/**
- * Deletes the current entry and removes it from the module.
+ Deletes the current entry and removes it from the module.
*/
- bool deleteEntry( CSwordKey* const key );
+ bool deleteEntry(CSwordKey * const key);
+
/**
- * Returns the language of the module.
+ \returns the language of the module.
*/
- const CLanguageMgr::Language* language() const;
+ inline const CLanguageMgr::Language *language() const {
+ return m_cachedLanguage;
+ }
+
/**
- * Returns true if this module may be written by the write display windows.
+ \returns whether this module may be written to.
*/
- inline virtual bool isWritable() const;
+ inline virtual bool isWritable() const {
+ return false;
+ }
+
/**
* Returns true if this module is hidden (not to be shown with other modules in certain views).
*/
@@ -308,9 +342,12 @@ class CSwordModuleInfo: public QObject {
bool setHidden(bool hide);
/**
- * Returns the category of this module. See CSwordModuleInfo::Category for possible values.
+ \returns the category of this module.
*/
- CSwordModuleInfo::Category category() const;
+ inline CSwordModuleInfo::Category category() const {
+ return m_cachedCategory;
+ }
+
/**
* The about text which belongs to this module.
*/
@@ -320,9 +357,39 @@ class CSwordModuleInfo: public QObject {
* Protected because it should not be used outside of the CSword*ModuleInfo classes.
*/
inline bool isUnicode() const {
- return m_dataCache.isUnicode;
+ return m_module->isUnicode();
}
+ /**
+ Returns an icon for the given module.
+ \param[in] module The module whose icon to return.
+ */
+ static QIcon moduleIcon(const CSwordModuleInfo *module);
+
+ /**
+ Returns the icon filename for the given module.
+ \param[in] module The module whose icon filename to return.
+ */
+ static const QString &moduleIconFilename(const CSwordModuleInfo *module);
+
+ /**
+ Returns an icon for the category of given module.
+ \param[in] module The module whose category icon to return.
+ */
+ static QIcon categoryIcon(const CSwordModuleInfo::Category &category);
+
+ /**
+ Returns the icon filename for the category of given module.
+ \param[in] module The module whose category icon filename to return.
+ */
+ static const QString &categoryIconFilename(const CSwordModuleInfo::Category &category);
+
+ /**
+ Returns a translated name for the given category.
+ \param[in] module The category whose translated name to return.
+ */
+ static QString categoryName(const CSwordModuleInfo::Category &category);
+
public slots:
inline void cancelIndexing() {
m_cancelIndexing = true;
@@ -344,66 +411,42 @@ class CSwordModuleInfo: public QObject {
QString getSimpleConfigEntry(const QString& name) const;
QString getFormattedConfigEntry(const QString& name) const;
+ private: /* Methods: */
+ /**
+ Initializes CSwordModuleInfo::m_cachedCategory.
+ \pre m_module must be set
+ */
+ void initCachedCategory();
+
+ /**
+ Initializes CSwordModuleInfo::m_cachedLanguage.
+ \pre CSwordModuleInfo::m_module must be set
+ \pre CSwordModuleInfo::m_cachedLanguage must be set
+ */
+ void initCachedLanguage();
+
signals:
- void hasIndexChanged(bool);
- void hiddenChanged(bool);
+ void hasIndexChanged(bool hasIndex);
+ void hiddenChanged(bool hidden);
+ void unlockedChanged(bool unlocked);
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;
-
+ sword::SWModule * const m_module;
+ CSwordBackend *m_backend;
+ ModuleType m_type;
bool m_hidden;
-
bool m_cancelIndexing;
+
+ // Cached data:
+ const QString m_cachedName;
+ CSwordModuleInfo::Category m_cachedCategory;
+ const CLanguageMgr::Language *m_cachedLanguage;
+ bool m_cachedHasVersion;
};
Q_DECLARE_METATYPE(CSwordModuleInfo::Category);
Q_DECLARE_OPERATORS_FOR_FLAGS(CSwordModuleInfo::Categories)
-inline CSwordModuleInfo::ModuleType CSwordModuleInfo::type() const {
- return CSwordModuleInfo::Unknown;
-}
-
-inline sword::SWModule* CSwordModuleInfo::module() const {
- return m_module;
-}
-
-inline bool CSwordModuleInfo::hasVersion() const {
- return m_dataCache.hasVersion;
-}
-
-
-/**
-* Returns the name of the module.
-* The Sword library takes care of the duplicate names: _n is added after each duplicate.
-*/
-inline QString CSwordModuleInfo::name() const {
- return m_dataCache.name;
-}
-
-/** Returns true if this module may be written by the write display windows. */
-inline bool CSwordModuleInfo::isWritable() const {
- return false;
-}
-
-//#include "util/cpointers.h"
-
#endif
diff --git a/src/backend/filters/bt_gbfhtml.h b/src/backend/filters/bt_gbfhtml.h
deleted file mode 100644
index 45e7e59..0000000
--- a/src/backend/filters/bt_gbfhtml.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BT_GBFHTML_H
-#define BT_GBFHTML_H
-
-// Sword includes:
-#include <gbfhtml.h>
-
-
-namespace Filters {
-
-/** GBF to HTML filter,
-* This filter converts GBF Text into HTML
-*/
-
-class BT_GBFHTML : public sword::GBFHTML { /*, protected CFilterTool */
-
- protected:
-
- 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;
- }
-
- short unsigned int swordFootnote;
- };
-
- 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);
-};
-
-}
-
-#endif
diff --git a/src/backend/filters/bt_osishtml.h b/src/backend/filters/bt_osishtml.h
deleted file mode 100644
index 83bf0a9..0000000
--- a/src/backend/filters/bt_osishtml.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BT_OSISHTML_H
-#define BT_OSISHTML_H
-
-// Sword includes:
-#include <osishtmlhref.h>
-#include <swbuf.h>
-#include <swmodule.h>
-
-namespace Filters {
-
-/** 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);
-};
-
-} //end of Filters namespace
-
-#endif
diff --git a/src/backend/filters/bt_plainhtml.h b/src/backend/filters/bt_plainhtml.h
deleted file mode 100644
index c228660..0000000
--- a/src/backend/filters/bt_plainhtml.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BT_PLAINHTML_H
-#define BT_PLAINHTML_H
-
-// Sword includes:
-#include <swbuf.h>
-#include <swfilter.h>
-
-
-class SWKey;
-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();
-};
-}
-
-#endif
diff --git a/src/backend/filters/bt_teihtml.h b/src/backend/filters/bt_teihtml.h
deleted file mode 100644
index 2160349..0000000
--- a/src/backend/filters/bt_teihtml.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BT_TEIHTML_H
-#define BT_TEIHTML_H
-
-// Sword includes:
-#include <teihtmlhref.h>
-#include <swbuf.h>
-
-namespace Filters {
-
-/** BibleTime's TEI to HTMl filter.
-* This filter works on TEI tags and outputs HTML in the structure supported by BibleTime.
-*/
-
-class BT_TEIHTML : public sword::TEIHTMLHREF {
-
- public:
- BT_TEIHTML();
- virtual bool handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData);
- private:
- void renderReference(const char *osisRef, sword::SWBuf &buf, sword::BasicFilterUserData *myUserData);
-};
-
-} //end of Filters namespace
-
-#endif
diff --git a/src/backend/filters/bt_thmlhtml.h b/src/backend/filters/bt_thmlhtml.h
deleted file mode 100644
index 6a220b6..0000000
--- a/src/backend/filters/bt_thmlhtml.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BT_THMLHTML_H
-#define BT_THMLHTML_H
-
-// Sword includes:
-#include <swbuf.h>
-#include <thmlhtml.h>
-
-
-namespace Filters {
-
-/** ThML to HTML filter.
-* This filter converts ThML text to HTML text
-*/
-
-class BT_ThMLHTML : public sword::ThMLHTML {
-
- protected:
-
- 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;
- }
-
- 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);
- }
-
- 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);
-};
-
-}
-
-#endif
diff --git a/src/backend/filters/bt_thmlplain.h b/src/backend/filters/bt_thmlplain.h
deleted file mode 100644
index 92c2c33..0000000
--- a/src/backend/filters/bt_thmlplain.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BT_THMLPLAIN_H
-#define BT_THMLPLAIN_H
-
-// Sword includes:
-#include <swbuf.h>
-#include <swfilter.h>
-
-
-namespace Filters {
-
-/** 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();
-};
-
-}
-#endif
diff --git a/src/backend/filters/bt_gbfhtml.cpp b/src/backend/filters/gbftohtml.cpp
index 8d6a36a..fac70ba 100644
--- a/src/backend/filters/bt_gbfhtml.cpp
+++ b/src/backend/filters/gbftohtml.cpp
@@ -2,24 +2,23 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "backend/filters/bt_gbfhtml.h"
+#include "backend/filters/gbftohtml.h"
#include <QRegExp>
#include <QString>
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
-#include "util/cpointers.h"
// Sword includes:
#include <utilxml.h>
-Filters::BT_GBFHTML::BT_GBFHTML() : sword::GBFHTML() {
+Filters::GbfToHtml::GbfToHtml() : sword::GBFHTML() {
setEscapeStringCaseSensitive(true);
setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
@@ -72,14 +71,14 @@ Filters::BT_GBFHTML::BT_GBFHTML() : sword::GBFHTML() {
}
/** No descriptions */
-char Filters::BT_GBFHTML::processText(sword::SWBuf& buf, const sword::SWKey * key, const sword::SWModule * module) {
+char Filters::GbfToHtml::processText(sword::SWBuf& buf, const sword::SWKey * key, const sword::SWModule * module) {
GBFHTML::processText(buf, key, module);
if (!module->isProcessEntryAttributes()) {
return 1; //no processing should be done, may happen in a search
}
- CSwordModuleInfo* m = CPointers::backend()->findModuleByName( module->Name() );
+ CSwordModuleInfo* m = CSwordBackend::instance()->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
@@ -227,13 +226,11 @@ char Filters::BT_GBFHTML::processText(sword::SWBuf& buf, const sword::SWKey * ke
return 1;
}
-bool Filters::BT_GBFHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) {
+bool Filters::GbfToHtml::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);
+ UserData* myUserData = dynamic_cast<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)
@@ -272,7 +269,7 @@ bool Filters::BT_GBFHTML::handleToken(sword::SWBuf &buf, const char *token, swor
else if (!strncmp(token, "FN", 2)) { //the end </font> tag is inserted in addTokenSubsitute
buf.append("<font face=\"");
- for (i = 2; i < tokenLength; i++) {
+ for (unsigned long i = 2; i < tokenLength; i++) {
if (token[i] != '\"') {
buf.append( token[i] );
}
diff --git a/src/backend/filters/gbftohtml.h b/src/backend/filters/gbftohtml.h
new file mode 100644
index 0000000..fbe5db2
--- /dev/null
+++ b/src/backend/filters/gbftohtml.h
@@ -0,0 +1,61 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef FILTERS_GBFTOHTML_H
+#define FILTERS_GBFTOHTML_H
+
+// Sword includes:
+#include <gbfhtml.h>
+
+
+namespace Filters {
+
+/**
+ \brief GBF to HTML conversion filter.
+*/
+class GbfToHtml: public sword::GBFHTML {
+ protected: /* Types: */
+ class UserData: public sword::GBFHTML::MyUserData {
+ public:
+ inline UserData(const sword::SWModule *module,
+ const sword::SWKey *key)
+ : sword::GBFHTML::MyUserData(module, key),
+ swordFootnote(1)
+ {
+ hasFootnotePreTag = false;
+ }
+
+ short unsigned int swordFootnote;
+ };
+
+ public: /* Methods: */
+ GbfToHtml();
+
+ /** Reimplemented from sword::OSISHTMLHREF. */
+ virtual bool handleToken(sword::SWBuf &buf,
+ const char *token,
+ sword::BasicFilterUserData *userData);
+
+ /** Reimplemented from sword::SWFilter. */
+ virtual char processText(sword::SWBuf &buf,
+ const sword::SWKey *key,
+ const sword::SWModule *module = 0);
+
+ protected: /* Methods: */
+ /** Reimplemented from sword::OSISHTMLHREF. */
+ virtual inline sword::BasicFilterUserData *createUserData(
+ const sword::SWModule *module, const sword::SWKey *key)
+ {
+ return new UserData(module, key);
+ }
+};
+
+} // namespace Filters
+
+#endif
diff --git a/src/backend/filters/osismorphsegmentation.cpp b/src/backend/filters/osismorphsegmentation.cpp
index 512fe2e..421b63e 100644
--- a/src/backend/filters/osismorphsegmentation.cpp
+++ b/src/backend/filters/osismorphsegmentation.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -67,7 +67,7 @@ char Filters::OSISMorphSegmentation::processText(sword::SWBuf &text, const sword
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
diff --git a/src/backend/filters/osismorphsegmentation.h b/src/backend/filters/osismorphsegmentation.h
index c5bbb18..4843488 100644
--- a/src/backend/filters/osismorphsegmentation.h
+++ b/src/backend/filters/osismorphsegmentation.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/backend/filters/bt_osishtml.cpp b/src/backend/filters/osistohtml.cpp
index 7525aca..c04c820 100644
--- a/src/backend/filters/bt_osishtml.cpp
+++ b/src/backend/filters/osistohtml.cpp
@@ -2,19 +2,18 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "backend/filters/bt_osishtml.h"
+#include "backend/filters/osistohtml.h"
#include <QString>
#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/clanguagemgr.h"
#include "backend/managers/referencemanager.h"
-#include "util/cpointers.h"
// Sword includes:
#include <swbuf.h>
@@ -22,7 +21,7 @@
#include <utilxml.h>
-Filters::BT_OSISHTML::BT_OSISHTML() : sword::OSISHTMLHREF() {
+Filters::OsisToHtml::OsisToHtml() : sword::OSISHTMLHREF() {
setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
addTokenSubstitute("inscription", "<span class=\"inscription\">");
@@ -31,12 +30,12 @@ Filters::BT_OSISHTML::BT_OSISHTML() : sword::OSISHTMLHREF() {
addTokenSubstitute("mentioned", "<span class=\"mentioned\">");
addTokenSubstitute("/mentioned", "</span>");
-// addTokenSubstitute("divineName", "<span class=\"name\"><span class=\"divine\">");
-// addTokenSubstitute("/divineName", "</span></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
-// addTokenSubstitute("seg type=\"morph\"", "<span class=\"morphSegmentation\">");
-// addTokenSubstitute("/seg", "</span>");
+// addTokenSubstitute("seg type=\"morph\"", "<span class=\"morphSegmentation\">");
+// addTokenSubstitute("/seg", "</span>");
// OSIS tables
addTokenSubstitute("table", "<table>");
@@ -48,11 +47,11 @@ Filters::BT_OSISHTML::BT_OSISHTML() : sword::OSISHTMLHREF() {
}
-bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) {
+bool Filters::OsisToHtml::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);
+ UserData* myUserData = dynamic_cast<UserData*>(userData);
sword::SWModule* myModule = const_cast<sword::SWModule*>(myUserData->module); //hack
sword::XMLTag tag(token);
@@ -185,7 +184,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
}
//strongs is handled by BibleTime
/*else if (!strncmp("strongs", attrib, val-atrrib)) {
- attrValue.append( !strncmp(attrib, "x-", 2) ? attrib+2 : attrib );
+ attrValue.append( !strncmp(attrib, "x-", 2) ? attrib+2 : attrib );
}*/
else {
attrValue.append( !strncmp(attrib, "x-", 2) ? attrib + 2 : attrib );
@@ -224,7 +223,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
if (type == "crossReference") { //note containing cross references
myUserData->inCrossrefNote = true;
- myUserData->noteType = BT_UserData::CrossReference;
+ myUserData->noteType = UserData::CrossReference;
/*
* Do not count crossrefs as footnotes if they are displayed in the text. This will cause problems
@@ -251,7 +250,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
*/
myUserData->suspendTextPassThru = true;
- myUserData->noteType = BT_UserData::StrongsMarkup;
+ myUserData->noteType = UserData::StrongsMarkup;
}
else {
@@ -269,20 +268,20 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
buf.append( (n.length() > 0) ? n.c_str() : "*" );
buf.append("</span> ");
- myUserData->noteType = BT_UserData::Footnote;
+ myUserData->noteType = UserData::Footnote;
myUserData->suspendTextPassThru = true;
}
}
else { //if (tag.isEndTag()) {
- Q_ASSERT(myUserData->noteType != BT_UserData::Unknown);
+ Q_ASSERT(myUserData->noteType != UserData::Unknown);
- if (myUserData->noteType == BT_UserData::CrossReference) {
+ if (myUserData->noteType == UserData::CrossReference) {
buf.append("</span> ");
-// myUserData->suspendTextPassThru = false;
+// myUserData->suspendTextPassThru = false;
myUserData->inCrossrefNote = false;
}
- myUserData->noteType = BT_UserData::Unknown;
+ myUserData->noteType = UserData::Unknown;
myUserData->suspendTextPassThru = false;
}
}
@@ -425,15 +424,18 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
// <q> quote
else if (!strcmp(tag.getName(), "q")) {
- sword::SWBuf type = tag.getAttribute("type");
+ //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");
+ sword::SWBuf quoteMarker = tag.getAttribute("marker");
if ((!tag.isEndTag())) {
- myUserData->quote.who = who;
- if (quoteMarker) {
+ if (!tag.isEmpty()) {
+ myUserData->quote.who = who;
+ }
+
+ if (quoteMarker.size() > 0) {
buf.append(quoteMarker);
}
else if (osisQToTick) //alternate " and '
@@ -447,7 +449,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
if (myUserData->quote.who == "Jesus") {
buf.append("</span>");
}
- if (quoteMarker) {
+ if (quoteMarker.size() > 0) {
buf.append(quoteMarker);
}
else if (osisQToTick) { //alternate " and '
@@ -536,7 +538,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
return false;
}
-void Filters::BT_OSISHTML::renderReference(const char *osisRef, sword::SWBuf &buf, sword::SWModule *myModule, BT_UserData *myUserData) {
+void Filters::OsisToHtml::renderReference(const char *osisRef, sword::SWBuf &buf, sword::SWModule *myModule, UserData *myUserData) {
QString ref( osisRef );
QString hrefRef( ref );
//Q_ASSERT(!ref.isEmpty()); checked later
@@ -546,7 +548,7 @@ void Filters::BT_OSISHTML::renderReference(const char *osisRef, sword::SWBuf &bu
//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);
+ CSwordModuleInfo* mod = CSwordBackend::instance()->findSwordModuleByPointer(myModule);
//Q_ASSERT(mod); checked later
if (!mod || (mod->type() != CSwordModuleInfo::Bible
&& mod->type() != CSwordModuleInfo::Commentary)) {
@@ -563,8 +565,8 @@ void Filters::BT_OSISHTML::renderReference(const char *osisRef, sword::SWBuf &bu
QString newModuleName = ref.left(pos);
hrefRef = ref.mid(pos + 1);
- if (CPointers::backend()->findModuleByName(newModuleName)) {
- mod = CPointers::backend()->findModuleByName(newModuleName);
+ if (CSwordBackend::instance()->findModuleByName(newModuleName)) {
+ mod = CSwordBackend::instance()->findModuleByName(newModuleName);
}
}
diff --git a/src/backend/filters/osistohtml.h b/src/backend/filters/osistohtml.h
new file mode 100644
index 0000000..ca36fe6
--- /dev/null
+++ b/src/backend/filters/osistohtml.h
@@ -0,0 +1,75 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef FILTERS_OSISTOHTML_H
+#define FILTERS_OSISTOHTML_H
+
+// Sword includes:
+#include <osishtmlhref.h>
+#include <swbuf.h>
+#include <swmodule.h>
+
+namespace Filters {
+
+/**
+ \brief OSIS to HTMl conversion filter.
+*/
+class OsisToHtml: public sword::OSISHTMLHREF {
+ protected: /* Types: */
+ class UserData: public sword::OSISHTMLHREF::MyUserData {
+ public:
+ inline UserData(const sword::SWModule *module,
+ const sword::SWKey *key)
+ : sword::OSISHTMLHREF::MyUserData(module, key),
+ swordFootnote(1), inCrossrefNote(false),
+ entryAttributes(module->getEntryAttributes()),
+ noteType(Unknown) {}
+
+ unsigned short int swordFootnote;
+ bool inCrossrefNote;
+ sword::AttributeTypeList entryAttributes;
+
+ enum NoteType {
+ Unknown,
+ Alternative,
+ CrossReference,
+ Footnote,
+ StrongsMarkup
+ } noteType;
+
+ struct {
+ sword::SWBuf who;
+ } quote;
+ };
+
+ public: /* Methods: */
+ OsisToHtml();
+
+ /** Reimplemented from sword::OSISHTMLHREF. */
+ virtual bool handleToken(sword::SWBuf &buf,
+ const char *token,
+ sword::BasicFilterUserData *userData);
+
+ protected: /* Methods: */
+ /** Reimplemented from sword::OSISHTMLHREF. */
+ virtual inline sword::BasicFilterUserData *createUserData(
+ const sword::SWModule *module,
+ const sword::SWKey *key)
+ {
+ return new UserData(module, key);
+ }
+
+ private: /* Methods: */
+ void renderReference(const char *osisRef, sword::SWBuf &buf,
+ sword::SWModule *myModule, UserData *myUserData);
+};
+
+} // namespace Filters
+
+#endif
diff --git a/src/backend/filters/bt_plainhtml.cpp b/src/backend/filters/plaintohtml.cpp
index c70db79..bc19440 100644
--- a/src/backend/filters/bt_plainhtml.cpp
+++ b/src/backend/filters/plaintohtml.cpp
@@ -2,19 +2,19 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "backend/filters/bt_plainhtml.h"
+#include "backend/filters/plaintohtml.h"
-Filters::BT_PLAINHTML::BT_PLAINHTML() : sword::SWFilter() {
+Filters::PlainToHtml::PlainToHtml() : sword::SWFilter() {
}
/** No descriptions */
-char Filters::BT_PLAINHTML::processText(sword::SWBuf& text, const sword::SWKey* /*key*/, const sword::SWModule* /*module*/) {
+char Filters::PlainToHtml::processText(sword::SWBuf& text, const sword::SWKey* /*key*/, const sword::SWModule* /*module*/) {
int count = 0;
sword::SWBuf orig = text;
diff --git a/src/backend/filters/plaintohtml.h b/src/backend/filters/plaintohtml.h
new file mode 100644
index 0000000..1093e2c
--- /dev/null
+++ b/src/backend/filters/plaintohtml.h
@@ -0,0 +1,40 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef FILTERS_PLAINTOHTML_H
+#define FILTERS_PLAINTOHTML_H
+
+// Sword includes:
+#include <swbuf.h>
+#include <swfilter.h>
+
+namespace sword {
+ class SWKey;
+ class SWModule;
+}
+
+namespace Filters {
+
+/**
+ \brief Plain text to HTML conversion filter.
+*/
+class PlainToHtml: public sword::SWFilter {
+ public: /* Methods: */
+ PlainToHtml();
+
+ protected: /* Methods: */
+ /** Reimplemented from sword::SWFilter. */
+ virtual char processText(sword::SWBuf &buf,
+ const sword::SWKey *key,
+ const sword::SWModule *module = 0);
+};
+
+} // namespace Filters
+
+#endif
diff --git a/src/backend/filters/bt_teihtml.cpp b/src/backend/filters/teitohtml.cpp
index b242f46..4b390d5 100644
--- a/src/backend/filters/bt_teihtml.cpp
+++ b/src/backend/filters/teitohtml.cpp
@@ -2,19 +2,18 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "backend/filters/bt_teihtml.h"
+#include "backend/filters/teitohtml.h"
#include <QString>
#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/clanguagemgr.h"
#include "backend/managers/referencemanager.h"
-#include "util/cpointers.h"
// Sword includes:
#include <swbuf.h>
@@ -22,12 +21,17 @@
#include <utilxml.h>
+namespace Filters {
-Filters::BT_TEIHTML::BT_TEIHTML() : sword::TEIHTMLHREF() {
- setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
+TeiToHtml::TeiToHtml()
+ : sword::TEIHTMLHREF()
+{
+ setPassThruUnknownEscapeString(true); // the HTML widget will render the HTML escape codes
}
-bool Filters::BT_TEIHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) {
+bool TeiToHtml::handleToken(sword::SWBuf &buf, const char *token,
+ sword::BasicFilterUserData *userData)
+{
// manually process if it wasn't a simple substitution
if (!substituteToken(buf, token)) {
@@ -93,7 +97,9 @@ bool Filters::BT_TEIHTML::handleToken(sword::SWBuf &buf, const char *token, swor
return false;
}
-void Filters::BT_TEIHTML::renderReference(const char *osisRef, sword::SWBuf &buf, sword::BasicFilterUserData *myUserData) {
+void TeiToHtml::renderReference(const char *osisRef, sword::SWBuf &buf,
+ sword::BasicFilterUserData *myUserData)
+{
QString ref( osisRef );
QString hrefRef( ref );
@@ -113,8 +119,8 @@ void Filters::BT_TEIHTML::renderReference(const char *osisRef, sword::SWBuf &buf
QString newModuleName = ref.left(pos);
hrefRef = ref.mid(pos + 1);
- if (CPointers::backend()->findModuleByName(newModuleName)) {
- mod = CPointers::backend()->findModuleByName(newModuleName);
+ if (CSwordBackend::instance()->findModuleByName(newModuleName)) {
+ mod = CSwordBackend::instance()->findModuleByName(newModuleName);
}
}
@@ -141,3 +147,4 @@ void Filters::BT_TEIHTML::renderReference(const char *osisRef, sword::SWBuf &buf
}
}
+} // namespace Filters
diff --git a/src/backend/filters/teitohtml.h b/src/backend/filters/teitohtml.h
new file mode 100644
index 0000000..6fcc2c6
--- /dev/null
+++ b/src/backend/filters/teitohtml.h
@@ -0,0 +1,37 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef FILTERS_TEITOHTML_H
+#define FILTERS_TEITOHTML_H
+
+// Sword includes:
+#include <teihtmlhref.h>
+#include <swbuf.h>
+
+namespace Filters {
+
+/**
+ \brief TEI to HTML conversion filter.
+*/
+class TeiToHtml: public sword::TEIHTMLHREF {
+ public: /* Methods: */
+ TeiToHtml();
+
+ /** Reimplemented from sword::OSISHTMLHREF. */
+ virtual bool handleToken(sword::SWBuf &buf, const char *token,
+ sword::BasicFilterUserData *userData);
+
+ private: /* Methods: */
+ void renderReference(const char *osisRef, sword::SWBuf &buf,
+ sword::BasicFilterUserData *myUserData);
+};
+
+} // namespace Filters
+
+#endif
diff --git a/src/backend/filters/bt_thmlhtml.cpp b/src/backend/filters/thmltohtml.cpp
index 478339c..703b362 100644
--- a/src/backend/filters/bt_thmlhtml.cpp
+++ b/src/backend/filters/thmltohtml.cpp
@@ -2,12 +2,12 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "backend/filters/bt_thmlhtml.h"
+#include "backend/filters/thmltohtml.h"
#include <QString>
#include <QRegExp>
@@ -17,7 +17,6 @@
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/clanguagemgr.h"
#include "backend/managers/referencemanager.h"
-#include "util/cpointers.h"
// Sword includes:
#include <swmodule.h>
@@ -26,7 +25,9 @@
#include <versekey.h>
-Filters::BT_ThMLHTML::BT_ThMLHTML() {
+namespace Filters {
+
+ThmlToHtml::ThmlToHtml() {
setEscapeStringCaseSensitive(true);
setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
@@ -40,10 +41,12 @@ Filters::BT_ThMLHTML::BT_ThMLHTML() {
removeTokenSubstitute("/note");
}
-char Filters::BT_ThMLHTML::processText(sword::SWBuf& buf, const sword::SWKey* key, const sword::SWModule* module) {
+char ThmlToHtml::processText(sword::SWBuf &buf, const sword::SWKey *key,
+ const sword::SWModule *module)
+{
sword::ThMLHTML::processText(buf, key, module);
- CSwordModuleInfo* m = CPointers::backend()->findModuleByName( module->Name() );
+ CSwordModuleInfo* m = CSwordBackend::instance()->findModuleByName( module->Name() );
if (m && !(m->has(CSwordModuleInfo::lemmas) || m->has(CSwordModuleInfo::strongNumbers))) { //only parse if the module has strongs or lemmas
return 1;
@@ -195,17 +198,19 @@ char Filters::BT_ThMLHTML::processText(sword::SWBuf& buf, const sword::SWKey* ke
}
-bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) {
+bool ThmlToHtml::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);
+ UserData* myUserData = dynamic_cast<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) );
+ //const CLanguageMgr::Language* const language = CLanguageMgr::instance()->languageForAbbrev( QString::fromLatin1(abbrev) );
buf.append("<span class=\"foreign\" lang=\"");
buf.append(abbrev);
@@ -383,3 +388,5 @@ bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, swo
return true;
}
+
+} // namespace Filtes
diff --git a/src/backend/filters/thmltohtml.h b/src/backend/filters/thmltohtml.h
new file mode 100644
index 0000000..99bbabb
--- /dev/null
+++ b/src/backend/filters/thmltohtml.h
@@ -0,0 +1,62 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef FILTERS_THMLTOHTML_H
+#define FILTERS_THMLTOHTML_H
+
+// Sword includes:
+#include <swbuf.h>
+#include <thmlhtml.h>
+
+
+namespace Filters {
+
+/**
+ \brief ThML to HTML conversion filter.
+*/
+class ThmlToHtml: public sword::ThMLHTML {
+ protected: /* Types: */
+ class UserData: public sword::ThMLHTML::MyUserData {
+ public:
+ inline UserData(const sword::SWModule *module,
+ const sword::SWKey *key)
+ : sword::ThMLHTML::MyUserData(module, key),
+ inscriptRef(false), inFootnoteTag(false),
+ swordFootnote(1) {}
+
+ bool inscriptRef;
+ bool inFootnoteTag;
+ unsigned short int swordFootnote;
+ };
+
+ public: /* Methods: */
+ ThmlToHtml();
+
+ /** Reimplemented from sword::OSISHTMLHREF. */
+ virtual bool handleToken(sword::SWBuf &buf,
+ const char *token,
+ sword::BasicFilterUserData *userData);
+
+ /** Reimplemented from sword::SWFilter. */
+ virtual char processText(sword::SWBuf &buf,
+ const sword::SWKey *key,
+ const sword::SWModule *module = 0);
+
+ protected: /* Methods: */
+ /** Reimplemented from sword::OSISHTMLHREF. */
+ virtual inline sword::BasicFilterUserData *createUserData(
+ const sword::SWModule *module, const sword::SWKey *key)
+ {
+ return new UserData(module, key);
+ }
+};
+
+} // namespace Filters
+
+#endif
diff --git a/src/backend/filters/bt_thmlplain.cpp b/src/backend/filters/thmltoplain.cpp
index ecd7bbd..42f383e 100644
--- a/src/backend/filters/bt_thmlplain.cpp
+++ b/src/backend/filters/thmltoplain.cpp
@@ -2,24 +2,25 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-/******************************************************************************
- *
- * thmlplain - SWFilter descendant to strip out all ThML tags or convert to
- * ASCII rendered symbols.
- */
+#include "backend/filters/thmltoplain.h"
-#include "backend/filters/bt_thmlplain.h"
+#include <QtGlobal>
-Filters::BT_ThMLPlain::BT_ThMLPlain() {
-}
+namespace Filters {
+
+char ThmlToPlain::processText(sword::SWBuf &text,
+ const sword::SWKey *key,
+ const sword::SWModule *module)
+{
+ Q_UNUSED(key);
+ Q_UNUSED(module);
-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;
@@ -197,7 +198,7 @@ char Filters::BT_ThMLPlain::processText(sword::SWBuf &text, const sword::SWKey*
token[tokpos++] = *from;
token[tokpos+2] = 0;
}
- else text += *from;
+ else text += *from;
}
orig = text;
@@ -218,3 +219,4 @@ char Filters::BT_ThMLPlain::processText(sword::SWBuf &text, const sword::SWKey*
return 0;
}
+} // namespace Filters
diff --git a/src/backend/filters/thmltoplain.h b/src/backend/filters/thmltoplain.h
new file mode 100644
index 0000000..77e2a2b
--- /dev/null
+++ b/src/backend/filters/thmltoplain.h
@@ -0,0 +1,33 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef FILTERS_THMLTOPLAIN_H
+#define FILTERS_THMLTOPLAIN_H
+
+// Sword includes:
+#include <swbuf.h>
+#include <swfilter.h>
+
+
+namespace Filters {
+
+/**
+ \brief ThML text to plain text conversion filter
+*/
+class ThmlToPlain: public sword::SWFilter {
+ protected: /* Methods: */
+ /** Reimplemented from sword::SWFilter. */
+ virtual char processText(sword::SWBuf &text,
+ const sword::SWKey *key = 0,
+ const sword::SWModule *module = 0);
+};
+
+} // namespace Filters
+
+#endif
diff --git a/src/backend/keys/cswordkey.cpp b/src/backend/keys/cswordkey.cpp
index 24f4909..9c5b25b 100644
--- a/src/backend/keys/cswordkey.cpp
+++ b/src/backend/keys/cswordkey.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,6 +16,7 @@
#include "backend/keys/cswordldkey.h"
#include "backend/keys/cswordtreekey.h"
#include "backend/keys/cswordversekey.h"
+#include "util/btsignal.h"
// Sword includes:
#include <swkey.h>
@@ -26,12 +27,21 @@
#include <versekey.h>
-CSwordKey::CSwordKey(CSwordModuleInfo* const module) : m_module(module) {}
+const QTextCodec *CSwordKey::m_cp1252Codec = QTextCodec::codecForName("Windows-1252");
-CSwordKey::CSwordKey(const CSwordKey& k) {
+CSwordKey::CSwordKey(const CSwordModuleInfo * const module)
+ : m_module(module),
+ m_signal(0) {}
+
+CSwordKey::CSwordKey(const CSwordKey& k)
+ : m_signal(0) {
m_module = k.m_module;
}
+CSwordKey::~CSwordKey() {
+ delete m_signal;
+}
+
QString CSwordKey::rawText() {
if (!m_module) return QString::null;
@@ -51,7 +61,6 @@ QString CSwordKey::renderedText( const CSwordKey::TextRenderType mode ) {
if (k) {
sword::VerseKey* vk_mod = dynamic_cast<sword::VerseKey*>(m_module->module()->getKey());
-
if (vk_mod) {
vk_mod->Headings(1);
}
@@ -74,25 +83,26 @@ QString CSwordKey::renderedText( const CSwordKey::TextRenderType mode ) {
//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;
+ bool DoRender = mode != ProcessEntryAttributesOnly;
+ 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
+ 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 langcode = QString(language.at(0)); // "G" or "H"
QString number = rx.cap(2);
- QString paddednumber = number.rightJustified(5, '0'); // Form 00123
+ 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
+ "(>[^<>]+)" // 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)
);
@@ -101,23 +111,22 @@ QString CSwordKey::renderedText( const CSwordKey::TextRenderType mode ) {
}
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>;
+ /*
+ Here we encode all non-latin1 characters as HTML unicode entities
+ in the form &#<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);
+ // Reserve characters to reduce number of memory allocations:
+ ret.reserve(text.size());
+
+ for (int i = 0; i < text.size(); ++i) {
+ const QChar c = text.at(i);
- if (c.toLatin1()) { //normal latin1 character
+ if (c.toLatin1()) {
ret.append(c);
- }
- else {//unicode character, needs to be escaped
- ret.append("&#")
- .append(c.unicode())
- .append(";");
+ } else {
+ ret.append("&#").append(c.unicode()).append(";");
}
}
@@ -144,14 +153,13 @@ QString CSwordKey::strippedText() {
return QString::fromUtf8( m_module->module()->StripText() );
}
-const QTextCodec* CSwordKey::cp1252Codec() {
- static QTextCodec * codec = QTextCodec::codecForName("Windows-1252");
- return codec;
+void CSwordKey::emitChanged() {
+ if (m_signal.isNull()) return;
+ m_signal->emitChanged();
}
-
/** This will create a proper key object from a given module */
-CSwordKey* CSwordKey::createInstance( CSwordModuleInfo* const module ) {
+CSwordKey *CSwordKey::createInstance(const CSwordModuleInfo *module) {
if (!module) {
return 0;
}
@@ -173,3 +181,9 @@ CSwordKey* CSwordKey::createInstance( CSwordModuleInfo* const module ) {
return 0;
}
}
+
+const BtSignal* CSwordKey::signaler() {
+ if (m_signal.isNull())
+ m_signal = new BtSignal();
+ return m_signal;
+}
diff --git a/src/backend/keys/cswordkey.h b/src/backend/keys/cswordkey.h
index d1924d6..48e511c 100644
--- a/src/backend/keys/cswordkey.h
+++ b/src/backend/keys/cswordkey.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,89 +10,103 @@
#ifndef CSWORDKEY_H
#define CSWORDKEY_H
+#include <QPointer>
#include <QString>
class CSwordModuleInfo;
class QTextCodec;
+class BtSignal;
/** Base class for all keys.
* The base class for all Sword based keys.
* @author The BibleTime team
* @version $Id: cswordkey.h,v 1.27 2006/10/30 19:53:32 mgruner Exp $
*/
-
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.
+ /**
+ \param module The module which belongs to this key, may be NULL
*/
- CSwordKey(const CSwordKey&); //copy constructor
+ CSwordKey(const CSwordModuleInfo * const module = 0);
+
+ CSwordKey(const CSwordKey &copy);
public:
enum TextRenderType {
Normal = 0,
HTMLEscaped = 1,
- ProcessEntryAttributesOnly = 2 // in this case, renderText() will not return text, but only cause EntryAttribute processing
+ 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
+ virtual ~CSwordKey();
+
/** Returns the current key.
- * @return The current key which belongs to the current object.
+ * @return The 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;
+
+ /**
+ 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 setKey(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 setKey(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 module which belongs to this key.
+ */
+ inline const CSwordModuleInfo *module() const {
+ return m_module;
+ }
+
+ /**
+ Sets the module which belongs to this key.
+ \param[in] newModule the module to set.
+ */
+ virtual inline void setModule(const CSwordModuleInfo *newModule) {
+ m_module = newModule;
+ }
+
/** 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
+ /** Returns the rendered text. Returns the text of the current key after passing 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();
+
+ const BtSignal *signaler();
+
/**
* 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);
+ static CSwordKey* createInstance(const CSwordModuleInfo *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
+ static inline const QTextCodec *cp1252Codec() { return m_cp1252Codec; };
+ void emitChanged();
private:
/**
@@ -100,13 +114,10 @@ class CSwordKey {
*/
CSwordKey& operator= ( const CSwordKey & );
+ protected:
+ static const QTextCodec *m_cp1252Codec;
+ const CSwordModuleInfo *m_module;
+ QPointer<BtSignal> m_signal;
};
-inline CSwordModuleInfo* CSwordKey::module(CSwordModuleInfo* const newModule) {
- if (newModule) {
- m_module = newModule;
- }
- return m_module;
-}
-
#endif
diff --git a/src/backend/keys/cswordldkey.cpp b/src/backend/keys/cswordldkey.cpp
index bc1e2c1..ecde8b7 100644
--- a/src/backend/keys/cswordldkey.cpp
+++ b/src/backend/keys/cswordldkey.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,8 +18,8 @@
#include <utilstr.h>
-CSwordLDKey::CSwordLDKey( CSwordModuleInfo* module ) {
- if ((m_module = dynamic_cast<CSwordLexiconModuleInfo*>(module))) {
+CSwordLDKey::CSwordLDKey(const CSwordModuleInfo *module) {
+ if ((m_module = dynamic_cast<const CSwordLexiconModuleInfo*>(module))) {
// *(m_module->module()) = TOP;
}
@@ -30,7 +30,11 @@ CSwordLDKey::CSwordLDKey( CSwordModuleInfo* module ) {
CSwordLDKey::CSwordLDKey( const CSwordLDKey &k ) : CSwordKey(k), SWKey((const char*)k) {}
/** No descriptions */
-CSwordLDKey::CSwordLDKey( const SWKey *k, CSwordModuleInfo* module) : CSwordKey(module), SWKey(*k) {}
+CSwordLDKey::CSwordLDKey(const SWKey *k, const CSwordModuleInfo *module)
+ : CSwordKey(module), SWKey(*k)
+{
+ // Intentionally empty
+}
/** Clones this object by copying the members. */
CSwordLDKey* CSwordLDKey::copy() const {
@@ -38,14 +42,14 @@ CSwordLDKey* CSwordLDKey::copy() const {
}
/** 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);
- }
-
- return m_module;
+void CSwordLDKey::setModule(const CSwordModuleInfo *newModule) {
+ Q_ASSERT(newModule);
+ if (m_module == newModule) return;
+ Q_ASSERT(newModule->type() == CSwordModuleInfo::Lexicon);
+
+ const QString oldKey = key();
+ m_module = newModule;
+ setKey(oldKey);
}
QString CSwordLDKey::key() const {
@@ -61,23 +65,23 @@ QString CSwordLDKey::key() const {
}
const char * CSwordLDKey::rawKey() const {
- return (const char*)*this;
+ return getText();
}
-bool CSwordLDKey::key( const QString& newKey ) {
+bool CSwordLDKey::setKey(const QString &newKey) {
Q_ASSERT(m_module);
if (m_module->isUnicode()) {
- return key(newKey.toUtf8().constData());
+ return setKey(newKey.toUtf8().constData());
}
else {
- return key((const char*)cp1252Codec()->fromUnicode(newKey));
+ return setKey((const char*)cp1252Codec()->fromUnicode(newKey));
}
}
/** Sets the key of this instance */
-bool CSwordLDKey::key( const char* newKey ) {
+bool CSwordLDKey::setKey(const char *newKey) {
Q_ASSERT(newKey);
if (newKey) {
@@ -98,7 +102,7 @@ CSwordLDKey* CSwordLDKey::NextEntry() {
( *( m_module->module() ) )++;
m_module->module()->setSkipConsecutiveLinks(false);
- key(m_module->module()->KeyText());
+ setKey(m_module->module()->KeyText());
SWKey::operator = (m_module->module()->KeyText());
return this;
diff --git a/src/backend/keys/cswordldkey.h b/src/backend/keys/cswordldkey.h
index 2e460d7..ed43ce7 100644
--- a/src/backend/keys/cswordldkey.h
+++ b/src/backend/keys/cswordldkey.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -52,19 +52,19 @@ class CSwordLDKey : public CSwordKey, public sword::SWKey {
public:
/**
- * Constructor of CSwordLDKey
+ \todo Document param
*/
- CSwordLDKey( CSwordModuleInfo* module );
- /**
- * Copy constructor for this key class.
- */
- CSwordLDKey( const CSwordLDKey &k );
+ CSwordLDKey(const CSwordModuleInfo *module);
+
+ CSwordLDKey(const CSwordLDKey &copy);
+
/**
- * Copy constructor for this key class.
+ \todo Document params
*/
- CSwordLDKey( const sword::SWKey *k, CSwordModuleInfo* module);
+ CSwordLDKey(const sword::SWKey *k, const CSwordModuleInfo *module);
+
/**
- * Clones this object by copying the members.
+ Reimplementation of CSwordKey::copy()
*/
virtual CSwordLDKey* copy() const;
/**
@@ -75,22 +75,26 @@ class CSwordLDKey : public CSwordKey, public sword::SWKey {
* Uses the parameter to returns the previous entry afer this key.
*/
CSwordLDKey* PreviousEntry( void );
+
/**
- * Sets the module of this key.
+ Sets the module of this key.
*/
- virtual CSwordModuleInfo* module( CSwordModuleInfo* const module = 0 );
+ virtual void setModule(const CSwordModuleInfo *module);
+
/**
* Returns the current key as a QString
*/
virtual QString key() const;
+
/**
- * Set the current key using unicode decoded QString.
+ Reimplemented from CSwordKey::setKey(const QString &key).
*/
- virtual bool key( const QString& newKey );
+ virtual bool setKey(const QString &newKey);
+
/**
- * Set the current key from char*. To avoid encoding problems use key(QString) instead.
+ Reimplemented from CSwordKey::setKey(const char *key).
*/
- virtual bool key( const char* );
+ virtual bool setKey(const char *key);
protected:
/**
diff --git a/src/backend/keys/cswordtreekey.cpp b/src/backend/keys/cswordtreekey.cpp
index e1ac9c3..4ea624f 100644
--- a/src/backend/keys/cswordtreekey.cpp
+++ b/src/backend/keys/cswordtreekey.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,7 +16,12 @@
CSwordTreeKey::CSwordTreeKey( const CSwordTreeKey& k ) : CSwordKey(k), TreeKeyIdx(k) {}
-CSwordTreeKey::CSwordTreeKey( const TreeKeyIdx *k, CSwordModuleInfo* module ) : CSwordKey(module), TreeKeyIdx(*k) {}
+CSwordTreeKey::CSwordTreeKey(const TreeKeyIdx *k,
+ const CSwordModuleInfo *module)
+ : CSwordKey(module), TreeKeyIdx(*k)
+{
+ // Intentionally empty
+}
CSwordTreeKey* CSwordTreeKey::copy() const {
return new CSwordTreeKey(*this);
@@ -38,19 +43,19 @@ const char * CSwordTreeKey::rawKey() const {
return getText();
}
-bool CSwordTreeKey::key( const QString& newKey ) {
+bool CSwordTreeKey::setKey(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());
+ return setKey(newKey.toUtf8().constData());
}
else {
- return key((const char*)cp1252Codec()->fromUnicode(newKey));
+ return setKey((const char*)cp1252Codec()->fromUnicode(newKey));
}
}
-bool CSwordTreeKey::key( const char* newKey ) {
+bool CSwordTreeKey::setKey(const char *newKey) {
Q_ASSERT(newKey);
if (newKey) {
@@ -75,21 +80,21 @@ QString CSwordTreeKey::getLocalNameUnicode() {
}
}
-CSwordModuleInfo* CSwordTreeKey::module( CSwordModuleInfo* const newModule ) {
- if (newModule && (newModule != m_module) && (newModule->type() == CSwordModuleInfo::GenericBook) ) {
- m_module = newModule;
+void CSwordTreeKey::setModule(const CSwordModuleInfo *newModule) {
+ Q_ASSERT(newModule);
+ if (m_module == newModule) return;
+ Q_ASSERT(newModule->type() == CSwordModuleInfo::GenericBook);
- const QString oldKey = key();
+ m_module = newModule;
- CSwordBookModuleInfo* newBook = dynamic_cast<CSwordBookModuleInfo*>(newModule);
- copyFrom( *(newBook->tree()) );
+ const QString oldKey = key();
- key(oldKey); //try to restore our old key
+ const CSwordBookModuleInfo *newBook = dynamic_cast<const CSwordBookModuleInfo*>(newModule);
+ copyFrom( *(newBook->tree()) );
- //set the key to the root node
- root();
- firstChild();
- }
+ setKey(oldKey); //try to restore our old key
- return m_module;
+ //set the key to the root node
+ root();
+ firstChild();
}
diff --git a/src/backend/keys/cswordtreekey.h b/src/backend/keys/cswordtreekey.h
index 9a60d5b..d6eb5ec 100644
--- a/src/backend/keys/cswordtreekey.h
+++ b/src/backend/keys/cswordtreekey.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -26,18 +26,20 @@ 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.
+ /**
+ \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,
+ const CSwordModuleInfo *module);
+
CSwordTreeKey( const CSwordTreeKey& k );
- /** The module which belongs to this key.
- * @return The module.
- */
- virtual CSwordModuleInfo* module( CSwordModuleInfo* const newModule );
+
+ /**
+ Reimplemented from CSwordKey.
+ */
+ virtual void setModule(const CSwordModuleInfo *newModule);
+
/** Copy method.
* @return A new copy of this object.
*/
@@ -53,15 +55,16 @@ class CSwordTreeKey : public CSwordKey, public sword::TreeKeyIdx {
* 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 "/"
+ Reimplemented from CSwordKey::setKey(const QString &key).
*/
- virtual bool key( const QString& key );
+ virtual bool setKey(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).
+ Reimplemented from CSwordKey::setKey(const char *key).
*/
- virtual bool key( const char* key );
+ virtual bool setKey(const char *key);
protected:
/**
diff --git a/src/backend/keys/cswordversekey.cpp b/src/backend/keys/cswordversekey.cpp
index a7e16c5..5ea1455 100644
--- a/src/backend/keys/cswordversekey.cpp
+++ b/src/backend/keys/cswordversekey.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,19 +14,22 @@
#include "backend/drivers/cswordbiblemoduleinfo.h"
#include "backend/drivers/cswordcommentarymoduleinfo.h"
+#include "util/btsignal.h"
// Sword includes:
#include <swmodule.h>
#include <localemgr.h>
-CSwordVerseKey::CSwordVerseKey( CSwordModuleInfo* const module ) :
- CSwordKey(module) {
- if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module) ) {
+CSwordVerseKey::CSwordVerseKey(const CSwordModuleInfo *module)
+ : CSwordKey(module)
+{
+ typedef CSwordBibleModuleInfo CSBMI;
+ if (const CSBMI *bible = dynamic_cast<const CSBMI*>(module) ) {
// Copy important settings like versification system
copyFrom((sword::VerseKey*) bible->module()->getKey());
- key( bible->lowerBound().key() );
+ setKey( bible->lowerBound().key() );
}
this->VerseKey::setAutoNormalize(true);
}
@@ -35,7 +38,12 @@ CSwordVerseKey::CSwordVerseKey( const CSwordVerseKey& k ) : CSwordKey(k), VerseK
this->VerseKey::setAutoNormalize(true);
}
-CSwordVerseKey::CSwordVerseKey( const VerseKey* const k, CSwordModuleInfo* const module ) : CSwordKey(module), VerseKey(*k) {}
+CSwordVerseKey::CSwordVerseKey(const VerseKey *k,
+ const CSwordModuleInfo *module)
+ : CSwordKey(module), VerseKey(*k)
+{
+ // Intentionally empty
+}
/** Clones this object. */
CSwordKey* CSwordVerseKey::copy() const {
@@ -43,33 +51,38 @@ CSwordKey* CSwordVerseKey::copy() const {
}
/** 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;
+void CSwordVerseKey::setModule(const CSwordModuleInfo *newModule) {
+ typedef CSwordBibleModuleInfo CSBMI;
- //check if the module contains the key we present
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(newModule);
+ Q_ASSERT(newModule);
+ if (m_module == newModule) return;
+ Q_ASSERT(newModule->type() == CSwordModuleInfo::Bible
+ || newModule->type() == CSwordModuleInfo::Commentary);
- if (_compare(bible->lowerBound()) < 0) {
- key( bible->lowerBound() );
- }
+ m_module = newModule;
- if (_compare(bible->upperBound()) > 0) {
- key( bible->upperBound() );
- }
+ //check if the module contains the key we present
+ const CSBMI* bible = dynamic_cast<const CSBMI*>(newModule);
+
+ if (_compare(bible->lowerBound()) < 0) {
+ setKey(bible->lowerBound());
}
- return dynamic_cast<CSwordBibleModuleInfo*>(m_module);
+ if (_compare(bible->upperBound()) > 0) {
+ setKey(bible->upperBound());
+ }
}
/** Returns the current book as Text, not as integer. */
QString CSwordVerseKey::book( const QString& newBook ) {
+ typedef CSwordBibleModuleInfo CSBMI;
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);
+ const CSBMI *bible = dynamic_cast<const CSBMI*>(module());
+ if (bible != 0) {
+ const bool hasOT = bible->hasTestament(CSBMI::OldTestament);
+ const bool hasNT = bible->hasTestament(CSBMI::NewTestament);
if (hasOT && hasNT) {
min = 0;
@@ -110,26 +123,37 @@ const char * CSwordVerseKey::rawKey() const {
return getText();
}
-bool CSwordVerseKey::key( const QString& newKey ) {
- return key( newKey.toUtf8().constData() );
+bool CSwordVerseKey::setKey(const QString &newKey) {
+ return setKey(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());
+bool CSwordVerseKey::setKey(const char *newKey) {
+ typedef CSwordBibleModuleInfo CSBMI;
+
+ /// \todo Is this check necessary?
+ if (newKey) {
+ /// \todo Is this check necessary?
+ // Check if empty string:
+ if (*newKey != '\0') {
+ positionFrom(newKey);
+ } else {
+ const CSwordModuleInfo *m = module();
+ if (m->type() == CSwordModuleInfo::Bible) {
+ Q_ASSERT(dynamic_cast<const CSBMI*>(m) != 0);
+ const CSBMI *bible = static_cast<const CSBMI*>(m);
+ positionFrom(bible->lowerBound().key().toUtf8().constData());
+ }
}
}
+ /// \todo Do we ALWAYS need to emit this signal and check for errors?
+ emitChanged();
return !Error();
}
bool CSwordVerseKey::next( const JumpType type ) {
+ typedef CSwordBibleModuleInfo CSBMI;
+
Error(); //clear Error status
bool ret = true;
@@ -174,7 +198,7 @@ bool CSwordVerseKey::next( const JumpType type ) {
m_module->module()->setSkipConsecutiveLinks(oldStatus);
if (!m_module->module()->Error()) {
- key( QString::fromUtf8(m_module->module()->KeyText()) );
+ setKey(QString::fromUtf8(m_module->module()->KeyText()));
}
else {
// Verse(Verse()+1);
@@ -196,27 +220,32 @@ bool CSwordVerseKey::next( const JumpType type ) {
return false;
}
- if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()) ) {
+ const CSBMI *bible = dynamic_cast<const CSBMI*>(module());
+ if (bible != 0) {
if (_compare(bible->lowerBound()) < 0 ) {
- key( bible->lowerBound() );
+ setKey(bible->lowerBound());
ret = false;
}
if (_compare(bible->upperBound()) > 0 ) {
- key( bible->upperBound() );
+ setKey(bible->upperBound());
ret = false;
}
+ emitChanged();
return ret;
}
else if (Error()) { //we have no module, so take care of VerseKey::Error()
return false;
}
+ emitChanged();
return ret;
}
bool CSwordVerseKey::previous( const JumpType type ) {
+ typedef CSwordBibleModuleInfo CSBMI;
+
bool ret = true;
switch (type) {
@@ -256,7 +285,7 @@ bool CSwordVerseKey::previous( const JumpType type ) {
m_module->module()->setSkipConsecutiveLinks(oldStatus);
if (!m_module->module()->Error()) {
- key( QString::fromUtf8(m_module->module()->KeyText()) );//don't use fromUtf8
+ setKey(QString::fromUtf8(m_module->module()->KeyText()));//don't use fromUtf8
}
else {
ret = false;
@@ -275,22 +304,25 @@ bool CSwordVerseKey::previous( const JumpType type ) {
return false;
}
- if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module()) ) {
+ const CSBMI *bible = dynamic_cast<const CSBMI*>(module());
+ if (bible != 0) {
if (_compare(bible->lowerBound()) < 0 ) {
- key( bible->lowerBound() );
+ setKey(bible->lowerBound());
ret = false;
}
if (_compare(bible->upperBound()) > 0 ) {
- key( bible->upperBound() );
+ setKey(bible->upperBound());
ret = false;
}
+ emitChanged();
return ret;
}
else if (Error()) {
return false;
}
+ emitChanged();
return ret;
}
diff --git a/src/backend/keys/cswordversekey.h b/src/backend/keys/cswordversekey.h
index bfbfa25..2769cbf 100644
--- a/src/backend/keys/cswordversekey.h
+++ b/src/backend/keys/cswordversekey.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -35,8 +35,8 @@ class CSwordModuleInfo;
* @see NextVerse()
* @see PreviousVerse().
*
- * Call the constructor only with a valid verse based modules, otherwise this key will be invalid
- * and the application will probably crash.
+ * Call the constructor only with valid verse based modules, otherwise this key
+ * will be invalid and the application will probably crash.
*
* @version $Id: cswordversekey.h,v 1.26 2006/02/25 11:38:15 joachim Exp $
* @short CSwordKey implementation for Sword's VerseKey.
@@ -53,39 +53,43 @@ class CSwordVerseKey : public CSwordKey, public sword::VerseKey {
};
/**
- * 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.
+ Constructs a versekey with the current module position and setups
+ the m_module members.
*/
- CSwordVerseKey( const CSwordVerseKey& k );
+ CSwordVerseKey(const CSwordModuleInfo *module);
+
+ CSwordVerseKey(const CSwordVerseKey &copy);
+
/**
- * VerseKey based constructor.
- */
- CSwordVerseKey( const sword::VerseKey* const k, CSwordModuleInfo* const module );
+ * Constructs a CSwordVerseKey using the given module at the position given
+ * by the versekey.
+ *
+ * \param[in] k Position to use.
+ * \param[in] module Module to use.
+ */
+ CSwordVerseKey(const sword::VerseKey *k,
+ const CSwordModuleInfo *module);
+
/**
- * Clones this object.
+ Reimplementation of CSwordKey::copy().
*/
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.
+ Reimplemented from CSwordKey::setKey(const QString &key).
*/
- virtual bool key( const QString& );
+ virtual bool setKey(const QString &key);
+
/**
- * 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.
+ Reimplemented from CSwordKey::setKey(const char *key).
*/
- virtual bool key( const char* key );
+ virtual bool setKey(const char *key);
/**
* Jumps to the next entry of the given type
@@ -102,10 +106,11 @@ class CSwordVerseKey : public CSwordKey, public sword::VerseKey {
* @return The name of the current book
*/
QString book(const QString& newBook = QString::null);
+
/**
- * Sets the module for this key
+ Sets the module for this key.
*/
- virtual CSwordModuleInfo* module( CSwordModuleInfo* const newModule = 0 );
+ virtual void setModule(const CSwordModuleInfo *newModule);
protected:
/**
@@ -114,7 +119,7 @@ class CSwordVerseKey : public CSwordKey, public sword::VerseKey {
virtual const char * rawKey() const;
private:
- /** Disable assignment operator */
+ /** Disable assignment operator */
CSwordVerseKey& operator= (const CSwordVerseKey&);
/** Disable from base class to prevent compiler warnings */
inline virtual CSwordVerseKey& operator= (const sword::VerseKey&) {
diff --git a/src/backend/managers/btstringmgr.cpp b/src/backend/managers/btstringmgr.cpp
index a2abc7f..ad1fb3e 100644
--- a/src/backend/managers/btstringmgr.cpp
+++ b/src/backend/managers/btstringmgr.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/backend/managers/btstringmgr.h b/src/backend/managers/btstringmgr.h
index 7f44df8..1cf7170 100644
--- a/src/backend/managers/btstringmgr.h
+++ b/src/backend/managers/btstringmgr.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/backend/managers/cdisplaytemplatemgr.cpp b/src/backend/managers/cdisplaytemplatemgr.cpp
index 11d2a59..b3def8c 100644
--- a/src/backend/managers/cdisplaytemplatemgr.cpp
+++ b/src/backend/managers/cdisplaytemplatemgr.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,15 +17,38 @@
#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/clanguagemgr.h"
-#include "util/cpointers.h"
#include "util/directory.h"
-CDisplayTemplateMgr::CDisplayTemplateMgr() {
- loadTemplates();
-}
+CDisplayTemplateMgr *CDisplayTemplateMgr::m_instance = 0;
+
+CDisplayTemplateMgr::CDisplayTemplateMgr(QString &errorMessage) {
+ Q_ASSERT(m_instance == 0);
-CDisplayTemplateMgr::~CDisplayTemplateMgr() {
+ m_instance = this;
+ namespace DU = util::directory;
+
+ QStringList filter("*.tmpl");
+
+ // Preload global display templates from disk:
+ QDir td = DU::getDisplayTemplatesDir();
+ Q_FOREACH(QString file, td.entryList(filter, QDir::Files | QDir::Readable))
+ loadTemplate(td.canonicalPath() + "/" + file);
+
+ /*
+ Preload user display templates from disk, overriding any global templates
+ with the same file name:
+ */
+ QDir utd = DU::getUserDisplayTemplatesDir();
+ Q_FOREACH(QString file, utd.entryList(filter, QDir::Files | QDir::Readable))
+ loadTemplate(utd.canonicalPath() + "/" + file);
+
+ if (m_templateMap.contains(defaultTemplate())) {
+ errorMessage = QString::null;
+ } else {
+ errorMessage = QObject::tr("Default template \"%1\" not found!")
+ .arg(defaultTemplate());
+ }
}
const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QString& content, Settings& settings ) {
@@ -70,9 +93,9 @@ const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QStr
qDebug() << "There were more than 1 module, create headers";
QString header;
- QList<CSwordModuleInfo*>::iterator end_it = settings.modules.end();
+ QList<const CSwordModuleInfo*>::iterator end_it = settings.modules.end();
- for (QList<CSwordModuleInfo*>::iterator it(settings.modules.begin()); it != end_it; ++it) {
+ for (QList<const CSwordModuleInfo*>::iterator it(settings.modules.begin()); it != end_it; ++it) {
header.append("<th style=\"width:")
.append(QString::number(int( 100.0 / (float)moduleCount )))
.append("%;\">")
@@ -88,7 +111,7 @@ const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QStr
}
QString langCSS;
- CLanguageMgr::LangMap langMap = CPointers::languageMgr()->availableLanguages();
+ CLanguageMgr::LangMap langMap = CLanguageMgr::instance()->availableLanguages();
qDebug() << "langMap length:" << langMap.count();
qDebug() << "loop through langMap";
@@ -118,7 +141,7 @@ const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QStr
//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_v(QString("en"), QString("English"), QString::null);
CLanguageMgr::Language* lang = &lang_v;
if (lang && !lang->abbrev().isEmpty()/*&& lang->isValid()*/) {
@@ -132,7 +155,7 @@ const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QStr
);
}
-// qWarning("Outputing unformated text");
+// 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)
@@ -144,25 +167,13 @@ const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QStr
return t;
}
-void CDisplayTemplateMgr::loadTemplates() {
- namespace DU = util::directory;
-
- QStringList files;
- foreach (QString file, DU::getDisplayTemplatesDir().entryList(QStringList("*.tmpl"))) {
- files += DU::getDisplayTemplatesDir().canonicalPath() + "/" + file;
- }
- foreach (QString file, DU::getUserDisplayTemplatesDir().entryList(QStringList("*.tmpl"))) {
- files += DU::getUserDisplayTemplatesDir().canonicalPath() + "/" + file;
- }
-
- foreach (QString file, files) {
- QFile f(file);
- if (f.exists() && f.open( QIODevice::ReadOnly )) {
- QString fileContent = QTextStream( &f ).readAll();
+void CDisplayTemplateMgr::loadTemplate(const QString &filename) {
+ QFile f(filename);
+ if (f.open(QIODevice::ReadOnly)) {
+ QString fileContent = QTextStream(&f).readAll();
- if (!fileContent.isEmpty()) {
- m_templateMap[ QFileInfo(file).fileName() ] = fileContent;
- }
+ if (!fileContent.isEmpty()) {
+ m_templateMap[QFileInfo(f).fileName()] = fileContent;
}
}
}
diff --git a/src/backend/managers/cdisplaytemplatemgr.h b/src/backend/managers/cdisplaytemplatemgr.h
index 16725a5..9b96e8b 100644
--- a/src/backend/managers/cdisplaytemplatemgr.h
+++ b/src/backend/managers/cdisplaytemplatemgr.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,71 +18,82 @@
class CSwordModuleInfo;
/**
- * Manages the display templates used in the filters and display classes.
- * @author The BibleTime team
+ Manages the display templates used in the filters and display classes.
+ \note This is a singleton.
*/
class CDisplayTemplateMgr {
- public:
- /** Settings which are used to fill the content into the template.
+ public: /* Types: */
+ /**
+ 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 */
+ Settings() : pageDirection("ltr") {}
+
+ /** The list of modules */
+ QList<const CSwordModuleInfo*> modules;
+
+ /** The title which is used for the new processed HTML page */
+ QString title;
+
+ /** The language for the HTML page. */
+ QString langAbbrev;
+
+ /** The language direction for the HTML page. */
+ QString pageDirection;
+
+ /** The CSS ID which is used in the content part of the page */
+ QString pageCSS_ID;
};
- /** Available templates.
- * @return The list of templates, which are available.
+ public: /* Methods: */
+
+ /**
+ \param[out] errorMessage Set to error string on error, otherwise set
+ to QString::null.
*/
- 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.
+ explicit CDisplayTemplateMgr(QString &errorMessage);
+
+ /**
+ \returns the list of available templates.
*/
- const QString fillTemplate( const QString& name, const QString& content, Settings& settings);
- /** Default template.
- * @return The i18n'ed name of the default template
+ inline const QStringList availableTemplates() const {
+ return m_templateMap.keys();
+ }
+
+ /**
+ \brief Fills the template.
+
+ Fills rendered content into the template given by the name.
+
+ \param name The name of the template to fill.
+ \param content The content which should be filled into the template.
+ \param settings The settings which are used to process the templating
+ process.
+
+ \returns The full HTML template HTML code including the CSS data.
*/
- 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;
-};
+ const QString fillTemplate( const QString& name, const QString& content, Settings& settings);
-inline const QString CDisplayTemplateMgr::defaultTemplate() {
- return QString("Blue.tmpl");
-}
+ /**
+ \returns the name of the default template.
+ */
+ inline static const char *defaultTemplate() { return "Blue.tmpl"; }
-/**
- * CDisplayTemplateMgr::availableTemplates()
- */
-inline const QStringList CDisplayTemplateMgr::availableTemplates() {
- return m_templateMap.keys();
-}
+ /**
+ \returns The singleton instance of the instance of this class.
+ */
+ static inline CDisplayTemplateMgr *instance() {
+ Q_ASSERT(m_instance != 0);
+ return m_instance;
+ };
+ private: /* Methods: */
+ /** Preloads a single template from disk: */
+ void loadTemplate(const QString &filename);
+ private: /* Fields: */
+ QMap<QString, QString> m_templateMap;
+ static CDisplayTemplateMgr *m_instance;
+};
#endif
diff --git a/src/backend/managers/clanguagemgr.cpp b/src/backend/managers/clanguagemgr.cpp
index 5c44405..a8d4e1f 100644
--- a/src/backend/managers/clanguagemgr.cpp
+++ b/src/backend/managers/clanguagemgr.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,7 +11,6 @@
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
-#include "util/cpointers.h"
CLanguageMgr::Language::Language() {}
@@ -37,6 +36,22 @@ CLanguageMgr::Language::~Language() {
/****************************************************/
/******************** CLanguageMgr ******************/
/****************************************************/
+
+CLanguageMgr *CLanguageMgr::m_instance = 0;
+
+void CLanguageMgr::destroyInstance() {
+ delete m_instance;
+ m_instance = 0;
+}
+
+CLanguageMgr *CLanguageMgr::instance() {
+ if (m_instance == 0) {
+ m_instance = new CLanguageMgr();
+ }
+
+ return m_instance;
+}
+
CLanguageMgr::CLanguageMgr() : m_langMap() {
m_availableModulesCache.moduleCount = 0;
init();
@@ -50,7 +65,7 @@ CLanguageMgr::~CLanguageMgr() {
}
const CLanguageMgr::LangMap& CLanguageMgr::availableLanguages() {
- QList<CSwordModuleInfo*> mods = CPointers::backend()->moduleList();
+ QList<CSwordModuleInfo*> mods = CSwordBackend::instance()->moduleList();
if ( m_availableModulesCache.moduleCount != (unsigned int)mods.count() ) { //we have to refill the cached map
m_availableModulesCache.availableLanguages.clear();
@@ -98,13 +113,6 @@ const CLanguageMgr::Language* CLanguageMgr::languageForAbbrev( const QString& ab
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
-}
-
const CLanguageMgr::Language* CLanguageMgr::languageForTranslatedName( const QString& name ) const {
foreach ( const Language* lang, m_langList ) {
if (lang->translatedName() == name) return lang;
diff --git a/src/backend/managers/clanguagemgr.h b/src/backend/managers/clanguagemgr.h
index de716c0..cbe70e9 100644
--- a/src/backend/managers/clanguagemgr.h
+++ b/src/backend/managers/clanguagemgr.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,9 +16,10 @@
#include <QStringList>
-/** Manages the languages of BibleTime and provides functions to work with them.
- * @author The BibleTime team
- */
+/**
+ \brief Manages the languages and provides functions to work with them.
+ \note This is a singleton.
+*/
class CLanguageMgr {
public:
@@ -27,21 +28,21 @@ class CLanguageMgr {
*/
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.
+ /**
+ 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(const Language &copy);
+
+ Language(const QString &abbrev, const QString &englishName,
+ const QString &translatedName,
+ const QStringList &altAbbrevs = QStringList());
+
~Language();
+
/** Returns the abbreviation.
* @return The abbreviation of the chosen language.
*/
@@ -88,12 +89,17 @@ class CLanguageMgr {
typedef QHash<QString, const Language*> LangMap;
typedef QHash<QString, const Language*>::const_iterator LangMapIterator;
- /** Constructor.
- */
+
+ /** Returns the singleton instance, creating it if one does not exist. */
+ static CLanguageMgr *instance();
+
+ /** Destroys the singleton instance, if one exists. */
+ static void destroyInstance();
+
CLanguageMgr();
- /** Destructor
- */
+
virtual ~CLanguageMgr();
+
/**
* Returns the standard languages available as standard. Does nothing for Sword.
* @return A LangMap map which contains all known languages
@@ -111,11 +117,7 @@ class CLanguageMgr {
* @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
@@ -142,8 +144,9 @@ class CLanguageMgr {
struct ModuleCache {
unsigned int moduleCount;
LangMap availableLanguages;
- }
- m_availableModulesCache;
+ } m_availableModulesCache;
+
+ static CLanguageMgr *m_instance;
};
#endif
diff --git a/src/backend/managers/cswordbackend.cpp b/src/backend/managers/cswordbackend.cpp
index 4596a61..b5c109f 100644
--- a/src/backend/managers/cswordbackend.cpp
+++ b/src/backend/managers/cswordbackend.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,16 +20,9 @@
#include "backend/drivers/cswordbookmoduleinfo.h"
#include "backend/drivers/cswordcommentarymoduleinfo.h"
#include "backend/drivers/cswordlexiconmoduleinfo.h"
-#include "backend/filters/bt_gbfhtml.h"
-#include "backend/filters/bt_osishtml.h"
-#include "backend/filters/bt_teihtml.h"
-#include "backend/filters/bt_plainhtml.h"
-#include "backend/filters/bt_thmlhtml.h"
-#include "backend/filters/bt_thmlplain.h"
+#include "backend/filters/thmltoplain.h"
#include "backend/filters/osismorphsegmentation.h"
-#include "backend/rendering/cbookdisplay.h"
-#include "backend/rendering/cchapterdisplay.h"
-#include "backend/rendering/centrydisplay.h"
+#include "btglobal.h"
#include "util/directory.h"
// Sword includes:
@@ -42,52 +35,25 @@
#include <utilstr.h>
-using namespace Filters;
using namespace Rendering;
-CSwordBackend::CSwordBackend()
- : 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.tei = new BT_TEIHTML();
-
- m_displays.entry = new CEntryDisplay();
- m_displays.chapter = new CChapterDisplay();
- m_displays.book = new CBookDisplay();
+CSwordBackend *CSwordBackend::m_instance = 0;
+CSwordBackend::CSwordBackend()
+ : sword::SWMgr(0, 0, false,
+ new sword::EncodingFilterMgr(sword::ENC_UTF8), true),
+ m_dataModel(this)
+{
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();
- m_filters.tei = new BT_TEIHTML();
-
- m_displays.entry = new CEntryDisplay();
- m_displays.chapter = new CChapterDisplay();
- m_displays.book = new CBookDisplay();
-
filterInit();
}
CSwordBackend::~CSwordBackend() {
shutdownModules();
-
- delete m_filters.gbf;
- delete m_filters.plain;
- delete m_filters.thml;
- delete m_filters.osis;
- delete m_filters.tei;
-
- delete m_displays.book;
- delete m_displays.chapter;
- delete m_displays.entry;
}
void CSwordBackend::filterInit() {
@@ -97,7 +63,7 @@ void CSwordBackend::filterInit() {
optionFilters.erase("OSISMorphSegmentation");
delete filter;
}
- sword::SWOptionFilter* tmpFilter = new OSISMorphSegmentation();
+ sword::SWOptionFilter *tmpFilter = new Filters::OSISMorphSegmentation();
optionFilters.insert(sword::OptionFilterMap::value_type("OSISMorphSegmentation", tmpFilter));
cleanupFilters.push_back(tmpFilter);
@@ -105,7 +71,7 @@ void CSwordBackend::filterInit() {
//remove this hack as soon as Sword is fixed
cleanupFilters.remove(thmlplain);
delete thmlplain;
- thmlplain = new BT_ThMLPlain();
+ thmlplain = new Filters::ThmlToPlain();
cleanupFilters.push_back(thmlplain);
}
@@ -125,10 +91,23 @@ QList<CSwordModuleInfo*> CSwordBackend::takeModulesFromList(QStringList names) {
return list;
}
-QList<CSwordModuleInfo*> CSwordBackend::getPointerList(QStringList names) {
+QList<CSwordModuleInfo*> CSwordBackend::getPointerList(const QStringList &names) {
QList<CSwordModuleInfo*> list;
- foreach(QString name, names) {
- CSwordModuleInfo* mInfo = findModuleByName(name);
+ Q_FOREACH (const QString &name, names) {
+ CSwordModuleInfo *mInfo = findModuleByName(name);
+ if (mInfo) {
+ list.append(mInfo);
+ }
+ }
+ return list;
+}
+
+QList<const CSwordModuleInfo*> CSwordBackend::getConstPointerList(
+ const QStringList &names)
+{
+ QList<const CSwordModuleInfo*> list;
+ Q_FOREACH (const QString &name, names) {
+ const CSwordModuleInfo *mInfo = findModuleByName(name);
if (mInfo) {
list.append(mInfo);
}
@@ -154,19 +133,19 @@ CSwordBackend::LoadError CSwordBackend::initModules(SetupChangedReason reason) {
if (!strcmp(curMod->Type(), "Biblical Texts")) {
newModule = new CSwordBibleModuleInfo(curMod, this);
- newModule->module()->Disp(m_displays.chapter);
+ newModule->module()->Disp(&m_chapterDisplay);
}
else if (!strcmp(curMod->Type(), "Commentaries")) {
newModule = new CSwordCommentaryModuleInfo(curMod, this);
- newModule->module()->Disp(m_displays.entry);
+ newModule->module()->Disp(&m_entryDisplay);
}
else if (!strcmp(curMod->Type(), "Lexicons / Dictionaries")) {
newModule = new CSwordLexiconModuleInfo(curMod, this);
- newModule->module()->Disp(m_displays.entry);
+ newModule->module()->Disp(&m_entryDisplay);
}
else if (!strcmp(curMod->Type(), "Generic Books")) {
newModule = new CSwordBookModuleInfo(curMod, this);
- newModule->module()->Disp(m_displays.book);
+ newModule->module()->Disp(&m_bookDisplay);
}
if (newModule) {
@@ -181,8 +160,7 @@ CSwordBackend::LoadError CSwordBackend::initModules(SetupChangedReason reason) {
}
}
- Q_FOREACH(CSwordModuleInfo* mod, m_dataModel.modules()) {
- m_moduleDescriptionMap.insert( mod->config(CSwordModuleInfo::Description), mod->name() );
+ Q_FOREACH(CSwordModuleInfo* mod, m_dataModel.moduleList()) {
//unlock modules if keys are present
if ( mod->isEncrypted() ) {
const QString unlockKey = CBTConfig::getModuleEncryptionKey( mod->name() );
@@ -206,29 +184,29 @@ void CSwordBackend::AddRenderFilters(sword::SWModule *module, sword::ConfigEntMa
moduleDriver = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
if (sourceformat == "OSIS") {
- module->AddRenderFilter(m_filters.osis);
+ module->AddRenderFilter(&m_osisFilter);
noDriver = false;
}
else if (sourceformat == "ThML") {
- module->AddRenderFilter(m_filters.thml);
+ module->AddRenderFilter(&m_thmlFilter);
noDriver = false;
}
else if (sourceformat == "TEI") {
- module->AddRenderFilter(m_filters.tei);
+ module->AddRenderFilter(&m_teiFilter);
noDriver = false;
}
else if (sourceformat == "GBF") {
- module->AddRenderFilter(m_filters.gbf);
+ module->AddRenderFilter(&m_gbfFilter);
noDriver = false;
}
else if (sourceformat == "PLAIN") {
- module->AddRenderFilter(m_filters.plain);
+ module->AddRenderFilter(&m_plainFilter);
noDriver = false;
}
if (noDriver) { //no driver found
if ( (moduleDriver == "RawCom") || (moduleDriver == "RawLD") ) {
- module->AddRenderFilter(m_filters.plain);
+ module->AddRenderFilter(&m_plainFilter);
noDriver = false;
}
}
@@ -284,7 +262,7 @@ void CSwordBackend::setOption( const CSwordModuleInfo::FilterTypes type, const i
setGlobalOption(optionName(type).toUtf8().constData(), value.c_str());
}
-void CSwordBackend::setFilterOptions( const CSwordBackend::FilterOptions options) {
+void CSwordBackend::setFilterOptions(const FilterOptions &options) {
setOption( CSwordModuleInfo::footnotes, options.footnotes );
setOption( CSwordModuleInfo::strongNumbers, options.strongNumbers );
setOption( CSwordModuleInfo::headings, options.headings );
@@ -302,93 +280,27 @@ void CSwordBackend::setFilterOptions( const CSwordBackend::FilterOptions options
/** This function searches for a module with the specified description */
CSwordModuleInfo* CSwordBackend::findModuleByDescription(const QString& description) {
- Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.modules()) {
+ Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.moduleList()) {
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;
-}
-
/** This function searches for a module with the specified name */
CSwordModuleInfo* CSwordBackend::findModuleByName(const QString& name) {
- Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.modules()) {
+ Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.moduleList()) {
if (mod->name() == name) return mod;
}
return 0;
}
CSwordModuleInfo* CSwordBackend::findSwordModuleByPointer(const sword::SWModule* const swmodule) {
- Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.modules()) {
+ Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.moduleList()) {
if (mod->module() == swmodule ) return mod;
}
return 0;
}
-CSwordModuleInfo* CSwordBackend::findModuleByPointer(const CSwordModuleInfo* const module) {
- 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;
- QDir dir(QString::fromUtf8(configPath));
- bool foundConfig = false;
-
- QFileInfoList list = dir.entryInfoList();
- if (dir.isReadable()) {
- for (int i = 0; i < list.size(); ++i) {
- QFileInfo fileInfo = list.at(i);
-
- moduleConfig = sword::SWConfig( fileInfo.absoluteFilePath().toLocal8Bit().constData() );
- section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
- foundConfig = ( section != moduleConfig.Sections.end() );
- }
- }
- 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::directory::getUserHomeSwordModsDir().absolutePath();
- dir.setPath(myPath);
-
- QFileInfoList list = dir.entryInfoList();
- if (dir.isReadable()) {
- for (int i = 0; i < list.size(); ++i) {
- QFileInfo fileInfo = list.at(i);
- moduleConfig = sword::SWConfig( fileInfo.absoluteFilePath().toLocal8Bit().constData() );
- section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
- foundConfig = ( section != moduleConfig.Sections.end() );
- }
- }
- }
-
- return foundConfig;
-}
-
/** Returns the text used for the option given as parameter. */
const QString CSwordBackend::optionName( const CSwordModuleInfo::FilterTypes option ) {
switch (option) {
@@ -490,7 +402,7 @@ const QString CSwordBackend::booknameLanguage( const QString& language ) {
//use what sword returns, language may be different
QString newLocaleName( sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName() );
- Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.modules()) {
+ Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.moduleList()) {
if ( (mod->type() == CSwordModuleInfo::Bible) || (mod->type() == CSwordModuleInfo::Commentary) ) {
//Create a new key, it will get the default bookname language
((sword::VerseKey*)(mod->module()->getKey()))->setLocale( newLocaleName.toUtf8().constData() );
@@ -609,3 +521,26 @@ QStringList CSwordBackend::swordDirList() const {
return swordDirSet.values();
}
+
+void CSwordBackend::deleteOrphanedIndices() {
+ QDir dir(CSwordModuleInfo::getGlobalBaseIndexLocation());
+ dir.setFilter(QDir::Dirs);
+ CSwordModuleInfo* module;
+
+ for (unsigned int i = 0; i < dir.count(); i++) {
+ if (dir[i] != "." && dir[i] != "..") {
+ if ( (module = this->findModuleByName(dir[i])) ) { //mod exists
+ if (!module->hasIndex()) { //index files found, but wrong version etc.
+ qDebug() << "deleting outdated index for module" << dir[i];
+ CSwordModuleInfo::deleteIndexForModule( dir[i] );
+ }
+ }
+ else { //no module exists
+ if (CBTConfig::get( CBTConfig::autoDeleteOrphanedIndices ) ) {
+ qDebug() << "deleting orphaned index in directory" << dir[i];
+ CSwordModuleInfo::deleteIndexForModule( dir[i] );
+ }
+ }
+ }
+ }
+}
diff --git a/src/backend/managers/cswordbackend.h b/src/backend/managers/cswordbackend.h
index c8b4f77..68be102 100644
--- a/src/backend/managers/cswordbackend.h
+++ b/src/backend/managers/cswordbackend.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,6 +16,14 @@
#include <QStringList>
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/bookshelfmodel/btbookshelfmodel.h"
+#include "backend/filters/gbftohtml.h"
+#include "backend/filters/osistohtml.h"
+#include "backend/filters/plaintohtml.h"
+#include "backend/filters/teitohtml.h"
+#include "backend/filters/thmltohtml.h"
+#include "backend/rendering/cbookdisplay.h"
+#include "backend/rendering/cchapterdisplay.h"
+#include "backend/rendering/centrydisplay.h"
// Sword includes:
#include <swmgr.h>
@@ -25,20 +33,17 @@
#include <localemgr.h>
#include <utilstr.h>
-namespace Rendering {
-class CEntryDisplay;
-class CChapterDisplay;
-class CBookDisplay;
-}
+/**
+ \brief The backend layer main class, a backend implementation of Sword.
+
+ This is the implementation of CBackend for Sword. It's additionally derived
+ from SWMgr to provide functions of Sword.
-/** The backend layer main class.
- * This is the implementation of CBackend for Sword. It's additionally derived from SWMgr
- * to provide functions of Sword.
- *
- * @short The backend implementation of Sword
- * @author The BibleTime team
- * @version $Id: cswordbackend.h,v 1.58 2007/03/14 21:32:47 joachim Exp $
- */
+ \note Mostly, only one instance of this class is used. This instance is
+ created by BibleTime::initBackends() and is destroyed by
+ BibleTimeApp::~BibleTimeApp(). Only when \ref BackendNotSingleton
+ "managing modules" separate backends are created.
+*/
class CSwordBackend : public QObject, public sword::SWMgr {
Q_OBJECT
public:
@@ -52,32 +57,6 @@ class CSwordBackend : public QObject, public sword::SWMgr {
OtherChange = 16
};
- /** Filter options. Filter options to
- * control the text display of modules. Uses int and not bool because not all
- * options have just two toggle values.
- */
- struct FilterOptions {
- int footnotes; /**< 0 for disabled, 1 for enabled */
- int strongNumbers; /**< 0 for disabled, 1 for enabled */
- int headings; /**< 0 for disabled, 1 for enabled */
- int morphTags; /**< 0 for disabled, 1 for enabled */
- int lemmas; /**< 0 for disabled, 1 for enabled */
- int hebrewPoints; /**< 0 for disabled, 1 for enabled */
- int hebrewCantillation; /**< 0 for disabled, 1 for enabled */
- int greekAccents; /**< 0 for disabled, 1 for enabled */
- int textualVariants; /**< Number n to enabled the n-th variant */
- int redLetterWords; /**< 0 for disabled, 1 for enabled */
- int scriptureReferences; /**< 0 for disabled, 1 for enabled */
- int morphSegmentation; /**< 0 for disabled, 1 for enabled */
- };
-
- /** Control the display of a text.
- */
- struct DisplayOptions {
- int lineBreaks;
- int verseNumbers;
- };
-
/** The error codes which may be returned by the @ref Load() call.
*/
enum LoadError { // the values exist to cast from the char return of SWMgr::Load
@@ -86,12 +65,6 @@ class CSwordBackend : public QObject, public sword::SWMgr {
NoModules = 1
};
/**
- * The constructor of the Sword backend.
- * It creates the SWModule objects using SWMgr's methods, it adds the necessary
- * filters for the module format.
- */
- CSwordBackend();
- /**
* The constructor of the Sword backend. This is actually used nowhere.
* Notice that using augmentHome=false can mess up the system because it is true elsewhere.
* @param path The path which is used to load modules
@@ -104,6 +77,19 @@ class CSwordBackend : public QObject, public sword::SWMgr {
*/
~CSwordBackend();
+ /** Creates and returns the instance. */
+ static inline CSwordBackend *createInstance() {
+ Q_ASSERT(m_instance == 0);
+ m_instance = new CSwordBackend();
+ return m_instance;
+ }
+
+ /** Returns the singleton instance, creating it if one does not exist. */
+ static inline CSwordBackend *instance() { return m_instance; }
+
+ /** Destroys the singleton instance, if one exists. */
+ static void destroyInstance() { delete m_instance; }
+
/**
* This function returns the list of available modules managed by this
* backend. You have to call initModules() first; This method is
@@ -134,8 +120,8 @@ class CSwordBackend : public QObject, public sword::SWMgr {
* @param enable If this is true the option will be enabled, otherwise it will be disabled.
*/
void setOption( const CSwordModuleInfo::FilterTypes type, const int state );
- /** */
- void setFilterOptions( const CSwordBackend::FilterOptions options );
+
+ void setFilterOptions(const FilterOptions &options);
/**
* Sets the language for the international booknames of Sword.
* @param langName The abbreviation string which should be used for the Sword backend
@@ -147,12 +133,7 @@ class CSwordBackend : public QObject, public sword::SWMgr {
* @return pointer to the desired module; null if no module has the specified description
*/
CSwordModuleInfo* findModuleByDescription(const QString& description);
- /**
- * This function searches for a module with the specified description
- * @param description The description of the desired module
- * @return pointer to the desired module; null if no module has the specified description
- */
- const QString findModuleNameByDescription(const QString& description);
+
/**
* This function searches for a module with the specified name
* @param name The name of the desired module
@@ -165,21 +146,12 @@ class CSwordBackend : public QObject, public sword::SWMgr {
* @return pointer to the desired module; null if no module has the specified name
*/
CSwordModuleInfo* findSwordModuleByPointer(const sword::SWModule* const swmodule);
- /**
- * This function searches for a module which is the same as the passed module.
- * @param module The module which should be used for searching the new one. May be child of a different backend.
- * @return Pointer to the desired module; null if no module has the specified name
- */
- CSwordModuleInfo* findModuleByPointer(const CSwordModuleInfo* const module);
+
/**
* @return Our global config object which contains the configs of all modules merged together.
*/
inline sword::SWConfig* getConfig() const;
- /**
- * Tries to find the config object for the module. The second paramter will be the found config.
- * @return True if the config was found, false if not. If false is returned the moduleConfig object is in undefined/unknwon state.
- */
- bool moduleConfig(const QString& module, sword::SWConfig& moduleConfig );
+
/**
* Returns the text used for the option given as parameter.
* @param The paramter enum
@@ -195,11 +167,7 @@ class CSwordBackend : public QObject, public sword::SWMgr {
* @param The translated option name
*/
static const QString translatedOptionName(const CSwordModuleInfo::FilterTypes option );
- /**
- * Returns the version of the Sword library.
- * @return The version used by this backend
- */
- inline const sword::SWVersion Version();
+
/**
* Reload all Sword modules.
*/
@@ -212,22 +180,39 @@ class CSwordBackend : public QObject, public sword::SWMgr {
QList<CSwordModuleInfo*> takeModulesFromList(QStringList names);
/**
- * Returns a list of pointers to modules, created from a list of module names.
+ \returns a list of pointers to modules, created from a list of module
+ names.
+ */
+ QList<CSwordModuleInfo*> getPointerList(const QStringList &names);
+
+ /**
+ \returns a list of pointers to const modules, created from a list of
+ module names.
*/
- QList<CSwordModuleInfo*> getPointerList(QStringList names);
+ QList<const CSwordModuleInfo*> getConstPointerList(const QStringList &names);
/** Sword prefix list.
* @return A list of all known Sword prefix dirs
*/
QStringList swordDirList() const;
+ /**
+ * delete all orphaned indexes (no module present) if autoDeleteOrphanedIndices is true
+ * delete all indices of modules where hasIndex() returns false (because of wrong index version etc.)
+ */
+ void deleteOrphanedIndices();
signals:
void sigSwordSetupChanged(CSwordBackend::SetupChangedReason reason);
protected:
/**
- * Adds a render filter to the module.
- * This is used to apply our own render filters to our modules instead of the sword filters
+ Creates the SWModule objects using SWMgr's methods, it adds the
+ necessary filters for the module format.
+ */
+ CSwordBackend();
+
+ /**
+ * Reimplemented from sword::SWMgr.
*/
void AddRenderFilters(sword::SWModule *module, sword::ConfigEntMap &section);
/**
@@ -239,32 +224,27 @@ class CSwordBackend : public QObject, public sword::SWMgr {
QString getPrivateSwordConfigPath() const;
QString getPrivateSwordConfigFile() const;
- private:
- // Filters
- struct Filters {
- sword::SWFilter* gbf;
- sword::SWFilter* plain;
- sword::SWFilter* thml;
- sword::SWFilter* osis;
- sword::SWFilter* tei;
- } m_filters;
-
- struct Displays {
- Rendering::CChapterDisplay* chapter;
- Rendering::CEntryDisplay* entry;
- Rendering::CBookDisplay* book;
- } m_displays;
+ private: /* Fields: */
+ // Filters:
+ Filters::GbfToHtml m_gbfFilter;
+ Filters::OsisToHtml m_osisFilter;
+ Filters::PlainToHtml m_plainFilter;
+ Filters::TeiToHtml m_teiFilter;
+ Filters::ThmlToHtml m_thmlFilter;
+
+ // Displays:
+ Rendering::CChapterDisplay m_chapterDisplay;
+ Rendering::CEntryDisplay m_entryDisplay;
+ Rendering::CBookDisplay m_bookDisplay;
BtBookshelfModel m_dataModel;
- QMap<QString, QString> m_moduleDescriptionMap;
-};
-Q_DECLARE_METATYPE(CSwordBackend::FilterOptions)
-Q_DECLARE_METATYPE(CSwordBackend::DisplayOptions)
+ static CSwordBackend *m_instance;
+};
/**Returns The list of modules managed by this backend*/
inline const QList<CSwordModuleInfo*> &CSwordBackend::moduleList() const {
- return m_dataModel.modules();
+ return m_dataModel.moduleList();
}
inline BtBookshelfModel *CSwordBackend::model() {
@@ -276,9 +256,4 @@ inline sword::SWConfig* CSwordBackend::getConfig() const {
return config;
}
-/** Returns the version of the Sword library. */
-inline const sword::SWVersion CSwordBackend::Version() {
- return sword::SWVersion::currentVersion;
-}
-
#endif
diff --git a/src/backend/managers/referencemanager.cpp b/src/backend/managers/referencemanager.cpp
index 4fc5e53..de41af2 100644
--- a/src/backend/managers/referencemanager.cpp
+++ b/src/backend/managers/referencemanager.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,12 +10,10 @@
#include "backend/managers/referencemanager.h"
#include <algorithm>
-
#include <QRegExp>
#include <QDebug>
#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordversekey.h"
-#include "util/cpointers.h"
/** Returns a hyperlink used to be imbedded in the display windows. At the moment the format is sword://module/key */
@@ -87,15 +85,15 @@ const QString ReferenceManager::encodeHyperlink( const QString moduleName, const
case Bible: //bibles or commentary keys need parsing
case Commentary: {
- /* CSwordModuleInfo* mod = CPointers::backend()->findModuleByName(moduleName);
+ /* CSwordModuleInfo* mod = CSwordBackend::instance()()->findModuleByName(moduleName);
- ParseOptions options;
- options.refDestinationModule = mod->name();
- options.refBase =
- options.sourceLanguage = mod->module()->Lang();
- options.destinationLanguage = "en";
+ 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( parseVerseReference(key, options) ); //we add the english key, so drag and drop will work in all cases*/
ret.append(key);
break;
}
@@ -237,20 +235,6 @@ bool ReferenceManager::decodeHyperlink( const QString& hyperlink, QString& modul
return true;
}
-const QString ReferenceManager::encodeReference(const QString &module, const QString &reference) {
- //return QString("(%1)%2").arg(module).arg(reference);
- return QString("(").append(module).append(")").append(reference);
-}
-
-void ReferenceManager::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);
-
- module = fallbackModule;
- reference = dragreference;
-}
-
/** Returns true if the parameter is a hyperlink. */
bool ReferenceManager::isHyperlink( const QString& hyperlink ) {
return ( hyperlink.left(8) == "sword://")
@@ -341,7 +325,7 @@ ReferenceManager::Type ReferenceManager::typeFromModule( const CSwordModuleInfo:
/** Parses the given verse references using the given language and the module.*/
const QString ReferenceManager::parseVerseReference( const QString& ref, const ReferenceManager::ParseOptions& options) {
- CSwordModuleInfo* const mod = CPointers::backend()->findModuleByName(options.refDestinationModule);
+ CSwordModuleInfo* const mod = CSwordBackend::instance()->findModuleByName(options.refDestinationModule);
//Q_ASSERT(mod); tested later
if (!mod) {
@@ -371,19 +355,19 @@ const QString ReferenceManager::parseVerseReference( const QString& ref, const R
CSwordVerseKey baseKey(0);
baseKey.setLocale( sourceLanguage.toUtf8().constData() );
- baseKey.key( options.refBase ); //probably in the sourceLanguage
+ baseKey.setKey(options.refBase); //probably in the sourceLanguage
baseKey.setLocale( "en_US" ); //english works in all environments as base
-// CSwordVerseKey dummy(0);
+// 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);
+ const QString oldLocaleName = CSwordBackend::instance()->booknameLanguage();
+ CSwordBackend::instance()->booknameLanguage(sourceLanguage);
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());
+// 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
@@ -416,6 +400,6 @@ const QString ReferenceManager::parseVerseReference( const QString& ref, const R
}
- CPointers::backend()->booknameLanguage(oldLocaleName);
+ CSwordBackend::instance()->booknameLanguage(oldLocaleName);
return ret;
}
diff --git a/src/backend/managers/referencemanager.h b/src/backend/managers/referencemanager.h
index fdef8b2..a07b480 100644
--- a/src/backend/managers/referencemanager.h
+++ b/src/backend/managers/referencemanager.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -47,20 +47,7 @@ bool decodeHyperlink( const QString& hyperlink, QString& module, QString& key, T
* @return The encoded hyperlink
*/
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
-*/
-const QString encodeReference(const QString &module, const QString &reference);
-/**
-* decodes a 'draggable' reference into a modulename and a reference
-* @author Martin Gruner
-*/
-void decodeReference(QString &dragreference, QString &module, QString &reference);
+
/**
* Returns true if the parameter is a hyperlink.
* @param hyperlink The string which is tested
diff --git a/src/backend/rendering/cbookdisplay.cpp b/src/backend/rendering/cbookdisplay.cpp
index 9da57f2..259e904 100644
--- a/src/backend/rendering/cbookdisplay.cpp
+++ b/src/backend/rendering/cbookdisplay.cpp
@@ -2,14 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "backend/rendering/cbookdisplay.h"
-#include <boost/scoped_ptr.hpp>
+#include <QSharedPointer>
#include <QtAlgorithms>
#include "backend/drivers/cswordbookmoduleinfo.h"
@@ -17,12 +17,18 @@
#include "backend/rendering/cdisplayrendering.h"
-/** Returns the rendered text using the modules in the list and using the key parameter. The displayoptions and filter options are used, too. */
-const QString Rendering::CBookDisplay::text( const QList<CSwordModuleInfo*>& modules, const QString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) {
- CSwordBookModuleInfo* book = dynamic_cast<CSwordBookModuleInfo*>(modules.first());
+const QString Rendering::CBookDisplay::text(
+ const QList<const CSwordModuleInfo*> &modules,
+ const QString &keyName,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions)
+{
+ typedef CSwordBookModuleInfo CSBMI;
+
+ const CSBMI* book = dynamic_cast<const CSBMI*>(modules.first());
Q_ASSERT(book);
- CSwordBackend::DisplayOptions dOpts = displayOptions;
+ DisplayOptions dOpts = displayOptions;
dOpts.lineBreaks = true; //books should render with blocks, not with inlined sections
CDisplayRendering render(dOpts, filterOptions);
@@ -32,10 +38,10 @@ const QString Rendering::CBookDisplay::text( const QList<CSwordModuleInfo*>& mod
// the number of levels which should be display together, 1 means display no entries together
int displayLevel = book->config( CSwordModuleInfo::DisplayLevel ).toInt();
- boost::scoped_ptr<CSwordTreeKey> key (
+ QSharedPointer<CSwordTreeKey> key (
dynamic_cast<CSwordTreeKey*>( CSwordKey::createInstance(book) )
);
- key->key(keyName); //set the key to position we'd like to get
+ key->setKey(keyName); //set the key to position we'd like to get
const unsigned long offset = key->getOffset();
@@ -60,7 +66,7 @@ const QString Rendering::CBookDisplay::text( const QList<CSwordModuleInfo*>& mod
int possibleLevels = 1; //we start with the default value of displayLevel, which means no entries together
- while ( key->parent() && (key->key() != "/") && !key->key().isEmpty() ) {//add parents
+ while ( key->sword::TreeKeyIdx::parent() && (key->key() != "/") && !key->key().isEmpty() ) {//add parents
++possibleLevels;
};
@@ -90,7 +96,7 @@ const QString Rendering::CBookDisplay::text( const QList<CSwordModuleInfo*>& mod
// at the moment we're at the lowest level, so we only have to go up!
for (int currentLevel = 1; currentLevel < displayLevel; ++currentLevel) { //we start again with 1 == standard of displayLevel
- if ( !key->parent() ) { //something went wrong although we checked before! Be safe and return entry's text
+ if ( !key->sword::TreeKeyIdx::parent() ) { //something went wrong although we checked before! Be safe and return entry's text
tree.append( new CDisplayRendering::KeyTreeItem( key->key(), modules, itemSettings ) );
const QString renderedText = render.renderKeyTree(tree);
@@ -108,7 +114,7 @@ const QString Rendering::CBookDisplay::text( const QList<CSwordModuleInfo*>& mod
//const bool hasToplevelText = !key->strippedText().isEmpty();
key->firstChild(); //go to the first sibling on the same level
- setupRenderTree(key.get(), &tree, keyName);
+ setupRenderTree(key.data(), &tree, keyName);
const QString renderedText = render.renderKeyTree(tree);
@@ -126,7 +132,9 @@ void Rendering::CBookDisplay::setupRenderTree(CSwordTreeKey * swordTree, CTextRe
CTextRendering::KeyTreeItem::Settings settings;
settings.highlight = (key == highlightKey);
- CTextRendering::KeyTreeItem* item = new CTextRendering::KeyTreeItem(key, swordTree->module(0), settings );
+ /// \todo Check whether this is correct:
+ CTextRendering::KeyTreeItem *item = new CTextRendering::KeyTreeItem(
+ key, swordTree->module(), settings);
renderTree->append( item );
if (swordTree->hasChildren()) { //print tree for the child items
diff --git a/src/backend/rendering/cbookdisplay.h b/src/backend/rendering/cbookdisplay.h
index 832249f..be5ec9b 100644
--- a/src/backend/rendering/cbookdisplay.h
+++ b/src/backend/rendering/cbookdisplay.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,26 +20,27 @@ class CSwordTreeKey;
namespace Rendering {
/**
-* A CEntryDisplay implementation which works on tree-based GenBook modules
-* of Sword.
-* @short CEntryDisplay implementation for GenBook modules,
-* @author The BibleTime team
-*/
-
-class CBookDisplay : public CEntryDisplay {
- public: // Public methods
- virtual ~CBookDisplay() {}
+* \brief CEntryDisplay implementation for GenBook modules,
- /**
- * Returns the rendered text using the modules in the list and using the key parameter.
- * The displayoptions and filter options are used, too.
- */
- virtual const QString text( const QList<CSwordModuleInfo*>& modules, const QString& key, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions);
-
- protected:
- void setupRenderTree(CSwordTreeKey* swordTree, CTextRendering::KeyTree* renderTree, const QString& highlightKey);
+ A CEntryDisplay implementation which works on tree-based GenBook modules of
+ Sword.
+*/
+class CBookDisplay: public CEntryDisplay {
+ public: /* Methods: */
+ virtual inline ~CBookDisplay() {}
+
+ /** Reimplemented from CEntryDisplay. */
+ virtual const QString text(const QList<const CSwordModuleInfo*> &modules,
+ const QString &key,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions);
+
+ protected: /* Methods: */
+ void setupRenderTree(CSwordTreeKey *swordTree,
+ CTextRendering::KeyTree *renderTree,
+ const QString &highlightKey);
};
-}
+} // namespace Rendering
#endif
diff --git a/src/backend/rendering/cchapterdisplay.cpp b/src/backend/rendering/cchapterdisplay.cpp
index 74063cf..31b56b8 100644
--- a/src/backend/rendering/cchapterdisplay.cpp
+++ b/src/backend/rendering/cchapterdisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,11 +14,18 @@
#include "backend/rendering/cdisplayrendering.h"
-const QString Rendering::CChapterDisplay::text( const QList<CSwordModuleInfo*>& modules, const QString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) {
+const QString Rendering::CChapterDisplay::text(
+ const QList<const CSwordModuleInfo*> &modules,
+ const QString &keyName,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions)
+{
+ typedef CSwordBibleModuleInfo CSBMI;
+
Q_ASSERT( modules.count() >= 1 );
Q_ASSERT( !keyName.isEmpty() );
- CSwordModuleInfo* module = modules.first();
+ const CSwordModuleInfo *module = modules.first();
if (modules.count() == 1) module->module()->setSkipConsecutiveLinks( true ); //skip empty, linked verses
@@ -37,14 +44,14 @@ const QString Rendering::CChapterDisplay::text( const QList<CSwordModuleInfo*>&
if (module->type() == CSwordModuleInfo::Bible) {
((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
- CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module);
- Q_ASSERT(bible);
+ Q_ASSERT(dynamic_cast<const CSBMI*>(module) != 0);
+ const CSBMI *bible = static_cast<const CSBMI*>(module);
CSwordVerseKey k1(module);
k1.Headings(1);
- k1.key(keyName);
+ k1.setKey(keyName);
- if (k1.Chapter() == 1) k1.Chapter(0); //Chapter 1, start with 0:0, otherwise X:0
+ if (k1.Chapter() == 1) k1.Chapter(0); //Chapter 1, start with 0:0, otherwise X:0
k1.Verse(0);
diff --git a/src/backend/rendering/cchapterdisplay.h b/src/backend/rendering/cchapterdisplay.h
index 3b3d363..a13ebc3 100644
--- a/src/backend/rendering/cchapterdisplay.h
+++ b/src/backend/rendering/cchapterdisplay.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,24 +15,25 @@
namespace Rendering {
-/** Chapter rendering.
-* A CEntryDisplay implementation mde for Bibles to display whole chapters
-* at once.
-* @author The BibleTime team
-*/
-
-class CChapterDisplay : public CEntryDisplay {
+/**
+ \brief CEntryDisplay implementation for whole chapters.
- public: // Public methods
- virtual ~CChapterDisplay() {}
+ A CEntryDisplay implementation made for Bibles to display whole chapters at
+ once.
+*/
+class CChapterDisplay: public CEntryDisplay {
+ public: /* Methods: */
+ virtual inline ~CChapterDisplay() {}
/**
- * Returns the rendered text using the modules in the list and using the key parameter.
- * The displayoptions and filter options are used, too.
+ Reimplemented from CEntryDisplay.
*/
- virtual const QString text( const QList<CSwordModuleInfo*>& modules, const QString& key, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions);
+ virtual const QString text(const QList<const CSwordModuleInfo*> &modules,
+ const QString &key,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions);
};
-}
+} // namespace Rendering
#endif
diff --git a/src/backend/rendering/cdisplayrendering.cpp b/src/backend/rendering/cdisplayrendering.cpp
index cc3f7c9..c79cfdf 100644
--- a/src/backend/rendering/cdisplayrendering.cpp
+++ b/src/backend/rendering/cdisplayrendering.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,15 +16,21 @@
#include "backend/keys/cswordversekey.h"
#include "backend/managers/cdisplaytemplatemgr.h"
#include "backend/managers/referencemanager.h"
-#include "util/cpointers.h"
namespace Rendering {
-CDisplayRendering::CDisplayRendering(CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions)
- : CHTMLExportRendering(CHTMLExportRendering::Settings(true), displayOptions, filterOptions) {}
+CDisplayRendering::CDisplayRendering(const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions)
+ : CHTMLExportRendering(CHTMLExportRendering::Settings(true),
+ displayOptions, filterOptions)
+{
+ // Intentionally empty
+}
-const QString CDisplayRendering::entryLink( const KeyTreeItem& item, CSwordModuleInfo* module ) {
+const QString CDisplayRendering::entryLink(const KeyTreeItem &item,
+ const CSwordModuleInfo *module)
+{
QString linkText;
const bool isBible = module && (module->type() == CSwordModuleInfo::Bible);
@@ -32,7 +38,7 @@ const QString CDisplayRendering::entryLink( const KeyTreeItem& item, CSwordModul
vk.Headings(true);
if (isBible) {
- vk.key(item.key());
+ vk.setKey(item.key());
}
if (isBible && (vk.Verse() == 0)) {
@@ -105,7 +111,7 @@ const QString CDisplayRendering::keyToHTMLAnchor(const QString& key) {
}
const QString CDisplayRendering::finishText( const QString& oldText, KeyTree& tree ) {
- QList<CSwordModuleInfo*> modules = collectModules(&tree);
+ QList<const CSwordModuleInfo*> modules = collectModules(&tree);
qDebug() << "CDisplayRendering::finishText";
//marking words is very slow, we have to find a better solution
@@ -139,9 +145,9 @@ const QString CDisplayRendering::finishText( const QString& oldText, KeyTree& tr
const CLanguageMgr::Language* const lang =
(modules.count() >= 1)
? modules.first()->language()
- : CPointers::languageMgr()->defaultLanguage();
+ : CLanguageMgr::instance()->defaultLanguage();
- CDisplayTemplateMgr* tMgr = CPointers::displayTemplateManager();
+ CDisplayTemplateMgr *tMgr = CDisplayTemplateMgr::instance();
//Q_ASSERT(modules.count() >= 1);
diff --git a/src/backend/rendering/cdisplayrendering.h b/src/backend/rendering/cdisplayrendering.h
index f66e556..8b222ac 100644
--- a/src/backend/rendering/cdisplayrendering.h
+++ b/src/backend/rendering/cdisplayrendering.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,12 +25,14 @@ class CDisplayRendering : public CHTMLExportRendering {
static const QString keyToHTMLAnchor(const QString& key);
CDisplayRendering(
- CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(),
- CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults()
+ const DisplayOptions &displayOptions = CBTConfig::getDisplayOptionDefaults(),
+ const FilterOptions &filterOptions = CBTConfig::getFilterOptionDefaults()
);
protected:
- virtual const QString entryLink( const KeyTreeItem& item, CSwordModuleInfo* const module );
+ virtual const QString entryLink(const KeyTreeItem &item,
+ const CSwordModuleInfo *module);
+
virtual const QString finishText( const QString&, KeyTree& tree );
};
diff --git a/src/backend/rendering/centrydisplay.cpp b/src/backend/rendering/centrydisplay.cpp
index b6c7a27..d1b2a34 100644
--- a/src/backend/rendering/centrydisplay.cpp
+++ b/src/backend/rendering/centrydisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -24,15 +24,17 @@
using namespace Rendering;
-/** Returns the rendered text using the modules in the list and using the key parameter.
- * The displayoptions and filter options are used, too.
- */
-const QString CEntryDisplay::text( const QList<CSwordModuleInfo*>& modules, const QString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) {
+const QString CEntryDisplay::text(
+ const QList<const CSwordModuleInfo*> &modules,
+ const QString &keyName,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions)
+{
CDisplayRendering render(displayOptions, filterOptions);
//no highlighted key and no extra key link in the text
CTextRendering::KeyTreeItem::Settings normal_settings(false, CTextRendering::KeyTreeItem::Settings::CompleteShort);
- CSwordModuleInfo* module = modules.first();
+ const CSwordModuleInfo *module = modules.first();
Rendering::CTextRendering::KeyTree tree;
@@ -42,7 +44,7 @@ const QString CEntryDisplay::text( const QList<CSwordModuleInfo*>& modules, cons
CSwordVerseKey k1(module);
k1.Headings(1);
- k1.key(keyName);
+ k1.setKey(keyName);
// don't print the key
CTextRendering::KeyTreeItem::Settings preverse_settings(false, CTextRendering::KeyTreeItem::Settings::NoKey);
diff --git a/src/backend/rendering/centrydisplay.h b/src/backend/rendering/centrydisplay.h
index 5f410a5..08a55c4 100644
--- a/src/backend/rendering/centrydisplay.h
+++ b/src/backend/rendering/centrydisplay.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,35 +10,28 @@
#ifndef CENTRYDISPLAY_H
#define CENTRYDISPLAY_H
-#include "util/cpointers.h"
-
#include <QString>
-#include "backend/managers/cswordbackend.h"
// Sword includes:
#include <swdisp.h>
class CSwordModuleInfo;
+struct DisplayOptions;
+struct FilterOptions;
namespace Rendering {
-/**
-* The reimplementation of SWDisplay to fit our needs.
-* @short Display implementation
-* @author The BibleTime team
-*/
-
-class CEntryDisplay : public sword::SWDisplay, public CPointers {
-
+class CEntryDisplay: public sword::SWDisplay {
public:
- virtual ~CEntryDisplay() {}
-
/**
- * Returns the rendered text using the modules in the list and using the key parameter.
- * The displayoptions and filter options are used, too.
+ \returns the rendered text using the modules in the list and using the
+ key parameter.
*/
- virtual const QString text( const QList<CSwordModuleInfo*>& modules, const QString& key, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions);
+ virtual const QString text(const QList<const CSwordModuleInfo*> &modules,
+ const QString &key,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions);
};
diff --git a/src/backend/rendering/chtmlexportrendering.cpp b/src/backend/rendering/chtmlexportrendering.cpp
index 6a571c6..3d82602 100644
--- a/src/backend/rendering/chtmlexportrendering.cpp
+++ b/src/backend/rendering/chtmlexportrendering.cpp
@@ -2,15 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "backend/rendering/chtmlexportrendering.h"
-#include <boost/scoped_ptr.hpp>
-#include <iostream>
+#include <QSharedPointer>
#include <QDebug>
#include "backend/drivers/cswordmoduleinfo.h"
@@ -18,42 +17,43 @@
#include "backend/keys/cswordversekey.h"
#include "backend/managers/cdisplaytemplatemgr.h"
#include "backend/managers/clanguagemgr.h"
-#include "util/cpointers.h"
+#ifdef BT_DEBUG
namespace {
-/*
- * Helper function to dump a verse with all its enty attributes
- */
-
+/** Helper function to dump a verse with all its enty attributes. */
void dumpEntryAttributes(sword::SWModule *module) {
- std::cout << "Attributes for key: " << module->getKeyText() << std::endl;
+ qDebug() << "Attributes for key: " << module->getKeyText();
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";
+ qDebug() << "[ " << i1->first << " ]";
for (i2 = i1->second.begin(); i2 != i1->second.end(); i2++) {
- std::cout << "\t[ " << i2->first << " ]\n";
+ qDebug() << "\t[ " << i2->first << " ]";
for (i3 = i2->second.begin(); i3 != i2->second.end(); i3++) {
- std::cout << "\t\t" << i3->first << " = " << i3->second << "\n";
+ qDebug() << "\t\t" << i3->first << " = " << i3->second;
}
}
}
- std::cout << std::endl;
}
-}
+} // anonymous namespace
+#endif
namespace Rendering {
-CHTMLExportRendering::CHTMLExportRendering(const CHTMLExportRendering::Settings& settings, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions)
+CHTMLExportRendering::CHTMLExportRendering(
+ const CHTMLExportRendering::Settings &settings,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions)
: m_displayOptions(displayOptions),
- m_filterOptions(filterOptions),
- m_settings(settings) {}
-
-CHTMLExportRendering::~CHTMLExportRendering() {}
+ m_filterOptions(filterOptions),
+ m_settings(settings)
+{
+ // Intentionally empty
+}
const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey* k) {
@@ -62,13 +62,13 @@ const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey
ret.append(i.getAlternativeContent());
// Q_ASSERT(i.hasChildItems());
-
+
if (!i.childList()->isEmpty()) {
KeyTree * const tree = i.childList();
- const QList<CSwordModuleInfo*> modules = collectModules(tree);
+ const QList<const CSwordModuleInfo*> modules = collectModules(tree);
- if (modules.count() == 1) { //insert the direction into the sorrounding div
+ if (modules.count() == 1) { //insert the direction into the surrounding div
ret.insert( 5, QString("dir=\"%1\" ").arg((modules.first()->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl" ));
}
@@ -82,13 +82,13 @@ const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey
}
- const QList<CSwordModuleInfo*>& modules( i.modules() );
+ const QList<const CSwordModuleInfo*> &modules(i.modules());
if (modules.count() == 0) {
return QString(""); //no module present for rendering
}
- boost::scoped_ptr<CSwordKey> scoped_key( !k ? CSwordKey::createInstance(modules.first()) : 0 );
- CSwordKey* key = k ? k : scoped_key.get();
+ QSharedPointer<CSwordKey> scoped_key( !k ? CSwordKey::createInstance(modules.first()) : 0 );
+ CSwordKey* key = k ? k : scoped_key.data();
Q_ASSERT(key);
CSwordVerseKey* myVK = dynamic_cast<CSwordVerseKey*>(key);
@@ -100,19 +100,17 @@ const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey
//declarations out of the loop for optimization
QString entry;
- QString keyText;
bool isRTL;
QString preverseHeading;
QString langAttr;
QString key_renderedText;
- QList<CSwordModuleInfo*>::const_iterator end_modItr = modules.end();
+ QList<const CSwordModuleInfo*>::const_iterator end_modItr = modules.end();
- for (QList<CSwordModuleInfo*>::const_iterator mod_Itr(modules.begin()); mod_Itr != end_modItr; ++mod_Itr) {
- key->module(*mod_Itr);
- key->key( i.key() );
+ for (QList<const CSwordModuleInfo*>::const_iterator mod_Itr(modules.begin()); mod_Itr != end_modItr; ++mod_Itr) {
+ key->setModule(*mod_Itr);
+ key->setKey(i.key());
- keyText = key->key();
isRTL = ((*mod_Itr)->textDirection() == CSwordModuleInfo::RightToLeft);
entry = QString::null;
@@ -144,7 +142,16 @@ const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey
(*mod_Itr)->module()->getEntryAttributes()["Heading"]["Preverse"].end();
for (; it != end; ++it) {
- preverseHeading = QString::fromUtf8(it->second.c_str());
+ QString unfiltered = it->second.c_str();
+
+ /// \todo This is only a preliminary workaround to strip the tags:
+ QRegExp filter("<title>(.*)</title>");
+ if (unfiltered.indexOf(filter) >= 0) {
+ preverseHeading = filter.cap(1);
+ } else {
+ preverseHeading = unfiltered;
+ }
+
/// \todo Take care of the heading type!
if (!preverseHeading.isEmpty()) {
entry.append("<div ")
@@ -207,16 +214,16 @@ const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey
}
void CHTMLExportRendering::initRendering() {
- //CPointers::backend()->setDisplayOptions( m_displayOptions );
- CPointers::backend()->setFilterOptions( m_filterOptions );
+ //CSwordBackend::instance()()->setDisplayOptions( m_displayOptions );
+ CSwordBackend::instance()->setFilterOptions( m_filterOptions );
}
const QString CHTMLExportRendering::finishText( const QString& text, KeyTree& tree ) {
- const QList<CSwordModuleInfo*> modules = collectModules(&tree);
+ const QList<const CSwordModuleInfo*> modules = collectModules(&tree);
const CLanguageMgr::Language* const lang = modules.first()->language();
- CDisplayTemplateMgr* tMgr = CPointers::displayTemplateManager();
+ CDisplayTemplateMgr *tMgr = CDisplayTemplateMgr::instance();
CDisplayTemplateMgr::Settings settings;
settings.modules = modules;
settings.langAbbrev = ((modules.count() == 1) && lang->isValid()) ? lang->abbrev() : "unknown";
@@ -231,7 +238,11 @@ const QString CHTMLExportRendering::finishText( const QString& text, KeyTree& tr
/*!
\fn CHTMLExportRendering::entryLink( KeyTreeItem& item )
*/
-const QString CHTMLExportRendering::entryLink( const KeyTreeItem& item, CSwordModuleInfo* ) {
+const QString CHTMLExportRendering::entryLink(const KeyTreeItem& item,
+ const CSwordModuleInfo *module)
+{
+ Q_UNUSED(module);
+
return item.key();
}
diff --git a/src/backend/rendering/chtmlexportrendering.h b/src/backend/rendering/chtmlexportrendering.h
index 065bb85..97e632d 100644
--- a/src/backend/rendering/chtmlexportrendering.h
+++ b/src/backend/rendering/chtmlexportrendering.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,6 +14,7 @@
#include "backend/config/cbtconfig.h"
#include "backend/managers/cswordbackend.h"
+#include "btglobal.h"
namespace Rendering {
@@ -37,20 +38,21 @@ class CHTMLExportRendering : public CTextRendering {
};
CHTMLExportRendering(
- const Settings& settings,
- CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(),
- CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults()
+ const Settings &settings,
+ const DisplayOptions &displayOptions = CBTConfig::getDisplayOptionDefaults(),
+ const FilterOptions &filterOptions = CBTConfig::getFilterOptionDefaults()
);
- virtual ~CHTMLExportRendering();
+ virtual inline ~CHTMLExportRendering() {};
protected:
virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 );
virtual const QString finishText( const QString&, KeyTree& tree );
- virtual const QString entryLink( const KeyTreeItem& item, CSwordModuleInfo* module );
+ virtual const QString entryLink(const KeyTreeItem &item,
+ const CSwordModuleInfo *module);
virtual void initRendering();
- CSwordBackend::DisplayOptions m_displayOptions;
- CSwordBackend::FilterOptions m_filterOptions;
+ DisplayOptions m_displayOptions;
+ FilterOptions m_filterOptions;
Settings m_settings;
};
diff --git a/src/backend/rendering/cplaintextexportrendering.cpp b/src/backend/rendering/cplaintextexportrendering.cpp
index fdbf78d..cad5eb9 100644
--- a/src/backend/rendering/cplaintextexportrendering.cpp
+++ b/src/backend/rendering/cplaintextexportrendering.cpp
@@ -2,40 +2,48 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "backend/rendering/cplaintextexportrendering.h"
-#include <boost/scoped_ptr.hpp>
+#include <QSharedPointer>
#include "backend/keys/cswordkey.h"
namespace Rendering {
-CPlainTextExportRendering::CPlainTextExportRendering(const CPlainTextExportRendering::Settings& settings, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions)
- : CHTMLExportRendering(settings, displayOptions, filterOptions) {}
+CPlainTextExportRendering::CPlainTextExportRendering(
+ const CPlainTextExportRendering::Settings &settings,
+ const DisplayOptions &displayOptions,
+ const FilterOptions &filterOptions)
+ : CHTMLExportRendering(settings, displayOptions, filterOptions)
+{
+ // Intentionally empty
+}
-CPlainTextExportRendering::~CPlainTextExportRendering() {}
+const QString CPlainTextExportRendering::renderEntry(const KeyTreeItem &i,
+ CSwordKey *k)
+{
+ Q_UNUSED(k);
-const QString CPlainTextExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey* ) {
if (!m_settings.addText) {
return QString(i.key()).append("\n");
}
- QList<CSwordModuleInfo*> modules = i.modules();
- boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(modules.first()) );
+ QList<const CSwordModuleInfo*> modules = i.modules();
+ QSharedPointer<CSwordKey> key( CSwordKey::createInstance(modules.first()) );
QString renderedText = QString(i.key()).append(":\n");
QString entry;
// for (CSwordModuleInfo* m = modules.first(); m; m = modules.next()) {
- QList<CSwordModuleInfo*>::iterator end_it = modules.end();
+ QList<const CSwordModuleInfo*>::iterator end_it = modules.end();
- for (QList<CSwordModuleInfo*>::iterator it(modules.begin()); it != end_it; ++it) {
- key->module(*it);
- key->key( i.key() );
+ for (QList<const CSwordModuleInfo*>::iterator it(modules.begin()); it != end_it; ++it) {
+ key->setModule(*it);
+ key->setKey(i.key());
/// \todo Check this code
entry.append(key->strippedText()).append("\n");
diff --git a/src/backend/rendering/cplaintextexportrendering.h b/src/backend/rendering/cplaintextexportrendering.h
index 5ebbb24..d14192e 100644
--- a/src/backend/rendering/cplaintextexportrendering.h
+++ b/src/backend/rendering/cplaintextexportrendering.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,11 +25,11 @@ class CPlainTextExportRendering : public CHTMLExportRendering {
public:
CPlainTextExportRendering(
- const Settings& settings,
- CSwordBackend::DisplayOptions displayOptions = CBTConfig::getDisplayOptionDefaults(),
- CSwordBackend::FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults()
+ const Settings &settings,
+ const DisplayOptions &displayOptions = CBTConfig::getDisplayOptionDefaults(),
+ const FilterOptions &filterOptions = CBTConfig::getFilterOptionDefaults()
);
- virtual ~CPlainTextExportRendering();
+ virtual inline ~CPlainTextExportRendering() {};
protected:
virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 );
diff --git a/src/backend/rendering/ctextrendering.cpp b/src/backend/rendering/ctextrendering.cpp
index 645b5d6..586d11e 100644
--- a/src/backend/rendering/ctextrendering.cpp
+++ b/src/backend/rendering/ctextrendering.cpp
@@ -2,14 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "backend/rendering/ctextrendering.h"
-#include <boost/scoped_ptr.hpp>
+#include <QSharedPointer>
#include <QRegExp>
#include <QtAlgorithms>
@@ -26,17 +26,20 @@
using namespace Rendering;
-CTextRendering::KeyTreeItem::KeyTreeItem(const QString& key, CSwordModuleInfo const * mod, const Settings settings )
- : m_settings( settings ),
+CTextRendering::KeyTreeItem::KeyTreeItem(const QString &key,
+ const CSwordModuleInfo *module,
+ const Settings &settings)
+ : m_settings(settings),
m_moduleList(),
m_key( key ),
m_childList(),
m_stopKey( QString::null ),
m_alternativeContent( QString::null ) {
- m_moduleList.append( const_cast<CSwordModuleInfo*>(mod) ); //BAD CODE
+ m_moduleList.append( const_cast<CSwordModuleInfo*>(module) ); //BAD CODE
}
-CTextRendering::KeyTreeItem::KeyTreeItem(const QString& content, const Settings settings )
+CTextRendering::KeyTreeItem::KeyTreeItem(const QString &content,
+ const Settings &settings)
: m_settings( settings ),
m_moduleList(),
m_key( QString::null ),
@@ -45,7 +48,9 @@ CTextRendering::KeyTreeItem::KeyTreeItem(const QString& content, const Settings
m_alternativeContent( content ) {
}
-CTextRendering::KeyTreeItem::KeyTreeItem(const QString& key, const QList<CSwordModuleInfo*>& mods, const Settings settings )
+CTextRendering::KeyTreeItem::KeyTreeItem(const QString &key,
+ const QList<const CSwordModuleInfo*> &mods,
+ const Settings &settings)
: m_settings( settings ),
m_moduleList( mods ),
m_key( key ),
@@ -76,11 +81,10 @@ CTextRendering::KeyTreeItem::KeyTreeItem(const KeyTreeItem& i)
}
-CTextRendering::KeyTreeItem::~KeyTreeItem() {
- qDeleteAll(m_childList);
-}
-
-CTextRendering::KeyTreeItem::KeyTreeItem(const QString& startKey, const QString& stopKey, CSwordModuleInfo* module, const Settings settings)
+CTextRendering::KeyTreeItem::KeyTreeItem(const QString &startKey,
+ const QString &stopKey,
+ const CSwordModuleInfo *module,
+ const Settings &settings)
: m_settings( settings ),
m_moduleList(),
m_key( startKey ),
@@ -94,10 +98,10 @@ CTextRendering::KeyTreeItem::KeyTreeItem(const QString& startKey, const QString&
if (module->type() == CSwordModuleInfo::Bible) {
CSwordVerseKey start(module);
- start.key(startKey);
+ start.setKey(startKey);
CSwordVerseKey stop(module);
- stop.key(stopKey);
+ stop.setKey(stopKey);
if (!m_key.isEmpty() && !m_stopKey.isEmpty()) { //we have a range of keys
bool ok = true;
@@ -154,13 +158,13 @@ const QString& CTextRendering::KeyTreeItem::getAlternativeContent() const {
return m_alternativeContent;
}
-const QList<CSwordModuleInfo*> CTextRendering::collectModules(KeyTree* const tree) const {
+const QList<const CSwordModuleInfo*> CTextRendering::collectModules(KeyTree* const tree) const {
//collect all modules which are available and used by child items
- QList<CSwordModuleInfo*> modules;
+ QList<const CSwordModuleInfo*> modules;
foreach (KeyTreeItem* c, (*tree)) {
Q_ASSERT(c);
- foreach (CSwordModuleInfo* mod, c->modules()) {
+ foreach (const CSwordModuleInfo* mod, c->modules()) {
if (!modules.contains(mod)) {
modules.append(mod);
}
@@ -172,20 +176,22 @@ const QList<CSwordModuleInfo*> CTextRendering::collectModules(KeyTree* const tre
const QString CTextRendering::renderKeyTree( KeyTree& tree ) {
initRendering();
- QList<CSwordModuleInfo*> modules = collectModules(&tree);
+ QList<const CSwordModuleInfo*> modules = collectModules(&tree);
QString t;
//optimization for entries with the same key
- boost::scoped_ptr<CSwordKey> key(
+ QSharedPointer<CSwordKey> key(
(modules.count() == 1) ? CSwordKey::createInstance(modules.first()) : 0
);
- foreach (KeyTreeItem* c, tree) {
- if (modules.count() == 1) { //this optimizes the rendering, only one key created for all items
- key->key( c->key() );
- t.append( renderEntry( *c, key.get()) );
+ if (modules.count() == 1) { //this optimizes the rendering, only one key created for all items
+ foreach (KeyTreeItem* c, tree) {
+ key->setKey(c->key());
+ t.append( renderEntry( *c, key.data()) );
}
- else {
+ }
+ else {
+ foreach (KeyTreeItem* c, tree) {
t.append( renderEntry( *c ) );
}
}
@@ -193,19 +199,25 @@ const QString CTextRendering::renderKeyTree( KeyTree& tree ) {
return finishText(t, tree);
}
-const QString CTextRendering::renderKeyRange( const QString& start, const QString& stop, const QList<CSwordModuleInfo*>& modules, const QString& highlightKey, const KeyTreeItem::Settings& keySettings ) {
+const QString CTextRendering::renderKeyRange(
+ const QString &start,
+ const QString &stop,
+ const QList<const CSwordModuleInfo*> &modules,
+ const QString &highlightKey,
+ const KeyTreeItem::Settings &keySettings)
+{
- CSwordModuleInfo* module = modules.first();
+ const CSwordModuleInfo *module = modules.first();
//qWarning( "renderKeyRange start %s stop %s \n", start.latin1(), stop.latin1() );
- boost::scoped_ptr<CSwordKey> lowerBound( CSwordKey::createInstance(module) );
- lowerBound->key(start);
+ QSharedPointer<CSwordKey> lowerBound( CSwordKey::createInstance(module) );
+ lowerBound->setKey(start);
- boost::scoped_ptr<CSwordKey> upperBound( CSwordKey::createInstance(module) );
- upperBound->key(stop);
+ QSharedPointer<CSwordKey> upperBound( CSwordKey::createInstance(module) );
+ upperBound->setKey(stop);
- sword::SWKey* sw_start = dynamic_cast<sword::SWKey*>(lowerBound.get());
- sword::SWKey* sw_stop = dynamic_cast<sword::SWKey*>(upperBound.get());
+ sword::SWKey* sw_start = dynamic_cast<sword::SWKey*>(lowerBound.data());
+ sword::SWKey* sw_stop = dynamic_cast<sword::SWKey*>(upperBound.data());
Q_ASSERT((*sw_start == *sw_stop) || (*sw_start < *sw_stop));
@@ -216,10 +228,10 @@ const QString CTextRendering::renderKeyRange( const QString& start, const QStrin
KeyTree tree;
KeyTreeItem::Settings settings = keySettings;
- CSwordVerseKey* vk_start = dynamic_cast<CSwordVerseKey*>(lowerBound.get());
+ CSwordVerseKey* vk_start = dynamic_cast<CSwordVerseKey*>(lowerBound.data());
Q_ASSERT(vk_start);
- CSwordVerseKey* vk_stop = dynamic_cast<CSwordVerseKey*>(upperBound.get());
+ CSwordVerseKey* vk_stop = dynamic_cast<CSwordVerseKey*>(upperBound.data());
Q_ASSERT(vk_stop);
bool ok = true;
@@ -250,13 +262,15 @@ const QString CTextRendering::renderKeyRange( const QString& start, const QStrin
return QString::null;
}
-const QString CTextRendering::renderSingleKey( const QString& key, const QList<CSwordModuleInfo*>& moduleList, const KeyTreeItem::Settings& settings ) {
+const QString CTextRendering::renderSingleKey(
+ const QString &key,
+ const QList<const CSwordModuleInfo*> &modules,
+ const KeyTreeItem::Settings &settings)
+{
KeyTree tree;
- tree.append( new KeyTreeItem(key, moduleList, settings) );
+ tree.append( new KeyTreeItem(key, modules, settings) );
const QString renderedText = renderKeyTree(tree);
qDeleteAll(tree);
return renderedText;
}
-
-
diff --git a/src/backend/rendering/ctextrendering.h b/src/backend/rendering/ctextrendering.h
index b6dd5e1..c6b187a 100644
--- a/src/backend/rendering/ctextrendering.h
+++ b/src/backend/rendering/ctextrendering.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -53,13 +53,26 @@ class CTextRendering {
KeyRenderingFace keyRenderingFace;
};
- KeyTreeItem(const QString& key, CSwordModuleInfo const * module, const Settings settings);
- KeyTreeItem(const QString& key, const QList<CSwordModuleInfo*>& modules, const Settings settings);
- KeyTreeItem(const QString& startKey, const QString& stopKey, CSwordModuleInfo* module, const Settings settings);
- KeyTreeItem(const QString& content, const Settings settings);
- KeyTreeItem(const KeyTreeItem& i);
+ KeyTreeItem(const QString &key,
+ const CSwordModuleInfo *module,
+ const Settings &settings);
- virtual ~KeyTreeItem();
+ KeyTreeItem(const QString &key,
+ const QList<const CSwordModuleInfo*> &modules,
+ const Settings &settings);
+
+ KeyTreeItem(const QString &startKey,
+ const QString &stopKey,
+ const CSwordModuleInfo *module,
+ const Settings &settings);
+
+ KeyTreeItem(const QString &content, const Settings &settings);
+
+ KeyTreeItem(const KeyTreeItem &i);
+
+ virtual inline ~KeyTreeItem() {
+ qDeleteAll(m_childList);
+ }
const QString& getAlternativeContent() const;
inline void setAlternativeContent(const QString& newContent) {
@@ -70,7 +83,7 @@ class CTextRendering {
return !m_alternativeContent.isNull();
};
- inline const QList<CSwordModuleInfo*>& modules() const {
+ inline const QList<const CSwordModuleInfo*>& modules() const {
return m_moduleList;
};
@@ -83,13 +96,13 @@ class CTextRendering {
};
inline KeyTree* childList() const;
-// inline const bool hasChildItems() const;
+// inline const bool hasChildItems() const;
protected:
KeyTreeItem();
Settings m_settings;
- QList<CSwordModuleInfo*> m_moduleList;
+ QList<const CSwordModuleInfo*> m_moduleList;
QString m_key;
mutable KeyTree m_childList;
@@ -101,12 +114,20 @@ class CTextRendering {
const QString renderKeyTree( KeyTree& );
- const QString renderKeyRange( const QString& start, const QString& stop, const QList<CSwordModuleInfo*>& modules, const QString& hightlightKey = QString::null, const KeyTreeItem::Settings& settings = KeyTreeItem::Settings() );
+ const QString renderKeyRange(
+ const QString &start,
+ const QString &stop,
+ const QList<const CSwordModuleInfo*> &modules,
+ const QString &hightlightKey = QString::null,
+ const KeyTreeItem::Settings &settings = KeyTreeItem::Settings());
- const QString renderSingleKey( const QString& key, const QList<CSwordModuleInfo*>&, const KeyTreeItem::Settings& settings = KeyTreeItem::Settings() );
+ const QString renderSingleKey(
+ const QString &key,
+ const QList<const CSwordModuleInfo*> &modules,
+ const KeyTreeItem::Settings &settings = KeyTreeItem::Settings());
protected:
- const QList<CSwordModuleInfo*> collectModules(KeyTree* const tree) const;
+ const QList<const CSwordModuleInfo*> collectModules(KeyTree* const tree) const;
virtual const QString renderEntry( const KeyTreeItem&, CSwordKey* = 0 ) = 0;
virtual const QString finishText( const QString&, KeyTree& tree ) = 0;
virtual void initRendering() = 0;
@@ -117,7 +138,7 @@ inline CTextRendering::KeyTree* CTextRendering::KeyTreeItem::childList() const {
}
//
//inline const bool CTextRendering::KeyTreeItem::hasChildItems() const {
-// return !m_childList.isEmpty();
+// return !m_childList.isEmpty();
//}
}
diff --git a/src/bibletime.cpp b/src/bibletime.cpp
index f2478d9..d4fa90d 100644
--- a/src/bibletime.cpp
+++ b/src/bibletime.cpp
@@ -2,16 +2,13 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "bibletime.h"
-#include <cstdlib>
-#include <iostream>
-#include <ctime>
#include <QAction>
#include <QApplication>
#include <QCloseEvent>
@@ -19,8 +16,10 @@
#include <QDebug>
#include <QInputDialog>
#include <QMdiSubWindow>
+#include <QMessageBox>
#include <QSplashScreen>
#include <QSplitter>
+#include <ctime>
#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordbiblemoduleinfo.h"
#include "backend/drivers/cswordbookmoduleinfo.h"
@@ -38,17 +37,22 @@
#include "frontend/displaywindow/cwritewindow.h"
#include "frontend/keychooser/ckeychooser.h"
#include "frontend/searchdialog/csearchdialog.h"
-#include "util/cpointers.h"
#include "util/cresmgr.h"
#include "util/directory.h"
using namespace Profile;
-BibleTime::BibleTime()
- : m_WindowWasMaximizedBeforeFullScreen(false) {
+BibleTime *BibleTime::m_instance = 0;
+
+BibleTime::BibleTime(QWidget *parent, Qt::WindowFlags flags)
+ : QMainWindow(parent, flags), m_WindowWasMaximizedBeforeFullScreen(false)
+{
namespace DU = util::directory;
+ Q_ASSERT(m_instance == 0);
+ m_instance = this;
+
QSplashScreen splash;
bool showSplash = CBTConfig::get(CBTConfig::logo);
QString splashHtml;
@@ -90,16 +94,23 @@ BibleTime::BibleTime()
Qt::AlignCenter);
}
initActions();
+ initMenubar();
+ initToolbars();
initConnections();
readSettings();
setWindowTitle("BibleTime " BT_VERSION);
setWindowIcon(DU::getIcon(CResMgr::mainWindow::icon));
+ retranslateUi();
}
BibleTime::~BibleTime() {
// delete m_dcopInterface;
// The backend is deleted by the BibleTimeApp instance
+#ifdef BT_DEBUG
+ deleteDebugWindow();
+#endif
+ saveSettings();
}
/** Saves the properties of BibleTime to the application wide configfile */
@@ -107,17 +118,18 @@ void BibleTime::saveSettings() {
/// \todo how to write settings?
//accel()->writeSettings(CBTConfig::getConfig());
- CBTConfig::set(CBTConfig::toolbar, m_viewToolbar_action->isChecked());
+ CBTConfig::set(CBTConfig::toolbar, m_viewToolbarAction->isChecked());
// set the default to false
/* CBTConfig::set(CBTConfig::autoTileVertical, false);
CBTConfig::set(CBTConfig::autoTileHorizontal, false);
CBTConfig::set(CBTConfig::autoCascade, false);
*/
- CBTConfig::set(CBTConfig::autoTileVertical, m_windowAutoTileVertical_action->isChecked());
- CBTConfig::set(CBTConfig::autoTileHorizontal, m_windowAutoTileHorizontal_action->isChecked());
- CBTConfig::set(CBTConfig::autoTile, m_windowAutoTile_action->isChecked());
- CBTConfig::set(CBTConfig::autoCascade, m_windowAutoCascade_action->isChecked());
+ CBTConfig::set(CBTConfig::autoTileVertical, m_windowAutoTileVerticalAction->isChecked());
+ CBTConfig::set(CBTConfig::autoTileHorizontal, m_windowAutoTileHorizontalAction->isChecked());
+ CBTConfig::set(CBTConfig::autoTile, m_windowAutoTileAction->isChecked());
+ CBTConfig::set(CBTConfig::autoTabbed, m_windowAutoTabbedAction->isChecked());
+ CBTConfig::set(CBTConfig::autoCascade, m_windowAutoCascadeAction->isChecked());
CProfile* p = m_profileMgr.startupProfile();
if (p) {
@@ -131,31 +143,36 @@ void BibleTime::readSettings() {
// accel()->readSettings(CBTConfig::getConfig());
CBTConfig::setupAccelSettings(CBTConfig::application, m_actionCollection);
- m_viewToolbar_action->setChecked( CBTConfig::get(CBTConfig::toolbar) );
- slotToggleToolbar();
+ m_viewToolbarAction->setChecked( CBTConfig::get(CBTConfig::toolbar) );
+ slotToggleMainToolbar();
if ( CBTConfig::get(CBTConfig::autoTileVertical) ) {
- m_windowAutoTileVertical_action->setChecked( true );
- m_windowManualMode_action->setChecked(false);
+ m_windowAutoTileVerticalAction->setChecked( true );
+ m_windowManualModeAction->setChecked(false);
slotAutoTileVertical();
}
else if ( CBTConfig::get(CBTConfig::autoTileHorizontal) ) {
- m_windowAutoTileHorizontal_action->setChecked( true );
- m_windowManualMode_action->setChecked(false);
+ m_windowAutoTileHorizontalAction->setChecked( true );
+ m_windowManualModeAction->setChecked(false);
slotAutoTileHorizontal();
}
else if ( CBTConfig::get(CBTConfig::autoTile) ) {
- m_windowAutoTile_action->setChecked(true);
- m_windowManualMode_action->setChecked(false);
+ m_windowAutoTileAction->setChecked(true);
+ m_windowManualModeAction->setChecked(false);
slotAutoTile();
}
+ else if ( CBTConfig::get(CBTConfig::autoTabbed) ) {
+ m_windowAutoTabbedAction->setChecked(true);
+ m_windowManualModeAction->setChecked(false);
+ slotAutoTabbed();
+ }
else if ( CBTConfig::get(CBTConfig::autoCascade) ) {
- m_windowAutoCascade_action->setChecked(true);
- m_windowManualMode_action->setChecked(false);
+ m_windowAutoCascadeAction->setChecked(true);
+ m_windowManualModeAction->setChecked(false);
slotAutoCascade();
}
else {
- m_windowManualMode_action->setChecked(true);
+ m_windowManualModeAction->setChecked(true);
slotManualArrangementMode();
}
}
@@ -167,10 +184,8 @@ CDisplayWindow* BibleTime::createReadDisplayWindow(QList<CSwordModuleInfo*> modu
CDisplayWindow* displayWindow = CDisplayWindowFactory::createReadInstance(modules, m_mdi);
if ( displayWindow ) {
displayWindow->init();
- if (m_mdi->subWindowList().count() == 0)
- displayWindow->showMaximized();
- else
- displayWindow->show();
+ m_mdi->addSubWindow(displayWindow);
+ displayWindow->show();
// if (!key.isEmpty())
displayWindow->lookupKey(key);
}
@@ -192,7 +207,7 @@ CDisplayWindow* BibleTime::createReadDisplayWindow(CSwordModuleInfo* module, con
return createReadDisplayWindow(list, key);
}
-CDisplayWindow* BibleTime::createWriteDisplayWindow(CSwordModuleInfo* module, const QString& key, const CDisplayWindow::WriteWindowType& type) {
+CDisplayWindow* BibleTime::createWriteDisplayWindow(CSwordModuleInfo* module, const QString& key, const CWriteWindow::WriteWindowType& type) {
qApp->setOverrideCursor( QCursor(Qt::WaitCursor) );
QList<CSwordModuleInfo*> modules;
@@ -201,6 +216,7 @@ CDisplayWindow* BibleTime::createWriteDisplayWindow(CSwordModuleInfo* module, co
CDisplayWindow* displayWindow = CDisplayWindowFactory::createWriteInstance(modules, m_mdi, type);
if ( displayWindow ) {
displayWindow->init();
+ m_mdi->addSubWindow(displayWindow);
if (m_mdi->subWindowList().count() == 0)
displayWindow->showMaximized();
else
@@ -216,45 +232,64 @@ CDisplayWindow* BibleTime::moduleEditPlain(CSwordModuleInfo *module) {
/// \todo Refactor this.
return createWriteDisplayWindow(module,
QString::null,
- CDisplayWindow::PlainTextWindow);
+ CWriteWindow::PlainTextWindow);
}
CDisplayWindow* BibleTime::moduleEditHtml(CSwordModuleInfo *module) {
/// \todo Refactor this.
return createWriteDisplayWindow(module,
QString::null,
- CDisplayWindow::HTMLWindow);
+ CWriteWindow::HTMLWindow);
}
void BibleTime::searchInModule(CSwordModuleInfo *module) {
/// \todo Refactor this.
- QList<CSwordModuleInfo *> modules;
+ QList<const CSwordModuleInfo *> modules;
modules.append(module);
Search::CSearchDialog::openDialog(modules, QString::null);
}
-void BibleTime::moduleUnlock(CSwordModuleInfo *module) {
+bool BibleTime::moduleUnlock(CSwordModuleInfo *module, QWidget *parent) {
+ /// \todo Write a proper unlocking dialog with integrated error messages.
+ QString unlockKey;
bool ok;
- const QString unlockKey =
- QInputDialog::getText(
- this,
- tr("Unlock Work"),
- tr("Enter the unlock key for this work."),
- QLineEdit::Normal,
- module->config(CSwordModuleInfo::CipherKey),
- &ok
+ for (;;) {
+ unlockKey = QInputDialog::getText(
+ parent, tr("Unlock Work"), tr("Enter the unlock key for %1.").arg(module->name()),
+ QLineEdit::Normal, module->config(CSwordModuleInfo::CipherKey), &ok
);
- if (ok) {
- /// \todo Refactor. Unlock the module via a global modules model.
- if (module->unlock(unlockKey)) {
- CPointers::backend()->reloadModules(CSwordBackend::OtherChange);
+ if (!ok) return false;
+ module->unlock(unlockKey);
+
+ /// \todo refactor this module reload
+ /* There is currently a deficiency in sword 1.6.1 in that backend->setCipherKey() does
+ * not work correctly for modules from which data was already fetched. Therefore we have to
+ * reload the modules.
+ */
+ {
+ const QString moduleName(module->name());
+ CSwordBackend *backend = CSwordBackend::instance();
+ backend->reloadModules(CSwordBackend::OtherChange);
+ module = backend->findModuleByName(moduleName);
+ Q_ASSERT(module != 0);
}
+
+ if (!module->isLocked()) break;
+ QMessageBox::warning(parent, tr("Warning: Invalid unlock key!"),
+ tr("The unlock key you provided did not properly unlock this "
+ "module. Please try again."));
}
+ return true;
+}
+
+void BibleTime::slotModuleUnlock(CSwordModuleInfo *module) {
+ moduleUnlock(module, this);
}
void BibleTime::moduleAbout(CSwordModuleInfo *module) {
- BTAboutModuleDialog *dialog(new BTAboutModuleDialog(this, module));
+ BTAboutModuleDialog *dialog = new BTAboutModuleDialog(module, this);
+ dialog->setAttribute(Qt::WA_DeleteOnClose); // Destroy dialog when closed
dialog->show();
dialog->raise();
}
@@ -269,28 +304,25 @@ void BibleTime::refreshDisplayWindows() {
}
/** Refresh main window accelerators */
-void::BibleTime::refreshBibleTimeAccel() {
+void BibleTime::refreshBibleTimeAccel() {
CBTConfig::setupAccelSettings(CBTConfig::application, m_actionCollection);
}
-/** Called before quit. */
-void BibleTime::slot_aboutToQuit() {
- saveSettings();
-}
-
-/** Called before a window is closed */
-bool BibleTime::queryClose() {
- qDebug() << "BibleTime::queryClose";
- bool ret = true;
-
- foreach(QMdiSubWindow* subWindow, m_mdi->subWindowList()) {
+void BibleTime::closeEvent(QCloseEvent *event) {
+ /*
+ Sequentially queries all open subwindows whether its fine to close them. If some sub-
+ window returns false, the querying is stopped and the close event is ignored. If all
+ subwindows return true, the close event is accepted.
+ */
+ Q_FOREACH(QMdiSubWindow *subWindow, m_mdi->subWindowList()) {
if (CDisplayWindow* window = dynamic_cast<CDisplayWindow*>(subWindow->widget())) {
- ret = ret && window->queryClose();
+ if (!window->queryClose()) {
+ event->ignore();
+ return;
+ }
}
- qDebug() << "return value:" << ret;
}
- qDebug() << "final return value:" << ret;
- return ret;
+ event->accept();
}
/** Restores the workspace if the flag for this is set in the config. */
@@ -300,32 +332,20 @@ void BibleTime::restoreWorkspace() {
}
}
-/** Processes the commandline options given to BibleTime. */
-void BibleTime::processCommandline() {
- QStringList args = qApp->QCoreApplication::arguments();
-
- if (args.contains("--help") || args.contains("-h") || args.contains("/h") || args.contains("/?")) {
- std::cout << "BibleTime" << std::endl << "--help (-h, /h, /?): Show this help message and exit"
- << std::endl << "--ignore-session: open a clean session" << std:: endl << "--open-default-bible <ref>: "
- << "Open the default Bible with the reference <ref>" << std::endl;
- std::cout << "Some Qt arguments:" << std::endl << "-reverse: reverse the UI layout direction"
- << std::endl;
- exit(0);
- //printHelpAndExit();
+void BibleTime::processCommandline(bool ignoreSession, const QString &bibleKey) {
+ if (CBTConfig::get(CBTConfig::crashedTwoTimes)) {
+ return;
}
- if ( !CBTConfig::get(CBTConfig::crashedTwoTimes) &&
- !args.contains("--ignore-session") ) {
+
+ if (!ignoreSession) {
restoreWorkspace();
}
- if ( args.contains("--open-default-bible") &&
- !CBTConfig::get(CBTConfig::crashedLastTime) &&
- !CBTConfig::get(CBTConfig::crashedTwoTimes)) {
- int index = args.indexOf("--open-default-bible");
- QString bibleKey;
- if (index >= 0 && (index + 1) < args.size()) {
- bibleKey = args.at(index + 1);
- }
+ if (CBTConfig::get(CBTConfig::crashedLastTime)) {
+ return;
+ }
+
+ if (!bibleKey.isNull()) {
CSwordModuleInfo* bible = CBTConfig::get(CBTConfig::standardBible);
if (bibleKey == "random") {
CSwordVerseKey vk(0);
@@ -336,10 +356,16 @@ void BibleTime::processCommandline() {
int newIndex = rand() % maxIndex;
vk.setPosition(sword::TOP);
vk.Index(newIndex);
- bibleKey = vk.key();
+ createReadDisplayWindow(bible, vk.key());
+ } else {
+ createReadDisplayWindow(bible, bibleKey);
}
- createReadDisplayWindow(bible, bibleKey);
- m_mdi->myTileVertical();//we are sure only one window is open, which should be displayed fullscreen in the working area
+
+ /*
+ We are sure only one window is open - it should be displayed
+ fullscreen in the working area:
+ */
+ m_mdi->myTileVertical();
}
}
@@ -348,9 +374,3 @@ bool BibleTime::event(QEvent* event) {
Search::CSearchDialog::closeDialog();
return QMainWindow::event(event);
}
-
-QAction* BibleTime::getAction(const QString& actionName)
-{
- return m_actionCollection->action(actionName);
-}
-
diff --git a/src/bibletime.h b/src/bibletime.h
index 89d0473..f35be23 100644
--- a/src/bibletime.h
+++ b/src/bibletime.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,9 +14,13 @@
#include <QList>
#include "frontend/displaywindow/cdisplaywindow.h"
+#include "frontend/displaywindow/cwritewindow.h"
#include "frontend/profile/cprofile.h"
#include "frontend/profile/cprofilemgr.h"
#include <QSignalMapper>
+#ifdef BT_DEBUG
+#include <QMutex>
+#endif
namespace InfoDisplay {
@@ -24,11 +28,13 @@ class CInfoDisplay;
}
class BtActionClass;
class BtBookshelfDockWidget;
+class BtOpenWorkAction;
class CBookmarkIndex;
class CDisplayWindow;
class CMDIArea;
class CSwordModuleInfo;
class QAction;
+class QLabel;
class QMenu;
class QToolBar;
class QSplitter;
@@ -45,7 +51,7 @@ class QSignalMapper;
* and SWKey (CSwordLDKey).
* </p>
* <p>
- * The classes used to handle all module based stuff are derived from CModuleInfo.
+ * The classes used to handle all module based stuff are derived from CSwordModuleInfo.
* The module classes are: CSwordModuleInfo (for Sword modules),
* CSwordBibleModuleInfo (for bibles), CSwordCommentaryModuleInfo (for commentaries) and
* CSwordLexiconModuleInfo (for lexicons).
@@ -67,44 +73,43 @@ class QSignalMapper;
* @page frontend The structure of the frontend
*
* <p>
- * The frontend contains the classes which interact with the user. For example the main index,
- * the display windows, the searchdialog or the other parts.
+ * The frontend contains the classes which interact with the user. For example the
+ * display windows, the searchdialog or the other parts.
+ * </p><p>
+ * The display windows which provide functionality are CBibleReadWindow for
+ * Bibles, CBookReadWindow for books, CCommentaryReadWindow for commentaries and CLexiconReadWindow for
+ * lexicon and dictionaries. CHTMLWriteWindow and CPlainWriteWindows are used for editing the Personal Commentary.
* </p><p>
- * The main index is implemented in the class CGroupManager, the items of the
- * main index are implemented in the class CGroupManagerItem.
- * Each CGroupManagerItem has a type() function which returns the type of
- * the object (Module, Bookmark or Group).<br/>
- * The display windows are all derived from the base class CPresenter.
- * The display windows which handle Sword modules are all derived from the
- * CSwordPresenter class.
- * The display windows which provide functionality are CBiblePresenter for
- * Bibles, CCommentaryPresenter for commentaries and CLexiconPresenter for
- * lexicon and dictionaries.
- * CSwordPresenter provides the essential base functions which are
- * reimplemented in the derived classes (for example CSwordPresenter::lookup).<br/>
+ *
+ * The class CDisplayWindow is the class that various views with in the windows are derived.
* </p><p>
+ *
* Another important part of the frontend are the keychoosers.
* They provide an interface to choose a key of a module.
* The interface for different module types is different.
* The base class is CKeyChooser which is the factory for the derived classes.
* Use the function CKeyChooser::createInstance to get the correct
* keychooser implementation for the desired module.<br/>
+ * </p><p>
+ * Some major toolbar widgets are CKeyChooser and BtDisplaySettingsButton.
* </p>
*/
/** @mainpage BibleTime - sourcecode documentation
* BibleTime main page.
- * <p>This is the sourcecode documentation of BibleTime, a Bible study tool for KDE/Linux.
- * BibleTime is devided in two major parts, the backend and the frontend.
+ * <p>This is the sourcecode documentation of BibleTime, a Bible study tool.
+ * <p>
+ * The main class of BibleTime is called @ref BibleTime, which is the main window
+ * and initializes all important parts at startup.
+ * </p><p>
+ * BibleTime is divided in two major parts, the backend and the frontend.
+ * The text display windows belong to the @ref frontend.
* The backend is mainly a wrapper around Sword's classes to use Qt functionality
* to allow easy access to it's functionality and to have it in a (more or less :)
* object oriented structure.</p><br/>
* <p>
- * -Introduction to the backend: @ref backend<br/>
* -Introduction to the frontend: @ref frontend.<br/>
- * The main class of BibleTime is called @ref BibleTime, which is the main window
- * and initializes all important parts at startup. The text display windows
- * belong to the @ref frontend.
+ * -Introduction to the backend: @ref backend<br/>
* </p>
*/
@@ -122,16 +127,15 @@ class BibleTime : public QMainWindow {
friend class CDisplayWindow;
friend class BibleTimeDBusAdaptor;
Q_OBJECT
+
public:
- /**
- * construtor of BibleTime
- */
- BibleTime();
- /**
- * destructor of BibleTime
- */
+
+ BibleTime(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+
~BibleTime();
+ static inline BibleTime *instance() { return m_instance; }
+
/**
* Reads the settings from the configfile and sets the right properties.
*/
@@ -157,9 +161,51 @@ class BibleTime : public QMainWindow {
*/
void saveConfigSettings();
/**
- * Get QAction from actionCollection
+ * Get pointer to Navigation toolbar
+ */
+ inline QToolBar *navToolBar() const {
+ return m_navToolBar;
+ }
+ /**
+ * Get pointer to Works toolbar
+ */
+ inline BtModuleChooserBar *worksToolBar() const {
+ return m_worksToolBar;
+ }
+ /**
+ * Get pointer to Tools toolbar
*/
- QAction* getAction(const QString& actionName);
+ inline QToolBar *toolsToolBar() const {
+ return m_toolsToolBar;
+ }
+ /**
+ * Get pointer to Format toolbar
+ */
+ inline QToolBar *formatToolBar() const {
+ return m_formatToolBar;
+ }
+
+ /**
+ \returns a pointer to the info display.
+ */
+ inline InfoDisplay::CInfoDisplay *infoDisplay() const {
+ return m_infoDisplay;
+ }
+
+ /**
+ * Clears the actions of the MDI related toolbars
+ */
+ void clearMdiToolBars();
+
+ /**
+ Displays a dialog which asks the user an unlock key for the given module and tries
+ to unlock the module. If an invalid unlock key is given, a warning message is
+ issued and the user is again asked for the key.
+ \param[in] module The module to unlock.
+ \param[in] parent The parent widget for the unlock dialogs.
+ \returns whether the module was successfully unlocked.
+ */
+ static bool moduleUnlock(CSwordModuleInfo *module, QWidget *parent = 0);
public slots:
/**
@@ -178,10 +224,20 @@ class BibleTime : public QMainWindow {
* Opens the bible study howto.
*/
void openOnlineHelp_Howto();
+
/**
- * Processes the commandline options given to BibleTime.
+ * Open the Tip Dialog
*/
- void processCommandline();
+ void slotOpenTipDialog();
+
+ /**
+ Processes the command-line options given to BibleTime.
+ \param[in] ignoreSession Specifies whether --ignore-session was used.
+ \param[in] bibleKey If --open-default-bible was used, the bible key
+ specified, or null otherwise.
+ */
+ void processCommandline(bool ignoreSession, const QString &bibleKey);
+
/**
* Creates QAction's that have keyboard shortcuts
*/
@@ -193,6 +249,10 @@ class BibleTime : public QMainWindow {
*/
bool event(QEvent* event);
/**
+ * Create the main window menu and toolbar
+ */
+ void createMenuAndToolBar();
+ /**
* Initializes the sword.conf in the $HOME\Sword directory
*/
void initSwordConfigFile();
@@ -217,6 +277,18 @@ class BibleTime : public QMainWindow {
*/
void initActions();
/**
+ Initializes the toolbars.
+ */
+ void initToolbars();
+ /**
+ Retranslates the UI.
+ */
+ void retranslateUi();
+ /**
+ Retranslates the UI actions.
+ */
+ static void retranslateUiActions(BtActionCollection* ac);
+ /**
* Initializes one action object
*/
QAction* initAction(QAction* action, QString text, QString icon, QKeySequence accel,
@@ -229,10 +301,11 @@ class BibleTime : public QMainWindow {
* Refresh main window accelerators
*/
void refreshBibleTimeAccel();
+
/**
- * Called before a window is closed
+ * Reimplemented from QWidget.
*/
- bool queryClose();
+ void closeEvent(QCloseEvent *event);
protected slots:
/**
@@ -240,11 +313,11 @@ class BibleTime : public QMainWindow {
*/
CDisplayWindow* createReadDisplayWindow(QList<CSwordModuleInfo*> modules, const QString& key);
CDisplayWindow* createReadDisplayWindow(CSwordModuleInfo* module, const QString& key = QString::null);
- CDisplayWindow* createWriteDisplayWindow(CSwordModuleInfo* module, const QString& key, const CDisplayWindow::WriteWindowType& type);
+ CDisplayWindow* createWriteDisplayWindow(CSwordModuleInfo* module, const QString& key, const CWriteWindow::WriteWindowType& type);
CDisplayWindow* moduleEditPlain(CSwordModuleInfo *module);
CDisplayWindow* moduleEditHtml(CSwordModuleInfo *module);
void searchInModule(CSwordModuleInfo *module);
- void moduleUnlock(CSwordModuleInfo *module);
+ void slotModuleUnlock(CSwordModuleInfo *module);
void moduleAbout(CSwordModuleInfo *module);
void quit();
@@ -257,19 +330,23 @@ class BibleTime : public QMainWindow {
*/
void slotOpenWindowsMenuAboutToShow();
/**
- * This slot is connected with the windowAutoTile_action object
+ * This slot is connected with the windowAutoTileVerticalAction object
*/
void slotAutoTileVertical();
/**
- * This slot is connected with the windowAutoTile_action object
+ * This slot is connected with the windowAutoTileHorizontalAction object
*/
void slotAutoTileHorizontal();
/**
- * This slot is connected with the windowAutoCascade_action object
+ * This slot is connected with the windowAutoTileAction object
*/
void slotAutoTile();
/**
- * This slot is connected with the windowAutoTile_action object
+ * This slot is connected with the windowAutoTabbedAction object
+ */
+ void slotAutoTabbed();
+ /**
+ * This slot is connected with the windowAutoCascadeAction object
*/
void slotAutoCascade();
void slotUpdateWindowArrangementActions( QAction* );
@@ -282,20 +359,22 @@ class BibleTime : public QMainWindow {
void slotManualArrangementMode();
/**
- * Shows/hides the toolbar
+ * Shows/hides the main toolbar
*/
- void slotToggleToolbar();
-
+ void slotToggleMainToolbar();
+ void slotToggleToolsToolbar();
+ void slotToggleNavigatorToolbar();
+ void slotToggleWorksToolbar();
+ void slotToggleFormatToolbar();
+
+ void slotToggleToolBarsInEachWindow();
+
/**
* Shows/hides the text window text area headers and sets
* configuration that newly opened windows don't user headers.
*/
void slotToggleTextWindowHeader();
-
- void slotToggleTextWindowToolButtons();
- void slotToggleTextWindowNavigator();
- void slotToggleTextWindowModuleChooser();
-
+
/**
* Used to set the active menu
*/
@@ -346,10 +425,7 @@ class BibleTime : public QMainWindow {
* Slot to refresh the save profile and load profile menus.
*/
void refreshProfileMenus();
- /**
- * Called before quit.
- */
- void slot_aboutToQuit();
+
/**
* Open the About Dialog
*/
@@ -360,8 +436,11 @@ class BibleTime : public QMainWindow {
void toggledTextWindowNavigator(bool newState);
void toggledTextWindowToolButtons(bool newState);
void toggledTextWindowModuleChooser(bool newState);
+ void toggledTextWindowFormatToolbar(bool newState);
private:
+ static BibleTime *m_instance;
+
// True if window was maximized before last toggle to full screen.
bool m_WindowWasMaximizedBeforeFullScreen;
@@ -373,29 +452,71 @@ class BibleTime : public QMainWindow {
InfoDisplay::CInfoDisplay* m_infoDisplay;
QToolBar* m_mainToolBar;
- // VIEW menu actions
- QAction* m_viewToolbar_action;
- QMenu* m_windowMenu;
- QMenu* m_openWindowsMenu;
- /** WINDOW menu actions */
- QAction* m_windowCascade_action;
- QAction* m_windowTile_action;
- QAction* m_windowTileHorizontal_action;
- QAction* m_windowTileVertical_action;
- QAction* m_windowManualMode_action;
- QAction* m_windowAutoCascade_action;
- QAction* m_windowAutoTile_action;
- QAction* m_windowAutoTileVertical_action;
- QAction* m_windowAutoTileHorizontal_action;
- QAction* m_windowClose_action;
- QAction* m_windowCloseAll_action;
+ QToolBar* m_navToolBar;
+ BtModuleChooserBar* m_worksToolBar;
+ QToolBar* m_toolsToolBar;
+ QToolBar* m_formatToolBar;
+
+ // File menu:
+ QMenu *m_fileMenu;
+ BtOpenWorkAction *m_openWorkAction;
+ QAction *m_quitAction;
+
+ // View menu:
+ QMenu *m_viewMenu;
+ QAction* m_viewToolbarAction;
+ QAction *m_showBookshelfAction;
+ QAction *m_showBookmarksAction;
+ QAction *m_showMagAction;
+ QMenu *m_toolBarsMenu;
+ QAction *m_showTextAreaHeadersAction;
+ QAction *m_showTextWindowNavigationAction;
+ QAction *m_showTextWindowModuleChooserAction;
+ QAction *m_showTextWindowToolButtonsAction;
+ QAction *m_showFormatToolbarAction;
+ QAction *m_toolbarsInEachWindow;
+
+ // Search menu:
+ QMenu *m_searchMenu;
+ QAction *m_searchOpenWorksAction;
+ QAction *m_searchStandardBibleAction;
+
+ // Window menu:
+ QMenu *m_windowMenu;
+ QMenu *m_openWindowsMenu;
+ QAction *m_windowCascadeAction;
+ QAction *m_windowTileAction;
+ QAction *m_windowTileHorizontalAction;
+ QAction *m_windowTileVerticalAction;
+ QAction *m_windowManualModeAction;
+ QMenu *m_windowArrangementMenu;
+ QAction *m_windowAutoCascadeAction;
+ QAction *m_windowAutoTileAction;
+ QAction *m_windowAutoTabbedAction;
+ QAction *m_windowAutoTileVerticalAction;
+ QAction *m_windowAutoTileHorizontalAction;
+ QAction *m_windowCloseAction;
+ QAction *m_windowCloseAllAction;
+
+ // Settings menu:
+ QMenu *m_settingsMenu;
+ QAction *m_setPreferencesAction;
+ QAction *m_bookshelfManagerAction;
+
+ // Help menu:
+ QMenu *m_helpMenu;
+ QAction *m_openHandbookAction;
+ QAction *m_bibleStudyHowtoAction;
+ QAction *m_aboutBibleTimeAction;
+ QAction *m_tipOfTheDayAction;
+
BtActionCollection* m_actionCollection;
QMenu* m_windowSaveProfileMenu;
- QAction* m_windowSaveToNewProfile_action;
+ QAction* m_windowSaveToNewProfileAction;
QMenu* m_windowLoadProfileMenu;
QMenu* m_windowDeleteProfileMenu;
- QAction* m_windowFullscreen_action;
+ QAction* m_windowFullscreenAction;
/**
* Signal mapper to map windows to menu items.
@@ -425,6 +546,20 @@ class BibleTime : public QMainWindow {
// Helper function
void syncAllModulesByType(const CSwordModuleInfo::ModuleType type, const QString& key);
+
+ private:
+ void showOrHideToolBars();
+#ifdef BT_DEBUG
+ void deleteDebugWindow();
+ private slots:
+ void slotDebugWindowClosing();
+ void slotDebugTimeout();
+ void slotShowDebugWindow(bool);
+ private:
+ QAction *m_debugWidgetAction;
+ static QLabel *m_debugWindow;
+ static QMutex m_debugWindowLock;
+#endif
};
#endif
diff --git a/src/bibletime_dbus.cpp b/src/bibletime_dbus.cpp
index 6adf71c..e3013db 100644
--- a/src/bibletime_dbus.cpp
+++ b/src/bibletime_dbus.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -60,7 +60,7 @@ void BibleTime::syncAllVerseBasedModules(const QString& key) {
void BibleTime::openWindow(const QString& moduleName, const QString& key) {
qDebug() << "DBUS: open window for module" << moduleName.toLatin1() << "and key" << key.toLatin1();
- CSwordModuleInfo* module = CPointers::backend()->findModuleByName(moduleName);
+ CSwordModuleInfo* module = CSwordBackend::instance()->findModuleByName(moduleName);
if (module) {
createReadDisplayWindow(module, key);
}
@@ -77,16 +77,17 @@ void BibleTime::openDefaultBible(const QString& key) {
QStringList BibleTime::searchInModule(const QString& moduleName, const QString& searchText) {
qDebug() << "DBUS: searchInModule" << moduleName.toLatin1();
QStringList ret;
- CSwordModuleInfo* mod = CPointers::backend()->findModuleByName(moduleName);
+ CSwordModuleInfo* mod = CSwordBackend::instance()->findModuleByName(moduleName);
if (mod) {
+ sword::ListKey result;
+
//mod->search(searchText, CSwordModuleSearch::multipleWords, sword::ListKey());
sword::ListKey scope;
- mod->searchIndexed( searchText, scope );
+ mod->searchIndexed(searchText, scope, result);
- sword::ListKey result = mod->searchResult();
const QString lead = QString("[%1] ").arg(moduleName);
- ;
+
for ( int i = 0; i < result.Count(); ++i ) {
sword::SWKey* key = result.getElement(i);
Q_ASSERT(key);
@@ -111,9 +112,9 @@ QStringList BibleTime::searchInOpenModules(const QString& searchText) {
QStringList ret;
foreach (QMdiSubWindow* subWindow, m_mdi->subWindowList()) {
if (CDisplayWindow* w = dynamic_cast<CDisplayWindow*>(subWindow->widget())) {
- QList<CSwordModuleInfo*> windowModules = w->modules();
- QList<CSwordModuleInfo*>::iterator end_it = windowModules.end();
- for (QList<CSwordModuleInfo*>::iterator it(windowModules.begin()); it != end_it; ++it) {
+ QList<const CSwordModuleInfo*> windowModules = w->modules();
+ QList<const CSwordModuleInfo*>::iterator end_it = windowModules.end();
+ for (QList<const CSwordModuleInfo*>::iterator it(windowModules.begin()); it != end_it; ++it) {
ret += searchInModule((*it)->name(), searchText);
}
}
@@ -189,7 +190,7 @@ QStringList BibleTime::getModulesOfType(const QString& type) {
modType = CSwordModuleInfo::GenericBook;
}
- QList<CSwordModuleInfo*> modList = CPointers::backend()->moduleList();
+ QList<CSwordModuleInfo*> modList = CSwordBackend::instance()->moduleList();
for (QList<CSwordModuleInfo*>::iterator it( modList.begin() ); it != modList.end(); ++it) {
if ((*it)->type() == modType) {
ret.append( (*it)->name() );
diff --git a/src/bibletime_dbus_adaptor.cpp b/src/bibletime_dbus_adaptor.cpp
index 30619ec..bf6ba79 100644
--- a/src/bibletime_dbus_adaptor.cpp
+++ b/src/bibletime_dbus_adaptor.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/bibletime_dbus_adaptor.h b/src/bibletime_dbus_adaptor.h
index ea4ec69..0f9f301 100644
--- a/src/bibletime_dbus_adaptor.h
+++ b/src/bibletime_dbus_adaptor.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -63,19 +63,19 @@ class BibleTimeDBusAdaptor : QDBusAbstractAdaptor {
void closeAllModuleWindows();
/** Returns the reference used in the current window.
* The format of the returned reference is
- * [Module] [Type] OSIS_Reference,
+ * [Module] [Type] OSIS_Reference,
* wtih type one of BIBLE/COMMENTARY/BOOK/LEXICON/UNSUPPORTED
* If the type is BIBLE or COMMENTARY the reference is an OSIS ref
* in the other cases it's the key name, for books /Chapter/Subsection
* for Lexicons just the plain key, e.g. "ADAM".
* e.g.
- * [KJV] [BIBLE] Gen.1.1
- * [MHC] [COMMENTARY] Gen.1.1
- * [ISBE] [LEXICON] REDEMPTION
+ * [KJV] [BIBLE] Gen.1.1
+ * [MHC] [COMMENTARY] Gen.1.1
+ * [ISBE] [LEXICON] REDEMPTION
* @return The reference displayed in the currently active module window. Empty if none is active.
*/
QString getCurrentReference();
- /** Seach the searchText in the specified module.
+ /** Search the searchText in the specified module.
* @param moduleName The module to search in
* @param searchText Search for this in the modules
* @return The search result. It's in the format [modulename] osis_ref_of_the_found_key. For example "[KJV] Gen.1.1".
diff --git a/src/bibletime_init.cpp b/src/bibletime_init.cpp
index cbff79f..4ac6350 100644
--- a/src/bibletime_init.cpp
+++ b/src/bibletime_init.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,53 +18,65 @@
#include <QPointer>
#include <QSplitter>
#include <QToolBar>
+#include <QToolButton>
#include <QVBoxLayout>
#include "backend/config/cbtconfig.h"
#include "backend/managers/btstringmgr.h"
#include "backend/managers/clanguagemgr.h"
#include "backend/managers/cswordbackend.h"
#include "frontend/btbookshelfdockwidget.h"
+#include "frontend/btopenworkaction.h"
#include "frontend/cinfodisplay.h"
#include "frontend/cmdiarea.h"
#include "frontend/cprinter.h"
#include "frontend/displaywindow/btactioncollection.h"
-#include "frontend/mainindex/bookmarks/cbookmarkindex.h"
+#include "frontend/displaywindow/btmodulechooserbar.h"
+#include "frontend/bookmarks/cbookmarkindex.h"
#include "frontend/profile/cprofile.h"
#include "frontend/profile/cprofilemgr.h"
-#include "util/cpointers.h"
#include "util/cresmgr.h"
#include "util/directory.h"
// Sword includes:
#include <swlog.h>
+#ifdef BT_DEBUG
+#include <QLabel>
+#include <QMetaObject>
+#include <QMutexLocker>
+#include <QTimer>
+#endif
+
using namespace InfoDisplay;
using namespace Profile;
/**Initializes the view of this widget*/
void BibleTime::initView() {
+
+ // Create menu and toolbar before the mdi area
+ createMenuAndToolBar();
+
m_mdi = new CMDIArea(this);
setCentralWidget(m_mdi);
m_bookshelfDock = new BtBookshelfDockWidget(this);
addDockWidget(Qt::LeftDockWidgetArea, m_bookshelfDock);
- m_bookmarksDock = new QDockWidget(tr("Bookmarks"), this);
+ m_bookmarksDock = new QDockWidget(this);
m_bookmarksDock->setObjectName("BookmarksDock");
m_bookmarksPage = new CBookmarkIndex(0);
m_bookmarksDock->setWidget(m_bookmarksPage);
addDockWidget(Qt::LeftDockWidgetArea, m_bookmarksDock);
tabifyDockWidget(m_bookmarksDock, m_bookshelfDock);
- m_magDock = new QDockWidget(tr("Mag"), this);
+ m_magDock = new QDockWidget(this);
m_magDock->setObjectName("MagDock");
m_infoDisplay = new CInfoDisplay(this);
m_infoDisplay->resize(150, 150);
m_magDock->setWidget(m_infoDisplay);
addDockWidget(Qt::LeftDockWidgetArea, m_magDock);
- CPointers::setInfoDisplay(m_infoDisplay);
m_mdi->setMinimumSize(100, 100);
m_mdi->setFocusPolicy(Qt::ClickFocus);
}
@@ -158,6 +170,13 @@ void BibleTime::insertKeyboardActions( BtActionCollection* const a ) {
a->addAction("autoTile", action);
action = new QAction(a);
+ action->setText(tr("Ta&bbed"));
+ action->setIcon(DU::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTabbed::icon));
+ action->setShortcut(QKeySequence(CResMgr::mainMenu::window::arrangementMode::autoTabbed::accel));
+ action->setToolTip(tr("Automatically tab the open windows"));
+ a->addAction("autoTabbed", action);
+
+ action = new QAction(a);
action->setText(tr("Auto-&cascade"));
action->setIcon(DU::getIcon(CResMgr::mainMenu::window::arrangementMode::autoCascade::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::window::arrangementMode::autoCascade::accel));
@@ -237,241 +256,431 @@ void BibleTime::insertKeyboardActions( BtActionCollection* const a ) {
action->setText(tr("&About BibleTime"));
action->setToolTip(tr("Information about the BibleTime program"));
a->addAction("aboutBibleTime", action);
-}
-/** Initializes the action objects of the GUI */
-void BibleTime::initActions() {
- m_actionCollection = new BtActionCollection(this);
+ action = new QAction(a);
+ action->setText(tr("&Tip of the day..."));
+ action->setIcon(DU::getIcon(CResMgr::mainMenu::help::tipOfTheDay::icon));
+ action->setShortcut(QKeySequence(CResMgr::mainMenu::help::tipOfTheDay::accel));
+ action->setToolTip(tr("Show tips about BibleTime"));
+ a->addAction("tipOfTheDay", action);
- /**
- * Create the window to signal mapper and connect it up.
- */
- m_windowMapper = new QSignalMapper(this);
- connect(m_windowMapper, SIGNAL(mapped(QWidget*)),
- this, SLOT(slotSetActiveSubWindow(QWidget*)));
+ action = new QAction(a);
+ a->addAction("showToolbarsInTextWindows", action);
- insertKeyboardActions(m_actionCollection);
+ action = new QAction(a);
+ a->addAction("showNavigation", action);
- // Main menus
- QMenu* fileMenu = menuBar()->addMenu(tr("&File"));
- QMenu* viewMenu = menuBar()->addMenu(tr("&View"));
- QMenu* searchMenu = menuBar()->addMenu(tr("&Search"));
- m_windowMenu = menuBar()->addMenu(tr("&Window"));
- QMenu* settingsMenu = menuBar()->addMenu(tr("Se&ttings"));
- QMenu* helpMenu = menuBar()->addMenu(tr("&Help"));
-
- // Name of the main toolbar
- m_mainToolBar = addToolBar(tr("Main Toolbar"));
- m_mainToolBar->setObjectName("MainToolBar");
- m_mainToolBar->setFloatable(false);
- m_mainToolBar->setMovable(false);
-
- QAction* tmp = m_actionCollection->action("quit");
- fileMenu->addAction(tmp);
- connect(tmp, SIGNAL(triggered()), this, SLOT(quit()) );
-
-
- // ********** View menu *********************
-
- m_windowFullscreen_action = m_actionCollection->action("toggleFullscreen");
- m_windowFullscreen_action->setCheckable(true);
- viewMenu->addAction(m_windowFullscreen_action);
- m_mainToolBar->addAction(m_windowFullscreen_action);
- connect(m_windowFullscreen_action, SIGNAL(triggered()), this, SLOT(toggleFullscreen()) );
-
- m_viewToolbar_action = m_actionCollection->action("showToolbar");
- m_viewToolbar_action->setCheckable(true);
- m_viewToolbar_action->setChecked(true);
- viewMenu->addAction(m_viewToolbar_action);
- connect(m_viewToolbar_action, SIGNAL(triggered()), this, SLOT(slotToggleToolbar()) );
-
- QAction* action = m_bookshelfDock->toggleViewAction();
- action->setText(tr("Show Bookshelf"));
- viewMenu->addAction(action);
-
- action = m_bookmarksDock->toggleViewAction();
- action->setText(tr("Show Bookmarks"));
- viewMenu->addAction(action);
-
- action = m_magDock->toggleViewAction();
- action->setText(tr("Show Mag"));
- viewMenu->addAction(action);
-
- viewMenu->addSeparator();
- QMenu* textWindowsMenu = new QMenu(tr("Text windows"));
- viewMenu->addMenu(textWindowsMenu);
-
- action = new QAction(tr("Show text area headers"), this);
- action->setCheckable(true);
- action->setChecked(CBTConfig::get(CBTConfig::showTextWindowHeaders));
- connect(action, SIGNAL(toggled(bool)), SLOT(slotToggleTextWindowHeader()));
- textWindowsMenu->addAction(action);
-
- action = new QAction(tr("Show navigation"), this);
- action->setCheckable(true);
- action->setChecked(CBTConfig::get(CBTConfig::showTextWindowNavigator));
- connect(action, SIGNAL(toggled(bool)), SLOT(slotToggleTextWindowNavigator()));
- textWindowsMenu->addAction(action);
-
- action = new QAction(tr("Show work chooser buttons"), this);
- action->setCheckable(true);
- action->setChecked(CBTConfig::get(CBTConfig::showTextWindowModuleSelectorButtons));
- connect(action, SIGNAL(toggled(bool)), SLOT(slotToggleTextWindowModuleChooser()));
- textWindowsMenu->addAction(action);
-
- action = new QAction(tr("Show tools"), this);
- action->setCheckable(true);
- action->setChecked(CBTConfig::get(CBTConfig::showTextWindowToolButtons));
- connect(action, SIGNAL(toggled(bool)), SLOT(slotToggleTextWindowToolButtons()));
- textWindowsMenu->addAction(action);
-
- // *************************************
- m_mainToolBar->addSeparator();
+ action = new QAction(a);
+ a->addAction("showWorks", action);
- tmp = m_actionCollection->action("searchOpenWorks");
- searchMenu->addAction(tmp);
- m_mainToolBar->addAction(tmp);
- m_mainToolBar->addSeparator();
- connect(tmp, SIGNAL(triggered()), this, SLOT(slotSearchModules()) );
+ action = new QAction(a);
+ a->addAction("showTools", action);
- tmp = m_actionCollection->action("searchStdBible");
- searchMenu->addAction(tmp);
- connect(tmp, SIGNAL(triggered()), this, SLOT(slotSearchDefaultBible()) );
+ action = new QAction(a);
+ a->addAction("showFormat", action);
- /**
- * Window Menu
- */
- m_openWindowsMenu = new QMenu(tr("O&pen Windows"), m_windowMenu);
- m_windowMenu->addMenu(m_openWindowsMenu);
+ action = new QAction(a);
+ a->addAction("showParallelTextHeaders", action);
- m_windowClose_action = m_actionCollection->action("closeWindow");
- m_windowMenu->addAction(m_windowClose_action);
- connect(m_windowClose_action, SIGNAL(triggered()), m_mdi, SLOT(closeActiveSubWindow()));
+ action = new QAction(a);
+ a->addAction("showBookshelf", action);
- m_windowCloseAll_action = m_actionCollection->action("closeAllWindows");
- m_windowMenu->addAction(m_windowCloseAll_action);
- connect(m_windowCloseAll_action, SIGNAL(triggered()), m_mdi, SLOT(closeAllSubWindows()));
+ action = new QAction(a);
+ a->addAction("showBookmarks", action);
- m_windowMenu->addSeparator();
+ action = new QAction(a);
+ a->addAction("showMag", action);
- // *** Window arrangement actions ***
+ retranslateUiActions(a);
+}
- m_windowCascade_action = m_actionCollection->action("cascade");
- m_windowMenu->addAction(m_windowCascade_action);
- connect(m_windowCascade_action, SIGNAL(triggered()), this, SLOT(slotCascade()) );
+static QToolBar* createToolBar(const QString& name, QWidget* parent, bool visible) {
+ QToolBar* bar = new QToolBar(parent);
+ bar->setObjectName(name);
+ bar->setFloatable(false);
+ bar->setMovable(true);
+ bar->setVisible(visible);
+ return bar;
+}
- m_windowTile_action = m_actionCollection->action("tile");
- m_windowMenu->addAction(m_windowTile_action);
- connect(m_windowTile_action, SIGNAL(triggered()), this, SLOT(slotTile()) );
+void BibleTime::clearMdiToolBars() {
+ // Clear main window toolbars
+ m_navToolBar->clear();
+ m_worksToolBar->clear();
+ m_toolsToolBar->clear();
+ m_formatToolBar->clear();
+}
- m_windowTileVertical_action = m_actionCollection->action("tileVertically");
- m_windowMenu->addAction(m_windowTileVertical_action);
- connect(m_windowTileVertical_action, SIGNAL(triggered()), this, SLOT(slotTileVertical()) );
+void BibleTime::createMenuAndToolBar()
+{
+ // Create menubar
+ menuBar();
- m_windowTileHorizontal_action = m_actionCollection->action("tileHorizontally");
- m_windowMenu->addAction(m_windowTileHorizontal_action);
- connect(m_windowTileHorizontal_action, SIGNAL(triggered()), this, SLOT(slotTileHorizontal()) );
+ m_mainToolBar = createToolBar("MainToolBar", this, true);
+ addToolBar(m_mainToolBar);
- QMenu* arrangementMenu = new QMenu(tr("&Arrangement mode"));
- m_windowMenu->addMenu(arrangementMenu);
+ // Set visibility of main window toolbars based on config
+ bool visible = ! CBTConfig::get(CBTConfig::showToolbarsInEachWindow);
- m_windowManualMode_action = m_actionCollection->action("manualArrangement");
- m_windowManualMode_action->setCheckable(true);
- arrangementMenu->addAction(m_windowManualMode_action);
- connect(m_windowManualMode_action, SIGNAL(triggered()), this, SLOT(slotManualArrangementMode()) );
+ m_navToolBar = createToolBar("NavToolBar", this, visible);
+ addToolBar(m_navToolBar);
- //: Vertical tiling means that windows are vertical, placed side by side
- m_windowAutoTileVertical_action = m_actionCollection->action("autoVertical");
- m_windowAutoTileVertical_action->setCheckable(true);
- arrangementMenu->addAction(m_windowAutoTileVertical_action);
- connect(m_windowAutoTileVertical_action, SIGNAL(triggered()), this, SLOT(slotAutoTileVertical()) );
+ m_worksToolBar = new BtModuleChooserBar(this);
+ m_worksToolBar->setObjectName("WorksToolBar");
+ m_worksToolBar->setVisible(visible);
+ addToolBar(m_worksToolBar);
- //: Horizontal tiling means that windows are horizontal, placed on top of each other
- m_windowAutoTileHorizontal_action = m_actionCollection->action("autoHorizontal");
- m_windowAutoTileHorizontal_action->setCheckable(true);
- arrangementMenu->addAction(m_windowAutoTileHorizontal_action);
- connect(m_windowAutoTileHorizontal_action, SIGNAL(triggered()), this, SLOT(slotAutoTileHorizontal()) );
+ m_toolsToolBar = createToolBar("ToolsToolBar", this, visible);
+ addToolBar(m_toolsToolBar);
- m_windowAutoTile_action = m_actionCollection->action("autoTile");
- m_windowAutoTile_action->setCheckable(true);
- arrangementMenu->addAction(m_windowAutoTile_action);
- connect(m_windowAutoTile_action, SIGNAL(triggered()), this, SLOT(slotAutoTile()) );
+ m_formatToolBar = createToolBar("FormatToolBar", this, visible);
+ addToolBar(m_formatToolBar);
+}
- m_windowAutoCascade_action = m_actionCollection->action("autoCascade");
- m_windowAutoCascade_action->setCheckable(true);
- arrangementMenu->addAction(m_windowAutoCascade_action);
- connect(m_windowAutoCascade_action, SIGNAL(triggered()), this, SLOT(slotAutoCascade()) );
+/** Initializes the action objects of the GUI */
+void BibleTime::initActions() {
+ m_actionCollection = new BtActionCollection(this);
+ insertKeyboardActions(m_actionCollection);
- m_windowMenu->addSeparator();
+ // Create the window to signal mapper and connect it up:
+ m_windowMapper = new QSignalMapper(this);
+ connect(m_windowMapper, SIGNAL(mapped(QWidget*)),
+ this, SLOT(slotSetActiveSubWindow(QWidget*)));
+
+ // File menu actions:
+ m_openWorkAction = new BtOpenWorkAction("GUI/MainWindow/OpenWorkAction/grouping", this);
+ connect(m_openWorkAction, SIGNAL(triggered(CSwordModuleInfo*)),
+ this, SLOT(createReadDisplayWindow(CSwordModuleInfo*)));
+
+ m_quitAction = m_actionCollection->action("quit");
+ connect(m_quitAction, SIGNAL(triggered()),
+ this, SLOT(quit()));
+
+
+ // View menu actions:
+ m_windowFullscreenAction = m_actionCollection->action("toggleFullscreen");
+ m_windowFullscreenAction->setCheckable(true);
+ connect(m_windowFullscreenAction, SIGNAL(triggered()),
+ this, SLOT(toggleFullscreen()));
+
+ m_viewToolbarAction = m_actionCollection->action("showToolbar");
+ m_viewToolbarAction->setCheckable(true);
+ m_viewToolbarAction->setChecked(true);
+ connect(m_viewToolbarAction, SIGNAL(triggered()),
+ this, SLOT(slotToggleMainToolbar()));
+
+ // Special case these actions, overwrite those already in collection
+ m_showBookshelfAction = m_bookshelfDock->toggleViewAction();
+ m_actionCollection->addAction("showBookshelf", m_showBookshelfAction);
+ m_showBookmarksAction = m_bookmarksDock->toggleViewAction();
+ m_actionCollection->addAction("showBookmarks", m_showBookmarksAction);
+ m_showMagAction = m_magDock->toggleViewAction();
+ m_actionCollection->addAction("showMag", m_showMagAction);
+
+ m_showTextAreaHeadersAction = m_actionCollection->action("showParallelTextHeaders");
+ m_showTextAreaHeadersAction->setCheckable(true);
+ m_showTextAreaHeadersAction->setChecked(CBTConfig::get(CBTConfig::showTextWindowHeaders));
+ connect(m_showTextAreaHeadersAction, SIGNAL(toggled(bool)),
+ this, SLOT(slotToggleTextWindowHeader()));
+
+ m_showTextWindowNavigationAction = m_actionCollection->action("showNavigation");
+ m_showTextWindowNavigationAction->setCheckable(true);
+ m_showTextWindowNavigationAction->setChecked(CBTConfig::get(CBTConfig::showTextWindowNavigator));
+ connect(m_showTextWindowNavigationAction, SIGNAL(toggled(bool)),
+ this, SLOT(slotToggleNavigatorToolbar()));
+
+ m_showTextWindowModuleChooserAction = m_actionCollection->action("showWorks");
+ m_showTextWindowModuleChooserAction->setCheckable(true);
+ m_showTextWindowModuleChooserAction->setChecked(CBTConfig::get(CBTConfig::showTextWindowModuleSelectorButtons));
+ connect(m_showTextWindowModuleChooserAction, SIGNAL(toggled(bool)),
+ this, SLOT(slotToggleWorksToolbar()));
+
+ m_showTextWindowToolButtonsAction = m_actionCollection->action("showTools");
+ m_showTextWindowToolButtonsAction->setCheckable(true);
+ m_showTextWindowToolButtonsAction->setChecked(CBTConfig::get(CBTConfig::showTextWindowToolButtons));
+ connect(m_showTextWindowToolButtonsAction, SIGNAL(toggled(bool)),
+ this, SLOT(slotToggleToolsToolbar()));
+
+ m_showFormatToolbarAction = m_actionCollection->action("showFormat");
+ m_showFormatToolbarAction->setCheckable(true);
+ m_showFormatToolbarAction->setChecked(CBTConfig::get(CBTConfig::showFormatToolbarButtons));
+ bool ok = connect(m_showFormatToolbarAction, SIGNAL(toggled(bool)),
+ this, SLOT(slotToggleFormatToolbar()));
+
+ m_toolbarsInEachWindow = m_actionCollection->action("showToolbarsInTextWindows");
+ m_toolbarsInEachWindow->setCheckable(true);
+ m_toolbarsInEachWindow->setChecked(CBTConfig::get(CBTConfig::showToolbarsInEachWindow));
+ ok = connect(m_toolbarsInEachWindow, SIGNAL(toggled(bool)),
+ this, SLOT(slotToggleToolBarsInEachWindow()));
+ Q_ASSERT(ok);
- m_windowSaveProfileMenu = new QMenu(tr("&Save session"));
- m_windowMenu->addMenu(m_windowSaveProfileMenu);
+ // Search menu actions:
+ m_searchOpenWorksAction = m_actionCollection->action("searchOpenWorks");
+ connect(m_searchOpenWorksAction, SIGNAL(triggered()),
+ this, SLOT(slotSearchModules()));
- m_windowSaveToNewProfile_action = m_actionCollection->action("saveNewSession");
- m_windowMenu->addAction(m_windowSaveToNewProfile_action);
- connect(m_windowSaveToNewProfile_action, SIGNAL(triggered()), this, SLOT(saveToNewProfile()) );
+ m_searchStandardBibleAction = m_actionCollection->action("searchStdBible");
+ connect(m_searchStandardBibleAction, SIGNAL(triggered()),
+ this, SLOT(slotSearchDefaultBible()));
- m_windowLoadProfileMenu = new QMenu(tr("&Load session"));
- m_windowMenu->addMenu(m_windowLoadProfileMenu);
+ // Window menu actions:
+ m_windowCloseAction = m_actionCollection->action("closeWindow");
+ connect(m_windowCloseAction, SIGNAL(triggered()),
+ m_mdi, SLOT(closeActiveSubWindow()));
- m_windowDeleteProfileMenu = new QMenu(tr("&Delete session"));
- m_windowMenu->addMenu(m_windowDeleteProfileMenu);
+ m_windowCloseAllAction = m_actionCollection->action("closeAllWindows");
+ connect(m_windowCloseAllAction, SIGNAL(triggered()),
+ m_mdi, SLOT(closeAllSubWindows()));
- QObject::connect(m_windowLoadProfileMenu, SIGNAL(triggered(QAction*)), SLOT(loadProfile(QAction*)));
- QObject::connect(m_windowSaveProfileMenu, SIGNAL(triggered(QAction*)), SLOT(saveProfile(QAction*)));
- QObject::connect(m_windowDeleteProfileMenu, SIGNAL(triggered(QAction*)), SLOT(deleteProfile(QAction*)));
+ m_windowCascadeAction = m_actionCollection->action("cascade");
+ connect(m_windowCascadeAction, SIGNAL(triggered()),
+ this, SLOT(slotCascade()));
- refreshProfileMenus();
+ m_windowTileAction = m_actionCollection->action("tile");
+ connect(m_windowTileAction, SIGNAL(triggered()),
+ this, SLOT(slotTile()));
+
+ m_windowTileVerticalAction = m_actionCollection->action("tileVertically");
+ connect(m_windowTileVerticalAction, SIGNAL(triggered()),
+ this, SLOT(slotTileVertical()));
+
+ m_windowTileHorizontalAction = m_actionCollection->action("tileHorizontally");
+ connect(m_windowTileHorizontalAction, SIGNAL(triggered()),
+ this, SLOT(slotTileHorizontal()));
- tmp = m_actionCollection->action("setPreferences");
- settingsMenu->addAction(tmp);
- connect(tmp, SIGNAL(triggered()), this, SLOT(slotSettingsOptions()) );
+ m_windowManualModeAction = m_actionCollection->action("manualArrangement");
+ m_windowManualModeAction->setCheckable(true);
+ connect(m_windowManualModeAction, SIGNAL(triggered()),
+ this, SLOT(slotManualArrangementMode()));
- settingsMenu->addSeparator();
+ m_windowAutoTabbedAction = m_actionCollection->action("autoTabbed");
+ m_windowAutoTabbedAction->setCheckable(true);
+ connect(m_windowAutoTabbedAction, SIGNAL(triggered()),
+ this, SLOT(slotAutoTabbed()));
- tmp = m_actionCollection->action("bookshelfManager");
- settingsMenu->addAction(tmp);
- connect(tmp, SIGNAL(triggered()), this, SLOT(slotSwordSetupDialog()) );
+ //: Vertical tiling means that windows are vertical, placed side by side
+ m_windowAutoTileVerticalAction = m_actionCollection->action("autoVertical");
+ m_windowAutoTileVerticalAction->setCheckable(true);
+ connect(m_windowAutoTileVerticalAction, SIGNAL(triggered()),
+ this, SLOT(slotAutoTileVertical()));
+
+ //: Horizontal tiling means that windows are horizontal, placed on top of each other
+ m_windowAutoTileHorizontalAction = m_actionCollection->action("autoHorizontal");
+ m_windowAutoTileHorizontalAction->setCheckable(true);
+ connect(m_windowAutoTileHorizontalAction, SIGNAL(triggered()),
+ this, SLOT(slotAutoTileHorizontal()));
+
+ m_windowAutoTileAction = m_actionCollection->action("autoTile");
+ m_windowAutoTileAction->setCheckable(true);
+ connect(m_windowAutoTileAction, SIGNAL(triggered()),
+ this, SLOT(slotAutoTile()));
+
+ m_windowAutoCascadeAction = m_actionCollection->action("autoCascade");
+ m_windowAutoCascadeAction->setCheckable(true);
+ connect(m_windowAutoCascadeAction, SIGNAL(triggered()),
+ this, SLOT(slotAutoCascade()));
+
+ m_windowSaveToNewProfileAction = m_actionCollection->action("saveNewSession");
+ connect(m_windowSaveToNewProfileAction, SIGNAL(triggered()),
+ this, SLOT(saveToNewProfile()));
+
+ m_setPreferencesAction = m_actionCollection->action("setPreferences");
+ connect(m_setPreferencesAction, SIGNAL(triggered()),
+ this, SLOT(slotSettingsOptions()));
+
+ m_bookshelfManagerAction = m_actionCollection->action("bookshelfManager");
+ connect(m_bookshelfManagerAction, SIGNAL(triggered()),
+ this, SLOT(slotSwordSetupDialog()));
+
+ m_openHandbookAction = m_actionCollection->action("openHandbook");
+ connect(m_openHandbookAction, SIGNAL(triggered()),
+ this, SLOT(openOnlineHelp_Handbook()));
+
+ m_bibleStudyHowtoAction = m_actionCollection->action("bibleStudyHowto");
+ connect(m_bibleStudyHowtoAction, SIGNAL(triggered()),
+ this, SLOT(openOnlineHelp_Howto()));
+
+ m_aboutBibleTimeAction = m_actionCollection->action("aboutBibleTime");
+ connect(m_aboutBibleTimeAction, SIGNAL(triggered()),
+ this, SLOT(slotOpenAboutDialog()) );
+
+ m_tipOfTheDayAction = m_actionCollection->action("tipOfTheDay");
+ connect(m_tipOfTheDayAction, SIGNAL(triggered()),
+ this, SLOT(slotOpenTipDialog()) );
+
+ #ifdef BT_DEBUG
+ m_debugWidgetAction = new QAction(this);
+ m_debugWidgetAction->setCheckable(true);
+ connect(m_debugWidgetAction, SIGNAL(triggered(bool)),
+ this, SLOT(slotShowDebugWindow(bool)));
+ #endif
+
+ retranslateUiActions(m_actionCollection);
+}
+
+void BibleTime::initMenubar() {
+ // File menu:
+ m_fileMenu = new QMenu(this);
+ m_fileMenu->addAction(m_openWorkAction);
+ m_fileMenu->addSeparator();
+ m_fileMenu->addAction(m_quitAction);
+ menuBar()->addMenu(m_fileMenu);
+
+ // View menu:
+ m_viewMenu = new QMenu(this);
+ m_viewMenu->addAction(m_windowFullscreenAction);
+ m_viewMenu->addAction(m_showBookshelfAction);
+ m_viewMenu->addAction(m_showBookmarksAction);
+ m_viewMenu->addAction(m_showMagAction);
+ m_viewMenu->addAction(m_showTextAreaHeadersAction);
+ m_viewMenu->addSeparator();
+ m_toolBarsMenu = new QMenu(this);
+ m_toolBarsMenu->addAction(m_viewToolbarAction);
+ m_toolBarsMenu->addAction(m_showTextWindowNavigationAction);
+ m_toolBarsMenu->addAction(m_showTextWindowModuleChooserAction);
+ m_toolBarsMenu->addAction(m_showTextWindowToolButtonsAction);
+ m_toolBarsMenu->addAction(m_showFormatToolbarAction);
+ m_toolBarsMenu->addSeparator();
+ m_toolBarsMenu->addAction(m_toolbarsInEachWindow);
+ m_viewMenu->addMenu(m_toolBarsMenu);
+ menuBar()->addMenu(m_viewMenu);
+
+ // Search menu:
+ m_searchMenu = new QMenu(this);
+ m_searchMenu->addAction(m_searchOpenWorksAction);
+ m_searchMenu->addAction(m_searchStandardBibleAction);
+ menuBar()->addMenu(m_searchMenu);
+
+ // Window menu:
+ m_windowMenu = new QMenu(this);
+ m_openWindowsMenu = new QMenu(this);
+ QObject::connect(m_openWindowsMenu, SIGNAL(aboutToShow()),
+ this, SLOT(slotOpenWindowsMenuAboutToShow()));
+ m_windowMenu->addMenu(m_openWindowsMenu);
+ m_windowMenu->addAction(m_windowCloseAction);
+ m_windowMenu->addAction(m_windowCloseAllAction);
+ m_windowMenu->addSeparator();
+ m_windowMenu->addAction(m_windowCascadeAction);
+ m_windowMenu->addAction(m_windowTileAction);
+ m_windowMenu->addAction(m_windowTileVerticalAction);
+ m_windowMenu->addAction(m_windowTileHorizontalAction);
+ m_windowArrangementMenu = new QMenu(this);
+ m_windowArrangementMenu->addAction(m_windowManualModeAction);
+ m_windowArrangementMenu->addAction(m_windowAutoTabbedAction);
+ m_windowArrangementMenu->addAction(m_windowAutoTileVerticalAction);
+ m_windowArrangementMenu->addAction(m_windowAutoTileHorizontalAction);
+ m_windowArrangementMenu->addAction(m_windowAutoTileAction);
+ m_windowArrangementMenu->addAction(m_windowAutoCascadeAction);
+ m_windowMenu->addMenu(m_windowArrangementMenu);
+ m_windowMenu->addSeparator();
+ m_windowSaveProfileMenu = new QMenu(this);
+ m_windowMenu->addMenu(m_windowSaveProfileMenu);
+ m_windowMenu->addAction(m_windowSaveToNewProfileAction);
+ m_windowLoadProfileMenu = new QMenu(this);
+ m_windowMenu->addMenu(m_windowLoadProfileMenu);
+ m_windowDeleteProfileMenu = new QMenu(this);
+ m_windowMenu->addMenu(m_windowDeleteProfileMenu);
+ connect(m_windowLoadProfileMenu, SIGNAL(triggered(QAction*)),
+ this, SLOT(loadProfile(QAction*)));
+ connect(m_windowSaveProfileMenu, SIGNAL(triggered(QAction*)),
+ this, SLOT(saveProfile(QAction*)));
+ connect(m_windowDeleteProfileMenu, SIGNAL(triggered(QAction*)),
+ this, SLOT(deleteProfile(QAction*)));
+ refreshProfileMenus();
+ menuBar()->addMenu(m_windowMenu);
+ connect(m_windowMenu, SIGNAL(aboutToShow()),
+ this, SLOT(slotWindowMenuAboutToShow()));
+
+ // Settings menu:
+ m_settingsMenu = new QMenu(this);
+ m_settingsMenu->addAction(m_setPreferencesAction);
+ m_settingsMenu->addSeparator();
+ m_settingsMenu->addAction(m_bookshelfManagerAction);
+ menuBar()->addMenu(m_settingsMenu);
+
+ // Help menu:
+ m_helpMenu = new QMenu(this);
+ m_helpMenu->addAction(m_openHandbookAction);
+ m_helpMenu->addAction(m_bibleStudyHowtoAction);
+ m_helpMenu->addAction(m_tipOfTheDayAction);
+ m_helpMenu->addSeparator();
+ m_helpMenu->addAction(m_aboutBibleTimeAction);
+ #ifdef BT_DEBUG
+ m_helpMenu->addSeparator();
+ m_helpMenu->addAction(m_debugWidgetAction);
+ #endif
+ menuBar()->addMenu(m_helpMenu);
+}
- tmp = m_actionCollection->action("openHandbook");
- helpMenu->addAction(tmp);
- m_mainToolBar->addAction(tmp);
- connect(tmp, SIGNAL(triggered()), this, SLOT(openOnlineHelp_Handbook()) );
+void BibleTime::initToolbars() {
+ QToolButton *openWorkButton = new QToolButton(this);
+ openWorkButton->setDefaultAction(m_openWorkAction);
+ openWorkButton->setPopupMode(QToolButton::InstantPopup);
+ m_mainToolBar->addWidget(openWorkButton);
- tmp = m_actionCollection->action("bibleStudyHowto");
- helpMenu->addAction(tmp);
- connect(tmp, SIGNAL(triggered()), this, SLOT(openOnlineHelp_Howto()) );
+ m_mainToolBar->addSeparator();
+ m_mainToolBar->addAction(m_windowFullscreenAction);
+ m_mainToolBar->addSeparator();
+ m_mainToolBar->addAction(m_searchOpenWorksAction);
+ m_mainToolBar->addSeparator();
+ m_mainToolBar->addAction(m_openHandbookAction);
+}
- helpMenu->addSeparator();
+void BibleTime::retranslateUi() {
+ m_bookmarksDock->setWindowTitle(tr("Bookmarks"));
+ m_magDock->setWindowTitle(tr("Mag"));
+ m_mainToolBar->setWindowTitle(tr("Main toolbar"));
+ m_navToolBar->setWindowTitle(tr("Navigation toolbar"));
+ m_worksToolBar->setWindowTitle(tr("Works toolbar"));
+ m_toolsToolBar->setWindowTitle(tr("Tools toolbar"));
+ m_formatToolBar->setWindowTitle(tr("Format toolbar"));
+
+ m_fileMenu->setTitle(tr("&File"));
+ m_viewMenu->setTitle(tr("&View"));
+ m_toolBarsMenu->setTitle(tr("Toolbars"));
+
+ m_searchMenu->setTitle(tr("&Search"));
+ m_windowMenu->setTitle(tr("&Window"));
+ m_openWindowsMenu->setTitle(tr("O&pen windows"));
+ m_windowArrangementMenu->setTitle(tr("&Arrangement mode"));
+ m_windowSaveProfileMenu->setTitle(tr("&Save session"));
+ m_windowLoadProfileMenu->setTitle(tr("&Load session"));
+ m_windowDeleteProfileMenu->setTitle(tr("&Delete session"));
+ m_settingsMenu->setTitle(tr("Se&ttings"));
+ m_helpMenu->setTitle(tr("&Help"));
+
+ #ifdef BT_DEBUG
+ m_debugWidgetAction->setText(tr("Show \"Whats this widget\" dialog"));
+ #endif
+
+ retranslateUiActions(m_actionCollection);
+}
- tmp = m_actionCollection->action("aboutBibleTime");
- helpMenu->addAction(tmp);
- connect(tmp, SIGNAL(triggered()), this, SLOT(slotOpenAboutDialog()) );
+/** retranslation for actions used in this class
+* This is called for two different collections of actions
+* One set is for the actual use in the menus, etc
+* The second is used during the use of the configuration shortcut editor
+*/
+void BibleTime::retranslateUiActions(BtActionCollection* ac) {
+ ac->action("showToolbarsInTextWindows")->setText(tr("Show toolbars in text windows"));
+ ac->action("showToolbar")->setText(tr("Show main toolbar"));
+ ac->action("showNavigation")->setText(tr("Show navigation bar"));
+ ac->action("showWorks")->setText(tr("Show works toolbar"));
+ ac->action("showTools")->setText(tr("Show tools toolbar"));
+ ac->action("showFormat")->setText(tr("Show formatting toolbar"));
+ ac->action("showBookshelf")->setText(tr("Show bookshelf"));
+ ac->action("showBookmarks")->setText(tr("Show bookmarks"));
+ ac->action("showMag")->setText(tr("Show mag"));
+ ac->action("showParallelTextHeaders")->setText(tr("Show parallel text headers"));
}
/** Initializes the SIGNAL / SLOT connections */
void BibleTime::initConnections() {
- if (m_windowMenu) {
- QObject::connect(m_windowMenu, SIGNAL(aboutToShow()), this, SLOT(slotWindowMenuAboutToShow()));
- }
- else {
- qWarning() << "Main window: can't find window menu";
- }
+ // Bookmarks page connections:
+ connect(m_bookmarksPage, SIGNAL(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)),
+ this, SLOT(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)));
- if (m_openWindowsMenu) {
- QObject::connect(m_openWindowsMenu, SIGNAL(aboutToShow()),
- this, SLOT(slotOpenWindowsMenuAboutToShow()));
- }
- else {
- qWarning() << "Main window: can't find open windows menu";
- }
-
- bool ok;
- ok = connect(m_bookmarksPage,
- SIGNAL(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)),
- this,
- SLOT(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)));
- Q_ASSERT(ok);
+ // Bookshelf dock connections:
connect(m_bookshelfDock, SIGNAL(moduleOpenTriggered(CSwordModuleInfo*)),
this, SLOT(createReadDisplayWindow(CSwordModuleInfo*)));
connect(m_bookshelfDock, SIGNAL(moduleSearchTriggered(CSwordModuleInfo*)),
@@ -481,11 +690,9 @@ void BibleTime::initConnections() {
connect(m_bookshelfDock, SIGNAL(moduleEditHtmlTriggered(CSwordModuleInfo*)),
this, SLOT(moduleEditHtml(CSwordModuleInfo*)));
connect(m_bookshelfDock, SIGNAL(moduleUnlockTriggered(CSwordModuleInfo*)),
- this, SLOT(moduleUnlock(CSwordModuleInfo*)));
+ this, SLOT(slotModuleUnlock(CSwordModuleInfo*)));
connect(m_bookshelfDock, SIGNAL(moduleAboutTriggered(CSwordModuleInfo*)),
this, SLOT(moduleAbout(CSwordModuleInfo*)));
-
- connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slot_aboutToQuit()));
}
void BibleTime::initSwordConfigFile() {
@@ -511,6 +718,24 @@ void BibleTime::initSwordConfigFile() {
out << "\n";
file.close();
#endif
+
+#ifdef Q_WS_MAC
+ namespace DU = util::directory;
+ QString configFile = util::directory::getUserHomeSwordDir().filePath("sword.conf");
+ QFile file(configFile);
+ if (file.exists()) {
+ return;
+ }
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ return;
+ }
+ QTextStream out(&file);
+ out << "\n";
+ out << "[Install]\n";
+ out << "DataPath=" << DU::convertDirSeparators( DU::getUserHomeSwordDir().absolutePath()) << "\n";
+ out << "\n";
+ file.close();
+#endif
}
/** Initializes the backend */
@@ -520,55 +745,64 @@ void BibleTime::initBackends() {
initSwordConfigFile();
sword::StringMgr::setSystemStringMgr( new BTStringMgr() );
- sword::SWLog::getSystemLog()->setLogLevel(1);
+ sword::SWLog::getSystemLog()->setLogLevel(sword::SWLog::LOG_ERROR);
+
+ if (qApp->property("--debug").toBool()) {
+ sword::SWLog::getSystemLog()->setLogLevel(sword::SWLog::LOG_DEBUG);
+ }
- CSwordBackend* backend = new CSwordBackend();
+#ifdef Q_WS_MAC
+ // set a LocaleMgr with a fixed path to the locales.d of the DMG image on MacOS
+ // note: this must be done after setting the BTStringMgr, because this will reset the LocaleMgr
+ qDebug() << "Using sword locales dir: " << util::directory::getSwordLocalesDir().absolutePath().toUtf8();
+ sword::LocaleMgr::setSystemLocaleMgr(new sword::LocaleMgr(util::directory::getSwordLocalesDir().absolutePath().toUtf8()));
+#endif
+
+ CSwordBackend *backend = CSwordBackend::createInstance();
backend->booknameLanguage(CBTConfig::get(CBTConfig::language) );
- CPointers::setBackend(backend);
- const CSwordBackend::LoadError errorCode = CPointers::backend()->initModules(CSwordBackend::OtherChange);
+ const CSwordBackend::LoadError errorCode = CSwordBackend::instance()->initModules(CSwordBackend::OtherChange);
if (errorCode != CSwordBackend::NoError) {
//show error message that initBackend failed
/// \todo
-// switch (errorCode) {
-// case CSwordBackend::NoSwordConfig: //mods.d or mods.conf missing
-// {
-// KStartupLogo::hideSplash();
-// qDebug() << "case CSwordBackend::NoSwordConfig";
-// BookshelfManager::CSwordSetupDialog dlg;
-// dlg.showPart( BookshelfManager::CSwordSetupDialog::Sword );
-// dlg.exec();
-// break;
-// }
+// switch (errorCode) {
+// case CSwordBackend::NoSwordConfig: //mods.d or mods.conf missing
+// {
+// KStartupLogo::hideSplash();
+// qDebug() << "case CSwordBackend::NoSwordConfig";
+// BookshelfManager::CSwordSetupDialog dlg;
+// dlg.showPart( BookshelfManager::CSwordSetupDialog::Sword );
+// dlg.exec();
+// break;
+// }
//
-// case CSwordBackend::NoModules: //no modules installed, but config exists
-// {
-// KStartupLogo::hideSplash();
-// qDebug() << "case CSwordBackend::NoModules";
-// BookshelfManager::CSwordSetupDialog dlg;
-// dlg.showPart( BookshelfManager::CSwordSetupDialog::Install );
-// dlg.exec();
-// break;
-// }
+// case CSwordBackend::NoModules: //no modules installed, but config exists
+// {
+// KStartupLogo::hideSplash();
+// qDebug() << "case CSwordBackend::NoModules";
+// BookshelfManager::CSwordSetupDialog dlg;
+// dlg.showPart( BookshelfManager::CSwordSetupDialog::Install );
+// dlg.exec();
+// break;
+// }
//
-// default: //unknown error
-// {
-// KStartupLogo::hideSplash();
-// qDebug() << "unknown error";
-// BookshelfManager::CSwordSetupDialog dlg;
-// dlg.showPart( BookshelfManager::CSwordSetupDialog::Sword );
-// dlg.exec();
-// break;
-// }
-// }
+// default: //unknown error
+// {
+// KStartupLogo::hideSplash();
+// qDebug() << "unknown error";
+// BookshelfManager::CSwordSetupDialog dlg;
+// dlg.showPart( BookshelfManager::CSwordSetupDialog::Sword );
+// dlg.exec();
+// break;
+// }
+// }
}
- //This function will
+ // This function will
// - delete all orphaned indexes (no module present) if autoDeleteOrphanedIndices is true
// - delete all indices of modules where hasIndex() returns false
- //BookshelfManager::CManageIndicesWidget::deleteOrphanedIndices();
- /// \todo //backend::deleteOrphanedIndices();
+ backend->deleteOrphanedIndices();
}
@@ -577,10 +811,10 @@ void BibleTime::applyProfileSettings( CProfile* p ) {
Q_ASSERT(p);
if (!p) return;
- //first Main Window state
- restoreState(p->getMainwindowState());
+ //first Main Window geometry
restoreGeometry(p->getMainwindowGeometry());
- m_windowFullscreen_action->setChecked(isFullScreen());
+ restoreState(p->getMainwindowState());
+ m_windowFullscreenAction->setChecked(isFullScreen());
const CMDIArea::MDIArrangementMode newArrangementMode = p->getMDIArrangementMode();
//make sure actions are updated by calling the slot functions
@@ -598,6 +832,9 @@ void BibleTime::applyProfileSettings( CProfile* p ) {
case CMDIArea::ArrangementModeTile:
slotAutoTile();
break;
+ case CMDIArea::ArrangementModeTabbed:
+ slotAutoTabbed();
+ break;
case CMDIArea::ArrangementModeManual:
slotManualArrangementMode();
break;
@@ -605,14 +842,87 @@ void BibleTime::applyProfileSettings( CProfile* p ) {
slotAutoTileVertical();
break;
}
+ layout()->invalidate();
}
void BibleTime::storeProfileSettings( CProfile* p ) {
- Q_ASSERT(p && m_windowFullscreen_action);
- if (!p || !m_windowFullscreen_action) return;
+ Q_ASSERT(p && m_windowFullscreenAction);
+ if (!p || !m_windowFullscreenAction) return;
p->setMainwindowState(saveState());
p->setMainwindowGeometry(saveGeometry());
p->setMDIArrangementMode(m_mdi->getMDIArrangementMode());
}
+#if BT_DEBUG
+
+QLabel *BibleTime::m_debugWindow = 0;
+QMutex BibleTime::m_debugWindowLock;
+
+void BibleTime::slotShowDebugWindow(bool show) {
+ if (show) {
+ QMutexLocker lock(&m_debugWindowLock);
+ if (m_debugWindow == 0) {
+ m_debugWindow = new QLabel(0, Qt::Dialog);
+ m_debugWindow->setAttribute(Qt::WA_DeleteOnClose);
+ m_debugWindow->setTextFormat(Qt::RichText);
+ m_debugWindow->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ m_debugWindow->setWindowTitle(tr("Whats this widget?"));
+ }
+ m_debugWindow->show();
+ connect(m_debugWindow, SIGNAL(destroyed()),
+ this, SLOT(slotDebugWindowClosing()), Qt::DirectConnection);
+ QTimer::singleShot(0, this, SLOT(slotDebugTimeout()));
+ } else {
+ deleteDebugWindow();
+ }
+}
+
+void BibleTime::deleteDebugWindow() {
+ QMutexLocker lock(&m_debugWindowLock);
+ if (m_debugWindow != 0) {
+ m_debugWindow->disconnect(SIGNAL(destroyed()), this, SLOT(slotDebugWindowClosing()));
+ delete m_debugWindow;
+ m_debugWindow = 0;
+ }
+}
+
+void BibleTime::slotDebugWindowClosing() {
+ QMutexLocker lock(&m_debugWindowLock);
+ m_debugWindow = 0;
+ m_debugWidgetAction->setChecked(false);
+}
+
+void BibleTime::slotDebugTimeout() {
+ QMutexLocker lock(&m_debugWindowLock);
+ if (m_debugWindow == 0 || m_debugWindow->isVisible() == false) return;
+
+ QTimer::singleShot(0, this, SLOT(slotDebugTimeout()));
+ QObject *w = QApplication::widgetAt(QCursor::pos());
+ if (w != 0) {
+ QString objectHierarchy;
+ do {
+ const QMetaObject *m = w->metaObject();
+ QString classHierarchy;
+ do {
+ if (!classHierarchy.isEmpty()) classHierarchy += ": ";
+ classHierarchy += m->className();
+
+ m = m->superClass();
+ } while (m != 0);
+ if (!objectHierarchy.isEmpty()) {
+ objectHierarchy += "<br/><b>child of:</b> ";
+ } else {
+ objectHierarchy += "<b>This widget is:</b> ";
+ }
+ objectHierarchy += classHierarchy;
+ w = w->parent();
+ } while (w != 0);
+ m_debugWindow->setText(objectHierarchy);
+ } else {
+ m_debugWindow->setText("No widget");
+ }
+ m_debugWindow->resize(m_debugWindow->minimumSizeHint());
+}
+
+#endif
diff --git a/src/bibletime_slots.cpp b/src/bibletime_slots.cpp
index b1ee3b3..9fdab62 100644
--- a/src/bibletime_slots.cpp
+++ b/src/bibletime_slots.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,20 +20,21 @@
#include <QProcess>
#include <QtGlobal>
#include <QToolBar>
+#include <QUrl>
#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordversekey.h"
+#include "frontend/btaboutdialog.h"
#include "frontend/cinfodisplay.h"
-#include "frontend/cinputdialog.h"
#include "frontend/cmdiarea.h"
#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
-#include "frontend/displaywindow/cbiblereadwindow.h"
+#include "frontend/displaywindow/btmodulechooserbar.h"
#include "frontend/displaywindow/cdisplaywindow.h"
-#include "frontend/htmldialogs/btaboutdialog.h"
#include "frontend/profile/cprofilemgr.h"
#include "frontend/profile/cprofile.h"
#include "frontend/profile/cprofilewindow.h"
#include "frontend/searchdialog/csearchdialog.h"
#include "frontend/settingsdialogs/cconfigurationdialog.h"
+#include "frontend/tips/bttipdialog.h"
#include "util/directory.h"
@@ -60,17 +61,17 @@ void BibleTime::saveConfigSettings() {
void BibleTime::slotSettingsChanged() {
qDebug() << "BibleTime::slotSettingsChanged";
const QString language = CBTConfig::get(CBTConfig::language);
- CPointers::backend()->booknameLanguage(language);
+ CSwordBackend::instance()->booknameLanguage(language);
// \todo update the bookmarks after Bible bookname language has been changed
-// QTreeWidgetItemIterator it(m_mainIndex);
-// while (*it) {
-// CIndexItemBase* citem = dynamic_cast<CIndexItemBase*>(*it);
-// if (citem) {
-// citem->update();
-// }
-// ++it;
-// }
+// QTreeWidgetItemIterator it(m_mainIndex);
+// while (*it) {
+// CIndexItemBase* citem = dynamic_cast<CIndexItemBase*>(*it);
+// if (citem) {
+// citem->update();
+// }
+// ++it;
+// }
refreshBibleTimeAccel();
refreshDisplayWindows();
@@ -93,26 +94,26 @@ void BibleTime::slotWindowMenuAboutToShow() {
Q_ASSERT(m_windowMenu);
if ( m_mdi->subWindowList().isEmpty() ) {
- m_windowCascade_action->setEnabled(false);
- m_windowTileVertical_action->setEnabled(false);
- m_windowTileHorizontal_action->setEnabled(false);
- m_windowClose_action->setEnabled(false);
- m_windowCloseAll_action->setEnabled(false);
+ m_windowCascadeAction->setEnabled(false);
+ m_windowTileVerticalAction->setEnabled(false);
+ m_windowTileHorizontalAction->setEnabled(false);
+ m_windowCloseAction->setEnabled(false);
+ m_windowCloseAllAction->setEnabled(false);
m_openWindowsMenu->setEnabled(false);
}
else if (m_mdi->subWindowList().count() == 1) {
- m_windowTileVertical_action->setEnabled(false);
- m_windowTileHorizontal_action->setEnabled(false);
- m_windowCascade_action->setEnabled(false);
- m_windowClose_action->setEnabled(true);
- m_windowCloseAll_action->setEnabled(true);
+ m_windowTileVerticalAction->setEnabled(false);
+ m_windowTileHorizontalAction->setEnabled(false);
+ m_windowCascadeAction->setEnabled(false);
+ m_windowCloseAction->setEnabled(true);
+ m_windowCloseAllAction->setEnabled(true);
m_openWindowsMenu->setEnabled(true);
// m_windowMenu->insertSeparator();
}
else {
slotUpdateWindowArrangementActions(0); //update the window tile/cascade states
- m_windowClose_action->setEnabled(true);
- m_windowCloseAll_action->setEnabled(true);
+ m_windowCloseAction->setEnabled(true);
+ m_windowCloseAllAction->setEnabled(true);
m_openWindowsMenu->setEnabled(true);
}
}
@@ -132,132 +133,152 @@ void BibleTime::slotOpenWindowsMenuAboutToShow() {
}
}
-/** This slot is connected with the windowAutoTile_action object */
+/** This slot is connected with the windowAutoTileAction object */
void BibleTime::slotUpdateWindowArrangementActions( QAction* clickedAction ) {
- /* If a toggle action was clicked we see if it checked ot unchecked and
+ /* If a toggle action was clicked we see if it is checked or unchecked and
* enable/disable the simple cascade and tile options accordingly
*/
- m_windowTileVertical_action->setEnabled( m_windowManualMode_action->isChecked() );
- m_windowTileHorizontal_action->setEnabled( m_windowManualMode_action->isChecked() );
- m_windowCascade_action->setEnabled( m_windowManualMode_action->isChecked() );
- m_windowTile_action->setEnabled( m_windowManualMode_action->isChecked() );
+ m_windowTileVerticalAction->setEnabled( m_windowManualModeAction->isChecked() );
+ m_windowTileHorizontalAction->setEnabled( m_windowManualModeAction->isChecked() );
+ m_windowCascadeAction->setEnabled( m_windowManualModeAction->isChecked() );
+ m_windowTileAction->setEnabled( m_windowManualModeAction->isChecked() );
if (clickedAction) {
- m_windowManualMode_action->setEnabled(
- m_windowManualMode_action != clickedAction
- && m_windowTileHorizontal_action != clickedAction
- && m_windowTileVertical_action != clickedAction
- && m_windowCascade_action != clickedAction
- && m_windowTile_action != clickedAction
+ m_windowManualModeAction->setEnabled(
+ m_windowManualModeAction != clickedAction
+ && m_windowTileHorizontalAction != clickedAction
+ && m_windowTileVerticalAction != clickedAction
+ && m_windowCascadeAction != clickedAction
+ && m_windowTileAction != clickedAction
);
- m_windowAutoTileVertical_action->setEnabled( m_windowAutoTileVertical_action != clickedAction );
- m_windowAutoTileHorizontal_action->setEnabled( m_windowAutoTileHorizontal_action != clickedAction );
- m_windowAutoCascade_action->setEnabled( m_windowAutoCascade_action != clickedAction );
- m_windowAutoTile_action->setEnabled( m_windowAutoTile_action != clickedAction );
+ m_windowAutoTileVerticalAction->setEnabled( m_windowAutoTileVerticalAction != clickedAction );
+ m_windowAutoTileHorizontalAction->setEnabled( m_windowAutoTileHorizontalAction != clickedAction );
+ m_windowAutoCascadeAction->setEnabled( m_windowAutoCascadeAction != clickedAction );
+ m_windowAutoTileAction->setEnabled( m_windowAutoTileAction != clickedAction );
+ m_windowAutoTabbedAction->setEnabled( m_windowAutoTabbedAction != clickedAction );
}
- if (clickedAction == m_windowManualMode_action) {
- m_windowAutoTileVertical_action->setChecked(false);
- m_windowAutoTileHorizontal_action->setChecked(false);
- m_windowAutoCascade_action->setChecked(false);
- m_windowAutoTile_action->setChecked(false);
+ if (clickedAction == m_windowManualModeAction) {
+ m_windowAutoTileVerticalAction->setChecked(false);
+ m_windowAutoTileHorizontalAction->setChecked(false);
+ m_windowAutoCascadeAction->setChecked(false);
+ m_windowAutoTileAction->setChecked(false);
+ m_windowAutoTabbedAction->setChecked(false);
m_mdi->enableWindowMinMaxFlags(true);
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
}
- else if (clickedAction == m_windowAutoTileVertical_action) {
- m_windowManualMode_action->setChecked(false);
- m_windowAutoTileHorizontal_action->setChecked(false);
- m_windowAutoCascade_action->setChecked(false);
- m_windowAutoTile_action->setChecked(false);
+ else if (clickedAction == m_windowAutoTileVerticalAction) {
+ m_windowManualModeAction->setChecked(false);
+ m_windowAutoTileHorizontalAction->setChecked(false);
+ m_windowAutoCascadeAction->setChecked(false);
+ m_windowAutoTileAction->setChecked(false);
+ m_windowAutoTabbedAction->setChecked(false);
m_mdi->enableWindowMinMaxFlags(false);
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeTileVertical );
}
- else if (clickedAction == m_windowAutoTileHorizontal_action) {
- m_windowManualMode_action->setChecked(false);
- m_windowAutoTileVertical_action->setChecked(false);
- m_windowAutoCascade_action->setChecked(false);
- m_windowAutoTile_action->setChecked(false);
+ else if (clickedAction == m_windowAutoTileHorizontalAction) {
+ m_windowManualModeAction->setChecked(false);
+ m_windowAutoTileVerticalAction->setChecked(false);
+ m_windowAutoCascadeAction->setChecked(false);
+ m_windowAutoTileAction->setChecked(false);
+ m_windowAutoTabbedAction->setChecked(false);
m_mdi->enableWindowMinMaxFlags(false);
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeTileHorizontal );
}
- else if (clickedAction == m_windowAutoTile_action) {
- m_windowManualMode_action->setChecked(false);
- m_windowAutoTileHorizontal_action->setChecked(false);
- m_windowAutoTileVertical_action->setChecked(false);
- m_windowAutoCascade_action->setChecked(false);
+ else if (clickedAction == m_windowAutoTileAction) {
+ m_windowManualModeAction->setChecked(false);
+ m_windowAutoTileHorizontalAction->setChecked(false);
+ m_windowAutoTileVerticalAction->setChecked(false);
+ m_windowAutoTabbedAction->setChecked(false);
+ m_windowAutoCascadeAction->setChecked(false);
m_mdi->enableWindowMinMaxFlags(false);
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeTile );
}
- else if (clickedAction == m_windowAutoCascade_action) {
- m_windowManualMode_action->setChecked(false);
- m_windowAutoTileHorizontal_action->setChecked(false);
- m_windowAutoTileVertical_action->setChecked(false);
- m_windowAutoTile_action->setChecked(false);
+ else if (clickedAction == m_windowAutoTabbedAction) {
+ m_windowManualModeAction->setChecked(false);
+ m_windowAutoTileHorizontalAction->setChecked(false);
+ m_windowAutoTileVerticalAction->setChecked(false);
+ m_windowAutoTileAction->setChecked(false);
+ m_windowAutoCascadeAction->setChecked(false);
+ m_mdi->enableWindowMinMaxFlags(false);
+ m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeTabbed );
+ }
+ else if (clickedAction == m_windowAutoCascadeAction) {
+ m_windowManualModeAction->setChecked(false);
+ m_windowAutoTileHorizontalAction->setChecked(false);
+ m_windowAutoTileVerticalAction->setChecked(false);
+ m_windowAutoTileAction->setChecked(false);
+ m_windowAutoTabbedAction->setChecked(false);
m_mdi->enableWindowMinMaxFlags(false);
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeCascade );
}
- else if (clickedAction == m_windowTile_action) {
+ else if (clickedAction == m_windowTileAction) {
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
m_mdi->myTile();
}
- else if (clickedAction == m_windowCascade_action) {
+ else if (clickedAction == m_windowCascadeAction) {
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
m_mdi->myCascade();
}
- else if (clickedAction == m_windowTileVertical_action) {
+ else if (clickedAction == m_windowTileVerticalAction) {
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
m_mdi->myTileVertical();
}
- else if (clickedAction == m_windowTileHorizontal_action) {
+ else if (clickedAction == m_windowTileHorizontalAction) {
m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
m_mdi->myTileHorizontal();
}
}
void BibleTime::slotManualArrangementMode() {
- slotUpdateWindowArrangementActions( m_windowManualMode_action );
+ slotUpdateWindowArrangementActions( m_windowManualModeAction );
}
-/** This slot is connected with the windowAutoTile_action object */
+/** This slot is connected with the windowAutoTileAction object */
void BibleTime::slotAutoTileHorizontal() {
- slotUpdateWindowArrangementActions( m_windowAutoTileHorizontal_action );
+ slotUpdateWindowArrangementActions( m_windowAutoTileHorizontalAction );
}
-/** This slot is connected with the windowAutoTile_action object */
+/** This slot is connected with the windowAutoTileAction object */
void BibleTime::slotAutoTileVertical() {
- slotUpdateWindowArrangementActions( m_windowAutoTileVertical_action );
+ slotUpdateWindowArrangementActions( m_windowAutoTileVerticalAction );
}
-/** This slot is connected with the windowAutoTile_action object */
+/** This slot is connected with the windowAutoTileAction object */
void BibleTime::slotAutoTile() {
- slotUpdateWindowArrangementActions( m_windowAutoTile_action );
+ slotUpdateWindowArrangementActions( m_windowAutoTileAction );
+}
+
+/** This slot is connected with the windowAutoTabbedAction object */
+void BibleTime::slotAutoTabbed() {
+ slotUpdateWindowArrangementActions( m_windowAutoTabbedAction );
}
void BibleTime::slotTile() {
- slotUpdateWindowArrangementActions( m_windowTile_action );
+ slotUpdateWindowArrangementActions( m_windowTileAction );
}
void BibleTime::slotCascade() {
- slotUpdateWindowArrangementActions( m_windowCascade_action );
+ slotUpdateWindowArrangementActions( m_windowCascadeAction );
}
void BibleTime::slotTileVertical() {
- slotUpdateWindowArrangementActions( m_windowTileVertical_action );
+ slotUpdateWindowArrangementActions( m_windowTileVerticalAction );
}
void BibleTime::slotTileHorizontal() {
- slotUpdateWindowArrangementActions( m_windowTileHorizontal_action );
+ slotUpdateWindowArrangementActions( m_windowTileHorizontalAction );
}
-/** This slot is connected with the windowAutoCascade_action object */
+/** This slot is connected with the windowAutoCascadeAction object */
void BibleTime::slotAutoCascade() {
- slotUpdateWindowArrangementActions( m_windowAutoCascade_action );
+ slotUpdateWindowArrangementActions( m_windowAutoCascadeAction );
}
/** Shows/hides the toolbar */
-void BibleTime::slotToggleToolbar() {
+void BibleTime::slotToggleMainToolbar() {
Q_ASSERT(m_mainToolBar);
- if (m_viewToolbar_action->isChecked()) {
+ if (m_viewToolbarAction->isChecked()) {
m_mainToolBar->show();
}
else {
@@ -271,22 +292,80 @@ void BibleTime::slotToggleTextWindowHeader() {
emit toggledTextWindowHeader(!currentState);
}
-void BibleTime::slotToggleTextWindowNavigator() {
+void BibleTime::slotToggleNavigatorToolbar() {
bool currentState = CBTConfig::get(CBTConfig::showTextWindowNavigator);
CBTConfig::set(CBTConfig::showTextWindowNavigator, !currentState);
- emit toggledTextWindowNavigator(!currentState);
+ showOrHideToolBars();
+ if (CBTConfig::get(CBTConfig::showToolbarsInEachWindow))
+ emit toggledTextWindowNavigator(!currentState);
+ else
+ emit toggledTextWindowNavigator(false);
}
-void BibleTime::slotToggleTextWindowToolButtons() {
+void BibleTime::slotToggleToolsToolbar() {
bool currentState = CBTConfig::get(CBTConfig::showTextWindowToolButtons);
CBTConfig::set(CBTConfig::showTextWindowToolButtons, !currentState);
- emit toggledTextWindowToolButtons(!currentState);
+ showOrHideToolBars();
+ if (CBTConfig::get(CBTConfig::showToolbarsInEachWindow))
+ emit toggledTextWindowToolButtons(!currentState);
+ else
+ emit toggledTextWindowToolButtons(false);
}
-void BibleTime::slotToggleTextWindowModuleChooser() {
+void BibleTime::slotToggleWorksToolbar() {
bool currentState = CBTConfig::get(CBTConfig::showTextWindowModuleSelectorButtons);
CBTConfig::set(CBTConfig::showTextWindowModuleSelectorButtons, !currentState);
- emit toggledTextWindowModuleChooser(!currentState);
+ showOrHideToolBars();
+ if (CBTConfig::get(CBTConfig::showToolbarsInEachWindow))
+ emit toggledTextWindowModuleChooser(!currentState);
+ else
+ emit toggledTextWindowModuleChooser(false);
+}
+
+void BibleTime::slotToggleFormatToolbar() {
+ bool currentState = CBTConfig::get(CBTConfig::showFormatToolbarButtons);
+ CBTConfig::set(CBTConfig::showFormatToolbarButtons, !currentState);
+ showOrHideToolBars();
+ if (CBTConfig::get(CBTConfig::showToolbarsInEachWindow))
+ emit toggledTextWindowFormatToolbar(!currentState);
+ else
+ emit toggledTextWindowFormatToolbar(false);
+}
+
+void BibleTime::slotToggleToolBarsInEachWindow() {
+ bool currentState = CBTConfig::get(CBTConfig::showToolbarsInEachWindow);
+ CBTConfig::set(CBTConfig::showToolbarsInEachWindow, !currentState);
+ showOrHideToolBars();
+
+ if (!currentState) {
+ emit toggledTextWindowNavigator(CBTConfig::get(CBTConfig::showTextWindowNavigator));
+ emit toggledTextWindowToolButtons(CBTConfig::get(CBTConfig::showTextWindowToolButtons));
+ emit toggledTextWindowModuleChooser(CBTConfig::get(CBTConfig::showTextWindowModuleSelectorButtons));
+ emit toggledTextWindowFormatToolbar(CBTConfig::get(CBTConfig::showFormatToolbarButtons));
+ }
+ else {
+ emit toggledTextWindowNavigator(false);
+ emit toggledTextWindowToolButtons(false);
+ emit toggledTextWindowModuleChooser(false);
+ emit toggledTextWindowFormatToolbar(false);
+ }
+
+
+}
+
+void BibleTime::showOrHideToolBars() {
+ if (CBTConfig::get(CBTConfig::showToolbarsInEachWindow)) {
+ m_navToolBar->setVisible(false);
+ m_worksToolBar->setVisible(false);
+ m_toolsToolBar->setVisible(false);
+ m_formatToolBar->setVisible(false);
+ }
+ else {
+ m_navToolBar->setVisible(CBTConfig::get(CBTConfig::showTextWindowNavigator));
+ m_worksToolBar->setVisible(CBTConfig::get(CBTConfig::showTextWindowModuleSelectorButtons));
+ m_toolsToolBar->setVisible(CBTConfig::get(CBTConfig::showTextWindowToolButtons));
+ m_formatToolBar->setVisible(CBTConfig::get(CBTConfig::showFormatToolbarButtons));
+ }
}
/** Sets the active window. */
@@ -298,7 +377,7 @@ void BibleTime::slotSetActiveSubWindow(QWidget* window) {
void BibleTime::slotSearchModules() {
//get the modules of the open windows
- QList<CSwordModuleInfo*> modules;
+ QList<const CSwordModuleInfo*> modules;
foreach(QMdiSubWindow* subWindow, m_mdi->subWindowList()) {
if (CDisplayWindow* w = dynamic_cast<CDisplayWindow*>(subWindow->widget())) {
@@ -312,7 +391,7 @@ void BibleTime::slotSearchModules() {
* Call CSearchDialog::openDialog with only the default bible module
*/
void BibleTime::slotSearchDefaultBible() {
- QList<CSwordModuleInfo*> module;
+ QList<const CSwordModuleInfo*> module;
CSwordModuleInfo* bible = CBTConfig::get(CBTConfig::standardBible);
if (bible) {
module.append(bible);
@@ -335,6 +414,11 @@ void BibleTime::slotOpenAboutDialog() {
dlg->show();
}
+void BibleTime::slotOpenTipDialog() {
+ BtTipDialog* dlg = new BtTipDialog(this);
+ dlg->show();
+}
+
/** Saves the current settings into the currently activated profile. */
void BibleTime::saveProfile(QAction* action) {
m_mdi->setUpdatesEnabled(false);
@@ -405,7 +489,7 @@ void BibleTime::loadProfile(CProfile* p) {
QList<CSwordModuleInfo*> modules;
for ( QStringList::Iterator it = usedModules.begin(); it != usedModules.end(); ++it ) {
- if (CSwordModuleInfo* m = CPointers::backend()->findModuleByName(*it)) {
+ if (CSwordModuleInfo* m = CSwordBackend::instance()->findModuleByName(*it)) {
modules.append(m);
}
}
@@ -416,7 +500,7 @@ void BibleTime::loadProfile(CProfile* p) {
//is w->isWriteWindow is false we create a write window, otherwise a read window
CDisplayWindow* displayWindow = 0;
if (w->writeWindowType() > 0) { //create a write window
- displayWindow = createWriteDisplayWindow(modules.first(), key, CDisplayWindow::WriteWindowType(w->writeWindowType()) );
+ displayWindow = createWriteDisplayWindow(modules.first(), key, CWriteWindow::WriteWindowType(w->writeWindowType()) );
}
else { //create a read window
displayWindow = createReadDisplayWindow(modules, key);
@@ -449,7 +533,7 @@ void BibleTime::deleteProfile(QAction* action) {
}
void BibleTime::toggleFullscreen() {
- if (m_windowFullscreen_action->isChecked()) {
+ if (m_windowFullscreenAction->isChecked()) {
// set full screen mode
m_WindowWasMaximizedBeforeFullScreen = isMaximized();
showFullScreen();
diff --git a/src/bibletimeapp.cpp b/src/bibletimeapp.cpp
index 73ac468..8521f2a 100644
--- a/src/bibletimeapp.cpp
+++ b/src/bibletimeapp.cpp
@@ -2,40 +2,36 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "bibletimeapp.h"
+#include <QMessageBox>
#include "backend/config/cbtconfig.h"
+#include "backend/managers/cdisplaytemplatemgr.h"
#include "util/cresmgr.h"
-BibleTimeApp::BibleTimeApp( int & argc, char ** argv ) : QApplication(argc, argv) {
-// initDCOP();
- CResMgr::init_tr();
-}
-
BibleTimeApp::~BibleTimeApp() {
+ // Prevent writing to the log file before the directory cache is init:
+ if (!m_init) return;
//we can set this safely now because we close now (hopyfully without crash)
CBTConfig::set(CBTConfig::crashedLastTime, false);
CBTConfig::set(CBTConfig::crashedTwoTimes, false);
- deleteDisplayTemplateMgr();
- deleteLanguageMgr();
- deleteBackend();
+ delete CDisplayTemplateMgr::instance();
+ CLanguageMgr::destroyInstance();
+ CSwordBackend::destroyInstance();
}
-/*
-void BibleTimeApp::initDCOP() {
- const bool dcopOk = dcopClient()->attach();
- Q_ASSERT(dcopOk);
- if (dcopOk) {
- const Q3CString appId = dcopClient()->registerAs(kapp->name(), false);
- // dcopClient()->setDefaultObject("BibleTimeInterface");
- }
+bool BibleTimeApp::initDisplayTemplateManager() {
+ QString errorMessage;
+ new CDisplayTemplateMgr(errorMessage);
+ if (errorMessage.isNull()) return true;
+ QMessageBox::critical(0, tr("Fatal error!"), errorMessage);
+ return false;
}
-*/
diff --git a/src/bibletimeapp.h b/src/bibletimeapp.h
index b3d5a0e..7ac1ebf 100644
--- a/src/bibletimeapp.h
+++ b/src/bibletimeapp.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,19 +11,22 @@
#define BIBLETIMEAPP_H
#include <QApplication>
-#include "util/cpointers.h"
-/** The BibleTimeApp class is used to clean up all instances of the backend and to delete all created module objects.
- * @author The BibleTime team
- */
-class BibleTimeApp : public QApplication, public CPointers {
+/**
+ The BibleTimeApp class is used to clean up all instances of the backend and to
+ delete all created module objects.
+*/
+class BibleTimeApp : public QApplication {
public:
- BibleTimeApp(int &argc, char **argv);
+ inline BibleTimeApp(int &argc, char **argv) : QApplication(argc, argv), m_init(false) {}
~BibleTimeApp();
- protected:
-// void initDCOP();
+ inline void startInit() { m_init = true; }
+ bool initDisplayTemplateManager();
+
+ private:
+ bool m_init;
};
#endif
diff --git a/src/btglobal.h b/src/btglobal.h
new file mode 100644
index 0000000..9fa97fe
--- /dev/null
+++ b/src/btglobal.h
@@ -0,0 +1,53 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTGLOBAL_H
+#define BTGLOBAL_H
+
+/**
+ Filter options to control the text display of modules. Uses int and not bool
+ because not all options have just two toggle values.
+*/
+struct FilterOptions {
+ int footnotes; /**< 0 for disabled, 1 for enabled */
+ int strongNumbers; /**< 0 for disabled, 1 for enabled */
+ int headings; /**< 0 for disabled, 1 for enabled */
+ int morphTags; /**< 0 for disabled, 1 for enabled */
+ int lemmas; /**< 0 for disabled, 1 for enabled */
+ int hebrewPoints; /**< 0 for disabled, 1 for enabled */
+ int hebrewCantillation; /**< 0 for disabled, 1 for enabled */
+ int greekAccents; /**< 0 for disabled, 1 for enabled */
+ int textualVariants; /**< Number n to enabled the n-th variant */
+ int redLetterWords; /**< 0 for disabled, 1 for enabled */
+ int scriptureReferences; /**< 0 for disabled, 1 for enabled */
+ int morphSegmentation; /**< 0 for disabled, 1 for enabled */
+};
+Q_DECLARE_METATYPE(FilterOptions)
+
+/**
+ Controls the display of a text.
+*/
+struct DisplayOptions {
+ int lineBreaks;
+ int verseNumbers;
+
+/**
+ Work around for Windows compiler bug in Visual Studio 2008 & 2010. The Crash
+ occurs at the return statement of CBTConfig::getDisplayOptionDefaults and is
+ caused by a bad calling sequence when called from CDisplayWindow::init.
+ \todo Properly identify this bug and remove the #ifdef when fix is available.
+*/
+#ifdef Q_WS_WIN
+ int notUsed;
+#endif
+
+};
+Q_DECLARE_METATYPE(DisplayOptions)
+
+#endif // BTGLOBAL_H
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp b/src/frontend/bookmarks/btbookmarkfolder.cpp
index 2091a54..1cc2583 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp
+++ b/src/frontend/bookmarks/btbookmarkfolder.cpp
@@ -2,23 +2,23 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "frontend/mainindex/bookmarks/btbookmarkfolder.h"
+#include "frontend/bookmarks/btbookmarkfolder.h"
#include <QDebug>
#include <QFileDialog>
-#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
-#include "frontend/mainindex/bookmarks/btbookmarkitem.h"
-#include "frontend/mainindex/bookmarks/btbookmarkloader.h"
+#include "frontend/bookmarks/btbookmarkitembase.h"
+#include "frontend/bookmarks/btbookmarkitem.h"
+#include "frontend/bookmarks/btbookmarkloader.h"
#include "util/cresmgr.h"
#include "util/directory.h"
-BtBookmarkFolder::BtBookmarkFolder(QTreeWidgetItem* parent, QString name)
+BtBookmarkFolder::BtBookmarkFolder(const QString &name, QTreeWidgetItem *parent)
: BtBookmarkItemBase(parent) {
setText(0, name);
setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled);
@@ -27,7 +27,7 @@ BtBookmarkFolder::BtBookmarkFolder(QTreeWidgetItem* parent, QString name)
bool BtBookmarkFolder::enableAction(MenuAction action) {
if (action == ChangeFolder || action == NewFolder || action == DeleteEntries || action == ImportBookmarks )
return true;
- if (action == ExportBookmarks || action == ImportBookmarks )
+ if (action == SortFolderBookmarks || action == ExportBookmarks || action == ImportBookmarks )
return true;
if ((action == PrintBookmarks) && childCount())
return true;
@@ -57,13 +57,13 @@ void BtBookmarkFolder::importBookmarks() {
};
}
-QString BtBookmarkFolder::toolTip() {
- return QString();
+QString BtBookmarkFolder::toolTip() const {
+ return QString::null;
}
void BtBookmarkFolder::newSubFolder() {
if (dynamic_cast<BtBookmarkFolder*>(this)) {
- BtBookmarkFolder* f = new BtBookmarkFolder(this, QObject::tr("New folder"));
+ BtBookmarkFolder* f = new BtBookmarkFolder(QObject::tr("New folder"), this);
treeWidget()->setCurrentItem(f);
f->update();
@@ -123,7 +123,7 @@ bool BtBookmarkFolder::hasDescendant(QTreeWidgetItem* item) const {
BtBookmarkFolder* BtBookmarkFolder::deepCopy() {
qDebug() << "BtBookmarkFolder::deepCopy";
- BtBookmarkFolder* newFolder = new BtBookmarkFolder(0, this->text(0));
+ BtBookmarkFolder* newFolder = new BtBookmarkFolder(this->text(0));
foreach(QTreeWidgetItem* subitem, getChildList()) {
if (BtBookmarkItem* bmItem = dynamic_cast<BtBookmarkItem*>(subitem)) {
newFolder->addChild(new BtBookmarkItem(*bmItem));
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkfolder.h b/src/frontend/bookmarks/btbookmarkfolder.h
index 9f065f4..90021f8 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkfolder.h
+++ b/src/frontend/bookmarks/btbookmarkfolder.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,7 +10,7 @@
#ifndef BTBOOKMARKFOLDER_H
#define BTBOOKMARKFOLDER_H
-#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
+#include "frontend/bookmarks/btbookmarkitembase.h"
#define CURRENT_SYNTAX_VERSION 1
@@ -18,7 +18,7 @@
class BtBookmarkFolder : public BtBookmarkItemBase {
public:
friend class BtBookmarkLoader;
- BtBookmarkFolder(QTreeWidgetItem* parent, QString name);
+ BtBookmarkFolder(const QString &name, QTreeWidgetItem *parent = 0);
~BtBookmarkFolder() {}
/** See the base class. */
@@ -44,7 +44,7 @@ class BtBookmarkFolder : public BtBookmarkItemBase {
void rename();
void update();
- QString toolTip();
+ QString toolTip() const;
};
#endif
diff --git a/src/frontend/bookmarks/btbookmarkitem.cpp b/src/frontend/bookmarks/btbookmarkitem.cpp
new file mode 100644
index 0000000..fff3d2c
--- /dev/null
+++ b/src/frontend/bookmarks/btbookmarkitem.cpp
@@ -0,0 +1,149 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "frontend/bookmarks/btbookmarkitem.h"
+
+#include <QSharedPointer>
+#include <QDebug>
+#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/keys/cswordversekey.h"
+#include "btglobal.h"
+#include "frontend/bookmarks/btbookmarkfolder.h"
+#include "frontend/bookmarks/bteditbookmarkdialog.h"
+#include "util/cresmgr.h"
+#include "util/directory.h"
+
+
+BtBookmarkItem::BtBookmarkItem(const CSwordModuleInfo *module,
+ const QString &key,
+ const QString &description,
+ const QString &title)
+ : m_description(description),
+ m_moduleName(module ? module->name() : QString::null),
+ m_title(title)
+{
+ if (((module && (module->type() == CSwordModuleInfo::Bible)) || (module->type() == CSwordModuleInfo::Commentary)) ) {
+ CSwordVerseKey vk(0);
+ vk.setKey(key);
+ vk.setLocale("en");
+ m_key = vk.key(); //the m_key member is always the english key!
+ }
+ else {
+ m_key = key;
+ };
+
+ update();
+}
+
+BtBookmarkItem::BtBookmarkItem(QTreeWidgetItem* parent)
+ : BtBookmarkItemBase(parent) {}
+
+BtBookmarkItem::BtBookmarkItem(const BtBookmarkItem& other)
+ : BtBookmarkItemBase(0),
+ m_key(other.m_key),
+ m_description(other.m_description),
+ m_moduleName(other.m_moduleName),
+ m_title(other.m_title)
+{
+ update();
+}
+
+CSwordModuleInfo *BtBookmarkItem::module() const {
+ return CSwordBackend::instance()->findModuleByName(m_moduleName);
+}
+
+QString BtBookmarkItem::key() const {
+ const QString englishKeyName = englishKey();
+ if (!module()) {
+ return englishKeyName;
+ }
+
+ QString returnKeyName = englishKeyName;
+ if ((module()->type() == CSwordModuleInfo::Bible) || (module()->type() == CSwordModuleInfo::Commentary)) {
+ CSwordVerseKey vk(0);
+ vk.setKey(englishKeyName);
+ vk.setLocale(CSwordBackend::instance()->booknameLanguage().toLatin1() );
+
+ returnKeyName = vk.key(); //the returned key is always in the currently set bookname language
+ }
+
+ return returnKeyName;
+}
+
+QString BtBookmarkItem::toolTip() const {
+ if (!module()) {
+ return QString::null;
+ }
+
+ FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults();
+ filterOptions.footnotes = false;
+ filterOptions.scriptureReferences = false;
+ CSwordBackend::instance()->setFilterOptions(filterOptions);
+
+ QString ret;
+ QSharedPointer<CSwordKey> k( CSwordKey::createInstance(module()) );
+ k->setKey(key());
+
+ // const CLanguageMgr::Language* lang = module()->language();
+ // CBTConfig::FontSettingsPair fontPair = CBTConfig::get(lang);
+
+ Q_ASSERT(k.data());
+ QString header = QString::fromLatin1("%1 (%2)")
+ .arg(key())
+ .arg(module()->name());
+ if (title() != header) {
+ ret = QString::fromLatin1("<b>%1</b><br>%2<hr>%3")
+ .arg(header)
+ .arg(title())
+ .arg(description())
+ ;
+ }
+ else {
+ ret = QString::fromLatin1("<b>%1</b><hr>%2")
+ .arg(header)
+ .arg(description())
+ ;
+ }
+
+ return ret;
+}
+
+bool BtBookmarkItem::enableAction(MenuAction action) {
+ if (action == EditBookmark || (module() && (action == PrintBookmarks)) || action == DeleteEntries)
+ return true;
+
+ return false;
+}
+
+void BtBookmarkItem::rename() {
+ BtEditBookmarkDialog d(QString::fromLatin1("%1 (%2)").arg(key()).arg(module() ? module()->name() : QObject::tr("unknown")),
+ m_title,
+ m_description, treeWidget());
+
+ if (d.exec() == QDialog::Accepted) {
+ m_title = d.titleText();
+ m_description = d.descriptionText();
+ update();
+ }
+}
+
+void BtBookmarkItem::update() {
+ namespace DU = util::directory;
+
+ qDebug() << "BtBookmarkItem::update";
+ setIcon(0, DU::getIcon(CResMgr::mainIndex::bookmark::icon));
+
+ if (m_title.isEmpty()) {
+ m_title = QString::fromLatin1("%1 (%2)").arg(key()).arg(module() ? module()->name() : QObject::tr("unknown"));
+ }
+ setText(0,m_title);
+ setToolTip(0, toolTip());
+}
+
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkitem.h b/src/frontend/bookmarks/btbookmarkitem.h
index 6677f61..3166e61 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkitem.h
+++ b/src/frontend/bookmarks/btbookmarkitem.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,7 +10,7 @@
#ifndef BTBOOKMARKITEM_H
#define BTBOOKMARKITEM_H
-#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
+#include "frontend/bookmarks/btbookmarkitembase.h"
#include <QString>
@@ -25,7 +25,8 @@ class BtBookmarkItem : public BtBookmarkItemBase {
BtBookmarkItem(QTreeWidgetItem* parent);
/** Creates a bookmark with module, key and description. */
- BtBookmarkItem(CSwordModuleInfo* module, QString key, QString& description);
+ BtBookmarkItem(const CSwordModuleInfo *module, const QString &key,
+ const QString &description, const QString &title);
/** Creates a copy. */
BtBookmarkItem(const BtBookmarkItem& other);
@@ -33,18 +34,23 @@ class BtBookmarkItem : public BtBookmarkItemBase {
~BtBookmarkItem() {}
/** Returns the used module, 0 if there is no such module. */
- CSwordModuleInfo* module();
+ CSwordModuleInfo *module() const;
/** Returns the used key. */
- QString key();
+ QString key() const;
/** Returns the used description. */
- const QString& description();
- /** Sets the description text for this bookmark. */
- virtual void setDescription(QString text);
+ inline const QString &description() const {
+ return m_description;
+ }
+
+ /** Returns the title. */
+ inline const QString &title() const {
+ return m_title;
+ }
/** Returns a tooltip for this bookmark. */
- virtual QString toolTip();
+ virtual QString toolTip() const;
/** Returns whether the action is supported by this item. */
virtual bool enableAction(MenuAction action);
@@ -56,11 +62,15 @@ class BtBookmarkItem : public BtBookmarkItemBase {
private:
/** Returns the english key.*/
- QString englishKey() const;
+ inline const QString &englishKey() const {
+ return m_key;
+ }
+ private:
QString m_key;
QString m_description;
QString m_moduleName;
+ QString m_title;
};
#endif
diff --git a/src/frontend/bookmarks/btbookmarkitembase.cpp b/src/frontend/bookmarks/btbookmarkitembase.cpp
new file mode 100644
index 0000000..1a80f7d
--- /dev/null
+++ b/src/frontend/bookmarks/btbookmarkitembase.cpp
@@ -0,0 +1,21 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "frontend/bookmarks/btbookmarkitembase.h"
+
+
+BtBookmarkItemBase::BtBookmarkItemBase() {
+ // Intentionally empty
+}
+
+BtBookmarkItemBase::BtBookmarkItemBase(QTreeWidgetItem *parent)
+ : QTreeWidgetItem(parent)
+{
+ // Intentionally empty
+}
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkitembase.h b/src/frontend/bookmarks/btbookmarkitembase.h
index 78754f7..8452473 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkitembase.h
+++ b/src/frontend/bookmarks/btbookmarkitembase.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,7 +25,9 @@ class BtBookmarkItemBase : public QTreeWidgetItem {
NewFolder = 0,
ChangeFolder,
- ChangeBookmark,
+ EditBookmark,
+ SortFolderBookmarks,
+ SortAllBookmarks,
ImportBookmarks,
ExportBookmarks,
PrintBookmarks,
@@ -43,8 +45,7 @@ class BtBookmarkItemBase : public QTreeWidgetItem {
BtBookmarkItemBase(QTreeWidgetItem* parent);
virtual ~BtBookmarkItemBase() {}
- virtual QString toolTip() = 0;
- virtual CBookmarkIndex* bookmarkWidget() const;
+ virtual QString toolTip() const = 0;
/** Returns true if the given action should be enabled in the popup menu. */
virtual bool enableAction( MenuAction action ) = 0;
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkloader.cpp b/src/frontend/bookmarks/btbookmarkloader.cpp
index ddf656e..ed1dd29 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkloader.cpp
+++ b/src/frontend/bookmarks/btbookmarkloader.cpp
@@ -2,12 +2,12 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "frontend/mainindex/bookmarks/btbookmarkloader.h"
+#include "frontend/bookmarks/btbookmarkloader.h"
#include <QDebug>
#include <QDomElement>
@@ -19,8 +19,8 @@
#include <QTextStream>
#include <QTreeWidgetItem>
#include "backend/drivers/cswordmoduleinfo.h"
-#include "frontend/mainindex/bookmarks/btbookmarkitem.h"
-#include "frontend/mainindex/bookmarks/btbookmarkfolder.h"
+#include "frontend/bookmarks/btbookmarkitem.h"
+#include "frontend/bookmarks/btbookmarkfolder.h"
#include "util/tool.h"
@@ -64,7 +64,7 @@ QTreeWidgetItem* BtBookmarkLoader::handleXmlElement(QDomElement& element, QTreeW
QTreeWidgetItem* newItem = 0;
if (element.tagName() == "Folder") {
qDebug() << "BtBookmarkLoader::handleXmlElement: found folder";
- BtBookmarkFolder* newFolder = new BtBookmarkFolder(parent, QString());
+ BtBookmarkFolder* newFolder = new BtBookmarkFolder(QString::null, parent);
if (element.hasAttribute("caption")) {
newFolder->setText(0, element.attribute("caption"));
}
@@ -91,6 +91,9 @@ QTreeWidgetItem* BtBookmarkLoader::handleXmlElement(QDomElement& element, QTreeW
if (element.hasAttribute("description")) {
newBookmarkItem->m_description = element.attribute("description");
}
+ if (element.hasAttribute("title")) {
+ newBookmarkItem->m_title = element.attribute("title");
+ }
newBookmarkItem->update();
newItem = newBookmarkItem;
}
@@ -107,7 +110,7 @@ QString BtBookmarkLoader::loadXmlFromFile(QString fileName) {
}
QFile file(fileName);
if (!file.exists())
- return QString();
+ return QString::null;
QString xml;
if (file.open(QIODevice::ReadOnly)) {
@@ -166,7 +169,9 @@ void BtBookmarkLoader::saveItem(QTreeWidgetItem* item, QDomElement& parentElemen
elem.setAttribute("description", bookmarkItem->description());
elem.setAttribute("modulename", bookmarkItem->m_moduleName);
elem.setAttribute("moduledescription", bookmarkItem->module() ? bookmarkItem->module()->config(CSwordModuleInfo::Description) : QString::null);
-
+ if ( ! bookmarkItem->title().isEmpty()) {
+ elem.setAttribute("title", bookmarkItem->m_title);
+ }
parentElement.appendChild(elem);
}
}
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkloader.h b/src/frontend/bookmarks/btbookmarkloader.h
index 3102ca2..8b819ce 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkloader.h
+++ b/src/frontend/bookmarks/btbookmarkloader.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookmarks/bteditbookmarkdialog.cpp b/src/frontend/bookmarks/bteditbookmarkdialog.cpp
new file mode 100644
index 0000000..614498f
--- /dev/null
+++ b/src/frontend/bookmarks/bteditbookmarkdialog.cpp
@@ -0,0 +1,78 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "bteditbookmarkdialog.h"
+
+#include <QDialogButtonBox>
+#include <QVBoxLayout>
+#include <QFormLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QTextEdit>
+#include <QWidget>
+#include "util/cresmgr.h"
+#include "util/dialogutil.h"
+#include "util/directory.h"
+
+
+BtEditBookmarkDialog::BtEditBookmarkDialog(const QString &key,
+ const QString &title,
+ const QString &description,
+ QWidget *parent,
+ Qt::WindowFlags wflags)
+ : QDialog(parent, wflags)
+{
+ namespace DU = util::directory;
+
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
+
+ resize(400, 300);
+ setWindowIcon(DU::getIcon(CResMgr::mainIndex::bookmark::icon));
+
+ m_layout = new QFormLayout;
+
+ m_keyLabel = new QLabel(this);
+ m_keyTextLabel = new QLabel(key, this);
+ m_layout->addRow(m_keyLabel, m_keyTextLabel);
+
+ m_titleLabel = new QLabel(this);
+ m_titleEdit = new QLineEdit(title, this);
+ m_layout->addRow(m_titleLabel, m_titleEdit);
+
+ m_descriptionLabel = new QLabel(this);
+ m_descriptionEdit = new QTextEdit(description, this);
+ m_descriptionEdit->setWordWrapMode(QTextOption::WordWrap);
+ m_layout->addRow(m_descriptionLabel, m_descriptionEdit);
+
+ mainLayout->addLayout(m_layout);
+
+ m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel
+ | QDialogButtonBox::NoButton
+ | QDialogButtonBox::Ok,
+ Qt::Horizontal,
+ this);
+ util::prepareDialogBox(m_buttonBox);
+ mainLayout->addWidget(m_buttonBox);
+
+ QObject::connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+ QObject::connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+
+ retranslateUi();
+
+ m_titleEdit->setFocus();
+}
+
+void BtEditBookmarkDialog::retranslateUi() {
+ setWindowTitle(tr("Edit Bookmark"));
+ m_keyLabel->setText(tr("Location:"));
+ m_titleLabel->setText(tr("Title:"));
+ m_descriptionLabel->setText(tr("Description:"));
+
+ /// \todo Add tooltips and what's this texts etc.
+}
diff --git a/src/frontend/bookmarks/bteditbookmarkdialog.h b/src/frontend/bookmarks/bteditbookmarkdialog.h
new file mode 100644
index 0000000..c3455e2
--- /dev/null
+++ b/src/frontend/bookmarks/bteditbookmarkdialog.h
@@ -0,0 +1,62 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTEDITBOOKMARKDIALOG_H
+#define BTEDITBOOKMARKDIALOG_H
+
+#include <QDialog>
+#include <QLineEdit>
+#include <QTextEdit>
+
+class QDialogButtonBox;
+class QFormLayout;
+class QLabel;
+class QWidget;
+
+/**
+ \brief A dialog box for editing bookmarks.
+*/
+class BtEditBookmarkDialog : public QDialog {
+ Q_OBJECT
+
+ public: /* Methods: */
+ BtEditBookmarkDialog(const QString &key,
+ const QString &title,
+ const QString &description,
+ QWidget *parent = 0,
+ Qt::WindowFlags wflags = Qt::Dialog);
+
+ /**
+ * Returns the description written in the description box.
+ */
+ inline const QString descriptionText() {
+ return m_descriptionEdit->toPlainText();
+ }
+
+ /**
+ * Returns the title written in the title box.
+ */
+ inline const QString titleText() { return m_titleEdit->text(); }
+
+ protected: /* Methods: */
+ void retranslateUi();
+
+ private: /* Fields: */
+ QFormLayout *m_layout;
+ QLabel *m_keyLabel;
+ QLabel *m_keyTextLabel;
+ QLabel *m_titleLabel;
+ QLineEdit *m_titleEdit;
+ QLabel *m_descriptionLabel;
+ QTextEdit *m_descriptionEdit;
+ QDialogButtonBox *m_buttonBox;
+
+};
+
+#endif
diff --git a/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp b/src/frontend/bookmarks/cbookmarkindex.cpp
index 1f88125..b6adbfa 100644
--- a/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp
+++ b/src/frontend/bookmarks/cbookmarkindex.cpp
@@ -2,14 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "frontend/mainindex/bookmarks/cbookmarkindex.h"
+#include "frontend/bookmarks/cbookmarkindex.h"
-#include <boost/scoped_ptr.hpp>
+#include <QSharedPointer>
#include <QAction>
#include <QApplication>
#include <QCursor>
@@ -18,7 +18,6 @@
#include <QDragLeaveEvent>
#include <QDragMoveEvent>
#include <QDropEvent>
-#include <QHeaderView>
#include <QInputDialog>
#include <QList>
#include <QMenu>
@@ -35,15 +34,16 @@
#include "frontend/cdragdrop.h"
#include "frontend/cinfodisplay.h"
#include "frontend/cprinter.h"
-#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
-#include "frontend/mainindex/bookmarks/btbookmarkitem.h"
-#include "frontend/mainindex/bookmarks/btbookmarkfolder.h"
-#include "frontend/mainindex/bookmarks/btbookmarkloader.h"
+#include "frontend/bookmarks/btbookmarkitembase.h"
+#include "frontend/bookmarks/btbookmarkitem.h"
+#include "frontend/bookmarks/btbookmarkfolder.h"
+#include "frontend/bookmarks/btbookmarkloader.h"
#include "frontend/searchdialog/csearchdialog.h"
#include "util/cresmgr.h"
#include "util/tool.h"
#include "util/directory.h"
#include "util/dialogutil.h"
+#include "bibletime.h"
CBookmarkIndex::CBookmarkIndex(QWidget *parent)
@@ -68,7 +68,7 @@ CBookmarkIndex::~CBookmarkIndex() {
void CBookmarkIndex::initView() {
//qDebug() << "CBookmarkIndex::initView";
- header()->hide();
+ setHeaderHidden(true);
setFocusPolicy(Qt::WheelFocus);
@@ -92,7 +92,10 @@ void CBookmarkIndex::initView() {
m_actions.newFolder = newQAction(tr("New folder"), CResMgr::mainIndex::newFolder::icon, 0, this, SLOT(createNewFolder()), this);
m_actions.changeFolder = newQAction(tr("Rename folder"), CResMgr::mainIndex::changeFolder::icon, 0, this, SLOT(changeFolder()), this);
- m_actions.changeBookmark = newQAction(tr("Change bookmark description..."), CResMgr::mainIndex::changeBookmark::icon, 0, this, SLOT(changeBookmark()), this);
+ m_actions.editBookmark = newQAction(tr("Edit bookmark..."), CResMgr::mainIndex::editBookmark::icon, 0, this, SLOT(editBookmark()), this);
+ /// \todo Add icons for sorting bookmarks
+ m_actions.sortFolderBookmarks = newQAction(tr("Sort folder bookmarks..."), QString::null, 0, this, SLOT(sortFolderBookmarks()), this);
+ m_actions.sortAllBookmarks = newQAction(tr("Sort all bookmarks..."), QString::null, 0, this, SLOT(sortAllBookmarks()), this);
m_actions.importBookmarks = newQAction(tr("Import to folder..."), CResMgr::mainIndex::importBookmarks::icon, 0, this, SLOT(importBookmarks()), this);
m_actions.exportBookmarks = newQAction(tr("Export from folder..."), CResMgr::mainIndex::exportBookmarks::icon, 0, this, SLOT(exportBookmarks()), this);
m_actions.printBookmarks = newQAction(tr("Print bookmarks..."), CResMgr::mainIndex::printBookmarks::icon, 0, this, SLOT(printBookmarks()), this);
@@ -106,7 +109,9 @@ void CBookmarkIndex::initView() {
QAction* separator = new QAction(this);
separator->setSeparator(true);
m_popup->addAction(separator);
- m_popup->addAction(m_actions.changeBookmark);
+ m_popup->addAction(m_actions.editBookmark);
+ m_popup->addAction(m_actions.sortFolderBookmarks);
+ m_popup->addAction(m_actions.sortAllBookmarks);
m_popup->addAction(m_actions.importBookmarks);
m_popup->addAction(m_actions.exportBookmarks);
m_popup->addAction(m_actions.printBookmarks);
@@ -125,7 +130,12 @@ void CBookmarkIndex::initView() {
*/
QAction* CBookmarkIndex::newQAction(const QString& text, const QString& pix, const int /*shortcut*/, const QObject* receiver, const char* slot, QObject* parent) {
namespace DU = util::directory;
- QAction* action = new QAction(DU::getIcon(pix), text, parent);
+ QAction *action;
+ if (pix.isEmpty()) {
+ action = new QAction(text, parent);
+ } else {
+ action = new QAction(DU::getIcon(pix), text, parent);
+ }
QObject::connect(action, SIGNAL(triggered()), receiver, slot);
return action;
}
@@ -451,9 +461,10 @@ void CBookmarkIndex::createBookmarkFromDrop(QDropEvent* event, QTreeWidgetItem*
QString moduleName = mdata->bookmark().module();
QString keyText = mdata->bookmark().key();
QString description = mdata->bookmark().description();
- CSwordModuleInfo* minfo = CPointers::backend()->findModuleByName(moduleName);
+ CSwordModuleInfo *minfo = CSwordBackend::instance()->findModuleByName(moduleName);
+ QString title; // TODO
- QTreeWidgetItem* newItem = new BtBookmarkItem(minfo, keyText, description);
+ QTreeWidgetItem* newItem = new BtBookmarkItem(minfo, keyText, description, title);
// connect(newItem, SIGNAL(bookmarkModified()), this, SLOT(needToSaveBookmarks()) );
parentItem->insertChild(indexInParent, newItem);
@@ -494,8 +505,12 @@ QAction* CBookmarkIndex::action( BtBookmarkItemBase::MenuAction type ) const {
case BtBookmarkItemBase::ChangeFolder:
return m_actions.changeFolder;
- case BtBookmarkItemBase::ChangeBookmark:
- return m_actions.changeBookmark;
+ case BtBookmarkItemBase::EditBookmark:
+ return m_actions.editBookmark;
+ case BtBookmarkItemBase::SortFolderBookmarks:
+ return m_actions.sortFolderBookmarks;
+ case BtBookmarkItemBase::SortAllBookmarks:
+ return m_actions.sortAllBookmarks;
case BtBookmarkItemBase::ImportBookmarks:
return m_actions.importBookmarks;
case BtBookmarkItemBase::ExportBookmarks:
@@ -531,6 +546,7 @@ void CBookmarkIndex::contextMenu(const QPoint& p) {
//case BtBookmarkItemBase::ExportBookmarks:
//case BtBookmarkItemBase::ImportBookmarks:
case BtBookmarkItemBase::NewFolder:
+ case BtBookmarkItemBase::SortAllBookmarks:
//case BtBookmarkItemBase::PrintBookmarks:
a->setEnabled(true);
break;
@@ -592,7 +608,7 @@ void CBookmarkIndex::createNewFolder() {
}
else {
// create a top level folder
- BtBookmarkFolder* newFolder = new BtBookmarkFolder(0, QObject::tr("New folder"));
+ BtBookmarkFolder* newFolder = new BtBookmarkFolder(tr("New folder"));
//parentFolder->addChild(newFolder);
insertTopLevelItem(topLevelItemCount() - 1, newFolder);
newFolder->update();
@@ -610,8 +626,8 @@ void CBookmarkIndex::changeFolder() {
}
}
-/** Changes the current bookmark. */
-void CBookmarkIndex::changeBookmark() {
+/** Edits the current bookmark. */
+void CBookmarkIndex::editBookmark() {
BtBookmarkItem* i = dynamic_cast<BtBookmarkItem*>(currentItem());
Q_ASSERT(i);
@@ -620,6 +636,28 @@ void CBookmarkIndex::changeBookmark() {
}
}
+/** Sorts the current folder bookmarks. */
+void CBookmarkIndex::sortFolderBookmarks() {
+ BtBookmarkFolder* i = dynamic_cast<BtBookmarkFolder*>(currentItem());
+ Q_ASSERT(i);
+
+ if (i) {
+ i->sortChildren(0, Qt::AscendingOrder);
+ }
+}
+
+/** Sorts all bookmarks. */
+void CBookmarkIndex::sortAllBookmarks() {
+ sortItems(0, Qt::AscendingOrder);
+ int index = indexOfTopLevelItem(m_extraItem);
+ if (index >= 0) {
+ QTreeWidgetItem* item = takeTopLevelItem(index);
+ if (item != 0) {
+ addTopLevelItem(m_extraItem);
+ }
+ }
+}
+
/** Exports the bookmarks being in the selected folder. */
void CBookmarkIndex::exportBookmarks() {
BtBookmarkFolder* i = dynamic_cast<BtBookmarkFolder*>(currentItem());
@@ -671,7 +709,7 @@ void CBookmarkIndex::printBookmarks() {
qWarning("Tried to print empty bookmark list.");
return;
}
- boost::scoped_ptr<Printing::CPrinter> printer(
+ QSharedPointer<Printing::CPrinter> printer(
new Printing::CPrinter( this, CBTConfig::getDisplayOptionDefaults(), CBTConfig::getFilterOptionDefaults() )
);
printer->printKeyTree(tree);
@@ -740,7 +778,11 @@ bool CBookmarkIndex::isMultiAction( const BtBookmarkItemBase::MenuAction type )
case BtBookmarkItemBase::ChangeFolder:
return false;
- case BtBookmarkItemBase::ChangeBookmark:
+ case BtBookmarkItemBase::EditBookmark:
+ return false;
+ case BtBookmarkItemBase::SortFolderBookmarks:
+ return false;
+ case BtBookmarkItemBase::SortAllBookmarks:
return false;
case BtBookmarkItemBase::ImportBookmarks:
return false;
@@ -799,13 +841,13 @@ void CBookmarkIndex::magTimeout() {
//qDebug() << "CBookmarkIndex::timerEvent: update the infodisplay";
// Update the mag
if (bitem->module()) {
- (CPointers::infoDisplay())->setInfo(
+ (BibleTime::instance()->infoDisplay())->setInfo(
InfoDisplay::CInfoDisplay::CrossReference,
bitem->module()->name() + ":" + bitem->key()
);
}
else {
- (CPointers::infoDisplay())->setInfo(InfoDisplay::CInfoDisplay::Text, tr("The work to which the bookmark points to is not installed."));
+ (BibleTime::instance()->infoDisplay())->setInfo(InfoDisplay::CInfoDisplay::Text, tr("The work to which the bookmark points to is not installed."));
}
}
diff --git a/src/frontend/mainindex/bookmarks/cbookmarkindex.h b/src/frontend/bookmarks/cbookmarkindex.h
index 90f9ab2..2875a5d 100644
--- a/src/frontend/mainindex/bookmarks/cbookmarkindex.h
+++ b/src/frontend/bookmarks/cbookmarkindex.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,7 +10,7 @@
#ifndef CBOOKMARKINDEX_H
#define CBOOKMARKINDEX_H
-#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
+#include "frontend/bookmarks/btbookmarkitembase.h"
#include <QList>
#include <QTimer>
@@ -18,7 +18,6 @@
#include <QTreeWidgetItem>
#include <QToolTip>
#include "frontend/displaywindow/cdisplaywindow.h"
-#include "util/cpointers.h"
class BTMimeData;
@@ -126,7 +125,13 @@ class CBookmarkIndex : public QTreeWidget {
void exportBookmarks();
/** Changes the current bookmark. */
- void changeBookmark();
+ void editBookmark();
+
+ /** Sorts the current folder bookmarks. */
+ void sortFolderBookmarks();
+
+ /** Sorts all bookmarks. */
+ void sortAllBookmarks();
/** Helps with the extra item. */
void slotItemEntered(QTreeWidgetItem*, int);
@@ -170,7 +175,9 @@ class CBookmarkIndex : public QTreeWidget {
QAction* newFolder;
QAction* changeFolder;
- QAction* changeBookmark;
+ QAction* editBookmark;
+ QAction* sortFolderBookmarks;
+ QAction* sortAllBookmarks;
QAction* importBookmarks;
QAction* exportBookmarks;
QAction* printBookmarks;
diff --git a/src/frontend/bookshelfmanager/btconfigdialog.cpp b/src/frontend/bookshelfmanager/btconfigdialog.cpp
index 565765d..3d02388 100644
--- a/src/frontend/bookshelfmanager/btconfigdialog.cpp
+++ b/src/frontend/bookshelfmanager/btconfigdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,8 +20,6 @@
#include <QListWidgetItem>
#include <QStackedWidget>
#include <QVBoxLayout>
-#include "util/directory.h"
-#include "util/tool.h"
BtConfigDialog::BtConfigDialog(QWidget* parent)
@@ -44,14 +42,6 @@ BtConfigDialog::BtConfigDialog(QWidget* parent)
m_pageLayout->addWidget(m_pageWidget);
- // Horizontal line
- QFrame* line = new QFrame();
- line->setGeometry(QRect(1, 1, 1, 3));
- line->setFrameShape(QFrame::HLine);
- line->setFrameShadow(QFrame::Sunken);
- line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- m_pageLayout->addWidget(line);
-
connect(m_contentsList,
SIGNAL(currentRowChanged(int)),
this, SLOT(slotChangePage(int))
@@ -62,22 +52,14 @@ BtConfigDialog::BtConfigDialog(QWidget* parent)
BtConfigDialog::~BtConfigDialog() {}
void BtConfigDialog::addPage(BtConfigPage* pageWidget) {
- namespace DU = util::directory;
-
// this is a friend
pageWidget->m_parentDialog = this;
- QVBoxLayout* containerLayout = new QVBoxLayout;
- QLabel* headerLabel = util::tool::explanationLabel(pageWidget, pageWidget->header(), pageWidget->label());
- containerLayout->addWidget(headerLabel);
- containerLayout->addWidget(pageWidget);
- QWidget* containerWidget = new QWidget(m_pageWidget);
- containerWidget->setLayout(containerLayout);
- m_pageWidget->addWidget(containerWidget);
+ m_pageWidget->addWidget(pageWidget);
QListWidgetItem* item = new QListWidgetItem(m_contentsList);
- item->setIcon(DU::getIcon(pageWidget->iconName()));
+ item->setIcon(pageWidget->icon());
item->setText(pageWidget->header());
item->setTextAlignment(Qt::AlignHCenter);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
@@ -96,11 +78,16 @@ void BtConfigDialog::addPage(BtConfigPage* pageWidget) {
}
void BtConfigDialog::addButtonBox(QDialogButtonBox* box) {
- m_pageLayout->addWidget(box);
-}
+ // First add a horizontal ruler:
+ QFrame *line = new QFrame();
+ line->setGeometry(QRect(1, 1, 1, 3));
+ line->setFrameShape(QFrame::HLine);
+ line->setFrameShadow(QFrame::Sunken);
+ line->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ m_pageLayout->addWidget(line);
-BtConfigPage* BtConfigDialog::currentPage() {
- return dynamic_cast<BtConfigPage*>(m_pageWidget->currentWidget());
+ // Add button box:
+ m_pageLayout->addWidget(box);
}
void BtConfigDialog::slotChangePage(int newIndex) {
@@ -113,6 +100,13 @@ void BtConfigDialog::slotChangePage(int newIndex) {
-BtConfigPage::BtConfigPage() {}
+BtConfigPage::BtConfigPage(QWidget *parent)
+ : QWidget(parent)
+ , m_parentDialog(0)
+{
+ setLayout(new QVBoxLayout);
+}
-BtConfigPage::~BtConfigPage() {}
+BtConfigPage::~BtConfigPage() {
+ // Intentionally empty
+}
diff --git a/src/frontend/bookshelfmanager/btconfigdialog.h b/src/frontend/bookshelfmanager/btconfigdialog.h
index 547cb4e..dce22ab 100644
--- a/src/frontend/bookshelfmanager/btconfigdialog.h
+++ b/src/frontend/bookshelfmanager/btconfigdialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,10 +17,11 @@
class BtConfigPage;
-class QListWidgetItem;
+class QDialogButtonBox;
+class QLabel;
class QListWidget;
+class QListWidgetItem;
class QStackedWidget;
-class QDialogButtonBox;
class QVBoxLayout;
/**
@@ -34,7 +35,7 @@ class QVBoxLayout;
class BtConfigDialog : public QDialog {
Q_OBJECT
public:
- BtConfigDialog(QWidget* parent);
+ BtConfigDialog(QWidget *parent = 0);
virtual ~BtConfigDialog();
/** Adds a BtConfigPage to the paged widget stack. The new page will be the current page.*/
@@ -42,9 +43,6 @@ class BtConfigDialog : public QDialog {
/** Adds a button box to the lower edge of the dialog. */
void addButtonBox(QDialogButtonBox* buttonBox);
- /** Returns the currently selected page. */
- BtConfigPage* currentPage();
-
public slots:
/** Changes the current page using the given index number. */
void slotChangePage(int newIndex);
@@ -64,24 +62,29 @@ class BtConfigDialog : public QDialog {
*/
class BtConfigPage : public QWidget {
Q_OBJECT
+ friend class BtConfigDialog;
+
public:
- BtConfigPage();
+ /**
+ Constructs a configuration dialog base, with QVBoxLayout as layout() and a header
+ label as the first widget in this layout.
+ \param[in] parent The parent widget.
+ */
+ BtConfigPage(QWidget *parent = 0);
virtual ~BtConfigPage();
/** Implement these to return the correct values.
* For example: header(){return tr("General");}
*/
- virtual QString iconName() = 0;
- virtual QString label() = 0;
- virtual QString header() = 0;
- BtConfigDialog* parentDialog() {
+ virtual const QIcon &icon() const = 0;
+ virtual QString header() const = 0;
+
+ inline BtConfigDialog *parentDialog() const {
return m_parentDialog;
}
private:
- friend class BtConfigDialog;
- BtConfigDialog* m_parentDialog;
-
+ BtConfigDialog *m_parentDialog;
};
diff --git a/src/frontend/bookshelfmanager/btinstallmgr.cpp b/src/frontend/bookshelfmanager/btinstallmgr.cpp
index ace804f..756fcae 100644
--- a/src/frontend/bookshelfmanager/btinstallmgr.cpp
+++ b/src/frontend/bookshelfmanager/btinstallmgr.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,7 +10,7 @@
#include "frontend/bookshelfmanager/btinstallmgr.h"
#include "backend/managers/cswordbackend.h"
-#include "frontend/bookshelfmanager/instbackend.h"
+#include "backend/btinstallbackend.h"
#include <QDebug>
#include <QList>
#include <QObject>
@@ -25,8 +25,9 @@
using namespace sword;
BtInstallMgr::BtInstallMgr()
- : InstallMgr(instbackend::configPath().toLatin1(), this),
- m_firstCallOfPreStatus(true) { //use this class also as status reporter
+ : InstallMgr(BtInstallBackend::configPath().toLatin1(), this),
+ m_totalBytes(1), m_completedBytes(0), m_firstCallOfPreStatus(true)
+{ //use this class also as status reporter
qDebug() << "BtInstallMgr::BtInstallMgr";
this->setFTPPassive(true);
}
diff --git a/src/frontend/bookshelfmanager/btinstallmgr.h b/src/frontend/bookshelfmanager/btinstallmgr.h
index 7eff1ae..7d39440 100644
--- a/src/frontend/bookshelfmanager/btinstallmgr.h
+++ b/src/frontend/bookshelfmanager/btinstallmgr.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,53 +21,42 @@
#include <ftptrans.h>
-class CSwordBackend;
-
-typedef QList<sword::InstallSource*> InstallSourceList;
-
/**
* Our own reimplementation to provide installation and status bar updates.
*/
class BtInstallMgr : public QObject, public sword::InstallMgr, public sword::StatusReporter {
Q_OBJECT
public:
-
BtInstallMgr();
- virtual ~BtInstallMgr();
-
- /**
- * Refreshing the source should be cancellable (othewise it might freeze the app if there is
- * for example something wrong with the network).
- */
- void slotRefreshCanceled();
+ ~BtInstallMgr();
/** Re-implemented from sword::InstallMgr. */
- virtual bool isUserDisclaimerConfirmed() const;
+ bool isUserDisclaimerConfirmed() const;
+
+ signals:
+ /** Download status. Percent of total and file.*/
+ void percentCompleted(const int total, const int file);
+ void downloadStarted();
protected:
- /* Reimplementations of methods in StatusReporter */
/**
- * Gets the total and current file status, emits the signal with those values as percents.
+ Reimplementation of sword::StatusReporter::statusUpdate().
*/
- virtual void statusUpdate(double dltotal, double dlnow);
+ void statusUpdate(double dltotal, double dlnow);
+
/**
+ * Reimplementation of sword::StatusReporter::preStatus().
+ * \warning This method is not always called before statusUpdate().
* Called before starting to download each file of the module package.
* The sword message is not i18n'ed, it's in the form "Downloading (1 of 6): nt.bzs".
* This function is not utilized in the UI ATM.
*/
- virtual void preStatus(long totalBytes, long completedBytes, const char *message);
+ void preStatus(long totalBytes, long completedBytes, const char *message);
+ private:
long m_totalBytes;
long m_completedBytes;
-
- private:
bool m_firstCallOfPreStatus;
-
- signals:
- /** Download status. Percent of total and file.*/
- void percentCompleted( const int, const int);
- void downloadStarted();
};
-
#endif
diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
index b261305..f0547b8 100644
--- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
+++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
@@ -2,21 +2,18 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
-#include <QDialogButtonBox>
#include "backend/config/cbtconfig.h"
#include "backend/managers/cswordbackend.h"
#include "frontend/bookshelfmanager/indexpage/btindexpage.h"
#include "frontend/bookshelfmanager/installpage/btinstallpage.h"
#include "frontend/bookshelfmanager/removepage/btremovepage.h"
-#include "util/cpointers.h"
-#include "util/dialogutil.h"
static BtModuleManagerDialog *m_staticModuleManagerDialog = 0;
@@ -48,13 +45,6 @@ BtModuleManagerDialog::BtModuleManagerDialog(QWidget* parent)
slotChangePage(0);
- // Dialog button (Close)
- QDialogButtonBox* bbox = new QDialogButtonBox(this);
- bbox->addButton(QDialogButtonBox::Close);
- util::prepareDialogBox(bbox);
- addButtonBox(bbox);
- connect(bbox, SIGNAL(rejected()), SLOT(close()));
-
loadDialogSettings();
}
diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
index c51efd2..0392cc2 100644
--- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
+++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -44,7 +44,7 @@ class BtModuleManagerDialog : public BtConfigDialog {
//signals:
-// void swordSetupChanged();
+// void swordSetupChanged();
};
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
index e326641..14aecb9 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
@@ -2,14 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h"
-#include <boost/scoped_ptr.hpp>
+#include <QSharedPointer>
#include <QComboBox>
#include <QDir>
#include <QFileInfo>
@@ -25,7 +25,7 @@
#include <QProgressDialog>
#include <QApplication>
#include <QDebug>
-#include "frontend/bookshelfmanager/instbackend.h"
+#include "backend/btinstallbackend.h"
#include "util/dialogutil.h"
const QString PROTO_FILE( QObject::tr("Local") ); //Local path
@@ -102,11 +102,10 @@ void CSwordSetupInstallSourcesDialog::slotOk() {
//BTInstallMgr iMgr;
//sword::InstallSource is = BTInstallMgr::Tool::RemoteConfig::source( &iMgr, m_captionEdit->text() );
- sword::InstallSource is = instbackend::source(m_captionEdit->text());
+ sword::InstallSource is = BtInstallBackend::source(m_captionEdit->text());
if ( (QString)is.caption.c_str() == m_captionEdit->text() ) { //source already exists
util::showInformation( this, tr( "Error" ),
- /** \bug Double space in the following string: */
- tr("A source with this caption already exists. Please provide a different caption."));
+ tr("A source with this caption already exists. Please provide a different caption."));
return;
}
@@ -177,17 +176,15 @@ void CSwordSetupInstallSourcesDialog::slotGetListClicked() {
qApp->processEvents();
qWarning() << "Start downloading the list of sources";
int ret = iMgr.refreshRemoteSourceConfiguration();
- bool success = false;
+
if ( !ret ) { //make sure the sources were updated sucessfully
qDebug() << "download succeeded";
- success = true;
m_progressDialog->setValue(100); //make sure the dialog closes
m_remoteListAdded = true;
accept();
}
else {
qWarning("InstallMgr: getting remote list returned an error.");
- success = false;
}
delete m_progressDialog;
m_progressDialog = 0;
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
index 12df221..e69e9a9 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
index 984700c..026aad5 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,20 +19,20 @@
#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
-#include "frontend/cmoduleindexdialog.h"
+#include "frontend/btmoduleindexdialog.h"
#include "util/directory.h"
-#include "util/cpointers.h"
#include "util/cresmgr.h"
#include "util/tool.h"
-BtIndexPage::BtIndexPage()
- : BtConfigPage() {
+BtIndexPage::BtIndexPage(QWidget *parent)
+ : BtConfigPage(parent)
+{
namespace DU = util::directory;
- QVBoxLayout *vboxLayout;
+ Q_ASSERT(qobject_cast<QVBoxLayout*>(layout()) != 0);
+ QVBoxLayout *vboxLayout = static_cast<QVBoxLayout*>(layout());
QHBoxLayout *hboxLayout;
- vboxLayout = new QVBoxLayout(this);
m_autoDeleteOrphanedIndicesBox = new QCheckBox(this);
m_autoDeleteOrphanedIndicesBox->setToolTip(tr("If selected, those indexes which have no corresponding work will be deleted when BibleTime starts"));
@@ -75,22 +75,20 @@ BtIndexPage::BtIndexPage()
// connect our signals/slots
connect(m_createButton, SIGNAL(clicked()), this, SLOT(createIndices()));
connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deleteIndices()));
- connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged()));
+ connect(CSwordBackend::instance(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged()));
populateModuleList();
}
BtIndexPage::~BtIndexPage() {
CBTConfig::set( CBTConfig::autoDeleteOrphanedIndices, m_autoDeleteOrphanedIndicesBox->isChecked() );
-
-}
-QString BtIndexPage::label() {
- return tr("Create new search indexes and delete created indexes for the installed works.");
}
-QString BtIndexPage::iconName() {
- return CResMgr::bookshelfmgr::indexpage::icon;
+
+const QIcon &BtIndexPage::icon() const {
+ return util::directory::getIcon(CResMgr::bookshelfmgr::indexpage::icon);
}
-QString BtIndexPage::header() {
+
+QString BtIndexPage::header() const {
return tr("Search Indexes");
}
@@ -114,7 +112,7 @@ void BtIndexPage::populateModuleList() {
- const QList<CSwordModuleInfo*> &modules(CPointers::backend()->moduleList());
+ const QList<CSwordModuleInfo*> &modules(CSwordBackend::instance()->moduleList());
for (MLCI it(modules.begin()); it != modules.end(); ++it) {
QTreeWidgetItem* item = 0;
@@ -138,11 +136,11 @@ void BtIndexPage::populateModuleList() {
/** Creates indices for selected modules if no index currently exists */
void BtIndexPage::createIndices() {
bool indicesCreated = false;
- QList<CSwordModuleInfo*> moduleList;
+ QList<const CSwordModuleInfo*> moduleList;
for (int i = 0; i < m_modsWithoutIndices->childCount(); i++) {
if (m_modsWithoutIndices->child(i)->checkState(0) == Qt::Checked) {
- CSwordModuleInfo* module = CPointers::backend()->findModuleByName(m_modsWithoutIndices->child(i)->text(0).toUtf8());
+ CSwordModuleInfo* module = CSwordBackend::instance()->findModuleByName(m_modsWithoutIndices->child(i)->text(0).toUtf8());
if (module) {
moduleList.append( module );
indicesCreated = true;
@@ -152,7 +150,7 @@ void BtIndexPage::createIndices() {
//Shows the progress dialog
if (indicesCreated) {
- CModuleIndexDialog::getInstance()->indexAllModules( moduleList );
+ BtModuleIndexDialog::indexAllModules(moduleList);
populateModuleList();
}
}
@@ -163,7 +161,7 @@ void BtIndexPage::deleteIndices() {
for (int i = 0; i < m_modsWithIndices->childCount(); i++) {
if (m_modsWithIndices->child(i)->checkState(0) == Qt::Checked) {
- CSwordModuleInfo* module = CPointers::backend()->findModuleByName(m_modsWithIndices->child(i)->text(0).toUtf8());
+ CSwordModuleInfo* module = CSwordBackend::instance()->findModuleByName(m_modsWithIndices->child(i)->text(0).toUtf8());
if (module) {
module->deleteIndex();
indicesDeleted = true;
@@ -177,27 +175,6 @@ void BtIndexPage::deleteIndices() {
}
}
-void BtIndexPage::deleteOrphanedIndices() {
- QDir dir(CSwordModuleInfo::getGlobalBaseIndexLocation());
- dir.setFilter(QDir::Dirs);
- CSwordModuleInfo* module;
-
- for (unsigned int i = 0; i < dir.count(); i++) {
- if (dir[i] != "." && dir[i] != "..") {
- if ( (module = CPointers::backend()->findModuleByName(dir[i])) ) { //mod exists
- if (!module->hasIndex()) { //index files found, but wrong version etc.
- CSwordModuleInfo::deleteIndexForModule( dir[i] );
- }
- }
- else { //no module exists
- if (CBTConfig::get( CBTConfig::autoDeleteOrphanedIndices ) ) {
- CSwordModuleInfo::deleteIndexForModule( dir[i] );
- }
- }
- }
- }
-}
-
void BtIndexPage::slotSwordSetupChanged() {
populateModuleList();
}
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.h b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
index 795cc0b..89a7e35 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.h
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -26,20 +26,14 @@ class BtIndexPage : public BtConfigPage {
Q_OBJECT
public:
- /**
- * Constructor
- */
- BtIndexPage();
-
- /**
- * Destructor
- */
+ BtIndexPage(QWidget *parent = 0);
~BtIndexPage();
- // BtConfigPage methods
- QString header();
- QString iconName();
- QString label();
+ /** Reimplemented from BtConfigPage. */
+ virtual QString header() const;
+
+ /** Reimplemented from BtConfigPage. */
+ virtual const QIcon &icon() const;
public slots:
void slotSwordSetupChanged();
@@ -63,13 +57,6 @@ class BtIndexPage : public BtConfigPage {
*/
void deleteIndices();
- public:
- /**
- * Deletes orphaned indices if the autoDeleteOrphanedIndices is true
- * Always deletes indices of existing modules where hasIndex() returns false
- */
- static void deleteOrphanedIndices();
-
private:
QCheckBox *m_autoDeleteOrphanedIndicesBox;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
index 8fd87ec..01ca55b 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
@@ -1,127 +1,83 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2009 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
*
**********/
#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h"
-#include <QBrush>
-#include <QDebug>
-#include <QList>
-#include <QPushButton>
-#include <QString>
-#include <QTreeWidgetItem>
-#include <QWidget>
-#include "backend/btmoduletreeitem.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "frontend/cmodulechooserdialog.h"
+#include <QAction>
+#include <QHeaderView>
+#include <QToolButton>
+#include "backend/bookshelfmodel/btbookshelffiltermodel.h"
+#include "frontend/btbookshelfview.h"
+#include "util/tool.h"
-BtInstallModuleChooserDialog::BtInstallModuleChooserDialog(QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*>* empty)
- : CModuleChooserDialog(parent, title, label, empty) {
- qDebug() << "BtInstallModuleChooserDialog::BtInstallModuleChooserDialog start";
- init();
- okButton()->setText(tr("Install"));
- m_nameList = QStringList();
+namespace {
+const QString groupingOrderKey("GUI/BookshelfManager/InstallConfirmDialog/grouping");
}
-// Do nothing, the tree is initialized outside this class.
-void BtInstallModuleChooserDialog::initModuleItem(BTModuleTreeItem*, QTreeWidgetItem*) {}
-
-void BtInstallModuleChooserDialog::initModuleItem(QString name, QTreeWidgetItem* sourceItem) {
- /// \todo Use new bookshelf model instead
- /// \bug Valgrind reports memory leak:
- QTreeWidgetItem* moduleItem = new QTreeWidgetItem(sourceItem);
- moduleItem->setText(0, name);
- moduleItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
- moduleItem->setCheckState(0, Qt::Checked);
+BtInstallModuleChooserDialog::BtInstallModuleChooserDialog(const BtBookshelfTreeModel::Grouping &g,
+ QWidget *parent,
+ Qt::WindowFlags flags)
+ : BtModuleChooserDialog(parent, flags), m_shown(false)
+{
+ resize(550, 340);
- // prevent double items
- if (m_nameList.contains(name)) {
- qDebug() << "item already in list:" << name;
- //moduleItem->setCheckState(0, Qt::Unchecked);
- QBrush bg(Qt::red);
- moduleItem->setBackground(0, bg);
- //find and change the other offending items
- foreach (QTreeWidgetItem* doubleItem, treeWidget()->findItems(name, Qt::MatchFixedString | Qt::MatchCaseSensitive | Qt::MatchRecursive, 0)) {
- //doubleItem->setCheckState(0, Qt::Unchecked);
- //qDebug() << "CInstallModuleChooserDialog::initModuleItem" << doubleItem;
- doubleItem->setBackground(0, bg);
- }
- m_doubleCheckedModules[name] = true;
- enableOk(false);
+ // Read grouping order from settings or the default from argument:
+ BtBookshelfTreeModel::Grouping groupingOrder(false);
+ if (!groupingOrder.loadFrom(groupingOrderKey)) {
+ groupingOrder = g;
}
- m_nameList << name;
-}
-void BtInstallModuleChooserDialog::slotItemChecked(QTreeWidgetItem* item, int column) {
- QString moduleName = item->text(0);
- qDebug() << "BtInstallModuleChooserDialog::slotItemChecked start";
- // handle only non-toplevel items which has duplicates and where the first column was changed
- if (item->parent() && column == 0 && (findModuleItemsByName(moduleName).count() > 1)) {
- //prevent handling when the color is changed
- if (item->data(1, Qt::UserRole).toBool() == false) {
- qDebug() << "was not updating";
- item->setData(1, Qt::UserRole, true);
- }
- else {
- qDebug() << "was updating";
- item->setData(1, Qt::UserRole, false);
- return;
- }
+ BtInstallModuleChooserDialogModel *treeModel;
+ treeModel = new BtInstallModuleChooserDialogModel(groupingOrder, this);
+ connect(treeModel, SIGNAL(groupingOrderChanged(BtBookshelfTreeModel::Grouping)),
+ this, SLOT(slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping&)));
- QList<QTreeWidgetItem*> doubleNameItems = findModuleItemsByName(moduleName);
- QList<QTreeWidgetItem*> doubleCheckedItems;
- foreach (QTreeWidgetItem* nItem, doubleNameItems) {
- if (nItem->checkState(0) == Qt::Checked) {
- doubleCheckedItems << nItem;
- }
- }
+ m_bookshelfModel = new BtBookshelfModel(this);
+ bookshelfWidget()->postFilterModel()->setShowShown(true);
+ bookshelfWidget()->setTreeModel(treeModel);
+ bookshelfWidget()->setSourceModel(m_bookshelfModel);
+ bookshelfWidget()->showHideAction()->setVisible(false);
+ bookshelfWidget()->showHideButton()->hide();
+ bookshelfWidget()->treeView()->header()->show();
- if (doubleCheckedItems.count() > 1) {
- enableOk(false);
- // color the items
- qDebug() << "there were more than 1 item of the name" << moduleName;
- foreach (QTreeWidgetItem* i, doubleNameItems) {
- QBrush bg(Qt::red);
- i->setBackground(0, bg);
- }
- m_doubleCheckedModules[moduleName] = true;
- }
- else if (doubleCheckedItems.count() == 1) {
- qDebug() << "there were 1 checked items of the name" << moduleName;
- // uncolor the items
- foreach (QTreeWidgetItem* i, doubleNameItems) {
- i->setBackground(0, i->parent()->background(0));
- }
- m_doubleCheckedModules.remove(moduleName);
- if (m_doubleCheckedModules.count() == 0) {
- enableOk(true);
- }
- }
- }
+ retranslateUi();
}
-QList<QTreeWidgetItem*> BtInstallModuleChooserDialog::findModuleItemsByName(QString name) {
- qDebug() << "BtInstallModuleChooserDialog::findModuleItemsByName:" << name << treeWidget()->topLevelItemCount();
- QList<QTreeWidgetItem*> doubleNamedAllItems = treeWidget()->findItems(name, Qt::MatchFixedString | Qt::MatchCaseSensitive | Qt::MatchRecursive);
- //qDebug() << "doubleNamedAllItems: " << doubleNamedAllItems.count();
- QList<QTreeWidgetItem*> doubleNamedModuleItems;
- foreach (QTreeWidgetItem* item, doubleNamedAllItems) {
- //qDebug() << "item:" << item;
- if (item->parent()) {
- doubleNamedModuleItems << item;
- }
- }
- //qDebug() << "module items:" << doubleNamedModuleItems.count();
- return doubleNamedModuleItems;
+void BtInstallModuleChooserDialog::addModuleItem(CSwordModuleInfo *module,
+ const QString &sourceName)
+{
+ module->setProperty("installSourceName", sourceName);
+ m_bookshelfModel->addModule(module);
+}
+
+void BtInstallModuleChooserDialog::retranslateUi() {
+ setWindowTitle(tr("Install/Update works?"));
+ util::tool::initExplanationLabel(
+ label(), QString::null,
+ tr("Do you really want to install these works?") + "<br/><br/><small>" +
+ tr("Only one version of a work can be installed at the same time. Select only "
+ "one if there are items marked with red.") + "</small>");
+}
+
+void BtInstallModuleChooserDialog::showEvent(QShowEvent *event) {
+ Q_UNUSED(event);
+
+ if (m_shown) return;
+ bookshelfWidget()->treeView()->expandAll();
+ bookshelfWidget()->treeView()->header()->resizeSections(QHeaderView::ResizeToContents);
+ m_shown = true;
}
-void BtInstallModuleChooserDialog::enableOk(bool enabled) {
- qDebug() << "BtInstallModuleChooserDialog::enableOk" << enabled;
- okButton()->setEnabled(enabled);
+void BtInstallModuleChooserDialog::slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g) {
+ g.saveTo(groupingOrderKey);
}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
index 06144ff..070df6f 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
@@ -1,51 +1,55 @@
/*********
*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
*
**********/
#ifndef BTINSTALLMODULECHOOSERDIALOG_H
#define BTINSTALLMODULECHOOSERDIALOG_H
-#include "frontend/cmodulechooserdialog.h"
+#include "frontend/btmodulechooserdialog.h"
-#include <QList>
-#include <QMap>
-#include <QObject>
-#include <QString>
+#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h"
-class BTModuleTreeItem;
-class QWidget;
-class QTreeWidgetItem;
+class BtBookshelfModel;
+class BtInstallModuleChooserDialogModel;
+class CSwordModuleInfo;
/**
* Confirmation dialog for installation. Lets the user
* uncheck modules from the list.
*/
-class BtInstallModuleChooserDialog : public CModuleChooserDialog {
- Q_OBJECT
-
+class BtInstallModuleChooserDialog: public BtModuleChooserDialog {
+ Q_OBJECT
public:
- BtInstallModuleChooserDialog(QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*>* empty);
+ BtInstallModuleChooserDialog(const BtBookshelfTreeModel::Grouping &g,
+ QWidget *parent = 0,
+ Qt::WindowFlags flags = 0);
- void initModuleItem(QString name, QTreeWidgetItem* sourceItem);
- void enableOk(bool enabled);
+ inline const QSet<CSwordModuleInfo*> &checkedModules() const {
+ return bookshelfWidget()->treeModel()->checkedModules();
+ }
- public slots:
- void slotItemChecked(QTreeWidgetItem* item, int column);
+ void addModuleItem(CSwordModuleInfo *module, const QString &sourceName);
protected:
- virtual void initModuleItem(BTModuleTreeItem*, QTreeWidgetItem*);
+ void retranslateUi();
+ void showEvent(QShowEvent *event);
+
+ protected slots:
+ void slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g);
- QList<QTreeWidgetItem*> findModuleItemsByName(QString name);
private:
- QStringList m_nameList;
- QMap<QString, bool> m_doubleCheckedModules;
+ BtBookshelfModel *m_bookshelfModel;
+ bool m_shown;
};
-#endif
+#endif // BTINSTALLMODULECHOOSERDIALOG_H
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp
new file mode 100644
index 0000000..880ea6a
--- /dev/null
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp
@@ -0,0 +1,136 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h"
+
+#include <QBrush>
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/cswordbackend.h"
+
+
+#define MODULEPOINTERFORINDEX(i) static_cast<CSwordModuleInfo *>(\
+ BtBookshelfTreeModel::data((i), BtBookshelfModel::ModulePointerRole).value<void*>())
+
+BtInstallModuleChooserDialogModel::BtInstallModuleChooserDialogModel(
+ const Grouping &grouping,
+ QObject *parent)
+ : BtBookshelfTreeModel(grouping, parent), m_dataChangedFired(false)
+{
+ setDefaultChecked(BtBookshelfTreeModel::CHECKED);
+ setCheckable(true);
+ connect(this, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
+ this, SLOT(parentDataChanged(QModelIndex,QModelIndex)),
+ Qt::DirectConnection);
+}
+
+BtInstallModuleChooserDialogModel::~BtInstallModuleChooserDialogModel() {
+ // Intentionally empty
+}
+
+QVariant BtInstallModuleChooserDialogModel::data(const QModelIndex &i, int role) const {
+ switch (role) {
+ case Qt::BackgroundRole:
+ if (isMulti(i)) return QBrush(Qt::red);
+ return BtBookshelfTreeModel::data(i, role);
+ case Qt::ForegroundRole:
+ if (isMulti(i)) return QBrush(Qt::white);
+ return BtBookshelfTreeModel::data(i, role);
+ case Qt::DisplayRole:
+ switch (i.column()) {
+ case 0:
+ return BtBookshelfTreeModel::data(i, role);
+ case 1:
+ {
+ CSwordModuleInfo *module = MODULEPOINTERFORINDEX(index(i.row(), 0, i.parent()));
+ if (module != 0) return module->property("installSourceName");
+ break;
+ }
+ case 2:
+ {
+ CSwordModuleInfo *module = MODULEPOINTERFORINDEX(index(i.row(), 0, i.parent()));
+ if (module == 0) break;
+ CSwordBackend *b = CSwordBackend::instance();
+ CSwordModuleInfo *imodule = b->findModuleByName(module->name());
+ if (imodule == 0) {
+ return module->config(CSwordModuleInfo::ModuleVersion);
+ } else {
+ return imodule->config(CSwordModuleInfo::ModuleVersion)
+ + " => "
+ + module->config(CSwordModuleInfo::ModuleVersion);
+ }
+ }
+ default: break;
+ }
+ default:
+ if (i.column() == 0) return BtBookshelfTreeModel::data(i, role);
+ }
+
+ return QVariant();
+}
+
+int BtInstallModuleChooserDialogModel::columnCount(const QModelIndex &parent) const {
+ Q_UNUSED(parent);
+
+ return 3;
+}
+
+QVariant BtInstallModuleChooserDialogModel::headerData(int section,
+ Qt::Orientation orientation,
+ int role) const
+{
+ if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
+ switch (section) {
+ case 0: return tr("Work");
+ case 1: return tr("Installation source");
+ case 2: return tr("Version");
+ default: break;
+ }
+ }
+
+ return QVariant();
+}
+
+void BtInstallModuleChooserDialogModel::parentDataChanged(const QModelIndex &topLeft,
+ const QModelIndex &bottomRight)
+{
+ Q_UNUSED(topLeft);
+ Q_UNUSED(bottomRight);
+
+ if (m_dataChangedFired) return;
+ m_dataChangedFired = true;
+ resetData();
+ m_dataChangedFired = false;
+}
+
+bool BtInstallModuleChooserDialogModel::isMulti(CSwordModuleInfo *m1) const {
+ if (m1 != 0 && checkedModules().contains(m1)) {
+ Q_FOREACH(CSwordModuleInfo *m2, m_modules.keys()) {
+ if (m1 != m2 && checkedModules().contains(m2) && m1->name() == m2->name()) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool BtInstallModuleChooserDialogModel::isMulti(const QModelIndex &i) const {
+ if (!i.isValid()) return false;
+
+ if (!hasChildren(i)) {
+ return isMulti(MODULEPOINTERFORINDEX(index(i.row(), 0, i.parent())));
+ } else {
+ for (int row = 0; row < rowCount(i); row++) {
+ if (isMulti(i.child(row, 0))) return true;
+ }
+ }
+ return false;
+}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h
new file mode 100644
index 0000000..6120fa8
--- /dev/null
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h
@@ -0,0 +1,44 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BTINSTALLMODULECHOOSERDIALOGMODEL_H
+#define BTINSTALLMODULECHOOSERDIALOGMODEL_H
+
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+
+#include <QMap>
+
+
+class BtInstallModuleChooserDialogModel: public BtBookshelfTreeModel {
+ Q_OBJECT
+ public:
+ BtInstallModuleChooserDialogModel(const Grouping &grouping, QObject *parent = 0);
+ ~BtInstallModuleChooserDialogModel();
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+
+ private slots:
+ void parentDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+
+ private:
+ bool isMulti(CSwordModuleInfo *module) const;
+ bool isMulti(const QModelIndex &index) const;
+
+ private:
+ QMap<QString, int> m_nameCounts;
+ bool m_dataChangedFired;
+};
+
+#endif // BTINSTALLMODULECHOOSERDIALOGMODEL_H
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
index b71599a..d3bac59 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
@@ -2,63 +2,60 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/bookshelfmanager/installpage/btinstallpage.h"
-#include <QAction>
#include <QApplication>
-#include <QButtonGroup>
#include <QComboBox>
-#include <QDialog>
-#include <QFileInfo>
+#include <QGroupBox>
#include <QHBoxLayout>
#include <QHeaderView>
#include <QLabel>
-#include <QMessageBox>
-#include <QProgressBar>
-#include <QProgressDialog>
#include <QPushButton>
-#include <QSpacerItem>
-#include <QStackedWidget>
-#include <QTabBar>
-#include <QTimer>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
+#include <QSettings>
+#include <QSharedPointer>
+#include <QStackedLayout>
#include <QToolButton>
-#include <QVBoxLayout>
-#include <QWidget>
#include "backend/config/cbtconfig.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/managers/cswordbackend.h"
-#include "frontend/bookshelfmanager/btconfigdialog.h"
-#include "frontend/bookshelfmanager/btinstallmgr.h"
+#include "backend/btinstallbackend.h"
#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
#include "frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h"
+#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h"
+#include "frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h"
#include "frontend/bookshelfmanager/installpage/btinstallpathdialog.h"
#include "frontend/bookshelfmanager/installpage/btinstallprogressdialog.h"
-#include "frontend/bookshelfmanager/installpage/btsourcewidget.h"
-#include "frontend/bookshelfmanager/installpage/btsourcearea.h"
-#include "frontend/bookshelfmanager/instbackend.h"
-#include "frontend/cmodulechooserdialog.h"
-#include "util/directory.h"
-#include "util/cpointers.h"
+#include "frontend/btbookshelfview.h"
#include "util/cresmgr.h"
+#include "util/dialogutil.h"
+#include "util/directory.h"
+#include "util/tool.h"
+
-// Sword includes:
-#include <swversion.h>
+namespace {
+const QString groupingOrderKey ("GUI/BookshelfManager/InstallPage/grouping");
+const QString headerStateKey ("GUI/BookshelfManager/InstallPage/headerState");
+const QString selectedModuleKey("GUI/BookshelfManager/InstallPage/selectedModule");
+} // anonymous namespace
// *********************************************************
// *********** Config dialog page: Install/Update **********
// *********************************************************
-BtInstallPage::BtInstallPage()
- : BtConfigPage() {
- qDebug() << "BtInstallPage::BtInstallPage() start";
+BtInstallPage::BtInstallPage(QWidget *parent)
+ : BtConfigPage(parent)
+ , m_groupingOrder(groupingOrderKey)
+ , m_modulesSelected(0)
+ , m_modulesSelectedSources(0)
+{
+ // Read settings:
+ m_headerState = CBTConfig::getConfig()->value(headerStateKey).toByteArray();
+
+ // Initialize widgets:
initView();
initConnections();
}
@@ -75,68 +72,105 @@ QString BtInstallPage::selectedInstallPath() {
void BtInstallPage::initView() {
namespace DU = util::directory;
- qDebug() << "void BtInstallPage::initView() start";
- QVBoxLayout *mainLayout = new QVBoxLayout(this);
-
- // installation path chooser
- QHBoxLayout* pathLayout = new QHBoxLayout();
- // beautify the layout
- int top;
- int bottom;
- int left;
- int right;
- pathLayout->getContentsMargins(&left, &top, &right, &bottom);
- pathLayout->setContentsMargins(left, top + 7, right, bottom + 7 );
- QLabel* pathLabel = new QLabel(tr("Install folder:"));
- m_pathCombo = new QComboBox();
+ // Warning label:
+
+ m_warningLabel = util::tool::explanationLabel(this, tr("WARNING!!!"),
+ tr("If you live in a persecuted country and don't want to risk "
+ "detection don't use remote sources."));
+
+ // Source chooser:
+ m_sourceGroupBox = new QGroupBox(tr("Select installation &source:"), this);
+ m_sourceGroupBox->setFlat(true);
+
+ m_sourceComboBox = new QComboBox(this);
+ m_sourceComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
+ initSourcesCombo();
+
+ m_sourceAddButton = new QPushButton(tr("&Add..."));
+ m_sourceAddButton ->setToolTip(tr("Add new source"));
+ m_sourceAddButton ->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::add_icon));
+
+ m_sourceDeleteButton = new QPushButton(tr("&Delete..."));
+ m_sourceDeleteButton->setToolTip(tr("Delete this source"));
+ m_sourceDeleteButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::delete_icon));
+
+ QHBoxLayout *sourceChooserLayout = new QHBoxLayout();
+ sourceChooserLayout->setContentsMargins(0, 0, 0, 0);
+ sourceChooserLayout->addWidget(m_sourceComboBox, 1);
+ sourceChooserLayout->addWidget(m_sourceAddButton);
+ sourceChooserLayout->addWidget(m_sourceDeleteButton);
+ m_sourceGroupBox->setLayout(sourceChooserLayout);
+
+ // Works chooser:
+ m_worksGroupBox = new QGroupBox(tr("Select &works to install:"), this);
+ m_worksGroupBox->setFlat(true);
+ m_worksLayout = new QStackedLayout();
+ m_worksGroupBox->setLayout(m_worksLayout);
+ slotSourceIndexChanged(m_sourceComboBox->currentIndex());
+
+ // Installation path chooser:
+ m_installGroupBox = new QGroupBox(this);
+ m_installGroupBox->setFlat(true);
+ retranslateInstallGroupBox();
+
+ m_pathLabel = new QLabel(tr("Install &folder:"));
+ m_pathCombo = new QComboBox(this);
m_pathCombo->setMinimumContentsLength(20);
m_pathCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
m_pathCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
m_pathCombo->setToolTip(tr("The folder where the new works will be installed"));
m_pathCombo->view()->setTextElideMode(Qt::ElideMiddle);
- initPathCombo(); // set the paths and the current path
+ m_pathLabel->setBuddy(m_pathCombo);
+ initPathCombo();
+
m_configurePathButton = new QToolButton(this);
m_configurePathButton->setToolTip(tr("Configure folders where works are installed and found"));
m_configurePathButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::path_icon));
- pathLayout->addWidget(pathLabel);
- pathLayout->addWidget(m_pathCombo);
- pathLayout->addWidget(m_configurePathButton);
- mainLayout->addLayout(pathLayout);
-
- // Source widget
- m_sourceWidget = new BtSourceWidget(this);
- mainLayout->addWidget(m_sourceWidget);
- // Install button
- QHBoxLayout *installButtonLayout = new QHBoxLayout();
- installButtonLayout->setContentsMargins(0, 5, 0, 5);
- QSpacerItem *installButtonSpacer = new QSpacerItem(371, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
- installButtonLayout->addItem(installButtonSpacer);
- m_installButton = new QPushButton(tr("Install..."), this);
+ m_installButton = new QPushButton(tr("&Install..."), this);
m_installButton->setToolTip(tr("Install or update selected works"));
m_installButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::install_icon));
m_installButton->setEnabled(false);
- installButtonLayout->addWidget(m_installButton);
- mainLayout->addLayout(installButtonLayout);
+ QHBoxLayout *pathLayout = new QHBoxLayout();
+ pathLayout->setContentsMargins(0, 0, 0, 0);
+ pathLayout->addWidget(m_pathLabel);
+ pathLayout->addWidget(m_pathCombo);
+ pathLayout->addWidget(m_configurePathButton);
+ pathLayout->addWidget(m_installButton);
+ m_installGroupBox->setLayout(pathLayout);
+
+ Q_ASSERT(qobject_cast<QVBoxLayout*>(layout()) != 0);
+ QVBoxLayout *mainLayout = static_cast<QVBoxLayout*>(layout());
+ mainLayout->addWidget(m_warningLabel);
+ mainLayout->addWidget(m_sourceGroupBox);
+ mainLayout->addWidget(m_worksGroupBox, 1);
+ mainLayout->addWidget(m_installGroupBox);
}
void BtInstallPage::initConnections() {
- qDebug() << "void BtInstallPage::initConnections() start";
- QObject::connect(m_pathCombo, SIGNAL(activated(const QString&)), this , SLOT(slotPathChanged(const QString&)));
- QObject::connect(m_configurePathButton, SIGNAL(clicked()), this, SLOT(slotEditPaths()));
- QObject::connect(m_installButton, SIGNAL(clicked()), m_sourceWidget, SLOT(slotInstall()) );
-
- QObject::connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), this, SLOT(slotSwordSetupChanged()));
- //source widget has its own connections, not here
+ connect(m_sourceComboBox, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(slotSourceIndexChanged(int)));
+ connect(m_sourceAddButton, SIGNAL(clicked()),
+ this, SLOT(slotSourceAdd()));
+ connect(m_sourceDeleteButton, SIGNAL(clicked()),
+ this, SLOT(slotSourceDelete()));
+ connect(m_installButton, SIGNAL(clicked()),
+ this, SLOT(slotInstall()));
+ connect(m_pathCombo, SIGNAL(activated(const QString&)),
+ this , SLOT(slotPathChanged(const QString&)));
+ connect(m_configurePathButton, SIGNAL(clicked()),
+ this, SLOT(slotEditPaths()));
+ connect(CSwordBackend::instance(),
+ SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)),
+ this, SLOT(slotSwordSetupChanged()));
}
void BtInstallPage::initPathCombo() {
- qDebug() << "void BtInstallPage::initPathCombo() start";
//populate the combo list
m_pathCombo->clear();
- QStringList targets = instbackend::targetList();
+ QStringList targets = BtInstallBackend::targetList();
for (QStringList::iterator it = targets.begin(); it != targets.end(); ++it) {
// Add the path only if it's writable
if ((*it).isEmpty()) continue;
@@ -154,43 +188,252 @@ void BtInstallPage::initPathCombo() {
m_pathCombo->setCurrentIndex(index);
}
+void BtInstallPage::initSourcesCombo() {
+ /// \todo Implement a proper model for this
+
+ m_sourceComboBox->clear();
+ QStringList sourceList = BtInstallBackend::sourceNameList();
+
+ // Add a default entry, the Crosswire main repository
+ if (sourceList.empty()) {
+ /// \todo Open a dialog which asks whether to get list from server and add sources
+ sword::InstallSource is("FTP"); //default return value
+ is.caption = "CrossWire Bible Society";
+ is.source = "ftp.crosswire.org";
+ is.directory = "/pub/sword/raw";
+ // passive ftp is not needed here, it's the default
+
+ BtInstallBackend::addSource(is);
+
+ sourceList = BtInstallBackend::sourceNameList();
+ Q_ASSERT(!sourceList.empty());
+ }
+
+ // Read selected module from config:
+ QString selected = CBTConfig::getConfig()->value(selectedModuleKey).toString();
+
+ // Populate combo box
+ bool selectionOk = false;
+ for (int i = 0; i < sourceList.size(); i++) {
+ m_sourceComboBox->addItem(sourceList.at(i));
+
+ // Select configured item:
+ if (!selectionOk && sourceList.at(i) == selected) {
+ m_sourceComboBox->setCurrentIndex(i);
+ selectionOk = true;
+ }
+ }
+
+ // Set selection, if it wasn't properly configured:
+ if (!selectionOk) {
+ m_sourceComboBox->setCurrentIndex(0);
+ CBTConfig::getConfig()->setValue(selectedModuleKey, sourceList.at(0));
+ }
+}
+
+void BtInstallPage::activateSource(const sword::InstallSource &src) {
+ qDebug() << "Selected source" << src.caption;
+ qApp->setOverrideCursor(Qt::WaitCursor);
+ BtInstallPageWorksWidget *w = m_sourceMap.value(QString(src.caption), 0);
+ if (w == 0) {
+ if (parentDialog() != 0) parentDialog()->setEnabled(false);
+ qApp->processEvents();
+ w = new BtInstallPageWorksWidget(src, m_groupingOrder, this);
+ m_sourceMap.insert(QString(src.caption), w);
+ m_worksLayout->addWidget(w);
+ connect(w->treeModel(), SIGNAL(groupingOrderChanged(BtBookshelfTreeModel::Grouping)),
+ this, SLOT(slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping&)));
+ connect(w->treeModel(), SIGNAL(moduleChecked(CSwordModuleInfo*,bool)),
+ this, SLOT(slotSelectedModulesChanged()));
+ if (parentDialog() != 0) parentDialog()->setEnabled(true);
+ } else {
+ disconnect(w->treeView()->header(), SIGNAL(geometriesChanged()),
+ this, SLOT(slotHeaderChanged()));
+ }
+ m_worksLayout->setCurrentWidget(w);
+ w->treeModel()->setGroupingOrder(m_groupingOrder);
+ w->treeView()->header()->restoreState(m_headerState);
+ connect(w->treeView()->header(), SIGNAL(geometriesChanged()),
+ this, SLOT(slotHeaderChanged()));
+ qApp->restoreOverrideCursor();
+}
+
+void BtInstallPage::retranslateInstallGroupBox() {
+ if (m_modulesSelected > 0) {
+ m_installGroupBox->setTitle(tr("Start installation of %1 works from %2 sources:")
+ .arg(m_modulesSelected)
+ .arg(m_modulesSelectedSources));
+ } else {
+ m_installGroupBox->setTitle(tr("Start installation:"));
+ }
+}
+
+void BtInstallPage::slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g) {
+ m_groupingOrder = g;
+ m_groupingOrder.saveTo(groupingOrderKey);
+}
+
+void BtInstallPage::slotHeaderChanged() {
+ typedef BtInstallPageWorksWidget IPWW;
+ Q_ASSERT(qobject_cast<IPWW*>(m_worksLayout->currentWidget()) != 0);
+ IPWW *w = static_cast<IPWW*>(m_worksLayout->currentWidget());
+ m_headerState = w->treeView()->header()->saveState();
+ CBTConfig::getConfig()->setValue(headerStateKey, m_headerState);
+}
+
+void BtInstallPage::slotInstall() {
+ qDebug() << "BtInstallPage::slotInstall";
+
+ // check that the destination path is writable, do nothing if not and user doesn't want to continue
+ QDir dir = selectedInstallPath();
+ bool canWrite = true;
+ if (dir.isReadable()) {
+ const QFileInfo fi( dir.canonicalPath() );
+ if (!fi.exists() || !fi.isWritable()) {
+ canWrite = false;
+ }
+ }
+ else {
+ canWrite = false;
+ }
+ if (!canWrite) {
+ const int result = util::showWarning(this, tr("Warning"), tr("The destination directory is not writable or does not exist. Installation will fail unless this has first been fixed."), QMessageBox::Ignore | QMessageBox::Cancel, QMessageBox::Cancel);
+ if (result != QMessageBox::Ignore) {
+ return;
+ }
+ }
+
+ // create the confirmation dialog
+ BtInstallModuleChooserDialog *dlg = new BtInstallModuleChooserDialog(m_groupingOrder, this);
+
+ // Add all checked modules from all tabs:
+ Q_FOREACH (BtInstallPageWorksWidget *w, m_sourceMap.values()) {
+ Q_FOREACH (CSwordModuleInfo *module, w->treeModel()->checkedModules()) {
+ dlg->addModuleItem(module, QString(w->installSource().caption));
+ }
+ }
+
+ if (dlg->exec() == QDialog::Accepted) {
+ QSet<const CSwordModuleInfo*> cm;
+ Q_FOREACH(const CSwordModuleInfo *m, dlg->checkedModules()) {
+ cm.insert(m);
+ }
+
+ if (cm.empty()) return;
+
+ /// \todo first remove all modules which will be updated from the module list
+ // but what modules? all with the same real name? (there may be _n modules...)
+
+ BtModuleManagerDialog *parentDlg = dynamic_cast<BtModuleManagerDialog*>(parentDialog());
+
+ BtInstallProgressDialog *dlg = new BtInstallProgressDialog(cm, selectedInstallPath(), parentDlg);
+
+ if (!parentDlg) qDebug() << "error, wrong parent!";
+
+ m_installButton->setEnabled(false);
+
+ // the progress dialog is now modal, it can be made modeless later.
+ dlg->exec();
+
+ qDebug() << "BtSourceWidget::slotInstallAccepted end";
+ }
+ delete dlg;
+}
+
void BtInstallPage::slotPathChanged(const QString& /*pathText*/) {
CBTConfig::set(CBTConfig::installPathIndex, m_pathCombo->currentIndex( ) );
}
void BtInstallPage::slotEditPaths() {
- qDebug() << "void BtInstallPage::slotEditPaths() start";
-
BtInstallPathDialog* dlg = new BtInstallPathDialog();
int result = dlg->exec();
if (result == QDialog::Accepted) {
//dynamic_cast<BtModuleManagerDialog*>(parentDialog())->slotSwordSetupChanged();
- CPointers::backend()->reloadModules(CSwordBackend::PathChanged);
+ CSwordBackend::instance()->reloadModules(CSwordBackend::PathChanged);
}
}
-// implement the BtConfigPage methods
+void BtInstallPage::slotSourceAdd() {
+ typedef CSwordSetupInstallSourcesDialog SSISD;
-QString BtInstallPage::iconName() {
- return CResMgr::bookshelfmgr::installpage::icon;
+ QSharedPointer<SSISD> dlg(new SSISD());
+ if (dlg->exec() == QDialog::Accepted) {
+ if (!dlg->wasRemoteListAdded()) {
+ sword::InstallSource newSource = dlg->getSource();
+ if ( !((QString)newSource.type.c_str()).isEmpty() ) { // we have a valid source to add
+ BtInstallBackend::addSource(newSource);
+ }
+ initSourcesCombo();
+ for (int i = 0; i < m_sourceComboBox->count(); i++) {
+ if (m_sourceComboBox->itemText(i) == newSource.caption) {
+ m_sourceComboBox->setCurrentIndex(i);
+ break;
+ }
+ }
+ }
+ }
}
-QString BtInstallPage::label() {
- // \todo move the warning to a dialog which is shown when adding a source.
- return tr("Install and update works. Add remote or local sources, refresh them, select the works to be installed/updated and click Install.<br/><b>WARNING:</b> If you live in a persecuted country and don't want to risk detection don't use remote sources.");
+
+void BtInstallPage::slotSourceDelete() {
+ typedef BtInstallPageWorksWidget IPWW;
+
+ int ret = util::showWarning(this, tr("Delete Source?"),
+ tr("Do you really want to delete this source?"),
+ QMessageBox::Yes | QMessageBox::No);
+
+ if (ret == QMessageBox::Yes) {
+ Q_ASSERT(qobject_cast<IPWW*>(m_worksLayout->currentWidget()));
+ IPWW *w = static_cast<IPWW*>(m_worksLayout->currentWidget());
+ w->deleteSource();
+ initSourcesCombo();
+ slotSourceIndexChanged(m_sourceComboBox->currentIndex());
+ delete w;
+ }
}
-QString BtInstallPage::header() {
- return tr("Install/Update");
+
+void BtInstallPage::slotSourceIndexChanged(int index) {
+ if (index < 0) index = 0;
+
+ /// \todo use pointers instead of text
+ QString moduleName = m_sourceComboBox->itemText(index);
+ CBTConfig::getConfig()->setValue(selectedModuleKey, moduleName);
+ activateSource(BtInstallBackend::source(moduleName));
}
-void BtInstallPage::slotSwordSetupChanged() {
- qDebug() << "BtInstallPage::slotSwordSetupChanged";
- initPathCombo();
-// for (int i = 0; i < m_sourceWidget->count(); i++ ) {
-// BtSourceArea* sourceArea = dynamic_cast<BtSourceArea*>(m_sourceWidget->widget(i));
-// Q_ASSERT(sourceArea);
-// sourceArea->createModuleTree();
-// }
+void BtInstallPage::slotSelectedModulesChanged() {
+ m_modulesSelected = 0;
+ m_modulesSelectedSources = 0;
+ Q_FOREACH (BtInstallPageWorksWidget *w, m_sourceMap.values()) {
+ int selected = w->treeModel()->checkedModules().size();
+ if (selected > 0) {
+ m_modulesSelectedSources++;
+ m_modulesSelected += selected;
+ }
+ }
+
+ m_installButton->setEnabled(m_modulesSelected > 0);
+ retranslateInstallGroupBox();
+}
+
+// implement the BtConfigPage methods
+
+const QIcon &BtInstallPage::icon() const {
+ return util::directory::getIcon(CResMgr::bookshelfmgr::installpage::icon);
}
+QString BtInstallPage::header() const {
+ return tr("Install/Update");
+}
+void BtInstallPage::slotSwordSetupChanged() {
+ QString moduleName = m_sourceComboBox->currentText();
+ initSourcesCombo();
+ qDeleteAll(m_sourceMap.values());
+ m_sourceMap.clear();
+ m_sourceComboBox->setCurrentIndex(m_sourceComboBox->findText(moduleName));
+ initPathCombo();
+ m_modulesSelected = 0;
+ m_modulesSelectedSources = 0;
+ retranslateInstallGroupBox();
+}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.h b/src/frontend/bookshelfmanager/installpage/btinstallpage.h
index fde9919..88d1f92 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,29 +12,34 @@
#include "frontend/bookshelfmanager/btconfigdialog.h"
-#include <QString>
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
-// Sword includes:
-#include <installmgr.h>
+namespace sword {
+class InstallSource;
+}
-class BtSourceWidget;
+class BtInstallPageWorksWidget;
class QComboBox;
+class QGroupBox;
class QPushButton;
+class QStackedLayout;
class QToolButton;
/**
* The Install page includes module path chooser, source/module handler and install button.
*/
-class BtInstallPage : public BtConfigPage {
+class BtInstallPage: public BtConfigPage {
Q_OBJECT
+
public:
- BtInstallPage();
+ BtInstallPage(QWidget *parent = 0);
+
+ /** Reimplemented from BtConfigPage. */
+ virtual const QIcon &icon() const;
- // reimplemented from btinstallpage
- QString iconName();
- QString label();
- QString header();
+ /** Reimplemented from BtConfigPage. */
+ virtual QString header() const;
void setInstallEnabled(bool b);
@@ -47,18 +52,46 @@ class BtInstallPage : public BtConfigPage {
void initView();
void initConnections();
void initPathCombo();
+ void initSourcesCombo();
+
+ void activateSource(const sword::InstallSource &src);
+ void retranslateInstallGroupBox();
private slots:
+ void slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g);
+ void slotHeaderChanged();
+ void slotInstall();
void slotPathChanged(const QString& pathText);
void slotEditPaths();
+ void slotSourceAdd();
+ void slotSourceDelete();
+ void slotSourceIndexChanged(int index);
+ void slotSelectedModulesChanged();
private:
+ BtBookshelfTreeModel::Grouping m_groupingOrder;
+ QByteArray m_headerState;
+
+ QMap<QString, BtInstallPageWorksWidget*> m_sourceMap;
+
+ QLabel *m_warningLabel;
+
+ QGroupBox *m_sourceGroupBox;
+ QComboBox *m_sourceComboBox;
+ QPushButton *m_sourceAddButton;
+ QPushButton *m_sourceDeleteButton;
+
+ QGroupBox *m_worksGroupBox;
+ QStackedLayout *m_worksLayout;
+
+ QGroupBox *m_installGroupBox;
+ QLabel *m_pathLabel;
+ QComboBox *m_pathCombo;
+ QToolButton *m_configurePathButton;
+ QPushButton *m_installButton;
- QComboBox* m_pathCombo;
- //QPushButton* m_configurePathButton;
- QToolButton* m_configurePathButton;
- BtSourceWidget* m_sourceWidget;
- QPushButton* m_installButton;
+ unsigned m_modulesSelected;
+ unsigned m_modulesSelectedSources;
};
#endif
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp
new file mode 100644
index 0000000..9aa6743
--- /dev/null
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp
@@ -0,0 +1,87 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "frontend/bookshelfmanager/installpage/btinstallpagemodel.h"
+
+
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/cswordbackend.h"
+
+
+#define MODULEPOINTERFORINDEX(i) static_cast<CSwordModuleInfo *>(\
+ BtBookshelfTreeModel::data((i), BtBookshelfModel::ModulePointerRole).value<void*>())
+
+BtInstallPageModel::BtInstallPageModel(const Grouping &grouping, QObject *parent)
+ : BtBookshelfTreeModel(grouping, parent)
+{
+ setDefaultChecked(BtBookshelfTreeModel::UNCHECKED);
+ setCheckable(true);
+}
+
+BtInstallPageModel::~BtInstallPageModel() {
+ // Intentionally empty
+}
+
+QVariant BtInstallPageModel::data(const QModelIndex &i, int role) const {
+ switch (role) {
+ case Qt::DisplayRole:
+ switch (i.column()) {
+ case 0:
+ return BtBookshelfTreeModel::data(i, role);
+ case 1:
+ {
+ CSwordModuleInfo *module = MODULEPOINTERFORINDEX(index(i.row(), 0, i.parent()));
+ if (module == 0) break;
+ CSwordBackend *b = CSwordBackend::instance();
+ CSwordModuleInfo *imodule = b->findModuleByName(module->name());
+ if (imodule == 0) {
+ return module->config(CSwordModuleInfo::ModuleVersion);
+ } else {
+ return imodule->config(CSwordModuleInfo::ModuleVersion)
+ + " => "
+ + module->config(CSwordModuleInfo::ModuleVersion);
+ }
+ }
+ case 2:
+ {
+ CSwordModuleInfo *module = MODULEPOINTERFORINDEX(index(i.row(), 0, i.parent()));
+ if (module != 0) return module->config(CSwordModuleInfo::Description);
+ }
+ default: break;
+ }
+ default:
+ if (i.column() == 0) return BtBookshelfTreeModel::data(i, role);
+ }
+
+ return QVariant();
+}
+
+int BtInstallPageModel::columnCount(const QModelIndex &parent) const {
+ Q_UNUSED(parent);
+
+ return 3;
+}
+
+QVariant BtInstallPageModel::headerData(int section, Qt::Orientation orientation,
+ int role) const
+{
+ if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
+ switch (section) {
+ case 0: return tr("Work");
+ case 1: return tr("Version");
+ case 2: return tr("Description");
+ default: break;
+ }
+ }
+
+ return QVariant();
+}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h
new file mode 100644
index 0000000..8a02409
--- /dev/null
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h
@@ -0,0 +1,33 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BTINSTALLPAGEMODEL_H
+#define BTINSTALLPAGEMODEL_H
+
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+
+#include <QMap>
+
+
+class BtInstallPageModel: public BtBookshelfTreeModel {
+ Q_OBJECT
+ public:
+ BtInstallPageModel(const Grouping &grouping, QObject *parent = 0);
+ ~BtInstallPageModel();
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+};
+
+#endif // BTINSTALLPAGEMODEL_H
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp
new file mode 100644
index 0000000..6b9fb53
--- /dev/null
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp
@@ -0,0 +1,140 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h"
+
+#include <QApplication>
+#include <QAction>
+#include <QDebug>
+#include <QTimer>
+#include <QToolButton>
+#include "backend/btinstallbackend.h"
+#include "backend/managers/cswordbackend.h"
+#include "frontend/bookshelfmanager/installpage/btinstallpage.h"
+#include "frontend/bookshelfmanager/installpage/btinstallpagemodel.h"
+#include "frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h"
+#include "frontend/btbookshelfview.h"
+#include "util/cresmgr.h"
+#include "util/directory.h"
+
+
+namespace {
+
+/** Filters out already installed modules which can't be updated right now. */
+bool filter(CSwordModuleInfo *mInfo) {
+ typedef CSwordModuleInfo CSMI;
+ typedef sword::SWVersion SV;
+
+ const CSMI *installedModule = CSwordBackend::instance()->findModuleByName(mInfo->name());
+ if (installedModule) {
+ // Already installed, check if it's an update:
+ const SV curVersion(installedModule->config(CSMI::ModuleVersion).toLatin1());
+ const SV newVersion(mInfo->config(CSMI::ModuleVersion).toLatin1());
+ if (curVersion >= newVersion) {
+ return false;
+ }
+ }
+ return true;
+}
+
+}
+
+BtInstallPageWorksWidget::BtInstallPageWorksWidget(
+ const sword::InstallSource &source,
+ const BtBookshelfTreeModel::Grouping &g,
+ BtInstallPage *parent, Qt::WindowFlags flags)
+ : BtBookshelfWidget(parent, flags)
+ , m_source(source)
+ , m_parent(parent)
+ , m_backend(0)
+ , m_myModel(0)
+{
+ namespace DU = util::directory;
+
+ qDebug() << "Creating new BtInstallPageWorksWidget for source" << source.caption;
+
+ setTreeModel(new BtInstallPageModel(g, this));
+
+ treeView()->setHeaderHidden(false);
+ showHideButton()->hide();
+ showHideAction()->setVisible(false);
+
+ m_sourceRefreshButton = new QToolButton(this);
+ m_sourceRefreshButton->setAutoRaise(true);
+ m_sourceRefreshButton ->setToolTip(tr("Refresh the list of works from this source"));
+ m_sourceRefreshButton ->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::refresh_icon));
+ setRightCornerWidget(m_sourceRefreshButton);
+
+ connect(m_sourceRefreshButton, SIGNAL(clicked()),
+ this, SLOT(slotSourceRefresh()));
+
+ // Delayed init, part 1 - disable parent:
+ parent->setEnabled(false);
+}
+
+BtInstallPageWorksWidget::~BtInstallPageWorksWidget() {
+ qDebug() << "Deleting BtInstallPageWorksWidget for source" << m_source.caption;
+
+ delete m_backend;
+}
+
+void BtInstallPageWorksWidget::deleteSource() {
+ qDebug() << "Deleting source" << m_source.caption;
+
+ setEnabled(false);
+ m_myModel->clear();
+ BtInstallBackend::deleteSource(QString(m_source.caption));
+}
+
+void BtInstallPageWorksWidget::updateTree() {
+ qDebug() << "Updating BtInstallPageWorksWidget tree for source" << m_source.caption;
+
+ m_myModel->clear();
+
+ // Is this necessary?
+ m_source = BtInstallBackend::source(QString(m_source.caption));
+ m_backend = BtInstallBackend::backend(m_source);
+
+ // Repopulate model:
+ Q_FOREACH(CSwordModuleInfo *module, m_backend->moduleList()) {
+ if (filter(module)) m_myModel->addModule(module);
+ }
+}
+
+void BtInstallPageWorksWidget::paintEvent(QPaintEvent *e) {
+ // Delayed init, part 2 - queue init when painted:
+ if (m_myModel == 0) {
+ QTimer::singleShot(0, this, SLOT(slotDelayedInit()));
+ }
+ BtBookshelfWidget::paintEvent(e);
+}
+
+void BtInstallPageWorksWidget::slotDelayedInit() {
+ // Delayed init, part 3 - initialize + reenable parent
+ qApp->setOverrideCursor(Qt::WaitCursor);
+ m_backend = BtInstallBackend::backend(m_source);
+ Q_ASSERT(m_backend != 0);
+ m_myModel = new BtBookshelfModel(this);
+ Q_FOREACH(CSwordModuleInfo *module, m_backend->moduleList()) {
+ if (filter(module)) m_myModel->addModule(module);
+ }
+ setSourceModel(m_myModel);
+ m_parent->setEnabled(true);
+ qApp->restoreOverrideCursor();
+}
+
+void BtInstallPageWorksWidget::slotSourceRefresh() {
+ qDebug() << "Refreshing source" << m_source.caption;
+
+ if (BtInstallBackend::isRemote(m_source)) {
+ BtRefreshProgressDialog d(m_source, this);
+ if (!d.runAndDelete()) return;
+ }
+ updateTree();
+}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h
new file mode 100644
index 0000000..1a9bd8f
--- /dev/null
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h
@@ -0,0 +1,59 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2011 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTINSTALLPAGEWORKSWIDGET_H
+#define BTINSTALLPAGEWORKSWIDGET_H
+
+
+#include "frontend/btbookshelfwidget.h"
+
+// Sword includes
+#include <installmgr.h>
+
+
+class BtInstallPage;
+
+class BtInstallPageWorksWidget: public BtBookshelfWidget {
+ Q_OBJECT
+
+ public: /* Methods: */
+
+ BtInstallPageWorksWidget(const sword::InstallSource &source,
+ const BtBookshelfTreeModel::Grouping &g,
+ BtInstallPage *parent, Qt::WindowFlags f = 0);
+
+ ~BtInstallPageWorksWidget();
+
+ inline const sword::InstallSource &installSource() const {
+ return m_source;
+ }
+ void deleteSource();
+
+ private: /* Methods: */
+
+ void updateTree();
+
+ /** Reimplemented from QWidget. */
+ virtual void paintEvent(QPaintEvent *e);
+
+ private slots:
+
+ void slotDelayedInit();
+ void slotSourceRefresh();
+
+ private: /* Fields: */
+
+ sword::InstallSource m_source;
+ BtInstallPage *m_parent;
+ QToolButton *m_sourceRefreshButton;
+ CSwordBackend *m_backend;
+ BtBookshelfModel *m_myModel;
+};
+
+#endif // BTINSTALLPAGEWORKSWIDGET_H
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
index 9efb9f0..a272d89 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,13 +15,12 @@
#include <QDir>
#include <QFileDialog>
#include <QGridLayout>
-#include <QHeaderView>
#include <QLabel>
#include <QPushButton>
#include <QString>
#include <QTreeWidget>
#include <QTreeWidgetItem>
-#include "frontend/bookshelfmanager/instbackend.h"
+#include "backend/btinstallbackend.h"
#include "util/dialogutil.h"
#include "util/directory.h"
#include "util/cresmgr.h"
@@ -47,7 +46,7 @@ BtInstallPathDialog::BtInstallPathDialog() {
tr("Configure bookshelf folders"), l1 + QString("<small><br/><br/>") + l2 + QString("</small>"));
mainLayout->addWidget(mainLabel);
- QString swordConfPath = instbackend::swordConfigFilename();
+ QString swordConfPath = BtInstallBackend::swordConfigFilename();
/// \todo After releasing 2.4, change the following line to: QLabel *confPathLabel = new QLabel(tr("Configuration file for the folders is: <b>%1</b>").arg(swordConfPath), this);
QLabel* confPathLabel = new QLabel(tr("Configuration file for the folders is: ").append("<b>%1</b>").arg(swordConfPath), this);
confPathLabel->setWordWrap(true);
@@ -55,7 +54,7 @@ BtInstallPathDialog::BtInstallPathDialog() {
m_swordPathListBox = new QTreeWidget(this);
- m_swordPathListBox->header()->hide();
+ m_swordPathListBox->setHeaderHidden(true);
QString rwfolderitem(tr("Folders where new works can be installed"));
m_writableItem = new QTreeWidgetItem(m_swordPathListBox, QStringList(rwfolderitem));;
@@ -65,7 +64,7 @@ BtInstallPathDialog::BtInstallPathDialog() {
m_nonexistingItem = new QTreeWidgetItem(m_swordPathListBox, QStringList(tr("Nonexistent folders")));;
m_nonexistingItem->setFlags(Qt::ItemIsEnabled);
- QStringList targets = instbackend::targetList();
+ QStringList targets = BtInstallBackend::targetList();
foreach (QString pathname, targets) {
addPathToList(pathname);
@@ -76,19 +75,19 @@ BtInstallPathDialog::BtInstallPathDialog() {
QVBoxLayout* buttonLayout = new QVBoxLayout();
- m_addButton = new QPushButton(tr("Add..."), this);
+ m_addButton = new QPushButton(tr("&Add..."), this);
m_addButton->setToolTip(tr("Add new folder"));
m_addButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::paths::add_icon));
connect(m_addButton, SIGNAL(clicked()), this, SLOT(slotAddClicked()));
buttonLayout->addWidget(m_addButton);
- m_editButton = new QPushButton(tr("Edit..."), this);
+ m_editButton = new QPushButton(tr("&Edit..."), this);
m_editButton->setToolTip(tr("Edit the selected folder"));
m_editButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::paths::edit_icon));
connect(m_editButton, SIGNAL(clicked()), this, SLOT(slotEditClicked()));
buttonLayout->addWidget(m_editButton);
- m_removeButton = new QPushButton(tr("Remove"), this);
+ m_removeButton = new QPushButton(tr("&Remove"), this);
m_removeButton->setToolTip(tr("Remove the selected folder"));
m_removeButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::paths::remove_icon));
connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveClicked()));
@@ -162,7 +161,7 @@ void BtInstallPathDialog::addPathToList(QString pathname) {
i = new QTreeWidgetItem(m_readableItem, QStringList(pathname) );
}
}
- if (i && QDir(pathname) == instbackend::swordDir()) {
+ if (i && QDir(pathname) == BtInstallBackend::swordDir()) {
i->setFlags(Qt::NoItemFlags);
i->setToolTip(0, tr("This default folder in your home directory can't be removed"));
}
@@ -231,7 +230,7 @@ void BtInstallPathDialog::writeSwordConfig() {
++it;
}
qDebug() << "save the target list" << targets;
- instbackend::setTargetList(targets); //creates new Sword config
+ BtInstallBackend::setTargetList(targets);