summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/bookshelfmodel/btbookshelffiltermodel.cpp158
-rw-r--r--src/backend/bookshelfmodel/btbookshelffiltermodel.h210
-rw-r--r--src/backend/bookshelfmodel/btbookshelfmodel.cpp130
-rw-r--r--src/backend/bookshelfmodel/btbookshelfmodel.h295
-rw-r--r--src/backend/bookshelfmodel/btbookshelftreemodel.cpp534
-rw-r--r--src/backend/bookshelfmodel/btbookshelftreemodel.h308
-rw-r--r--src/backend/bookshelfmodel/categoryitem.cpp24
-rw-r--r--src/backend/bookshelfmodel/categoryitem.h33
-rw-r--r--src/backend/bookshelfmodel/indexingitem.cpp24
-rw-r--r--src/backend/bookshelfmodel/indexingitem.h25
-rw-r--r--src/backend/bookshelfmodel/item.cpp48
-rw-r--r--src/backend/bookshelfmodel/item.h266
-rw-r--r--src/backend/bookshelfmodel/languageitem.cpp15
-rw-r--r--src/backend/bookshelfmodel/languageitem.h26
-rw-r--r--src/backend/bookshelfmodel/moduleitem.cpp11
-rw-r--r--src/backend/bookshelfmodel/moduleitem.h46
-rw-r--r--src/backend/btinstallbackend.cpp78
-rw-r--r--src/backend/btinstallbackend.h6
-rw-r--r--src/backend/btinstallmgr.cpp99
-rw-r--r--src/backend/btinstallmgr.h73
-rw-r--r--src/backend/btinstallthread.cpp143
-rw-r--r--src/backend/btinstallthread.h94
-rw-r--r--src/backend/btmoduletreeitem.cpp2
-rw-r--r--src/backend/btmoduletreeitem.h16
-rw-r--r--src/backend/config/btconfig.cpp363
-rw-r--r--src/backend/config/btconfig.h248
-rw-r--r--src/backend/config/btconfigcore.cpp202
-rw-r--r--src/backend/config/btconfigcore.h342
-rw-r--r--src/backend/config/cbtconfig.cpp776
-rw-r--r--src/backend/config/cbtconfig.h204
-rw-r--r--src/backend/cswordmodulesearch.cpp293
-rw-r--r--src/backend/cswordmodulesearch.h15
-rw-r--r--src/backend/drivers/cswordbiblemoduleinfo.cpp33
-rw-r--r--src/backend/drivers/cswordbiblemoduleinfo.h7
-rw-r--r--src/backend/drivers/cswordbookmoduleinfo.cpp31
-rw-r--r--src/backend/drivers/cswordbookmoduleinfo.h11
-rw-r--r--src/backend/drivers/cswordcommentarymoduleinfo.cpp6
-rw-r--r--src/backend/drivers/cswordcommentarymoduleinfo.h14
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.cpp16
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.h8
-rw-r--r--src/backend/drivers/cswordmoduleinfo.cpp924
-rw-r--r--src/backend/drivers/cswordmoduleinfo.h812
-rw-r--r--src/backend/filters/btosismorphsegmentation.cpp95
-rw-r--r--src/backend/filters/btosismorphsegmentation.h47
-rw-r--r--src/backend/filters/gbftohtml.cpp6
-rw-r--r--src/backend/filters/gbftohtml.h4
-rw-r--r--src/backend/filters/osismorphsegmentation.cpp83
-rw-r--r--src/backend/filters/osismorphsegmentation.h37
-rw-r--r--src/backend/filters/osistohtml.cpp39
-rw-r--r--src/backend/filters/osistohtml.h4
-rw-r--r--src/backend/filters/plaintohtml.cpp2
-rw-r--r--src/backend/filters/plaintohtml.h4
-rw-r--r--src/backend/filters/teitohtml.cpp9
-rw-r--r--src/backend/filters/teitohtml.h4
-rw-r--r--src/backend/filters/thmltohtml.cpp17
-rw-r--r--src/backend/filters/thmltohtml.h4
-rw-r--r--src/backend/filters/thmltoplain.cpp2
-rw-r--r--src/backend/filters/thmltoplain.h4
-rw-r--r--src/backend/keys/cswordkey.cpp207
-rw-r--r--src/backend/keys/cswordkey.h227
-rw-r--r--src/backend/keys/cswordldkey.cpp6
-rw-r--r--src/backend/keys/cswordldkey.h4
-rw-r--r--src/backend/keys/cswordtreekey.cpp6
-rw-r--r--src/backend/keys/cswordtreekey.h4
-rw-r--r--src/backend/keys/cswordversekey.cpp38
-rw-r--r--src/backend/keys/cswordversekey.h4
-rw-r--r--src/backend/managers/btstringmgr.cpp55
-rw-r--r--src/backend/managers/btstringmgr.h22
-rw-r--r--src/backend/managers/cdisplaytemplatemgr.cpp54
-rw-r--r--src/backend/managers/cdisplaytemplatemgr.h4
-rw-r--r--src/backend/managers/clanguagemgr.cpp35
-rw-r--r--src/backend/managers/clanguagemgr.h117
-rw-r--r--src/backend/managers/cswordbackend.cpp461
-rw-r--r--src/backend/managers/cswordbackend.h429
-rw-r--r--src/backend/managers/referencemanager.cpp37
-rw-r--r--src/backend/managers/referencemanager.h4
-rw-r--r--src/backend/rendering/cbookdisplay.cpp2
-rw-r--r--src/backend/rendering/cbookdisplay.h4
-rw-r--r--src/backend/rendering/cchapterdisplay.cpp6
-rw-r--r--src/backend/rendering/cchapterdisplay.h4
-rw-r--r--src/backend/rendering/cdisplayrendering.cpp5
-rw-r--r--src/backend/rendering/cdisplayrendering.h9
-rw-r--r--src/backend/rendering/centrydisplay.cpp7
-rw-r--r--src/backend/rendering/centrydisplay.h8
-rw-r--r--src/backend/rendering/chtmlexportrendering.cpp30
-rw-r--r--src/backend/rendering/chtmlexportrendering.h12
-rw-r--r--src/backend/rendering/cplaintextexportrendering.cpp2
-rw-r--r--src/backend/rendering/cplaintextexportrendering.h9
-rw-r--r--src/backend/rendering/ctextrendering.cpp25
-rw-r--r--src/backend/rendering/ctextrendering.h6
-rw-r--r--src/bibletime.cpp77
-rw-r--r--src/bibletime.h98
-rw-r--r--src/bibletime_dbus.cpp5
-rw-r--r--src/bibletime_dbus_adaptor.cpp8
-rw-r--r--src/bibletime_dbus_adaptor.h4
-rw-r--r--src/bibletime_init.cpp303
-rw-r--r--src/bibletime_slots.cpp610
-rw-r--r--src/bibletimeapp.cpp39
-rw-r--r--src/bibletimeapp.h19
-rw-r--r--src/btglobal.h12
-rw-r--r--src/display-templates/Basic.tmpl25
-rw-r--r--src/display-templates/Blue.css222
-rw-r--r--src/display-templates/Christmastide.css92
-rw-r--r--src/display-templates/Crazy.css108
-rw-r--r--src/display-templates/Green.css220
-rw-r--r--src/display-templates/HighContrast.css242
-rw-r--r--src/display-templates/Simple.css96
-rw-r--r--src/frontend/bookmarks/btbookmarkfolder.cpp14
-rw-r--r--src/frontend/bookmarks/btbookmarkfolder.h4
-rw-r--r--src/frontend/bookmarks/btbookmarkitem.cpp16
-rw-r--r--src/frontend/bookmarks/btbookmarkitem.h4
-rw-r--r--src/frontend/bookmarks/btbookmarkitembase.h4
-rw-r--r--src/frontend/bookmarks/btbookmarkloader.cpp2
-rw-r--r--src/frontend/bookmarks/btbookmarkloader.h4
-rw-r--r--src/frontend/bookmarks/bteditbookmarkdialog.cpp13
-rw-r--r--src/frontend/bookmarks/bteditbookmarkdialog.h4
-rw-r--r--src/frontend/bookmarks/cbookmarkindex.cpp17
-rw-r--r--src/frontend/bookmarks/cbookmarkindex.h4
-rw-r--r--src/frontend/bookshelfmanager/btconfigdialog.cpp2
-rw-r--r--src/frontend/bookshelfmanager/btconfigdialog.h4
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.cpp76
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.h62
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp16
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.h4
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp56
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h7
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.cpp19
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.h4
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp2
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h2
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp17
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h3
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.cpp69
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.h4
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp6
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h3
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp42
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h8
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp18
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h4
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp250
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h88
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.cpp185
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.h99
-rw-r--r--src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp4
-rw-r--r--src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h6
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.cpp23
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.h2
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp2
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h2
-rw-r--r--src/frontend/btaboutdialog.cpp16
-rw-r--r--src/frontend/btaboutdialog.h5
-rw-r--r--src/frontend/btaboutmoduledialog.cpp6
-rw-r--r--src/frontend/btaboutmoduledialog.h4
-rw-r--r--src/frontend/btbookshelfdockwidget.cpp22
-rw-r--r--src/frontend/btbookshelfdockwidget.h2
-rw-r--r--src/frontend/btbookshelfgroupingmenu.cpp7
-rw-r--r--src/frontend/btbookshelfgroupingmenu.h2
-rw-r--r--src/frontend/btbookshelfview.cpp13
-rw-r--r--src/frontend/btbookshelfview.h3
-rw-r--r--src/frontend/btbookshelfwidget.cpp11
-rw-r--r--src/frontend/btbookshelfwidget.h3
-rw-r--r--src/frontend/btcentralwidget.cpp51
-rw-r--r--src/frontend/btcentralwidget.h33
-rw-r--r--src/frontend/btmenuview.cpp2
-rw-r--r--src/frontend/btmenuview.h2
-rw-r--r--src/frontend/btmodulechooserdialog.cpp10
-rw-r--r--src/frontend/btmodulechooserdialog.h4
-rw-r--r--src/frontend/btmoduleindexdialog.cpp2
-rw-r--r--src/frontend/btmoduleindexdialog.h4
-rw-r--r--src/frontend/btopenworkaction.cpp11
-rw-r--r--src/frontend/btopenworkaction.h3
-rw-r--r--src/frontend/cdragdrop.h4
-rw-r--r--src/frontend/cexportmanager.cpp39
-rw-r--r--src/frontend/cexportmanager.h10
-rw-r--r--src/frontend/cinfodisplay.cpp304
-rw-r--r--src/frontend/cinfodisplay.h102
-rw-r--r--src/frontend/cmdiarea.cpp86
-rw-r--r--src/frontend/cmdiarea.h23
-rw-r--r--src/frontend/cprinter.cpp3
-rw-r--r--src/frontend/cprinter.h4
-rw-r--r--src/frontend/crossrefrendering.cpp2
-rw-r--r--src/frontend/crossrefrendering.h9
-rw-r--r--src/frontend/display/btcolorwidget.cpp2
-rw-r--r--src/frontend/display/btcolorwidget.h4
-rw-r--r--src/frontend/display/btfindwidget.cpp118
-rw-r--r--src/frontend/display/btfindwidget.h56
-rw-r--r--src/frontend/display/btfontsizewidget.cpp2
-rw-r--r--src/frontend/display/btfontsizewidget.h4
-rw-r--r--src/frontend/display/bthtml.js156
-rw-r--r--src/frontend/display/bthtmlfindtext.cpp95
-rw-r--r--src/frontend/display/bthtmlfindtext.h36
-rw-r--r--src/frontend/display/bthtmlfindtext.ui145
-rw-r--r--src/frontend/display/bthtmljsobject.cpp42
-rw-r--r--src/frontend/display/bthtmljsobject.h4
-rw-r--r--src/frontend/display/bthtmlreaddisplay.cpp10
-rw-r--r--src/frontend/display/bthtmlreaddisplay.h17
-rw-r--r--src/frontend/display/cdisplay.cpp16
-rw-r--r--src/frontend/display/cdisplay.h17
-rw-r--r--src/frontend/display/chtmlwritedisplay.cpp183
-rw-r--r--src/frontend/display/chtmlwritedisplay.h52
-rw-r--r--src/frontend/display/cplainwritedisplay.cpp9
-rw-r--r--src/frontend/display/cplainwritedisplay.h31
-rw-r--r--src/frontend/display/creaddisplay.cpp2
-rw-r--r--src/frontend/display/creaddisplay.h6
-rw-r--r--src/frontend/display/cwritedisplay.cpp21
-rw-r--r--src/frontend/display/cwritedisplay.h47
-rw-r--r--src/frontend/displaywindow/btactioncollection.cpp67
-rw-r--r--src/frontend/displaywindow/btactioncollection.h35
-rw-r--r--src/frontend/displaywindow/btdisplaysettingsbutton.cpp9
-rw-r--r--src/frontend/displaywindow/btdisplaysettingsbutton.h4
-rw-r--r--src/frontend/displaywindow/btmodulechooserbar.cpp2
-rw-r--r--src/frontend/displaywindow/btmodulechooserbar.h4
-rw-r--r--src/frontend/displaywindow/btmodulechooserbutton.cpp14
-rw-r--r--src/frontend/displaywindow/btmodulechooserbutton.h4
-rw-r--r--src/frontend/displaywindow/bttextwindowheader.cpp2
-rw-r--r--src/frontend/displaywindow/bttextwindowheader.h4
-rw-r--r--src/frontend/displaywindow/bttextwindowheaderwidget.cpp23
-rw-r--r--src/frontend/displaywindow/bttextwindowheaderwidget.h4
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.cpp2
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.h4
-rw-r--r--src/frontend/displaywindow/btwindowmodulechooser.h4
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.cpp91
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.h44
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.cpp36
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.h46
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.cpp38
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.h18
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.cpp122
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.h19
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.cpp11
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.h14
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.cpp70
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.h36
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.cpp13
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.h6
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.cpp159
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.h56
-rw-r--r--src/frontend/displaywindow/creadwindow.cpp56
-rw-r--r--src/frontend/displaywindow/creadwindow.h28
-rw-r--r--src/frontend/displaywindow/cwritewindow.cpp158
-rw-r--r--src/frontend/displaywindow/cwritewindow.h92
-rw-r--r--src/frontend/keychooser/bthistory.cpp5
-rw-r--r--src/frontend/keychooser/bthistory.h6
-rw-r--r--src/frontend/keychooser/cbookkeychooser.cpp163
-rw-r--r--src/frontend/keychooser/cbookkeychooser.h142
-rw-r--r--src/frontend/keychooser/cbooktreechooser.cpp20
-rw-r--r--src/frontend/keychooser/cbooktreechooser.h6
-rw-r--r--src/frontend/keychooser/ckeychooser.cpp56
-rw-r--r--src/frontend/keychooser/ckeychooser.h161
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.cpp214
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.h274
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.cpp25
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.h6
-rw-r--r--src/frontend/keychooser/cscrollbutton.cpp6
-rw-r--r--src/frontend/keychooser/cscrollbutton.h5
-rw-r--r--src/frontend/keychooser/cscrollerwidgetset.cpp79
-rw-r--r--src/frontend/keychooser/cscrollerwidgetset.h96
-rw-r--r--src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp18
-rw-r--r--src/frontend/keychooser/versekeychooser/btbiblekeywidget.h4
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp2
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h4
-rw-r--r--src/frontend/keychooser/versekeychooser/btversekeymenu.cpp8
-rw-r--r--src/frontend/keychooser/versekeychooser/btversekeymenu.h4
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp15
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.h10
-rw-r--r--src/frontend/messagedialog.cpp (renamed from src/util/dialogutil.cpp)20
-rw-r--r--src/frontend/messagedialog.h (renamed from src/util/dialogutil.h)26
-rw-r--r--src/frontend/profile/cprofile.cpp380
-rw-r--r--src/frontend/profile/cprofile.h113
-rw-r--r--src/frontend/profile/cprofilemgr.cpp118
-rw-r--r--src/frontend/profile/cprofilemgr.h67
-rw-r--r--src/frontend/profile/cprofilewindow.cpp30
-rw-r--r--src/frontend/profile/cprofilewindow.h45
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp6
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.h4
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.cpp57
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.h18
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp2
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.h4
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.cpp136
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.h4
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.cpp2
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.h4
-rw-r--r--src/frontend/searchdialog/btsearchmodulechooserdialog.cpp6
-rw-r--r--src/frontend/searchdialog/btsearchmodulechooserdialog.h3
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.cpp58
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.h6
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.cpp332
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.h14
-rw-r--r--src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp11
-rw-r--r--src/frontend/searchdialog/btsearchsyntaxhelpdialog.h5
-rw-r--r--src/frontend/searchdialog/chistorycombobox.cpp2
-rw-r--r--src/frontend/searchdialog/chistorycombobox.h4
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.cpp81
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.h4
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.cpp26
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.h4
-rw-r--r--src/frontend/searchdialog/csearchdialog.cpp32
-rw-r--r--src/frontend/searchdialog/csearchdialog.h4
-rw-r--r--src/frontend/searchdialog/csearchresultview.cpp22
-rw-r--r--src/frontend/searchdialog/csearchresultview.h4
-rw-r--r--src/frontend/settingsdialogs/btfontchooserwidget.cpp2
-rw-r--r--src/frontend/settingsdialogs/btfontchooserwidget.h4
-rw-r--r--src/frontend/settingsdialogs/btfontsettings.cpp30
-rw-r--r--src/frontend/settingsdialogs/btfontsettings.h8
-rw-r--r--src/frontend/settingsdialogs/btlanguagesettings.cpp19
-rw-r--r--src/frontend/settingsdialogs/btlanguagesettings.h4
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.cpp6
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.h4
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.cpp2
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.h4
-rw-r--r--src/frontend/settingsdialogs/btstandardworkstab.cpp203
-rw-r--r--src/frontend/settingsdialogs/btstandardworkstab.h55
-rw-r--r--src/frontend/settingsdialogs/bttextfilterstab.cpp87
-rw-r--r--src/frontend/settingsdialogs/bttextfilterstab.h54
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.cpp58
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.h4
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.cpp19
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.h4
-rw-r--r--src/frontend/settingsdialogs/cdisplaysettings.cpp19
-rw-r--r--src/frontend/settingsdialogs/cdisplaysettings.h4
-rw-r--r--src/frontend/settingsdialogs/clistwidget.cpp6
-rw-r--r--src/frontend/settingsdialogs/clistwidget.h6
-rw-r--r--src/frontend/settingsdialogs/cswordsettings.cpp306
-rw-r--r--src/frontend/settingsdialogs/cswordsettings.h97
-rw-r--r--src/frontend/tips/bttipdialog.cpp32
-rw-r--r--src/frontend/tips/bttipdialog.h4
-rw-r--r--src/main.cpp65
-rw-r--r--src/mobile/bibletime.cpp101
-rw-r--r--src/mobile/bibletime.h31
-rw-r--r--src/mobile/bibletimeapp.cpp95
-rw-r--r--src/mobile/bibletimeapp.h55
-rw-r--r--src/mobile/bookshelfmanager/installmanager.cpp371
-rw-r--r--src/mobile/bookshelfmanager/installmanager.h82
-rw-r--r--src/mobile/bookshelfmanager/installprogress.cpp199
-rw-r--r--src/mobile/bookshelfmanager/installprogress.h61
-rw-r--r--src/mobile/bookshelfmanager/installsources.cpp75
-rw-r--r--src/mobile/bookshelfmanager/installsources.h52
-rw-r--r--src/mobile/bookshelfmanager/installsourcesmanager.cpp85
-rw-r--r--src/mobile/bookshelfmanager/installsourcesmanager.h45
-rw-r--r--src/mobile/btmmain.cpp106
-rw-r--r--src/mobile/btmmain.h23
-rw-r--r--src/mobile/keychooser/bookkeychooser.cpp272
-rw-r--r--src/mobile/keychooser/bookkeychooser.h81
-rw-r--r--src/mobile/keychooser/versechooser.cpp160
-rw-r--r--src/mobile/keychooser/versechooser.h86
-rw-r--r--src/mobile/models/bibletextmodelbuilder.cpp184
-rw-r--r--src/mobile/models/bibletextmodelbuilder.h46
-rw-r--r--src/mobile/models/booktextmodelbuilder.cpp101
-rw-r--r--src/mobile/models/booktextmodelbuilder.h40
-rw-r--r--src/mobile/models/roleitemmodel.cpp54
-rw-r--r--src/mobile/models/roleitemmodel.h24
-rw-r--r--src/mobile/qml/ContextMenu.qml62
-rw-r--r--src/mobile/qml/FontSizeSlider.qml139
-rw-r--r--src/mobile/qml/GridChooser.qml117
-rw-r--r--src/mobile/qml/GridChooserButton.qml52
-rw-r--r--src/mobile/qml/ImageButton.qml24
-rw-r--r--src/mobile/qml/InstallManagerChooser.qml153
-rw-r--r--src/mobile/qml/ListTextView.qml108
-rw-r--r--src/mobile/qml/ListWorksView.qml123
-rw-r--r--src/mobile/qml/MainToolbar.qml27
-rw-r--r--src/mobile/qml/MenuButton.qml30
-rw-r--r--src/mobile/qml/MenuView.qml28
-rw-r--r--src/mobile/qml/Menus.qml61
-rw-r--r--src/mobile/qml/ModuleChooser.qml109
-rw-r--r--src/mobile/qml/Progress.qml63
-rw-r--r--src/mobile/qml/Settings.qml93
-rw-r--r--src/mobile/qml/TreeChooser.qml167
-rw-r--r--src/mobile/qml/Window.qml178
-rw-r--r--src/mobile/qml/WindowManager.qml291
-rw-r--r--src/mobile/qml/checkmark.svg42
-rw-r--r--src/mobile/qml/leftarrow.svg83
-rw-r--r--src/mobile/qml/main.qml270
-rw-r--r--src/mobile/qml/rightarrow.svg82
-rw-r--r--src/mobile/qml/tab.pngbin0 -> 507 bytes
-rw-r--r--src/mobile/ui/btstyle.cpp334
-rw-r--r--src/mobile/ui/btstyle.h132
-rw-r--r--src/mobile/ui/btwindowinterface.cpp257
-rw-r--r--src/mobile/ui/btwindowinterface.h73
-rw-r--r--src/mobile/ui/gridchooser.cpp63
-rw-r--r--src/mobile/ui/gridchooser.h43
-rw-r--r--src/mobile/ui/modulechooser.cpp44
-rw-r--r--src/mobile/ui/modulechooser.h35
-rw-r--r--src/mobile/ui/moduleinterface.cpp187
-rw-r--r--src/mobile/ui/moduleinterface.h48
-rw-r--r--src/mobile/ui/qtquick2applicationviewer.cpp63
-rw-r--r--src/mobile/ui/qtquick2applicationviewer.h32
-rw-r--r--src/mobile/ui/treechoosermodel.cpp22
-rw-r--r--src/mobile/ui/treechoosermodel.h20
-rw-r--r--src/mobile/ui/viewmanager.cpp52
-rw-r--r--src/mobile/ui/viewmanager.h34
-rw-r--r--src/mobile/util/findqmlobject.cpp34
-rw-r--r--src/mobile/util/findqmlobject.h28
-rw-r--r--src/mobile/util/messagedialog.cpp36
-rw-r--r--src/mobile/util/messagedialog.h36
-rw-r--r--src/util/btmodules.cpp2
-rw-r--r--src/util/btmodules.h4
-rw-r--r--src/util/btsignal.h40
-rw-r--r--src/util/cresmgr.cpp8
-rw-r--r--src/util/cresmgr.h10
-rw-r--r--src/util/directory.cpp287
-rw-r--r--src/util/directory.h11
-rw-r--r--src/util/exceptions.h4
-rw-r--r--src/util/geticon.cpp54
-rw-r--r--src/util/geticon.h30
-rw-r--r--src/util/htmlescape.h33
-rw-r--r--src/util/macros.h4
-rw-r--r--src/util/tool.cpp98
-rw-r--r--src/util/tool.h82
410 files changed, 16350 insertions, 10410 deletions
diff --git a/src/backend/bookshelfmodel/btbookshelffiltermodel.cpp b/src/backend/bookshelfmodel/btbookshelffiltermodel.cpp
index 182d337..320d693 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -15,25 +15,26 @@
#include "backend/bookshelfmodel/btbookshelfmodel.h"
-BtBookshelfFilterModel::BtBookshelfFilterModel(QObject *parent)
- : QSortFilterProxyModel(parent), m_enabled(true),
- m_nameFilterRole(BtBookshelfModel::ModuleNameRole), m_nameFilterColumn(0),
- m_nameFilterCase(Qt::CaseInsensitive),
- m_hiddenFilterRole(BtBookshelfModel::ModuleHiddenRole),
- m_hiddenFilterColumn(0), m_showHidden(false), m_showShown(true),
- m_categoryFilter(CSwordModuleInfo::AllCategories),
- m_categoryFilterRole(BtBookshelfModel::ModuleCategoryRole),
- m_categoryFilterColumn(0)
+BtBookshelfFilterModel::BtBookshelfFilterModel(QObject * parent)
+ : QSortFilterProxyModel(parent)
+ , m_enabled(true)
+ , m_nameFilterRole(BtBookshelfModel::ModuleNameRole)
+ , m_nameFilterColumn(0)
+ , m_nameFilterCase(Qt::CaseInsensitive)
+ , m_hiddenFilterRole(BtBookshelfModel::ModuleHiddenRole)
+ , m_hiddenFilterColumn(0)
+ , m_showHidden(false)
+ , m_showShown(true)
+ , m_categoryFilter(CSwordModuleInfo::AllCategories)
+ , m_categoryFilterRole(BtBookshelfModel::ModuleCategoryRole)
+ , m_categoryFilterColumn(0)
{
setDynamicSortFilter(true);
}
-BtBookshelfFilterModel::~BtBookshelfFilterModel() {
- // Intentionally empty
-}
-
void BtBookshelfFilterModel::setEnabled(bool enable) {
- if (enable == m_enabled) return;
+ if (enable == m_enabled)
+ return;
m_enabled = enable;
invalidateFilter();
}
@@ -41,25 +42,29 @@ void BtBookshelfFilterModel::setEnabled(bool enable) {
// Name filter:
void BtBookshelfFilterModel::setNameFilterRole(int role) {
- if (m_nameFilterRole == role) return;
+ if (m_nameFilterRole == role)
+ return;
m_nameFilterRole = role;
invalidateFilter();
}
void BtBookshelfFilterModel::setNameFilterKeyColumn(int column) {
- if (m_nameFilterColumn == column) return;
+ if (m_nameFilterColumn == column)
+ return;
m_nameFilterColumn = column;
invalidateFilter();
}
void BtBookshelfFilterModel::setNameFilterFixedString(const QString &filter) {
- if (m_nameFilter == filter) return;
+ if (m_nameFilter == filter)
+ return;
m_nameFilter = filter;
invalidateFilter();
}
void BtBookshelfFilterModel::setNameFilterCase(Qt::CaseSensitivity value) {
- if (m_nameFilterCase == value) return;
+ if (m_nameFilterCase == value)
+ return;
m_nameFilterCase = value;
invalidateFilter();
}
@@ -67,25 +72,29 @@ void BtBookshelfFilterModel::setNameFilterCase(Qt::CaseSensitivity value) {
// Hidden filter:
void BtBookshelfFilterModel::setHiddenFilterRole(int role) {
- if (m_hiddenFilterRole == role) return;
+ if (m_hiddenFilterRole == role)
+ return;
m_hiddenFilterRole = role;
invalidateFilter();
}
void BtBookshelfFilterModel::setHiddenFilterKeyColumn(int column) {
- if (m_hiddenFilterColumn == column) return;
+ if (m_hiddenFilterColumn == column)
+ return;
m_hiddenFilterColumn = column;
invalidateFilter();
}
void BtBookshelfFilterModel::setShowHidden(bool show) {
- if (m_showHidden == show) return;
+ if (m_showHidden == show)
+ return;
m_showHidden = show;
invalidateFilter();
}
void BtBookshelfFilterModel::setShowShown(bool show) {
- if (m_showShown == show) return;
+ if (m_showShown == show)
+ return;
m_showShown = show;
invalidateFilter();
}
@@ -93,21 +102,24 @@ void BtBookshelfFilterModel::setShowShown(bool show) {
// Category filter:
void BtBookshelfFilterModel::setCategoryFilterRole(int role) {
- if (m_categoryFilterRole == role) return;
+ if (m_categoryFilterRole == role)
+ return;
m_categoryFilterRole = role;
invalidateFilter();
}
void BtBookshelfFilterModel::setCategoryFilterKeyColumn(int column) {
- if (m_categoryFilterColumn == column) return;
+ if (m_categoryFilterColumn == column)
+ return;
m_categoryFilterColumn = column;
invalidateFilter();
}
void BtBookshelfFilterModel::setShownCategories(
- const CSwordModuleInfo::Categories &categories)
+ const CSwordModuleInfo::Categories & categories)
{
- if (m_categoryFilter == categories) return;
+ if (m_categoryFilter == categories)
+ return;
m_categoryFilter = categories;
invalidateFilter();
}
@@ -115,20 +127,27 @@ void BtBookshelfFilterModel::setShownCategories(
// Filtering:
bool BtBookshelfFilterModel::filterAcceptsRow(int row,
- const QModelIndex &parent) const
+ const QModelIndex & parent) const
{
- if (!m_enabled) return true;
+ if (!m_enabled)
+ return true;
- if (!hiddenFilterAcceptsRow(row, parent)) return false;
- if (!nameFilterAcceptsRow(row, parent)) return false;
- if (!categoryFilterAcceptsRow(row, parent)) return false;
+ if (!hiddenFilterAcceptsRow(row, parent))
+ return false;
+ if (!nameFilterAcceptsRow(row, parent))
+ return false;
+ if (!categoryFilterAcceptsRow(row, parent))
+ return false;
return true;
}
-bool BtBookshelfFilterModel::nameFilterAcceptsRow(int row, const QModelIndex &parent) const {
- if (m_nameFilter.isEmpty()) return true;
+bool BtBookshelfFilterModel::nameFilterAcceptsRow(int row,
+ const QModelIndex & parent) const
+{
+ if (m_nameFilter.isEmpty())
+ return true;
- const QAbstractItemModel *m(sourceModel());
+ const QAbstractItemModel * const m = sourceModel();
Q_ASSERT(m != 0);
QModelIndex itemIndex(m->index(row, m_nameFilterColumn, parent));
@@ -137,59 +156,54 @@ bool BtBookshelfFilterModel::nameFilterAcceptsRow(int row, const QModelIndex &pa
QVariant data(m->data(itemIndex, m_nameFilterRole));
return data.toString().contains(m_nameFilter, m_nameFilterCase);
}
- else {
- for (int i(0); i < numChildren; i++) {
- if (filterAcceptsRow(i, itemIndex)) return true;
- }
- return false;
- }
+
+ for (int i = 0; i < numChildren; i++)
+ if (filterAcceptsRow(i, itemIndex))
+ return true;
+ return false;
}
-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;
+ if (m_showHidden && m_showShown)
+ return true;
- typedef Qt::CheckState CS;
-
- QAbstractItemModel *m(sourceModel());
+ const QAbstractItemModel * const m = sourceModel();
Q_ASSERT(m != 0);
- QModelIndex itemIndex(m->index(row, m_hiddenFilterColumn, parent));
- int numChildren(m->rowCount(itemIndex));
+ const QModelIndex itemIndex = m->index(row, m_hiddenFilterColumn, parent);
+ const int numChildren = m->rowCount(itemIndex);
if (numChildren == 0) {
- if ((CS) m->data(itemIndex, m_hiddenFilterRole).toBool()) {
+ if (static_cast<Qt::CheckState>(m->data(itemIndex, m_hiddenFilterRole).toBool()))
return m_showHidden;
- }
- else {
- return m_showShown;
- }
- }
- else {
- for (int i(0); i < numChildren; i++) {
- if (filterAcceptsRow(i, itemIndex)) return true;
- }
- return false;
+ return m_showShown;
}
+
+ for (int i = 0; i < numChildren; i++)
+ if (filterAcceptsRow(i, itemIndex))
+ return true;
+ return false;
}
bool BtBookshelfFilterModel::categoryFilterAcceptsRow(int row,
- const QModelIndex &parent) const
+ const QModelIndex & parent) const
{
- if (m_categoryFilter == CSwordModuleInfo::AllCategories) return true;
+ if (m_categoryFilter == CSwordModuleInfo::AllCategories)
+ return true;
- QAbstractItemModel *m(sourceModel());
+ const QAbstractItemModel * const m = sourceModel();
Q_ASSERT(m != 0);
- QModelIndex itemIndex(m->index(row, m_categoryFilterColumn, parent));
- int numChildren(m->rowCount(itemIndex));
+ const QModelIndex itemIndex(m->index(row, m_categoryFilterColumn, parent));
+ const int numChildren(m->rowCount(itemIndex));
if (numChildren == 0) {
- int cat = m->data(itemIndex, m_categoryFilterRole).toInt();
- return m_categoryFilter.testFlag((CSwordModuleInfo::Category) cat);
- }
- else {
- for (int i(0); i < numChildren; i++) {
- if (filterAcceptsRow(i, itemIndex)) return true;
- }
- return false;
+ const int cat = m->data(itemIndex, m_categoryFilterRole).toInt();
+ return m_categoryFilter.testFlag(static_cast<CSwordModuleInfo::Category>(cat));
}
+
+ for (int i = 0; i < numChildren; i++)
+ if (filterAcceptsRow(i, itemIndex))
+ return true;
+ return false;
}
diff --git a/src/backend/bookshelfmodel/btbookshelffiltermodel.h b/src/backend/bookshelfmodel/btbookshelffiltermodel.h
index 55322ed..b1b22e6 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -19,109 +19,113 @@
class BtBookshelfFilterModel: public QSortFilterProxyModel {
+
Q_OBJECT
- public:
- BtBookshelfFilterModel(QObject *parent = 0);
- virtual ~BtBookshelfFilterModel();
-
- // Common methods:
- inline bool enabled() const {
- return m_enabled;
- }
-
- virtual bool filterAcceptsRow(int row, const QModelIndex &parent) const;
-
- // Name filter:
- inline int nameFilterRole() const {
- return m_nameFilterRole;
- }
-
- inline int nameFilterKeyColumn() const {
- return m_nameFilterColumn;
- }
-
- inline const QString &nameFilter() const {
- return m_nameFilter;
- }
-
- inline const Qt::CaseSensitivity nameFilterCase() const {
- return m_nameFilterCase;
- }
-
- // Hidden filter:
- int hiddenFilterRole() const {
- return m_hiddenFilterRole;
- }
-
- int hiddenFilterKeyColumn() const {
- return m_hiddenFilterColumn;
- }
-
- inline bool showHidden() const {
- return m_showHidden;
- }
-
- inline bool showShown() const {
- return m_showShown;
- }
-
- // Category filter:
- int categoryFilterRole() const {
- return m_categoryFilterRole;
- }
-
- int categoryFilterKeyColumn() const {
- return m_categoryFilterColumn;
- }
-
- inline CSwordModuleInfo::Categories shownCategories() const {
- return m_categoryFilter;
- }
-
- public slots:
- void setEnabled(bool enable);
-
- // Name filter:
- void setNameFilterRole(int role);
- void setNameFilterKeyColumn(int column);
- void setNameFilterFixedString(const QString &nameFilter);
- void setNameFilterCase(Qt::CaseSensitivity value);
-
- // Hidden filter:
- void setHiddenFilterRole(int role);
- void setHiddenFilterKeyColumn(int column);
- void setShowHidden(bool show);
- void setShowShown(bool show);
-
- // Category filter:
- void setCategoryFilterRole(int role);
- void setCategoryFilterKeyColumn(int column);
- void setShownCategories(const CSwordModuleInfo::Categories &categories);
-
- protected:
- bool nameFilterAcceptsRow(int row, const QModelIndex &parent) const;
- bool hiddenFilterAcceptsRow(int row, const QModelIndex &parent) const;
- bool categoryFilterAcceptsRow(int row, const QModelIndex &parent) const;
-
- protected:
- bool m_enabled;
-
- // Name filter:
- QString m_nameFilter;
- int m_nameFilterRole;
- int m_nameFilterColumn;
- Qt::CaseSensitivity m_nameFilterCase;
-
- // Hidden filter:
- int m_hiddenFilterRole;
- int m_hiddenFilterColumn;
- bool m_showHidden;
- bool m_showShown;
-
- // Categories filter:
- CSwordModuleInfo::Categories m_categoryFilter;
- int m_categoryFilterRole;
- int m_categoryFilterColumn;
+
+public: /* Methods: */
+
+ BtBookshelfFilterModel(QObject * parent = 0);
+
+ inline bool enabled() const {
+ return m_enabled;
+ }
+
+ virtual bool filterAcceptsRow(int row, const QModelIndex & parent) const;
+
+ // Name filter:
+ inline int nameFilterRole() const {
+ return m_nameFilterRole;
+ }
+
+ inline int nameFilterKeyColumn() const {
+ return m_nameFilterColumn;
+ }
+
+ inline const QString &nameFilter() const {
+ return m_nameFilter;
+ }
+
+ inline Qt::CaseSensitivity nameFilterCase() const {
+ return m_nameFilterCase;
+ }
+
+ // Hidden filter:
+ int hiddenFilterRole() const {
+ return m_hiddenFilterRole;
+ }
+
+ int hiddenFilterKeyColumn() const {
+ return m_hiddenFilterColumn;
+ }
+
+ inline bool showHidden() const {
+ return m_showHidden;
+ }
+
+ inline bool showShown() const {
+ return m_showShown;
+ }
+
+ // Category filter:
+ int categoryFilterRole() const {
+ return m_categoryFilterRole;
+ }
+
+ int categoryFilterKeyColumn() const {
+ return m_categoryFilterColumn;
+ }
+
+ inline CSwordModuleInfo::Categories shownCategories() const {
+ return m_categoryFilter;
+ }
+
+public slots:
+ void setEnabled(bool enable);
+
+ // Name filter:
+ void setNameFilterRole(int role);
+ void setNameFilterKeyColumn(int column);
+ void setNameFilterFixedString(const QString & nameFilter);
+ void setNameFilterCase(Qt::CaseSensitivity value);
+
+ // Hidden filter:
+ void setHiddenFilterRole(int role);
+ void setHiddenFilterKeyColumn(int column);
+ void setShowHidden(bool show);
+ void setShowShown(bool show);
+
+ // Category filter:
+ void setCategoryFilterRole(int role);
+ void setCategoryFilterKeyColumn(int column);
+ void setShownCategories(const CSwordModuleInfo::Categories & categories);
+
+private: /* Methods: */
+
+ bool nameFilterAcceptsRow(int row, const QModelIndex & parent) const;
+ bool hiddenFilterAcceptsRow(int row, const QModelIndex & parent) const;
+ bool categoryFilterAcceptsRow(int row, const QModelIndex & parent) const;
+
+private: /* Fields: */
+
+ bool m_enabled;
+
+ // Name filter:
+ QString m_nameFilter;
+ int m_nameFilterRole;
+ int m_nameFilterColumn;
+ Qt::CaseSensitivity m_nameFilterCase;
+
+ // Hidden filter:
+ int m_hiddenFilterRole;
+ int m_hiddenFilterColumn;
+ bool m_showHidden;
+ bool m_showShown;
+
+ // Categories filter:
+ CSwordModuleInfo::Categories m_categoryFilter;
+ int m_categoryFilterRole;
+ int m_categoryFilterColumn;
+
};
#endif // BTBOOKSHELFFILTERMODEL_H
diff --git a/src/backend/bookshelfmodel/btbookshelfmodel.cpp b/src/backend/bookshelfmodel/btbookshelfmodel.cpp
index 322b22a..c19e429 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -17,29 +17,22 @@
#include "util/macros.h"
-BtBookshelfModel::BtBookshelfModel(QObject *parent)
- : QAbstractListModel(parent) {
- // Intentionally empty
-}
-
-BtBookshelfModel::~BtBookshelfModel() {
- // Intentionally empty
-}
-
-int BtBookshelfModel::rowCount(const QModelIndex &parent) const {
- if (parent.isValid()) return 0;
+int BtBookshelfModel::rowCount(const QModelIndex & parent) const {
+ if (parent.isValid())
+ return 0;
return m_data.size();
}
-QVariant BtBookshelfModel::data(CSwordModuleInfo *module, int role) const {
+QVariant BtBookshelfModel::data(CSwordModuleInfo * module, int role) const {
+ Q_ASSERT(module);
switch (role) {
case ModuleNameRole: // Qt::DisplayRole
return module->name();
case ModuleIconRole: // Qt::DecorationRole
- return CSwordModuleInfo::moduleIcon(module);
+ return CSwordModuleInfo::moduleIcon(*module);
case ModulePointerRole:
- return qVariantFromValue((void*) module);
+ return qVariantFromValue(static_cast<void *>(module));
case ModuleCategoryRole:
return QVariant::fromValue(module->category());
case ModuleLanguageRole:
@@ -64,30 +57,40 @@ QVariant BtBookshelfModel::data(CSwordModuleInfo *module, int role) const {
}
QVariant BtBookshelfModel::data(const QModelIndex &index, int role) const {
- if (!index.isValid() || index.column() != 0 || index.parent().isValid()) {
+ if (!index.isValid() || index.column() != 0 || index.parent().isValid())
+ return QVariant();
+
+ int row = index.row();
+ if (row >= m_data.size())
return QVariant();
- }
- int row(index.row());
- if (row >= m_data.size()) return QVariant();
return data(m_data.at(row), role);
}
-QVariant BtBookshelfModel::headerData(int section, Qt::Orientation orientation,
- int role) const {
- if (role == Qt::DisplayRole && orientation == Qt::Horizontal &&
- section == 0) {
+QVariant BtBookshelfModel::headerData(int section,
+ Qt::Orientation orientation,
+ int role) const
+{
+ if (role == Qt::DisplayRole
+ && orientation == Qt::Horizontal
+ && section == 0)
+ {
return tr("Module");
}
return QVariant();
}
-bool BtBookshelfModel::setData(const QModelIndex &index, const QVariant &value,
- int role) {
- int row(index.row());
- if (role == ModuleHiddenRole && row >= 0 && row < m_data.size()
- && index.column() == 0) {
+bool BtBookshelfModel::setData(const QModelIndex & index,
+ const QVariant & value,
+ int role)
+{
+ int row = index.row();
+ if (role == ModuleHiddenRole
+ && row >= 0
+ && row < m_data.size()
+ && index.column() == 0)
+ {
/*
Emitting dataChanged here is actually mandatory, but were not doing it
directly. Since we're connected to the module, changing its hidden
@@ -100,12 +103,12 @@ bool BtBookshelfModel::setData(const QModelIndex &index, const QVariant &value,
}
void BtBookshelfModel::clear(bool destroy) {
- if (m_data.size() <= 0) return;
+ if (m_data.size() <= 0)
+ return;
beginRemoveRows(QModelIndex(), 0, m_data.size() - 1);
- if (destroy) {
+ if (destroy)
qDeleteAll(m_data);
- }
m_data.clear();
endRemoveRows();
}
@@ -113,7 +116,8 @@ void BtBookshelfModel::clear(bool destroy) {
void BtBookshelfModel::addModule(CSwordModuleInfo * const module) {
Q_ASSERT(module != 0);
- if (m_data.contains(module)) return;
+ if (m_data.contains(module))
+ return;
const int index(m_data.size());
beginInsertRows(QModelIndex(), index, index);
@@ -127,23 +131,23 @@ void BtBookshelfModel::addModule(CSwordModuleInfo * const module) {
endInsertRows();
}
-void BtBookshelfModel::addModules(const QList<CSwordModuleInfo *> &modules) {
+void BtBookshelfModel::addModules(const QList<CSwordModuleInfo *> & modules) {
addModules(modules.toSet());
}
-void BtBookshelfModel::addModules(const QSet<CSwordModuleInfo *> &modules) {
+void BtBookshelfModel::addModules(const QSet<CSwordModuleInfo *> & modules) {
QList<CSwordModuleInfo *> newModules;
- Q_FOREACH(CSwordModuleInfo *module, modules) {
- if (!m_data.contains(module)) {
+ Q_FOREACH (CSwordModuleInfo * module, modules)
+ if (!m_data.contains(module))
newModules.append(module);
- }
- }
- if (newModules.isEmpty()) return;
+ if (newModules.isEmpty())
+ return;
- beginInsertRows(QModelIndex(), m_data.size(),
+ beginInsertRows(QModelIndex(),
+ m_data.size(),
m_data.size() + newModules.size() - 1);
- Q_FOREACH(CSwordModuleInfo *module, newModules) {
+ Q_FOREACH (CSwordModuleInfo * module, newModules) {
m_data.append(module);
connect(module, SIGNAL(hiddenChanged(bool)),
this, SLOT(moduleHidden(bool)));
@@ -157,8 +161,9 @@ void BtBookshelfModel::addModules(const QSet<CSwordModuleInfo *> &modules) {
void BtBookshelfModel::removeModule(CSwordModuleInfo * const module,
bool destroy) {
- const int index(m_data.indexOf(module));
- if (index == -1) return;
+ const int index = m_data.indexOf(module);
+ if (index == -1)
+ return;
beginRemoveRows(QModelIndex(), index, index);
disconnect(module, SIGNAL(hiddenChanged(bool)),
@@ -169,48 +174,51 @@ void BtBookshelfModel::removeModule(CSwordModuleInfo * const module,
this, SLOT(moduleUnlocked(bool)));
m_data.removeAt(index);
endRemoveRows();
- if (destroy) delete module;
+ if (destroy)
+ delete module;
}
-void BtBookshelfModel::removeModules(const QList<CSwordModuleInfo *> &modules,
- bool destroy) {
+void BtBookshelfModel::removeModules(const QList<CSwordModuleInfo *> & modules,
+ bool destroy)
+{
removeModules(modules.toSet(), destroy);
}
-void BtBookshelfModel::removeModules(const QSet<CSwordModuleInfo *> &modules,
- bool destroy) {
+void BtBookshelfModel::removeModules(const QSet<CSwordModuleInfo *> & modules,
+ bool destroy)
+{
// This is inefficient, since signals are emitted for each removed module:
- Q_FOREACH(CSwordModuleInfo *module, modules) {
+ Q_FOREACH (CSwordModuleInfo * module, modules)
removeModule(module, destroy);
- }
}
-CSwordModuleInfo* BtBookshelfModel::getModule(const QString &name) const {
- Q_FOREACH(CSwordModuleInfo *module, m_data) {
- if (UNLIKELY(module->name() == name)) return module;
- }
+CSwordModuleInfo * BtBookshelfModel::getModule(const QString & name) const {
+ Q_FOREACH (CSwordModuleInfo * module, m_data)
+ if (UNLIKELY(module->name() == name))
+ return module;
+
return 0;
}
void BtBookshelfModel::moduleHidden(bool) {
- Q_ASSERT(qobject_cast<CSwordModuleInfo*>(sender()) != 0);
+ Q_ASSERT(qobject_cast<CSwordModuleInfo *>(sender()) != 0);
- moduleDataChanged(static_cast<CSwordModuleInfo*>(sender()));
+ moduleDataChanged(static_cast<CSwordModuleInfo *>(sender()));
}
void BtBookshelfModel::moduleIndexed(bool) {
- Q_ASSERT(qobject_cast<CSwordModuleInfo*>(sender()) != 0);
+ Q_ASSERT(qobject_cast<CSwordModuleInfo *>(sender()) != 0);
- moduleDataChanged(static_cast<CSwordModuleInfo*>(sender()));
+ moduleDataChanged(static_cast<CSwordModuleInfo *>(sender()));
}
void BtBookshelfModel::moduleUnlocked(bool) {
- Q_ASSERT(qobject_cast<CSwordModuleInfo*>(sender()) != 0);
+ Q_ASSERT(qobject_cast<CSwordModuleInfo *>(sender()) != 0);
- moduleDataChanged(static_cast<CSwordModuleInfo*>(sender()));
+ moduleDataChanged(static_cast<CSwordModuleInfo *>(sender()));
}
-void BtBookshelfModel::moduleDataChanged(CSwordModuleInfo *module) {
+void BtBookshelfModel::moduleDataChanged(CSwordModuleInfo * module) {
Q_ASSERT(m_data.count(module) == 1);
QModelIndex i(index(m_data.indexOf(module), 0));
diff --git a/src/backend/bookshelfmodel/btbookshelfmodel.h b/src/backend/bookshelfmodel/btbookshelfmodel.h
index 20f2b3d..0884b4c 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -25,148 +25,157 @@
BtBookshelfTreeModel might be a better choice, since it also provides sorting and grouping.
*/
class BtBookshelfModel: public QAbstractListModel {
- Q_OBJECT
- public:
- enum ModuleRole {
- ModuleNameRole = Qt::DisplayRole,
- ModuleIconRole = Qt::DecorationRole,
- ModulePointerRole = Qt::UserRole,
- ModuleCategoryRole = Qt::UserRole + 1,
- ModuleLanguageRole = Qt::UserRole + 2,
- ModuleHiddenRole = Qt::UserRole + 3,
- 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);
- ~BtBookshelfModel();
-
- // 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 *>();
- }
-
- /**
- 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;
-
- /**
- 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;
+
+ Q_OBJECT
+
+public: /* Types: */
+
+ enum ModuleRole {
+ ModuleNameRole = Qt::DisplayRole,
+ ModuleIconRole = Qt::DecorationRole,
+ ModulePointerRole = Qt::UserRole,
+ ModuleCategoryRole = Qt::UserRole + 1,
+ ModuleLanguageRole = Qt::UserRole + 2,
+ ModuleHiddenRole = Qt::UserRole + 3,
+ ModuleInstallPathRole = Qt::UserRole + 4,
+ ModuleHasIndexRole = Qt::UserRole + 5,
+ ModuleIndexSizeRole = Qt::UserRole + 6,
+ ModuleDescriptionRole = Qt::UserRole + 7,
+ UserRole = Qt::UserRole + 100
+ };
+
+public: /* Methods: */
+
+ inline BtBookshelfModel(QObject * const parent = 0)
+ : QAbstractListModel(parent) {}
+
+ // 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 static_cast<CSwordModuleInfo *>(
+ data(index, BtBookshelfModel::ModulePointerRole).value<void *>());
+ }
+
+ /**
+ 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;
+
+ /**
+ 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);
+
+private: /* Methods: */
+
+ /**
+ 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);
+
+private: /* Fields: */
+
+ /**
+ The underlying data as a list of pointers to the respective CSwordModuleInfo
+ instances.
+ */
+ QList<CSwordModuleInfo *> m_data;
+
};
#endif // BTBOOKSHELFMODEL_H
diff --git a/src/backend/bookshelfmodel/btbookshelftreemodel.cpp b/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
index 0fcd14e..f3dbc4a 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -13,20 +13,19 @@
#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 "backend/config/btconfig.h"
#include "util/macros.h"
using namespace BookshelfModel;
-bool BtBookshelfTreeModel::Grouping::loadFrom(const QString &configKey) {
+bool BtBookshelfTreeModel::Grouping::loadFrom(const QString & configKey) {
Q_ASSERT(!configKey.isNull());
- QVariant v = CBTConfig::getConfig()->value(configKey);
+ QVariant v = btConfig().qVariantValue(configKey, QVariant());
if (!v.canConvert<Grouping>())
return false;
@@ -34,141 +33,142 @@ bool BtBookshelfTreeModel::Grouping::loadFrom(const QString &configKey) {
return true;
}
-void BtBookshelfTreeModel::Grouping::saveTo(const QString &configKey) const {
+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)
-{
- // 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)
-{
- // Intentionally empty
-}
+ btConfig().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) {}
+
+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) {}
+
+BtBookshelfTreeModel::BtBookshelfTreeModel(const Grouping & grouping,
+ QObject * parent)
+ : QAbstractItemModel(parent)
+ , m_sourceModel(0)
+ , m_rootItem(new RootItem)
+ , m_groupingOrder(grouping)
+ , m_defaultChecked(MODULE_HIDDEN)
+ , m_checkable(false) {}
BtBookshelfTreeModel::~BtBookshelfTreeModel() {
delete m_rootItem;
}
-int BtBookshelfTreeModel::rowCount(const QModelIndex &parent) const {
- return getItem(parent)->children().size();
+int BtBookshelfTreeModel::rowCount(const QModelIndex & parent) const {
+ return getItem(parent).children().size();
}
-int BtBookshelfTreeModel::columnCount(const QModelIndex &parent) const {
+int BtBookshelfTreeModel::columnCount(const QModelIndex & parent) const {
Q_UNUSED(parent);
return 1;
}
-bool BtBookshelfTreeModel::hasChildren(const QModelIndex &parent) const {
- return !getItem(parent)->children().isEmpty();
+bool BtBookshelfTreeModel::hasChildren(const QModelIndex & parent) const {
+ return !getItem(parent).children().isEmpty();
}
QModelIndex BtBookshelfTreeModel::index(int row, int column,
- const QModelIndex &parent) const {
+ const QModelIndex & parent) const
+{
if (!hasIndex(row, column, parent)) return QModelIndex();
- Item *parentItem(getItem(parent));
- Item *childItem(parentItem->children().at(row));
- if (childItem != 0) {
- return createIndex(row, column, childItem);
- }
- else {
+ Item & parentItem = getItem(parent);
+ Item * const childItem = parentItem.children().at(row);
+ if (!childItem)
return QModelIndex();
- }
+
+ return createIndex(row, column, childItem);
}
-QModelIndex BtBookshelfTreeModel::parent(const QModelIndex &index) const {
- if (!index.isValid()) return QModelIndex();
+QModelIndex BtBookshelfTreeModel::parent(const QModelIndex & index) const {
+ if (!index.isValid())
+ return QModelIndex();
- Item *childItem(static_cast<Item*>(index.internalPointer()));
+ Item * childItem(static_cast<Item*>(index.internalPointer()));
Q_ASSERT(childItem != 0);
- Item *parentItem(childItem->parent());
+ Item * parentItem(childItem->parent());
Q_ASSERT(parentItem != 0);
- if (parentItem == m_rootItem) {
+ if (parentItem == m_rootItem)
return QModelIndex();
- }
+
return createIndex(parentItem->childIndex(), 0, parentItem);
}
-QVariant BtBookshelfTreeModel::data(const QModelIndex &index, int role) const {
- if (!index.isValid() || index.column() != 0) {
+QVariant BtBookshelfTreeModel::data(const QModelIndex & index, int role) const {
+ if (!index.isValid() || index.column() != 0)
return QVariant();
- }
- Item *i(static_cast<Item*>(index.internalPointer()));
+ const Item * const i = static_cast<Item*>(index.internalPointer());
Q_ASSERT(i != 0);
switch (role) {
+
case Qt::CheckStateRole:
- if (!m_checkable) break;
+ if (!m_checkable)
+ break;
+
case BtBookshelfTreeModel::CheckStateRole:
return i->checkState();
+
case BtBookshelfModel::ModulePointerRole:
/* This case is just an optimization. */
if (i->type() == Item::ITEM_MODULE) {
- ModuleItem *mi(static_cast<ModuleItem *>(i));
- return qVariantFromValue((void*) mi->moduleInfo());
+ const ModuleItem & mi = *static_cast<const ModuleItem *>(i);
+ return qVariantFromValue(static_cast<void *>(&mi.moduleInfo()));
}
return 0;
+
case Qt::DisplayRole:
case Qt::DecorationRole:
case BtBookshelfModel::ModuleHiddenRole:
default:
- if (i->type() == Item::ITEM_MODULE) {
- ModuleItem *item(static_cast<ModuleItem *>(i));
- CSwordModuleInfo* m(item->moduleInfo());
- return data(m, role);
- }
- else {
- return i->data(role);
- }
+ if (i->type() == Item::ITEM_MODULE)
+ return data(static_cast<const ModuleItem *>(i)->moduleInfo(), role);
+
+ return i->data(role);
+
}
return QVariant();
}
-QVariant BtBookshelfTreeModel::data(CSwordModuleInfo *module, int role) const {
- Q_ASSERT(m_sourceIndexMap.contains(module));
- return m_sourceModel->data(m_sourceIndexMap.value(module), role);
+QVariant BtBookshelfTreeModel::data(CSwordModuleInfo & module, int role) const {
+ Q_ASSERT(m_sourceIndexMap.contains(&module));
+ return m_sourceModel->data(m_sourceIndexMap.value(&module), role);
}
-bool BtBookshelfTreeModel::setData(const QModelIndex &itemIndex,
- const QVariant &value,
+bool BtBookshelfTreeModel::setData(const QModelIndex & itemIndex,
+ const QVariant & value,
int role) {
Q_ASSERT(itemIndex.isValid());
typedef QPair<Item *, QModelIndex> IP;
- Qt::CheckState newState;
- if (LIKELY(role == Qt::CheckStateRole)) {
- bool ok;
- newState = (Qt::CheckState) value.toInt(&ok);
- if (UNLIKELY(!ok)) return false;
- }
- else {
+ if (UNLIKELY(role != Qt::CheckStateRole))
+ return false;
+
+ bool ok;
+ Qt::CheckState newState = static_cast<Qt::CheckState>(value.toInt(&ok));
+ if (UNLIKELY(!ok))
return false;
- }
// Handle partially checked as checked here in setData():
- if (newState == Qt::PartiallyChecked) newState = Qt::Checked;
+ if (newState == Qt::PartiallyChecked)
+ newState = Qt::Checked;
- Item *item(static_cast<Item*>(itemIndex.internalPointer()));
+ Item * item = static_cast<Item *>(itemIndex.internalPointer());
Q_ASSERT(item != 0);
if (item->checkState() == newState) return false;
@@ -180,25 +180,23 @@ bool BtBookshelfTreeModel::setData(const QModelIndex &itemIndex,
item->setCheckState(newState);
emit dataChanged(p.second, p.second);
if (item->type() == Item::ITEM_MODULE) {
- ModuleItem *mItem(static_cast<ModuleItem*>(item));
- CSwordModuleInfo *mInfo(mItem->moduleInfo());
+ ModuleItem & mItem = *static_cast<ModuleItem *>(item);
+ CSwordModuleInfo & mInfo = mItem.moduleInfo();
if (newState == Qt::Checked) {
- m_checkedModulesCache.insert(mInfo);
- emit moduleChecked(mInfo, true);
- }
- else {
- m_checkedModulesCache.remove(mInfo);
- emit moduleChecked(mInfo, false);
+ m_checkedModulesCache.insert(&mInfo);
+ emit moduleChecked(&mInfo, true);
+ } else {
+ m_checkedModulesCache.remove(&mInfo);
+ emit moduleChecked(&mInfo, false);
}
- }
- else {
- const QList<Item*> &children(item->children());
- for (int i(0); i < children.size(); i++) {
+ } else {
+ const QList<Item *> & children = item->children();
+ for (int i = 0; i < children.size(); i++)
q.append(IP(children.at(i), index(i, 0, p.second)));
- }
}
}
- if (q.empty()) break;
+ if (q.empty())
+ break;
p = q.takeFirst();
item = p.first;
}
@@ -209,36 +207,36 @@ bool BtBookshelfTreeModel::setData(const QModelIndex &itemIndex,
return true;
}
-Qt::ItemFlags BtBookshelfTreeModel::flags(const QModelIndex &index) const {
- if (!index.isValid()) return 0;
+Qt::ItemFlags BtBookshelfTreeModel::flags(const QModelIndex & index) const {
+ if (!index.isValid())
+ return 0;
Qt::ItemFlags f(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
if (m_checkable) {
f |= Qt::ItemIsUserCheckable;
- Item *i(static_cast<Item*>(index.internalPointer()));
- Q_ASSERT(i != 0);
-
- if (i->type() != Item::ITEM_MODULE) {
+ const Item & i = *static_cast<Item*>(index.internalPointer());
+ if (i.type() != Item::ITEM_MODULE)
f |= Qt::ItemIsTristate;
- }
}
return f;
}
QVariant BtBookshelfTreeModel::headerData(int section,
- Qt::Orientation orientation,
- int role) const {
- if (orientation == Qt::Horizontal) {
+ Qt::Orientation orientation,
+ int role) const
+{
+ if (orientation == Qt::Horizontal)
return m_sourceModel->headerData(section, orientation, role);
- }
+
return QVariant();
}
-void BtBookshelfTreeModel::setSourceModel(QAbstractItemModel *sourceModel) {
- if (m_sourceModel == sourceModel) return;
+void BtBookshelfTreeModel::setSourceModel(QAbstractItemModel * sourceModel) {
+ if (m_sourceModel == sourceModel)
+ return;
if (m_sourceModel != 0) {
disconnect(this, SLOT(moduleInserted(QModelIndex, int, int)));
@@ -263,43 +261,38 @@ void BtBookshelfTreeModel::setSourceModel(QAbstractItemModel *sourceModel) {
connect(sourceModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
this, SLOT(moduleDataChanged(QModelIndex, QModelIndex)));
- for (int i(0); i < sourceModel->rowCount(); i++) {
- typedef BtBookshelfModel::ModuleRole MRole;
- static const MRole HR(BtBookshelfModel::ModuleHiddenRole);
- static const MRole PR(BtBookshelfModel::ModulePointerRole);
- static const MRole IR(BtBookshelfModel::ModuleHasIndexRole);
-
- QModelIndex moduleIndex(sourceModel->index(i, 0));
- CSwordModuleInfo *module(
- static_cast<CSwordModuleInfo *>(
- sourceModel->data(moduleIndex, PR).value<void*>()
- )
- );
- Q_ASSERT(module != 0);
+ for (int i = 0; i < sourceModel->rowCount(); i++) {
+ const QModelIndex moduleIndex(sourceModel->index(i, 0));
+ CSwordModuleInfo & module = *static_cast<CSwordModuleInfo *>(
+ sourceModel->data(moduleIndex,
+ BtBookshelfModel::ModulePointerRole).value<void*>());
+
bool checked;
if (m_defaultChecked == MODULE_HIDDEN) {
- checked = !sourceModel->data(moduleIndex, HR).toBool();
- }
- else if (m_defaultChecked == MODULE_INDEXED) {
- checked = !sourceModel->data(moduleIndex, IR).toBool();
- }
- else {
+ checked = !sourceModel->data(moduleIndex,
+ BtBookshelfModel::ModuleHiddenRole).toBool();
+ } else if (m_defaultChecked == MODULE_INDEXED) {
+ checked = !sourceModel->data(moduleIndex,
+ BtBookshelfModel::ModuleHasIndexRole).toBool();
+ } else {
checked = (m_defaultChecked == CHECKED);
}
- m_sourceIndexMap[module] = moduleIndex;
+ m_sourceIndexMap[&module] = moduleIndex;
addModule(module, checked);
}
}
}
-void BtBookshelfTreeModel::setGroupingOrder(const Grouping &groupingOrder,
+void BtBookshelfTreeModel::setGroupingOrder(const Grouping & groupingOrder,
bool emitSignal)
{
- if (m_groupingOrder == groupingOrder) return;
+ if (m_groupingOrder == groupingOrder)
+ return;
+
m_groupingOrder = groupingOrder;
if (m_sourceModel != 0) {
- QSet<CSwordModuleInfo*> checked(m_checkedModulesCache);
+ const QSet<CSwordModuleInfo *> checked(m_checkedModulesCache);
m_checkedModulesCache.clear();
beginRemoveRows(QModelIndex(), 0, m_rootItem->children().size() - 1);
@@ -308,42 +301,39 @@ void BtBookshelfTreeModel::setGroupingOrder(const Grouping &groupingOrder,
m_rootItem = new RootItem;
endRemoveRows();
- for (int i(0); i < m_sourceModel->rowCount(); i++) {
- QModelIndex sourceIndex(m_sourceModel->index(i, 0));
- CSwordModuleInfo *module(
- static_cast<CSwordModuleInfo *>(
- m_sourceModel->data(
- sourceIndex,
- BtBookshelfModel::ModulePointerRole
- ).value<void*>()
- )
- );
- Q_ASSERT(module != 0);
- m_sourceIndexMap[module] = sourceIndex;
- addModule(module, checked.contains(module));
+ for (int i = 0; i < m_sourceModel->rowCount(); i++) {
+ const QModelIndex sourceIndex(m_sourceModel->index(i, 0));
+ CSwordModuleInfo & module = *static_cast<CSwordModuleInfo *>(
+ m_sourceModel->data(sourceIndex,
+ BtBookshelfModel::ModulePointerRole).value<void *>());
+ m_sourceIndexMap[&module] = sourceIndex;
+ addModule(module, checked.contains(&module));
}
}
- if (emitSignal) emit groupingOrderChanged(groupingOrder);
+ if (emitSignal)
+ emit groupingOrderChanged(groupingOrder);
}
void BtBookshelfTreeModel::setCheckable(bool checkable) {
- if (m_checkable == checkable) return;
+ if (m_checkable == checkable)
+ return;
m_checkable = checkable;
- if (m_sourceModel == 0) return;
+ if (m_sourceModel == 0)
+ return;
// Notify views that flags changed for all items:
resetData();
}
-void BtBookshelfTreeModel::setCheckedModules(const QSet<CSwordModuleInfo*> &modules) {
+void BtBookshelfTreeModel::setCheckedModules(const QSet<CSwordModuleInfo *> & modules) {
typedef ModuleItemMap::const_iterator MIMCI;
- for (MIMCI it(m_modules.constBegin()); it != m_modules.constEnd(); it++) {
+ for (MIMCI it = m_modules.constBegin(); it != m_modules.constEnd(); ++it) {
if (modules.contains(it.key())) {
- setData(getIndex(it.value()), Qt::Checked, Qt::CheckStateRole);
+ setData(getIndex(*it.value()), Qt::Checked, Qt::CheckStateRole);
} else {
- setData(getIndex(it.value()), Qt::Unchecked, Qt::CheckStateRole);
+ setData(getIndex(*it.value()), Qt::Unchecked, Qt::CheckStateRole);
}
}
}
@@ -355,18 +345,17 @@ void BtBookshelfTreeModel::resetData() {
QModelIndex parent(queue.takeFirst());
emit dataChanged(index(0, 0, parent),
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) {
+ for (int i = 0; i < rowCount(parent); i++) {
+ const QModelIndex childIndex(index(i, 0, parent));
+ if (rowCount(childIndex) > 0)
queue.append(childIndex);
- }
}
- }
- while (!queue.isEmpty());
+ } while (!queue.isEmpty());
}
-void BtBookshelfTreeModel::addModule(CSwordModuleInfo *module, bool checked) {
- if (m_modules.contains(module)) return;
+void BtBookshelfTreeModel::addModule(CSwordModuleInfo & module, bool checked) {
+ if (m_modules.contains(&module))
+ return;
#if QT_VERSION >= 0x040600
beginResetModel();
@@ -388,42 +377,43 @@ void BtBookshelfTreeModel::addModule(CSwordModuleInfo *module, bool checked) {
#endif
}
-void BtBookshelfTreeModel::addModule(CSwordModuleInfo *module,
+void BtBookshelfTreeModel::addModule(CSwordModuleInfo & module,
QModelIndex parentIndex,
- Grouping &intermediateGrouping,
- bool checked) {
- Q_ASSERT(module != 0);
-
+ Grouping & intermediateGrouping,
+ bool checked)
+{
if (!intermediateGrouping.empty()) {
QModelIndex newIndex;
switch (intermediateGrouping.front()) {
+
case GROUP_CATEGORY:
newIndex = getGroup<CategoryItem>(module, parentIndex);
break;
+
case GROUP_LANGUAGE:
newIndex = getGroup<LanguageItem>(module, parentIndex);
break;
+
case GROUP_INDEXING:
newIndex = getGroup<IndexingItem>(module, parentIndex);
break;
+
}
intermediateGrouping.pop_front();
addModule(module, newIndex, intermediateGrouping, checked);
- }
- else {
- Item *parentItem(getItem(parentIndex));
- ModuleItem *newItem(new ModuleItem(module, this));
+ } else {
+ Item & parentItem = getItem(parentIndex);
+ ModuleItem * const newItem = new ModuleItem(module, *this);
newItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
- const int newIndex(parentItem->indexFor(newItem));
+ const int newIndex(parentItem.indexFor(newItem));
// Actually do the insertion:
beginInsertRows(parentIndex, newIndex, newIndex);
- parentItem->insertChild(newIndex, newItem);
- m_modules.insert(module, newItem);
- if (checked) {
- // Add to checked modules cache
- m_checkedModulesCache.insert(module);
- }
+ parentItem.insertChild(newIndex, newItem);
+ m_modules.insert(&module, newItem);
+ if (checked) // Add to checked modules cache
+ m_checkedModulesCache.insert(&module);
+
endInsertRows();
// Reset parent item check states, if needed:
@@ -431,85 +421,84 @@ void BtBookshelfTreeModel::addModule(CSwordModuleInfo *module,
}
}
-void BtBookshelfTreeModel::removeModule(CSwordModuleInfo *module) {
- if (!m_modules.contains(module)) return;
+void BtBookshelfTreeModel::removeModule(CSwordModuleInfo & module) {
+ typedef ModuleItemMap::iterator MIMI;
+ const MIMI it = m_modules.find(&module);
+ if (it == m_modules.end())
+ return;
- Item *i(m_modules[module]);
+ Item * i = it.value();
// Set i to be the lowest item (including empty groups) to remove:
- Q_ASSERT(i->parent() != 0);
- while (i->parent() != m_rootItem && i->parent()->children().size() <= 1) {
+ Q_ASSERT(i->parent());
+ while (i->parent() != m_rootItem && i->parent()->children().size() <= 1)
i = i->parent();
- }
- Q_ASSERT(i != 0);
- Q_ASSERT(i->parent() != 0);
+ Q_ASSERT(i);
+ Q_ASSERT(i->parent());
// Calculate item indexes:
- int index(i->childIndex());
- QModelIndex parentIndex(getIndex(i->parent()));
+ const int index = i->childIndex();
+ const QModelIndex parentIndex(getIndex(*i->parent()));
// Actually remove the item:
beginRemoveRows(parentIndex, index, index);
delete i->parent()->children().takeAt(index);
- m_modules.remove(module);
- m_checkedModulesCache.remove(module);
+ m_modules.erase(it);
+ m_checkedModulesCache.remove(&module);
endRemoveRows();
// Reset parent item check states, if needed:
resetParentCheckStates(parentIndex);
}
-Item *BtBookshelfTreeModel::getItem(const QModelIndex &index) const {
- if (LIKELY(index.isValid())) {
- Item *item(static_cast<Item*>(index.internalPointer()));
- Q_ASSERT(item != 0);
- return item;
- }
- else {
- return m_rootItem;
- }
-}
+Item & BtBookshelfTreeModel::getItem(const QModelIndex & index) const {
+ if (UNLIKELY(!index.isValid()))
+ return *m_rootItem;
-QModelIndex BtBookshelfTreeModel::getIndex(const BookshelfModel::Item *item) {
- Q_ASSERT(item != 0);
+ Item * const item = static_cast<Item *>(index.internalPointer());
+ Q_ASSERT(item);
+ return *item;
+}
+QModelIndex BtBookshelfTreeModel::getIndex(const BookshelfModel::Item & item) {
+ const BookshelfModel::Item * it = &item;
QList<int> indexes;
for (;;) {
- int i(item->childIndex());
- if (i < 0) break;
+ const int i = it->childIndex();
+ if (i < 0)
+ break;
indexes.append(i);
- item = item->parent();
+ it = it->parent();
}
QModelIndex i;
- while (!indexes.isEmpty()) {
+ while (!indexes.isEmpty())
i = index(indexes.takeLast(), 0, i);
- }
return i;
}
void BtBookshelfTreeModel::resetParentCheckStates(QModelIndex parentIndex) {
for ( ; parentIndex.isValid(); parentIndex = parentIndex.parent()) {
- Item *parentItem(static_cast<Item*>(parentIndex.internalPointer()));
- Q_ASSERT(parentItem != 0);
-
- Qt::CheckState oldState(parentItem->checkState());
- bool haveCheckedChildren(false);
- bool haveUncheckedChildren(false);
- for (int i(0); i < parentItem->children().size(); i++) {
- Qt::CheckState state(parentItem->children().at(i)->checkState());
+ Item & parentItem = *static_cast<Item *>(parentIndex.internalPointer());
+
+ const Qt::CheckState oldState = parentItem.checkState();
+ bool haveCheckedChildren = false;
+ bool haveUncheckedChildren = false;
+ for (int i = 0; i < parentItem.children().size(); i++) {
+ const Qt::CheckState state = parentItem.children().at(i)->checkState();
if (state == Qt::PartiallyChecked) {
haveCheckedChildren = true;
haveUncheckedChildren = true;
break;
- }
- else if (state == Qt::Checked) {
+ } else if (state == Qt::Checked) {
haveCheckedChildren = true;
- if (haveUncheckedChildren) break;
- }
- else if (state == Qt::Unchecked) {
+ if (haveUncheckedChildren)
+ break;
+ } else {
+ Q_ASSERT(state == Qt::Unchecked);
haveUncheckedChildren = true;
- if (haveCheckedChildren) break;
+ if (haveCheckedChildren)
+ break;
}
}
@@ -517,35 +506,34 @@ void BtBookshelfTreeModel::resetParentCheckStates(QModelIndex parentIndex) {
if (haveCheckedChildren) {
if (haveUncheckedChildren) {
newState = Qt::PartiallyChecked;
- }
- else {
+ } else {
newState = Qt::Checked;
}
- }
- else {
+ } else {
newState = Qt::Unchecked;
}
- if (newState == oldState) break;
+ if (newState == oldState)
+ break;
- parentItem->setCheckState(newState);
+ parentItem.setCheckState(newState);
emit dataChanged(parentIndex, parentIndex);
} // for ( ; parentIndex.isValid(); parentIndex = parentIndex.parent())
}
-void BtBookshelfTreeModel::moduleDataChanged(const QModelIndex &topLeft,
- const QModelIndex &bottomRight) {
- typedef BtBookshelfModel BM;
- static const BM::ModuleRole PR(BM::ModulePointerRole);
-
+void BtBookshelfTreeModel::moduleDataChanged(const QModelIndex & topLeft,
+ const QModelIndex & bottomRight)
+{
Q_ASSERT(!topLeft.parent().isValid());
Q_ASSERT(!bottomRight.parent().isValid());
- Q_ASSERT(topLeft.column() == 0 && bottomRight.column() == 0);
-
- for (int i(topLeft.row()); i <= bottomRight.row(); i++) {
- QModelIndex moduleIndex(m_sourceModel->index(i, 0, topLeft.parent()));
- QVariant data(m_sourceModel->data(moduleIndex, PR));
- CSwordModuleInfo *module((CSwordModuleInfo *) (data.value<void*>()));
- QModelIndex itemIndex(getIndex(m_modules[module]));
+ Q_ASSERT(topLeft.column() == 0);
+ Q_ASSERT(bottomRight.column() == 0);
+
+ for (int i = topLeft.row(); i <= bottomRight.row(); i++) {
+ const QModelIndex moduleIndex(m_sourceModel->index(i, 0, topLeft.parent()));
+ const QVariant data(m_sourceModel->data(moduleIndex,
+ BtBookshelfModel::ModulePointerRole));
+ CSwordModuleInfo & module = *static_cast<CSwordModuleInfo *>(data.value<void *>());
+ QModelIndex itemIndex(getIndex(*m_modules[&module]));
Q_ASSERT(itemIndex.isValid());
emit dataChanged(itemIndex, itemIndex);
@@ -557,67 +545,73 @@ void BtBookshelfTreeModel::moduleDataChanged(const QModelIndex &topLeft,
do {
itemIndex = itemIndex.parent();
emit dataChanged(itemIndex, itemIndex);
- }
- while (itemIndex.isValid());
+ } while (itemIndex.isValid());
}
}
-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);
- static const BM::ModuleRole IR(BM::ModuleHasIndexRole);
+void BtBookshelfTreeModel::moduleInserted(const QModelIndex & parent,
+ int start,
+ int end)
+{
+ Q_ASSERT(start <= end);
- for (int i(start); i <= end; i++) {
- QModelIndex moduleIndex(m_sourceModel->index(i, 0, parent));
- QVariant data(m_sourceModel->data(moduleIndex, PR));
- CSwordModuleInfo *module((CSwordModuleInfo *) (data.value<void*>()));
+ for (int i = start; i <= end; i++) {
+ const QModelIndex moduleIndex(m_sourceModel->index(i, 0, parent));
+ const QVariant data(m_sourceModel->data(moduleIndex,
+ BtBookshelfModel::ModulePointerRole));
+ CSwordModuleInfo & module = *static_cast<CSwordModuleInfo *>(data.value<void *>());
bool checked;
if (m_defaultChecked == MODULE_HIDDEN) {
- checked = !m_sourceModel->data(moduleIndex, HR).toBool();
- }
- else if (m_defaultChecked == MODULE_INDEXED) {
- checked = !m_sourceModel->data(moduleIndex, IR).toBool();
- }
- else {
+ checked = !m_sourceModel->data(moduleIndex,
+ BtBookshelfModel::ModuleHiddenRole).toBool();
+ } else if (m_defaultChecked == MODULE_INDEXED) {
+ checked = !m_sourceModel->data(moduleIndex,
+ BtBookshelfModel::ModuleHasIndexRole).toBool();
+ } else {
+ Q_ASSERT(m_defaultChecked == CHECKED || m_defaultChecked == UNCHECKED);
checked = (m_defaultChecked == CHECKED);
}
- m_sourceIndexMap[module] = moduleIndex;
+ m_sourceIndexMap[&module] = moduleIndex;
addModule(module, checked);
}
}
-void BtBookshelfTreeModel::moduleRemoved(const QModelIndex &parent, int start, int end) {
- typedef BtBookshelfModel BM;
- static const BM::ModuleRole PR(BM::ModulePointerRole);
-
- for (int i(start); i <= end; i++) {
- QModelIndex moduleIndex(m_sourceModel->index(i, 0, parent));
- QVariant data(m_sourceModel->data(moduleIndex, PR));
- CSwordModuleInfo *module((CSwordModuleInfo *) (data.value<void*>()));
+void BtBookshelfTreeModel::moduleRemoved(const QModelIndex & parent,
+ int start,
+ int end)
+{
+ Q_ASSERT(start <= end);
+ for (int i = start; i <= end; i++) {
+ const QModelIndex moduleIndex(m_sourceModel->index(i, 0, parent));
+ const QVariant data(m_sourceModel->data(moduleIndex,
+ BtBookshelfModel::ModulePointerRole));
+ CSwordModuleInfo & module = *static_cast<CSwordModuleInfo *>(data.value<void*>());
removeModule(module);
- m_sourceIndexMap.remove(module);
+ m_sourceIndexMap.remove(&module);
}
}
-QDataStream &operator<<(QDataStream &os, const BtBookshelfTreeModel::Grouping &o) {
+QDataStream & operator <<(QDataStream & os,
+ const BtBookshelfTreeModel::Grouping & o)
+{
os << o.size();
- Q_FOREACH(BtBookshelfTreeModel::Group g, o) {
- os << (int) g;
- }
+ Q_FOREACH(BtBookshelfTreeModel::Group g, o)
+ os << static_cast<int>(g);
return os;
}
-QDataStream &operator>>(QDataStream &is, BtBookshelfTreeModel::Grouping &o) {
+QDataStream & operator >>(QDataStream & is,
+ BtBookshelfTreeModel::Grouping & o)
+{
int s;
is >> s;
o.clear();
- for (int i(0); i < s; i++) {
+ for (int i = 0; i < s; i++) {
int g;
is >> g;
- o.append((BtBookshelfTreeModel::Group) g);
+ o.append(static_cast<BtBookshelfTreeModel::Group>(g));
}
return is;
}
diff --git a/src/backend/bookshelfmodel/btbookshelftreemodel.h b/src/backend/bookshelfmodel/btbookshelftreemodel.h
index 085095d..14c3289 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -23,157 +23,181 @@
#include "backend/bookshelfmodel/item.h"
-namespace BookshelfModel {
-class ModuleItem;
-}
+namespace BookshelfModel { class ModuleItem; }
class CSwordModuleInfo;
class QDataStream;
class BtBookshelfTreeModel: public QAbstractItemModel {
- Q_OBJECT
- Q_ENUMS(Group)
-
- typedef QMap<CSwordModuleInfo*, BookshelfModel::ModuleItem*> ModuleItemMap;
- typedef QMap<CSwordModuleInfo*, QPersistentModelIndex> SourceIndexMap;
-
- public: /* Types: */
- enum ModuleRole {
- CheckStateRole = BtBookshelfModel::UserRole,
- UserRole = BtBookshelfModel::UserRole + 100
- };
- enum Group {
- GROUP_CATEGORY = 0,
- GROUP_LANGUAGE = 1,
- GROUP_INDEXING
- };
- enum CheckedBehavior {
- CHECKED, /**< Check all added modules by default. */
- UNCHECKED, /**< Uncheck all added modules by default. */
- MODULE_HIDDEN, /**< By default, check only added modules that are not hidden. */
- MODULE_INDEXED /**< By default, check only added modules that are indexed. */
- };
-
- 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) {
- if (loadFrom(configKey))
- return;
- push_back(GROUP_CATEGORY);
- push_back(GROUP_LANGUAGE);
- }
- 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();
-
- virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
- virtual int columnCount(const QModelIndex &parent = QModelIndex())
- const;
- virtual bool hasChildren(const QModelIndex &parent = QModelIndex())
- const;
- virtual QModelIndex index(int row, int column,
- const QModelIndex &parent = QModelIndex())
- const;
- virtual QModelIndex parent(const QModelIndex &index) const;
- virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- QVariant data(CSwordModuleInfo *module, int role = Qt::DisplayRole) const;
- virtual Qt::ItemFlags flags(const QModelIndex &index) const;
- virtual QVariant headerData(int section, Qt::Orientation orientation,
- int role = Qt::DisplayRole) const;
- virtual bool setData(const QModelIndex &index, const QVariant &value,
- int role);
-
- 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 void setDefaultChecked(CheckedBehavior b) {
- m_defaultChecked = b;
- }
- void setCheckedModules(const QSet<CSwordModuleInfo*> &modules);
-
- 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,
- Grouping &intermediateGrouping, bool checked);
- void removeModule(CSwordModuleInfo *module);
-
- BookshelfModel::Item *getItem(const QModelIndex &index) const;
- QModelIndex getIndex(const BookshelfModel::Item *item);
- void resetParentCheckStates(QModelIndex parentIndex);
-
- template <class T>
- QModelIndex getGroup(CSwordModuleInfo *module,
- QModelIndex parentIndex) {
- BookshelfModel::Item *parentItem(getItem(parentIndex));
- int groupIndex;
- T *groupItem(parentItem->getGroupItem<T>(module, groupIndex));
-
- if (groupItem == 0) {
- groupItem = new T(module);
- groupIndex = parentItem->indexFor(groupItem);
- beginInsertRows(parentIndex, groupIndex, groupIndex);
- parentItem->insertChild(groupIndex, groupItem);
- endInsertRows();
+ Q_OBJECT
+ Q_ENUMS(Group)
+
+private: /* Types: */
+
+ typedef QMap<CSwordModuleInfo *, BookshelfModel::ModuleItem *> ModuleItemMap;
+ typedef QMap<CSwordModuleInfo *, QPersistentModelIndex> SourceIndexMap;
+
+public: /* Types: */
+
+ enum ModuleRole {
+ CheckStateRole = BtBookshelfModel::UserRole,
+ UserRole = BtBookshelfModel::UserRole + 100
+ };
+
+ enum Group {
+ GROUP_CATEGORY = 0,
+ GROUP_LANGUAGE = 1,
+ GROUP_INDEXING
+ };
+
+ enum CheckedBehavior {
+ CHECKED, /**< Check all added modules by default. */
+ UNCHECKED, /**< Uncheck all added modules by default. */
+ MODULE_HIDDEN, /**< By default, check only added modules that are not hidden. */
+ MODULE_INDEXED /**< By default, check only added modules that are indexed. */
+ };
+
+ class Grouping: public QList<Group> {
+
+ public: /* Methods: */
+
+ /**
+ \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) {
+ if (loadFrom(configKey))
+ return;
+ push_back(GROUP_CATEGORY);
+ push_back(GROUP_LANGUAGE);
}
- return index(groupIndex, 0, parentIndex);
+
+ 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();
+
+ virtual int rowCount(const QModelIndex & parent = QModelIndex()) const;
+ virtual int columnCount(const QModelIndex & parent = QModelIndex())
+ const;
+ virtual bool hasChildren(const QModelIndex & parent = QModelIndex())
+ const;
+ virtual QModelIndex index(int row,
+ int column,
+ const QModelIndex & parent = QModelIndex())
+ const;
+ virtual QModelIndex parent(const QModelIndex & index) const;
+ virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
+ QVariant data(CSwordModuleInfo & module, int role = Qt::DisplayRole) const;
+ virtual Qt::ItemFlags flags(const QModelIndex & index) const;
+ virtual QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+ virtual bool setData(const QModelIndex & index,
+ const QVariant & value,
+ int role);
+
+ 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 void setDefaultChecked(CheckedBehavior b) {
+ m_defaultChecked = b;
+ }
+ void setCheckedModules(const QSet<CSwordModuleInfo *> & modules);
+
+signals:
+
+ void groupingOrderChanged(BtBookshelfTreeModel::Grouping newGrouping);
+ void moduleChecked(CSwordModuleInfo * module, bool checked);
+
+protected: /* Methods: */
+
+ void resetData();
+
+protected slots:
+
+ void moduleDataChanged(const QModelIndex & topLeft,
+ const QModelIndex & bottomRight);
+ void moduleInserted(const QModelIndex & parent, int start, int end);
+ void moduleRemoved(const QModelIndex & parent, int start, int end);
+
+private: /* Methods: */
+
+ void addModule(CSwordModuleInfo & module, bool checked);
+ void addModule(CSwordModuleInfo & module,
+ QModelIndex parentIndex,
+ Grouping & intermediateGrouping,
+ bool checked);
+ void removeModule(CSwordModuleInfo & module);
+
+ BookshelfModel::Item & getItem(const QModelIndex & index) const;
+ QModelIndex getIndex(const BookshelfModel::Item & item);
+ void resetParentCheckStates(QModelIndex parentIndex);
+
+ template <class T>
+ QModelIndex getGroup(CSwordModuleInfo & module,
+ QModelIndex parentIndex)
+ {
+ BookshelfModel::Item & parentItem = getItem(parentIndex);
+ int groupIndex;
+ T * groupItem = parentItem.getGroupItem<T>(module, groupIndex);
+
+ if (!groupItem) {
+ groupItem = new T(module);
+ groupIndex = parentItem.indexFor(groupItem);
+ beginInsertRows(parentIndex, groupIndex, groupIndex);
+ parentItem.insertChild(groupIndex, groupItem);
+ endInsertRows();
}
+ return index(groupIndex, 0, parentIndex);
+ }
+
+private: /* Fields: */
+
+ QAbstractItemModel * m_sourceModel;
+ BookshelfModel::Item * m_rootItem;
+ ModuleItemMap m_modules;
+ SourceIndexMap m_sourceIndexMap;
+ Grouping m_groupingOrder;
+ CheckedBehavior m_defaultChecked;
+ bool m_checkable;
+
+ QSet<CSwordModuleInfo *> m_checkedModulesCache;
- protected slots:
- void moduleDataChanged(const QModelIndex &topLeft,
- const QModelIndex &bottomRight);
- void moduleInserted(const QModelIndex &parent, int start, int end);
- void moduleRemoved(const QModelIndex &parent, int start, int end);
-
- protected:
- QAbstractItemModel *m_sourceModel;
- BookshelfModel::Item *m_rootItem;
- ModuleItemMap m_modules;
- SourceIndexMap m_sourceIndexMap;
- Grouping m_groupingOrder;
- CheckedBehavior m_defaultChecked;
- bool m_checkable;
-
- QSet<CSwordModuleInfo*> m_checkedModulesCache;
};
-QDataStream &operator<<(QDataStream &os, const BtBookshelfTreeModel::Grouping &o);
-QDataStream &operator>>(QDataStream &is, BtBookshelfTreeModel::Grouping &o);
+QDataStream & operator <<(QDataStream & os, const BtBookshelfTreeModel::Grouping & o);
+QDataStream & operator >>(QDataStream & is, BtBookshelfTreeModel::Grouping & o);
-Q_DECLARE_METATYPE(BtBookshelfTreeModel::Grouping);
+Q_DECLARE_METATYPE(BtBookshelfTreeModel::Grouping)
#endif // BTBOOKSHELFTREEMODEL_H
diff --git a/src/backend/bookshelfmodel/categoryitem.cpp b/src/backend/bookshelfmodel/categoryitem.cpp
index aaf5566..20ba8e4 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -15,29 +15,31 @@
namespace BookshelfModel {
-CategoryItem::CategoryItem(CSwordModuleInfo *module)
- : Item(ITEM_CATEGORY), m_category(module->category()) {
- // Intentionally empty
-}
QVariant CategoryItem::data(int role) const {
switch (role) {
+
case Qt::DisplayRole:
return CSwordModuleInfo::categoryName(m_category);
+
case Qt::DecorationRole:
return CSwordModuleInfo::categoryIcon(m_category);
+
default:
return Item::data(role);
+
}
}
-bool CategoryItem::operator<(const Item &other) const {
- if (other.type() != ITEM_CATEGORY) {
+bool CategoryItem::operator<(const Item & other) const {
+ if (other.type() != ITEM_CATEGORY)
return ITEM_CATEGORY < other.type();
- }
- const CategoryItem &o(static_cast<const CategoryItem &>(other));
- if (m_category == CSwordModuleInfo::UnknownCategory) return false;
- if (o.m_category == CSwordModuleInfo::UnknownCategory) return true;
+
+ const CategoryItem & o = static_cast<const CategoryItem &>(other);
+ if (m_category == CSwordModuleInfo::UnknownCategory)
+ return false;
+ if (o.m_category == CSwordModuleInfo::UnknownCategory)
+ return true;
return m_category < o.m_category;
}
diff --git a/src/backend/bookshelfmodel/categoryitem.h b/src/backend/bookshelfmodel/categoryitem.h
index 75d5a7c..135f337 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -22,28 +22,29 @@
namespace BookshelfModel {
-class CategoryItem: public Item {
- Q_DECLARE_TR_FUNCTIONS(CategoryItem);
+class CategoryItem: public GroupItem<Item::ITEM_CATEGORY> {
- public:
- static const Item::Type GROUP_TYPE = Item::ITEM_CATEGORY;
+public: /* Methods: */
- CategoryItem(CSwordModuleInfo *module);
+ inline CategoryItem(const CSwordModuleInfo & module)
+ : m_category(module.category()) {}
- inline const CSwordModuleInfo::Category &category() const {
- return m_category;
- }
+ inline const CSwordModuleInfo::Category & category() const {
+ return m_category;
+ }
- QVariant data(int role = Qt::DisplayRole) const;
+ QVariant data(int role = Qt::DisplayRole) const;
- inline bool fitFor(CSwordModuleInfo *module) const {
- return module->category() == m_category;
- }
+ inline bool fitFor(const CSwordModuleInfo & module) const {
+ return module.category() == m_category;
+ }
- bool operator<(const Item &other) const;
+ bool operator<(const Item & other) const;
+
+private: /* Fields: */
+
+ const CSwordModuleInfo::Category m_category;
- protected:
- CSwordModuleInfo::Category m_category;
};
} // namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/indexingitem.cpp b/src/backend/bookshelfmodel/indexingitem.cpp
index 5491ca5..46488a4 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -15,23 +15,13 @@
namespace BookshelfModel {
-IndexingItem::IndexingItem(CSwordModuleInfo *module)
- : Item(Item::ITEM_INDEXING), m_indexed(module->hasIndex()) {
- // Intentionally empty
-}
-
QVariant IndexingItem::data(int role) const {
- switch (role) {
- case Qt::DisplayRole:
- if (m_indexed) {
- return QObject::tr("Indexed works");
- }
- else {
- return QObject::tr("Unindexed works");
- }
- default:
- return Item::data(role);
- }
+ if (role != Qt::DisplayRole)
+ return Item::data(role);
+
+ return m_indexed
+ ? QObject::tr("Indexed works")
+ : QObject::tr("Unindexed works");
}
} // namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/indexingitem.h b/src/backend/bookshelfmodel/indexingitem.h
index a1eb812..3e1e0cd 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -20,20 +20,23 @@
namespace BookshelfModel {
-class IndexingItem: public Item {
- public:
- static const Item::Type GROUP_TYPE = Item::ITEM_INDEXING;
+class IndexingItem: public GroupItem<Item::ITEM_INDEXING> {
- IndexingItem(CSwordModuleInfo *module);
+public: /* Methods: */
- QVariant data(int role = Qt::DisplayRole) const;
+ inline IndexingItem(const CSwordModuleInfo & module)
+ : m_indexed(module.hasIndex()) {}
- inline bool fitFor(CSwordModuleInfo *module) const {
- return module->hasIndex() == m_indexed;
- }
+ QVariant data(int role = Qt::DisplayRole) const;
+
+ inline bool fitFor(const CSwordModuleInfo & module) const {
+ return module.hasIndex() == m_indexed;
+ }
+
+private: /* Fields: */
+
+ bool m_indexed;
- protected:
- bool m_indexed;
};
} // namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/item.cpp b/src/backend/bookshelfmodel/item.cpp
index 02cd991..9d6e5af 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -17,56 +17,56 @@
namespace BookshelfModel {
-Item::Item(Type type)
- : m_type(type), m_parent(0), m_checkState(Qt::Unchecked) {
- // Intentionally empty
-}
-
Item::~Item() {
qDeleteAll(m_children);
}
-int Item::indexFor(Item *newItem) {
- Q_ASSERT(newItem != 0);
+int Item::indexFor(Item * newItem) {
+ Q_ASSERT(newItem);
- if (m_children.empty()) return 0;
+ if (m_children.empty())
+ return 0;
- int i(0);
+ int i = 0;
for (;;) {
- Item *nextItem(m_children.at(i));
+ Item * const nextItem(m_children.at(i));
Q_ASSERT(nextItem->type() == newItem->type());
- if (*newItem < *nextItem) {
+ if (*newItem < *nextItem)
return i;
- }
+
i++;
- if (i >= m_children.size()) {
+ if (i >= m_children.size())
return i;
- }
}
}
QVariant Item::data(int role) const {
switch (role) {
+
case Qt::CheckStateRole:
return m_checkState;
+
case BtBookshelfModel::ModuleHiddenRole:
- if (m_children.empty()) return true;
+ if (m_children.empty())
+ return true;
- foreach (Item *child, m_children) {
- if (!child->data(role).toBool()) return false;
- }
+ Q_FOREACH (Item * child, m_children)
+ if (!child->data(role).toBool())
+ return false;
return true;
+
default:
return QVariant();
+
}
}
-bool Item::operator<(const Item &other) const {
- if (m_type != other.type()) {
+bool Item::operator<(const Item & other) const {
+ if (m_type != other.type())
return m_type < other.type();
- }
- QString first(data(Qt::DisplayRole).toString().toLower());
- QString second(other.data(Qt::DisplayRole).toString().toLower());
+
+ const QString first(data(Qt::DisplayRole).toString().toLower());
+ const QString second(other.data(Qt::DisplayRole).toString().toLower());
return first.localeAwareCompare(second) < 0;
}
diff --git a/src/backend/bookshelfmodel/item.h b/src/backend/bookshelfmodel/item.h
index 652120b..712d4a2 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -13,10 +13,7 @@
#ifndef ITEM_H
#define ITEM_H
-#include <QIcon>
#include <QList>
-#include <QString>
-#include <QtGlobal>
#include <QVariant>
@@ -25,134 +22,165 @@ class CSwordModuleInfo;
namespace BookshelfModel {
class Item {
- public:
- enum Type {
- ITEM_ROOT = 0,
- ITEM_CATEGORY = 1,
- ITEM_LANGUAGE = 2,
- ITEM_MODULE = 3,
- ITEM_INDEXING = 4
- };
-
- Item(Type type);
- virtual ~Item();
-
- /**
- \brief Returns the type of this item.
- */
- inline Type type() const {
- return m_type;
- }
- /**
- \brief Returns a pointer to the parent item of this item.
- \retval 0 if this item has no parent.
- */
- inline Item *parent() const {
- return m_parent;
+public: /* Types: */
+
+ enum Type {
+ ITEM_ROOT = 0,
+ ITEM_CATEGORY = 1,
+ ITEM_LANGUAGE = 2,
+ ITEM_MODULE = 3,
+ ITEM_INDEXING = 4
+ };
+
+public: /* Methods: */
+
+ inline Item(Type type)
+ : m_type(type)
+ , m_parent(0)
+ , m_checkState(Qt::Unchecked) {}
+
+ virtual ~Item();
+
+ /**
+ \brief Returns the type of this item.
+ */
+ inline Type type() const {
+ return m_type;
+ }
+
+ /**
+ \brief Returns a pointer to the parent item of this item.
+ \retval 0 if this item has no parent.
+ */
+ inline Item * parent() const {
+ return m_parent;
+ }
+
+ /**
+ \brief Returns the list of child items of this node.
+ */
+ inline QList<Item *> & children() {
+ return m_children;
+ }
+
+ /**
+ \brief Returns the index of this item under its parent.
+ \retval -1 if this item has no parent.
+ */
+ inline int childIndex() const {
+ return m_parent == 0
+ ? -1
+ : m_parent->m_children.indexOf(const_cast<Item *>(this));
+ }
+
+ /**
+ \brief Returns the position for where the given child item would be
+ inserted.
+ \param[in] newItem Pointer to the item that would be inserted.
+ */
+ int indexFor(Item * newItem);
+
+ /**
+ \brief Inserts the given item as a child at the given index.
+ \pre The given index is a valid position for the item.
+ \param[in] index The child index to insert the item at.
+ \param[in] newItem The item to insert.
+ */
+ inline void insertChild(int index, Item * newItem) {
+ Q_ASSERT(newItem != 0);
+ Q_ASSERT(index >= 0 && index <= m_children.size());
+ m_children.insert(index, newItem);
+ newItem->setParent(this);
+ }
+
+ template <class T>
+ inline T * getGroupItem(CSwordModuleInfo & module, int & outIndex) {
+ for (int i = 0; i < m_children.size(); i++) {
+ Q_ASSERT(m_children.at(i)->type() == T::staticItemType());
+ T * item = static_cast<T *>(m_children.at(i));
+ if (item->fitFor(module)) {
+ outIndex = i;
+ return item;
+ }
}
+ return 0;
+ }
+
+ /**
+ \brief Returns data for this item.
+ */
+ virtual QVariant data(int role = Qt::DisplayRole) const;
+
+ /**
+ \brief Returns the check state of this item.
+ */
+ inline Qt::CheckState checkState() const {
+ return m_checkState;
+ }
+
+ /**
+ \brief Sets the check state of this item.
+ \param[in] state new check state.
+ */
+ inline void setCheckState(const Qt::CheckState state) {
+ m_checkState = state;
+ }
+
+ /**
+ \brief Returns whether this item is fit to contain the given module.
+ \param[in] module The module to check with.
+ \retval true If this item is a group and can contain the given module.
+ \retval false This item is not a group or is a wrong group.
+ */
+ inline virtual bool fitFor(const CSwordModuleInfo & module) const = 0;
+
+ /**
+ \brief Comparsion operator used sorting child items.
+ */
+ virtual bool operator<(const Item & other) const;
+
+private: /* Methods: */
+
+ inline void setParent(Item * parent) {
+ Q_ASSERT(parent != 0);
+ m_parent = parent;
+ }
+
+private: /* Fields: */
+
+ Type m_type;
+ Item * m_parent;
+ QList<Item *> m_children;
+ Qt::CheckState m_checkState;
- /**
- \brief Returns the list of child items of this node.
- */
- inline QList<Item*> &children() {
- return m_children;
- }
+};
- /**
- \brief Returns the index of this item under its parent.
- \retval -1 if this item has no parent.
- */
- inline int childIndex() const {
- if (m_parent == 0) return -1;
- return m_parent->m_children.indexOf(const_cast<Item*>(this));
- }
+class RootItem: public Item {
- /**
- \brief Returns the position for where the given child item would be
- inserted.
- \param[in] newItem Pointer to the item that would be inserted.
- */
- int indexFor(Item *newItem);
-
- /**
- \brief Inserts the given item as a child at the given index.
- \pre The given index is a valid position for the item.
- \param[in] index The child index to insert the item at.
- \param[in] newItem The item to insert.
- */
- inline void insertChild(int index, Item *newItem) {
- Q_ASSERT(newItem != 0);
- Q_ASSERT(index >= 0 && index <= m_children.size());
- m_children.insert(index, newItem);
- newItem->setParent(this);
- }
+public: /* Methods: */
- template <class T>
- T *getGroupItem(CSwordModuleInfo *module, int &outIndex) {
- for (int i(0); i < m_children.size(); i++) {
- Q_ASSERT(m_children.at(i)->type() == T::GROUP_TYPE);
- T *item(static_cast<T*>(m_children.at(i)));
- if (item->fitFor(module)) {
- outIndex = i;
- return item;
- }
- }
- return 0;
- }
+ inline RootItem()
+ : Item(Item::ITEM_ROOT) {}
- /**
- \brief Returns data for this item.
- */
- virtual QVariant data(int role = Qt::DisplayRole) const;
+ inline virtual bool fitFor(const CSwordModuleInfo &) const {
+ return true;
+ }
- /**
- \brief Returns the check state of this item.
- */
- inline Qt::CheckState checkState() const {
- return m_checkState;
- }
-
- /**
- \brief Sets the check state of this item.
- \param[in] state new check state.
- */
- inline void setCheckState(const Qt::CheckState state) {
- m_checkState = state;
- }
+};
- /**
- \brief Returns whether this item is fit to contain the given module.
- \param[in] module The module to check with.
- \retval true If this item is a group and can contain the given module.
- \retval false This item is not a group or is a wrong group.
- */
- inline virtual bool fitFor(CSwordModuleInfo *module) const {
- Q_UNUSED(module);
- return false;
- }
+template <Item::Type TYPE>
+class GroupItem: public Item {
- /**
- \brief Comparsion operator used sorting child items.
- */
- virtual bool operator<(const Item &other) const;
+public: /* Methods: */
- protected:
- inline void setParent(Item *parent) {
- Q_ASSERT(parent != 0);
- m_parent = parent;
- }
+ inline GroupItem()
+ : Item(TYPE) {}
- protected:
- Type m_type;
- Item *m_parent;
- QList<Item*> m_children;
- Qt::CheckState m_checkState;
-};
+ inline static Item::Type staticItemType() {
+ return TYPE;
+ }
-class RootItem: public Item {
- public:
- inline RootItem() : Item(Item::ITEM_ROOT) {}
};
} // Namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/languageitem.cpp b/src/backend/bookshelfmodel/languageitem.cpp
index 2fdab8b..072d720 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -12,22 +12,23 @@
#include "backend/bookshelfmodel/languageitem.h"
+#include "util/geticon.h"
-namespace BookshelfModel {
-LanguageItem::LanguageItem(CSwordModuleInfo *module)
- : Item(ITEM_LANGUAGE), m_language(module->language()) {
- // Intentionally empty
-}
+namespace BookshelfModel {
QVariant LanguageItem::data(int role) const {
switch (role) {
+
case Qt::DisplayRole:
return m_language->translatedName();
+
case Qt::DecorationRole:
- return util::directory::getIcon("flag.svg");
+ return util::getIcon("flag.svg");
+
default:
return Item::data(role);
+
}
}
diff --git a/src/backend/bookshelfmodel/languageitem.h b/src/backend/bookshelfmodel/languageitem.h
index 03a9ce3..1d1d5fa 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -17,25 +17,27 @@
#include "backend/bookshelfmodel/btbookshelfmodel.h"
#include "backend/drivers/cswordmoduleinfo.h"
-#include "util/directory.h"
namespace BookshelfModel {
-class LanguageItem: public Item {
- public:
- static const Item::Type GROUP_TYPE = Item::ITEM_LANGUAGE;
+class LanguageItem: public GroupItem<Item::ITEM_LANGUAGE> {
- LanguageItem(CSwordModuleInfo *module);
+public: /* Methods: */
- QVariant data(int role = Qt::DisplayRole) const;
+ inline LanguageItem(const CSwordModuleInfo & module)
+ : m_language(module.language()) {}
- inline bool fitFor(CSwordModuleInfo *module) const {
- return module->language() == m_language;
- }
+ QVariant data(int role = Qt::DisplayRole) const;
+
+ inline bool fitFor(const CSwordModuleInfo & module) const {
+ return module.language() == m_language;
+ }
+
+private: /* Fields: */
+
+ const CLanguageMgr::Language * m_language;
- protected:
- const CLanguageMgr::Language *m_language;
};
} // namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/moduleitem.cpp b/src/backend/bookshelfmodel/moduleitem.cpp
index ca9c3fb..ffe8eb8 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -18,16 +18,9 @@
namespace BookshelfModel {
-ModuleItem::ModuleItem(CSwordModuleInfo *module,
- BtBookshelfTreeModel *parentModel)
- : Item(ITEM_MODULE), m_moduleInfo(module), m_parentModel(parentModel) {
- Q_ASSERT(module != 0);
- Q_ASSERT(parentModel != 0);
-}
-
QVariant ModuleItem::data(int role) const {
// Dispatch request to tree model:
- return m_parentModel->data(m_moduleInfo, role);
+ return m_parentModel.data(m_moduleInfo, role);
}
} // namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/moduleitem.h b/src/backend/bookshelfmodel/moduleitem.h
index 5e6e1ba..071e3fe 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -24,22 +24,34 @@ class BtBookshelfTreeModel;
namespace BookshelfModel {
class ModuleItem: public Item {
- public:
- ModuleItem(CSwordModuleInfo *module, BtBookshelfTreeModel *parentModel);
-
- /**
- Reimplementation of Item::data() which dispatches all
- requests to the parent model (BtBookshelfTreeModel).
- */
- virtual QVariant data(int role = Qt::DisplayRole) const;
-
- inline CSwordModuleInfo *moduleInfo() const {
- return m_moduleInfo;
- }
-
- protected:
- CSwordModuleInfo *m_moduleInfo;
- BtBookshelfTreeModel *m_parentModel;
+
+public: /* Methods: */
+
+ ModuleItem(CSwordModuleInfo & module,
+ BtBookshelfTreeModel & parentModel)
+ : Item(ITEM_MODULE)
+ , m_moduleInfo(module)
+ , m_parentModel(parentModel) {}
+
+ /**
+ Reimplementation of Item::data() which dispatches all
+ requests to the parent model (BtBookshelfTreeModel).
+ */
+ virtual QVariant data(int role = Qt::DisplayRole) const;
+
+ inline CSwordModuleInfo & moduleInfo() const {
+ return m_moduleInfo;
+ }
+
+ inline virtual bool fitFor(const CSwordModuleInfo &) const {
+ return false;
+ }
+
+private: /* Fields: */
+
+ CSwordModuleInfo & m_moduleInfo;
+ BtBookshelfTreeModel & m_parentModel;
+
};
} // namespace BookshelfModel
diff --git a/src/backend/btinstallbackend.cpp b/src/backend/btinstallbackend.cpp
index c1136bf..7eb3ff4 100644
--- a/src/backend/btinstallbackend.cpp
+++ b/src/backend/btinstallbackend.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,9 +14,9 @@
#include <QFile>
#include <QFileInfo>
#include "backend/managers/cswordbackend.h"
-#include "frontend/bookshelfmanager/btinstallmgr.h"
+#include "backend/btinstallmgr.h"
#include "util/directory.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
// Sword includes:
#include <filemgr.h>
@@ -31,13 +31,22 @@ namespace BtInstallBackend {
/** Adds the source described by Source to the backend. */
bool addSource(sword::InstallSource& source) {
SWConfig config(configFilename().toLatin1());
- if (!strcmp(source.type, "FTP")) {
- //make sure the path doesn't have a trailing slash, sword doesn't like it
+ if (isRemote(source)) {
if (source.directory[ source.directory.length()-1 ] == '/') {
- source.directory--; //make one char shorter
+ source.directory--;
+ }
+ if (!strcmp(source.type, "FTP")) {
+ config["Sources"].insert( std::make_pair(SWBuf("FTPSource"), source.getConfEnt()) );
+ }
+ else if (!strcmp(source.type, "SFTP")) {
+ config["Sources"].insert( std::make_pair(SWBuf("SFTPSource"), source.getConfEnt()) );
+ }
+ else if (!strcmp(source.type, "HTTP")) {
+ config["Sources"].insert( std::make_pair(SWBuf("HTTPSource"), source.getConfEnt()) );
+ }
+ else if (!strcmp(source.type, "HTTPS")) {
+ config["Sources"].insert( std::make_pair(SWBuf("HTTPSSource"), source.getConfEnt()) );
}
-
- config["Sources"].insert( std::make_pair(SWBuf("FTPSource"), source.getConfEnt()) );
}
else if (!strcmp(source.type, "DIR")) {
config["Sources"].insert( std::make_pair(SWBuf("DIRSource"), source.getConfEnt()) );
@@ -68,7 +77,7 @@ sword::InstallSource source(const QString &name) {
return is;
}
- sourceBegin++;//next source
+ ++sourceBegin; //next source
}
}
}
@@ -87,15 +96,10 @@ bool deleteSource(const QString &name) {
SWConfig config(configFilename().toLatin1());
//this code can probably be shortened by using the stl remove_if functionality
- std::pair< ConfigEntMap::iterator, ConfigEntMap::iterator > range =
- isRemote(is)
- ? config["Sources"].equal_range("FTPSource")
- : config["Sources"].equal_range("DIRSource");
-
- ConfigEntMap::iterator it = range.first;
SWBuf sourceConfigEntry = is.getConfEnt();
bool notFound = true;
- while (it != range.second) {
+ ConfigEntMap::iterator it = config["Sources"].begin();
+ while (it != config["Sources"].end()) {
//SWORD lib gave us a "nice" surprise: getConfEnt() adds uid, so old sources added by BT are not recognized here
if (it->second == sourceConfigEntry) {
config["Sources"].erase(it);
@@ -111,8 +115,8 @@ bool deleteSource(const QString &name) {
QStringList l = sce.split('|');
l.removeLast();
sce = l.join("|").append("|");
- it = range.first;
- while (it != range.second) {
+ it = config["Sources"].begin();
+ while (it != config["Sources"].end()) {
if (it->second == sce) {
config["Sources"].erase(it);
break;
@@ -132,7 +136,10 @@ QList<CSwordModuleInfo*> moduleList(QString /*name*/) {
}
bool isRemote(const sword::InstallSource& source) {
- return !strcmp(source.type, "FTP");
+ return !strcmp(source.type, "FTP") ||
+ !strcmp(source.type, "SFTP") ||
+ !strcmp(source.type, "HTTP") ||
+ !strcmp(source.type, "HTTPS");
}
QString configPath() {
@@ -171,7 +178,7 @@ bool setTargetList( const QStringList& targets ) {
if (!i.exists() || !i.isWritable()) {
// There is no way to save to the file
qWarning() << "The Sword config file is not writable!";
- util::showWarning(0, QObject::tr("Can't write file"), QObject::tr("The Sword config file can't be written!"));
+ message::showWarning(0, QObject::tr("Can't write file"), QObject::tr("The Sword config file can't be written!"));
return false;
}
@@ -179,7 +186,7 @@ bool setTargetList( const QStringList& targets ) {
SWConfig conf(filename.toLocal8Bit());
conf.Sections.clear();
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
// On Windows, add the sword directory to the config file.
QString swordPath = DU::convertDirSeparators( DU::getApplicationSwordDir().absolutePath());
conf["Install"].insert(
@@ -190,7 +197,7 @@ bool setTargetList( const QStringList& targets ) {
bool setDataPath = false;
for (QStringList::const_iterator it = targets.begin(); it != targets.end(); ++it) {
QString t = DU::convertDirSeparators(*it);
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
if (t.contains(DU::convertDirSeparators(DU::getUserHomeDir().canonicalPath().append("\\Sword")))) {
#else
if (t.contains(DU::getUserHomeDir().canonicalPath().append("/.sword"))) {
@@ -217,7 +224,7 @@ QStringList sourceNameList() {
QStringList names;
//add Sword remote sources
- for (InstallSourceMap::iterator it = mgr.sources.begin(); it != mgr.sources.end(); it++) {
+ for (InstallSourceMap::iterator it = mgr.sources.begin(); it != mgr.sources.end(); ++it) {
names << QString::fromLocal8Bit(it->second->caption);
}
@@ -232,7 +239,7 @@ QStringList sourceNameList() {
InstallSource is("DIR", sourceBegin->second.c_str());
names << QString::fromLatin1(is.caption.c_str());
- sourceBegin++;
+ ++sourceBegin;
}
}
@@ -249,7 +256,7 @@ QString swordConfigFilename() {
namespace DU = util::directory;
qDebug() << "Sword config:"
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
<< DU::getUserHomeDir().absolutePath().append("/Sword/sword.conf");
return DU::getUserHomeDir().absolutePath().append("/Sword/sword.conf");
// return DU::getApplicationDir().absolutePath().append("/sword.conf");
@@ -262,27 +269,20 @@ QString swordConfigFilename() {
QDir swordDir() {
namespace DU = util::directory;
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
return QDir(DU::getUserHomeDir().absolutePath().append("/Sword/"));
#else
return QDir(DU::getUserHomeDir().absolutePath().append("/.sword/"));
#endif
}
-CSwordBackend* backend( const sword::InstallSource& is) {
- CSwordBackend* ret = 0;
+CSwordBackend * backend(const sword::InstallSource & is) {
/// \anchor BackendNotSingleton
- if (isRemote(is)) {
- ret = new CSwordBackend( QString(is.localShadow.c_str()), false );
- }
- else {
- ret = new CSwordBackend( QString(is.directory.c_str()), false);
- }
-
- Q_ASSERT(ret);
- if (ret) {
- ret->initModules(CSwordBackend::OtherChange);
- }
+ CSwordBackend * const ret = new CSwordBackend(isRemote(is)
+ ? is.localShadow.c_str()
+ : is.directory.c_str(),
+ false);
+ ret->initModules(CSwordBackend::OtherChange);
return ret;
}
diff --git a/src/backend/btinstallbackend.h b/src/backend/btinstallbackend.h
index fc71697..1827f64 100644
--- a/src/backend/btinstallbackend.h
+++ b/src/backend/btinstallbackend.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -64,7 +66,7 @@ QString swordConfigFilename();
QDir swordDir();
/** Returns backend Sword manager for the source. */
-CSwordBackend* backend( const sword::InstallSource& is);
+CSwordBackend * backend(const sword::InstallSource & is);
} // namespace BtInstallBackend
diff --git a/src/backend/btinstallmgr.cpp b/src/backend/btinstallmgr.cpp
new file mode 100644
index 0000000..2734dd3
--- /dev/null
+++ b/src/backend/btinstallmgr.cpp
@@ -0,0 +1,99 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "backend/btinstallmgr.h"
+
+#include "backend/btinstallbackend.h"
+
+
+namespace {
+
+template <typename T>
+inline T normalizeCompletionPercentage(const T value) {
+ if (value < 0)
+ return 0;
+ if (value > 100)
+ return 100;
+ return value;
+}
+
+template <typename T>
+inline int calculateIntPercentage(T done, T total) {
+ Q_ASSERT(done >= 0);
+ Q_ASSERT(total >= 0);
+
+ // Special care (see warning in BtInstallMgr::statusUpdate()).
+ if (done > total)
+ done = total;
+ if (total == 0)
+ return 100;
+
+ return normalizeCompletionPercentage<int>((done / total) * 100);
+}
+
+} // anonymous namespace
+
+using namespace sword;
+
+BtInstallMgr::BtInstallMgr(QObject * parent)
+ : QObject(parent)
+ , InstallMgr(BtInstallBackend::configPath().toLatin1(), this)
+ , m_totalBytes(1)
+ , m_completedBytes(0)
+ , m_firstCallOfPreStatus(true)
+{ // Use this class also as status reporter:
+ this->setFTPPassive(true);
+}
+
+BtInstallMgr::~BtInstallMgr() {
+ //doesn't really help because it only sets a flag
+ this->terminate(); // make sure to close the connection
+}
+
+bool BtInstallMgr::isUserDisclaimerConfirmed() const {
+ //// \todo Check from config if it's been confirmed with "don't show this anymore" checked.
+ // Create a dialog with the message, checkbox and Continue/Cancel, Cancel as default.
+ return true;
+}
+
+void BtInstallMgr::statusUpdate(double dltotal, double dlnow) {
+ /**
+ \warning Note that these *might be* rough measures due to the double data
+ type being used by Sword to store the number of bytes. Special
+ care must be taken to work around this, since the arguments may
+ contain weird values which would otherwise break this logic.
+ */
+
+ if (dltotal < 0.0) // Special care (see warning above)
+ dltotal = 0.0;
+ if (dlnow < 0.0) // Special care (see warning above)
+ dlnow = 0.0;
+
+ const int totalPercent = calculateIntPercentage<double>(dlnow + m_completedBytes,
+ m_totalBytes);
+ const int filePercent = calculateIntPercentage(dlnow, dltotal);
+
+ //qApp->processEvents();
+ emit percentCompleted(totalPercent, filePercent);
+}
+
+
+void BtInstallMgr::preStatus(long totalBytes,
+ long completedBytes,
+ const char * message)
+{
+ Q_UNUSED(message);
+ Q_ASSERT(completedBytes <= totalBytes);
+ if (m_firstCallOfPreStatus) {
+ m_firstCallOfPreStatus = false;
+ emit downloadStarted();
+ }
+ m_completedBytes = completedBytes;
+ m_totalBytes = totalBytes;
+}
diff --git a/src/backend/btinstallmgr.h b/src/backend/btinstallmgr.h
new file mode 100644
index 0000000..e82b470
--- /dev/null
+++ b/src/backend/btinstallmgr.h
@@ -0,0 +1,73 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTINSTALLMGR_H
+#define BTINSTALLMGR_H
+
+#include <QObject>
+// Sword includes:
+#include <installmgr.h>
+#include <remotetrans.h>
+
+
+/**
+* Our own reimplementation to provide installation and status bar updates.
+*/
+class BtInstallMgr
+ : public QObject
+ , public sword::InstallMgr
+ , public sword::StatusReporter
+{
+
+ Q_OBJECT
+
+public: /* Methods: */
+
+ BtInstallMgr(QObject * parent = 0);
+ ~BtInstallMgr();
+
+ virtual bool isUserDisclaimerConfirmed() const;
+
+signals:
+
+ /**
+ Download status. Percent of total and file.
+ \warning Use these values for display only, since they might be incorrect.
+ */
+ void percentCompleted(const int total, const int file);
+
+ void downloadStarted();
+
+protected: /* Methods: */
+
+ /** \note Reimplementation of sword::StatusReporter::statusUpdate(). */
+ virtual void statusUpdate(double dltotal, double dlnow);
+
+ /**
+ * \note 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);
+
+private: /* Fields: */
+
+ long m_totalBytes;
+ long m_completedBytes;
+ bool m_firstCallOfPreStatus;
+
+};
+
+#endif /* BTINSTALLMGR_H */
diff --git a/src/backend/btinstallthread.cpp b/src/backend/btinstallthread.cpp
new file mode 100644
index 0000000..69e5fb8
--- /dev/null
+++ b/src/backend/btinstallthread.cpp
@@ -0,0 +1,143 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "backend/btinstallthread.h"
+
+#include <QDebug>
+#include <QDir>
+#include <QString>
+#include <QThread>
+#include "backend/managers/cswordbackend.h"
+
+#include "backend/btinstallbackend.h"
+
+// Sword includes:
+#include <filemgr.h>
+
+
+namespace {
+
+inline bool runMkdir(QDir & dir, const QString & dirName) {
+ if (!dir.exists(dirName)) {
+ if (!dir.mkpath(dirName)) {
+ qDebug() << "failed to make directory" << dirName;
+ return false;
+ }
+ qDebug() << "made directory" << dirName;
+ }
+ return true;
+}
+
+}
+
+void BtInstallThread::run() {
+ // Make sure target/mods.d and target/modules exist
+ /// \todo move this to some common precondition
+ QDir dir(m_destination);
+ if (!runMkdir(dir, m_destination)
+ || !runMkdir(dir, "modules")
+ || !runMkdir(dir, "mods.d"))
+ {
+ return;
+ }
+
+ m_stopRequestedMutex.lock();
+ try {
+ for (m_currentModuleIndex = 0;
+ !m_stopRequested && (m_currentModuleIndex < m_modules.size());
+ m_currentModuleIndex++)
+ {
+ m_stopRequestedMutex.unlock();
+ installModule();
+ m_stopRequestedMutex.lock();
+ }
+ } catch (...) {
+ m_stopRequestedMutex.unlock();
+ throw;
+ }
+ m_stopRequestedMutex.unlock();
+}
+
+void BtInstallThread::installModule() {
+ emit preparingInstall(m_currentModuleIndex);
+
+ const CSwordModuleInfo * const module = m_modules.at(m_currentModuleIndex);
+
+ sword::InstallSource installSource = BtInstallBackend::source(module->property("installSourceName").toString());
+ QScopedPointer<CSwordBackend> backendForSource(BtInstallBackend::backend(installSource));
+
+ // Check whether it's an update. If yes, remove existing module first:
+ /// \todo silently removing without undo if the user cancels the update is WRONG!!!
+ if (!removeModule()) {
+ QMutexLocker lock(&m_stopRequestedMutex);
+ if (m_stopRequested)
+ return;
+ }
+
+ // manager for the destination path
+ sword::SWMgr lMgr(m_destination.toLatin1());
+ if (BtInstallBackend::isRemote(installSource)) {
+ int status = m_iMgr.installModule(&lMgr,
+ 0,
+ module->name().toLatin1(),
+ &installSource);
+ if (status == 0) {
+ emit statusUpdated(m_currentModuleIndex, 100);
+ } else {
+ qWarning() << "Error with install: " << status
+ << "module:" << module->name();
+ }
+ emit installCompleted(m_currentModuleIndex, status == 0);
+ } else { // Local source
+ int status = m_iMgr.installModule(&lMgr,
+ installSource.directory.c_str(),
+ module->name().toLatin1());
+ if (status == 0) {
+ emit statusUpdated(m_currentModuleIndex, 100);
+ } else if (status != -1) {
+ qWarning() << "Error with install: " << status
+ << "module:" << module->name();
+ }
+ emit installCompleted(m_currentModuleIndex, status == 0);
+ }
+}
+
+void BtInstallThread::slotManagerStatusUpdated(int totalProgress, int /*fileProgress*/) {
+ emit statusUpdated(m_currentModuleIndex, totalProgress);
+}
+
+void BtInstallThread::slotDownloadStarted() {
+ emit downloadStarted(m_currentModuleIndex);
+}
+
+bool BtInstallThread::removeModule() {
+ CSwordModuleInfo * const installedModule = m_modules.at(m_currentModuleIndex);
+ CSwordModuleInfo * m = CSwordBackend::instance()->findModuleByName(installedModule->name());
+ if (!m)
+ m = BtInstallBackend::backend(BtInstallBackend::source(m_destination.toLatin1()))->findModuleByName(installedModule->name());
+
+ if (!m)
+ return false;
+
+ qDebug() << "Removing module" << installedModule->name();
+ QString prefixPath = m->config(CSwordModuleInfo::AbsoluteDataPath) + "/";
+ QString dataPath = m->config(CSwordModuleInfo::DataPath);
+ if (dataPath.left(2) == "./")
+ dataPath = dataPath.mid(2);
+
+ if (prefixPath.contains(dataPath)) {
+ prefixPath.remove(prefixPath.indexOf(dataPath), dataPath.length());
+ } else {
+ prefixPath = QString::fromLatin1(CSwordBackend::instance()->prefixPath);
+ }
+
+ sword::SWMgr mgr(prefixPath.toLatin1());
+ BtInstallMgr().removeModule(&mgr, m->name().toLatin1());
+ return true;
+}
diff --git a/src/backend/btinstallthread.h b/src/backend/btinstallthread.h
new file mode 100644
index 0000000..d4cbdc3
--- /dev/null
+++ b/src/backend/btinstallthread.h
@@ -0,0 +1,94 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTINSTALLTHREAD_H
+#define BTINSTALLTHREAD_H
+
+#include <QThread>
+
+#include <QMutex>
+#include <QMutexLocker>
+#include <QSharedPointer>
+#include "backend/btinstallmgr.h"
+
+
+class BtInstallProgressDialog;
+class CSwordBackend;
+class CSwordModuleInfo;
+
+
+class BtInstallThread: public QThread {
+
+ Q_OBJECT
+
+ public:
+
+ BtInstallThread(const QList<CSwordModuleInfo *> & modules,
+ const QString & destination,
+ QObject * const parent = 0)
+ : QThread(parent)
+ , m_modules(modules)
+ , m_destination(destination)
+ , m_stopRequested(false)
+ {
+ connect(&m_iMgr, SIGNAL(percentCompleted(int, int)),
+ this, SLOT(slotManagerStatusUpdated(int, int)),
+ Qt::QueuedConnection);
+ connect(&m_iMgr, SIGNAL(downloadStarted()),
+ this, SLOT(slotDownloadStarted()),
+ Qt::QueuedConnection);
+ }
+
+ void stopInstall() {
+ const QMutexLocker lock(&m_stopRequestedMutex);
+ m_stopRequested = true;
+ }
+
+ signals:
+
+ /** Emitted when starting the installation. */
+ void preparingInstall(int moduleIndex);
+
+ /** Emitted when the first file download has been started. */
+ void downloadStarted(int moduleIndex);
+
+ /** Emitted when the install progress status is updated. */
+ void statusUpdated(int moduleIndex, int progressPercent);
+
+ /** Emitted when installing is complete. */
+ void installCompleted(int moduleIndex, bool success);
+
+ protected: /* Methods: */
+
+ virtual void run();
+
+ private: /* Methods: */
+
+ void installModule();
+ bool removeModule();
+
+ private slots:
+
+ void slotDownloadStarted();
+ void slotManagerStatusUpdated(int totalProgress, int fileProgress);
+
+ private: /* Fields: */
+
+ const QList<CSwordModuleInfo *> & m_modules;
+ const QString m_destination;
+ BtInstallMgr m_iMgr;
+ int m_currentModuleIndex;
+ QMutex m_stopRequestedMutex;
+ bool m_stopRequested;
+
+};
+
+#endif
diff --git a/src/backend/btmoduletreeitem.cpp b/src/backend/btmoduletreeitem.cpp
index 4c16231..7900ef0 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/backend/btmoduletreeitem.h b/src/backend/btmoduletreeitem.h
index 008bfb2..189f9b2 100644
--- a/src/backend/btmoduletreeitem.h
+++ b/src/backend/btmoduletreeitem.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -115,8 +117,8 @@ class BTModuleTreeItem {
/** When the root item is deleted the whole tree is deleted. */
~BTModuleTreeItem();
- /** Adds filtered items to the tree */
- void add_items(QList<BTModuleTreeItem::Filter*>& filters);
+ /** Adds filtered items to the tree */
+ void add_items(QList<BTModuleTreeItem::Filter*>& filters);
/**
* Returns the item type.
@@ -168,10 +170,10 @@ class BTModuleTreeItem {
/** Helper function for creating a group item while creating the tree. */
BTModuleTreeItem* create_parent_item(BTModuleTreeItem* parent, const QString& text, BTModuleTreeItem::Type type, CSwordModuleInfo::Category category = CSwordModuleInfo::UnknownCategory);
- static bool m_map_initialized;
- static QMap<CSwordModuleInfo::Category, QString> m_CategoryNamesMap;
-
-
+ static bool m_map_initialized;
+ static QMap<CSwordModuleInfo::Category, QString> m_CategoryNamesMap;
+
+
CSwordModuleInfo* m_moduleInfo;
QString m_text;
BTModuleTreeItem* m_firstChild;
diff --git a/src/backend/config/btconfig.cpp b/src/backend/config/btconfig.cpp
new file mode 100644
index 0000000..e76b246
--- /dev/null
+++ b/src/backend/config/btconfig.cpp
@@ -0,0 +1,363 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "btconfig.h"
+
+#include <QDebug>
+#include <QLocale>
+#include "backend/btmoduletreeitem.h"
+#include "backend/managers/cdisplaytemplatemgr.h"
+#include "frontend/messagedialog.h"
+#include "util/directory.h" // DU::getUserBaseDir()
+
+// Sword includes:
+#include <backend/managers/cswordbackend.h>
+#include <versekey.h> // For search scope configuration
+
+
+#define BTCONFIG_API_VERSION 1
+namespace {
+const QString BTCONFIG_API_VERSION_KEY = "btconfig_api_version";
+}
+
+
+/*
+ * set the instance variable initially to 0, so it can be safely checked
+ * whether the variable has been initialized yet.
+ */
+BtConfig * BtConfig::m_instance = NULL;
+
+BtConfig::StringMap BtConfig::m_defaultSearchScopes;
+
+
+BtConfig::BtConfig(const QString & settingsFile)
+ : BtConfigCore(settingsFile)
+{
+ Q_ASSERT_X(!m_instance, "BtConfig", "Already initialized!");
+ m_instance = this;
+
+ if (m_defaultSearchScopes.isEmpty()) {
+ m_defaultSearchScopes.insert(tr("Old testament"), QString("Gen - Mal"));
+ m_defaultSearchScopes.insert(tr("Moses/Pentateuch/Torah"), QString("Gen - Deut"));
+ m_defaultSearchScopes.insert(tr("History"), QString("Jos - Est"));
+ m_defaultSearchScopes.insert(tr("Prophets"), QString("Isa - Mal"));
+ m_defaultSearchScopes.insert(tr("New testament"), QString("Mat - Rev"));
+ m_defaultSearchScopes.insert(tr("Gospels"), QString("Mat - Joh"));
+ m_defaultSearchScopes.insert(tr("Letters/Epistles"), QString("Rom - Jude"));
+ m_defaultSearchScopes.insert(tr("Paul's Epistles"), QString("Rom - Phile"));
+ }
+}
+
+bool BtConfig::initBtConfig() {
+ Q_ASSERT(!m_instance);
+
+ const QString confFileName = util::directory::getUserBaseDir().absolutePath()
+ + "/bibletimerc";
+ bool confExisted = QFile::exists(confFileName);
+ m_instance = new BtConfig(confFileName);
+ if (!confExisted) {
+ m_instance->setValue<int>(BTCONFIG_API_VERSION_KEY, BTCONFIG_API_VERSION);
+ return true;
+ }
+
+ int btConfigOldApi = m_instance->value<int>(BTCONFIG_API_VERSION_KEY, 0);
+ if (btConfigOldApi == BTCONFIG_API_VERSION)
+ return true;
+
+ bool cont;
+ if (btConfigOldApi < BTCONFIG_API_VERSION) {
+ /// \todo Migrate from btConfigOldApi to BTCONFIG_API_VERSION
+ qWarning() << "BibleTime configuration migration is not yet implemented!!!";
+ cont = message::showWarning(
+ 0, "Warning!",
+ "Migration to the new configuration system is not yet "
+ "implemented. Proceeding might result in <b>loss of data"
+ "</b>. Please backup your configuration files before you "
+ "continue!<br/><br/>Do you want to continue? Press \"No\" "
+ "to quit BibleTime immediately.",
+ QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::No) == QMessageBox::Yes;
+ } else {
+ Q_ASSERT(btConfigOldApi > BTCONFIG_API_VERSION);
+ cont = message::showWarning(
+ 0, tr("Error loading configuration!"),
+ tr("Failed to load BibleTime's configuration, because it "
+ "appears that the configuration file corresponds to a "
+ "newer version of BibleTime. This is likely caused by "
+ "BibleTime being downgraded. Loading the new "
+ "configuration file may result in <b>loss of data</b>."
+ "<br/><br/>Do you still want to try to load the new "
+ "configuration file? Press \"No\" to quit BibleTime "
+ "immediately."),
+ QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::No) == QMessageBox::Yes;
+ }
+ if (cont)
+ m_instance->setValue<int>(BTCONFIG_API_VERSION_KEY, BTCONFIG_API_VERSION);
+ return cont;
+}
+
+BtConfig& BtConfig::getInstance() {
+ Q_ASSERT_X(m_instance, "BtConfig", "Not yet initialized!");
+ return *m_instance;
+}
+
+void BtConfig::destroyInstance() {
+ delete m_instance;
+ m_instance = NULL;
+}
+
+void BtConfig::setModuleEncryptionKey(const QString & name,
+ const QString & key)
+{
+ Q_ASSERT(!name.isEmpty());
+ setValue("Module keys/" + name, key);
+}
+
+QString BtConfig::getModuleEncryptionKey(const QString & name) {
+ Q_ASSERT(!name.isEmpty());
+ return value<QString>("Module keys/" + name, QString::null);
+}
+
+QHash<QString, QList<QKeySequence> > BtConfig::getShortcuts(const QString & shortcutGroup) {
+ beginGroup(shortcutGroup);
+ QHash<QString, QList<QKeySequence> > allShortcuts;
+ Q_FOREACH (const QString & key, childKeys()) {
+ QVariant variant = qVariantValue(key);
+
+ QList<QKeySequence> shortcuts;
+
+ if (variant.type() == QVariant::List) { // For BibleTime before 2.9
+ Q_FOREACH (const QVariant & shortcut, variant.toList())
+ shortcuts.append(shortcut.toString());
+ } else if (variant.type() == QVariant::StringList
+ || variant.type() == QVariant::String)
+ { // a StringList with one element is recognized as a QVariant::String
+ Q_FOREACH (const QString & shortcut, variant.toStringList())
+ shortcuts.append(shortcut);
+ } else { // it's something we don't know, skip it
+ continue;
+ }
+
+ allShortcuts.insert(key, shortcuts);
+ }
+ endGroup();
+ return allShortcuts;
+}
+
+void BtConfig::setShortcuts(const QString & shortcutGroup,
+ const QHash<QString, QList<QKeySequence> > & shortcuts)
+{
+ typedef QHash<QString, QList<QKeySequence> >::const_iterator SHMCI;
+
+ beginGroup(shortcutGroup);
+ for (SHMCI it = shortcuts.begin(); it != shortcuts.end(); ++it) {
+ // Write beautiful string lists (since 2.9):
+ /// \note saving QKeySequences directly doesn't appear to work!
+ QStringList varList;
+ Q_FOREACH (const QKeySequence & shortcut, it.value())
+ varList.append(shortcut.toString());
+
+ if (!varList.empty())
+ setValue(it.key(), varList);
+ }
+ endGroup();
+}
+
+FilterOptions BtConfig::getFilterOptions() {
+ FilterOptions os;
+ beginGroup("presentation");
+ os.footnotes = sessionValue<bool>("footnotes", true);
+ os.strongNumbers = sessionValue<bool>("strongNumbers", true);
+ os.headings = sessionValue<bool>("headings", true);
+ os.morphTags = sessionValue<bool>("morphTags", true);
+ os.lemmas = sessionValue<bool>("lemmas", true);
+ os.redLetterWords = sessionValue<bool>("redLetterWords", true);
+ os.hebrewPoints = sessionValue<bool>("hebrewPoints", true);
+ os.hebrewCantillation = sessionValue<bool>("hebrewCantillation", true);
+ os.greekAccents = sessionValue<bool>("greekAccents", true);
+ os.textualVariants = sessionValue<bool>("textualVariants", false);
+ os.scriptureReferences = sessionValue<bool>("scriptureReferences", true);
+ os.morphSegmentation = sessionValue<bool>("morphSegmentation", true);
+ endGroup();
+ return os;
+}
+
+void BtConfig::setFilterOptions(const FilterOptions & os) {
+ beginGroup("presentation");
+ setSessionValue("footnotes", static_cast<bool>(os.footnotes));
+ setSessionValue("strongNumbers", static_cast<bool>(os.strongNumbers));
+ setSessionValue("headings", static_cast<bool>(os.headings));
+ setSessionValue("morphTags", static_cast<bool>(os.morphTags));
+ setSessionValue("lemmas", static_cast<bool>(os.lemmas));
+ setSessionValue("redLetterWords", static_cast<bool>(os.redLetterWords));
+ setSessionValue("hebrewPoints", static_cast<bool>(os.hebrewPoints));
+ setSessionValue("hebrewCantillation", static_cast<bool>(os.hebrewCantillation));
+ setSessionValue("greekAccents", static_cast<bool>(os.greekAccents));
+ setSessionValue("textualVariants", static_cast<bool>(os.textualVariants));
+ setSessionValue("scriptureReferences", static_cast<bool>(os.scriptureReferences));
+ setSessionValue("morphSegmentation", static_cast<bool>(os.morphSegmentation));
+ endGroup();
+}
+
+DisplayOptions BtConfig::getDisplayOptions() {
+ DisplayOptions os;
+ beginGroup("presentation");
+ os.lineBreaks = sessionValue<bool>("lineBreaks", false);
+ os.verseNumbers = sessionValue<bool>("verseNumbers", false);
+ endGroup();
+ return os;
+}
+
+void BtConfig::setDisplayOptions(const DisplayOptions & os) {
+ beginGroup("presentation");
+ setSessionValue("lineBreaks", static_cast<bool>(os.lineBreaks));
+ setSessionValue("verseNumbers", static_cast<bool>(os.verseNumbers));
+ endGroup();
+}
+
+void BtConfig::setFontForLanguage(const CLanguageMgr::Language & language,
+ const FontSettingsPair & fontSettings)
+{
+ const QString & englishName = language.englishName();
+ Q_ASSERT(!englishName.isEmpty());
+
+ QMutexLocker lock(&this->m_mutex);
+ // write the language to the settings
+ setValue("fonts/" + englishName, fontSettings.second.toString());
+ setValue("font standard settings/" + englishName, fontSettings.first);
+
+ // Remove language from the cache:
+ m_fontCache.remove(&language);
+}
+
+BtConfig::FontSettingsPair BtConfig::getFontForLanguage(
+ const CLanguageMgr::Language & language)
+{
+ const QString & englishName = language.englishName();
+ Q_ASSERT(!englishName.isEmpty());
+
+ QMutexLocker lock(&this->m_mutex);
+ // Check the cache first:
+ FontCacheMap::const_iterator it(m_fontCache.find(&language));
+ if (it != m_fontCache.end())
+ return *it;
+
+ // Retrieve the font from the settings
+ FontSettingsPair fontSettings;
+
+ fontSettings.first = value<bool>("font standard settings/" + englishName, false);
+
+ QFont font;
+ if (fontSettings.first) {
+ if (!font.fromString(value<QString>("fonts/" + englishName, getDefaultFont().toString()))) {
+ /// \todo
+ }
+ } else {
+ font = getDefaultFont();
+ }
+ fontSettings.second = font;
+
+ // Cache the value:
+ m_fontCache.insert(&language, fontSettings);
+
+ return fontSettings;
+}
+
+BtConfig::StringMap BtConfig::getSearchScopesForCurrentLocale() {
+ StringMap map = value<BtConfig::StringMap>("properties/searchScopes", m_defaultSearchScopes);
+
+ // Convert map to current locale:
+ sword::VerseKey vk;
+ for (StringMap::Iterator it = map.begin(); it != map.end(); it++) {
+ QString &s = it.value();
+ sword::ListKey list(vk.parseVerseList(QByteArray(s.toUtf8()), "Genesis 1:1", true));
+ s.clear();
+ for (int i = 0; i < list.getCount(); i++) {
+ s.append(QString::fromUtf8(list.getElement(i)->getRangeText()));
+ s.append("; ");
+ }
+ }
+ return map;
+}
+
+void BtConfig::setSearchScopesWithCurrentLocale(StringMap searchScopes) {
+ /**
+ * We want to make sure that the search scopes are saved with english
+ * key names so loading them will always work with each locale set.
+ */
+ sword::VerseKey vk;
+ BtConfig::StringMap::Iterator iter = searchScopes.begin();
+ while (iter != searchScopes.end()) {
+ QString &data = iter.value();
+ bool parsingWorked = true;
+ sword::ListKey list(vk.parseVerseList(data.toUtf8(), "Genesis 1:1", true));
+ data.clear();
+ for (int i = 0; i < list.getCount(); i++) {
+ sword::VerseKey * verse(dynamic_cast<sword::VerseKey *>(list.getElement(i)));
+
+ if (verse != 0) {
+ verse->setLocale("en");
+ data.append(QString::fromUtf8(verse->getRangeText()));
+ data.append(";");
+ } else {
+ parsingWorked = false;
+ break;
+ }
+ }
+
+ if (parsingWorked)
+ iter++;
+ else
+ iter = searchScopes.erase(iter);
+ }
+ setValue("properties/searchScopes", searchScopes);
+}
+
+void BtConfig::deleteSearchScopesWithCurrentLocale() {
+ remove("properties/searchScopes");
+}
+
+CSwordModuleInfo *BtConfig::getDefaultSwordModuleByType(const QString & moduleType) {
+ const QString moduleName = value<QString>("settings/defaults/" + moduleType, QString());
+ if (moduleName.isEmpty())
+ return 0;
+
+ return CSwordBackend::instance()->findModuleByName(moduleName);
+}
+
+void BtConfig::setDefaultSwordModuleByType(const QString &moduleType,
+ const CSwordModuleInfo * const module)
+{
+ setValue("settings/defaults/" + moduleType,
+ module != 0 ? module->name() : QString::null);
+}
+
+/**
+ \todo -CDisplayWindow gets a construct method that reads from config and constructs and
+ returns the respective child window (check whether module is installed...)
+ -CDisplayWindows get a new variable "id" or something, which is a unique identifier.
+ The path in the configuration will use this id as name. (who gives out the IDs?)
+ -values are updated as they are changed, just like the rest of bibletime
+ -QMdiArea::subWindowActivated signal will trigger reading the window order and saving
+ it to the config.
+ Action Plan:
+ 1. get current code to work with old session system
+ 2. move complete code over to BtConfig
+ 3. remove CBTConfig
+ 4. implement BtConfig infrastructure for saving window configuration
+ - function to add a window
+ - function to remove a window
+ - specify how to save ordering
+ 5. change CDisplayWindows to write all state changes to the configuration
+ 6. implement BtConfig::readSession and callers
+ 7. make session handling code work with QSetting paths instead of properties
+ 8. add gui for new session handling
+ 9. remove old gui for session handling
+*/
diff --git a/src/backend/config/btconfig.h b/src/backend/config/btconfig.h
new file mode 100644
index 0000000..be19d41
--- /dev/null
+++ b/src/backend/config/btconfig.h
@@ -0,0 +1,248 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTCONFIG_H
+#define BTCONFIG_H
+
+#include <QDataStream>
+#include <QFont>
+#include <QHash>
+#include <QKeySequence>
+#include <QMetaType>
+#include <QSet>
+#include <QSettings>
+#include <QString>
+#include <QStringList>
+#include <QVariant>
+
+#include "backend/config/btconfigcore.h"
+
+#include "backend/btmoduletreeitem.h" // for BTModuleTreeItem::Grouping
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "btglobal.h"
+
+
+class BibleTimeApp;
+
+class BtConfig: public BtConfigCore {
+
+ Q_DISABLE_COPY(BtConfig)
+
+ friend class BibleTimeApp;
+
+public: /* Types: */
+
+ /*!
+ * The first parameter indicates whether the custom font should be used or not.
+ * The second parameter is the custom font that has been set.
+ */
+ typedef QPair<bool, QFont> FontSettingsPair;
+ typedef QMap<QString, QString> StringMap;
+
+private: /* Types: */
+
+ typedef QHash<const CLanguageMgr::Language *, FontSettingsPair> FontCacheMap;
+
+public: /* Methods: */
+
+ static BtConfig & getInstance();
+
+ /*!
+ * \brief Function to set a module decryption key.
+ *
+ * This helper function will set a module decryption key
+ * in the configuration. Any previous key will be overwritten.
+ *
+ * \param[in] name Name of module to set the key for
+ * \param[in] key Decryption key to set as string
+ */
+ void setModuleEncryptionKey(const QString & name, const QString & key);
+
+ /*!
+ * \brief Function to get a module decryption key.
+ *
+ * This helper function will retrieve a previously set
+ * module decryption key from the configuration. If the key
+ * is not set it will return a null string.
+ *
+ * \param[in] name Name of module to retrieve the key for
+ * \returns Decryption key as a string
+ */
+ QString getModuleEncryptionKey(const QString & name);
+
+ /*!
+ * \brief Gets the shortcuts for the given group.
+ *
+ * Returns a hash of shortcuts for strings for the respective
+ * shortcut group.
+ * \param[in] shortcutGroup The group to retrieve shortcuts for.
+ * \returns Hash of strings and lists of shortcuts.
+ */
+ QHash<QString, QList<QKeySequence> > getShortcuts(const QString & shortcutGroup);
+
+ /*!
+ * \brief Sets the shortcuts for the given group.
+ *
+ * Writes a hash of shortcuts for strings for the respective
+ * shortcut group.
+ * \param[in] shortcutGroup The group to retrieve shortcuts for.
+ * \param[in] Hash of strings and lists of shortcuts to write.
+ */
+ void setShortcuts(const QString & shortcutGroup,
+ const QHash<QString, QList<QKeySequence> > & shortcuts);
+
+ /*!
+ * \brief Returns current filter options.
+ *
+ * Returns a structure containing the current
+ * settings to be used for filtering.
+ *
+ * \returns FilterOptions structure containing filter settings.
+ */
+ FilterOptions getFilterOptions();
+
+ /*!
+ * \brief Saves the current filter options.
+ *
+ * \param[in] options The filter options to save.
+ */
+ void setFilterOptions(const FilterOptions & options);
+
+ /*!
+ * \brief Returns current display options.
+ *
+ * Returns a structure containing the current
+ * settings to be used for displaying texts.
+ *
+ * \returns DisplayOptions structure containing display settings.
+ */
+ DisplayOptions getDisplayOptions();
+
+ /*!
+ * \brief Saves the current display options.
+ *
+ * \param[in] options The display options to save.
+ */
+ void setDisplayOptions(const DisplayOptions & options);
+
+ /*!
+ * Returns a default font that is suitable for the current language.
+ * \returns QFont suitable for current language.
+ */
+ inline const QFont & getDefaultFont() const {
+ QMutexLocker lock(&this->m_mutex);
+ return m_defaultFont;
+ }
+
+ /// \todo: put FontSettingsPair in QVariant directly
+ /*!
+ * \brief Set font for a language.
+ *
+ * Sets a FontSettingsPair for the language given.
+ * \param[in] language pointer to a language to set the font for
+ * \param[in] fontSettings FontSettingsPair to set
+ */
+ void setFontForLanguage(const CLanguageMgr::Language & language,
+ const FontSettingsPair & fontSettings);
+
+ /*!
+ * \brief Get font for a language.
+ *
+ * Gets a FontSettingsPair for the language given. If no font has been saved
+ * a default font is returned.
+ * \param[in] language pointer to a language to get the font for.
+ * \returns FontSettingsPair for given language
+ */
+ FontSettingsPair getFontForLanguage(const CLanguageMgr::Language & language);
+
+ /// \todo: unit test these functions
+ /*!
+ * Returns the searchScopes for the current locale.
+ *
+ * This function retrieves the search scopes of the
+ * "properties/searchScopes" property and converts them
+ * to the current locale.
+ *
+ * \returns Search scopes in current locale.
+ */
+ StringMap getSearchScopesForCurrentLocale();
+
+ /*!
+ * Sets the searchScopes given in the current locale.
+ *
+ * This function sets the search scopes of the
+ * "properties/searchScopes" property, the scopes are
+ * converted to the english locale before saving them.
+ *
+ * \param[in] searchScopes Search scopes in any locale.
+ */
+ void setSearchScopesWithCurrentLocale(StringMap searchScopes);
+
+ /*!
+ * Deletes the searchScopes given in the current locale.
+ */
+ void deleteSearchScopesWithCurrentLocale();
+
+ /*!
+ * \brief Returns default sword module info class for a given module type.
+ *
+ * This is basically a convenience function for getting the respective
+ * "settings/defaults/ *" variable and searching that module manually.
+ * If module is not installed 0 will be returned.
+ * \param[in] moduleType module type to return the default sword module info for
+ * \returns sword module info pointer or 0
+ */
+ CSwordModuleInfo * getDefaultSwordModuleByType(const QString & moduleType);
+
+ /*!
+ * \brief Sets the default sword module for a module type.
+ *
+ * This is basically a convenience function for setting the "settings/defaults/ *"
+ * variables to the module->name() string manually.
+ * 0 is allowed as the module, then the default module will be unset.
+ * \param[in] moduleType module type to set
+ * \param[in] module the sword module info to set as default module
+ */
+ void setDefaultSwordModuleByType(const QString & moduleType,
+ const CSwordModuleInfo * const module);
+
+private: /* Methods: */
+
+ explicit BtConfig(const QString & settingsFile);
+
+ static bool initBtConfig();
+
+ static void destroyInstance();
+
+private: /* Fields: */
+
+ static BtConfig * m_instance; //!< singleton instance
+
+ QFont m_defaultFont; //!< default font used when no special one is set
+ FontCacheMap m_fontCache; //!< a cache for the fonts saved in the configuration file for speed
+
+ static StringMap m_defaultSearchScopes;
+
+};
+
+// declare types used in configuration as metatype so they can be saved directly into the configuration
+Q_DECLARE_METATYPE(BtConfig::StringMap)
+Q_DECLARE_METATYPE(QList<int>)
+
+/*!
+ * \brief This is a shortchand for BtConfig::getInstance().
+ * \returns BtConfig singleton instance.
+ */
+inline BtConfig & btConfig() {
+ return BtConfig::getInstance();
+}
+
+#endif // BTCONFIG_H
diff --git a/src/backend/config/btconfigcore.cpp b/src/backend/config/btconfigcore.cpp
new file mode 100644
index 0000000..0914508
--- /dev/null
+++ b/src/backend/config/btconfigcore.cpp
@@ -0,0 +1,202 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "btconfigcore.h"
+
+#include <cstddef>
+#include <limits>
+
+
+const QString BtConfigCore::GROUP_SESSIONS = "sessions/";
+const QString BtConfigCore::KEY_CURRENT_SESSION = "sessions/currentSession";
+const QString BtConfigCore::GROUP_SESSION = "sessions/%1/";
+const QString BtConfigCore::KEY_SESSION_NAME = "sessions/%1/name";
+const QString BtConfigCore::UI_FONT_SIZE = "ui/fontSize";
+
+
+BtConfigCore::BtConfigCore(const QString & settingsFile)
+ : m_mutex(QMutex::Recursive)
+ , m_settings(settingsFile, QSettings::IniFormat)
+{
+ /**
+ \todo Read UI language from settings, and initialize translator for tr()
+ strings.
+ */
+
+ // Read all session keys and names:
+ m_settings.beginGroup(GROUP_SESSIONS);
+ const QStringList sessionKeys = m_settings.childGroups();
+ m_settings.endGroup();
+ Q_FOREACH (const QString & sessionKey, sessionKeys) {
+ // Skip empty//keys just in case:
+ if (sessionKey.isEmpty())
+ continue;
+
+ const QString fullKey = KEY_SESSION_NAME.arg(sessionKey);
+ const QString sessionName = m_settings.value(fullKey).toString();
+ if (!sessionName.isEmpty())
+ m_sessionNames.insert(sessionKey, sessionName);
+ }
+
+ // Get current session key:
+ m_currentSessionKey = m_settings.value(KEY_CURRENT_SESSION).toString();
+
+ /*
+ If no session with the current session key exists, default to the first
+ session found. If no sessions were found, create a default session.
+ */
+ if (m_currentSessionKey.isEmpty()
+ || !m_sessionNames.contains(m_currentSessionKey))
+ {
+ if (m_sessionNames.isEmpty()) {
+ const QString &newSessionName = QString::number((qulonglong) 0u, 36);
+ m_currentSessionKey = newSessionName;
+ m_settings.setValue(KEY_CURRENT_SESSION, newSessionName);
+ m_settings.setValue(KEY_SESSION_NAME.arg(newSessionName),
+ tr("Default Session"));
+ } else {
+ m_currentSessionKey = m_sessionNames.keys().first();
+ }
+ }
+ m_cachedCurrentSessionGroup = GROUP_SESSION.arg(m_currentSessionKey);
+}
+
+void BtConfigCore::setCurrentSession(const QString & key) {
+ Q_ASSERT(!key.isEmpty());
+
+ QMutexLocker lock(&m_mutex);
+ Q_ASSERT(m_sessionNames.contains(key));
+ m_currentSessionKey = key;
+ m_cachedCurrentSessionGroup = GROUP_SESSION.arg(key);
+
+ m_settings.setValue(KEY_CURRENT_SESSION, key);
+ m_settings.sync();
+}
+
+QString BtConfigCore::addSession(const QString & name) {
+ Q_ASSERT(!name.isEmpty());
+
+ // Generate a new session key:
+ QString key = QString::number(0u, 36);
+ QMutexLocker lock(&m_mutex);
+ if (m_sessionNames.contains(key)) {
+ QString keyPrefix;
+ std::size_t i = 1u;
+ for (;;) {
+ key = QString::number(i, 36);
+ if (!m_sessionNames.contains(keyPrefix + key))
+ break;
+ if (i == std::numeric_limits<std::size_t>::max()) {
+ i = 0u;
+ keyPrefix.append('_');
+ } else {
+ i++;
+ }
+ };
+ }
+ Q_ASSERT(!m_sessionNames.contains(key));
+ m_sessionNames.insert(key, name);
+
+ m_settings.setValue(KEY_SESSION_NAME.arg(key), name);
+ m_settings.sync();
+ return key;
+}
+
+
+void BtConfigCore::deleteSession(const QString & key) {
+ QMutexLocker lock(&m_mutex);
+ Q_ASSERT(m_sessionNames.contains(key));
+ Q_ASSERT(key != m_currentSessionKey);
+ m_sessionNames.remove(key);
+
+ m_settings.remove(GROUP_SESSIONS + key);
+ m_settings.sync();
+}
+
+QStringList BtConfigCore::childKeys() {
+ QMutexLocker lock(&m_mutex);
+ return childGroups__();
+}
+
+QStringList BtConfigCore::childKeys__() {
+ if (m_groups.isEmpty())
+ return m_settings.childKeys();
+
+ m_settings.beginGroup(group());
+ const QStringList gs = m_settings.childKeys();
+ m_settings.endGroup();
+ return gs;
+}
+
+QStringList BtConfigCore::childKeys(const QString & subkey) {
+ beginGroup(subkey);
+ QStringList gs = childKeys__();
+ endGroup();
+ return gs;
+}
+
+QStringList BtConfigCore::childGroups() {
+ QMutexLocker lock(&m_mutex);
+ return childGroups__();
+}
+
+QStringList BtConfigCore::childGroups__() {
+ if (m_groups.isEmpty())
+ return m_settings.childGroups();
+
+ m_settings.beginGroup(group());
+ const QStringList gs = m_settings.childGroups();
+ m_settings.endGroup();
+ return gs;
+}
+
+QStringList BtConfigCore::childGroups(const QString & subkey) {
+ beginGroup(subkey);
+ QStringList gs = childGroups__();
+ endGroup();
+ return gs;
+}
+
+QStringList BtConfigCore::sessionChildGroups() {
+ QMutexLocker lock(&m_mutex);
+ return sessionChildGroups__();
+}
+
+QStringList BtConfigCore::sessionChildGroups__() {
+ QMutexLocker lock(&m_mutex);
+ m_settings.beginGroup(m_cachedCurrentSessionGroup + group());
+ const QStringList gs = m_settings.childGroups();
+ m_settings.endGroup();
+ return gs;
+}
+
+QStringList BtConfigCore::sessionChildGroups(const QString & subkey) {
+ beginGroup(subkey);
+ QStringList gs = sessionChildGroups__();
+ endGroup();
+ return gs;
+}
+
+void BtConfigCore::remove(const QString & key) {
+ QMutexLocker lock(&m_mutex);
+ if (m_groups.isEmpty()) {
+ m_settings.remove(key);
+ } else {
+ m_settings.remove(m_groups.join("/") + '/' + key);
+ }
+}
+
+void BtConfigCore::sessionRemove(const QString & key) {
+ QMutexLocker lock(&m_mutex);
+ if (m_groups.isEmpty()) {
+ m_settings.remove(m_cachedCurrentSessionGroup + key);
+ } else {
+ m_settings.remove(m_cachedCurrentSessionGroup + m_groups.join("/") + '/' + key);
+ }
+}
diff --git a/src/backend/config/btconfigcore.h b/src/backend/config/btconfigcore.h
new file mode 100644
index 0000000..5c24b4f
--- /dev/null
+++ b/src/backend/config/btconfigcore.h
@@ -0,0 +1,342 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTCONFIGCORE_H
+#define BTCONFIGCORE_H
+
+#include <QSettings>
+
+#include <QCoreApplication>
+#include <QHash>
+#include <QMutex>
+#include <QStringList>
+
+
+/**
+ \note Session keys are QStrings because we even want to handle cases where the
+ configuration file is manually changed. When creating new sessions, they
+ are still generated from unsigned integers.
+*/
+class BtConfigCore {
+
+ Q_DISABLE_COPY(BtConfigCore)
+ Q_DECLARE_TR_FUNCTIONS(BtConfigCore)
+
+public: /* Types: */
+
+ typedef QHash<QString, QString> SessionNamesHashMap;
+
+public: /* Methods: */
+
+ /**
+ \param[in] settingsFile The filename of the settings file.
+ */
+ explicit BtConfigCore(const QString & settingsFile);
+
+ inline ~BtConfigCore() { sync(); }
+
+
+ /**
+ \returns the key of the current session.
+ */
+ inline const QString & currentSessionKey() const {
+ QMutexLocker lock(&m_mutex);
+ return m_currentSessionKey;
+ }
+
+ /**
+ \returns the name of the current session.
+ */
+ inline const QString & currentSessionName() const {
+ QMutexLocker lock(&m_mutex);
+ typedef QHash<QString, QString>::const_iterator SSHCI;
+ SSHCI it = m_sessionNames.constFind(m_currentSessionKey);
+ Q_ASSERT(it != m_sessionNames.constEnd());
+ return it.value();
+ }
+
+ /**
+ \returns a hashmap with the keys and printable names of the sessions.
+ */
+ inline const SessionNamesHashMap & sessionNames() const {
+ QMutexLocker lock(&m_mutex);
+ return m_sessionNames;
+ }
+
+ /**
+ \brief Notifies the configuration system that the session settings
+ should be read from and saved to the given session.
+
+ \pre The session with the given key must exist.
+ \param[in] key the key of the session to switch to.
+ \post the sessionValue() and value() methods will work with the settings
+ of the given session.
+ */
+ void setCurrentSession(const QString & key);
+
+ /**
+ \brief Creates a new session with the given name.
+
+ \pre The given name must not be an empty string.
+ \param[in] name the name of the session
+ \returns the key of the created session.
+ */
+ QString addSession(const QString & name);
+
+ /**
+ \brief Deletes the session with the given key.
+
+ \pre The session with the given key must exist.
+ \pre The session with the given key must not be the current session.
+ \param[in] key the key of the session to delete.
+ \post The session with the given key and its settings are deleted.
+ \returns whether deleting the session was successful.
+ */
+ void deleteSession(const QString & key);
+
+ /**
+ \brief Returns the settings value for the given global key.
+
+ \param[in] key Key to get the value for.
+ \param[in] defaultValue The value to return if no saved value is found.
+ \returns the value of type specified by the template parameter.
+ */
+ template<typename T>
+ inline T value(const QString & key, const T & defaultValue = T()) {
+ QMutexLocker lock(&m_mutex);
+ return m_settings.value(group() + key,
+ QVariant::fromValue(defaultValue)).template value<T>();
+ }
+
+ /**
+ \brief Returns the settings value for the given global key as a QVariant.
+
+ \param[in] key Key to get the value for.
+ \param[in] defaultValue The value to return if no saved value is found.
+ \returns the value.
+ */
+ inline QVariant qVariantValue(const QString & key,
+ const QVariant & defaultValue = QVariant())
+ {
+ QMutexLocker lock(&m_mutex);
+ return m_settings.value(group() + key,
+ QVariant::fromValue(defaultValue));
+ }
+
+ /**
+ \brief Returns the settings value for the given session key.
+
+ \param[in] key Session key to get the value for.
+ \param[in] defaultValue The value to return if no saved value is found.
+ \returns the value of type specified by the template parameter.
+ */
+ template<typename T>
+ inline T sessionValue(const QString & key, const T & defaultValue = T()) {
+ QMutexLocker lock(&m_mutex);
+ return m_settings.value(m_cachedCurrentSessionGroup + group() + key,
+ QVariant::fromValue(defaultValue)).template value<T>();
+ }
+
+ /**
+ \brief Sets a value for a global settings key.
+
+ \param[in] key Ket to set.
+ \param[in] value Value to set.
+ */
+ template<typename T>
+ inline void setValue(const QString & key, const T & value) {
+ QMutexLocker lock(&m_mutex);
+ m_settings.setValue(group() + key, QVariant::fromValue<T>(value));
+ }
+
+ /**
+ \brief Sets a value for a session settings key.
+
+ \param[in] key Ket to set.
+ \param[in] value Value to set.
+ */
+ template<typename T>
+ inline void setSessionValue(const QString & key, const T & value) {
+ QMutexLocker lock(&m_mutex);
+ m_settings.setValue(m_cachedCurrentSessionGroup + group() + key,
+ QVariant::fromValue<T>(value));
+ }
+
+ /**
+ \returns a list of first-level keys in the current group in global settings.
+ */
+ QStringList childKeys();
+
+ /**
+ \pre subkey is not empty
+ \param[in] subkey the subkey
+ \returns a list of keys under the current group and subkey in global settings.
+ */
+ QStringList childKeys(const QString & subkey);
+
+ /**
+ \returns a list of first-level groups in the current group in global settings.
+ */
+ QStringList childGroups();
+
+ /**
+ \pre subkey is not empty
+ \param[in] subkey the subkey
+ \returns a list of groups under the current group and subkey in global settings.
+ */
+ QStringList childGroups(const QString & subkey);
+
+ /**
+ \returns a list of first-level groups in the current group in session settings.
+ */
+ QStringList sessionChildGroups();
+
+ /**
+ \pre subkey is not empty
+ \param[in] subkey the subkey
+ \returns a list of groups under the current group and subkey in session settings.
+ */
+ QStringList sessionChildGroups(const QString & subkey);
+
+ /**
+ \brief removes a key all its children from global settings.
+
+ \param[in] key the key to remove
+ */
+ void remove(const QString & key);
+
+ /**
+ \brief removes a key all its children from session settings.
+
+ \param[in] key the key to remove
+ */
+ void sessionRemove(const QString & key);
+
+ /**
+ \brief Synchronize the underlying QSettings.
+ */
+ inline void sync() {
+ QMutexLocker lock(&m_mutex);
+ m_settings.sync();
+ }
+
+ /**
+ \brief Appends the given prefix to the current group.
+
+ The current group is automatically prepended to all keys when reading or
+ writing settings values. The behaviour is similar to QSettings::beginGroup().
+
+ \warning Locks the object (recursively) until endGroup().
+
+ \param[in] prefix the prefix to append
+ */
+ inline void beginGroup(QString prefix) {
+ Q_ASSERT(!prefix.isEmpty());
+ while (prefix.startsWith('/'))
+ prefix.remove(0, 1);
+ Q_ASSERT(!prefix.isEmpty());
+ while (prefix.endsWith('/'))
+ prefix.chop(1);
+ Q_ASSERT(!prefix.isEmpty());
+
+ m_mutex.lock();
+ m_groups.append(prefix);
+ m_cachedGroup = QString();
+ }
+
+ /**
+ \brief Resets the current group to its previous value.
+
+ Call this function after you are done with a started group. Every call to
+ beginGroup() must be matched with a call to this function in the same
+ thread.
+
+ \warning Locks the object (recursively) until endGroup().
+ */
+ inline void endGroup() {
+ Q_ASSERT_X(!m_groups.isEmpty(), "BtConfig", "endGroup() called, but no beginGroup() active.");
+ m_groups.removeLast();
+ m_cachedGroup = QString();
+ m_mutex.unlock();
+ }
+
+ /**
+ \brief Returns the current group.
+
+ Returns the group the BtConfig is currently set to. It will contain a
+ trailing / so is suitable to be preprended to a key directly.
+
+ \returns the group string or an empty string if no group is set.
+ */
+ inline QString group() const {
+ QMutexLocker lock(&m_mutex);
+ if (m_cachedGroup.isNull()) {
+ m_cachedGroup = m_groups.isEmpty()
+ ? ""
+ : m_groups.join("/") + '/';
+ }
+ return m_cachedGroup;
+ }
+
+private: /* Methods: */
+
+ /**
+ \Brief Same childKeys(), but not thread-safe.
+ \returns a list of first-level keys in the current group in global settings.
+ */
+ QStringList childKeys__();
+
+ /**
+ \Brief Same childGroups(), but not thread-safe.
+ \returns a list of first-level groups in the current group in global settings.
+ */
+ QStringList childGroups__();
+
+ /**
+ \Brief Same sessionChildGroups(), but not thread-safe.
+ \returns a list of first-level groups in the current group in session settings.
+ */
+ QStringList sessionChildGroups__();
+
+protected: /* Fields: */
+
+ /** Required for asynchronous access */
+ mutable QMutex m_mutex;
+
+private: /* Fields: */
+
+ /** Underlying backend */
+ QSettings m_settings;
+
+ /** List of active group prefixes */
+ QStringList m_groups;
+
+ /** Cached group() string or QString::null if not cached */
+ mutable QString m_cachedGroup;
+
+ /** Index of currently active session */
+ QString m_currentSessionKey;
+
+ /** Cached group name of the currently active session */
+ mutable QString m_cachedCurrentSessionGroup;
+
+ /** Keys and names all sessions */
+ SessionNamesHashMap m_sessionNames;
+
+ // Helper key strings:
+ static const QString GROUP_SESSIONS;
+ static const QString KEY_CURRENT_SESSION;
+ static const QString GROUP_SESSION;
+ static const QString KEY_SESSION_NAME;
+ static const QString UI_FONT_SIZE;
+};
+
+#endif // BTCONFIGCORE_H
diff --git a/src/backend/config/cbtconfig.cpp b/src/backend/config/cbtconfig.cpp
deleted file mode 100644
index d82fc7d..0000000
--- a/src/backend/config/cbtconfig.cpp
+++ /dev/null
@@ -1,776 +0,0 @@
-/*********
-*
-* 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 "backend/config/cbtconfig.h"
-
-#include <QDebug>
-#include <QLocale>
-#include <QSettings>
-#include <QVariant>
-#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/directory.h"
-
-// Sword includes:
-#include <versekey.h> // For range configuration
-
-
-namespace CBTConfig {
-namespace {
-
-typedef QMap<const CLanguageMgr::Language*, FontSettingsPair> FontCacheMap;
-
-QFont *m_defaultFont = 0;
-FontCacheMap m_fontCache;
-
-QString getKey(const strings ID) {
- switch (ID) {
- case bibletimeVersion:
- return "bibletimeVersion";
- case language:
- return "language";
- case displayStyle:
- return "displayStyle";
- case bookshelfCurrentItem:
- return "bookshelfCurrentItem";
- }
- return QString::null;
-}
-
-QString getKey(const modules ID) {
- switch (ID) {
- case standardBible:
- return "standardBible";
- case standardCommentary:
- return "standardCommentary";
- case standardLexicon:
- return "standardLexicon";
- case standardDailyDevotional:
- return "standardDailyDevotional";
- case standardHebrewStrongsLexicon:
- return "standardHebrewLexicon";
- case standardGreekStrongsLexicon:
- return "standardGreekLexicon";
- case standardHebrewMorphLexicon:
- return "standardHebrewMorphLexicon";
- case standardGreekMorphLexicon:
- return "standardGreekMorphLexicon";
- }
- return QString::null;
-}
-
-QString getKey(const bools ID) {
- switch (ID) {
- case firstSearchDialog:
- return "firstSearchDialog";
- case readOldBookmarks:
- return "readOldBookmarks";
-
- case showMainWindowToolbar:
- return "showMainWindowToolbar";
- case mainIndex:
- return "mainIndex";
- case infoDisplay:
- return "infoDisplay";
-
- case autoTileVertical:
- return "autoTileVertical";
- case autoTileHorizontal:
- return "autoTileHorizontal";
- case autoTile:
- return "autoTile";
- case autoTabbed:
- return "autoTabbed";
- case autoCascade:
- return "autoCascade";
-
- case lineBreaks:
- return "lineBreaks";
- case verseNumbers:
- return "verseNumbers";
-
- case logo:
- return "logo";
- case autoDeleteOrphanedIndices:
- return "autoDeleteOrphanedIndices";
- case crashedLastTime:
- return "crashedLastTime";
- case crashedTwoTimes:
- return "crashedTwoTimes";
-
- case bookshelfShowHidden:
- return "bookshelfShowHidden";
- case allowNetworkConnection:
- return "allowNetworkConnection";
-
- case 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";
- default:
- Q_ASSERT(false);
- return QString::null;
- }
-}
-
-QString getKey(const ints ID) {
- switch (ID) {
- case footnotes:
- return "footnotes";
- case strongNumbers:
- return "strongNumbers";
- case headings:
- return "headings";
- case morphTags:
- return "morphTags";
- case lemmas:
- return "lemmas";
- case hebrewPoints:
- return "hebrewPoints";
- case hebrewCantillation:
- return "hebrewCantillation";
- case greekAccents:
- return "greekAccents";
- case textualVariants:
- return "textualVariants";
- case scriptureReferences:
- return "scriptureReferences";
- case morphSegmentation:
- return "morphSegmentation";
- case bookshelfContentsX:
- return "bookshelfContentsX";
- case bookshelfContentsY:
- return "bookshelfContentsY";
- case magDelay:
- return "magDelay";
- case bookshelfGrouping:
- return "bookshelfGrouping";
- case mainindexActiveTab:
- return "mainindexActiveTab";
- case searchDialogWidth:
- return "searchDialogWidth";
- case searchDialogHeight:
- return "searchDialogHeight";
- case searchDialogX:
- return "searchDialogX";
- case searchDialogY:
- return "searchDialogY";
- case searchType:
- return "searchType";
- case installPathIndex:
- return "installPathIndex";
- case bookshelfPosX:
- return "bookshelfPosX";
- case bookshelfPosY:
- return "bookshelfPosY";
- case bookshelfHeight:
- return "bookshelfHeight";
- case bookshelfWidth:
- return "bookshelfWidth";
- case configDialogPosX:
- return "configDialogPosX";
- case configDialogPosY:
- return "configDialogPosY";
- case configDialogHeight:
- return "configDialogHeight";
- case configDialogWidth:
- return "configDialogWidth";
- case tipNumber:
- return "tipNumber";
- default:
- Q_ASSERT(false);
- return QString::null;
- }
-}
-
-QString getKey(const intLists ID) {
- switch (ID) {
- case leftPaneSplitterSizes:
- return "leftPaneSplitterSizes";
- case mainSplitterSizes:
- return "mainSplitterSizes";
- case searchMainSplitterSizes:
- return "searchMainSplitterSizes";
- case searchResultSplitterSizes:
- return "searchResultSplitterSizes";
- }
- return QString::null;
-}
-
-QString getKey(const stringLists ID) {
- switch (ID) {
- case searchCompletionTexts:
- return "searchCompletionTexts";
- case searchTexts:
- return "searchTexts";
- case searchModulesHistory:
- return "searchModulesHistory";
- case bookshelfOpenGroups:
- return "bookshelfOpenGroups";
- case hiddenModules:
- return "hiddenModules";
- default:
- Q_ASSERT(false);
- return QString::null;
- }
-}
-
-QString getKey(const stringMaps ID) {
- Q_ASSERT(ID == searchScopes);
- return "SearchScopes";
-}
-
-QString getKey(const CLanguageMgr::Language * const language) {
- Q_ASSERT(!language->name().isEmpty());
- return language->name();
-}
-
-} // anonymous namespace
-
-QString IntListToString(const QList<int> &intList) {
- QStringList intStrings;
- Q_FOREACH (int i, intList) {
- intStrings << QString::number(i);
- }
- return intStrings.join(",");
-}
-
-QList<int> StringToIntList(const QString &intListString,
- bool *ok,
- QString::SplitBehavior splitBehavior)
-{
- QList<int> intList;
- if (ok != 0) {
- *ok = true;
-
- if (!intListString.isEmpty()) {
- Q_FOREACH (const QString &intString, intListString.split(',', splitBehavior)) {
- int i = intString.trimmed().toInt(ok);
- if (!(*ok))
- break;
-
- intList << i;
- }
- }
- } else {
- if (!intListString.isEmpty()) {
- Q_FOREACH (const QString &intString, intListString.split(',', splitBehavior)) {
- intList << intString.trimmed().toInt();
- }
- }
- }
- return intList;
-}
-
-QString getDefault(const strings ID) {
- switch (ID) {
- case bibletimeVersion:
- return "0.0"; // main() will realize this and set the value to VERSION
- case language:
- return QLocale::system().name();
- case displayStyle:
- return CDisplayTemplateMgr::defaultTemplateName();
- case bookshelfCurrentItem:
- default:
- return QString::null;
- }
-}
-
-QString getDefault(const modules ID) {
- switch (ID) {
- case standardBible:
- return "KJV";
- case standardCommentary:
- return "MHC";
- case standardLexicon:
- return "ISBE";
- case standardDailyDevotional:
- return ""; // No default
-
- case standardHebrewStrongsLexicon:
- return "StrongsHebrew";
- case standardGreekStrongsLexicon:
- return "StrongsGreek";
- case standardHebrewMorphLexicon:
- return "StrongsHebrew";
- case standardGreekMorphLexicon:
- return "StrongsGreek";
- default:
- return QString::null;
- }
-}
-
-bool getDefault(const bools ID) {
- switch (ID) {
- case firstSearchDialog:
- case showMainWindowToolbar:
- case mainIndex:
- case infoDisplay:
- case autoTileVertical:
- case verseNumbers:
- case logo:
- case autoDeleteOrphanedIndices:
- case showTextWindowHeaders:
- case showTextWindowNavigator:
- case showTextWindowModuleSelectorButtons:
- case showTextWindowToolButtons:
- case showFormatToolbarButtons:
- case showToolbarsInEachWindow:
- case showTipAtStartup:
- return true;
- case readOldBookmarks:
- case autoTileHorizontal:
- case autoTile:
- case autoTabbed:
- case autoCascade:
- case lineBreaks:
- case crashedLastTime:
- case crashedTwoTimes:
- case bookshelfShowHidden:
- case allowNetworkConnection:
- default:
- return false;
- }
-}
-
-int getDefault(const ints ID) {
- switch (ID) {
- case bookshelfGrouping:
- return BTModuleTreeItem::CatLangMod;
- case searchType:
- return Search::BtSearchOptionsArea::AndType;
- case searchDialogHeight:
- case magDelay:
- return 400;
- case searchDialogWidth:
- case searchDialogX:
- case searchDialogY:
- return 200;
- case footnotes:
- case strongNumbers:
- case headings:
- case morphTags:
- case lemmas:
- case hebrewPoints:
- case hebrewCantillation:
- case greekAccents:
- case scriptureReferences:
- case morphSegmentation:
- case bookshelfPosX:
- case bookshelfPosY:
- case bookshelfHeight:
- case bookshelfWidth:
- case configDialogPosX:
- case configDialogPosY:
- case configDialogHeight:
- case configDialogWidth:
- return 1;
- case textualVariants:
- case bookshelfContentsX:
- case bookshelfContentsY:
- case mainindexActiveTab:
- case installPathIndex:
- case tipNumber:
- default:
- return 0;
- }
-}
-
-QList<int> getDefault(const intLists /*ID*/) {
- return QList<int>();
-}
-
-QStringList getDefault(const stringLists ID) {
- if (ID == searchTexts) {
- QStringList list;
- list.append(QString::null);
- return list;
- } else {
- return QStringList();
- }
-}
-
-StringMap getDefault(const stringMaps ID) {
- Q_ASSERT(ID == searchScopes);
-
- StringMap map;
- map.insert(QObject::tr("Old testament"), QString("Gen - Mal"));
- map.insert(QObject::tr("Moses/Pentateuch/Torah"), QString("Gen - Deut"));
- map.insert(QObject::tr("History"), QString("Jos - Est"));
- map.insert(QObject::tr("Prophets"), QString("Isa - Mal"));
- map.insert(QObject::tr("New testament"), QString("Mat - Rev"));
- map.insert(QObject::tr("Gospels"), QString("Mat - Joh"));
- map.insert(QObject::tr("Letters/Epistles"), QString("Rom - Jude"));
- map.insert(QObject::tr("Paul's Epistles"), QString("Rom - Phile"));
-
- // Make the list to the current bookname language!
- sword::VerseKey vk;
- vk.setLocale("en_US");
-
- for (StringMap::Iterator it(map.begin()); it != map.end(); it++) {
- sword::ListKey list(vk.ParseVerseList(it.value().toLocal8Bit(), "Genesis 1:1", true));
- QString data;
- for (int i(0); i < list.Count(); i++) {
- data.append(QString::fromUtf8(list.getElement(i)->getRangeText()));
- data.append("; ");
- }
- map[it.key()] = data;
- };
-
- return map;
-}
-
-QFont &getDefault(const CLanguageMgr::Language * const) {
- // Language specific lookup of the font name
- if (m_defaultFont)
- return *m_defaultFont;
-
- /// \todo make the font name and size a configuration option
-
- m_defaultFont = new QFont();
- m_defaultFont->setPointSize(12);
- return *m_defaultFont;
-}
-
-QString get(const strings ID) {
- QVariant v = getConfig()->value("strings/" + getKey(ID));
- if (v.isValid())
- return v.toString();
-
- return getDefault(ID);
-}
-
-CSwordModuleInfo *get(const modules ID) {
- QVariant v = getConfig()->value("modules/" + getKey(ID));
- CSwordBackend *b = CSwordBackend::instance();
- if (v.isValid())
- return b->findModuleByName(v.toString());
-
- return b->findModuleByName(getDefault(ID));
-}
-
-bool get(const bools ID) {
- QVariant v = getConfig()->value("bools/" + getKey(ID));
- if (v.isValid())
- return v.toBool();
-
- return getDefault(ID);
-}
-
-int get(const ints ID) {
- QVariant v = getConfig()->value("ints/" + getKey(ID));
- if (v.isValid())
- return v.toInt();
-
- return getDefault(ID);
-}
-
-QList<int> get(const intLists ID) {
- QVariant v = getConfig()->value("intlists/" + getKey(ID));
- if (v.isValid()) {
- bool ok;
- QList<int> r = StringToIntList(v.toString(), &ok);
- if (ok)
- return r;
- }
- return getDefault(ID);
-}
-
-QStringList get(const stringLists ID) {
- QVariant v = getConfig()->value("stringlists/" + getKey(ID));
- if (v.isValid())
- return v.toStringList();
-
- return getDefault(ID);
-}
-
-StringMap get(const stringMaps ID) {
- Q_ASSERT(ID == searchScopes);
-
- QSettings *s = getConfig();
- s->beginGroup(getKey(ID));
- const QStringList keys = s->childKeys();
-
- if (keys.isEmpty()) {
- s->endGroup();
- return getDefault(ID);
- }
-
- /**
- Make sure we return the scopes in the chosen language. saved
- keys are in english.
- */
- StringMap map;
- sword::VerseKey vk;
- Q_FOREACH (const QString &key, keys) {
- if (key.isEmpty())
- continue;
-
- QByteArray b = s->value(key).toString().toUtf8();
- sword::ListKey list(vk.ParseVerseList(b, "Genesis 1:1", true));
- QString data;
- for (int i = 0; i < list.Count(); i++) {
- data.append(QString::fromUtf8(list.getElement(i)->getRangeText()));
- data.append("; ");
- }
- map[key] = data; // Set the new data
- }
- s->endGroup();
- return map;
-}
-
-FontSettingsPair get(const CLanguageMgr::Language * const language) {
- // Check the cache first:
- FontCacheMap::const_iterator it = m_fontCache.find(language);
- if (it != m_fontCache.end())
- return *it;
-
- QSettings *s = getConfig();
- FontSettingsPair fontSettings;
- fontSettings.first = s->value("font standard settings/" + getKey(language), false).toBool();
-
- if (fontSettings.first) {
- QVariant v = s->value("fonts/" + getKey(language));
- if (v.isValid()) {
- fontSettings.second.fromString(v.toString());
- } else {
- fontSettings.second = getDefault(language);
- }
- } else {
- fontSettings.second = getDefault(language);
- }
-
- // Cache the value:
- m_fontCache.insert(language, fontSettings);
-
- return fontSettings;
-}
-
-void set(const strings ID, const QString &value) {
- getConfig()->setValue("strings/" + getKey(ID), value);
-}
-
-void set(const modules ID, CSwordModuleInfo * const value) {
- getConfig()->setValue("modules/" + getKey(ID), value ? value->name() : QString::null);
-}
-
-void set(const modules ID, const QString &value) {
- CSwordModuleInfo *module(CSwordBackend::instance()->findModuleByName(value));
- if (module) {
- set(ID, module);
- }
-}
-
-void set(const bools ID, const bool value) {
- getConfig()->setValue("bools/" + getKey(ID), value);
-}
-
-void set(const ints ID, const int value) {
- getConfig()->setValue("ints/" + getKey(ID), value);
-}
-
-void set(const intLists ID, const QList<int> &value) {
- getConfig()->setValue("intlists/" + getKey(ID), IntListToString(value));
-}
-
-void set(const stringLists ID, const QStringList &value) {
- getConfig()->setValue("stringlists/" + getKey(ID), value);
-}
-
-void set(const stringMaps ID, const StringMap &value) {
- typedef StringMap::ConstIterator SMCI;
- using namespace sword;
-
- QSettings *s = getConfig();
- s->beginGroup(getKey(ID));
-
- // Clear all entries of this group to make sure old stuff gets removed:
- s->remove("");
-
- switch (ID) {
- case searchScopes: {
- /**
- We want to make sure that the search scopes are saved with english
- key names so loading them will always work with each locale set.
- */
- VerseKey vk;
- for (SMCI it(value.begin()); it != value.end(); it++) {
- QString data;
- ListKey list(vk.ParseVerseList(it.value().toUtf8(), "Genesis 1:1", true));
- for (int i(0); i < list.Count(); i++) {
- VerseKey *range(dynamic_cast<VerseKey*>(list.getElement(i)));
- if (range) {
- range->setLocale("en");
- data.append(QString::fromUtf8( range->getRangeText() ));
- data.append(";");
- }
- }
- s->setValue(it.key(), data);
- }
- break;
- }
- default: {
- for (SMCI it(value.begin()); it != value.end(); it++) {
- s->setValue(it.key(), it.value());
- }
- break;
- }
- }
- s->endGroup();
-}
-
-void set(const CLanguageMgr::Language * const language,
- const FontSettingsPair& value)
-{
- QSettings *s = getConfig();
- QString lang = getKey(language);
- s->setValue("fonts/" + lang, value.second.toString());
- s->setValue("font standard settings/" + lang, value.first);
-
- // Remove language from the cache:
- m_fontCache.remove(language);
-}
-
-DisplayOptions getDisplayOptionDefaults() {
- DisplayOptions options;
- options.lineBreaks = get(lineBreaks);
- options.verseNumbers = get(verseNumbers);
- return options;
-}
-
-FilterOptions getFilterOptionDefaults() {
- FilterOptions options;
-
- options.footnotes = true; // Required for the info display
- options.strongNumbers = true; // get(strongNumbers);
- options.headings = get(headings);
- options.morphTags = true; // Required for the info display
- options.lemmas = true; // Required for the info display
- options.redLetterWords = true;
- options.hebrewPoints = get(hebrewPoints);
- options.hebrewCantillation = get(hebrewCantillation);
- options.greekAccents = get(greekAccents);
- options.textualVariants = get(textualVariants);
- options.scriptureReferences = get(scriptureReferences);
- options.morphSegmentation = get(morphSegmentation);
-
- return options;
-}
-
-void setupAccelSettings(const keys type,
- BtActionCollection * const actionCollection)
-{
- const char *groupName ="";
- switch (type) {
- case allWindows:
- groupName = "Displaywindow shortcuts";
- break;
- case writeWindow:
- groupName = "Writewindow shortcuts";
- break;
- case readWindow:
- groupName = "Readwindow shortcuts";
- break;
- case bookWindow:
- groupName = "Book shortcuts";
- break;
- case bibleWindow:
- groupName = "Bible shortcuts";
- break;
- case commentaryWindow:
- groupName = "Commentary shortcuts";
- break;
- case lexiconWindow:
- groupName = "Lexicon shortcuts";
- break;
- case application:
- groupName = "Application shortcuts";
- break;
- }
-
- actionCollection->setConfigGroup(groupName);
- actionCollection->readSettings();
-}
-
-void saveAccelSettings(const keys type,
- BtActionCollection * const actionCollection)
-{
- const char *groupName ="";
- switch (type) {
- case allWindows:
- groupName = "Displaywindow shortcuts";
- break;
- case writeWindow:
- groupName = "Writewindow shortcuts";
- break;
- case readWindow:
- groupName = "Readwindow shortcuts";
- break;
- case bookWindow:
- groupName = "Book shortcuts";
- break;
- case bibleWindow:
- groupName = "Bible shortcuts";
- break;
- case commentaryWindow:
- groupName = "Commentary shortcuts";
- break;
- case lexiconWindow:
- groupName = "Lexicon shortcuts";
- break;
- case application:
- groupName = "Application shortcuts";
- break;
- }
-
- actionCollection->setConfigGroup(groupName);
- actionCollection->writeSettings();
-}
-
-
-QString getModuleEncryptionKey(const QString &module) {
- Q_ASSERT(!module.isEmpty());
- static const QString nullString;
-
- QVariant v = getConfig()->value("Module keys/" + module);
- if (v.isValid())
- return v.toString();
-
- return nullString;
-}
-
-void setModuleEncryptionKey(const QString &module, const QString &key) {
- getConfig()->setValue("Module keys/" + module, key);
-}
-
-QSettings *getConfig() {
- namespace DU = util::directory;
- static QSettings config(DU::getUserBaseDir().absolutePath() + "/bibletimerc", QSettings::IniFormat);
- return &config;
-}
-
-void syncConfig() {
- getConfig()->sync();
-}
-
-} // namespace CBTConfig
diff --git a/src/backend/config/cbtconfig.h b/src/backend/config/cbtconfig.h
deleted file mode 100644
index f3fa042..0000000
--- a/src/backend/config/cbtconfig.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/*********
-*
-* 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 CBTCONFIG_H
-#define CBTCONFIG_H
-
-#include <QString>
-#include <QFont>
-#include <QList>
-#include <QMap>
-#include "backend/managers/cswordbackend.h"
-
-class QSettings;
-class BtActionCollection;
-
-/**
- * This class is the interface to the config object of BibleTime
- * @author The BibleTime team
- */
-namespace CBTConfig {
-
-typedef QMap<QString, QString> StringMap;
-typedef std::pair<bool, QFont> FontSettingsPair;
-
-enum strings {
- bibletimeVersion,
- language,
- displayStyle,
- bookshelfCurrentItem
-};
-enum modules {
- standardBible = 0, // Just to make sure, default is IMHO 0, so that's redundant here
- standardCommentary,
- standardLexicon,
- standardDailyDevotional,
- standardHebrewStrongsLexicon,
- standardGreekStrongsLexicon,
- standardHebrewMorphLexicon,
- standardGreekMorphLexicon,
- lastModuleType = standardGreekMorphLexicon
-};
-enum bools {
- firstSearchDialog,
- readOldBookmarks,
-
- showMainWindowToolbar,
- mainIndex,
- infoDisplay,
-
- autoTileVertical,
- autoTileHorizontal,
- autoTile,
- autoTabbed,
- autoCascade,
-
- lineBreaks,
- verseNumbers,
-
- logo,
- autoDeleteOrphanedIndices,
- crashedLastTime,
- crashedTwoTimes,
-
- bookshelfShowHidden,
-
- allowNetworkConnection,
-
- showTextWindowHeaders,
- showTextWindowNavigator,
- showTextWindowToolButtons,
- showTextWindowModuleSelectorButtons,
- showFormatToolbarButtons,
- showToolbarsInEachWindow,
- showTipAtStartup
-};
-enum ints {
- footnotes,
- strongNumbers,
- headings,
- morphTags,
- lemmas,
- hebrewPoints,
- hebrewCantillation,
- greekAccents,
- textualVariants,
- scriptureReferences,
- morphSegmentation,
-
- bookshelfContentsX,
- bookshelfContentsY,
- magDelay, /* The delay until a mouse move makes the content appear in the mag */
- bookshelfGrouping,
- mainindexActiveTab,
-
- searchDialogWidth,
- searchDialogHeight,
- searchDialogX,
- searchDialogY,
- searchType,
-
- installPathIndex,
-
- bookshelfPosX,
- bookshelfPosY,
- bookshelfHeight,
- bookshelfWidth,
-
- configDialogPosX,
- configDialogPosY,
- configDialogHeight,
- configDialogWidth,
- tipNumber
-};
-enum intLists {
- leftPaneSplitterSizes,
- mainSplitterSizes,
- searchMainSplitterSizes,
- searchResultSplitterSizes
-};
-enum stringLists {
- searchCompletionTexts,
- searchTexts,
- searchModulesHistory,
- bookshelfOpenGroups,
- hiddenModules
-};
-enum keys {
- allWindows,
- readWindow,
- writeWindow,
- bookWindow,
- bibleWindow,
- commentaryWindow,
- lexiconWindow,
- application
-};
-enum stringMaps {
- searchScopes
-};
-
-QString IntListToString(const QList<int> &intList);
-QList<int> StringToIntList(const QString &intListString,
- bool *ok = 0,
- QString::SplitBehavior splitBehavior = QString::KeepEmptyParts);
-
-QString getDefault(const strings);
-QString getDefault(const modules);
-bool getDefault(const bools);
-int getDefault(const ints);
-QList<int> getDefault(const intLists);
-QStringList getDefault(const stringLists);
-StringMap getDefault(const stringMaps);
-QFont &getDefault(const CLanguageMgr::Language * const);
-
-QString get(const strings);
-CSwordModuleInfo *get(const modules);
-bool get(const bools);
-int get(const ints);
-QList<int> get(const intLists);
-QStringList get(const stringLists);
-StringMap get(const stringMaps);
-FontSettingsPair get(const CLanguageMgr::Language * const);
-
-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);
-void set(const ints, const int value);
-void set(const intLists, const QList<int> &value);
-void set(const stringLists, const QStringList &value);
-void set(const stringMaps, const StringMap &value);
-void set(const CLanguageMgr::Language * const language,
- const FontSettingsPair &fontSettings);
-
-FilterOptions getFilterOptionDefaults();
-DisplayOptions getDisplayOptionDefaults();
-
-void setupAccelSettings(const keys type,
- BtActionCollection * const actionCollection);
-void saveAccelSettings (const keys type,
- BtActionCollection * const actionCollection);
-
-QString getModuleEncryptionKey(const QString &name);
-void setModuleEncryptionKey(const QString &name, const QString &key);
-
-/**
- Re-reads the config from disk.
-*/
-void syncConfig();
-
-/**
- Returns the config object.
-*/
-QSettings* getConfig();
-
-} // namespace CBTConfig
-
-#endif
diff --git a/src/backend/cswordmodulesearch.cpp b/src/backend/cswordmodulesearch.cpp
index 694151d..799032b 100644
--- a/src/backend/cswordmodulesearch.cpp
+++ b/src/backend/cswordmodulesearch.cpp
@@ -2,16 +2,19 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
+#include <QDebug>
+
#include "backend/cswordmodulesearch.h"
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/managers/cswordbackend.h"
#include "btglobal.h"
+#include "util/tool.h"
void CSwordModuleSearch::startSearch() {
@@ -20,7 +23,7 @@ void CSwordModuleSearch::startSearch() {
m_foundItems = 0;
/// \todo What is the purpose of the following statement?
- CSwordBackend::instance()->setFilterOptions(CBTConfig::getFilterOptionDefaults());
+ CSwordBackend::instance()->setFilterOptions(btConfig().getFilterOptions());
// Search module-by-module:
Q_FOREACH(const CSwordModuleInfo *m, m_searchModules) {
@@ -61,3 +64,287 @@ QList<const CSwordModuleInfo*> CSwordModuleSearch::unindexedModules(
}
return unindexed;
}
+
+QString CSwordModuleSearch::highlightSearchedText(const QString& content, const QString& searchedText) {
+ QString ret = content;
+
+ const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
+
+ // int index = 0;
+ int index = ret.indexOf("<body", 0);
+ int matchLen = 0;
+ int length = searchedText.length();
+
+ // Highlighting constants -
+ // \todo We need to make the highlight color configurable.
+ const QString rep1("<span style=\"background-color:#FFFF66;\">");
+ const QString rep2("</span>");
+ const unsigned int repLength = rep1.length() + rep1.length();
+ const QString rep3("style=\"background-color:#FFFF66;\" ");
+ const unsigned int rep3Length = rep3.length();
+
+
+ QString newSearchText;
+
+ newSearchText = searchedText;
+
+ // find the strongs search lemma and highlight it
+ // search the searched text for "strong:" until it is not found anymore
+ QStringList list;
+
+ // split the search string - some possibilities are "\\s|\\|", "\\s|\\+", or "\\s|\\|\\+"
+ // \todo find all possible seperators
+ QString regExp = "\\s";
+ list = searchedText.split(QRegExp(regExp));
+ foreach (QString newSearchText, list) {
+ int sstIndex; // strong search text index for finding "strong:"
+ int idx1, idx2;
+ QString sNumber, lemmaText;
+
+ sstIndex = newSearchText.indexOf("strong:");
+ if (sstIndex == -1)
+ continue;
+
+ // set the start index to the start of <body>
+ int strongIndex = index;
+
+ // Get the strongs number from the search text.
+ // First, find the first space after "strong:"
+ sstIndex = sstIndex + 7;
+ // get the strongs number -> the text following "strong:" to the end of the string.
+ sNumber = newSearchText.mid(sstIndex, -1);
+ // find all the "lemma=" inside the the content
+ while ((strongIndex = ret.indexOf("lemma=", strongIndex, cs)) != -1) {
+ // get the strongs number after the lemma and compare it with the
+ // strongs number we are looking for
+ idx1 = ret.indexOf("\"", strongIndex) + 1;
+ idx2 = ret.indexOf("\"", idx1 + 1);
+ lemmaText = ret.mid(idx1, idx2 - idx1);
+
+ // this is interesting because we could have a strongs number like: G3218|G300
+ // To handle this we will use some extra cpu cycles and do a partial match against
+ // the lemmaText
+ if (lemmaText.contains(sNumber)) {
+ // strongs number is found now we need to highlight it
+ // I believe the easiest way is to insert rep3 just before "lemma="
+ ret = ret.insert(strongIndex, rep3);
+ strongIndex += rep3Length;
+ }
+ strongIndex += 6; // 6 is the length of "lemma="
+ }
+ }
+ //---------------------------------------------------------------------
+ // now that the strong: stuff is out of the way continue with
+ // other search options
+ //---------------------------------------------------------------------
+
+ // try to figure out how to use the lucene query parser
+
+ //using namespace lucene::queryParser;
+ //using namespace lucene::search;
+ //using namespace lucene::analysis;
+ //using namespace lucene::util;
+
+ //wchar_t *buf;
+ //char buf8[1000];
+ //standard::WhitespaceAnalyzer analyzer;
+ //lucene_utf8towcs(m_wcharBuffer, searchedText.utf8(), MAX_CONV_SIZE);
+ //QSharedPointer<Query> q( QueryParser::parse(m_wcharBuffer, _T("content"), &analyzer) );
+ //StringReader reader(m_wcharBuffer);
+ //TokenStream* tokenStream = analyzer.tokenStream( _T("field"), &reader);
+ //Token token;
+ //while(tokenStream->next(&token) != 0) {
+ // lucene_wcstoutf8(buf8, token.termText(), 1000);
+ // printf("%s\n", buf8);
+ //}
+
+ //===========================================================
+ // since I could not figure out the lucene query parser, I
+ // made a simple parser.
+ //===========================================================
+ QStringList words = queryParser(newSearchText);
+ qDebug() << "btsearchresultarea.cpp: " << __LINE__ << ": " << words << '\n';
+ foreach (QString word, words) { //search for every word in the list
+ QRegExp findExp;
+ if (word.contains("*")) {
+ length = word.length() - 1;
+ word.replace('*', "\\S*"); //match within a word
+ findExp = QRegExp(word);
+ findExp.setMinimal(true);
+ }
+ else if (word.contains("?")) {
+ length = word.length() - 1;
+ word.replace('?', "\\S?"); //match within a word
+ findExp = QRegExp(word);
+ findExp.setMinimal(true);
+ }
+ else {
+ length = word.length();
+ findExp = QRegExp("\\b" + word + "\\b");
+ }
+
+ // index = 0; //for every word start at the beginning
+ index = ret.indexOf("<body", 0);
+ findExp.setCaseSensitivity(cs);
+ //while ( (index = ret.find(findExp, index)) != -1 ) { //while we found the word
+ while ( (index = findExp.indexIn(ret, index)) != -1 ) { //while we found the word
+ matchLen = findExp.matchedLength();
+ if (!util::tool::inHTMLTag(index, ret)) {
+ length = matchLen;
+ ret = ret.insert( index + length, rep2 );
+ ret = ret.insert( index, rep1 );
+ index += repLength;
+ }
+ index += length;
+ }
+ }
+ qDebug() << "btsearchresultarea.cpp: " << __LINE__ << ": " << words << '\n';
+ //qWarning("\n\n\n%s", ret.latin1());
+ return ret;
+}
+
+QStringList CSwordModuleSearch::queryParser(const QString& queryString) {
+ QString token;
+ QStringList tokenList;
+ int cnt, pos;
+
+ token = "";
+ cnt = 0;
+ while (cnt < queryString.length()) {
+ // add to token
+ if ((queryString[cnt]).isLetterOrNumber() || (queryString[cnt] == '*')) {
+ token = token + queryString[cnt];
+ cnt++;
+ }
+ else if ((queryString[cnt]).isLetterOrNumber() || (queryString[cnt] == '?')) {
+ token = token + queryString[cnt];
+ cnt++;
+ }
+ // token break
+ else if (queryString[cnt] == ' ') {
+ token = token.simplified();
+ if ((token != "*") && (token != ""))
+ tokenList.append(token);
+ token = "";
+ cnt++;
+ }
+ // clucene appears to ignore quoted strings in the sence
+ // that it treats all the words within quoted strings as
+ // regular tokens and not as a single token.
+ else if (queryString[cnt] == '"') {
+ cnt++;
+ }
+ // wild card - treat as a special token break
+ //else if (queryString[cnt] == '*') {
+ // token = token + queryString[cnt];
+ // token = token.simplified();
+ // if ((token != "*") && (token != ""))
+ // tokenList.append(token);
+ // // start next token with wildcard (kin*m -> kin* *m)
+ // token = "*";
+ // cnt++;
+ //}
+ // the ! token is also a token break
+ else if (queryString[cnt] == '!') {
+ // store away current token
+ token = token.simplified();
+ if ((token != "*") && (token != ""))
+ tokenList.append(token);
+ // add the ! token
+ tokenList.append("!");
+ token = "";
+ cnt++;
+ }
+ // the - token is also a token break
+ else if (queryString[cnt] == '-') {
+ // store away current token
+ token = token.simplified();
+ if ((token != "*") && (token != ""))
+ tokenList.append(token);
+ // add the ! token
+ tokenList.append("-");
+ token = "";
+ cnt++;
+ }
+ // the + token is also a token break
+ else if (queryString[cnt] == '+') {
+ // store away current token
+ token = token.simplified();
+ if ((token != "*") && (token != ""))
+ tokenList.append(token);
+ // add the + token
+ tokenList.append("+");
+ token = "";
+ cnt++;
+ }
+ // the || token is also a token break
+ else if ((queryString[cnt] == '|') && (queryString[cnt+1] == '|')) {
+ // store away current token
+ token = token.simplified();
+ if ((token != "*") && (token != ""))
+ tokenList.append(token);
+ // add the || token
+ tokenList.append("||");
+ token = "";
+ cnt += 2;
+ }
+ // the && token is also a token break
+ else if ((queryString[cnt] == '&') && (queryString[cnt+1] == '&')) {
+ // store away current token
+ token = token.simplified();
+ if ((token != "*") && (token != ""))
+ tokenList.append(token);
+ // add the || token
+ tokenList.append("&&");
+ token = "";
+ cnt += 2;
+ }
+ else cnt++;
+ }
+ token = token.simplified();
+ if ((token != "*") && (token != ""))
+ tokenList.append(token);
+
+ cnt = 0;
+ QStringList::iterator it;
+ for (it = tokenList.begin(); it != tokenList.end(); ++it) {
+ //-----------------------------------------------------------
+ // remove all the NOT(!) tokens - these do not need to be
+ // highlighted in the highlighter
+ //-----------------------------------------------------------
+ if (((*it) == "!") || ((*it) == "NOT") || ((*it) == "-")) {
+ it = tokenList.erase(it);
+ if (it == tokenList.end())
+ break;
+ it = tokenList.erase(it);
+ if (it == tokenList.end())
+ break;
+ --it;
+ }
+ //-----------------------------------------------------------
+ // remove all the operator tokens - these do not need to be
+ // highlighted in the highlighter
+ //-----------------------------------------------------------
+ else if ( ((*it) == "||") || ((*it) == "OR") || ((*it) == "+") ||
+ ((*it) == "AND") || ((*it) == "&&") ) {
+ it = tokenList.erase(it);
+ if (it == tokenList.end())
+ break;
+ --it;
+ }
+ // if the token contains a ^ then trim the remainder of the
+ // token from the ^
+ //What??? error: invalid conversion from ‘const void*’ to ‘int’
+ // and how come "contains" returns bool but is used as int?
+ //else if ( (pos = (*it).contains("^")) >= 0 ) {
+ else if ( (pos = (*it).indexOf("^") ) >= 0 ) {
+ (*it) = (*it).left(pos - 1);
+ }
+ // if the token contains a ~ then trim the remainder of the
+ // token from the ~
+ else if ( (pos = (*it).indexOf("~") ) >= 0 ) {
+ (*it) = (*it).left(pos - 2) + "*";
+ }
+ }
+ return(tokenList);
+}
diff --git a/src/backend/cswordmodulesearch.h b/src/backend/cswordmodulesearch.h
index aa864b0..48b66d2 100644
--- a/src/backend/cswordmodulesearch.h
+++ b/src/backend/cswordmodulesearch.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -101,6 +103,17 @@ class CSwordModuleSearch: public QObject {
static QList<const CSwordModuleInfo*> unindexedModules(
const QList<const CSwordModuleInfo*> &modules);
+ /**
+ * This function highlights the searched text in the content using the search type given by search flags
+ */
+ static QString highlightSearchedText(const QString& content, const QString& searchedText);
+
+ protected:
+ /**
+ * This function breakes the queryString into clucene tokens
+ */
+ static QStringList queryParser(const QString& queryString);
+
private: /* Fields: */
QString m_searchText;
sword::ListKey m_searchScope;
diff --git a/src/backend/drivers/cswordbiblemoduleinfo.cpp b/src/backend/drivers/cswordbiblemoduleinfo.cpp
index e87fea2..1c1d124 100644
--- a/src/backend/drivers/cswordbiblemoduleinfo.cpp
+++ b/src/backend/drivers/cswordbiblemoduleinfo.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,9 +18,9 @@
CSwordBibleModuleInfo::CSwordBibleModuleInfo(sword::SWModule *module,
- CSwordBackend * const usedBackend,
+ CSwordBackend & backend,
ModuleType type)
- : CSwordModuleInfo(module, usedBackend, type)
+ : CSwordModuleInfo(module, backend, type)
, m_boundsInitialized(false)
, m_lowerBound(0)
, m_upperBound(0)
@@ -35,7 +35,7 @@ void CSwordBibleModuleInfo::initBounds() const {
Q_ASSERT(!m_boundsInitialized);
sword::SWModule *m = module();
- const bool oldStatus = m->getSkipConsecutiveLinks();
+ const bool oldStatus = m->isSkipConsecutiveLinks();
m->setSkipConsecutiveLinks(true);
m->setPosition(sword::TOP); // position to first entry
@@ -57,11 +57,14 @@ void CSwordBibleModuleInfo::initBounds() const {
/** Returns the books available in this module */
QStringList *CSwordBibleModuleInfo::books() const {
- if (m_cachedLocale != backend()->booknameLanguage()) {
- // Reset the booklist because the locale has changed
- m_cachedLocale = backend()->booknameLanguage();
- delete m_bookList;
- m_bookList = 0;
+ {
+ CSwordBackend & b = backend();
+ if (m_cachedLocale != b.booknameLanguage()) {
+ // Reset the booklist because the locale has changed
+ m_cachedLocale = b.booknameLanguage();
+ delete m_bookList;
+ m_bookList = 0;
+ }
}
if (!m_bookList) {
@@ -81,12 +84,12 @@ QStringList *CSwordBibleModuleInfo::books() const {
max--; // max == 1
if (min > max) {
- qWarning("CSwordBibleModuleInfo (%s) no OT and not NT! Check your config!", module()->Name());
+ qWarning("CSwordBibleModuleInfo (%s) no OT and not NT! Check your config!", module()->getName());
} else {
- QSharedPointer<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ QSharedPointer<sword::VerseKey> key((sword::VerseKey *)module()->createKey());
key->setPosition(sword::TOP);
- for (key->setTestament(min); !key->Error() && key->getTestament() <= max; key->setBook(key->getBook() + 1)) {
+ for (key->setTestament(min); !key->popError() && key->getTestament() <= max; key->setBook(key->getBook() + 1)) {
m_bookList->append( QString::fromUtf8(key->getBookName()) );
}
}
@@ -98,7 +101,7 @@ QStringList *CSwordBibleModuleInfo::books() const {
unsigned int CSwordBibleModuleInfo::chapterCount(const unsigned int book) const {
int result = 0;
- QSharedPointer<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ QSharedPointer<sword::VerseKey> key((sword::VerseKey *)module()->createKey());
key->setPosition(sword::TOP);
// works for old and new versions
@@ -120,7 +123,7 @@ unsigned int CSwordBibleModuleInfo::verseCount(const unsigned int book,
{
unsigned int result = 0;
- QSharedPointer<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ QSharedPointer<sword::VerseKey> key((sword::VerseKey *)module()->createKey());
key->setPosition(sword::TOP);
// works for old and new versions
@@ -141,7 +144,7 @@ unsigned int CSwordBibleModuleInfo::verseCount(const QString &book,
unsigned int CSwordBibleModuleInfo::bookNumber(const QString &book) const {
unsigned int bookNumber = 0;
- QSharedPointer<sword::VerseKey> key((sword::VerseKey *)module()->CreateKey());
+ QSharedPointer<sword::VerseKey> key((sword::VerseKey *)module()->createKey());
key->setPosition(sword::TOP);
key->setBookName(book.toUtf8().constData());
diff --git a/src/backend/drivers/cswordbiblemoduleinfo.h b/src/backend/drivers/cswordbiblemoduleinfo.h
index 49606e3..fb630c3 100644
--- a/src/backend/drivers/cswordbiblemoduleinfo.h
+++ b/src/backend/drivers/cswordbiblemoduleinfo.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,7 +27,8 @@ class CSwordBibleModuleInfo: public CSwordModuleInfo {
Q_OBJECT
public: /* Methods: */
- CSwordBibleModuleInfo(sword::SWModule *module, CSwordBackend * const,
+ CSwordBibleModuleInfo(sword::SWModule * module,
+ CSwordBackend & backend,
ModuleType type = Bible);
inline ~CSwordBibleModuleInfo() {
diff --git a/src/backend/drivers/cswordbookmoduleinfo.cpp b/src/backend/drivers/cswordbookmoduleinfo.cpp
index 8c6b8b1..bae54b9 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,11 +16,10 @@
#include <treekeyidx.h>
-CSwordBookModuleInfo::CSwordBookModuleInfo(sword::SWModule *module,
- CSwordBackend * const usedBackend)
- : CSwordModuleInfo(module, usedBackend,
- CSwordModuleInfo::GenericBook),
- m_depth(-1)
+CSwordBookModuleInfo::CSwordBookModuleInfo(sword::SWModule * module,
+ CSwordBackend & backend)
+ : CSwordModuleInfo(module, backend, CSwordModuleInfo::GenericBook)
+ , m_depth(-1)
{
sword::TreeKeyIdx *key = tree();
if (key) {
@@ -29,25 +28,21 @@ CSwordBookModuleInfo::CSwordBookModuleInfo(sword::SWModule *module,
}
}
-void CSwordBookModuleInfo::computeDepth(sword::TreeKeyIdx *key, int level) {
- std::string savedKey;
- // savedKey = key->getFullName(); //sword 1.5.8
- savedKey = key->getText();
-
- if (level > m_depth) {
+void CSwordBookModuleInfo::computeDepth(sword::TreeKeyIdx * const key,
+ const int level)
+{
+ const QByteArray savedKey(key->getText());
+ if (level > m_depth)
m_depth = level;
- }
if (key->hasChildren()) {
key->firstChild();
- computeDepth(key, level + 1);
-
- key->setText( savedKey.c_str() );//return to the initial value
+ computeDepth(key, level + 1u);
+ key->setText(savedKey.constData()); // Return to the initial value
}
- if (key->nextSibling()) {
+ if (key->nextSibling())
computeDepth(key, level);
- }
}
/** Returns a treekey filled with the structure of this module */
diff --git a/src/backend/drivers/cswordbookmoduleinfo.h b/src/backend/drivers/cswordbookmoduleinfo.h
index c6b0494..d540932 100644
--- a/src/backend/drivers/cswordbookmoduleinfo.h
+++ b/src/backend/drivers/cswordbookmoduleinfo.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -27,8 +29,8 @@ class CSwordBookModuleInfo: public CSwordModuleInfo {
\param module The module which belongs to this object
\param backend The parent backend for this book module.
*/
- CSwordBookModuleInfo(sword::SWModule *module,
- CSwordBackend * const usedBackend);
+ CSwordBookModuleInfo(sword::SWModule * module,
+ CSwordBackend & usedBackend);
inline CSwordBookModuleInfo(const CSwordBookModuleInfo &copy)
: CSwordModuleInfo(copy), m_depth(copy.m_depth) {}
@@ -46,10 +48,11 @@ class CSwordBookModuleInfo: public CSwordModuleInfo {
sword::TreeKeyIdx *tree() const;
private: /* Methods: */
+
/**
* A recursive helper function to help computng the module depth!
*/
- void computeDepth(sword::TreeKeyIdx *key, int level = 0);
+ void computeDepth(sword::TreeKeyIdx * const key, const int level = 0);
private: /* Fields: */
int m_depth;
diff --git a/src/backend/drivers/cswordcommentarymoduleinfo.cpp b/src/backend/drivers/cswordcommentarymoduleinfo.cpp
index 07e09d2..9baaf97 100644
--- a/src/backend/drivers/cswordcommentarymoduleinfo.cpp
+++ b/src/backend/drivers/cswordcommentarymoduleinfo.cpp
@@ -2,19 +2,17 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "backend/drivers/cswordcommentarymoduleinfo.h"
-
bool CSwordCommentaryModuleInfo::isWritable() const {
/*
A module is only writable if it's a RawFiles module with writable
returning true.
*/
- return std::string(module()->getConfigEntry("ModDrv")) == "RawFiles"
- && module()->isWritable();
+ return !qstrcmp(module()->getConfigEntry("ModDrv"), "RawFiles") && module()->isWritable();
}
diff --git a/src/backend/drivers/cswordcommentarymoduleinfo.h b/src/backend/drivers/cswordcommentarymoduleinfo.h
index 3c42d99..688ae53 100644
--- a/src/backend/drivers/cswordcommentarymoduleinfo.h
+++ b/src/backend/drivers/cswordcommentarymoduleinfo.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,10 +24,12 @@ class CSwordCommentaryModuleInfo: public CSwordBibleModuleInfo {
Q_OBJECT
public: /* Methods: */
- inline CSwordCommentaryModuleInfo(sword::SWModule *module,
- CSwordBackend * const usedBackend)
- : CSwordBibleModuleInfo(module, usedBackend,
- CSwordModuleInfo::Commentary) {}
+
+ inline CSwordCommentaryModuleInfo(sword::SWModule * module,
+ CSwordBackend & backend)
+ : CSwordBibleModuleInfo(module,
+ backend,
+ CSwordModuleInfo::Commentary) {}
/* Reimplementation of CSwordModuleInfo::isWritable(). */
virtual bool isWritable() const;
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.cpp b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
index 1b976d3..350a49c 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.cpp
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -31,17 +31,6 @@ const QStringList &CSwordLexiconModuleInfo::entries() const {
return m_entries;
}
- // 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_entries;
- }
- if ( name() == QString("EReo_en")) {
- qWarning() << "Module EReo_en is buggy and will not be loaded.";
- return m_entries;
- }
-
QString dir(DU::getUserCacheDir().absolutePath());
QFile f1( QString(dir).append("/").append(name()));
@@ -95,11 +84,12 @@ const QStringList &CSwordLexiconModuleInfo::entries() const {
}
module()->increment();
- } while (!module()->Error());
+ } while (!module()->popError());
module()->setPosition(sword::TOP); // back to the first entry
module()->setSkipConsecutiveLinks(false);
+ /// \todo Document why the following code is here:
if (!m_entries.empty() && m_entries.front().simplified().isEmpty())
m_entries.pop_front();
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.h b/src/backend/drivers/cswordlexiconmoduleinfo.h
index 1789b9b..74fad8c 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.h
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,8 +24,8 @@ class CSwordLexiconModuleInfo: public CSwordModuleInfo {
Q_OBJECT
public: /* Methods: */
- inline CSwordLexiconModuleInfo(sword::SWModule *module,
- CSwordBackend * const backend)
+ inline CSwordLexiconModuleInfo(sword::SWModule * module,
+ CSwordBackend & backend)
: CSwordModuleInfo(module, backend, Lexicon) {}
inline CSwordLexiconModuleInfo(const CSwordLexiconModuleInfo &copy)
diff --git a/src/backend/drivers/cswordmoduleinfo.cpp b/src/backend/drivers/cswordmoduleinfo.cpp
index 08721c9..f86f9ac 100644
--- a/src/backend/drivers/cswordmoduleinfo.cpp
+++ b/src/backend/drivers/cswordmoduleinfo.cpp
@@ -2,35 +2,37 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 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 <QSharedPointer>
#include <CLucene.h>
#include <QByteArray>
#include <QCoreApplication>
#include <QDebug>
#include <QDir>
#include <QFileInfo>
-#include <QList>
-#include <QRegExp>
#include <QSettings>
-#include "backend/config/cbtconfig.h"
+#include <QSharedPointer>
+#include <QTextDocument>
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordlexiconmoduleinfo.h"
#include "backend/keys/cswordkey.h"
#include "backend/managers/clanguagemgr.h"
#include "backend/managers/cswordbackend.h"
#include "backend/rendering/centrydisplay.h"
#include "backend/cswordmodulesearch.h"
+#include "bibletimeapp.h"
#include "btglobal.h"
+#include "frontend/messagedialog.h"
#include "util/cresmgr.h"
#include "util/directory.h"
#include "util/exceptions.h"
-#include "util/dialogutil.h"
+#include "util/geticon.h"
+#include "util/htmlescape.h"
// Sword includes:
#include <listkey.h>
@@ -41,29 +43,6 @@
#include <versekey.h>
-#if 0
-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;
@@ -72,72 +51,74 @@ 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,
+CSwordModuleInfo::CSwordModuleInfo(sword::SWModule * module,
+ CSwordBackend & backend,
ModuleType type)
- : m_module(module),
- m_backend(usedBackend ? usedBackend : CSwordBackend::instance()),
+ : m_module((Q_ASSERT(module), module)),
+ m_backend(backend),
m_type(type),
m_cancelIndexing(false),
- m_cachedName(QString::fromUtf8(module->Name())),
- m_cachedHasVersion(!QString((*m_backend->getConfig())[module->Name()]["Version"]).isEmpty())
+ m_cachedName(QString::fromUtf8(module->getName())),
+ m_cachedHasVersion(!QString((*m_backend.getConfig())[module->getName()]["Version"]).isEmpty())
{
- Q_ASSERT(module != 0);
- Q_ASSERT(usedBackend != 0);
-
initCachedCategory();
initCachedLanguage();
- 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?
- }
- }
-}
+ m_hidden = btConfig().value<QStringList>("state/hiddenModules",
+ QStringList()).contains(m_cachedName);
-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)
+ if (m_cachedHasVersion
+ && (minimumSwordVersion() > sword::SWVersion::currentVersion))
+ {
+ qWarning("The module \"%s\" requires a newer Sword library. Please "
+ "update to \"Sword %s\".",
+ m_cachedName.toUtf8().constData(),
+ minimumSwordVersion().getText());
+
+ /// \todo if this is the case, can we use the module at all?
+ }
+}
+
+CSwordModuleInfo::CSwordModuleInfo(const CSwordModuleInfo & copy)
+ : QObject(NULL)
+ , m_module(copy.m_module)
+ , m_backend(copy.m_backend)
+ , m_type(copy.m_type)
+ , m_hidden(copy.m_hidden)
+ , m_cancelIndexing(copy.m_cancelIndexing)
+ , m_cachedName(copy.m_cachedName)
+ , m_cachedCategory(copy.m_cachedCategory)
+ , m_cachedLanguage(copy.m_cachedLanguage)
+ , m_cachedHasVersion(copy.m_cachedHasVersion)
{
// Intentionally empty
}
bool CSwordModuleInfo::unlock(const QString & unlockKey) {
- if (!isEncrypted()) {
+ if (!isEncrypted())
return false;
- }
bool unlocked = unlockKeyIsValid();
- CBTConfig::setModuleEncryptionKey(name(), unlockKey);
+ btConfig().setModuleEncryptionKey(m_cachedName, 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());
+ /* 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 */
+ m_backend.setCipherKey(m_module->getName(), unlockKey.toUtf8().constData());
/// \todo write to Sword config as well
- if (unlockKeyIsValid() != unlocked) {
+ if (unlockKeyIsValid() != unlocked)
emit unlockedChanged(!unlocked);
- }
return true;
}
bool CSwordModuleInfo::isLocked() const {
- //still works, but the cipherkey is stored in CBTConfig.
- //Works because it is set in sword on program startup.
+ // still works, but the cipherkey is stored in BtConfig.
+ // Works because it is set in sword on program startup.
return isEncrypted() && !unlockKeyIsValid();
}
@@ -148,38 +129,35 @@ bool CSwordModuleInfo::isEncrypted() const {
* is encrypted but not necessarily locked
*/
- //This code is still right, though we do no longer write to the module config files any more
- 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())
+ /* This code is still right, though we do no longer write to the module
+ config files any more. */
+ typedef sword::SectionMap::const_iterator SMCI;
+ SMCI it = m_backend.getConfig()->Sections.find(m_cachedName.toUtf8().constData());
+ if (it == m_backend.getConfig()->Sections.end())
return false;
- sword::ConfigEntMap config = SectionMapIter->second;
- sword::ConfigEntMap::iterator it = config.find("CipherKey");
- return it != config.end();
+ const sword::ConfigEntMap & config = it->second;
+ return config.find("CipherKey") != config.end();
}
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
- // Unicode text, because all non-ASCII Unicode chars consist of bytes >127
- // and therefore contain no control (nonprintable) characters, which are all <127.
- QString test = isUnicode()
- ? QString::fromUtf8(m_module->getRawEntryBuf().c_str())
- : QString::fromLatin1( m_module->getRawEntryBuf().c_str() );
+ /* This needs to use ::fromLatin1 because if the text is still locked, a lot
+ of garbage will show up. It will also work with properly decrypted
+ Unicode text, because all non-ASCII Unicode chars consist of bytes >127
+ and therefore contain no control (nonprintable) characters, which are all
+ <127. */
+ const QString test(isUnicode()
+ ? QString::fromUtf8(m_module->getRawEntryBuf().c_str())
+ : QString::fromLatin1(m_module->getRawEntryBuf().c_str()));
- if (test.isEmpty()) {
+ if (test.isEmpty())
return false;
- }
- for (int i = 0; i <= test.length() && i < 100; i++) {
- if ( !test[i].isPrint() && !test[i].isNull() ) {
+ for (int i = 0; i < test.length() && i < 100; i++)
+ if (!test[i].isPrint() && !test[i].isNull())
return false;
- }
- }
-
return true;
}
@@ -188,336 +166,374 @@ QString CSwordModuleInfo::getGlobalBaseIndexLocation() {
}
QString CSwordModuleInfo::getModuleBaseIndexLocation() const {
- return getGlobalBaseIndexLocation() + QString("/") + name().toLocal8Bit();
+ return getGlobalBaseIndexLocation() + QString("/") + m_cachedName.toLocal8Bit();
}
-QString CSwordModuleInfo::getModuleStandardIndexLocation() const { //this for now returns the location of the main index
+QString CSwordModuleInfo::getModuleStandardIndexLocation() const {
+ // This for now returns the location of the main index
return getModuleBaseIndexLocation() + QString("/standard");
}
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;
- if (!d.exists( getModuleStandardIndexLocation() )) {
- return false;
+ { // Is this a directory?
+ QFileInfo fi(getModuleStandardIndexLocation());
+ if (!fi.isDir())
+ return false;
}
- //first check if the index version and module version are ok
- QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
+ // Are the index version and module version OK?
+ QSettings module_config(getModuleBaseIndexLocation()
+ + QString("/bibletime-index.conf"),
+ QSettings::IniFormat);
- if (hasVersion() &&
- module_config.value("module-version").toString() != config(CSwordModuleInfo::ModuleVersion))
+ if (m_cachedHasVersion
+ && module_config.value("module-version").toString()
+ != config(CSwordModuleInfo::ModuleVersion))
{
return false;
}
if (module_config.value("index-version").toUInt() != INDEX_VERSION) {
- qDebug("%s: INDEX_VERSION is not compatible with this version of BibleTime.", name().toUtf8().constData());
+ qDebug("%s: INDEX_VERSION is not compatible with this version of "
+ "BibleTime.",
+ m_cachedName.toUtf8().constData());
return false;
}
- //then check if the index is there
- return lucene::index::IndexReader::indexExists(getModuleStandardIndexLocation().toLatin1().constData());
+ // Is the index there?
+ return lucene::index::IndexReader::indexExists(getModuleStandardIndexLocation()
+ .toLatin1().constData());
}
bool CSwordModuleInfo::buildIndex() {
-
m_cancelIndexing = false;
try {
- //Without this we don't get strongs, lemmas, etc
- backend()->setFilterOptions ( CBTConfig::getFilterOptionDefaults() );
- //make sure we reset all important filter options which influcence the plain filters.
- // turn on these options, they are needed for the EntryAttributes population
- backend()->setOption( CSwordModuleInfo::strongNumbers, true );
- backend()->setOption( CSwordModuleInfo::morphTags, true );
- backend()->setOption( CSwordModuleInfo::footnotes, true );
- backend()->setOption( CSwordModuleInfo::headings, true );
- // we don't want the following in the text, the do not carry searchable information
- backend()->setOption( CSwordModuleInfo::morphSegmentation, false );
- backend()->setOption( CSwordModuleInfo::scriptureReferences, false );
- backend()->setOption( CSwordModuleInfo::redLetterWords, false );
-
- // do not use any stop words
- const TCHAR* stop_words[] = { NULL };
- lucene::analysis::standard::StandardAnalyzer an( (const TCHAR**)stop_words );
- QString index = getModuleStandardIndexLocation();
+ // Without this we don't get strongs, lemmas, etc.
+ m_backend.setFilterOptions(btConfig().getFilterOptions());
+ /* Make sure we reset all important filter options which influcence the
+ plain filters. Turn on these options, they are needed for the
+ EntryAttributes population */
+ m_backend.setOption(CSwordModuleInfo::strongNumbers, true);
+ m_backend.setOption(CSwordModuleInfo::morphTags, true);
+ m_backend.setOption(CSwordModuleInfo::footnotes, true);
+ m_backend.setOption(CSwordModuleInfo::headings, true);
+ /* We don't want the following in the text, the do not carry searchable
+ information. */
+ m_backend.setOption(CSwordModuleInfo::morphSegmentation, false);
+ m_backend.setOption(CSwordModuleInfo::scriptureReferences, false);
+ m_backend.setOption(CSwordModuleInfo::redLetterWords, false);
+
+ // Do not use any stop words:
+ static const TCHAR * stop_words[1u] = { NULL };
+ lucene::analysis::standard::StandardAnalyzer an(static_cast<const TCHAR **>(stop_words));
+ const QString index(getModuleStandardIndexLocation());
QDir dir("/");
- dir.mkpath( getGlobalBaseIndexLocation() );
- dir.mkpath( getModuleBaseIndexLocation() );
- dir.mkpath( getModuleStandardIndexLocation() );
+ dir.mkpath(getGlobalBaseIndexLocation());
+ dir.mkpath(getModuleBaseIndexLocation());
+ dir.mkpath(getModuleStandardIndexLocation());
- if (lucene::index::IndexReader::indexExists(index.toLatin1().constData())) {
- if (lucene::index::IndexReader::isLocked(index.toLatin1().constData()) ) {
+ if (lucene::index::IndexReader::indexExists(index.toLatin1().constData()))
+ if (lucene::index::IndexReader::isLocked(index.toLatin1().constData()))
lucene::index::IndexReader::unlock(index.toLatin1().constData());
- }
- }
- QSharedPointer<lucene::index::IndexWriter> writer( new lucene::index::IndexWriter(index.toLatin1().constData(), &an, true) ); //always create a new index
+ // Always create a new index:
+ typedef lucene::index::IndexWriter IW;
+ QSharedPointer<IW> writer(new IW(index.toLatin1().constData(), &an, true));
writer->setMaxFieldLength(BT_MAX_LUCENE_FIELD_LENGTH);
- writer->setUseCompoundFile(true); //merge segments into a single file
+ writer->setUseCompoundFile(true); // Merge segments into a single file
+#ifndef CLUCENE2
+ writer->setMinMergeDocs(1000);
+#endif
m_module->setPosition(sword::TOP);
- unsigned long verseLowIndex = m_module->Index();
+ unsigned long verseLowIndex = m_module->getIndex();
m_module->setPosition(sword::BOTTOM);
- unsigned long verseHighIndex = m_module->Index();
+ unsigned long verseHighIndex = m_module->getIndex();
- //verseLowIndex is not 0 in all cases (i.e. NT-only modules)
+ // verseLowIndex is not 0 in all cases (i.e. NT-only modules)
unsigned long verseIndex = verseLowIndex + 1;
unsigned long verseSpan = verseHighIndex - verseLowIndex;
- //Index() is not implemented properly for lexicons, so we use a
- //workaround.
- if (type() == CSwordModuleInfo::Lexicon) {
+ // Index() is not implemented properly for lexicons, so work around it:
+ if (m_type == CSwordModuleInfo::Lexicon) {
verseIndex = 0;
verseLowIndex = 0;
- verseSpan = ((CSwordLexiconModuleInfo*)this)->entries().size();
+ verseSpan = static_cast<CSwordLexiconModuleInfo *>(this)->entries().size();
}
emit indexingProgress(0);
- sword::SWKey* key = m_module->getKey();
- //VerseKey for bibles
- sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key);
+ sword::SWKey * const key = m_module->getKey();
+ sword::VerseKey * const vk = dynamic_cast<sword::VerseKey *>(key);
if (vk) {
- // we have to be sure to insert the english key into the index, otherwise we'd be in trouble if the language changes
+ /* We have to be sure to insert the english key into the index,
+ otherwise we'd be in trouble if the language changes. */
vk->setLocale("en_US");
- //If we have a verse based module, we want to include the pre-chapter etc. headings in the search
- vk->Headings(1);
+ /* If we have a verse based module, we want to include the pre-
+ chapter etc. headings in the search. */
+ vk->setIntros(true);
}
- //holds UTF-8 data and is faster than QString.
- QByteArray textBuffer;
+ QByteArray textBuffer; // Holds UTF-8 data and is faster than QString.
// we start with the first module entry, key is automatically updated
// because key is a pointer to the modules key
m_module->setSkipConsecutiveLinks(true);
- wchar_t wcharBuffer[BT_MAX_LUCENE_FIELD_LENGTH + 1];
+ QScopedPointer<wchar_t, QScopedPointerArrayDeleter<wchar_t> >
+ sPwcharBuffer(new wchar_t[BT_MAX_LUCENE_FIELD_LENGTH + 1]);
+ wchar_t * const wcharBuffer = sPwcharBuffer.data();
+ Q_ASSERT(wcharBuffer);
m_module->setPosition(sword::TOP);
- while (!(m_module->Error()) && !m_cancelIndexing) {
+ while (!(m_module->popError()) && !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)
+ /* 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). */
QSharedPointer<lucene::document::Document> doc(new lucene::document::Document());
//index the key
lucene_utf8towcs(wcharBuffer, key->getText(), BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnIndexed((const TCHAR*)_T("key"), (const TCHAR*)wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("key"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_YES | lucene::document::Field::INDEX_NO)));
-
- // index the main text
- //at this point we have to make sure we disabled the strongs and the other options
- //so the plain filters won't include the numbers somehow.
- lucene_utf8towcs(wcharBuffer, (const char*) textBuffer.append(m_module->StripText()), BT_MAX_LUCENE_FIELD_LENGTH);
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("content"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- textBuffer.resize(0); //clean up
-
- // index attributes
- sword::AttributeList::iterator attListI;
- sword::AttributeValue::iterator attValueI;
- // Footnotes
- for (attListI = m_module->getEntryAttributes()["Footnote"].begin();
- attListI != m_module->getEntryAttributes()["Footnote"].end();
- attListI++) {
- lucene_utf8towcs(wcharBuffer, attListI->second["body"], BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("footnote"), wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("footnote"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- } // for attListI
+ doc->add(*(new lucene::document::Field(static_cast<const TCHAR *>(_T("key")),
+ static_cast<const TCHAR *>(wcharBuffer),
+ lucene::document::Field::STORE_YES
+ | lucene::document::Field::INDEX_NO)));
+
+ /* At this point we have to make sure we disabled the strongs and
+ the other options, so the plain filters won't include the numbers
+ somehow. */
+ textBuffer.append(m_module->stripText());
+ lucene_utf8towcs(wcharBuffer,
+ static_cast<const char *>(textBuffer),
+ BT_MAX_LUCENE_FIELD_LENGTH);
+ doc->add(*(new lucene::document::Field(static_cast<const TCHAR *>(_T("content")),
+ static_cast<const TCHAR *>(wcharBuffer),
+ lucene::document::Field::STORE_NO
+ | lucene::document::Field::INDEX_TOKENIZED)));
+ textBuffer.clear();
+
+ typedef sword::AttributeList::iterator ALI;
+ typedef sword::AttributeValue::iterator AVI;
+
+ for (ALI it = m_module->getEntryAttributes()["Footnote"].begin();
+ it != m_module->getEntryAttributes()["Footnote"].end();
+ ++it)
+ {
+ lucene_utf8towcs(wcharBuffer, it->second["body"], BT_MAX_LUCENE_FIELD_LENGTH);
+ doc->add(*(new lucene::document::Field(static_cast<const TCHAR *>(_T("footnote")),
+ static_cast<const TCHAR *>(wcharBuffer),
+ lucene::document::Field::STORE_NO
+ | lucene::document::Field::INDEX_TOKENIZED)));
+ }
// Headings
- for (attValueI = m_module->getEntryAttributes()["Heading"]["Preverse"].begin();
- attValueI != m_module->getEntryAttributes()["Heading"]["Preverse"].end();
- attValueI++) {
- lucene_utf8towcs(wcharBuffer, attValueI->second, BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("heading"), wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("heading"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- } // for attValueI
+ for (AVI it = m_module->getEntryAttributes()["Heading"]["Preverse"].begin();
+ it != m_module->getEntryAttributes()["Heading"]["Preverse"].end();
+ ++it)
+ {
+ lucene_utf8towcs(wcharBuffer, it->second, BT_MAX_LUCENE_FIELD_LENGTH);
+ doc->add(*(new lucene::document::Field(static_cast<const TCHAR *>(_T("heading")),
+ static_cast<const TCHAR *>(wcharBuffer),
+ lucene::document::Field::STORE_NO
+ | lucene::document::Field::INDEX_TOKENIZED)));
+ }
// Strongs/Morphs
- for (attListI = m_module->getEntryAttributes()["Word"].begin();
- attListI != m_module->getEntryAttributes()["Word"].end();
- attListI++) {
- // for each attribute
- if (attListI->second["LemmaClass"] == "strong") {
- lucene_utf8towcs(wcharBuffer, attListI->second["Lemma"], BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("strong"), wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("strong"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
- //qWarning("Adding strong %s", attListI->second["Lemma"].c_str());
+ for (ALI it = m_module->getEntryAttributes()["Word"].begin();
+ it != m_module->getEntryAttributes()["Word"].end();
+ ++it)
+ {
+ if (it->second["LemmaClass"] == "strong") {
+ lucene_utf8towcs(wcharBuffer, it->second["Lemma"], BT_MAX_LUCENE_FIELD_LENGTH);
+ doc->add(*(new lucene::document::Field(static_cast<const TCHAR *>(_T("strong")),
+ static_cast<const TCHAR *>(wcharBuffer),
+ lucene::document::Field::STORE_NO
+ | lucene::document::Field::INDEX_TOKENIZED)));
}
- if (attListI->second.find("Morph") != attListI->second.end()) {
- lucene_utf8towcs(wcharBuffer, attListI->second["Morph"], BT_MAX_LUCENE_FIELD_LENGTH);
- //doc->add(*lucene::document::Field::UnStored((const TCHAR*)_T("morph"), wcharBuffer));
- doc->add(*(new lucene::document::Field((const TCHAR*)_T("morph"), (const TCHAR*)wcharBuffer, lucene::document::Field::STORE_NO | lucene::document::Field::INDEX_TOKENIZED)));
+ if (it->second.find("Morph") != it->second.end()) {
+ lucene_utf8towcs(wcharBuffer, it->second["Morph"], BT_MAX_LUCENE_FIELD_LENGTH);
+ doc->add(*(new lucene::document::Field(static_cast<const TCHAR *>(_T("morph")),
+ static_cast<const TCHAR *>(wcharBuffer),
+ lucene::document::Field::STORE_NO
+ | lucene::document::Field::INDEX_TOKENIZED)));
}
- } // for attListI
+ }
writer->addDocument(doc.data());
//Index() is not implemented properly for lexicons, so we use a
//workaround.
- if (type() == CSwordModuleInfo::Lexicon) {
+ if (m_type == CSwordModuleInfo::Lexicon) {
verseIndex++;
- }
- else {
- verseIndex = m_module->Index();
+ } else {
+ verseIndex = m_module->getIndex();
}
if (verseIndex % 200 == 0) {
int indexingProgressValue;
- if (verseSpan == 0) { //prevent division by zero
- //m_indexingProgress.setValue( QVariant(0) );
+ if (verseSpan == 0) { // Prevent division by zero
indexingProgressValue = 0;
- }
- else {
- //m_indexingProgress.setValue( QVariant((int)((100*(verseIndex-verseLowIndex))/(verseHighIndex-verseLowIndex))) );
+ } else {
indexingProgressValue = (int)((100 * (verseIndex - verseLowIndex)) / (verseSpan));
}
- //m_indexingProgress.activate();
emit indexingProgress(indexingProgressValue);
}
m_module->increment();
} // while (!(m_module->Error()) && !m_cancelIndexing)
- if (!m_cancelIndexing) {
+ if (!m_cancelIndexing)
writer->optimize();
- }
writer->close();
if (m_cancelIndexing) {
deleteIndex();
m_cancelIndexing = false;
- }
- else {
- QSettings module_config(getModuleBaseIndexLocation() + QString("/bibletime-index.conf"), QSettings::IniFormat);
- if (hasVersion()) module_config.setValue("module-version", config(CSwordModuleInfo::ModuleVersion) );
+ } else {
+ QSettings module_config(getModuleBaseIndexLocation()
+ + QString("/bibletime-index.conf"),
+ QSettings::IniFormat);
+ if (m_cachedHasVersion)
+ module_config.setValue("module-version",
+ config(CSwordModuleInfo::ModuleVersion));
module_config.setValue("index-version", INDEX_VERSION);
emit hasIndexChanged(true);
}
- }
- catch (CLuceneError &e) {
+ } catch (CLuceneError & e) {
qWarning() << "CLucene exception occurred while indexing:" << e.what();
- util::showWarning(0, QCoreApplication::tr("Indexing aborted"), QCoreApplication::tr("An internal error occurred while building the index: %1").arg(e.what()));
+ message::showWarning(0,
+ QCoreApplication::tr("Indexing aborted"),
+ QCoreApplication::tr("An internal error occurred "
+ "while building the index: %1")
+ .arg(e.what()));
deleteIndex();
m_cancelIndexing = false;
return false;
- }
- catch (...) {
+ } catch (...) {
qWarning("CLucene exception occurred while indexing");
- util::showWarning(0, QCoreApplication::tr("Indexing aborted"), QCoreApplication::tr("An internal error occurred while building the index."));
+ message::showWarning(0,
+ QCoreApplication::tr("Indexing aborted"),
+ QCoreApplication::tr("An internal error occurred "
+ "while building the index."));
deleteIndex();
m_cancelIndexing = false;
return false;
}
-
return true;
}
void CSwordModuleInfo::deleteIndex() {
- deleteIndexForModule(name());
+ deleteIndexForModule(m_cachedName);
emit hasIndexChanged(false);
}
-void CSwordModuleInfo::deleteIndexForModule(const QString &name) {
- util::directory::removeRecursive( getGlobalBaseIndexLocation() + "/" + name );
+void CSwordModuleInfo::deleteIndexForModule(const QString & name) {
+ util::directory::removeRecursive(getGlobalBaseIndexLocation() + "/" + name);
}
unsigned long CSwordModuleInfo::indexSize() const {
namespace DU = util::directory;
- return DU::getDirSizeRecursive( getModuleBaseIndexLocation() );
+ return DU::getDirSizeRecursive(getModuleBaseIndexLocation());
}
-
-int CSwordModuleInfo::searchIndexed(const QString &searchedText,
- const sword::ListKey &scope,
- sword::ListKey &results) const
+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];
+ QScopedPointer<char, QScopedPointerArrayDeleter<char> >
+ sPutfBuffer(new char[BT_MAX_LUCENE_FIELD_LENGTH + 1]);
+ QScopedPointer<wchar_t, QScopedPointerArrayDeleter<wchar_t> >
+ sPwcharBuffer(new wchar_t[BT_MAX_LUCENE_FIELD_LENGTH + 1]);
+ char * const utfBuffer = sPutfBuffer.data();
+ Q_ASSERT(utfBuffer);
+ wchar_t * const wcharBuffer = sPwcharBuffer.data();
+ Q_ASSERT(wcharBuffer);
// work around Swords thread insafety for Bibles and Commentaries
- 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);
+ QSharedPointer<CSwordKey> key(CSwordKey::createInstance(this));
+ {
+ const sword::SWKey * const s = dynamic_cast<sword::SWKey *>(key.data());
+ if (s)
+ m_module->setKey(*s);
}
+ QList<sword::VerseKey *> list;
results.clear();
try {
// do not use any stop words
- const TCHAR* stop_words[] = { NULL };
- lucene::analysis::standard::StandardAnalyzer analyzer( stop_words );
+ static const TCHAR * stop_words[1u] = { NULL };
+ lucene::analysis::standard::StandardAnalyzer analyzer(stop_words);
lucene::search::IndexSearcher searcher(getModuleStandardIndexLocation().toLatin1().constData());
lucene_utf8towcs(wcharBuffer, searchedText.toUtf8().constData(), BT_MAX_LUCENE_FIELD_LENGTH);
- QSharedPointer<lucene::search::Query> q( lucene::queryParser::QueryParser::parse((const TCHAR*)wcharBuffer, (const TCHAR*)_T("content"), &analyzer) );
-
-#ifdef CLUCENE2
- QSharedPointer<lucene::search::Hits> h( searcher.search(q.data(), lucene::search::Sort::INDEXORDER()) );
-#else
- QSharedPointer<lucene::search::Hits> h( searcher.search(q.data(), lucene::search::Sort::INDEXORDER) );
-#endif
+ QSharedPointer<lucene::search::Query> q(lucene::queryParser::QueryParser::parse(static_cast<const TCHAR *>(wcharBuffer),
+ static_cast<const TCHAR *>(_T("content")),
+ &analyzer));
- /// \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);
+ QSharedPointer<lucene::search::Hits> h(searcher.search(q.data(),
+ #ifdef CLUCENE2
+ lucene::search::Sort::INDEXORDER()));
+ #else
+ lucene::search::Sort::INDEXORDER));
+ #endif
- lucene::document::Document* doc = 0;
- QSharedPointer<sword::SWKey> swKey( module()->CreateKey() );
+ const bool useScope = (scope.getCount() > 0);
+ lucene::document::Document * doc = 0;
+ QSharedPointer<sword::SWKey> swKey(m_module->createKey());
#ifdef CLUCENE2
for (unsigned int i = 0; i < h->length(); ++i) {
#else
- for (int i = 0; i < h->length(); ++i) {
+ for (int i = 0; i < h->length(); ++i) {
#endif
doc = &h->doc(i);
- lucene_wcstoutf8(utfBuffer, (const wchar_t*)doc->get((const TCHAR*)_T("key")), BT_MAX_LUCENE_FIELD_LENGTH);
+ lucene_wcstoutf8(utfBuffer,
+ static_cast<const wchar_t *>(doc->get(static_cast<const TCHAR *>(_T("key")))),
+ BT_MAX_LUCENE_FIELD_LENGTH);
swKey->setText(utfBuffer);
- // limit results based on scope
- //if (searchOptions & CSwordModuleSearch::useScope && scope.Count() > 0){
+ // Limit results based on scope:
if (useScope) {
- /// \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) {
+ for (int j = 0; j < scope.getCount(); j++) {
+ Q_ASSERT(dynamic_cast<const sword::VerseKey *>(scope.getElement(j)));
+ const sword::VerseKey * const vkey = static_cast<const sword::VerseKey *>(scope.getElement(j));
+ if (vkey->getLowerBound().compare(*swKey) <= 0
+ && vkey->getUpperBound().compare(*swKey) >= 0)
+ {
results.add(*swKey);
}
}
- }
- else { // no scope, give me all buffers
- results.add(*swKey);
+ } else {
+ results.add(*swKey); // No scope, give me all buffers
}
}
- }
- catch (...) {
+ } catch (...) {
qWarning("CLucene exception occurred");
- util::showWarning(0, QCoreApplication::tr("Search aborted"), QCoreApplication::tr("An internal error occurred while executing your search."));
+ message::showWarning(0,
+ QCoreApplication::tr("Search aborted"),
+ QCoreApplication::tr("An internal error occurred "
+ "while executing your search."));
return 0;
}
qDeleteAll(list);
list.clear();
- return results.Count();
+ return results.getCount();
}
sword::SWVersion CSwordModuleInfo::minimumSwordVersion() const {
- return sword::SWVersion(config(CSwordModuleInfo::MinimumSwordVersion).toUtf8().constData());
+ return sword::SWVersion(config(CSwordModuleInfo::MinimumSwordVersion)
+ .toUtf8().constData());
}
QString CSwordModuleInfo::config(const CSwordModuleInfo::ConfigEntry entry) const {
@@ -527,37 +543,32 @@ QString CSwordModuleInfo::config(const CSwordModuleInfo::ConfigEntry entry) cons
return getFormattedConfigEntry("About");
case CipherKey: {
- if (CBTConfig::getModuleEncryptionKey(name()).isNull()) { //fall back!
- return QString(m_module->getConfigEntry("CipherKey"));
- }
- else {
- return CBTConfig::getModuleEncryptionKey(name());
+ if (btConfig().getModuleEncryptionKey(m_cachedName).isNull()) {
+ return QString(m_module->getConfigEntry("CipherKey")); // Fallback
+ } else {
+ return btConfig().getModuleEncryptionKey(m_cachedName);
}
}
case AbsoluteDataPath: {
- QString path( getSimpleConfigEntry("AbsoluteDataPath") );
- path.replace(QRegExp("/./"), "/"); // make /abs/path/./modules/ looking better
- //make sure we have a trailing slash!
-
- if (path.right(1) != "/") {
+ QString path(getSimpleConfigEntry("AbsoluteDataPath"));
+ if (!path.endsWith('/')) /// \todo is this needed?
path.append('/');
- }
return path;
}
- case DataPath: { //make sure we remove the dataFile part if it's a Lexicon
+ case DataPath: {
QString path(getSimpleConfigEntry("DataPath"));
- if ((type() == CSwordModuleInfo::GenericBook) || (type() == CSwordModuleInfo::Lexicon)) {
- int pos = path.lastIndexOf("/"); //last slash in the string
-
- if (pos != -1) {
- path = path.left(pos + 1); //include the slash
- }
+ // Make sure we remove the dataFile part if it's a Lexicon
+ if (m_type == CSwordModuleInfo::GenericBook
+ || m_type == CSwordModuleInfo::Lexicon)
+ {
+ int pos = path.lastIndexOf("/"); // Last slash in the string
+ if (pos != -1)
+ path = path.left(pos + 1); // Include the slash
}
-
return path;
}
@@ -565,84 +576,76 @@ QString CSwordModuleInfo::config(const CSwordModuleInfo::ConfigEntry entry) cons
return getFormattedConfigEntry("Description");
case ModuleVersion: {
- QString version(getSimpleConfigEntry("Version"));
-
- if (version.isEmpty()) {
- version = "1.0";
- }
-
- return version;
+ const QString version(getSimpleConfigEntry("Version"));
+ return version.isEmpty() ? "1.0" : version;
}
case MinimumSwordVersion: {
const QString minimumVersion(getSimpleConfigEntry("MinimumVersion"));
- return !minimumVersion.isEmpty() ? minimumVersion : QString("0.0");
+ return minimumVersion.isEmpty() ? "0.0" : minimumVersion;
}
case TextDir: {
const QString dir(getSimpleConfigEntry("Direction"));
- return !dir.isEmpty() ? dir : QString("LtoR");
+ return dir.isEmpty() ? QString("LtoR") : dir;
}
case DisplayLevel: {
const QString level(getSimpleConfigEntry("DisplayLevel"));
- return !level.isEmpty() ? level : QString("1");
+ return level.isEmpty() ? QString("1") : level;
}
case GlossaryFrom: {
- if (category() != Glossary) {
+ if (m_cachedCategory != Glossary)
return QString::null;
- };
const QString lang(getSimpleConfigEntry("GlossaryFrom"));
-
- return !lang.isEmpty() ? lang : QString::null;
+ return lang.isEmpty() ? QString::null : lang;
}
case GlossaryTo: {
- if (category() != Glossary) {
+ if (m_cachedCategory != Glossary) {
return QString::null;
};
const QString lang(getSimpleConfigEntry("GlossaryTo"));
-
- return !lang.isEmpty() ? lang : QString::null;
+ return lang.isEmpty() ? QString::null : lang;
}
case Markup: {
const QString markup(getSimpleConfigEntry("SourceType"));
- return !markup.isEmpty() ? markup : QString("Unknown");
+ return markup.isEmpty() ? QString("Unknown") : markup;
}
case DistributionLicense:
- return getSimpleConfigEntry("DistributionLicense");
+ return getFormattedConfigEntry("DistributionLicense");
case DistributionSource:
- return getSimpleConfigEntry("DistributionSource");
+ return getFormattedConfigEntry("DistributionSource");
case DistributionNotes:
- return getSimpleConfigEntry("DistributionNotes");
+ return getFormattedConfigEntry("DistributionNotes");
case TextSource:
- return getSimpleConfigEntry("TextSource");
+ return getFormattedConfigEntry("TextSource");
case CopyrightNotes:
- return getSimpleConfigEntry("CopyrightNotes");
+ return getFormattedConfigEntry("CopyrightNotes");
case CopyrightHolder:
- return getSimpleConfigEntry("CopyrightHolder");
+ return getFormattedConfigEntry("CopyrightHolder");
case CopyrightDate:
- return getSimpleConfigEntry("CopyrightDate");
+ return getFormattedConfigEntry("CopyrightDate");
case CopyrightContactName:
- return getSimpleConfigEntry("CopyrightContactName");
+ return getFormattedConfigEntry("CopyrightContactName");
case CopyrightContactAddress:
- return getSimpleConfigEntry("CopyrightContactAddress");
+ return getFormattedConfigEntry("CopyrightContactAddress");
case CopyrightContactEmail:
- return getSimpleConfigEntry("CopyrightContactEmail");
+ return getFormattedConfigEntry("CopyrightContactEmail");
default:
return QString::null;
@@ -651,75 +654,54 @@ QString CSwordModuleInfo::config(const CSwordModuleInfo::ConfigEntry entry) cons
bool CSwordModuleInfo::has(const CSwordModuleInfo::Feature feature) const {
switch (feature) {
-
- // case StrongsNumbers:
- // return m_module->getConfig().has("Feature", "StrongsNumber");
-
- case GreekDef:
- return m_module->getConfig().has("Feature", "GreekDef");
-
- case HebrewDef:
- return m_module->getConfig().has("Feature", "HebrewDef");
-
- case GreekParse:
- return m_module->getConfig().has("Feature", "GreekParse");
-
- case HebrewParse:
- return m_module->getConfig().has("Feature", "HebrewParse");
+ case GreekDef: return m_module->getConfig().has("Feature", "GreekDef");
+ case HebrewDef: return m_module->getConfig().has("Feature", "HebrewDef");
+ case GreekParse: return m_module->getConfig().has("Feature", "GreekParse");
+ case HebrewParse: return m_module->getConfig().has("Feature", "HebrewParse");
}
-
return false;
}
bool CSwordModuleInfo::has(const CSwordModuleInfo::FilterTypes option) const {
- //BAD workaround to see if the filter is GBF, OSIS or ThML!
- const QString name = backend()->configOptionName(option);
-
- if (m_module->getConfig().has("GlobalOptionFilter", QString("OSIS").append(name).toUtf8().constData())) {
- return true;
- }
-
- if (m_module->getConfig().has("GlobalOptionFilter", QString("GBF").append(name).toUtf8().constData())) {
- return true;
- }
-
- if (m_module->getConfig().has("GlobalOptionFilter", QString("ThML").append(name).toUtf8().constData())) {
- return true;
- }
-
- if (m_module->getConfig().has("GlobalOptionFilter", QString("UTF8").append(name).toUtf8().constData())) {
- return true;
- }
-
- if (m_module->getConfig().has("GlobalOptionFilter", name.toUtf8().constData())) {
- return true;
- }
-
- return false;
+ /// \todo This is a BAD workaround to see if the filter is GBF, OSIS or ThML!
+ const QString name = m_backend.configOptionName(option);
+ return m_module->getConfig().has("GlobalOptionFilter",
+ QString("OSIS").append(name).toUtf8().constData())
+ || m_module->getConfig().has("GlobalOptionFilter",
+ QString("GBF").append(name).toUtf8().constData())
+ || m_module->getConfig().has("GlobalOptionFilter",
+ QString("ThML").append(name).toUtf8().constData())
+ || m_module->getConfig().has("GlobalOptionFilter",
+ QString("UTF8").append(name).toUtf8().constData())
+ || m_module->getConfig().has("GlobalOptionFilter",
+ name.toUtf8().constData());
}
CSwordModuleInfo::TextDirection CSwordModuleInfo::textDirection() const {
- if (config(TextDir) == "RtoL")
- return CSwordModuleInfo::RightToLeft;
-
- return CSwordModuleInfo::LeftToRight;
+ return (config(TextDir) == "RtoL")
+ ? CSwordModuleInfo::RightToLeft
+ : CSwordModuleInfo::LeftToRight;
}
-void CSwordModuleInfo::write(CSwordKey *key, const QString &newText) {
- module()->setKey(key->key().toUtf8().constData());
+void CSwordModuleInfo::write(CSwordKey * key, const QString & newText) {
+ m_module->setKey(key->key().toUtf8().constData());
- //don't store a pointer to the const char* value somewhere because QCString doesn't keep the value of it
- module()->setEntry(isUnicode() ? newText.toUtf8().constData() : newText.toLocal8Bit().constData());
+ /* Don't store a pointer to the const char* value somewhere because QCString
+ doesn't keep the value of it. */
+ m_module->setEntry(isUnicode()
+ ? newText.toUtf8().constData()
+ : newText.toLocal8Bit().constData());
}
bool CSwordModuleInfo::deleteEntry(CSwordKey * const key) {
- module()->setKey(isUnicode() ? key->key().toUtf8().constData() : key->key().toLocal8Bit().constData());
+ m_module->setKey(isUnicode()
+ ? key->key().toUtf8().constData()
+ : key->key().toLocal8Bit().constData());
- if (module()) {
- module()->deleteEntry();
+ if (m_module) {
+ m_module->deleteEntry();
return true;
}
-
return false;
}
@@ -727,7 +709,7 @@ void CSwordModuleInfo::initCachedCategory() {
/// \todo Maybe we can use raw string comparsion instead of QString?
const QString cat(m_module->getConfigEntry("Category"));
- /// \warning cat has to be checked before type() !!!
+ /// \warning cat has to be checked before m_type !!!
if (cat == "Cults / Unorthodox / Questionable Material") {
m_cachedCategory = Cult;
} else if (cat == "Daily Devotional"
@@ -741,7 +723,7 @@ void CSwordModuleInfo::initCachedCategory() {
} else if (cat == "Images" || cat == "Maps") {
m_cachedCategory = Images;
} else {
- switch (type()) {
+ switch (m_type) {
case Bible: m_cachedCategory = Bibles; break;
case Commentary: m_cachedCategory = Commentaries; break;
case Lexicon: m_cachedCategory = Lexicons; break;
@@ -753,15 +735,15 @@ void CSwordModuleInfo::initCachedCategory() {
}
void CSwordModuleInfo::initCachedLanguage() {
- CLanguageMgr *lm = CLanguageMgr::instance();
- if (category() == Glossary) {
+ const CLanguageMgr & lm = *CLanguageMgr::instance();
+ if (m_cachedCategory == Glossary) {
/*
Special handling for glossaries, we use the "from language" as
language for the module.
*/
- m_cachedLanguage = lm->languageForAbbrev(config(GlossaryFrom));
+ m_cachedLanguage = lm.languageForAbbrev(config(GlossaryFrom));
} else {
- m_cachedLanguage = lm->languageForAbbrev(m_module->Lang());
+ m_cachedLanguage = lm.languageForAbbrev(m_module->getLanguage());
}
}
@@ -770,74 +752,87 @@ Rendering::CEntryDisplay * CSwordModuleInfo::getDisplay() const {
}
QString CSwordModuleInfo::aboutText() const {
+ using util::htmlEscape;
+
+ static const QString row("<tr><td><b>%1</b></td><td>%2</td></tr>");
+
QString text;
text += "<table>";
- text += QString("<tr><td><b>%1</b></td><td>%2</td><tr>")
+ text += row
.arg(tr("Version"))
- .arg(hasVersion() ? config(CSwordModuleInfo::ModuleVersion) : tr("unknown"));
+ .arg(m_cachedHasVersion
+ ? htmlEscape(config(CSwordModuleInfo::ModuleVersion))
+ : tr("unknown"));
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(tr("Markup"))
- .arg(!QString(m_module->getConfigEntry("SourceType")).isEmpty() ? QString(m_module->
- getConfigEntry("SourceType")) : tr("unknown"));
+ {
+ const QString sourceType(m_module->getConfigEntry("SourceType"));
+ text += row
+ .arg(tr("Markup"))
+ .arg(!sourceType.isEmpty()
+ ? htmlEscape(sourceType)
+ : tr("unknown"));
+ }
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ text += row
.arg(tr("Location"))
- .arg(config(CSwordModuleInfo::AbsoluteDataPath));
+ .arg(htmlEscape(config(CSwordModuleInfo::AbsoluteDataPath)));
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ text += row
.arg(tr("Language"))
- .arg(language()->translatedName());
+ .arg(htmlEscape(m_cachedLanguage->translatedName()));
if (m_module->getConfigEntry("Category"))
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ text += row
.arg(tr("Category"))
- .arg(m_module->getConfigEntry("Category"));
+ .arg(htmlEscape(m_module->getConfigEntry("Category")));
if (m_module->getConfigEntry("LCSH"))
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ text += row
.arg(tr("LCSH"))
- .arg(m_module->getConfigEntry("LCSH"));
+ .arg(htmlEscape(m_module->getConfigEntry("LCSH")));
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ text += row
.arg(tr("Writable"))
.arg(isWritable() ? tr("yes") : tr("no"));
if (isEncrypted())
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ text += row
.arg(tr("Unlock key"))
- .arg(config(CSwordModuleInfo::CipherKey));
+ .arg(htmlEscape(config(CSwordModuleInfo::CipherKey)));
QString options;
unsigned int opts;
- for (opts = CSwordModuleInfo::filterTypesMIN; opts <= CSwordModuleInfo::filterTypesMAX; ++opts) {
+ for (opts = CSwordModuleInfo::filterTypesMIN;
+ opts <= CSwordModuleInfo::filterTypesMAX;
+ ++opts)
+ {
if (has(static_cast < CSwordModuleInfo::FilterTypes > (opts))) {
- if (!options.isEmpty()) {
+ if (!options.isEmpty())
options += QString::fromLatin1(", ");
- }
-
- options += CSwordBackend::translatedOptionName(static_cast < CSwordModuleInfo::FilterTypes > (opts));
+ typedef CSwordModuleInfo::FilterTypes FT;
+ options += CSwordBackend::translatedOptionName(static_cast<FT>(opts));
}
}
- if (!options.isEmpty()) {
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
+ if (!options.isEmpty())
+ text += row
.arg(tr("Features"))
- .arg(options);
- }
+ .arg(htmlEscape(options));
text += "</table><hr>";
- if (category() == Cult) //clearly say the module contains cult/questionable materials
+ // Clearly say the module contains cult/questionable materials
+ if (m_cachedCategory == Cult)
text += QString("<br/><b>%1</b><br/><br/>")
- .arg(tr("Take care, this work contains cult / questionable material!"));
+ .arg(tr("Take care, this work contains cult / questionable "
+ "material!"));
text += QString("<b>%1:</b><br/>%2</font>")
.arg(tr("About"))
- .arg(config(AboutInformation));
+ .arg(config(AboutInformation)); // May contain HTML, don't escape
typedef QList<CSwordModuleInfo::ConfigEntry> ListConfigEntry;
@@ -871,61 +866,47 @@ QString CSwordModuleInfo::aboutText() const {
text += ("<hr><table>");
- for (ListConfigEntry::iterator it(entries.begin()); it != entries.end(); ++it) {
- QString t( config(*it) );
-
- if (!t.isEmpty()) {
- text += QString("<tr><td><b>%1</b></td><td>%2</td></tr>")
- .arg(entryMap[*it])
- .arg(config(*it));
- }
-
- }
+ for (ListConfigEntry::iterator it(entries.begin()); it != entries.end(); ++it)
+ if (!config(*it).isEmpty())
+ text += row
+ .arg(htmlEscape(entryMap[*it]))
+ .arg(htmlEscape(config(*it)));
text += "</table></font>";
return text;
}
-QIcon CSwordModuleInfo::moduleIcon(const CSwordModuleInfo *module) {
- const QString &filename = moduleIconFilename(module);
- if (filename.isEmpty()) return QIcon();
- return util::directory::getIcon(filename);
+QIcon CSwordModuleInfo::moduleIcon(const CSwordModuleInfo & module) {
+ const QString & filename = moduleIconFilename(module);
+ if (filename.isEmpty())
+ return QIcon();
+ return util::getIcon(filename);
}
-const QString &CSwordModuleInfo::moduleIconFilename(
- const CSwordModuleInfo *module)
-{
- const CSwordModuleInfo::Category cat(module->category());
+const QString & CSwordModuleInfo::moduleIconFilename(const CSwordModuleInfo & module) {
+ const CSwordModuleInfo::Category cat(module.m_cachedCategory);
switch (cat) {
case CSwordModuleInfo::Bibles:
- if (module->isLocked()) {
- return CResMgr::modules::bible::icon_locked;
- }
- else {
- return CResMgr::modules::bible::icon_unlocked;
- }
+ return module.isLocked()
+ ? CResMgr::modules::bible::icon_locked
+ : CResMgr::modules::bible::icon_unlocked;
+
case CSwordModuleInfo::Commentaries:
- if (module->isLocked()) {
- return CResMgr::modules::commentary::icon_locked;
- }
- else {
- return CResMgr::modules::commentary::icon_unlocked;
- }
+ return module.isLocked()
+ ? CResMgr::modules::commentary::icon_locked
+ : CResMgr::modules::commentary::icon_unlocked;
+
case CSwordModuleInfo::Lexicons:
- if (module->isLocked()) {
- return CResMgr::modules::lexicon::icon_locked;
- }
- else {
- return CResMgr::modules::lexicon::icon_unlocked;
- }
+ return module.isLocked()
+ ? CResMgr::modules::lexicon::icon_locked
+ : CResMgr::modules::lexicon::icon_unlocked;
+
case CSwordModuleInfo::Books:
- if (module->isLocked()) {
- return CResMgr::modules::book::icon_locked;
- }
- else {
- return CResMgr::modules::book::icon_unlocked;
- }
+ return module.isLocked()
+ ? CResMgr::modules::book::icon_locked
+ : CResMgr::modules::book::icon_unlocked;
+
case CSwordModuleInfo::Cult:
case CSwordModuleInfo::Images:
case CSwordModuleInfo::DailyDevotional:
@@ -936,16 +917,14 @@ const QString &CSwordModuleInfo::moduleIconFilename(
}
}
-QIcon CSwordModuleInfo::categoryIcon(const CSwordModuleInfo::Category &category)
-{
- QString filename = categoryIconFilename(category);
- if (filename.isEmpty()) return QIcon();
- return util::directory::getIcon(filename);
+QIcon CSwordModuleInfo::categoryIcon(const CSwordModuleInfo::Category & category) {
+ const QString filename(categoryIconFilename(category));
+ if (filename.isEmpty())
+ return QIcon();
+ return util::getIcon(filename);
}
-const QString &CSwordModuleInfo::categoryIconFilename(
- const CSwordModuleInfo::Category &category)
-{
+const QString & CSwordModuleInfo::categoryIconFilename(const CSwordModuleInfo::Category & category) {
static const QString noFilename;
switch (category) {
@@ -971,8 +950,7 @@ const QString &CSwordModuleInfo::categoryIconFilename(
}
}
-QString CSwordModuleInfo::categoryName(
- const CSwordModuleInfo::Category &category) {
+QString CSwordModuleInfo::categoryName(const CSwordModuleInfo::Category & category) {
switch (category) {
case CSwordModuleInfo::Bibles:
return tr("Bibles");
@@ -995,7 +973,7 @@ QString CSwordModuleInfo::categoryName(
}
}
-QString CSwordModuleInfo::getSimpleConfigEntry(const QString& name) const {
+QString CSwordModuleInfo::getSimpleConfigEntry(const QString & name) const {
QString ret = isUnicode()
? QString::fromUtf8(m_module->getConfigEntry(name.toUtf8().constData()))
: QString::fromLatin1(m_module->getConfigEntry(name.toUtf8().constData()));
@@ -1003,32 +981,38 @@ QString CSwordModuleInfo::getSimpleConfigEntry(const QString& name) const {
return ret.isEmpty() ? QString::null : ret;
}
-QString CSwordModuleInfo::getFormattedConfigEntry(const QString& name) const {
- sword::SWBuf RTF_Buffer(m_module->getConfigEntry(name.toUtf8().constData()));
- sword::RTFHTML RTF_Filter;
- RTF_Filter.processText(RTF_Buffer, 0, 0);
- QString ret = isUnicode()
- ? QString::fromUtf8(RTF_Buffer.c_str())
- : QString::fromLatin1(RTF_Buffer.c_str());
-
- return ret.isEmpty() ? QString::null : ret;
+/// \note See http://www.crosswire.org/wiki/DevTools:conf_Files#Localization
+QString CSwordModuleInfo::getFormattedConfigEntry(const QString & name) const {
+ const QStringList localeNames(QLocale(CSwordBackend::instance()->booknameLanguage()).uiLanguages());
+ for (int i = localeNames.size() - 1; i >= -1; --i) {
+ sword::SWBuf RTF_Buffer =
+ m_module->getConfigEntry(
+ QString(i >= 0 ? name + "_" + localeNames[i] : name)
+ .toUtf8().constData());
+ if (RTF_Buffer.length() > 0) {
+ sword::RTFHTML RTF_Filter;
+ RTF_Filter.processText(RTF_Buffer, 0, 0);
+ return isUnicode()
+ ? QString::fromUtf8(RTF_Buffer.c_str())
+ : QString::fromLatin1(RTF_Buffer.c_str());
+ }
+ }
+ return QString::null;
}
bool CSwordModuleInfo::setHidden(bool hide) {
- if (m_hidden == hide) return false;
+ if (m_hidden == hide)
+ return false;
m_hidden = hide;
- QStringList hiddenModules(CBTConfig::get(CBTConfig::hiddenModules));
+ QStringList hiddenModules(btConfig().value<QStringList>("state/hiddenModules"));
+ Q_ASSERT(hiddenModules.contains(m_cachedName) != hide);
if (hide) {
- Q_ASSERT(!hiddenModules.contains(name()));
- hiddenModules.append(name());
- }
- else {
- Q_ASSERT(hiddenModules.contains(name()));
- hiddenModules.removeOne(name());
+ hiddenModules.append(m_cachedName);
+ } else {
+ hiddenModules.removeOne(m_cachedName);
}
- CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
+ btConfig().setValue("state/hiddenModules", hiddenModules);
emit hiddenChanged(hide);
return true;
}
-
diff --git a/src/backend/drivers/cswordmoduleinfo.h b/src/backend/drivers/cswordmoduleinfo.h
index 3c59f9d..c1b6c88 100644
--- a/src/backend/drivers/cswordmoduleinfo.h
+++ b/src/backend/drivers/cswordmoduleinfo.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,6 +14,7 @@
#include "backend/managers/clanguagemgr.h"
+#include <QIcon>
#include <QList>
#include <QMetaType>
#include <QString>
@@ -47,403 +50,418 @@ class CEntryDisplay;
*/
class CSwordModuleInfo: public QObject {
- Q_OBJECT
-
- public:
- /**
- * These are the options which could be supported by modules and by this backend.
- * It's used in @ref CSwordBackend::setOption.
- */
- enum FilterTypes {
- footnotes, /**< Footnotes embedded in the module's text */
- strongNumbers, /**< strong numbers, usually in the text for the info display */
- headings, /**< additional section headings */
- morphTags, /**< morphology */
- lemmas, /**< lemma tags */
- hebrewPoints,/**< Hebrew vowel points */
- hebrewCantillation, /**<Hewbrew caantillation points */
- greekAccents, /**< Greek accents may be switched on and off */
- scriptureReferences, /**< scripture references may be switched on and off, just makes sense in Bibles */
- redLetterWords, /**< Jesus words in red, color is template specific */
- textualVariants, /**< variants */
- morphSegmentation, /**< morph word segmentation, supported by OSIS */
- filterTypesMIN = footnotes, /**< first entry of this enum */
- filterTypesMAX = morphSegmentation /**< last item in this enum */
- // transliteration /* The following are handled in a special way */
- };
- /** The text direction of a module */
- enum TextDirection { /* The text direction of the modules's text */
- LeftToRight, /**< Left to right text direction, the default setting */
- RightToLeft /**< Right to left text directin, e.g. for hebrew */
- };
- /** The module type.
- */
- enum ModuleType {
- Bible, /**< Bible module */
- Commentary, /**< Commentary module */
- Lexicon, /**< Lexicon module */
- GenericBook, /**< Generic book module */
- Unknown /**< Fall back type for unknown modules */
- };
- /**
- * This enum is used to give
- * back an error code after unlocking the module
- * BibleTime stores the unlock key not in the module's config file but in BibleTime's
- * configuration file.
- */
- enum UnlockErrorCode {
- noError, /**< No error occured, everything worked ok. The key was written to the BibleTime config */
- wrongUnlockKey, /**< The wrong key was used. Module is not unlocked */
- notLocked, /**< The module was not locked so it can't be unlocked */
- noPermission /**< The key was not written to config because we have no permissions */
- };
- enum ConfigEntry {
- AboutInformation, /**< The about information of a module which is stored in the config file*/
- AbsoluteDataPath, /**< The absolute data path stored in the config object */
- CipherKey, /**< The cipher key which was used to unlock the module. Not necessarily set.*/
- DataPath, /**< The relative path. See AbsoluteDataPath*/
- Description, /**< The module description stored in the config file */
- ModuleVersion, /**< The module's version.*/
- MinimumSwordVersion, /**< The required Sword Version of this module. Otherwise some things may not work (compression etc.).*/
- TextDir, /**< The text direction */
- DisplayLevel, /**< Mostly used for books. Gives the level which should contain the connected entries.*/
- GlossaryFrom, /**< lamguage from which the Glosaary tramslates */
- GlossaryTo, /**< lamguages to which the glossary maps to */
- DistributionLicense,
- DistributionSource,
- DistributionNotes,
- TextSource,
- CopyrightNotes,
- CopyrightHolder,
- CopyrightDate,
- CopyrightContactName,
- CopyrightContactAddress,
- CopyrightContactEmail,
- Markup /**< The markup of this module */
- };
- enum Feature {
- //StrongsNumbers, /**< Use for Bibles which have embedded strong numbers */ BT does not use this as a user option
- GreekDef,
- HebrewDef,
- GreekParse,
- HebrewParse,
- featureMin = GreekDef,
- featureMax = HebrewParse
- };
- enum Category {
- UnknownCategory = 0x0, /**< Unknown or unset category. */
- NoCategory = 0x0,
- Bibles = 0x01,
- Commentaries = 0x02,
- Books = 0x04,
- Lexicons = 0x08,
- Glossary = 0x10,
- DailyDevotional = 0x20,
- Images = 0x40,
- Cult = 0x80, /**< Cult / sect / questionable module. */
- AllCategories = 0xff
- };
- Q_DECLARE_FLAGS(Categories, Category)
-
- /**
- * Returns the base directory for search indices
- */
- static QString getGlobalBaseIndexLocation();
-
- /**
- Removes the search index for this module (rm -rf).
- */
- void deleteIndex();
-
- /**
- Removes search index for a module, even if the module is not there any more.
- \param[in] name name of the module.
- */
- static void deleteIndexForModule(const QString &name);
-
-
- /**
- * Returns the config entry which is pecified by the parameter.
- */
- QString config( const CSwordModuleInfo::ConfigEntry entry ) const;
-
- CSwordModuleInfo(sword::SWModule *module,
- CSwordBackend * const = 0,
- ModuleType type = Unknown);
-
- CSwordModuleInfo(const CSwordModuleInfo &copy);
-
- /**
- * Returns the module object so all objects can access the original Sword module.
- */
- inline sword::SWModule *module() const {
- return m_module;
- }
-
- /**
- * 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
+
+ Q_OBJECT
+
+public: /* Methods: */
+
+ /**
+ * These are the options which could be supported by modules and by this backend.
+ * It's used in @ref CSwordBackend::setOption.
+ */
+ enum FilterTypes {
+ footnotes, /**< Footnotes embedded in the module's text */
+ strongNumbers, /**< strong numbers, usually in the text for the info display */
+ headings, /**< additional section headings */
+ morphTags, /**< morphology */
+ lemmas, /**< lemma tags */
+ hebrewPoints,/**< Hebrew vowel points */
+ hebrewCantillation, /**<Hewbrew caantillation points */
+ greekAccents, /**< Greek accents may be switched on and off */
+ scriptureReferences, /**< scripture references may be switched on and off, just makes sense in Bibles */
+ redLetterWords, /**< Jesus words in red, color is template specific */
+ textualVariants, /**< variants */
+ morphSegmentation, /**< morph word segmentation, supported by OSIS */
+ filterTypesMIN = footnotes, /**< first entry of this enum */
+ filterTypesMAX = morphSegmentation /**< last item in this enum */
+ // transliteration /* The following are handled in a special way */
+ };
+
+ /** The text direction of a module */
+ enum TextDirection { /* The text direction of the modules's text */
+ LeftToRight, /**< Left to right text direction, the default setting */
+ RightToLeft /**< Right to left text directin, e.g. for hebrew */
+ };
+
+ /** The module type. */
+ enum ModuleType {
+ Bible, /**< Bible module */
+ Commentary, /**< Commentary module */
+ Lexicon, /**< Lexicon module */
+ GenericBook, /**< Generic book module */
+ Unknown /**< Fall back type for unknown modules */
+ };
+
+ /**
+ * This enum is used to give
+ * back an error code after unlocking the module
+ * BibleTime stores the unlock key not in the module's config file but in BibleTime's
+ * configuration file.
+ */
+ enum UnlockErrorCode {
+ noError, /**< No error occured, everything worked ok. The key was written to the BibleTime config */
+ wrongUnlockKey, /**< The wrong key was used. Module is not unlocked */
+ notLocked, /**< The module was not locked so it can't be unlocked */
+ noPermission /**< The key was not written to config because we have no permissions */
+ };
+
+ enum ConfigEntry {
+ AboutInformation, /**< The about information of a module which is stored in the config file*/
+ AbsoluteDataPath, /**< The absolute data path stored in the config object */
+ CipherKey, /**< The cipher key which was used to unlock the module. Not necessarily set.*/
+ DataPath, /**< The relative path. See AbsoluteDataPath*/
+ Description, /**< The module description stored in the config file */
+ ModuleVersion, /**< The module's version.*/
+ MinimumSwordVersion, /**< The required Sword Version of this module. Otherwise some things may not work (compression etc.).*/
+ TextDir, /**< The text direction */
+ DisplayLevel, /**< Mostly used for books. Gives the level which should contain the connected entries.*/
+ GlossaryFrom, /**< lamguage from which the Glosaary tramslates */
+ GlossaryTo, /**< lamguages to which the glossary maps to */
+ DistributionLicense,
+ DistributionSource,
+ DistributionNotes,
+ TextSource,
+ CopyrightNotes,
+ CopyrightHolder,
+ CopyrightDate,
+ CopyrightContactName,
+ CopyrightContactAddress,
+ CopyrightContactEmail,
+ Markup /**< The markup of this module */
+ };
+
+ enum Feature {
+ //StrongsNumbers, /**< Use for Bibles which have embedded strong numbers */ BT does not use this as a user option
+ GreekDef,
+ HebrewDef,
+ GreekParse,
+ HebrewParse,
+ featureMin = GreekDef,
+ featureMax = HebrewParse
+ };
+
+ enum Category {
+ UnknownCategory = 0x0, /**< Unknown or unset category. */
+ NoCategory = 0x0,
+ Bibles = 0x01,
+ Commentaries = 0x02,
+ Books = 0x04,
+ Lexicons = 0x08,
+ Glossary = 0x10,
+ DailyDevotional = 0x20,
+ Images = 0x40,
+ Cult = 0x80, /**< Cult / sect / questionable module. */
+ AllCategories = 0xff
+ };
+ Q_DECLARE_FLAGS(Categories, Category)
+
+ /**
+ * Returns the base directory for search indices
+ */
+ static QString getGlobalBaseIndexLocation();
+
+ /**
+ Removes the search index for this module (rm -rf).
+ */
+ void deleteIndex();
+
+ /**
+ Removes search index for a module, even if the module is not there any more.
+ \param[in] name name of the module.
+ */
+ static void deleteIndexForModule(const QString & name);
+
+ /**
+ * Returns the config entry which is pecified by the parameter.
+ */
+ QString config(const CSwordModuleInfo::ConfigEntry entry) const;
+
+ /**
+ * Returns the module object so all objects can access the original Sword module.
+ */
+ inline sword::SWModule * module() const {
+ return m_module;
+ }
+
+ /**
+ * 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 );
- /**
- * Returns the display object for this module. Normally every module should have a Display object.
- * Please don't use module()->Display() because this function does return the Sword display and does
- * render the text, too.
- * This function performs some casts to return the correct display. If it returns 0 there's no valid
- * display object.
- */
- Rendering::CEntryDisplay* getDisplay() const;
- /**
- * This function does return true if the data files of the module are encrypted by the module author
- * (the on who made the module) no matter if it's locked or not.
- * @return True if this module is encryped
- */
- bool isEncrypted() const;
- /**
- * This function returns true if this module is locked (encrypted + correct cipher key),
- * otherwise return false.
- * @return True if this module is locked, i.e. encrypted but without a key set
- */
- bool isLocked() const;
-
-
- /**
- 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 unlockKeyIsValid() const;
-
- /**
- \retval true if this module has a version number
- \retval false if it doesn't have a version number
- */
- inline bool hasVersion() const {
- return m_cachedHasVersion;
- }
-
- /**
- \returns true if the module's index has been built.
- */
- bool hasIndex() const;
-
- /**
- \returns the path to this module's index base dir
- */
- QString getModuleBaseIndexLocation() const;
-
- /**
- \returns the path to this module's standard index
- */
- QString getModuleStandardIndexLocation() const;
-
- /**
- Builds a search index for this module
- \returns Whether indexing this module was successful.
- */
- bool buildIndex();
-
- /**
- \returns index size
- */
- unsigned long indexSize() const;
-
- /**
- 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
- */
- int searchIndexed(const QString &searchedText,
- const sword::ListKey &scope,
- sword::ListKey &results) const;
-
- /**
- \returns the type of the module.
- */
- 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() const;
-
- /**
- \note The Sword library takes care of the duplicate names: _n is added
- after each duplicate.
- \returns The name of this module.
- */
- 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 inline bool snap() const {
- return false;
- }
-
- /**
- \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.
- */
- CSwordModuleInfo::TextDirection textDirection() const;
-
- /**
- Writes the new text at the given position into the module. This does
- only work for writabe modules.
- */
- void write(CSwordKey *key, const QString &newText);
-
- /**
- Deletes the current entry and removes it from the module.
- */
- bool deleteEntry(CSwordKey * const key);
-
- /**
- \returns the language of the module.
- */
- inline const CLanguageMgr::Language *language() const {
- return m_cachedLanguage;
- }
-
- /**
- \returns whether this module may be written to.
- */
- inline virtual bool isWritable() const {
- return false;
- }
-
- /**
- * Returns true if this module is hidden (not to be shown with other modules in certain views).
- */
- inline bool isHidden() const {
- return m_hidden;
- }
-
- /**
- Shows or hides the module.
- \param hide Whether the module should be hidden.
- \returns whether the hidden state was changed.
- */
- bool setHidden(bool hide);
-
- /**
- \returns the category of this module.
- */
- inline CSwordModuleInfo::Category category() const {
- return m_cachedCategory;
- }
-
- /**
- * The about text which belongs to this module.
- */
- QString aboutText() const;
- /**
- * Returns true if this module is Unicode encoded. False if the charset is iso8859-1.
- * Protected because it should not be used outside of the CSword*ModuleInfo classes.
- */
- inline bool isUnicode() const {
- return m_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;
- }
-
- protected:
-
- inline CSwordBackend* backend() const {
- return m_backend;
- }
-
- inline void backend( CSwordBackend* newBackend ) {
- if (newBackend) {
- m_backend = newBackend;
- }
- }
-
- QString getSimpleConfigEntry(const QString& name) const;
- QString getFormattedConfigEntry(const QString& name) const;
-
- 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 hasIndex);
- void hiddenChanged(bool hidden);
- void unlockedChanged(bool unlocked);
- void indexingFinished();
- void indexingProgress(int);
-
- private:
- 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;
+ */
+ bool unlock(const QString & unlockKey);
+
+ /**
+ * Returns the display object for this module. Normally every module should have a Display object.
+ * Please don't use module()->Display() because this function does return the Sword display and does
+ * render the text, too.
+ * This function performs some casts to return the correct display. If it returns 0 there's no valid
+ * display object.
+ */
+ Rendering::CEntryDisplay * getDisplay() const;
+
+ /**
+ * This function does return true if the data files of the module are encrypted by the module author
+ * (the on who made the module) no matter if it's locked or not.
+ * @return True if this module is encryped
+ */
+ bool isEncrypted() const;
+
+ /**
+ * This function returns true if this module is locked (encrypted + correct cipher key),
+ * otherwise return false.
+ * @return True if this module is locked, i.e. encrypted but without a key set
+ */
+ bool isLocked() const;
+
+ /**
+ 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 unlockKeyIsValid() const;
+
+ /**
+ \retval true if this module has a version number
+ \retval false if it doesn't have a version number
+ */
+ inline bool hasVersion() const {
+ return m_cachedHasVersion;
+ }
+
+ /**
+ \returns true if the module's index has been built.
+ */
+ bool hasIndex() const;
+
+ /**
+ \returns the path to this module's index base dir
+ */
+ QString getModuleBaseIndexLocation() const;
+
+ /**
+ \returns the path to this module's standard index
+ */
+ QString getModuleStandardIndexLocation() const;
+
+ /**
+ Builds a search index for this module
+ \returns Whether indexing this module was successful.
+ */
+ bool buildIndex();
+
+ /**
+ \returns index size
+ */
+ unsigned long indexSize() const;
+
+ /**
+ 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
+ */
+ int searchIndexed(const QString & searchedText,
+ const sword::ListKey & scope,
+ sword::ListKey & results) const;
+
+ /**
+ \returns the type of the module.
+ */
+ 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() const;
+
+ /**
+ \note The Sword library takes care of the duplicate names: _n is added
+ after each duplicate.
+ \returns The name of this module.
+ */
+ 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 inline bool snap() const {
+ return false;
+ }
+
+ /**
+ \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.
+ */
+ CSwordModuleInfo::TextDirection textDirection() const;
+
+ /**
+ Writes the new text at the given position into the module. This does
+ only work for writabe modules.
+ */
+ void write(CSwordKey * key, const QString & newText);
+
+ /**
+ Deletes the current entry and removes it from the module.
+ */
+ bool deleteEntry(CSwordKey * const key);
+
+ /**
+ \returns the language of the module.
+ */
+ inline const CLanguageMgr::Language * language() const {
+ return m_cachedLanguage;
+ }
+
+ /**
+ \returns whether this module may be written to.
+ */
+ inline virtual bool isWritable() const {
+ return false;
+ }
+
+ /**
+ * Returns true if this module is hidden (not to be shown with other modules in certain views).
+ */
+ inline bool isHidden() const {
+ return m_hidden;
+ }
+
+ /**
+ Shows or hides the module.
+ \param hide Whether the module should be hidden.
+ \returns whether the hidden state was changed.
+ */
+ bool setHidden(bool hide);
+
+ /**
+ \returns the category of this module.
+ */
+ inline CSwordModuleInfo::Category category() const {
+ return m_cachedCategory;
+ }
+
+ /**
+ * The about text which belongs to this module.
+ */
+ QString aboutText() const;
+
+ /**
+ * Returns true if this module is Unicode encoded. False if the charset is iso8859-1.
+ * Protected because it should not be used outside of the CSword*ModuleInfo classes.
+ */
+ inline bool isUnicode() const {
+ return m_module->isUnicode();
+ }
+
+ /**
+ Returns an icon for this module.
+ */
+ inline QIcon moduleIcon() const {
+ return CSwordModuleInfo::moduleIcon(*this);
+ }
+
+ /**
+ 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;
+ }
+
+protected: /* Methods: */
+
+ CSwordModuleInfo(sword::SWModule * module,
+ CSwordBackend & backend,
+ ModuleType type);
+
+ CSwordModuleInfo(const CSwordModuleInfo & copy);
+
+ inline CSwordBackend & backend() const {
+ return m_backend;
+ }
+
+ 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 hasIndex);
+ void hiddenChanged(bool hidden);
+ void unlockedChanged(bool unlocked);
+ void indexingFinished();
+ void indexingProgress(int);
+
+private: /* Fields: */
+
+ 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);
diff --git a/src/backend/filters/btosismorphsegmentation.cpp b/src/backend/filters/btosismorphsegmentation.cpp
new file mode 100644
index 0000000..1675476
--- /dev/null
+++ b/src/backend/filters/btosismorphsegmentation.cpp
@@ -0,0 +1,95 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "backend/filters/btosismorphsegmentation.h"
+
+// Sword includes:
+#include <utilxml.h>
+
+
+const char Filters::BtOSISMorphSegmentation::oName[] = "Morph segmentation";
+const char Filters::BtOSISMorphSegmentation::oTip[] = "Toggles morph "
+ "segmentation On and Off "
+ "if they exist";
+
+const sword::SWBuf Filters::BtOSISMorphSegmentation::choices[3] = { "Off",
+ "On",
+ "" };
+
+const sword::StringList Filters::BtOSISMorphSegmentation::oValues(&choices[0],
+ &choices[2]);
+
+Filters::BtOSISMorphSegmentation::BtOSISMorphSegmentation()
+ : sword::SWOptionFilter(oName, oTip, &oValues)
+{
+ setOptionValue("Off");
+}
+
+char Filters::BtOSISMorphSegmentation::processText(sword::SWBuf & text,
+ const sword::SWKey * key,
+ const sword::SWModule * mod)
+{
+ (void) key;
+ (void) mod;
+
+ sword::SWBuf token;
+ bool intoken = false;
+ bool hide = false;
+
+ sword::SWBuf orig(text);
+ const char * from = orig.c_str();
+
+ sword::XMLTag tag;
+
+ for (text = ""; *from; ++from) {
+ if (*from == '<') {
+ intoken = true;
+ token = "";
+ continue;
+ }
+
+ if (*from == '>') { // process tokens
+ intoken = false;
+
+ if (!strncmp(token.c_str(), "seg ", 4)
+ || !strncmp(token.c_str(), "/seg", 4))
+ {
+ tag = token;
+
+ if (!tag.isEndTag()
+ && tag.getAttribute("type")
+ && !strcmp("morph", tag.getAttribute("type")))
+ { // <seg type="morph"> start tag
+ hide = (option == 0); // only hide if option is Off
+ }
+
+ if (hide) { // hides start and end tags as long as hide is set
+ if (tag.isEndTag()) //</seg>
+ hide = false;
+ continue; // leave out the current token
+ }
+ } // end of seg tag handling
+
+ text.append('<');
+ text.append(token);
+ text.append('>');
+ // hide = false; // not right, because there may be child tags in seg. Only /seg may disable the seg hiding.
+ continue;
+ } // end of intoken part
+
+ if (intoken) {
+ token.append(*from); // copy token
+ } else {
+ text.append(*from); // copy text which is not inside of a tag
+ }
+ }
+
+ return 0;
+}
+
diff --git a/src/backend/filters/btosismorphsegmentation.h b/src/backend/filters/btosismorphsegmentation.h
new file mode 100644
index 0000000..66d4724
--- /dev/null
+++ b/src/backend/filters/btosismorphsegmentation.h
@@ -0,0 +1,47 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTOSISMORPHSEGMENTATION_H
+#define BTOSISMORPHSEGMENTATION_H
+
+// Sword includes:
+#include <swbuf.h>
+#include <swoptfilter.h>
+
+
+namespace Filters {
+
+/**
+ \brief This Filter shows/hides headings in a OSIS text.
+ \author Martin Gruner
+*/
+class BtOSISMorphSegmentation: public sword::SWOptionFilter {
+
+public: /* Methods: */
+
+ BtOSISMorphSegmentation();
+
+ virtual char processText(sword::SWBuf & text,
+ const sword::SWKey * key = 0,
+ const sword::SWModule * module = 0);
+
+private: /* Fields: */
+
+ static const char oName[];
+ static const char oTip[];
+ static const sword::SWBuf choices[3];
+ static const sword::StringList oValues;
+
+};
+
+} /* namespace Filters { */
+
+#endif /* BTOSISMORPHSEGMENTATION_H */
diff --git a/src/backend/filters/gbftohtml.cpp b/src/backend/filters/gbftohtml.cpp
index fac70ba..8f2fcc5 100644
--- a/src/backend/filters/gbftohtml.cpp
+++ b/src/backend/filters/gbftohtml.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -78,7 +78,7 @@ char Filters::GbfToHtml::processText(sword::SWBuf& buf, const sword::SWKey * key
return 1; //no processing should be done, may happen in a search
}
- CSwordModuleInfo* m = CSwordBackend::instance()->findModuleByName( module->Name() );
+ CSwordModuleInfo* m = CSwordBackend::instance()->findModuleByName( module->getName() );
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
@@ -254,7 +254,7 @@ bool Filters::GbfToHtml::handleToken(sword::SWBuf &buf, const char *token, sword
}
buf.append(" <span class=\"footnote\" note=\"");
- buf.append(myModule->Name());
+ buf.append(myModule->getName());
buf.append('/');
buf.append(myUserData->key->getShortText());
buf.append('/');
diff --git a/src/backend/filters/gbftohtml.h b/src/backend/filters/gbftohtml.h
index fbe5db2..bfe8501 100644
--- a/src/backend/filters/gbftohtml.h
+++ b/src/backend/filters/gbftohtml.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/osismorphsegmentation.cpp b/src/backend/filters/osismorphsegmentation.cpp
deleted file mode 100644
index 981ce89..0000000
--- a/src/backend/filters/osismorphsegmentation.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*********
-*
-* 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 "backend/filters/osismorphsegmentation.h"
-
-// Sword includes:
-#include <utilxml.h>
-
-
-const char Filters::OSISMorphSegmentation::oName[] = "Morph segmentation";
-const char Filters::OSISMorphSegmentation::oTip[] = "Toggles morph segmentation On and Off if they exist";
-
-const sword::SWBuf Filters::OSISMorphSegmentation::choices[3] = {"Off", "On", ""};
-
-const sword::StringList Filters::OSISMorphSegmentation::oValues(&choices[0], &choices[2]);
-
-Filters::OSISMorphSegmentation::OSISMorphSegmentation() : sword::SWOptionFilter(oName, oTip, &oValues) {
- setOptionValue("Off");
-}
-
-char Filters::OSISMorphSegmentation::processText(sword::SWBuf &text, const sword::SWKey * /*key*/, const sword::SWModule * /*module*/) {
- sword::SWBuf token;
- bool intoken = false;
- bool hide = false;
-
- sword::SWBuf orig( text );
- const char *from = orig.c_str();
-
- sword::XMLTag tag;
-
- for (text = ""; *from; ++from) {
- if (*from == '<') {
- intoken = true;
- token = "";
- continue;
- }
-
- if (*from == '>') { // process tokens
- intoken = false;
-
- if (!strncmp(token.c_str(), "seg ", 4) || !strncmp(token.c_str(), "/seg", 4)) {
- tag = token;
-
- if (!tag.isEndTag() && tag.getAttribute("type") && !strcmp("morph", tag.getAttribute("type"))) { //<seg type="morph"> start tag
- hide = (option == 0); //only hide if option is Off
- }
-
- if (hide) { //hides start and end tags as long as hide is set
-
- if (tag.isEndTag()) { //</seg>
- hide = false;
- }
-
- continue; //leave out the current token
- }
- } //end of seg tag handling
-
- text.append('<');
- text.append(token);
- text.append('>');
-
- // hide = false; //not right, because there may be child tags in seg. Only /seg may disable the seg hiding.
-
- continue;
- } //end of intoken part
-
- if (intoken) { //copy token
- token.append(*from);
- }
- else { //copy text which is not inside of a tag
- text.append(*from);
- }
- }
-
- return 0;
-}
-
diff --git a/src/backend/filters/osismorphsegmentation.h b/src/backend/filters/osismorphsegmentation.h
deleted file mode 100644
index 8d5a4ab..0000000
--- a/src/backend/filters/osismorphsegmentation.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*********
-*
-* 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 OSISMORPHSEGMENTATION_H
-#define OSISMORPHSEGMENTATION_H
-
-// Sword includes:
-#include <swbuf.h>
-#include <swoptfilter.h>
-
-
-namespace Filters {
-
-/** This Filter shows/hides headings in a OSIS text.
- * @author Martin Gruner
- */
-class OSISMorphSegmentation : public sword::SWOptionFilter {
- static const char oName[];
- static const char oTip[];
- static const sword::SWBuf choices[3];
- static const sword::StringList oValues;
-
- public:
- OSISMorphSegmentation();
-
- virtual char processText(sword::SWBuf &text, const sword::SWKey *key = 0, const sword::SWModule *module = 0);
-};
-
-}
-
-#endif
diff --git a/src/backend/filters/osistohtml.cpp b/src/backend/filters/osistohtml.cpp
index c04c820..3a8d65f 100644
--- a/src/backend/filters/osistohtml.cpp
+++ b/src/backend/filters/osistohtml.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,10 +10,11 @@
#include "backend/filters/osistohtml.h"
#include <QString>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/clanguagemgr.h"
#include "backend/managers/referencemanager.h"
+#include "backend/managers/cswordbackend.h"
// Sword includes:
#include <swbuf.h>
@@ -64,24 +65,22 @@ bool Filters::OsisToHtml::handleToken(sword::SWBuf &buf, const char *token, swor
// <div> tag
if (!strcmp(tag.getName(), "div")) {
- //handle intro
-
- if ((!tag.isEmpty()) && (!tag.isEndTag())) { //start tag
+ if (tag.isEndTag()) {
+ buf.append("</div>");
+ } else {
sword::SWBuf type( tag.getAttribute("type") );
-
if (type == "introduction") {
- buf.append("<div class=\"introduction\">");
- }
- else if (type == "chapter") {
- buf.append("<div class=\"chapter\" />"); //don't open a div here, that would lead to a broken XML structure
- }
- else {
+ if (!tag.isEmpty())
+ buf.append("<div class=\"introduction\">");
+ } else if (type == "chapter") {
+ if (!tag.isEmpty())
+ buf.append("<div class=\"chapter\" ></div>"); //don't open a div here, that would lead to a broken XML structure
+ } else if (type == "x-p") {
+ buf.append("<br/>");
+ } else {
buf.append("<div>");
}
}
- else if (tag.isEndTag()) { //end tag
- buf.append("</div>");
- }
}
else if (!strcmp(tag.getName(), "w")) {
if ((!tag.isEmpty()) && (!tag.isEndTag())) { //start tag
@@ -192,7 +191,7 @@ bool Filters::OsisToHtml::handleToken(sword::SWBuf &buf, const char *token, swor
}
else { //no prefix given
val = attrib;
- const bool skipFirst = ((val[0] == 'T') && ((val[1] == 'H') || (val[1] == 'H')));
+ const bool skipFirst = ((val[0] == 'T') && ((val[1] == 'H') || (val[1] == 'G')));
attrValue.append( skipFirst ? val + 1 : val );
}
}
@@ -237,7 +236,7 @@ bool Filters::OsisToHtml::handleToken(sword::SWBuf &buf, const char *token, swor
buf.append("<span class=\"crossreference\">");
sword::SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
sword::SWBuf footnoteBody = myUserData->entryAttributes["Footnote"][footnoteNumber]["body"];
- buf += myModule->RenderText(footnoteBody);
+ buf += myModule->renderText(footnoteBody);
}
/* else if (type == "explanation") {
@@ -256,7 +255,7 @@ bool Filters::OsisToHtml::handleToken(sword::SWBuf &buf, const char *token, swor
else {
// qWarning("found note in %s", myUserData->key->getShortText());
buf.append(" <span class=\"footnote\" note=\"");
- buf.append(myModule->Name());
+ buf.append(myModule->getName());
buf.append('/');
buf.append(myUserData->key->getShortText());
buf.append('/');
@@ -553,7 +552,7 @@ void Filters::OsisToHtml::renderReference(const char *osisRef, sword::SWBuf &buf
if (!mod || (mod->type() != CSwordModuleInfo::Bible
&& mod->type() != CSwordModuleInfo::Commentary)) {
- mod = CBTConfig::get( CBTConfig::standardBible );
+ mod = btConfig().getDefaultSwordModuleByType("standardBible");
}
// Q_ASSERT(mod); There's no necessarily a module or standard Bible
@@ -574,7 +573,7 @@ void Filters::OsisToHtml::renderReference(const char *osisRef, sword::SWBuf &buf
ReferenceManager::ParseOptions options;
options.refBase = QString::fromUtf8(myUserData->key->getText());
options.refDestinationModule = QString(mod->name());
- options.sourceLanguage = QString(myModule->Lang());
+ options.sourceLanguage = QString(myModule->getLanguage());
options.destinationLanguage = QString("en");
buf.append("<a href=\"");
diff --git a/src/backend/filters/osistohtml.h b/src/backend/filters/osistohtml.h
index ca36fe6..1c59ae1 100644
--- a/src/backend/filters/osistohtml.h
+++ b/src/backend/filters/osistohtml.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/plaintohtml.cpp b/src/backend/filters/plaintohtml.cpp
index 70df723..edb6208 100644
--- a/src/backend/filters/plaintohtml.cpp
+++ b/src/backend/filters/plaintohtml.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 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/plaintohtml.h b/src/backend/filters/plaintohtml.h
index b327ecc..e8ae570 100644
--- a/src/backend/filters/plaintohtml.h
+++ b/src/backend/filters/plaintohtml.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/teitohtml.cpp b/src/backend/filters/teitohtml.cpp
index 4b390d5..6367e22 100644
--- a/src/backend/filters/teitohtml.cpp
+++ b/src/backend/filters/teitohtml.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,10 +10,11 @@
#include "backend/filters/teitohtml.h"
#include <QString>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/clanguagemgr.h"
#include "backend/managers/referencemanager.h"
+#include "backend/managers/cswordbackend.h"
// Sword includes:
#include <swbuf.h>
@@ -108,7 +109,7 @@ void TeiToHtml::renderReference(const char *osisRef, sword::SWBuf &buf,
//If the osisRef is something like "ModuleID:key comes here" then the
// modulename is given, so we'll use that one
- CSwordModuleInfo* mod = CBTConfig::get( CBTConfig::standardBible );
+ CSwordModuleInfo* mod = btConfig().getDefaultSwordModuleByType( "standardBible" );
// Q_ASSERT(mod); There's no necessarily a module or standard Bible
@@ -128,7 +129,7 @@ void TeiToHtml::renderReference(const char *osisRef, sword::SWBuf &buf,
ReferenceManager::ParseOptions options;
options.refBase = QString::fromUtf8(myUserData->key->getText());
options.refDestinationModule = QString(mod->name());
- options.sourceLanguage = QString(mod->module()->Lang());
+ options.sourceLanguage = QString(mod->module()->getLanguage());
options.destinationLanguage = QString("en");
buf.append("<a href=\"");
diff --git a/src/backend/filters/teitohtml.h b/src/backend/filters/teitohtml.h
index 6fcc2c6..f365616 100644
--- a/src/backend/filters/teitohtml.h
+++ b/src/backend/filters/teitohtml.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/thmltohtml.cpp b/src/backend/filters/thmltohtml.cpp
index 12f42bf..0bf6e63 100644
--- a/src/backend/filters/thmltohtml.cpp
+++ b/src/backend/filters/thmltohtml.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,10 +13,11 @@
#include <QRegExp>
#include <QUrl>
#include <QTextCodec>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/clanguagemgr.h"
#include "backend/managers/referencemanager.h"
+#include "backend/managers/cswordbackend.h"
// Sword includes:
#include <swmodule.h>
@@ -46,7 +47,7 @@ char ThmlToHtml::processText(sword::SWBuf &buf, const sword::SWKey *key,
{
sword::ThMLHTML::processText(buf, key, module);
- CSwordModuleInfo* m = CSwordBackend::instance()->findModuleByName( module->Name() );
+ CSwordModuleInfo* m = CSwordBackend::instance()->findModuleByName( module->getName() );
if (m && !(m->has(CSwordModuleInfo::lemmas) || m->has(CSwordModuleInfo::strongNumbers))) { //only parse if the module has strongs or lemmas
return 1;
@@ -230,7 +231,7 @@ bool ThmlToHtml::handleToken(sword::SWBuf &buf, const char *token,
if (!tag.isEndTag() && !tag.isEmpty()) {
//appending is faster than appendFormatted
buf.append(" <span class=\"footnote\" note=\"");
- buf.append(myModule->Name());
+ buf.append(myModule->getName());
buf.append('/');
buf.append(myUserData->key->getShortText());
buf.append('/');
@@ -259,13 +260,13 @@ bool ThmlToHtml::handleToken(sword::SWBuf &buf, const char *token,
}
else { // like "<scripRef>John 3:16</scripRef>"
- CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
+ CSwordModuleInfo* mod = btConfig().getDefaultSwordModuleByType("standardBible");
//Q_ASSERT(mod); tested later
if (mod) {
ReferenceManager::ParseOptions options;
options.refBase = QString::fromUtf8(myUserData->key->getText()); //current module key
options.refDestinationModule = QString(mod->name());
- options.sourceLanguage = QString(myModule->Lang());
+ options.sourceLanguage = QString(myModule->getLanguage());
options.destinationLanguage = QString("en");
//it's ok to split the reference, because to descriptive text is given
@@ -318,13 +319,13 @@ bool ThmlToHtml::handleToken(sword::SWBuf &buf, const char *token,
const char* ref = tag.getAttribute("passage");
Q_ASSERT(ref);
- CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
+ CSwordModuleInfo* mod = btConfig().getDefaultSwordModuleByType("standardBible");
//Q_ASSERT(mod); tested later
ReferenceManager::ParseOptions options;
options.refBase = QString::fromUtf8(myUserData->key->getText());
- options.sourceLanguage = myModule->Lang();
+ options.sourceLanguage = myModule->getLanguage();
options.destinationLanguage = QString("en");
const QString completeRef = ReferenceManager::parseVerseReference(QString::fromUtf8(ref), options);
diff --git a/src/backend/filters/thmltohtml.h b/src/backend/filters/thmltohtml.h
index 99bbabb..ff40cf9 100644
--- a/src/backend/filters/thmltohtml.h
+++ b/src/backend/filters/thmltohtml.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/thmltoplain.cpp b/src/backend/filters/thmltoplain.cpp
index 42f383e..9f81173 100644
--- a/src/backend/filters/thmltoplain.cpp
+++ b/src/backend/filters/thmltoplain.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 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/thmltoplain.h b/src/backend/filters/thmltoplain.h
index 77e2a2b..68a5d95 100644
--- a/src/backend/filters/thmltoplain.h
+++ b/src/backend/filters/thmltoplain.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/backend/keys/cswordkey.cpp b/src/backend/keys/cswordkey.cpp
index a685b27..5fc37bd 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,7 +16,6 @@
#include "backend/keys/cswordldkey.h"
#include "backend/keys/cswordtreekey.h"
#include "backend/keys/cswordversekey.h"
-#include "util/btsignal.h"
// Sword includes:
#include <swkey.h>
@@ -27,170 +26,168 @@
#include <versekey.h>
-const QTextCodec *CSwordKey::m_cp1252Codec = QTextCodec::codecForName("Windows-1252");
-
-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;
-}
+const QTextCodec * CSwordKey::m_cp1252Codec = QTextCodec::codecForName("Windows-1252");
QString CSwordKey::rawText() {
- if (!m_module) return QString::null;
+ if (!m_module)
+ return QString::null;
- if (dynamic_cast<sword::SWKey*>(this)) {
+ if (dynamic_cast<sword::SWKey*>(this))
m_module->module()->getKey()->setText( rawKey() );
- }
- if (key().isNull()) return QString::null;
+ if (key().isNull())
+ return QString::null;
- return QString::fromUtf8( m_module->module()->getRawEntry() );
+ return QString::fromUtf8(m_module->module()->getRawEntry());
}
-QString CSwordKey::renderedText( const CSwordKey::TextRenderType mode ) {
+QString CSwordKey::renderedText(const CSwordKey::TextRenderType mode) {
Q_ASSERT(m_module);
- sword::SWKey* const k = dynamic_cast<sword::SWKey*>(this);
+ sword::SWKey * const k = dynamic_cast<sword::SWKey *>(this);
if (k) {
- sword::VerseKey* vk_mod = dynamic_cast<sword::VerseKey*>(m_module->module()->getKey());
- if (vk_mod) {
- vk_mod->Headings(1);
- }
+ sword::VerseKey * vk_mod = dynamic_cast<sword::VerseKey *>(m_module->module()->getKey());
+ if (vk_mod)
+ vk_mod->setIntros(true);
- m_module->module()->getKey()->setText( rawKey() );
+ m_module->module()->getKey()->setText(rawKey());
if (m_module->type() == CSwordModuleInfo::Lexicon) {
m_module->snap();
/* In lexicons make sure that our key (e.g. 123) was successfully set to the module,
i.e. the module key contains this key (e.g. 0123 contains 123) */
- if ( sword::stricmp(m_module->module()->getKey()->getText(), rawKey())
- && !strstr(m_module->module()->getKey()->getText(), rawKey())
- ) {
+ if (sword::stricmp(m_module->module()->getKey()->getText(), rawKey())
+ && !strstr(m_module->module()->getKey()->getText(), rawKey()))
+ {
qDebug("return an empty key for %s", m_module->module()->getKey()->getText());
return QString::null;
}
}
}
- //Q_ASSERT(!key().isNull());
- if (!key().isNull()) { //we have valid text
- bool DoRender = mode != ProcessEntryAttributesOnly;
- QString text = QString::fromUtf8( m_module->module()->RenderText(0,-1, DoRender));
- if (!DoRender)
- return QString::null;
-
- // This is yucky, but if we want strong lexicon refs we have to do it here.
- if (m_module->type() == CSwordModuleInfo::Lexicon) {
- QString t(text);
- QRegExp rx("(GREEK|HEBREW) for 0*([1-9]\\d*)"); // ignore 0's before number
- int pos = 0;
- while ( (pos = rx.indexIn(t, pos)) != -1 ) {
- QString language = rx.cap(1);
- QString langcode = QString(language.at(0)); // "G" or "H"
- QString number = rx.cap(2);
- QString paddednumber = number.rightJustified(5, '0'); // Form 00123
-
- text.replace(
- QRegExp( QString(
- "(>[^<>]+)" // Avoid replacing inside tags
- "\\b(0*%1)\\b").arg(number) ), // And span around 0's
- QString("\\1<span lemma=\"%1%2\"><a href=\"strongs://%3/%4\">\\2</a></span>")
+ if (key().isNull())
+ 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) {
+ const QString t(text);
+ const QRegExp rx("(GREEK|HEBREW) for 0*([1-9]\\d*)"); // ignore 0's before number
+ int pos = 0;
+ while ((pos = rx.indexIn(t, pos)) != -1) {
+ const QString language = rx.cap(1);
+ const QString langcode = QString(language.at(0)); // "G" or "H"
+ const QString number = rx.cap(2);
+ const QString paddednumber = number.rightJustified(5, '0'); // Form 00123
+
+ text.replace(
+ QRegExp(QString(
+ "(>[^<>]+)" // Avoid replacing inside tags
+ "\\b(0*%1)\\b").arg(number)), // And span around 0's
+ QString("\\1<span lemma=\"%1%2\"><a href=\"strongs://%3/%4\">\\2</a></span>")
.arg(langcode, paddednumber, language, paddednumber)
- );
- pos += rx.matchedLength();
- }
+ );
+ pos += rx.matchedLength();
}
+ }
- if (mode == HTMLEscaped) {
- /*
- Here we encode all non-latin1 characters as HTML unicode entities
- in the form &#<decimal unicode value here>;
- */
- QString ret;
-
- // 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()) {
- ret.append(c);
- } else {
- ret.append("&#").append(c.unicode()).append(";");
- }
+ if (mode == HTMLEscaped) {
+ /*
+ Here we encode all non-latin1 characters as HTML unicode entities
+ in the form &#<decimal unicode value here>;
+ */
+ QString ret;
+
+ // Reserve characters to reduce number of memory allocations:
+ ret.reserve(text.size());
+
+ for (const QChar * c = text.constBegin(); c != text.constEnd(); c++) {
+ if (c->toLatin1()) {
+ ret.append(*c);
+ } else {
+ ret.append("&#").append(c->unicode()).append(";");
}
-
- return ret;
- }
- else {
- return text;
}
- }
- return QString::null;
+ return ret;
+ }
+ else {
+ return text;
+ }
}
QString CSwordKey::strippedText() {
- if (!m_module) return QString::null;
+ if (!m_module)
+ return QString::null;
if (dynamic_cast<sword::SWKey*>(this)) {
char * buffer = new char[strlen(rawKey()) + 1];
strcpy(buffer, rawKey());
- m_module->module()->getKey()->setText( buffer );
+ m_module->module()->getKey()->setText(buffer);
delete [] buffer;
}
- return QString::fromUtf8( m_module->module()->StripText() );
+ return QString::fromUtf8(m_module->module()->stripText());
}
void CSwordKey::emitBeforeChanged() {
- if (m_signal.isNull())
- return;
- m_signal->emitBeforeChanged();
+ if (!m_beforeChangedSignaller.isNull())
+ m_beforeChangedSignaller->emitSignal();
}
-void CSwordKey::emitChanged() {
- if (m_signal.isNull())
- return;
- m_signal->emitChanged();
+void CSwordKey::emitAfterChanged() {
+ if (!m_afterChangedSignaller.isNull())
+ m_afterChangedSignaller->emitSignal();
}
-/** This will create a proper key object from a given module */
-CSwordKey *CSwordKey::createInstance(const CSwordModuleInfo *module) {
- if (!module) {
+CSwordKey * CSwordKey::createInstance(const CSwordModuleInfo * module) {
+ if (!module)
return 0;
- }
- switch ( module->type() ) {
+ sword::SWKey * const key = module->module()->getKey();
- case CSwordModuleInfo::Bible://fall through
+ switch (module->type()) {
+ case CSwordModuleInfo::Bible: // Fall through
case CSwordModuleInfo::Commentary:
- return new CSwordVerseKey( (sword::VerseKey *) ( (sword::SWKey *)(*module->module()) ), module );
+
+ Q_ASSERT(dynamic_cast<sword::VerseKey *>(key) != 0);
+ return new CSwordVerseKey(static_cast<sword::VerseKey *>(key),
+ module);
case CSwordModuleInfo::Lexicon:
- return new CSwordLDKey( (sword::SWKey *)(*module->module()), module);
+
+ return new CSwordLDKey(key, module);
case CSwordModuleInfo::GenericBook:
- return new CSwordTreeKey( (sword::TreeKeyIdx*)((sword::SWKey *)(*module->module())), module );
+
+ Q_ASSERT(dynamic_cast<sword::TreeKeyIdx *>(key) != 0);
+ return new CSwordTreeKey(dynamic_cast<sword::TreeKeyIdx *>(key),
+ module );
default:
+
return 0;
+
}
}
-const BtSignal* CSwordKey::signaler() {
- if (m_signal.isNull())
- m_signal = new BtSignal();
- return m_signal;
+const BtSignal * CSwordKey::beforeChangedSignaller() {
+ if (m_beforeChangedSignaller.isNull())
+ m_beforeChangedSignaller = new BtSignal();
+
+ return m_beforeChangedSignaller;
+}
+
+const BtSignal * CSwordKey::afterChangedSignaller() {
+ if (m_afterChangedSignaller.isNull())
+ m_afterChangedSignaller = new BtSignal();
+
+ return m_afterChangedSignaller;
}
diff --git a/src/backend/keys/cswordkey.h b/src/backend/keys/cswordkey.h
index 9b043b7..ee816a5 100644
--- a/src/backend/keys/cswordkey.h
+++ b/src/backend/keys/cswordkey.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,120 +14,127 @@
#include <QPointer>
#include <QString>
+#include "util/btsignal.h"
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 $
- */
+/** Base class for all Sword based keys. */
class CSwordKey {
- protected:
- /**
- \param module The module which belongs to this key, may be NULL
- */
- 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
- };
-
- virtual ~CSwordKey();
-
- /** Returns the current key.
- * @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 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;
-
- /**
- \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.
- */
- QString rawText();
- /** Returns the rendered text. Returns the text of the current key after passing it through the
- * modules filters.
- */
- QString renderedText( const CSwordKey::TextRenderType mode = CSwordKey::Normal );
- /** Stripped down text. Returns the text after removing all markup tags from it.
- */
- 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(const CSwordModuleInfo *module);
-
- /**
- * This is called before a key change to emit a signal
- * */
- void emitBeforeChanged();
- /**
- * This is called after a key change to emit a signal
- * */
- void emitChanged();
-
- protected:
- /**
- * Returns the encoded key appropriate for use directly with Sword.
- */
- virtual const char * rawKey() const = 0;
- static inline const QTextCodec *cp1252Codec() { return m_cp1252Codec; };
-
- private:
- /**
- * Disable the assignment operator
- */
- CSwordKey& operator= ( const CSwordKey & );
-
- protected:
- static const QTextCodec *m_cp1252Codec;
- const CSwordModuleInfo *m_module;
- QPointer<BtSignal> m_signal;
+
+public: /* Types: */
+
+ enum TextRenderType {
+ Normal = 0,
+ HTMLEscaped = 1,
+ ProcessEntryAttributesOnly = 2 // in this case, renderText() will not return text, but only cause EntryAttribute processing
+ };
+
+ virtual inline ~CSwordKey() { delete m_beforeChangedSignaller; }
+
+ /**
+ \returns The key which belongs to the current object.
+ */
+ virtual QString key() const = 0;
+
+ /**
+ Sets the current key using a utf8 enabled QString.
+ \param[in] 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[in] key The key which should be used to set the current one.
+ */
+ virtual bool setKey(const char * key) = 0;
+
+ /**
+ \returns a clone of this object.
+ */
+ virtual CSwordKey * copy() const = 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 from the module (i.e. without any filter
+ modifications).
+ */
+ QString rawText();
+
+ /**
+ \returns the rendered text by passing the text under the current key
+ through the filters.
+ */
+ QString renderedText(const CSwordKey::TextRenderType mode = CSwordKey::Normal);
+
+ /**
+ \returns the text after removing all markup tags from it.
+ */
+ QString strippedText();
+
+ const BtSignal * beforeChangedSignaller();
+ const BtSignal * afterChangedSignaller();
+
+ /**
+ \returns a new CSwordkey subclass instance for the given module, depending
+ on the type of the module.
+ */
+ static CSwordKey * createInstance(const CSwordModuleInfo * module);
+
+ /**
+ This is called before a key change to emit a signal
+ */
+ void emitBeforeChanged();
+
+ /**
+ This is called after a key change to emit a signal
+ */
+ void emitAfterChanged();
+
+protected: /* Methods: */
+
+ inline CSwordKey(const CSwordModuleInfo * const module = 0)
+ : m_module(module) {}
+
+ inline CSwordKey(const CSwordKey & copy)
+ : m_module(copy.m_module) {}
+
+ /**
+ \returns the encoded key appropriate for use directly with Sword.
+ */
+ virtual const char * rawKey() const = 0;
+
+ static inline const QTextCodec * cp1252Codec() { return m_cp1252Codec; }
+
+private: /* Methods: */
+
+ /**
+ Disable the assignment operator
+ */
+ CSwordKey & operator=(const CSwordKey &);
+
+protected: /* Fields: */
+
+ static const QTextCodec * m_cp1252Codec;
+ const CSwordModuleInfo * m_module;
+ QPointer<BtSignal> m_beforeChangedSignaller;
+ QPointer<BtSignal> m_afterChangedSignaller;
+
};
#endif
diff --git a/src/backend/keys/cswordldkey.cpp b/src/backend/keys/cswordldkey.cpp
index 822da8c..f6ffb25 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -75,7 +75,7 @@ bool CSwordLDKey::setKey(const QString &newKey) {
return setKey(newKey.toUtf8().constData());
}
else {
- return setKey((const char*)cp1252Codec()->fromUnicode(newKey));
+ return setKey(cp1252Codec()->fromUnicode(newKey).constData());
}
}
@@ -90,7 +90,7 @@ bool CSwordLDKey::setKey(const char *newKey) {
m_module->snap();
}
- return !Error();
+ return !popError();
}
/** Uses the parameter to returns the next entry afer this key. */
diff --git a/src/backend/keys/cswordldkey.h b/src/backend/keys/cswordldkey.h
index ed43ce7..e8fba24 100644
--- a/src/backend/keys/cswordldkey.h
+++ b/src/backend/keys/cswordldkey.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/backend/keys/cswordtreekey.cpp b/src/backend/keys/cswordtreekey.cpp
index 4ea624f..2823e5f 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -51,7 +51,7 @@ bool CSwordTreeKey::setKey(const QString &newKey) {
return setKey(newKey.toUtf8().constData());
}
else {
- return setKey((const char*)cp1252Codec()->fromUnicode(newKey));
+ return setKey(cp1252Codec()->fromUnicode(newKey).constData());
}
}
@@ -65,7 +65,7 @@ bool CSwordTreeKey::setKey(const char *newKey) {
root();
}
- return !Error();
+ return !popError();
}
QString CSwordTreeKey::getLocalNameUnicode() {
diff --git a/src/backend/keys/cswordtreekey.h b/src/backend/keys/cswordtreekey.h
index d6eb5ec..2bdfd6c 100644
--- a/src/backend/keys/cswordtreekey.h
+++ b/src/backend/keys/cswordtreekey.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/backend/keys/cswordversekey.cpp b/src/backend/keys/cswordversekey.cpp
index de4fd0e..3dc0c75 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -150,14 +150,14 @@ bool CSwordVerseKey::setKey(const char *newKey) {
}
/// \todo Do we ALWAYS need to emit this signal and check for errors?
- emitChanged();
- return !Error();
+ emitAfterChanged();
+ return !popError();
}
bool CSwordVerseKey::next( const JumpType type ) {
typedef CSwordBibleModuleInfo CSBMI;
- Error(); //clear Error status
+ popError(); //clear Error status
bool ret = true;
switch (type) {
@@ -186,21 +186,22 @@ bool CSwordVerseKey::next( const JumpType type ) {
case UseVerse: {
if (m_module && m_module->module()) {
- const bool oldStatus = m_module->module()->getSkipConsecutiveLinks();
+ const bool oldStatus = m_module->module()->isSkipConsecutiveLinks();
m_module->module()->setSkipConsecutiveLinks(true);
//disable headings for next verse
const bool useHeaders = 1; //(Verse() == 0);
- const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders );
+ const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->isIntros();
+ ((VerseKey*)(m_module->module()->getKey()))->setIntros( useHeaders );
//don't use setKey(), that would create a new key without Headings set
m_module->module()->getKey()->setText( key().toUtf8().constData() );
(*(m_module->module()) )++;
- ((VerseKey*)(m_module->module()->getKey()))->Headings(oldHeadingsStatus);
+ ((VerseKey*)(m_module->module()->getKey()))->setIntros(oldHeadingsStatus);
m_module->module()->setSkipConsecutiveLinks(oldStatus);
- if (!m_module->module()->Error()) {
+ if (!m_module->module()->popError()) {
setKey(QString::fromUtf8(m_module->module()->getKeyText()));
}
else {
@@ -237,14 +238,14 @@ bool CSwordVerseKey::next( const JumpType type ) {
ret = false;
}
- emitChanged();
+ emitAfterChanged();
return ret;
}
- else if (Error()) { //we have no module, so take care of VerseKey::Error()
+ else if (popError()) { //we have no module, so take care of VerseKey::Error()
return false;
}
- emitChanged();
+ emitAfterChanged();
return ret;
}
@@ -278,18 +279,19 @@ bool CSwordVerseKey::previous( const JumpType type ) {
case UseVerse: {
if (m_module && m_module->module()) {
const bool useHeaders = 1; //(Verse() == 0);
- const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->Headings( useHeaders );
+ const bool oldHeadingsStatus = ((VerseKey*)(m_module->module()->getKey()))->isIntros();
+ ((VerseKey*)(m_module->module()->getKey()))->setIntros( useHeaders );
m_module->module()->getKey()->setText( key().toUtf8().constData() );
- const bool oldStatus = m_module->module()->getSkipConsecutiveLinks();
+ const bool oldStatus = m_module->module()->isSkipConsecutiveLinks();
m_module->module()->setSkipConsecutiveLinks(true);
( *( m_module->module() ) )--;
- ((VerseKey*)(m_module->module()->getKey()))->Headings( oldHeadingsStatus );
+ ((VerseKey*)(m_module->module()->getKey()))->setIntros( oldHeadingsStatus );
m_module->module()->setSkipConsecutiveLinks(oldStatus);
- if (!m_module->module()->Error()) {
+ if (!m_module->module()->popError()) {
setKey(QString::fromUtf8(m_module->module()->getKeyText())); // don't use fromUtf8
}
else {
@@ -323,13 +325,13 @@ bool CSwordVerseKey::previous( const JumpType type ) {
ret = false;
}
- emitChanged();
+ emitAfterChanged();
return ret;
}
- else if (Error()) {
+ else if (popError()) {
return false;
}
- emitChanged();
+ emitAfterChanged();
return ret;
}
diff --git a/src/backend/keys/cswordversekey.h b/src/backend/keys/cswordversekey.h
index 2769cbf..4f33521 100644
--- a/src/backend/keys/cswordversekey.h
+++ b/src/backend/keys/cswordversekey.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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.cpp b/src/backend/managers/btstringmgr.cpp
index ad1fb3e..2e2e22a 100644
--- a/src/backend/managers/btstringmgr.cpp
+++ b/src/backend/managers/btstringmgr.cpp
@@ -2,52 +2,59 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "backend/managers/btstringmgr.h"
+#include <cstring>
+#include "util/macros.h"
-char* BTStringMgr::upperUTF8(char* text, unsigned int maxlen) const {
- const int max = (maxlen > 0) ? maxlen : strlen(text);
- if (isUtf8(text)) {
- strncpy(text, (const char*)QString::fromUtf8(text).toUpper().toUtf8(), max);
+char * BtStringMgr::upperUTF8(char * const text, unsigned int maxlen) const {
+ size_t max = (maxlen > 0u) ? maxlen : strlen(text);
- return text;
- }
- else {
- char* ret = text;
-
- while (*text) {
- *text = toupper(*text);
- text++;
+ if (LIKELY(max > 1u)) {
+ max--;
+ if (isUtf8(text)) {
+ strncpy(text, QString::fromUtf8(text).toUpper().toUtf8().constData(), max);
}
-
- return ret;
+ else {
+ strncpy(text, QString::fromLatin1(text).toUpper().toLatin1().constData(), max);
+ }
+ text[max] = '\0';
+ } else if (max == 1u) {
+ text[0u] = '\0';
+ } else {
+ Q_ASSERT(max == 0u);
}
return text;
}
-char* BTStringMgr::upperLatin1(char* text, unsigned int /*max*/) const {
- char* ret = text;
-
- while (*text) {
- *text = toupper(*text);
- text++;
+char * BtStringMgr::upperLatin1(char * const text, unsigned int maxlen) const {
+ size_t max = (maxlen > 0u) ? maxlen : strlen(text);
+
+ if (LIKELY(max > 1u)) {
+ max--;
+ strncpy(text, QString::fromLatin1(text).toUpper().toLatin1().constData(), max);
+ text[max] = '\0';
+ } else if (max == 1u) {
+ text[0u] = '\0';
+ } else {
+ Q_ASSERT(max == 0u);
}
- return ret;
+ return text;
}
-bool BTStringMgr::supportsUnicode() const {
+bool BtStringMgr::supportsUnicode() const {
return true;
}
-bool BTStringMgr::isUtf8(const char *buf) const {
+bool BtStringMgr::isUtf8(const char *buf) const {
int i, n;
register unsigned char c;
bool gotone = false;
diff --git a/src/backend/managers/btstringmgr.h b/src/backend/managers/btstringmgr.h
index 1cf7170..3fd0175 100644
--- a/src/backend/managers/btstringmgr.h
+++ b/src/backend/managers/btstringmgr.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,16 +14,20 @@
#include <QString>
-// Sword includes:
+/* Sword includes: */
#include <stringmgr.h>
-/** Unicode string manager implementation.
- * This is the StringManager implementation which works with QString.
- * @author The BibleTime developers
- */
+/**
+ Unicode string manager implementation.
-class BTStringMgr : public sword::StringMgr {
+ A Qt-based sword::StringMgr is better than the default one in Sword, in case
+ Sword is not compiled against ICU regarding this. However, we have no good
+ means to check this, so let's use this class as default. This is currently
+ done in BibleTime::initBackends() as follows:
+ sword::StringMgr::setSystemStringMgr(new BtStringMgr());
+*/
+class BtStringMgr : public sword::StringMgr {
public:
/** Converts the param to an upper case Utf8 string
@@ -50,4 +56,4 @@ class BTStringMgr : public sword::StringMgr {
bool isUtf8(const char *buf) const;
};
-#endif
+#endif /* BTSTRINGMGR_H */
diff --git a/src/backend/managers/cdisplaytemplatemgr.cpp b/src/backend/managers/cdisplaytemplatemgr.cpp
index fbeb921..734d912 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,7 +13,7 @@
#include <QFileInfo>
#include <QStringList>
#include <QTextStream>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/clanguagemgr.h"
#include "util/directory.h"
@@ -21,6 +21,15 @@
#define CSSTEMPLATEBASE "Basic.tmpl"
+namespace {
+
+inline QString readFileToString(const QString & filename) {
+ QFile f(filename);
+ return f.open(QIODevice::ReadOnly) ? QTextStream(&f).readAll() : QString();
+}
+
+} // anonymous namespace
+
CDisplayTemplateMgr * CDisplayTemplateMgr::m_instance = 0;
CDisplayTemplateMgr::CDisplayTemplateMgr(QString & errorMessage) {
@@ -57,7 +66,7 @@ CDisplayTemplateMgr::CDisplayTemplateMgr(QString & errorMessage) {
loadCSSTemplate(td.canonicalPath() + "/" + file);
// Load user app stylesheets
Q_FOREACH(const QString & file, utd.entryList(cssfilter, readableFileFilter))
- loadCSSTemplate(td.canonicalPath() + "/" + file);
+ loadCSSTemplate(utd.canonicalPath() + "/" + file);
}
}
@@ -145,12 +154,7 @@ QString CDisplayTemplateMgr::fillTemplate(const QString & name,
QString langCSS;
{
- /*
- At first append the font standard settings for all languages without
- configured font. Create a dummy language (the langmap may be empty).
- */
- const CLanguageMgr::Language lang(QString("en"), QString("English"), QString::null);
- const QFont f = CBTConfig::getDefault(&lang);
+ const QFont & f = btConfig().getDefaultFont();
langCSS.append("#content{font-family:").append(f.family())
.append(";font-size:").append(QString::number(f.pointSizeF(), 'f'))
.append("pt;font-weight:").append(f.bold() ? "bold" : "normal")
@@ -160,8 +164,12 @@ QString CDisplayTemplateMgr::fillTemplate(const QString & name,
{
const CLanguageMgr::LangMap & langMap = CLanguageMgr::instance()->availableLanguages();
Q_FOREACH (const CLanguageMgr::Language * lang, langMap) {
- if (!lang->abbrev().isEmpty() && CBTConfig::get(lang).first) {
- const QFont f = CBTConfig::get(lang).second;
+ if (lang->abbrev().isEmpty())
+ continue;
+
+ BtConfig::FontSettingsPair fp = btConfig().getFontForLanguage(*lang);
+ if (fp.first) {
+ const QFont & f = fp.second;
langCSS.append("*[lang=").append(lang->abbrev()).append("]{")
.append("font-family:").append(f.family())
@@ -188,28 +196,26 @@ QString CDisplayTemplateMgr::fillTemplate(const QString & name,
.replace("#DISPLAY_TEMPLATES_PATH#", DU::getDisplayTemplatesDir().absolutePath());
if (templateIsCss)
- output.replace("#THEME_STYLE#", m_cssMap[name]);
+ output.replace("#THEME_STYLE#", readFileToString(m_cssMap[name]));
return output;
}
QString CDisplayTemplateMgr::activeTemplateName() {
- const QString tn = CBTConfig::get(CBTConfig::displayStyle);
- if (tn.isEmpty())
- return defaultTemplateName();
-
- return tn;
+ const QString tn = btConfig().value<QString>("GUI/activeTemplateName",
+ QString());
+ return (tn.isEmpty()
+ || !instance()->m_availableTemplateNamesCache.contains(tn))
+ ? defaultTemplateName()
+ : tn;
}
void CDisplayTemplateMgr::loadTemplate(const QString & filename) {
Q_ASSERT(filename.endsWith(".tmpl"));
Q_ASSERT(QFileInfo(filename).isFile());
- QFile f(filename);
- if (f.open(QIODevice::ReadOnly)) {
- const QString fileContent(QTextStream(&f).readAll());
- if (!fileContent.isEmpty())
- m_templateMap.insert(QFileInfo(f).fileName(), fileContent);
- }
+ const QString templateString = readFileToString(filename);
+ if (!templateString.isEmpty())
+ m_templateMap.insert(QFileInfo(filename).fileName(), templateString);
}
void CDisplayTemplateMgr::loadCSSTemplate(const QString & filename) {
@@ -217,5 +223,5 @@ void CDisplayTemplateMgr::loadCSSTemplate(const QString & filename) {
const QFileInfo fi(filename);
Q_ASSERT(fi.isFile());
if (fi.isReadable())
- m_cssMap.insert(fi.fileName(), fi.absoluteFilePath());
+ m_cssMap.insert(fi.fileName(), filename);
}
diff --git a/src/backend/managers/cdisplaytemplatemgr.h b/src/backend/managers/cdisplaytemplatemgr.h
index a9e6380..823312c 100644
--- a/src/backend/managers/cdisplaytemplatemgr.h
+++ b/src/backend/managers/cdisplaytemplatemgr.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/clanguagemgr.cpp b/src/backend/managers/clanguagemgr.cpp
index a8d4e1f..49cc1a1 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,26 +13,6 @@
#include "backend/managers/cswordbackend.h"
-CLanguageMgr::Language::Language() {}
-
-CLanguageMgr::Language::Language(const Language& l) {
- m_abbrev = l.m_abbrev;
- m_englishName = l.m_englishName;
- m_translatedName = l.m_translatedName;
- m_altAbbrevs = l.m_altAbbrevs;
-}
-
-CLanguageMgr::Language::Language( const QString& abbrev, const QString& name, const QString& translatedName, const QStringList& altAbbrevs ) {
- m_abbrev = abbrev;
- m_englishName = name;
- m_translatedName = translatedName;
- m_altAbbrevs = altAbbrevs;
-}
-
-CLanguageMgr::Language::~Language() {
-}
-
-
/****************************************************/
/******************** CLanguageMgr ******************/
/****************************************************/
@@ -52,7 +32,10 @@ CLanguageMgr *CLanguageMgr::instance() {
return m_instance;
}
-CLanguageMgr::CLanguageMgr() : m_langMap() {
+CLanguageMgr::CLanguageMgr()
+ : m_defaultLanguage("", "", QString::null)
+ , m_langMap()
+{
m_availableModulesCache.moduleCount = 0;
init();
}
@@ -75,8 +58,8 @@ const CLanguageMgr::LangMap& CLanguageMgr::availableLanguages() {
QStringList abbrevs;
foreach (const CSwordModuleInfo* mod, mods) {
- if (!abbrevs.contains(mod->module()->Lang())) {
- abbrevs.append(mod->module()->Lang());
+ if (!abbrevs.contains(mod->module()->getLanguage())) {
+ abbrevs.append(mod->module()->getLanguage());
}
}
@@ -122,10 +105,6 @@ const CLanguageMgr::Language* CLanguageMgr::languageForTranslatedName( const QSt
void CLanguageMgr::init() {
- // The main() sets string literal codec to utf8:
- // QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
- // The language names include escape sequences \uxxxx
-
//if we've already inserted all items we do not proceed
if (m_langMap.count() > 0) return;
diff --git a/src/backend/managers/clanguagemgr.h b/src/backend/managers/clanguagemgr.h
index cbe70e9..fee236f 100644
--- a/src/backend/managers/clanguagemgr.h
+++ b/src/backend/managers/clanguagemgr.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -23,67 +25,94 @@
class CLanguageMgr {
public:
- /** Language container.
- * This class (Language) contains the information about the chosen language.
- */
- class Language {
- public:
- /**
- 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();
- Language(const Language &copy);
+ /**
+ \brief A language descriptor for CLanguageMgr.
+
+ This class (Language) contains the information about the a language.
+ */
+ class Language {
- Language(const QString &abbrev, const QString &englishName,
- const QString &translatedName,
- const QStringList &altAbbrevs = QStringList());
+ friend class CLanguageMgr;
+ friend class BtFontSettingsPage;
- ~Language();
+ public: /* Methods: */
- /** Returns the abbreviation.
- * @return The abbreviation of the chosen language.
- */
- inline const QString& abbrev() const {
- if (m_abbrev.isEmpty() && m_altAbbrevs.count()) { //no standard abbrev but alternative ones
+ /**
+ \returns the abbreviation of the this language.
+ */
+ inline const QString & abbrev() const {
+ if (m_abbrev.isEmpty() && m_altAbbrevs.count()) {
+ /* No standard abbrev but alternative ones */
return m_altAbbrevs.first();
}
return m_abbrev;
}
- /** Returns the translated name.
- * @return The translated name of the language.
- */
- inline const QString& translatedName() const {
+
+ /**
+ \returns the translated name of this language.
+ */
+ inline const QString & translatedName() const {
return m_translatedName;
}
- /** The english name of the language.
- * @return The english name of the chosen language.
- */
- inline const QString& name() const {
+
+ /**
+ \returns the english name of this language.
+ */
+ inline const QString & englishName() const {
return m_englishName;
}
- /** The alternative abbreviations which are avalable for this language.
- * @return The List of alternate abbreviations
- */
- inline const QStringList alternativeAbbrevs() const {
+
+ /**
+ \returns a list of alternative abbreviations for this language.
+ */
+ inline const QStringList & alternativeAbbrevs() const {
return m_altAbbrevs;
}
+
/**
- * Returns true if this language object is valid, i.e. has an abbrev and name.
- * @return True if the data is valid for this language.
- */
+ \returns whether this language object is valid, i.e. has an
+ abbreviation and an english name.
+ */
inline bool isValid() const {
- return (!abbrev().isEmpty() && !name().isEmpty());
+ return (!m_abbrev.isEmpty() && !m_englishName.isEmpty());
}
- private:
- QString m_abbrev;
- QString m_englishName;
- QString m_translatedName;
- QStringList m_altAbbrevs;
- };
+ private: /* Methods: */
+
+ inline Language() {}
+
+ inline Language(const char * abbrev,
+ const char * englishName,
+ const QString & translatedName)
+ : m_abbrev(abbrev)
+ , m_englishName(QString::fromUtf8(englishName))
+ , m_translatedName(translatedName) {}
+
+ inline Language(const QString & abbrev,
+ const QString & englishName,
+ const QString & translatedName)
+ : m_abbrev(abbrev)
+ , m_englishName(englishName)
+ , m_translatedName(translatedName) {}
+
+ inline Language(const char * abbrev,
+ const char * englishName,
+ const QString & translatedName,
+ const QStringList & altAbbrevs)
+ : m_abbrev(abbrev)
+ , m_englishName(QString::fromUtf8(englishName))
+ , m_translatedName(translatedName)
+ , m_altAbbrevs(altAbbrevs) {}
+
+ private: /* Fields: */
+
+ const QString m_abbrev;
+ const QString m_englishName;
+ const QString m_translatedName;
+ const QStringList m_altAbbrevs;
+
+ }; /* class Language { */
typedef QList<Language*> LanguageList;
typedef QHash<QString, const Language*> LangMap;
diff --git a/src/backend/managers/cswordbackend.cpp b/src/backend/managers/cswordbackend.cpp
index b5f4bff..c126c47 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,13 +15,13 @@
#include <QSet>
#include <QString>
#include <QTextCodec>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordbiblemoduleinfo.h"
#include "backend/drivers/cswordbookmoduleinfo.h"
#include "backend/drivers/cswordcommentarymoduleinfo.h"
#include "backend/drivers/cswordlexiconmoduleinfo.h"
+#include "backend/filters/btosismorphsegmentation.h"
#include "backend/filters/thmltoplain.h"
-#include "backend/filters/osismorphsegmentation.h"
#include "btglobal.h"
#include "util/directory.h"
@@ -37,18 +37,21 @@
using namespace Rendering;
-CSwordBackend *CSwordBackend::m_instance = 0;
+CSwordBackend * CSwordBackend::m_instance = 0;
CSwordBackend::CSwordBackend()
: sword::SWMgr(0, 0, false,
- new sword::EncodingFilterMgr(sword::ENC_UTF8), true),
- m_dataModel(this)
+ 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
+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
filterInit();
}
@@ -57,28 +60,28 @@ CSwordBackend::~CSwordBackend() {
}
void CSwordBackend::filterInit() {
- //HACK: replace Sword's OSISMorphSegmentation filter, seems to be buggy, ours works
- if (sword::SWOptionFilter* filter = optionFilters["OSISMorphSegmentation"]) {
+ // HACK: replace Sword's OSISMorphSegmentation filter, seems to be buggy, ours works
+ if (sword::SWOptionFilter * const filter = optionFilters["OSISMorphSegmentation"]) {
cleanupFilters.remove(filter);
optionFilters.erase("OSISMorphSegmentation");
delete filter;
}
- sword::SWOptionFilter *tmpFilter = new Filters::OSISMorphSegmentation();
+ sword::SWOptionFilter * const tmpFilter = new Filters::BtOSISMorphSegmentation();
optionFilters.insert(sword::OptionFilterMap::value_type("OSISMorphSegmentation", tmpFilter));
cleanupFilters.push_back(tmpFilter);
- //HACK: replace Sword's ThML strip filter with our own version
- //remove this hack as soon as Sword is fixed
+ // HACK: replace Sword's ThML strip filter with our own version
+ // Remove this hack as soon as Sword is fixed
cleanupFilters.remove(thmlplain);
delete thmlplain;
thmlplain = new Filters::ThmlToPlain();
cleanupFilters.push_back(thmlplain);
}
-QList<CSwordModuleInfo*> CSwordBackend::takeModulesFromList(const QStringList &names) {
- QList<CSwordModuleInfo*> list;
- Q_FOREACH (const QString &name, names) {
- CSwordModuleInfo* mInfo = findModuleByName(name);
+QList<CSwordModuleInfo *> CSwordBackend::takeModulesFromList(const QStringList & names) {
+ QList<CSwordModuleInfo *> list;
+ Q_FOREACH (const QString & name, names) {
+ CSwordModuleInfo * const mInfo = findModuleByName(name);
if (mInfo) {
m_dataModel.removeModule(mInfo);
list.append(mInfo);
@@ -89,82 +92,76 @@ QList<CSwordModuleInfo*> CSwordBackend::takeModulesFromList(const QStringList &n
return list;
}
-QList<CSwordModuleInfo*> CSwordBackend::getPointerList(const QStringList &names) const {
- QList<CSwordModuleInfo*> list;
- Q_FOREACH (const QString &name, names) {
- CSwordModuleInfo *mInfo = findModuleByName(name);
- if (mInfo) {
+QList<CSwordModuleInfo *> CSwordBackend::getPointerList(const QStringList & names) const {
+ QList<CSwordModuleInfo *> list;
+ Q_FOREACH (const QString & name, names) {
+ CSwordModuleInfo * const mInfo = findModuleByName(name);
+ if (mInfo)
list.append(mInfo);
- }
}
return list;
}
-QList<const CSwordModuleInfo*> CSwordBackend::getConstPointerList(
- const QStringList &names) const
+QList<const CSwordModuleInfo *> CSwordBackend::getConstPointerList(
+ const QStringList & names) const
{
- QList<const CSwordModuleInfo*> list;
- Q_FOREACH (const QString &name, names) {
- const CSwordModuleInfo *mInfo = findModuleByName(name);
- if (mInfo) {
+ QList<const CSwordModuleInfo *> list;
+ Q_FOREACH (const QString & name, names) {
+ const CSwordModuleInfo * const mInfo = findModuleByName(name);
+ if (mInfo)
list.append(mInfo);
- }
}
return list;
}
+CSwordBackend::LoadError CSwordBackend::initModules(const SetupChangedReason reason) {
+ // qWarning("globalSwordConfigPath is %s", globalConfPath);
-/** Initializes the Sword modules. */
-CSwordBackend::LoadError CSwordBackend::initModules(SetupChangedReason reason) {
- // qWarning("globalSwordConfigPath is %s", globalConfPath);
- LoadError ret = NoError;
-
- shutdownModules(); //remove previous modules
+ shutdownModules(); // Remove previous modules
m_dataModel.clear();
sword::ModMap::iterator end = Modules.end();
- ret = LoadError( Load() );
+ const LoadError ret = static_cast<LoadError>(Load());
- for (sword::ModMap::iterator it = Modules.begin(); it != end; it++) {
- sword::SWModule* const curMod = (*it).second;
- CSwordModuleInfo* newModule = 0;
+ for (sword::ModMap::iterator it = Modules.begin(); it != end; ++it) {
+ sword::SWModule * const curMod = it->second;
+ CSwordModuleInfo * newModule;
- if (!strcmp(curMod->Type(), "Biblical Texts")) {
- newModule = new CSwordBibleModuleInfo(curMod, this);
+ const char * const modType = curMod->getType();
+ if (!strcmp(modType, "Biblical Texts")) {
+ newModule = new CSwordBibleModuleInfo(curMod, *this);
newModule->module()->setDisplay(&m_chapterDisplay);
- }
- else if (!strcmp(curMod->Type(), "Commentaries")) {
- newModule = new CSwordCommentaryModuleInfo(curMod, this);
+ } else if (!strcmp(modType, "Commentaries")) {
+ newModule = new CSwordCommentaryModuleInfo(curMod, *this);
newModule->module()->setDisplay(&m_entryDisplay);
- }
- else if (!strcmp(curMod->Type(), "Lexicons / Dictionaries")) {
- newModule = new CSwordLexiconModuleInfo(curMod, this);
+ } else if (!strcmp(modType, "Lexicons / Dictionaries")) {
+ newModule = new CSwordLexiconModuleInfo(curMod, *this);
newModule->module()->setDisplay(&m_entryDisplay);
- }
- else if (!strcmp(curMod->Type(), "Generic Books")) {
- newModule = new CSwordBookModuleInfo(curMod, this);
+ } else if (!strcmp(modType, "Generic Books")) {
+ newModule = new CSwordBookModuleInfo(curMod, *this);
newModule->module()->setDisplay(&m_bookDisplay);
+ } else {
+ continue;
}
- if (newModule) {
- //Append the new modules to our list, but only if it's supported
- //The constructor of CSwordModuleInfo prints a warning on stdout
- if (!newModule->hasVersion() || (newModule->minimumSwordVersion() <= sword::SWVersion::currentVersion)) {
- m_dataModel.addModule(newModule);
- }
- else {
- delete newModule;
- }
+ // Append the new modules to our list, but only if it's supported
+ // The constructor of CSwordModuleInfo prints a warning on stdout
+ if (!newModule->hasVersion()
+ || (newModule->minimumSwordVersion() <= sword::SWVersion::currentVersion))
+ {
+ m_dataModel.addModule(newModule);
+ } else {
+ delete newModule;
}
}
- Q_FOREACH(CSwordModuleInfo* mod, m_dataModel.moduleList()) {
- //unlock modules if keys are present
- if ( mod->isEncrypted() ) {
- const QString unlockKey = CBTConfig::getModuleEncryptionKey( mod->name() );
- if (!unlockKey.isNull()) {
- setCipherKey( mod->name().toUtf8().constData(), unlockKey.toUtf8().constData() );
- }
+ // Unlock modules if keys are present:
+ Q_FOREACH(CSwordModuleInfo * mod, m_dataModel.moduleList()) {
+ if (mod->isEncrypted()) {
+ const QString unlockKey = btConfig().getModuleEncryptionKey(mod->name());
+ if (!unlockKey.isNull())
+ setCipherKey(mod->name().toUtf8().constData(),
+ unlockKey.toUtf8().constData());
}
}
@@ -172,46 +169,36 @@ CSwordBackend::LoadError CSwordBackend::initModules(SetupChangedReason reason) {
return ret;
}
-void CSwordBackend::AddRenderFilters(sword::SWModule *module, sword::ConfigEntMap &section) {
- sword::SWBuf moduleDriver;
- sword::SWBuf sourceformat;
- sword::ConfigEntMap::iterator entry;
- bool noDriver = true;
-
- sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
- moduleDriver = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
-
- if (sourceformat == "OSIS") {
- module->AddRenderFilter(&m_osisFilter);
- noDriver = false;
- }
- else if (sourceformat == "ThML") {
- module->AddRenderFilter(&m_thmlFilter);
- noDriver = false;
- }
- else if (sourceformat == "TEI") {
- module->AddRenderFilter(&m_teiFilter);
- noDriver = false;
- }
- else if (sourceformat == "GBF") {
- module->AddRenderFilter(&m_gbfFilter);
- noDriver = false;
- }
- else if (sourceformat == "PLAIN") {
- module->AddRenderFilter(&m_plainFilter);
- noDriver = false;
- }
-
- if (noDriver) { //no driver found
- if ( (moduleDriver == "RawCom") || (moduleDriver == "RawLD") ) {
- module->AddRenderFilter(&m_plainFilter);
- noDriver = false;
+void CSwordBackend::AddRenderFilters(sword::SWModule * module,
+ sword::ConfigEntMap & section)
+{
+ sword::ConfigEntMap::const_iterator entry = section.find("SourceType");
+ if (entry != section.end()) {
+ if (entry->second == "OSIS") {
+ module->addRenderFilter(&m_osisFilter);
+ return;
+ } else if (entry->second == "ThML") {
+ module->addRenderFilter(&m_thmlFilter);
+ return;
+ } else if (entry->second == "TEI") {
+ module->addRenderFilter(&m_teiFilter);
+ return;
+ } else if (entry->second == "GBF") {
+ module->addRenderFilter(&m_gbfFilter);
+ return;
+ } else if (entry->second == "PLAIN") {
+ module->addRenderFilter(&m_plainFilter);
+ return;
}
}
+
+ // No driver found
+ entry = section.find("ModDrv");
+ if (entry != section.end() && (entry->second == "RawCom" || entry->second == "RawLD"))
+ module->addRenderFilter(&m_plainFilter);
}
-/** This function deinitializes the modules and deletes them. */
-bool CSwordBackend::shutdownModules() {
+void CSwordBackend::shutdownModules() {
m_dataModel.clear(true);
//BT mods are deleted now, delete Sword mods, too.
DeleteMods();
@@ -221,117 +208,107 @@ bool CSwordBackend::shutdownModules() {
* modules. If these modules are removed, the filters need to be removed as well,
* so that they are re-created for the new module objects.
*/
- sword::FilterMap::iterator cipher_it;
- for (cipher_it = cipherFilters.begin(); cipher_it != cipherFilters.end(); cipher_it++) {
+ typedef sword::FilterMap::const_iterator FMCI;
+ for (FMCI it = cipherFilters.begin(); it != cipherFilters.end(); ++it) {
//Delete the Filter and remove it from the cleanup list
- cleanupFilters.remove(cipher_it->second);
- delete cipher_it->second;
+ cleanupFilters.remove(it->second);
+ delete it->second;
}
cipherFilters.clear();
-
- return true;
}
-void CSwordBackend::setOption( const CSwordModuleInfo::FilterTypes type, const int state ) {
- sword::SWBuf value;
-
- switch (type) {
-
- case CSwordModuleInfo::textualVariants:
-
- if (state == 0) {
- value = "Primary Reading";
- }
- else if (state == 1) {
- value = "Secondary Reading";
- }
- else {
- value = "All Readings";
- }
-
+void CSwordBackend::setOption(const CSwordModuleInfo::FilterTypes type,
+ const int state)
+{
+ if (type == CSwordModuleInfo::textualVariants) {
+ switch (state) {
+ case 0:
+ setGlobalOption(optionName(type).toUtf8().constData(),
+ "Primary Reading");
+ break;
+ case 1:
+ setGlobalOption(optionName(type).toUtf8().constData(),
+ "Secondary Reading");
break;
-
default:
- value = state ? "On" : "Off";
+ setGlobalOption(optionName(type).toUtf8().constData(),
+ "All Readings");
break;
- };
-
- if (value.length())
- setGlobalOption(optionName(type).toUtf8().constData(), value.c_str());
+ }
+ } else {
+ setGlobalOption(optionName(type).toUtf8().constData(),
+ state ? "On" : "Off");
+ }
}
-void CSwordBackend::setFilterOptions(const FilterOptions &options) {
- setOption( CSwordModuleInfo::footnotes, options.footnotes );
- setOption( CSwordModuleInfo::strongNumbers, options.strongNumbers );
- setOption( CSwordModuleInfo::headings, options.headings );
- setOption( CSwordModuleInfo::morphTags, options.morphTags );
- setOption( CSwordModuleInfo::lemmas, options.lemmas );
- setOption( CSwordModuleInfo::hebrewPoints, options.hebrewPoints );
- setOption( CSwordModuleInfo::hebrewCantillation, options.hebrewCantillation );
- setOption( CSwordModuleInfo::greekAccents, options.greekAccents );
- setOption( CSwordModuleInfo::redLetterWords, options.redLetterWords );
- setOption( CSwordModuleInfo::textualVariants, options.textualVariants );
- setOption( CSwordModuleInfo::morphSegmentation, options.morphSegmentation );
- // setOption( CSwordModuleInfo::transliteration, options.transliteration );
- setOption( CSwordModuleInfo::scriptureReferences, options.scriptureReferences);
+void CSwordBackend::setFilterOptions(const FilterOptions & options) {
+ setOption(CSwordModuleInfo::footnotes, options.footnotes);
+ setOption(CSwordModuleInfo::strongNumbers, options.strongNumbers);
+ setOption(CSwordModuleInfo::headings, options.headings);
+ setOption(CSwordModuleInfo::morphTags, options.morphTags);
+ setOption(CSwordModuleInfo::lemmas, options.lemmas);
+ setOption(CSwordModuleInfo::hebrewPoints, options.hebrewPoints);
+ setOption(CSwordModuleInfo::hebrewCantillation, options.hebrewCantillation);
+ setOption(CSwordModuleInfo::greekAccents, options.greekAccents);
+ setOption(CSwordModuleInfo::redLetterWords, options.redLetterWords);
+ setOption(CSwordModuleInfo::textualVariants, options.textualVariants);
+ setOption(CSwordModuleInfo::morphSegmentation, options.morphSegmentation);
+ // setOption(CSwordModuleInfo::transliteration, options.transliteration);
+ setOption(CSwordModuleInfo::scriptureReferences, options.scriptureReferences);
}
-/** This function searches for a module with the specified description */
-CSwordModuleInfo* CSwordBackend::findModuleByDescription(const QString &description) const {
- Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.moduleList()) {
- if (mod->config(CSwordModuleInfo::Description) == description) return mod;
- }
+CSwordModuleInfo * CSwordBackend::findModuleByDescription(const QString & description) const {
+ 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 name */
-CSwordModuleInfo* CSwordBackend::findModuleByName(const QString &name) const {
- Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.moduleList()) {
- if (mod->name() == name) return mod;
- }
+CSwordModuleInfo * CSwordBackend::findModuleByName(const QString & name) const {
+ Q_FOREACH (CSwordModuleInfo * mod, m_dataModel.moduleList())
+ if (mod->name() == name)
+ return mod;
return 0;
}
-CSwordModuleInfo* CSwordBackend::findSwordModuleByPointer(const sword::SWModule * const swmodule) const {
- Q_FOREACH (CSwordModuleInfo *mod, m_dataModel.moduleList()) {
- if (mod->module() == swmodule) return mod;
- }
+CSwordModuleInfo * CSwordBackend::findSwordModuleByPointer(const sword::SWModule * const swmodule) const {
+ Q_FOREACH (CSwordModuleInfo * mod, m_dataModel.moduleList())
+ if (mod->module() == swmodule)
+ return mod;
return 0;
}
-/** Returns the text used for the option given as parameter. */
-const QString CSwordBackend::optionName( const CSwordModuleInfo::FilterTypes option ) {
+QString CSwordBackend::optionName(const CSwordModuleInfo::FilterTypes option) {
switch (option) {
case CSwordModuleInfo::footnotes:
- return QString("Footnotes");
+ return "Footnotes";
case CSwordModuleInfo::strongNumbers:
- return QString("Strong's Numbers");
+ return "Strong's Numbers";
case CSwordModuleInfo::headings:
- return QString("Headings");
+ return "Headings";
case CSwordModuleInfo::morphTags:
- return QString("Morphological Tags");
+ return "Morphological Tags";
case CSwordModuleInfo::lemmas:
- return QString("Lemmas");
+ return "Lemmas";
case CSwordModuleInfo::hebrewPoints:
- return QString("Hebrew Vowel Points");
+ return "Hebrew Vowel Points";
case CSwordModuleInfo::hebrewCantillation:
- return QString("Hebrew Cantillation");
+ return "Hebrew Cantillation";
case CSwordModuleInfo::greekAccents:
- return QString("Greek Accents");
+ return "Greek Accents";
case CSwordModuleInfo::redLetterWords:
- return QString("Words of Christ in Red");
+ return "Words of Christ in Red";
case CSwordModuleInfo::textualVariants:
- return QString("Textual Variants");
+ return "Textual Variants";
case CSwordModuleInfo::scriptureReferences:
- return QString("Cross-references");
+ return "Cross-references";
case CSwordModuleInfo::morphSegmentation:
- return QString("Morph Segmentation");
+ return "Morph Segmentation";
}
return QString::null;
}
-/** Returns the translated name of the option given as parameter. */
-const QString CSwordBackend::translatedOptionName(const CSwordModuleInfo::FilterTypes option) {
+QString CSwordBackend::translatedOptionName(const CSwordModuleInfo::FilterTypes option) {
switch (option) {
case CSwordModuleInfo::footnotes:
return QObject::tr("Footnotes");
@@ -362,58 +339,60 @@ const QString CSwordBackend::translatedOptionName(const CSwordModuleInfo::Filter
}
-const QString CSwordBackend::configOptionName( const CSwordModuleInfo::FilterTypes option ) {
+QString CSwordBackend::configOptionName(const CSwordModuleInfo::FilterTypes option) {
switch (option) {
case CSwordModuleInfo::footnotes:
- return QString("Footnotes");
+ return "Footnotes";
case CSwordModuleInfo::strongNumbers:
- return QString("Strongs");
+ return "Strongs";
case CSwordModuleInfo::headings:
- return QString("Headings");
+ return "Headings";
case CSwordModuleInfo::morphTags:
- return QString("Morph");
+ return "Morph";
case CSwordModuleInfo::lemmas:
- return QString("Lemma");
+ return "Lemma";
case CSwordModuleInfo::hebrewPoints:
- return QString("HebrewPoints");
+ return "HebrewPoints";
case CSwordModuleInfo::hebrewCantillation:
- return QString("Cantillation");
+ return "Cantillation";
case CSwordModuleInfo::greekAccents:
- return QString("GreekAccents");
+ return "GreekAccents";
case CSwordModuleInfo::redLetterWords:
- return QString("RedLetterWords");
+ return "RedLetterWords";
case CSwordModuleInfo::textualVariants:
- return QString("Variants");
+ return "Variants";
case CSwordModuleInfo::scriptureReferences:
- return QString("Scripref");
+ return "Scripref";
case CSwordModuleInfo::morphSegmentation:
- return QString("MorphSegmentation");
+ return "MorphSegmentation";
}
return QString::null;
}
-const QString CSwordBackend::booknameLanguage( const QString& language ) {
+const QString CSwordBackend::booknameLanguage(const QString & language) {
if (!language.isEmpty()) {
- sword::LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName( language.toUtf8().constData() );
-
- //refresh the locale of all Bible and commentary modules!
- //use what sword returns, language may be different
- QString newLocaleName( sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName() );
-
- 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() );
+ sword::LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName(language.toUtf8().constData());
+
+ // Refresh the locale of all Bible and commentary modules!
+ // Use what sword returns, language may be different.
+ const QByteArray newLocaleName(QString(sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName()).toUtf8());
+
+ 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:
+ typedef sword::VerseKey VK;
+ VK & vk = *static_cast<VK *>(mod->module()->getKey());
+ vk.setLocale(newLocaleName.constData());
}
}
}
- return QString( sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName() );
+ return sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName();
}
-
-/** Reload all Sword modules. */
-void CSwordBackend::reloadModules(SetupChangedReason reason) {
+void CSwordBackend::reloadModules(const SetupChangedReason reason) {
shutdownModules();
//delete Sword's config to make Sword reload it!
@@ -425,8 +404,7 @@ void CSwordBackend::reloadModules(SetupChangedReason reason) {
findConfig(&configType, &prefixPath, &configPath, &augPaths, &sysConfig);
// now re-read module configuration files
loadConfigDir(configPath);
- }
- else if (config) {
+ } else if (config) {
config->Load();
}
@@ -435,17 +413,13 @@ void CSwordBackend::reloadModules(SetupChangedReason reason) {
// Get one or more shared sword config (sword.conf) files
QStringList CSwordBackend::getSharedSwordConfigFiles() const {
- QStringList configPath;
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
// %ALLUSERSPROFILE%\Sword\sword.conf
- QString tmp = util::directory::getSharedSwordDir().filePath("sword.conf");
- QString globalPath = util::directory::convertDirSeparators(QString(getenv("SWORD_PATH")));
- configPath << globalPath.append("/Sword/sword.conf");
+ return QStringList(util::directory::convertDirSeparators(QString(getenv("SWORD_PATH"))) += "/Sword/sword.conf");
#else
// /etc/sword.conf, /usr/local/etc/sword.conf
- configPath = QString(globalConfPath).split(":");
+ return QString(globalConfPath).split(":");
#endif
- return configPath;
}
// Get the private sword directory
@@ -454,15 +428,13 @@ QString CSwordBackend::getPrivateSwordConfigPath() const {
}
QString CSwordBackend::getPrivateSwordConfigFile() const {
- QString file(getPrivateSwordConfigPath() + "/sword.conf");
- return util::directory::convertDirSeparators(file);
+ return util::directory::convertDirSeparators(getPrivateSwordConfigPath() += "/sword.conf");
}
// Return a list of used Sword dirs. Useful for the installer.
QStringList CSwordBackend::swordDirList() const {
namespace DU = util::directory;
typedef QStringList::const_iterator SLCI;
- typedef sword::ConfigEntMap::const_iterator CEMCI;
// Get the set of sword directories that could contain modules:
QSet<QString> swordDirSet;
@@ -471,8 +443,7 @@ QStringList CSwordBackend::swordDirList() const {
if (QFile(getPrivateSwordConfigFile()).exists()) {
// Use the private sword.conf file:
configs << getPrivateSwordConfigFile();
- }
- else {
+ } else {
/*
Did not find private sword.conf, will use shared sword.conf files to
build the private one. Once the private sword.conf exist, the shared
@@ -480,7 +451,7 @@ QStringList CSwordBackend::swordDirList() const {
*/
configs = getSharedSwordConfigFiles();
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
/*
On Windows, add the shared sword directory to the set so the new
private sword.conf will have it. The user could decide to delete this
@@ -491,53 +462,49 @@ QStringList CSwordBackend::swordDirList() const {
}
// Search the sword.conf file(s) for sword directories that could contain modules
- for (SLCI it(configs.begin()); it != configs.end(); it++) {
- if (!QFileInfo(*it).exists()) {
+ for (SLCI it = configs.begin(); it != configs.end(); ++it) {
+ if (!QFileInfo(*it).exists())
continue;
- }
/*
Get all DataPath and AugmentPath entries from the config file and add
them to the list:
*/
- sword::SWConfig conf((*it).toUtf8().constData());
+ sword::SWConfig conf(it->toUtf8().constData());
swordDirSet << QDir(QTextCodec::codecForLocale()->toUnicode(conf["Install"]["DataPath"].c_str())).absolutePath();
- sword::ConfigEntMap group(conf["Install"]);
- const sword::ConfigEntMap::iterator start(group.equal_range("AugmentPath").first);
- const sword::ConfigEntMap::iterator end(group.equal_range("AugmentPath").second);
-
- for (CEMCI it(start); it != end; it++) {
- QDir(QTextCodec::codecForLocale()->toUnicode(it->second.c_str())).absolutePath();
+ const sword::ConfigEntMap group(conf["Install"]);
+ typedef sword::ConfigEntMap::const_iterator CEMCI;
+ for (std::pair<CEMCI, CEMCI> its = group.equal_range("AugmentPath");
+ its.first != its.second;
+ ++(its.first))
+ {
// Added augment path:
- swordDirSet << QDir(QTextCodec::codecForLocale()->toUnicode(it->second.c_str())).absolutePath();
+ swordDirSet << QDir(QTextCodec::codecForLocale()->toUnicode(its.first->second.c_str())).absolutePath();
}
}
// Add the private sword path to the set if not there already:
swordDirSet << getPrivateSwordConfigPath();
- return swordDirSet.values();
+ return QStringList::fromSet(swordDirSet);
}
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] );
- }
+ const QStringList entries = QDir(CSwordModuleInfo::getGlobalBaseIndexLocation()).entryList(QDir::Dirs);
+ Q_FOREACH(const QString & entry, entries) {
+ if (entry == "." || entry == "..")
+ continue;
+ CSwordModuleInfo * const module = findModuleByName(entry);
+ if (module) { //mod exists
+ if (!module->hasIndex()) { //index files found, but wrong version etc.
+ qDebug() << "deleting outdated index for module" << entry;
+ CSwordModuleInfo::deleteIndexForModule(entry);
}
- else { //no module exists
- if (CBTConfig::get( CBTConfig::autoDeleteOrphanedIndices ) ) {
- qDebug() << "deleting orphaned index in directory" << dir[i];
- CSwordModuleInfo::deleteIndexForModule( dir[i] );
- }
+ } else { //no module exists
+ if (btConfig().value<bool>("settings/behaviour/autoDeleteOrphanedIndices", true)) {
+ qDebug() << "deleting orphaned index in directory" << entry;
+ CSwordModuleInfo::deleteIndexForModule(entry);
}
}
}
diff --git a/src/backend/managers/cswordbackend.h b/src/backend/managers/cswordbackend.h
index 764d6d5..21da696 100644
--- a/src/backend/managers/cswordbackend.h
+++ b/src/backend/managers/cswordbackend.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,7 +12,6 @@
#ifndef CSWORDBACKEND_H
#define CSWORDBACKEND_H
-#include <QMap>
#include <QObject>
#include <QString>
#include <QStringList>
@@ -44,215 +45,241 @@
BibleTimeApp::~BibleTimeApp(). Only when \ref BackendNotSingleton
"managing modules" separate backends are created.
*/
-class CSwordBackend : public QObject, public sword::SWMgr {
- Q_OBJECT
- public:
-
- /** The reason for the sigSwordSetupChanged signal, i.e. why the module list has changed. */
- enum SetupChangedReason {
- AddedModules = 1,
- RemovedModules = 2,
- HidedModules = 4,
- PathChanged = 8,
- OtherChange = 16
- };
-
- /** 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
- NoSwordConfig = -1,
- NoError = 0,
- NoModules = 1
- };
- /**
- * The constructor of the Sword backend. Used by BtInstallBackend only.
- * 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
- * @param augmentHome True if the $HOME/.sword/ modules should be augmented with the other modules
- */
- CSwordBackend( const QString& path, const bool augmentHome = true );
-
- /**
- * The destrctor of this backend. This function shuts the modules down using @ref shutdownModules.
- */
- ~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
- * equivalent to model()->modules().
- *
- * @return The list of modules managed by this backend
- */
- inline const QList<CSwordModuleInfo*>& moduleList() const;
-
- inline BtBookshelfModel *model();
-
- /**
- * Initializes the Sword modules.
- *
- * @return True if the initializiation was succesful, otherwise return false.
- */
- CSwordBackend::LoadError initModules(SetupChangedReason reason);
- /**
- * This function deinitializes the modules and deletes them.
- *
- * @return True if it was succesful, otherwise return false
- */
- bool shutdownModules();
- /**
- * Sets the given options enabled or disabled depending on the second parameter.
- *
- * @param type This is the type this function should set enabled or disabled
- * @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 FilterOptions &options);
- /**
- * Sets the language for the international booknames of Sword.
- * @param langName The abbreviation string which should be used for the Sword backend
- */
- const QString booknameLanguage( const QString& langName = QString::null );
- /**
- * 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
- */
- CSwordModuleInfo* findModuleByDescription(const QString &description) const;
-
- /**
- * This function searches for a module with the specified name
- * @param name The name of the desired module
- * @return Pointer to the desired module; null if no module has the specified name
- */
- CSwordModuleInfo* findModuleByName(const QString &name) const;
- /**
- * This function searches for a module with the specified sword module as module() object!
- * @param swmodule to a Sword module
- * @return pointer to the desired module; null if no module has the specified name
- */
- CSwordModuleInfo* findSwordModuleByPointer(const sword::SWModule * const swmodule) const;
-
- /**
- * @return Our global config object which contains the configs of all modules merged together.
- */
- inline sword::SWConfig* getConfig() const;
-
- /**
- * Returns the text used for the option given as parameter.
- * @param The paramter enum
- * @return The name of the option given by the parameter
- */
- static const QString optionName( const CSwordModuleInfo::FilterTypes option );
- /**
- * Returns the text used for the option given as parameter.
- */
- static const QString configOptionName( const CSwordModuleInfo::FilterTypes option );
- /**
- * Returns the translated name of the option given as parameter.
- * @param The translated option name
- */
- static const QString translatedOptionName(const CSwordModuleInfo::FilterTypes option );
-
- /**
- * Reload all Sword modules.
- */
- void reloadModules(SetupChangedReason reason);
-
- /**
- * Takes off the given modules from the list and returns them.
- * User must take care of the deletion of the returned CSwordModuleInfo pointers.
- */
- QList<CSwordModuleInfo*> takeModulesFromList(const QStringList &names);
-
- /**
- \returns a list of pointers to modules, created from a list of module
- names.
- */
- QList<CSwordModuleInfo*> getPointerList(const QStringList &names) const;
-
- /**
- \returns a list of pointers to const modules, created from a list of
- module names.
- */
- QList<const CSwordModuleInfo*> getConstPointerList(const QStringList &names) const;
-
- /** 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:
- /**
- 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);
- /**
- * Overrides Sword filters which appear to be buggy.
- */
- void filterInit();
-
- QStringList getSharedSwordConfigFiles() const;
- QString getPrivateSwordConfigPath() const;
- QString getPrivateSwordConfigFile() const;
-
- 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;
-
- static CSwordBackend *m_instance;
+class CSwordBackend: public QObject, public sword::SWMgr {
+
+ Q_OBJECT
+
+public: /* Types: */
+
+ /**
+ \brief The reason for the sigSwordSetupChanged signal, i.e. why the module
+ list has changed.
+ */
+ enum SetupChangedReason {
+ AddedModules = 1,
+ RemovedModules = 2,
+ HidedModules = 4,
+ PathChanged = 8,
+ OtherChange = 16
+ };
+
+ /**
+ \brief The error codes which may be returned by the \ref Load() call.
+ \note These values exist to cast from the char return of SWMgr::Load().
+ */
+ enum LoadError {
+ NoSwordConfig = -1,
+ NoError = 0,
+ NoModules = 1
+ };
+
+public: /* Methods: */
+
+ /**
+ \note Used by BtInstallBackend only.
+ \note Using augmentHome=false can mess up the system because it is true
+ elsewhere.
+ \param[in] path The path which is used to load modules.
+ \param[in] augmentHome Whether $HOME/.sword/ modules should be augmented
+ with the other modules.
+ */
+ CSwordBackend(const QString & path, const bool augmentHome = true);
+
+ ~CSwordBackend();
+
+ /** \returns the CSwordBackend singleton instance (created if needed). */
+ static inline CSwordBackend * createInstance() {
+ Q_ASSERT(!m_instance);
+ 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; }
+
+ /** \brief Destroys the singleton instance, if one exists. */
+ static inline void destroyInstance() {
+ delete m_instance;
+ m_instance = NULL;
+ }
+
+ /**
+ \warning You have to call initModules() first.
+ \note This method is equivalent to model()->modules().
+ \returns The list of modules managed by this backend.
+ */
+ inline const QList<CSwordModuleInfo *> & moduleList() const;
+
+ inline BtBookshelfModel * model();
+
+ /**
+ \brief Initializes the Sword modules.
+ \returns whether the initializiation was successful.
+ */
+ CSwordBackend::LoadError initModules(const SetupChangedReason reason);
+
+ /**
+ \brief Deinitializes and frees the modules.
+ \returns whether the method succeeded.
+ */
+ void shutdownModules();
+
+ /**
+ \brief Sets the state of the given filter option.
+ \param[in] type The filter type whose state to set.
+ \param[in] state The new filter option state.
+ */
+ void setOption(const CSwordModuleInfo::FilterTypes type, const int state);
+
+ void setFilterOptions(const FilterOptions & options);
+
+ /**
+ \brief Sets the language for the international booknames of Sword.
+ \param[in] langName The abbreviation string which should be used for the
+ Sword backend.
+ */
+ const QString booknameLanguage(const QString & langName = QString::null);
+
+ /**
+ \brief Searches for a module with the given description.
+ \param[in] description The description of the desired module.
+ \returns a pointer to the desired module or NULL if not found.
+ */
+ CSwordModuleInfo * findModuleByDescription(const QString & description) const;
+
+ /**
+ \brief Searches for a module with the given name.
+ \param[in] name The name of the desired module.
+ \returns a pointer to the desired module or NULL if not found.
+ */
+ CSwordModuleInfo * findModuleByName(const QString & name) const;
+
+ /**
+ \brief Searches for a module with the given sword module as module().
+ \param[in] swmodule The SWModule of the desired module.
+ \returns a pointer to the desired module or NULL if not found.
+ */
+ CSwordModuleInfo * findSwordModuleByPointer(const sword::SWModule * const swmodule) const;
+
+ /**
+ \returns The global config object containing the configs of all modules
+ merged together.
+ */
+ inline sword::SWConfig * getConfig() const;
+
+ /**
+ \param[in] option The option name to return.
+ \returns The name of the option given by the parameter.
+ */
+ static QString optionName(const CSwordModuleInfo::FilterTypes option);
+
+ /**
+ \param[in] option The configuration option name to return.
+ \returns the text used for the configuration option given.
+ */
+ static QString configOptionName(const CSwordModuleInfo::FilterTypes option);
+
+ /**
+ \param[in] option The translated option name.
+ \returns the translated name of the option given.
+ */
+ static QString translatedOptionName(const CSwordModuleInfo::FilterTypes option);
+
+ /**
+ \brief Reloads all Sword modules.
+ \param[in] reason The reason for the reload.
+ */
+ void reloadModules(const SetupChangedReason reason);
+
+ /**
+ \brief Takes off the given modules from the list and returns them.
+ \param[in] names The names of the modules to take.
+ \note User must take care of the deletion of the returned CSwordModuleInfo
+ pointers.
+ */
+ QList<CSwordModuleInfo *> takeModulesFromList(const QStringList & names);
+
+ /**
+ \param[in] names The names of the modules to return.
+ \returns a list of pointers to modules, created from a list of module
+ names.
+ */
+ QList<CSwordModuleInfo *> getPointerList(const QStringList & names) const;
+
+ /**
+ \param[in] names The names of the modules to return.
+ \returns a list of pointers to const modules, created from a list of
+ module names.
+ */
+ QList<const CSwordModuleInfo *> getConstPointerList(const QStringList & names) const;
+
+ /**
+ \brief Sword prefix list.
+ \returns A list of all known Sword prefix dirs
+ */
+ QStringList swordDirList() const;
+
+ /**
+ Deletes all indices of modules where hasIndex() returns false (because of
+ wrong index version etc.) and deletes all orphaned indexes (no module
+ present) if autoDeleteOrphanedIndices is true.
+ */
+ void deleteOrphanedIndices();
+
+signals:
+
+ void sigSwordSetupChanged(CSwordBackend::SetupChangedReason reason);
+
+protected: /* Methods: */
+
+ /**
+ 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);
+
+ /** Overrides Sword filters which appear to be buggy. */
+ void filterInit();
+
+ QStringList getSharedSwordConfigFiles() const;
+ QString getPrivateSwordConfigPath() const;
+ QString getPrivateSwordConfigFile() const;
+
+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;
+
+ static CSwordBackend * m_instance;
+
};
/**Returns The list of modules managed by this backend*/
-inline const QList<CSwordModuleInfo*> &CSwordBackend::moduleList() const {
+inline const QList<CSwordModuleInfo *> & CSwordBackend::moduleList() const {
return m_dataModel.moduleList();
}
-inline BtBookshelfModel *CSwordBackend::model() {
+inline BtBookshelfModel * CSwordBackend::model() {
return &m_dataModel;
}
/** 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. */
-inline sword::SWConfig* CSwordBackend::getConfig() const {
+inline sword::SWConfig * CSwordBackend::getConfig() const {
return config;
}
diff --git a/src/backend/managers/referencemanager.cpp b/src/backend/managers/referencemanager.cpp
index 0a17645..144ad8c 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,8 +12,10 @@
#include <algorithm>
#include <QRegExp>
#include <QDebug>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/keys/cswordversekey.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/cswordbackend.h"
/** Returns a hyperlink used to be imbedded in the display windows. At the moment the format is sword://module/key */
@@ -250,33 +252,26 @@ const QString ReferenceManager::preferredModule( const ReferenceManager::Type ty
switch (type) {
case ReferenceManager::Bible:
- module = CBTConfig::get(CBTConfig::standardBible);
+ module = btConfig().getDefaultSwordModuleByType( "standardBible" );
break;
-
case ReferenceManager::Commentary:
- module = CBTConfig::get(CBTConfig::standardCommentary);
+ module = btConfig().getDefaultSwordModuleByType( "standardCommentary" );
break;
-
case ReferenceManager::Lexicon:
- module = CBTConfig::get(CBTConfig::standardLexicon);
+ module = btConfig().getDefaultSwordModuleByType( "standardLexicon" );
break;
-
case ReferenceManager::StrongsHebrew:
- module = CBTConfig::get(CBTConfig::standardHebrewStrongsLexicon);
+ module = btConfig().getDefaultSwordModuleByType( "standardHebrewStrongsLexicon" );
break;
-
case ReferenceManager::StrongsGreek:
- module = CBTConfig::get(CBTConfig::standardGreekStrongsLexicon);
+ module = btConfig().getDefaultSwordModuleByType( "standardGreekStrongsLexicon" );
break;
-
case ReferenceManager::MorphHebrew:
- module = CBTConfig::get(CBTConfig::standardHebrewMorphLexicon);
+ module = btConfig().getDefaultSwordModuleByType( "standardHebrewMorphLexicon" );
break;
-
case ReferenceManager::MorphGreek:
- module = CBTConfig::get(CBTConfig::standardGreekMorphLexicon);
+ module = btConfig().getDefaultSwordModuleByType( "standardGreekMorphLexicon" );
break;
-
default:
module = 0;
break;
@@ -353,18 +348,18 @@ const QString ReferenceManager::parseVerseReference( const QString& ref, const R
// 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++) {
+ for (QStringList::iterator it = refList.begin(); it != refList.end(); ++it) {
//The listkey may contain more than one item, because a ref lik "Gen 1:3,5" is parsed into two single refs
- sword::ListKey lk = dummy.ParseVerseList((*it).toUtf8().constData(), baseKey.key().toUtf8().constData(), true);
- Q_ASSERT(!dummy.Error());
+ sword::ListKey lk = dummy.parseVerseList((*it).toUtf8().constData(), baseKey.key().toUtf8().constData(), true);
+ Q_ASSERT(!dummy.popError());
//Q_ASSERT(lk.Count());
- if (!lk.Count()) {
+ if (!lk.getCount()) {
ret.append( *it ); //don't change the original
continue;
}
- for (int i = 0; i < lk.Count(); ++i) {
+ for (int i = 0; i < lk.getCount(); ++i) {
if (dynamic_cast<sword::VerseKey*>(lk.getElement(i))) { // a range
sword::VerseKey* k = dynamic_cast<sword::VerseKey*>(lk.getElement(i));
Q_ASSERT(k);
diff --git a/src/backend/managers/referencemanager.h b/src/backend/managers/referencemanager.h
index a07b480..80d00d6 100644
--- a/src/backend/managers/referencemanager.h
+++ b/src/backend/managers/referencemanager.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/backend/rendering/cbookdisplay.cpp b/src/backend/rendering/cbookdisplay.cpp
index 6589e99..e139c6f 100644
--- a/src/backend/rendering/cbookdisplay.cpp
+++ b/src/backend/rendering/cbookdisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/backend/rendering/cbookdisplay.h b/src/backend/rendering/cbookdisplay.h
index 4bd5c22..6ed1bba 100644
--- a/src/backend/rendering/cbookdisplay.h
+++ b/src/backend/rendering/cbookdisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/backend/rendering/cchapterdisplay.cpp b/src/backend/rendering/cchapterdisplay.cpp
index eea2a72..e4fd1a1 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -42,13 +42,13 @@ const QString Rendering::CChapterDisplay::text(
Q_ASSERT((module->type() == CSwordModuleInfo::Bible));
if (module->type() == CSwordModuleInfo::Bible) {
- ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
+ ((sword::VerseKey*)(module->module()->getKey()))->setIntros(true); //HACK: enable headings for VerseKeys
Q_ASSERT(dynamic_cast<const CSBMI*>(module) != 0);
const CSBMI *bible = static_cast<const CSBMI*>(module);
CSwordVerseKey k1(module);
- k1.Headings(1);
+ k1.setIntros(true);
k1.setKey(keyName);
if (k1.getChapter() == 1)
diff --git a/src/backend/rendering/cchapterdisplay.h b/src/backend/rendering/cchapterdisplay.h
index c245c57..b19f103 100644
--- a/src/backend/rendering/cchapterdisplay.h
+++ b/src/backend/rendering/cchapterdisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/backend/rendering/cdisplayrendering.cpp b/src/backend/rendering/cdisplayrendering.cpp
index bd5aa87..cbcc046 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,6 +15,7 @@
#include "backend/keys/cswordversekey.h"
#include "backend/managers/cdisplaytemplatemgr.h"
#include "backend/managers/referencemanager.h"
+#include "backend/config/btconfig.h"
namespace Rendering {
@@ -33,7 +34,7 @@ QString CDisplayRendering::entryLink(const KeyTreeItem &item,
const bool isBible = module && (module->type() == CSwordModuleInfo::Bible);
CSwordVerseKey vk(module); //only valid for bible modules, i.e. isBible == true
- vk.Headings(true);
+ vk.setIntros(true);
if (isBible) {
vk.setKey(item.key());
diff --git a/src/backend/rendering/cdisplayrendering.h b/src/backend/rendering/cdisplayrendering.h
index 362fc2a..da87b79 100644
--- a/src/backend/rendering/cdisplayrendering.h
+++ b/src/backend/rendering/cdisplayrendering.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,6 +13,7 @@
#define RENDERINGCDISPLAYRENDERING_H
#include "backend/rendering/chtmlexportrendering.h"
+#include "backend/config/btconfig.h"
namespace Rendering {
@@ -27,8 +30,8 @@ class CDisplayRendering : public CHTMLExportRendering {
static QString keyToHTMLAnchor(const QString &key);
CDisplayRendering(
- const DisplayOptions &displayOptions = CBTConfig::getDisplayOptionDefaults(),
- const FilterOptions &filterOptions = CBTConfig::getFilterOptionDefaults());
+ const DisplayOptions &displayOptions = btConfig().getDisplayOptions(),
+ const FilterOptions &filterOptions = btConfig().getFilterOptions());
protected: /* Methods: */
diff --git a/src/backend/rendering/centrydisplay.cpp b/src/backend/rendering/centrydisplay.cpp
index 7415eda..3dbe63f 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +12,6 @@
#include <QApplication>
#include <QRegExp>
-#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordbookmoduleinfo.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
@@ -40,10 +39,10 @@ const QString CEntryDisplay::text(
//in Bibles and Commentaries we need to check if 0:0 and X:0 contain something
if (module->type() == CSwordModuleInfo::Bible || module->type() == CSwordModuleInfo::Commentary) {
- ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
+ ((sword::VerseKey*)(module->module()->getKey()))->setIntros(true); //HACK: enable headings for VerseKeys
CSwordVerseKey k1(module);
- k1.Headings(1);
+ k1.setIntros(true);
k1.setKey(keyName);
// don't print the key
diff --git a/src/backend/rendering/centrydisplay.h b/src/backend/rendering/centrydisplay.h
index 50b6447..8773eb7 100644
--- a/src/backend/rendering/centrydisplay.h
+++ b/src/backend/rendering/centrydisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,7 +16,7 @@
// Sword includes:
#include <swdisp.h>
-
+#include <swmodule.h>
class CSwordModuleInfo;
struct DisplayOptions;
@@ -35,6 +37,8 @@ class CEntryDisplay: public sword::SWDisplay {
const DisplayOptions &displayOptions,
const FilterOptions &filterOptions);
+ virtual char display(sword::SWModule& mod) { (void)mod; return 'c';}
+
}; /* class CEntryDisplay */
} /* namespace Rendering */
diff --git a/src/backend/rendering/chtmlexportrendering.cpp b/src/backend/rendering/chtmlexportrendering.cpp
index 0e19897..7c467b1 100644
--- a/src/backend/rendering/chtmlexportrendering.cpp
+++ b/src/backend/rendering/chtmlexportrendering.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -65,7 +65,7 @@ QString CHTMLExportRendering::renderEntry(const KeyTreeItem& i, CSwordKey* k) {
ret.append(i.getAlternativeContent());
// Q_ASSERT(i.hasChildItems());
-
+
if (!i.childList()->isEmpty()) {
const KeyTree & tree = *i.childList();
@@ -97,7 +97,7 @@ QString CHTMLExportRendering::renderEntry(const KeyTreeItem& i, CSwordKey* k) {
CSwordVerseKey* myVK = dynamic_cast<CSwordVerseKey*>(key);
if (myVK) {
- myVK->Headings(1);
+ myVK->setIntros(true);
}
QString renderedText( (modules.count() > 1) ? "\n\t\t<tr>\n" : "\n" );
@@ -128,9 +128,9 @@ QString CHTMLExportRendering::renderEntry(const KeyTreeItem& i, CSwordKey* k) {
}
else {
langAttr = QString("xml:lang=\"")
- .append((*mod_Itr)->module()->Lang())
+ .append((*mod_Itr)->module()->getLanguage())
.append("\" lang=\"")
- .append((*mod_Itr)->module()->Lang())
+ .append((*mod_Itr)->module()->getLanguage())
.append("\"");
}
@@ -139,7 +139,7 @@ QString CHTMLExportRendering::renderEntry(const KeyTreeItem& i, CSwordKey* k) {
if (m_filterOptions.headings) {
// only process EntryAttributes, do not render, this might destroy the EntryAttributes again
- (*mod_Itr)->module()->RenderText(0, -1, 0);
+ (*mod_Itr)->module()->renderText(0, -1, 0);
sword::AttributeValue::const_iterator it =
(*mod_Itr)->module()->getEntryAttributes()["Heading"]["Preverse"].begin();
@@ -150,12 +150,16 @@ QString CHTMLExportRendering::renderEntry(const KeyTreeItem& i, CSwordKey* k) {
QString unfiltered = QString::fromUtf8(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;
+ QRegExp filter("(.*)<title[^>]*>(.*)</title>(.*)");
+ while(filter.indexIn(unfiltered) >= 0) {
+ unfiltered = filter.cap(1) + filter.cap(2) + filter.cap(3);
+ }
+ // Fiter out offending self-closing div tags, which are bad HTML
+ QRegExp ofilter("(.*)<div[^>]*/>(.*)");
+ while(ofilter.indexIn(unfiltered) >= 0) {
+ unfiltered = ofilter.cap(1) + ofilter.cap(2);
}
+ preverseHeading = unfiltered;
/// \todo Take care of the heading type!
if (!preverseHeading.isEmpty()) {
@@ -237,7 +241,9 @@ QString CHTMLExportRendering::finishText(const QString &text, const KeyTree &tre
settings.langAbbrev = "unknown";
}
- return CDTM::instance()->fillTemplate(QObject::tr("Export"), text, settings);
+ return CDTM::instance()->fillTemplate(CDisplayTemplateMgr::activeTemplateName(),
+ text,
+ settings);
}
/*!
diff --git a/src/backend/rendering/chtmlexportrendering.h b/src/backend/rendering/chtmlexportrendering.h
index db90707..51041a3 100644
--- a/src/backend/rendering/chtmlexportrendering.h
+++ b/src/backend/rendering/chtmlexportrendering.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +14,7 @@
#include "backend/rendering/ctextrendering.h"
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/managers/cswordbackend.h"
#include "btglobal.h"
@@ -31,8 +33,10 @@ class CHTMLExportRendering: public CTextRendering {
CHTMLExportRendering(
bool addText,
- const DisplayOptions &displayOptions = CBTConfig::getDisplayOptionDefaults(),
- const FilterOptions &filterOptions = CBTConfig::getFilterOptionDefaults());
+ const DisplayOptions &displayOptions = btConfig().getDisplayOptions(),
+ const FilterOptions &filterOptions = btConfig().getFilterOptions());
+
+ ~CHTMLExportRendering() {};
protected: /* Methods: */
diff --git a/src/backend/rendering/cplaintextexportrendering.cpp b/src/backend/rendering/cplaintextexportrendering.cpp
index 4bff025..e462e53 100644
--- a/src/backend/rendering/cplaintextexportrendering.cpp
+++ b/src/backend/rendering/cplaintextexportrendering.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/backend/rendering/cplaintextexportrendering.h b/src/backend/rendering/cplaintextexportrendering.h
index 9360474..45ad8ac 100644
--- a/src/backend/rendering/cplaintextexportrendering.h
+++ b/src/backend/rendering/cplaintextexportrendering.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,6 +13,7 @@
#define RENDERINGCPLAINTEXTEXPORTRENDERING_H
#include "backend/rendering/chtmlexportrendering.h"
+#include "backend/config/btconfig.h"
namespace Rendering {
@@ -26,8 +29,8 @@ class CPlainTextExportRendering: public CHTMLExportRendering {
CPlainTextExportRendering(
bool addText,
- const DisplayOptions &displayOptions = CBTConfig::getDisplayOptionDefaults(),
- const FilterOptions &filterOptions = CBTConfig::getFilterOptionDefaults());
+ const DisplayOptions &displayOptions = btConfig().getDisplayOptions(),
+ const FilterOptions &filterOptions = btConfig().getFilterOptions());
protected: /* Methods: */
diff --git a/src/backend/rendering/ctextrendering.cpp b/src/backend/rendering/ctextrendering.cpp
index 72e4e12..409a601 100644
--- a/src/backend/rendering/ctextrendering.cpp
+++ b/src/backend/rendering/ctextrendering.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -136,19 +136,19 @@ CTextRendering::KeyTreeItem::KeyTreeItem(const QString &startKey,
else {
sword::VerseKey vk(startKey.toUtf8().constData(), stopKey.toUtf8().constData());
- if (vk.LowerBound().getBook() != vk.UpperBound().getBook()) {
+ if (vk.getLowerBound().getBook() != vk.getUpperBound().getBook()) {
m_alternativeContent = QString::fromUtf8(vk.getRangeText());
}
- else if (vk.LowerBound().getChapter() != vk.UpperBound().getChapter()) {
+ else if (vk.getLowerBound().getChapter() != vk.getUpperBound().getChapter()) {
m_alternativeContent = QString("%1 - %2:%3")
- .arg(QString::fromUtf8(vk.LowerBound().getText()))
- .arg(vk.UpperBound().getChapter())
- .arg(vk.UpperBound().getVerse());
+ .arg(QString::fromUtf8(vk.getLowerBound().getText()))
+ .arg(vk.getUpperBound().getChapter())
+ .arg(vk.getUpperBound().getVerse());
}
else { //only verses differ (same book, same chapter)
m_alternativeContent = QString("%1 - %2")
- .arg(QString::fromUtf8(vk.LowerBound().getText()))
- .arg(vk.UpperBound().getVerse());
+ .arg(QString::fromUtf8(vk.getLowerBound().getText()))
+ .arg(vk.getUpperBound().getVerse());
}
}
@@ -231,8 +231,8 @@ const QString CTextRendering::renderKeyRange(
CSwordVerseKey* vk_stop = dynamic_cast<CSwordVerseKey*>(upperBound.data());
Q_ASSERT(vk_stop);
- bool ok = true;
- while (ok && ((*vk_start < *vk_stop) || (*vk_start == *vk_stop))) {
+ while ((*vk_start < *vk_stop) || (*vk_start == *vk_stop)) {
+
//make sure the key given by highlightKey gets marked as current key
settings.highlight = (!highlightKey.isEmpty() ? (vk_start->key() == highlightKey) : false);
@@ -249,7 +249,10 @@ const QString CTextRendering::renderKeyRange(
vk_start->setVerse(0);
}
tree.append( new KeyTreeItem(vk_start->key(), modules, settings) );
- ok = vk_start->next(CSwordVerseKey::UseVerse);
+ if (!vk_start->next(CSwordVerseKey::UseVerse)) {
+ /// \todo Notify the user about this failure.
+ break;
+ }
}
return renderKeyTree(tree);
}
diff --git a/src/backend/rendering/ctextrendering.h b/src/backend/rendering/ctextrendering.h
index 9d467cc..c62a877 100644
--- a/src/backend/rendering/ctextrendering.h
+++ b/src/backend/rendering/ctextrendering.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -134,7 +136,7 @@ class CTextRendering {
public: /* Methods: */
- virtual inline ~CTextRendering() {}
+ virtual ~CTextRendering() {};
const QString renderKeyTree(const KeyTree &tree);
diff --git a/src/bibletime.cpp b/src/bibletime.cpp
index 72cb4cd..95461e5 100644
--- a/src/bibletime.cpp
+++ b/src/bibletime.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,10 +16,9 @@
#include <QDebug>
#include <QInputDialog>
#include <QMdiSubWindow>
-#include <QMessageBox>
#include <QSplashScreen>
#include <QSplitter>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordbiblemoduleinfo.h"
#include "backend/drivers/cswordbookmoduleinfo.h"
#include "backend/drivers/cswordcommentarymoduleinfo.h"
@@ -27,21 +26,22 @@
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/keys/cswordldkey.h"
#include "backend/keys/cswordversekey.h"
+#include "bibletimeapp.h"
#include "frontend/btaboutmoduledialog.h"
#include "frontend/cmdiarea.h"
+#include "frontend/display/btfindwidget.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/cdisplaywindow.h"
#include "frontend/displaywindow/cdisplaywindowfactory.h"
#include "frontend/displaywindow/creadwindow.h"
-#include "frontend/displaywindow/cwritewindow.h"
#include "frontend/keychooser/ckeychooser.h"
+#include "frontend/messagedialog.h"
#include "frontend/searchdialog/csearchdialog.h"
#include "util/cresmgr.h"
#include "util/directory.h"
+#include "util/geticon.h"
-using namespace Profile;
-
BibleTime *BibleTime::m_instance = 0;
BibleTime::BibleTime(QWidget *parent, Qt::WindowFlags flags)
@@ -55,14 +55,15 @@ BibleTime::BibleTime(QWidget *parent, Qt::WindowFlags flags)
QSplashScreen *splash = 0;
QString splashHtml;
- if (CBTConfig::get(CBTConfig::logo)) {
+ if (btConfig().value<bool>("GUI/showSplashScreen", true)) {
splashHtml = "<div style='background:transparent;color:white;font-weight:bold'>%1"
"</div>";
+ static const char splash1[] = "startuplogo.png";
+ static const char splash2[] = "startuplogo_christmas.png";
+ static const char splash3[] = "startuplogo_easter.jpg";
static const char * const splashes[3] = {
- "startuplogo.png",
- "startuplogo_christmas.png",
- "startuplogo_easter.jpg"
+ splash1, splash2, splash3
};
QString splashImage = DU::getPicsDir().canonicalPath().append("/")
.append(splashes[rand() % 3]);
@@ -98,7 +99,7 @@ BibleTime::BibleTime(QWidget *parent, Qt::WindowFlags flags)
initConnections();
setWindowTitle("BibleTime " BT_VERSION);
- setWindowIcon(DU::getIcon(CResMgr::mainWindow::icon));
+ setWindowIcon(util::getIcon(CResMgr::mainWindow::icon));
retranslateUi();
}
@@ -108,10 +109,7 @@ BibleTime::~BibleTime() {
#ifdef BT_DEBUG
deleteDebugWindow();
#endif
- CProfile* p = m_profileMgr.startupProfile();
- if (p) {
- saveProfile(p);
- }
+ saveProfile();
}
/** Creates a new presenter in the MDI area according to the type of the module. */
@@ -144,7 +142,7 @@ CDisplayWindow* BibleTime::createReadDisplayWindow(CSwordModuleInfo* module, con
return createReadDisplayWindow(list, key);
}
-CDisplayWindow* BibleTime::createWriteDisplayWindow(CSwordModuleInfo* module, const QString& key, const CWriteWindow::WriteWindowType& type) {
+CDisplayWindow * BibleTime::createWriteDisplayWindow(CSwordModuleInfo * module, const QString & key, CPlainWriteWindow::WriteWindowType type) {
qApp->setOverrideCursor( QCursor(Qt::WaitCursor) );
QList<CSwordModuleInfo*> modules;
@@ -169,14 +167,14 @@ CDisplayWindow* BibleTime::moduleEditPlain(CSwordModuleInfo *module) {
/// \todo Refactor this.
return createWriteDisplayWindow(module,
QString::null,
- CWriteWindow::PlainTextWindow);
+ CPlainWriteWindow::PlainTextWindow);
}
CDisplayWindow* BibleTime::moduleEditHtml(CSwordModuleInfo *module) {
/// \todo Refactor this.
return createWriteDisplayWindow(module,
QString::null,
- CWriteWindow::HTMLWindow);
+ CPlainWriteWindow::HTMLWindow);
}
@@ -213,7 +211,7 @@ bool BibleTime::moduleUnlock(CSwordModuleInfo *module, QWidget *parent) {
}
if (!module->isLocked()) break;
- QMessageBox::warning(parent, tr("Warning: Invalid unlock key!"),
+ message::showWarning(parent, tr("Warning: Invalid unlock key!"),
tr("The unlock key you provided did not properly unlock this "
"module. Please try again."));
}
@@ -242,7 +240,7 @@ void BibleTime::refreshDisplayWindows() const {
/** Refresh main window accelerators */
void BibleTime::refreshBibleTimeAccel() {
- CBTConfig::setupAccelSettings(CBTConfig::application, m_actionCollection);
+ m_actionCollection->readShortcuts("Application shortcuts");
}
void BibleTime::closeEvent(QCloseEvent *event) {
@@ -263,29 +261,26 @@ void BibleTime::closeEvent(QCloseEvent *event) {
}
void BibleTime::processCommandline(bool ignoreSession, const QString &bibleKey) {
- if (CBTConfig::get(CBTConfig::crashedTwoTimes)) {
+ if (btConfig().value<bool>("state/crashedTwoTimes", false)) {
return;
}
// Restore workspace if not not ignoring session data:
- if (!ignoreSession) {
- CProfile * p = m_profileMgr.startupProfile();
- if (p)
- loadProfile(p);
- }
+ if (!ignoreSession)
+ reloadProfile();
- if (CBTConfig::get(CBTConfig::crashedLastTime)) {
+ if (btConfig().value<bool>("state/crashedLastTime", false)) {
return;
}
if (!bibleKey.isNull()) {
- CSwordModuleInfo* bible = CBTConfig::get(CBTConfig::standardBible);
+ CSwordModuleInfo* bible = btConfig().getDefaultSwordModuleByType("standardBible");
if (bibleKey == "random") {
CSwordVerseKey vk(0);
const int maxIndex = 31100;
int newIndex = rand() % maxIndex;
vk.setPosition(sword::TOP);
- vk.Index(newIndex);
+ vk.setIndex(newIndex);
createReadDisplayWindow(bible, vk.key());
} else {
createReadDisplayWindow(bible, bibleKey);
@@ -297,6 +292,14 @@ void BibleTime::processCommandline(bool ignoreSession, const QString &bibleKey)
*/
m_mdi->myTileVertical();
}
+
+ if (btConfig().value<bool>("state/crashedLastTime", false)) {
+ btConfig().setValue("state/crashedTwoTimes", true);
+ }
+ else {
+ btConfig().setValue("state/crashedLastTime", true);
+ }
+ btConfig().sync();
}
bool BibleTime::event(QEvent* event) {
@@ -304,3 +307,19 @@ bool BibleTime::event(QEvent* event) {
Search::CSearchDialog::closeDialog();
return QMainWindow::event(event);
}
+
+const CSwordModuleInfo* BibleTime::getCurrentModule() {
+ QMdiSubWindow* activeSubWindow = m_mdi->activeSubWindow();
+ if (!activeSubWindow)
+ return 0;
+ CDisplayWindow* w = dynamic_cast<CDisplayWindow*>(activeSubWindow->widget());
+ if (!w)
+ return 0;
+ return w->modules().first();
+}
+
+void BibleTime::openFindWidget()
+{
+ m_findWidget->setVisible(true);
+ m_findWidget->showAndSelect();
+}
diff --git a/src/bibletime.h b/src/bibletime.h
index 22faac2..5712515 100644
--- a/src/bibletime.h
+++ b/src/bibletime.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,8 +16,7 @@
#include <QList>
#include "frontend/displaywindow/cdisplaywindow.h"
-#include "frontend/displaywindow/cwritewindow.h"
-#include "frontend/profile/cprofilemgr.h"
+#include "frontend/displaywindow/cplainwritewindow.h"
#include <QSignalMapper>
#ifdef BT_DEBUG
#include <QMutex>
@@ -27,6 +28,7 @@ class CInfoDisplay;
}
class BtActionClass;
class BtBookshelfDockWidget;
+class BtFindWidget;
class BtOpenWorkAction;
class CBookmarkIndex;
class CDisplayWindow;
@@ -34,7 +36,9 @@ class CMDIArea;
class CSwordModuleInfo;
class QAction;
class QLabel;
+class QMdiSubWindow;
class QMenu;
+class QActionGroup;
class QToolBar;
class QSplitter;
class QSignalMapper;
@@ -136,14 +140,6 @@ class BibleTime : public QMainWindow {
static inline BibleTime *instance() { return m_instance; }
/**
- * Apply the settings given by the profile p
- */
- void applyProfileSettings( Profile::CProfile* p );
- /**
- * Stores the settings of the mainwindow in the profile p
- */
- void storeProfileSettings( Profile::CProfile* p );
- /**
* Save the configuration dialog settings, don't open dialog
*/
void saveConfigSettings();
@@ -194,7 +190,17 @@ class BibleTime : public QMainWindow {
*/
static bool moduleUnlock(CSwordModuleInfo *module, QWidget *parent = 0);
- public slots:
+ /**
+ Get a pointer to the module associated with the current window
+ */
+ const CSwordModuleInfo* getCurrentModule();
+
+ /**
+ Open the BtFindWidget below the mdi area
+ */
+ void openFindWidget();
+
+public slots:
/**
* Opens the optionsdialog of BibleTime.
*/
@@ -240,6 +246,10 @@ class BibleTime : public QMainWindow {
*/
void createMenuAndToolBar();
/**
+ Creates mdi and and BtFindWidget
+ */
+ void createCentralWidget();
+ /**
* Initializes the sword.conf in the $HOME\Sword directory
*/
void initSwordConfigFile();
@@ -300,7 +310,7 @@ 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 CWriteWindow::WriteWindowType& type);
+ CDisplayWindow* createWriteDisplayWindow(CSwordModuleInfo * module, const QString & key, CPlainWriteWindow::WriteWindowType type);
CDisplayWindow* moduleEditPlain(CSwordModuleInfo *module);
CDisplayWindow* moduleEditHtml(CSwordModuleInfo *module);
void searchInModule(CSwordModuleInfo *module);
@@ -316,35 +326,13 @@ class BibleTime : public QMainWindow {
* Is called when the open windows menu is about to show ;-)
*/
void slotOpenWindowsMenuAboutToShow();
- /**
- * This slot is connected with the windowAutoTileVerticalAction object
- */
- void slotAutoTileVertical();
- /**
- * This slot is connected with the windowAutoTileHorizontalAction object
- */
- void slotAutoTileHorizontal();
- /**
- * This slot is connected with the windowAutoTileAction object
- */
- void slotAutoTile();
- /**
- * This slot is connected with the windowAutoTabbedAction object
- */
- void slotAutoTabbed();
- /**
- * This slot is connected with the windowAutoCascadeAction object
- */
- void slotAutoCascade();
- void slotUpdateWindowArrangementActions( QAction* );
+ void slotUpdateWindowArrangementActions(QAction * trigerredAction);
void slotCascade();
void slotTile();
void slotTileVertical();
void slotTileHorizontal();
- void slotManualArrangementMode();
-
/**
* Shows/hides the main toolbar
*/
@@ -367,13 +355,13 @@ class BibleTime : public QMainWindow {
*/
void slotSetActiveSubWindow(QWidget* window);
/**
- * Saves to the profile with the menu id ID
- */
- void saveProfile(QAction* action);
+ * The active window was changed
+ */
+ void slotActiveWindowChanged(QMdiSubWindow* window);
/**
- * Saves the current settings into the currently activatred profile.
+ * Saves the current settings into the currently activated profile.
*/
- void saveProfile(Profile::CProfile* p);
+ void saveProfile();
/**
* Deletes the chosen session from the menu and from disk.
*/
@@ -381,11 +369,15 @@ class BibleTime : public QMainWindow {
/**
* Loads the profile with the menu id ID
*/
- void loadProfile(QAction* action);
+ void loadProfile(QAction * action);
+ /**
+ * Loads the profile with the given key
+ */
+ void loadProfile(const QString & profileKey);
/**
- * Loads the profile with the menu ID id
+ * Reloads the current profile
*/
- void loadProfile(Profile::CProfile* p);
+ void reloadProfile();
/**
* Toggles between normal and fullscreen mode.
*/
@@ -474,6 +466,7 @@ class BibleTime : public QMainWindow {
QAction *m_windowTileVerticalAction;
QAction *m_windowManualModeAction;
QMenu *m_windowArrangementMenu;
+ QActionGroup *m_windowArrangementActionGroup;
QAction *m_windowAutoCascadeAction;
QAction *m_windowAutoTileAction;
QAction *m_windowAutoTabbedAction;
@@ -481,6 +474,10 @@ class BibleTime : public QMainWindow {
QAction *m_windowAutoTileHorizontalAction;
QAction *m_windowCloseAction;
QAction *m_windowCloseAllAction;
+ QAction* m_windowSaveToNewProfileAction;
+ QMenu* m_windowLoadProfileMenu;
+ QActionGroup* m_windowLoadProfileActionGroup;
+ QMenu* m_windowDeleteProfileMenu;
// Settings menu:
QMenu *m_settingsMenu;
@@ -496,10 +493,7 @@ class BibleTime : public QMainWindow {
BtActionCollection* m_actionCollection;
- QMenu* m_windowSaveProfileMenu;
- QAction* m_windowSaveToNewProfileAction;
- QMenu* m_windowLoadProfileMenu;
- QMenu* m_windowDeleteProfileMenu;
+
QAction* m_windowFullscreenAction;
/**
@@ -510,8 +504,7 @@ class BibleTime : public QMainWindow {
// QList<QAction*> m_windowOpenWindowsList;
CMDIArea* m_mdi;
-
- Profile::CProfileMgr m_profileMgr;
+ BtFindWidget* m_findWidget;
protected: //DBUS interface implementation
@@ -532,7 +525,12 @@ class BibleTime : public QMainWindow {
void syncAllModulesByType(const CSwordModuleInfo::ModuleType type, const QString& key);
private:
+ /**
+ * Set the visibility of all tool bars according to the configuration
+ * taking the toolbarsInEachWindow setting into account.
+ */
void showOrHideToolBars();
+
#ifdef BT_DEBUG
void deleteDebugWindow();
private slots:
diff --git a/src/bibletime_dbus.cpp b/src/bibletime_dbus.cpp
index 9b983c1..6beb7fd 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -32,7 +32,6 @@ void BibleTime::syncAllModulesByType(const CSwordModuleInfo::ModuleType type, co
void BibleTime::closeAllModuleWindows() {
m_mdi->closeAllSubWindows();
}
-
QStringList BibleTime::searchInModule(const QString& moduleName, const QString& searchText) {
QStringList ret;
CSwordModuleInfo* mod = CSwordBackend::instance()->findModuleByName(moduleName);
@@ -46,7 +45,7 @@ QStringList BibleTime::searchInModule(const QString& moduleName, const QString&
const QString lead = QString("[%1] ").arg(moduleName);
- for ( int i = 0; i < result.Count(); ++i ) {
+ for (int i = 0; i < result.getCount(); i++) {
sword::SWKey* key = result.getElement(i);
Q_ASSERT(key);
diff --git a/src/bibletime_dbus_adaptor.cpp b/src/bibletime_dbus_adaptor.cpp
index 6912ff1..b393a11 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +12,7 @@
#include "bibletime_dbus_adaptor.h"
#include <QDebug>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
BibleTimeDBusAdaptor::BibleTimeDBusAdaptor(BibleTime *pBibleTime)
: QDBusAbstractAdaptor(pBibleTime)
@@ -50,7 +50,7 @@ void BibleTimeDBusAdaptor::openWindow(const QString &moduleName, const QString &
void BibleTimeDBusAdaptor::openDefaultBible(const QString &key) {
qDebug() << "DBUS: open default bible ...";
- CSwordModuleInfo *module = CBTConfig::get(CBTConfig::standardBible);
+ CSwordModuleInfo *module = btConfig().getDefaultSwordModuleByType("standardBible");
if (module)
m_bibletime->createReadDisplayWindow(module, key);
}
@@ -77,7 +77,7 @@ QStringList BibleTimeDBusAdaptor::searchInOpenModules(const QString &searchText)
QStringList BibleTimeDBusAdaptor::searchInDefaultBible(const QString &searchText) {
qDebug() << "DBUS: search in default bible ...";
- CSwordModuleInfo *bible = CBTConfig::get(CBTConfig::standardBible);
+ CSwordModuleInfo *bible = btConfig().getDefaultSwordModuleByType("standardBible");
return m_bibletime->searchInModule(bible->name(), searchText);
}
diff --git a/src/bibletime_dbus_adaptor.h b/src/bibletime_dbus_adaptor.h
index 65c5c7b..cf7200c 100644
--- a/src/bibletime_dbus_adaptor.h
+++ b/src/bibletime_dbus_adaptor.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/bibletime_init.cpp b/src/bibletime_init.cpp
index df8fdea..7a3c5b7 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,20 +20,24 @@
#include <QToolBar>
#include <QToolButton>
#include <QVBoxLayout>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/managers/btstringmgr.h"
#include "backend/managers/clanguagemgr.h"
#include "backend/managers/cswordbackend.h"
+#include "bibletimeapp.h"
#include "frontend/btbookshelfdockwidget.h"
#include "frontend/btopenworkaction.h"
#include "frontend/cinfodisplay.h"
#include "frontend/cmdiarea.h"
#include "frontend/cprinter.h"
+#include "frontend/display/btfindwidget.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/btmodulechooserbar.h"
#include "frontend/bookmarks/cbookmarkindex.h"
+#include "frontend/settingsdialogs/btlanguagesettings.h"
#include "util/cresmgr.h"
#include "util/directory.h"
+#include "util/geticon.h"
// Sword includes:
#include <swlog.h>
@@ -47,7 +51,6 @@
using namespace InfoDisplay;
-using namespace Profile;
/**Initializes the view of this widget*/
void BibleTime::initView() {
@@ -55,8 +58,7 @@ void BibleTime::initView() {
// Create menu and toolbar before the mdi area
createMenuAndToolBar();
- m_mdi = new CMDIArea(this);
- setCentralWidget(m_mdi);
+ createCentralWidget();
m_bookshelfDock = new BtBookshelfDockWidget(this);
addDockWidget(Qt::LeftDockWidgetArea, m_bookshelfDock);
@@ -85,11 +87,9 @@ void BibleTime::initView() {
QAction* BibleTime::initAction(QAction* action, QString text, QString icon,
QKeySequence accel, const QString& tooltip,
const QString& actionName, const char* slot) {
- namespace DU = util::directory;
-
action->setText(text);
if ( ! icon.isEmpty() )
- action->setIcon(DU::getIcon(icon));
+ action->setIcon(util::getIcon(icon));
action->setShortcut(accel);
if (tooltip != QString::null) action->setToolTip(tooltip);
m_actionCollection->addAction(actionName, action);
@@ -100,18 +100,16 @@ QAction* BibleTime::initAction(QAction* action, QString text, QString icon,
// Creates QAction's for all actions that can have keyboard shortcuts
// Used in creating the main window and by the configuration dialog for setting shortcuts
void BibleTime::insertKeyboardActions( BtActionCollection* const a ) {
- namespace DU = util::directory;
-
QAction* action = new QAction(a);
action->setText(tr("&Quit"));
- action->setIcon(DU::getIcon("exit.svg"));
+ action->setIcon(util::getIcon("exit.svg"));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
action->setToolTip(tr("Quit BibleTime"));
a->addAction("quit", action);
action = new QAction(a);
action->setText(tr("&Fullscreen mode"));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::window::showFullscreen::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::window::showFullscreen::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::window::showFullscreen::accel));
action->setToolTip(tr("Toggle fullscreen mode of the main window"));
a->addAction("toggleFullscreen", action);
@@ -123,132 +121,132 @@ void BibleTime::insertKeyboardActions( BtActionCollection* const a ) {
action = new QAction(a);
action->setText(tr("Search in &open works..."));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::mainIndex::search::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::mainIndex::search::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::mainIndex::search::accel));
action->setToolTip(tr("Search in all works that are currently open"));
a->addAction("searchOpenWorks", action);
action = new QAction(a);
action->setText(tr("Search in standard &Bible..."));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::mainIndex::searchdefaultbible::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::mainIndex::searchdefaultbible::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::mainIndex::searchdefaultbible::accel));
action->setToolTip(tr("Search in the standard Bible"));
a->addAction("searchStdBible", action);
action = new QAction(a);
action->setText(tr("Save as &new session..."));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::window::saveToNewProfile::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::window::saveToNewProfile::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::window::saveToNewProfile::accel));
action->setToolTip(tr("Create and save a new session"));
a->addAction("saveNewSession", action);
action = new QAction(a);
action->setText(tr("&Manual mode"));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::window::arrangementMode::manual::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::window::arrangementMode::manual::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::window::arrangementMode::manual::accel));
action->setToolTip(tr("Manually arrange the open windows"));
a->addAction("manualArrangement", action);
action = new QAction(a);
action->setText(tr("Auto-tile &vertically"));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTileVertical::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTileVertical::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::window::arrangementMode::autoTileVertical::accel));
action->setToolTip(tr("Automatically tile the open windows vertically (arrange side by side)"));
a->addAction("autoVertical", action);
action = new QAction(a);
action->setText(tr("Auto-tile &horizontally"));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTileHorizontal::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTileHorizontal::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::window::arrangementMode::autoTileHorizontal::accel));
action->setToolTip(tr("Automatically tile the open windows horizontally (arrange on top of each other)"));
a->addAction("autoHorizontal", action);
action = new QAction(a);
action->setText(tr("Auto-&tile"));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTile::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTile::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::window::arrangementMode::autoTile::accel));
action->setToolTip(tr("Automatically tile the open windows"));
a->addAction("autoTile", action);
action = new QAction(a);
action->setText(tr("Ta&bbed"));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTabbed::icon));
+ action->setIcon(util::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->setIcon(util::getIcon(CResMgr::mainMenu::window::arrangementMode::autoCascade::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::window::arrangementMode::autoCascade::accel));
action->setToolTip(tr("Automatically cascade the open windows"));
a->addAction("autoCascade", action);
action = new QAction(a);
action->setText(tr("&Cascade"));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::window::cascade::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::window::cascade::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::window::cascade::accel));
action->setToolTip(tr("Cascade the open windows"));
a->addAction("cascade", action);
action = new QAction(a);
action->setText(tr("&Tile"));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::window::tile::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::window::tile::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::window::tile::accel));
action->setToolTip(tr("Tile the open windows"));
a->addAction("tile", action);
action = new QAction(a);
action->setText(tr("Tile &vertically"));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::window::tileVertical::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::window::tileVertical::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::window::tileVertical::accel));
action->setToolTip(tr("Vertically tile (arrange side by side) the open windows"));
a->addAction("tileVertically", action);
action = new QAction(a);
action->setText(tr("Tile &horizontally"));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::window::tileHorizontal::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::window::tileHorizontal::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::window::tileHorizontal::accel));
action->setToolTip(tr("Horizontally tile (arrange on top of each other) the open windows"));
a->addAction("tileHorizontally", action);
action = new QAction(a);
action->setText(tr("Close &window"));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::window::close::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::window::close::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::window::close::accel));
action->setToolTip(tr("Close the current open window"));
a->addAction("closeWindow", action);
action = new QAction(a);
action->setText(tr("Cl&ose all windows"));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::window::closeAll::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::window::closeAll::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::window::closeAll::accel));
action->setToolTip(tr("Close all open windows inside BibleTime"));
a->addAction("closeAllWindows", action);
action = new QAction(a);
action->setText(tr("&Configure BibleTime..."));
- action->setIcon(DU::getIcon("configure.svg"));
+ action->setIcon(util::getIcon("configure.svg"));
action->setToolTip(tr("Set BibleTime's preferences"));
a->addAction("setPreferences", action);
action = new QAction(a);
action->setText(tr("Bookshelf &Manager..."));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::settings::swordSetupDialog::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::settings::swordSetupDialog::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::settings::swordSetupDialog::accel));
action->setToolTip(tr("Configure your bookshelf and install/update/remove/index works"));
a->addAction("bookshelfManager", action);
action = new QAction(a);
action->setText(tr("&Handbook"));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::help::handbook::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::help::handbook::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::help::handbook::accel));
action->setToolTip(tr("Open BibleTime's handbook"));
a->addAction("openHandbook", action);
action = new QAction(a);
action->setText(tr("&Bible Study Howto"));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::help::bibleStudyHowTo::icon));
+ action->setIcon(util::getIcon(CResMgr::mainMenu::help::bibleStudyHowTo::icon));
action->setShortcut(QKeySequence(CResMgr::mainMenu::help::bibleStudyHowTo::accel));
action->setToolTip(tr("Open the Bible study HowTo included with BibleTime.<br/>This HowTo is an introduction on how to study the Bible in an efficient way."));
a->addAction("bibleStudyHowto", action);
@@ -260,7 +258,7 @@ void BibleTime::insertKeyboardActions( BtActionCollection* const a ) {
action = new QAction(a);
action->setText(tr("&Tip of the day..."));
- action->setIcon(DU::getIcon(CResMgr::mainMenu::help::tipOfTheDay::icon));
+ action->setIcon(util::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);
@@ -321,7 +319,7 @@ void BibleTime::createMenuAndToolBar()
addToolBar(m_mainToolBar);
// Set visibility of main window toolbars based on config
- bool visible = ! CBTConfig::get(CBTConfig::showToolbarsInEachWindow);
+ bool visible = ! btConfig().sessionValue<bool>("GUI/showToolbarsInEachWindow", true);
m_navToolBar = createToolBar("NavToolBar", this, visible);
addToolBar(m_navToolBar);
@@ -338,6 +336,36 @@ void BibleTime::createMenuAndToolBar()
addToolBar(m_formatToolBar);
}
+void BibleTime::createCentralWidget()
+{
+ m_mdi = new CMDIArea(this);
+ m_findWidget = new BtFindWidget(this);
+ m_findWidget->setVisible(false);
+
+ QVBoxLayout* layout = new QVBoxLayout();
+ layout->addWidget(m_mdi);
+ layout->addWidget(m_findWidget);
+
+ QWidget* widget = new QWidget(this);
+ widget->setLayout(layout);
+ setCentralWidget(widget);
+
+ bool ok = connect(m_findWidget, SIGNAL(findNext(const QString&,bool)),
+ m_mdi, SLOT(findNextTextInActiveWindow(const QString &, bool)));
+ Q_ASSERT(ok);
+
+ ok = connect(m_findWidget, SIGNAL(findPrevious(const QString&,bool)),
+ m_mdi, SLOT(findPreviousTextInActiveWindow(const QString &, bool)));
+ Q_ASSERT(ok);
+ ok = connect(m_findWidget, SIGNAL(highlightText(const QString&,bool)),
+ m_mdi, SLOT(highlightTextInActiveWindow(const QString &, bool)));
+ Q_ASSERT(ok);
+
+ ok = connect(m_mdi, SIGNAL(subWindowActivated(QMdiSubWindow*)),
+ this, SLOT(slotActiveWindowChanged(QMdiSubWindow*)));
+ Q_ASSERT(ok);
+}
+
/** Initializes the action objects of the GUI */
void BibleTime::initActions() {
m_actionCollection = new BtActionCollection(this);
@@ -349,11 +377,13 @@ void BibleTime::initActions() {
this, SLOT(slotSetActiveSubWindow(QWidget*)));
// File menu actions:
- m_openWorkAction = new BtOpenWorkAction("GUI/MainWindow/OpenWorkAction/grouping", this);
+ m_openWorkAction = new BtOpenWorkAction("GUI/mainWindow/openWorkAction/grouping", this);
+ Q_ASSERT(m_openWorkAction != 0);
connect(m_openWorkAction, SIGNAL(triggered(CSwordModuleInfo*)),
this, SLOT(createReadDisplayWindow(CSwordModuleInfo*)));
m_quitAction = m_actionCollection->action("quit");
+ m_quitAction->setMenuRole(QAction::QuitRole);
Q_ASSERT(m_quitAction != 0);
connect(m_quitAction, SIGNAL(triggered()),
this, SLOT(quit()));
@@ -367,68 +397,68 @@ void BibleTime::initActions() {
this, SLOT(toggleFullscreen()));
// Special case these actions, overwrite those already in collection
- namespace DU = util::directory;
m_showBookshelfAction = m_bookshelfDock->toggleViewAction();
- m_showBookshelfAction->setIcon(DU::getIcon(CResMgr::mainMenu::view::showBookshelf::icon));
+ m_showBookshelfAction->setIcon(util::getIcon(CResMgr::mainMenu::view::showBookshelf::icon));
m_showBookshelfAction->setToolTip(tr("Toggle visibility of the bookshelf window"));
m_actionCollection->addAction("showBookshelf", m_showBookshelfAction);
m_showBookmarksAction = m_bookmarksDock->toggleViewAction();
- m_showBookmarksAction->setIcon(DU::getIcon(CResMgr::mainMenu::view::showBookmarks::icon));
+ m_showBookmarksAction->setIcon(util::getIcon(CResMgr::mainMenu::view::showBookmarks::icon));
m_showBookmarksAction->setToolTip(tr("Toggle visibility of the bookmarks window"));
m_actionCollection->addAction("showBookmarks", m_showBookmarksAction);
m_showMagAction = m_magDock->toggleViewAction();
- m_showMagAction->setIcon(DU::getIcon(CResMgr::mainMenu::view::showMag::icon));
+ m_showMagAction->setIcon(util::getIcon(CResMgr::mainMenu::view::showMag::icon));
m_showMagAction->setToolTip(tr("Toggle visibility of the mag window"));
m_actionCollection->addAction("showMag", m_showMagAction);
m_showTextAreaHeadersAction = m_actionCollection->action("showParallelTextHeaders");
Q_ASSERT(m_showTextAreaHeadersAction != 0);
m_showTextAreaHeadersAction->setCheckable(true);
- m_showTextAreaHeadersAction->setChecked(CBTConfig::get(CBTConfig::showTextWindowHeaders));
+ m_showTextAreaHeadersAction->setChecked(btConfig().sessionValue<bool>("GUI/showTextWindowHeaders", true));
connect(m_showTextAreaHeadersAction, SIGNAL(toggled(bool)),
this, SLOT(slotToggleTextWindowHeader()));
m_showMainWindowToolbarAction = m_actionCollection->action("showToolbar");
Q_ASSERT(m_showMainWindowToolbarAction != 0);
m_showMainWindowToolbarAction->setCheckable(true);
- m_showMainWindowToolbarAction->setChecked(CBTConfig::get(CBTConfig::showMainWindowToolbar));
+ m_showMainWindowToolbarAction->setChecked(btConfig().sessionValue<bool>("GUI/showMainToolbar", true));
connect( m_showMainWindowToolbarAction, SIGNAL(triggered()),
this, SLOT(slotToggleMainToolbar()));
m_showTextWindowNavigationAction = m_actionCollection->action("showNavigation");
Q_ASSERT(m_showTextWindowNavigationAction != 0);
m_showTextWindowNavigationAction->setCheckable(true);
- m_showTextWindowNavigationAction->setChecked(CBTConfig::get(CBTConfig::showTextWindowNavigator));
+ m_showTextWindowNavigationAction->setChecked(btConfig().sessionValue<bool>("GUI/showTextWindowNavigator", true));
connect(m_showTextWindowNavigationAction, SIGNAL(toggled(bool)),
this, SLOT(slotToggleNavigatorToolbar()));
m_showTextWindowModuleChooserAction = m_actionCollection->action("showWorks");
Q_ASSERT(m_showTextWindowModuleChooserAction != 0);
m_showTextWindowModuleChooserAction->setCheckable(true);
- m_showTextWindowModuleChooserAction->setChecked(CBTConfig::get(CBTConfig::showTextWindowModuleSelectorButtons));
+ m_showTextWindowModuleChooserAction->setChecked(btConfig().sessionValue<bool>("GUI/showTextWindowModuleSelectorButtons", true));
connect(m_showTextWindowModuleChooserAction, SIGNAL(toggled(bool)),
this, SLOT(slotToggleWorksToolbar()));
m_showTextWindowToolButtonsAction = m_actionCollection->action("showTools");
Q_ASSERT(m_showTextWindowToolButtonsAction != 0);
m_showTextWindowToolButtonsAction->setCheckable(true);
- m_showTextWindowToolButtonsAction->setChecked(CBTConfig::get(CBTConfig::showTextWindowToolButtons));
+ m_showTextWindowToolButtonsAction->setChecked(btConfig().sessionValue<bool>("GUI/showTextWindowToolButtons", true));
connect(m_showTextWindowToolButtonsAction, SIGNAL(toggled(bool)),
this, SLOT(slotToggleToolsToolbar()));
m_showFormatToolbarAction = m_actionCollection->action("showFormat");
Q_ASSERT(m_showFormatToolbarAction != 0);
m_showFormatToolbarAction->setCheckable(true);
- m_showFormatToolbarAction->setChecked(CBTConfig::get(CBTConfig::showFormatToolbarButtons));
+ m_showFormatToolbarAction->setChecked(btConfig().sessionValue<bool>("GUI/showFormatToolbarButtons", true));
bool ok = connect(m_showFormatToolbarAction, SIGNAL(toggled(bool)),
this, SLOT(slotToggleFormatToolbar()));
+ Q_ASSERT(ok);
m_toolbarsInEachWindow = m_actionCollection->action("showToolbarsInTextWindows");
Q_ASSERT(m_toolbarsInEachWindow != 0);
m_toolbarsInEachWindow->setCheckable(true);
- m_toolbarsInEachWindow->setChecked(CBTConfig::get(CBTConfig::showToolbarsInEachWindow));
+ m_toolbarsInEachWindow->setChecked(btConfig().sessionValue<bool>("GUI/showToolbarsInEachWindow", true));
ok = connect(m_toolbarsInEachWindow, SIGNAL(toggled(bool)),
- this, SLOT(slotToggleToolBarsInEachWindow()));
+ this, SLOT(slotToggleToolBarsInEachWindow()));
Q_ASSERT(ok);
// Search menu actions:
@@ -473,81 +503,56 @@ void BibleTime::initActions() {
connect(m_windowTileHorizontalAction, SIGNAL(triggered()),
this, SLOT(slotTileHorizontal()));
+ alignmentMode alignment = btConfig().sessionValue<alignmentMode>("GUI/alignmentMode", autoTileVertical);
+
m_windowManualModeAction = m_actionCollection->action("manualArrangement");
Q_ASSERT(m_windowManualModeAction != 0);
m_windowManualModeAction->setCheckable(true);
- m_windowManualModeAction->setChecked(true);
- connect(m_windowManualModeAction, SIGNAL(triggered()),
- this, SLOT(slotManualArrangementMode()));
m_windowAutoTabbedAction = m_actionCollection->action("autoTabbed");
Q_ASSERT(m_windowAutoTabbedAction != 0);
m_windowAutoTabbedAction->setCheckable(true);
- if(CBTConfig::get(CBTConfig::autoTabbed) == true) {
- m_windowManualModeAction->setChecked(false);
- m_windowAutoTabbedAction->setChecked(true);
- }
- connect(m_windowAutoTabbedAction, SIGNAL(triggered()),
- this, SLOT(slotAutoTabbed()));
//: Vertical tiling means that windows are vertical, placed side by side
m_windowAutoTileVerticalAction = m_actionCollection->action("autoVertical");
Q_ASSERT(m_windowAutoTileVerticalAction != 0);
m_windowAutoTileVerticalAction->setCheckable(true);
- if(CBTConfig::get(CBTConfig::autoTileVertical) == true) {
- m_windowManualModeAction->setChecked(false);
- m_windowAutoTileVerticalAction->setChecked(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");
Q_ASSERT(m_windowAutoTileHorizontalAction != 0);
m_windowAutoTileHorizontalAction->setCheckable(true);
- if(CBTConfig::get(CBTConfig::autoTileHorizontal) == true) {
- m_windowManualModeAction->setChecked(false);
- m_windowAutoTileHorizontalAction->setChecked(true);
- }
- connect(m_windowAutoTileHorizontalAction, SIGNAL(triggered()),
- this, SLOT(slotAutoTileHorizontal()));
m_windowAutoTileAction = m_actionCollection->action("autoTile");
Q_ASSERT(m_windowAutoTileAction != 0);
m_windowAutoTileAction->setCheckable(true);
- if(CBTConfig::get(CBTConfig::autoTile) == true) {
- m_windowManualModeAction->setChecked(false);
- m_windowAutoTileAction->setChecked(true);
- }
- connect(m_windowAutoTileAction, SIGNAL(triggered()),
- this, SLOT(slotAutoTile()));
m_windowAutoCascadeAction = m_actionCollection->action("autoCascade");
Q_ASSERT(m_windowAutoCascadeAction != 0);
m_windowAutoCascadeAction->setCheckable(true);
- if(CBTConfig::get(CBTConfig::autoCascade) == true) {
- m_windowManualModeAction->setChecked(false);
- m_windowAutoCascadeAction->setChecked(true);
- }
- connect(m_windowAutoCascadeAction, SIGNAL(triggered()),
- this, SLOT(slotAutoCascade()));
/*
* All actions related to arrangement modes have to be initialized before calling a slot on them,
* thus we call them afterwards now.
*/
- if(m_windowAutoTabbedAction->isChecked() == true)
- slotAutoTabbed();
- else if(m_windowAutoTileVerticalAction->isChecked() == true)
- slotAutoTileVertical();
- else if(m_windowAutoTileHorizontalAction->isChecked() == true)
- slotAutoTileHorizontal();
- else if(m_windowAutoTileAction->isChecked() == true)
- slotAutoTile();
- else if(m_windowAutoCascadeAction->isChecked() == true)
- slotAutoCascade();
- else
- slotManualArrangementMode();
+ QAction * alignmentAction;
+ switch (alignment) {
+ case autoTabbed:
+ alignmentAction = m_windowAutoTabbedAction; break;
+ case autoTileVertical:
+ alignmentAction = m_windowAutoTileVerticalAction; break;
+ case autoTileHorizontal:
+ alignmentAction = m_windowAutoTileHorizontalAction; break;
+ case autoTile:
+ alignmentAction = m_windowAutoTileAction; break;
+ case autoCascade:
+ alignmentAction = m_windowAutoCascadeAction; break;
+ case manual:
+ default:
+ alignmentAction = m_windowManualModeAction; break;
+ }
+ alignmentAction->setChecked(true);
+ slotUpdateWindowArrangementActions(alignmentAction);
m_windowSaveToNewProfileAction = m_actionCollection->action("saveNewSession");
Q_ASSERT(m_windowSaveToNewProfileAction != 0);
@@ -556,11 +561,13 @@ void BibleTime::initActions() {
m_setPreferencesAction = m_actionCollection->action("setPreferences");
Q_ASSERT(m_setPreferencesAction != 0);
+ m_setPreferencesAction->setMenuRole( QAction::PreferencesRole );
connect(m_setPreferencesAction, SIGNAL(triggered()),
this, SLOT(slotSettingsOptions()));
m_bookshelfManagerAction = m_actionCollection->action("bookshelfManager");
Q_ASSERT(m_bookshelfManagerAction != 0);
+ m_bookshelfManagerAction->setMenuRole( QAction::ApplicationSpecificRole );
connect(m_bookshelfManagerAction, SIGNAL(triggered()),
this, SLOT(slotSwordSetupDialog()));
@@ -576,6 +583,7 @@ void BibleTime::initActions() {
m_aboutBibleTimeAction = m_actionCollection->action("aboutBibleTime");
Q_ASSERT(m_aboutBibleTimeAction != 0);
+ m_aboutBibleTimeAction->setMenuRole( QAction::AboutRole );
connect(m_aboutBibleTimeAction, SIGNAL(triggered()),
this, SLOT(slotOpenAboutDialog()) );
@@ -641,25 +649,32 @@ void BibleTime::initMenubar() {
m_windowMenu->addAction(m_windowTileVerticalAction);
m_windowMenu->addAction(m_windowTileHorizontalAction);
m_windowArrangementMenu = new QMenu(this);
+ m_windowArrangementActionGroup = new QActionGroup(m_windowArrangementMenu);
m_windowArrangementMenu->addAction(m_windowManualModeAction);
+ m_windowArrangementActionGroup->addAction(m_windowManualModeAction);
m_windowArrangementMenu->addAction(m_windowAutoTabbedAction);
+ m_windowArrangementActionGroup->addAction(m_windowAutoTabbedAction);
m_windowArrangementMenu->addAction(m_windowAutoTileVerticalAction);
+ m_windowArrangementActionGroup->addAction(m_windowAutoTileVerticalAction);
m_windowArrangementMenu->addAction(m_windowAutoTileHorizontalAction);
+ m_windowArrangementActionGroup->addAction(m_windowAutoTileHorizontalAction);
m_windowArrangementMenu->addAction(m_windowAutoTileAction);
+ m_windowArrangementActionGroup->addAction(m_windowAutoTileAction);
m_windowArrangementMenu->addAction(m_windowAutoCascadeAction);
+ m_windowArrangementActionGroup->addAction(m_windowAutoCascadeAction);
+ connect(m_windowArrangementActionGroup, SIGNAL(triggered(QAction *)),
+ this, SLOT(slotUpdateWindowArrangementActions(QAction *)));
+
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_windowLoadProfileActionGroup = new QActionGroup(m_windowLoadProfileMenu);
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();
@@ -667,12 +682,18 @@ void BibleTime::initMenubar() {
connect(m_windowMenu, SIGNAL(aboutToShow()),
this, SLOT(slotWindowMenuAboutToShow()));
- // Settings menu:
+ #ifndef Q_OS_MAC
m_settingsMenu = new QMenu(this);
m_settingsMenu->addAction(m_setPreferencesAction);
m_settingsMenu->addSeparator();
m_settingsMenu->addAction(m_bookshelfManagerAction);
menuBar()->addMenu(m_settingsMenu);
+ #else
+ // On MAC OS, the settings actions will be moved to a system menu item.
+ // Therefore the settings menu would be empty, so we do not show it.
+ m_fileMenu->addAction(m_setPreferencesAction);
+ m_fileMenu->addAction(m_bookshelfManagerAction);
+ #endif
// Help menu:
m_helpMenu = new QMenu(this);
@@ -719,16 +740,20 @@ void BibleTime::retranslateUi() {
m_fileMenu->setTitle(tr("&File"));
m_viewMenu->setTitle(tr("&View"));
- m_toolBarsMenu->setTitle(tr("Toolbars"));
+ 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_openWindowsMenu->setTitle(tr("O&pen windows"));
+ m_windowArrangementMenu->setTitle(tr("&Arrangement mode"));
+ m_windowLoadProfileMenu->setTitle(tr("Sw&itch session"));
+ m_windowDeleteProfileMenu->setTitle(tr("&Delete session"));
+
+ #ifndef Q_OS_MAC
+ // This item is not present on Mac OS
m_settingsMenu->setTitle(tr("Se&ttings"));
+ #endif
+
m_helpMenu->setTitle(tr("&Help"));
#ifdef BT_DEBUG
@@ -802,8 +827,7 @@ void BibleTime::initSwordConfigFile() {
// It will contain the LocalePath which is used for sword locales
// It also contains a DataPath to the %ALLUSERSPROFILE%\Sword directory
// If this is not done here, the sword locales.d won't be found
-#ifdef Q_WS_WIN
- namespace DU = util::directory;
+#ifdef Q_OS_WIN
QString configFile = util::directory::getUserHomeSwordDir().filePath("sword.conf");
QFile file(configFile);
if (file.exists()) {
@@ -815,14 +839,13 @@ void BibleTime::initSwordConfigFile() {
QTextStream out(&file);
out << "\n";
out << "[Install]\n";
- out << "DataPath=" << DU::convertDirSeparators( DU::getSharedSwordDir().absolutePath()) << "\n";
- out << "LocalePath=" << DU::convertDirSeparators(DU::getApplicationSwordDir().absolutePath()) << "\n";
+ out << "DataPath=" << util::directory::convertDirSeparators( util::directory::getSharedSwordDir().absolutePath()) << "\n";
+ out << "LocalePath=" << util::directory::convertDirSeparators(util::directory::getApplicationSwordDir().absolutePath()) << "\n";
out << "\n";
file.close();
#endif
-#ifdef Q_WS_MAC
- namespace DU = util::directory;
+#ifdef Q_OS_MAC
QString configFile = util::directory::getUserHomeSwordDir().filePath("sword.conf");
QFile file(configFile);
if (file.exists()) {
@@ -834,7 +857,7 @@ void BibleTime::initSwordConfigFile() {
QTextStream out(&file);
out << "\n";
out << "[Install]\n";
- out << "DataPath=" << DU::convertDirSeparators( DU::getUserHomeSwordDir().absolutePath()) << "\n";
+ out << "DataPath=" << util::directory::convertDirSeparators( util::directory::getUserHomeSwordDir().absolutePath()) << "\n";
out << "\n";
file.close();
#endif
@@ -844,22 +867,31 @@ void BibleTime::initSwordConfigFile() {
void BibleTime::initBackends() {
initSwordConfigFile();
- sword::StringMgr::setSystemStringMgr( new BTStringMgr() );
+ sword::StringMgr::setSystemStringMgr( new BtStringMgr() );
sword::SWLog::getSystemLog()->setLogLevel(sword::SWLog::LOG_ERROR);
if (qApp->property("--debug").toBool()) {
sword::SWLog::getSystemLog()->setLogLevel(sword::SWLog::LOG_DEBUG);
}
-#ifdef Q_WS_MAC
+#ifdef Q_OS_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
+ /*
+ Set book names language if not set. This is a hack. We do this call here,
+ because we need to keep the setting displayed in BtLanguageSettingsPage in
+ sync with the language of the book names displayed, so that both would
+ always use the same setting.
+ */
+ BtLanguageSettingsPage::resetLanguage(); /// \todo refactor this hack
+
+
CSwordBackend *backend = CSwordBackend::createInstance();
- backend->booknameLanguage(CBTConfig::get(CBTConfig::language) );
+ backend->booknameLanguage(btConfig().value<QString>("language", QLocale::system().name()));
const CSwordBackend::LoadError errorCode = CSwordBackend::instance()->initModules(CSwordBackend::OtherChange);
@@ -906,53 +938,6 @@ void BibleTime::initBackends() {
}
-void BibleTime::applyProfileSettings( CProfile* p ) {
- Q_ASSERT(p);
- if (!p) return;
-
- //first Main Window geometry
- restoreGeometry(p->getMainwindowGeometry());
- restoreState(p->getMainwindowState());
- m_windowFullscreenAction->setChecked(isFullScreen());
-
- const CMDIArea::MDIArrangementMode newArrangementMode = p->getMDIArrangementMode();
- //make sure actions are updated by calling the slot functions
- //updatesEnabled in the MDI area is false atm, so changes won't actually be displayed yet
- switch (newArrangementMode) {
- case CMDIArea::ArrangementModeTileVertical:
- slotAutoTileVertical();
- break;
- case CMDIArea::ArrangementModeTileHorizontal:
- slotAutoTileHorizontal();
- break;
- case CMDIArea::ArrangementModeCascade:
- slotAutoCascade();
- break;
- case CMDIArea::ArrangementModeTile:
- slotAutoTile();
- break;
- case CMDIArea::ArrangementModeTabbed:
- slotAutoTabbed();
- break;
- case CMDIArea::ArrangementModeManual:
- slotManualArrangementMode();
- break;
- default:
- slotAutoTileVertical();
- break;
- }
- layout()->invalidate();
-}
-
-void BibleTime::storeProfileSettings( CProfile* p ) {
- 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;
diff --git a/src/bibletime_slots.cpp b/src/bibletime_slots.cpp
index 05729bf..0572f73 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,23 +22,22 @@
#include <QtGlobal>
#include <QToolBar>
#include <QUrl>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/keys/cswordversekey.h"
#include "frontend/btaboutdialog.h"
#include "frontend/cinfodisplay.h"
#include "frontend/cmdiarea.h"
#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
+#include "frontend/display/btfindwidget.h"
#include "frontend/displaywindow/btmodulechooserbar.h"
#include "frontend/displaywindow/cdisplaywindow.h"
+#include "frontend/messagedialog.h"
#include "frontend/searchdialog/csearchdialog.h"
#include "frontend/settingsdialogs/cconfigurationdialog.h"
#include "frontend/tips/bttipdialog.h"
#include "util/directory.h"
-using namespace Profile;
-
-
/** Opens the optionsdialog of BibleTime. */
void BibleTime::slotSettingsOptions() {
qDebug() << "BibleTime::slotSettingsOptions";
@@ -58,7 +57,7 @@ void BibleTime::saveConfigSettings() {
/** Is called when settings in the optionsdialog were changed (ok or apply) */
void BibleTime::slotSettingsChanged() {
qDebug() << "BibleTime::slotSettingsChanged";
- const QString language = CBTConfig::get(CBTConfig::language);
+ const QString language = btConfig().value<QString>("language", QLocale::system().name());
CSwordBackend::instance()->booknameLanguage(language);
// \todo update the bookmarks after Bible bookname language has been changed
@@ -91,38 +90,24 @@ void BibleTime::slotSwordSetupDialog() {
void BibleTime::slotWindowMenuAboutToShow() {
Q_ASSERT(m_windowMenu);
- if ( m_mdi->subWindowList().isEmpty() ) {
- 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_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_windowCloseAction->setEnabled(true);
- m_windowCloseAllAction->setEnabled(true);
- m_openWindowsMenu->setEnabled(true);
- }
+ const int numSubWindows = m_mdi->subWindowList().count();
+ m_windowCloseAction->setEnabled(numSubWindows);
+ m_windowCloseAllAction->setEnabled(numSubWindows);
+ m_openWindowsMenu->setEnabled(numSubWindows);
+
+ const bool enableManualArrangeActions = numSubWindows > 1;
+ m_windowCascadeAction->setEnabled(enableManualArrangeActions);
+ m_windowTileAction->setEnabled(enableManualArrangeActions);
+ m_windowTileVerticalAction->setEnabled(enableManualArrangeActions);
+ m_windowTileHorizontalAction->setEnabled(enableManualArrangeActions);
}
/** Is called just before the open windows menu is shown. */
void BibleTime::slotOpenWindowsMenuAboutToShow() {
Q_ASSERT(m_openWindowsMenu);
- QList<QMdiSubWindow*> windows = m_mdi->usableWindowList();
m_openWindowsMenu->clear();
- Q_FOREACH (QMdiSubWindow * const window, windows) {
+ Q_FOREACH (QMdiSubWindow * const window, m_mdi->usableWindowList()) {
QAction *openWindowAction = m_openWindowsMenu->addAction(window->windowTitle());
openWindowAction->setCheckable(true);
openWindowAction->setChecked(window == m_mdi->activeSubWindow());
@@ -132,134 +117,56 @@ void BibleTime::slotOpenWindowsMenuAboutToShow() {
}
/** This slot is connected with the windowAutoTileAction object */
-void BibleTime::slotUpdateWindowArrangementActions( QAction* clickedAction ) {
- /* 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_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_windowManualModeAction->setEnabled(
- m_windowManualModeAction != clickedAction
- && m_windowTileHorizontalAction != clickedAction
- && m_windowTileVerticalAction != clickedAction
- && m_windowCascadeAction != clickedAction
- && m_windowTileAction != 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 );
- }
+void BibleTime::slotUpdateWindowArrangementActions(QAction * trigerredAction) {
+ Q_ASSERT(trigerredAction);
- 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 );
- CBTConfig::set(CBTConfig::autoTileVertical, false);
- CBTConfig::set(CBTConfig::autoTileHorizontal, false);
- CBTConfig::set(CBTConfig::autoTile, false);
- CBTConfig::set(CBTConfig::autoTabbed, false);
- CBTConfig::set(CBTConfig::autoCascade, 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 );
- CBTConfig::set(CBTConfig::autoTileVertical, true);
- }
- 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 );
- CBTConfig::set(CBTConfig::autoTileHorizontal, true);
+ if (trigerredAction == m_windowAutoTileVerticalAction) {
+ m_mdi->setMDIArrangementMode(CMDIArea::ArrangementModeTileVertical);
+ btConfig().setSessionValue("GUI/alignmentMode", autoTileVertical);
}
- 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 );
- CBTConfig::set(CBTConfig::autoTile, true);
+ else if (trigerredAction == m_windowAutoTileHorizontalAction) {
+ m_mdi->setMDIArrangementMode(CMDIArea::ArrangementModeTileHorizontal);
+ btConfig().setSessionValue("GUI/alignmentMode", autoTileHorizontal);
}
- 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 );
- CBTConfig::set(CBTConfig::autoTabbed, true);
+ else if (trigerredAction == m_windowAutoTileAction) {
+ m_mdi->setMDIArrangementMode(CMDIArea::ArrangementModeTile);
+ btConfig().setSessionValue("GUI/alignmentMode", autoTile);
}
- 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 );
- CBTConfig::set(CBTConfig::autoCascade, true);
+ else if (trigerredAction == m_windowAutoTabbedAction) {
+ m_mdi->setMDIArrangementMode(CMDIArea::ArrangementModeTabbed);
+ btConfig().setSessionValue("GUI/alignmentMode", autoTabbed);
}
- else if (clickedAction == m_windowTileAction) {
- m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
- m_mdi->myTile();
+ else if (trigerredAction == m_windowAutoCascadeAction) {
+ m_mdi->setMDIArrangementMode(CMDIArea::ArrangementModeCascade);
+ btConfig().setSessionValue("GUI/alignmentMode", autoCascade);
}
- else if (clickedAction == m_windowCascadeAction) {
- m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
- m_mdi->myCascade();
- }
- else if (clickedAction == m_windowTileVerticalAction) {
- m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
- m_mdi->myTileVertical();
- }
- else if (clickedAction == m_windowTileHorizontalAction) {
- m_mdi->setMDIArrangementMode( CMDIArea::ArrangementModeManual );
- m_mdi->myTileHorizontal();
- }
-}
-
-void BibleTime::slotManualArrangementMode() {
- slotUpdateWindowArrangementActions( m_windowManualModeAction );
-}
+ else {
+ Q_ASSERT(trigerredAction == m_windowManualModeAction
+ || trigerredAction == m_windowTileAction
+ || trigerredAction == m_windowCascadeAction
+ || trigerredAction == m_windowTileVerticalAction
+ || trigerredAction == m_windowTileHorizontalAction);
-/** This slot is connected with the windowAutoTileAction object */
-void BibleTime::slotAutoTileHorizontal() {
- slotUpdateWindowArrangementActions( m_windowAutoTileHorizontalAction );
-}
+ if (trigerredAction != m_windowManualModeAction)
+ m_windowManualModeAction->setChecked(true);
-/** This slot is connected with the windowAutoTileAction object */
-void BibleTime::slotAutoTileVertical() {
- slotUpdateWindowArrangementActions( m_windowAutoTileVerticalAction );
-}
+ m_mdi->enableWindowMinMaxFlags(true);
+ m_mdi->setMDIArrangementMode(CMDIArea::ArrangementModeManual);
+ btConfig().setSessionValue("GUI/alignmentMode", manual);
+
+ if (trigerredAction == m_windowTileAction)
+ m_mdi->myTile();
+ else if (trigerredAction == m_windowCascadeAction)
+ m_mdi->myCascade();
+ else if (trigerredAction == m_windowTileVerticalAction)
+ m_mdi->myTileVertical();
+ else if (trigerredAction == m_windowTileHorizontalAction)
+ m_mdi->myTileHorizontal();
-/** This slot is connected with the windowAutoTileAction object */
-void BibleTime::slotAutoTile() {
- slotUpdateWindowArrangementActions( m_windowAutoTileAction );
-}
+ return;
+ }
-/** This slot is connected with the windowAutoTabbedAction object */
-void BibleTime::slotAutoTabbed() {
- slotUpdateWindowArrangementActions( m_windowAutoTabbedAction );
+ m_mdi->enableWindowMinMaxFlags(false);
}
void BibleTime::slotTile() {
@@ -278,16 +185,11 @@ void BibleTime::slotTileHorizontal() {
slotUpdateWindowArrangementActions( m_windowTileHorizontalAction );
}
-/** This slot is connected with the windowAutoCascadeAction object */
-void BibleTime::slotAutoCascade() {
- slotUpdateWindowArrangementActions( m_windowAutoCascadeAction );
-}
-
/** Shows/hides the toolbar */
void BibleTime::slotToggleMainToolbar() {
Q_ASSERT(m_mainToolBar);
- bool currentState = CBTConfig::get(CBTConfig::showMainWindowToolbar);
- CBTConfig::set(CBTConfig::showMainWindowToolbar, !currentState);
+ bool currentState = btConfig().sessionValue<bool>("GUI/showMainToolbar", true);
+ btConfig().setSessionValue("GUI/showMainToolbar", !currentState);
if ( m_showMainWindowToolbarAction->isChecked()) {
m_mainToolBar->show();
}
@@ -297,84 +199,77 @@ void BibleTime::slotToggleMainToolbar() {
}
void BibleTime::slotToggleTextWindowHeader() {
- bool currentState = CBTConfig::get(CBTConfig::showTextWindowHeaders);
- CBTConfig::set(CBTConfig::showTextWindowHeaders, !currentState);
+ bool currentState = btConfig().sessionValue<bool>("GUI/showTextWindowHeaders", true);
+ btConfig().setSessionValue("GUI/showTextWindowHeaders", !currentState);
emit toggledTextWindowHeader(!currentState);
}
void BibleTime::slotToggleNavigatorToolbar() {
- bool currentState = CBTConfig::get(CBTConfig::showTextWindowNavigator);
- CBTConfig::set(CBTConfig::showTextWindowNavigator, !currentState);
- showOrHideToolBars();
- if (CBTConfig::get(CBTConfig::showToolbarsInEachWindow))
+ bool currentState = btConfig().sessionValue<bool>("GUI/showTextWindowNavigator", true);
+ btConfig().setSessionValue("GUI/showTextWindowNavigator", !currentState);
+ if (btConfig().sessionValue<bool>("GUI/showToolbarsInEachWindow", true))
emit toggledTextWindowNavigator(!currentState);
else
- emit toggledTextWindowNavigator(false);
+ m_navToolBar->setVisible(btConfig().sessionValue<bool>("GUI/showTextWindowNavigator", true));
}
void BibleTime::slotToggleToolsToolbar() {
- bool currentState = CBTConfig::get(CBTConfig::showTextWindowToolButtons);
- CBTConfig::set(CBTConfig::showTextWindowToolButtons, !currentState);
- showOrHideToolBars();
- if (CBTConfig::get(CBTConfig::showToolbarsInEachWindow))
+ bool currentState = btConfig().sessionValue<bool>("GUI/showTextWindowToolButtons", true);
+ btConfig().setSessionValue("GUI/showTextWindowToolButtons", !currentState);
+ if (btConfig().sessionValue<bool>("GUI/showToolbarsInEachWindow", true))
emit toggledTextWindowToolButtons(!currentState);
else
- emit toggledTextWindowToolButtons(false);
+ m_toolsToolBar->setVisible(btConfig().sessionValue<bool>("GUI/showTextWindowToolButtons", true));
}
void BibleTime::slotToggleWorksToolbar() {
- bool currentState = CBTConfig::get(CBTConfig::showTextWindowModuleSelectorButtons);
- CBTConfig::set(CBTConfig::showTextWindowModuleSelectorButtons, !currentState);
- showOrHideToolBars();
- if (CBTConfig::get(CBTConfig::showToolbarsInEachWindow))
+ bool currentState = btConfig().sessionValue<bool>("GUI/showTextWindowModuleSelectorButtons", true);
+ btConfig().setSessionValue("GUI/showTextWindowModuleSelectorButtons", !currentState);
+ if (btConfig().sessionValue<bool>("GUI/showToolbarsInEachWindow", true))
emit toggledTextWindowModuleChooser(!currentState);
else
- emit toggledTextWindowModuleChooser(false);
+ m_worksToolBar->setVisible(btConfig().sessionValue<bool>("GUI/showTextWindowModuleSelectorButtons", true));
}
void BibleTime::slotToggleFormatToolbar() {
- bool currentState = CBTConfig::get(CBTConfig::showFormatToolbarButtons);
- CBTConfig::set(CBTConfig::showFormatToolbarButtons, !currentState);
- showOrHideToolBars();
- if (CBTConfig::get(CBTConfig::showToolbarsInEachWindow))
+ bool currentState = btConfig().sessionValue<bool>("GUI/showFormatToolbarButtons", true);
+ btConfig().setSessionValue("GUI/showFormatToolbarButtons", !currentState);
+ if (btConfig().sessionValue<bool>("GUI/showToolbarsInEachWindow", true))
emit toggledTextWindowFormatToolbar(!currentState);
else
- emit toggledTextWindowFormatToolbar(false);
+ m_formatToolBar->setVisible(!currentState);
}
void BibleTime::slotToggleToolBarsInEachWindow() {
- bool currentState = CBTConfig::get(CBTConfig::showToolbarsInEachWindow);
- CBTConfig::set(CBTConfig::showToolbarsInEachWindow, !currentState);
+ bool currentState = btConfig().sessionValue<bool>("GUI/showToolbarsInEachWindow", true);
+ btConfig().setSessionValue("GUI/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)) {
+ if (btConfig().sessionValue<bool>("GUI/showToolbarsInEachWindow", true)) {
+ // set main window widgets invisible
m_navToolBar->setVisible(false);
m_worksToolBar->setVisible(false);
m_toolsToolBar->setVisible(false);
m_formatToolBar->setVisible(false);
+ // set state of sub window widets
+ emit toggledTextWindowNavigator(btConfig().sessionValue<bool>("GUI/showTextWindowNavigator", true));
+ emit toggledTextWindowModuleChooser(btConfig().sessionValue<bool>("GUI/showTextWindowModuleSelectorButtons", true));
+ emit toggledTextWindowToolButtons(btConfig().sessionValue<bool>("GUI/showTextWindowToolButtons", true));
+ emit toggledTextWindowFormatToolbar(btConfig().sessionValue<bool>("GUI/showFormatToolbarButtons", true));
}
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));
+ // set state of main window widgets
+ m_navToolBar->setVisible(btConfig().sessionValue<bool>("GUI/showTextWindowNavigator", true));
+ m_worksToolBar->setVisible(btConfig().sessionValue<bool>("GUI/showTextWindowModuleSelectorButtons", true));
+ m_toolsToolBar->setVisible(btConfig().sessionValue<bool>("GUI/showTextWindowToolButtons", true));
+ m_formatToolBar->setVisible(btConfig().sessionValue<bool>("GUI/showFormatToolbarButtons", true));
+ //set sub window widgets invisible
+ emit toggledTextWindowNavigator(false);
+ emit toggledTextWindowToolButtons(false);
+ emit toggledTextWindowModuleChooser(false);
+ emit toggledTextWindowFormatToolbar(false);
}
}
@@ -398,12 +293,18 @@ void BibleTime::slotSearchModules() {
Search::CSearchDialog::openDialog(modules, QString::null);
}
+void BibleTime::slotActiveWindowChanged(QMdiSubWindow* window)
+{
+ if (window == 0)
+ m_findWidget->setVisible(false);
+}
+
/* Search default Bible slot
* Call CSearchDialog::openDialog with only the default bible module
*/
void BibleTime::slotSearchDefaultBible() {
QList<const CSwordModuleInfo*> module;
- CSwordModuleInfo* bible = CBTConfig::get(CBTConfig::standardBible);
+ CSwordModuleInfo* bible = btConfig().getDefaultSwordModuleByType("standardBible");
if (bible) {
module.append(bible);
}
@@ -430,117 +331,187 @@ void BibleTime::slotOpenTipDialog() {
dlg->show();
}
-/** Saves the current settings into the currently activated profile. */
-void BibleTime::saveProfile(QAction* action) {
- m_mdi->setUpdatesEnabled(false);
-
- CProfile * p = (CProfile *) action->property("CProfilePointer").value<void *>();
- Q_ASSERT(p);
- Q_ASSERT(p == m_profileMgr.profile(action->text().remove("&")));
- if ( p ) {
- saveProfile(p);
- }
-
- m_mdi->setUpdatesEnabled(true);
-}
+void BibleTime::saveProfile() {
+ // Save main window settings:
+ BtConfig & conf = btConfig();
+ conf.setSessionValue("MainWindow/geometry", saveGeometry());
+ conf.setSessionValue("MainWindow/state", saveState());
+ conf.setSessionValue("MainWindow/MDIArrangementMode", static_cast<int>(m_mdi->getMDIArrangementMode()));
-void BibleTime::saveProfile(CProfile* profile) {
- if (!profile) {
- return;
- }
- //save mainwindow settings
- storeProfileSettings(profile);
+ conf.setSessionValue("FindIsVisible", m_findWidget->isVisibleTo(this));
- QList<CProfileWindow*> profileWindows;
- Q_FOREACH (const QMdiSubWindow * const w, m_mdi->subWindowList(QMdiArea::StackingOrder)) {
+ QStringList windowsList;
+ Q_FOREACH (const QMdiSubWindow * const w,
+ m_mdi->subWindowList(QMdiArea::StackingOrder))
+ {
CDisplayWindow * const displayWindow = dynamic_cast<CDisplayWindow*>(w->widget());
- if (displayWindow == 0) {
+ if (!displayWindow)
continue;
- }
- CProfileWindow * const profileWindow = new CProfileWindow();
- displayWindow->storeProfileSettings(profileWindow);
- profileWindows.append(profileWindow);
+ const QString windowKey = QString::number(windowsList.size());
+ windowsList.append(windowKey);
+ const QString windowGroup = "window/" + windowKey + '/';
+ displayWindow->storeProfileSettings(windowGroup);
}
- profile->save(profileWindows);
-
- //clean up memory - delete all created profile windows
- //profileWindows.setAutoDelete(true);
- qDeleteAll(profileWindows);
- profileWindows.clear();
+ conf.setSessionValue("windowsList", windowsList);
}
-void BibleTime::loadProfile(QAction* action) {
- CProfile * p = (CProfile *) action->property("CProfilePointer").value<void *>();
- Q_ASSERT(p);
- Q_ASSERT(p == m_profileMgr.profile(action->text().remove("&")));
- if ( p ) {
- m_mdi->closeAllSubWindows();
- loadProfile(p);
- }
+void BibleTime::loadProfile(QAction * action) {
+ Q_ASSERT(action);
+ QVariant keyProperty = action->property("ProfileKey");
+ Q_ASSERT(keyProperty.type() == QVariant::String);
+ Q_ASSERT(btConfig().sessionNames().contains(keyProperty.toString()));
+ loadProfile(keyProperty.toString());
}
-void BibleTime::loadProfile(CProfile* p) {
- if (!p)
- return;
-
- QList<CProfileWindow*> windows = p->load();
+void BibleTime::loadProfile(const QString & profileKey) {
+ Q_ASSERT(btConfig().sessionNames().contains(profileKey));
- m_mdi->setUpdatesEnabled(false);//don't auto tile or auto cascade, this would mess up everything!!
+ // do nothing if requested session is the current session
+ if (profileKey == btConfig().currentSessionKey())
+ return;
- //load mainwindow setttings
- applyProfileSettings(p);
+ // Save old profile:
+ saveProfile();
- QWidget* focusWindow = 0;
+ // Close all open windows BEFORE switching profile:
+ m_mdi->closeAllSubWindows();
- // for (CProfileWindow* w = windows.last(); w; w = windows.prev()) { //from the last one to make sure the order is right in the mdi area
- Q_FOREACH (CProfileWindow * w, windows) {
- const QString &key = w->key;
+ // Switch profile Activate profile:
+ btConfig().setCurrentSession(profileKey);
+ reloadProfile();
+ refreshProfileMenus();
+}
- QList<CSwordModuleInfo*> modules;
- Q_FOREACH (const QString &moduleName, w->modules) {
+namespace {
+
+/// Helper object for reloadProfile()
+struct WindowLoadStatus {
+ inline WindowLoadStatus() : window(0) {}
+ QStringList failedModules;
+ QList<CSwordModuleInfo*> okModules;
+ CDisplayWindow * window;
+};
+
+} // anonymous namespace
+
+void BibleTime::reloadProfile() {
+ typedef CMDIArea::MDIArrangementMode MAM;
+ typedef CPlainWriteWindow::WriteWindowType WWT;
+ using message::setQActionCheckedNoTrigger;
+
+ // Cache pointer to config:
+ BtConfig & conf = btConfig();
+
+ // Disable updates while doing big changes:
+ setUpdatesEnabled(false);
+
+ // Close all open windows:
+ m_mdi->closeAllSubWindows();
+
+ // Reload main window settings:
+ restoreGeometry(conf.sessionValue<QByteArray>("MainWindow/geometry"));
+ restoreState(conf.sessionValue<QByteArray>("MainWindow/state"));
+
+ /*
+ * restoreState includes visibility of child widgets, the manually added
+ * qactions (so not including bookmark, bookshelf and mag) are not restored
+ * though, so we restore their state here.
+ */
+ setQActionCheckedNoTrigger(m_windowFullscreenAction, isFullScreen());
+ setQActionCheckedNoTrigger(m_showTextAreaHeadersAction, conf.sessionValue<bool>("GUI/showTextWindowHeaders", true));
+ setQActionCheckedNoTrigger(m_showMainWindowToolbarAction, conf.sessionValue<bool>("GUI/showMainToolbar", true));
+ setQActionCheckedNoTrigger(m_showTextWindowNavigationAction, conf.sessionValue<bool>("GUI/showTextWindowNavigator", true));
+ setQActionCheckedNoTrigger(m_showTextWindowModuleChooserAction, conf.sessionValue<bool>("GUI/showTextWindowModuleSelectorButtons", true));
+ setQActionCheckedNoTrigger(m_showTextWindowToolButtonsAction, conf.sessionValue<bool>("GUI/showTextWindowToolButtons", true));
+ setQActionCheckedNoTrigger(m_showFormatToolbarAction, conf.sessionValue<bool>("GUI/showFormatToolbarButtons", true));
+ setQActionCheckedNoTrigger(m_toolbarsInEachWindow, conf.sessionValue<bool>("GUI/showToolbarsInEachWindow", true));
+
+ m_mdi->setMDIArrangementMode(static_cast<MAM>(conf.sessionValue<int>("MainWindow/MDIArrangementMode")));
+
+ m_findWidget->setVisible(conf.sessionValue<bool>("FindIsVisible", false));
+
+ QWidget * focusWindow = 0;
+ QMap<QString, WindowLoadStatus> failedWindows;
+ Q_FOREACH (const QString & w,
+ conf.sessionValue<QStringList>("windowsList"))
+ {
+ const QString windowGroup = "window/" + w + '/';
+
+ // Try to determine window modules:
+ WindowLoadStatus wls;
+ Q_FOREACH (const QString &moduleName,
+ conf.sessionValue<QStringList>(windowGroup + "modules"))
+ {
CSwordModuleInfo * const m = CSwordBackend::instance()->findModuleByName(moduleName);
- if (m != 0) {
- modules.append(m);
+ if (m) {
+ wls.okModules.append(m);
+ } else {
+ wls.failedModules.append(moduleName);
}
}
- if (modules.isEmpty()) { //are the modules still installed? If not continue wih next session window
+
+ // Check whether the window totally failed (no modules can be loaded):
+ if (wls.okModules.isEmpty()) {
+ failedWindows.insert(w, wls);
continue;
}
- //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, CWriteWindow::WriteWindowType(w->writeWindowType) );
- }
- else { //create a read window
- displayWindow = createReadDisplayWindow(modules, key);
+ // Check whether the window partially failed:
+ if (!wls.failedModules.isEmpty())
+ failedWindows.insert(w, wls);
+
+ // Try to respawn the window:
+ Q_ASSERT(!wls.window);
+ const QString key = conf.sessionValue<QString>(windowGroup + "key");
+ WWT wwt = static_cast<WWT>(conf.sessionValue<int>(windowGroup + "writeWindowType", 0));
+ if (wwt > 0) {
+ // Note, that we *might* lose the rest of wls.okModules here:
+ if (wls.okModules.size() > 1)
+ qWarning() << "Got more modules for a \"write window\" than expected from the profile!";
+
+ wls.window = createWriteDisplayWindow(wls.okModules.first(), key, wwt);
+ } else {
+ wls.window = createReadDisplayWindow(wls.okModules, key);
}
- if (displayWindow) { //if a window was created initialize it.
- if (w->hasFocus) {
- focusWindow = displayWindow;
- }
-
- displayWindow->applyProfileSettings(w);
+ if (wls.window) {
+ wls.window->applyProfileSettings(windowGroup);
+ if (conf.sessionValue<bool>(windowGroup + "hasFocus", false))
+ focusWindow = wls.window;
+ } else {
+ failedWindows.insert(w, wls);
}
}
- m_mdi->setUpdatesEnabled(true);
+ /* This call is necessary to restore the visibility of the toolbars in the child
+ * windows, since their state is not saved automatically.
+ */
+ showOrHideToolBars();
+
+ // Re-arrange MDI:
m_mdi->triggerWindowUpdate();
- if (focusWindow) {
+ // Activate focused window:
+ if (focusWindow)
focusWindow->setFocus();
- }
+
+ // Re-enable updates and repaint:
+ setUpdatesEnabled(true);
+ repaint(); /// \bug The main window (except decors) is all black without this (not even hover over toolbar buttons work)
+ raise(); /// \bug The main window would not refresh at all. A call to this function or adjustSize() seems to fix this
+
+ /// \todo For windows in failedWindows ask whether to keep the settings / close windows etc
}
void BibleTime::deleteProfile(QAction* action) {
- //HACK: work around the inserted & char by KPopupMenu
- CProfile * p = (CProfile *) action->property("CProfilePointer").value<void *>();
- Q_ASSERT(p);
- Q_ASSERT(p == m_profileMgr.profile(action->text().remove("&")));
- if (p)
- m_profileMgr.remove(p);
+ Q_ASSERT(action);
+ QVariant keyProperty = action->property("ProfileKey");
+ Q_ASSERT(keyProperty.type() == QVariant::String);
+ Q_ASSERT(btConfig().sessionNames().contains(keyProperty.toString()));
+
+ /// \todo Ask for confirmation
+ btConfig().deleteSession(keyProperty.toString());
refreshProfileMenus();
}
@@ -551,40 +522,75 @@ void BibleTime::toggleFullscreen() {
/** Saves current settings into a new profile. */
void BibleTime::saveToNewProfile() {
- bool ok = false;
- const QString name = QInputDialog::getText(this, tr("New Session"),
- tr("Please enter a name for the new session."), QLineEdit::Normal, QString::null, &ok);
- if (ok && !name.isEmpty()) {
- CProfile* profile = m_profileMgr.create(name);
- saveProfile(profile);
+ BtConfig & conf = btConfig();
+
+ // Get new unique name:
+ QString name;
+ for (;;) {
+ bool ok;
+ name = QInputDialog::getText(
+ this, tr("New Session"),
+ tr("Please enter a name for the new session."),
+ QLineEdit::Normal, name, &ok);
+ if (!ok)
+ return;
+
+ if (!name.isEmpty()) {
+ // Check whether name already exists:
+ if (conf.sessionNames().values().contains(name)) {
+ message::showInformation(this, tr("Session already exists"),
+ tr("Session with the name \"%1\" "
+ "already exists. Please provide a "
+ "different name.").arg(name));
+ } else {
+ break;
+ }
+ }
}
+
+ // Also save old profile:
+ saveProfile();
+
+ // Save new profile:
+ conf.setCurrentSession(conf.addSession(name));
+ saveProfile();
+
+ // Refresh profile menus:
refreshProfileMenus();
}
-/** Slot to refresh the save profile and load profile menus. */
+/** Slot to refresh the saved profile and load profile menus. */
void BibleTime::refreshProfileMenus() {
- m_windowSaveProfileMenu->clear();
+ typedef BtConfig::SessionNamesHashMap SNHM;
+ typedef SNHM::const_iterator SNHMCI;
+
m_windowLoadProfileMenu->clear();
m_windowDeleteProfileMenu->clear();
- //refresh the load, save and delete profile menus
- m_profileMgr.refresh();
- const QList<CProfile*> profiles = m_profileMgr.profiles();
+ BtConfig & conf = btConfig();
+ const BtConfig::SessionNamesHashMap &sessions = conf.sessionNames();
- const bool enableActions = !profiles.isEmpty();
- m_windowSaveProfileMenu->setEnabled(enableActions);
+ const bool enableActions = sessions.size() > 1;
m_windowLoadProfileMenu->setEnabled(enableActions);
m_windowDeleteProfileMenu->setEnabled(enableActions);
- Q_FOREACH (const CProfile * const p, profiles) {
- const QString &profileName = p->name();
- QAction * a;
- a = m_windowSaveProfileMenu->addAction(profileName);
- a->setProperty("CProfilePointer", QVariant::fromValue((void *) p));
- a = m_windowLoadProfileMenu->addAction(profileName);
- a->setProperty("CProfilePointer", QVariant::fromValue((void *) p));
- a = m_windowDeleteProfileMenu->addAction(profileName);
- a->setProperty("CProfilePointer", QVariant::fromValue((void *) p));
+
+ if (enableActions) {
+ for (SNHMCI it = sessions.constBegin(); it != sessions.constEnd(); ++it) {
+ QAction * a;
+
+ a = m_windowLoadProfileMenu->addAction(it.value());
+ a->setProperty("ProfileKey", it.key());
+ a->setActionGroup(m_windowLoadProfileActionGroup);
+ a->setCheckable(true);
+ if (it.key() == conf.currentSessionKey())
+ a->setChecked(true);
+
+ a = m_windowDeleteProfileMenu->addAction(it.value());
+ a->setProperty("ProfileKey", it.key());
+ if (it.key() == conf.currentSessionKey())
+ a->setDisabled(true);
+ }
}
}
diff --git a/src/bibletimeapp.cpp b/src/bibletimeapp.cpp
index f73d501..c8e4274 100644
--- a/src/bibletimeapp.cpp
+++ b/src/bibletimeapp.cpp
@@ -2,38 +2,61 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 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 <QDebug>
+#include <QFile>
+#include "frontend/messagedialog.h"
+#include "backend/config/btconfig.h"
+#include "backend/managers/cswordbackend.h"
#include "backend/managers/cdisplaytemplatemgr.h"
-#include "util/cresmgr.h"
+#include "util/geticon.h"
+BibleTimeApp::BibleTimeApp(int &argc, char **argv)
+ : QApplication(argc, argv)
+ , m_init(false)
+{
+ setApplicationName("bibletime");
+ setApplicationVersion(BT_VERSION);
+}
+
BibleTimeApp::~BibleTimeApp() {
// Prevent writing to the log file before the directory cache is init:
- if (!m_init)
+ if (!m_init || BtConfig::m_instance == 0)
return;
//we can set this safely now because we close now (hopyfully without crash)
- CBTConfig::set(CBTConfig::crashedLastTime, false);
- CBTConfig::set(CBTConfig::crashedTwoTimes, false);
+ btConfig().setValue("state/crashedLastTime", false);
+ btConfig().setValue("state/crashedTwoTimes", false);
delete CDisplayTemplateMgr::instance();
CLanguageMgr::destroyInstance();
CSwordBackend::destroyInstance();
+ util::clearIconCache();
+
+ BtConfig::destroyInstance();
+}
+
+bool BibleTimeApp::initBtConfig() {
+ Q_ASSERT(m_init);
+
+ return BtConfig::initBtConfig();
}
bool BibleTimeApp::initDisplayTemplateManager() {
+ Q_ASSERT(m_init);
+
QString errorMessage;
new CDisplayTemplateMgr(errorMessage);
if (errorMessage.isNull())
return true;
- QMessageBox::critical(0, tr("Fatal error!"), errorMessage);
+ message::showCritical(0, tr("Fatal error!"), errorMessage);
return false;
}
+
diff --git a/src/bibletimeapp.h b/src/bibletimeapp.h
index 7ac1ebf..23a1ce8 100644
--- a/src/bibletimeapp.h
+++ b/src/bibletimeapp.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,15 +20,24 @@
delete all created module objects.
*/
class BibleTimeApp : public QApplication {
- public:
- inline BibleTimeApp(int &argc, char **argv) : QApplication(argc, argv), m_init(false) {}
+
+ Q_OBJECT
+
+ public: /* Methods: */
+
+ BibleTimeApp(int &argc, char **argv);
~BibleTimeApp();
inline void startInit() { m_init = true; }
+ bool initBtConfig();
bool initDisplayTemplateManager();
- private:
+ private: /* Fields: */
+
bool m_init;
+
};
+#define bApp (static_cast<BibleTimeApp *>(QCoreApplication::instance()))
+
#endif
diff --git a/src/btglobal.h b/src/btglobal.h
index 1b584e8..1b956b7 100644
--- a/src/btglobal.h
+++ b/src/btglobal.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -45,11 +47,13 @@ struct DisplayOptions {
/**
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.
+ occurs at the return statement of the not anymore existing
+ CBTConfig::getDisplayOptionDefaults and is caused by a bad calling sequence
+ when called from CDisplayWindow::init. The bug might still occur but now
+ caused by BtConfig::getDisplayOptions.
\todo Properly identify this bug and remove the #ifdef when fix is available.
*/
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
int notUsed;
#endif
diff --git a/src/display-templates/Basic.tmpl b/src/display-templates/Basic.tmpl
index 192e5b4..6d0df9d 100644
--- a/src/display-templates/Basic.tmpl
+++ b/src/display-templates/Basic.tmpl
@@ -2,25 +2,26 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
- <title>#TITLE#</title>
- <meta name="GENERATOR" content="BibleTime - www.bibletime.info" />
- <meta name="AUTHOR" content="BibleTime - www.bibletime.info" />
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <style type="text/css">
- /* <![CDATA[ */
+ <title>#TITLE#</title>
+ <meta name="GENERATOR" content="BibleTime - www.bibletime.info" />
+ <meta name="AUTHOR" content="BibleTime - www.bibletime.info" />
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+ <style type="text/css">
+ /* <![CDATA[ */
#LANG_CSS#
- /* ]]> */
- </style>
+ /* ]]> */
+ </style>
- <!-- Link to the application default stylesheet -->
- <link rel="stylesheet" type="text/css" href="file://#THEME_STYLE#" />
- <!-- Link to module stylesheet, if applicable -->
+ <!-- Link to the application default stylesheet -->
+ <style type="text/css">#THEME_STYLE#</style>
+ <!-- Link to module stylesheet, if applicable -->
</head>
<body id="#DISPLAYTYPE#" class="#MODTYPE# #MODTYPE#_#MODNAME#">
- <div id="content" lang="#LANG_ABBREV#" xml:lang="#LANG_ABBREV#" dir="#PAGE_DIRECTION#">#CONTENT#</div>
+ <div id="content" lang="#LANG_ABBREV#" xml:lang="#LANG_ABBREV#" dir="#PAGE_DIRECTION#">#CONTENT#</div>
</body>
</html>
diff --git a/src/display-templates/Blue.css b/src/display-templates/Blue.css
index 229289c..eafe85b 100644
--- a/src/display-templates/Blue.css
+++ b/src/display-templates/Blue.css
@@ -2,148 +2,148 @@
* Theme by BibleTime - www.bibletime.info *
*/
body {
- background-color: white;
- color: black;
+ background-color: white;
+ color: black;
}
#content {
- margin:10px;
+ margin:10px;
}
#content > table {
- margin: 0;
- padding: 0;
- border-spacing:10px;
+ margin: 0;
+ padding: 0;
+ border-spacing:10px;
}
#content > table th {
- padding: 0 0 2px 0;
- text-align: center;
- font-weight: bold;
- font-size: 110%;
- border-bottom: 1px dotted #7B7B7B;
+ padding: 0 0 2px 0;
+ text-align: center;
+ font-weight: bold;
+ font-size: 110%;
+ border-bottom: 1px dotted #7B7B7B;
}
a {
- text-decoration:none;
- font-weight:normal;
- color: #7B7B7B;
- padding:0 2px;
+ text-decoration:none;
+ font-weight:normal;
+ color: #7B7B7B;
+ padding:0 2px;
}
a:hover {
- text-decoration:none;
- color: #0000FF;
- padding:0 2px;
+ text-decoration:none;
+ color: #0000FF;
+ padding:0 2px;
}
/* Settings which apply to all entries in all modules */
.entry {
- padding: 2px;
- /*vertical-align: middle;*/
- text-align: justify;
+ padding: 2px;
+ /*vertical-align: middle;*/
+ text-align: justify;
}
td.entry, td.currententry {
- vertical-align: top;
- text-align: justify !important;
+ vertical-align: top;
+ text-align: justify !important;
}
#printer .entry {
- font-size: 90%;
- text-align: left;
+ font-size: 90%;
+ text-align: left;
}
.entry[dir=rtl] {
- text-align: right !important;
+ text-align: right !important;
}
#printer .entry[dir=rtl] {
- text-align:right !important;
+ text-align:right !important;
}
/* Keep the values the same as in .entry (take the border into account!) */
.currententry {
- padding: 2px;
- /*vertical-align: middle;*/
- text-align: justify;
- background-color: #E6E4FF;
+ padding: 2px;
+ /*vertical-align: middle;*/
+ text-align: justify;
+ background-color: #E6E4FF;
}
.currententry[dir=rtl] {
- text-align:right !important;
+ text-align:right !important;
}
div.currententry {
}
span.currententry {
- background-color: #EDEFFF !important;
+ background-color: #EDEFFF !important;
}
/* Space between the columns of modules displayed side by side */
td.entry + td.entry {
- margin-left: 5px;
+ margin-left: 5px;
}
/* Several additional settings for display of modules*/
#bible div.currententry, #bible td.currententry {
- border: 1px solid #B7B7B7;
- padding: 2px;
+ border: 1px solid #B7B7B7;
+ padding: 2px;
}
/*Same for books!*/
#book div.currententry, #book td.currententry {
- border: 1px solid #B7B7B7;
- padding: 2px;
+ border: 1px solid #B7B7B7;
+ padding: 2px;
}
#book .entryname + .entry {
- margin-top:2px;
- padding-top:1px;
+ margin-top:2px;
+ padding-top:1px;
}
/* To remove the gap between the entrynam and the entry's content*/
#book .entry > *, #book .currententry > * {
- margin-top:0px;
- padding-top:0px;
+ margin-top:0px;
+ padding-top:0px;
}
.entryname {
- font-size:80%;
- padding:0 2px 0 0;
- vertical-align:super;
+ font-size:80%;
+ padding:0 2px 0 0;
+ vertical-align:super;
}
.entry[dir=rtl] .entryname, .currententry[dir=rtl] .entryname {
- padding: 0 0 0 2px;
- font-size: 80%;
- vertical-align: super;
+ padding: 0 0 0 2px;
+ font-size: 80%;
+ vertical-align: super;
}
.entryname a, #printer .entryname {
}
#printer .entry .entry, #printer .entry .sectiontitle , #printer .entry .booktitle {
- padding-top: 0.05em;
- margin-left: 10px;
+ padding-top: 0.05em;
+ margin-left: 10px;
}
.footnote {
- vertical-align:super;
- font-weight: normal;
- color: blue;
- font-size: 80%;
- cursor: help;
+ vertical-align:super;
+ font-weight: normal;
+ color: blue;
+ font-size: 80%;
+ cursor: help;
}
.footnote:before { content:"("; }
.footnote:after { content:")"; }
.footnotepre {
- font-style: italic;
+ font-style: italic;
}
.crossreference {
- font-size: 80%;
- color: blue;
+ font-size: 80%;
+ color: blue;
}
#bible .crossreference:before { content:" ["; }
#bible .crossreference:after { content:"]"; }
.crossreference a {
- color: blue;
+ color: blue;
}
.crossreference a:hover {
- color: blue;
+ color: blue;
}
.alternative {}
@@ -155,36 +155,36 @@ td.entry + td.entry {
}
.sectiontitle {
- font-weight: bold;
- font-size: 110%;
+ font-weight: bold;
+ font-size: 110%;
}
#printer .sectiontitle {
- font-weight: bold;
- font-size: 100%;
+ font-weight: bold;
+ font-size: 100%;
}
* + .sectiontitle {
- margin-top:15px;
+ margin-top:15px;
}
.booktitle {
- font-weight: bold;
- font-size: 120%;
- font-variant: small-caps;
+ font-weight: bold;
+ font-size: 120%;
+ font-variant: small-caps;
}
#printer .booktitle {
- font-weight: bold;
- font-size: 120%;
- font-variant: small-caps;
+ font-weight: bold;
+ font-size: 120%;
+ font-variant: small-caps;
}
.foreign {
}
.jesuswords {
- color:#9C2323;
+ color:#9C2323;
}
.introduction {
- font-size:80%;
- text-align:justify;
+ font-size:80%;
+ text-align:justify;
}
.quotation {
@@ -192,25 +192,25 @@ td.entry + td.entry {
.poetry {
}
.sup {
- vertical-align: super;
+ vertical-align: super;
}
.sub {
- vertical-align: sub;
+ vertical-align: sub;
}
.right {
- text-align: right;
+ text-align: right;
}
.center {
- text-align: center;
+ text-align: center;
}
.bold {
- font-weight:bold;
+ font-weight:bold;
}
.illuminated {
}
.italic {
- font-style:italic;
+ font-style:italic;
}
.line-through {
text-decoration: line-through;
@@ -221,7 +221,7 @@ td.entry + td.entry {
font-variant: small-caps;
}
.underline {
- text-decoration: underline;
+ text-decoration: underline;
}
.inscription {
@@ -243,10 +243,10 @@ td.entry + td.entry {
}
.transchange {
- font-style:italic;
+ font-style:italic;
}
.transchange > .added {
- background-color:inherit;
+ background-color:inherit;
}
.transchange > .amplified {
}
@@ -260,61 +260,61 @@ td.entry + td.entry {
}
.morphSegmentation {
- border-right: 2px solid gray;
+ border-right: 2px solid gray;
}
#infodisplay {
- margin:0;
- padding:0;
+ margin:0;
+ padding:0;
}
#infodisplay .footnoteinfo h3, #infodisplay .strongsinfo h3, #infodisplay .morphinfo h3, #infodisplay .translationinfo h3, #infodisplay .crossrefinfo h3, #infodisplay .moduleinfo h3 {
- padding:4px 4px 2px 0;
- color:darkGray;
- font-weight:bold;
- border-bottom:1px solid gray;
- text-align: right;
+ padding:4px 4px 2px 0;
+ color:darkGray;
+ font-weight:bold;
+ border-bottom:1px solid gray;
+ text-align: right;
}
#infodisplay > p, #infodisplay * > p,
#infodisplay > .para, #infodisplay * > .para
{ /* We only format the first p child in a special way */
- text-align:justify !important;
- color:black;
- margin:0px;
- padding:0px;
+ text-align:justify !important;
+ color:black;
+ margin:0px;
+ padding:0px;
}
/*Required for cross references*/
#infodisplay .entry {
- padding:2px;
- text-align:justify !important;
- margin-bottom:10px;
- margin-left:15px;
+ padding:2px;
+ text-align:justify !important;
+ margin-bottom:10px;
+ margin-left:15px;
}
#infodisplay .entry[dir=rtl] {
- text-align: right !important;
+ text-align: right !important;
}
#infodisplay .entry .entry { /*No smaller font size for nested entries*/
- margin:0px;
+ margin:0px;
}
#infodisplay .entry .entry[dir=rtl] { /*No smaller font size for nested entries*/
- text-align: right !important;
+ text-align: right !important;
}
#infodisplay .entryname {
- padding:2px;
- margin:0px;
- text-align:left !important;
- font-weight:bold;
+ padding:2px;
+ margin:0px;
+ text-align:left !important;
+ font-weight:bold;
}
#infodisplay .rangeheading {
- color:black;
- font-weight:bold;
- margin-left:-10px;
+ color:black;
+ font-weight:bold;
+ margin-left:-10px;
}
#printer .rangeheading {
- border-bottom:1px solid black;
- color:black;
+ border-bottom:1px solid black;
+ color:black;
}
diff --git a/src/display-templates/Christmastide.css b/src/display-templates/Christmastide.css
index e12385b..bc65e76 100644
--- a/src/display-templates/Christmastide.css
+++ b/src/display-templates/Christmastide.css
@@ -2,100 +2,100 @@
* Theme by tabthorpe@FreeBSD.org *
*/
body {
- background-color: #FDF5E6; /* OldeLaceWhite */
- color: #006400; /* # DarkGreen */
+ background-color: #FDF5E6; /* OldeLaceWhite */
+ color: #006400; /* # DarkGreen */
}
#content {
- margin: 5px;
+ margin: 5px;
}
#content table {
- margin:0;
- padding:0;
- border-spacing:10px;
- border-collapse: collapse;
- vertical-align: top;
+ margin:0;
+ padding:0;
+ border-spacing:10px;
+ border-collapse: collapse;
+ vertical-align: top;
}
#content table th {
- padding: 0 0 2px 0;
- text-align: center;
- font-weight: bold;
- font-size: 115%;
+ padding: 0 0 2px 0;
+ text-align: center;
+ font-weight: bold;
+ font-size: 115%;
}
a {
- text-decoration:none;
- font-weight:normal;
- color: #4A766E; /* # DarkGreenCopper */
- padding:2px;
+ text-decoration:none;
+ font-weight:normal;
+ color: #4A766E; /* # DarkGreenCopper */
+ padding:2px;
}
td.entry, div.entry {
- padding: 5px;
- vertical-align: top;
+ padding: 5px;
+ vertical-align: top;
}
div.entry {
- padding: 5px;
+ padding: 5px;
}
td.currententry, div.currententry {
- padding: 5px;
- vertical-align: top;
- font-weight:bold;
+ padding: 5px;
+ vertical-align: top;
+ font-weight:bold;
}
td.entry + td.entry {
- margin-left: 5px;
+ margin-left: 5px;
}
div.currententry {
- font-weight:bold;
- padding: 5px;
+ font-weight:bold;
+ padding: 5px;
}
.footnote {
- color: #2E8B57; /* #SeaGreen */
+ color: #2E8B57; /* #SeaGreen */
}
.strongnumber {
- vertical-align: top;
- font-size: 60%;
- color: #20B2AA; /* #LightSeaGreen */
+ vertical-align: top;
+ font-size: 60%;
+ color: #20B2AA; /* #LightSeaGreen */
}
.morphcode {
- vertical-align: top;
- font-size: 60%;
- color: #20B2AA; /* #LightSeaGreen */
+ vertical-align: top;
+ font-size: 60%;
+ color: #20B2AA; /* #LightSeaGreen */
}
.lemma {
}
.sectiontitle {
- font-weight: bold;
- font-size: 120%;
+ font-weight: bold;
+ font-size: 120%;
}
.entry + .sectiontitle {
- margin-top:35px;
- padding-top:35px;
+ margin-top:35px;
+ padding-top:35px;
}
.booktitle {
- font-weight: bold;
- font-size: 140%;
+ font-weight: bold;
+ font-size: 140%;
}
.foreign {
}
.jesuswords {
- color: red;
- font-size: 0.9em;
+ color: red;
+ font-size: 0.9em;
}
.name > .divine {
@@ -109,25 +109,25 @@ div.currententry {
}
.sup {
- vertical-align: super;
+ vertical-align: super;
}
.sub {
- vertical-align: sub;
+ vertical-align: sub;
}
.right {
- text-align: right;
+ text-align: right;
}
.center {
- text-align: center;
+ text-align: center;
}
.bold {
- font-weight: bold;
+ font-weight: bold;
}
.italic {
- font-style: italic;
+ font-style: italic;
}
diff --git a/src/display-templates/Crazy.css b/src/display-templates/Crazy.css
index 94e9646..e404fc3 100644
--- a/src/display-templates/Crazy.css
+++ b/src/display-templates/Crazy.css
@@ -2,36 +2,36 @@
* Theme by BibleTime - www.bibletime.info *
*/
body {
- background-color: white;
- color: black;
- margin:0px;
- padding:0;
- padding:1em;
+ background-color: white;
+ color: black;
+ margin:0px;
+ padding:0;
+ padding:1em;
}
/* content wraps all of the displayed elements */
#content {
- margin:0px;
- padding:0px;
- font-size:12pt;
- text-align:justify;
+ margin:0px;
+ padding:0px;
+ font-size:12pt;
+ text-align:justify;
}
/* The table contains the Bible verses, each verse on an own row, each Bible module in an own column */
#content > table {
- margin:0;
- padding:3px;
- border-spacing:0;
- vertical-align:top;
- text-align:justify;
+ margin:0;
+ padding:3px;
+ border-spacing:0;
+ vertical-align:top;
+ text-align:justify;
}
/* The heading contains the name of the module and may contain additional information like the display keys */
#content > table th {
- text-shadow:black 1px 1px 3px;
- font-size:1.3em;
- background-color:#F0F0F0;
- padding:8px;
- border-bottom:1px solid black;
+ text-shadow:black 1px 1px 3px;
+ font-size:1.3em;
+ background-color:#F0F0F0;
+ padding:8px;
+ border-bottom:1px solid black;
}
#content tr:nth-child(odd) { background-color: white; }
@@ -50,14 +50,14 @@ a:hover { }
If more than one module (Bibles) was chosen, the entry class applies to "td" elements, one column for a verse
*/
.entry {
- padding:0.3em;
+ padding:0.3em;
}
table .entry:nth-child(odd) {
- border-left:10px solid #DEE6F6;
+ border-left:10px solid #DEE6F6;
}
table .entry:nth-child(even) {
- border-left:10px solid #E6EEFF;
+ border-left:10px solid #E6EEFF;
}
#printer .entry { text-indent:15px; }
@@ -68,24 +68,24 @@ table .entry:nth-child(even) {
/* Special formatting for the block element entries */
div.entry, td.entry { }
td.entry, td.currententry {
- vertical-align:top;
+ vertical-align:top;
}
/* Currententry is chosen when the entry should be highlighted as the current entry chosen by the user
currententry may apply to span, div, td (just like .entry)
*/
.currententry {
- padding:0.3em;
- line-height:1.6em;
- background-color:#D3E5FF;
- /*border: thin solid black;*/
+ padding:0.3em;
+ line-height:1.6em;
+ background-color:#D3E5FF;
+ /*border: thin solid black;*/
}
table .currententry:nth-child(1) {
- margin-left:0;
- border-left:10px solid #99B4FF;
- /*border-left:10px solid #F5FF6A;*/
+ margin-left:0;
+ border-left:10px solid #99B4FF;
+ /*border-left:10px solid #F5FF6A;*/
}
/* .currententry[dir=rtl] { */
/* } */
@@ -94,24 +94,24 @@ span.currententry { }
/* You may use this to format the space between two columns */
td.entry + td.entry {
- margin:0;
+ margin:0;
}
/* Several additional settings for displaying Bible modules*/
#bible div.entry {
- border-left:10px solid white;
+ border-left:10px solid white;
}
#bible div.entry[dir=rtl] {
- border-left:none;
- border-right:10px solid white;
- text-align:right;
+ border-left:none;
+ border-right:10px solid white;
+ text-align:right;
}
#bible div.currententry {
- border-left:10px solid #99B4FF;
+ border-left:10px solid #99B4FF;
}
#bible div.currententry[dir=rtl] {
- border-left:none;
- border-right:10px solid #99B4FF;
+ border-left:none;
+ border-right:10px solid #99B4FF;
}
#bible div.currententry, #bible td.currententry { }
#bible td.currententry { }
@@ -170,12 +170,12 @@ so something like .alternative:before { content:"'"attr(alternative); } is possi
/* A title within the text. This is the formatting which applies to a title of a section, as you can find them in Bibles */
.sectiontitle {
- padding:0.3em;
- /*text-shadow:gray 0px 0px 3px;*/
- font-size:1.3em;
- font-weight:bold;
- text-transform:uppercase;
- padding-bottom:2px;
+ padding:0.3em;
+ /*text-shadow:gray 0px 0px 3px;*/
+ font-size:1.3em;
+ font-weight:bold;
+ text-transform:uppercase;
+ padding-bottom:2px;
}
#printer .sectiontitle { }
/* You may want to format elements before section titles in a special way. */
@@ -258,7 +258,7 @@ so something like .alternative:before { content:"'"attr(alternative); } is possi
/* Morph segmentation is a special feature for hebrew to markup the word divisions in the text */
/* .morphSegmentation { border-left:1px solid red; } */
.morphSegmentation + .morphSegmentation {
- border-right: 1px red solid;
+ border-right: 1px red solid;
}
/* The formatting of all things displayed in the information window */
@@ -271,13 +271,13 @@ so something like .alternative:before { content:"'"attr(alternative); } is possi
#infodisplay .translationinfo h3,
#infodisplay .crossrefinfo h3,
#infodisplay .moduleinfo h3 {
- font-size:12pt;
- font-weight:bold;
- text-transform:uppercase;
- text-align:right;
- color:gray;
- border-bottom:1px solid black;
- padding:4px;
+ font-size:12pt;
+ font-weight:bold;
+ text-transform:uppercase;
+ text-align:right;
+ color:gray;
+ border-bottom:1px solid black;
+ padding:4px;
}
#infodisplay > p, #infodisplay * > p { /* We only format the first p child in a special way */
@@ -289,10 +289,10 @@ so something like .alternative:before { content:"'"attr(alternative); } is possi
#infodisplay .entry .entry { /* No smaller font size for nested entries */
}
#infodisplay .entryname {
- font-weight:bold;
+ font-weight:bold;
}
#infodisplay .rangeheading {
- font-weight:bold;
+ font-weight:bold;
}
#printer .rangeheading {}
diff --git a/src/display-templates/Green.css b/src/display-templates/Green.css
index cd9e68b..4be46b9 100644
--- a/src/display-templates/Green.css
+++ b/src/display-templates/Green.css
@@ -2,173 +2,173 @@
* Theme by BibleTime - www.bibletime.info *
*/
body {
- background-color: white;
- color: black;
+ background-color: white;
+ color: black;
}
#content {
- margin:10px;
+ margin:10px;
}
#content > table {
- margin: 0;
- padding: 0;
- border-spacing:10px;
- vertical-align:top;
+ margin: 0;
+ padding: 0;
+ border-spacing:10px;
+ vertical-align:top;
}
#content > table th {
- padding: 0 0 2px 0;
- text-align: center;
- font-weight: bold;
- font-size: 110%;
- border-bottom: 1px solid #6B6B6B;
+ padding: 0 0 2px 0;
+ text-align: center;
+ font-weight: bold;
+ font-size: 110%;
+ border-bottom: 1px solid #6B6B6B;
}
a {
- text-decoration:none;
- font-weight:normal;
- color: #3B11AE;
- padding:0 2px;
+ text-decoration:none;
+ font-weight:normal;
+ color: #3B11AE;
+ padding:0 2px;
}
a:hover {
- color: #AE1518;
- padding:0 2px;
+ color: #AE1518;
+ padding:0 2px;
}
/* Settings which apply to all entries in all modules */
.entry {
- padding: 3px;
- vertical-align: middle;
- text-align: justify;
+ padding: 3px;
+ vertical-align: middle;
+ text-align: justify;
}
#printer .entry {
- font-size:90%;
- text-align:left;
+ font-size:90%;
+ text-align:left;
}
.entry[dir=rtl] {
- text-align:right !important;
+ text-align:right !important;
}
#printer .entry[dir=rtl] {
- text-align:right !important;
+ text-align:right !important;
}
td.entry, td.currententry {
- vertical-align:top;
+ vertical-align:top;
}
/* Keep the values the same as in .entry (take the border into account!) */
.currententry {
- padding:3px;
- text-align:justify;
+ padding:3px;
+ text-align:justify;
}
.currententry[dir=rtl] {
- text-align:right !important;
+ text-align:right !important;
}
div.currententry {
}
span.currententry {
- background-color:#D4FFCB;
+ background-color:#D4FFCB;
}
/*Space between the columns of modules displayed side by side*/
td.entry + td.entry {
- margin-left: 5px;
+ margin-left: 5px;
}
/* Several additional settings for display of modules*/
#bible div.currententry, #bible td.currententry {
- border:1px solid black;
- padding:2px;
- background-color:#F6FFF7;
+ border:1px solid black;
+ padding:2px;
+ background-color:#F6FFF7;
}
#bible span.currententry {
- background-color:#C8FFB6;
+ background-color:#C8FFB6;
}
/*Same for books!*/
#book div.currententry, #book td.currententry {
- border:1px solid black;
- background-color:#F6FFF7;
+ border:1px solid black;
+ background-color:#F6FFF7;
}
#book span.currententry {
- background-color:#C8FFB6;
+ background-color:#C8FFB6;
}
.entryname {
- font-size:80%;
- padding:0 2px 0 0;
- vertical-align:super;
+ font-size:80%;
+ padding:0 2px 0 0;
+ vertical-align:super;
}
.entry[dir=rtl] .entryname, .currententry[dir=rtl] .entryname {
- padding: 0 0 0 2px;
- font-size: 80%;
- vertical-align:super;
+ padding: 0 0 0 2px;
+ font-size: 80%;
+ vertical-align:super;
}
.entryname a, #printer .entryname {
- vertical-align: middle
+ vertical-align: middle
}
#printer .entry .entry, #printer .entry .sectiontitle , #printer .entry .booktitle {
- padding-top: 0.05em;
- margin-left: 10px;
+ padding-top: 0.05em;
+ margin-left: 10px;
}
.footnote {
- vertical-align:super;
- color: blue;
- font-size: 70%;
+ vertical-align:super;
+ color: blue;
+ font-size: 70%;
}
.footnote:before { content:"("; }
.footnote:after { content:")"; }
.crossreference {
- font-size: 80%;
- /*vertical-align:middle;*/
- color: blue;
+ font-size: 80%;
+ /*vertical-align:middle;*/
+ color: blue;
}
.crossreference a {
- font-size: 80%;
- /*vertical-align:middle;*/
- color: blue;
+ font-size: 80%;
+ /*vertical-align:middle;*/
+ color: blue;
}
.crossreference a:hover {
- font-size: 80%;
- /*vertical-align:middle;*/
- color: blue;
+ font-size: 80%;
+ /*vertical-align:middle;*/
+ color: blue;
}
.sectiontitle {
- font-weight: bold;
- font-size: 110%;
+ font-weight: bold;
+ font-size: 110%;
}
#printer .sectiontitle {
- font-weight: bold;
- font-size: 100%;
+ font-weight: bold;
+ font-size: 100%;
}
* + .sectiontitle {
- margin-top:15px;
+ margin-top:15px;
}
.booktitle {
- font-weight: bold;
- font-size: 120%;
- font-variant: small-caps;
+ font-weight: bold;
+ font-size: 120%;
+ font-variant: small-caps;
}
#printer .booktitle {
- font-weight: bold;
- font-size: 120%;
- font-variant: small-caps;
+ font-weight: bold;
+ font-size: 120%;
+ font-variant: small-caps;
}
.foreign {
}
.jesuswords {
- color:#9C2323;
+ color:#9C2323;
}
.quotation {
@@ -176,25 +176,25 @@ td.entry + td.entry {
.poetry {
}
.sup {
- vertical-align: super;
+ vertical-align: super;
}
.sub {
- vertical-align: sub;
+ vertical-align: sub;
}
.right {
- text-align: right;
+ text-align: right;
}
.center {
- text-align: center;
+ text-align: center;
}
.bold {
- font-weight:bold;
+ font-weight:bold;
}
.illuminated {
}
.italic {
- font-style:italic;
+ font-style:italic;
}
.line-through {
text-decoration: line-through;
@@ -205,7 +205,7 @@ td.entry + td.entry {
font-variant: small-caps;
}
.underline {
- text-decoration: underline;
+ text-decoration: underline;
}
.inscription {
@@ -227,10 +227,10 @@ td.entry + td.entry {
}
.transchange {
- font-style:italic;
+ font-style:italic;
}
.transchange > .added {
- background-color:inherit;
+ background-color:inherit;
}
.transchange > .amplified {
}
@@ -244,57 +244,57 @@ td.entry + td.entry {
}
.morphSegmentation {
- border: 1px solid gray;
- margin-top: 1px; /* Don`t let the boxes touch here, between the lines */
- margin-left: -1px; /* But here, for better reading of the text,
- this will only occur within a word consisting of several segments.*/
- margin-right: 0px;
+ border: 1px solid gray;
+ margin-top: 1px; /* Don`t let the boxes touch here, between the lines */
+ margin-left: -1px; /* But here, for better reading of the text,
+ this will only occur within a word consisting of several segments.*/
+ margin-right: 0px;
}
#infodisplay {
- margin:0;
- padding:0;
+ margin:0;
+ padding:0;
}
#infodisplay .footnoteinfo h3, #infodisplay .strongsinfo h3, #infodisplay .morphinfo h3, #infodisplay .translationinfo h3, #infodisplay .crossrefinfo h3, #infodisplay .moduleinfo h3 {
- padding:4px 4px 2px 0;
- color:darkGray;
- font-weight:bold;
- border-bottom:1px solid gray;
- text-align:left !important;
+ padding:4px 4px 2px 0;
+ color:darkGray;
+ font-weight:bold;
+ border-bottom:1px solid gray;
+ text-align:left !important;
}
#infodisplay > p, #infodisplay * > p { /* We only format the first p child in a special way */
- text-align:justify;
- color:black;
- margin:0px;
- padding:0px;
+ text-align:justify;
+ color:black;
+ margin:0px;
+ padding:0px;
}
/*Required for cross references*/
#infodisplay .entry {
- padding:2px;
- text-align:justify;
- margin-bottom:10px;
- margin-left:15px;
+ padding:2px;
+ text-align:justify;
+ margin-bottom:10px;
+ margin-left:15px;
}
#infodisplay .entry .entry { /*No smaller font size for nested entries*/
- margin:0px;
+ margin:0px;
}
#infodisplay .entryname {
- padding:2px;
- margin:0px;
- text-align:left;
- font-weight:bold;
+ padding:2px;
+ margin:0px;
+ text-align:left;
+ font-weight:bold;
}
#infodisplay .rangeheading {
- color:black;
- font-weight:bold;
- margin-left:-10px;
+ color:black;
+ font-weight:bold;
+ margin-left:-10px;
}
#printer .rangeheading {
- border-bottom:1px solid black;
- color:black;
+ border-bottom:1px solid black;
+ color:black;
}
diff --git a/src/display-templates/HighContrast.css b/src/display-templates/HighContrast.css
index 3652b74..0dd1053 100644
--- a/src/display-templates/HighContrast.css
+++ b/src/display-templates/HighContrast.css
@@ -2,70 +2,70 @@
* Theme by BibleTime - www.bibletime.info
*/
* {
- /* To work around a KDE 3.2 bug / problem */
- /* background-color:white; #this seems to break*/
+ /* To work around a KDE 3.2 bug / problem */
+ /* background-color:white; #this seems to break*/
}
body {
- background-color: white;
- color: black;
+ background-color: white;
+ color: black;
}
#content {
- margin: 10px;
+ margin: 10px;
}
#content > table {
- margin: 0;
- padding: 0;
- border-spacing:10px;
- vertical-align:top;
+ margin: 0;
+ padding: 0;
+ border-spacing:10px;
+ vertical-align:top;
}
#content > table th {
- padding: 0 0 2px 0;
- text-align: center;
- /*font-weight: bold;*/
- font-size: 110%;
- border-bottom: 1px solid #6B6B6B;
+ padding: 0 0 2px 0;
+ text-align: center;
+ /*font-weight: bold;*/
+ font-size: 110%;
+ border-bottom: 1px solid #6B6B6B;
}
a {
- text-decoration:none;
- font-weight:normal;
- /*color: #F98100;*/
- padding:1px;
+ text-decoration:none;
+ font-weight:normal;
+ /*color: #F98100;*/
+ padding:1px;
}
a:hover {
- color: #FF0000;
- padding:1px;
- text-decoration:underline;
+ color: #FF0000;
+ padding:1px;
+ text-decoration:underline;
}
/* Settings which apply to all entries in all modules */
.entry {
- padding: 2px;
- /*vertical-align: top;*/
- text-align: justify;
+ padding: 2px;
+ /*vertical-align: top;*/
+ text-align: justify;
}
#printer .entry {
- font-size: 90%;
- text-align: left;
+ font-size: 90%;
+ text-align: left;
}
.entry[dir=rtl],#printer .entry[dir=rtl] {
- text-align: right;
+ text-align: right;
}
div.entry, td.entry, td.currententry {
- vertical-align:top;
+ vertical-align:top;
}
/* Keep the values the same as in .entry (take the border into account!) */
.currententry {
- padding: 2px;
- text-align: justify;
- /*color:white;*/
- /*The background colour of selected text as of kde 3.5.2*/
- background-color: #A5A5FF;
+ padding: 2px;
+ text-align: justify;
+ /*color:white;*/
+ /*The background colour of selected text as of kde 3.5.2*/
+ background-color: #A5A5FF;
}
.currententry[dir=rtl] {
- text-align: right;
+ text-align: right;
}
div.currententry {
}
@@ -76,113 +76,113 @@ span.currententry {
/*Space between the columns of modules displayed side by side*/
td.entry + td.entry {
- margin-left: 5px;
+ margin-left: 5px;
}
/* Several additional settings for display of modules*/
#bible div.currententry, #bible td.currententry {
- /*border: 1px solid black;*/
- padding: 4px;
+ /*border: 1px solid black;*/
+ padding: 4px;
}
#bible span.currententry {
}
/*Same for books!*/
#book div.currententry, #book td.currententry {
- border: 1px solid black;
+ border: 1px solid black;
}
#book span.currententry {
}
.entryname {
- font-size:70%;
- padding:0 1px 0 0;
- vertical-align:top;
- /*color: #F98100;*/
- color: black;
- /*font-style: italic;*/
+ font-size:70%;
+ padding:0 1px 0 0;
+ vertical-align:top;
+ /*color: #F98100;*/
+ color: black;
+ /*font-style: italic;*/
}
.entry[dir=rtl] .entryname, .currententry[dir=rtl] .entryname {
- padding:0 0 0 1px;
- font-size:60%;
- /*vertical-align:top; */
+ padding:0 0 0 1px;
+ font-size:60%;
+ /*vertical-align:top; */
}
.entryname a, #printer .entryname {
- vertical-align: top;
- font-size: 100%;
- font-weight: bold;
- color: black;
+ vertical-align: top;
+ font-size: 100%;
+ font-weight: bold;
+ color: black;
}
#printer .entry .entry, #printer .entry .sectiontitle , #printer .entry .booktitle {
- padding-top:0.05em;
- margin-left:10px;
+ padding-top:0.05em;
+ margin-left:10px;
}
.footnote {
- vertical-align:super;
- font-weight:bold;
- /*color: #00B7FF;*/ /*This one is kind of blinding on white*/
- /*color: #F98100;*/
- font-size:80%;
- color: black;
+ vertical-align:super;
+ font-weight:bold;
+ /*color: #00B7FF;*/ /*This one is kind of blinding on white*/
+ /*color: #F98100;*/
+ font-size:80%;
+ color: black;
}
.footnote:before {
- content: "(";
+ content: "(";
}
.footnote:after {
- content: ")";
+ content: ")";
}
.crossreference {
- font-size: 80%;
- /*vertical-align:middle;*/
- /*color: blue;*/
- /*color: #F98100;*/
+ font-size: 80%;
+ /*vertical-align:middle;*/
+ /*color: blue;*/
+ /*color: #F98100;*/
}
.crossreference:before {
- content: "[";
+ content: "[";
}
.crosreference:after {
- content: "]";
+ content: "]";
}
.sectiontitle {
- font-weight: bold;
- font-size: 110%;
+ font-weight: bold;
+ font-size: 110%;
}
#printer .sectiontitle {
- font-weight: bold;
- font-size: 100%;
+ font-weight: bold;
+ font-size: 100%;
}
* + .sectiontitle {
- margin-top:15px;
+ margin-top:15px;
}
.booktitle {
- font-weight: bold;
- font-size: 120%;
- font-variant: small-caps;
+ font-weight: bold;
+ font-size: 120%;
+ font-variant: small-caps;
}
#printer .booktitle {
- font-weight: bold;
- font-size: 120%;
- font-variant: small-caps;
+ font-weight: bold;
+ font-size: 120%;
+ font-variant: small-caps;
}
.foreign {
}
.jesuswords {
- /*color:red;*/
- /*color: #7500AC;*/
- /*color: #F98100;*/
- font-style:italic;
- /*font-weight: bold;*/
- font-size:0.9em;
+ /*color:red;*/
+ /*color: #7500AC;*/
+ /*color: #F98100;*/
+ font-style:italic;
+ /*font-weight: bold;*/
+ font-size:0.9em;
}
.quotation {
@@ -190,25 +190,25 @@ td.entry + td.entry {
.poetry {
}
.sup {
- vertical-align: super;
+ vertical-align: super;
}
.sub {
- vertical-align: sub;
+ vertical-align: sub;
}
.right {
- text-align: right;
+ text-align: right;
}
.center {
- text-align: center;
+ text-align: center;
}
.bold {
- font-weight:bold;
+ font-weight:bold;
}
.illuminated {
}
.italic {
- font-style:italic;
+ font-style:italic;
}
.line-through {
text-decoration: line-through;
@@ -219,7 +219,7 @@ td.entry + td.entry {
font-variant: small-caps;
}
.underline {
- text-decoration: underline;
+ text-decoration: underline;
}
.inscription {
@@ -241,10 +241,10 @@ td.entry + td.entry {
}
.transchange {
- font-style:italic;
+ font-style:italic;
}
.transchange > .added {
- background-color:inherit;
+ background-color:inherit;
}
.transchange > .amplified {
}
@@ -258,55 +258,55 @@ td.entry + td.entry {
}
.morphSegmentation {
- border: 1px solid grey;
- margin-top: 1px; /* Don`t let the boxes touch here, between the lines */
- margin-left: -1px; /* But here, for better reading of the text,
- this will only occur within a word consisting of several segments.*/
- margin-right: 0px;
+ border: 1px solid grey;
+ margin-top: 1px; /* Don`t let the boxes touch here, between the lines */
+ margin-left: -1px; /* But here, for better reading of the text,
+ this will only occur within a word consisting of several segments.*/
+ margin-right: 0px;
}
#infodisplay {
- margin:0;
- padding:0;
+ margin:0;
+ padding:0;
}
#infodisplay .footnoteinfo h3, #infodisplay .strongsinfo h3, #infodisplay .morphinfo h3, #infodisplay .translationinfo h3, #infodisplay .crossrefinfo h3, #infodisplay .moduleinfo h3 {
- padding: 2px 0 0 0;
- color: black;
- font-weight: bold;
- border-bottom: 1px solid black;
- margin: 0 0 3px 0;
+ padding: 2px 0 0 0;
+ color: black;
+ font-weight: bold;
+ border-bottom: 1px solid black;
+ margin: 0 0 3px 0;
}
#infodisplay > p { /* We only format the first p child in a special way */
- color: black;
- margin: 0px;
- padding: 0px;
+ color: black;
+ margin: 0px;
+ padding: 0px;
}
/*Required for cross references*/
#infodisplay .entry {
- padding: 2px;
- text-align: justify;
- margin: 0 0 10px 10px;
+ padding: 2px;
+ text-align: justify;
+ margin: 0 0 10px 10px;
}
#infodisplay .entry .entry { /*No smaller font size for nested entries*/
- margin: 0px;
+ margin: 0px;
}
#infodisplay .entryname {
- padding: 2px;
- margin: 0px;
- text-align: left;
- font-weight: bold;
+ padding: 2px;
+ margin: 0px;
+ text-align: left;
+ font-weight: bold;
}
#infodisplay .rangeheading {
- color: black;
- font-weight: bold;
- margin-left: -5px;
+ color: black;
+ font-weight: bold;
+ margin-left: -5px;
}
#printer .rangeheading {
- border-bottom: 1px solid black;
- color: black;
+ border-bottom: 1px solid black;
+ color: black;
}
diff --git a/src/display-templates/Simple.css b/src/display-templates/Simple.css
index ed2e976..32ec57f 100644
--- a/src/display-templates/Simple.css
+++ b/src/display-templates/Simple.css
@@ -2,90 +2,90 @@
* Theme by BibleTime
*/
body {
- background-color: white;
- color: black;
+ background-color: white;
+ color: black;
}
#content {
- margin: 5px;
+ margin: 5px;
}
#content table {
- margin:0;
- padding:0;
- border-spacing:10px;
- border-collapse: collapse;
- vertical-align: top;
+ margin:0;
+ padding:0;
+ border-spacing:10px;
+ border-collapse: collapse;
+ vertical-align: top;
}
#content table th {
- padding: 0 0 2px 0;
- text-align: center;
- font-weight: bold;
- font-size: 115%;
+ padding: 0 0 2px 0;
+ text-align: center;
+ font-weight: bold;
+ font-size: 115%;
}
a {
- text-decoration:none;
- font-weight:normal;
- color: blue;
- padding:2px;
+ text-decoration:none;
+ font-weight:normal;
+ color: blue;
+ padding:2px;
}
td.entry, div.entry {
- padding: 5px;
- vertical-align: top;
+ padding: 5px;
+ vertical-align: top;
}
div.entry {
- padding: 5px;
+ padding: 5px;
}
td.currententry, div.currententry {
- padding: 5px;
- vertical-align: top;
- font-weight:bold;
+ padding: 5px;
+ vertical-align: top;
+ font-weight:bold;
}
td.entry + td.entry {
- margin-left: 5px;
+ margin-left: 5px;
}
div.currententry {
- font-weight:bold;
- /*vertical-align: middle;*/
- padding: 5px;
+ font-weight:bold;
+ /*vertical-align: middle;*/
+ padding: 5px;
}
.footnote {
- color: gray;
+ color: gray;
}
.strongnumber {
- vertical-align: top;
- font-size: 60%;
- color: blue;
+ vertical-align: top;
+ font-size: 60%;
+ color: blue;
}
.morphcode {
- vertical-align: top;
- font-size: 60%;
- color: blue;
+ vertical-align: top;
+ font-size: 60%;
+ color: blue;
}
.lemma {
}
.sectiontitle {
- font-weight: bold;
- font-size: 120%;
+ font-weight: bold;
+ font-size: 120%;
}
.entry + .sectiontitle {
- margin-top:35px;
- padding-top:35px;
+ margin-top:35px;
+ padding-top:35px;
}
.booktitle {
- font-weight: bold;
- font-size: 140%;
+ font-weight: bold;
+ font-size: 140%;
}
.foreign {
}
.jesuswords {
- color: red;
- font-size: 0.9em;
+ color: red;
+ font-size: 0.9em;
}
.name > .divine {
@@ -97,22 +97,22 @@ div.currententry {
.poetry {
}
.sup {
- vertical-align: super;
+ vertical-align: super;
}
.sub {
- vertical-align: sub;
+ vertical-align: sub;
}
.right {
- text-align: right;
+ text-align: right;
}
.center {
- text-align: center;
+ text-align: center;
}
/*TODO: Think of something better here since this will get confusing*/
-/* on verses but, is needed for things inthe Mag/Info window*/
+/* on verses but, is needed for things inthe Mag/Info window*/
.bold {
- font-weight: bold;
+ font-weight: bold;
}
.italic {
- font-style: italic;
+ font-style: italic;
}
diff --git a/src/frontend/bookmarks/btbookmarkfolder.cpp b/src/frontend/bookmarks/btbookmarkfolder.cpp
index af027a9..3088e99 100644
--- a/src/frontend/bookmarks/btbookmarkfolder.cpp
+++ b/src/frontend/bookmarks/btbookmarkfolder.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,11 +10,12 @@
#include "frontend/bookmarks/btbookmarkfolder.h"
#include <QFileDialog>
+#include "bibletimeapp.h"
#include "frontend/bookmarks/btbookmarkitembase.h"
#include "frontend/bookmarks/btbookmarkitem.h"
#include "frontend/bookmarks/btbookmarkloader.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
BtBookmarkFolder::BtBookmarkFolder(const QString &name, QTreeWidgetItem *parent)
@@ -77,12 +78,9 @@ void BtBookmarkFolder::rename() {
}
void BtBookmarkFolder::update() {
- namespace DU = util::directory;
-
- if (isExpanded() && childCount())
- setIcon(0, DU::getIcon(CResMgr::mainIndex::openedFolder::icon));
- else
- setIcon(0, DU::getIcon(CResMgr::mainIndex::closedFolder::icon));
+ setIcon(0, util::getIcon(isExpanded() && childCount()
+ ? CResMgr::mainIndex::openedFolder::icon
+ : CResMgr::mainIndex::closedFolder::icon));
}
bool BtBookmarkFolder::hasDescendant(QTreeWidgetItem* item) const {
diff --git a/src/frontend/bookmarks/btbookmarkfolder.h b/src/frontend/bookmarks/btbookmarkfolder.h
index 20388df..4f7c80c 100644
--- a/src/frontend/bookmarks/btbookmarkfolder.h
+++ b/src/frontend/bookmarks/btbookmarkfolder.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/btbookmarkitem.cpp b/src/frontend/bookmarks/btbookmarkitem.cpp
index 639d33e..952be22 100644
--- a/src/frontend/bookmarks/btbookmarkitem.cpp
+++ b/src/frontend/bookmarks/btbookmarkitem.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,14 +10,16 @@
#include "frontend/bookmarks/btbookmarkitem.h"
#include <QSharedPointer>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
+#include "backend/managers/cswordbackend.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/keys/cswordversekey.h"
+#include "bibletimeapp.h"
#include "btglobal.h"
#include "frontend/bookmarks/btbookmarkfolder.h"
#include "frontend/bookmarks/bteditbookmarkdialog.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
BtBookmarkItem::BtBookmarkItem(const CSwordModuleInfo *module,
@@ -81,7 +83,7 @@ QString BtBookmarkItem::toolTip() const {
return QString::null;
}
- FilterOptions filterOptions = CBTConfig::getFilterOptionDefaults();
+ FilterOptions filterOptions = btConfig().getFilterOptions();
filterOptions.footnotes = false;
filterOptions.scriptureReferences = false;
CSwordBackend::instance()->setFilterOptions(filterOptions);
@@ -91,7 +93,7 @@ QString BtBookmarkItem::toolTip() const {
k->setKey(key());
// const CLanguageMgr::Language* lang = module()->language();
- // CBTConfig::FontSettingsPair fontPair = CBTConfig::get(lang);
+ // BtConfig::FontSettingsPair fontPair = getBtConfig().getFontForLanguage(lang);
Q_ASSERT(k.data());
QString header = QString::fromLatin1("%1 (%2)")
@@ -134,9 +136,7 @@ void BtBookmarkItem::rename() {
}
void BtBookmarkItem::update() {
- namespace DU = util::directory;
-
- setIcon(0, DU::getIcon(CResMgr::mainIndex::bookmark::icon));
+ setIcon(0, util::getIcon(CResMgr::mainIndex::bookmark::icon));
if (m_title.isEmpty()) {
m_title = QString::fromLatin1("%1 (%2)").arg(key()).arg(module() ? module()->name() : QObject::tr("unknown"));
diff --git a/src/frontend/bookmarks/btbookmarkitem.h b/src/frontend/bookmarks/btbookmarkitem.h
index 89fd412..932d4e0 100644
--- a/src/frontend/bookmarks/btbookmarkitem.h
+++ b/src/frontend/bookmarks/btbookmarkitem.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/btbookmarkitembase.h b/src/frontend/bookmarks/btbookmarkitembase.h
index 2ae1430..630d018 100644
--- a/src/frontend/bookmarks/btbookmarkitembase.h
+++ b/src/frontend/bookmarks/btbookmarkitembase.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/btbookmarkloader.cpp b/src/frontend/bookmarks/btbookmarkloader.cpp
index daebfe1..63e0797 100644
--- a/src/frontend/bookmarks/btbookmarkloader.cpp
+++ b/src/frontend/bookmarks/btbookmarkloader.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 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/btbookmarkloader.h b/src/frontend/bookmarks/btbookmarkloader.h
index 8b819ce..25b56b8 100644
--- a/src/frontend/bookmarks/btbookmarkloader.h
+++ b/src/frontend/bookmarks/btbookmarkloader.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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
index 614498f..1291f56 100644
--- a/src/frontend/bookmarks/bteditbookmarkdialog.cpp
+++ b/src/frontend/bookmarks/bteditbookmarkdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,9 +16,10 @@
#include <QLineEdit>
#include <QTextEdit>
#include <QWidget>
+#include "bibletimeapp.h"
#include "util/cresmgr.h"
-#include "util/dialogutil.h"
-#include "util/directory.h"
+#include "frontend/messagedialog.h"
+#include "util/geticon.h"
BtEditBookmarkDialog::BtEditBookmarkDialog(const QString &key,
@@ -28,12 +29,10 @@ BtEditBookmarkDialog::BtEditBookmarkDialog(const QString &key,
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));
+ setWindowIcon(util::getIcon(CResMgr::mainIndex::bookmark::icon));
m_layout = new QFormLayout;
@@ -57,7 +56,7 @@ BtEditBookmarkDialog::BtEditBookmarkDialog(const QString &key,
| QDialogButtonBox::Ok,
Qt::Horizontal,
this);
- util::prepareDialogBox(m_buttonBox);
+ message::prepareDialogBox(m_buttonBox);
mainLayout->addWidget(m_buttonBox);
QObject::connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
diff --git a/src/frontend/bookmarks/bteditbookmarkdialog.h b/src/frontend/bookmarks/bteditbookmarkdialog.h
index c3455e2..674ccdf 100644
--- a/src/frontend/bookmarks/bteditbookmarkdialog.h
+++ b/src/frontend/bookmarks/bteditbookmarkdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/cbookmarkindex.cpp b/src/frontend/bookmarks/cbookmarkindex.cpp
index 15f272c..1b697d0 100644
--- a/src/frontend/bookmarks/cbookmarkindex.cpp
+++ b/src/frontend/bookmarks/cbookmarkindex.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -28,9 +28,10 @@
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QToolTip>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/referencemanager.h"
+#include "bibletimeapp.h"
#include "frontend/cdragdrop.h"
#include "frontend/cinfodisplay.h"
#include "frontend/cprinter.h"
@@ -38,11 +39,12 @@
#include "frontend/bookmarks/btbookmarkitem.h"
#include "frontend/bookmarks/btbookmarkfolder.h"
#include "frontend/bookmarks/btbookmarkloader.h"
+#include "frontend/messagedialog.h"
#include "frontend/searchdialog/csearchdialog.h"
#include "util/cresmgr.h"
#include "util/tool.h"
#include "util/directory.h"
-#include "util/dialogutil.h"
+#include "util/geticon.h"
#include "bibletime.h"
@@ -52,7 +54,7 @@ CBookmarkIndex::CBookmarkIndex(QWidget *parent)
m_previousEventItem(0) {
setMouseTracking(true);
m_magTimer.setSingleShot(true);
- m_magTimer.setInterval(CBTConfig::get(CBTConfig::magDelay));
+ m_magTimer.setInterval(btConfig().value<int>("GUI/magDelay", 400));
setContextMenuPolicy(Qt::CustomContextMenu);
initView();
initConnections();
@@ -126,12 +128,11 @@ void CBookmarkIndex::initView() {
* than to modify all QAction constructors.
*/
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;
if (pix.isEmpty()) {
action = new QAction(text, parent);
} else {
- action = new QAction(DU::getIcon(pix), text, parent);
+ action = new QAction(util::getIcon(pix), text, parent);
}
QObject::connect(action, SIGNAL(triggered()), receiver, slot);
return action;
@@ -681,7 +682,7 @@ void CBookmarkIndex::printBookmarks() {
return;
}
QSharedPointer<Printing::CPrinter> printer(
- new Printing::CPrinter( this, CBTConfig::getDisplayOptionDefaults(), CBTConfig::getFilterOptionDefaults() )
+ new Printing::CPrinter( this, btConfig().getDisplayOptions(), btConfig().getFilterOptions() )
);
printer->printKeyTree(tree);
}
@@ -699,7 +700,7 @@ void CBookmarkIndex::deleteEntries(bool confirm) {
}
}
- if (util::showQuestion(this, tr("Delete Items"),
+ if (message::showQuestion(this, tr("Delete Items"),
tr("Do you really want to delete the selected items and child-items?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No )
!= QMessageBox::Yes) {
diff --git a/src/frontend/bookmarks/cbookmarkindex.h b/src/frontend/bookmarks/cbookmarkindex.h
index 2875a5d..df4a1c6 100644
--- a/src/frontend/bookmarks/cbookmarkindex.h
+++ b/src/frontend/bookmarks/cbookmarkindex.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/btconfigdialog.cpp b/src/frontend/bookshelfmanager/btconfigdialog.cpp
index 3b82560..e5d0fd1 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 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/btconfigdialog.h b/src/frontend/bookshelfmanager/btconfigdialog.h
index e90c3ed..2525bd8 100644
--- a/src/frontend/bookshelfmanager/btconfigdialog.h
+++ b/src/frontend/bookshelfmanager/btconfigdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/btinstallmgr.cpp b/src/frontend/bookshelfmanager/btinstallmgr.cpp
deleted file mode 100644
index 652ff04..0000000
--- a/src/frontend/bookshelfmanager/btinstallmgr.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/*********
-*
-* 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/btinstallmgr.h"
-
-#include "backend/managers/cswordbackend.h"
-#include "backend/btinstallbackend.h"
-#include <QList>
-#include <QObject>
-#include <QString>
-#include <QStringList>
-
-// Sword includes:
-#include <installmgr.h>
-#include <ftptrans.h>
-
-
-using namespace sword;
-
-BtInstallMgr::BtInstallMgr()
- : InstallMgr(BtInstallBackend::configPath().toLatin1(), this),
- m_totalBytes(1), m_completedBytes(0), m_firstCallOfPreStatus(true)
-{ //use this class also as status reporter
- this->setFTPPassive(true);
-}
-
-BtInstallMgr::~BtInstallMgr() {
- //doesn't really help because it only sets a flag
- terminate(); //make sure to close the connection
-}
-
-bool BtInstallMgr::isUserDisclaimerConfirmed() const {
- // \todo Check from config if it's been confirmed with "don't show this anymore" checked.
- // Create a dialog with the message, checkbox and Continue/Cancel, Cancel as default.
- return true;
-}
-
-void BtInstallMgr::statusUpdate(double dltotal, double dlnow) {
- if (dlnow > dltotal)
- dlnow = dltotal;
-
- int totalPercent = (int)((float)(dlnow + m_completedBytes) / (float)(m_totalBytes) * 100.0);
-
- if (totalPercent > 100) {
- totalPercent = 100;
- }
- else if (totalPercent < 0) {
- totalPercent = 0;
- }
-
- int filePercent = (int)((float)(dlnow) / (float)(dltotal + 1) * 100.0);
- if (filePercent > 100) {
- filePercent = 100;
- }
- else if (filePercent < 0) {
- filePercent = 0;
- }
- //qApp->processEvents();
- emit percentCompleted(totalPercent, filePercent);
-}
-
-
-void BtInstallMgr::preStatus(long totalBytes, long completedBytes, const char* message) {
- if (m_firstCallOfPreStatus) {
- m_firstCallOfPreStatus = false;
- emit downloadStarted();
- }
- m_completedBytes = completedBytes;
- m_totalBytes = (totalBytes > 0) ? totalBytes : 1; //avoid division by zero
-}
diff --git a/src/frontend/bookshelfmanager/btinstallmgr.h b/src/frontend/bookshelfmanager/btinstallmgr.h
deleted file mode 100644
index 7d39440..0000000
--- a/src/frontend/bookshelfmanager/btinstallmgr.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*********
-*
-* 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 NEWBTINSTALLMGR_H
-#define NEWBTINSTALLMGR_H
-
-#include <QObject>
-
-#include <QList>
-#include <QString>
-#include <QStringList>
-
-// Sword includes:
-#include <installmgr.h>
-#include <ftptrans.h>
-
-
-/**
-* Our own reimplementation to provide installation and status bar updates.
-*/
-class BtInstallMgr : public QObject, public sword::InstallMgr, public sword::StatusReporter {
- Q_OBJECT
- public:
- BtInstallMgr();
- ~BtInstallMgr();
-
- /** Re-implemented from sword::InstallMgr. */
- bool isUserDisclaimerConfirmed() const;
-
- signals:
- /** Download status. Percent of total and file.*/
- void percentCompleted(const int total, const int file);
- void downloadStarted();
-
- protected:
- /**
- Reimplementation of sword::StatusReporter::statusUpdate().
- */
- 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.
- */
- void preStatus(long totalBytes, long completedBytes, const char *message);
-
- private:
- long m_totalBytes;
- long m_completedBytes;
- bool m_firstCallOfPreStatus;
-};
-
-#endif
diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
index 42febaa..8eebde6 100644
--- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
+++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
@@ -2,20 +2,24 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 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 "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/managers/cswordbackend.h"
#include "frontend/bookshelfmanager/indexpage/btindexpage.h"
#include "frontend/bookshelfmanager/installpage/btinstallpage.h"
#include "frontend/bookshelfmanager/removepage/btremovepage.h"
+namespace {
+const QString GeometryKey = "GUI/BookshelfManager/ModuleManagerDialog/geometry";
+} // anonymous namespace
+
static BtModuleManagerDialog *m_staticModuleManagerDialog = 0;
BtModuleManagerDialog* BtModuleManagerDialog::getInstance(QWidget *parent,
@@ -59,13 +63,9 @@ BtModuleManagerDialog::~BtModuleManagerDialog() {
}
void BtModuleManagerDialog::loadDialogSettings() {
- resize(CBTConfig::get(CBTConfig::bookshelfWidth), CBTConfig::get(CBTConfig::bookshelfHeight));
- move(CBTConfig::get(CBTConfig::bookshelfPosX), CBTConfig::get(CBTConfig::bookshelfPosY));
+ restoreGeometry(btConfig().value<QByteArray>(GeometryKey, QByteArray()));
}
void BtModuleManagerDialog::saveDialogSettings() const {
- CBTConfig::set(CBTConfig::bookshelfWidth, size().width());
- CBTConfig::set(CBTConfig::bookshelfHeight, size().height());
- CBTConfig::set(CBTConfig::bookshelfPosX, x());
- CBTConfig::set(CBTConfig::bookshelfPosY, y());
+ btConfig().setValue(GeometryKey, saveGeometry());
}
diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
index 01ef594..4d94026 100644
--- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
+++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/cswordsetupinstallsourcesdialog.cpp b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
index f40d8c3..646efab 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,10 +25,13 @@
#include <QProgressDialog>
#include <QApplication>
#include "backend/btinstallbackend.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
const QString PROTO_FILE( QObject::tr("Local") ); //Local path
-const QString PROTO_FTP( QObject::tr("Remote") ); //Remote path
+const QString PROTO_FTP( QObject::tr("Remote FTP") ); //Remote path
+const QString PROTO_SFTP( QObject::tr("Remote SFTP") );
+const QString PROTO_HTTP( QObject::tr("Remote HTTP") );
+const QString PROTO_HTTPS( QObject::tr("Remote HTTPS") );
CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *parent*/)
: QDialog(),
@@ -39,7 +42,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
mainLayout->setMargin( 10 );
mainLayout->setSpacing( 5 );
- QHBoxLayout *captionLayout = new QHBoxLayout( this );
+ QHBoxLayout *captionLayout = new QHBoxLayout;
mainLayout->addLayout(captionLayout);
QLabel *label = new QLabel( tr("Caption"), this );
captionLayout->addWidget( label );
@@ -50,7 +53,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
mainLayout->addSpacing( 10 );
- QGridLayout* layout = new QGridLayout( this );
+ QGridLayout* layout = new QGridLayout;
layout->setSpacing(3);
layout->setMargin(3);
mainLayout->addLayout(layout);
@@ -68,6 +71,9 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
m_protocolCombo = new QComboBox( this );
layout->addWidget(m_protocolCombo, 1, 0);
m_protocolCombo->addItem( PROTO_FTP );
+ m_protocolCombo->addItem( PROTO_SFTP );
+ m_protocolCombo->addItem( PROTO_HTTP );
+ m_protocolCombo->addItem( PROTO_HTTPS);
m_protocolCombo->addItem( PROTO_FILE );
m_serverEdit = new QLineEdit( this );
@@ -81,7 +87,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
mainLayout->addSpacing( 10 );
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel | QDialogButtonBox::Save, Qt::Horizontal, this);
- util::prepareDialogBox(buttonBox);
+ message::prepareDialogBox(buttonBox);
QPushButton* getListButton = new QPushButton(tr("Get list..."), this);
getListButton->setToolTip(tr("Download a list of sources from CrossWire server and add sources"));
buttonBox->addButton(getListButton, QDialogButtonBox::ActionRole);
@@ -95,7 +101,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
void CSwordSetupInstallSourcesDialog::slotOk() {
//run a few tests to validate the input first
if ( m_captionEdit->text().trimmed().isEmpty() ) { //no caption
- util::showInformation( this, tr( "Error" ), tr("Please provide a caption."));
+ message::showInformation( this, tr( "Error" ), tr("Please provide a caption."));
return;
}
@@ -103,25 +109,25 @@ void CSwordSetupInstallSourcesDialog::slotOk() {
//sword::InstallSource is = BTInstallMgr::Tool::RemoteConfig::source( &iMgr, 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" ),
+ message::showInformation( this, tr( "Error" ),
tr("A source with this caption already exists. Please provide a different caption."));
return;
}
- if ( m_protocolCombo->currentText() == PROTO_FTP &&
+ if ( this->isRemote(m_protocolCombo->currentText()) &&
m_serverEdit->text().trimmed().isEmpty() ) { //no server name
- util::showInformation( this, tr( "Error" ), tr("Please provide a server name."));
+ message::showInformation( this, tr( "Error" ), tr("Please provide a server name."));
return;
}
if ( m_protocolCombo->currentText() == PROTO_FILE) {
const QFileInfo fi( m_pathEdit->text() );
if (!fi.exists() || !fi.isReadable()) { //no valid and readable path
- util::showInformation( this, tr( "Error" ), tr("Please provide a valid, readable path."));
+ message::showInformation( this, tr( "Error" ), tr("Please provide a valid, readable path."));
return;
}
else if ( m_pathEdit->text().isEmpty() ) {
- util::showInformation( this, tr( "Error" ), tr("Please provide a path."));
+ message::showInformation( this, tr( "Error" ), tr("Please provide a path."));
}
}
@@ -130,7 +136,7 @@ void CSwordSetupInstallSourcesDialog::slotOk() {
}
void CSwordSetupInstallSourcesDialog::slotProtocolChanged() {
- if (m_protocolCombo->currentText() == PROTO_FTP) { //REMOTE
+ if (this->isRemote(m_protocolCombo->currentText())) { //REMOTE
m_serverLabel->setEnabled(true);
m_serverEdit->setEnabled(true);
}
@@ -152,7 +158,7 @@ void CSwordSetupInstallSourcesDialog::slotProtocolChanged() {
void CSwordSetupInstallSourcesDialog::slotGetListClicked() {
QString message(tr("List of sources will be downloaded from a remote server. Sources will be added to the current list. New source will replace an old one if it has the same label. You can later remove the sources you don't want to keep.\n\nDo you want to continue?"));
- QMessageBox::StandardButton answer = util::showQuestion(this, tr("Get source list from remote server?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+ QMessageBox::StandardButton answer = message::showQuestion(this, tr("Get source list from remote server?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (answer == QMessageBox::No) {
return;
}
@@ -206,9 +212,20 @@ void CSwordSetupInstallSourcesDialog::slotRefreshCanceled() {
sword::InstallSource CSwordSetupInstallSourcesDialog::getSource() {
sword::InstallSource newSource(""); //empty, invalid Source
- if (m_protocolCombo->currentText() == PROTO_FTP) {
- newSource.type = "FTP";
- newSource.source = m_serverEdit->text().toUtf8();
+ if (this->isRemote(m_protocolCombo->currentText())) {
+ if (m_protocolCombo->currentText() == PROTO_FTP) {
+ newSource.type = "FTP";
+ }
+ else if (m_protocolCombo->currentText() == PROTO_SFTP) {
+ newSource.type = "SFTP";
+ }
+ else if (m_protocolCombo->currentText() == PROTO_HTTP) {
+ newSource.type = "HTTP";
+ }
+ else if (m_protocolCombo->currentText() == PROTO_HTTPS) {
+ newSource.type = "HTTPS";
+ }
+ newSource.source = m_serverEdit->text().toUtf8();
//a message to the user would be nice, but we're in message freeze right now (1.5.1)
if (m_serverEdit->text().right(1) == "/") { //remove a trailing slash
newSource.source = m_serverEdit->text().mid(0, m_serverEdit->text().length() - 1).toUtf8();
@@ -225,4 +242,7 @@ sword::InstallSource CSwordSetupInstallSourcesDialog::getSource() {
return newSource;
}
-
+bool CSwordSetupInstallSourcesDialog::isRemote(const QString& sourceType) {
+ return sourceType == PROTO_FTP || sourceType == PROTO_SFTP ||
+ sourceType == PROTO_HTTP || sourceType == PROTO_HTTPS;
+}
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
index e69e9a9..20bf461 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +14,7 @@
#include <QDialog>
-#include "frontend/bookshelfmanager/btinstallmgr.h"
+#include "backend/btinstallmgr.h"
// Sword includes:
#include <installmgr.h>
@@ -41,6 +43,7 @@ class CSwordSetupInstallSourcesDialog : public QDialog {
void slotRefreshProgress(const int, const int current);
private:
+ bool isRemote(const QString&);
QLabel *m_serverLabel;
QLineEdit *m_captionEdit, *m_serverEdit, *m_pathEdit;
QComboBox *m_protocolCombo;
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
index 960f5c8..b117f80 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,21 +16,20 @@
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QVBoxLayout>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
+#include "bibletimeapp.h"
#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
#include "frontend/btmoduleindexdialog.h"
-#include "util/directory.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
BtIndexPage::BtIndexPage(BtModuleManagerDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::bookshelfmgr::indexpage::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::bookshelfmgr::indexpage::icon), parent)
{
- namespace DU = util::directory;
-
QVBoxLayout *vboxLayout = new QVBoxLayout(this);
QHBoxLayout *hboxLayout;
@@ -60,11 +59,11 @@ BtIndexPage::BtIndexPage(BtModuleManagerDialog *parent)
//m_moduleList->setTextAlignment(1, Qt::AlignRight); see doc...
m_moduleList->setSortingEnabled(false);
- m_autoDeleteOrphanedIndicesBox->setChecked( CBTConfig::get( CBTConfig::autoDeleteOrphanedIndices ) );
+ m_autoDeleteOrphanedIndicesBox->setChecked( btConfig().value<bool>("settings/behaviour/autoDeleteOrphanedIndices", true) );
// icons for our buttons
- m_createButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::indexpage::create_icon));
- m_deleteButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::indexpage::delete_icon));
+ m_createButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::indexpage::create_icon));
+ m_deleteButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::indexpage::delete_icon));
// connect our signals/slots
connect(m_createButton, SIGNAL(clicked()),
@@ -78,7 +77,7 @@ BtIndexPage::BtIndexPage(BtModuleManagerDialog *parent)
}
BtIndexPage::~BtIndexPage() {
- CBTConfig::set( CBTConfig::autoDeleteOrphanedIndices, m_autoDeleteOrphanedIndicesBox->isChecked() );
+ btConfig().setValue("settings/behaviour/autoDeleteOrphanedIndices", m_autoDeleteOrphanedIndicesBox->isChecked() );
}
/** Populates the module list with installed modules and orphaned indices */
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.h b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
index 303c6ab..100de17 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.h
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/installpage/btinstallmodulechooserdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
index 01ca55b..a689c05 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 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/installpage/btinstallmodulechooserdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
index 070df6f..49f1978 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 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/installpage/btinstallmodulechooserdialogmodel.cpp b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp
index 880ea6a..6f0fc9b 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -32,10 +32,6 @@ BtInstallModuleChooserDialogModel::BtInstallModuleChooserDialogModel(
Qt::DirectConnection);
}
-BtInstallModuleChooserDialogModel::~BtInstallModuleChooserDialogModel() {
- // Intentionally empty
-}
-
QVariant BtInstallModuleChooserDialogModel::data(const QModelIndex &i, int role) const {
switch (role) {
case Qt::BackgroundRole:
@@ -111,14 +107,11 @@ void BtInstallModuleChooserDialogModel::parentDataChanged(const QModelIndex &top
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()) {
+bool BtInstallModuleChooserDialogModel::isMulti(CSwordModuleInfo * m1) const {
+ if (m1 != 0 && checkedModules().contains(m1))
+ Q_FOREACH (CSwordModuleInfo * m2, modules())
+ if (m1 != m2 && checkedModules().contains(m2) && m1->name() == m2->name())
return true;
- }
- }
- }
return false;
}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h
index 6120fa8..406b89c 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -22,7 +22,6 @@ 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;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
index 9c7955a..5f8bfb8 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,12 +16,12 @@
#include <QHeaderView>
#include <QLabel>
#include <QPushButton>
-#include <QSettings>
#include <QSharedPointer>
#include <QStackedLayout>
#include <QToolButton>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/btinstallbackend.h"
+#include "bibletimeapp.h"
#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
#include "frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h"
#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h"
@@ -29,9 +29,10 @@
#include "frontend/bookshelfmanager/installpage/btinstallpathdialog.h"
#include "frontend/bookshelfmanager/installpage/btinstallprogressdialog.h"
#include "frontend/btbookshelfview.h"
+#include "frontend/messagedialog.h"
#include "util/cresmgr.h"
-#include "util/dialogutil.h"
#include "util/directory.h"
+#include "util/geticon.h"
#include "util/tool.h"
@@ -39,6 +40,7 @@ namespace {
const QString groupingOrderKey ("GUI/BookshelfManager/InstallPage/grouping");
const QString headerStateKey ("GUI/BookshelfManager/InstallPage/headerState");
const QString selectedModuleKey("GUI/BookshelfManager/InstallPage/selectedModule");
+const QString installPathKey ("GUI/BookshelfManager/InstallPage/installPathIndex");
} // anonymous namespace
@@ -47,13 +49,13 @@ const QString selectedModuleKey("GUI/BookshelfManager/InstallPage/selectedModule
// *********************************************************
BtInstallPage::BtInstallPage(BtModuleManagerDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::bookshelfmgr::installpage::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::bookshelfmgr::installpage::icon), parent)
, m_groupingOrder(groupingOrderKey)
, m_modulesSelected(0)
, m_modulesSelectedSources(0)
{
// Read settings:
- m_headerState = CBTConfig::getConfig()->value(headerStateKey).toByteArray();
+ m_headerState = btConfig().value<QByteArray>(headerStateKey, QByteArray());
// Initialize widgets:
initView();
@@ -71,8 +73,6 @@ QString BtInstallPage::selectedInstallPath() {
}
void BtInstallPage::initView() {
- namespace DU = util::directory;
-
// Warning label:
m_warningLabel = new QLabel(this);
@@ -85,10 +85,10 @@ void BtInstallPage::initView() {
initSourcesCombo();
m_sourceAddButton = new QPushButton(this);
- m_sourceAddButton ->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::add_icon));
+ m_sourceAddButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::add_icon));
m_sourceDeleteButton = new QPushButton(this);
- m_sourceDeleteButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::delete_icon));
+ m_sourceDeleteButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::delete_icon));
QHBoxLayout *sourceChooserLayout = new QHBoxLayout();
sourceChooserLayout->setContentsMargins(0, 8, 0, 0);
@@ -119,10 +119,10 @@ void BtInstallPage::initView() {
initPathCombo();
m_configurePathButton = new QToolButton(this);
- m_configurePathButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::path_icon));
+ m_configurePathButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::path_icon));
m_installButton = new QPushButton(this);
- m_installButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::install_icon));
+ m_installButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::installpage::install_icon));
m_installButton->setEnabled(false);
QHBoxLayout *pathLayout = new QHBoxLayout();
@@ -175,7 +175,7 @@ void BtInstallPage::initPathCombo() {
}
// choose the current value from config but check whether we have so many items
- int configValue = CBTConfig::get(CBTConfig::installPathIndex);
+ int configValue = btConfig().value<int>(installPathKey, 0);
int index = configValue > (m_pathCombo->count() - 1) ? m_pathCombo->count() - 1 : configValue;
m_pathCombo->setCurrentIndex(index);
}
@@ -202,7 +202,7 @@ void BtInstallPage::initSourcesCombo() {
}
// Read selected module from config:
- QString selected = CBTConfig::getConfig()->value(selectedModuleKey).toString();
+ const QString selected = btConfig().value<QString>(selectedModuleKey, QString());
// Populate combo box
bool selectionOk = false;
@@ -219,7 +219,7 @@ void BtInstallPage::initSourcesCombo() {
// Set selection, if it wasn't properly configured:
if (!selectionOk) {
m_sourceComboBox->setCurrentIndex(0);
- CBTConfig::getConfig()->setValue(selectedModuleKey, sourceList.at(0));
+ btConfig().setValue(selectedModuleKey, sourceList.at(0));
}
}
@@ -268,7 +268,7 @@ void BtInstallPage::retranslateUi() {
m_sourceGroupBox->setTitle(tr("Select installation &source:"));
m_sourceAddButton->setText(tr("&Add..."));
- m_sourceAddButton ->setToolTip(tr("Add new source"));
+ m_sourceAddButton->setToolTip(tr("Add new source"));
m_sourceDeleteButton->setText(tr("&Delete..."));
m_sourceDeleteButton->setToolTip(tr("Delete this source"));
@@ -293,7 +293,7 @@ void BtInstallPage::slotHeaderChanged() {
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);
+ btConfig().setValue(headerStateKey, m_headerState);
}
void BtInstallPage::slotInstall() {
@@ -310,7 +310,7 @@ void BtInstallPage::slotInstall() {
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);
+ const int result = message::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;
}
@@ -327,22 +327,17 @@ void BtInstallPage::slotInstall() {
}
if (dlg->exec() == QDialog::Accepted) {
- QSet<const CSwordModuleInfo*> cm;
- Q_FOREACH(const CSwordModuleInfo *m, dlg->checkedModules()) {
- cm.insert(m);
- }
-
- if (cm.empty())
+ QList<CSwordModuleInfo *> modules(dlg->checkedModules().toList());
+ if (modules.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...)
// progressDialog is WA_DeleteOnClose
- BtInstallProgressDialog *progressDialog = new BtInstallProgressDialog(cm, selectedInstallPath(), this);
-
+ typedef BtInstallProgressDialog BIPD;
+ BIPD * const progressDialog = new BIPD(modules, selectedInstallPath(), this);
m_installButton->setEnabled(false);
-
// the progress dialog is now modal, it can be made modeless later.
progressDialog->exec();
@@ -351,7 +346,7 @@ void BtInstallPage::slotInstall() {
}
void BtInstallPage::slotPathChanged(const QString& /*pathText*/) {
- CBTConfig::set(CBTConfig::installPathIndex, m_pathCombo->currentIndex( ) );
+ btConfig().setValue(installPathKey, m_pathCombo->currentIndex());
}
void BtInstallPage::slotEditPaths() {
@@ -390,26 +385,35 @@ void BtInstallPage::slotSourceAdd() {
void BtInstallPage::slotSourceDelete() {
typedef BtInstallPageWorksWidget IPWW;
- int ret = util::showWarning(this, tr("Delete Source?"),
+ int ret = message::showWarning(this, tr("Delete Source?"),
tr("Do you really want to delete this source?"),
QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::Yes) {
+ qApp->setOverrideCursor(Qt::WaitCursor);
+ window()->setEnabled(false);
Q_ASSERT(qobject_cast<IPWW*>(m_worksLayout->currentWidget()));
IPWW *w = static_cast<IPWW*>(m_worksLayout->currentWidget());
+ m_sourceMap.remove(QString(w->installSource().caption));
w->deleteSource();
initSourcesCombo();
slotSourceIndexChanged(m_sourceComboBox->currentIndex());
delete w;
+ window()->setEnabled(true);
+ qApp->restoreOverrideCursor();
}
}
void BtInstallPage::slotSourceIndexChanged(int index) {
- if (index < 0) index = 0;
+ if (index < 0) {
+ if(!m_sourceComboBox->count())
+ return;
+ index = 0;
+ }
/// \todo use pointers instead of text
QString moduleName = m_sourceComboBox->itemText(index);
- CBTConfig::getConfig()->setValue(selectedModuleKey, moduleName);
+ btConfig().setValue(selectedModuleKey, moduleName);
activateSource(BtInstallBackend::source(moduleName));
}
@@ -431,9 +435,10 @@ void BtInstallPage::slotSelectedModulesChanged() {
void BtInstallPage::slotSwordSetupChanged() {
QString moduleName = m_sourceComboBox->currentText();
- initSourcesCombo();
+ // clean m_sourceMap before initSourcesCombo() make too much work
qDeleteAll(m_sourceMap.values());
m_sourceMap.clear();
+ initSourcesCombo();
m_sourceComboBox->setCurrentIndex(m_sourceComboBox->findText(moduleName));
initPathCombo();
m_modulesSelected = 0;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.h b/src/frontend/bookshelfmanager/installpage/btinstallpage.h
index 0cb6724..fe791cf 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/installpage/btinstallpagemodel.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp
index 9aa6743..06e97f8 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -27,10 +27,6 @@ BtInstallPageModel::BtInstallPageModel(const Grouping &grouping, QObject *parent
setCheckable(true);
}
-BtInstallPageModel::~BtInstallPageModel() {
- // Intentionally empty
-}
-
QVariant BtInstallPageModel::data(const QModelIndex &i, int role) const {
switch (role) {
case Qt::DisplayRole:
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h
index 8a02409..009aa15 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpagemodel.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -22,7 +22,6 @@ 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;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp
index 0bb8829..629a69c 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,12 +16,13 @@
#include <QToolButton>
#include "backend/btinstallbackend.h"
#include "backend/managers/cswordbackend.h"
+#include "bibletimeapp.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"
+#include "util/geticon.h"
namespace {
@@ -55,7 +56,6 @@ BtInstallPageWorksWidget::BtInstallPageWorksWidget(
, m_backend(0)
, m_myModel(0)
{
- namespace DU = util::directory;
setTreeModel(new BtInstallPageModel(g, this));
@@ -65,15 +65,20 @@ BtInstallPageWorksWidget::BtInstallPageWorksWidget(
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));
+ m_sourceRefreshButton->setToolTip(tr("Refresh the list of works from this source"));
+ m_sourceRefreshButton->setIcon(util::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);
+ 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);
}
BtInstallPageWorksWidget::~BtInstallPageWorksWidget() {
@@ -83,7 +88,6 @@ BtInstallPageWorksWidget::~BtInstallPageWorksWidget() {
void BtInstallPageWorksWidget::deleteSource() {
qDebug() << "Deleting source" << m_source.caption;
- setEnabled(false);
m_myModel->clear();
BtInstallBackend::deleteSource(QString(m_source.caption));
}
@@ -103,28 +107,6 @@ void BtInstallPageWorksWidget::updateTree() {
}
}
-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;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h
index 1a9bd8f..d02e99e 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpageworkswidget.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -39,12 +41,8 @@ class BtInstallPageWorksWidget: public BtBookshelfWidget {
void updateTree();
- /** Reimplemented from QWidget. */
- virtual void paintEvent(QPaintEvent *e);
-
private slots:
- void slotDelayedInit();
void slotSourceRefresh();
private: /* Fields: */
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
index b4deb51..109bbd9 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-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,9 +21,11 @@
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include "backend/btinstallbackend.h"
-#include "util/dialogutil.h"
+#include "bibletimeapp.h"
+#include "frontend/messagedialog.h"
#include "util/directory.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
@@ -77,19 +79,19 @@ BtInstallPathDialog::BtInstallPathDialog() {
m_addButton = new QPushButton(tr("&Add..."), this);
m_addButton->setToolTip(tr("Add new folder"));
- m_addButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::paths::add_icon));
+ m_addButton->setIcon(util::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->setToolTip(tr("Edit the selected folder"));
- m_editButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::paths::edit_icon));
+ m_editButton->setIcon(util::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->setToolTip(tr("Remove the selected folder"));
- m_removeButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::paths::remove_icon));
+ m_removeButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::paths::remove_icon));
connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveClicked()));
buttonLayout->addWidget(m_removeButton);
@@ -102,7 +104,7 @@ BtInstallPathDialog::BtInstallPathDialog() {
QDialogButtonBox* buttonBox = new QDialogButtonBox(this);
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::NoButton | QDialogButtonBox::Ok);
- util::prepareDialogBox(buttonBox);
+ message::prepareDialogBox(buttonBox);
mainLayout->addWidget(buttonBox);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
@@ -177,7 +179,7 @@ void BtInstallPathDialog::slotEditClicked() {
if (dir.isReadable()) {
const QFileInfo fi( dir.canonicalPath() );
if (!fi.exists() || !fi.isWritable()) {
- const int result = util::showWarning(this, tr("Use Folder?"), tr("This folder is not writable, so works can not be installed here using BibleTime. Do you want to use this folder instead of the previous value?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+ const int result = message::showWarning(this, tr("Use Folder?"), tr("This folder is not writable, so works can not be installed here using BibleTime. Do you want to use this folder instead of the previous value?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (result != QMessageBox::Yes) return;
}
//i->setText(0, dir.absolutePath()); // absolute, not canonical
@@ -197,7 +199,7 @@ void BtInstallPathDialog::slotAddClicked() {
if (dir.isReadable()) {
const QFileInfo fi( dir.canonicalPath() );
if (!fi.exists() || !fi.isWritable()) {
- const int result = util::showWarning(this, tr("Use Folder?"), tr("This folder is not writable, so works can not be installed here using BibleTime. Do you still want to add it to the list of bookshelf folders?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+ const int result = message::showWarning(this, tr("Use Folder?"), tr("This folder is not writable, so works can not be installed here using BibleTime. Do you still want to add it to the list of bookshelf folders?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (result != QMessageBox::Yes) {
return;
}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
index 9adf6bc..de4c69a 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 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/installpage/btinstallprogressdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
index cc862fa..53fd274 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,21 +21,24 @@
#include <QTreeWidgetItem>
#include <QVBoxLayout>
#include "backend/managers/cswordbackend.h"
-#include "frontend/bookshelfmanager/installpage/btinstallthread.h"
+#include "backend/btinstallthread.h"
-BtInstallProgressDialog::BtInstallProgressDialog(
- const QSet<const CSwordModuleInfo*> &modules,
- const QString &destination, QWidget *parent, Qt::WindowFlags flags)
+BtInstallProgressDialog::BtInstallProgressDialog(const QList<CSwordModuleInfo *> & modules,
+ const QString & destination,
+ QWidget * parent,
+ Qt::WindowFlags flags)
: QDialog(parent, flags)
+ , m_nextInstallIndex(0)
{
// we want this dialog to be deleted when user closes it or the downloads are completed
setAttribute(Qt::WA_DeleteOnClose, true);
+
setWindowTitle(tr("Install Progress"));
- //create the dialog which shows the status and lets the user stop installation
+
m_statusWidget = new QTreeWidget();
m_statusWidget->setRootIsDecorated(false);
- m_statusWidget->setHeaderLabels(QStringList(tr("Work")) << tr("Progress") << QString::null);
+ m_statusWidget->setHeaderLabels(QStringList(tr("Work")) << tr("Progress"));
m_statusWidget->header()->setStretchLastSection(false);
#if QT_VERSION < 0x050000
m_statusWidget->header()->setResizeMode(1, QHeaderView::Stretch);
@@ -44,190 +47,117 @@ BtInstallProgressDialog::BtInstallProgressDialog(
m_statusWidget->header()->setSectionResizeMode(1, QHeaderView::Stretch);
m_statusWidget->header()->setSectionsMovable(false);
#endif
- //m_statusWidget->setColumnWidth(1, util::tool::mWidth(m_statusWidget, 2));
-
- Q_FOREACH(const CSwordModuleInfo *module, modules) {
- const QString sourceName(module->property("installSourceName").toString());
- // create a thread for this module
- BtInstallThread* thread = new BtInstallThread(module->name(), sourceName, destination);
- m_waitingThreads.insert(sourceName, thread);
- m_threadsByModule.insert(module->name(), thread);
- // progress widget/item
- QPushButton* stopButton = new QPushButton(tr("Stop"), m_statusWidget);
- stopButton->setFixedSize(stopButton->sizeHint());
-
- // the item
- QTreeWidgetItem* progressItem = new QTreeWidgetItem(m_statusWidget);
- m_statusWidget->setColumnWidth(2, stopButton->sizeHint().width());
- progressItem->setSizeHint(2, stopButton->sizeHint());
+
+ Q_FOREACH(const CSwordModuleInfo * module, modules) {
+ QTreeWidgetItem * progressItem = new QTreeWidgetItem(m_statusWidget);
progressItem->setText(0, module->name());
- progressItem->setFlags(Qt::ItemIsEnabled);
- m_statusWidget->setItemWidget(progressItem, 2, stopButton);
+ progressItem->setIcon(0, module->moduleIcon());
progressItem->setText(1, tr("Waiting for turn..."));
-
- //connect the signals between the dialog, items and threads
- QObject::connect(stopButton, SIGNAL(clicked()), thread, SLOT(slotStopInstall()), Qt::QueuedConnection);
- QObject::connect(thread, SIGNAL(installStopped(QString, QString)), this, SLOT(slotOneItemStopped(QString, QString)), Qt::QueuedConnection);
- //is this needed or is statusUpdated enough?
- QObject::connect(thread, SIGNAL(installCompleted(QString, QString, int)), this, SLOT(slotOneItemCompleted(QString, QString, int)), Qt::QueuedConnection);
- QObject::connect(thread, SIGNAL(statusUpdated(QString, int)), this, SLOT(slotStatusUpdated(QString, int)), Qt::QueuedConnection);
- QObject::connect(thread, SIGNAL(downloadStarted(QString)), this, SLOT(slotDownloadStarted(QString)), Qt::QueuedConnection);
-
- QObject::connect(thread, SIGNAL(preparingInstall(QString, QString)), this, SLOT(slotInstallStarted(QString, QString)), Qt::QueuedConnection);
+ progressItem->setFlags(Qt::ItemIsEnabled);
}
m_statusWidget->setMinimumWidth(m_statusWidget->size().width());
- QPushButton* stopAllButton = new QPushButton(tr("Stop All"), this);
+ m_stopAllButton = new QPushButton(tr("Stop All"), this);
- QVBoxLayout* layout = new QVBoxLayout(this);
+ QVBoxLayout * layout = new QVBoxLayout(this);
layout->addWidget(m_statusWidget);
- layout->addWidget(stopAllButton);
-
- connect(stopAllButton, SIGNAL(clicked()), SLOT(slotStopInstall()) );
-
- qApp->processEvents();
-
- startThreads();
-
+ layout->addWidget(m_stopAllButton);
+
+ connect(m_stopAllButton, SIGNAL(clicked()),
+ this, SLOT(slotStopInstall()));
+
+ m_thread = new BtInstallThread(modules, destination, this);
+ // Connect the signals between the dialog, items and threads
+ connect(m_thread, SIGNAL(preparingInstall(int)),
+ this, SLOT(slotInstallStarted(int)),
+ Qt::QueuedConnection);
+ connect(m_thread, SIGNAL(downloadStarted(int)),
+ this, SLOT(slotDownloadStarted(int)),
+ Qt::QueuedConnection);
+ connect(m_thread, SIGNAL(statusUpdated(int, int)),
+ this, SLOT(slotStatusUpdated(int, int)),
+ Qt::QueuedConnection);
+ connect(m_thread, SIGNAL(installCompleted(int, bool)),
+ this, SLOT(slotOneItemCompleted(int, bool)),
+ Qt::QueuedConnection);
+ connect(m_thread, SIGNAL(finished()),
+ this, SLOT(slotThreadFinished()),
+ Qt::QueuedConnection);
+ #if QT_VERSION < 0x050000
+ connect(m_thread, SIGNAL(terminated()),
+ this, SLOT(slotThreadFinished()),
+ Qt::QueuedConnection);
+ #endif
+ m_thread->start();
}
-void BtInstallProgressDialog::startThreads() {
- // remove all the updated modules from the backend module list at once
- //foreach (QString mName, m_threadsByModule.keys()) {
- //}
- //QList<CSwordModuleInfo*> CSwordBackend::instance()()->takeModulesFromList(m_threadsByModule.keys());
- //loop through the multimap of the waiting threads, start at most 3 threads for each source
- QMultiMap<QString, BtInstallThread*>::iterator threadIterator = m_waitingThreads.end();
-// concurrency is disabled for now
-// while (threadIterator != m_waitingThreads.end()) {
-// QString sourceName = threadIterator.key();
-// if (m_runningThreads.values(sourceName).count() < 3) {
-// BtInstallThread* t = threadIterator.value();
-// m_runningThreads.insert(sourceName, t);
-// threadIterator = m_waitingThreads.erase(threadIterator);
-// t->start();
-// }
-// else ++threadIterator;
-// }
- //non-concurrent
- if (threadIterator != m_waitingThreads.begin()) {
- // go to the last item which is actually the first in the visible list
- // because the iterator is reversed compared to insert order
- threadIterator--;
- QString sourceName = threadIterator.key();
- BtInstallThread* t = threadIterator.value();
- m_runningThreads.insert(sourceName, t);
- threadIterator = m_waitingThreads.erase(threadIterator);
- t->start();
- }
+BtInstallProgressDialog::~BtInstallProgressDialog() {
+ m_thread->wait();
+ delete m_thread;
}
-void BtInstallProgressDialog::slotOneItemCompleted(QString module, QString source, int status) {
- QString message;
- //status comes from the sword installer.
- /// \todo Additionally we should check that there are files really installed.
- if (status != 0) {
- message = tr("Failed");
- }
- else {
- message = tr("Completed");
+void BtInstallProgressDialog::slotStopInstall() {
+ m_stopAllButton->setDisabled(true);
+ m_thread->stopInstall();
+ for (int i = m_nextInstallIndex; i < m_statusWidget->topLevelItemCount(); i++) {
+ QTreeWidgetItem * const item = m_statusWidget->topLevelItem(i);
+ item->setText(1, QString::null);
+ item->setDisabled(true);
}
- oneItemStoppedOrCompleted(module, source, message);
-}
-
-void BtInstallProgressDialog::slotOneItemStopped(QString module, QString source) {
- oneItemStoppedOrCompleted(module, source, tr("Cancelled"));
}
-void BtInstallProgressDialog::oneItemStoppedOrCompleted(QString module, QString source, QString statusMessage) {
- qDebug() << "\n**********************************\nBtInstallProgressDialog::oneItemStoppedOrCompleted" << module << statusMessage << "\n******************************************";
- // update the list item
- m_statusWidget->setItemWidget(getItem(module), 1, 0);
- getItem(module)->setText(1, statusMessage);
- m_statusWidget->itemWidget(getItem(module), 2)->setEnabled(false);
- getItem(module)->setDisabled(true);
-
- qDebug() << "remove from threads maps" << source << m_threadsByModule.value(module);
- m_runningThreads.remove(source, m_threadsByModule.value(module));
- m_waitingThreads.remove(source, m_threadsByModule.value(module));
-
-//concurrency is disabled for now
-// //start a waiting thread if there are any
-// QList<BtInstallThread*> threadsForSource = m_waitingThreads.values(source);
-// if (!threadsForSource.isEmpty()) {
-// BtInstallThread* thread = threadsForSource.at(0);
-// m_waitingThreads.remove(source, thread);
-// m_runningThreads.insert(source, thread);
-// thread->start();
-// }
-
- //non-concurrent
- QMultiMap<QString, BtInstallThread*>::iterator threadIterator = m_waitingThreads.end();
- if (m_runningThreads.isEmpty() && threadIterator != m_waitingThreads.begin()) {
- threadIterator--; // the last item
- QString sourceName = threadIterator.key();
- BtInstallThread* t = threadIterator.value();
- m_runningThreads.insert(sourceName, t);
- threadIterator = m_waitingThreads.erase(threadIterator);
- t->start();
- }
-
- if (threadsDone()) {
- qDebug() << "close the dialog";
- close();
- }
+void BtInstallProgressDialog::slotInstallStarted(int moduleIndex) {
+ Q_ASSERT(moduleIndex == m_nextInstallIndex);
+ m_nextInstallIndex++;
+ QTreeWidgetItem * const item = m_statusWidget->topLevelItem(moduleIndex);
+ item->setText(1, tr("Preparing install..."));
+ m_statusWidget->scrollToItem(item);
}
-void BtInstallProgressDialog::slotStopInstall() {
- qDebug() << "BtInstallProgressDialog::slotStopInstall";
-
- // Clear the waiting threads map, stop all running threads.
-
- m_waitingThreads.clear();
- if (m_runningThreads.count() > 0) {
- foreach(BtInstallThread* thread, m_runningThreads) {
- thread->slotStopInstall();
- }
- }
- else {
- close();
- }
+void BtInstallProgressDialog::slotDownloadStarted(int moduleIndex) {
+ QTreeWidgetItem * const item = m_statusWidget->topLevelItem(moduleIndex);
+ item->setText(1, QString::null);
+ getOrCreateProgressBar(item)->setValue(0);
}
-void BtInstallProgressDialog::slotStatusUpdated(QString module, int status) {
+void BtInstallProgressDialog::slotStatusUpdated(int moduleIndex, int status) {
// find the progress bar for this module and update the value
- QWidget* itemWidget = m_statusWidget->itemWidget(getItem(module) , 1);
- QProgressBar* bar = dynamic_cast<QProgressBar*>(itemWidget);
- if (bar) bar->setValue(status);
-}
-
-void BtInstallProgressDialog::slotInstallStarted(QString module, QString) {
- getItem(module)->setText(1, tr("Preparing install..."));
+ getOrCreateProgressBar(moduleIndex)->setValue(status);
}
-void BtInstallProgressDialog::slotDownloadStarted(QString module) {
- getItem(module)->setText(1, QString::null);
- //m_statusWidget->itemWidget(getItem(module), 1)->setVisible(true);
-
- QProgressBar* bar = new QProgressBar(m_statusWidget);
- bar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- bar->setValue(0);
- m_statusWidget->setItemWidget(getItem(module), 1, bar);
+void BtInstallProgressDialog::slotOneItemCompleted(int moduleIndex, bool successful) {
+QTreeWidgetItem * const item = m_statusWidget->topLevelItem(moduleIndex);
+ // update the list item
+ m_statusWidget->setItemWidget(item, 1, NULL);
+ item->setText(1, successful ? tr("Completed") : tr("Failed"));
+ item->setDisabled(true);
}
-QTreeWidgetItem* BtInstallProgressDialog::getItem(QString moduleName) {
- return m_statusWidget->findItems(moduleName, Qt::MatchExactly).at(0);
+void BtInstallProgressDialog::slotThreadFinished() {
+ close();
}
-void BtInstallProgressDialog::closeEvent(QCloseEvent* event) {
+void BtInstallProgressDialog::closeEvent(QCloseEvent * event) {
if (event->spontaneous()) {
event->ignore();
+ slotStopInstall();
return;
}
// other parts of the UI/engine must be updated
CSwordBackend::instance()->reloadModules(CSwordBackend::AddedModules);
}
-bool BtInstallProgressDialog::threadsDone() {
- return (m_waitingThreads.isEmpty() && m_runningThreads.isEmpty());
+QProgressBar * BtInstallProgressDialog::getOrCreateProgressBar(int moduleIndex) {
+ return getOrCreateProgressBar(m_statusWidget->topLevelItem(moduleIndex));
+}
+
+QProgressBar * BtInstallProgressDialog::getOrCreateProgressBar(QTreeWidgetItem * item) {
+ QWidget * const itemWidget = m_statusWidget->itemWidget(item, 1);
+ QProgressBar * progressBar = dynamic_cast<QProgressBar *>(itemWidget);
+ if (!progressBar) {
+ progressBar = new QProgressBar(m_statusWidget);
+ progressBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ m_statusWidget->setItemWidget(item, 1, progressBar);
+ }
+ return progressBar;
}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
index a72b280..e6add1c 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,56 +14,56 @@
#include <QDialog>
-#include <QMultiMap>
#include <QString>
class BtInstallThread;
class CSwordModuleInfo;
+class QProgressBar;
class QTreeWidget;
class QTreeWidgetItem;
-class BtInstallProgressDialog : public QDialog {
- Q_OBJECT
- public:
- BtInstallProgressDialog(const QSet<const CSwordModuleInfo*> &modules,
- const QString &destination, QWidget *parent = 0,
- Qt::WindowFlags flags = 0);
-
- public slots:
- void slotOneItemCompleted(QString module, QString source, int status);
- void slotOneItemStopped(QString module, QString source);
- void slotStopInstall();
- void slotStatusUpdated(QString module, int status);
- void slotDownloadStarted(QString module);
- void slotInstallStarted(QString module, QString);
-
- protected:
- /**
- * Handles closing by the window close button, Cancel (Stop) All button, or completing
- * the downloads.
- */
- virtual void closeEvent(QCloseEvent* event);
-
-//signals:
-// void swordSetupChanged();
-
- private:
-
- /// \todo using maps is tedious and error prone. Find better solution for handling the modules
- // and their states.
- QMultiMap<QString, BtInstallThread*> m_waitingThreads;
- QMultiMap<QString, BtInstallThread*> m_runningThreads;
- QMap<QString, BtInstallThread*> m_threadsByModule;
- //QList<BtInstallThread*> m_doneThreads;
-
- QTreeWidget* m_statusWidget;
-
- private:
- QTreeWidgetItem* getItem(QString moduleName);
- bool threadsDone();
- void startThreads();
- void oneItemStoppedOrCompleted(QString module, QString source, QString message);
+class BtInstallProgressDialog: public QDialog {
+
+ Q_OBJECT
+
+public: /* Methods: */
+
+ BtInstallProgressDialog(const QList<CSwordModuleInfo *> & modules,
+ const QString & destination,
+ QWidget * parent = 0,
+ Qt::WindowFlags flags = 0);
+ ~BtInstallProgressDialog();
+
+public slots:
+
+ void slotStopInstall();
+ void slotInstallStarted(int moduleIndex);
+ void slotDownloadStarted(int moduleIndex);
+ void slotStatusUpdated(int moduleIndex, int status);
+ void slotOneItemCompleted(int moduleIndex, bool status);
+ void slotThreadFinished();
+
+protected: /* Methods: */
+
+ /**
+ Handles closing by the window close button, Cancel (Stop) All button, or
+ completing the downloads.
+ */
+ virtual void closeEvent(QCloseEvent * event);
+
+private: /* Methods: */
+
+ QProgressBar * getOrCreateProgressBar(int moduleIndex);
+ QProgressBar * getOrCreateProgressBar(QTreeWidgetItem * item);
+
+private: /* Fields: */
+
+ QTreeWidget * m_statusWidget;
+ QPushButton * m_stopAllButton;
+ BtInstallThread * m_thread;
+ int m_nextInstallIndex;
+
};
#endif
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp b/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
deleted file mode 100644
index 3b25f02..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/*********
-*
-* 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/btinstallthread.h"
-
-#include <QApplication>
-#include <QDebug>
-#include <QDir>
-#include <QString>
-#include <QThread>
-#include "backend/managers/cswordbackend.h"
-#include "frontend/bookshelfmanager/btinstallmgr.h"
-#include "backend/btinstallbackend.h"
-
-// Sword includes:
-#include <filemgr.h>
-
-
-BtInstallThread::BtInstallThread(const QString &moduleName, const QString &sourceName,
- const QString &destinationName, QObject *parent)
- : QThread(parent),
- done(false),
- m_module(moduleName),
- m_destination(destinationName),
- m_source(sourceName),
- m_cancelled(false) {
- m_iMgr = new BtInstallMgr();
-}
-
-
-BtInstallThread::~BtInstallThread() {
- delete m_iMgr;
-}
-
-void BtInstallThread::run() {
- qDebug() << "****************************************\nBtInstallThread::run, mod:" << m_module << "\n************************************";
-
-
- emit preparingInstall(m_module, m_source);
- //This is 0 before set here - remember when using the value when cancelling
- // the installation before this has been run
- m_installSource = QSharedPointer<sword::InstallSource>(new sword::InstallSource(BtInstallBackend::source(m_source)));
- m_backendForSource = QSharedPointer<CSwordBackend>(BtInstallBackend::backend(*m_installSource));
-
- //make sure target/mods.d and target/modules exist
- /// \todo move this to some common precondition
- QDir dir(m_destination);
- if (!dir.exists()) {
- dir.mkdir(m_destination);
- qDebug() << "made directory" << m_destination;
- }
- if (!dir.exists("modules")) {
- dir.mkdir("modules");
- qDebug() << "made directory" << m_destination << "/modules";
- }
- if (!dir.exists("mods.d")) {
- dir.mkdir("mods.d");
- qDebug() << "made directory" << m_destination << "/mods.d";
- }
-
- QObject::connect(m_iMgr, SIGNAL(percentCompleted(int, int)), this, SLOT(slotManagerStatusUpdated(int, int)), Qt::QueuedConnection);
- QObject::connect(m_iMgr, SIGNAL(downloadStarted()), this, SLOT(slotDownloadStarted()), Qt::QueuedConnection);
-
- //check whether it's an update. If yes, remove existing module first
- /// \todo silently removing without undo if the user cancels the update is WRONG!!!
- removeModule();
-
- // manager for the destination path
- sword::SWMgr lMgr( m_destination.toLatin1() );
-
- if (BtInstallBackend::isRemote(*m_installSource)) {
- int status = m_iMgr->installModule(&lMgr, 0, m_module.toLatin1(), m_installSource.data());
- if (status != 0) {
- qWarning() << "Error with install: " << status << "module:" << m_module;
- }
- else {
- done = true;
- emit installCompleted(m_module, m_source, status);
- }
- }
- else { //local source
- emit statusUpdated(m_module, 0);
- int status = m_iMgr->installModule(&lMgr, m_installSource->directory.c_str(), m_module.toLatin1());
- if (status > 0) {
- qWarning() << "Error with install: " << status << "module:" << m_module;
- }
- else if (status == -1) {
- // it was terminated, do nothing
- }
- else {
- emit statusUpdated(m_module, 100);
- done = true;
- emit installCompleted(m_module, m_source, status);
- }
- }
-}
-
-void BtInstallThread::slotStopInstall() {
- qDebug() << "*************************************\nBtInstallThread::slotStopInstall" << m_module << "\n********************************";
- if (!done) {
- done = true;
- qDebug() << "*********************************\nBtInstallThread::slotStopInstall, installing" << m_module << "was cancelled\n**************************************";
- m_iMgr->terminate();
- //this->terminate(); // It's dangerous to forcibly stop, but we will clean up the files
- //qApp->processEvents();
- // wait to terminate for some secs. We rather let the execution go on and cleaning up to fail than the app to freeze
- int notRun = this->wait(25000);
- if (notRun) {
- this->terminate();
- this->wait(10000);
- qDebug() << "installthread (" << m_module << ") terminated, delete m_iMgr";
- delete m_iMgr; // this makes sure the ftp library will be cleaned up in the destroyer
- m_iMgr = 0;
- }
- // cleanup: remove the module, remove the temp files
- // if installation has already started
- if (m_installSource.data() != 0) {
- // remove the installed module, just to be sure because mgr may
- // have been terminated when copying files
- removeModule();
- removeTempFiles();
- qDebug() << "BtInstallThread::slotStopInstall will emit installStopped...";
- }
- emit installStopped(m_module, m_source);
- }
-}
-
-void BtInstallThread::slotManagerStatusUpdated(int totalProgress, int /*fileProgress*/) {
- emit statusUpdated(m_module, totalProgress);
-}
-
-void BtInstallThread::slotDownloadStarted() {
- emit downloadStarted(m_module);
-}
-
-void BtInstallThread::removeModule() {
- CSwordModuleInfo* m;
- m = CSwordBackend::instance()->findModuleByName(m_module);
- if (!m) {
- m = BtInstallBackend::backend(BtInstallBackend::source(m_destination.toLatin1()))->findModuleByName(m_module);
- }
- if (m) { //module found?
- qDebug() << "BtInstallThread::removeModule, module" << m_module << "found";
- QString prefixPath = m->config(CSwordModuleInfo::AbsoluteDataPath) + "/";
- QString dataPath = m->config(CSwordModuleInfo::DataPath);
- if (dataPath.left(2) == "./") {
- dataPath = dataPath.mid(2);
- }
-
- if (prefixPath.contains(dataPath)) {
- prefixPath.remove( prefixPath.indexOf(dataPath), dataPath.length() );
- }
- else {
- prefixPath = QString::fromLatin1(CSwordBackend::instance()->prefixPath);
- }
-
- sword::SWMgr mgr(prefixPath.toLatin1());
- BtInstallMgr iMgr;
- iMgr.removeModule(&mgr, m->name().toLatin1());
- }
- else {
- qDebug() << "BtInstallThread::removeModule, module" << m_module << "not found";
- }
-}
-
-void BtInstallThread::removeTempFiles() {
- // (take the remote conf file for this module, take DataPath,
- // take the absolute path of the InstallMgr)
-
- //sword::InstallSource is = BtInstallBackend::source(m_source);
- if (BtInstallBackend::isRemote(*m_installSource)) {
- // get the path for the module temp files
- CSwordModuleInfo* mInfo = m_backendForSource->findModuleByName(m_module);
- QString dataPath = mInfo->config(CSwordModuleInfo::AbsoluteDataPath);
- qDebug() << "Delete path:" << dataPath;
- // it's easier to use sword than qt
- sword::FileMgr::removeDir(dataPath.toLatin1().data());
- }
-}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallthread.h b/src/frontend/bookshelfmanager/installpage/btinstallthread.h
deleted file mode 100644
index 8bb660d..0000000
--- a/src/frontend/bookshelfmanager/installpage/btinstallthread.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*********
-*
-* 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 BTINSTALLTHREAD_H
-#define BTINSTALLTHREAD_H
-
-#include <QThread>
-
-#include <QSharedPointer>
-#include "frontend/bookshelfmanager/btinstallmgr.h"
-
-
-class BtInstallProgressDialog;
-class CSwordBackend;
-
-/**
-* Thread for installing a module.
-*
-* See the Qt thread documents. We have to be careful with signals and slots,
-* with other things.
-
-The main thread creates and owns the BtInstallThread object.
-When the install thread (the run() method) has been started
-the install thread object receives status update signals
-from the installmgr object. This works because these signals are sent
-from the running install thread but received in the thread object which
-lives in the main thread (note the difference between a thread object and a
-running thread). The slot of the thread object is executed in the main thread
-event loop, not in the install thread.
-
-The running thread sends update signals to the progress dialog.
-(This works because the signals are queued, i.e. the dialog is running
-in the main app event loop which queues the signals. ???)
-
-When the user cancels installing the main thread sends signal to a slot
-in the thread object. The slot is then run in the main thread, not
-in the install thread (note again the difference between a thread object and a
-running thread). That slot terminates the running install thread immediately.
-That is not the cleanest way to do it, but the Sword library has no good
-support for threads. Terminating a Sword InstallMgr takes time and leads to
-slow response. Therefore we stop installing by force and clean up the
-temporary files manually.
-
-* Terminating a thread forcibly is "dangerous and discouraged" but we have to do it,
-* I couldn't get cancelling work reliably otherwise. The Sword library is bad for threads.
-* We use ftp connection and file resources; the connection can be ignored but the files
-* have to be cleaned up after termination.
-*/
-class BtInstallThread : public QThread {
- Q_OBJECT
- public:
- BtInstallThread(const QString &moduleName, const QString &sourceName,
- const QString &destinationName, QObject *parent = 0);
-
- ~BtInstallThread();
-
- public slots:
- void slotStopInstall();
- void slotManagerStatusUpdated(int totalProgress, int fileProgress);
- void slotDownloadStarted();
-
- public: // data member
- bool done;
-
- protected:
- virtual void run();
- void removeModule();
- void removeTempFiles();
-
- QString m_module;
- QString m_destination;
- QString m_source;
- bool m_cancelled;
- BtInstallMgr* m_iMgr;
- //BtInstallMgr m_iMgr;
- QSharedPointer<sword::InstallSource> m_installSource;
- /// \todo it would be best to get the backend from the bookshelf manager install page
- // where it has already been created. Could fasten the progress dialog startup.
- QSharedPointer<CSwordBackend> m_backendForSource;
-
- signals:
- /** Emitted when the install progress status is updated. */
- void statusUpdated(QString module, int progressPercent);
- /** Emitted when installing has been stopped/cancelled. */
- void installStopped(QString module, QString source);
- /** Emitted when installing is complete. */
- void installCompleted(QString module, QString source, int errorStatus);
- /** Emitted when the first file download has been started. */
- void downloadStarted(QString module);
- void preparingInstall(QString module, QString source);
-};
-
-#endif
diff --git a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp
index 949c82e..856f58b 100644
--- a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.cpp
@@ -2,7 +2,7 @@
#include <QApplication>
#include "backend/btinstallbackend.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
BtRefreshProgressDialog::BtRefreshProgressDialog(sword::InstallSource &source,
@@ -44,7 +44,7 @@ bool BtRefreshProgressDialog::runAndDelete() {
setValue(100);
qApp->processEvents();
} else {
- util::showWarning(this, tr("Warning"),
+ message::showWarning(this, tr("Warning"),
tr("Failed to refresh source %1")
.arg(QString(m_source.caption)));
}
diff --git a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h
index dfabcf6..03f82c9 100644
--- a/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btrefreshprogressdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +14,7 @@
#include <QProgressDialog>
-#include "frontend/bookshelfmanager/btinstallmgr.h"
+#include "backend/btinstallmgr.h"
class BtRefreshProgressDialog: public QProgressDialog {
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
index 8b9dd3c..57879ea 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
+++ b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -17,18 +17,19 @@
#include <QGroupBox>
#include <QHBoxLayout>
#include <QHeaderView>
-#include <QMessageBox>
#include <QPushButton>
#include <QToolButton>
#include <QVBoxLayout>
#include "backend/bookshelfmodel/btbookshelffiltermodel.h"
#include "backend/managers/cswordbackend.h"
+#include "bibletimeapp.h"
#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
#include "frontend/btbookshelfview.h"
#include "frontend/btbookshelfwidget.h"
+#include "frontend/messagedialog.h"
#include "util/cresmgr.h"
-#include "util/dialogutil.h"
#include "util/directory.h"
+#include "util/geticon.h"
// Sword includes:
#include <swmgr.h>
@@ -40,10 +41,8 @@ const QString groupingOrderKey("GUI/BookshelfManager/RemovePage/grouping");
}
BtRemovePage::BtRemovePage(BtModuleManagerDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::bookshelfmgr::removepage::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::bookshelfmgr::removepage::icon), parent)
{
- namespace DU = util::directory;
-
m_worksGroupBox = new QGroupBox(this);
m_worksGroupBox->setFlat(true);
QVBoxLayout *wLayout = new QVBoxLayout;
@@ -77,7 +76,7 @@ BtRemovePage::BtRemovePage(BtModuleManagerDialog *parent)
uLayout->addStretch(1);
m_removeButton = new QPushButton(this);
- m_removeButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::removepage::remove_icon));
+ m_removeButton->setIcon(util::getIcon(CResMgr::bookshelfmgr::removepage::remove_icon));
m_removeButton->setEnabled(false);
uLayout->addWidget(m_removeButton, 0, Qt::AlignRight);
@@ -131,13 +130,13 @@ void BtRemovePage::slotRemoveModules() {
/// \bug <nobr> is not working, Qt bug
const QString moduleString("<nobr><img src=\"%1\" width=\"%2\" height=\"%3\"/>&nbsp;%4</nobr>");
const QString iconDir = util::directory::getIconDir().canonicalPath() + '/';
- Q_FOREACH(const CSwordModuleInfo *m,
+ Q_FOREACH(const CSwordModuleInfo * m,
m_bookshelfWidget->treeModel()->checkedModules())
{
- const QIcon icon = CSwordModuleInfo::moduleIcon(m);
+ const QIcon icon = CSwordModuleInfo::moduleIcon(*m);
const QSize iconSize = icon.actualSize(QSize(textHeight, textHeight));
prettyModuleNames.append(moduleString
- .arg(iconDir + CSwordModuleInfo::moduleIconFilename(m))
+ .arg(iconDir + CSwordModuleInfo::moduleIconFilename(*m))
.arg(iconSize.width())
.arg(iconSize.height())
.arg(m->name()));
@@ -149,7 +148,7 @@ void BtRemovePage::slotRemoveModules() {
.append("<br/><br/>")
.append(tr("Do you really want to remove them from your system?"));
- if ((util::showQuestion(this, tr("Remove Works?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)) { //Yes was pressed.
+ if ((message::showQuestion(this, tr("Remove Works?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)) { //Yes was pressed.
// Update the module list before really removing. Remember deleting the pointers later.
QList<CSwordModuleInfo*> toBeDeleted = CSwordBackend::instance()->takeModulesFromList(moduleNames);
@@ -180,7 +179,7 @@ void BtRemovePage::slotRemoveModules() {
mgr = mgrDict[ prefixPath ];
}
qDebug() << "Removing the module" << mInfo->name() << "...";
- installMgr.removeModule(mgr, mInfo->module()->Name());
+ installMgr.removeModule(mgr, mInfo->module()->getName());
}
//delete the removed moduleinfo pointers
qDeleteAll(toBeDeleted);
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.h b/src/frontend/bookshelfmanager/removepage/btremovepage.h
index 02ff88e..a9600d8 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepage.h
+++ b/src/frontend/bookshelfmanager/removepage/btremovepage.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 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/removepage/btremovepagetreemodel.cpp b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp
index a0955b2..9fce7ab 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp
+++ b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 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/removepage/btremovepagetreemodel.h b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h
index 14e0a67..50da32b 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h
+++ b/src/frontend/bookshelfmanager/removepage/btremovepagetreemodel.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/frontend/btaboutdialog.cpp b/src/frontend/btaboutdialog.cpp
index 1bfe708..fd0a3c9 100644
--- a/src/frontend/btaboutdialog.cpp
+++ b/src/frontend/btaboutdialog.cpp
@@ -2,13 +2,14 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/btaboutdialog.h"
+#include "frontend/messagedialog.h"
#include <QApplication>
#include <QDesktopServices>
#include <QDialogButtonBox>
@@ -18,7 +19,6 @@
#include <QTextStream>
#include <QVBoxLayout>
#include <QWebView>
-#include "util/dialogutil.h"
#include "util/directory.h"
// Sword includes:
@@ -88,11 +88,8 @@ BtAboutDialog::BtAboutDialog(QWidget *parent, Qt::WindowFlags wflags)
retranslateUi();
}
-BtAboutDialog::~BtAboutDialog() {
- // Intentionally empty
-}
-
void BtAboutDialog::resizeEvent(QResizeEvent* event) {
+ Q_UNUSED(event);
QString version = "BibleTime " BT_VERSION;
QFontMetrics fm(m_versionLabel->font());
int w = width() - m_iconLabel->width() - 80;
@@ -117,7 +114,7 @@ void BtAboutDialog::retranslateUi() {
retranslateQtTab();
retranslateLicenceTab();
- util::prepareDialogBox(m_buttonBox);
+ message::prepareDialogBox(m_buttonBox);
}
void BtAboutDialog::retranslateBtTab() {
@@ -130,7 +127,7 @@ void BtAboutDialog::retranslateBtTab() {
"our team, please send an email to %1.")
.arg(MAKE_LINK_STATIC("mailto:info@bibletime.info", "info@bibletime.info"));
content += "</p><p>";
- content += tr("(c)1999-2011, The BibleTime Team");
+ content += tr("(c)1999-2014, The BibleTime Team");
content += "</p><p>" MAKE_LINK_STATIC("http://www.bibletime.info", "www.bibletime.info")
"</p>";
m_bibletimeTab->setHtml(MAKE_HTML(m_bibletimeTab, content));
@@ -168,6 +165,7 @@ void BtAboutDialog::retranslateContributorsTab() {
MAKE_CONTR(content, "Eeli Kaikkonnen", developer)
MAKE_CONTR(content, "Chris Kujawa", developer)
MAKE_CONTR(content, "Mark Lybarger", developer)
+ MAKE_CONTR(content, "Konstantin Maslyuk", developer)
MAKE_CONTR(content, "Luke Mauldin", developer)
MAKE_CONTR(content, "James Ots", designer)
MAKE_CONTR(content, "Andrus Raag", artist)
@@ -177,6 +175,7 @@ void BtAboutDialog::retranslateContributorsTab() {
MAKE_CONTR2(content, "Wolfgang Stradner", tr("tester"), tr("usability expert"))
MAKE_CONTR(content, "Kang Sun", developer)
MAKE_CONTR(content, "Thorsten Uhlmann", developer)
+ MAKE_CONTR(content, "John Turpish", developer)
MAKE_CONTR(content, "David White", developer)
MAKE_CONTR(content, "Mark Zealey", developer)
MAKE_CONTR(content, "Patrick Sebastian Zimmermann", developer)
@@ -210,6 +209,7 @@ void BtAboutDialog::retranslateContributorsTab() {
"<li>Vlad Savitsky</li>"
"<li>Henrik Sonesson</li>"
"<li>Johan van der Lingen</li>"
+ "<li>Damian Wrzalski</li>"
"<li>Konstantin Maslyuk</li>"
"<li>Jean Van Schaftingen</li>"
"<li>Roland Teschner</li>"
diff --git a/src/frontend/btaboutdialog.h b/src/frontend/btaboutdialog.h
index 2ad6607..132074a 100644
--- a/src/frontend/btaboutdialog.h
+++ b/src/frontend/btaboutdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,7 +24,6 @@ class BtAboutDialog: public QDialog {
Q_OBJECT
public:
BtAboutDialog(QWidget *parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
- ~BtAboutDialog();
protected:
virtual void resizeEvent(QResizeEvent* event);
diff --git a/src/frontend/btaboutmoduledialog.cpp b/src/frontend/btaboutmoduledialog.cpp
index ab15fb9..b8603b5 100644
--- a/src/frontend/btaboutmoduledialog.cpp
+++ b/src/frontend/btaboutmoduledialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,7 +14,7 @@
#include <QWidget>
#include "backend/drivers/cswordmoduleinfo.h"
#include "frontend/btaboutmoduledialog.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
BTAboutModuleDialog::BTAboutModuleDialog(const CSwordModuleInfo *moduleInfo,
@@ -44,5 +44,5 @@ BTAboutModuleDialog::BTAboutModuleDialog(const CSwordModuleInfo *moduleInfo,
void BTAboutModuleDialog::retranslateUi() {
setWindowTitle(tr("Information About %1").arg(m_moduleInfo->name()));
m_textEdit->setHtml(m_moduleInfo->aboutText());
- util::prepareDialogBox(m_buttons);
+ message::prepareDialogBox(m_buttons);
}
diff --git a/src/frontend/btaboutmoduledialog.h b/src/frontend/btaboutmoduledialog.h
index fda51ea..05f78d1 100644
--- a/src/frontend/btaboutmoduledialog.h
+++ b/src/frontend/btaboutmoduledialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/btbookshelfdockwidget.cpp b/src/frontend/btbookshelfdockwidget.cpp
index 2d85930..46ee023 100644
--- a/src/frontend/btbookshelfdockwidget.cpp
+++ b/src/frontend/btbookshelfdockwidget.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -16,16 +16,17 @@
#include <QActionGroup>
#include <QLabel>
#include <QMenu>
-#include <QMessageBox>
#include <QPushButton>
#include <QStackedWidget>
#include <QVBoxLayout>
#include "backend/managers/cswordbackend.h"
#include "bibletime.h"
+#include "bibletimeapp.h"
#include "frontend/btbookshelfview.h"
#include "frontend/btbookshelfwidget.h"
+#include "frontend/messagedialog.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
namespace {
@@ -102,7 +103,6 @@ BtBookshelfDockWidget::BtBookshelfDockWidget(QWidget *parent, Qt::WindowFlags f)
}
void BtBookshelfDockWidget::initMenus() {
- namespace DU = util::directory;
namespace RM = CResMgr::mainIndex;
m_itemContextMenu = new QMenu(this);
@@ -115,30 +115,30 @@ void BtBookshelfDockWidget::initMenus() {
m_itemContextMenu->addAction(m_itemOpenAction);
m_itemSearchAction = new QAction(this);
- m_itemSearchAction->setIcon(DU::getIcon(RM::search::icon));
+ m_itemSearchAction->setIcon(util::getIcon(RM::search::icon));
m_itemActionGroup->addAction(m_itemSearchAction);
m_itemContextMenu->addAction(m_itemSearchAction);
m_itemEditMenu = new QMenu(this);
- m_itemEditMenu->setIcon(DU::getIcon(RM::editModuleMenu::icon));
+ m_itemEditMenu->setIcon(util::getIcon(RM::editModuleMenu::icon));
m_itemContextMenu->addMenu(m_itemEditMenu);
m_itemEditPlainAction = new QAction(this);
- m_itemEditPlainAction->setIcon(DU::getIcon(RM::editModulePlain::icon));
+ m_itemEditPlainAction->setIcon(util::getIcon(RM::editModulePlain::icon));
m_itemActionGroup->addAction(m_itemEditPlainAction);
m_itemEditMenu->addAction(m_itemEditPlainAction);
m_itemEditHtmlAction = new QAction(this);
- m_itemEditHtmlAction->setIcon(DU::getIcon(RM::editModuleHTML::icon));
+ m_itemEditHtmlAction->setIcon(util::getIcon(RM::editModuleHTML::icon));
m_itemActionGroup->addAction(m_itemEditHtmlAction);
m_itemEditMenu->addAction(m_itemEditHtmlAction);
m_itemUnlockAction = new QAction(this);
- m_itemUnlockAction->setIcon(DU::getIcon(RM::unlockModule::icon));
+ m_itemUnlockAction->setIcon(util::getIcon(RM::unlockModule::icon));
m_itemActionGroup->addAction(m_itemUnlockAction);
m_itemContextMenu->addAction(m_itemUnlockAction);
m_itemAboutAction = new QAction(this);
- m_itemAboutAction->setIcon(DU::getIcon(RM::aboutModule::icon));
+ m_itemAboutAction->setIcon(util::getIcon(RM::aboutModule::icon));
m_itemActionGroup->addAction(m_itemAboutAction);
m_itemContextMenu->addAction(m_itemAboutAction);
@@ -170,7 +170,7 @@ void BtBookshelfDockWidget::slotModuleActivated(CSwordModuleInfo *module) {
warning message. Actually the whole case when the user tries to open a locked
module needs to be rethought and refactored.
*/
- QMessageBox::warning(this, tr("Warning: Module locked!"),
+ message::showWarning(this, tr("Warning: Module locked!"),
tr("You are trying to access an encrypted module. Please "
"provide an unlock key in the following dialog to open the "
"module."));
diff --git a/src/frontend/btbookshelfdockwidget.h b/src/frontend/btbookshelfdockwidget.h
index 87508f4..fe415d7 100644
--- a/src/frontend/btbookshelfdockwidget.h
+++ b/src/frontend/btbookshelfdockwidget.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/frontend/btbookshelfgroupingmenu.cpp b/src/frontend/btbookshelfgroupingmenu.cpp
index de2bcf6..c456f80 100644
--- a/src/frontend/btbookshelfgroupingmenu.cpp
+++ b/src/frontend/btbookshelfgroupingmenu.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -12,8 +12,10 @@
#include "frontend/btbookshelfgroupingmenu.h"
+#include "bibletimeapp.h"
#include "util/cresmgr.h"
#include "util/directory.h"
+#include "util/geticon.h"
namespace {
@@ -48,12 +50,11 @@ inline const BtBookshelfTreeModel::Grouping &getActionRef(const QAction *a) {
void BtBookshelfGroupingMenu::initMenu(bool showNoGrouping) {
- namespace DU = util::directory;
namespace RM = CResMgr::mainIndex;
if (!groupsInitialized) initializeGroups();
- setIcon(DU::getIcon(RM::grouping::icon));
+ setIcon(util::getIcon(RM::grouping::icon));
m_groupingActionGroup = new QActionGroup(this);
m_groupingActionGroup->setExclusive(true);
diff --git a/src/frontend/btbookshelfgroupingmenu.h b/src/frontend/btbookshelfgroupingmenu.h
index 83605a7..f49c3c0 100644
--- a/src/frontend/btbookshelfgroupingmenu.h
+++ b/src/frontend/btbookshelfgroupingmenu.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/frontend/btbookshelfview.cpp b/src/frontend/btbookshelfview.cpp
index cb0dcd9..1a04eff 100644
--- a/src/frontend/btbookshelfview.cpp
+++ b/src/frontend/btbookshelfview.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -37,13 +37,10 @@ BtBookshelfView::BtBookshelfView(QWidget *parent)
this, SLOT(slotItemHovered(QModelIndex)));
}
-BtBookshelfView::~BtBookshelfView() {
- // Intentionally empty
-}
-
-CSwordModuleInfo *BtBookshelfView::getModule(const QModelIndex &index) const {
- return (CSwordModuleInfo *) model()
- ->data(index, BtBookshelfModel::ModulePointerRole).value<void*>();
+CSwordModuleInfo * BtBookshelfView::getModule(const QModelIndex & index) const {
+ void * const module = model()->data(index,
+ BtBookshelfModel::ModulePointerRole).value<void *>();
+ return static_cast<CSwordModuleInfo *>(module);
}
void BtBookshelfView::keyPressEvent(QKeyEvent *event) {
diff --git a/src/frontend/btbookshelfview.h b/src/frontend/btbookshelfview.h
index 940c084..f957785 100644
--- a/src/frontend/btbookshelfview.h
+++ b/src/frontend/btbookshelfview.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -22,7 +22,6 @@ class BtBookshelfView: public QTreeView {
Q_OBJECT
public:
BtBookshelfView(QWidget *parent = 0);
- virtual ~BtBookshelfView();
CSwordModuleInfo *getModule(const QModelIndex &index) const;
diff --git a/src/frontend/btbookshelfwidget.cpp b/src/frontend/btbookshelfwidget.cpp
index c4b0d54..2ce812e 100644
--- a/src/frontend/btbookshelfwidget.cpp
+++ b/src/frontend/btbookshelfwidget.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -24,6 +24,7 @@
#include <QToolButton>
#include <QVBoxLayout>
#include "backend/bookshelfmodel/btbookshelffiltermodel.h"
+#include "bibletimeapp.h"
#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialogmodel.h"
#include "frontend/bookshelfmanager/removepage/btremovepagetreemodel.h"
#include "frontend/btbookshelfdockwidget.h"
@@ -31,6 +32,7 @@
#include "frontend/btbookshelfview.h"
#include "util/cresmgr.h"
#include "util/directory.h"
+#include "util/geticon.h"
BtBookshelfWidget::BtBookshelfWidget(QWidget *parent, Qt::WindowFlags flags)
@@ -61,10 +63,6 @@ BtBookshelfWidget::BtBookshelfWidget(QWidget *parent, Qt::WindowFlags flags)
this, SLOT(slotShowItemContextMenu(CSwordModuleInfo*, QPoint)));
}
-BtBookshelfWidget::~BtBookshelfWidget() {
- // Intentionally empty
-}
-
void BtBookshelfWidget::setSourceModel(QAbstractItemModel *model) {
Q_ASSERT(model != 0);
m_sourceModel = model;
@@ -96,11 +94,10 @@ void BtBookshelfWidget::setRightCornerWidget(QWidget *w) {
}
void BtBookshelfWidget::initActions() {
- namespace DU = util::directory;
namespace RM = CResMgr::mainIndex;
m_showHideAction = new QAction(this);
- m_showHideAction->setIcon(DU::getIcon("layer-visible-on.svg"));
+ m_showHideAction->setIcon(util::getIcon("layer-visible-on.svg"));
m_showHideAction->setCheckable(true);
connect(m_showHideAction, SIGNAL(toggled(bool)),
m_postFilterModel, SLOT(setShowHidden(bool)));
diff --git a/src/frontend/btbookshelfwidget.h b/src/frontend/btbookshelfwidget.h
index 3f1e605..7811b5c 100644
--- a/src/frontend/btbookshelfwidget.h
+++ b/src/frontend/btbookshelfwidget.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -35,7 +35,6 @@ class BtBookshelfWidget: public QWidget {
Q_OBJECT
public:
explicit BtBookshelfWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0);
- ~BtBookshelfWidget();
void setSourceModel(QAbstractItemModel *model);
diff --git a/src/frontend/btcentralwidget.cpp b/src/frontend/btcentralwidget.cpp
new file mode 100644
index 0000000..04615c3
--- /dev/null
+++ b/src/frontend/btcentralwidget.cpp
@@ -0,0 +1,51 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "frontend/btcentralwidget.h"
+
+#include "frontend/cmdiarea.h"
+#include "frontend/displaywindow/btactioncollection.h"
+#include "frontend/displaywindow/cdisplaywindow.h"
+#include <QAction>
+#include <QKeyEvent>
+#include <QKeySequence>
+
+
+ BtCentralWidget::BtCentralWidget(CMDIArea* mdiArea, BtFindWidget* findWidget, QWidget* parent)
+ : QWidget(parent), m_mdiArea(mdiArea), m_findWidget(findWidget) {
+ }
+
+void BtCentralWidget::keyPressEvent(QKeyEvent *e) {
+
+// const QString text = e->text();
+// if (text.isEmpty()) {
+ QWidget::keyPressEvent(e);
+// return;
+// }
+// CDisplayWindow* activeDisplayWindow = m_mdiArea->getActiveDisplayWindow();
+// if (activeDisplayWindow != 0) {
+
+// BtActionCollection* actionCollection = activeDisplayWindow->actionCollection();
+// QAction* findAction = actionCollection->action("findText");
+// QKeySequence keySequence = findAction->shortcut();
+// QString key = keySequence.toString();
+// if (key == text)
+// return;
+// }
+
+// if (text.startsWith(QLatin1Char('/'))) {
+// if (!m_findWidget->isVisible()) {
+// m_findWidget->showAndClear();
+// } else {
+// m_findWidget->show();
+// }
+// } else {
+// QWidget::keyPressEvent(e);
+// }
+}
diff --git a/src/frontend/btcentralwidget.h b/src/frontend/btcentralwidget.h
new file mode 100644
index 0000000..3ef9002
--- /dev/null
+++ b/src/frontend/btcentralwidget.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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTCENTRALWIDGET_H
+#define BTCENTRALWIDGET_H
+
+#include <QWidget>
+class QKeyEvent;
+class CMDIArea;
+class BtFindWidget;
+
+class BtCentralWidget: public QWidget {
+
+public:
+ BtCentralWidget(CMDIArea* mdiArea, BtFindWidget* findWidget, QWidget* parent=0);
+
+protected:
+ void keyPressEvent(QKeyEvent *e);
+
+private:
+ CMDIArea* m_mdiArea;
+ BtFindWidget* m_findWidget;
+};
+
+#endif
diff --git a/src/frontend/btmenuview.cpp b/src/frontend/btmenuview.cpp
index 71998b7..919602b 100644
--- a/src/frontend/btmenuview.cpp
+++ b/src/frontend/btmenuview.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/frontend/btmenuview.h b/src/frontend/btmenuview.h
index 98ec729..39b56f6 100644
--- a/src/frontend/btmenuview.h
+++ b/src/frontend/btmenuview.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
diff --git a/src/frontend/btmodulechooserdialog.cpp b/src/frontend/btmodulechooserdialog.cpp
index e8f3dd0..e6ed79f 100644
--- a/src/frontend/btmodulechooserdialog.cpp
+++ b/src/frontend/btmodulechooserdialog.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -19,7 +19,7 @@
#include "frontend/btaboutmoduledialog.h"
#include "frontend/btbookshelfview.h"
#include "frontend/btbookshelfwidget.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
#include "util/tool.h"
@@ -49,12 +49,8 @@ BtModuleChooserDialog::BtModuleChooserDialog(QWidget *parent, Qt::WindowFlags fl
retranslateUi();
}
-BtModuleChooserDialog::~BtModuleChooserDialog() {
- // Intentionally empty
-}
-
void BtModuleChooserDialog::retranslateUi() {
- util::prepareDialogBox(m_buttonBox);
+ message::prepareDialogBox(m_buttonBox);
}
void BtModuleChooserDialog::slotModuleAbout(CSwordModuleInfo *module) {
diff --git a/src/frontend/btmodulechooserdialog.h b/src/frontend/btmodulechooserdialog.h
index 706088c..685ac48 100644
--- a/src/frontend/btmodulechooserdialog.h
+++ b/src/frontend/btmodulechooserdialog.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -24,8 +24,6 @@ class QLabel;
class BtModuleChooserDialog : public QDialog {
Q_OBJECT
- public:
- virtual ~BtModuleChooserDialog();
protected:
explicit BtModuleChooserDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
diff --git a/src/frontend/btmoduleindexdialog.cpp b/src/frontend/btmoduleindexdialog.cpp
index 2dac498..2714ea7 100644
--- a/src/frontend/btmoduleindexdialog.cpp
+++ b/src/frontend/btmoduleindexdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/btmoduleindexdialog.h b/src/frontend/btmoduleindexdialog.h
index 29a13c4..8b794f9 100644
--- a/src/frontend/btmoduleindexdialog.h
+++ b/src/frontend/btmoduleindexdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/btopenworkaction.cpp b/src/frontend/btopenworkaction.cpp
index 50d0d5f..a398412 100644
--- a/src/frontend/btopenworkaction.cpp
+++ b/src/frontend/btopenworkaction.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -14,8 +14,9 @@
#include "backend/bookshelfmodel/btbookshelffiltermodel.h"
#include "backend/managers/cswordbackend.h"
+#include "bibletimeapp.h"
#include "frontend/btbookshelfgroupingmenu.h"
-#include "util/directory.h"
+#include "util/geticon.h"
BtOpenWorkActionMenu::BtOpenWorkActionMenu(const QString &groupingConfigKey,
@@ -33,10 +34,6 @@ BtOpenWorkActionMenu::BtOpenWorkActionMenu(const QString &groupingConfigKey,
this, SLOT(slotIndexTriggered(QModelIndex)));
}
-BtOpenWorkActionMenu::~BtOpenWorkActionMenu() {
- // Intentionally empty
-}
-
void BtOpenWorkActionMenu::setSourceModel(QAbstractItemModel *model) {
m_treeModel->setSourceModel(model);
}
@@ -81,7 +78,7 @@ BtOpenWorkAction::BtOpenWorkAction(const QString &groupingConfigKey,
m_menu->setSourceModel(CSwordBackend::instance()->model());
setMenu(m_menu);
- setIcon(util::directory::getIcon("folder-open.svg"));
+ setIcon(util::getIcon("folder-open.svg"));
retranslateUi();
slotModelChanged();
diff --git a/src/frontend/btopenworkaction.h b/src/frontend/btopenworkaction.h
index 6b28908..1ca8379 100644
--- a/src/frontend/btopenworkaction.h
+++ b/src/frontend/btopenworkaction.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -29,7 +29,6 @@ class BtOpenWorkActionMenu: public BtMenuView {
public:
BtOpenWorkActionMenu(const QString &groupingConfigKey,
QWidget *parent = 0);
- ~BtOpenWorkActionMenu();
void setSourceModel(QAbstractItemModel *model);
inline QAbstractItemModel *sourceModel() const { return m_treeModel->sourceModel(); }
diff --git a/src/frontend/cdragdrop.h b/src/frontend/cdragdrop.h
index 8fa270f..869d2fb 100644
--- a/src/frontend/cdragdrop.h
+++ b/src/frontend/cdragdrop.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/cexportmanager.cpp b/src/frontend/cexportmanager.cpp
index 640eae7..e7546ba 100644
--- a/src/frontend/cexportmanager.cpp
+++ b/src/frontend/cexportmanager.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -76,7 +76,7 @@ bool CExportManager::saveKey(CSwordKey* key, const Format format, const bool add
CSwordVerseKey *vk = dynamic_cast<CSwordVerseKey*>(key);
if (vk && vk->isBoundSet()) {
- text = render->renderKeyRange( QString::fromUtf8(vk->LowerBound()), QString::fromUtf8(vk->UpperBound()), modules );
+ text = render->renderKeyRange( QString::fromUtf8(vk->getLowerBound()), QString::fromUtf8(vk->getUpperBound()), modules );
}
else { //no range supported
text = render->renderSingleKey(key->key(), modules);
@@ -90,14 +90,12 @@ bool CExportManager::saveKey(CSwordKey* key, const Format format, const bool add
return true;
}
-bool CExportManager::saveKeyList(const sword::ListKey &l,
+bool CExportManager::saveKeyList(const sword::ListKey & l,
const CSwordModuleInfo *module,
Format format,
bool addText)
{
- /// \warning This is a workaround for Sword constness
- sword::ListKey list = l;
- if (!list.Count())
+ if (!l.getCount())
return false;
const QString filename = getSaveFileName(format);
@@ -107,12 +105,13 @@ bool CExportManager::saveKeyList(const sword::ListKey &l,
CTextRendering::KeyTree tree; /// \todo Verify that items in tree are properly freed.
- setProgressRange(list.Count());
+ setProgressRange(l.getCount());
CTextRendering::KeyTreeItem::Settings itemSettings;
itemSettings.highlight = false;
+ sword::ListKey list(l);
list.setPosition(sword::TOP);
- while (!list.Error() && !progressWasCancelled()) {
+ while (!list.popError() && !progressWasCancelled()) {
tree.append( new CTextRendering::KeyTreeItem(QString::fromLocal8Bit((const char*)list) , module, itemSettings) );
incProgress();
@@ -180,8 +179,8 @@ bool CExportManager::copyKey(CSwordKey* key, const Format format, const bool add
CSwordVerseKey * vk = dynamic_cast<CSwordVerseKey*>(key);
if (vk && vk->isBoundSet()) {
text = render->renderKeyRange(
- QString::fromUtf8(vk->LowerBound()),
- QString::fromUtf8(vk->UpperBound()),
+ QString::fromUtf8(vk->getLowerBound()),
+ QString::fromUtf8(vk->getUpperBound()),
modules
);
}
@@ -201,7 +200,7 @@ bool CExportManager::copyKeyList(const sword::ListKey &l,
bool addText)
{
sword::ListKey list = l;
- if (!list.Count())
+ if (!list.getCount())
return false;
CTextRendering::KeyTree tree; /// \todo Verify that items in tree are properly freed.
@@ -209,7 +208,7 @@ bool CExportManager::copyKeyList(const sword::ListKey &l,
itemSettings.highlight = false;
list.setPosition(sword::TOP);
- while (!list.Error() && !progressWasCancelled()) {
+ while (!list.popError() && !progressWasCancelled()) {
tree.append( new CTextRendering::KeyTreeItem(QString::fromLocal8Bit((const char*)list) , module, itemSettings) );
list.increment();
@@ -254,18 +253,16 @@ bool CExportManager::copyKeyList(const QList<CSwordKey*> &list,
return true;
}
-bool CExportManager::printKeyList(const sword::ListKey &l,
+bool CExportManager::printKeyList(const sword::ListKey & list,
const CSwordModuleInfo *module,
const DisplayOptions &displayOptions,
const FilterOptions &filterOptions)
{
- /// \warning This is a workaround for Sword constness
- sword::ListKey list = l;
CPrinter::KeyTreeItem::Settings settings;
CPrinter::KeyTree tree; /// \todo Verify that items in tree are properly freed.
- setProgressRange(list.Count());
- for (int i=0; i< list.Count(); i++) {
+ setProgressRange(list.getCount());
+ for (int i=0; i< list.getCount(); i++) {
const sword::SWKey* swKey = list.getElement(i);
const sword::VerseKey* vKey = dynamic_cast<const sword::VerseKey*>(swKey);
if (vKey != 0) {
@@ -370,13 +367,13 @@ bool CExportManager::printByHyperlink(const QString &hyperlink,
if (module) {
//check if we have a range of entries or a single one
if ((module->type() == CSwordModuleInfo::Bible) || (module->type() == CSwordModuleInfo::Commentary)) {
- sword::ListKey verses = sword::VerseKey().ParseVerseList((const char*)keyName.toUtf8(), "Genesis 1:1", true);
+ sword::ListKey verses = sword::VerseKey().parseVerseList((const char*)keyName.toUtf8(), "Genesis 1:1", true);
- for (int i = 0; i < verses.Count(); ++i) {
+ for (int i = 0; i < verses.getCount(); i++) {
sword::VerseKey* element = dynamic_cast<sword::VerseKey*>(verses.getElement(i));
if (element) {
- const QString startKey = QString::fromUtf8(element->LowerBound().getText());
- const QString stopKey = QString::fromUtf8(element->UpperBound().getText());
+ const QString startKey = QString::fromUtf8(element->getLowerBound().getText());
+ const QString stopKey = QString::fromUtf8(element->getUpperBound().getText());
tree.append( new CPrinter::KeyTreeItem(startKey, stopKey, module, settings) );
}
diff --git a/src/frontend/cexportmanager.h b/src/frontend/cexportmanager.h
index 0d882e0..a222ac8 100644
--- a/src/frontend/cexportmanager.h
+++ b/src/frontend/cexportmanager.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +14,7 @@
#include <QList>
#include <QString>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "btglobal.h"
class CSwordKey;
@@ -37,8 +39,8 @@ class CExportManager {
CExportManager(const bool showProgress = true,
const QString &progressLabel = QString::null,
- const FilterOptions &filterOptions = CBTConfig::getFilterOptionDefaults(),
- const DisplayOptions &displayOptions = CBTConfig::getDisplayOptionDefaults());
+ const FilterOptions &filterOptions = btConfig().getFilterOptions(),
+ const DisplayOptions &displayOptions = btConfig().getDisplayOptions());
~CExportManager();
bool saveKey(CSwordKey* key, const Format format, const bool addText);
diff --git a/src/frontend/cinfodisplay.cpp b/src/frontend/cinfodisplay.cpp
index 8165b8b..202eb48 100644
--- a/src/frontend/cinfodisplay.cpp
+++ b/src/frontend/cinfodisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,15 +20,16 @@
#include <QtAlgorithms>
#include <QMenu>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
#include "backend/managers/referencemanager.h"
#include "backend/managers/cdisplaytemplatemgr.h"
+#include "bibletime.h"
#include "frontend/crossrefrendering.h"
-#include "frontend/display/cdisplay.h"
-#include "frontend/display/creaddisplay.h"
+#include "frontend/display/bthtmlreaddisplay.h"
+#include "util/htmlescape.h"
// Sword includes:
#include <listkey.h>
@@ -39,33 +40,36 @@ using namespace sword;
namespace InfoDisplay {
-CInfoDisplay::CInfoDisplay(QWidget *parent) : QWidget(parent) {
- QVBoxLayout* layout = new QVBoxLayout(this);
+CInfoDisplay::CInfoDisplay(BibleTime * parent)
+ : QWidget(parent)
+ , m_mainWindow(parent)
+{
+ QVBoxLayout * const layout = new QVBoxLayout(this);
layout->setContentsMargins(2, 2, 2, 2); // Leave small border
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
- m_htmlPart = CDisplay::createReadInstance(0, this);
- m_htmlPart->setMouseTracking(false); //we don't want strong/lemma/note mouse infos
+ m_htmlPart = new BtHtmlReadDisplay(0, this);
+ m_htmlPart->setMouseTracking(false); // We don't want strong/lemma/note mouse infos
m_htmlPart->view()->setAcceptDrops(false);
- QAction* selectAllAction = new QAction(QIcon(), tr("Select all"), this);
+ QAction * const selectAllAction = new QAction(QIcon(), tr("Select all"), this);
selectAllAction->setShortcut(QKeySequence::SelectAll);
- QObject::connect(selectAllAction, SIGNAL(triggered()), this, SLOT(selectAll()) );
+ QObject::connect(selectAllAction, SIGNAL(triggered()),
+ this, SLOT(selectAll()));
- QAction* copyAction = new QAction(tr("Copy"), this);
- copyAction->setShortcut( QKeySequence(Qt::CTRL + Qt::Key_C) );
- QObject::connect(copyAction, SIGNAL(triggered()), m_htmlPart->connectionsProxy(), SLOT(copySelection()) );
+ QAction * const copyAction = new QAction(tr("Copy"), this);
+ copyAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
+ QObject::connect(copyAction, SIGNAL(triggered()),
+ m_htmlPart->connectionsProxy(), SLOT(copySelection()));
- QMenu* menu = new QMenu(this);
+ QMenu * const menu = new QMenu(this);
menu->addAction(selectAllAction);
menu->addAction(copyAction);
m_htmlPart->installPopup(menu);
- connect(
- m_htmlPart->connectionsProxy(),
- SIGNAL(referenceClicked(const QString&, const QString&)),
- SLOT(lookupInfo(const QString&, const QString&))
- );
+ QObject::connect(m_htmlPart->connectionsProxy(),
+ SIGNAL(referenceClicked(const QString &, const QString &)),
+ SLOT(lookupInfo(const QString &, const QString &)));
layout->addWidget(m_htmlPart->view());
@@ -80,102 +84,101 @@ void CInfoDisplay::unsetInfo() {
"moving the mouse.</small>"));
}
-void CInfoDisplay::setInfo(const QString &data, const QString &lang) {
- CDisplayTemplateMgr *mgr = CDisplayTemplateMgr::instance();
+void CInfoDisplay::setInfo(const QString & renderedData, const QString & lang) {
+ CDisplayTemplateMgr * const mgr = CDisplayTemplateMgr::instance();
Q_ASSERT(mgr != 0);
CDisplayTemplateMgr::Settings settings;
settings.pageCSS_ID = "infodisplay";
QString div = "<div class=\"infodisplay\"";
- if (!lang.isEmpty()) {
- div.append(" lang=\"");
- div.append(lang);
- div.append("\"");
- }
+ if (!lang.isEmpty())
+ div.append(" lang=\"").append(lang).append("\"");
+
div.append(">");
QString content(mgr->fillTemplate(CDisplayTemplateMgr::activeTemplateName(),
- div + data + "</div>",
+ div + renderedData + "</div>",
settings));
m_htmlPart->setText(content);
}
-void CInfoDisplay::lookupInfo(const QString &mod_name, const QString &key_text) {
+void CInfoDisplay::lookupInfo(const QString & mod_name,
+ const QString & key_text)
+{
qDebug() << "CInfoDisplay::lookup";
qDebug() << mod_name << key_text;
- CSwordModuleInfo* m = CSwordBackend::instance()->findModuleByName(mod_name);
+ CSwordModuleInfo * const m = CSwordBackend::instance()->findModuleByName(mod_name);
Q_ASSERT(m);
if (!m)
return;
- QSharedPointer<CSwordKey> key( CSwordKey::createInstance(m) );
+ QSharedPointer<CSwordKey> key(CSwordKey::createInstance(m));
key->setKey(key_text);
setInfo(key->renderedText(), m->language()->abbrev());
}
-void CInfoDisplay::setInfo(const InfoType type, const QString& data) {
+void CInfoDisplay::setInfo(const InfoType type, const QString & data) {
ListInfoData list;
- list.append( qMakePair(type, data) );
-
+ list.append(qMakePair(type, data));
setInfo(list);
}
-void CInfoDisplay::setInfo(const ListInfoData& list) {
- //if the widget is hidden it would be inefficient to render and display the data
- if (!isVisible()) {
+void CInfoDisplay::setInfo(const ListInfoData & list) {
+ // If the widget is hidden it would be inefficient to render and display the data
+ if (!isVisible())
return;
- }
if (list.isEmpty()) {
m_htmlPart->setText("<html></html>");
return;
}
- QString text;
+ QString renderedText;
ListInfoData::const_iterator end = list.end();
for (ListInfoData::const_iterator it = list.begin(); it != end; ++it) {
- switch ( (*it).first ) {
+ switch ((*it).first) {
case Lemma:
- text.append( decodeStrongs( (*it).second ) );
+ renderedText.append(decodeStrongs((*it).second));
continue;
case Morph:
- text.append( decodeMorph( (*it).second ) );
+ renderedText.append(decodeMorph((*it).second));
continue;
case CrossReference:
- text.append( decodeCrossReference( (*it).second ) );
+ renderedText.append(decodeCrossReference((*it).second));
continue;
case Footnote:
- text.append( decodeFootnote( (*it).second ) );
+ renderedText.append(decodeFootnote((*it).second));
continue;
case WordTranslation:
- text.append( getWordTranslation( (*it).second ) );
+ renderedText.append(getWordTranslation((*it).second));
continue;
case WordGloss:
- //text.append( getWordTranslation( (*it).second ) );
+ //text.append(getWordTranslation((*it).second));
continue;
case Abbreviation:
- text.append( decodeAbbreviation( (*it).second ) );
+ renderedText.append(decodeAbbreviation((*it).second));
continue;
case Text:
- text.append( (*it).second );
+ renderedText.append((*it).second);
continue;
default:
continue;
};
}
-
- setInfo(text);
+ setInfo(renderedText);
}
-void CInfoDisplay::setInfo(CSwordModuleInfo *module) {
+void CInfoDisplay::setInfo(CSwordModuleInfo * const module) {
+ using util::htmlEscape;
+
if (module) {
setInfo(tr("<div class=\"moduleinfo\"><h3>%1</h3><p>%2</p><p>Version: %3</p></div>")
- .arg(module->name())
- .arg(module->config(CSwordModuleInfo::Description))
- .arg(module->config(CSwordModuleInfo::ModuleVersion)));
+ .arg(htmlEscape(module->name()))
+ .arg(htmlEscape(module->config(CSwordModuleInfo::Description)))
+ .arg(htmlEscape(module->config(CSwordModuleInfo::ModuleVersion))));
} else {
unsetInfo();
}
@@ -185,28 +188,21 @@ void CInfoDisplay::selectAll() {
m_htmlPart->selectAll();
}
-const QString CInfoDisplay::decodeAbbreviation( const QString& data ) {
- // QStringList strongs = QStringList::split("|", data);
- QString ret;
- QString text = data;
-
- ret.append(
- QString("<div class=\"abbreviation\"><h3>%1: %2</h3><p>%3</p></div>")
+const QString CInfoDisplay::decodeAbbreviation(const QString & data) {
+ // QStringList strongs = QStringList::split("|", data);
+ return QString("<div class=\"abbreviation\"><h3>%1: %2</h3><p>%3</p></div>")
.arg(tr("Abbreviation"))
.arg("text")
- .arg(text));
-
- return ret;
+ .arg(data);
}
-const QString CInfoDisplay::decodeCrossReference( const QString& data ) {
+const QString CInfoDisplay::decodeCrossReference(const QString & data) {
Q_ASSERT(!data.isEmpty());
- if (data.isEmpty()) {
+ if (data.isEmpty())
return QString("<div class=\"crossrefinfo\"><h3>%1</h3></div>")
.arg(tr("Cross references"));
- }
- // qWarning("setting crossref %s", data.latin1());
+ // qWarning("setting crossref %s", data.latin1());
DisplayOptions dispOpts;
dispOpts.lineBreaks = false;
@@ -223,99 +219,87 @@ const QString CInfoDisplay::decodeCrossReference( const QString& data ) {
CrossRefRendering renderer(dispOpts, filterOpts);
CTextRendering::KeyTree tree;
- // const bool isBible = true;
- CSwordModuleInfo* module = CBTConfig::get(CBTConfig::standardBible);
+ // const bool isBible = true;
+ const CSwordModuleInfo * module = btConfig().getDefaultSwordModuleByType("standardBible");
+ if (!module)
+ module = m_mainWindow->getCurrentModule();
- //a prefixed module gives the module to look into
+ // a prefixed module gives the module to look into
QRegExp re("^[^ ]+:");
- // re.setMinimal(true);
+ // re.setMinimal(true);
int pos = re.indexIn(data);
- if (pos != -1) {
+ if (pos != -1)
pos += re.matchedLength() - 1;
- }
if (pos > 0) {
const QString moduleName = data.left(pos);
- // qWarning("found module %s", moduleName.latin1());
+ // qWarning("found module %s", moduleName.latin1());
module = CSwordBackend::instance()->findModuleByName(moduleName);
- if (!module) {
- module = CBTConfig::get(CBTConfig::standardBible);
- }
- // Q_ASSERT(module);
+ if (!module)
+ module = btConfig().getDefaultSwordModuleByType("standardBible");
+ // Q_ASSERT(module);
}
- //Q_ASSERT(module); //why? the existense of the module is tested later
- CTextRendering::KeyTreeItem::Settings settings (
+ // Q_ASSERT(module); // why? the existense of the module is tested later
+ CTextRendering::KeyTreeItem::Settings settings(
false,
CTextRendering::KeyTreeItem::Settings::CompleteShort
);
if (module && (module->type() == CSwordModuleInfo::Bible)) {
VerseKey vk;
- sword::ListKey refs = vk.ParseVerseList((const char*)data.mid((pos == -1) ? 0 : pos + 1).toUtf8(), "Gen 1:1", true);
+ sword::ListKey refs = vk.parseVerseList((const char*) data.mid((pos == -1) ? 0 : pos + 1).toUtf8(), "Gen 1:1", true);
- for (int i = 0; i < refs.Count(); ++i) {
- SWKey* key = refs.getElement(i);
+ for (int i = 0; i < refs.getCount(); i++) {
+ SWKey * const key = refs.getElement(i);
Q_ASSERT(key);
- VerseKey* vk = dynamic_cast<VerseKey*>(key);
+ VerseKey * const vk = dynamic_cast<VerseKey*>(key);
- CTextRendering::KeyTreeItem* itm = (CTextRendering::KeyTreeItem*)0; //explicit conversion for MS VS
- if (vk && vk->isBoundSet()) { //render a range of keys
- itm = new CTextRendering::KeyTreeItem(
- QString::fromUtf8(vk->LowerBound().getText()),
- QString::fromUtf8(vk->UpperBound().getText()),
+ if (vk && vk->isBoundSet()) { // render a range of keys
+ tree.append(new CTextRendering::KeyTreeItem(
+ QString::fromUtf8(vk->getLowerBound().getText()),
+ QString::fromUtf8(vk->getUpperBound().getText()),
module,
settings
- );
- }
- else {
- itm = new CTextRendering::KeyTreeItem(
+ ));
+ } else {
+ tree.append(new CTextRendering::KeyTreeItem(
QString::fromUtf8(key->getText()),
QString::fromUtf8(key->getText()),
module,
settings
- );
+ ));
}
-
- Q_ASSERT(itm);
-
- tree.append( itm );
}
- }
- else if (module) {
- CTextRendering::KeyTreeItem* itm = new CTextRendering::KeyTreeItem(
- data.mid((pos == -1) ? 0 : pos + 1),
- module,
- settings
- );
- tree.append( itm );
+ } else if (module) {
+ tree.append(new CTextRendering::KeyTreeItem(data.mid((pos == -1)
+ ? 0
+ : pos + 1),
+ module,
+ settings));
}
- // qWarning("rendered the tree: %s", renderer.renderKeyTree(tree).latin1());
- //spanns containing rtl text need dir=rtl on their parent tag to be aligned properly
+ // qWarning("rendered the tree: %s", renderer.renderKeyTree(tree).latin1());
+ // spanns containing rtl text need dir=rtl on their parent tag to be aligned properly
QString lang = "en"; // default english
- if (module) {
+ if (module)
lang = module->language()->abbrev();
- }
-
- const QString RenderedText = renderer.renderKeyTree(tree);
return QString("<div class=\"crossrefinfo\" lang=\"%1\"><h3>%2</h3><div class=\"para\" dir=\"%3\">%4</div></div>")
.arg(lang)
.arg(tr("Cross references"))
.arg(module ? ((module->textDirection() == CSwordModuleInfo::LeftToRight) ? "ltr" : "rtl") : "")
- .arg(RenderedText);
+ .arg(renderer.renderKeyTree(tree));
}
/*!
- \fn CInfoDisplay::decodeFootnote( const QString& data )
+ \fn CInfoDisplay::decodeFootnote(const QString & data)
*/
-const QString CInfoDisplay::decodeFootnote( const QString& data ) {
+const QString CInfoDisplay::decodeFootnote(const QString & data) {
QStringList list = data.split("/");
Q_ASSERT(list.count() >= 3);
- if (!list.count()) {
+ if (!list.count())
return QString::null;
- }
FilterOptions filterOpts;
filterOpts.headings = false;
@@ -336,25 +320,23 @@ const QString CInfoDisplay::decodeFootnote( const QString& data ) {
list.pop_front();
const QString keyname = list.join("/");
- CSwordModuleInfo* module = CSwordBackend::instance()->findModuleByName(modulename);
- if (!module) {
+ CSwordModuleInfo * const module = CSwordBackend::instance()->findModuleByName(modulename);
+ if (!module)
return QString::null;
- }
- QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) );
+ QSharedPointer<CSwordKey> key(CSwordKey::createInstance(module));
key->setKey(keyname);
- key->renderedText(CSwordKey::ProcessEntryAttributesOnly); //force entryAttributes
+ key->renderedText(CSwordKey::ProcessEntryAttributesOnly); // force entryAttributes
- const char* note =
+ const char * const note =
module->module()->getEntryAttributes()
["Footnote"][swordFootnote.toLatin1().data()]["body"].c_str();
QString text = module->isUnicode() ? QString::fromUtf8(note) : QString(note);
- text = QString::fromUtf8(module->module()->RenderText(
+ text = QString::fromUtf8(module->module()->renderText(
module->isUnicode()
- ? (const char*)text.toUtf8()
- : (const char*)text.toLatin1()
- ));
+ ? static_cast<const char *>(text.toUtf8())
+ : static_cast<const char *>(text.toLatin1())));
return QString("<div class=\"footnoteinfo\" lang=\"%1\"><h3>%2</h3><p>%3</p></div>")
.arg(module->language()->abbrev())
@@ -362,22 +344,22 @@ const QString CInfoDisplay::decodeFootnote( const QString& data ) {
.arg(text);
}
-const QString CInfoDisplay::decodeStrongs( const QString& data ) {
+const QString CInfoDisplay::decodeStrongs(const QString & data) {
QStringList strongs = data.split("|");
QString ret;
QStringList::const_iterator end = strongs.end();
for (QStringList::const_iterator it = strongs.begin(); it != end; ++it) {
- CSwordModuleInfo* const module = CBTConfig::get
+ CSwordModuleInfo * const module = btConfig().getDefaultSwordModuleByType
(
((*it).left(1) == QString("H")) ?
- CBTConfig::standardHebrewStrongsLexicon :
- CBTConfig::standardGreekStrongsLexicon
+ "standardHebrewStrongsLexicon" :
+ "standardGreekStrongsLexicon"
);
QString text;
if (module) {
- QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) );
+ QSharedPointer<CSwordKey> key(CSwordKey::createInstance(module));
key->setKey((*it).mid(1)); // skip H or G (language sign), will have to change later if we have better modules
text = key->renderedText();
}
@@ -398,13 +380,13 @@ const QString CInfoDisplay::decodeStrongs( const QString& data ) {
return ret;
}
-const QString CInfoDisplay::decodeMorph( const QString& data ) {
+const QString CInfoDisplay::decodeMorph(const QString & data) {
QStringList morphs = data.split("|");
QString ret;
- foreach(QString morph, morphs) {
+ Q_FOREACH (QString morph, morphs) {
//qDebug() << "CInfoDisplay::decodeMorph, morph: " << morph;
- CSwordModuleInfo* module = 0;
+ CSwordModuleInfo * module = 0;
bool skipFirstChar = false;
QString value = "";
QString valueClass = "";
@@ -412,8 +394,8 @@ const QString CInfoDisplay::decodeMorph( const QString& data ) {
int valStart = morph.indexOf(':');
if (valStart > -1) {
valueClass = morph.mid(0, valStart);
- //qDebug() << "valueClass: " << valueClass;
- module = CSwordBackend::instance()->findModuleByName( valueClass );
+ // qDebug() << "valueClass: " << valueClass;
+ module = CSwordBackend::instance()->findModuleByName(valueClass);
}
value = morph.mid(valStart + 1); //works for prepended module and without (-1 +1 == 0).
@@ -425,51 +407,46 @@ const QString CInfoDisplay::decodeMorph( const QString& data ) {
if (value.size() > 1 && value.at(1).isDigit()) {
switch (value.at(0).toLatin1()) {
case 'G':
- module = CBTConfig::get
- (CBTConfig::standardGreekMorphLexicon);
+ module = btConfig().getDefaultSwordModuleByType("standardGreekMorphLexicon");
skipFirstChar = true;
break;
case 'H':
- module = CBTConfig::get
- (CBTConfig::standardHebrewMorphLexicon);
+ module = btConfig().getDefaultSwordModuleByType("standardHebrewMorphLexicon");
skipFirstChar = true;
break;
default:
skipFirstChar = false;
/// \todo we can't tell here if it's a greek or hebrew moprh code, that's a problem we have to solve
- // module = CBTConfig::get(CBTConfig::standardGreekMorphLexicon);
+ // module = getBtConfig().getDefaultSwordModuleByType("standardGreekMorphLexicon");
break;
}
}
//if it is still not set use the default
- if (!module) {
- module = CBTConfig::get
- (CBTConfig::standardGreekMorphLexicon);
- }
+ if (!module)
+ module = btConfig().getDefaultSwordModuleByType("standardGreekMorphLexicon");
}
QString text;
- //Q_ASSERT(module);
+ // Q_ASSERT(module);
if (module) {
- QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) );
+ QSharedPointer<CSwordKey> key(CSwordKey::createInstance(module));
- //skip H or G (language sign) if we have to skip it
+ // skip H or G (language sign) if we have to skip it
const bool isOk = key->setKey(skipFirstChar ? value.mid(1) : value);
- //Q_ASSERT(isOk);
- if (!isOk) { //try to use the other morph lexicon, because this one failed with the current morph code
- key->setModule(CBTConfig::get
- (CBTConfig::standardHebrewMorphLexicon));
+ // Q_ASSERT(isOk);
+ if (!isOk) { // try to use the other morph lexicon, because this one failed with the current morph code
+ key->setModule(btConfig().getDefaultSwordModuleByType("standardHebrewMorphLexicon")); /// \todo: what if the module doesn't exist?
key->setKey(skipFirstChar ? value.mid(1) : value);
}
text = key->renderedText();
}
- //if the module wasn't found just display an empty morph info
+ // if the module wasn't found just display an empty morph info
QString lang = "en"; // default to english
if (module)
lang = module->language()->abbrev();
- ret.append( QString("<div class=\"morphinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>")
+ ret.append(QString("<div class=\"morphinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>")
.arg(lang)
.arg(tr("Morphology"))
.arg(value)
@@ -480,26 +457,21 @@ const QString CInfoDisplay::decodeMorph( const QString& data ) {
return ret;
}
-const QString CInfoDisplay::getWordTranslation( const QString& data ) {
- CSwordModuleInfo* const module = CBTConfig::get
- (CBTConfig::standardLexicon);
- if (!module) {
+const QString CInfoDisplay::getWordTranslation(const QString & data) {
+ CSwordModuleInfo * const module = btConfig().getDefaultSwordModuleByType("standardLexicon");
+ if (!module)
return QString::null;
- }
- QSharedPointer<CSwordKey> key( CSwordKey::createInstance(module) );
+ QSharedPointer<CSwordKey> key(CSwordKey::createInstance(module));
key->setKey(data);
- if (key->key().toUpper() != data.toUpper()) { //key not present in the lexicon
+ if (key->key().toUpper() != data.toUpper()) //key not present in the lexicon
return QString::null;
- }
- QString ret = QString("<div class=\"translationinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>")
+ return QString("<div class=\"translationinfo\" lang=\"%1\"><h3>%2: %3</h3><p>%4</p></div>")
.arg(module->language()->abbrev())
.arg(tr("Word lookup"))
.arg(data)
.arg(key->renderedText());
-
- return ret;
}
QSize CInfoDisplay::sizeHint() const {
diff --git a/src/frontend/cinfodisplay.h b/src/frontend/cinfodisplay.h
index 7bc15e7..46623ba 100644
--- a/src/frontend/cinfodisplay.h
+++ b/src/frontend/cinfodisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,51 +22,65 @@
class CReadDisplay;
class QAction;
class QSize;
+class BibleTime;
+
namespace InfoDisplay {
-class CInfoDisplay : public QWidget {
- Q_OBJECT
- public:
- enum InfoType {
- Abbreviation,
- CrossReference,
- Footnote,
- Lemma,
- Morph,
- WordTranslation,
- WordGloss,
- Text
- };
-
- typedef QPair<InfoType, QString> InfoData;
- typedef QList<InfoData> ListInfoData;
-
- CInfoDisplay(QWidget *parent = 0);
-
- void unsetInfo();
- void setInfo(const QString &data, const QString &lang = QString());
- void setInfo(const InfoType, const QString& data);
- void setInfo(const ListInfoData&);
- QSize sizeHint() const;
-
- public slots:
- void setInfo(CSwordModuleInfo *module);
-
- protected:
- const QString decodeAbbreviation( const QString& data );
- const QString decodeCrossReference( const QString& data );
- const QString decodeFootnote( const QString& data );
- const QString decodeStrongs( const QString& data );
- const QString decodeMorph( const QString& data );
- const QString getWordTranslation( const QString& data );
-
- protected slots:
- void lookupInfo(const QString &, const QString &);
- void selectAll();
-
- private:
- CReadDisplay* m_htmlPart;
+class CInfoDisplay: public QWidget {
+
+ Q_OBJECT
+
+public: /* Types: */
+
+ enum InfoType {
+ Abbreviation,
+ CrossReference,
+ Footnote,
+ Lemma,
+ Morph,
+ WordTranslation,
+ WordGloss,
+ Text
+ };
+
+ typedef QPair<InfoType, QString> InfoData;
+ typedef QList<InfoData> ListInfoData;
+
+public: /* Methods: */
+
+ CInfoDisplay(BibleTime * parent = NULL);
+
+ void unsetInfo();
+ void setInfo(const QString & renderedData,
+ const QString & lang = QString());
+ void setInfo(const InfoType, const QString & data);
+ void setInfo(const ListInfoData &);
+ QSize sizeHint() const;
+
+public slots:
+
+ void setInfo(CSwordModuleInfo * module);
+
+private: /* Methods: */
+
+ const QString decodeAbbreviation(const QString & data);
+ const QString decodeCrossReference(const QString & data);
+ const QString decodeFootnote(const QString & data);
+ const QString decodeStrongs(const QString & data);
+ const QString decodeMorph(const QString & data);
+ const QString getWordTranslation(const QString & data);
+
+private slots:
+
+ void lookupInfo(const QString &, const QString &);
+ void selectAll();
+
+private: /* Fields: */
+
+ CReadDisplay * m_htmlPart;
+ BibleTime * m_mainWindow;
+
};
} //end of InfoDisplay namespace
diff --git a/src/frontend/cmdiarea.cpp b/src/frontend/cmdiarea.cpp
index fb116af..d879dfa 100644
--- a/src/frontend/cmdiarea.cpp
+++ b/src/frontend/cmdiarea.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,7 +10,7 @@
#include "bibletime.h"
#include "frontend/cmdiarea.h"
#include "frontend/displaywindow/btmodulechooserbar.h"
-
+#include "frontend/display/cdisplay.h"
#include <QEvent>
#include <QMdiSubWindow>
#include <QMenu>
@@ -18,9 +18,26 @@
#include <QTabBar>
#include <QTimer>
#include <QToolBar>
+#include <QWebView>
#include <QWindowStateChangeEvent>
-#define MOVESIZE 30
+
+namespace {
+
+inline CDisplayWindow * getDisplayWindow(const QMdiSubWindow * const mdiWindow) {
+ return qobject_cast<CDisplayWindow *>(mdiWindow->widget());
+}
+
+inline QWebView * getWebViewFromDisplayWindow(const CDisplayWindow * const displayWindow) {
+ if (!displayWindow)
+ return NULL;
+ CDisplay * const display = displayWindow->displayWidget();
+ if (!display)
+ return NULL;
+ return qobject_cast<QWebView *>(display->view());
+}
+
+} // anonymous namespace
CMDIArea::CMDIArea(BibleTime *parent)
@@ -61,8 +78,10 @@ void CMDIArea::fixSystemMenu(QMdiSubWindow* subWindow) {
}
}
-QMdiSubWindow* CMDIArea::addSubWindow(QWidget * widget, Qt::WindowFlags windowFlags) {
- QMdiSubWindow* subWindow = QMdiArea::addSubWindow(widget, windowFlags);
+QMdiSubWindow * CMDIArea::addSubWindow(QWidget * widget,
+ Qt::WindowFlags windowFlags)
+{
+ QMdiSubWindow * const subWindow = QMdiArea::addSubWindow(widget, windowFlags);
subWindow->installEventFilter(this);
fixSystemMenu(subWindow);
@@ -73,28 +92,24 @@ QMdiSubWindow* CMDIArea::addSubWindow(QWidget * widget, Qt::WindowFlags windowFl
// If we already have an active window, make the new one simular to it
if (activeSubWindow()) {
if (activeSubWindow()->isMaximized()) {
- // Maximize the new window
- subWindow->showMaximized();
- }
- else {
+ subWindow->showMaximized(); // Maximize the new window
+ } else {
// Make new window the same size as the active window and move it slightly.
subWindow->resize(activeSubWindow()->size());
QRect subWinGeom = activeSubWindow()->geometry();
+ static const int MOVESIZE = 30;
subWinGeom.translate(MOVESIZE, MOVESIZE);
// If it goes off screen, move it almost to the top left
- if ( ! frameRect().contains(subWinGeom)) {
+ if (!frameRect().contains(subWinGeom))
subWinGeom.moveTo(MOVESIZE, MOVESIZE);
- }
subWindow->setGeometry(subWinGeom);
}
- }
- else {
+ } else {
//set the window to be big enough
subWindow->resize(400, 400);
}
subWindow->raise();
- }
- else {
+ } else {
// Automatic arrangement modes
enableWindowMinMaxFlags(false);
triggerWindowUpdate();
@@ -285,6 +300,14 @@ QList<QMdiSubWindow*> CMDIArea::usableWindowList() const {
return ret;
}
+QWebView* CMDIArea::getActiveWebView()
+{
+ QMdiSubWindow* activeMdiWindow = activeSubWindow();
+ CDisplayWindow* const activeWindow = getDisplayWindow(activeMdiWindow);
+ QWebView* webView = getWebViewFromDisplayWindow(activeWindow);
+ return webView;
+}
+
void CMDIArea::slotSubWindowActivated(QMdiSubWindow* client) {
if (subWindowList().isEmpty())
m_bibleTime->clearMdiToolBars();
@@ -295,13 +318,44 @@ void CMDIArea::slotSubWindowActivated(QMdiSubWindow* client) {
emit sigSetToplevelCaption( client->windowTitle().trimmed() );
// Notify child window it is active
- CDisplayWindow * const activeWindow = qobject_cast<CDisplayWindow*>(client->widget());
+ CDisplayWindow* const activeWindow = getDisplayWindow(client);
if (activeWindow != 0 && activeWindow != m_activeWindow) {
m_activeWindow = activeWindow;
activeWindow->windowActivated();
}
}
+void CMDIArea::findNextTextInActiveWindow(const QString& text, bool caseSensitive) {
+ QWebView* activeWebView = getActiveWebView();
+ if (activeWebView == 0)
+ return;
+ QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
+ if (caseSensitive)
+ options |= QWebPage::FindCaseSensitively;
+ activeWebView->findText(text, options);
+}
+
+void CMDIArea::findPreviousTextInActiveWindow(const QString& text, bool caseSensitive) {
+ QWebView* activeWebView = getActiveWebView();
+ if (activeWebView == 0)
+ return;
+ QWebPage::FindFlags options = QWebPage::FindWrapsAroundDocument;
+ if (caseSensitive)
+ options |= QWebPage::FindCaseSensitively;
+ activeWebView->findText(text, options);
+}
+
+void CMDIArea::highlightTextInActiveWindow(const QString& text, bool caseSensitive) {
+ QWebView* activeWebView = getActiveWebView();
+ if (activeWebView == 0)
+ return;
+ QWebPage::FindFlags options = QWebPage::HighlightAllOccurrences;
+ if (caseSensitive)
+ options |= QWebPage::FindCaseSensitively;
+ activeWebView->findText("", options); // clear old highlight
+ activeWebView->findText(text, options);
+}
+
void CMDIArea::resizeEvent(QResizeEvent* e) {
/*
Do not call QMdiArea::resizeEvent(e) if we are in manual arrangement
diff --git a/src/frontend/cmdiarea.h b/src/frontend/cmdiarea.h
index 4b9d70e..6245d94 100644
--- a/src/frontend/cmdiarea.h
+++ b/src/frontend/cmdiarea.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,6 +20,7 @@
class BibleTime;
class CSwordModuleInfo;
class CDisplayWindow;
+class QWebView;
/**
A custom MDI area widget.
@@ -51,7 +54,15 @@ class CMDIArea: public QMdiArea {
/**
Reimplementation of QMdiArea::addSubWindow().
*/
- QMdiSubWindow *addSubWindow(QWidget *widget, Qt::WindowFlags windowFlags = 0);
+ QMdiSubWindow * addSubWindow(QWidget * widget,
+ Qt::WindowFlags windowFlags = 0);
+
+ /**
+ Returns the BibleTime main window
+ */
+ BibleTime* bibleTimeWindow() {
+ return m_bibleTime;
+ }
/**
Resets the MDI arrangement mode and arranges the windows.
@@ -118,6 +129,12 @@ class CMDIArea: public QMdiArea {
*/
void myTileHorizontal();
+ void findNextTextInActiveWindow(const QString& text, bool caseSensitive);
+
+ void findPreviousTextInActiveWindow(const QString& text, bool caseSensitive);
+
+ void highlightTextInActiveWindow(const QString& text, bool caseSensitive);
+
signals:
/**
@@ -143,6 +160,8 @@ class CMDIArea: public QMdiArea {
void fixSystemMenu(QMdiSubWindow* subWindow);
+ QWebView* getActiveWebView();
+
protected slots:
/**
diff --git a/src/frontend/cprinter.cpp b/src/frontend/cprinter.cpp
index 50ff67d..b10d614 100644
--- a/src/frontend/cprinter.cpp
+++ b/src/frontend/cprinter.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,6 +15,7 @@
#include <QWebPage>
#include "backend/keys/cswordversekey.h"
#include "backend/managers/cdisplaytemplatemgr.h"
+#include "backend/config/btconfig.h"
namespace Printing {
diff --git a/src/frontend/cprinter.h b/src/frontend/cprinter.h
index e702565..48001a1 100644
--- a/src/frontend/cprinter.h
+++ b/src/frontend/cprinter.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/crossrefrendering.cpp b/src/frontend/crossrefrendering.cpp
index ac538da..868b6ce 100644
--- a/src/frontend/crossrefrendering.cpp
+++ b/src/frontend/crossrefrendering.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/crossrefrendering.h b/src/frontend/crossrefrendering.h
index d6f33a2..fb22aa2 100644
--- a/src/frontend/crossrefrendering.h
+++ b/src/frontend/crossrefrendering.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,6 +13,7 @@
#define INFODISPLAYCROSSREFRENDERING_H
#include "backend/rendering/chtmlexportrendering.h"
+#include "backend/config/btconfig.h"
namespace InfoDisplay {
@@ -20,8 +23,8 @@ class CrossRefRendering : public Rendering::CHTMLExportRendering {
friend class CInfoDisplay;
CrossRefRendering(
- const DisplayOptions &displayOptions = CBTConfig::getDisplayOptionDefaults(),
- const FilterOptions &filterOptions = CBTConfig::getFilterOptionDefaults()
+ const DisplayOptions &displayOptions = btConfig().getDisplayOptions(),
+ const FilterOptions &filterOptions = btConfig().getFilterOptions()
);
virtual QString entryLink(const KeyTreeItem &item,
diff --git a/src/frontend/display/btcolorwidget.cpp b/src/frontend/display/btcolorwidget.cpp
index 0d09259..579e461 100644
--- a/src/frontend/display/btcolorwidget.cpp
+++ b/src/frontend/display/btcolorwidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/btcolorwidget.h b/src/frontend/display/btcolorwidget.h
index 5cc0f56..9dd2e97 100644
--- a/src/frontend/display/btcolorwidget.h
+++ b/src/frontend/display/btcolorwidget.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/btfindwidget.cpp b/src/frontend/display/btfindwidget.cpp
new file mode 100644
index 0000000..1ada629
--- /dev/null
+++ b/src/frontend/display/btfindwidget.cpp
@@ -0,0 +1,118 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "frontend/display/btfindwidget.h"
+
+#include "QApplication"
+#include "QCheckBox"
+#include "QHBoxLayout"
+#include "QLineEdit"
+#include "QSpacerItem"
+#include "QToolButton"
+#include "bibletimeapp.h"
+#include "util/cresmgr.h"
+#include "util/geticon.h"
+
+
+BtFindWidget::BtFindWidget(QWidget* parent)
+ : QWidget(parent) {
+ createLayout();
+ createToolButton(CResMgr::findWidget::close_icon, "", SLOT(hide()));
+ createTextEditor();
+ createToolButton(CResMgr::findWidget::previous_icon, tr("Previous"), SLOT(findPrevious()));
+ createToolButton(CResMgr::findWidget::next_icon, tr("Next"), SLOT(findNext()));
+ createCaseCheckBox();
+ createSpacer();
+ setFocusProxy(m_textEditor);
+}
+
+BtFindWidget::~BtFindWidget() {
+}
+
+void BtFindWidget::createLayout() {
+ m_layout = new QHBoxLayout(this);
+ m_layout->setMargin(0);
+ m_layout->setSpacing(8);
+}
+
+void BtFindWidget::createToolButton(const QString& iconName, const QString& text, const char* slot) {
+ QToolButton* button = new QToolButton(this);
+ button->setIcon(util::getIcon(iconName));
+ button->setIconSize(QSize(16,16));
+ button->setText(text);
+ button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ button->setAutoRaise(true);
+ m_layout->addWidget(button);
+ bool ok = connect(button, SIGNAL(released()), this, slot);
+ Q_ASSERT(ok);
+}
+
+void BtFindWidget::createTextEditor() {
+ m_textEditor = new QLineEdit(this);
+#if QT_VERSION < 0x050000
+ m_textEditor->setToolTip(QApplication::translate("findWidget",
+ "The text you want to search for", 0, QApplication::UnicodeUTF8));
+#else
+ m_textEditor->setToolTip(QApplication::translate("findWidget",
+ "The text you want to search for", 0));
+#endif
+ m_layout->addWidget(m_textEditor);
+ bool ok = connect(m_textEditor, SIGNAL(textChanged(const QString&)),
+ this, SLOT(textChanged(const QString&)));
+ Q_ASSERT(ok);
+ ok = connect(m_textEditor,SIGNAL(returnPressed()), this, SLOT(returnPressed()));
+ Q_ASSERT(ok);
+}
+
+void BtFindWidget::createCaseCheckBox() {
+ m_caseCheckBox = new QCheckBox(tr("Match case"), this);
+ m_layout->addWidget(m_caseCheckBox);
+}
+
+void BtFindWidget::createSpacer() {
+ QSpacerItem* spacer = new QSpacerItem(0,0,QSizePolicy::Expanding, QSizePolicy::Minimum);
+ m_layout->addItem(spacer);
+}
+
+void BtFindWidget::highlightText(const QString& text) {
+ bool caseSensitive = m_caseCheckBox->checkState() == Qt::Checked;
+ emit highlightText(text, caseSensitive);
+}
+
+void BtFindWidget::returnPressed() {
+ bool caseSensitive = m_caseCheckBox->checkState() == Qt::Checked;
+ QString text = m_textEditor->text();
+ emit highlightText(text, caseSensitive);
+ emit findNext(text, caseSensitive);
+}
+
+void BtFindWidget::textChanged(const QString& text) {
+ bool caseSensitive = m_caseCheckBox->checkState() == Qt::Checked;
+ emit highlightText(text, caseSensitive);
+ emit findNext(text, caseSensitive);
+}
+
+void BtFindWidget::findNext() {
+ bool caseSensitive = m_caseCheckBox->checkState() == Qt::Checked;
+ QString text = m_textEditor->text();
+ emit findNext(text, caseSensitive);
+}
+
+void BtFindWidget::findPrevious() {
+ bool caseSensitive = m_caseCheckBox->checkState() == Qt::Checked;
+ QString text = m_textEditor->text();
+ emit findPrevious(text, caseSensitive);
+}
+
+void BtFindWidget::showAndSelect(){
+ setVisible(true);
+ QWidget::show();
+ m_textEditor->selectAll();
+ m_textEditor->setFocus(Qt::ShortcutFocusReason);
+}
diff --git a/src/frontend/display/btfindwidget.h b/src/frontend/display/btfindwidget.h
new file mode 100644
index 0000000..52a879a
--- /dev/null
+++ b/src/frontend/display/btfindwidget.h
@@ -0,0 +1,56 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTFINDIDGET_H
+#define BTFINDIDGET_H
+
+#include <QWidget>
+#include <QWebPage>
+class QCheckBox;
+class QLineEdit;
+class QHBoxLayout;
+class QString;
+
+class BtFindWidget : public QWidget {
+ Q_OBJECT
+
+ public:
+ BtFindWidget(QWidget* parent = 0);
+ ~BtFindWidget();
+ void showAndSelect();
+
+ private slots:
+ void findNext();
+ void findPrevious();
+ void returnPressed();
+ void textChanged(const QString& text);
+
+ private:
+ void createCaseCheckBox();
+ void createLayout();
+ void createSpacer();
+ void createTextEditor();
+ void createToolButton(const QString& iconName, const QString& text, const char* slot);
+ void highlightText(const QString& searchText);
+
+ QHBoxLayout* m_layout;
+ QLineEdit* m_textEditor;
+ QCheckBox* m_caseCheckBox;
+
+ signals:
+ void findPrevious(const QString & text, bool caseSensitive);
+ void findNext(const QString & text, bool caseSensitive);
+ void highlightText(const QString & text, bool caseSensitive);
+};
+
+#endif
+
+
diff --git a/src/frontend/display/btfontsizewidget.cpp b/src/frontend/display/btfontsizewidget.cpp
index b302fed..82fdd08 100644
--- a/src/frontend/display/btfontsizewidget.cpp
+++ b/src/frontend/display/btfontsizewidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/btfontsizewidget.h b/src/frontend/display/btfontsizewidget.h
index c2d7198..40b94a1 100644
--- a/src/frontend/display/btfontsizewidget.h
+++ b/src/frontend/display/btfontsizewidget.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/bthtml.js b/src/frontend/display/bthtml.js
index 689ba55..d56318f 100644
--- a/src/frontend/display/bthtml.js
+++ b/src/frontend/display/bthtml.js
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,119 +18,105 @@ var timeOutId = -1;
// Scroll window to html anchor
function gotoAnchor(anchor)
{
- document.location=document.location + "#" + anchor;
-}
-
-// Set body editable
-function setEditable()
-{
- var theBody = document.getElementsByTagName('body')[0];
- theBody.setAttribute('contenteditable','true');
-}
-
-// Set body not editable
-function setNotEditable()
-{
- var theBody = document.getElementsByTagName('body')[0];
- theBody.setAttribute('contenteditable','false');
+ document.location=document.location + "#" + anchor;
}
// Mouse button clicked handler
function mouseClickHandler (mEvent)
{
- var mTarget = mEvent.target;
- if (mTarget)
- {
- var url = "";
- var tmpUrl = mEvent.target.getAttribute("href");
- if (tmpUrl)
- url = tmpUrl;
- btHtmlJsObject.mouseClick(url);
- }
+ var mTarget = mEvent.target;
+ if (mTarget)
+ {
+ var url = "";
+ var tmpUrl = mEvent.target.getAttribute("href");
+ if (tmpUrl)
+ url = tmpUrl;
+ btHtmlJsObject.mouseClick(url);
+ }
}
// Mouse button pressed down handler
function mouseDownHandler (mEvent)
{
- var node;
- var url = "";
- var lemma = "";
- var mTarget = mEvent.target;
- if (mTarget)
- {
- var tmpUrl = mEvent.target.getAttribute("href");
- if (tmpUrl)
- url = tmpUrl;
- var tmpLemma = mEvent.target.getAttribute("lemma");
- if (tmpLemma)
- lemma = tmpLemma;
- }
-
- if (mEvent.button === 2) // Right mouse button
- {
- btHtmlJsObject.mouseDownRight(url, lemma);
- }
- if (mEvent.button === 0) // Left mouse button
- {
- if (!(mEvent.target === undefined))
- {
- var X = mEvent.clientX;
- var Y = mEvent.clientY;
- btHtmlJsObject.mouseDownLeft(url, X, Y);
- }
- }
+ var node;
+ var url = "";
+ var lemma = "";
+ var mTarget = mEvent.target;
+ if (mTarget)
+ {
+ var tmpUrl = mEvent.target.getAttribute("href");
+ if (tmpUrl)
+ url = tmpUrl;
+ var tmpLemma = mEvent.target.getAttribute("lemma");
+ if (tmpLemma)
+ lemma = tmpLemma;
+ }
+
+ if (mEvent.button === 2) // Right mouse button
+ {
+ btHtmlJsObject.mouseDownRight(url, lemma);
+ }
+ if (mEvent.button === 0) // Left mouse button
+ {
+ if (!(mEvent.target === undefined))
+ {
+ var X = mEvent.clientX;
+ var Y = mEvent.clientY;
+ btHtmlJsObject.mouseDownLeft(url, X, Y);
+ }
+ }
}
// Mouse moved event handler
function mouseMoveHandler (mEvent)
{
- currentNode = mEvent.target;
- var shiftKey = mEvent.shiftKey;
- var x = mEvent.clientX;
- var y = mEvent.clientY;
- var node = mEvent.target;
- if ( node != undefined && node != prevNode )
- {
- prevNode = node;
-
- if (node.attributes.length > 0)
- {
- attribList = getNodeAttributes(node);
- btHtmlJsObject.mouseMoveEvent(attribList, x, y, shiftKey);
- }
- }
+ currentNode = mEvent.target;
+ var shiftKey = mEvent.shiftKey;
+ var x = mEvent.clientX;
+ var y = mEvent.clientY;
+ var node = mEvent.target;
+ if ( node != undefined && node != prevNode )
+ {
+ prevNode = node;
+
+ if (node.attributes.length > 0)
+ {
+ attribList = getNodeAttributes(node);
+ btHtmlJsObject.mouseMoveEvent(attribList, x, y, shiftKey);
+ }
+ }
}
// Get attributes of a DOM node and put into a single string
function getNodeAttributes(node)
{
- var attribList = '';
- if (node.attributes.length > 0)
- {
- for (i = 0; i < node.attributes.length; i++)
- {
- attribList = attribList + node.attributes[i].nodeName + '=' + node.attributes[i].nodeValue + '||';
- }
- }
- return attribList;
+ var attribList = '';
+ if (node.attributes.length > 0)
+ {
+ for (i = 0; i < node.attributes.length; i++)
+ {
+ attribList = attribList + node.attributes[i].nodeName + '=' + node.attributes[i].nodeValue + '||';
+ }
+ }
+ return attribList;
}
// Start a timer event
function startTimer(time)
{
- clearTimeout(timeOutId);
- timeOutId = setTimeout("timerEvent()",time);
+ clearTimeout(timeOutId);
+ timeOutId = setTimeout("timerEvent()",time);
}
// Handles a timer event
function timerEvent()
{
- timeOutId = -1;
- if (currentNode != 0 && currentNode == prevNode)
- {
- var attributes = getNodeAttributes(currentNode);
- btHtmlJsObject.timeOutEvent(attributes);
- }
+ timeOutId = -1;
+ if (currentNode != 0 && currentNode == prevNode)
+ {
+ var attributes = getNodeAttributes(currentNode);
+ btHtmlJsObject.timeOutEvent(attributes);
+ }
}
document.getElementsByTagName("body")[0].addEventListener ('mousedown', function (eve) { mouseDownHandler (eve); }, true);
@@ -139,8 +125,6 @@ document.getElementsByTagName("body")[0].addEventListener ('click', function
btHtmlJsObject.startTimer.connect(this, this.startTimer);
btHtmlJsObject.gotoAnchor.connect(this, this.gotoAnchor);
-btHtmlJsObject.setDocumentEditable.connect(this, this.setEditable);
-btHtmlJsObject.setDocumentNotEditable.connect(this, this.setNotEditable);
;
diff --git a/src/frontend/display/bthtmlfindtext.cpp b/src/frontend/display/bthtmlfindtext.cpp
deleted file mode 100644
index 1b15b11..0000000
--- a/src/frontend/display/bthtmlfindtext.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*********
-*
-* 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/display/bthtmlfindtext.h"
-
-#include <QMdiSubWindow>
-#include "frontend/cmdiarea.h"
-#include "frontend/display/bthtmlreaddisplay.h"
-#include "frontend/display/creaddisplay.h"
-#include "frontend/displaywindow/cdisplaywindow.h"
-
-
-static BtHtmlFindText* dialog = 0;
-
-void showBtHtmlFindText(CMDIArea* mdiArea) {
- if (dialog == 0)
- dialog = new BtHtmlFindText(mdiArea, mdiArea);
- dialog->show();
-}
-
-BtHtmlFindText::BtHtmlFindText(CMDIArea* mdiArea, QWidget *parent, Qt::WindowFlags f)
- : QDialog(parent, f), m_mdiArea(mdiArea) {
- ui.setupUi(this);
- bool ok;
- ok = connect(ui.nextButton, SIGNAL(clicked()), this, SLOT(findNext()));
- Q_ASSERT(ok);
- ok = connect(ui.previousButton, SIGNAL(clicked()), this, SLOT(findPrevious()));
- Q_ASSERT(ok);
-}
-
-BtHtmlFindText::~BtHtmlFindText() {
-}
-
-void BtHtmlFindText::findNext() {
- QWebView* webView = getActiveWindowWebView();
- if (webView != 0) {
- QWebPage::FindFlags options = 0;
- if (ui.caseBox->checkState() == Qt::Checked)
- options |= QWebPage::FindCaseSensitively;
- QString searchText = ui.findTextComboBox->currentText();
- if (!searchText.isEmpty())
- webView->findText(searchText, options);
- }
-}
-
-void BtHtmlFindText::findPrevious() {
- QWebView* webView = getActiveWindowWebView();
- if (webView != 0) {
- QWebPage::FindFlags options = QWebPage::FindBackward;
- if (ui.caseBox->checkState() == Qt::Checked)
- options |= QWebPage::FindCaseSensitively;
- QString searchText = ui.findTextComboBox->currentText();
- if (!searchText.isEmpty())
- webView->findText(searchText, options);
- }
-}
-
-
-QWebView* BtHtmlFindText::getActiveWindowWebView() {
- QMdiSubWindow* activeSubWindow = m_mdiArea->activeSubWindow();
- if (activeSubWindow == 0)
- return 0;
-
- QWidget* activeWindowWidget = activeSubWindow->widget();
- if (activeWindowWidget == 0)
- return 0;
-
- CDisplayWindow* cDisplayWindow = qobject_cast<CDisplayWindow*>(activeWindowWidget);
- if (cDisplayWindow == 0)
- return 0;
-
- CDisplay* cDisplay = cDisplayWindow->displayWidget();
- if (cDisplay == 0)
- return 0;
-
- QWidget* textView = cDisplay->view();
- if (textView == 0)
- return 0;
-
- QWebView* webView = qobject_cast<QWebView*>(textView);
- return webView;
-}
-
-
-
-
-
-
-
diff --git a/src/frontend/display/bthtmlfindtext.h b/src/frontend/display/bthtmlfindtext.h
deleted file mode 100644
index 1d941c1..0000000
--- a/src/frontend/display/bthtmlfindtext.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*********
-*
-* 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 BTHTMLFINDTEXT_H
-#define BTHTMLFINDTEXT_H
-
-/// \todo Qt Designer UI file!?
-#include "ui_bthtmlfindtext.h"
-
-
-class CMDIArea;
-class QWebView;
-
-class BtHtmlFindText : public QDialog {
- Q_OBJECT
-
- public:
- BtHtmlFindText(CMDIArea* mdiArea, QWidget *parent = 0, Qt::WindowFlags f = 0);
- ~BtHtmlFindText();
- public slots:
- void findNext();
- void findPrevious();
- private:
- QWebView* getActiveWindowWebView();
- Ui_findTextDialog ui;
- CMDIArea* m_mdiArea;
-};
-
-
-#endif
diff --git a/src/frontend/display/bthtmlfindtext.ui b/src/frontend/display/bthtmlfindtext.ui
deleted file mode 100644
index c04de0c..0000000
--- a/src/frontend/display/bthtmlfindtext.ui
+++ /dev/null
@@ -1,145 +0,0 @@
-<ui version="4.0" >
- <class>findTextDialog</class>
- <widget class="QDialog" name="findTextDialog" >
- <property name="geometry" >
- <rect>
- <x>0</x>
- <y>0</y>
- <width>227</width>
- <height>115</height>
- </rect>
- </property>
- <property name="windowTitle" >
- <string>Find Text</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout" >
- <item>
- <widget class="QFrame" name="findFrame" >
- <property name="frameShape" >
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow" >
- <enum>QFrame::Raised</enum>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2" >
- <item>
- <spacer name="verticalSpacer" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QComboBox" name="findTextComboBox" >
- <property name="toolTip" >
- <string>The text you want to search for</string>
- </property>
- <property name="editable" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="caseBox" >
- <property name="toolTip" >
- <string>Search with case sensitivity</string>
- </property>
- <property name="text" >
- <string>Case &amp;sensitive</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_2" >
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_6" >
- <item>
- <spacer name="horizontalSpacer_6" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="previousButton" >
- <property name="toolTip" >
- <string>Find the previous location of the text</string>
- </property>
- <property name="text" >
- <string>&amp;Previous</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="nextButton" >
- <property name="toolTip" >
- <string>Find the next location of the text</string>
- </property>
- <property name="text" >
- <string>&amp;Next</string>
- </property>
- <property name="default" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="closeButton" >
- <property name="toolTip" >
- <string>Close the dialog</string>
- </property>
- <property name="text" >
- <string>&amp;Close</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections>
- <connection>
- <sender>closeButton</sender>
- <signal>clicked()</signal>
- <receiver>findTextDialog</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>200</x>
- <y>124</y>
- </hint>
- <hint type="destinationlabel" >
- <x>224</x>
- <y>106</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/src/frontend/display/bthtmljsobject.cpp b/src/frontend/display/bthtmljsobject.cpp
index aa44865..cb395cc 100644
--- a/src/frontend/display/bthtmljsobject.cpp
+++ b/src/frontend/display/bthtmljsobject.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,7 +11,7 @@
#include <QDrag>
#include <QSharedPointer>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/keys/cswordkey.h"
#include "backend/managers/referencemanager.h"
#include "backend/managers/cswordbackend.h"
@@ -105,7 +105,7 @@ void BtHtmlJsObject::mouseMoveEvent(const QString& attributes, const int& x, con
// no mouse button pressed and tracking enabled
// start timer that updates the mag window
// Sets timer in javascript. See bthtml.js startTimer()
- emit startTimer(CBTConfig::get(CBTConfig::magDelay));
+ emit startTimer(btConfig().value<int>("GUI/magDelay", 400));
m_prev_attributes = attributes;
// When the javascript timer interupts, the see timerEvent() in bthtml.js
// will call the timeOutEvent in this class
@@ -113,40 +113,32 @@ void BtHtmlJsObject::mouseMoveEvent(const QString& attributes, const int& x, con
}
// called from javascript timerEvent() in bthtml.js
-void BtHtmlJsObject::timeOutEvent(const QString& attributes) {
+void BtHtmlJsObject::timeOutEvent(const QString & attributes) {
if (m_prev_attributes != attributes)
return;
m_prev_attributes = "";
CInfoDisplay::ListInfoData infoList;
- QStringList attrList = attributes.split("||");
+ const QStringList attrList = attributes.split("||");
for (int i = 0; i < attrList.count(); i++) {
- QString attrPair = attrList[i];
- QStringList attr = attrPair.split("=");
+ const QStringList attr(attrList[i].split('='));
if (attr.count() == 2) {
- QString attrName = attr[0];
- QString attrValue = attr[1];
- if (attrName == "note") {
- infoList.append( qMakePair(CInfoDisplay::Footnote, attrValue));
- }
- if (attrName == "lemma") {
- infoList.append( qMakePair(CInfoDisplay::Lemma, attrValue));
- }
- if (attrName == "morph") {
- infoList.append( qMakePair(CInfoDisplay::Morph, attrValue));
- }
- if (attrName == "expansion") {
- infoList.append( qMakePair(CInfoDisplay::Abbreviation, attrValue));
- }
- if (attrName == "crossrefs") {
- infoList.append( qMakePair(CInfoDisplay::CrossReference, attrValue));
+ if (attr[0] == "note") {
+ infoList.append(qMakePair(CInfoDisplay::Footnote, attr[1]));
+ } else if (attr[0] == "lemma") {
+ infoList.append(qMakePair(CInfoDisplay::Lemma, attr[1]));
+ } else if (attr[0] == "morph") {
+ infoList.append(qMakePair(CInfoDisplay::Morph, attr[1]));
+ } else if (attr[0] == "expansion") {
+ infoList.append(qMakePair(CInfoDisplay::Abbreviation, attr[1]));
+ } else if (attr[0] == "crossrefs") {
+ infoList.append(qMakePair(CInfoDisplay::CrossReference, attr[1]));
}
}
}
// Update the mag if valid attributes were found
- if (!(infoList.isEmpty())) {
+ if (!(infoList.isEmpty()))
BibleTime::instance()->infoDisplay()->setInfo(infoList);
- }
}
// clearing the previous attribute effectively stops any time out event
diff --git a/src/frontend/display/bthtmljsobject.h b/src/frontend/display/bthtmljsobject.h
index 109de5a..3bf37f5 100644
--- a/src/frontend/display/bthtmljsobject.h
+++ b/src/frontend/display/bthtmljsobject.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/bthtmlreaddisplay.cpp b/src/frontend/display/bthtmlreaddisplay.cpp
index 1842178..7b303e7 100644
--- a/src/frontend/display/bthtmlreaddisplay.cpp
+++ b/src/frontend/display/bthtmlreaddisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,8 +14,10 @@
#include <QString>
#include "backend/keys/cswordkey.h"
#include "backend/managers/referencemanager.h"
+#include "bibletime.h"
#include "frontend/cdragdrop.h"
#include "frontend/cinfodisplay.h"
+#include "frontend/cmdiarea.h"
#include "frontend/display/bthtmljsobject.h"
#include "frontend/displaywindow/cdisplaywindow.h"
#include "frontend/displaywindow/cdisplaywindowfactory.h"
@@ -25,8 +27,6 @@
using namespace InfoDisplay;
-void showBtHtmlFindText(CMDIArea*);
-
static QString javascript; // Initialized from file bthtml.js
BtHtmlReadDisplay::BtHtmlReadDisplay(CReadWindow* readWindow, QWidget* parentWidget)
@@ -266,8 +266,8 @@ void BtHtmlReadDisplay::setLemma(const QString& lemma) {
// Open the Find text dialog
void BtHtmlReadDisplay::openFindTextDialog() {
- CMDIArea* mdiArea = parentWindow()->mdi();
- showBtHtmlFindText(mdiArea);
+ BibleTime* bibleTime = parentWindow()->mdi()->bibleTimeWindow();
+ bibleTime->openFindWidget();
}
// Send "completed" signal when the text is finished loading into the viewer
diff --git a/src/frontend/display/bthtmlreaddisplay.h b/src/frontend/display/bthtmlreaddisplay.h
index f1e1f5c..0a703d3 100644
--- a/src/frontend/display/bthtmlreaddisplay.h
+++ b/src/frontend/display/bthtmlreaddisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -23,11 +25,6 @@
class BtHtmlReadDisplayView;
-class QScrollArea;
-class QWidget;
-class QString;
-class BtHtmlReadDisplay;
-class QEvent;
/** The implementation for the HTML read display.
* @author The BibleTime team
@@ -38,6 +35,10 @@ class BtHtmlReadDisplay : public QWebPage, public CReadDisplay {
friend class BtHtmlReadDisplayView;
public:
+
+ BtHtmlReadDisplay( CReadWindow* readWindow, QWidget* parent = 0 );
+ virtual ~BtHtmlReadDisplay();
+
//reimplemented functions from CDisplay
// Returns the right text part in the specified format.
virtual const QString text( const CDisplay::TextType format = CDisplay::HTMLText,
@@ -68,9 +69,7 @@ class BtHtmlReadDisplay : public QWebPage, public CReadDisplay {
void completed();
protected:
- friend class CDisplay;
- BtHtmlReadDisplay( CReadWindow* readWindow, QWidget* parent = 0 );
- virtual ~BtHtmlReadDisplay();
+
void slotGoToAnchor(const QString& anchor);
struct DNDData {
bool mousePressed;
diff --git a/src/frontend/display/cdisplay.cpp b/src/frontend/display/cdisplay.cpp
index 4def9f5..a5c5bc8 100644
--- a/src/frontend/display/cdisplay.cpp
+++ b/src/frontend/display/cdisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -98,20 +98,6 @@ void CDisplayConnections::openFindTextDialog() {
/*----------------------*/
-CReadDisplay* CDisplay::createReadInstance( CReadWindow* readWindow, QWidget* parent ) {
- return new BtHtmlReadDisplay(readWindow, parent);
-}
-
-CWriteDisplay* CDisplay::createWriteInstance( CWriteWindow* writeWindow, const CWriteDisplay::WriteDisplayType& type, QWidget* parent ) {
- // qWarning("CDisplay::createWriteInstance");
- if (type == PlainTextDisplay) {
- return new CPlainWriteDisplay(writeWindow, parent);
- }
- else {
- return new CHTMLWriteDisplay(writeWindow, parent);
- };
-}
-
CDisplay::CDisplay(CDisplayWindow* parent) :
m_parentWindow(parent),
diff --git a/src/frontend/display/cdisplay.h b/src/frontend/display/cdisplay.h
index a0a0020..de971d5 100644
--- a/src/frontend/display/cdisplay.h
+++ b/src/frontend/display/cdisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,10 +18,6 @@
class CDisplayConnections;
class CDisplayWindow;
-class CReadDisplay;
-class CReadWindow;
-class CWriteDisplay;
-class CWriteWindow;
class QMenu;
/** The base class for all display widgets.
@@ -27,15 +25,6 @@ class QMenu;
*/
class CDisplay {
public:
- enum WriteDisplayType {
- HTMLDisplay = 0,
- PlainTextDisplay
- };
-
- static CReadDisplay* createReadInstance(CReadWindow* readWindow, QWidget* parent = 0);
- static CWriteDisplay* createWriteInstance( CWriteWindow* writeWindow,
- const WriteDisplayType& type = PlainTextDisplay,
- QWidget* parent = 0 );
enum TextType {
HTMLText, /* Used for HTML markup */
diff --git a/src/frontend/display/chtmlwritedisplay.cpp b/src/frontend/display/chtmlwritedisplay.cpp
index ce7b94c..829f607 100644
--- a/src/frontend/display/chtmlwritedisplay.cpp
+++ b/src/frontend/display/chtmlwritedisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,90 +14,109 @@
#include <QTextEdit>
#include <QToolBar>
#include <QToolTip>
+#include "backend/config/btconfig.h"
+#include "bibletimeapp.h"
#include "frontend/display/btcolorwidget.h"
#include "frontend/display/btfontsizewidget.h"
#include "frontend/displaywindow/btactioncollection.h"
-#include "frontend/displaywindow/cwritewindow.h"
+#include "frontend/displaywindow/chtmlwritewindow.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
class BtActionCollection;
-CHTMLWriteDisplay::CHTMLWriteDisplay(CWriteWindow* parentWindow, QWidget* parent)
-: CPlainWriteDisplay(parentWindow, parent) {
- m_actions.bold = 0;
- m_actions.italic = 0;
- m_actions.underline = 0;
- m_actions.selectAll = 0;
+namespace {
+const QString CHTMLWriteDisplayFontKey = "HtmlWriteDisplay/font";
+const QString CHTMLWriteDisplayFontColorKey = "HtmlWriteDisplay/fontColor";
+}
+
+CHTMLWriteDisplay::CHTMLWriteDisplay(CHTMLWriteWindow * parentWindow, QWidget* parent)
+ : CPlainWriteDisplay(parentWindow, parent)
+ , m_handingFormatChangeFromEditor(false)
+{
+
+ BtConfig & conf = btConfig();
+ setTextColor(conf.sessionValue(CHTMLWriteDisplayFontColorKey, textColor()));
+ QFont f = conf.sessionValue(CHTMLWriteDisplayFontKey, currentFont());
+ setCurrentFont(f);
+
//--------------------bold toggle-------------------------
- namespace DU = util::directory;
m_actions.bold = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::boldText::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::boldText::icon),
tr("Bold"),
this);
m_actions.bold->setCheckable(true);
+ m_actions.bold->setChecked(f.bold());
m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::boldText::accel);
m_actions.bold->setToolTip( tr("Bold") );
- connect(m_actions.bold, SIGNAL(toggled(bool)), this, SLOT(toggleBold(bool)));
+ connect(m_actions.bold, SIGNAL(toggled(bool)),
+ this, SLOT(toggleBold(bool)), Qt::DirectConnection);
//--------------------italic toggle-------------------------
m_actions.italic = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::italicText::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::italicText::icon),
tr("Italic"),
this );
m_actions.italic->setCheckable(true);
+ m_actions.italic->setChecked(f.italic());
m_actions.bold->setShortcut(CResMgr::displaywindows::writeWindow::italicText::accel);
- connect(m_actions.italic, SIGNAL(toggled(bool)), this, SLOT(toggleItalic(bool)));
+ connect(m_actions.italic, SIGNAL(toggled(bool)),
+ this, SLOT(toggleItalic(bool)), Qt::DirectConnection);
m_actions.italic->setToolTip( tr("Italic") );
//--------------------underline toggle-------------------------
m_actions.underline = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::underlinedText::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::underlinedText::icon),
tr("Underline"),
this );
m_actions.underline->setCheckable(true);
+ m_actions.underline->setChecked(f.underline());
m_actions.underline->setShortcut(CResMgr::displaywindows::writeWindow::underlinedText::accel);
- connect(m_actions.underline, SIGNAL(toggled(bool)), this, SLOT(toggleUnderline(bool)));
+ connect(m_actions.underline, SIGNAL(toggled(bool)),
+ this, SLOT(toggleUnderline(bool)), Qt::DirectConnection);
m_actions.underline->setToolTip( tr("Underline") );
//--------------------align left toggle-------------------------
m_actions.alignLeft = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::alignLeft::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::alignLeft::icon),
tr("Left"), this);
m_actions.alignLeft->setCheckable(true);
m_actions.alignLeft->setShortcut(CResMgr::displaywindows::writeWindow::alignLeft::accel);
- connect(m_actions.alignLeft, SIGNAL(toggled(bool)), this, SLOT(alignLeft(bool)));
+ connect(m_actions.alignLeft, SIGNAL(toggled(bool)),
+ this, SLOT(alignLeft(bool)), Qt::DirectConnection);
m_actions.alignLeft->setToolTip( tr("Align left") );
//--------------------align center toggle-------------------------
m_actions.alignCenter = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::alignCenter::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::alignCenter::icon),
tr("Center"), this);
m_actions.alignCenter->setCheckable(true);
m_actions.alignCenter->setShortcut(CResMgr::displaywindows::writeWindow::alignCenter::accel);
- connect(m_actions.alignCenter, SIGNAL(toggled(bool)), this, SLOT(alignCenter(bool)));
+ connect(m_actions.alignCenter, SIGNAL(toggled(bool)),
+ this, SLOT(alignCenter(bool)), Qt::DirectConnection);
m_actions.alignCenter->setToolTip( tr("Center") );
//--------------------align right toggle-------------------------
m_actions.alignRight = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::alignRight::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::alignRight::icon),
tr("Right"), this);
m_actions.alignRight->setCheckable(true);
m_actions.alignRight->setShortcut(CResMgr::displaywindows::writeWindow::alignRight::accel);
- connect(m_actions.alignRight, SIGNAL(toggled(bool)), this, SLOT(alignRight(bool)));
+ connect(m_actions.alignRight, SIGNAL(toggled(bool)),
+ this, SLOT(alignRight(bool)), Qt::DirectConnection);
m_actions.alignRight->setToolTip( tr("Align right") );
setAcceptRichText(true);
setAcceptDrops(true);
viewport()->setAcceptDrops(true);
-}
-CHTMLWriteDisplay::~CHTMLWriteDisplay() {
+ connect(this, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
+ this, SLOT(slotCurrentCharFormatChanged(QTextCharFormat)), Qt::DirectConnection);
}
-void CHTMLWriteDisplay::setText( const QString& newText ) {
+void CHTMLWriteDisplay::setText(const QString & newText) {
QTextEdit::setHtml(newText);
}
@@ -105,42 +124,45 @@ const QString CHTMLWriteDisplay::plainText() {
return QTextEdit::toPlainText();
}
-void CHTMLWriteDisplay::toggleBold(bool) {
- setFontWeight( m_actions.bold->isChecked() ? QFont::Bold : QFont::Normal );
+void CHTMLWriteDisplay::toggleBold(bool checked) {
+ if (!m_handingFormatChangeFromEditor)
+ setFontWeight(checked ? QFont::Bold : QFont::Normal);
}
-void CHTMLWriteDisplay::toggleItalic(bool) {
- setFontItalic( m_actions.italic->isChecked() );
+void CHTMLWriteDisplay::toggleItalic(bool checked) {
+ if (!m_handingFormatChangeFromEditor)
+ setFontItalic(checked);
}
-void CHTMLWriteDisplay::toggleUnderline(bool) {
- setFontUnderline( m_actions.underline->isChecked() );
+void CHTMLWriteDisplay::toggleUnderline(bool checked) {
+ if (!m_handingFormatChangeFromEditor)
+ setFontUnderline(checked);
}
-
void CHTMLWriteDisplay::alignLeft(bool set) {
- if (set && (alignment() != Qt::AlignLeft)) {
+ if (!m_handingFormatChangeFromEditor && set && (alignment() != Qt::AlignLeft)) {
setAlignment(Qt::AlignLeft);
- slotAlignmentChanged(Qt::AlignLeft);
+ alignmentChanged(Qt::AlignLeft);
}
}
void CHTMLWriteDisplay::alignCenter(bool set) {
- if (set && (alignment() != Qt::AlignHCenter)) {
+ if (!m_handingFormatChangeFromEditor && set && (alignment() != Qt::AlignHCenter)) {
setAlignment(Qt::AlignHCenter);
- slotAlignmentChanged(Qt::AlignHCenter);
+ alignmentChanged(Qt::AlignHCenter);
}
}
void CHTMLWriteDisplay::alignRight(bool set) {
- if (set && (alignment() != Qt::AlignRight)) {
+ if (!m_handingFormatChangeFromEditor && set && (alignment() != Qt::AlignRight)) {
setAlignment(Qt::AlignRight);
- slotAlignmentChanged(Qt::AlignRight);
+ alignmentChanged(Qt::AlignRight);
}
}
/** The text's alignment changed. Enable the right buttons. */
-void CHTMLWriteDisplay::slotAlignmentChanged( int a ) {
+void CHTMLWriteDisplay::alignmentChanged( int a ) {
+ Q_ASSERT(!m_handingFormatChangeFromEditor);
bool alignLeft = false;
bool alignCenter = false;
bool alignRight = false;
@@ -164,61 +186,79 @@ void CHTMLWriteDisplay::slotAlignmentChanged( int a ) {
m_actions.alignRight->setChecked( alignRight );
}
-void CHTMLWriteDisplay::changeFontSize(int newSize) {
- setFontPointSize((qreal)newSize);
-}
-
-/** Is called when a new color was selected. */
-void CHTMLWriteDisplay::slotColorSelected( const QColor& c) {
- setTextColor( c );
+void CHTMLWriteDisplay::slotCurrentCharFormatChanged(const QTextCharFormat &) {
+ Q_ASSERT(!m_handingFormatChangeFromEditor);
+ m_handingFormatChangeFromEditor = true;
+ QFont f = currentFont();
+ emit signalFontChanged(f);
+ emit signalFontSizeChanged(f.pointSize());
+ emit signalFontColorChanged(textColor());
+
+ m_actions.bold->setChecked(f.bold());
+ m_actions.italic->setChecked(f.italic());
+ m_actions.underline->setChecked(f.underline());
+ m_handingFormatChangeFromEditor = false;
+
+ BtConfig & conf = btConfig();
+ conf.setSessionValue(CHTMLWriteDisplayFontKey, currentFont());
+ conf.setSessionValue(CHTMLWriteDisplayFontColorKey, textColor());
}
-/** Is called when a text with another color was selected. */
-void CHTMLWriteDisplay::slotColorChanged(const QColor& c) {
- emit setColor(c);
+void CHTMLWriteDisplay::slotFontSizeChosen(int newSize) {
+ if (!m_handingFormatChangeFromEditor)
+ setFontPointSize((qreal)newSize);
}
-void CHTMLWriteDisplay::slotFontChanged( const QFont& font ) {
- emit fontChanged(font);
- emit fontSizeChanged(font.pointSize());
-
- m_actions.bold->setChecked( font.bold() );
- m_actions.italic->setChecked( font.italic() );
- m_actions.underline->setChecked( font.underline() );
+/** Is called when a new color was selected. */
+void CHTMLWriteDisplay::slotFontColorChosen( const QColor& c) {
+ if (!m_handingFormatChangeFromEditor)
+ setTextColor( c );
}
-void CHTMLWriteDisplay::slotFontFamilyChoosen(const QFont& font) {
- setFontFamily(font.family());
+void CHTMLWriteDisplay::slotFontFamilyChosen(const QFont& font) {
+ if (!m_handingFormatChangeFromEditor)
+ setFontFamily(font.family());
}
void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * actions) {
+ Q_UNUSED(actions);
+
+ QFont f = currentFont();
//--------------------font chooser-------------------------
QFontComboBox* fontFamilyCombo = new QFontComboBox(this);
+ fontFamilyCombo->setCurrentFont(f);
fontFamilyCombo->setToolTip( tr("Font") );
bar->addWidget(fontFamilyCombo);
bool ok = connect(fontFamilyCombo, SIGNAL(currentFontChanged(const QFont&)),
- this, SLOT(slotFontFamilyChoosen(const QFont&)));
+ this, SLOT(slotFontFamilyChosen(const QFont&)), Qt::DirectConnection);
Q_ASSERT(ok);
- ok = connect(this, SIGNAL(fontChanged(const QFont&)), fontFamilyCombo, SLOT(setCurrentFont(const QFont&)));
+ ok = connect(this, SIGNAL(signalFontChanged(const QFont&)),
+ fontFamilyCombo, SLOT(setCurrentFont(const QFont&)), Qt::DirectConnection);
Q_ASSERT(ok);
//--------------------font size chooser-------------------------
BtFontSizeWidget* fontSizeChooser = new BtFontSizeWidget(this);
+ fontSizeChooser->setFontSize(f.pointSize());
fontSizeChooser->setToolTip( tr("Font size") );
bar->addWidget(fontSizeChooser);
- ok = connect(fontSizeChooser, SIGNAL(fontSizeChanged(int)), this, SLOT(changeFontSize(int)));
+ ok = connect(fontSizeChooser, SIGNAL(fontSizeChanged(int)),
+ this, SLOT(slotFontSizeChosen(int)), Qt::DirectConnection);
Q_ASSERT(ok);
- ok = connect(this, SIGNAL(fontSizeChanged(int)), fontSizeChooser, SLOT(setFontSize(int)));
+ ok = connect(this, SIGNAL(signalFontSizeChanged(int)),
+ fontSizeChooser, SLOT(setFontSize(int)), Qt::DirectConnection);
Q_ASSERT(ok);
//--------------------color button-------------------------
- BtColorWidget* colorChooser = new BtColorWidget();
- colorChooser->setToolTip(tr("Font color"));
- bar->addWidget(colorChooser);
- ok = connect(colorChooser, SIGNAL(changed(const QColor&)), this, SLOT(slotColorSelected(const QColor&)));
+ BtColorWidget* fontColorChooser = new BtColorWidget();
+ fontColorChooser->setColor(textColor());
+ fontColorChooser->setToolTip(tr("Font color"));
+ bar->addWidget(fontColorChooser);
+ ok = connect(fontColorChooser, SIGNAL(changed(const QColor&)),
+ this, SLOT(slotFontColorChosen(const QColor&)), Qt::DirectConnection);
Q_ASSERT(ok);
- ok = connect(this, SIGNAL(setColor(const QColor&)), colorChooser, SLOT(setColor(const QColor&)));
+ ok = connect(this, SIGNAL(signalFontColorChanged(const QColor&)),
+ fontColorChooser, SLOT(setColor(QColor)), Qt::DirectConnection);
Q_ASSERT(ok);
bar->addSeparator();
@@ -233,13 +273,4 @@ void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * action
bar->addAction(m_actions.alignLeft);
bar->addAction(m_actions.alignCenter);
bar->addAction(m_actions.alignRight);
-
- connect(this, SIGNAL(currentFontChanged(const QFont&)), SLOT(slotFontChanged(const QFont&)));
- connect(this, SIGNAL(currentAlignmentChanged(int)), SLOT(slotAlignmentChanged(int)));
- connect(this, SIGNAL(currentColorChanged(const QColor&)), SLOT(slotColorChanged(const QColor&)));
-
- //set initial values for toolbar items
- slotFontChanged( font() );
- slotAlignmentChanged( alignment() );
- slotColorChanged( textColor() );
}
diff --git a/src/frontend/display/chtmlwritedisplay.h b/src/frontend/display/chtmlwritedisplay.h
index e8e4e7c..1bc9dd0 100644
--- a/src/frontend/display/chtmlwritedisplay.h
+++ b/src/frontend/display/chtmlwritedisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,7 +18,7 @@
class BtActionCollection;
class BtColorWidget;
class BtFontSizeWidget;
-class CWriteWindow;
+class CHTMLWriteWindow;
class QAction;
class QFontComboBox;
class QMenu;
@@ -29,6 +31,9 @@ class QWidget;
class CHTMLWriteDisplay : public CPlainWriteDisplay {
Q_OBJECT
public:
+
+ CHTMLWriteDisplay(CHTMLWriteWindow * parentWindow, QWidget * parent = 0);
+
/**
* Sets the new text for this display widget. (CPlainWriteDisplay).
*/
@@ -45,41 +50,29 @@ class CHTMLWriteDisplay : public CPlainWriteDisplay {
virtual void setupToolbar(QToolBar * bar, BtActionCollection * actionCollection);
protected:
- friend class CDisplay;
- CHTMLWriteDisplay(CWriteWindow* parentWindow, QWidget* parent);
- ~CHTMLWriteDisplay();
+
+ void alignmentChanged(int);
protected slots:
- void toggleBold(bool);
- void toggleItalic(bool);
- void toggleUnderline(bool);
+ void toggleBold(bool checked);
+ void toggleItalic(bool checked);
+ void toggleUnderline(bool checked);
void alignLeft(bool);
void alignCenter(bool);
void alignRight(bool);
- void changeFontSize(int);
+ void slotFontFamilyChosen(const QFont&);
+ void slotFontSizeChosen(int);
+ void slotFontColorChosen( const QColor& );
- void slotFontChanged( const QFont& );
- void slotFontFamilyChoosen(const QFont&);
-
- /**
- * The text's alignment changed. Enable the right buttons.
- */
- void slotAlignmentChanged( int );
- /**
- * Is called when a new color was selected.
- */
- void slotColorSelected( const QColor& );
- /**
- * Is called when a text with another color was selected.
- */
- void slotColorChanged( const QColor& );
+ void slotCurrentCharFormatChanged(const QTextCharFormat &);
signals:
- void fontChanged(const QFont& font);
- void fontSizeChanged(int);
- void setColor(const QColor&);
+
+ void signalFontChanged(const QFont &);
+ void signalFontSizeChanged(int);
+ void signalFontColorChanged(const QColor &);
private:
struct {
@@ -90,11 +83,10 @@ class CHTMLWriteDisplay : public CPlainWriteDisplay {
QAction* alignLeft;
QAction* alignCenter;
QAction* alignRight;
-
- //popup menu
- QAction* selectAll;
}
m_actions;
+
+ bool m_handingFormatChangeFromEditor;
};
#endif
diff --git a/src/frontend/display/cplainwritedisplay.cpp b/src/frontend/display/cplainwritedisplay.cpp
index 07cecf3..e4b22d5 100644
--- a/src/frontend/display/cplainwritedisplay.cpp
+++ b/src/frontend/display/cplainwritedisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,10 +19,13 @@
#include "frontend/cdragdrop.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/cdisplaywindow.h"
-#include "frontend/displaywindow/cwritewindow.h"
+#include "frontend/displaywindow/cplainwritewindow.h"
-CPlainWriteDisplay::CPlainWriteDisplay(CWriteWindow* parentWindow, QWidget* parent) : QTextEdit(parentWindow ? parentWindow : parent), CWriteDisplay(parentWindow) {
+CPlainWriteDisplay::CPlainWriteDisplay(CPlainWriteWindow * parentWindow, QWidget * parent)
+ : QTextEdit(parentWindow ? parentWindow : parent)
+ , CDisplay(parentWindow)
+{
setAcceptRichText(false);
setAcceptDrops(true);
viewport()->setAcceptDrops(true);
diff --git a/src/frontend/display/cplainwritedisplay.h b/src/frontend/display/cplainwritedisplay.h
index 575789e..dad57a1 100644
--- a/src/frontend/display/cplainwritedisplay.h
+++ b/src/frontend/display/cplainwritedisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,22 +13,21 @@
#define CPLAINWRITEDISPLAY_H
#include <QTextEdit>
-#include "frontend/display/cwritedisplay.h"
+#include "frontend/display/cdisplay.h"
class BtActionCollection;
-class CHTMLWriteDisplay;
-class QDragEnterEvent;
-class QDragMoveEvent;
-class QDropEvent;
-class QMenu;
-class QWidget;
+class CPlainWriteWindow;
+class QToolBar;
/** The write display implementation for plain source code editing.
* @author The BibleTime team
*/
-class CPlainWriteDisplay : public QTextEdit, public CWriteDisplay {
+class CPlainWriteDisplay : public QTextEdit, public CDisplay {
public:
+
+ CPlainWriteDisplay(CPlainWriteWindow * parentWindow, QWidget * parent = 0);
+
/**
* Reimplementation.
*/
@@ -52,27 +53,21 @@ class CPlainWriteDisplay : public QTextEdit, public CWriteDisplay {
const DisplayOptions &,
const FilterOptions &) {}
- /**
- * Reimplementation (CWriteDisplay).
- */
virtual bool isModified() const;
/**
- * Sets the current status of the edit widget (CWriteDisplay).
+ * Sets the current status of the edit widget.
*/
virtual void setModified( const bool modified );
/**
- * Returns the text of this edit widget (CWriteDisplay).
+ * Returns the text of this edit widget.
*/
virtual const QString plainText();
/**
- * Creates the necessary action objects and puts them on the toolbar (CWriteDisplay).
+ * Creates the necessary action objects and puts them on the toolbar.
*/
virtual void setupToolbar(QToolBar*, BtActionCollection*);
protected:
- friend class CDisplay;
-
- CPlainWriteDisplay(CWriteWindow* parentWindow, QWidget* parent);
/**
* Reimplementation from QTextEdit to manage drops of our drag and drop objects.
diff --git a/src/frontend/display/creaddisplay.cpp b/src/frontend/display/creaddisplay.cpp
index f1b2f65..f5c3459 100644
--- a/src/frontend/display/creaddisplay.cpp
+++ b/src/frontend/display/creaddisplay.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/display/creaddisplay.h b/src/frontend/display/creaddisplay.h
index 4b6dbeb..dd25a76 100644
--- a/src/frontend/display/creaddisplay.h
+++ b/src/frontend/display/creaddisplay.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,6 +18,8 @@
#include "backend/managers/cswordbackend.h"
+class CReadWindow;
+
/** The base class for all read-only widgets like KHTMLView.
*@author The BibleTime team
*/
diff --git a/src/frontend/display/cwritedisplay.cpp b/src/frontend/display/cwritedisplay.cpp
deleted file mode 100644
index 47a3302..0000000
--- a/src/frontend/display/cwritedisplay.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-/*********
-*
-* 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/display/cwritedisplay.h"
-
-#include "frontend/displaywindow/cwritewindow.h"
-
-
-CWriteDisplay::CWriteDisplay( CWriteWindow* writeWindow ) : CDisplay(writeWindow) {
- // Intentionally empty
-}
-
-CWriteDisplay::~CWriteDisplay() {
- // Intentionally empty
-}
diff --git a/src/frontend/display/cwritedisplay.h b/src/frontend/display/cwritedisplay.h
deleted file mode 100644
index 0010749..0000000
--- a/src/frontend/display/cwritedisplay.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*********
-*
-* 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 CWRITEDISPLAY_H
-#define CWRITEDISPLAY_H
-
-#include "frontend/display/cdisplay.h"
-
-
-class BtActionCollection;
-class QToolBar;
-
-/** The base class for all read/write-display classes.
- *@author The BibleTime team
- */
-class CWriteDisplay : public CDisplay {
- protected:
-
- CWriteDisplay( CWriteWindow* writeWindow );
- ~CWriteDisplay();
-
- public: // Public methods
- /**
- * Sets the current modified status of the widget.
- */
- virtual void setModified( const bool modified ) = 0;
- /**
- * Returns true if the current text was modified.
- */
- virtual bool isModified() const = 0;
- /**
- * Returns the text of this edit widget.
- */
- virtual const QString plainText() = 0;
- /**
- * Creates the necessary action objects and puts them on the toolbar.
- */
- virtual void setupToolbar( QToolBar* bar, BtActionCollection* actionCollection ) = 0;
-};
-
-#endif
diff --git a/src/frontend/displaywindow/btactioncollection.cpp b/src/frontend/displaywindow/btactioncollection.cpp
index 55909b7..f25b972 100644
--- a/src/frontend/displaywindow/btactioncollection.cpp
+++ b/src/frontend/displaywindow/btactioncollection.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,10 +12,8 @@
#include <QAction>
#include <QDebug>
#include <QKeySequence>
-#include <QSettings>
#include <QString>
#include <QStringList>
-#include "backend/config/cbtconfig.h"
#include "util/directory.h"
@@ -40,7 +38,7 @@ QList<QAction*> BtActionCollection::actions() {
QList<QAction*> actionList;
for (ActionMap::const_iterator iter = m_actions.constBegin();
iter != m_actions.constEnd();
- iter++)
+ ++iter)
{
actionList.append(iter.value()->action);
}
@@ -79,7 +77,7 @@ QAction* BtActionCollection::addAction(const QString &name, const QObject *recei
QKeySequence BtActionCollection::getDefaultShortcut(QAction* action) {
for (ActionMap::const_iterator iter = m_actions.constBegin();
iter != m_actions.constEnd();
- iter++)
+ ++iter)
{
if (iter.value()->action == action) {
return iter.value()->defaultKeys;
@@ -88,57 +86,26 @@ QKeySequence BtActionCollection::getDefaultShortcut(QAction* action) {
return QKeySequence();
}
-void BtActionCollection::readSettings() {
- QSettings* settings = CBTConfig::getConfig();
- settings->beginGroup(m_groupName);
-
- Q_FOREACH (const QString &key, settings->childKeys()) {
- QAction *a = action(key);
+void BtActionCollection::readShortcuts(const QString &group) {
+ QHash<QString, QList <QKeySequence > > shortcuts = btConfig().getShortcuts(group);
+ for(QHash<QString, QList <QKeySequence> >::const_iterator iter = shortcuts.begin();
+ iter != shortcuts.end();
+ ++iter)
+ {
+ QAction *a = action(iter.key());
if (a == 0)
continue;
-
- QVariant variant = settings->value(key);
- // qDebug() << variant << " | " << variant.typeName();
- if (variant.type() != QVariant::List
- && variant.type() != QVariant::StringList)
- {
- continue;
- }
-
- QList<QKeySequence> shortcuts;
- if (variant.type() == QVariant::List) { // For BibleTime before 2.9
- Q_FOREACH (const QVariant &shortcut, variant.toList()) {
- shortcuts.append(shortcut.toString());
- }
- } else {
- Q_ASSERT(variant.type() == QVariant::StringList);
- Q_FOREACH (const QString &shortcut, variant.toStringList()) {
- shortcuts.append(shortcut);
- }
- }
- a->setShortcuts(shortcuts);
+ action(iter.key())->setShortcuts(iter.value());
}
-
- settings->endGroup();
}
-void BtActionCollection::writeSettings() {
- QSettings* settings = CBTConfig::getConfig();
- settings->beginGroup(m_groupName);
-
+void BtActionCollection::writeShortcuts(const QString &group) {
+ QHash< QString, QList<QKeySequence> > shortcuts;
for (ActionMap::const_iterator iter = m_actions.constBegin();
- iter != m_actions.constEnd();
- iter++)
+ iter != m_actions.constEnd();
+ ++iter)
{
- // Write beautiful string lists (since 2.9):
- QStringList varList;
- Q_FOREACH (const QKeySequence &shortcut, iter.value()->action->shortcuts()) {
- /// \note saving QKeySequences directly doesn't appear to work!
- varList.append(shortcut.toString());
- }
- settings->setValue(iter.key(), varList);
- // qDebug() << ">>" << settings->value(iter.key()).typeName();
+ shortcuts.insert(iter.key(), iter.value()->action->shortcuts());
}
-
- settings->endGroup();
+ btConfig().setShortcuts(group, shortcuts);
}
diff --git a/src/frontend/displaywindow/btactioncollection.h b/src/frontend/displaywindow/btactioncollection.h
index e99522d..a4d062f 100644
--- a/src/frontend/displaywindow/btactioncollection.h
+++ b/src/frontend/displaywindow/btactioncollection.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,10 +17,12 @@
#include <QList>
#include <QMap>
+#include "backend/config/btconfig.h"
class BtActionItem;
class QAction;
class QKeySequence;
+class QString;
class BtActionCollection: public QObject {
@@ -40,20 +44,31 @@ class BtActionCollection: public QObject {
QAction *action(const QString &name) const;
- inline void setConfigGroup(const QString &group) {
- m_groupName = group;
- }
-
- void readSettings();
-
- void writeSettings();
-
+ /*!
+ * \brief Read shortcuts from config.
+ *
+ * Read the shortcuts for the given group
+ * from the configuration and add them to
+ * this action collection.
+ *
+ * \param[in] group Shortcut group to read actions from.
+ */
+ void readShortcuts(const QString &group);
+
+ /*!
+ * \brief Write shortcuts to config.
+ *
+ * Write the shortcuts of this action collection
+ * to the given group in the configuration.
+ *
+ * \param[in] group Shortcut group to write actions to.
+ */
+ void writeShortcuts(const QString& group);
QKeySequence getDefaultShortcut(QAction* action);
private: /* Fields: */
ActionMap m_actions;
- QString m_groupName;
};
diff --git a/src/frontend/displaywindow/btdisplaysettingsbutton.cpp b/src/frontend/displaywindow/btdisplaysettingsbutton.cpp
index 597a965..bca9334 100644
--- a/src/frontend/displaywindow/btdisplaysettingsbutton.cpp
+++ b/src/frontend/displaywindow/btdisplaysettingsbutton.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,17 +14,16 @@
#include <QString>
#include <QToolTip>
#include <QToolButton>
-#include "util/directory.h"
+#include "bibletimeapp.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
BtDisplaySettingsButton::BtDisplaySettingsButton(QWidget *parent)
: QToolButton(parent) {
- namespace DU = util::directory;
-
initMenu();
- setIcon(DU::getIcon(CResMgr::displaywindows::displaySettings::icon));
+ setIcon(util::getIcon(CResMgr::displaywindows::displaySettings::icon));
setPopupMode(QToolButton::InstantPopup);
setEnabled(false);
diff --git a/src/frontend/displaywindow/btdisplaysettingsbutton.h b/src/frontend/displaywindow/btdisplaysettingsbutton.h
index c7c8f09..f82f682 100644
--- a/src/frontend/displaywindow/btdisplaysettingsbutton.h
+++ b/src/frontend/displaywindow/btdisplaysettingsbutton.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/btmodulechooserbar.cpp b/src/frontend/displaywindow/btmodulechooserbar.cpp
index 22b5ca8..e8d80cb 100644
--- a/src/frontend/displaywindow/btmodulechooserbar.cpp
+++ b/src/frontend/displaywindow/btmodulechooserbar.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/btmodulechooserbar.h b/src/frontend/displaywindow/btmodulechooserbar.h
index 977d3c0..024bc08 100644
--- a/src/frontend/displaywindow/btmodulechooserbar.h
+++ b/src/frontend/displaywindow/btmodulechooserbar.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/btmodulechooserbutton.cpp b/src/frontend/displaywindow/btmodulechooserbutton.cpp
index 200da78..4e0a5fc 100644
--- a/src/frontend/displaywindow/btmodulechooserbutton.cpp
+++ b/src/frontend/displaywindow/btmodulechooserbutton.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,11 +15,12 @@
#include <QString>
#include <QToolButton>
#include <QToolTip>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/managers/cswordbackend.h"
+#include "bibletimeapp.h"
#include "frontend/displaywindow/btmodulechooserbar.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
BtModuleChooserButton::BtModuleChooserButton(BtModuleChooserBar *parent, CSwordModuleInfo::ModuleType mtype)
@@ -58,7 +59,6 @@ void BtModuleChooserButton::updateMenu(QStringList newModulesToUse, QString this
m_module = thisModule;
m_hasModule = thisModule.isEmpty() ? false : true;
- namespace DU = util::directory;
//All items are iterated and the state is changed properly
QListIterator<QMenu*> it(m_submenus);
@@ -70,7 +70,7 @@ void BtModuleChooserButton::updateMenu(QStringList newModulesToUse, QString this
}
}
m_noneAction->setChecked(m_hasModule ? false : true);
- setIcon(DU::getIcon(iconName()));
+ setIcon(util::getIcon(iconName()));
if (m_hasModule) {
setToolTip( QString(tr("Select a work [%1]")).arg(m_module) );
@@ -141,7 +141,7 @@ void BtModuleChooserButton::populateMenu() {
// Filters: add only non-hidden and right type
BTModuleTreeItem::HiddenOff hiddenFilter;
QList<BTModuleTreeItem::Filter*> filters;
- if (!CBTConfig::get(CBTConfig::bookshelfShowHidden)) {
+ if (!btConfig().value<bool>("GUI/bookshelfShowHidden", false)) {
filters.append(&hiddenFilter);
}
TypeFilter typeFilter(m_moduleType);
@@ -150,7 +150,7 @@ void BtModuleChooserButton::populateMenu() {
if (m_moduleType == CSwordModuleInfo::Bible) {
BTModuleTreeItem root(filters, BTModuleTreeItem::CatLangMod);
QList<BTModuleTreeItem::Filter*> filters2;
- if (!CBTConfig::get(CBTConfig::bookshelfShowHidden)) {
+ if (!btConfig().value<bool>("GUI/bookshelfShowHidden", false)) {
filters2.append(&hiddenFilter);
}
TypeFilter typeFilter2(CSwordModuleInfo::Commentary);
diff --git a/src/frontend/displaywindow/btmodulechooserbutton.h b/src/frontend/displaywindow/btmodulechooserbutton.h
index ba7d89e..03c2b9b 100644
--- a/src/frontend/displaywindow/btmodulechooserbutton.h
+++ b/src/frontend/displaywindow/btmodulechooserbutton.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/bttextwindowheader.cpp b/src/frontend/displaywindow/bttextwindowheader.cpp
index 71e98f0..6f108d7 100644
--- a/src/frontend/displaywindow/bttextwindowheader.cpp
+++ b/src/frontend/displaywindow/bttextwindowheader.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/bttextwindowheader.h b/src/frontend/displaywindow/bttextwindowheader.h
index 6dd4b0a..2673d78 100644
--- a/src/frontend/displaywindow/bttextwindowheader.h
+++ b/src/frontend/displaywindow/bttextwindowheader.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/bttextwindowheaderwidget.cpp b/src/frontend/displaywindow/bttextwindowheaderwidget.cpp
index 600bf15..a974c2c 100644
--- a/src/frontend/displaywindow/bttextwindowheaderwidget.cpp
+++ b/src/frontend/displaywindow/bttextwindowheaderwidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,11 +17,17 @@
#include <QSizePolicy>
#include <QLabel>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/managers/cswordbackend.h"
+#include "bibletimeapp.h"
#include "frontend/displaywindow/bttextwindowheader.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
+
+
+namespace {
+const QString BookshelfShowHiddenKey = "GUI/bookshelfShowHidden";
+} // anonymous namespace
const char* ActionType = "ActionType";
@@ -81,7 +87,6 @@ void BtTextWindowHeaderWidget::updateWidget(QStringList newModulesToUse, QString
populateMenu();
m_module = thisModule;
- namespace DU = util::directory;
//All items are iterated and the state is changed properly
QListIterator<QMenu*> it(m_submenus);
@@ -147,18 +152,18 @@ void BtTextWindowHeaderWidget::populateMenu() {
m_removeAction = new QAction(tr("Remove"), m_popup);
m_removeAction->setProperty(ActionType, RemoveAction);
- m_removeAction->setIcon(util::directory::getIcon(CResMgr::displaywindows::general::removemoduleicon));
+ m_removeAction->setIcon(util::getIcon(CResMgr::displaywindows::general::removemoduleicon));
m_popup->addAction(m_removeAction);
// Add Replace and Add menus, both have all modules in them
QMenu* replaceItem = new QMenu(tr("Replace"), m_popup);
- replaceItem->setIcon(util::directory::getIcon(CResMgr::displaywindows::general::replacemoduleicon));
+ replaceItem->setIcon(util::getIcon(CResMgr::displaywindows::general::replacemoduleicon));
replaceItem->setProperty(ActionType, ReplaceAction);
m_popup->addMenu(replaceItem);
QMenu* addItem = new QMenu(tr("Add"), m_popup);
addItem->setProperty(ActionType, AddAction);
- addItem->setIcon(util::directory::getIcon(CResMgr::displaywindows::general::addmoduleicon));
+ addItem->setIcon(util::getIcon(CResMgr::displaywindows::general::addmoduleicon));
m_popup->addMenu(addItem);
QList<QMenu*> toplevelMenus;
@@ -170,7 +175,7 @@ void BtTextWindowHeaderWidget::populateMenu() {
// Filters: add only non-hidden, non-locked and correct type
BTModuleTreeItem::HiddenOff hiddenFilter;
QList<BTModuleTreeItem::Filter*> filters;
- if (!CBTConfig::get(CBTConfig::bookshelfShowHidden)) {
+ if (!btConfig().value<bool>(BookshelfShowHiddenKey, false)) {
filters.append(&hiddenFilter);
}
TypeFilter typeFilter(m_moduleType);
@@ -179,7 +184,7 @@ void BtTextWindowHeaderWidget::populateMenu() {
if (m_moduleType == CSwordModuleInfo::Bible) {
BTModuleTreeItem root(filters, BTModuleTreeItem::CatLangMod);
QList<BTModuleTreeItem::Filter*> filters2;
- if (!CBTConfig::get(CBTConfig::bookshelfShowHidden)) {
+ if (!btConfig().value<bool>(BookshelfShowHiddenKey, false)) {
filters2.append(&hiddenFilter);
}
if (menu == addItem || menu == replaceItem) {
diff --git a/src/frontend/displaywindow/bttextwindowheaderwidget.h b/src/frontend/displaywindow/bttextwindowheaderwidget.h
index 02e0310..c69bf11 100644
--- a/src/frontend/displaywindow/bttextwindowheaderwidget.h
+++ b/src/frontend/displaywindow/bttextwindowheaderwidget.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.cpp b/src/frontend/displaywindow/bttoolbarpopupaction.cpp
index 1a5593b..e443f8a 100644
--- a/src/frontend/displaywindow/bttoolbarpopupaction.cpp
+++ b/src/frontend/displaywindow/bttoolbarpopupaction.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.h b/src/frontend/displaywindow/bttoolbarpopupaction.h
index ebbc848..4999098 100644
--- a/src/frontend/displaywindow/bttoolbarpopupaction.h
+++ b/src/frontend/displaywindow/bttoolbarpopupaction.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/btwindowmodulechooser.h b/src/frontend/displaywindow/btwindowmodulechooser.h
index a39e7a1..40ffcf0 100644
--- a/src/frontend/displaywindow/btwindowmodulechooser.h
+++ b/src/frontend/displaywindow/btwindowmodulechooser.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/displaywindow/cbiblereadwindow.cpp b/src/frontend/displaywindow/cbiblereadwindow.cpp
index aa6ae6b..4d88f13 100644
--- a/src/frontend/displaywindow/cbiblereadwindow.cpp
+++ b/src/frontend/displaywindow/cbiblereadwindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,7 +16,6 @@
#include <QMenu>
#include <QTimer>
#include <QWidget>
-#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordbiblemoduleinfo.h"
#include "backend/keys/cswordversekey.h"
#include "frontend/cexportmanager.h"
@@ -26,44 +25,19 @@
#include "frontend/displaywindow/ccommentaryreadwindow.h"
#include "frontend/displaywindow/btdisplaysettingsbutton.h"
#include "frontend/keychooser/ckeychooser.h"
-#include "frontend/profile/cprofilewindow.h"
#include "util/directory.h"
#include "util/cresmgr.h"
#include "util/tool.h"
-using namespace Profile;
+void CBibleReadWindow::applyProfileSettings(const QString & windowGroup) {
+ CLexiconReadWindow::applyProfileSettings(windowGroup);
-CBibleReadWindow::CBibleReadWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea* parent)
- : CLexiconReadWindow(moduleList, parent) {
-}
-
-CBibleReadWindow::~CBibleReadWindow() {
-}
-
-void CBibleReadWindow::applyProfileSettings(CProfileWindow* const settings) {
- /**
- \todo Make CProfileWindow properly handle these things so we wouldn't have
- to mess around with bits.
- */
- CLexiconReadWindow::applyProfileSettings(settings);
-
- int result = settings->windowSettings;
-
- filterOptions().footnotes = (result & 0x0001) != 0;
- filterOptions().strongNumbers = (result & 0x0002) != 0;
- filterOptions().headings = (result & 0x0004) != 0;
- filterOptions().morphTags = (result & 0x0008) != 0;
- filterOptions().lemmas = (result & 0x0010) != 0;
- filterOptions().hebrewPoints = (result & 0x0020) != 0;
- filterOptions().hebrewCantillation = (result & 0x0040) != 0;
- filterOptions().greekAccents = (result & 0x0080) != 0;
- filterOptions().textualVariants = (result & 0x0100) != 0;
- filterOptions().redLetterWords = (result & 0x0200) != 0;
- filterOptions().scriptureReferences = (result & 0x0400) != 0;
- filterOptions().morphSegmentation = (result & 0x0800) != 0;
- displayOptions().lineBreaks = (result & 0x1000) != 0;
- displayOptions().verseNumbers = (result & 0x2000) != 0;
+ BtConfig & conf = btConfig();
+ conf.beginGroup(windowGroup);
+ filterOptions() = conf.getFilterOptions();
+ displayOptions() = conf.getDisplayOptions();
+ conf.endGroup();
emit sigFilterOptionsChanged(filterOptions());
emit sigDisplayOptionsChanged(displayOptions());
@@ -72,31 +46,14 @@ void CBibleReadWindow::applyProfileSettings(CProfileWindow* const settings) {
lookup();
}
-void CBibleReadWindow::storeProfileSettings( CProfileWindow * const settings) {
- /**
- \todo Make CProfileWindow properly handle these things so we wouldn't have
- to mess around with bits.
- */
-
- int result = 0x0000;
- if (filterOptions().footnotes) result |= 0x0001;
- if (filterOptions().strongNumbers) result |= 0x0002;
- if (filterOptions().headings) result |= 0x0004;
- if (filterOptions().morphTags) result |= 0x0008;
- if (filterOptions().lemmas) result |= 0x0010;
- if (filterOptions().hebrewPoints) result |= 0x0020;
- if (filterOptions().hebrewCantillation) result |= 0x0040;
- if (filterOptions().greekAccents) result |= 0x0080;
- if (filterOptions().textualVariants) result |= 0x0100;
- if (filterOptions().redLetterWords) result |= 0x0200;
- if (filterOptions().scriptureReferences) result |= 0x0400;
- if (filterOptions().morphSegmentation) result |= 0x0800;
- if (displayOptions().lineBreaks) result |= 0x1000;
- if (displayOptions().verseNumbers) result |= 0x2000;
-
- settings->windowSettings = result;
-
- CLexiconReadWindow::storeProfileSettings(settings);
+void CBibleReadWindow::storeProfileSettings(const QString & windowGroup) {
+ BtConfig & conf = btConfig();
+ conf.beginGroup(windowGroup);
+ conf.setFilterOptions(filterOptions());
+ conf.setDisplayOptions(displayOptions());
+ conf.endGroup();
+
+ CLexiconReadWindow::storeProfileSettings(windowGroup);
}
@@ -274,7 +231,7 @@ void CBibleReadWindow::initActions() {
this, SLOT(printAll()));
addAction(m_actions.print.chapter);
- CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, ac);
+ ac->readShortcuts("Bible shortcuts");
}
void CBibleReadWindow::initConnections() {
@@ -405,11 +362,11 @@ void CBibleReadWindow::copyDisplayedText() {
dummy.setVerse(1);
CSwordVerseKey vk(*verseKey());
- vk.LowerBound(dummy);
+ vk.setLowerBound(dummy);
const CSwordBibleModuleInfo* bible = dynamic_cast<const CSwordBibleModuleInfo*>(modules().first());
dummy.setVerse(bible->verseCount(dummy.book(), dummy.getChapter()));
- vk.UpperBound(dummy);
+ vk.setUpperBound(dummy);
CExportManager mgr(false, tr("Copying"), filterOptions(), displayOptions());
mgr.copyKey(&vk, CExportManager::Text, true);
@@ -425,10 +382,10 @@ void CBibleReadWindow::saveChapterHTML() {
dummy.setVerse(1);
CSwordVerseKey vk(*verseKey());
- vk.LowerBound(dummy);
+ vk.setLowerBound(dummy);
dummy.setVerse(bible->verseCount(dummy.book(), dummy.getChapter()));
- vk.UpperBound(dummy);
+ vk.setUpperBound(dummy);
CExportManager mgr(true, tr("Saving"), filterOptions(), displayOptions());
mgr.saveKey(&vk, CExportManager::HTML, true);
@@ -442,11 +399,11 @@ void CBibleReadWindow::saveChapterPlain() {
CSwordVerseKey dummy(*verseKey());
dummy.setVerse(1);
- vk.LowerBound(dummy);
+ vk.setLowerBound(dummy);
const CSwordBibleModuleInfo* bible = dynamic_cast<const CSwordBibleModuleInfo*>(modules().first());
dummy.setVerse(bible->verseCount(dummy.book(), dummy.getChapter()));
- vk.UpperBound(dummy);
+ vk.setUpperBound(dummy);
CExportManager mgr(true, tr("Saving"), filterOptions(), displayOptions());
mgr.saveKey(&vk, CExportManager::Text, true);
@@ -464,7 +421,7 @@ void CBibleReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
verseKey()->setLocale( CSwordBackend::instance()->booknameLanguage().toLatin1() );
keyChooser()->refreshContent();
- CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, actionCollection());
+ actionCollection()->readShortcuts("Bible shortcuts");
}
/** No descriptions */
diff --git a/src/frontend/displaywindow/cbiblereadwindow.h b/src/frontend/displaywindow/cbiblereadwindow.h
index 198c4fd..99c98fb 100644
--- a/src/frontend/displaywindow/cbiblereadwindow.h
+++ b/src/frontend/displaywindow/cbiblereadwindow.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,28 +24,21 @@ class QEvent;
class QMenu;
class QObject;
-/** The read display window for Bibles.
- *@author The BibleTime team
- */
-class CBibleReadWindow : public CLexiconReadWindow {
+class CBibleReadWindow: public CLexiconReadWindow {
+
Q_OBJECT
- public:
- CBibleReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- virtual ~CBibleReadWindow();
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings( Profile::CProfileWindow* const settings );
- /**
- * Store the settings of this window in the given profile window.
- */
- virtual void applyProfileSettings( Profile::CProfileWindow* const settings );
- /**
- * Reimplementation.
- */
+
+ public: /* Methods: */
+
+ inline CBibleReadWindow(const QList<CSwordModuleInfo*> & modules, CMDIArea* parent)
+ : CLexiconReadWindow(modules, parent) {}
+
+ virtual void storeProfileSettings(const QString & windowGroup);
+ virtual void applyProfileSettings(const QString & windowGroup);
static void insertKeyboardActions( BtActionCollection* const a );
- protected:
+ protected: /* Methods: */
+
virtual void initActions();
virtual void initToolbars();
virtual void initConnections();
@@ -97,6 +92,7 @@ class CBibleReadWindow : public CLexiconReadWindow {
public slots:
+
void nextBook();
void previousBook();
void nextChapter();
@@ -108,7 +104,8 @@ class CBibleReadWindow : public CLexiconReadWindow {
*/
virtual void reload(CSwordBackend::SetupChangedReason reason);
- protected slots: // Protected slots
+ protected slots:
+
/**
* Copies the current chapter into the clipboard.
*/
@@ -124,14 +121,13 @@ class CBibleReadWindow : public CLexiconReadWindow {
virtual void lookupSwordKey( CSwordKey* newKey );
void syncWindows();
- private:
+ private: /* Methods: */
/**
* Wrapper around key() to return the right type of key.
*/
CSwordVerseKey* verseKey();
- // CTransliterationButton* m_transliterationButton;
};
-#endif
+#endif /* CBIBLEREADWINDOW_H */
diff --git a/src/frontend/displaywindow/cbookreadwindow.cpp b/src/frontend/displaywindow/cbookreadwindow.cpp
index ff2adf2..fade4d5 100644
--- a/src/frontend/displaywindow/cbookreadwindow.cpp
+++ b/src/frontend/displaywindow/cbookreadwindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,41 +14,31 @@
#include <QSplitter>
#include <QToolBar>
#include "bibletime.h"
-#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordtreekey.h"
-#include "frontend/display/cdisplay.h"
+#include "frontend/display/bthtmlreaddisplay.h"
#include "frontend/displaywindow/bttoolbarpopupaction.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/btmodulechooserbar.h"
#include "frontend/displaywindow/btdisplaysettingsbutton.h"
#include "frontend/keychooser/cbooktreechooser.h"
-#include "frontend/profile/cprofilewindow.h"
#include "util/cresmgr.h"
#include "util/tool.h"
-using namespace Profile;
+void CBookReadWindow::applyProfileSettings(const QString & windowGroup) {
+ CLexiconReadWindow::applyProfileSettings(windowGroup);
-CBookReadWindow::CBookReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
- : CLexiconReadWindow(modules, parent), m_treeAction(0), m_treeChooser(0) {
-}
-
-CBookReadWindow::~CBookReadWindow() {
-}
-
-void CBookReadWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
- CLexiconReadWindow::applyProfileSettings(profileWindow);
-
- if (profileWindow->windowSettings) {
+ Q_ASSERT(m_treeAction);
+ Q_ASSERT(windowGroup.endsWith('/'));
+ if (btConfig().sessionValue<bool>(windowGroup + "treeShown", true) != m_treeAction->isChecked())
m_treeAction->activate(QAction::Trigger);
- }
}
-void CBookReadWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
- CLexiconReadWindow::storeProfileSettings(profileWindow);
+void CBookReadWindow::storeProfileSettings(const QString & windowGroup) {
+ CLexiconReadWindow::storeProfileSettings(windowGroup);
- //store information about our show tree structure button
- profileWindow->windowSettings = m_treeAction->isChecked();
+ Q_ASSERT(windowGroup.endsWith('/'));
+ btConfig().setSessionValue(windowGroup + "treeShown", m_treeAction->isChecked());
}
void CBookReadWindow::initActions() {
@@ -70,7 +60,7 @@ void CBookReadWindow::initActions() {
this, SLOT(treeToggled()));
addAction(m_treeAction);
- CBTConfig::setupAccelSettings(CBTConfig::bookWindow, ac);
+ ac->readShortcuts("Book shortcuts");
}
void CBookReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
@@ -96,7 +86,7 @@ void CBookReadWindow::initConnections() {
void CBookReadWindow::initView() {
QSplitter* splitter = new QSplitter(this);
m_treeChooser = new CBookTreeChooser(modules(), history(), key(), splitter);
- setDisplayWidget( CDisplay::createReadInstance(this, splitter) );
+ setDisplayWidget(new BtHtmlReadDisplay(this, splitter));
m_treeChooser->hide();
// Create Navigation toolbar
diff --git a/src/frontend/displaywindow/cbookreadwindow.h b/src/frontend/displaywindow/cbookreadwindow.h
index 8b85504..63f3922 100644
--- a/src/frontend/displaywindow/cbookreadwindow.h
+++ b/src/frontend/displaywindow/cbookreadwindow.h
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's BtActionCollection code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime BtActionCollection code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,33 +17,30 @@ class BtActionCollection;
class CBookTreeChooser;
class QAction;
-/**
- * @author The BibleTime team
- */
-class CBookReadWindow : public CLexiconReadWindow {
+class CBookReadWindow: public CLexiconReadWindow {
+
Q_OBJECT
- public:
- static void insertKeyboardActions( BtActionCollection* const a );
- CBookReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ public: /* Methods: */
- virtual ~CBookReadWindow();
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow );
- /**
- * Store the settings of this window in the given profile window.
- */
- virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow );
+ inline CBookReadWindow(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent)
+ : CLexiconReadWindow(modules, parent)
+ , m_treeAction(0)
+ , m_treeChooser(0) {}
+
+ virtual void storeProfileSettings(const QString & windowGroup);
+ virtual void applyProfileSettings(const QString & windowGroup);
+ static void insertKeyboardActions(BtActionCollection * const a);
public slots:
+
/**
* Refreshes the content of this display window and the content of the keychooser.
*/
virtual void reload(CSwordBackend::SetupChangedReason reason);
- protected:
+ protected: /* Methods: */
+
virtual void initActions();
virtual void initToolbars();
virtual void initConnections();
@@ -53,21 +50,24 @@ class CBookReadWindow : public CLexiconReadWindow {
virtual void setupPopupMenu();
- protected slots: // Protected slots
+ protected slots:
+
/**
* Reimplementation to take care of the tree chooser.
*/
virtual void modulesChanged();
- private:
- QAction* m_treeAction;
- CBookTreeChooser* m_treeChooser;
+ private slots:
- private slots: // Private slots
/**
* Is called when the action was executed to toggle the tree view.
*/
void treeToggled();
+
+ private: /* Fields: */
+
+ QAction * m_treeAction;
+ CBookTreeChooser * m_treeChooser;
};
#endif
diff --git a/src/frontend/displaywindow/ccommentaryreadwindow.cpp b/src/frontend/displaywindow/ccommentaryreadwindow.cpp
index f2c2c3d..1beb5c5 100644
--- a/src/frontend/displaywindow/ccommentaryreadwindow.cpp
+++ b/src/frontend/displaywindow/ccommentaryreadwindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,25 +13,19 @@
#include <QIcon>
#include <QMenu>
#include <QToolBar>
-#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordversekey.h"
#include "bibletime.h"
+#include "bibletimeapp.h"
#include "frontend/display/cdisplay.h"
#include "frontend/display/creaddisplay.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/btmodulechooserbar.h"
#include "frontend/keychooser/ckeychooser.h"
-#include "frontend/profile/cprofilewindow.h"
-#include "util/directory.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
-using namespace Profile;
-
-CCommentaryReadWindow::CCommentaryReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent) : CLexiconReadWindow(modules, parent) {
-}
void CCommentaryReadWindow::insertKeyboardActions(BtActionCollection* const a) {
- namespace DU = util::directory;
QAction* qaction;
qaction = new QAction(tr("Next book"), a);
@@ -58,7 +52,7 @@ void CCommentaryReadWindow::insertKeyboardActions(BtActionCollection* const a) {
qaction->setShortcut(CResMgr::displaywindows::bibleWindow::previousVerse::accel);
a->addAction("previousVerse", qaction);
- qaction = new QAction(QIcon(DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon)),
+ qaction = new QAction(QIcon(util::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon)),
tr("Synchronize"), a);
qaction->setCheckable(true);
qaction->setShortcut(CResMgr::displaywindows::commentaryWindow::syncWindow::accel);
@@ -120,19 +114,23 @@ void CCommentaryReadWindow::initActions() {
m_syncButton = qaction;
addAction(qaction);
- CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
+ actionCollection()->readShortcuts("Commentary shortcuts");
}
-void CCommentaryReadWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
- CLexiconReadWindow::applyProfileSettings(profileWindow);
- if (profileWindow->windowSettings) {
- m_syncButton->setChecked(true);
- }
+void CCommentaryReadWindow::applyProfileSettings(const QString & windowGroup) {
+ CLexiconReadWindow::applyProfileSettings(windowGroup);
+
+ Q_ASSERT(windowGroup.endsWith('/'));
+ Q_ASSERT(m_syncButton);
+ m_syncButton->setChecked(btConfig().sessionValue<bool>(windowGroup + "syncEnabled", false));
}
-void CCommentaryReadWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
- CLexiconReadWindow::storeProfileSettings(profileWindow);
- profileWindow->windowSettings = m_syncButton->isChecked();
+void CCommentaryReadWindow::storeProfileSettings(const QString & windowGroup) {
+ CLexiconReadWindow::storeProfileSettings(windowGroup);
+
+ Q_ASSERT(windowGroup.endsWith('/'));
+ Q_ASSERT(m_syncButton);
+ btConfig().setSessionValue(windowGroup + "syncEnabled", m_syncButton->isChecked());
}
void CCommentaryReadWindow::initToolbars() {
@@ -153,7 +151,7 @@ void CCommentaryReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
verseKey()->setLocale( CSwordBackend::instance()->booknameLanguage().toLatin1() );
keyChooser()->refreshContent();
- CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, actionCollection());
+ actionCollection()->readShortcuts("Commentary shortcuts");
}
/** rapper around key() to return the right type of key. */
diff --git a/src/frontend/displaywindow/ccommentaryreadwindow.h b/src/frontend/displaywindow/ccommentaryreadwindow.h
index 679906c..06cbd93 100644
--- a/src/frontend/displaywindow/ccommentaryreadwindow.h
+++ b/src/frontend/displaywindow/ccommentaryreadwindow.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -28,15 +30,11 @@ class CCommentaryReadWindow : public CLexiconReadWindow {
*/
static void insertKeyboardActions( BtActionCollection* const a );
- CCommentaryReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow );
- /**
- * Store the settings of this window in the given profile window.
- */
- virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow );
+ inline CCommentaryReadWindow(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent)
+ : CLexiconReadWindow(modules, parent) {}
+
+ virtual void storeProfileSettings(const QString & windowGroup);
+ virtual void applyProfileSettings(const QString & windowGroup);
virtual bool syncAllowed() const;
public slots: // Public slots
diff --git a/src/frontend/displaywindow/cdisplaywindow.cpp b/src/frontend/displaywindow/cdisplaywindow.cpp
index 0b9bc61..a584d6e 100644
--- a/src/frontend/displaywindow/cdisplaywindow.cpp
+++ b/src/frontend/displaywindow/cdisplaywindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,12 +11,14 @@
#include <QCloseEvent>
#include <QDebug>
+#include <QMdiSubWindow>
#include <QMenu>
#include <QStringList>
#include <QWidget>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/keys/cswordkey.h"
#include "bibletime.h"
+#include "bibletimeapp.h"
#include "frontend/cmdiarea.h"
#include "frontend/display/cdisplay.h"
#include "frontend/displaywindow/bttoolbarpopupaction.h"
@@ -25,15 +27,12 @@
#include "frontend/displaywindow/btdisplaysettingsbutton.h"
#include "frontend/keychooser/ckeychooser.h"
#include "frontend/keychooser/bthistory.h"
-#include "frontend/profile/cprofilewindow.h"
#include "frontend/searchdialog/csearchdialog.h"
-#include "util/directory.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
-using namespace Profile;
-
-CDisplayWindow::CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea *parent)
+CDisplayWindow::CDisplayWindow(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent)
: QMainWindow(parent),
m_actionCollection(0),
m_mdi(parent),
@@ -69,8 +68,17 @@ CDisplayWindow::~CDisplayWindow() {
m_swordKey = 0;
}
+QWidget * CDisplayWindow::getProfileWindow() const {
+ for (QWidget * w = parentWidget(); w; w = w->parentWidget()) {
+ QMdiSubWindow * sw = qobject_cast<QMdiSubWindow *>(w);
+ if (sw)
+ return sw;
+ }
+ return const_cast<CDisplayWindow *>(this);
+}
+
BibleTime* CDisplayWindow::btMainWindow() {
- return dynamic_cast<BibleTime*>(m_mdi->parent());
+ return dynamic_cast<BibleTime*>(m_mdi->parent()->parent());
}
void CDisplayWindow::setToolBarsHidden() {
@@ -110,9 +118,77 @@ const QList<const CSwordModuleInfo*> CDisplayWindow::modules() const {
return CSwordBackend::instance()->getConstPointerList(m_modules);
}
-void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
- namespace DU = util::directory;
+/** Store the settings of this window in the given CProfileWindow object. */
+void CDisplayWindow::storeProfileSettings(const QString & windowGroup) {
+ BtConfig & conf = btConfig();
+
+ conf.beginGroup(windowGroup);
+
+ QWidget * w = getProfileWindow();
+
+ /**
+ \note We don't use saveGeometry/restoreGeometry for MDI subwindows,
+ because they give slightly incorrect results with some window
+ managers. Might be related to Qt bug QTBUG-7634.
+ */
+ const QRect rect(w->x(), w->y(), w->width(), w->height());
+ conf.setSessionValue<QRect>("windowRect", rect);
+
+ conf.setSessionValue("maximized", w->isMaximized());
+
+ bool hasFocus = (w == dynamic_cast<CDisplayWindow *>(mdi()->activeSubWindow()));
+ conf.setSessionValue("hasFocus", hasFocus);
+ // conf.setSessionValue("type", static_cast<int>(modules().first()->type()));
+
+ // Save current key:
+ if (key()) {
+ CSwordKey * k = key();
+ sword::VerseKey * vk = dynamic_cast<sword::VerseKey*>(k);
+ QString oldLang;
+ if (vk) {
+ // Save keys in english only:
+ const QString oldLang = QString::fromLatin1(vk->getLocale());
+ vk->setLocale("en");
+ conf.setSessionValue("key", k->key());
+ vk->setLocale(oldLang.toLatin1());
+ } else {
+ conf.setSessionValue("key", k->key());
+ }
+ }
+ // Save list of modules:
+ QStringList mods;
+ Q_FOREACH (const CSwordModuleInfo * module, modules())
+ mods.append(module->name());
+ conf.setSessionValue("modules", mods);
+
+ conf.endGroup();
+}
+
+void CDisplayWindow::applyProfileSettings(const QString & windowGroup) {
+ BtConfig & conf = btConfig();
+ conf.beginGroup(windowGroup);
+ setUpdatesEnabled(false);
+
+ QWidget * w = getProfileWindow();
+
+ /**
+ \note We don't use restoreGeometry/saveGeometry for MDI subwindows,
+ because they give slightly incorrect results with some window
+ managers. Might be related to Qt bug QTBUG-7634.
+ */
+ const QRect rect = conf.sessionValue<QRect>("windowRect");
+ w->resize(rect.width(), rect.height());
+ w->move(rect.x(), rect.y());
+
+ if (conf.sessionValue<bool>("maximized"))
+ w->showMaximized();
+
+ setUpdatesEnabled(true);
+ conf.endGroup();
+}
+
+void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
QAction* actn = new QAction(QIcon(), tr("Select all"), a);
actn->setShortcut(QKeySequence::SelectAll);
a->addAction("selectAll", actn);
@@ -129,13 +205,13 @@ void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
actn->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
a->addAction("openLocation", actn);
- actn = new QAction(QIcon(DU::getIcon(CResMgr::displaywindows::general::search::icon)),
+ actn = new QAction(QIcon(util::getIcon(CResMgr::displaywindows::general::search::icon)),
tr("Search with works of this window"), a);
actn->setShortcut(CResMgr::displaywindows::general::search::accel);
a->addAction(CResMgr::displaywindows::general::search::actionName, actn);
BtToolBarPopupAction* action = new BtToolBarPopupAction(
- QIcon(DU::getIcon(CResMgr::displaywindows::general::backInHistory::icon)),
+ QIcon(util::getIcon(CResMgr::displaywindows::general::backInHistory::icon)),
tr("Back in history"),
a
);
@@ -143,7 +219,7 @@ void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
a->addAction(CResMgr::displaywindows::general::backInHistory::actionName, action);
action = new BtToolBarPopupAction(
- QIcon(DU::getIcon(CResMgr::displaywindows::general::forwardInHistory::icon)),
+ QIcon(util::getIcon(CResMgr::displaywindows::general::forwardInHistory::icon)),
tr("Forward in history"),
a
);
@@ -201,7 +277,7 @@ void CDisplayWindow::initActions() {
Q_ASSERT(ok);
addAction(actn);
- CBTConfig::setupAccelSettings(CBTConfig::allWindows, ac);
+ ac->readShortcuts("Displaywindow shortcuts");
}
/** Refresh the settings of this window. */
@@ -223,8 +299,8 @@ void CDisplayWindow::reload(CSwordBackend::SetupChangedReason) {
lookup();
- CBTConfig::setupAccelSettings(CBTConfig::allWindows, actionCollection());
- CBTConfig::setupAccelSettings(CBTConfig::readWindow, actionCollection());
+ actionCollection()->readShortcuts("DisplayWindow shortcuts");
+ actionCollection()->readShortcuts("Readwindow shortcuts");
emit sigModuleListSet(m_modules);
}
@@ -316,7 +392,7 @@ void CDisplayWindow::setModuleChooserBar( BtModuleChooserBar* bar ) {
m_moduleChooserBar = bar;
bar->setWindowTitle(tr("Work chooser buttons"));
bar->setLayoutDirection(Qt::LeftToRight);
- bar->setVisible(CBTConfig::get(CBTConfig::showTextWindowModuleSelectorButtons));
+ bar->setVisible(btConfig().sessionValue<bool>("GUI/showTextWindowModuleSelectorButtons", true));
}
}
@@ -325,7 +401,7 @@ void CDisplayWindow::setHeaderBar( QToolBar* header ) {
m_headerBar = header;
header->setMovable(false);
header->setWindowTitle(tr("Text area header"));
- header->setVisible(CBTConfig::get(CBTConfig::showTextWindowHeaders));
+ header->setVisible(btConfig().sessionValue<bool>("GUI/showTextWindowHeaders", true));
}
/** Sets the modules. */
@@ -348,15 +424,15 @@ bool CDisplayWindow::init() {
parentWidget()->setFocusPolicy(Qt::ClickFocus);
initActions();
initToolbars();
- if ( ! CBTConfig::get(CBTConfig::showToolbarsInEachWindow))
+ if (!btConfig().sessionValue<bool>("GUI/showToolbarsInEachWindow", true))
setToolBarsHidden();
btMainWindow()->clearMdiToolBars();
clearMainWindowToolBars();
initConnections();
setupPopupMenu();
- m_filterOptions = CBTConfig::getFilterOptionDefaults();
- m_displayOptions = CBTConfig::getDisplayOptionDefaults();
+ m_filterOptions = btConfig().getFilterOptions();
+ m_displayOptions = btConfig().getDisplayOptions();
emit sigDisplayOptionsChanged(m_displayOptions);
emit sigFilterOptionsChanged(m_filterOptions);
emit sigModulesChanged(modules());
@@ -374,13 +450,13 @@ static void prepareToolBar(QToolBar* bar, const QString& title, bool visible) {
/** Setup the Navigation toolbar. */
void CDisplayWindow::setMainToolBar( QToolBar* bar ) {
- prepareToolBar(bar, tr("Navigation"), CBTConfig::get(CBTConfig::showTextWindowNavigator) );
+ prepareToolBar(bar, tr("Navigation"), btConfig().sessionValue<bool>("GUI/showTextWindowNavigator", true));
m_mainToolBar = bar;
}
/** Setup the Tools toolbar. */
void CDisplayWindow::setButtonsToolBar( QToolBar* bar ) {
- prepareToolBar(bar, tr("Tool"), CBTConfig::get(CBTConfig::showTextWindowToolButtons) );
+ prepareToolBar(bar, tr("Tool"), btConfig().sessionValue<bool>("GUI/showTextWindowToolButtons", true));
m_buttonsToolBar = bar;
}
diff --git a/src/frontend/displaywindow/cdisplaywindow.h b/src/frontend/displaywindow/cdisplaywindow.h
index 4935d8f..72199d1 100644
--- a/src/frontend/displaywindow/cdisplaywindow.h
+++ b/src/frontend/displaywindow/cdisplaywindow.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -15,7 +17,6 @@
#include <QStringList>
#include "backend/managers/cswordbackend.h"
#include "btglobal.h"
-#include "frontend/profile/cprofilewindow.h"
class BtActionCollection;
@@ -25,14 +26,13 @@ class CKeyChooser;
class CMDIArea;
class BtModuleChooserBar;
class CSwordModuleInfo;
-class QCloseEvent;
class QMenu;
class QToolBar;
class BTHistory;
class BibleTime;
-/** The base class for all display windows of BibleTime.
- *
+/** The base class for all display windows of BibleTime.
+ *
* Inherits QMainWindow.
*
* Inherited by CReadWindow and CWriteWindow.
@@ -46,6 +46,9 @@ class CDisplayWindow : public QMainWindow {
/** Insert the keyboard accelerators of this window into the given actioncollection.*/
static void insertKeyboardActions( BtActionCollection* const a );
+ /** Returns a pointer to the parent widget of type QMdiSubWindow or pointer to self if none found. */
+ QWidget * getProfileWindow() const;
+
/** Returns pointer to the mdi area object.*/
inline CMDIArea *mdi() const {
return m_mdi;
@@ -63,10 +66,10 @@ class CDisplayWindow : public QMainWindow {
}
/** Store the settings of this window in the given CProfileWindow object.*/
- virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
+ virtual void storeProfileSettings(const QString & windowGroup);
/** Load the settings the given CProfileWindow object into this window.*/
- virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
+ virtual void applyProfileSettings(const QString & windowGroup);
/** Returns the display options used by this display window. */
inline const DisplayOptions &displayOptions() const {
@@ -228,7 +231,7 @@ class CDisplayWindow : public QMainWindow {
friend class CBibleReadWindow;
- CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ CDisplayWindow(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent);
virtual ~CDisplayWindow();
/**
diff --git a/src/frontend/displaywindow/cdisplaywindowfactory.cpp b/src/frontend/displaywindow/cdisplaywindowfactory.cpp
index e280c6d..12059d1 100644
--- a/src/frontend/displaywindow/cdisplaywindowfactory.cpp
+++ b/src/frontend/displaywindow/cdisplaywindowfactory.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,11 +17,10 @@
#include "frontend/displaywindow/clexiconreadwindow.h"
#include "frontend/displaywindow/cplainwritewindow.h"
#include "frontend/displaywindow/creadwindow.h"
-#include "frontend/displaywindow/cwritewindow.h"
#include "frontend/cmdiarea.h"
-CReadWindow* CDisplayWindowFactory::createReadInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent) {
+CReadWindow* CDisplayWindowFactory::createReadInstance(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent) {
CReadWindow* win = 0;
switch (modules.first()->type()) {
case CSwordModuleInfo::Bible:
@@ -43,8 +42,8 @@ CReadWindow* CDisplayWindowFactory::createReadInstance(QList<CSwordModuleInfo*>
return win;
}
-CWriteWindow* CDisplayWindowFactory::createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CWriteWindow::WriteWindowType type) {
- if (type == CWriteWindow::HTMLWindow) {
+CPlainWriteWindow * CDisplayWindowFactory::createWriteInstance(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent, CPlainWriteWindow::WriteWindowType type) {
+ if (type == CPlainWriteWindow::HTMLWindow) {
return new CHTMLWriteWindow(modules, parent);
}
else {
@@ -53,7 +52,7 @@ CWriteWindow* CDisplayWindowFactory::createWriteInstance(QList<CSwordModuleInfo*
return 0;
}
-const CSwordModuleInfo::ModuleType CDisplayWindowFactory::getModuleType(QObject* widget) {
+CSwordModuleInfo::ModuleType CDisplayWindowFactory::getModuleType(QObject* widget) {
if (qobject_cast<CBibleReadWindow*>(widget) != 0 )
return CSwordModuleInfo::Bible;
if (qobject_cast<CCommentaryReadWindow*>(widget) != 0 )
diff --git a/src/frontend/displaywindow/cdisplaywindowfactory.h b/src/frontend/displaywindow/cdisplaywindowfactory.h
index 06d9aa4..e065e50 100644
--- a/src/frontend/displaywindow/cdisplaywindowfactory.h
+++ b/src/frontend/displaywindow/cdisplaywindowfactory.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -11,20 +13,18 @@
#define CDISPLAYWINDOWFACTORY_H
#include "frontend/displaywindow/cdisplaywindow.h"
-#include "frontend/displaywindow/cwritewindow.h"
+#include "frontend/displaywindow/cplainwritewindow.h"
-class CMDIArea;
class CReadWindow;
class CSwordModuleInfo;
-class CWriteWindow;
/// \todo Make CDisplayWindowFactory a namespace instead?
class CDisplayWindowFactory {
public:
- static CReadWindow* createReadInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- static CWriteWindow* createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CWriteWindow::WriteWindowType type = CWriteWindow::HTMLWindow);
- static const CSwordModuleInfo::ModuleType getModuleType(QObject* widget);
+ static CReadWindow* createReadInstance(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent);
+ static CPlainWriteWindow* createWriteInstance(const QList<CSwordModuleInfo*> & modules, CMDIArea * parent, CPlainWriteWindow::WriteWindowType type = CPlainWriteWindow::HTMLWindow);
+ static CSwordModuleInfo::ModuleType getModuleType(QObject* widget);
private:
CDisplayWindowFactory();
diff --git a/src/frontend/displaywindow/chtmlwritewindow.cpp b/src/frontend/displaywindow/chtmlwritewindow.cpp
index 705daf0..20c8323 100644
--- a/src/frontend/displaywindow/chtmlwritewindow.cpp
+++ b/src/frontend/displaywindow/chtmlwritewindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,26 +14,22 @@
#include "bibletime.h"
#include "backend/keys/cswordkey.h"
#include "frontend/display/chtmlwritedisplay.h"
-#include "frontend/display/cwritedisplay.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/btmodulechooserbar.h"
#include "frontend/keychooser/ckeychooser.h"
-#include "frontend/profile/cprofilewindow.h"
+#include "frontend/messagedialog.h"
#include "util/directory.h"
-#include "util/dialogutil.h"
#include "util/cresmgr.h"
-using namespace Profile;
-
-CHTMLWriteWindow::CHTMLWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
+CHTMLWriteWindow::CHTMLWriteWindow(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent)
: CPlainWriteWindow(modules, parent) {}
void CHTMLWriteWindow::initView() {
- CWriteDisplay* writeDisplay = CDisplay::createWriteInstance(this, CDisplay::HTMLDisplay);
- Q_ASSERT(writeDisplay);
- setDisplayWidget( writeDisplay );
- setCentralWidget( displayWidget()->view() );
+ m_writeDisplay = new CHTMLWriteDisplay(this, this);
+ Q_ASSERT(m_writeDisplay);
+ setDisplayWidget(m_writeDisplay);
+ setCentralWidget(m_writeDisplay->view() );
// Create Navigation toolbar
setMainToolBar( new QToolBar(this) );
@@ -48,19 +44,11 @@ void CHTMLWriteWindow::initView() {
addToolBar(formatToolBar());
}
-void CHTMLWriteWindow::initActions() {
- insertKeyboardActions(actionCollection());
- CPlainWriteWindow::initActions();
-}
-
-void CHTMLWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
-}
-
void CHTMLWriteWindow::initConnections() {
- CWriteWindow::initConnections();
+ CPlainWriteWindow::initConnections();
connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
- connect(displayWidget()->connectionsProxy(), SIGNAL(textChanged()), this, SLOT(textChanged()) );
+ connect(m_writeDisplay->connectionsProxy(), SIGNAL(textChanged()), this, SLOT(textChanged()) );
}
void CHTMLWriteWindow::initToolbars() {
@@ -69,39 +57,41 @@ void CHTMLWriteWindow::initToolbars() {
CPlainWriteWindow::initToolbars();
//Formatting toolbar
- ((CWriteDisplay*)displayWidget())->setupToolbar( formatToolBar(), actionCollection() );
+ m_writeDisplay->setupToolbar( formatToolBar(), actionCollection() );
}
-void CHTMLWriteWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
- CWriteWindow::storeProfileSettings(profileWindow);
- QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+void CHTMLWriteWindow::storeProfileSettings(const QString & windowGroup) {
+ CPlainWriteWindow::storeProfileSettings(windowGroup);
+
+ QAction * action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
Q_ASSERT(action != 0);
- profileWindow->windowSettings = action->isChecked();
+ Q_ASSERT(windowGroup.endsWith('/'));
+ btConfig().setSessionValue(windowGroup + "syncWindowEnabled", action->isChecked());
}
-void CHTMLWriteWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
- CWriteWindow::applyProfileSettings(profileWindow);
- if (profileWindow->windowSettings) {
- QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
- Q_ASSERT(action != 0);
- action->setChecked(true);
- }
+void CHTMLWriteWindow::applyProfileSettings(const QString & windowGroup) {
+ CPlainWriteWindow::applyProfileSettings(windowGroup);
+
+ QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ Q_ASSERT(action != 0);
+ Q_ASSERT(windowGroup.endsWith('/'));
+ action->setChecked(btConfig().sessionValue<bool>(windowGroup + "syncWindowEnabled", false));
}
/** Is called when the current text was changed. */
void CHTMLWriteWindow::textChanged() {
QAction* action = actionCollection()->action(CResMgr::displaywindows::writeWindow::saveText::actionName);
Q_ASSERT(action != 0);
- action->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ action->setEnabled(m_writeDisplay->isModified());
action = actionCollection()->action(CResMgr::displaywindows::writeWindow::restoreText::actionName);
Q_ASSERT(action != 0);
- action->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ action->setEnabled(m_writeDisplay->isModified());
}
/** Loads the original text from the module. */
void CHTMLWriteWindow::restoreText() {
lookupSwordKey(key());
- ((CWriteDisplay*)displayWidget())->setModified(false);
+ m_writeDisplay->setModified(false);
textChanged();
}
@@ -113,7 +103,7 @@ bool CHTMLWriteWindow::syncAllowed() const {
/** Saves the text for the current key. Directly writes the changed text into the module. */
void CHTMLWriteWindow::saveCurrentText( const QString& /*key*/ ) {
- QString t = ((CHTMLWriteDisplay*)displayWidget())->toHtml();
+ QString t = m_writeDisplay->toHtml();
//since t is a complete HTML page at the moment, strip away headers and footers of a HTML page
QRegExp re("(?:<html.*>.+<body.*>)", Qt::CaseInsensitive); //remove headers, case insensitive
re.setMinimal(true);
@@ -125,11 +115,11 @@ void CHTMLWriteWindow::saveCurrentText( const QString& /*key*/ ) {
const_cast<CSwordModuleInfo*>(modules().first())->write(this->key(), t);
this->key()->setKey(oldKey);
- ((CWriteDisplay*)displayWidget())->setModified(false);
+ m_writeDisplay->setModified(false);
textChanged();
}
else {
- util::showCritical( this, tr("Module not writable"),
+ message::showCritical( this, tr("Module not writable"),
QString::fromLatin1("<qt><b>%1</b><br />%2</qt>")
.arg( tr("Module is not writable.") )
.arg( tr("Either the module may not be edited, or you do not have write permission.") ) );
@@ -139,5 +129,5 @@ void CHTMLWriteWindow::saveCurrentText( const QString& /*key*/ ) {
void CHTMLWriteWindow::setupMainWindowToolBars() {
CPlainWriteWindow::setupMainWindowToolBars();
//Formatting toolbar
- ((CWriteDisplay*)displayWidget())->setupToolbar( btMainWindow()->formatToolBar(), actionCollection() );
+ m_writeDisplay->setupToolbar( btMainWindow()->formatToolBar(), actionCollection() );
}
diff --git a/src/frontend/displaywindow/chtmlwritewindow.h b/src/frontend/displaywindow/chtmlwritewindow.h
index 8aec012..2d2eee6 100644
--- a/src/frontend/displaywindow/chtmlwritewindow.h
+++ b/src/frontend/displaywindow/chtmlwritewindow.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,9 +15,7 @@
#include "frontend/displaywindow/cplainwritewindow.h"
-class QAction;
-
-/**
+/**
* The write window class which offers a WYSIWYG text editor for creating a personal commentary.
*
* Inherits CPlainWriteWindow.
@@ -25,17 +25,10 @@ class QAction;
class CHTMLWriteWindow : public CPlainWriteWindow {
Q_OBJECT
public:
- CHTMLWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
-
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings( Profile::CProfileWindow* );
+ CHTMLWriteWindow(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent);
- /**
- * Store the settings of this window in the given profile window.
- */
- virtual void applyProfileSettings( Profile::CProfileWindow* );
+ virtual void storeProfileSettings(const QString & windowGroup);
+ virtual void applyProfileSettings(const QString & windowGroup);
/**
* Returns true if the sync toolbar is enabled.
@@ -49,18 +42,12 @@ class CHTMLWriteWindow : public CPlainWriteWindow {
virtual void initView();
virtual void initConnections();
virtual void initToolbars();
- virtual void initActions();
-
- /**
- * Insert the keyboard accelerators of this window into the given KAccel object.
- */
- static void insertKeyboardActions( BtActionCollection* const a );
- virtual CWriteWindow::WriteWindowType writeWindowType() {
- return CWriteWindow::HTMLWindow;
+ virtual WriteWindowType writeWindowType() const {
+ return HTMLWindow;
}
- /**
- * Called to add actions to mainWindow toolbars
+ /**
+ * Called to add actions to mainWindow toolbars
*/
virtual void setupMainWindowToolBars();
@@ -77,6 +64,7 @@ class CHTMLWriteWindow : public CPlainWriteWindow {
* Saves the text for the current key. Directly writes the changed text into the module.
*/
virtual void saveCurrentText( const QString& );
+
};
#endif
diff --git a/src/frontend/displaywindow/clexiconreadwindow.cpp b/src/frontend/displaywindow/clexiconreadwindow.cpp
index 7d76293..3b76f38 100644
--- a/src/frontend/displaywindow/clexiconreadwindow.cpp
+++ b/src/frontend/displaywindow/clexiconreadwindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,13 +17,10 @@
#include <QDebug>
#include "bibletime.h"
-#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordldkey.h"
#include "backend/keys/cswordkey.h"
#include "frontend/cexportmanager.h"
#include "frontend/display/bthtmlreaddisplay.h"
-#include "frontend/display/cdisplay.h"
-#include "frontend/display/creaddisplay.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/bttoolbarpopupaction.h"
#include "frontend/displaywindow/btdisplaysettingsbutton.h"
@@ -36,7 +33,7 @@
#include "util/tool.h"
-CLexiconReadWindow::CLexiconReadWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea* parent)
+CLexiconReadWindow::CLexiconReadWindow(const QList<CSwordModuleInfo *> & moduleList, CMDIArea * parent)
: CReadWindow(moduleList, parent) {
moduleList.first();
setKey( CSwordKey::createInstance(moduleList.first()) );
@@ -158,7 +155,7 @@ void CLexiconReadWindow::initActions() {
addAction(m_actions.print.entry);
// init with the user defined settings
- CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac);
+ ac->readShortcuts("Lexicon shortcuts");
}
/** No descriptions */
@@ -194,7 +191,7 @@ void CLexiconReadWindow::initConnections() {
void CLexiconReadWindow::initView() {
// Create display widget for this window
- setDisplayWidget( CDisplay::createReadInstance(this) );
+ setDisplayWidget(new BtHtmlReadDisplay(this, this));
setCentralWidget( displayWidget()->view() );
setWindowIcon(util::tool::getIconForModule(modules().first()));
@@ -320,7 +317,7 @@ void CLexiconReadWindow::updatePopupMenu() {
void CLexiconReadWindow::reload(CSwordBackend::SetupChangedReason reason) {
CReadWindow::reload(reason);
- CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, actionCollection());
+ actionCollection()->readShortcuts("Lexicon shortcuts");
}
/** No descriptions */
diff --git a/src/frontend/displaywindow/clexiconreadwindow.h b/src/frontend/displaywindow/clexiconreadwindow.h
index 36b47db..6233545 100644
--- a/src/frontend/displaywindow/clexiconreadwindow.h
+++ b/src/frontend/displaywindow/clexiconreadwindow.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -33,7 +35,7 @@ class QMenu;
class CLexiconReadWindow : public CReadWindow {
Q_OBJECT
public:
- CLexiconReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+ CLexiconReadWindow(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent);
virtual ~CLexiconReadWindow();
/** Insert the keyboard accelerators of this window into the given actioncollection.*/
diff --git a/src/frontend/displaywindow/cplainwritewindow.cpp b/src/frontend/displaywindow/cplainwritewindow.cpp
index f0af601..f4b2d0b 100644
--- a/src/frontend/displaywindow/cplainwritewindow.cpp
+++ b/src/frontend/displaywindow/cplainwritewindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,30 +14,55 @@
#include <QRegExp>
#include <QToolBar>
#include "bibletime.h"
-#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordkey.h"
-#include "frontend/display/cwritedisplay.h"
+#include "bibletimeapp.h"
+#include "frontend/display/cplainwritedisplay.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/btmodulechooserbar.h"
#include "frontend/keychooser/ckeychooser.h"
-#include "frontend/profile/cprofilewindow.h"
+#include "frontend/messagedialog.h"
+#include "util/btsignal.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
-#include "util/dialogutil.h"
+#include "util/geticon.h"
-using namespace Profile;
-
-CPlainWriteWindow::CPlainWriteWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea* parent) :
- CWriteWindow(moduleList, parent) {
+CPlainWriteWindow::CPlainWriteWindow(const QList<CSwordModuleInfo*> & moduleList, CMDIArea * parent)
+ : CDisplayWindow(moduleList, parent)
+ , m_writeDisplay(0)
+{
setKey( CSwordKey::createInstance(moduleList.first()) );
}
+void CPlainWriteWindow::setDisplayWidget(CDisplay * display) {
+ Q_ASSERT(dynamic_cast<CPlainWriteDisplay *>(display));
+ CDisplayWindow::setDisplayWidget(static_cast<CPlainWriteDisplay *>(display));
+ m_writeDisplay = static_cast<CPlainWriteDisplay *>(display);
+}
+
+void CPlainWriteWindow::lookupSwordKey(CSwordKey * newKey) {
+ //set the raw text to the display widget
+ if (!newKey)
+ return;
+
+ /*
+ Set passage of newKey to key() if they're different, otherwise we'd get
+ mixed up if we look up newkey which may have a different module set.
+ */
+ if (key() != newKey)
+ key()->setKey(newKey->key());
+
+ if (modules().count())
+ displayWidget()->setText(key()->rawText());
+
+ setWindowTitle(windowCaption());
+}
+
/** Initialize the state of this widget. */
void CPlainWriteWindow::initView() {
// qWarning("CPlainWriteWindow::initView()");
- setDisplayWidget( CDisplay::createWriteInstance(this) );
- setCentralWidget( displayWidget()->view() );
+ m_writeDisplay = new CPlainWriteDisplay(this, this);
+ setDisplayWidget(m_writeDisplay);
+ setCentralWidget(m_writeDisplay->view());
// Create Navigation toolbar
setMainToolBar( new QToolBar(this) );
@@ -49,8 +74,6 @@ void CPlainWriteWindow::initView() {
}
void CPlainWriteWindow::initToolbars() {
- namespace DU = util::directory;
-
// Navigation toolbar
setKeyChooser( CKeyChooser::createInstance(modules(),
history(), key(), mainToolBar()) );
@@ -94,30 +117,35 @@ void CPlainWriteWindow::setupMainWindowToolBars() {
}
void CPlainWriteWindow::initConnections() {
- CWriteWindow::initConnections();
+ Q_ASSERT(keyChooser());
+ QObject::connect(key()->beforeChangedSignaller(), SIGNAL(signal()), this, SLOT(beforeKeyChange()));
QObject::connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
QObject::connect(displayWidget()->connectionsProxy(), SIGNAL(textChanged()), this, SLOT(textChanged()) );
}
-void CPlainWriteWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
- CWriteWindow::storeProfileSettings(profileWindow);
- QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
- Q_ASSERT(action != 0);
- profileWindow->windowSettings = action->isChecked();
+void CPlainWriteWindow::storeProfileSettings(const QString & windowGroup) {
+ CDisplayWindow::storeProfileSettings(windowGroup);
+
+ QAction * action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ Q_ASSERT(action);
+ Q_ASSERT(windowGroup.endsWith('/'));
+ btConfig().setSessionValue(windowGroup + "writeWindowType",
+ static_cast<int>(writeWindowType()));
+ btConfig().setSessionValue(windowGroup + "syncWindowEnabled", action->isChecked());
}
-void CPlainWriteWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
- CWriteWindow::applyProfileSettings(profileWindow);
- if (profileWindow->windowSettings) {
- QAction* action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
- Q_ASSERT(action != 0);
- action->setChecked(true);
- }
+void CPlainWriteWindow::applyProfileSettings(const QString & windowGroup) {
+ CDisplayWindow::applyProfileSettings(windowGroup);
+
+ QAction * action = actionCollection()->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
+ Q_ASSERT(action != 0);
+ Q_ASSERT(windowGroup.endsWith('/'));
+ action->setChecked(btConfig().sessionValue<bool>(windowGroup + "syncWindowEnabled", false));
}
/** Saves the text for the current key. Directly writes the changed text into the module. */
void CPlainWriteWindow::saveCurrentText( const QString& /*key*/ ) {
- QString t = ((CWriteDisplay*)displayWidget())->plainText();
+ QString t = m_writeDisplay->plainText();
//since t is a complete HTML page at the moment, strip away headers and footers of a HTML page
QRegExp re("(?:<html.*>.+<body.*>)", Qt::CaseInsensitive); //remove headers, case insensitive
re.setMinimal(true);
@@ -127,12 +155,12 @@ void CPlainWriteWindow::saveCurrentText( const QString& /*key*/ ) {
const QString& oldKey = this->key()->key();
if ( modules().first()->isWritable() ) {
const_cast<CSwordModuleInfo*>(modules().first())->write(this->key(), t);
- ((CWriteDisplay*)displayWidget())->setModified(false);
+ m_writeDisplay->setModified(false);
this->key()->setKey(oldKey);
textChanged();
}
else {
- util::showCritical( this, tr("Module not writable"),
+ message::showCritical( this, tr("Module not writable"),
QString::fromLatin1("<qt><b>%1</b><br/>%2</qt>")
.arg( tr("Module is not writable.") )
.arg( tr("Either the module may not be edited, or "
@@ -143,7 +171,7 @@ void CPlainWriteWindow::saveCurrentText( const QString& /*key*/ ) {
/** Loads the original text from the module. */
void CPlainWriteWindow::restoreText() {
lookupSwordKey(key());
- ((CWriteDisplay*)displayWidget())->setModified(false);
+ m_writeDisplay->setModified(false);
textChanged();
}
@@ -151,17 +179,17 @@ void CPlainWriteWindow::restoreText() {
void CPlainWriteWindow::textChanged() {
QAction* action = actionCollection()->action(CResMgr::displaywindows::writeWindow::saveText::actionName);
Q_ASSERT(action != 0);
- action->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ action->setEnabled(m_writeDisplay->isModified());
action = actionCollection()->action(CResMgr::displaywindows::writeWindow::restoreText::actionName);
Q_ASSERT(action != 0);
- action->setEnabled( ((CWriteDisplay*)displayWidget())->isModified() );
+ action->setEnabled(m_writeDisplay->isModified());
}
/** Deletes the module entry and clears the edit widget, */
void CPlainWriteWindow::deleteEntry() {
const_cast<CSwordModuleInfo*>(modules().first())->deleteEntry(key());
lookupSwordKey( key() );
- ((CWriteDisplay*)displayWidget())->setModified(false);
+ m_writeDisplay->setModified(false);
}
/** Setups the popup menu of this display widget. */
@@ -202,11 +230,8 @@ void CPlainWriteWindow::initActions() {
}
void CPlainWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
-
- namespace DU = util::directory;
-
QAction* action = new QAction(
- DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
+ util::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
tr("Sync with active Bible"),
a
);
@@ -216,7 +241,7 @@ void CPlainWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
a->addAction(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName, action);
action = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
tr("Save text"),
a
);
@@ -225,7 +250,7 @@ void CPlainWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
a->addAction(CResMgr::displaywindows::writeWindow::saveText::actionName, action);
action = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
tr("Delete current entry"),
a
);
@@ -234,7 +259,7 @@ void CPlainWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
a->addAction(CResMgr::displaywindows::writeWindow::deleteEntry::actionName, action);
action = new QAction(
- DU::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
+ util::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
tr("Restore original text"),
a
);
@@ -242,3 +267,55 @@ void CPlainWriteWindow::insertKeyboardActions( BtActionCollection* const a) {
action->setToolTip( tr("Restore original text, new text will be lost") );
a->addAction(CResMgr::displaywindows::writeWindow::restoreText::actionName, action);
}
+
+void CPlainWriteWindow::saveCurrentText() {
+ if (key())
+ saveCurrentText(key()->key());
+}
+
+
+bool CPlainWriteWindow::queryClose() {
+ //save the text if it has changed
+ if (m_writeDisplay->isModified()) {
+ switch (message::showQuestion( this, tr("Save Text?"), tr("Save text before closing?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes) ) {
+ case QMessageBox::Yes: //save and close
+ saveCurrentText();
+ m_writeDisplay->setModified( false );
+ return true;
+ case QMessageBox::No: //don't save and close
+ return true;
+ default: // cancel, don't close
+ return false;
+ }
+ }
+ return true;
+}
+
+void CPlainWriteWindow::beforeKeyChange() {
+ Q_ASSERT(displayWidget());
+ Q_ASSERT(keyChooser());
+ if (!isReady())
+ return;
+
+ // Get current key string for this window
+ QString thisWindowsKey;
+ CSwordKey* oldKey = key();
+ if (oldKey == 0)
+ return;
+ thisWindowsKey = oldKey->key();
+
+ //If the text changed and we'd do a lookup ask the user if the text should be saved
+ if (modules().first() && m_writeDisplay->isModified()) {
+
+ switch (message::showQuestion( this, tr("Save Text?"), tr("Save changed text?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) ) {
+ case QMessageBox::Yes: { //save the changes
+ saveCurrentText( thisWindowsKey );
+ break;
+ }
+ default: {// set modified to false so it won't ask again
+ m_writeDisplay->setModified(false);
+ break;
+ }
+ }
+ }
+}
diff --git a/src/frontend/displaywindow/cplainwritewindow.h b/src/frontend/displaywindow/cplainwritewindow.h
index 732ff8a..cf11a46 100644
--- a/src/frontend/displaywindow/cplainwritewindow.h
+++ b/src/frontend/displaywindow/cplainwritewindow.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,12 +12,11 @@
#ifndef CPLAINWRITEWINDOW_H
#define CPLAINWRITEWINDOW_H
-#include "frontend/displaywindow/cwritewindow.h"
+#include "frontend/displaywindow/cdisplaywindow.h"
class BtActionCollection;
-class QAction;
-class QString;
+class CPlainWriteDisplay;
/** The write window class which offers a plain text editor for creating a personal commentary.
*
@@ -25,19 +26,24 @@ class QString;
*
* @author The BibleTime team
*/
-class CPlainWriteWindow : public CWriteWindow {
+class CPlainWriteWindow : public CDisplayWindow {
Q_OBJECT
public:
- CPlainWriteWindow( QList<CSwordModuleInfo*> modules, CMDIArea* parent);
+
+ enum WriteWindowType {
+ HTMLWindow = 1,
+ PlainTextWindow = 2
+ };
+
+ CPlainWriteWindow(const QList<CSwordModuleInfo *> & modules, CMDIArea * parent);
/**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings( Profile::CProfileWindow* profileWindow );
- /**
- * Store the settings of this window in the given profile window.
+ * Set the displayWidget which is a subclass of QWebPage.
*/
- virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow );
+ void setDisplayWidget( CDisplay* display );
+
+ virtual void storeProfileSettings(const QString & windowGroup);
+ virtual void applyProfileSettings(const QString & windowGroup);
/**
* Setups the popup menu of this display widget.
@@ -49,6 +55,13 @@ class CPlainWriteWindow : public CWriteWindow {
*/
virtual bool syncAllowed() const;
+ public slots:
+
+ /**
+ Look up the given key and display the text. In our case we offer to edit the text.
+ */
+ virtual void lookupSwordKey(CSwordKey * key);
+
protected: // Protected methods
/**
* Initialize the state of this widget.
@@ -56,9 +69,9 @@ class CPlainWriteWindow : public CWriteWindow {
virtual void initView();
virtual void initConnections();
virtual void initToolbars();
- virtual CWriteWindow::WriteWindowType writeWindowType() {
- return CWriteWindow::PlainTextWindow;
- };
+ virtual WriteWindowType writeWindowType() const {
+ return PlainTextWindow;
+ }
/** Called to add actions to mainWindow toolbars */
virtual void setupMainWindowToolBars();
@@ -71,7 +84,13 @@ class CPlainWriteWindow : public CWriteWindow {
*/
static void insertKeyboardActions( BtActionCollection* const a );
+ /** \returns whether the window may be closed.*/
+ virtual bool queryClose();
+
protected slots: // Protected slots
+
+ void saveCurrentText();
+
/**
* Saves the text for the current key. Directly writes the changed text into the module.
*/
@@ -88,6 +107,13 @@ class CPlainWriteWindow : public CWriteWindow {
* Deletes the module entry and clears the edit widget.
*/
virtual void deleteEntry();
+
+ virtual void beforeKeyChange();
+
+ protected: /* Fields: */
+
+ CPlainWriteDisplay * m_writeDisplay;
+
};
#endif
diff --git a/src/frontend/displaywindow/creadwindow.cpp b/src/frontend/displaywindow/creadwindow.cpp
index 7f11dca..0d8f2d9 100644
--- a/src/frontend/displaywindow/creadwindow.cpp
+++ b/src/frontend/displaywindow/creadwindow.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,12 +19,9 @@
#include "frontend/cmdiarea.h"
#include "frontend/display/bthtmlreaddisplay.h"
#include "frontend/displaywindow/btactioncollection.h"
-#include "frontend/profile/cprofilewindow.h"
#include "frontend/searchdialog/csearchdialog.h"
-using namespace Profile;
-
CReadWindow::CReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
: CDisplayWindow(modules, parent),
m_readDisplayWidget(0) {
@@ -108,57 +105,6 @@ void CReadWindow::slotMoveToAnchor() {
((CReadDisplay*)displayWidget())->moveToAnchor( Rendering::CDisplayRendering::keyToHTMLAnchor(key()->key()) );
}
-/** Store the settings of this window in the given CProfileWindow object. */
-void CReadWindow::storeProfileSettings(CProfileWindow * const settings) {
- QRect rect;
- rect.setX(parentWidget()->x());
- rect.setY(parentWidget()->y());
- rect.setWidth(parentWidget()->width());
- rect.setHeight(parentWidget()->height());
- settings->windowGeometry = rect;
-
- // settings->setScrollbarPositions( m_htmlWidget->view()->horizontalScrollBar()->value(), m_htmlWidget->view()->verticalScrollBar()->value() );
- settings->type = modules().first()->type();
- settings->maximized = (isMaximized() || parentWidget()->isMaximized());
- settings->hasFocus = (this == dynamic_cast<CReadWindow*>(mdi()->activeSubWindow()) ); //set property to true if this window is the active one.
-
- if (key()) {
- sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key());
- QString oldLang;
- if (vk) {
- oldLang = QString(vk->getLocale());
- vk->setLocale("en"); //save english locale names as default!
- }
- settings->key = key()->key();
- if (vk) {
- vk->setLocale(oldLang.toLatin1());
- }
- }
-
- QStringList mods;
- Q_FOREACH (const CSwordModuleInfo *module, modules()) {
- mods.append(module->name());
- }
- settings->modules = mods;
-}
-
-void CReadWindow::applyProfileSettings(CProfileWindow * const settings) {
- // parentWidget()->setUpdatesEnabled(false);
- setUpdatesEnabled(false);
-
- if (settings->maximized) { //maximize this window
- // Use parentWidget() to call showMaximized. Otherwise we'd get lot's of X11 errors
- parentWidget()->showMaximized();
- }
- else {
- const QRect &rect = settings->windowGeometry;
- parentWidget()->resize(rect.width(), rect.height());
- parentWidget()->move(rect.x(), rect.y());
- }
-
- setUpdatesEnabled(true);
-}
-
void CReadWindow::insertKeyboardActions( BtActionCollection* const ) {}
/** No descriptions */
diff --git a/src/frontend/displaywindow/creadwindow.h b/src/frontend/displaywindow/creadwindow.h
index d00d4f0..2446e1e 100644
--- a/src/frontend/displaywindow/creadwindow.h
+++ b/src/frontend/displaywindow/creadwindow.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,15 +21,10 @@
class BtActionCollection;
class QResizeEvent;
-/** The base class for all read-only display windows.
- *
- * Inherits CDisplayWindow.
- *
- * Inherited by CLexiconReadWindow
- *
- * @author The BibleTime team
- */
-class CReadWindow : public CDisplayWindow {
+/**
+ \brief The base class for all read-only display windows.
+*/
+class CReadWindow: public CDisplayWindow {
Q_OBJECT
public:
@@ -36,15 +33,6 @@ class CReadWindow : public CDisplayWindow {
CReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings(Profile::CProfileWindow * const settings);
- /**
- * Load the settings the given CProfileWindow object into this window.
- */
- virtual void applyProfileSettings(Profile::CProfileWindow * const settings);
-
protected:
/**
* Sets the display widget of this display window.
@@ -72,7 +60,7 @@ class CReadWindow : public CDisplayWindow {
* Update the status of the popup menu entries.
*/
virtual void copyDisplayedText();
- /**
+ /**
* Open the search dialog with the strong info of the last clicked word.
*/
void openSearchStrongsDialog();
diff --git a/src/frontend/displaywindow/cwritewindow.cpp b/src/frontend/displaywindow/cwritewindow.cpp
deleted file mode 100644
index fbcf8de..0000000
--- a/src/frontend/displaywindow/cwritewindow.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/*********
-*
-* 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/displaywindow/cwritewindow.h"
-
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/keys/cswordversekey.h"
-#include "frontend/display/cwritedisplay.h"
-#include "frontend/keychooser/ckeychooser.h"
-#include "frontend/profile/cprofilewindow.h"
-#include "util/dialogutil.h"
-#include "util/btsignal.h"
-
-using namespace Profile;
-
-CWriteWindow::CWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
- : CDisplayWindow(modules, parent), m_writeDisplay(0) {}
-
-void CWriteWindow::insertKeyboardActions( BtActionCollection* const ) {}
-
-void CWriteWindow::initConnections() {
- Q_ASSERT(keyChooser());
- QObject::connect(key()->signaler(), SIGNAL(beforeChanged()), this, SLOT(beforeKeyChange()));
-}
-
-void CWriteWindow::initActions() {}
-
-
-void CWriteWindow::storeProfileSettings(CProfileWindow * const settings) {
-
- settings->writeWindowType = writeWindowType();
- settings->windowGeometry.setRect(parentWidget()->x(),
- parentWidget()->y(),
- parentWidget()->width(),
- parentWidget()->height());
-
- // settings->setScrollbarPositions( m_htmlWidget->view()->horizontalScrollBar()->value(), m_htmlWidget->view()->verticalScrollBar()->value() );
- settings->type = modules().first()->type();
- settings->maximized = isMaximized() || parentWidget()->isMaximized();
-
- if (key()) {
- sword::VerseKey* vk = dynamic_cast<sword::VerseKey*>(key());
- QString oldLang;
- if (vk) {
- oldLang = QString::fromLatin1(vk->getLocale());
- vk->setLocale("en"); //save english locale names as default!
- }
- settings->key = key()->key();
- if (vk) {
- vk->setLocale(oldLang.toLatin1());
- }
- }
-
- QStringList mods;
- Q_FOREACH(const CSwordModuleInfo *m, modules()) {
- mods.append(m->name());
- }
- settings->modules = mods;
-}
-
-void CWriteWindow::applyProfileSettings(CProfileWindow * const settings) {
- setUpdatesEnabled(false);
-
- if (settings->maximized) {
- parentWidget()->showMaximized();
- }
- else {
- const QRect &rect = settings->windowGeometry;
- parentWidget()->resize(rect.width(), rect.height());
- parentWidget()->move(rect.x(), rect.y());
- //setGeometry( settings->geometry() );
- }
- // displayWidget()->view()->horizontalScrollBar()->setValue( settings->scrollbarPositions().horizontal );
- // m_htmlWidget->view()->verticalScrollBar()->setValue( settings->scrollbarPositions().vertical );
-
- setUpdatesEnabled(true);
-}
-
-void CWriteWindow::setDisplayWidget( CDisplay* display ) {
- Q_ASSERT(dynamic_cast<CWriteDisplay*>(display));
- CDisplayWindow::setDisplayWidget((CWriteDisplay*)display);
- m_writeDisplay = (CWriteDisplay*)display;
-}
-
-void CWriteWindow::lookupSwordKey( CSwordKey* newKey ) {
- //set the raw text to the display widget
- if (!newKey)
- return;
-
- if (key() != newKey) { //set passage of newKey to key() if they're different, otherwise we'd get mixed up if we look up newkey which may have a different module set
- key()->setKey(newKey->key());
- }
-
- if ( modules().count() ) {
- displayWidget()->setText( key()->rawText() );
- }
- setWindowTitle(windowCaption());
-}
-
-bool CWriteWindow::queryClose() {
- //save the text if it has changed
- if (m_writeDisplay->isModified()) {
- switch (util::showQuestion( this, tr("Save Text?"), tr("Save text before closing?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes) ) {
- case QMessageBox::Yes: //save and close
- saveCurrentText();
- m_writeDisplay->setModified( false );
- return true;
- case QMessageBox::No: //don't save and close
- return true;
- default: // cancel, don't close
- return false;
- }
- }
- return true;
-}
-
-void CWriteWindow::beforeKeyChange() {
- Q_ASSERT(displayWidget());
- Q_ASSERT(keyChooser());
- if (!isReady())
- return;
-
- // Get current key string for this window
- QString thisWindowsKey;
- CSwordKey* oldKey = key();
- if (oldKey == 0)
- return;
- thisWindowsKey = oldKey->key();
-
- //If the text changed and we'd do a lookup ask the user if the text should be saved
- if (modules().first() && ((CWriteDisplay*)displayWidget())->isModified()) {
-
- switch (util::showQuestion( this, tr("Save Text?"), tr("Save changed text?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) ) {
- case QMessageBox::Yes: { //save the changes
- saveCurrentText( thisWindowsKey );
- break;
- }
- default: {// set modified to false so it won't ask again
- ((CWriteDisplay*)displayWidget())->setModified(false);
- break;
- }
- }
- }
-}
-
-void CWriteWindow::saveCurrentText() {
- if (key()) {
- saveCurrentText(key()->key());
- }
-}
-
diff --git a/src/frontend/displaywindow/cwritewindow.h b/src/frontend/displaywindow/cwritewindow.h
deleted file mode 100644
index 3ff9d06..0000000
--- a/src/frontend/displaywindow/cwritewindow.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*********
-*
-* 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 CWRITEWINDOW_H
-#define CWRITEWINDOW_H
-
-#include "frontend/displaywindow/cdisplaywindow.h"
-
-
-class BtActionCollection;
-class CWriteDisplay;
-class QString;
-
-/** The base class for all write-only display windows.
- *
- * Inherits CDisplayWindow.
- *
- * Inherited by CPlainWriteWindow.
- *
- *@author The BibleTime team
- */
-class CWriteWindow : public CDisplayWindow {
- Q_OBJECT
- public:
- enum WriteWindowType {
- HTMLWindow = 1,
- PlainTextWindow = 2
- };
-
- /** Insert the keyboard accelerators of this window into the given actioncollection.*/
- static void insertKeyboardActions( BtActionCollection* const a );
-
- CWriteWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
- /**
- * Store the settings of this window in the given CProfileWindow object.
- */
- virtual void storeProfileSettings(Profile::CProfileWindow * const settings);
- /**
- * Load the settings the given CProfileWindow object into this window.
- */
- virtual void applyProfileSettings(Profile::CProfileWindow * const settings);
-
- /** Initializes the signal / slot connections of this display window.*/
- virtual void initConnections();
-
- /** Initializes the internel keyboard actions.*/
- virtual void initActions();
-
- public slots:
- /**
- * Look up the given key and display the text. In our case we offer to edit the text.
- */
- virtual void lookupSwordKey( CSwordKey* key );
-
-
- protected: // Protected methods
- /**
- * Set the displayWidget which is a subclass of QWebPage.
- */
- void setDisplayWidget( CDisplay* display );
-
- /** Returns the type of the write window.*/
- virtual CWriteWindow::WriteWindowType writeWindowType() = 0;
-
- /** Returns true if the window may be closed.*/
- virtual bool queryClose();
-
- /** Saves the text for the current key. Directly writes the changed text into the module. */
- virtual void saveCurrentText( const QString& key ) = 0;
-
- /** Called to add actions to mainWindow toolbars */
- virtual void setupMainWindowToolBars() = 0;
-
- protected slots:
- /** Save text to the module
- */
- void saveCurrentText();
- /**
- */
- virtual void beforeKeyChange();
-
- private:
- CWriteDisplay* m_writeDisplay;
-};
-
-#endif
diff --git a/src/frontend/keychooser/bthistory.cpp b/src/frontend/keychooser/bthistory.cpp
index 93651a5..22c9e69 100644
--- a/src/frontend/keychooser/bthistory.cpp
+++ b/src/frontend/keychooser/bthistory.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -44,8 +44,7 @@ void BTHistory::move(QAction* historyItem) {
//find the action in the list
m_index = m_historyList.indexOf(historyItem);
//move to the selected item in the list, it will be the current item
- QString newKey = m_historyList.at(m_index)->text();
- emit historyMoved(newKey); // signal to "outsiders"; key has been changed
+ emit historyMoved(m_historyList.at(m_index)->text()); // signal to "outsiders"; key has been changed
sendChangedSignal();
m_inHistoryFunction = false;
diff --git a/src/frontend/keychooser/bthistory.h b/src/frontend/keychooser/bthistory.h
index a92a25e..6c65aca 100644
--- a/src/frontend/keychooser/bthistory.h
+++ b/src/frontend/keychooser/bthistory.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -60,7 +62,7 @@ class BTHistory: public QObject {
/**
* Signal will be sent when the current point in history has moved
*/
- void historyMoved(QString& newKey);
+ void historyMoved(QString newKey);
private:
diff --git a/src/frontend/keychooser/cbookkeychooser.cpp b/src/frontend/keychooser/cbookkeychooser.cpp
index 1c7fccb..9255980 100644
--- a/src/frontend/keychooser/cbookkeychooser.cpp
+++ b/src/frontend/keychooser/cbookkeychooser.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,78 +13,76 @@
#include <QHBoxLayout>
#include <QList>
#include <QWidget>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordbookmoduleinfo.h"
#include "backend/keys/cswordtreekey.h"
#include "frontend/keychooser/bthistory.h"
-QMap<QObject*, int> boxes;
+#define ID_PROPERTY_NAME "CBookKeyChooser_ID"
-CBookKeyChooser::CBookKeyChooser(const QList<const CSwordModuleInfo*> &modules,
- BTHistory *historyPtr, CSwordKey *key,
- QWidget *parent)
- : CKeyChooser(modules, historyPtr, key, parent), m_layout(0)
+CBookKeyChooser::CBookKeyChooser(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * historyPtr,
+ CSwordKey * key,
+ QWidget * parent)
+ : CKeyChooser(modules, historyPtr, parent)
+ , m_layout(0)
{
-
setModules(modules, false);
- m_key = dynamic_cast<CSwordTreeKey*>(key);
- if (!m_modules.count()) {
+ m_key = dynamic_cast<CSwordTreeKey * >(key);
+ if (!m_modules.count())
m_key = 0;
- }
setModules(modules, true);
setKey(key);
adjustFont();
- connect(this, SIGNAL(keyChanged(CSwordKey*)), history(), SLOT(add(CSwordKey*)) );
+ connect(this, SIGNAL(keyChanged(CSwordKey *)),
+ history(), SLOT(add(CSwordKey *)));
}
-void CBookKeyChooser::setKey(CSwordKey* newKey) {
+void CBookKeyChooser::setKey(CSwordKey * newKey) {
setKey(newKey, true);
}
/** Sets a new key to this keychooser */
-void CBookKeyChooser::setKey(CSwordKey* newKey, const bool emitSignal) {
- if (m_key != newKey) { //set the internal key to the new one
+void CBookKeyChooser::setKey(CSwordKey * newKey, const bool emitSignal) {
+ if (m_key != newKey) // Set the internal key to the new one
m_key = dynamic_cast<CSwordTreeKey*>(newKey);
- }
- QString oldKey = m_key->key(); //string backup of key
+ QString oldKey(m_key->key());
- if (oldKey.isEmpty()) { //don't set keys equal to "/", always use a key which may have content
+ if (oldKey.isEmpty()) { // Don't set keys equal to "/", always use a key which may have content
m_key->firstChild();
oldKey = m_key->key();
}
- const int oldOffset = m_key->getOffset(); //backup key position
+ const int oldOffset = m_key->getOffset();
- QStringList siblings; //split up key
- if (m_key && !oldKey.isEmpty()) {
+ QStringList siblings; // Split up key
+ if (m_key && !oldKey.isEmpty())
siblings = oldKey.split('/', QString::SkipEmptyParts);
- }
int depth = 0;
- int index = 0;
m_key->root(); //start iteration at root node
- while ( m_key->firstChild() && (depth < siblings.count()) ) {
+ while (m_key->firstChild() && (depth < siblings.count())) {
QString key = m_key->key();
- index = (depth == 0) ? -1 : 0;
+ int index = (depth == 0) ? -1 : 0;
bool found = false;
do { //look for matching sibling
++index;
found = (m_key->getLocalNameUnicode() == siblings[depth]);
- }
- while (!found && m_key->nextSibling());
+ } while (!found && m_key->nextSibling());
- if (found)
+ if (found) {
key = m_key->key(); //found: change key to this level
- else
+ } else {
m_key->setKey(key); //not found: restore old key
+ }
setupCombo(key, depth, index);
@@ -98,41 +96,41 @@ void CBookKeyChooser::setKey(CSwordKey* newKey, const bool emitSignal) {
}
//clear the combos which were not filled
- for (; depth < m_modules.first()->depth(); ++depth) {
- CKeyChooserWidget* chooser = m_chooserWidgets.at(depth);
- if (chooser) chooser->reset(0, 0, false);
+ for (; depth < m_modules.first()->depth(); ++depth) {
+ CKeyChooserWidget * const chooser = m_chooserWidgets.at(depth);
+ if (chooser)
+ chooser->reset(0, 0, false);
}
if (oldKey.isEmpty()) {
m_key->root();
- }
- else {
+ } else {
//m_key->key(oldKey);
m_key->setOffset(oldOffset);
}
- if (emitSignal) emit keyChanged(m_key);
+ if (emitSignal)
+ emit keyChanged(m_key);
}
/** Returns the key of this kechooser. */
-CSwordKey* CBookKeyChooser::key() {
+CSwordKey * CBookKeyChooser::key() {
return m_key;
}
/** Sets another module to this keychooser */
-void CBookKeyChooser::setModules(const QList<const CSwordModuleInfo*> &modules,
+void CBookKeyChooser::setModules(const QList<const CSwordModuleInfo *> & modules,
bool refresh)
{
typedef CSwordBookModuleInfo CSBMI;
m_modules.clear();
// for (modules.first(); modules.current(); modules.next()) {
- Q_FOREACH(const CSwordModuleInfo *m, modules) {
+ Q_FOREACH(const CSwordModuleInfo * m, modules) {
if (m->type() == CSwordModuleInfo::GenericBook ) {
- const CSBMI *book = dynamic_cast<const CSBMI*>(m);
- if (book != 0) {
+ const CSBMI * const book = dynamic_cast<const CSBMI *>(m);
+ if (book != 0)
m_modules.append(book);
- }
}
}
@@ -149,45 +147,43 @@ void CBookKeyChooser::setModules(const QList<const CSwordModuleInfo*> &modules,
for (int i = 0; i < m_modules.first()->depth(); ++i) {
// Create an empty keychooser, don't handle next/prev signals
- CKeyChooserWidget* w = new CKeyChooserWidget(0, false, this);
- m_chooserWidgets.append( w );
+ CKeyChooserWidget * const w = new CKeyChooserWidget(0, this);
+ m_chooserWidgets.append(w);
//don't allow a too high width, try to keep as narrow as possible
//to aid users with smaller screen resolutions
int totalWidth = 200; //only 1 level
if (m_modules.first()->depth() > 1) {
- if (m_modules.first()->depth() > 3)
+ if (m_modules.first()->depth() > 3) {
totalWidth = 400; //4+ levels
- else
+ } else {
totalWidth = 300; //2-3 levels
+ }
}
int maxWidth = (int) ((float) totalWidth / (float) m_modules.first()->depth());
- w->comboBox()->setMaximumWidth(maxWidth);
- w->comboBox()->setCurrentIndex(0);
+ w->comboBox().setMaximumWidth(maxWidth);
+ w->comboBox().setCurrentIndex(0);
- connect(w, SIGNAL(changed(int)), SLOT(keyChooserChanged(int)));
+ connect(w, SIGNAL(changed(int)), SLOT(keyChooserChanged(int)));
connect(w, SIGNAL(focusOut(int)), SLOT(keyChooserChanged(int)));
m_layout->addWidget(w);
- boxes[w] = i;
-
+ w->setProperty(ID_PROPERTY_NAME, i+1);
w->show();
}
//set the tab order of the key chooser widgets
- CKeyChooserWidget* chooser = 0;
- CKeyChooserWidget* chooser_prev = 0;
+ CKeyChooserWidget * chooser = 0;
+ CKeyChooserWidget * chooser_prev = 0;
const int count = m_chooserWidgets.count();
- for (int i = 0; i < count; ++i) {
+ for (int i = 0; i < count; i++) {
chooser = m_chooserWidgets.at(i);
Q_ASSERT(chooser);
-
- if (chooser && chooser_prev) {
+ if (chooser_prev)
QWidget::setTabOrder(chooser_prev, chooser);
- }
chooser_prev = chooser;
}
@@ -201,21 +197,22 @@ void CBookKeyChooser::setModules(const QList<const CSwordModuleInfo*> &modules,
/** No descriptions */
void CBookKeyChooser::adjustFont() {
//Make sure the entries are displayed correctly.
- QListIterator<CKeyChooserWidget*> it(m_chooserWidgets);
- while (it.hasNext()) {
- it.next()->comboBox()->setFont( CBTConfig::get( m_modules.first()->language() ).second );
- }
+ QListIterator<CKeyChooserWidget *> it(m_chooserWidgets);
+ while (it.hasNext())
+ it.next()->comboBox().setFont(btConfig().getFontForLanguage(*m_modules.first()->language()).second);
}
/** Refreshes the content. */
void CBookKeyChooser::refreshContent() {
- if (m_key) {
- updateKey( m_key ); //refresh with current key
- }
+ if (m_key)
+ updateKey(m_key); // Refresh with current key
}
-void CBookKeyChooser::setupCombo(const QString key, const int depth, const int currentItem) {
- CKeyChooserWidget* chooserWidget = m_chooserWidgets.at(depth);
+void CBookKeyChooser::setupCombo(const QString & key,
+ const int depth,
+ const int currentItem)
+{
+ CKeyChooserWidget * const chooserWidget = m_chooserWidgets.at(depth);
CSwordTreeKey tmpKey(*m_key);
tmpKey.setKey(key);
@@ -223,32 +220,32 @@ void CBookKeyChooser::setupCombo(const QString key, const int depth, const int c
tmpKey.firstChild();
QStringList items;
- if (depth > 0) items << QString::null; //insert an empty item at the top
+ if (depth > 0)
+ items.append(QString::null); // Insert an empty item at the top
do {
- items << tmpKey.getLocalNameUnicode();
- }
- while (tmpKey.nextSibling());
+ items.append(tmpKey.getLocalNameUnicode());
+ } while (tmpKey.nextSibling());
- if (chooserWidget) chooserWidget->reset(items, currentItem, false);
+ if (chooserWidget)
+ chooserWidget->reset(items, currentItem, false);
}
/** A keychooser changed. Update and emit a signal if necessary. */
-void CBookKeyChooser::keyChooserChanged(int /*newIndex*/) {
- const int activeID = boxes[const_cast<QObject*>(sender())]; //no so good code!
-
+void CBookKeyChooser::keyChooserChanged(int newIndex) {
+ Q_UNUSED(newIndex);
QStringList items;
- CKeyChooserWidget* chooser;
- for (int i = 0; i < m_chooserWidgets.count(); ++i) {
- chooser = m_chooserWidgets.at(i);
- const QString currentText = (chooser && chooser->comboBox()) ? chooser->comboBox()->currentText() : QString::null;
-
- if (currentText.isEmpty() || i > activeID) {
+ const int max = std::min(m_chooserWidgets.count(),
+ sender()->property(ID_PROPERTY_NAME).toInt());
+ for (int i = 0; i < max; i++) {
+ CKeyChooserWidget * const chooser = m_chooserWidgets.at(i);
+ Q_ASSERT(chooser);
+ const QString currentText = chooser->comboBox().currentText();
+ if (currentText.isEmpty())
break;
- }
- items << currentText;
+ items.append(currentText);
}
QString newKey("/");
@@ -259,11 +256,11 @@ void CBookKeyChooser::keyChooserChanged(int /*newIndex*/) {
}
/** Updates the keychoosers for the given key but emit no signal. */
-void CBookKeyChooser::updateKey(CSwordKey* key) {
+void CBookKeyChooser::updateKey(CSwordKey * key) {
setKey(key, false);
}
-void CBookKeyChooser::setKey(QString& newKey) {
+void CBookKeyChooser::setKey(const QString & newKey) {
m_key->setKey(newKey);
setKey(m_key);
}
diff --git a/src/frontend/keychooser/cbookkeychooser.h b/src/frontend/keychooser/cbookkeychooser.h
index 3b32d48..c01e0e9 100644
--- a/src/frontend/keychooser/cbookkeychooser.h
+++ b/src/frontend/keychooser/cbookkeychooser.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,71 +22,79 @@ class CSwordBookModuleInfo;
class CSwordKey;
class CSwordTreeKey;
-namespace sword {
-class TreeKeyIdx;
-}
-
-/** The keychooser implementation for books.
- * @author The BibleTime team
- */
-class CBookKeyChooser : public CKeyChooser {
- Q_OBJECT
- public:
- CBookKeyChooser(const QList<const CSwordModuleInfo*> &modules,
- BTHistory *history, CSwordKey *key = 0,
- QWidget *parent = 0);
-
- /**
- Reimplemented from CKeyChooser.
- */
- virtual void refreshContent();
-
- /**
- * Sets another module to this keychooser
- */
- virtual void setModules(const QList<const CSwordModuleInfo*> &modules,
- bool refresh = false);
- /**
- * Returns the key of this keychooser
- */
- virtual CSwordKey* key();
- /**
- * Sets a new key to this keychooser
- */
- virtual void setKey(CSwordKey*);
- /**
- * Sets a new key to this keychooser
- */
- void setKey(CSwordKey*, const bool emitSignal);
-
-
- public slots: // Public slots
- /**
- * Updates the keychoosers for the given key but emit no signal.
- */
- void updateKey(CSwordKey*);
-
- protected: // Protected methods
- /**
- * Fills the combo given by depth with the items from the key having depth "depth".
- * The parent sibling is given by key.
- */
- void setupCombo(const QString key, const int depth, const int currentItem);
- /** No descriptions */
- virtual void adjustFont();
-
- protected slots:
- /**
- * A keychooser changed. Update and emit a signal if necessary.
- */
- void keyChooserChanged(int);
- virtual void setKey(QString& newKey);
-
- private:
- QList<CKeyChooserWidget*> m_chooserWidgets;
- QList<const CSwordBookModuleInfo*> m_modules;
- CSwordTreeKey *m_key;
- QHBoxLayout* m_layout;
+/**
+ \brief The keychooser implementation for books.
+*/
+class CBookKeyChooser: public CKeyChooser {
+
+ Q_OBJECT
+
+public:
+
+ CBookKeyChooser(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * history,
+ CSwordKey * key = 0,
+ QWidget * parent = 0);
+
+ /**
+ Reimplemented from CKeyChooser.
+ */
+ virtual void refreshContent();
+
+ /**
+ * Sets another module to this keychooser
+ */
+ virtual void setModules(const QList<const CSwordModuleInfo *> & modules,
+ bool refresh = false);
+ /**
+ * Returns the key of this keychooser
+ */
+ virtual CSwordKey * key();
+
+ /**
+ * Sets a new key to this keychooser
+ */
+ virtual void setKey(CSwordKey * key);
+
+ /**
+ * Sets a new key to this keychooser
+ */
+ void setKey(CSwordKey * key, const bool emitSignal);
+
+public slots: // Public slots
+
+ /**
+ * Updates the keychoosers for the given key but emit no signal.
+ */
+ void updateKey(CSwordKey * key);
+
+protected: /* Methods: */
+
+ /**
+ * Fills the combo given by depth with the items from the key having depth "depth".
+ * The parent sibling is given by key.
+ */
+ void setupCombo(const QString & key, const int depth, const int currentItem);
+
+ /** No descriptions */
+ virtual void adjustFont();
+
+protected slots:
+
+ /**
+ * A keychooser changed. Update and emit a signal if necessary.
+ */
+ void keyChooserChanged(int);
+
+ virtual void setKey(const QString & newKey);
+
+private: /* Fields: */
+
+ QList<CKeyChooserWidget *> m_chooserWidgets;
+ QList<const CSwordBookModuleInfo *> m_modules;
+ CSwordTreeKey * m_key;
+ QHBoxLayout * m_layout;
+
};
#endif
diff --git a/src/frontend/keychooser/cbooktreechooser.cpp b/src/frontend/keychooser/cbooktreechooser.cpp
index a41922e..96917d8 100644
--- a/src/frontend/keychooser/cbooktreechooser.cpp
+++ b/src/frontend/keychooser/cbooktreechooser.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,16 +13,19 @@
#include <QHBoxLayout>
#include <QTreeWidget>
#include <QTreeWidgetItem>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/drivers/cswordbookmoduleinfo.h"
#include "backend/keys/cswordtreekey.h"
#include "frontend/keychooser/bthistory.h"
-CBookTreeChooser::CBookTreeChooser(const QList<const CSwordModuleInfo*> &modules,
- BTHistory* historyPtr, CSwordKey *key, QWidget *parent)
- : CKeyChooser(modules, historyPtr, key, parent),
- m_key( dynamic_cast<CSwordTreeKey*>(key) ) {
+CBookTreeChooser::CBookTreeChooser(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * historyPtr,
+ CSwordKey * key,
+ QWidget * parent)
+ : CKeyChooser(modules, historyPtr, parent)
+ , m_key(dynamic_cast<CSwordTreeKey *>(key))
+{
setModules(modules, false);
@@ -109,8 +112,7 @@ void CBookTreeChooser::setModules(const QList<const CSwordModuleInfo*> &modules,
/** From ckeychooser. */
void CBookTreeChooser::adjustFont() {
//Make sure the entries are displayed correctly.
- m_treeView->setFont( CBTConfig::get(m_modules.first()->language()).second );
-
+ m_treeView->setFont(btConfig().getFontForLanguage(*m_modules.first()->language()).second);
}
@@ -183,7 +185,7 @@ void CBookTreeChooser::addKeyChildren(CSwordTreeKey* key, QTreeWidgetItem* item)
}
}
-void CBookTreeChooser::setKey(QString& newKey) {
+void CBookTreeChooser::setKey(const QString & newKey) {
m_key->setKey(newKey);
setKey(m_key);
}
diff --git a/src/frontend/keychooser/cbooktreechooser.h b/src/frontend/keychooser/cbooktreechooser.h
index 409038e..17b5825 100644
--- a/src/frontend/keychooser/cbooktreechooser.h
+++ b/src/frontend/keychooser/cbooktreechooser.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -79,7 +81,7 @@ class CBookTreeChooser : public CKeyChooser {
protected slots: // Protected slots
void itemActivated( QTreeWidgetItem* item );
- void setKey(QString& newKey);
+ void setKey(const QString & newKey);
private:
QList<const CSwordBookModuleInfo*> m_modules;
diff --git a/src/frontend/keychooser/ckeychooser.cpp b/src/frontend/keychooser/ckeychooser.cpp
index b46ee51..96b5638 100644
--- a/src/frontend/keychooser/ckeychooser.cpp
+++ b/src/frontend/keychooser/ckeychooser.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,48 +21,44 @@
#include "frontend/keychooser/versekeychooser/cbiblekeychooser.h"
-CKeyChooser::CKeyChooser(const QList<const CSwordModuleInfo*> &, BTHistory* historyPtr,
- CSwordKey *, QWidget *parent)
- : QWidget(parent),
- m_history(historyPtr) {
- bool ok = QObject::connect(history(), SIGNAL(historyMoved(QString&)), this, SLOT(setKey(QString&)));
+CKeyChooser::CKeyChooser(const QList<const CSwordModuleInfo *> &,
+ BTHistory * historyPtr,
+ QWidget * parent)
+ : QWidget(parent)
+ , m_history(historyPtr)
+{
+ bool ok = QObject::connect(history(), SIGNAL(historyMoved(QString)),
+ this, SLOT(setKey(const QString &)));
Q_ASSERT(ok);
}
-CKeyChooser* CKeyChooser::createInstance(
- const QList<const CSwordModuleInfo*> &modules, BTHistory *historyPtr,
- CSwordKey *key, QWidget *parent)
+CKeyChooser * CKeyChooser::createInstance(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * historyPtr,
+ CSwordKey * key,
+ QWidget * parent)
{
- if (!modules.count()) {
- /**
- \todo Verify and document that we need to return 0 here rather than
- fail with an assertion.
- */
- return 0;
- }
+ Q_ASSERT(!modules.empty());
+ Q_ASSERT(modules.first()->type() == CSwordModuleInfo::Commentary
+ || modules.first()->type() == CSwordModuleInfo::Bible
+ || modules.first()->type() == CSwordModuleInfo::Lexicon
+ || modules.first()->type() == CSwordModuleInfo::GenericBook);
+
+ switch (modules.first()->type()) {
- CSwordModuleInfo::ModuleType typeOfModules = modules.first()->type();
-/*
-#ifdef BT_DEBUG
- Q_FOREACH (const CSwordModuleInfo *module, modules) {
- Q_ASSERT(module->type() == typeOfModules);
- }
-#endif
-*/
- switch (typeOfModules) {
case CSwordModuleInfo::Commentary:
/* Fall thru - Bibles and commentaries use the same key chooser */
+
case CSwordModuleInfo::Bible:
return new CBibleKeyChooser(modules, historyPtr, key, parent);
+
case CSwordModuleInfo::Lexicon:
return new CLexiconKeyChooser(modules, historyPtr, key, parent);
+
case CSwordModuleInfo::GenericBook:
return new CBookKeyChooser(modules, historyPtr, key, parent);
+
default:
- /**
- \todo Verify and document that we need to return 0 here rather
- than fail with an assertion.
- */
- return 0;
+ abort();
+
}
}
diff --git a/src/frontend/keychooser/ckeychooser.h b/src/frontend/keychooser/ckeychooser.h
index 0ab9c5b..79706cc 100644
--- a/src/frontend/keychooser/ckeychooser.h
+++ b/src/frontend/keychooser/ckeychooser.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -23,83 +25,86 @@ class QAction;
* Do not use directly, create a KeyChooser with
* @ref #createInstance , this will create the proper one
* of the classes that inherit from @ref CKeyChooser
- *
- * @author The BibleTime team
- */
-class CKeyChooser : public QWidget {
- Q_OBJECT
- public:
-
- /**
- * Creates a proper Instance, either
- * @ref CLexiconKeyChooser or
- * @ref CBibleKeyChooser
- * @param info the @ref CModuleInfo to be represented by the KeyChooser
- * @param key if not NULL, the @ref CKey the KeyChooser should be set to
- * @param parent the parent of the widget to create
- */
- static CKeyChooser *createInstance(
- const QList<const CSwordModuleInfo*> &modules,
- BTHistory *history, CSwordKey *key, QWidget *parent);
-
-
- public slots:
- /**
- Sets the CKey
- \param key the key which the widget should be set to.
- */
- virtual void setKey(CSwordKey* key) = 0;
-
- /**
- Updates the CKey.
- \param key the key which the widget should be set to.
- */
- virtual void updateKey(CSwordKey *key) = 0;
-
- /**
- \returns the current CKey.
- */
- virtual CSwordKey *key() = 0;
-
- /**
- Sets the module of this keychooser and refreshes the comboboxes
- */
- virtual void setModules(const QList<const CSwordModuleInfo*> &modules,
- bool refresh = true) = 0;
-
- /**
- Refreshes the content of the different key chooser parts.
- */
- virtual void refreshContent() = 0;
-
- /**
- \returns the history object of this keychooser.
- */
- inline BTHistory *history() const { return m_history; }
-
- signals:
-
- /**
- * is emitted if the @ref CKey was changed by the user
- */
- void keyChanged(CSwordKey* newKey);
-
- protected:
-
- CKeyChooser(const QList<const CSwordModuleInfo*> &info,
- BTHistory *history, CSwordKey *key = 0,
- QWidget *parent = 0);
-
- /**
- Resets the appropriate font to for the modules.
- */
- virtual void adjustFont() = 0;
-
- protected slots:
- virtual void setKey(QString &newKey) = 0;
-
- private:
- BTHistory *m_history;
+ */
+class CKeyChooser: public QWidget {
+
+ Q_OBJECT
+
+public: /* Methods: */
+
+ /**
+ \returns the history object of this keychooser.
+ */
+ inline BTHistory * history() const { return m_history; }
+
+ /**
+ * Creates a proper Instance, either
+ * @ref CLexiconKeyChooser or
+ * @ref CBibleKeyChooser
+ * @param info the @ref CModuleInfo to be represented by the KeyChooser
+ * @param key if not NULL, the @ref CKey the KeyChooser should be set to
+ * @param parent the parent of the widget to create
+ */
+ static CKeyChooser * createInstance(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * history,
+ CSwordKey * key,
+ QWidget * parent);
+
+public slots:
+
+ /**
+ Sets the CKey
+ \param key the key which the widget should be set to.
+ */
+ virtual void setKey(CSwordKey * key) = 0;
+
+ /**
+ Updates the CKey.
+ \param key the key which the widget should be set to.
+ */
+ virtual void updateKey(CSwordKey * key) = 0;
+
+ /**
+ \returns the current CKey.
+ */
+ virtual CSwordKey * key() = 0;
+
+ /**
+ Sets the module of this keychooser and refreshes the comboboxes
+ */
+ virtual void setModules(const QList<const CSwordModuleInfo *> & modules,
+ bool refresh = true) = 0;
+
+ /**
+ Refreshes the content of the different key chooser parts.
+ */
+ virtual void refreshContent() = 0;
+
+signals:
+
+ /**
+ * is emitted if the @ref CKey was changed by the user
+ */
+ void keyChanged(CSwordKey * newKey);
+
+protected: /* Methods: */
+
+ CKeyChooser(const QList<const CSwordModuleInfo *> & info,
+ BTHistory * history,
+ QWidget * parent = 0);
+
+ /**
+ Resets the appropriate font to for the modules.
+ */
+ virtual void adjustFont() = 0;
+
+protected slots:
+
+ virtual void setKey(const QString & newKey) = 0;
+
+private: /* Fields: */
+
+ BTHistory * const m_history;
};
diff --git a/src/frontend/keychooser/ckeychooserwidget.cpp b/src/frontend/keychooser/ckeychooserwidget.cpp
index 36fc05b..ea3421e 100644
--- a/src/frontend/keychooser/ckeychooserwidget.cpp
+++ b/src/frontend/keychooser/ckeychooserwidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,58 +19,60 @@
class BtKeyLineEdit : public QLineEdit {
- public:
- BtKeyLineEdit(QWidget* parent)
- : QLineEdit(parent) {
- }
- protected:
- void focusInEvent(QFocusEvent* event) {
- Qt::FocusReason reason = event->reason();
- if (reason == Qt::OtherFocusReason) {
- selectAll();
- }
- QWidget::focusInEvent(event);
- }
-};
+public: /* Methods: */
+
+ BtKeyLineEdit(QWidget * parent)
+ : QLineEdit(parent) {}
+
+protected: /* Methods: */
+
+ virtual void focusInEvent(QFocusEvent * event) {
+ const Qt::FocusReason reason = event->reason();
+ if (reason == Qt::OtherFocusReason)
+ selectAll();
+ QWidget::focusInEvent(event);
+ }
+
+};
-CKCComboBox::CKCComboBox()
- : QComboBox() {
+CKCComboBox::CKCComboBox(QWidget * parent)
+ : QComboBox(parent)
+{
setFocusPolicy(Qt::WheelFocus);
setLineEdit(new BtKeyLineEdit(this));
- if (lineEdit()) {
- installEventFilter( lineEdit() );
- }
+ if (lineEdit())
+ installEventFilter(lineEdit());
}
-/** Reimplementation. */
-bool CKCComboBox::eventFilter( QObject *o, QEvent *e ) {
+bool CKCComboBox::eventFilter(QObject * o, QEvent * e) {
if (e->type() == QEvent::FocusOut) {
- QFocusEvent* f = static_cast<QFocusEvent*>(e);
+ QFocusEvent * const f = static_cast<QFocusEvent *>(e);
if (o == lineEdit() && f->reason() == Qt::TabFocusReason) {
int index = findText(currentText());
- if (index == -1) {
- index = 0;// return 0 if not found
- }
- setCurrentIndex( index );
- emit focusOut( index );
-
+ if (index == -1)
+ index = 0; // return 0 if not found
+ setCurrentIndex(index);
+ emit focusOut(index);
return false;
}
- else if (f->reason() == Qt::PopupFocusReason) {
+
+ if (f->reason() == Qt::PopupFocusReason)
return false;
- }
- else if (f->reason() == Qt::ActiveWindowFocusReason) {
+
+ if (f->reason() == Qt::ActiveWindowFocusReason) {
emit activated(currentText());
return false;
}
- else if (f->reason() == Qt::MouseFocusReason) {
+
+ if (f->reason() == Qt::MouseFocusReason) {
emit activated(currentText());
return false;
}
- else if (o == this) {
+
+ if (o == this) {
emit activated(currentText());
return false;
}
@@ -80,8 +82,8 @@ bool CKCComboBox::eventFilter( QObject *o, QEvent *e ) {
}
/** Scrolls in the list if the wheel of the mouse was used. */
-void CKCComboBox::wheelEvent( QWheelEvent* e ) {
- return QComboBox::wheelEvent(e);
+void CKCComboBox::wheelEvent(QWheelEvent * e) {
+ return QComboBox::wheelEvent(e); /// \bug rest method won't get executed.
const signed int change = (int)((float)e->delta() / (float)120);
int current = currentIndex();
@@ -89,18 +91,17 @@ void CKCComboBox::wheelEvent( QWheelEvent* e ) {
if ((current + change >= 0) && (current + change < count()) ) {
setCurrentIndex(current + change);
e->accept();
- emit activated( currentIndex() );
- }
- else {
+ emit activated(currentIndex());
+ } else {
e->ignore();
}
}
//**********************************************************************************/
-CKeyChooserWidget::CKeyChooserWidget(int count, const bool useNextPrevSignals, QWidget *parent ) : QWidget(parent) {
- m_useNextPrevSignals = useNextPrevSignals;
-
+CKeyChooserWidget::CKeyChooserWidget(int count, QWidget * parent)
+ : QWidget(parent)
+{
for (int index = 1; index <= count; index++) {
m_list.append( QString::number(index) );
}
@@ -108,15 +109,11 @@ CKeyChooserWidget::CKeyChooserWidget(int count, const bool useNextPrevSignals,
reset(m_list, 0, false);
}
-CKeyChooserWidget::CKeyChooserWidget(QStringList *list, const bool useNextPrevSignals, QWidget *parent ) : QWidget(parent) {
- m_useNextPrevSignals = useNextPrevSignals;
-
- if (list) {
- m_list = *list; //deep copy the items of list
- }
- else {
- m_list.clear();
- }
+CKeyChooserWidget::CKeyChooserWidget(QStringList * list, QWidget * parent )
+ : QWidget(parent)
+{
+ if (list)
+ m_list = *list;
init();
reset(m_list, 0, false);
@@ -129,14 +126,13 @@ void CKeyChooserWidget::reset(const int count, int index, bool do_emit) {
// return;
m_list.clear();
- for (int i = 1; i <= count; i++) { /// \todo CHECK
- m_list.append( QString::number(i) );
- }
+ for (int i = 1; i <= count; i++) /// \todo CHECK
+ m_list.append(QString::number(i));
reset(&m_list, index, do_emit);
}
-void CKeyChooserWidget::reset(const QStringList &list, int index, bool do_emit) {
+void CKeyChooserWidget::reset(const QStringList & list, int index, bool do_emit) {
//This prevents the widget from resetting during application load, which
//produces undesirable behavior.
//if (!updatesEnabled())
@@ -147,37 +143,34 @@ void CKeyChooserWidget::reset(const QStringList &list, int index, bool do_emit)
}
-void CKeyChooserWidget::reset(const QStringList *list, int index, bool do_emit) {
+void CKeyChooserWidget::reset(const QStringList * list, int index, bool do_emit) {
//if (isResetting || !updatesEnabled())
- if (isResetting)
+ if (m_isResetting)
return;
// qWarning("starting insert");
- isResetting = true;
+ m_isResetting = true;
- oldKey = QString::null;
+ m_oldKey = QString::null;
// m_comboBox->setUpdatesEnabled(false);
//DON'T REMOVE THE HIDE: Otherwise QComboBox's sizeHint() function won't work properly
m_comboBox->hide();
m_comboBox->clear();
- if (list) {
+ if (list)
m_comboBox->insertItems(-1, *list);
- }
- if (!list || (list && !list->count())) { //nothing in the combobox
+ if (!list || (list && !list->count())) { // nothing in the combobox
setEnabled(false);
- }
- else if (!isEnabled()) { //was disabled
+ } else if (!isEnabled()) { // was disabled
setEnabled(true);
}
- if (list->count()) {
+ if (list->count())
m_comboBox->setCurrentIndex(index);
- }
- if (do_emit) {
+
+ if (do_emit)
emit changed(m_comboBox->currentIndex());
- }
m_comboBox->sizeHint(); //without this function call the combo box won't be properly sized!
//DON'T REMOVE OR MOVE THE show()! Otherwise QComboBox's sizeHint() function won't work properly!
@@ -186,56 +179,56 @@ void CKeyChooserWidget::reset(const QStringList *list, int index, bool do_emit)
// m_comboBox->setFont( m_comboBox->font() );
// m_comboBox->setUpdatesEnabled(true);
- isResetting = false;
+ m_isResetting = false;
// qWarning("inserted");
}
/** Initializes this widget. We need this function because we have more than one constructor. */
void CKeyChooserWidget::init() {
- oldKey = QString::null;
+ m_oldKey = QString::null;
setFocusPolicy(Qt::WheelFocus);
- m_comboBox = new CKCComboBox();
+ m_comboBox = new CKCComboBox(this);
setFocusProxy(m_comboBox);
- m_comboBox->setAutoCompletion( true );
+ m_comboBox->setAutoCompletion(true);
m_comboBox->setEditable(true);
m_comboBox->setInsertPolicy(QComboBox::NoInsert);
m_comboBox->setFocusPolicy(Qt::WheelFocus);
- m_mainLayout = new QHBoxLayout( this );
+ m_mainLayout = new QHBoxLayout(this);
m_mainLayout->setSpacing(0);
m_mainLayout->setContentsMargins(0, 0, 0, 0);
m_mainLayout->addWidget(m_comboBox);
m_scroller = new CScrollerWidgetSet(this);
- m_mainLayout->addWidget( m_scroller );
+ m_mainLayout->addWidget(m_scroller);
m_mainLayout->addSpacing(0);
setTabOrder(m_comboBox, 0);
setFocusProxy(m_comboBox);
- connect(m_scroller, SIGNAL(scroller_pressed()), SLOT(lock()));
+ connect(m_scroller, SIGNAL(scroller_pressed()), SLOT(lock()));
connect(m_scroller, SIGNAL(scroller_released()), SLOT(unlock()));
- connect(m_scroller, SIGNAL(change(int)), SLOT(changeCombo(int)) );
-
- connect(m_comboBox, SIGNAL(activated(int)), SLOT(slotComboChanged(int)));
+ connect(m_scroller, SIGNAL(change(int)), SLOT(changeCombo(int)));
+ connect(m_comboBox, SIGNAL(activated(int)), SLOT(slotComboChanged(int)));
// connect(m_comboBox, SIGNAL(activated(const QString&)), SLOT(slotReturnPressed(const QString&)));
- connect(m_comboBox->lineEdit(), SIGNAL(returnPressed()), SLOT(slotReturnPressed()));
+ connect(m_comboBox->lineEdit(), SIGNAL(returnPressed()),
+ SLOT(slotReturnPressed()));
connect(m_comboBox, SIGNAL(focusOut(int)), SIGNAL(focusOut(int)));
updatelock = false;
- isResetting = false;
+ m_isResetting = false;
}
/** Is called when the return key was presed in the combobox. */
-void CKeyChooserWidget::slotReturnPressed( /*const QString& text*/) {
- Q_ASSERT(comboBox()->lineEdit());
+void CKeyChooserWidget::slotReturnPressed() {
+ Q_ASSERT(m_comboBox->lineEdit());
- QString text = comboBox()->lineEdit()->text();
- for (int index = 0; index < comboBox()->count(); ++index) {
- if (comboBox()->itemText(index) == text) {
+ const QString text(m_comboBox->lineEdit()->text());
+ for (int index = 0; index < m_comboBox->count(); ++index) {
+ if (m_comboBox->itemText(index) == text) {
// emit changed(index);
emit focusOut(index); // a workaround because focusOut is not checked, the slot connected to changed to check
break;
@@ -245,71 +238,74 @@ void CKeyChooserWidget::slotReturnPressed( /*const QString& text*/) {
/** Is called when the current item of the combo box was changed. */
void CKeyChooserWidget::slotComboChanged(int index) {
- if (!updatesEnabled()) {
+ if (!updatesEnabled())
return;
- }
setUpdatesEnabled(false);
- const QString key = comboBox()->itemText( index );
- if (oldKey.isNull() || (oldKey != key)) {
+ const QString key(m_comboBox->itemText(index));
+ if (m_oldKey.isNull() || (m_oldKey != key))
emit changed(index);
- }
- oldKey = key;
+ m_oldKey = key;
setUpdatesEnabled(true);
}
/** Sets the tooltips for the given entries using the parameters as text. */
-void CKeyChooserWidget::setToolTips( const QString comboTip, const QString nextEntryTip, const QString scrollButtonTip, const QString previousEntryTip) {
- comboBox()->setToolTip(comboTip);
+void CKeyChooserWidget::setToolTips(const QString & comboTip,
+ const QString & nextEntryTip,
+ const QString & scrollButtonTip,
+ const QString & previousEntryTip)
+{
+ m_comboBox->setToolTip(comboTip);
m_scroller->setToolTips(nextEntryTip, scrollButtonTip, previousEntryTip);
}
/** Sets the current item to the one with the given text */
-bool CKeyChooserWidget::setItem( const QString item ) {
+bool CKeyChooserWidget::setItem(const QString & item) {
bool ret = false;
- const int count = comboBox()->count();
+ const int count = m_comboBox->count();
for (int i = 0; i < count; ++i) {
- if (comboBox()->itemText(i) == item) {
- comboBox()->setCurrentIndex(i);
+ if (m_comboBox->itemText(i) == item) {
+ m_comboBox->setCurrentIndex(i);
ret = true;
break;
}
}
if (!ret)
- comboBox()->setCurrentIndex(-1);
+ m_comboBox->setCurrentIndex(-1);
return ret;
}
/* Handlers for the various scroller widgetset. */
void CKeyChooserWidget::lock() {
updatelock = true;
- comboBox()->setEditable(false);
- oldKey = comboBox()->currentText();
+ m_comboBox->setEditable(false);
+ m_oldKey = m_comboBox->currentText();
}
void CKeyChooserWidget::unlock() {
updatelock = false;
- comboBox()->setEditable(true);
- comboBox()->setEditText(comboBox()->itemText(comboBox()->currentIndex()));
- if (comboBox()->currentText() != oldKey) {
- emit changed(comboBox()->currentIndex());
- }
+ m_comboBox->setEditable(true);
+ m_comboBox->setEditText(m_comboBox->itemText(m_comboBox->currentIndex()));
+ if (m_comboBox->currentText() != m_oldKey)
+ emit changed(m_comboBox->currentIndex());
}
void CKeyChooserWidget::changeCombo(int n) {
- const int old_index = comboBox()->currentIndex();
+ const int old_index = m_comboBox->currentIndex();
int new_index = old_index + n;
//index of highest Item
- const int max = comboBox()->count() - 1;
- if (new_index > max) new_index = max;
- if (new_index < 0) new_index = 0;
+ const int max = m_comboBox->count() - 1;
+ if (new_index > max)
+ new_index = max;
+ if (new_index < 0)
+ new_index = 0;
if (new_index != old_index) {
- comboBox()->setCurrentIndex(new_index);
+ m_comboBox->setCurrentIndex(new_index);
if (!updatelock)
emit changed(new_index);
}
diff --git a/src/frontend/keychooser/ckeychooserwidget.h b/src/frontend/keychooser/ckeychooserwidget.h
index 3121af8..a1fd31d 100644
--- a/src/frontend/keychooser/ckeychooserwidget.h
+++ b/src/frontend/keychooser/ckeychooserwidget.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,7 +14,6 @@
#include <QComboBox>
-#include <QString>
#include <QStringList>
@@ -28,30 +29,27 @@ class QEvent;
* We use this class to control the focus move in the combobox
* This class is used in the key chooser widgets
*/
-class CKCComboBox : public QComboBox {
- Q_OBJECT
- public:
- CKCComboBox();
- /**
- * Returns the size this widget would like to have.
- */
- // virtual QSize sizeHint() const;
-
- protected:
- /**
- * Reimplementation.
- */
- virtual bool eventFilter( QObject *o, QEvent *e );
- /**
- * Scrolls in the list if the wheel of the mouse was used.
- */
- virtual void wheelEvent( QWheelEvent* e);
-
- signals:
- /**
- * Emitted when the user moves the focus away from the combo by pressing tab
- */
- void focusOut(int itemIndex);
+class CKCComboBox: public QComboBox {
+
+ Q_OBJECT
+
+public: /* Methods: */
+
+ CKCComboBox(QWidget * parent = 0);
+
+protected: /* Methods: */
+
+ virtual bool eventFilter(QObject * o, QEvent * e);
+
+ virtual void wheelEvent(QWheelEvent * e);
+
+signals:
+
+ /**
+ * Emitted when the user moves the focus away from the combo by pressing tab
+ */
+ void focusOut(int itemIndex);
+
};
/**
@@ -61,114 +59,122 @@ class CKCComboBox : public QComboBox {
*
* @author The BibleTime team
*/
-class CKeyChooserWidget : public QWidget {
- Q_OBJECT
-
- public:
- CKeyChooserWidget(QStringList *list = 0,
- const bool useNextPrevSignals = false,
- QWidget *parent = 0);
-
- CKeyChooserWidget(int count = 0, const bool useNextPrevSignals = false,
- QWidget *parent = 0);
-
- /**
- * This function does clear the combobox, then fill in
- * the StringList, set the ComboBox' current item to index
- * and if do_emit is true, it will emit @ref #changed
- *
- * @param list the stringlist to be inserted
- * @param index the index that the combobox is to jump to
- * @param do_emit should we emit @ref #changed(int)
- */
- void reset(const int count, int index, bool do_emit);
- void reset(const QStringList &list, int index, bool do_emit);
- void reset(const QStringList *list, int index, bool do_emit);
-
- /**
- * Initializes this widget. We need this function because
- * we have more than one constructor.
- */
- virtual void init();
- /**
- *
- */
- // virtual void adjustSize();
- /**
- * Sets the tooltips for the given entries using the parameters as text.
- */
- void setToolTips( const QString comboTip, const QString nextEntry, const QString scrollButton, const QString previousEntry);
- /**
- * Sets the current item to the one with the given text
- */
- bool setItem( const QString item);
- /**
- * Return the combobox of this key chooser widget.
- */
- QComboBox* comboBox() {
- return m_comboBox;
- };
-
- public slots:
- /**
- * is called to lock the combobox
- */
- void lock()
- ;
- /**
- * is called to unlock the combobox
- */
- void unlock();
- /**
- * is called to move the combobox to a certain index
- * @param index the index to jump to
- */
- void changeCombo(int index);
- void slotComboChanged(int index);
-
- signals:
- /**
- * Is emitted if the widget changed, but
- * only if it is not locked or being reset
- *
- * @param the current ComboBox index
- */
- void changed(int index);
- /**
- * Is emitted if the widget was left with a focus out event.
- * @param index The new index of the ComboBox
- */
- void focusOut(int index);
-
- protected:
- /**
- * indicates wheter we are resetting at the moment
- */
- bool isResetting;
- /**
- *
- */
- QString oldKey;
-
- protected slots: // Protected slots
- /**
- * Is called when the return key was presed in the combobox.
- */
- void slotReturnPressed( /*const QString&*/ );
-
-
- private:
-
- QStringList m_list;
- bool m_useNextPrevSignals;
- bool updatelock;
-
- /**
- * Members should never be public!!
- */
- CKCComboBox* m_comboBox;
- QHBoxLayout *m_mainLayout;
- CScrollerWidgetSet * m_scroller;
+class CKeyChooserWidget: public QWidget {
+
+ Q_OBJECT
+
+public: /* Methods: */
+
+ CKeyChooserWidget(QStringList * list = 0,
+ QWidget * parent = 0);
+
+ CKeyChooserWidget(int count = 0,
+ QWidget * parent = 0);
+
+ /**
+ * This function does clear the combobox, then fill in
+ * the StringList, set the ComboBox' current item to index
+ * and if do_emit is true, it will emit @ref #changed
+ *
+ * @param list the stringlist to be inserted
+ * @param index the index that the combobox is to jump to
+ * @param do_emit should we emit @ref #changed(int)
+ */
+ void reset(const int count, int index, bool do_emit);
+
+ void reset(const QStringList & list, int index, bool do_emit);
+
+ void reset(const QStringList * list, int index, bool do_emit);
+
+ /**
+ * Initializes this widget. We need this function because
+ * we have more than one constructor.
+ */
+ virtual void init();
+
+ /**
+ * Sets the tooltips for the given entries using the parameters as text.
+ */
+ void setToolTips(const QString & comboTip,
+ const QString & nextEntry,
+ const QString & scrollButton,
+ const QString & previousEntry);
+
+ /**
+ * Sets the current item to the one with the given text
+ */
+ bool setItem(const QString & item);
+
+ /**
+ * Return the combobox of this key chooser widget.
+ */
+ QComboBox & comboBox() const {
+ Q_ASSERT(m_comboBox);
+ return *m_comboBox;
+ }
+
+public slots:
+
+ /**
+ * is called to lock the combobox
+ */
+ void lock();
+
+ /**
+ * is called to unlock the combobox
+ */
+ void unlock();
+
+ /**
+ * is called to move the combobox to a certain index
+ * @param index the index to jump to
+ */
+ void changeCombo(int index);
+
+ void slotComboChanged(int index);
+
+signals:
+
+ /**
+ * Is emitted if the widget changed, but
+ * only if it is not locked or being reset
+ *
+ * @param the current ComboBox index
+ */
+ void changed(int index);
+
+ /**
+ * Is emitted if the widget was left with a focus out event.
+ * @param index The new index of the ComboBox
+ */
+ void focusOut(int index);
+
+protected slots:
+
+ /**
+ * Is called when the return key was presed in the combobox.
+ */
+ void slotReturnPressed();
+
+private: /* Fields: */
+
+ QStringList m_list;
+ bool updatelock;
+
+ /**
+ * Members should never be public!!
+ */
+ CKCComboBox * m_comboBox;
+ QHBoxLayout * m_mainLayout;
+ CScrollerWidgetSet * m_scroller;
+
+ /**
+ * indicates wheter we are resetting at the moment
+ */
+ bool m_isResetting;
+
+ QString m_oldKey;
+
};
#endif
diff --git a/src/frontend/keychooser/clexiconkeychooser.cpp b/src/frontend/keychooser/clexiconkeychooser.cpp
index 42fb4e8..2c6545a 100644
--- a/src/frontend/keychooser/clexiconkeychooser.cpp
+++ b/src/frontend/keychooser/clexiconkeychooser.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,11 +19,12 @@
#include "util/cresmgr.h"
-CLexiconKeyChooser::CLexiconKeyChooser(
- const QList<const CSwordModuleInfo*> &modules,
- BTHistory *historyPtr, CSwordKey *key, QWidget *parent)
- : CKeyChooser(modules, historyPtr, key, parent),
- m_key(dynamic_cast<CSwordLDKey*>(key))
+CLexiconKeyChooser::CLexiconKeyChooser(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * historyPtr,
+ CSwordKey * key,
+ QWidget * parent)
+ : CKeyChooser(modules, historyPtr, parent)
+ , m_key(dynamic_cast<CSwordLDKey *>(key))
{
setModules(modules, false);
@@ -34,12 +35,12 @@ CLexiconKeyChooser::CLexiconKeyChooser(
m_layout->setDirection(QBoxLayout::LeftToRight);
m_layout->setSizeConstraint(QLayout::SetNoConstraint);
- m_widget = new CKeyChooserWidget(0, false, this);
+ m_widget = new CKeyChooserWidget(0, this);
setFocusProxy(m_widget);
//don't allow a too high width, try to keep as narrow as possible
//to aid users with smaller screen resolutions
- m_widget->comboBox()->setMaximumWidth(200);
+ m_widget->comboBox().setMaximumWidth(200);
m_widget->setToolTips(
tr("Entries of the current work"),
@@ -70,8 +71,8 @@ void CLexiconKeyChooser::updateKey(CSwordKey* key) {
}
QString newKey = m_key->key();
- const int index = m_widget->comboBox()->findText(newKey);
- m_widget->comboBox()->setCurrentIndex(index);
+ const int index = m_widget->comboBox().findText(newKey);
+ m_widget->comboBox().setCurrentIndex(index);
}
void CLexiconKeyChooser::setKey(CSwordKey* key) {
@@ -87,7 +88,7 @@ void CLexiconKeyChooser::setKey(CSwordKey* key) {
void CLexiconKeyChooser::activated(int index) {
// qWarning("activated");
- const QString text = m_widget->comboBox()->itemText(index);
+ const QString text = m_widget->comboBox().itemText(index);
// To prevent from eternal loop, because activated() is emitted again
if (m_key && m_key->key() != text) {
@@ -169,7 +170,7 @@ void CLexiconKeyChooser::setModules(const QList<const CSwordModuleInfo*> &module
}
}
-void CLexiconKeyChooser::setKey(QString& newKey) {
+void CLexiconKeyChooser::setKey(const QString & newKey) {
m_key->setKey(newKey);
setKey(m_key);
}
diff --git a/src/frontend/keychooser/clexiconkeychooser.h b/src/frontend/keychooser/clexiconkeychooser.h
index e014448..5f14747 100644
--- a/src/frontend/keychooser/clexiconkeychooser.h
+++ b/src/frontend/keychooser/clexiconkeychooser.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -77,7 +79,7 @@ class CLexiconKeyChooser : public CKeyChooser {
virtual void updateKey(CSwordKey* key);
protected slots:
- virtual void setKey(QString& newKey);
+ virtual void setKey(const QString & newKey);
};
diff --git a/src/frontend/keychooser/cscrollbutton.cpp b/src/frontend/keychooser/cscrollbutton.cpp
index 9a92b5f..775d4db 100644
--- a/src/frontend/keychooser/cscrollbutton.cpp
+++ b/src/frontend/keychooser/cscrollbutton.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -24,10 +24,6 @@ CScrollButton::CScrollButton(QWidget *parent)
setCursor(Qt::SplitVCursor);
}
-CScrollButton::~CScrollButton() {
- // Intentionally empty
-}
-
void CScrollButton::mousePressEvent(QMouseEvent *e) {
if (m_isLocked) return;
if (e->button() != Qt::LeftButton) return;
diff --git a/src/frontend/keychooser/cscrollbutton.h b/src/frontend/keychooser/cscrollbutton.h
index 06d272d..2b3f662 100644
--- a/src/frontend/keychooser/cscrollbutton.h
+++ b/src/frontend/keychooser/cscrollbutton.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,7 +27,6 @@ class CScrollButton: public QToolButton {
Q_OBJECT
public:
CScrollButton(QWidget *parent = 0);
- virtual ~CScrollButton();
signals:
/**
diff --git a/src/frontend/keychooser/cscrollerwidgetset.cpp b/src/frontend/keychooser/cscrollerwidgetset.cpp
index 4ad8750..e169ae9 100644
--- a/src/frontend/keychooser/cscrollerwidgetset.cpp
+++ b/src/frontend/keychooser/cscrollerwidgetset.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,64 +16,69 @@
#include "frontend/keychooser/cscrollbutton.h"
-const unsigned int WIDTH = 16;
-const unsigned int ARROW_HEIGHT = 12;
-const unsigned int MOVER_HEIGHT = 6;
+#define WIDTH (static_cast<unsigned int>(16))
+#define ARROW_HEIGHT (static_cast<unsigned int>(12))
+#define MOVER_HEIGHT (static_cast<unsigned int>(6))
-CScrollerWidgetSet::CScrollerWidgetSet(QWidget *parent) : QWidget(parent) {
+
+CScrollerWidgetSet::CScrollerWidgetSet(QWidget * parent)
+ : QWidget(parent)
+{
m_layout = new QVBoxLayout(this);
m_layout->setSpacing(0);
m_layout->setContentsMargins(0, 0, 0, 0);
m_layout->setAlignment(this, Qt::AlignHCenter | Qt::AlignCenter);
- btn_up = new QToolButton(this);
- btn_up->setArrowType(Qt::UpArrow);
+ m_buttonUp = new QToolButton(this);
+ m_buttonUp->setArrowType(Qt::UpArrow);
- btn_up->setFixedSize(WIDTH, ARROW_HEIGHT);
- btn_up->setFocusPolicy(Qt::NoFocus);
- btn_up->setAutoRaise(true);
+ m_buttonUp->setFixedSize(WIDTH, ARROW_HEIGHT);
+ m_buttonUp->setFocusPolicy(Qt::NoFocus);
+ m_buttonUp->setAutoRaise(true);
- btn_fx = new CScrollButton(this);
- btn_fx->setFixedSize(WIDTH, MOVER_HEIGHT);
- btn_fx->setFocusPolicy(Qt::NoFocus);
+ m_scrollButton = new CScrollButton(this);
+ m_scrollButton->setFixedSize(WIDTH, MOVER_HEIGHT);
+ m_scrollButton->setFocusPolicy(Qt::NoFocus);
- btn_down = new QToolButton(this);
- btn_down->setArrowType(Qt::DownArrow);
- btn_down->setFixedSize(WIDTH, ARROW_HEIGHT);
- btn_down->setFocusPolicy(Qt::NoFocus);
- btn_down->setAutoRaise(true);
+ m_buttonDown = new QToolButton(this);
+ m_buttonDown->setArrowType(Qt::DownArrow);
+ m_buttonDown->setFixedSize(WIDTH, ARROW_HEIGHT);
+ m_buttonDown->setFocusPolicy(Qt::NoFocus);
+ m_buttonDown->setAutoRaise(true);
- m_layout->addWidget( btn_up, 0 );
- m_layout->addWidget( btn_fx, 0 );
- m_layout->addWidget( btn_down, 0 );
+ m_layout->addWidget(m_buttonUp, 0);
+ m_layout->addWidget(m_scrollButton, 0);
+ m_layout->addWidget(m_buttonDown, 0);
setMinimumWidth(WIDTH); // Kludge to add some spacing but seems to work.
- connect(btn_fx, SIGNAL(lock()), SLOT(slotLock()));
- connect(btn_fx, SIGNAL(unlock()), SLOT(slotUnlock()));
- connect(btn_fx, SIGNAL(change_requested(int)), SLOT(slotScroller(int)));
- connect(btn_up, SIGNAL(clicked()), SLOT(slotUpClick()));
- connect(btn_down, SIGNAL(clicked()), SLOT(slotDownClick()));
+ connect(m_scrollButton, SIGNAL(lock()), SLOT(slotLock()));
+ connect(m_scrollButton, SIGNAL(unlock()), SLOT(slotUnlock()));
+ connect(m_scrollButton, SIGNAL(change_requested(int)), SLOT(slotScroller(int)));
+ connect(m_buttonUp, SIGNAL(clicked()), SLOT(slotUpClick()));
+ connect(m_buttonDown, SIGNAL(clicked()), SLOT(slotDownClick()));
}
/** Sets the tooltips for the given entries using the parameters as text. */
-void CScrollerWidgetSet::setToolTips( const QString nextEntryTip, const QString scrollButtonTip, const QString previousEntryTip) {
- btn_fx->setToolTip(scrollButtonTip);
- btn_down->setToolTip(nextEntryTip);
- btn_up->setToolTip(previousEntryTip);
+void CScrollerWidgetSet::setToolTips(const QString & nextEntryTip,
+ const QString & scrollButtonTip,
+ const QString & previousEntryTip)
+{
+ m_scrollButton->setToolTip(scrollButtonTip);
+ m_buttonDown->setToolTip(nextEntryTip);
+ m_buttonUp->setToolTip(previousEntryTip);
}
-void CScrollerWidgetSet::wheelEvent( QWheelEvent* e ) {
+void CScrollerWidgetSet::wheelEvent(QWheelEvent * e) {
/**
* The problem is, that wheel events do everytime have the delta value 120
*/
- const int vchange = ((e->delta() > 0) ? (-1) : (1));
+ const int vchange = ((e->delta() > 0) ? -1 : 1);
- if (vchange != 0) {//do not emit a change with value 0
+ if (vchange != 0) { // Do not emit a change with value 0
emit change(vchange);
e->accept();
- }
- else {
+ } else {
e->ignore();
}
}
@@ -81,15 +86,19 @@ void CScrollerWidgetSet::wheelEvent( QWheelEvent* e ) {
void CScrollerWidgetSet::slotLock() {
emit scroller_pressed();
}
+
void CScrollerWidgetSet::slotUnlock() {
emit scroller_released();
}
+
void CScrollerWidgetSet::slotScroller(int n) {
emit change(n);
}
+
void CScrollerWidgetSet::slotUpClick() {
slotScroller(-1);
}
+
void CScrollerWidgetSet::slotDownClick() {
slotScroller(1);
}
diff --git a/src/frontend/keychooser/cscrollerwidgetset.h b/src/frontend/keychooser/cscrollerwidgetset.h
index f2ae643..2894928 100644
--- a/src/frontend/keychooser/cscrollerwidgetset.h
+++ b/src/frontend/keychooser/cscrollerwidgetset.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,51 +23,53 @@ class QVBoxLayout;
/**
* This class implements the Scroller Widget-set, which
* consists of two normal ref @QToolButton and a enhanced @ref CScrollButton
- *
- * @author The BibleTime team
- */
-class CScrollerWidgetSet : public QWidget {
- Q_OBJECT
-
- public:
- CScrollerWidgetSet(QWidget *parent = 0);
-
- /**
- * Sets the tooltips for the given entries using the parameters as text.
- */
- void setToolTips( const QString nextEntry, const QString scrollButton, const QString previousEntry);
-
- signals:
- /**
- * Is emitted to proceed to some other entry relative to the
- * current, indicated by the int value.
- * \param count offset to change to
- */
- void change(int count);
-
- /**
- * These emit when the scroll button is pressed or released
- */
- void scroller_pressed();
- void scroller_released();
-
- protected:
-
- virtual void wheelEvent( QWheelEvent* e );
-
- QToolButton* btn_up;
- QToolButton* btn_down;
- CScrollButton* btn_fx;
-
- protected slots:
- void slotLock();
- void slotUnlock();
- void slotUpClick();
- void slotDownClick();
- void slotScroller(int);
-
- private:
- QVBoxLayout *m_layout;
+ */
+class CScrollerWidgetSet: public QWidget {
+
+ Q_OBJECT
+
+public: /* Methods: */
+
+ CScrollerWidgetSet(QWidget * parent = 0);
+
+ /**
+ * Sets the tooltips for the given entries using the parameters as text.
+ */
+ void setToolTips(const QString & nextEntry,
+ const QString & scrollButton,
+ const QString & previousEntry);
+
+signals:
+
+ /**
+ * Is emitted to proceed to some other entry relative to the
+ * current, indicated by the int value.
+ * \param count offset to change to
+ */
+ void change(int count);
+
+ void scroller_pressed();
+
+ void scroller_released();
+
+protected: /* Methods: */
+
+ virtual void wheelEvent(QWheelEvent * e);
+
+protected slots:
+
+ void slotLock();
+ void slotUnlock();
+ void slotUpClick();
+ void slotDownClick();
+ void slotScroller(int);
+
+private: /* Fields: */
+
+ QVBoxLayout * m_layout;
+ QToolButton * m_buttonUp;
+ QToolButton * m_buttonDown;
+ CScrollButton * m_scrollButton;
};
diff --git a/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp
index 5feb371..2ac2574 100644
--- a/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp
+++ b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -21,11 +21,12 @@
#include <QStringList>
#include <QToolButton>
#include "backend/keys/cswordversekey.h"
+#include "bibletimeapp.h"
#include "frontend/keychooser/cscrollerwidgetset.h"
#include "frontend/keychooser/versekeychooser/btdropdownchooserbutton.h"
#include "util/btsignal.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
class BtLineEdit : public QLineEdit {
@@ -52,16 +53,13 @@ BtBibleKeyWidget::BtBibleKeyWidget(const CSwordBibleModuleInfo *mod,
{
Q_UNUSED(name);
- namespace DU = util::directory;
-
-
updatelock = false;
m_module = mod;
setFocusPolicy(Qt::WheelFocus);
QToolButton* clearRef = new QToolButton(this);
- clearRef->setIcon(DU::getIcon("edit_clear_locationbar"));
+ clearRef->setIcon(util::getIcon("edit_clear_locationbar"));
clearRef->setAutoRaise(true);
clearRef->setStyleSheet("QToolButton{margin:0px;}");
connect(clearRef, SIGNAL(clicked()), SLOT(slotClearRef()) );
@@ -138,7 +136,7 @@ BtBibleKeyWidget::BtBibleKeyWidget(const CSwordBibleModuleInfo *mod,
connect(m_verseScroller, SIGNAL(change(int)), SLOT(slotStepVerse(int)));
connect(m_verseScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
connect(m_verseScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
- bool ok = connect(m_key->signaler(), SIGNAL(changed()), this, SLOT(updateText()));
+ bool ok = connect(m_key->afterChangedSignaller(), SIGNAL(signal()), this, SLOT(updateText()));
Q_ASSERT(ok);
setKey(key); // The order of these two functions is important.
@@ -287,7 +285,7 @@ void BtBibleKeyWidget::slotChangeVerse(int n) {
emit beforeChange(m_key);
m_key->emitBeforeChanged();
m_key->setVerse(n);
- m_key->emitChanged();
+ m_key->emitAfterChanged();
setKey( m_key );
}
if (!updatelock) emit changed(m_key);
@@ -298,7 +296,7 @@ void BtBibleKeyWidget::slotChangeChapter(int n) {
emit beforeChange(m_key);
m_key->emitBeforeChanged();
m_key->setChapter(n);
- m_key->emitChanged();
+ m_key->emitAfterChanged();
setKey( m_key );
}
if (!updatelock)
@@ -310,7 +308,7 @@ void BtBibleKeyWidget::slotChangeBook(QString bookname) {
emit beforeChange(m_key);
m_key->emitBeforeChanged();
m_key->book( bookname );
- m_key->emitChanged();
+ m_key->emitAfterChanged();
setKey( m_key );
}
if (!updatelock)
diff --git a/src/frontend/keychooser/versekeychooser/btbiblekeywidget.h b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.h
index 644bc75..7d94c94 100644
--- a/src/frontend/keychooser/versekeychooser/btbiblekeywidget.h
+++ b/src/frontend/keychooser/versekeychooser/btbiblekeywidget.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
index 8030aaf..70f800a 100644
--- a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
+++ b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
index bdd56da..646b7ef 100644
--- a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
+++ b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp b/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp
index ac94299..9a8d35e 100644
--- a/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp
+++ b/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -25,13 +25,15 @@ BtVerseKeyMenu::BtVerseKeyMenu(QWidget* parent)
void BtVerseKeyMenu::startFirstClickDelayTimer() {
m_firstClickLock = true;
- killTimer(m_timerId);
+ if (m_timerId)
+ killTimer(m_timerId);
m_timerId = startTimer(300);
}
void BtVerseKeyMenu::timerEvent(QTimerEvent* e) {
if (e->timerId() == m_timerId) {
- killTimer(m_timerId);
+ if (m_timerId)
+ killTimer(m_timerId);
m_firstClickLock = false;
}
else {
diff --git a/src/frontend/keychooser/versekeychooser/btversekeymenu.h b/src/frontend/keychooser/versekeychooser/btversekeymenu.h
index 343277c..18caab5 100644
--- a/src/frontend/keychooser/versekeychooser/btversekeymenu.h
+++ b/src/frontend/keychooser/versekeychooser/btversekeymenu.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
index 358c9c4..e481020 100644
--- a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
+++ b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,11 +20,12 @@
#include "util/cresmgr.h"
-CBibleKeyChooser::CBibleKeyChooser(
- const QList<const CSwordModuleInfo*> &modules,
- BTHistory *historyPtr, CSwordKey *key, QWidget *parent)
- : CKeyChooser(modules, historyPtr, key, parent),
- m_key(dynamic_cast<CSwordVerseKey*>(key))
+CBibleKeyChooser::CBibleKeyChooser(const QList<const CSwordModuleInfo *> & modules,
+ BTHistory * historyPtr,
+ CSwordKey * key,
+ QWidget * parent)
+ : CKeyChooser(modules, historyPtr, parent)
+ , m_key(dynamic_cast<CSwordVerseKey *>(key))
{
typedef CSwordBibleModuleInfo CSBMI;
@@ -126,7 +127,7 @@ void CBibleKeyChooser::updateKey(CSwordKey* /*key*/) {
void CBibleKeyChooser::adjustFont() {}
-void CBibleKeyChooser::setKey(QString& newKey) {
+void CBibleKeyChooser::setKey(const QString & newKey) {
m_key->setKey(newKey);
setKey(m_key);
}
diff --git a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
index d2c5363..91ad265 100644
--- a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
+++ b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -70,10 +72,8 @@ class CBibleKeyChooser : public CKeyChooser {
void refreshContent();
protected slots:
- /**
- Reimplemented from CKeyChooser::setModules().
- */
- virtual void setKey(QString& newKey);
+
+ virtual void setKey(const QString & newKey);
private:
BtBibleKeyWidget* w_ref;
diff --git a/src/util/dialogutil.cpp b/src/frontend/messagedialog.cpp
index 661e314..f064f06 100644
--- a/src/util/dialogutil.cpp
+++ b/src/frontend/messagedialog.cpp
@@ -2,19 +2,20 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "util/dialogutil.h"
+#include "messagedialog.h"
-#include <QMessageBox>
+#include <QAction>
#include <QDialogButtonBox>
+#include <QMessageBox>
#include <QPushButton>
-#include <QDebug>
-namespace util {
+
+namespace message {
namespace {
@@ -46,6 +47,13 @@ QMessageBox::StandardButton bt_messageBox(QMessageBox::Icon icon,
} // anonymous namespace
+void setQActionCheckedNoTrigger(QAction * const action, const bool checked) {
+ Q_ASSERT(action);
+ const bool signalsWereBlocked = action->blockSignals(true);
+ action->setChecked(checked);
+ action->blockSignals(signalsWereBlocked);
+}
+
void prepareDialogBox(QDialogButtonBox *box) {
replaceText(box, QDialogButtonBox::Ok , QPushButton::tr("OK" , "Dialog Button"));
replaceText(box, QDialogButtonBox::Open , QPushButton::tr("Open" , "Dialog Button"));
@@ -80,4 +88,4 @@ QMessageBox::StandardButton showQuestion(QWidget * parent, const QString & title
return bt_messageBox(QMessageBox::Question, parent, title, text, buttons, defaultButton);
}
-} // namespace util
+} // namespace message
diff --git a/src/util/dialogutil.h b/src/frontend/messagedialog.h
index ea597cb..3f1a34b 100644
--- a/src/util/dialogutil.h
+++ b/src/frontend/messagedialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -12,20 +14,28 @@
#include <QMessageBox>
+class QAction;
class QDialogButtonBox;
-namespace util {
+namespace message {
-/*
-* Translate standard buttons in a QDialogButtonBox. Check that all used buttons are translated
-* in the implementation.
+/**
+ Change the state of a QAction without triggering their signals.
+ \param action The QAction instance to set the state for.
+ \param[in] checked The new state.
+*/
+void setQActionCheckedNoTrigger(QAction * const action, const bool checked = true);
+
+/**
+ Translates standard buttons in a QDialogButtonBox.
*/
void prepareDialogBox(QDialogButtonBox *box);
/*
-* Use util::showWarning() etc. instead of QMessageBox static functions.
-* QMessageBox button texts are not translated trustworthily.
+ Use util::showWarning() etc. instead of QMessageBox static functions.
+ QMessageBox button texts are not translated trustworthily.
*/
+
QMessageBox::StandardButton showWarning(QWidget * parent, const QString & title, const QString & text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
QMessageBox::StandardButton showCritical(QWidget * parent, const QString & title, const QString & text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
@@ -34,6 +44,6 @@ QMessageBox::StandardButton showInformation(QWidget * parent, const QString & ti
QMessageBox::StandardButton showQuestion(QWidget * parent, const QString & title, const QString & text, QMessageBox::StandardButtons buttons = QMessageBox::Ok, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
-} // namespace util
+} // namespace message
#endif
diff --git a/src/frontend/profile/cprofile.cpp b/src/frontend/profile/cprofile.cpp
deleted file mode 100644
index b1eca08..0000000
--- a/src/frontend/profile/cprofile.cpp
+++ /dev/null
@@ -1,380 +0,0 @@
-/*********
-*
-* 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/profile/cprofile.h"
-
-#include <QDomDocument>
-#include <QFile>
-#include <QString>
-#include <QTextStream>
-#include "util/directory.h"
-
-
-#define CURRENT_SYNTAX_VERSION 3
-
-namespace Profile {
-
-CProfile::CProfile( const QString& file, const QString& name )
- : m_name(name.isEmpty() ? QObject::tr("unknown") : name),
- m_filename(file),
- m_mdiArrangementMode((CMDIArea::MDIArrangementMode)0) { //0 is not a valid enum entry, means "unknown"
- namespace DU = util::directory;
-
- if (!m_filename.isEmpty() && name.isEmpty()) {
- loadBasics();
- }
- else if (m_filename.isEmpty() && !name.isEmpty()) {
- m_filename = name;
- m_filename.replace(QRegExp("\\s=#."), "_");
- m_filename = DU::getUserSessionsDir().absolutePath() + "/" + m_filename + ".xml";
- init(m_filename);
- }
- else {
- qWarning("CProfile: empty file name!");
- }
-}
-
-CProfile::~CProfile() {
- qDeleteAll(m_profileWindows); //there's no autodelete feature in qt4
- m_profileWindows.clear(); //delete all CProfileWindows objects
-}
-
-/** Loads the profile from the file given in the constructor. */
-QList<CProfileWindow*> CProfile::load() {
- QFile file(m_filename);
- if (!file.exists()) {
- //qWarning() << "Standard profile not found at filename " << m_filename;
- return QList<CProfileWindow*>();
- }
-
- QDomDocument doc;
- if (file.open(QIODevice::ReadOnly)) {
- QTextStream t( &file );
- t.setCodec("UTF-8");
- doc.setContent(t.readAll());
- file.close();
- }
-
- QDomElement document = doc.documentElement();
- if ( document.tagName() != "BibleTimeProfile" && document.tagName() != "BibleTime" ) { //BibleTime was used in syntax version 1.0
- qWarning("CProfile::load: Missing BibleTime doc");
- return m_profileWindows;
- }
- if (document.hasAttribute("name")) {
- m_name = document.attribute("name");
- }
-
- //load settings of the main window
- {
- // see if there's a section with the name MAINWINDOW
- QDomElement elem = document.firstChild().toElement();
- QDomElement mainWindow;
- while (!elem.isNull()) {
- if (elem.tagName() == "MAINWINDOW") {
- mainWindow = elem;
- break; //found the element
- }
- elem = elem.nextSibling().toElement();
- }
- if (!mainWindow.isNull()) { //was found
-
- QByteArray bgeometry;
- bgeometry += mainWindow.attribute("geometry");
- setMainwindowGeometry(QByteArray::fromHex(bgeometry));
-
- QByteArray bstate;
- bstate += mainWindow.attribute("state");
- setMainwindowState(QByteArray::fromHex(bstate));
-
- QDomElement mdi_element = mainWindow.namedItem("MDI").toElement();
- if (!mdi_element.isNull()) {
- if (mdi_element.hasAttribute("ArrangementMode")) {
- this->setMDIArrangementMode((CMDIArea::MDIArrangementMode)mdi_element.attribute("ArrangementMode").toInt());
- }
- }
- }
- }
-
- m_profileWindows.clear();
- QDomElement elem = document.firstChild().toElement();
- while (!elem.isNull()) {
- CProfileWindow* p = 0;
- if (elem.tagName() == "BIBLE") {
- p = new CProfileWindow(CSwordModuleInfo::Bible);
- }
- else if (elem.tagName() == "COMMENTARY") {
- p = new CProfileWindow(CSwordModuleInfo::Commentary);
- }
- else if (elem.tagName() == "LEXICON") {
- p = new CProfileWindow(CSwordModuleInfo::Lexicon);
- }
- else if (elem.tagName() == "BOOK") {
- p = new CProfileWindow(CSwordModuleInfo::GenericBook);
- }
-
- if (p) {
- m_profileWindows.append(p);
-
- if (elem.hasAttribute("windowSettings")) {
- p->windowSettings = elem.attribute("windowSettings").toInt();
- }
- if (elem.hasAttribute("writeWindowType")) {
- p->writeWindowType = elem.attribute("writeWindowType").toInt();
- }
- if (elem.hasAttribute("hasFocus")) {
- p->hasFocus = elem.attribute("hasFocus").toInt();
- }
-
- QRect rect;
-
- QDomElement object = elem.namedItem("GEOMETRY").toElement();
- if (!object.isNull()) {
- if (object.hasAttribute("x")) {
- rect.setX(object.attribute("x").toInt());
- }
- if (object.hasAttribute("y")) {
- rect.setY(object.attribute("y").toInt());
- }
- if (object.hasAttribute("width")) {
- rect.setWidth(object.attribute("width").toInt());
- }
- if (object.hasAttribute("height")) {
- rect.setHeight(object.attribute("height").toInt());
- }
- if (object.hasAttribute("isMaximized")) {
- p->maximized = object.attribute("isMaximized").toInt();
- }
- }
- p->windowGeometry = rect;
-
- object = elem.namedItem("MODULES").toElement();
- if (!object.isNull()) {
- if (object.hasAttribute("list")) {
- const QString sep = object.hasAttribute("separator") ? object.attribute("separator") : "|";
- p->modules = object.attribute("list").split(sep);
- }
- }
-
- object = elem.namedItem("KEY").toElement();
- if (!object.isNull()) {
- if (object.hasAttribute("name"))
- p->key = object.attribute("name");
- }
-
- object = elem.namedItem("SCROLLBARS").toElement();
- if (!object.isNull()) {
- p->scrollbarPosH = object.hasAttribute("horizontal")
- ? object.attribute("horizontal").toInt()
- : 0;
- p->scrollbarPosV = object.hasAttribute("vertical")
- ? object.attribute("vertical").toInt()
- : 0;
- }
- }
- elem = elem.nextSibling().toElement();
- }
-
- // Are any windows maximized?
- bool maximized = false;
- for (int i = 0; i < m_profileWindows.count(); i++) {
- if (m_profileWindows.at(i)->maximized)
- maximized = true;
- }
- // Set all windows the same for maximized
- for (int i = 0; i < m_profileWindows.count(); i++) {
- m_profileWindows.at(i)->maximized = maximized;
- }
-
- return m_profileWindows;
-}
-
-/** Saves the profile to the file given in the constructor. */
-bool CProfile::save(QList<CProfileWindow*> windows) {
- /** Save the settings using a XML file
- * Save the CProfileWindow objects using a XML file which name is in m_filename
- */
- bool ret = false;
- QDomDocument doc("DOC");
- doc.appendChild( doc.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) );
-
- QDomElement content = doc.createElement("BibleTimeProfile");
- content.setAttribute("syntaxVersion", CURRENT_SYNTAX_VERSION);
- content.setAttribute("name", m_name);
- doc.appendChild(content);
-
- //save mainwindow settings
- {
- QDomElement mainWindow = doc.createElement("MAINWINDOW");
-
- QString sgeometry = QString(getMainwindowGeometry().toHex());
- mainWindow.setAttribute("geometry", sgeometry);
-
- QString sstate = QString(getMainwindowState().toHex());
- mainWindow.setAttribute("state", sstate);
-
- QDomElement mdi = doc.createElement("MDI");
- mainWindow.appendChild(mdi);
- mdi.setAttribute("ArrangementMode", static_cast<int>(this->getMDIArrangementMode()));
-
- content.appendChild(mainWindow);
- }
-
- //for (CProfileWindow* p = windows.first(); p; p = windows.next()) {
- foreach(CProfileWindow* p, windows) {
- QDomElement window;
- switch (p->type) {
- case CSwordModuleInfo::Bible:
- window = doc.createElement("BIBLE");
- break;
- case CSwordModuleInfo::Commentary:
- window = doc.createElement("COMMENTARY");
- break;
- case CSwordModuleInfo::Lexicon:
- window = doc.createElement("LEXICON");
- break;
- case CSwordModuleInfo::GenericBook:
- window = doc.createElement("BOOK");
- break;
- default:
- break;
- }
- if (window.isNull())
- break;
- window.setAttribute("windowSettings", p->windowSettings);
- window.setAttribute("writeWindowType", p->writeWindowType);
- window.setAttribute("hasFocus", p->hasFocus);
-
- //save geomtery
- const QRect & r = p->windowGeometry;
- QDomElement geometry = doc.createElement("GEOMETRY");
- geometry.setAttribute("x", r.x());
- geometry.setAttribute("y", r.y());
- geometry.setAttribute("width", r.width());
- geometry.setAttribute("height", r.height());
- geometry.setAttribute("isMaximized", static_cast<int>(p->maximized));
- window.appendChild( geometry );
-
- QDomElement modules = doc.createElement("MODULES");
- modules.setAttribute("separator", "|");
- modules.setAttribute("list", p->modules.join("|"));
- window.appendChild( modules );
-
- QDomElement key = doc.createElement("KEY");
- key.setAttribute("name", p->key);
- window.appendChild( key );
-
- QDomElement scrollbars = doc.createElement("SCROLLBARS");
- scrollbars.setAttribute("horizontal", p->scrollbarPosH);
- scrollbars.setAttribute("vertical", p->scrollbarPosV);
- window.appendChild( scrollbars );
-
- content.appendChild( window );
- }
-
- QFile file(m_filename);
- if ( file.open(QIODevice::WriteOnly) ) {
- ret = true;
- QTextStream t( &file );
- t.setCodec("UTF-8");
- t << doc.toString();
- file.close();
- }
- else
- ret = false;
-
- return ret;
-}
-
-/** Saves the profile to the file given in the constructor. */
-bool CProfile::save() {
- return save(m_profileWindows);
-}
-
-/** Initializes the XML for the first time (use to create a new profile) */
-void CProfile::init(const QString file) {
- const QString oldFile = m_filename;
- m_filename = file;
- save(QList<CProfileWindow*>());
- m_filename = oldFile;
-}
-
-/** Changes the name of this profile. */
-void CProfile::setName( const QString& newName ) {
- m_name = newName;
- saveBasics(); //save chanegd name
-}
-
-/** Loads the basic settings requires for proper operation. */
-void CProfile::loadBasics() {
- QFile file(m_filename);
- if (!file.exists())
- return;
-
- QDomDocument doc;
- if (file.open(QIODevice::ReadOnly)) {
- QTextStream t( &file );
- t.setCodec("UTF-8");
- doc.setContent(t.readAll());
- file.close();
- }
- QDomElement document = doc.documentElement();
- if (document.hasAttribute("name"))
- m_name = document.attribute("name");
-}
-
-void CProfile::saveBasics() {
- QFile file(m_filename);
- if (!file.exists())
- return;
-
- QDomDocument doc;
- if (file.open(QIODevice::ReadOnly)) {
- QTextStream t(&file);
- t.setCodec("UTF-8");
- doc.setContent(t.readAll());
- file.close();
- }
-
- QDomElement document = doc.documentElement();
- document.setAttribute("name", m_name);
-
- if (file.open(QIODevice::WriteOnly)) {
- QTextStream t( &file );
- t.setCodec("UTF-8");
- t << doc.toString();
- file.close();
- }
-}
-
-void CProfile::setMDIArrangementMode(const CMDIArea::MDIArrangementMode newArrangementMode) {
- m_mdiArrangementMode = newArrangementMode;
-}
-
-CMDIArea::MDIArrangementMode CProfile::getMDIArrangementMode(void) {
- return m_mdiArrangementMode;
-}
-
-void CProfile::setMainwindowGeometry(const QByteArray& geometry) {
- m_mainwindowGeometry = geometry;
-}
-
-QByteArray CProfile::getMainwindowGeometry() {
- return m_mainwindowGeometry;
-}
-
-void CProfile::setMainwindowState(const QByteArray& state) {
- m_mainwindowState = state;
-}
-
-QByteArray CProfile::getMainwindowState() {
- return m_mainwindowState;
-}
-
-
-} //end of namespace Profile
diff --git a/src/frontend/profile/cprofile.h b/src/frontend/profile/cprofile.h
deleted file mode 100644
index 654160e..0000000
--- a/src/frontend/profile/cprofile.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*********
-*
-* 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 CPROFILE_H
-#define CPROFILE_H
-
-#include <QByteArray>
-#include <QList>
-#include "frontend/cmdiarea.h"
-#include "frontend/profile/cprofilewindow.h"
-
-
-namespace Profile {
-
-/** Manages one profile file. Provides functions to save and restore settings of the available display windows.
- * @author The BibleTime team
- */
-class CProfile {
- public:
- CProfile(const QString& fileName, const QString& name = QString::null);
- ~CProfile();
-
- /**
- * Saves the profile to the file given in the constructor.
- * @param windows The list of windows available in the profile.
- */
- bool save( QList<CProfileWindow*> windows );
- /**
- * Saves the profile to the file given in the constructor.
- */
- bool save();
- /**
- * Loads the profile from the file given in the constructor.
- * @return The list of profiled window which exist in the profile.
- */
- QList<CProfileWindow*> load();
- /**
- * Returns the name of this profile.
- */
- inline const QString &name() const {
- return m_name;
- }
- /**
- * Returns the filename used for this profile.
- */
- inline const QString &filename() const {
- return m_filename;
- }
- /**
- * Initializes the XML for the first time (use to create a new profile)
- */
- void init(const QString);
- /**
- * Chnages the name of this profile.
- */
- void setName( const QString& );
- /**
- * Returns true if the main window was maximized as the profile was saved.
- */
- bool maximized() const;
- /**
- * Set the parameter to true if the main window is maximized.
- */
- void setMaximized( const bool maximized );
- /**
- * Sets the MDI arrangement mode
- */
- void setMDIArrangementMode(const CMDIArea::MDIArrangementMode);
- /**
- * Returns mdi arrangement mode
- */
- CMDIArea::MDIArrangementMode getMDIArrangementMode(void);
- /**
- * set mainwindow saveGeometry - size and position of window
- */
- void setMainwindowGeometry(const QByteArray& geometry);
- /**
- * Return mainwindow saveGeometry - size and position of window
- */
- QByteArray getMainwindowGeometry();
- /**
- * set mainwindow saveState - position of docking windows and toolbar
- */
- void setMainwindowState(const QByteArray& state);
- /**
- * Return mainwindow saveState - position of docking windows and toolbar
- */
- QByteArray getMainwindowState();
-
- private:
- /**
- * Loads the basic settings requires for proper operation.
- */
- void loadBasics();
- void saveBasics();
-
- QList<CProfileWindow*> m_profileWindows;
- QString m_name;
- QString m_filename;
- CMDIArea::MDIArrangementMode m_mdiArrangementMode;
- QByteArray m_mainwindowGeometry;
- QByteArray m_mainwindowState;
-};
-
-} //end of namespace Profile
-
-#endif
diff --git a/src/frontend/profile/cprofilemgr.cpp b/src/frontend/profile/cprofilemgr.cpp
deleted file mode 100644
index 4b8bcc3..0000000
--- a/src/frontend/profile/cprofilemgr.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/*********
-*
-* 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/profile/cprofilemgr.h"
-
-#include <QDir>
-#include <QFile>
-#include <QList>
-#include "util/directory.h"
-
-
-namespace Profile {
-
-CProfileMgr::CProfileMgr() : m_startupProfile(0) {
- namespace DU = util::directory;
-
- //m_profiles.setAutoDelete(true);
-
- m_profilePath = DU::getUserSessionsDir().absolutePath() + "/";
-
- QDir d( m_profilePath );
- QStringList files = d.entryList(QStringList("*.xml"));
- for ( QStringList::Iterator it = files.begin(); it != files.end(); ++it ) {
- if ((*it) != "_startup_.xml") {
- m_profiles.append(new CProfile(m_profilePath + *it));
- }
- else {
- m_startupProfile = new CProfile(m_profilePath + *it);
- }
- }
-}
-
-CProfileMgr::~CProfileMgr() {
- qDeleteAll(m_profiles);
- m_profiles.clear();
- delete m_startupProfile;
-}
-
-/** Creates a new profile with the name "name" (first parameter). @return The profile object */
-CProfile *CProfileMgr::create(const QString &name) {
- CProfile* p = new CProfile(QString::null, name);
- m_profiles.append(p);
-
- return p;
-}
-
-/** Removes the profile from the list and from the directory containg the profile files. */
-bool CProfileMgr::remove( CProfile* p ) {
- bool ret = false;
- QFile f( p->filename() );
- if (f.exists())
- f.remove();
-
- int i = m_profiles.indexOf(p);
- if (i != -1)
- delete m_profiles.takeAt(i);
-
- ret = true;
- return ret;
-}
-
-bool CProfileMgr::remove( const QString& profile) {
- bool ret = false;
- QListIterator<CProfile*> it(m_profiles);
- while (it.hasNext()) {
- CProfile* p = it.next();
- if (p->name() == profile) {
- remove(p);
- ret = true;
- }
- }
- return ret;
-}
-
-/** Returns the profile with the desired name. If there's no such profile 0 is returned. */
-CProfile * CProfileMgr::profile(const QString & name) const {
- Q_FOREACH (CProfile * const p, m_profiles) {
- if (p && p->name() == name)
- return p;
- }
- return 0;
-}
-
-/** Returns the startup profile if it exists, otherwise return 0. */
-CProfile* CProfileMgr::startupProfile() {
- if (!m_startupProfile) {
- m_startupProfile = new CProfile(QString::null, "_startup_");
- }
-
- return m_startupProfile;
-}
-
-/** Refreshes the profiles available on disk. Use this function to update the list of profiles after another instance of CProfileMgr created a new profile. */
-void CProfileMgr::refresh() {
- qDeleteAll(m_profiles);
- m_profiles.clear(); //delete all profiles
- QDir d( m_profilePath );
- QStringList files = d.entryList(QStringList("*.xml"));
- for ( QStringList::Iterator it = files.begin(); it != files.end(); ++it ) {
- CProfile p(m_profilePath + *it);
- if (p.name() == "_startup_") { //new startup profile
- if (!m_startupProfile) { //don't put this in the if clause above,it doesn't work!
- m_startupProfile = new CProfile(m_profilePath + *it);
- }
- }
- else if (!profile(p.name())) { //don't have it already
- m_profiles.append(new CProfile(m_profilePath + *it));
- }
- }
-}
-
-} //end of namespace Profile
diff --git a/src/frontend/profile/cprofilemgr.h b/src/frontend/profile/cprofilemgr.h
deleted file mode 100644
index 00bb321..0000000
--- a/src/frontend/profile/cprofilemgr.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*********
-*
-* 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 CPROFILEMGR_H
-#define CPROFILEMGR_H
-
-#include <QList>
-#include <QString>
-#include "frontend/profile/cprofile.h"
-
-
-namespace Profile {
-/** The manager for profiles.
- * Provides functions to create, delete, save and load profiles.
- * @author The BibleTime team
- */
-class CProfileMgr {
- public:
- CProfileMgr();
- ~CProfileMgr();
-
- /** Creates a new profile with the name "name" (first parameter).
- * @return The profile object
- */
- CProfile *create(const QString &name);
- /**
- * @return a list of available profiles
- */
- inline const QList<CProfile*> &profiles() const {
- return m_profiles;
- }
- /**
- * Removes the profile from the list and from the directory containg the profile files.
- */
- bool remove( CProfile* p );
- /**
- * Removes the profile from the list and from the directory containg the profile files.
- */
- bool remove( const QString& );
- /**
- * Returns the profile with the desired name. If there's no such profile 0 is returned.
- */
- CProfile * profile(const QString & profileName) const;
- /**
- * Returns the startup profile if it exists, otherwise return 0.
- */
- CProfile* startupProfile();
- /**
- * Refreshes the profiles available on disk. Use this function to update the list of profiles after another instance of CProfileMgr created a new profile.
- */
- void refresh();
-
- protected:
- QList<CProfile*> m_profiles;
- QString m_profilePath;
- CProfile* m_startupProfile;
-};
-
-} //end of namespace Profile
-
-#endif
diff --git a/src/frontend/profile/cprofilewindow.cpp b/src/frontend/profile/cprofilewindow.cpp
deleted file mode 100644
index 682c99a..0000000
--- a/src/frontend/profile/cprofilewindow.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/*********
-*
-* 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/profile/cprofilewindow.h"
-
-
-namespace Profile {
-
-CProfileWindow::CProfileWindow(CSwordModuleInfo::ModuleType t)
- : type(t)
- , windowGeometry()
- , modules()
- , key(QString::null)
- , scrollbarPosH(0)
- , scrollbarPosV(0)
- , maximized(false)
- , hasFocus(false)
- , windowSettings(0)
- , writeWindowType(0)
-{
- // Intentionally empty
-}
-
-} //end of namespace Profile
diff --git a/src/frontend/profile/cprofilewindow.h b/src/frontend/profile/cprofilewindow.h
deleted file mode 100644
index 78d2b71..0000000
--- a/src/frontend/profile/cprofilewindow.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*********
-*
-* 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 CPROFILEWINDOW_H
-#define CPROFILEWINDOW_H
-
-#include <QRect>
-#include <QString>
-#include <QStringList>
-#include "backend/drivers/cswordmoduleinfo.h"
-
-
-class CSwordModuleInfo;
-
-namespace Profile {
-
-/** Contains the settings for one window saved in the profile.
- * @author The BibleTime team
- */
-struct CProfileWindow {
-
- CProfileWindow(CSwordModuleInfo::ModuleType type = CSwordModuleInfo::Unknown);
-
- CSwordModuleInfo::ModuleType type;
- QRect windowGeometry;
- QStringList modules;
- QString key;
- int scrollbarPosH;
- int scrollbarPosV;
- bool maximized;
- bool hasFocus;
- int windowSettings;
- int writeWindowType;
-
-};
-
-} //end of namespace Profile
-
-#endif
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp b/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
index ece0ced..10e4566 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,7 +18,7 @@
#include "backend/drivers/cswordmoduleinfo.h"
#include "frontend/searchdialog/analysis/csearchanalysisscene.h"
#include "frontend/searchdialog/analysis/csearchanalysisview.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
namespace Search {
@@ -59,7 +59,7 @@ void CSearchAnalysisDialog::initView() {
m_buttonBox->setStandardButtons(QDialogButtonBox::Close);
m_buttonBox->addButton(QDialogButtonBox::Save);
//tr("Save as HTML"),
- util::prepareDialogBox(m_buttonBox);
+ message::prepareDialogBox(m_buttonBox);
vboxLayout->addWidget(m_buttonBox);
bool ok = QObject::connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisdialog.h b/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
index b4edcad..454e105 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp b/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp
index 23b2962..c516184 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisitem.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,6 +17,7 @@
#include <QRect>
#include "backend/drivers/cswordmoduleinfo.h"
#include "frontend/searchdialog/analysis/csearchanalysisscene.h"
+#include "util/htmlescape.h"
namespace Search {
@@ -61,17 +62,6 @@ CSearchAnalysisItem::~CSearchAnalysisItem() {
delete m_bufferPixmap;
}
-/** Sets the resultcount of this item for the given module */
-void CSearchAnalysisItem::setCountForModule( const int moduleIndex, const int count) {
- m_resultCountArray[moduleIndex] = count;
-}
-
-/** Returns the resultcount of this item for the given module */
-int CSearchAnalysisItem::getCountForModule( const int moduleIndex) {
- return m_resultCountArray[moduleIndex];
-}
-
-
bool CSearchAnalysisItem::hasHitsInAnyModule() {
foreach (const int hits, m_resultCountArray) {
if (hits) return true;
@@ -142,33 +132,36 @@ int CSearchAnalysisItem::width() {
/** Returns the tooltip for this item. */
const QString CSearchAnalysisItem::getToolTip() {
typedef CSwordModuleSearch::Results::const_iterator RCI;
+ using util::htmlEscape;
- QString toolTipString = QString("<center><b>%1</b></center><hr/>").arg(m_bookName);
- toolTipString += "<table cellspacing=\"0\" cellpadding=\"3\" width=\"100%\" height=\"100%\" align=\"center\">";
+ QString toolTipString("<center><b>");
+ toolTipString.append(htmlEscape(m_bookName)).append("</b></center><hr/>")
+ .append("<table cellspacing=\"0\" cellpadding=\"3\" width=\"10"
+ "0%\" height=\"100%\" align=\"center\">");
/// \todo Fix that loop
int i = 0;
- for (RCI it = m_results.begin(); it != m_results.end(); it++) {
- const CSwordModuleInfo *info = it.key();
-
- /// \warning This is a workaround for sword constness
- sword::ListKey &results = const_cast<sword::ListKey &>(it.value());
-
- const QColor c = CSearchAnalysisScene::getColor(i);
-
- toolTipString.append(
- QString("<tr bgcolor=\"white\"><td><b><font color=\"%1\">%2</font></b></td><td>%3 (%4%)</td></tr>")
- .arg(c.name())
- .arg(info ? info->name() : QString::null)
- .arg( m_resultCountArray[i] )
- .arg( (info && m_resultCountArray[i]) ? ((double)m_resultCountArray[i] / (double)results.Count())*(double)100 : 0.0, 0, 'g', 2)
- );
+ for (RCI it = m_results.begin(); it != m_results.end(); ++it) {
+ const CSwordModuleInfo * const info = it.key();
+
+ const int count = it.value().getCount();
+ const double percent = (info && count)
+ ? ((static_cast<double>(m_resultCountArray.at(i))
+ * static_cast<double>(100.0))
+ / static_cast<double>(count))
+ : 0.0;
+ toolTipString.append("<tr bgcolor=\"white\"><td><b><font color=\"")
+ .append(CSearchAnalysisScene::getColor(i).name()).append("\">")
+ .append(info ? info->name() : QString::null)
+ .append("</font></b></td><td>")
+ .append(m_resultCountArray.at(i))
+ .append(" (")
+ .append(QString::number(percent, 'g', 2))
+ .append("%)</td></tr>");
++i;
}
- toolTipString += "</table>";
-
- return toolTipString;
+ return toolTipString.append("</table>");
}
}
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisitem.h b/src/frontend/searchdialog/analysis/csearchanalysisitem.h
index 7db96a9..ec2cd03 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisitem.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisitem.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -27,15 +29,21 @@ class CSearchAnalysisItem : public QGraphicsRectItem {
const CSwordModuleSearch::Results &results);
~CSearchAnalysisItem();
+
/**
- * Sets the resultcount of this item
+ Sets the resultcount of this item.
*/
- void setCountForModule( const int moduleIndex, const int count);
+ inline void setCountForModule(const int moduleIndex, const int count) {
+ m_resultCountArray[moduleIndex] = count;
+ }
/**
- * Returns the resultcount of this item
+ Returns the resultcount of this item.
*/
- int getCountForModule( const int moduleIndex);
+ inline int getCountForModule(const int moduleIndex) const {
+ return m_resultCountArray[moduleIndex];
+ }
+
/**
* Does one of the modules contain hits?
*/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
index c5b9d02..e630846 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
index 232fe64..f199aaf 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysislegenditem.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp b/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp
index a039e19..9b375e8 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisscene.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,10 +13,12 @@
#include <QFileDialog>
#include <QHashIterator>
#include <QTextCodec>
+#include <QTextDocument>
#include "backend/keys/cswordversekey.h"
#include "frontend/searchdialog/analysis/csearchanalysisitem.h"
#include "frontend/searchdialog/analysis/csearchanalysislegenditem.h"
#include "frontend/searchdialog/csearchdialog.h"
+#include "util/htmlescape.h"
#include "util/tool.h"
@@ -88,7 +90,7 @@ void CSearchAnalysisScene::analyse(
bool ok = true;
while (ok && analysisItem) {
moduleIndex = 0;
- for (RCI it = m_results.begin(); it != m_results.end(); it++) {
+ for (RCI it = m_results.begin(); it != m_results.end(); ++it) {
qApp->processEvents( QEventLoop::AllEvents );
if (!m_lastPosList.contains(it.key())) {
m_lastPosList.insert(it.key(), 0);
@@ -120,7 +122,7 @@ void CSearchAnalysisScene::setResults(
typedef CSwordModuleSearch::Results::const_iterator RCI;
m_results.clear();
- for (RCI it = results.begin(); it != results.end(); it++) {
+ for (RCI it = results.begin(); it != results.end(); ++it) {
const CSwordModuleInfo *m = it.key();
if ( (m->type() == CSwordModuleInfo::Bible) || (m->type() == CSwordModuleInfo::Commentary) ) { //a Bible or an commentary
m_results.insert(m, it.value());
@@ -205,13 +207,12 @@ QColor CSearchAnalysisScene::getColor(int index) {
unsigned int CSearchAnalysisScene::getCount(const QString &book,
const CSwordModuleInfo* module)
{
- /// \warning This is a workaround for sword constness
- sword::ListKey result = m_results[module];
+ const sword::ListKey & result = m_results[module];
const int length = book.length();
unsigned int i = m_lastPosList[module];
unsigned int count = 0;
- const unsigned int resultCount = result.Count();
+ const unsigned int resultCount = result.getCount();
while (i < resultCount) {
if (strncmp(book.toUtf8(), (const char *) *result.getElement(i), length))
break;
@@ -223,67 +224,86 @@ unsigned int CSearchAnalysisScene::getCount(const QString &book,
}
void CSearchAnalysisScene::saveAsHTML() {
- typedef CSwordModuleSearch::Results::const_iterator RCI;
-
- const QString fileName = QFileDialog::getSaveFileName(0, tr("Save Search Analysis"), QString::null, tr("HTML files (*.html;*.HTML;*.HTM;*.htm)") );
- if (fileName.isEmpty()) return;
-
- int count = 0;
- QString countStr = "";
- QString m_searchAnalysisHTML = "";
- QString tableTitle = "";
- QString tableTotals = "";
- QString VerseRange = "";
- const QString txtCSS = QString("<style type=\"text/css\">\ntd {border:1px solid black;}\nth {font-size: 130%; text-align:left; vertical-align:top;}\n</style>\n");
- const QString metaEncoding = QString("<META http-equiv=Content-Type content=\"text/html; charset=utf-8\">");
- CSwordVerseKey key(0);
+ using util::htmlEscape;
- key.setKey("Genesis 1:1");
-
- CSearchAnalysisItem* analysisItem = m_itemList.value( key.book() );
-
- QString text = "<html>\n<head>\n<title>" + tr("BibleTime Search Analysis") + "</title>\n" + txtCSS + metaEncoding + "</head>\n<body>\n";
- text += "<table>\n<tr><th>" + tr("Search text :") + "</th><th>" + CSearchDialog::getSearchDialog()->searchText() + "</th></tr>\n";
-
- tableTitle = "<tr><th align=\"left\">" + tr("Book") + "</th>";
- tableTotals = "<tr><td align=\"left\">" + tr("Total hits") + "</td>";
-
- for (RCI it = m_results.begin(); it != m_results.end(); it++) {
- const CSwordModuleInfo *mod = it.key();
- tableTitle += QString("<th align=\"left\">") + mod->name() + QString("</th>");
+ typedef CSwordModuleSearch::Results::const_iterator RCI;
- /// \warning This is a workaround for sword constness
- sword::ListKey searchResult = it.value();
- countStr.setNum(searchResult.Count());
+ const QString fileName = QFileDialog::getSaveFileName(0,
+ tr("Save Search Analysis"),
+ QString::null,
+ tr("XHTML files (*.html *.HTML *.HTM *.htm);;All files (*)"));
+ if (fileName.isEmpty())
+ return;
- tableTotals += QString("<td align=\"right\">") + countStr + QString("</td>");
+ QString text("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
+ "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>");
+ {
+ const QString title(tr("BibleTime Search Analysis"));
+ text += title;
+ text += "</title>"
+ "<style type=\"text/css\">"
+ "body{background-color:#fff;color:#000}"
+ "table{border-collapse:collapse}"
+ "td{border:1px solid #333}"
+ "th{font-size:130%;text-align:left;vertical-align:top}"
+ "td,th{text-align:left;padding:0.2em 0.5em}"
+ ".r{text-align:right}"
+ "</style>"
+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>"
+ "</head><body><h1>";
+ text += title;
}
- tableTitle += QString("</tr>\n");
- tableTotals += QString("</tr>\n");
-
- m_searchAnalysisHTML = "";
- bool ok = true;
- while (ok) {
- m_searchAnalysisHTML += QString("<tr><td>") + key.book() + QString("</td>");
- analysisItem = m_itemList.value( key.book() );
+ text += "</h1><p><span style=\"font-weight:bold\">";
+ text += tr("Search text:");
+ text += "</span>&nbsp;";
+ text += htmlEscape(CSearchDialog::getSearchDialog()->searchText());
+ text += "</p><table><caption>";
+ text += tr("Results by work and book");
+ text += "</caption><tr><th>";
+ text += tr("Book");
+ text += "</th>";
+
+ for (RCI it = m_results.begin(); it != m_results.end(); ++it) {
+ text += "<th>";
+ text += htmlEscape(it.key()->name());
+ text += "</th>";
+ }
+ text += "</tr>";
- int moduleIndex = 0;
- for (RCI it = m_results.begin(); it != m_results.end(); it++) {
- count = analysisItem->getCountForModule(moduleIndex);
- countStr.setNum(count);
- m_searchAnalysisHTML += QString("<td align=\"right\">") + countStr + QString("</td>");
+ CSwordVerseKey key(0);
+ key.setKey("Genesis 1:1");
- ++moduleIndex;
+ do {
+ text += "<tr><td>";
+ const QString keyBook(key.book());
+ text += htmlEscape(keyBook);
+ text += "</td>";
+
+ int mi = 0; // Module index
+ for (RCI it = m_results.begin(); it != m_results.end(); ++it, ++mi) {
+ text += "<td class=\"r\">";
+ text += QString::number(m_itemList.value(keyBook)->getCountForModule(mi));
+ text += "</td>";
}
- m_searchAnalysisHTML += QString("</tr>\n");
- ok = key.next(CSwordVerseKey::UseBook);
+ text += "</tr>";
+ } while (key.next(CSwordVerseKey::UseBook));
+ text += "<tr><th class=\"r\">";
+ text += tr("Total hits");
+ text += "</th>";
+
+ for (RCI it = m_results.begin(); it != m_results.end(); ++it) {
+ text += "<td class=\"r\">";
+ text += QString::number(it.value().getCount());
+ text += "</td>";
}
- text += QString("<table>\n") + tableTitle + tableTotals + m_searchAnalysisHTML + QString("</table>\n");
- text += QString("<center>") + tr("Created by <a href=\"http://www.bibletime.info/\">BibleTime</a>") + QString("</center>");
- text += QString("</body></html>");
+ text += "</tr></table><p style=\"text-align:center;font-size:x-small\">";
+ text += tr("Created by <a href=\"http://www.bibletime.info/\">BibleTime</a>");
+ text += "</p></body></html>";
- util::tool::savePlainFile(fileName, text, false, QTextCodec::codecForName("UTF8"));
+ util::tool::savePlainFile(fileName, text, true, QTextCodec::codecForName("UTF8"));
}
void CSearchAnalysisScene::resizeHeight(int height) {
@@ -291,4 +311,4 @@ void CSearchAnalysisScene::resizeHeight(int height) {
slotResized();
}
-}
+} // namespace Search {
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisscene.h b/src/frontend/searchdialog/analysis/csearchanalysisscene.h
index f8bb966..d1927d5 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisscene.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisscene.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisview.cpp b/src/frontend/searchdialog/analysis/csearchanalysisview.cpp
index d177f63..277c1a3 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisview.cpp
+++ b/src/frontend/searchdialog/analysis/csearchanalysisview.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/analysis/csearchanalysisview.h b/src/frontend/searchdialog/analysis/csearchanalysisview.h
index 19d53c1..4b072f3 100644
--- a/src/frontend/searchdialog/analysis/csearchanalysisview.h
+++ b/src/frontend/searchdialog/analysis/csearchanalysisview.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp b/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp
index 1d5f556..a5bfd2c 100644
--- a/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp
+++ b/src/frontend/searchdialog/btsearchmodulechooserdialog.cpp
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -43,10 +43,6 @@ BtSearchModuleChooserDialog::BtSearchModuleChooserDialog(QWidget *parent,
retranslateUi();
}
-BtSearchModuleChooserDialog::~BtSearchModuleChooserDialog() {
- // Intentionally empty
-}
-
void BtSearchModuleChooserDialog::retranslateUi() {
setWindowTitle(tr("Works to Search in"));
util::tool::initExplanationLabel(label(), QString::null,
diff --git a/src/frontend/searchdialog/btsearchmodulechooserdialog.h b/src/frontend/searchdialog/btsearchmodulechooserdialog.h
index 103682c..79802b5 100644
--- a/src/frontend/searchdialog/btsearchmodulechooserdialog.h
+++ b/src/frontend/searchdialog/btsearchmodulechooserdialog.h
@@ -4,7 +4,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License
* version 2.0.
*
@@ -26,7 +26,6 @@ class BtSearchModuleChooserDialog: public BtModuleChooserDialog {
public:
BtSearchModuleChooserDialog(QWidget *parent = 0,
Qt::WindowFlags flags = 0);
- ~BtSearchModuleChooserDialog();
inline void setCheckedModules(const QSet<CSwordModuleInfo*> &modules) {
bookshelfWidget()->treeModel()->setCheckedModules(modules);
diff --git a/src/frontend/searchdialog/btsearchoptionsarea.cpp b/src/frontend/searchdialog/btsearchoptionsarea.cpp
index 902666b..d850344 100644
--- a/src/frontend/searchdialog/btsearchoptionsarea.cpp
+++ b/src/frontend/searchdialog/btsearchoptionsarea.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,20 +16,25 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
-#include <QMessageBox>
#include <QPushButton>
#include <QRadioButton>
#include "backend/bookshelfmodel/btbookshelftreemodel.h"
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
+#include "backend/managers/cswordbackend.h"
#include "backend/drivers/cswordmoduleinfo.h"
+#include "bibletimeapp.h"
#include "frontend/searchdialog/btsearchmodulechooserdialog.h"
#include "frontend/searchdialog/btsearchsyntaxhelpdialog.h"
#include "frontend/searchdialog/crangechooserdialog.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
-#include "util/directory.h"
+namespace {
+const QString SearchTypeKey = "GUI/SearchDialog/searchType";
+} // anonymous namespace
+
namespace Search {
BtSearchOptionsArea::BtSearchOptionsArea(QWidget *parent )
@@ -57,10 +62,6 @@ BtSearchOptionsArea::SearchType BtSearchOptionsArea::searchType() {
return BtSearchOptionsArea::FullType;
}
-QPushButton* BtSearchOptionsArea::searchButton() const {
- return m_searchButton;
-}
-
void BtSearchOptionsArea::setSearchText(const QString& text) {
bool found = false;
int i = 0;
@@ -82,8 +83,6 @@ void BtSearchOptionsArea::setSearchText(const QString& text) {
}
void BtSearchOptionsArea::initView() {
- namespace DU = util::directory;
-
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
this->setSizePolicy(sizePolicy);
hboxLayout = new QHBoxLayout(this);
@@ -103,17 +102,17 @@ void BtSearchOptionsArea::initView() {
m_searchButton = new QPushButton(this);
m_searchButton->setText(tr("&Search"));
- m_searchButton->setIcon(DU::getIcon(CResMgr::searchdialog::icon));
+ m_searchButton->setIcon(util::getIcon(CResMgr::searchdialog::icon));
m_searchButton->setToolTip(tr("Start to search the text in the chosen works"));
gridLayout->addWidget(m_searchButton, 0, 2);
m_chooseModulesButton = new QPushButton(tr("Ch&oose..."), searchGroupBox);
- m_chooseModulesButton->setIcon(DU::getIcon(CResMgr::searchdialog::chooseworks_icon));
+ m_chooseModulesButton->setIcon(util::getIcon(CResMgr::searchdialog::chooseworks_icon));
m_chooseModulesButton->setToolTip( tr("Choose works for the search"));
gridLayout->addWidget(m_chooseModulesButton, 2, 2);
m_chooseRangeButton = new QPushButton(tr("S&etup..."), searchGroupBox);
- m_chooseRangeButton->setIcon(DU::getIcon(CResMgr::searchdialog::setupscope_icon));
+ m_chooseRangeButton->setIcon(util::getIcon(CResMgr::searchdialog::setupscope_icon));
m_chooseRangeButton->setToolTip(tr("Configure predefined scopes for search"));
gridLayout->addWidget(m_chooseRangeButton, 3, 2);
@@ -243,7 +242,7 @@ void BtSearchOptionsArea::setModules(const QList<const CSwordModuleInfo*> &modul
for (int i = 0; i < m_modulesCombo->count(); ++i) {
historyList.append(m_modulesCombo->itemText(i));
}
- CBTConfig::set(CBTConfig::searchModulesHistory, historyList);
+ btConfig().setValue("history/searchModuleHistory", historyList);
emit sigSetSearchButtonStatus(!modules.isEmpty());
}
@@ -284,7 +283,7 @@ void BtSearchOptionsArea::reset() {
}
void BtSearchOptionsArea::saveSettings() {
- CBTConfig::set(CBTConfig::searchTexts, m_searchTextCombo->historyItems());
+ btConfig().setValue("properties/searchTexts", m_searchTextCombo->historyItems());
SearchType t = FullType;
if (m_typeAndButton->isChecked()) {
t = AndType;
@@ -292,25 +291,25 @@ void BtSearchOptionsArea::saveSettings() {
if (m_typeOrButton->isChecked()) {
t = OrType;
}
- CBTConfig::set(CBTConfig::searchType, t);
+ btConfig().setValue(SearchTypeKey, t);
}
void BtSearchOptionsArea::readSettings() {
- QStringList texts = CBTConfig::get(CBTConfig::searchTexts);
+ const QStringList texts = btConfig().value<QStringList>("properties/searchTexts", QStringList());
//for some reason the slot was called when setting the upmost item
disconnect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
- for (int i = 0; i < texts.size(); i++) {
- if (texts.at(i).size() > 0)
- m_searchTextCombo->addItem(texts.at(i));
+ Q_FOREACH (const QString & text, texts) {
+ if (text.size() > 0)
+ m_searchTextCombo->addItem(text);
}
connect(m_searchTextCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(slotValidateText(const QString&)));
- m_modulesCombo->insertItems(0, CBTConfig::get(CBTConfig::searchModulesHistory));
+ m_modulesCombo->insertItems(0, btConfig().value<QStringList>("history/searchModuleHistory", QStringList()));
for (int i = 0; i < m_modulesCombo->count(); ++i) {
m_modulesCombo->setItemData(i, m_modulesCombo->itemText(i), Qt::ToolTipRole);
}
- int stype = CBTConfig::get(CBTConfig::searchType);
+ int stype = btConfig().value<int>(SearchTypeKey, AndType);
switch (stype) {
case AndType:
m_typeAndButton->setChecked(true);
@@ -336,8 +335,8 @@ void BtSearchOptionsArea::setupRanges() {
}
void BtSearchOptionsArea::syntaxHelp() {
- // The dialog is deleted on close:
- BtSearchSyntaxHelpDialog *dlg = new BtSearchSyntaxHelpDialog(this);
+ BtSearchSyntaxHelpDialog * dlg = new BtSearchSyntaxHelpDialog(this);
+ dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->show();
}
@@ -349,23 +348,22 @@ void BtSearchOptionsArea::refreshRanges() {
//m_rangeChooserCombo->insertItem(tr("Last search result"));
//insert the user-defined ranges
- m_rangeChooserCombo->insertItems(1, CBTConfig::get(CBTConfig::searchScopes).keys());
-
+ m_rangeChooserCombo->insertItems(1, btConfig().getSearchScopesForCurrentLocale().keys());
}
sword::ListKey BtSearchOptionsArea::searchScope() {
if (m_rangeChooserCombo->currentIndex() > 0) { //is not "no scope"
- CBTConfig::StringMap map = CBTConfig::get(CBTConfig::searchScopes);
+ BtConfig::StringMap map = btConfig().getSearchScopesForCurrentLocale();
QString scope = map[ m_rangeChooserCombo->currentText() ];
if (!scope.isEmpty()) {
- return sword::VerseKey().ParseVerseList( (const char*)scope.toUtf8(), "Genesis 1:1", true);
+ return sword::VerseKey().parseVerseList( (const char*)scope.toUtf8(), "Genesis 1:1", true);
}
}
return sword::ListKey();
}
bool BtSearchOptionsArea::hasSearchScope() {
- return (searchScope().Count() > 0);
+ return (searchScope().getCount() > 0);
}
void BtSearchOptionsArea::addToHistory(const QString& text) {
@@ -419,7 +417,7 @@ void BtSearchOptionsArea::slotValidateText(const QString& /*newText*/) {
} // namespace Search
QDataStream &operator<<(QDataStream &out, const Search::BtSearchOptionsArea::SearchType &searchType) {
- out << (qint8) searchType;
+ out << static_cast<qint8>(searchType);
return out;
}
diff --git a/src/frontend/searchdialog/btsearchoptionsarea.h b/src/frontend/searchdialog/btsearchoptionsarea.h
index 375b5e7..a6483ac 100644
--- a/src/frontend/searchdialog/btsearchoptionsarea.h
+++ b/src/frontend/searchdialog/btsearchoptionsarea.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -56,7 +58,7 @@ class BtSearchOptionsArea : public QWidget {
SearchType searchType();
- QPushButton* searchButton() const;
+ inline QPushButton * searchButton() const { return m_searchButton; }
/**
Returns the list of used modules.
diff --git a/src/frontend/searchdialog/btsearchresultarea.cpp b/src/frontend/searchdialog/btsearchresultarea.cpp
index 262ff23..6a82a4f 100644
--- a/src/frontend/searchdialog/btsearchresultarea.cpp
+++ b/src/frontend/searchdialog/btsearchresultarea.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -10,7 +10,6 @@
#include "frontend/searchdialog/btsearchresultarea.h"
#include <QApplication>
-#include <QDebug>
#include <QFrame>
#include <QMenu>
#include <QProgressDialog>
@@ -22,13 +21,19 @@
#include <QWidget>
#include "backend/keys/cswordversekey.h"
#include "backend/rendering/cdisplayrendering.h"
-#include "frontend/display/cdisplay.h"
+#include "backend/config/btconfig.h"
+#include "frontend/display/bthtmlreaddisplay.h"
#include "frontend/searchdialog/cmoduleresultview.h"
#include "frontend/searchdialog/csearchdialog.h"
#include "frontend/searchdialog/csearchresultview.h"
#include "util/tool.h"
+namespace {
+const QString MainSplitterSizesKey = "GUI/SearchDialog/SearchResultsArea/mainSplitterSizes";
+const QString ResultSplitterSizesKey = "GUI/SearchDialog/SearchResultsArea/resultSplitterSizes";
+} // anonymous namespace
+
namespace Search {
BtSearchResultArea::BtSearchResultArea(QWidget *parent)
@@ -76,7 +81,7 @@ void BtSearchResultArea::initView() {
QVBoxLayout* frameLayout = new QVBoxLayout(m_displayFrame);
frameLayout->setContentsMargins(0, 0, 0, 0);
- m_previewDisplay = CDisplay::createReadInstance(0, m_displayFrame);
+ m_previewDisplay = new BtHtmlReadDisplay(0, m_displayFrame);
m_previewDisplay->view()->setToolTip(tr("Text of the selected search result item"));
frameLayout->addWidget(m_previewDisplay->view());
@@ -143,10 +148,10 @@ void BtSearchResultArea::updatePreview(const QString& key) {
//for bibles render 5 context verses
if (module->type() == CSwordModuleInfo::Bible) {
CSwordVerseKey vk(module);
- vk.Headings(1);
+ vk.setIntros(true);
vk.setKey(key);
- ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
+ ((sword::VerseKey*)(module->module()->getKey()))->setIntros(true); //HACK: enable headings for VerseKeys
//first go back and then go forward the keys to be in context
vk.previous(CSwordVerseKey::UseVerse);
@@ -174,10 +179,10 @@ void BtSearchResultArea::updatePreview(const QString& key) {
//for commentaries only one verse, but with heading
else if (module->type() == CSwordModuleInfo::Commentary) {
CSwordVerseKey vk(module);
- vk.Headings(1);
+ vk.setIntros(true);
vk.setKey(key);
- ((sword::VerseKey*)(module->module()->getKey()))->Headings(1); //HACK: enable headings for VerseKeys
+ ((sword::VerseKey*)(module->module()->getKey()))->setIntros(true); //HACK: enable headings for VerseKeys
//include Headings in display, they are indexed and searched too
if (vk.getVerse() == 1) {
@@ -198,295 +203,11 @@ void BtSearchResultArea::updatePreview(const QString& key) {
text = render.renderSingleKey(key, modules, settings);
}
- m_previewDisplay->setText( highlightSearchedText(text, searchedText) );
+ m_previewDisplay->setText( CSwordModuleSearch::highlightSearchedText(text, searchedText) );
m_previewDisplay->moveToAnchor( CDisplayRendering::keyToHTMLAnchor(key) );
}
}
-QStringList BtSearchResultArea::queryParser(const QString& queryString) {
- QString token;
- QStringList tokenList;
- int cnt, pos;
-
- token = "";
- cnt = 0;
- while (cnt < queryString.length()) {
- // add to token
- if ((queryString[cnt]).isLetterOrNumber() || (queryString[cnt] == '*')) {
- token = token + queryString[cnt];
- cnt++;
- }
- else if ((queryString[cnt]).isLetterOrNumber() || (queryString[cnt] == '?')) {
- token = token + queryString[cnt];
- cnt++;
- }
- // token break
- else if (queryString[cnt] == ' ') {
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- token = "";
- cnt++;
- }
- // clucene appears to ignore quoted strings in the sence
- // that it treats all the words within quoted strings as
- // regular tokens and not as a single token.
- else if (queryString[cnt] == '"') {
- cnt++;
- }
- // wild card - treat as a special token break
- //else if (queryString[cnt] == '*') {
- // token = token + queryString[cnt];
- // token = token.simplified();
- // if ((token != "*") && (token != ""))
- // tokenList.append(token);
- // // start next token with wildcard (kin*m -> kin* *m)
- // token = "*";
- // cnt++;
- //}
- // the ! token is also a token break
- else if (queryString[cnt] == '!') {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the ! token
- tokenList.append("!");
- token = "";
- cnt++;
- }
- // the - token is also a token break
- else if (queryString[cnt] == '-') {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the ! token
- tokenList.append("-");
- token = "";
- cnt++;
- }
- // the + token is also a token break
- else if (queryString[cnt] == '+') {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the + token
- tokenList.append("+");
- token = "";
- cnt++;
- }
- // the || token is also a token break
- else if ((queryString[cnt] == '|') && (queryString[cnt+1] == '|')) {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the || token
- tokenList.append("||");
- token = "";
- cnt += 2;
- }
- // the && token is also a token break
- else if ((queryString[cnt] == '&') && (queryString[cnt+1] == '&')) {
- // store away current token
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
- // add the || token
- tokenList.append("&&");
- token = "";
- cnt += 2;
- }
- else cnt++;
- }
- token = token.simplified();
- if ((token != "*") && (token != ""))
- tokenList.append(token);
-
- cnt = 0;
- QStringList::iterator it;
- for ( it = tokenList.begin(); it != tokenList.end(); it++ ) {
- //-----------------------------------------------------------
- // remove all the NOT(!) tokens - these do not need to be
- // highlighted in the highlighter
- //-----------------------------------------------------------
- if (((*it) == "!") || ((*it) == "NOT") || ((*it) == "-")) {
- it = tokenList.erase(it);
- if (it == tokenList.end())
- break;
- it = tokenList.erase(it);
- if (it == tokenList.end())
- break;
- it--;
- }
- //-----------------------------------------------------------
- // remove all the operator tokens - these do not need to be
- // highlighted in the highlighter
- //-----------------------------------------------------------
- else if ( ((*it) == "||") || ((*it) == "OR") || ((*it) == "+") ||
- ((*it) == "AND") || ((*it) == "&&") ) {
- it = tokenList.erase(it);
- if (it == tokenList.end())
- break;
- it--;
- }
- // if the token contains a ^ then trim the remainder of the
- // token from the ^
- //What??? error: invalid conversion from ‘const void*’ to ‘int’
- // and how come "contains" returns bool but is used as int?
- //else if ( (pos = (*it).contains("^")) >= 0 ) {
- else if ( (pos = (*it).indexOf("^") ) >= 0 ) {
- (*it) = (*it).left(pos - 1);
- }
- // if the token contains a ~ then trim the remainder of the
- // token from the ~
- else if ( (pos = (*it).indexOf("~") ) >= 0 ) {
- (*it) = (*it).left(pos - 2) + "*";
- }
- }
- return(tokenList);
-}
-
-QString BtSearchResultArea::highlightSearchedText(const QString& content, const QString& searchedText) {
- QString ret = content;
-
- const Qt::CaseSensitivity cs = Qt::CaseInsensitive;
-
- // int index = 0;
- int index = ret.indexOf("<body", 0);
- int matchLen = 0;
- int length = searchedText.length();
-
- // Highlighting constants -
- // \todo We need to make the highlight color configurable.
- const QString rep1("<span style=\"background-color:#FFFF66;\">");
- const QString rep2("</span>");
- const unsigned int repLength = rep1.length() + rep1.length();
- const QString rep3("style=\"background-color:#FFFF66;\" ");
- const unsigned int rep3Length = rep3.length();
-
-
- QString newSearchText;
-
- newSearchText = searchedText;
-
- // find the strongs search lemma and highlight it
- // search the searched text for "strong:" until it is not found anymore
- QStringList list;
-
- // split the search string - some possibilities are "\\s|\\|", "\\s|\\+", or "\\s|\\|\\+"
- // \todo find all possible seperators
- QString regExp = "\\s";
- list = searchedText.split(QRegExp(regExp));
- foreach (QString newSearchText, list) {
- int sstIndex; // strong search text index for finding "strong:"
- int idx1, idx2;
- QString sNumber, lemmaText;
-
- sstIndex = newSearchText.indexOf("strong:");
- if (sstIndex == -1)
- continue;
-
- // set the start index to the start of <body>
- int strongIndex = index;
-
- // Get the strongs number from the search text.
- // First, find the first space after "strong:"
- sstIndex = sstIndex + 7;
- // get the strongs number -> the text following "strong:" to the end of the string.
- sNumber = newSearchText.mid(sstIndex, -1);
- // find all the "lemma=" inside the the content
- while ((strongIndex = ret.indexOf("lemma=", strongIndex, cs)) != -1) {
- // get the strongs number after the lemma and compare it with the
- // strongs number we are looking for
- idx1 = ret.indexOf("\"", strongIndex) + 1;
- idx2 = ret.indexOf("\"", idx1 + 1);
- lemmaText = ret.mid(idx1, idx2 - idx1);
-
- // this is interesting because we could have a strongs number like: G3218|G300
- // To handle this we will use some extra cpu cycles and do a partial match against
- // the lemmaText
- if (lemmaText.contains(sNumber)) {
- // strongs number is found now we need to highlight it
- // I believe the easiest way is to insert rep3 just before "lemma="
- ret = ret.insert(strongIndex, rep3);
- strongIndex += rep3Length;
- }
- strongIndex += 6; // 6 is the length of "lemma="
- }
- }
- //---------------------------------------------------------------------
- // now that the strong: stuff is out of the way continue with
- // other search options
- //---------------------------------------------------------------------
-
- // try to figure out how to use the lucene query parser
-
- //using namespace lucene::queryParser;
- //using namespace lucene::search;
- //using namespace lucene::analysis;
- //using namespace lucene::util;
-
- //wchar_t *buf;
- //char buf8[1000];
- //standard::WhitespaceAnalyzer analyzer;
- //lucene_utf8towcs(m_wcharBuffer, searchedText.utf8(), MAX_CONV_SIZE);
- //QSharedPointer<Query> q( QueryParser::parse(m_wcharBuffer, _T("content"), &analyzer) );
- //StringReader reader(m_wcharBuffer);
- //TokenStream* tokenStream = analyzer.tokenStream( _T("field"), &reader);
- //Token token;
- //while(tokenStream->next(&token) != 0) {
- // lucene_wcstoutf8(buf8, token.termText(), 1000);
- // printf("%s\n", buf8);
- //}
-
- //===========================================================
- // since I could not figure out the lucene query parser, I
- // made a simple parser.
- //===========================================================
- QStringList words = queryParser(newSearchText);
- qDebug() << "btsearchresultarea.cpp: " << __LINE__ << ": " << words << '\n';
- foreach (QString word, words) { //search for every word in the list
- QRegExp findExp;
- if (word.contains("*")) {
- length = word.length() - 1;
- word.replace('*', "\\S*"); //match within a word
- findExp = QRegExp(word);
- findExp.setMinimal(true);
- }
- else if (word.contains("?")) {
- length = word.length() - 1;
- word.replace('?', "\\S?"); //match within a word
- findExp = QRegExp(word);
- findExp.setMinimal(true);
- }
- else {
- length = word.length();
- findExp = QRegExp("\\b" + word + "\\b");
- }
-
- // index = 0; //for every word start at the beginning
- index = ret.indexOf("<body", 0);
- findExp.setCaseSensitivity(cs);
- //while ( (index = ret.find(findExp, index)) != -1 ) { //while we found the word
- while ( (index = findExp.indexIn(ret, index)) != -1 ) { //while we found the word
- matchLen = findExp.matchedLength();
- if (!util::tool::inHTMLTag(index, ret)) {
- length = matchLen;
- ret = ret.insert( index + length, rep2 );
- ret = ret.insert( index, rep1 );
- index += repLength;
- }
- index += length;
- }
- }
- qDebug() << "btsearchresultarea.cpp: " << __LINE__ << ": " << words << '\n';
- //qWarning("\n\n\n%s", ret.latin1());
- return ret;
-}
-
/** Initializes the signal slot conections of the child widgets, */
void BtSearchResultArea::initConnections() {
connect(m_resultListBox, SIGNAL(keySelected(const QString&)), this, SLOT(updatePreview(const QString&)));
@@ -506,26 +227,28 @@ void BtSearchResultArea::initConnections() {
* Load the settings from the resource file
*/
void BtSearchResultArea::loadDialogSettings() {
- QList<int> mainSplitterSizes = CBTConfig::get(CBTConfig::searchMainSplitterSizes);
- if (mainSplitterSizes.count() > 0) {
+ QList<int> mainSplitterSizes = btConfig().value< QList<int> >(MainSplitterSizesKey, QList<int>());
+ if (mainSplitterSizes.count() > 0)
m_mainSplitter->setSizes(mainSplitterSizes);
- }
- else {
+ else
+ {
int w = this->size().width();
int w2 = m_moduleListBox->sizeHint().width();
mainSplitterSizes << w2 << w - w2;
m_mainSplitter->setSizes(mainSplitterSizes);
}
- QList<int> resultSplitterSizes = CBTConfig::get(CBTConfig::searchResultSplitterSizes);
- if (resultSplitterSizes.count() > 0) m_resultListSplitter->setSizes(resultSplitterSizes);
+
+ QList<int> resultSplitterSizes = btConfig().value< QList<int> >(ResultSplitterSizesKey, QList<int>());
+ if (resultSplitterSizes.count() > 0)
+ m_resultListSplitter->setSizes(resultSplitterSizes);
}
/**
* Save the settings to the resource file
*/
void BtSearchResultArea::saveDialogSettings() const {
- CBTConfig::set(CBTConfig::searchMainSplitterSizes, m_mainSplitter->sizes());
- CBTConfig::set(CBTConfig::searchResultSplitterSizes, m_resultListSplitter->sizes());
+ btConfig().setValue(MainSplitterSizesKey, m_mainSplitter->sizes());
+ btConfig().setValue(ResultSplitterSizesKey, m_resultListSplitter->sizes());
}
/******************************************************************************
@@ -533,15 +256,12 @@ void BtSearchResultArea::saveDialogSettings() const {
******************************************************************************/
StrongsResultList::StrongsResultList(const CSwordModuleInfo *module,
- const sword::ListKey &results,
+ const sword::ListKey & result,
const QString &strongsNumber)
{
using namespace Rendering;
- /// \warning This is a workaround for Sword constness
- sword::ListKey result = results;
-
- int count = result.Count();
+ int count = result.getCount();
if (!count)
return;
diff --git a/src/frontend/searchdialog/btsearchresultarea.h b/src/frontend/searchdialog/btsearchresultarea.h
index bd75a02..e7a167d 100644
--- a/src/frontend/searchdialog/btsearchresultarea.h
+++ b/src/frontend/searchdialog/btsearchresultarea.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -134,16 +136,6 @@ class BtSearchResultArea : public QWidget {
void initConnections();
/**
- * This function breakes the queryString into clucene tokens
- */
- QStringList queryParser(const QString& queryString);
-
- /**
- * This function highlights the searched text in the content using the search type given by search flags
- */
- QString highlightSearchedText(const QString& content, const QString& searchedText);
-
- /**
* Load the settings from the resource file
*/
void loadDialogSettings();
diff --git a/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp
index a1debc3..f1acddc 100644
--- a/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp
+++ b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,7 +13,7 @@
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <QWebView>
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
#include "util/directory.h"
@@ -22,7 +22,6 @@ namespace Search {
BtSearchSyntaxHelpDialog::BtSearchSyntaxHelpDialog(QWidget *parent, Qt::WindowFlags wflags)
: QDialog(parent, wflags)
{
- setAttribute(Qt::WA_DeleteOnClose);
resize(550, 340);
QVBoxLayout *l = new QVBoxLayout;
@@ -42,10 +41,6 @@ BtSearchSyntaxHelpDialog::BtSearchSyntaxHelpDialog(QWidget *parent, Qt::WindowFl
retranslateUi();
}
-BtSearchSyntaxHelpDialog::~BtSearchSyntaxHelpDialog() {
- // Intentionally empty
-}
-
void BtSearchSyntaxHelpDialog::retranslateUi() {
namespace DU = util::directory;
@@ -219,7 +214,7 @@ void BtSearchSyntaxHelpDialog::retranslateUi() {
m_webView->setHtml(html, QUrl::fromLocalFile(DU::getIconDir().path()));
- util::prepareDialogBox(m_buttons);
+ message::prepareDialogBox(m_buttons);
}
void BtSearchSyntaxHelpDialog::linkClicked(const QUrl &url) {
diff --git a/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h
index 89cc805..74b74b5 100644
--- a/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h
+++ b/src/frontend/searchdialog/btsearchsyntaxhelpdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -22,7 +24,6 @@ class BtSearchSyntaxHelpDialog: public QDialog {
Q_OBJECT
public:
BtSearchSyntaxHelpDialog(QWidget *parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
- ~BtSearchSyntaxHelpDialog();
protected:
void retranslateUi();
diff --git a/src/frontend/searchdialog/chistorycombobox.cpp b/src/frontend/searchdialog/chistorycombobox.cpp
index cf77627..231bd65 100644
--- a/src/frontend/searchdialog/chistorycombobox.cpp
+++ b/src/frontend/searchdialog/chistorycombobox.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/chistorycombobox.h b/src/frontend/searchdialog/chistorycombobox.h
index dffbcd8..922b042 100644
--- a/src/frontend/searchdialog/chistorycombobox.h
+++ b/src/frontend/searchdialog/chistorycombobox.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/cmoduleresultview.cpp b/src/frontend/searchdialog/cmoduleresultview.cpp
index ab4810b..5bbc32f 100644
--- a/src/frontend/searchdialog/cmoduleresultview.cpp
+++ b/src/frontend/searchdialog/cmoduleresultview.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,10 +18,12 @@
#include <QtAlgorithms>
#include "backend/drivers/cswordmoduleinfo.h"
+#include "bibletimeapp.h"
#include "frontend/cexportmanager.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
-#include "util/directory.h"
+#include "backend/config/btconfig.h"
namespace Search {
@@ -43,8 +45,6 @@ CModuleResultView::~CModuleResultView() {
/** Initializes this widget. */
void CModuleResultView::initView() {
- namespace DU = util::directory;
-
// see also csearchresultview.cpp
setToolTip(tr("Works chosen for the search and the number of the hits in each work"));
setHeaderLabels( QStringList(tr("Work")) << tr("Hits") );
@@ -62,7 +62,7 @@ void CModuleResultView::initView() {
m_popup = new QMenu(this);
m_actions.copyMenu = new QMenu(tr("Copy..."), m_popup);
- m_actions.copyMenu->setIcon(DU::getIcon( CResMgr::searchdialog::result::moduleList::copyMenu::icon) );
+ m_actions.copyMenu->setIcon(util::getIcon( CResMgr::searchdialog::result::moduleList::copyMenu::icon) );
m_actions.copy.result = new QAction(tr("Reference only"), this);
QObject::connect(m_actions.copy.result, SIGNAL(triggered()), this, SLOT(copyResult()) );
m_actions.copyMenu->addAction(m_actions.copy.result);
@@ -72,7 +72,7 @@ void CModuleResultView::initView() {
m_popup->addMenu(m_actions.copyMenu);
m_actions.saveMenu = new QMenu(tr("Save..."), m_popup);
- m_actions.saveMenu->setIcon(DU::getIcon( CResMgr::searchdialog::result::moduleList::saveMenu::icon) );
+ m_actions.saveMenu->setIcon(util::getIcon( CResMgr::searchdialog::result::moduleList::saveMenu::icon) );
m_actions.save.result = new QAction(tr("Reference only"), this);
QObject::connect(m_actions.save.result, SIGNAL(triggered()), this, SLOT(saveResult()) );
m_actions.saveMenu->addAction(m_actions.save.result);
@@ -82,7 +82,7 @@ void CModuleResultView::initView() {
m_popup->addMenu(m_actions.saveMenu);
m_actions.printMenu = new QMenu(tr("Print..."), m_popup);
- m_actions.printMenu->setIcon(DU::getIcon(CResMgr::searchdialog::result::moduleList::printMenu::icon));
+ m_actions.printMenu->setIcon(util::getIcon(CResMgr::searchdialog::result::moduleList::printMenu::icon));
m_actions.print.result = new QAction(tr("Reference with text"), this);
QObject::connect(m_actions.print.result, SIGNAL(triggered()), this, SLOT(printResult()) );
m_actions.printMenu->addAction(m_actions.print.result);
@@ -96,48 +96,45 @@ void CModuleResultView::initConnections() {
this, SLOT(executed(QTreeWidgetItem*, QTreeWidgetItem*)));
}
-void CModuleResultView::setupTree(
- const CSwordModuleSearch::Results &results,
- const QString &searchedText)
+void CModuleResultView::setupTree(const CSwordModuleSearch::Results & results,
+ const QString & searchedText)
{
+ /// \todo implement sorting in this method.
+
clear();
m_results = results;
- /// \todo this class is for sorting
- //util::CSortListViewItem* item = 0;
- //util::CSortListViewItem* oldItem = 0;
- QTreeWidgetItem* item = 0;
-
qDeleteAll(m_strongsResults);
m_strongsResults.clear();
bool strongsAvailable = false;
- Q_FOREACH(const CSwordModuleInfo *m, results.keys()) {
- sword::ListKey result = results.value(m);
-
- item = new QTreeWidgetItem(this, QStringList(m->name()) << QString::number(result.Count()) );
- /// \todo item->setColumnSorting(1, util::CSortListViewItem::Number);
-
- item->setIcon(0, util::tool::getIconForModule(m) );
- //----------------------------------------------------------------------
- // we need to make a decision here. Either don't show any Strong's
- // number translations, or show the first one in the search text, or
- // figure out how to show them all.
- // I choose option number 2 at this time.
- //----------------------------------------------------------------------
- int sstIndex, sTokenIndex; // strong search text index for finding "strong:"
- if ((sstIndex = searchedText.indexOf("strong:", 0)) != -1) {
- QString sNumber;
- //--------------------------------------------------
- // get the strongs number from the search text
- //--------------------------------------------------
- // first find the first space after "strong:"
- // this should indicate a change in search token
- sstIndex = sstIndex + 7;
- sTokenIndex = searchedText.indexOf(" ", sstIndex);
- sNumber = searchedText.mid(sstIndex, sTokenIndex - sstIndex);
+ Q_FOREACH(const CSwordModuleInfo * m, results.keys()) {
+ /// \todo Remove this constructor hack once sword gets it right:
+ const int count = sword::ListKey(results.value(m)).getCount();
+ QTreeWidgetItem * item = new QTreeWidgetItem(this,
+ QStringList(m->name())
+ << QString::number(count));
+
+ item->setIcon(0, util::tool::getIconForModule(m));
+ /*
+ We need to make a decision here. Either don't show any Strong's
+ number translations, or show the first one in the search text, or
+ figure out how to show them all. I choose option number 2 at this time.
+ */
+
+ // strong search text index for finding "strong:"
+ int sstIndex = searchedText.indexOf("strong:", 0);
+ if (sstIndex != -1) {
+ /*
+ Get the strongs number from the search text. First find the first
+ space after "strong:". This should indicate a change in search
+ token
+ */
+ sstIndex += 7;
+ const int sTokenIndex = searchedText.indexOf(" ", sstIndex);
+ const QString sNumber(searchedText.mid(sstIndex, sTokenIndex - sstIndex));
setupStrongsResults(m, results[m], item, sNumber);
@@ -146,7 +143,7 @@ void CModuleResultView::setupTree(
}
};
- //Allow to hide the module strongs if there are any available
+ // Allow to hide the module strongs if there are any available
setRootIsDecorated( strongsAvailable );
}
@@ -269,8 +266,8 @@ void CModuleResultView::printResult() {
CSwordModuleInfo *m = activeModule();
if (m != 0) {
CExportManager mgr(true, tr("Printing search result"));
- mgr.printKeyList(m_results[m], m, CBTConfig::getDisplayOptionDefaults(),
- CBTConfig::getFilterOptionDefaults());
+ mgr.printKeyList(m_results[m], m, btConfig().getDisplayOptions(),
+ btConfig().getFilterOptions());
};
}
diff --git a/src/frontend/searchdialog/cmoduleresultview.h b/src/frontend/searchdialog/cmoduleresultview.h
index 526ac16..24571d9 100644
--- a/src/frontend/searchdialog/cmoduleresultview.h
+++ b/src/frontend/searchdialog/cmoduleresultview.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/crangechooserdialog.cpp b/src/frontend/searchdialog/crangechooserdialog.cpp
index 6a8c89d..efece49 100644
--- a/src/frontend/searchdialog/crangechooserdialog.cpp
+++ b/src/frontend/searchdialog/crangechooserdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -19,8 +19,8 @@
#include <QPushButton>
#include <QTextEdit>
#include <QVBoxLayout>
-#include "backend/config/cbtconfig.h"
-#include "util/dialogutil.h"
+#include "backend/config/btconfig.h"
+#include "frontend/messagedialog.h"
// Sword includes:
#include "versekey.h"
@@ -37,8 +37,8 @@ CRangeChooserDialog::CRangeChooserDialog(QWidget *parentDialog)
retranslateUi();
// Add the existing scopes
- CBTConfig::StringMap map = CBTConfig::get(CBTConfig::searchScopes);
- CBTConfig::StringMap::Iterator it;
+ BtConfig::StringMap map = btConfig().getSearchScopesForCurrentLocale();
+ BtConfig::StringMap::Iterator it;
for (it = map.begin(); it != map.end(); ++it) {
new RangeItem(it.key(), it.value(), m_rangeList);
}
@@ -74,7 +74,7 @@ void CRangeChooserDialog::initView() {
m_buttonBox->setStandardButtons(QDialogButtonBox::Ok
| QDialogButtonBox::Cancel
| QDialogButtonBox::RestoreDefaults);
- util::prepareDialogBox(m_buttonBox);
+ message::prepareDialogBox(m_buttonBox);
QHBoxLayout *rangeButtonsLayout = new QHBoxLayout();
rangeButtonsLayout->addWidget(m_newRangeButton);
@@ -176,6 +176,7 @@ void CRangeChooserDialog::addNewRange() {
void CRangeChooserDialog::selectedRangeChanged(QListWidgetItem * current,
QListWidgetItem * previous)
{
+ Q_UNUSED(current);
if (previous) {
Q_ASSERT(dynamic_cast<RangeItem*>(previous) != 0);
saveCurrentToRange(static_cast<RangeItem*>(previous));
@@ -211,9 +212,9 @@ void CRangeChooserDialog::updateResultList() {
//HACK: repair range to work with Sword 1.5.6
const QString range = m_rangeEdit->toPlainText().replace(QRegExp("\\s{0,}-\\s{0,}"), "-");
- sword::ListKey verses = VK().ParseVerseList(range.toUtf8().constData(),
+ sword::ListKey verses = VK().parseVerseList(range.toUtf8().constData(),
"Genesis 1:1", true);
- for (int i = 0; i < verses.Count(); ++i) {
+ for (int i = 0; i < verses.getCount(); i++) {
new QListWidgetItem(QString::fromUtf8(verses.getElement(i)->getRangeText()),
m_resultList);
}
@@ -238,22 +239,23 @@ void CRangeChooserDialog::accept() {
// Save the new sorted map of search scopes:
m_rangeList->sortItems();
- CBTConfig::StringMap map;
+ BtConfig::StringMap map;
for (int i = 0; i < m_rangeList->count(); i++) {
Q_ASSERT(dynamic_cast<RangeItem*>(m_rangeList->item(i)) != 0);
const RangeItem * item = static_cast<RangeItem*>(m_rangeList->item(i));
map[item->caption()] = item->range();
}
- CBTConfig::set(CBTConfig::searchScopes, map);
+ btConfig().setSearchScopesWithCurrentLocale(map);
QDialog::accept();
}
void CRangeChooserDialog::restoreDefaults() {
- typedef CBTConfig::StringMap::ConstIterator SMCI;
+ typedef BtConfig::StringMap::ConstIterator SMCI;
m_rangeList->clear();
- const CBTConfig::StringMap map = CBTConfig::getDefault(CBTConfig::searchScopes);
+ btConfig().deleteSearchScopesWithCurrentLocale();
+ const BtConfig::StringMap map = btConfig().getSearchScopesForCurrentLocale();
for (SMCI it = map.begin(); it != map.end(); ++it) {
new RangeItem(it.key(), it.value(), m_rangeList);
};
diff --git a/src/frontend/searchdialog/crangechooserdialog.h b/src/frontend/searchdialog/crangechooserdialog.h
index db2ad30..a9cbaf4 100644
--- a/src/frontend/searchdialog/crangechooserdialog.h
+++ b/src/frontend/searchdialog/crangechooserdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/csearchdialog.cpp b/src/frontend/searchdialog/csearchdialog.cpp
index 8ce55d4..54981e3 100644
--- a/src/frontend/searchdialog/csearchdialog.cpp
+++ b/src/frontend/searchdialog/csearchdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -20,18 +20,23 @@
#include <QVBoxLayout>
#include <QWidget>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/cswordmodulesearch.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
+#include "bibletimeapp.h"
#include "frontend/btmoduleindexdialog.h"
#include "frontend/searchdialog/btsearchoptionsarea.h"
#include "frontend/searchdialog/btsearchresultarea.h"
+#include "frontend/messagedialog.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
-#include "util/dialogutil.h"
+#include "util/geticon.h"
+namespace {
+const QString GeometryKey = "GUI/SearchDialog/geometry";
+} // anonymous namespace
+
namespace Search {
static CSearchDialog* m_staticDialog = 0;
@@ -78,9 +83,7 @@ CSearchDialog* CSearchDialog::getSearchDialog() {
CSearchDialog::CSearchDialog(QWidget *parent)
: QDialog(parent), /*m_searchButton(0),*/ m_closeButton(0),
m_searchResultArea(0), m_searchOptionsArea(0) {
- namespace DU = util::directory;
-
- setWindowIcon(DU::getIcon(CResMgr::searchdialog::icon));
+ setWindowIcon(util::getIcon(CResMgr::searchdialog::icon));
setWindowTitle(tr("Search"));
setAttribute(Qt::WA_DeleteOnClose);
@@ -123,7 +126,7 @@ void CSearchDialog::startSearch() {
moduleNames.append("</center><br>");
// Ask the user about unindexed modules:
- int result = util::showQuestion(
+ int result = message::showQuestion(
this, tr("Missing indices"),
tr("The following modules need to be indexed before they can be"
" searched in:") + moduleNames + tr("Indexing could take a l"
@@ -185,7 +188,7 @@ QString CSearchDialog::prepareSearchText(const QString& orig) {
qDebug() << "After syntax characters removed:" << text;
text.replace(andWords, "\"and\"");
text.replace(orWords, "\"or\"");
- qDebug() << "After andor repclaced:" << text;
+ qDebug() << "After \"and\" and \"or\" replaced:" << text;
text.replace(" ", " AND ");
}
if (m_searchOptionsArea->searchType() == BtSearchOptionsArea::OrType) {
@@ -219,7 +222,6 @@ void CSearchDialog::setSearchText( const QString &searchText ) {
/** Initializes this object. */
void CSearchDialog::initView() {
- namespace DU = util::directory;
QVBoxLayout* verticalLayout = new QVBoxLayout(this);
setLayout(verticalLayout);
@@ -244,7 +246,7 @@ void CSearchDialog::initView() {
m_closeButton = new QPushButton(this);
m_closeButton->setText(tr("&Close"));
- m_closeButton->setIcon(DU::getIcon(CResMgr::searchdialog::close_icon));
+ m_closeButton->setIcon(util::getIcon(CResMgr::searchdialog::close_icon));
horizontalLayout->addWidget(m_closeButton);
verticalLayout->addLayout(horizontalLayout);
@@ -283,15 +285,11 @@ void CSearchDialog::closeButtonClicked() {
}
void CSearchDialog::loadDialogSettings() {
- resize(CBTConfig::get(CBTConfig::searchDialogWidth), CBTConfig::get(CBTConfig::searchDialogHeight));
- move(CBTConfig::get(CBTConfig::searchDialogX), CBTConfig::get(CBTConfig::searchDialogY));
+ restoreGeometry(btConfig().value<QByteArray>(GeometryKey, QByteArray()));
}
void CSearchDialog::saveDialogSettings() const {
- CBTConfig::set(CBTConfig::searchDialogWidth, size().width());
- CBTConfig::set(CBTConfig::searchDialogHeight, size().height());
- CBTConfig::set(CBTConfig::searchDialogX, x());
- CBTConfig::set(CBTConfig::searchDialogY, y());
+ btConfig().setValue(GeometryKey, saveGeometry());
}
diff --git a/src/frontend/searchdialog/csearchdialog.h b/src/frontend/searchdialog/csearchdialog.h
index dd2fcd2..dde8537 100644
--- a/src/frontend/searchdialog/csearchdialog.h
+++ b/src/frontend/searchdialog/csearchdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/searchdialog/csearchresultview.cpp b/src/frontend/searchdialog/csearchresultview.cpp
index 7966e56..c08e5cc 100644
--- a/src/frontend/searchdialog/csearchresultview.cpp
+++ b/src/frontend/searchdialog/csearchresultview.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,10 +16,12 @@
#include <QTreeWidgetItem>
#include <QWidget>
#include "backend/keys/cswordversekey.h"
+#include "bibletimeapp.h"
#include "frontend/cdragdrop.h"
#include "frontend/cexportmanager.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
+#include "backend/config/btconfig.h"
namespace Search {
@@ -33,8 +35,6 @@ CSearchResultView::CSearchResultView(QWidget* parent)
/** Initializes the view of this widget. */
void CSearchResultView::initView() {
- namespace DU = util::directory;
-
setToolTip(tr("Search result of the selected work"));
setHeaderLabel(tr("Results"));
setDragEnabled(true);
@@ -45,7 +45,7 @@ void CSearchResultView::initView() {
m_popup = new QMenu(this);
m_actions.copyMenu = new QMenu(tr("Copy..."), m_popup);
- m_actions.copyMenu->setIcon(DU::getIcon(CResMgr::searchdialog::result::foundItems::copyMenu::icon));
+ m_actions.copyMenu->setIcon(util::getIcon(CResMgr::searchdialog::result::foundItems::copyMenu::icon));
m_actions.copy.result = new QAction(tr("Reference only"), this);
QObject::connect(m_actions.copy.result, SIGNAL(triggered()), this, SLOT(copyItems()) );
@@ -59,7 +59,7 @@ void CSearchResultView::initView() {
m_popup->addMenu(m_actions.copyMenu);
m_actions.saveMenu = new QMenu(tr("Save..."), m_popup);
- m_actions.saveMenu->setIcon(DU::getIcon(CResMgr::searchdialog::result::foundItems::saveMenu::icon));
+ m_actions.saveMenu->setIcon(util::getIcon(CResMgr::searchdialog::result::foundItems::saveMenu::icon));
m_actions.save.result = new QAction(tr("Reference only"), this);
QObject::connect(m_actions.save.result, SIGNAL(triggered()), this, SLOT(saveItems()) );
@@ -71,7 +71,7 @@ void CSearchResultView::initView() {
m_popup->addMenu(m_actions.saveMenu);
m_actions.printMenu = new QMenu(tr("Print..."), m_popup);
- m_actions.printMenu->setIcon(DU::getIcon(CResMgr::searchdialog::result::foundItems::printMenu::icon));
+ m_actions.printMenu->setIcon(util::getIcon(CResMgr::searchdialog::result::foundItems::printMenu::icon));
m_actions.print.result = new QAction(tr("Reference with text"), this);
QObject::connect(m_actions.print.result, SIGNAL(triggered()), this, SLOT(printItems()) );
@@ -91,16 +91,14 @@ void CSearchResultView::initConnections() {
/** Setups the list with the given module. */
void CSearchResultView::setupTree(const CSwordModuleInfo *m,
- const sword::ListKey &results)
+ const sword::ListKey & result)
{
clear();
if (!m) return;
m_module = m;
- /// \warning This is a workaround for Sword constness
- sword::ListKey &result = const_cast<sword::ListKey&>(results);
- const int count = result.Count();
+ const int count = result.getCount();
if (!count) return;
setUpdatesEnabled(false);
@@ -169,7 +167,7 @@ void CSearchResultView::printItems() {
foreach (QTreeWidgetItem* k, items) {
list.append( k->text(0) );
}
- mgr.printKeyList( list, module(), CBTConfig::getDisplayOptionDefaults(), CBTConfig::getFilterOptionDefaults() );
+ mgr.printKeyList( list, module(), btConfig().getDisplayOptions(), btConfig().getFilterOptions() );
}
void CSearchResultView::saveItems() {
diff --git a/src/frontend/searchdialog/csearchresultview.h b/src/frontend/searchdialog/csearchresultview.h
index 1d37cbd..76b6d38 100644
--- a/src/frontend/searchdialog/csearchresultview.h
+++ b/src/frontend/searchdialog/csearchresultview.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/btfontchooserwidget.cpp b/src/frontend/settingsdialogs/btfontchooserwidget.cpp
index 4d943c4..7fcf6b5 100644
--- a/src/frontend/settingsdialogs/btfontchooserwidget.cpp
+++ b/src/frontend/settingsdialogs/btfontchooserwidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/btfontchooserwidget.h b/src/frontend/settingsdialogs/btfontchooserwidget.h
index 9eb1f4d..eba5607 100644
--- a/src/frontend/settingsdialogs/btfontchooserwidget.h
+++ b/src/frontend/settingsdialogs/btfontchooserwidget.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/btfontsettings.cpp b/src/frontend/settingsdialogs/btfontsettings.cpp
index 77a8b0b..57a8aba 100644
--- a/src/frontend/settingsdialogs/btfontsettings.cpp
+++ b/src/frontend/settingsdialogs/btfontsettings.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -16,11 +16,13 @@
#include <QLabel>
#include <QVBoxLayout>
#include <QWidget>
+#include "backend/config/btconfig.h"
+#include "bibletimeapp.h"
#include "frontend/settingsdialogs/btfontchooserwidget.h"
#include "frontend/settingsdialogs/cconfigurationdialog.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
-#include "util/directory.h"
// Sword includes:
#include <localemgr.h>
@@ -28,10 +30,8 @@
BtFontSettingsPage::BtFontSettingsPage(CConfigurationDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::settings::fonts::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::settings::fonts::icon), parent)
{
- namespace DU = util::directory;
-
m_languageLabel = new QLabel(this);
m_languageComboBox = new QComboBox(this);
m_languageLabel->setBuddy(m_languageComboBox);
@@ -58,13 +58,13 @@ BtFontSettingsPage::BtFontSettingsPage(CConfigurationDialog *parent)
? &L::abbrev
: &L::translatedName;
- m_fontMap.insert((l->*f)(), CBTConfig::get(l));
+ m_fontMap.insert((l->*f)(), btConfig().getFontForLanguage(*l));
}
for (FontMap::ConstIterator it = m_fontMap.constBegin(); it != m_fontMap.constEnd(); ++it) {
const QString &k = it.key();
if (m_fontMap[k].first) { // show font icon
- m_languageComboBox->addItem(DU::getIcon("fonts.svg"), k);
+ m_languageComboBox->addItem(util::getIcon("fonts.svg"), k);
} else { // don't show icon for font
m_languageComboBox->addItem(k);
}
@@ -84,7 +84,7 @@ BtFontSettingsPage::BtFontSettingsPage(CConfigurationDialog *parent)
connect(m_languageComboBox, SIGNAL(activated(const QString&)),
this, SLOT(newDisplayWindowFontAreaSelected(const QString&)));
- const CBTConfig::FontSettingsPair &v = m_fontMap.value(m_languageComboBox->currentText());
+ const BtConfig::FontSettingsPair &v = m_fontMap.value(m_languageComboBox->currentText());
m_fontChooser->setFont(v.second);
useOwnFontClicked(v.first);
m_languageCheckBox->setChecked(v.first);
@@ -116,12 +116,12 @@ void BtFontSettingsPage::save() const {
// We possibly use a language, for which we have only the abbrevation
if (!lang->abbrev().isEmpty()) {
// Create a temp language:
- CLanguageMgr::Language l(k, k, k);
- CBTConfig::set(&l, it.value());
+ const CLanguageMgr::Language l(k, k, k);
+ btConfig().setFontForLanguage(l, it.value());
}
}
else {
- CBTConfig::set(lang, it.value());
+ btConfig().setFontForLanguage(*lang, it.value());
}
}
}
@@ -129,23 +129,21 @@ void BtFontSettingsPage::save() const {
void BtFontSettingsPage::newDisplayWindowFontSelected(const QFont &newFont) {
const QString languageName = m_languageComboBox->currentText();
m_fontMap.insert(languageName,
- CBTConfig::FontSettingsPair(m_fontMap[languageName].first, newFont));
+ BtConfig::FontSettingsPair(m_fontMap[languageName].first, newFont));
}
void BtFontSettingsPage::newDisplayWindowFontAreaSelected(const QString &usage) {
- const CBTConfig::FontSettingsPair &p = m_fontMap[usage];
+ const BtConfig::FontSettingsPair &p = m_fontMap[usage];
useOwnFontClicked(p.first);
m_languageCheckBox->setChecked(p.first);
m_fontChooser->setFont(p.second);
}
void BtFontSettingsPage::useOwnFontClicked(bool isOn) {
- namespace DU = util::directory;
-
m_fontChooser->setEnabled(isOn);
m_fontMap[m_languageComboBox->currentText()].first = isOn;
m_languageComboBox->setItemIcon(m_languageComboBox->currentIndex(),
- isOn ? DU::getIcon("fonts.svg") : QIcon());
+ isOn ? util::getIcon("fonts.svg") : QIcon());
}
void BtFontSettingsPage::retranslateUi() {
diff --git a/src/frontend/settingsdialogs/btfontsettings.h b/src/frontend/settingsdialogs/btfontsettings.h
index 659cd75..70d0d20 100644
--- a/src/frontend/settingsdialogs/btfontsettings.h
+++ b/src/frontend/settingsdialogs/btfontsettings.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,7 +16,7 @@
#include <QMap>
#include <QWidget>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
class BtFontChooserWidget;
@@ -30,7 +32,7 @@ class BtFontSettingsPage: public BtConfigDialog::Page {
private: /* Types: */
- typedef QMap<QString, CBTConfig::FontSettingsPair> FontMap;
+ typedef QMap<QString, BtConfig::FontSettingsPair> FontMap;
public: /* Methods: */
diff --git a/src/frontend/settingsdialogs/btlanguagesettings.cpp b/src/frontend/settingsdialogs/btlanguagesettings.cpp
index be2dd17..37e53c8 100644
--- a/src/frontend/settingsdialogs/btlanguagesettings.cpp
+++ b/src/frontend/settingsdialogs/btlanguagesettings.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,11 +14,12 @@
#include <QLabel>
#include <QVBoxLayout>
#include <QWidget>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
+#include "bibletimeapp.h"
#include "frontend/settingsdialogs/cconfigurationdialog.h"
#include "util/cresmgr.h"
+#include "util/geticon.h"
#include "util/tool.h"
-#include "util/directory.h"
// Sword includes:
#include <localemgr.h>
@@ -29,7 +30,7 @@ typedef std::list<sword::SWBuf>::const_iterator SBLCI;
BtLanguageSettingsPage::BtLanguageSettingsPage(CConfigurationDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::settings::languages::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::settings::languages::icon), parent)
{
m_swordLocaleCombo = new QComboBox(this);
m_languageNamesLabel = new QLabel(this);
@@ -44,7 +45,7 @@ BtLanguageSettingsPage::BtLanguageSettingsPage(CConfigurationDialog *parent)
}
void BtLanguageSettingsPage::save() {
- CBTConfig::set(CBTConfig::language, m_swordLocaleCombo->itemData(m_swordLocaleCombo->currentIndex()).toString());
+ btConfig().setValue("language", m_swordLocaleCombo->itemData(m_swordLocaleCombo->currentIndex()));
}
void BtLanguageSettingsPage::resetLanguage() {
@@ -67,14 +68,14 @@ void BtLanguageSettingsPage::resetLanguage() {
}
}
}
- CBTConfig::set(CBTConfig::language, best);
+ btConfig().setValue("language", best);
}
QVector<QString> BtLanguageSettingsPage::bookNameAbbreviationsTryVector() {
QVector<QString> atv;
atv.reserve(4);
{
- QString settingsLanguage = CBTConfig::get(CBTConfig::language);
+ QString settingsLanguage = btConfig().value<QString>("language");
if (!settingsLanguage.isEmpty())
atv.append(settingsLanguage);
}
@@ -132,5 +133,7 @@ void BtLanguageSettingsPage::retranslateUi() {
setHeaderText(tr("Languages"));
m_languageNamesLabel->setText(tr("Language for names of Bible books:"));
- m_swordLocaleCombo->setToolTip(tr("The languages which can be used for the biblical booknames"));
+ const QString toolTip(tr("The languages which can be used for the biblical book names. Translations are provided by the Sword library."));
+ m_languageNamesLabel->setToolTip(toolTip);
+ m_swordLocaleCombo->setToolTip(toolTip);
}
diff --git a/src/frontend/settingsdialogs/btlanguagesettings.h b/src/frontend/settingsdialogs/btlanguagesettings.h
index 7c3b0c9..89caaf2 100644
--- a/src/frontend/settingsdialogs/btlanguagesettings.h
+++ b/src/frontend/settingsdialogs/btlanguagesettings.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/btshortcutsdialog.cpp b/src/frontend/settingsdialogs/btshortcutsdialog.cpp
index a5d856d..10601f6 100644
--- a/src/frontend/settingsdialogs/btshortcutsdialog.cpp
+++ b/src/frontend/settingsdialogs/btshortcutsdialog.cpp
@@ -2,13 +2,13 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/settingsdialogs/btshortcutsdialog.h"
-#include "util/dialogutil.h"
+#include "frontend/messagedialog.h"
#include <QDialogButtonBox>
#include <QGridLayout>
@@ -56,7 +56,7 @@ BtShortcutsDialog::BtShortcutsDialog(QWidget* parent)
gridLayout->addWidget(m_alternateLabel, 1, 1);
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- util::prepareDialogBox(buttons);
+ message::prepareDialogBox(buttons);
vLayout->addWidget(buttons);
connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
diff --git a/src/frontend/settingsdialogs/btshortcutsdialog.h b/src/frontend/settingsdialogs/btshortcutsdialog.h
index f475ebd..722cef9 100644
--- a/src/frontend/settingsdialogs/btshortcutsdialog.h
+++ b/src/frontend/settingsdialogs/btshortcutsdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/btshortcutseditor.cpp b/src/frontend/settingsdialogs/btshortcutseditor.cpp
index 618e5ed..2e943eb 100644
--- a/src/frontend/settingsdialogs/btshortcutseditor.cpp
+++ b/src/frontend/settingsdialogs/btshortcutseditor.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/btshortcutseditor.h b/src/frontend/settingsdialogs/btshortcutseditor.h
index f9a812a..d58ac08 100644
--- a/src/frontend/settingsdialogs/btshortcutseditor.h
+++ b/src/frontend/settingsdialogs/btshortcutseditor.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/btstandardworkstab.cpp b/src/frontend/settingsdialogs/btstandardworkstab.cpp
new file mode 100644
index 0000000..9cef549
--- /dev/null
+++ b/src/frontend/settingsdialogs/btstandardworkstab.cpp
@@ -0,0 +1,203 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "frontend/settingsdialogs/btstandardworkstab.h"
+
+#include <QCheckBox>
+#include <QComboBox>
+#include <QFormLayout>
+#include <QLabel>
+#include <QVBoxLayout>
+#include "backend/config/btconfig.h"
+#include "backend/managers/cswordbackend.h"
+#include "frontend/settingsdialogs/cswordsettings.h"
+#include "util/tool.h"
+
+
+BtStandardWorksTab::BtStandardWorksTab(CSwordSettingsPage *parent)
+ : QWidget(parent)
+{
+ typedef QList<CSwordModuleInfo*>::const_iterator MLCI;
+
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
+ mainLayout->setMargin(5);
+ mainLayout->setSpacing(2);
+
+ m_explanationLabel = new QLabel(this);
+ m_explanationLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
+ m_explanationLabel->setMaximumHeight(50);
+ m_explanationLabel->setMinimumWidth(300);
+ mainLayout->addWidget(m_explanationLabel);
+
+ QFormLayout *formLayout = new QFormLayout;
+ formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
+
+#define STANDARD_WORKS_TAB_ADD_ROW(name) \
+ if (true) { \
+ m_ ## name ## Label = new QLabel(this); \
+ m_ ## name ## Combo = new QComboBox(this); \
+ formLayout->addRow(m_ ## name ## Label, m_ ## name ## Combo); \
+ } else (void) 0
+
+ STANDARD_WORKS_TAB_ADD_ROW(standardBible);
+ STANDARD_WORKS_TAB_ADD_ROW(standardCommentary);
+ STANDARD_WORKS_TAB_ADD_ROW(standardLexicon);
+ STANDARD_WORKS_TAB_ADD_ROW(standardDailyDevotional);
+ STANDARD_WORKS_TAB_ADD_ROW(standardHebrewStrongsLexicon);
+ STANDARD_WORKS_TAB_ADD_ROW(standardGreekStrongsLexicon);
+ STANDARD_WORKS_TAB_ADD_ROW(standardHebrewMorphLexicon);
+ STANDARD_WORKS_TAB_ADD_ROW(standardGreekMorphLexicon);
+
+ mainLayout->addLayout(formLayout);
+ mainLayout->addStretch();
+
+ //fill the comboboxes with the right modules
+
+ const QList<CSwordModuleInfo*> &modules(CSwordBackend::instance()->moduleList());
+ QString modDescript;
+ for (MLCI it(modules.begin()); it != modules.end(); it++) {
+ modDescript = (*it)->config(CSwordModuleInfo::Description);
+
+ switch ((*it)->type()) {
+ case CSwordModuleInfo::Bible:
+ m_standardBibleCombo->addItem(modDescript);
+ break;
+ case CSwordModuleInfo::Commentary:
+ m_standardCommentaryCombo->addItem(modDescript);
+ break;
+ case CSwordModuleInfo::Lexicon: {
+ bool inserted = false;
+ if ((*it)->has(CSwordModuleInfo::HebrewDef)) {
+ m_standardHebrewStrongsLexiconCombo->addItem(modDescript);
+ inserted = true;
+ }
+ if ((*it)->has(CSwordModuleInfo::GreekDef)) {
+ m_standardGreekStrongsLexiconCombo->addItem(modDescript);
+ inserted = true;
+ }
+ if ((*it)->has(CSwordModuleInfo::HebrewParse)) {
+ m_standardHebrewMorphLexiconCombo->addItem(modDescript);
+ inserted = true;
+ }
+ if ((*it)->has(CSwordModuleInfo::GreekParse)) {
+ m_standardGreekMorphLexiconCombo->addItem(modDescript);
+ inserted = true;
+ }
+ if ((*it)->category() == CSwordModuleInfo::DailyDevotional) {
+ m_standardDailyDevotionalCombo->addItem(modDescript);
+ inserted = true;
+ }
+
+ if (!inserted) { //daily dvotionals, striong lexicons etc. are not very useful for word lookups
+ m_standardLexiconCombo->addItem(modDescript);
+ }
+ break;
+ }
+ default://unknown type
+ break;
+ } //switch
+ } //for
+
+ //using two lists and one loop is better than six loops with almost the same code :)
+ QList<QComboBox*> comboList;
+ QStringList moduleList;
+
+ // fill combobox and modulelist
+ const CSwordModuleInfo* m;
+
+#define STANDARD_WORKS_COMBO_ADD(name) \
+ comboList.append(m_ ## name ## Combo); \
+ m = btConfig().getDefaultSwordModuleByType(#name); \
+ moduleList << (m != 0 ? m->config(CSwordModuleInfo::Description) : QString::null);
+
+ STANDARD_WORKS_COMBO_ADD(standardBible);
+ STANDARD_WORKS_COMBO_ADD(standardCommentary);
+ STANDARD_WORKS_COMBO_ADD(standardLexicon);
+ STANDARD_WORKS_COMBO_ADD(standardDailyDevotional);
+ STANDARD_WORKS_COMBO_ADD(standardHebrewStrongsLexicon);
+ STANDARD_WORKS_COMBO_ADD(standardGreekStrongsLexicon);
+ STANDARD_WORKS_COMBO_ADD(standardHebrewMorphLexicon);
+ STANDARD_WORKS_COMBO_ADD(standardGreekMorphLexicon);
+
+ QString module = QString::null;
+ int item = 0;
+ int count = 0;
+ QListIterator<QComboBox*> it(comboList);
+ while (it.hasNext()) {
+ //for (QComboBox* combo = comboList.first(); combo; combo = comboList.next() )
+ QComboBox* combo = it.next();
+ module = moduleList[comboList.indexOf(combo)];
+ count = combo->count();
+
+ for (item = 0; item < count; item++) {
+ if (combo->itemText(item) == module ) {
+ combo->setCurrentIndex(item);
+ break;
+ }
+ }
+ }
+
+ retranslateUi();
+}
+
+#define STANDARD_WORKS_SET_DEFAULT(name) \
+ btConfig().setDefaultSwordModuleByType(\
+ #name, \
+ CSwordBackend::instance()->findModuleByDescription(m_ ## name ## Combo->currentText()) \
+ );
+
+void BtStandardWorksTab::save() {
+ STANDARD_WORKS_SET_DEFAULT(standardBible);
+ STANDARD_WORKS_SET_DEFAULT(standardCommentary);
+ STANDARD_WORKS_SET_DEFAULT(standardLexicon);
+ STANDARD_WORKS_SET_DEFAULT(standardDailyDevotional);
+ STANDARD_WORKS_SET_DEFAULT(standardHebrewStrongsLexicon);
+ STANDARD_WORKS_SET_DEFAULT(standardGreekStrongsLexicon);
+ STANDARD_WORKS_SET_DEFAULT(standardHebrewMorphLexicon);
+ STANDARD_WORKS_SET_DEFAULT(standardGreekMorphLexicon);
+}
+
+void BtStandardWorksTab::retranslateUi() {
+ util::tool::initExplanationLabel(
+ m_explanationLabel, "",
+ tr("Standard works are used when no particular work is specified, for example "
+ "when a hyperlink into a Bible or lexicon was clicked."));
+
+ m_standardBibleLabel->setText(tr("Bible:"));
+ m_standardBibleCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ m_standardBibleCombo->setToolTip(tr("The standard Bible is used when a hyperlink into a Bible is clicked"));
+
+ m_standardCommentaryLabel->setText(tr("Commentary:"));
+ m_standardCommentaryCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ m_standardCommentaryCombo->setToolTip(tr("The standard commentary is used when a hyperlink into a commentary is clicked"));
+
+ m_standardLexiconLabel->setText(tr("Lexicon:"));
+ m_standardLexiconCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ m_standardLexiconCombo->setToolTip(tr("The standard lexicon is used when a hyperlink into a lexicon is clicked"));
+
+ m_standardDailyDevotionalLabel->setText(tr("Daily devotional:"));
+ m_standardDailyDevotionalCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ m_standardDailyDevotionalCombo->setToolTip(tr("The standard devotional will be used to display a short start up devotional"));
+
+ m_standardHebrewStrongsLexiconLabel->setText(tr("Hebrew Strong's lexicon:"));
+ m_standardHebrewStrongsLexiconCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ m_standardHebrewStrongsLexiconCombo->setToolTip(tr("The standard Hebrew lexicon is used when a hyperlink into a Hebrew lexicon is clicked"));
+
+ m_standardGreekStrongsLexiconLabel->setText(tr("Greek Strong's lexicon:"));
+ m_standardGreekStrongsLexiconCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ m_standardGreekStrongsLexiconCombo->setToolTip(tr("The standard Greek lexicon is used when a hyperlink into a Greek lexicon is clicked"));
+
+ m_standardHebrewMorphLexiconLabel->setText(tr("Hebrew morphological lexicon:"));
+ m_standardHebrewMorphLexiconCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ m_standardHebrewMorphLexiconCombo->setToolTip(tr("The standard morphological lexicon for Hebrew texts is used when a hyperlink of a morphological tag in a Hebrew text is clicked"));
+
+ m_standardGreekMorphLexiconLabel->setText(tr("Greek morphological lexicon:"));
+ m_standardGreekMorphLexiconCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
+ m_standardGreekMorphLexiconCombo->setToolTip(tr("The standard morphological lexicon for Greek texts is used when a hyperlink of a morphological tag in a Greek text is clicked"));
+}
diff --git a/src/frontend/settingsdialogs/btstandardworkstab.h b/src/frontend/settingsdialogs/btstandardworkstab.h
new file mode 100644
index 0000000..0b91b4c
--- /dev/null
+++ b/src/frontend/settingsdialogs/btstandardworkstab.h
@@ -0,0 +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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTSTANDARDWORKSTAB_H
+#define BTSTANDARDWORKSTAB_H
+
+#include <QWidget>
+
+
+class CSwordSettingsPage;
+class QCheckBox;
+class QComboBox;
+class QLabel;
+
+class BtStandardWorksTab: public QWidget {
+
+ Q_OBJECT
+
+ public: /* Methods: */
+
+ BtStandardWorksTab(CSwordSettingsPage * parent);
+
+ void save();
+
+ protected: /* Methods: */
+
+ void retranslateUi();
+
+ private: /* Fields: */
+
+ QLabel * m_explanationLabel;
+
+#define STANDARD_WORKS_TAB_FIELD(name) \
+ QLabel * m_ ## name ## Label; \
+ QComboBox * m_ ## name ## Combo
+
+ STANDARD_WORKS_TAB_FIELD(standardBible);
+ STANDARD_WORKS_TAB_FIELD(standardCommentary);
+ STANDARD_WORKS_TAB_FIELD(standardLexicon);
+ STANDARD_WORKS_TAB_FIELD(standardDailyDevotional);
+ STANDARD_WORKS_TAB_FIELD(standardHebrewStrongsLexicon);
+ STANDARD_WORKS_TAB_FIELD(standardGreekStrongsLexicon);
+ STANDARD_WORKS_TAB_FIELD(standardHebrewMorphLexicon);
+ STANDARD_WORKS_TAB_FIELD(standardGreekMorphLexicon);
+};
+
+#endif /* BTSTANDARDWORKSTAB_H */
diff --git a/src/frontend/settingsdialogs/bttextfilterstab.cpp b/src/frontend/settingsdialogs/bttextfilterstab.cpp
new file mode 100644
index 0000000..e8da038
--- /dev/null
+++ b/src/frontend/settingsdialogs/bttextfilterstab.cpp
@@ -0,0 +1,87 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "frontend/settingsdialogs/bttextfilterstab.h"
+
+#include <QCheckBox>
+#include <QLabel>
+#include <QVBoxLayout>
+#include "backend/config/btconfig.h"
+#include "frontend/settingsdialogs/cswordsettings.h"
+#include "util/tool.h"
+
+
+#define TEXT_FILTERS_TAB_ADD_ROW(name,def) \
+ m_ ## name ## Check = new QCheckBox(this); \
+ m_ ## name ## Check->setChecked(btConfig().sessionValue<bool>(#name,(def))); \
+ layout->addWidget(m_ ## name ## Check);
+
+BtTextFiltersTab::BtTextFiltersTab(CSwordSettingsPage *parent)
+ : QWidget(parent)
+{
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->setMargin(5);
+ layout->setSpacing(2);
+
+ m_explanationLabel = new QLabel(this);
+ m_explanationLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
+ m_explanationLabel->setMaximumHeight(50);
+ layout->addWidget(m_explanationLabel);
+
+ btConfig().beginGroup("presentation");
+ TEXT_FILTERS_TAB_ADD_ROW(lineBreaks, false);
+ TEXT_FILTERS_TAB_ADD_ROW(verseNumbers, false);
+ TEXT_FILTERS_TAB_ADD_ROW(headings, true);
+ TEXT_FILTERS_TAB_ADD_ROW(hebrewPoints, true);
+ TEXT_FILTERS_TAB_ADD_ROW(hebrewCantillation, true);
+ TEXT_FILTERS_TAB_ADD_ROW(morphSegmentation, true);
+ TEXT_FILTERS_TAB_ADD_ROW(greekAccents, true);
+ TEXT_FILTERS_TAB_ADD_ROW(textualVariants, false);
+ TEXT_FILTERS_TAB_ADD_ROW(scriptureReferences, true);
+ btConfig().endGroup();
+
+ layout->addStretch(4);
+
+ retranslateUi();
+}
+
+#define TEXT_FILTERS_TAB_SAVE(name) \
+ btConfig().setSessionValue(#name, m_ ## name ## Check->isChecked())
+
+void BtTextFiltersTab::save() {
+ btConfig().beginGroup("presentation");
+ TEXT_FILTERS_TAB_SAVE(lineBreaks);
+ TEXT_FILTERS_TAB_SAVE(verseNumbers);
+ TEXT_FILTERS_TAB_SAVE(headings);
+ TEXT_FILTERS_TAB_SAVE(hebrewPoints);
+ TEXT_FILTERS_TAB_SAVE(hebrewCantillation);
+ TEXT_FILTERS_TAB_SAVE(morphSegmentation);
+ TEXT_FILTERS_TAB_SAVE(greekAccents);
+ TEXT_FILTERS_TAB_SAVE(textualVariants);
+ TEXT_FILTERS_TAB_SAVE(scriptureReferences);
+ btConfig().endGroup();
+}
+
+
+void BtTextFiltersTab::retranslateUi() {
+ util::tool::initExplanationLabel(m_explanationLabel, "",
+ tr("Filters control the appearance of text. Here you can specify "
+ "default settings for all filters. You can override these "
+ "settings in each display window."));
+
+ m_lineBreaksCheck->setText(tr("Insert line break after each verse"));
+ m_verseNumbersCheck->setText(tr("Show verse numbers"));
+ m_headingsCheck->setText(tr("Show section headings"));
+ m_scriptureReferencesCheck->setText(tr("Show scripture cross-references"));
+ m_greekAccentsCheck->setText(tr("Show Greek accents"));
+ m_hebrewPointsCheck->setText(tr("Show Hebrew vowel points"));
+ m_hebrewCantillationCheck->setText(tr("Show Hebrew cantillation marks"));
+ m_morphSegmentationCheck->setText(tr("Show morph segmentation"));
+ m_textualVariantsCheck->setText(tr("Use textual variants"));
+}
diff --git a/src/frontend/settingsdialogs/bttextfilterstab.h b/src/frontend/settingsdialogs/bttextfilterstab.h
new file mode 100644
index 0000000..3f6e904
--- /dev/null
+++ b/src/frontend/settingsdialogs/bttextfilterstab.h
@@ -0,0 +1,54 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BTTEXTFILTERSTAB_H
+#define BTTEXTFILTERSTAB_H
+
+#include <QWidget>
+
+class CSwordSettingsPage;
+class QCheckBox;
+class QLabel;
+
+
+class BtTextFiltersTab: public QWidget {
+
+ Q_OBJECT
+
+ public: /* Methods: */
+
+ BtTextFiltersTab(CSwordSettingsPage * parent);
+
+ void save();
+
+ protected: /* Methods: */
+
+ void retranslateUi();
+
+ private: /* Fields: */
+
+ QLabel * m_explanationLabel;
+
+#define TEXT_FILTERS_TAB_FIELD(name) QCheckBox * m_ ## name ## Check
+
+ TEXT_FILTERS_TAB_FIELD(lineBreaks);
+ TEXT_FILTERS_TAB_FIELD(verseNumbers);
+ TEXT_FILTERS_TAB_FIELD(headings);
+ TEXT_FILTERS_TAB_FIELD(hebrewPoints);
+ TEXT_FILTERS_TAB_FIELD(hebrewCantillation);
+ TEXT_FILTERS_TAB_FIELD(morphSegmentation);
+ TEXT_FILTERS_TAB_FIELD(greekAccents);
+ TEXT_FILTERS_TAB_FIELD(textualVariants);
+ TEXT_FILTERS_TAB_FIELD(scriptureReferences);
+
+};
+
+#endif /* BTTEXTFILTERSTAB_H */
diff --git a/src/frontend/settingsdialogs/cacceleratorsettings.cpp b/src/frontend/settingsdialogs/cacceleratorsettings.cpp
index 177ea2f..d85bf51 100644
--- a/src/frontend/settingsdialogs/cacceleratorsettings.cpp
+++ b/src/frontend/settingsdialogs/cacceleratorsettings.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -13,25 +13,25 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QList>
-#include <QMessageBox>
#include <QStackedWidget>
#include <QVBoxLayout>
#include <QWidget>
#include "bibletime.h"
-#include "backend/config/cbtconfig.h"
+#include "bibletimeapp.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/cbiblereadwindow.h"
#include "frontend/displaywindow/cbookreadwindow.h"
#include "frontend/displaywindow/ccommentaryreadwindow.h"
#include "frontend/displaywindow/clexiconreadwindow.h"
#include "frontend/displaywindow/creadwindow.h"
+#include "frontend/messagedialog.h"
#include "frontend/settingsdialogs/cconfigurationdialog.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::settings::keys::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::settings::keys::icon), parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
@@ -48,21 +48,16 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
SLOT(slotKeyChooserTypeChanged(const QString&)) );
Q_ASSERT(ok);
+ // m_*.title strings are empty here, they are filled and added to the stacked widget in the retranslateUi() function
m_keyChooserStack = new QStackedWidget(this);
-
- m_typeChooser->addItem(m_application.title);
- m_typeChooser->addItem(m_general.title);
- m_typeChooser->addItem(m_bible.title);
- m_typeChooser->addItem(m_commentary.title);
- m_typeChooser->addItem(m_lexicon.title);
- m_typeChooser->addItem(m_book.title);
+ retranslateUi();
// create shortcuteditors
// ------ Application -------------- //
m_application.actionCollection = new BtActionCollection(this);
BibleTime::insertKeyboardActions( m_application.actionCollection);
- CBTConfig::setupAccelSettings(CBTConfig::application, m_application.actionCollection);
+ m_application.actionCollection->readShortcuts("Application shortcuts");
m_application.keyChooser = new BtShortcutsEditor(m_application.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_application.keyChooser);
ok = connect(m_application.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
@@ -72,7 +67,7 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
// ----- All display windows ------ //
m_general.actionCollection = new BtActionCollection(this);
CDisplayWindow::insertKeyboardActions( m_general.actionCollection);
- CBTConfig::setupAccelSettings(CBTConfig::allWindows, m_general.actionCollection);
+ m_general.actionCollection->readShortcuts("Displaywindow shortcuts");
m_general.keyChooser = new BtShortcutsEditor(m_general.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_general.keyChooser);
ok = connect(m_general.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
@@ -82,7 +77,7 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
// ----- Bible windows ------ //
m_bible.actionCollection = new BtActionCollection(this);
CBibleReadWindow::insertKeyboardActions( m_bible.actionCollection);
- CBTConfig::setupAccelSettings(CBTConfig::bibleWindow, m_bible.actionCollection);
+ m_bible.actionCollection->readShortcuts("Bible shortcuts");
m_bible.keyChooser = new BtShortcutsEditor(m_bible.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_bible.keyChooser);
ok = connect(m_bible.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
@@ -92,7 +87,7 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
// ----- Commentary windows ------ //
m_commentary.actionCollection = new BtActionCollection(this);
CCommentaryReadWindow::insertKeyboardActions( m_commentary.actionCollection);
- CBTConfig::setupAccelSettings(CBTConfig::commentaryWindow, m_commentary.actionCollection);
+ m_commentary.actionCollection->readShortcuts("Commentary shortcuts");
m_commentary.keyChooser = new BtShortcutsEditor(m_commentary.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_commentary.keyChooser);
ok = connect(m_commentary.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
@@ -102,8 +97,8 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
// ----- Lexicon windows ------ //
m_lexicon.actionCollection = new BtActionCollection(this);
CLexiconReadWindow::insertKeyboardActions( m_lexicon.actionCollection );
- CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, m_lexicon.actionCollection);
- m_lexicon.keyChooser = new BtShortcutsEditor(m_lexicon.actionCollection, m_keyChooserStack );
+ m_lexicon.actionCollection->readShortcuts("Lexicon shortcuts");
+ m_lexicon.keyChooser = new BtShortcutsEditor(m_lexicon.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_lexicon.keyChooser);
ok = connect(m_lexicon.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
this, SLOT(completeKeyChangeRequest(BtShortcutsEditor*, const QString&)));
@@ -112,7 +107,7 @@ CAcceleratorSettingsPage::CAcceleratorSettingsPage(CConfigurationDialog *parent)
// ----- Book windows ------ //
m_book.actionCollection = new BtActionCollection(this);
CBookReadWindow::insertKeyboardActions( m_book.actionCollection);
- CBTConfig::setupAccelSettings(CBTConfig::bookWindow, m_book.actionCollection);
+ m_book.actionCollection->readShortcuts("Book shortcuts");
m_book.keyChooser = new BtShortcutsEditor(m_book.actionCollection, m_keyChooserStack);
m_keyChooserStack->addWidget(m_book.keyChooser);
ok = connect(m_book.keyChooser, SIGNAL(keyChangeRequest(BtShortcutsEditor*, const QString&)),
@@ -157,17 +152,12 @@ void CAcceleratorSettingsPage::completeKeyChangeRequest(BtShortcutsEditor* short
QString conflicts = findConflictsWithKeys(keys, list);
if (!conflicts.isEmpty()) {
QString message = QObject::tr("This shortcut conflicts with the shortcut for the following actions:");
- message.append("\n");
+ message.append("<br/><br/>");
message.append(conflicts);
- QMessageBox msgBox(this);
- msgBox.setIcon(QMessageBox::Question);
- msgBox.setText(message);
- msgBox.setInformativeText(QObject::tr("Do you want to clear the conflicting shortcuts and continue?"));
- msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
- msgBox.setDefaultButton(QMessageBox::Yes);
- int ret = msgBox.exec();
- if ( ret == QMessageBox::Yes) {
+ if (message::showQuestion(this,
+ QObject::tr("Do you want to clear the conflicting shortcuts and continue?"),
+ message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) {
clearConflictsWithKeys(keys, list);
shortcutsEditor->changeShortcutInDialog(keys);
}
@@ -244,12 +234,12 @@ void CAcceleratorSettingsPage::save() {
if (m_book.keyChooser)
m_book.keyChooser->commitChanges();
- CBTConfig::saveAccelSettings(CBTConfig::application, m_application.actionCollection); //application
- CBTConfig::saveAccelSettings(CBTConfig::allWindows, m_general.actionCollection); //read display windows
- CBTConfig::saveAccelSettings(CBTConfig::bibleWindow, m_bible.actionCollection); //bible
- CBTConfig::saveAccelSettings(CBTConfig::commentaryWindow, m_commentary.actionCollection); //commentary
- CBTConfig::saveAccelSettings(CBTConfig::lexiconWindow, m_lexicon.actionCollection); //lexicon
- CBTConfig::saveAccelSettings(CBTConfig::bookWindow, m_book.actionCollection); //book
+ m_application.actionCollection->writeShortcuts("Application shortcuts"); //application
+ m_general.actionCollection->writeShortcuts("Displaywindow shortcuts"); //read display windows
+ m_bible.actionCollection->writeShortcuts("Bible shortcuts"); //bible
+ m_commentary.actionCollection->writeShortcuts("Commentary shortcuts"); //commentary
+ m_lexicon.actionCollection->writeShortcuts("Lexicon shortcuts"); //lexicon
+ m_book.actionCollection->writeShortcuts("Book shortcuts"); //book
}
void CAcceleratorSettingsPage::slotKeyChooserTypeChanged(const QString& title) {
diff --git a/src/frontend/settingsdialogs/cacceleratorsettings.h b/src/frontend/settingsdialogs/cacceleratorsettings.h
index 1bd4173..49408d5 100644
--- a/src/frontend/settingsdialogs/cacceleratorsettings.h
+++ b/src/frontend/settingsdialogs/cacceleratorsettings.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/cconfigurationdialog.cpp b/src/frontend/settingsdialogs/cconfigurationdialog.cpp
index 4c5bf1b..951880b 100644
--- a/src/frontend/settingsdialogs/cconfigurationdialog.cpp
+++ b/src/frontend/settingsdialogs/cconfigurationdialog.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,16 +14,21 @@
#include <QLayout>
#include <QPushButton>
#include <QWidget>
+#include "backend/config/btconfig.h"
#include "frontend/settingsdialogs/cacceleratorsettings.h"
#include "frontend/settingsdialogs/cdisplaysettings.h"
#include "frontend/settingsdialogs/btfontsettings.h"
#include "frontend/settingsdialogs/btlanguagesettings.h"
#include "frontend/settingsdialogs/cswordsettings.h"
+#include "frontend/messagedialog.h"
#include "util/cresmgr.h"
#include "util/directory.h"
-#include "util/dialogutil.h"
+namespace {
+const QString GeometryKey = "GUI/SettingsDialog/geometry";
+} // anonymous namespace
+
CConfigurationDialog::CConfigurationDialog(QWidget * parent, BtActionCollection* actionCollection )
: BtConfigDialog(parent),
m_actionCollection(actionCollection),
@@ -61,7 +66,7 @@ CConfigurationDialog::CConfigurationDialog(QWidget * parent, BtActionCollection*
m_bbox->addButton(QDialogButtonBox::Ok);
m_bbox->addButton(QDialogButtonBox::Apply);
m_bbox->addButton(QDialogButtonBox::Cancel);
- util::prepareDialogBox(m_bbox);
+ message::prepareDialogBox(m_bbox);
setButtonBox(m_bbox);
bool ok = connect(m_bbox, SIGNAL(clicked(QAbstractButton *)), SLOT(slotButtonClicked(QAbstractButton *)));
Q_ASSERT(ok);
@@ -99,13 +104,9 @@ void CConfigurationDialog::slotButtonClicked(QAbstractButton* button) {
}
void CConfigurationDialog::loadDialogSettings() {
- resize(CBTConfig::get(CBTConfig::configDialogWidth), CBTConfig::get(CBTConfig::configDialogHeight));
- move(CBTConfig::get(CBTConfig::configDialogPosX), CBTConfig::get(CBTConfig::configDialogPosY));
+ restoreGeometry(btConfig().value<QByteArray>(GeometryKey, QByteArray()));
}
void CConfigurationDialog::saveDialogSettings() const {
- CBTConfig::set(CBTConfig::configDialogWidth, size().width());
- CBTConfig::set(CBTConfig::configDialogHeight, size().height());
- CBTConfig::set(CBTConfig::configDialogPosX, x());
- CBTConfig::set(CBTConfig::configDialogPosY, y());
+ btConfig().setValue(GeometryKey, saveGeometry());
}
diff --git a/src/frontend/settingsdialogs/cconfigurationdialog.h b/src/frontend/settingsdialogs/cconfigurationdialog.h
index d38b4e4..fbd4944 100644
--- a/src/frontend/settingsdialogs/cconfigurationdialog.h
+++ b/src/frontend/settingsdialogs/cconfigurationdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/cdisplaysettings.cpp b/src/frontend/settingsdialogs/cdisplaysettings.cpp
index 6af4547..5b690f6 100644
--- a/src/frontend/settingsdialogs/cdisplaysettings.cpp
+++ b/src/frontend/settingsdialogs/cdisplaysettings.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,12 +14,13 @@
#include <QLabel>
#include <QVBoxLayout>
#include <QWebView>
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "backend/managers/cdisplaytemplatemgr.h"
#include "backend/rendering/cdisplayrendering.h"
+#include "bibletimeapp.h"
#include "frontend/settingsdialogs/cconfigurationdialog.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
+#include "util/geticon.h"
#include "util/tool.h"
@@ -46,13 +47,13 @@ QSize CWebViewerWidget::sizeHint () const {
/** Initializes the startup section of the OD. */
CDisplaySettingsPage::CDisplaySettingsPage(CConfigurationDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::settings::startup::icon), parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::settings::startup::icon), parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
{ //startup logo
m_showLogoCheck = new QCheckBox(this);
- m_showLogoCheck->setChecked(CBTConfig::get(CBTConfig::logo));
+ m_showLogoCheck->setChecked(btConfig().value<bool>("GUI/showSplashScreen", true));
mainLayout->addWidget(m_showLogoCheck);
}
mainLayout->addSpacing(20);
@@ -161,14 +162,14 @@ void CDisplaySettingsPage::updateStylePreview() {
/// \todo Remove the following hack:
const QString oldStyleName = CDisplayTemplateMgr::activeTemplateName();
- CBTConfig::set(CBTConfig::displayStyle, styleName);
+ btConfig().setValue("GUI/activeTemplateName", styleName);
CDisplayRendering render;
m_stylePreviewViewer->setHtml( render.renderKeyTree(tree));
- CBTConfig::set(CBTConfig::displayStyle, oldStyleName);
+ btConfig().setValue("GUI/activeTemplateName", oldStyleName);
}
void CDisplaySettingsPage::save() {
- CBTConfig::set(CBTConfig::logo, m_showLogoCheck->isChecked());
- CBTConfig::set(CBTConfig::displayStyle, m_styleChooserCombo->currentText());
+ btConfig().setValue("GUI/showSplashScreen", m_showLogoCheck->isChecked() );
+ btConfig().setValue("GUI/activeTemplateName", m_styleChooserCombo->currentText());
}
diff --git a/src/frontend/settingsdialogs/cdisplaysettings.h b/src/frontend/settingsdialogs/cdisplaysettings.h
index b18a26f..834c846 100644
--- a/src/frontend/settingsdialogs/cdisplaysettings.h
+++ b/src/frontend/settingsdialogs/cdisplaysettings.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/frontend/settingsdialogs/clistwidget.cpp b/src/frontend/settingsdialogs/clistwidget.cpp
index 3a2a4c7..9504009 100644
--- a/src/frontend/settingsdialogs/clistwidget.cpp
+++ b/src/frontend/settingsdialogs/clistwidget.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,10 +17,6 @@ CListWidget::CListWidget(QWidget* parent)
// Intentionally empty
}
-CListWidget::~CListWidget() {
- // Intentionally empty
-}
-
QSize CListWidget::sizeHint () const {
return QSize(100, 120);
}
diff --git a/src/frontend/settingsdialogs/clistwidget.h b/src/frontend/settingsdialogs/clistwidget.h
index ecd5f98..393754c 100644
--- a/src/frontend/settingsdialogs/clistwidget.h
+++ b/src/frontend/settingsdialogs/clistwidget.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -17,7 +19,7 @@ class CListWidget : public QListWidget {
Q_OBJECT
public:
CListWidget(QWidget* parent = 0);
- ~CListWidget();
+
virtual QSize sizeHint () const;
void setCharWidth(int width);
};
diff --git a/src/frontend/settingsdialogs/cswordsettings.cpp b/src/frontend/settingsdialogs/cswordsettings.cpp
index 60c0e7c..f8f0ebf 100644
--- a/src/frontend/settingsdialogs/cswordsettings.cpp
+++ b/src/frontend/settingsdialogs/cswordsettings.cpp
@@ -2,322 +2,36 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "frontend/settingsdialogs/cswordsettings.h"
-#include <QCheckBox>
-#include <QComboBox>
-#include <QFormLayout>
-#include <QLabel>
-#include <QList>
-#include <QString>
-#include <QStringList>
-#include <QTabWidget>
#include <QVBoxLayout>
-#include <QWidget>
-#include "backend/config/cbtconfig.h"
+#include "bibletimeapp.h"
+#include "frontend/settingsdialogs/btstandardworkstab.h"
+#include "frontend/settingsdialogs/bttextfilterstab.h"
#include "frontend/settingsdialogs/cconfigurationdialog.h"
#include "util/cresmgr.h"
-#include "util/directory.h"
-#include "util/tool.h"
+#include "util/geticon.h"
-/*******************************************************************************
- StandardWorksTab
-*******************************************************************************/
-
-StandardWorksTab::StandardWorksTab(CSwordSettingsPage *parent)
- : QWidget(parent)
-{
- typedef QList<CSwordModuleInfo*>::const_iterator MLCI;
-
- QVBoxLayout *mainLayout = new QVBoxLayout(this);
- mainLayout->setMargin(5);
- mainLayout->setSpacing(2);
-
- m_explanationLabel = new QLabel(this);
- m_explanationLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
- m_explanationLabel->setMaximumHeight(50);
- m_explanationLabel->setMinimumWidth(300);
- mainLayout->addWidget(m_explanationLabel);
-
- QFormLayout *formLayout = new QFormLayout;
-
-#define STANDARD_WORKS_TAB_ADD_ROW(name) \
- if (true) { \
- m_ ## name ## Label = new QLabel(this); \
- m_ ## name ## Combo = new QComboBox(this); \
- formLayout->addRow(m_ ## name ## Label, m_ ## name ## Combo); \
- } else (void) 0
-
- STANDARD_WORKS_TAB_ADD_ROW(standardBible);
- STANDARD_WORKS_TAB_ADD_ROW(standardCommentary);
- STANDARD_WORKS_TAB_ADD_ROW(standardLexicon);
- STANDARD_WORKS_TAB_ADD_ROW(standardDailyDevotional);
- STANDARD_WORKS_TAB_ADD_ROW(standardHebrewStrongsLexicon);
- STANDARD_WORKS_TAB_ADD_ROW(standardGreekStrongsLexicon);
- STANDARD_WORKS_TAB_ADD_ROW(standardHebrewMorphLexicon);
- STANDARD_WORKS_TAB_ADD_ROW(standardGreekMorphLexicon);
-
- mainLayout->addLayout(formLayout);
- mainLayout->addStretch();
-
- //fill the comboboxes with the right modules
-
- const QList<CSwordModuleInfo*> &modules(CSwordBackend::instance()->moduleList());
- QString modDescript;
- for (MLCI it(modules.begin()); it != modules.end(); it++) {
- modDescript = (*it)->config(CSwordModuleInfo::Description);
-
- switch ((*it)->type()) {
- case CSwordModuleInfo::Bible:
- m_standardBibleCombo->addItem(modDescript);
- break;
- case CSwordModuleInfo::Commentary:
- m_standardCommentaryCombo->addItem(modDescript);
- break;
- case CSwordModuleInfo::Lexicon: {
- bool inserted = false;
- if ((*it)->has(CSwordModuleInfo::HebrewDef)) {
- m_standardHebrewStrongsLexiconCombo->addItem(modDescript);
- inserted = true;
- }
- if ((*it)->has(CSwordModuleInfo::GreekDef)) {
- m_standardGreekStrongsLexiconCombo->addItem(modDescript);
- inserted = true;
- }
- if ((*it)->has(CSwordModuleInfo::HebrewParse)) {
- m_standardHebrewMorphLexiconCombo->addItem(modDescript);
- inserted = true;
- }
- if ((*it)->has(CSwordModuleInfo::GreekParse)) {
- m_standardGreekMorphLexiconCombo->addItem(modDescript);
- inserted = true;
- }
- if ((*it)->category() == CSwordModuleInfo::DailyDevotional) {
- m_standardDailyDevotionalCombo->addItem(modDescript);
- inserted = true;
- }
-
- if (!inserted) { //daily dvotionals, striong lexicons etc. are not very useful for word lookups
- m_standardLexiconCombo->addItem(modDescript);
- }
- break;
- }
- default://unknown type
- break;
- } //switch
- } //for
-
- //using two lists and one loop is better than six loops with almost the same code :)
- QList<QComboBox*> comboList;
- QStringList moduleList;
-
-#define STANDARD_WORKS_TAB_CASE(name) \
- case CBTConfig::name: \
- comboList.append(m_ ## name ## Combo); \
- break
-
- for (int i = 0; i <= (int)CBTConfig::lastModuleType; ++i) {
- //fill the combobox list in the right order (i.e. same order as the CBTConfig::module enum list)
- CBTConfig::modules moduleType = (CBTConfig::modules)(i);
- switch (moduleType) {
- STANDARD_WORKS_TAB_CASE(standardBible);
- STANDARD_WORKS_TAB_CASE(standardCommentary);
- STANDARD_WORKS_TAB_CASE(standardLexicon);
- STANDARD_WORKS_TAB_CASE(standardDailyDevotional);
- STANDARD_WORKS_TAB_CASE(standardHebrewStrongsLexicon);
- STANDARD_WORKS_TAB_CASE(standardGreekStrongsLexicon);
- STANDARD_WORKS_TAB_CASE(standardHebrewMorphLexicon);
- STANDARD_WORKS_TAB_CASE(standardGreekMorphLexicon);
- }
- ; //switch
-
- //fill the module list
- CSwordModuleInfo* const m = CBTConfig::get( (CBTConfig::modules)(i) );
- if (m) {
- moduleList << m->config(CSwordModuleInfo::Description);
- }
- else {
- moduleList << QString::null;
- }
- } //for
-
- QString module = QString::null;
- int item = 0;
- int count = 0;
- QListIterator<QComboBox*> it(comboList);
- while (it.hasNext()) {
- //for (QComboBox* combo = comboList.first(); combo; combo = comboList.next() )
- QComboBox* combo = it.next();
- module = moduleList[comboList.indexOf(combo)];
- count = combo->count();
- combo->setMaximumWidth(300);
-
- for (item = 0; item < count; item++) {
- if (combo->itemText(item) == module ) {
- combo->setCurrentIndex(item);
- break;
- }
- }
- }
-
- retranslateUi();
-}
-
-void StandardWorksTab::save() {
- for (int i = 0; i <= (int)CBTConfig::lastModuleType; ++i) {
- QString moduleDescription;
-
-
-#define STANDARD_WORKS_TAB_SCASE(name) \
- case CBTConfig::name: \
- moduleDescription = m_ ## name ## Combo->currentText(); \
- break;
-
- CBTConfig::modules moduleType = (CBTConfig::modules)(i);
- switch (moduleType) {
- STANDARD_WORKS_TAB_SCASE(standardBible);
- STANDARD_WORKS_TAB_SCASE(standardCommentary);
- STANDARD_WORKS_TAB_SCASE(standardLexicon);
- STANDARD_WORKS_TAB_SCASE(standardDailyDevotional);
- STANDARD_WORKS_TAB_SCASE(standardHebrewStrongsLexicon);
- STANDARD_WORKS_TAB_SCASE(standardGreekStrongsLexicon);
- STANDARD_WORKS_TAB_SCASE(standardHebrewMorphLexicon);
- STANDARD_WORKS_TAB_SCASE(standardGreekMorphLexicon);
- default:
- qWarning("Unhandled module type.");
- };
-
- CSwordModuleInfo * const module = CSwordBackend::instance()->findModuleByDescription(moduleDescription);
- CBTConfig::set(moduleType, module);
- }
-}
-
-void StandardWorksTab::retranslateUi() {
- util::tool::initExplanationLabel(
- m_explanationLabel, "",
- tr("Standard works are used when no particular work is specified, for example "
- "when a hyperlink into a Bible or lexicon was clicked."));
-
- m_standardBibleLabel->setText(tr("Bible:"));
- m_standardBibleCombo->setToolTip(tr("The standard Bible is used when a hyperlink into a Bible is clicked"));
-
- m_standardCommentaryLabel->setText(tr("Commentary:"));
- m_standardCommentaryCombo->setToolTip(tr("The standard commentary is used when a hyperlink into a commentary is clicked"));
-
- m_standardLexiconLabel->setText(tr("Lexicon:"));
- m_standardLexiconCombo->setToolTip(tr("The standard lexicon is used when a hyperlink into a lexicon is clicked"));
-
- m_standardDailyDevotionalLabel->setText(tr("Daily devotional:"));
- m_standardDailyDevotionalCombo->setToolTip(tr("The standard devotional will be used to display a short start up devotional"));
-
- m_standardHebrewStrongsLexiconLabel->setText(tr("Hebrew Strong's lexicon:"));
- m_standardHebrewStrongsLexiconCombo->setToolTip(tr("The standard Hebrew lexicon is used when a hyperlink into a Hebrew lexicon is clicked"));
-
- m_standardGreekStrongsLexiconLabel->setText(tr("Greek Strong's lexicon:"));
- m_standardGreekStrongsLexiconCombo->setToolTip(tr("The standard Greek lexicon is used when a hyperlink into a Greek lexicon is clicked"));
-
- m_standardHebrewMorphLexiconLabel->setText(tr("Hebrew morphological lexicon:"));
- m_standardHebrewMorphLexiconCombo->setToolTip(tr("The standard morphological lexicon for Hebrew texts is used when a hyperlink of a morphological tag in a Hebrew text is clicked"));
-
- m_standardGreekMorphLexiconLabel->setText(tr("Greek morphological lexicon:"));
- m_standardGreekMorphLexiconCombo->setToolTip(tr("The standard morphological lexicon for Greek texts is used when a hyperlink of a morphological tag in a Greek text is clicked"));
-}
-
-
-/*******************************************************************************
- TextFiltersTab
-*******************************************************************************/
-
-TextFiltersTab::TextFiltersTab(CSwordSettingsPage *parent)
- : QWidget(parent)
-{
- QVBoxLayout *layout = new QVBoxLayout(this);
- layout->setMargin(5);
- layout->setSpacing(2);
-
- m_explanationLabel = new QLabel(this);
- m_explanationLabel->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
- m_explanationLabel->setMaximumHeight(50);
- m_explanationLabel->setMinimumWidth(300);
- layout->addWidget(m_explanationLabel);
-
-#define TEXT_FILTERS_TAB_ADD_ROW(name) \
- m_ ## name ## Check = new QCheckBox(this); \
- m_ ## name ## Check->setChecked(CBTConfig::get(CBTConfig::name)); \
- layout->addWidget(m_ ## name ## Check);
-
- TEXT_FILTERS_TAB_ADD_ROW(lineBreaks);
- TEXT_FILTERS_TAB_ADD_ROW(verseNumbers);
- TEXT_FILTERS_TAB_ADD_ROW(headings);
- TEXT_FILTERS_TAB_ADD_ROW(hebrewPoints);
- TEXT_FILTERS_TAB_ADD_ROW(hebrewCantillation);
- TEXT_FILTERS_TAB_ADD_ROW(morphSegmentation);
- TEXT_FILTERS_TAB_ADD_ROW(greekAccents);
- TEXT_FILTERS_TAB_ADD_ROW(textualVariants);
- TEXT_FILTERS_TAB_ADD_ROW(scriptureReferences);
-
- layout->addStretch(4);
-
- retranslateUi();
-}
-
-void TextFiltersTab::save() {
-#define TEXT_FILTERS_TAB_SAVE(name) CBTConfig::set(CBTConfig::name, m_ ## name ## Check->isChecked())
-
- TEXT_FILTERS_TAB_SAVE(lineBreaks);
- TEXT_FILTERS_TAB_SAVE(verseNumbers);
- TEXT_FILTERS_TAB_SAVE(headings);
- TEXT_FILTERS_TAB_SAVE(hebrewPoints);
- TEXT_FILTERS_TAB_SAVE(hebrewCantillation);
- TEXT_FILTERS_TAB_SAVE(morphSegmentation);
- TEXT_FILTERS_TAB_SAVE(greekAccents);
- TEXT_FILTERS_TAB_SAVE(textualVariants);
- TEXT_FILTERS_TAB_SAVE(scriptureReferences);
-}
-
-
-void TextFiltersTab::retranslateUi() {
- util::tool::initExplanationLabel(m_explanationLabel, "",
- tr("Filters control the appearance of text. Here you can specify "
- "default settings for all filters. You can override these "
- "settings in each display window."));
-
- m_lineBreaksCheck->setText(tr("Insert line break after each verse"));
- m_verseNumbersCheck->setText(tr("Show verse numbers"));
- m_headingsCheck->setText(tr("Show section headings"));
- m_scriptureReferencesCheck->setText(tr("Show scripture cross-references"));
- m_greekAccentsCheck->setText(tr("Show Greek accents"));
- m_hebrewPointsCheck->setText(tr("Show Hebrew vowel points"));
- m_hebrewCantillationCheck->setText(tr("Show Hebrew cantillation marks"));
- m_morphSegmentationCheck->setText(tr("Show morph segmentation"));
- m_textualVariantsCheck->setText(tr("Use textual variants"));
-}
-
-
-/*******************************************************************************
- CSwordSettingsPage
-*******************************************************************************/
-
-CSwordSettingsPage::CSwordSettingsPage(CConfigurationDialog *parent)
- : BtConfigDialog::Page(util::directory::getIcon(CResMgr::settings::sword::icon), parent)
+CSwordSettingsPage::CSwordSettingsPage(CConfigurationDialog * parent)
+ : BtConfigDialog::Page(util::getIcon(CResMgr::settings::sword::icon), parent)
{
static const QString nullString;
m_tabWidget = new QTabWidget(this);
- m_worksTab = new StandardWorksTab(this);
+ m_worksTab = new BtStandardWorksTab(this);
m_tabWidget->addTab(m_worksTab, nullString);
- m_filtersTab = new TextFiltersTab(this);
+ m_filtersTab = new BtTextFiltersTab(this);
m_tabWidget->addTab(m_filtersTab, nullString);
- QVBoxLayout *mainLayout = new QVBoxLayout(this);
+ QVBoxLayout * mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(m_tabWidget);
retranslateUi();
diff --git a/src/frontend/settingsdialogs/cswordsettings.h b/src/frontend/settingsdialogs/cswordsettings.h
index c54630d..18a4268 100644
--- a/src/frontend/settingsdialogs/cswordsettings.h
+++ b/src/frontend/settingsdialogs/cswordsettings.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -14,90 +16,9 @@
#include <QWidget>
+class BtTextFiltersTab;
class CConfigurationDialog;
-class CSwordSettingsPage;
-class QCheckBox;
-class QComboBox;
-class QLabel;
-
-
-/*******************************************************************************
- StandardWorksTab
-*******************************************************************************/
-
-class StandardWorksTab: public QWidget {
-
- Q_OBJECT
-
- public: /* Methods: */
-
- StandardWorksTab(CSwordSettingsPage *parent);
-
- void save();
-
- protected: /* Methods: */
-
- void retranslateUi();
-
- private: /* Fields: */
-
- QLabel *m_explanationLabel;
-
-#define STANDARD_WORKS_TAB_FIELD(name) \
- QLabel *m_ ## name ## Label; \
- QComboBox *m_ ## name ## Combo
-
- STANDARD_WORKS_TAB_FIELD(standardBible);
- STANDARD_WORKS_TAB_FIELD(standardCommentary);
- STANDARD_WORKS_TAB_FIELD(standardLexicon);
- STANDARD_WORKS_TAB_FIELD(standardDailyDevotional);
- STANDARD_WORKS_TAB_FIELD(standardHebrewStrongsLexicon);
- STANDARD_WORKS_TAB_FIELD(standardGreekStrongsLexicon);
- STANDARD_WORKS_TAB_FIELD(standardHebrewMorphLexicon);
- STANDARD_WORKS_TAB_FIELD(standardGreekMorphLexicon);
-};
-
-
-/*******************************************************************************
- TextFiltersTab
-*******************************************************************************/
-
-class TextFiltersTab: public QWidget {
-
- Q_OBJECT
-
- public: /* Methods: */
-
- TextFiltersTab(CSwordSettingsPage *parent);
-
- void save();
-
- protected: /* Methods: */
-
- void retranslateUi();
-
- private: /* Fields: */
-
- QLabel *m_explanationLabel;
-
-#define TEXT_FILTERS_TAB_FIELD(name) QCheckBox *m_ ## name ## Check
-
- TEXT_FILTERS_TAB_FIELD(lineBreaks);
- TEXT_FILTERS_TAB_FIELD(verseNumbers);
- TEXT_FILTERS_TAB_FIELD(headings);
- TEXT_FILTERS_TAB_FIELD(hebrewPoints);
- TEXT_FILTERS_TAB_FIELD(hebrewCantillation);
- TEXT_FILTERS_TAB_FIELD(morphSegmentation);
- TEXT_FILTERS_TAB_FIELD(greekAccents);
- TEXT_FILTERS_TAB_FIELD(textualVariants);
- TEXT_FILTERS_TAB_FIELD(scriptureReferences);
-
-};
-
-
-/*******************************************************************************
- CSwordSettingsPage
-*******************************************************************************/
+class BtStandardWorksTab;
class CSwordSettingsPage: public BtConfigDialog::Page {
@@ -105,7 +26,7 @@ class CSwordSettingsPage: public BtConfigDialog::Page {
public: /* Methods: */
- CSwordSettingsPage(CConfigurationDialog *parent = 0);
+ CSwordSettingsPage(CConfigurationDialog * parent = 0);
void save();
@@ -115,9 +36,9 @@ class CSwordSettingsPage: public BtConfigDialog::Page {
private: /* Fields: */
- QTabWidget *m_tabWidget;
- StandardWorksTab *m_worksTab;
- TextFiltersTab *m_filtersTab;
+ QTabWidget * m_tabWidget;
+ BtStandardWorksTab * m_worksTab;
+ BtTextFiltersTab * m_filtersTab;
};
diff --git a/src/frontend/tips/bttipdialog.cpp b/src/frontend/tips/bttipdialog.cpp
index 5c4052d..75b7a6d 100644
--- a/src/frontend/tips/bttipdialog.cpp
+++ b/src/frontend/tips/bttipdialog.cpp
@@ -2,18 +2,13 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
#include "bttipdialog.h"
-#include "backend/config/cbtconfig.h"
-#include "util/cresmgr.h"
-#include "util/dialogutil.h"
-#include "util/directory.h"
-
#include <QCheckBox>
#include <QDesktopServices>
#include <QDialogButtonBox>
@@ -21,6 +16,13 @@
#include <QPushButton>
#include <QVBoxLayout>
#include <QWebView>
+#include "backend/config/btconfig.h"
+#include "bibletimeapp.h"
+#include "util/cresmgr.h"
+#include "frontend/messagedialog.h"
+#include "util/directory.h"
+#include "util/geticon.h"
+#include "util/htmlescape.h"
namespace {
@@ -52,20 +54,20 @@ inline QString make_icon(const QString &icon) {
namespace DU = util::directory;
QString fileName = DU::getIconDir().filePath(icon);
QString iconUrl = QUrl::fromLocalFile(fileName).toString();
- return "<img src=\"" + iconUrl + "\" width=\"32\" />";
+ return "<img src=\"" + util::htmlEscape(iconUrl) + "\" width=\"32\" />";
}
+const QString LastTipNumberKey = "GUI/lastTipNumber";
+
} // anonymous namespace
BtTipDialog::BtTipDialog(QWidget *parent, Qt::WindowFlags wflags)
: QDialog(parent, wflags)
{
- namespace DU = util::directory;
-
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle(tr("Tip Of The Day"));
- setWindowIcon(DU::getIcon(CResMgr::mainMenu::help::tipOfTheDay::icon));
+ setWindowIcon(util::getIcon(CResMgr::mainMenu::help::tipOfTheDay::icon));
resize(450, 240);
QVBoxLayout *mainLayout = new QVBoxLayout;
@@ -79,14 +81,14 @@ BtTipDialog::BtTipDialog(QWidget *parent, Qt::WindowFlags wflags)
m_showTipsCheckBox = new QCheckBox;
m_showTipsCheckBox->setText(tr("Show tips at startup"));
- bool showTips = CBTConfig::get(CBTConfig::showTipAtStartup);
+ bool showTips = btConfig().value<bool>("GUI/showTipAtStartup", true);
m_showTipsCheckBox->setChecked(showTips);
hLayout->addWidget(m_showTipsCheckBox);
m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Close,
Qt::Horizontal,
this);
- util::prepareDialogBox(m_buttonBox);
+ message::prepareDialogBox(m_buttonBox);
QPushButton *nextButton;
nextButton = m_buttonBox->addButton(tr("Next Tip"),
@@ -113,7 +115,7 @@ BtTipDialog::BtTipDialog(QWidget *parent, Qt::WindowFlags wflags)
this, SLOT(linkClicked(const QUrl&)));
Q_ASSERT(ok);
- m_tipNumber = CBTConfig::get(CBTConfig::tipNumber);
+ m_tipNumber = btConfig().value<int>(LastTipNumberKey, 0);
initTips();
displayTip();
}
@@ -183,7 +185,7 @@ void BtTipDialog::displayTip() {
}
void BtTipDialog::startupBoxChanged(bool checked) {
- CBTConfig::set(CBTConfig::showTipAtStartup, checked);
+ btConfig().setValue("GUI/showTipAtStartup", checked);
}
void BtTipDialog::nextTip() {
@@ -191,7 +193,7 @@ void BtTipDialog::nextTip() {
if (m_tipNumber >= m_tips.count()) {
m_tipNumber = 0;
}
- CBTConfig::set(CBTConfig::tipNumber, m_tipNumber);
+ btConfig().setValue(LastTipNumberKey, m_tipNumber);
displayTip();
}
diff --git a/src/frontend/tips/bttipdialog.h b/src/frontend/tips/bttipdialog.h
index cd00394..e8058ee 100644
--- a/src/frontend/tips/bttipdialog.h
+++ b/src/frontend/tips/bttipdialog.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/main.cpp b/src/main.cpp
index 0f2683c..6f459b9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,11 +18,11 @@
#include <QTextCodec>
#include <QTranslator>
#include "backend/bookshelfmodel/btbookshelftreemodel.h"
-#include "backend/config/cbtconfig.h"
+#include "backend/config/btconfig.h"
#include "bibletime.h"
#include "bibletime_dbus_adaptor.h"
#include "bibletimeapp.h"
-#include "frontend/settingsdialogs/btlanguagesettings.h"
+#include "frontend/searchdialog/btsearchoptionsarea.h"
#include "util/directory.h"
@@ -167,15 +167,15 @@ void myMessageOutput(
case QtCriticalMsg:
debugStream->write("(BibleTime " BT_VERSION ") CRITICAL: ");
debugStream->write(msg);
- debugStream->write("\nPlease report this bug! "
- "(http://www.bibletime.info/development_help.html)");
+ debugStream->write("\nPlease report this bug at "
+ "http://bugs.bibletime.info/");
debugStream->flush();
break;
case QtFatalMsg:
debugStream->write("(BibleTime " BT_VERSION ") FATAL: ");
debugStream->write(msg);
- debugStream->write("\nPlease report this bug! "
- "(http://www.bibletime.info/development_help.html)");
+ debugStream->write("\nPlease report this bug at "
+ "http://bugs.bibletime.info/");
// Dump core on purpose (see qInstallMsgHandler documentation):
debugStream->close();
@@ -191,6 +191,21 @@ void registerMetaTypes() {
qRegisterMetaType<FilterOptions>("FilterOptions");
qRegisterMetaType<DisplayOptions>("DisplayOptions");
qRegisterMetaTypeStreamOperators<BtBookshelfTreeModel::Grouping>("BtBookshelfTreeModel::Grouping");
+
+ qRegisterMetaType<BTModuleTreeItem::Grouping>("Grouping");
+ qRegisterMetaTypeStreamOperators<BTModuleTreeItem::Grouping>("Grouping");
+
+ qRegisterMetaType<alignmentMode>("alignmentMode");
+ qRegisterMetaTypeStreamOperators<alignmentMode>("alignmentMode");
+
+ qRegisterMetaType<Search::BtSearchOptionsArea::SearchType>("SearchType");
+ qRegisterMetaTypeStreamOperators<Search::BtSearchOptionsArea::SearchType>("SearchType");
+
+ qRegisterMetaType<BtConfig::StringMap>("StringMap");
+ qRegisterMetaTypeStreamOperators<BtConfig::StringMap>("StringMap");
+
+ qRegisterMetaType<QList<int> >("QList<int>");
+ qRegisterMetaTypeStreamOperators<QList<int> >("QList<int>");
}
} // anonymous namespace
@@ -204,8 +219,6 @@ int main(int argc, char* argv[]) {
namespace DU = util::directory;
BibleTimeApp app(argc, argv); //for QApplication
- app.setApplicationName("bibletime");
- app.setApplicationVersion(BT_VERSION);
// Parse command line arguments:
bool ignoreSession = false;
@@ -220,13 +233,17 @@ int main(int argc, char* argv[]) {
srand(qHash(QDateTime::currentDateTime().toString(Qt::ISODate)));
// Setup debugging:
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
// Use the default Qt message handler if --debug is not specified
// This works with Visual Studio debugger Output Window
if (showDebugMessages) {
debugStream.reset(new QFile(QDir::homePath().append("/BibleTime Debug.txt")));
debugStream->open(QIODevice::WriteOnly | QIODevice::Text);
+#if QT_VERSION >= 0x050000
+ qInstallMessageHandler(myMessageOutput);
+#else
qInstallMsgHandler(myMessageOutput);
+#endif
}
#else
debugStream.reset(new QFile);
@@ -238,7 +255,7 @@ int main(int argc, char* argv[]) {
#endif
#endif
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
// On Windows, add a path for Qt plugins to be loaded from
app.addLibraryPath(app.applicationDirPath() + "/plugins");
@@ -257,8 +274,11 @@ int main(int argc, char* argv[]) {
}
app.startInit();
+ if (!app.initBtConfig()) {
+ return EXIT_FAILURE;
+ }
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
// change directory to the Sword or .sword directory in the $HOME dir so that
// the sword.conf is found. It points to the sword/locales.d directory
QString homeSwordDir = util::directory::getUserHomeDir().absolutePath();
@@ -266,7 +286,7 @@ int main(int argc, char* argv[]) {
dir.setCurrent(homeSwordDir);
#endif
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
// change to the user's sword dir containing the sword.conf config file, so that
// Sword will correctly find it.
QString homeSwordDir = util::directory::getUserHomeSwordDir().absolutePath();
@@ -285,23 +305,18 @@ int main(int argc, char* argv[]) {
app.setProperty("--debug", QVariant(showDebugMessages));
- /*
- Set book names language if not set. This is a hack. We do this call here,
- because we need to keep the setting displayed in BtLanguageSettingsPage in
- sync with the language of the book names displayed, so that both would
- always use the same setting.
- */
- BtLanguageSettingsPage::resetLanguage(); /// \todo refactor this hack
-
// Initialize display template manager:
- if (!app.initDisplayTemplateManager()) return EXIT_FAILURE;
+ if (!app.initDisplayTemplateManager()) {
+ qFatal("Error initializing display template manager!");
+ return EXIT_FAILURE;
+ }
BibleTime *mainWindow = new BibleTime();
mainWindow->setAttribute(Qt::WA_DeleteOnClose);
// a new BibleTime version was installed (maybe a completely new installation)
- if (CBTConfig::get(CBTConfig::bibletimeVersion) != BT_VERSION) {
- CBTConfig::set(CBTConfig::bibletimeVersion, BT_VERSION);
+ if (btConfig().value<QString>("bibletimeVersion", BT_VERSION) != BT_VERSION) {
+ btConfig().setValue("bibletimeVersion", QString(BT_VERSION));
mainWindow->saveConfigSettings();
}
@@ -319,7 +334,7 @@ int main(int argc, char* argv[]) {
QDBusConnection::sessionBus().registerObject("/BibleTime", mainWindow);
#endif
- if (CBTConfig::get(CBTConfig::showTipAtStartup))
+ if (btConfig().value<bool>("GUI/showTipAtStartup", true))
mainWindow->slotOpenTipDialog();
r = app.exec();
diff --git a/src/mobile/bibletime.cpp b/src/mobile/bibletime.cpp
new file mode 100644
index 0000000..dd32bf4
--- /dev/null
+++ b/src/mobile/bibletime.cpp
@@ -0,0 +1,101 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "bibletime.h"
+
+#include "backend/config/btconfig.h"
+#include "backend/managers/btstringmgr.h"
+#include "backend/managers/clanguagemgr.h"
+#include "backend/managers/cswordbackend.h"
+#include <QLocale>
+#include <stringmgr.h>
+#include <swlog.h>
+
+namespace btm {
+
+BibleTime::BibleTime(QObject* parent)
+ : QObject(parent) {
+ initBackends();
+}
+
+
+/** Initializes the backend */
+void BibleTime::initBackends() {
+ initSwordConfigFile();
+
+ sword::StringMgr::setSystemStringMgr( new BtStringMgr() );
+ sword::SWLog::getSystemLog()->setLogLevel(sword::SWLog::LOG_ERROR);
+
+ if (qApp->property("--debug").toBool()) {
+ sword::SWLog::getSystemLog()->setLogLevel(sword::SWLog::LOG_DEBUG);
+ }
+
+#ifdef Q_OS_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();
+ QString systemName = QLocale::system().name();
+ QString language = btConfig().value<QString>("language", systemName);
+ backend->booknameLanguage(language);
+
+ const CSwordBackend::LoadError errorCode = CSwordBackend::instance()->initModules(CSwordBackend::OtherChange);
+ if (errorCode != CSwordBackend::NoError) {
+ ; // TODO
+ }
+}
+
+void BibleTime::initSwordConfigFile() {
+// On Windows the sword.conf must be created before the initialization of sword
+// It will contain the LocalePath which is used for sword locales
+// It also contains a DataPath to the %ALLUSERSPROFILE%\Sword directory
+// If this is not done here, the sword locales.d won't be found
+#ifdef Q_OS_WIN
+ 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=" << util::directory::convertDirSeparators( util::directory::getSharedSwordDir().absolutePath()) << "\n";
+ out << "LocalePath=" << util::directory::convertDirSeparators(util::directory::getApplicationSwordDir().absolutePath()) << "\n";
+ out << "\n";
+ file.close();
+#endif
+
+#ifdef Q_OS_MAC
+ 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=" << util::directory::convertDirSeparators( util::directory::getUserHomeSwordDir().absolutePath()) << "\n";
+ out << "\n";
+ file.close();
+#endif
+}
+
+}
diff --git a/src/mobile/bibletime.h b/src/mobile/bibletime.h
new file mode 100644
index 0000000..b424571
--- /dev/null
+++ b/src/mobile/bibletime.h
@@ -0,0 +1,31 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#pragma once
+
+#include <QObject>
+
+namespace btm {
+
+class BibleTime : public QObject {
+ Q_OBJECT
+
+public:
+ BibleTime(QObject* parent = 0);
+
+private:
+ void initBackends();
+ void initSwordConfigFile();
+
+};
+
+}
diff --git a/src/mobile/bibletimeapp.cpp b/src/mobile/bibletimeapp.cpp
new file mode 100644
index 0000000..f7801b8
--- /dev/null
+++ b/src/mobile/bibletimeapp.cpp
@@ -0,0 +1,95 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "bibletimeapp.h"
+
+#include <QDebug>
+#include <QFile>
+#include "backend/config/btconfig.h"
+#include "backend/managers/cswordbackend.h"
+#include "backend/managers/cdisplaytemplatemgr.h"
+#include "frontend/messagedialog.h"
+#include "util/cresmgr.h"
+#include "util/geticon.h"
+#include "util/directory.h"
+
+
+BibleTimeApp::BibleTimeApp(int &argc, char **argv)
+ : QGuiApplication(argc, argv)
+ , m_init(false) {
+ setApplicationName("bibletime");
+ setApplicationVersion(BT_VERSION);
+}
+
+BibleTimeApp::~BibleTimeApp() {
+ // Prevent writing to the log file before the directory cache is init:
+ if (!m_init || BtConfig::m_instance == 0)
+ return;
+
+ //we can set this safely now because we close now (hopyfully without crash)
+ btConfig().setValue("state/crashedLastTime", false);
+ btConfig().setValue("state/crashedTwoTimes", false);
+
+ delete CDisplayTemplateMgr::instance();
+ CLanguageMgr::destroyInstance();
+ CSwordBackend::destroyInstance();
+ util::clearIconCache();
+
+ BtConfig::destroyInstance();
+}
+
+bool BibleTimeApp::initBtConfig() {
+ Q_ASSERT(m_init);
+
+ return BtConfig::initBtConfig();
+}
+
+bool BibleTimeApp::initDisplayTemplateManager() {
+ Q_ASSERT(m_init);
+
+ QString errorMessage;
+ new CDisplayTemplateMgr(errorMessage);
+ if (errorMessage.isNull())
+ return true;
+ message::showCritical(0, tr("Fatal error!"), errorMessage);
+ return false;
+}
+
+
+const QIcon & BibleTimeApp::getIcon(const QString & name) const {
+ QString plainName(name);
+ if (plainName.endsWith(".svg", Qt::CaseInsensitive))
+ plainName.chop(4);
+
+ const QMap<QString, QIcon>::const_iterator i = m_iconCache.find(plainName);
+ if (i != m_iconCache.end())
+ return *i;
+
+ const QString iconDir = util::directory::getIconDir().canonicalPath();
+ QString iconFileName = iconDir + "/" + plainName + ".svg";
+ if (QFile(iconFileName).exists())
+ return *m_iconCache.insert(plainName, QIcon(iconFileName));
+
+ iconFileName = iconDir + "/" + plainName + ".png";
+ if (QFile(iconFileName).exists())
+ return *m_iconCache.insert(plainName, QIcon(iconFileName));
+
+ if (plainName != "default") {
+ qWarning() << "Cannot find icon file" << iconFileName
+ << ", using default icon.";
+ return getIcon("default");
+ }
+
+ qWarning() << "Cannot find default icon" << iconFileName
+ << ", using null icon.";
+ return m_nullIcon;
+}
diff --git a/src/mobile/bibletimeapp.h b/src/mobile/bibletimeapp.h
new file mode 100644
index 0000000..08cd0a5
--- /dev/null
+++ b/src/mobile/bibletimeapp.h
@@ -0,0 +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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BIBLETIMEAPP_H
+#define BIBLETIMEAPP_H
+
+#include <QGuiApplication>
+#include <QIcon>
+#include <QMap>
+
+
+/**
+ The BibleTimeApp class is used to clean up all instances of the backend and to
+ delete all created module objects.
+*/
+class BibleTimeApp : public QGuiApplication {
+
+ Q_OBJECT
+
+ public: /* Methods: */
+
+ BibleTimeApp(int &argc, char **argv);
+ ~BibleTimeApp();
+
+ inline void startInit() { m_init = true; }
+ bool initBtConfig();
+ bool initDisplayTemplateManager();
+
+ /**
+ \param[in] name the name of the icon to return.
+ \returns a reference to the icon with the given name or to a NULL
+ icon if no such icon is found.
+ */
+ const QIcon & getIcon(const QString & name) const;
+
+ private: /* Fields: */
+
+ mutable QMap<QString, QIcon> m_iconCache;
+ const QIcon m_nullIcon;
+ bool m_init;
+
+};
+
+#define bApp (static_cast<BibleTimeApp *>(QCoreApplication::instance()))
+
+#endif
diff --git a/src/mobile/bookshelfmanager/installmanager.cpp b/src/mobile/bookshelfmanager/installmanager.cpp
new file mode 100644
index 0000000..99a72a0
--- /dev/null
+++ b/src/mobile/bookshelfmanager/installmanager.cpp
@@ -0,0 +1,371 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "installmanager.h"
+
+#include "backend/btinstallbackend.h"
+#include "backend/managers/clanguagemgr.h"
+#include "backend/btinstallmgr.h"
+#include "mobile/btmmain.h"
+#include "mobile/ui/qtquick2applicationviewer.h"
+#include "mobile/ui/viewmanager.h"
+#include <QDebug>
+#include <QQuickItem>
+#include <QtAlgorithms>
+
+namespace btm {
+
+enum TextRoles {
+ TextRole = Qt::UserRole + 1
+};
+
+enum WorksRoles {
+ TitleRole = Qt::UserRole + 1,
+ DescriptionRole = Qt::UserRole + 2,
+ InstalledRole = Qt::UserRole + 3
+};
+
+static bool moduleInstalled(const CSwordModuleInfo& moduleInfo) {
+ const CSwordModuleInfo *installedModule = CSwordBackend::instance()->findModuleByName(moduleInfo.name());
+ return installedModule != 0;
+}
+
+static void setupTextModel(const QStringList& modelList, RoleItemModel* model) {
+ QHash<int, QByteArray> roleNames;
+ roleNames[TextRole] = "modelText";
+ model->setRoleNames(roleNames);
+
+ model->clear();
+ for (int i=0; i< modelList.count(); ++i) {
+ QString source = modelList.at(i);
+ QStandardItem* item = new QStandardItem();
+ item->setData(source, TextRole);
+ model->appendRow(item);
+ }
+}
+
+static void setupWorksModel(const QStringList& titleList,
+ const QStringList& descriptionList,
+ const QList<int>& installedList,
+ RoleItemModel* model) {
+ Q_ASSERT(titleList.count() == descriptionList.count());
+ Q_ASSERT(titleList.count() == installedList.count());
+
+ QHash<int, QByteArray> roleNames;
+ roleNames[TitleRole] = "title";
+ roleNames[DescriptionRole] = "desc";
+ roleNames[InstalledRole] = "installed";
+ model->setRoleNames(roleNames);
+
+ model->clear();
+ for (int i=0; i< titleList.count(); ++i) {
+ QStandardItem* item = new QStandardItem();
+ QString title = titleList.at(i);
+ item->setData(title, TitleRole);
+ QString description = descriptionList.at(i);
+ item->setData(description, DescriptionRole);
+ int installed = installedList.at(i);
+ item->setData(installed, InstalledRole);
+ model->appendRow(item);
+ }
+}
+
+InstallManager::InstallManager(QObject* /* parent */)
+ : m_installManagerChooserObject(0),
+ m_btInstallMgr(0) {
+}
+
+void InstallManager::openChooser() {
+
+ if (m_installManagerChooserObject == 0)
+ findInstallManagerObject();
+ if (m_installManagerChooserObject == 0)
+ return;
+
+ setupSourceModel();
+ makeConnections();
+ setProperties();
+ sourceIndexChanged(0);
+}
+
+void InstallManager::findInstallManagerObject() {
+
+ QtQuick2ApplicationViewer* viewer = getViewManager()->getViewer();
+ QQuickItem * rootObject = 0;
+ if (viewer != 0)
+ rootObject = viewer->rootObject();
+ if (rootObject != 0)
+ m_installManagerChooserObject = rootObject->findChild<QQuickItem*>("installManagerChooser");
+}
+
+void InstallManager::findProgressObject() {
+ QtQuick2ApplicationViewer* viewer = getViewManager()->getViewer();
+ QQuickItem * rootObject = 0;
+ if (viewer != 0)
+ rootObject = viewer->rootObject();
+ if (rootObject != 0)
+ m_progressObject = rootObject->findChild<QQuickItem*>("progress");
+}
+
+
+void InstallManager::setupSourceModel() {
+ m_sourceList = BtInstallBackend::sourceNameList();
+ setupTextModel(m_sourceList, &m_sourceModel);
+}
+
+void InstallManager::makeConnections()
+{
+ m_installManagerChooserObject->disconnect();
+
+ bool ok = connect(m_installManagerChooserObject, SIGNAL(sourceChanged(int)),
+ this, SLOT(sourceIndexChanged(int)));
+ Q_ASSERT(ok);
+
+ ok = connect(m_installManagerChooserObject, SIGNAL(categoryChanged(int)),
+ this, SLOT(categoryIndexChanged(int)));
+ Q_ASSERT(ok);
+
+ ok = connect(m_installManagerChooserObject, SIGNAL(languageChanged(int)),
+ this, SLOT(languageIndexChanged(int)));
+ Q_ASSERT(ok);
+
+ ok = connect(m_installManagerChooserObject, SIGNAL(workSelected(int)),
+ this, SLOT(workSelected(int)));
+ Q_ASSERT(ok);
+
+ ok = connect(m_installManagerChooserObject, SIGNAL(cancel()),
+ this, SLOT(cancel()));
+ Q_ASSERT(ok);
+
+ ok = connect(m_installManagerChooserObject, SIGNAL(installRemove()),
+ this, SLOT(installRemove()));
+ Q_ASSERT(ok);
+
+ ok = connect(m_installManagerChooserObject, SIGNAL(refreshLists()),
+ this, SLOT(refreshLists()));
+ Q_ASSERT(ok);
+}
+
+void InstallManager::setProperties() {
+ m_installManagerChooserObject->setProperty("sourceModel", QVariant::fromValue(&m_sourceModel));
+ m_installManagerChooserObject->setProperty("categoryModel", QVariant::fromValue(&m_categoryModel));
+ m_installManagerChooserObject->setProperty("languageModel", QVariant::fromValue(&m_languageModel));
+ m_installManagerChooserObject->setProperty("worksModel", QVariant::fromValue(&m_worksModel));
+ m_installManagerChooserObject->setProperty("sourceIndex", 0);
+ m_installManagerChooserObject->setProperty("visible", true);
+}
+
+void InstallManager::sourceIndexChanged(int index)
+{
+ if (index < 0 || index >= m_sourceList.count())
+ return;
+
+ updateCategoryAndLanguageModels();
+ updateWorksModel();
+}
+
+void InstallManager::categoryIndexChanged(int index)
+{
+ if (index < 0 || index >= m_categoryList.count())
+ return;
+ updateWorksModel();
+}
+
+void InstallManager::languageIndexChanged(int index)
+{
+ if (index < 0 || index >= m_languageList.count())
+ return;
+ updateWorksModel();
+}
+
+void InstallManager::workSelected(int index) {
+ QStandardItem* item = m_worksModel.item(index,0);
+ QVariant vInstalled = item->data(InstalledRole);
+ int installed = vInstalled.toInt();
+ installed = installed == 0 ? 1 : 0;
+ item->setData(installed, InstalledRole);
+
+ CSwordModuleInfo* moduleInfo = m_worksList.at(index);
+ m_modulesToInstallRemove[moduleInfo] = installed == 1;
+}
+
+void InstallManager::cancel() {
+ m_installManagerChooserObject->setProperty("visible", false);
+}
+
+void InstallManager::installRemove() {
+ m_installManagerChooserObject->setProperty("visible", false);
+
+ QList<CSwordModuleInfo*> modulesToRemove;
+ QList<CSwordModuleInfo*> modulesToInstall;
+ QMap<CSwordModuleInfo*, bool>::const_iterator it;
+ for(it=m_modulesToInstallRemove.constBegin();
+ it!=m_modulesToInstallRemove.constEnd();
+ ++it) {
+ CSwordModuleInfo* moduleInfo = it.key();
+ bool install = it.value();
+ QString name = moduleInfo->name();
+ if (moduleInstalled(*moduleInfo) && install == false) {
+ modulesToRemove.append(moduleInfo);
+ }
+ else if ( ! moduleInstalled(*moduleInfo) && install == true) {
+ modulesToInstall.append(moduleInfo);
+ }
+ }
+ removeModules(modulesToRemove);
+ installModules(modulesToInstall);
+}
+
+void InstallManager::updateCategoryAndLanguageModels()
+{
+ QString sourceName = getCurrentListItem("sourceIndex", m_sourceList);
+ sword::InstallSource source = BtInstallBackend::source(sourceName);
+ CSwordBackend* backend = BtInstallBackend::backend(source);
+ const QList<CSwordModuleInfo*> modules = backend->moduleList();
+
+ QSet<QString> categories;
+ QSet<QString> languages;
+ for (int moduleIndex=0; moduleIndex<modules.count(); ++moduleIndex) {
+ CSwordModuleInfo* module = modules.at(moduleIndex);
+ CSwordModuleInfo::Category category = module->category();
+ // QString name = module->name();
+ QString categoryName = module->categoryName(category);
+ const CLanguageMgr::Language* language = module->language();
+ QString languageName = language->englishName();
+ categories.insert(categoryName);
+ languages.insert(languageName);
+ }
+
+ QString currentCategory = getCurrentListItem("categoryIndex", m_categoryList);
+ m_categoryList = categories.toList();
+ m_categoryList.sort();
+ setupTextModel(m_categoryList, &m_categoryModel);
+ setCurrentListItem("categoryIndex", m_categoryList, currentCategory);
+
+ QString currentLanguage = getCurrentListItem("languageIndex", m_languageList);
+ m_languageList = languages.toList();
+ m_languageList.sort();
+ setupTextModel(m_languageList, &m_languageModel);
+ setCurrentListItem("languageIndex", m_languageList, currentLanguage);
+}
+
+QString InstallManager::getCurrentListItem(const char* propertyName, const QStringList& list) {
+ QString value;
+ QVariant vIndex = m_installManagerChooserObject->property(propertyName);
+ bool ok;
+ int index = vIndex.toInt(&ok);
+ if (ok) {
+ if (index >= 0 && index < list.count())
+ value = list.at(index);
+ }
+ return value;
+}
+
+void InstallManager::setCurrentListItem(const char* propertyName,
+ const QStringList& list,
+ const QString& itemName) {
+ int index = list.indexOf(itemName);
+ if (index < 0)
+ index = 0;
+ m_installManagerChooserObject->setProperty(propertyName, index);
+}
+
+void InstallManager::updateWorksModel()
+{
+ QString sourceName = getCurrentListItem("sourceIndex", m_sourceList);
+ QString categoryName = getCurrentListItem("categoryIndex", m_categoryList);
+ QString languageName = getCurrentListItem("languageIndex", m_languageList);
+
+ sword::InstallSource source = BtInstallBackend::source(sourceName);
+ CSwordBackend* backend = BtInstallBackend::backend(source);
+ const QList<CSwordModuleInfo*> modules = backend->moduleList();
+
+ m_worksTitleList.clear();
+ m_worksDescList.clear();
+ m_worksList.clear();
+ m_worksInstalledList.clear();
+ for (int moduleIndex=0; moduleIndex<modules.count(); ++moduleIndex) {
+ CSwordModuleInfo* module = modules.at(moduleIndex);
+ module->setProperty("installSourceName", sourceName);
+ CSwordModuleInfo::Category category = module->category();
+ QString moduleCategoryName = module->categoryName(category);
+ const CLanguageMgr::Language* language = module->language();
+ QString moduleLanguageName = language->englishName();
+ if (moduleCategoryName == categoryName &&
+ moduleLanguageName == languageName ) {
+ QString name = module->name();
+ QString description = module->config(CSwordModuleInfo::Description);
+ QString version = module->config(CSwordModuleInfo::ModuleVersion);
+ QString info = description + ": " + version;\
+ int installed = moduleInstalled(*module) ? 1 : 0;
+ m_worksTitleList.append(name);
+ m_worksDescList.append(info);
+ m_worksList.append(module);
+ m_worksInstalledList.append(installed);
+ }
+ }
+ setupWorksModel(m_worksTitleList, m_worksDescList, m_worksInstalledList, &m_worksModel);
+}
+
+void InstallManager::removeModules(const QList<CSwordModuleInfo*>& modules) {
+
+ QStringList moduleNames;
+ foreach ( CSwordModuleInfo* mInfo, modules ) {
+ QString moduleName = mInfo->name();
+ moduleNames.append(moduleName);
+ }
+ // Update the module list before really removing. Remember deleting the pointers later.
+ QList<CSwordModuleInfo*> toBeDeleted = CSwordBackend::instance()->takeModulesFromList(moduleNames);
+
+ sword::InstallMgr installMgr;
+ QMap<QString, sword::SWMgr*> mgrDict; //maps config paths to SWMgr objects
+ foreach ( CSwordModuleInfo* mInfo, toBeDeleted ) {
+ Q_ASSERT(mInfo); // Only installed modules could have been selected and returned by takeModulesFromList
+ // Find the install path for the sword manager
+ QString prefixPath = mInfo->config(CSwordModuleInfo::AbsoluteDataPath) + "/";
+ QString dataPath = mInfo->config(CSwordModuleInfo::DataPath);
+ if (dataPath.left(2) == "./") {
+ dataPath = dataPath.mid(2);
+ }
+ if (prefixPath.contains(dataPath)) { //remove module part to get the prefix path
+ prefixPath = prefixPath.remove( prefixPath.indexOf(dataPath), dataPath.length() );
+ }
+ else { //This is an error, should not happen
+ qWarning() << "Removing" << mInfo->name() << "didn't succeed because the absolute path" << prefixPath << "didn't contain the data path" << dataPath;
+ continue; // don't remove this, go to next of the for loop
+ }
+
+ // Create the sword manager and remove the module
+ sword::SWMgr* mgr = mgrDict[ prefixPath ];
+ if (!mgr) { //create new mgr if it's not yet available
+ mgrDict.insert(prefixPath, new sword::SWMgr(prefixPath.toLocal8Bit()));
+ mgr = mgrDict[ prefixPath ];
+ }
+ qDebug() << "Removing the module" << mInfo->name() << "...";
+ installMgr.removeModule(mgr, mInfo->module()->getName());
+ }
+ //delete the removed moduleinfo pointers
+ qDeleteAll(modules);
+ //delete all mgrs which were created above
+ qDeleteAll(mgrDict);
+ mgrDict.clear();
+}
+
+void InstallManager::installModules(const QList<CSwordModuleInfo*>& modules) {
+ m_installProgress.openProgress(modules);
+}
+
+void InstallManager::refreshLists() {
+ m_installSourcesManager.refreshSources();
+}
+
+} // end namespace
diff --git a/src/mobile/bookshelfmanager/installmanager.h b/src/mobile/bookshelfmanager/installmanager.h
new file mode 100644
index 0000000..a976ad8
--- /dev/null
+++ b/src/mobile/bookshelfmanager/installmanager.h
@@ -0,0 +1,82 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef INSTALL_MODULE_CHOOSER_H
+#define INSTALL_MODULE_CHOOSER_H
+
+#include "installsourcesmanager.h"
+#include "mobile/models/roleitemmodel.h"
+#include "installprogress.h"
+#include <QMap>
+#include <QObject>
+
+class QQuickItem;
+class CSwordModuleInfo;
+class BtInstallMgr;
+
+namespace btm {
+
+class InstallManager :public QObject {
+ Q_OBJECT
+
+public:
+ InstallManager(QObject* parent = 0);
+
+ Q_INVOKABLE void openChooser();
+
+private slots:
+ void cancel();
+ void categoryIndexChanged(int index);
+ void installRemove();
+ void languageIndexChanged(int index);
+ void refreshLists();
+ void sourceIndexChanged(int index);
+ void workSelected(int index);
+
+private:
+ QString getCurrentListItem(const char* propertyName,
+ const QStringList& list);
+ void findInstallManagerObject();
+ void findProgressObject();
+ void installModules(const QList<CSwordModuleInfo*>& modules);
+ void makeConnections();
+ void removeModules(const QList<CSwordModuleInfo*>& modules);
+ void setProperties();
+ void setupSourceModel();
+ void setCurrentListItem(const char* propertyName,
+ const QStringList& list,
+ const QString& itemName);
+ void updateCategoryAndLanguageModels();
+ void updateWorksModel();
+
+ QQuickItem* m_installManagerChooserObject;
+ QQuickItem* m_progressObject;
+ BtInstallMgr* m_btInstallMgr;
+ InstallSourcesManager m_installSourcesManager;
+
+ InstallProgress m_installProgress;
+ QStringList m_sourceList;
+ QStringList m_categoryList;
+ QStringList m_languageList;
+ QStringList m_worksTitleList;
+ QStringList m_worksDescList;
+ QList<CSwordModuleInfo*> m_worksList;
+ QList<int> m_worksInstalledList;
+ QMap<CSwordModuleInfo*, bool> m_modulesToInstallRemove;
+ RoleItemModel m_sourceModel;
+ RoleItemModel m_categoryModel;
+ RoleItemModel m_languageModel;
+ RoleItemModel m_worksModel;
+};
+
+} // end namespace
+#endif
diff --git a/src/mobile/bookshelfmanager/installprogress.cpp b/src/mobile/bookshelfmanager/installprogress.cpp
new file mode 100644
index 0000000..dd113ec
--- /dev/null
+++ b/src/mobile/bookshelfmanager/installprogress.cpp
@@ -0,0 +1,199 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "installprogress.h"
+
+#include "backend/btinstallbackend.h"
+#include "backend/managers/cswordbackend.h"
+#include "backend/btinstallthread.h"
+#include "mobile/btmmain.h"
+#include "mobile/ui/qtquick2applicationviewer.h"
+#include "mobile/ui/viewmanager.h"
+#include <QQuickItem>
+#include <QDebug>
+
+namespace btm {
+
+InstallProgress::InstallProgress(QObject* parent)
+ : QObject(parent), m_progressObject(0) {
+}
+
+void InstallProgress::openProgress(const QList<CSwordModuleInfo*>& modules) {
+ if (modules.count() == 0)
+ return;
+
+ if (m_progressObject == 0)
+ findProgressObject();
+ if (m_progressObject == 0)
+ return;
+
+ QString destination = getSourcePath();
+ if (destination.isEmpty())
+ return;
+
+ setProperties();
+
+ Q_FOREACH(const CSwordModuleInfo *module, modules) {
+ const QString sourceName(module->property("installSourceName").toString());
+ // create a thread for this module
+ BtInstallThread* thread = new BtInstallThread(module->name(), sourceName, destination);
+ m_waitingThreads.insert(sourceName, thread);
+ m_threadsByModule.insert(module->name(), thread);
+
+ QObject::connect(thread, SIGNAL(installStopped(QString, QString)),
+ this, SLOT(slotOneItemStopped(QString, QString)), Qt::QueuedConnection);
+ QObject::connect(thread, SIGNAL(installCompleted(QString, QString, int)),
+ this, SLOT(slotOneItemCompleted(QString, QString, int)), Qt::QueuedConnection);
+ QObject::connect(thread, SIGNAL(statusUpdated(QString, int)),
+ this, SLOT(slotStatusUpdated(QString, int)), Qt::QueuedConnection);
+ QObject::connect(thread, SIGNAL(downloadStarted(QString)),
+ this, SLOT(slotDownloadStarted(QString)), Qt::QueuedConnection);
+ QObject::connect(thread, SIGNAL(preparingInstall(QString, QString)),
+ this, SLOT(slotInstallStarted(QString, QString)), Qt::QueuedConnection);
+ }
+
+ connect(m_progressObject, SIGNAL(cancel()), this, SLOT(slotStopInstall()));
+ startThreads();
+}
+
+void InstallProgress::cancel() {
+ m_progressObject->setProperty("visible", false);
+}
+
+void InstallProgress::close() {
+ m_progressObject->setProperty("visible", false);
+ CSwordBackend::instance()->reloadModules(CSwordBackend::AddedModules);
+}
+
+void InstallProgress::slotOneItemCompleted(QString module, QString source, int status) {
+ QString message;
+ //status comes from the sword installer.
+ if (status != 0) {
+ message = tr("Failed");
+ }
+ else {
+ message = tr("Completed");
+ }
+ oneItemStoppedOrCompleted(module, source, message);
+}
+
+void InstallProgress::slotOneItemStopped(QString module, QString source) {
+ oneItemStoppedOrCompleted(module, source, tr("Cancelled"));
+}
+
+// TODO show failed status
+void InstallProgress::oneItemStoppedOrCompleted(QString module, QString source, QString statusMessage) {
+ qDebug() << "\n**********************************\nBtInstallProgressDialog::oneItemStoppedOrCompleted" << module << statusMessage << "\n******************************************";
+ qDebug() << "remove from threads maps" << source << m_threadsByModule.value(module);
+ m_runningThreads.remove(source, m_threadsByModule.value(module));
+ m_waitingThreads.remove(source, m_threadsByModule.value(module));
+
+ //non-concurrent
+ QMultiMap<QString, BtInstallThread*>::iterator threadIterator = m_waitingThreads.end();
+ if (m_runningThreads.isEmpty() && threadIterator != m_waitingThreads.begin()) {
+ --threadIterator; // the last item
+ QString sourceName = threadIterator.key();
+ BtInstallThread* t = threadIterator.value();
+ m_runningThreads.insert(sourceName, t);
+ threadIterator = m_waitingThreads.erase(threadIterator);
+ t->start();
+ }
+
+ if (threadsDone()) {
+ qDebug() << "close the dialog";
+ close();
+ }
+}
+
+void InstallProgress::slotStopInstall() {
+ qDebug() << "BtInstallProgressDialog::slotStopInstall";
+
+ // Clear the waiting threads map, stop all running threads.
+ m_waitingThreads.clear();
+ if (m_runningThreads.count() > 0) {
+ foreach(BtInstallThread* thread, m_runningThreads) {
+ thread->slotStopInstall();
+ }
+ }
+ else {
+ close();
+ }
+}
+
+void InstallProgress::slotStatusUpdated(QString /* module */, int status) {
+ m_progressObject->setProperty("value", status);
+}
+
+void InstallProgress::slotInstallStarted(QString /* module */, QString) {
+}
+
+void InstallProgress::slotDownloadStarted(QString module) {
+ QString message = "Installing " + module;
+ m_progressObject->setProperty("text", message);
+ m_progressObject->setProperty("value", 0);
+}
+
+void InstallProgress::startThreads() {
+ QMultiMap<QString, BtInstallThread*>::iterator threadIterator = m_waitingThreads.end();
+ if (threadIterator != m_waitingThreads.begin()) {
+ // go to the last item which is actually the first in the visible list
+ // because the iterator is reversed compared to insert order
+ --threadIterator;
+ QString sourceName = threadIterator.key();
+ BtInstallThread* t = threadIterator.value();
+ m_runningThreads.insert(sourceName, t);
+ threadIterator = m_waitingThreads.erase(threadIterator);
+ t->start();
+ }
+}
+
+bool InstallProgress::threadsDone() {
+ return (m_waitingThreads.isEmpty() && m_runningThreads.isEmpty());
+}
+
+void InstallProgress::findProgressObject() {
+ QtQuick2ApplicationViewer* viewer = getViewManager()->getViewer();
+ QQuickItem * rootObject = 0;
+ if (viewer != 0)
+ rootObject = viewer->rootObject();
+ if (rootObject != 0)
+ m_progressObject = rootObject->findChild<QQuickItem*>("progress");
+}
+
+void InstallProgress::setProperties() {
+ m_progressObject->setProperty("visible", true);
+ m_progressObject->setProperty("minimumValue", 0.0);
+ m_progressObject->setProperty("maximumValue", 100.0);
+ m_progressObject->setProperty("value", 0.0);
+}
+
+QString InstallProgress::getSourcePath() {
+ QStringList targets = BtInstallBackend::targetList();
+ for (QStringList::iterator it = targets.begin(); it != targets.end(); ++it) {
+ // Add the path only if it's writable
+ QString sourcePath = *it;
+ if (sourcePath.isEmpty())
+ continue;
+ QDir dir(sourcePath);
+ if (!dir.exists())
+ continue;
+ if (!dir.isReadable())
+ continue;
+ QFileInfo fi( dir.canonicalPath());
+ if (!fi.isWritable())
+ continue;
+ return sourcePath;
+ }
+ return QString();
+}
+
+}
diff --git a/src/mobile/bookshelfmanager/installprogress.h b/src/mobile/bookshelfmanager/installprogress.h
new file mode 100644
index 0000000..4f9908c
--- /dev/null
+++ b/src/mobile/bookshelfmanager/installprogress.h
@@ -0,0 +1,61 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef INSTALL_PROGRESS_H
+#define INSTALL_PROGRESS_H
+
+#include <QObject>
+#include <QMultiMap>
+#include <QMap>
+
+class QQuickItem;
+class CSwordModuleInfo;
+class BtInstallThread;
+
+namespace btm {
+
+class InstallProgress: public QObject {
+ Q_OBJECT
+
+public:
+ InstallProgress(QObject* parent = 0);
+
+ void openProgress(const QList<CSwordModuleInfo*>& modules);
+
+private slots:
+ void cancel();
+ void close();
+ void slotOneItemCompleted(QString module, QString source, int status);
+ void slotOneItemStopped(QString module, QString source);
+ void slotStopInstall();
+ void slotStatusUpdated(QString module, int status);
+ void slotDownloadStarted(QString module);
+ void slotInstallStarted(QString module, QString);
+ bool threadsDone();
+
+private:
+ void findProgressObject();
+ QString getSourcePath();
+ void oneItemStoppedOrCompleted(QString module, QString source, QString message);
+ void setProperties();
+ void startThreads();
+
+ QQuickItem* m_progressObject;
+ QMultiMap<QString, BtInstallThread*> m_waitingThreads;
+ QMultiMap<QString, BtInstallThread*> m_runningThreads;
+ QMap<QString, BtInstallThread*> m_threadsByModule;
+};
+
+
+}
+
+#endif
diff --git a/src/mobile/bookshelfmanager/installsources.cpp b/src/mobile/bookshelfmanager/installsources.cpp
new file mode 100644
index 0000000..6f6fa91
--- /dev/null
+++ b/src/mobile/bookshelfmanager/installsources.cpp
@@ -0,0 +1,75 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "installsources.h"
+
+#include "backend/btinstallbackend.h"
+#include "backend/btinstallmgr.h"
+#include <QDebug>
+
+namespace btm {
+
+InstallSources::InstallSources(QObject *parent)
+ : QObject(parent),
+ done(false),
+ m_cancelled(false) {
+ m_iMgr = new BtInstallMgr();
+}
+
+
+InstallSources::~InstallSources() {
+ delete m_iMgr;
+}
+
+void InstallSources::process() {
+
+ m_canceled = false;
+ refreshSourceList();
+ if (m_canceled)
+ return;
+ QStringList sourceNames = BtInstallBackend::sourceNameList();
+ refreshWorks(sourceNames);
+ emit finished();
+}
+
+void InstallSources::refreshSourceList() {
+ int ret = m_iMgr->refreshRemoteSourceConfiguration();
+ if (ret ) {
+ qWarning("InstallMgr: getting remote list returned an error.");
+ }
+}
+
+void InstallSources::refreshWorks(const QStringList& sourceNames) {
+ int sourceCount = sourceNames.count();
+ for (int i=0; i<sourceCount; ++i) {
+ if (m_canceled)
+ break;
+ QString sourceName = sourceNames.at(i);
+ int percent = 10 + 90 *((double)i/sourceCount);
+ QString title = "Refreshing " + sourceName;
+ emit percentComplete(percent, title);
+ qDebug() << title << percent;
+ sword::InstallSource source = BtInstallBackend::source(sourceName);
+ bool result = (m_iMgr->refreshRemoteSource(&source) == 0);
+ if (result) {
+ ;
+ } else {
+ QString error = QString(tr("Failed to refresh source %1")).arg(sourceName);
+ qDebug() << error;
+ }
+ }
+ emit percentComplete(100, "Done");
+}
+
+void InstallSources::cancel() {
+ m_canceled = true;
+ qDebug() << "IS canceled";
+}
+
+}
diff --git a/src/mobile/bookshelfmanager/installsources.h b/src/mobile/bookshelfmanager/installsources.h
new file mode 100644
index 0000000..f552c68
--- /dev/null
+++ b/src/mobile/bookshelfmanager/installsources.h
@@ -0,0 +1,52 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef INSTALLSOURCESTHREAD_H
+#define INSTALLSOURCESTHREAD_H
+
+#include <QObject>
+
+class BtInstallMgr;
+
+namespace btm {
+
+class InstallSources : public QObject {
+ Q_OBJECT
+ public:
+ InstallSources(QObject *parent = 0);
+
+ ~InstallSources();
+
+ public slots:
+ void process();
+ void cancel();
+
+ public:
+ bool done;
+
+ protected:
+ void refreshSourceList();
+ void refreshWorks(const QStringList& sourceNames);
+
+ bool m_cancelled;
+ BtInstallMgr* m_iMgr;
+
+ signals:
+ void finished();
+ void error(QString err);
+ void percentComplete(int percent, const QString& title);
+
+private:
+ bool m_canceled;
+};
+
+}
+#endif
diff --git a/src/mobile/bookshelfmanager/installsourcesmanager.cpp b/src/mobile/bookshelfmanager/installsourcesmanager.cpp
new file mode 100644
index 0000000..bc55f12
--- /dev/null
+++ b/src/mobile/bookshelfmanager/installsourcesmanager.cpp
@@ -0,0 +1,85 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "installsourcesmanager.h"
+
+#include "installsources.h"
+#include "backend/btinstallbackend.h"
+#include "mobile/btmmain.h"
+#include "mobile/ui/qtquick2applicationviewer.h"
+#include "mobile/ui/viewmanager.h"
+#include <QDebug>
+#include <QQuickItem>
+#include <QThread>
+
+namespace btm {
+
+InstallSourcesManager::InstallSourcesManager(QObject* /* parent */)
+ : m_worker(0) {
+}
+
+InstallSourcesManager::~InstallSourcesManager() {
+}
+
+void InstallSourcesManager::refreshSources() {
+ findProgressObject();
+ Q_ASSERT(m_progressObject != 0);
+ if (m_progressObject == 0)
+ return;
+ m_progressObject->disconnect(this);
+ connect(m_progressObject, SIGNAL(cancel()), this, SLOT(cancel()));
+
+ m_progressObject->setProperty("minimumValue", 0.0);
+ m_progressObject->setProperty("maximumValue", 100.0);
+ m_progressObject->setProperty("value", 0.0);
+ m_progressObject->setProperty("visible", true);
+ m_progressObject->setProperty("text", "Refreshing Source List");
+
+ runThread();
+}
+
+void InstallSourcesManager::cancel() {
+ m_worker->cancel();
+ m_progressObject->setProperty("visible", false);
+}
+
+void InstallSourcesManager::runThread() {
+ QThread* thread = new QThread;
+ m_worker = new InstallSources();
+ m_worker->moveToThread(thread);
+// connect(m_worker, SIGNAL(error(QString)), this, SLOT(errorString(QString)));
+ connect(thread, SIGNAL(started()), m_worker, SLOT(process()));
+ connect(m_worker, SIGNAL(finished()), thread, SLOT(quit()));
+ connect(m_worker, SIGNAL(finished()), m_worker, SLOT(deleteLater()));
+ connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
+ connect(m_worker, SIGNAL(percentComplete(int, const QString&)),
+ this, SLOT(percentComplete(int, const QString&)));
+ thread->start();
+}
+
+void InstallSourcesManager::percentComplete(int percent, const QString& title) {
+ m_progressObject->setProperty("value", percent);
+ m_progressObject->setProperty("text", title);
+ if (percent == 100)
+ m_progressObject->setProperty("visible", false);
+}
+
+void InstallSourcesManager::findProgressObject() {
+ QtQuick2ApplicationViewer* viewer = getViewManager()->getViewer();
+ QQuickItem * rootObject = 0;
+ if (viewer != 0)
+ rootObject = viewer->rootObject();
+ if (rootObject != 0)
+ m_progressObject = rootObject->findChild<QQuickItem*>("progress");
+}
+
+} // end namespace
diff --git a/src/mobile/bookshelfmanager/installsourcesmanager.h b/src/mobile/bookshelfmanager/installsourcesmanager.h
new file mode 100644
index 0000000..07665b4
--- /dev/null
+++ b/src/mobile/bookshelfmanager/installsourcesmanager.h
@@ -0,0 +1,45 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef INSTALL_SOURCES_MANAGER_H
+#define INSTALL_SOURCES_MANAGER_H
+
+#include <QObject>
+#include <QQuickItem>
+
+namespace btm {
+
+class InstallSources;
+
+class InstallSourcesManager :public QObject {
+ Q_OBJECT
+
+public:
+ InstallSourcesManager(QObject* parent = 0);
+ ~InstallSourcesManager();
+
+ void refreshSources();
+
+private slots:
+ void cancel();
+ void percentComplete(int percent, const QString& title);
+
+private:
+ void findProgressObject();
+ void runThread();
+
+ QQuickItem* m_progressObject;
+ InstallSources* m_worker;
+};
+
+} // end namespace
+#endif
diff --git a/src/mobile/btmmain.cpp b/src/mobile/btmmain.cpp
new file mode 100644
index 0000000..12cbbf4
--- /dev/null
+++ b/src/mobile/btmmain.cpp
@@ -0,0 +1,106 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "bibletime.h"
+#include "backend/config/btconfig.h"
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+#include "mobile/bibletimeapp.h"
+#include "mobile/bookshelfmanager/installmanager.h"
+#include "mobile/ui/btstyle.h"
+#include "mobile/ui/btwindowinterface.h"
+#include "mobile/ui/moduleinterface.h"
+#include "mobile/ui/qtquick2applicationviewer.h"
+#include "mobile/ui/viewmanager.h"
+#include <QBrush>
+#include <QColor>
+#include <QGuiApplication>
+#include <QPalette>
+#include <QQuickItem>
+#include <QQmlDebuggingEnabler>
+#include <QMetaType>
+#include <QTranslator>
+#include "util/directory.h"
+
+btm::ViewManager* mgr = 0;
+
+void register_gml_classes() {
+ QQmlDebuggingEnabler enabler;
+
+ qmlRegisterType<btm::BtWindowInterface>("BibleTime", 1, 0, "BtWindowInterface");
+ qmlRegisterType<btm::BtStyle>("BibleTime", 1, 0, "BtStyle");
+ qmlRegisterType<btm::InstallManager>("BibleTime", 1, 0, "InstallManager");
+ qmlRegisterType<btm::ModuleInterface>("BibleTime", 1, 0, "ModuleInterface");
+}
+
+btm::ViewManager* getViewManager() {
+ return mgr;
+}
+
+/*******************************************************************************
+ Handle Qt's meta type system.
+*******************************************************************************/
+
+void registerMetaTypes() {
+ qRegisterMetaType<FilterOptions>("FilterOptions");
+ qRegisterMetaType<DisplayOptions>("DisplayOptions");
+ qRegisterMetaTypeStreamOperators<BtBookshelfTreeModel::Grouping>("BtBookshelfTreeModel::Grouping");
+
+ qRegisterMetaType<BTModuleTreeItem::Grouping>("Grouping");
+ qRegisterMetaTypeStreamOperators<BTModuleTreeItem::Grouping>("Grouping");
+
+ qRegisterMetaType<BtConfig::StringMap>("StringMap");
+ qRegisterMetaTypeStreamOperators<BtConfig::StringMap>("StringMap");
+
+ qRegisterMetaType<QList<int> >("QList<int>");
+ qRegisterMetaTypeStreamOperators<QList<int> >("QList<int>");
+}
+
+
+int main(int argc, char *argv[]) {
+ namespace DU = util::directory;
+
+ BibleTimeApp app(argc, argv); //for QApplication
+
+ registerMetaTypes();
+
+ if (!DU::initDirectoryCache()) {
+ qFatal("Error initializing directory cache!");
+ return EXIT_FAILURE;
+ }
+
+ app.startInit();
+ if (!app.initBtConfig()) {
+ return EXIT_FAILURE;
+ }
+
+ //first install QT's own translations
+ QTranslator qtTranslator;
+ qtTranslator.load("qt_" + QLocale::system().name());
+ app.installTranslator(&qtTranslator);
+ //then our own
+ QTranslator BibleTimeTranslator;
+ BibleTimeTranslator.load( QString("bibletime_ui_").append(QLocale::system().name()), DU::getLocaleDir().canonicalPath());
+ app.installTranslator(&BibleTimeTranslator);
+
+// // a new BibleTime version was installed (maybe a completely new installation)
+// if (btConfig().value<QString>("bibletimeVersion", BT_VERSION) != BT_VERSION) {
+// btConfig().setValue("bibletimeVersion", QString(BT_VERSION));
+// mainWindow->saveConfigSettings();
+// }
+
+ register_gml_classes();
+ mgr = new btm::ViewManager;
+ mgr->show();
+ btm::BibleTime btm;
+
+ return app.exec();
+}
diff --git a/src/mobile/btmmain.h b/src/mobile/btmmain.h
new file mode 100644
index 0000000..64bd25e
--- /dev/null
+++ b/src/mobile/btmmain.h
@@ -0,0 +1,23 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef VIEW_MANAGER_INCLUDED
+#define VIEW_MANAGER_INCLUDED
+
+namespace btm {
+ class ViewManager;
+}
+
+btm::ViewManager* getViewManager();
+
+#endif
+
diff --git a/src/mobile/keychooser/bookkeychooser.cpp b/src/mobile/keychooser/bookkeychooser.cpp
new file mode 100644
index 0000000..9ae3ef9
--- /dev/null
+++ b/src/mobile/keychooser/bookkeychooser.cpp
@@ -0,0 +1,272 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "bookkeychooser.h"
+
+#include <cmath>
+#include "mobile/ui/btwindowinterface.h"
+#include "mobile/ui/qtquick2applicationviewer.h"
+#include <QCoreApplication>
+#include <QDebug>
+#include <QQmlProperty>
+#include <QQmlContext>
+#include <QQmlProperty>
+#include <QQuickItem>
+#include <QStandardItem>
+#include <QString>
+
+namespace btm {
+
+struct BookEntry {
+ enum BookRoles {
+ NameRole = Qt::UserRole + 1,
+ ChildCountRole
+ };
+};
+
+BookKeyChooser::BookKeyChooser(QtQuick2ApplicationViewer* viewer,
+ BtWindowInterface* windowInterface)
+ : m_viewer(viewer),
+ m_windowInterface(windowInterface),
+ m_key(0),
+ m_treeChooserObject(0),
+ m_state(CLOSED ) {
+ findTreeChooserObject();
+ initializeRoleNameModel();
+}
+
+void BookKeyChooser::copyKey()
+{
+ CSwordKey* key = m_windowInterface->getKey();
+ CSwordTreeKey* bookKey = dynamic_cast<CSwordTreeKey*>(key);
+ m_key = new CSwordTreeKey(*bookKey);
+}
+
+void BookKeyChooser::findTreeChooserObject() {
+ QQuickItem * rootObject = m_viewer->rootObject();
+ if (rootObject != 0)
+ m_treeChooserObject = rootObject->findChild<QQuickItem*>("treeChooser");
+}
+
+void BookKeyChooser::initializeRoleNameModel() {
+ QHash<int, QByteArray> roleNames;
+ roleNames[BookEntry::NameRole] = "name";
+ roleNames[BookEntry::ChildCountRole] = "childcount";
+ m_roleItemModel.setRoleNames(roleNames);
+}
+
+void BookKeyChooser::populateRoleNameModel(const QStringList& sibblings, const QList<int>& sibblingChildCounts) {
+ m_roleItemModel.clear();
+ Q_ASSERT(sibblings.count() == sibblingChildCounts.count());
+ for (int i=0; i< sibblings.count(); ++i) {
+ QString sibbling = sibblings.at(i);
+ int childCount = sibblingChildCounts.at(i);
+ QStandardItem* item = new QStandardItem();
+ item->setData(sibbling, BookEntry::NameRole);
+ item->setData(childCount, BookEntry::ChildCountRole);
+ m_roleItemModel.appendRow(item);
+ }
+}
+
+static QString constructPath(const QStringList& pathList) {
+ QString path;
+ for (int i=0; i< pathList.count(); ++i) {
+ QString leaf = QString("/") + pathList.at(i);
+ path.append(leaf);
+ }
+ return path;
+}
+
+static QString getBackPath(const CSwordTreeKey& key) {
+ QString path = key.key();
+ QStringList pathList = path.split('/', QString::SkipEmptyParts);
+ pathList.removeLast();
+
+ QString backPath;
+ if (pathList.count() == 0)
+ return backPath;
+
+ backPath = constructPath(pathList);
+ return backPath;
+}
+
+void BookKeyChooser::select(QString value) {
+ openChooser(false);
+
+ QStringList keyPathList = getKeyPath();
+ keyPathList.removeLast();
+ keyPathList.append(value);
+ QString newPath = constructPath(keyPathList);
+ CSwordTreeKey* tmpBookKey = dynamic_cast<CSwordTreeKey*>(m_key);
+ tmpBookKey->setKey(newPath);
+
+ CSwordKey* key = m_windowInterface->getKey();
+ CSwordTreeKey* bookKey = dynamic_cast<CSwordTreeKey*>(key);
+ bookKey->setKey(*tmpBookKey);
+
+ emit referenceChanged();
+}
+
+void BookKeyChooser::open() {
+ copyKey();
+
+ CSwordTreeKey tmpKey(*m_key);
+ m_backPath = getBackPath(tmpKey);
+ QStringList siblings;
+ QList<int> hasChildrenList;
+ parseKey(&siblings, &hasChildrenList, &tmpKey);
+ populateRoleNameModel(siblings, hasChildrenList);
+ openChooser(true);
+}
+
+void BookKeyChooser::next(QString value) {
+ openChooser(false);
+
+ QStringList keyPathList = getKeyPath();
+ keyPathList.removeLast();
+ keyPathList.append(value);
+
+ QString newPath = constructPath(keyPathList);
+ m_key->setKey(newPath);
+ m_key->firstChild();
+
+ CSwordTreeKey tmpKey(*m_key);
+ m_backPath = getBackPath(tmpKey);
+ QStringList siblings;
+ QList<int> counts;
+ parseKey(&siblings, &counts, &tmpKey);
+ populateRoleNameModel(siblings, counts);
+ openChooser(true);
+
+ m_key->setKey(tmpKey);
+}
+
+void BookKeyChooser::back() {
+ openChooser(false);
+
+ QStringList keyPathList = getKeyPath();
+ keyPathList.removeLast();
+
+ QString newPath = constructPath(keyPathList);
+ keyPathList.removeLast();
+ m_key->setKey(newPath);
+
+ CSwordTreeKey tmpKey(*m_key);
+ m_backPath = getBackPath(tmpKey);
+ QStringList siblings;
+ QList<int> counts;
+ parseKey(&siblings, &counts, &tmpKey);
+ populateRoleNameModel(siblings, counts);
+
+ openChooser(true);
+}
+
+void BookKeyChooser::stringCanceled() {
+}
+
+void BookKeyChooser::setProperties() {
+ m_treeChooserObject->setProperty("path",m_backPath);
+ m_treeChooserObject->setProperty("model", QVariant::fromValue(&m_roleItemModel));
+}
+
+void BookKeyChooser::openChooser(bool open) {
+ Q_ASSERT(m_treeChooserObject != 0);
+ if (m_treeChooserObject == 0)
+ return;
+
+ m_treeChooserObject->disconnect();
+ bool ok = connect(m_treeChooserObject, SIGNAL(select(QString)),
+ this, SLOT(select(QString)));
+ Q_ASSERT(ok);
+
+ ok = connect(m_treeChooserObject, SIGNAL(next(QString)),
+ this, SLOT(next(QString)));
+ Q_ASSERT(ok);
+
+ ok = connect(m_treeChooserObject, SIGNAL(back()),
+ this, SLOT(back()));
+ Q_ASSERT(ok);
+
+ setProperties();
+
+ m_treeChooserObject->setProperty("visible",open);
+}
+
+QStringList BookKeyChooser::getKeyPath() const {
+ QString oldKey = m_key->key(); //string backup of key
+
+ if (oldKey.isEmpty()) { //don't set keys equal to "/", always use a key which may have content
+ m_key->firstChild();
+ oldKey = m_key->key();
+ }
+
+ QStringList siblings; //split up key
+ if (!oldKey.isEmpty()) {
+ siblings = oldKey.split('/', QString::SkipEmptyParts);
+ }
+ return siblings;
+}
+
+static int findEntry(const QString& sibling, bool* found,
+ CSwordTreeKey* key, QString* matchingKey, QStringList* siblings, QList<int>* hasChildrenList) {
+ int index = 0;
+ int foundIndex = 0;
+ do { //look for matching sibling
+ QString keyName = key->getLocalNameUnicode();
+ if (keyName == sibling) {
+ *found = true;
+ foundIndex = index;
+ *matchingKey = key->key();
+ }
+ siblings->append(keyName);
+ bool hasChildren = key->hasChildren();
+ hasChildrenList->append(hasChildren ? 1 : 0);
+ ++index;
+ } while (key->nextSibling());
+ return foundIndex;
+}
+
+void BookKeyChooser::parseKey(QStringList * siblings,
+ QList<int>* hasChildrenList, CSwordTreeKey* key) {
+ QString oldKey = key->key();
+ QStringList pathDepthList = oldKey.split("/", QString::SkipEmptyParts);
+ int depth = 0;
+ key->root();
+
+ while ( key->firstChild() && (depth < pathDepthList.count()) ) {
+ QString localName = key->getLocalNameUnicode();
+ QString savedKey = key->key();
+ bool found = false;
+ QString path = pathDepthList[depth];
+ siblings->clear();
+ hasChildrenList->clear();
+ QString matchingKey;
+ findEntry(path, &found, key, &matchingKey, siblings, hasChildrenList);
+ if (found) {
+ key->setKey(matchingKey);
+ }
+ depth++;
+ }
+}
+
+void BookKeyChooser::createModel()
+{
+ m_model.clear();
+
+ QStandardItem *parentItem = m_model.invisibleRootItem();
+ for (int i = 0; i < 4; ++i) {
+ QStandardItem *item = new QStandardItem("item1");
+ parentItem->appendRow(item);
+ }
+}
+
+} // end namespace
diff --git a/src/mobile/keychooser/bookkeychooser.h b/src/mobile/keychooser/bookkeychooser.h
new file mode 100644
index 0000000..720e5f0
--- /dev/null
+++ b/src/mobile/keychooser/bookkeychooser.h
@@ -0,0 +1,81 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BOOK_KEY_CHOOSER_H
+#define BOOK_KEY_CHOOSER_H
+
+#include "backend/keys/cswordtreekey.h"
+#include <QObject>
+#include <QList>
+#include <QStringList>
+#include <QStandardItemModel>
+#include "mobile/models/roleitemmodel.h"
+
+class QtQuick2ApplicationViewer;
+class QQmlComponent;
+class QQuickItem;
+
+namespace btm {
+
+class BtWindowInterface;
+
+class BookKeyChooser : public QObject {
+ Q_OBJECT
+
+ enum State {
+ CLOSED,
+ BOOK,
+ CHAPTER,
+ VERSE
+ };
+
+public:
+ BookKeyChooser(QtQuick2ApplicationViewer* viewer, BtWindowInterface* windowInterface);
+ void open();
+
+signals:
+ void referenceChanged();
+
+private slots:
+ void select(QString value);
+ void next(QString value);
+ void back();
+ void stringCanceled();
+
+private:
+ void copyKey();
+ void findTreeChooserObject();
+ QStringList getKeyPath() const;
+ void showGridChooser(const QStringList& list);
+ void setProperties(const QStringList& list);
+ void parseKey(QStringList * sibblings, QList<int>* hasChildrenList, CSwordTreeKey* key);
+ void createModel();
+ void setProperties();
+ void initializeRoleNameModel();
+ void populateRoleNameModel(const QStringList& sibblings, const QList<int>& sibblingChildCounts);
+ void openChooser(bool open);
+
+
+ QtQuick2ApplicationViewer* m_viewer;
+ BtWindowInterface* m_windowInterface;
+ CSwordTreeKey* m_key;
+ QQuickItem* m_treeChooserObject;
+ int m_state;
+ QString m_backPath;
+ QStringList m_sibblings;
+ QStandardItemModel m_model;
+ RoleItemModel m_roleItemModel;
+};
+
+} // end namespace
+
+#endif
diff --git a/src/mobile/keychooser/versechooser.cpp b/src/mobile/keychooser/versechooser.cpp
new file mode 100644
index 0000000..f510da0
--- /dev/null
+++ b/src/mobile/keychooser/versechooser.cpp
@@ -0,0 +1,160 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "versechooser.h"
+
+#include "backend/keys/cswordversekey.h"
+#include "backend/drivers/cswordbiblemoduleinfo.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include <cmath>
+#include "mobile/ui/btwindowinterface.h"
+#include "mobile/ui/gridchooser.h"
+#include "mobile/ui/qtquick2applicationviewer.h"
+#include <QQuickItem>
+#include <QQmlProperty>
+#include <QQmlContext>
+#include <QDebug>
+#include <QQmlProperty>
+#include <QCoreApplication>
+
+namespace btm {
+
+VerseChooser::VerseChooser(QtQuick2ApplicationViewer* viewer, BtWindowInterface* bibleVerse)
+ : m_viewer(viewer),
+ m_gridChooser(0),
+ bibleVerse_(bibleVerse),
+ m_key(0),
+ m_state(CLOSED ) {
+ m_gridChooser = new GridChooser(m_viewer);
+ bool ok = connect(m_gridChooser, SIGNAL(accepted(const QString&)),
+ this, SLOT(stringAccepted(const QString&)));
+ Q_ASSERT(ok);
+}
+
+void VerseChooser::open(CSwordVerseKey* key) {
+ if (key == 0)
+ return;
+ m_key = key;
+ m_oldBook = getBook();
+ m_oldChapter = getChapter();
+ m_oldVerse = getVerse();
+ m_state = BOOK;
+ QStringList books = getBooks();
+ m_gridChooser->open(books, m_oldBook, "Book");
+}
+
+void VerseChooser::stringAccepted(const QString& value) {
+ if (m_state == BOOK) {
+ m_newBook = value;
+ m_state = CHAPTER;
+ setBook(value);
+ QStringList chapters = getChapters();
+ m_gridChooser->open(chapters, m_oldChapter, "Chapter");
+ }
+ else if (m_state == CHAPTER) {
+ m_newChapter = value;
+ m_state = VERSE;
+ setChapter(value);
+ QStringList verses = getVerses();
+ m_gridChooser->open(verses, m_oldVerse, "Verse");
+ }
+ else if (m_state == VERSE) {
+ m_newVerse = value;
+ m_state = CLOSED;
+ setVerse(m_newVerse);
+ }
+}
+
+void VerseChooser::stringCanceled() {
+}
+
+QString VerseChooser::getBook() const {
+ QString book;
+ if (m_key)
+ book = m_key->book();
+ return book;
+}
+
+void VerseChooser::setBook(const QString& book) {
+ if (m_key) {
+ m_key->book(book);
+ }
+}
+
+QString VerseChooser::getChapter() const {
+ QString chapter;
+ if (m_key)
+ chapter = QString::number(m_key->getChapter());
+ return chapter;
+}
+
+void VerseChooser::setChapter(const QString& chapter) {
+ if (m_key) {
+ int iChapter = chapter.toInt();
+ m_key->setChapter(iChapter);
+ }
+}
+
+QString VerseChooser::getVerse() const {
+ QString verse;
+ if (m_key) {
+ verse = QString::number(m_key->getVerse());
+ }
+ return verse;
+}
+
+void VerseChooser::setVerse(const QString& verse) {
+ if (m_key) {
+ int iVerse = verse.toInt();
+ m_key->setVerse(iVerse);
+ emit referenceChanged();
+ }
+}
+
+QStringList VerseChooser::getBooks() const {
+ QStringList books;
+ const CSwordModuleInfo* module = m_key->module();
+ const CSwordBibleModuleInfo* bibleModule = qobject_cast<const CSwordBibleModuleInfo*>(module);
+ if (bibleModule)
+ books = *bibleModule->books();
+ return books;
+}
+
+QStringList VerseChooser::getChapters() const {
+ QStringList chapters;
+ const CSwordModuleInfo* module = m_key->module();
+ const CSwordBibleModuleInfo* m = qobject_cast<const CSwordBibleModuleInfo*>(module);
+
+ QString book = m_key->book();
+ int count = m->chapterCount(book);
+ for (int i = 1; i <= count; i++) {
+ chapters << QString::number(i);
+ }
+ return chapters;
+}
+
+QStringList VerseChooser::getVerses() const {
+ QStringList verses;
+ const CSwordModuleInfo* module = m_key->module();
+ const CSwordBibleModuleInfo* m = qobject_cast<const CSwordBibleModuleInfo*>(module);
+ QString book = m_key->book();
+ int chapter = m_key->getChapter();
+ int count = m->verseCount(book,chapter);
+ for (int i = 1; i <= count; i++) {
+ verses << QString::number(i);
+ }
+ return verses;
+}
+
+
+
+} // end namespace
diff --git a/src/mobile/keychooser/versechooser.h b/src/mobile/keychooser/versechooser.h
new file mode 100644
index 0000000..3c7f52b
--- /dev/null
+++ b/src/mobile/keychooser/versechooser.h
@@ -0,0 +1,86 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef VERSE_CHOOSER_H
+#define VERSE_CHOOSER_H
+
+#include <QObject>
+#include <QList>
+
+class CSwordVerseKey;
+class QtQuick2ApplicationViewer;
+class QQmlComponent;
+class QQuickItem;
+class QStringList;
+
+namespace btm {
+
+class GridChooser;
+
+class BtWindowInterface;
+
+class VerseChooser : public QObject {
+ Q_OBJECT
+
+ enum State {
+ CLOSED,
+ BOOK,
+ CHAPTER,
+ VERSE
+ };
+
+public:
+ VerseChooser(QtQuick2ApplicationViewer* viewer, BtWindowInterface* bibleVerse);
+ void open(CSwordVerseKey* key);
+
+signals:
+ void referenceChanged();
+
+private slots:
+ void stringAccepted(const QString& value);
+ void stringCanceled();
+
+private:
+ QString getBook() const;
+ void setBook(const QString& book);
+
+ QString getChapter() const;
+ void setChapter(const QString& chapter);
+
+ QString getVerse() const;
+ void setVerse(const QString& chapter);
+
+ QStringList getBooks() const;
+ QStringList getChapters() const;
+ QStringList getVerses() const;
+
+ void showGridChooser(const QStringList& list);
+ void setProperties(const QStringList& list);
+
+
+ QtQuick2ApplicationViewer* m_viewer;
+ GridChooser* m_gridChooser;
+ BtWindowInterface* bibleVerse_;
+ CSwordVerseKey* m_key;
+ int m_state;
+
+ QString m_oldBook;
+ QString m_oldChapter;
+ QString m_oldVerse;
+ QString m_newBook;
+ QString m_newChapter;
+ QString m_newVerse;
+};
+
+} // end namespace
+
+#endif
diff --git a/src/mobile/models/bibletextmodelbuilder.cpp b/src/mobile/models/bibletextmodelbuilder.cpp
new file mode 100644
index 0000000..20faf14
--- /dev/null
+++ b/src/mobile/models/bibletextmodelbuilder.cpp
@@ -0,0 +1,184 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "bibletextmodelbuilder.h"
+
+#include "btglobal.h"
+#include "backend/keys/cswordversekey.h"
+#include "backend/drivers/cswordbiblemoduleinfo.h"
+#include "backend/managers/cswordbackend.h"
+
+namespace btm {
+
+struct BookEntry {
+ enum TextRoles {
+ ReferenceRole = Qt::UserRole + 1,
+ TextRole = Qt::UserRole + 2
+ };
+};
+
+BibleTextModelBuilder::BibleTextModelBuilder(RoleItemModel* model)
+ : m_model(model) {
+ QHash<int, QByteArray> roleNames;
+ roleNames[BookEntry::ReferenceRole] = "ref";
+ roleNames[BookEntry::TextRole] = "line";
+ m_model->setRoleNames(roleNames);
+}
+
+void BibleTextModelBuilder::updateModel(
+ QList<const CSwordModuleInfo*> modules,
+ const QString& keyName) {
+
+ Q_ASSERT( modules.count() >= 1 );
+ Q_ASSERT( !keyName.isEmpty() );
+
+ FilterOptions options;
+ options.footnotes = 0;
+ options.strongNumbers = 0;
+ options.headings = 1;
+ options.morphTags = 0;
+ options.lemmas = 0;
+ options.hebrewPoints = 0;
+ options.greekAccents = 0;
+ options.textualVariants = 0;
+ options.redLetterWords = 1;
+ options.scriptureReferences = 0;
+ options.morphSegmentation = 0;
+ CSwordBackend::instance()->setFilterOptions(options);
+
+ const CSwordModuleInfo *module = modules.first();
+
+ if (modules.count() == 1)
+ module->module()->setSkipConsecutiveLinks( true ); //skip empty, linked verses
+
+ QString startKey = keyName;
+ QString endKey = startKey;
+
+ //check whether there's an intro we have to include
+ Q_ASSERT((module->type() == CSwordModuleInfo::Bible));
+
+ if (module->type() == CSwordModuleInfo::Bible) {
+ ((sword::VerseKey*)(module->module()->getKey()))->setIntros(true);
+
+ Q_ASSERT(dynamic_cast<const CSwordBibleModuleInfo*>(module) != 0);
+ const CSwordBibleModuleInfo* bible =
+ static_cast<const CSwordBibleModuleInfo*>(module);
+
+ CSwordVerseKey k1(module);
+ k1.setIntros(true);
+ k1.setKey(keyName);
+
+ if (k1.getChapter() == 1)
+ k1.setChapter(0); // Chapter 1, start with 0:0, otherwise X:0
+
+ k1.setVerse(0);
+
+ startKey = k1.key();
+
+ if (k1.getChapter() == 0)
+ k1.setChapter(1);
+
+ k1.setVerse(bible->verseCount(k1.book(), k1.getChapter()));
+ endKey = k1.key();
+ }
+
+ updateKeyRange(modules, startKey, endKey, keyName);
+}
+
+void BibleTextModelBuilder::updateKeyRange(
+ QList<const CSwordModuleInfo*> modules,
+ const QString& startKey,
+ const QString& endKey,
+ const QString& highlightKey) {
+
+ m_model->clear();
+
+ const CSwordModuleInfo *module = modules.first();
+
+ QSharedPointer<CSwordKey> currentKey( CSwordKey::createInstance(module) );
+ currentKey->setKey(highlightKey);
+ CSwordVerseKey* vk_current = dynamic_cast<CSwordVerseKey*>(currentKey.data());
+ Q_ASSERT(vk_current);
+ m_currentVerse = vk_current->getVerse();
+
+ QSharedPointer<CSwordKey> lowerBound( CSwordKey::createInstance(module) );
+ lowerBound->setKey(startKey);
+
+ QSharedPointer<CSwordKey> upperBound( CSwordKey::createInstance(module) );
+ upperBound->setKey(endKey);
+
+ 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));
+
+ // if (*sw_start == *sw_stop) { //same key, render single key
+ // return renderSingleKey(lowerBound->key(), modules);
+ // }
+ // else if (*sw_start < *sw_stop) { // Render range
+ // KeyTree tree;
+ // KeyTreeItem::Settings settings = keySettings;
+
+ CSwordVerseKey* vk_start = dynamic_cast<CSwordVerseKey*>(lowerBound.data());
+ Q_ASSERT(vk_start);
+
+ CSwordVerseKey* vk_stop = dynamic_cast<CSwordVerseKey*>(upperBound.data());
+ Q_ASSERT(vk_stop);
+
+ while ((*vk_start < *vk_stop) || (*vk_start == *vk_stop)) {
+
+ //make sure the key given by highlightKey gets marked as current key
+ // settings.highlight = (!highlightKey.isEmpty() ? (vk_start->key() == highlightKey) : false);
+
+ /**
+ \todo We need to take care of linked verses if we render one or
+ (esp) more modules. If the verses 2,3,4,5 are linked to 1,
+ it should be displayed as one entry with the caption 1-5.
+ */
+
+ if (vk_start->getChapter() == 0) { // range was 0:0-1:x, render 0:0 first and jump to 1:0
+ vk_start->setVerse(0);
+ addVerseToModel(vk_start);
+ vk_start->setChapter(1);
+ vk_start->setVerse(0);
+ }
+ addVerseToModel(vk_start);
+ if (!vk_start->next(CSwordVerseKey::UseVerse)) {
+ /// \todo Notify the user about this failure.
+ break;
+ }
+ }
+}
+
+void BibleTextModelBuilder::addVerseToModel(CSwordVerseKey* key) {
+ int verseNumber = key->getVerse();
+ QString verse;
+ if (verseNumber != 0)
+ verse.setNum(verseNumber);
+ QString text = key->renderedText();
+ if (text.isEmpty())
+ return;
+ text.replace("<br /><br />", "<br />");
+ QStandardItem* item = new QStandardItem();
+ item->setData(verse, BookEntry::ReferenceRole);
+ item->setData(text, BookEntry::TextRole);
+ m_model->appendRow(item);
+
+ if (m_currentVerse == verseNumber)
+ m_currentModelIndex = m_model->rowCount() - 1;
+}
+
+int BibleTextModelBuilder::getCurrentModelIndex() const {
+ return m_currentModelIndex;
+}
+
+}
diff --git a/src/mobile/models/bibletextmodelbuilder.h b/src/mobile/models/bibletextmodelbuilder.h
new file mode 100644
index 0000000..620810a
--- /dev/null
+++ b/src/mobile/models/bibletextmodelbuilder.h
@@ -0,0 +1,46 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "mobile/models/roleitemmodel.h"
+#include <QList>
+#include <QString>
+#include "backend/drivers/cswordmoduleinfo.h"
+
+class CSwordVerseKey;
+
+namespace btm {
+
+class BibleTextModelBuilder {
+public:
+ BibleTextModelBuilder(RoleItemModel* model);
+
+ void updateModel(
+ QList<const CSwordModuleInfo*> modules,
+ const QString& keyText);
+
+ void updateKeyRange(
+ QList<const CSwordModuleInfo*> modules,
+ const QString& startKey,
+ const QString& endKey,
+ const QString& highlightKey);
+
+ int getCurrentModelIndex() const;
+
+private:
+ void addVerseToModel(CSwordVerseKey* key);
+
+ RoleItemModel* m_model;
+ int m_currentVerse;
+ int m_currentModelIndex;
+};
+
+}
diff --git a/src/mobile/models/booktextmodelbuilder.cpp b/src/mobile/models/booktextmodelbuilder.cpp
new file mode 100644
index 0000000..44d5d92
--- /dev/null
+++ b/src/mobile/models/booktextmodelbuilder.cpp
@@ -0,0 +1,101 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "booktextmodelbuilder.h"
+
+#include "btglobal.h"
+#include "backend/keys/cswordtreekey.h"
+#include "backend/drivers/cswordbookmoduleinfo.h"
+#include "backend/managers/cswordbackend.h"
+
+namespace btm {
+
+struct BookEntry {
+ enum TextRoles {
+ ReferenceRole = Qt::UserRole + 1,
+ TextRole = Qt::UserRole + 2
+ };
+};
+
+BookTextModelBuilder::BookTextModelBuilder(RoleItemModel* model)
+ : m_model(model) {
+ QHash<int, QByteArray> roleNames;
+ roleNames[BookEntry::ReferenceRole] = "ref";
+ roleNames[BookEntry::TextRole] = "line";
+ m_model->setRoleNames(roleNames);
+}
+
+void BookTextModelBuilder::updateModel(
+ QList<const CSwordModuleInfo*> modules,
+ const QString& keyName) {
+
+ Q_ASSERT( modules.count() >= 1 );
+ Q_ASSERT( !keyName.isEmpty() );
+
+ FilterOptions options;
+ options.footnotes = 0;
+ options.strongNumbers = 0;
+ options.headings = 1;
+ options.morphTags = 0;
+ options.lemmas = 0;
+ options.hebrewPoints = 0;
+ options.greekAccents = 0;
+ options.textualVariants = 0;
+ options.redLetterWords = 1;
+ options.scriptureReferences = 0;
+ options.morphSegmentation = 0;
+ CSwordBackend::instance()->setFilterOptions(options);
+
+ const CSwordModuleInfo *module = modules.first();
+
+ const CSwordBookModuleInfo* book = dynamic_cast<const CSwordBookModuleInfo*>(module);
+ Q_ASSERT(book);
+
+ QSharedPointer<CSwordTreeKey> key (
+ dynamic_cast<CSwordTreeKey*>( CSwordKey::createInstance(book) )
+ );
+ key->setKey(keyName); //set the key to position we'd like to get
+
+// const unsigned long offset = key->getOffset();
+
+ //check whether there's an intro we have to include
+ Q_ASSERT((module->type() == CSwordModuleInfo::GenericBook));
+
+ if (module->type() == CSwordModuleInfo::GenericBook) {
+ CSwordTreeKey* swKey = dynamic_cast<CSwordTreeKey*>(key.data());
+ addVerseToModel(swKey);
+ }
+}
+
+void BookTextModelBuilder::addVerseToModel(CSwordTreeKey* key) {
+// int verseNumber = key->getVerse();
+ QString verse;
+// if (verseNumber != 0)
+// verse.setNum(verseNumber);
+ QString text = key->renderedText(); // TODO - fix
+ if (text.isEmpty())
+ return;
+// text.replace("<br /><br />", "<br />");
+ QStandardItem* item = new QStandardItem();
+ item->setData(verse, BookEntry::ReferenceRole);
+ item->setData(text, BookEntry::TextRole);
+ m_model->appendRow(item);
+
+// if (m_currentVerse == verseNumber)
+// m_currentModelIndex = m_model->rowCount() - 1;
+}
+
+int BookTextModelBuilder::getCurrentModelIndex() const {
+ return m_currentModelIndex;
+}
+
+}
diff --git a/src/mobile/models/booktextmodelbuilder.h b/src/mobile/models/booktextmodelbuilder.h
new file mode 100644
index 0000000..a64c380
--- /dev/null
+++ b/src/mobile/models/booktextmodelbuilder.h
@@ -0,0 +1,40 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "mobile/models/roleitemmodel.h"
+#include <QList>
+#include <QString>
+#include "backend/drivers/cswordmoduleinfo.h"
+
+class CSwordTreeKey;
+
+namespace btm {
+
+class BookTextModelBuilder {
+public:
+ BookTextModelBuilder(RoleItemModel* model);
+
+ void updateModel(
+ QList<const CSwordModuleInfo*> modules,
+ const QString& keyText);
+
+ int getCurrentModelIndex() const;
+
+private:
+ void addVerseToModel(CSwordTreeKey* key);
+
+ RoleItemModel* m_model;
+ int m_currentVerse;
+ int m_currentModelIndex;
+};
+
+}
diff --git a/src/mobile/models/roleitemmodel.cpp b/src/mobile/models/roleitemmodel.cpp
new file mode 100644
index 0000000..95634af
--- /dev/null
+++ b/src/mobile/models/roleitemmodel.cpp
@@ -0,0 +1,54 @@
+#include "roleitemmodel.h"
+
+/* Example usage:
+
+Enumerate the role ID's somewhere
+---------------------------------
+
+struct RedditEntry {
+
+ enum RedditRoles {
+ UrlRole = Qt::UserRole + 1,
+ DescRole,
+ ...
+ };
+ ...
+}
+
+Instantiate the class
+---------------------
+
+ QHash<int, QByteArray> roleNames;
+ roleNames[RedditEntry::UrlRole] = "url";
+ roleNames[RedditEntry::ScoreRole] = "score";
+ m_linksmodel = new RoleItemModel(roleNames);
+
+Populate with data:
+-------------------
+
+ QStandardItem* it = new QStandardItem();
+ it->setData(e.desc, RedditEntry::DescRole);
+ it->setData(e.score, RedditEntry::ScoreRole);
+
+ m_linksmodel->appendRow(it);
+
+Expose to QML:
+-------------
+
+QDeclarativeContext *ctx = ...
+
+ctx->setContextProperty("mdlLinks", m_linksmodel);
+
+*/
+
+//RoleItemModel::RoleItemModel(const QHash<int, QByteArray> &roleNames)
+// : m_roleNames(roleNames) {
+//}
+
+QHash<int, QByteArray> RoleItemModel::roleNames() const {
+ return m_roleNames;
+}
+
+void RoleItemModel::setRoleNames(const QHash<int, QByteArray> &roleNames) {
+ m_roleNames = roleNames;
+}
diff --git a/src/mobile/models/roleitemmodel.h b/src/mobile/models/roleitemmodel.h
new file mode 100644
index 0000000..46f02be
--- /dev/null
+++ b/src/mobile/models/roleitemmodel.h
@@ -0,0 +1,24 @@
+#ifndef ROLEITEMMODEL_H
+#define ROLEITEMMODEL_H
+
+#include <QStandardItemModel>
+
+/* class to allow easily exposing
+ C++ data as a model for QML View.
+*/
+
+class RoleItemModel : public QStandardItemModel {
+public:
+ // roleNames is a map describing what role id (e.g. Qt::UserRole+1)
+ // is associated with what name on QML side (e.g. 'bookTitle')
+ // RoleItemModel(const QHash<int, QByteArray> &roleNames);
+
+ QHash<int, QByteArray> roleNames() const;
+ void setRoleNames(const QHash<int, QByteArray> &roleNames);
+
+private:
+ QHash<int, QByteArray> m_roleNames;
+
+};
+
+#endif // ROLEITEMMODEL_H
diff --git a/src/mobile/qml/ContextMenu.qml b/src/mobile/qml/ContextMenu.qml
new file mode 100644
index 0000000..bf55ebf
--- /dev/null
+++ b/src/mobile/qml/ContextMenu.qml
@@ -0,0 +1,62 @@
+import QtQuick 2.1
+import BibleTime 1.0
+
+Rectangle {
+ id: contextMenu
+
+ property alias model: menuList.model
+
+ signal accepted(string action)
+
+ color: "white"
+ border.color: "black"
+ border.width: 1
+ anchors.centerIn: parent
+ height: 250
+ width: 250
+
+ onVisibleChanged: PropertyAnimation {
+ target: settings
+ property: "opacity"
+ from: 0
+ to: 1
+ duration: 400
+ easing.type: Easing.InOutCubic
+ }
+
+ BtStyle {
+ id: btStyle
+ }
+
+ ListView {
+ id: menuList
+
+ anchors.fill: parent
+ anchors.topMargin: 100
+
+ delegate: Rectangle {
+ color: "white"
+ border.color: "black"
+ border.width: 1
+ width: parent.width
+ height: children[0].height * 2.5
+
+ Text {
+ id: menuText
+ x: 40
+ anchors.verticalCenter: parent.verticalCenter
+ text: title
+ color: "black"
+ font.pointSize: btStyle.uiFontPointSize
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ contextMenu.visible = false;
+ contextMenu.accepted(action);
+ }
+ }
+ }
+ }
+}
diff --git a/src/mobile/qml/FontSizeSlider.qml b/src/mobile/qml/FontSizeSlider.qml
new file mode 100644
index 0000000..6c11dc0
--- /dev/null
+++ b/src/mobile/qml/FontSizeSlider.qml
@@ -0,0 +1,139 @@
+import QtQuick 2.1
+import BibleTime 1.0
+
+Rectangle {
+ id: fontPointSize
+
+ property string title: ""
+ property int min: 10
+ property int max: 22
+ property int current: 12
+ property int previous: 12
+
+ signal accepted(int pointSize);
+
+ color: "#f8f8f8"
+ border.color: "black"
+ border.width: 1
+ anchors.centerIn: parent
+ width: parent.width * 0.85
+ height: 140
+
+ Text {
+ text: title
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.top: parent.top
+ anchors.topMargin: 10
+ height: 40
+ font.pointSize: btStyle.uiFontPointSize
+ }
+
+ Rectangle {
+ id: bar
+
+ color: "blue"
+ width: parent.width *.80
+ height: 3
+ anchors.centerIn: parent
+ }
+
+ Rectangle {
+ id: indicator
+
+ width: 18
+ height: 18
+ color: "red"
+ y: bar.y - height / 2
+ x: {
+ var range = fontPointSize.max - fontPointSize.min;
+ var xpos = bar.width *
+ (fontPointSize.current - fontPointSize.min) / range;
+ xpos = xpos + bar.x
+ return xpos
+ }
+ }
+
+ MouseArea {
+ property bool active: false
+ width: bar.width
+ anchors.left: bar.left
+ height: 40
+ anchors.verticalCenter: bar.verticalCenter
+
+ onPressed: {
+ active = true;
+ }
+
+ onReleased: {
+ active = false;
+ }
+
+ onMouseXChanged: {
+ if ( ! active)
+ return;
+ var range = fontPointSize.max - fontPointSize.min;
+ var currentF = mouse.x / bar.width * range + fontPointSize.min;
+ var value = Math.round(currentF);
+ if (value < fontPointSize.min)
+ value = min;
+ if (value > fontPointSize.max)
+ value = max;
+ fontPointSize.current = value;
+ accepted(value);
+ }
+
+ }
+
+ Grid {
+ id: buttons
+
+ spacing: 10
+ columns: 2
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ anchors.rightMargin: 10
+ anchors.bottomMargin: 10
+
+ Rectangle {
+ height: 40
+ width: 120
+ border.color: "black"
+ border.width: 1
+
+ Text {
+ text: "Ok"
+ anchors.centerIn: parent
+ font.pointSize: btStyle.uiFontPointSize
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ fontPointSize.visible = false;
+ }
+ }
+ }
+
+ Rectangle {
+ height: 40
+ width: 120
+ border.color: "black"
+ border.width: 1
+
+ Text {
+ text: "Cancel"
+ anchors.centerIn: parent
+ font.pointSize: btStyle.uiFontPointSize
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ accepted(previous);
+ fontPointSize.visible = false;
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/mobile/qml/GridChooser.qml b/src/mobile/qml/GridChooser.qml
new file mode 100644
index 0000000..b4d1612
--- /dev/null
+++ b/src/mobile/qml/GridChooser.qml
@@ -0,0 +1,117 @@
+import QtQuick 2.1
+import BibleTime 1.0
+
+Rectangle {
+ id: gridChooser
+
+ property int columns: 5
+ property int rows: 5
+ property int buttonWidth: 100
+ property int buttonHeight: 30
+ property int topMargin: 10
+ property int leftMargin: 10
+ property int titleHeight: 20
+ property int space:5
+ property string selected: ""
+ property string titleText: ""
+ property int maxLength: 0
+
+ signal accepted(string choosenText);
+ signal canceled();
+
+ onVisibleChanged: {
+
+ var count = gridChooserModel.length
+ if (count < 36)
+ count = 36;
+
+ calculateColumns(count);
+
+ buttonWidth = (width-50)/columns;
+ buttonHeight = Math.floor((height-(rows*5))/rows);
+
+ topMargin = (height - rows*(buttonHeight+space) + space)/2 +titleHeight;
+ leftMargin = (width - columns*(buttonWidth+space) + space)/2;
+ }
+
+ function calculateColumns(count) {
+ var aspectRatio = 0.175;
+ var columnsF = Math.sqrt(count * width * aspectRatio / height);
+ columns = Math.ceil(columnsF);
+ rows = Math.ceil((count-0.01)/columns);
+ }
+
+ function accept(value) {
+ visible = false;
+ gridChooser.accepted(value);
+ }
+
+ Text {
+ id: title
+
+ text: titleText
+ font.pointSize: btStyle.uiFontPointSize
+ height: titleHeight
+ anchors.top: parent.top
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ BtStyle {
+ id: btStyle
+ }
+
+ MouseArea {
+ id: mouseArea
+
+ anchors.fill: parent
+ enabled: gridChooser.opacity
+ }
+
+ Rectangle {
+ anchors.fill: parent
+ color: btStyle.buttonBackground
+ }
+
+ Rectangle {
+ id: topSpace
+
+ width: leftMargin
+ height: topMargin
+ color: btStyle.buttonBackground
+ }
+
+ Grid {
+ id: grid
+
+ anchors.top: topSpace.bottom
+ anchors.bottom: bottom.top
+ anchors.left: topSpace.right
+ anchors.right: parent.right
+ columns: gridChooser.columns
+ spacing: gridChooser.space
+
+ Repeater {
+ id: repeater
+
+ model: gridChooserModel
+
+ GridChooserButton {
+ id: buttonX
+
+ text: modelData
+ textHeight: btStyle.uiFontPointSize
+ buttonWidth: gridChooser.buttonWidth
+ buttonHeight: gridChooser.buttonHeight
+ textColor: {
+ if (text == gridChooser.selected)
+ return btStyle.buttonHighlightedText
+ else
+ return btStyle.buttonTextColor
+ }
+ buttonColor: btStyle.buttonColor
+ activeButtonColor: btStyle.buttonTextColor
+ onClicked: gridChooser.accept(text)
+ }
+ }
+ }
+}
diff --git a/src/mobile/qml/GridChooserButton.qml b/src/mobile/qml/GridChooserButton.qml
new file mode 100644
index 0000000..9a65041
--- /dev/null
+++ b/src/mobile/qml/GridChooserButton.qml
@@ -0,0 +1,52 @@
+import QtQuick 2.1
+import BibleTime 1.0
+
+Rectangle {
+ id: button
+
+ property int buttonWidth
+ property int buttonHeight
+ property int textHeight
+ property color textColor
+ property color buttonColor
+ property color activeButtonColor
+ property alias text: buttonText.text
+
+ signal clicked
+
+ width: buttonWidth
+ height: buttonHeight
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: btStyle.buttonGradient0 }
+ GradientStop { position: 0.15; color: btStyle.buttonGradient1 }
+ GradientStop { position: 0.85; color: btStyle.buttonGradient2 }
+ GradientStop { position: 1.0; color: btStyle.buttonGradient3 }
+ }
+ smooth: true
+
+ border {
+ width: 1
+ color: btStyle.buttonBorder
+ }
+
+ BtStyle {
+ id: btStyle
+ }
+
+ Text {
+ id: buttonText
+
+ width: buttonWidth-8
+ anchors.centerIn: parent
+ color: button.textColor
+ font.pointSize: parent.textHeight
+ elide: Text.ElideRight
+ }
+
+ MouseArea {
+ id: mouseArea
+
+ anchors.fill: parent
+ onClicked: button.clicked()
+ }
+}
diff --git a/src/mobile/qml/ImageButton.qml b/src/mobile/qml/ImageButton.qml
new file mode 100644
index 0000000..552a9b4
--- /dev/null
+++ b/src/mobile/qml/ImageButton.qml
@@ -0,0 +1,24 @@
+import QtQuick 2.1
+
+Rectangle {
+ id: imageButton
+
+ property bool show: true
+ property string icon: ""
+ property int corner: 6
+
+ border.width: 1
+ border.color: "gray"
+ radius: corner
+
+ Image{
+ id: nextIcon
+ anchors.fill: parent
+ fillMode: Image.PreserveAspectFit
+ source: imageButton.icon
+ height: parent.height
+ width: parent.height
+ anchors.right: parent.right
+ anchors.top: parent.top
+ }
+}
diff --git a/src/mobile/qml/InstallManagerChooser.qml b/src/mobile/qml/InstallManagerChooser.qml
new file mode 100644
index 0000000..15b6079
--- /dev/null
+++ b/src/mobile/qml/InstallManagerChooser.qml
@@ -0,0 +1,153 @@
+import QtQuick 2.1
+
+Rectangle {
+ id: installManager
+
+ property alias sourceModel: sourceView.model
+ property alias categoryModel: categoryView.model
+ property alias languageModel: languageView.model
+ property alias worksModel: worksView.model
+ property alias sourceIndex: sourceView.currentIndex
+ property alias categoryIndex: categoryView.currentIndex
+ property alias languageIndex: languageView.currentIndex
+ property int spacing: 8
+
+ objectName: "installManager"
+ color: "lightgray"
+ border.color: "black"
+ border.width: 2
+
+ signal sourceChanged(int index);
+ signal categoryChanged(int index);
+ signal languageChanged(int index);
+ signal workSelected(int index);
+ signal cancel();
+ signal installRemove();
+ signal refreshLists();
+
+ Grid {
+ id: grid
+ columns: 3
+ rows: 1
+ spacing: installManager.spacing
+ width: parent.width - installManager.spacing
+ height: installManager.height/3
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.margins: installManager.spacing
+
+ ListTextView {
+ id: sourceView
+ onItemSelected: {
+ sourceChanged(currentIndex)
+ }
+
+ title: "Source"
+ width: parent.width/3 - grid.spacing
+ height: installManager.height/3
+ }
+
+ ListTextView {
+ id: categoryView
+
+ title: "Category"
+ width: parent.width/3 - grid.spacing
+ height: installManager.height/3
+ onItemSelected: {
+ categoryChanged(currentIndex)
+ }
+ }
+
+ ListTextView {
+ id: languageView
+
+ title: "Language"
+ width: parent.width/3 - grid.spacing
+ height: installManager.height/3
+ onItemSelected: {
+ languageChanged(currentIndex)
+ }
+ }
+ }
+
+ ListWorksView {
+ id: worksView
+
+ title: "Work"
+ width: parent.width - 2 * installManager.spacing
+ anchors.top: grid.bottom
+ anchors.left: parent.left
+ anchors.bottom: installRemoveButton.top
+ anchors.margins: installManager.spacing
+ onItemSelected: {
+ workSelected(index)
+ }
+ }
+
+ Rectangle {
+ id: "refreshButton"
+ width:150
+ height: 40
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 10
+ anchors.right: installRemoveButton.left
+ anchors.rightMargin: 10
+ border.width: 1
+ border.color: "black"
+
+ Text {
+ text: "Refresh Lists"
+ anchors.centerIn: parent
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: installManager.refreshLists()
+ }
+ }
+
+ Rectangle {
+ id: "installRemoveButton"
+ width:150
+ height: 40
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 10
+ anchors.right: cancelButton.left
+ anchors.rightMargin: 10
+ border.width: 1
+ border.color: "black"
+
+ Text {
+ text: "Install / Remove"
+ anchors.centerIn: parent
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: installManager.installRemove()
+ }
+ }
+
+ Rectangle {
+ id: "cancelButton"
+ width: installRemoveButton.width
+ height: installRemoveButton.height
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 10
+ anchors.right: parent.right
+ anchors.rightMargin: 10
+ border.width: 1
+ border.color: "black"
+
+ Text {
+ text: "Cancel"
+ anchors.centerIn: parent
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: installManager.cancel();
+ }
+ }
+
+}
diff --git a/src/mobile/qml/ListTextView.qml b/src/mobile/qml/ListTextView.qml
new file mode 100644
index 0000000..703fe48
--- /dev/null
+++ b/src/mobile/qml/ListTextView.qml
@@ -0,0 +1,108 @@
+import QtQuick 2.1
+
+Rectangle {
+ id: top
+
+ property alias model: listView.model
+ property alias currentIndex: listView.currentIndex
+ property alias title: title.text
+ property bool highlight: true
+
+ border.color: "black"
+ border.width: 2
+
+ signal itemSelected(int index)
+
+ Rectangle {
+ id: titleRect
+
+ border.color: "black"
+ border.width: 1
+ height:25
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.leftMargin: 3
+ anchors.rightMargin: 3
+ anchors.topMargin: 3
+
+ Text {
+ id: title
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.centerIn: parent
+ horizontalAlignment: Text.AlignCenter
+ verticalAlignment: Text.AlignBottom
+ style: Text.Sunken
+ font.pointSize: btStyle.uiFontPointSize
+ }
+ }
+
+ ListView {
+ id: listView
+
+ anchors.top: titleRect.bottom
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.leftMargin: 3
+ anchors.rightMargin: 3
+ anchors.bottomMargin: 3
+ clip: true
+ highlightFollowsCurrentItem: true
+ currentIndex: 2
+
+ function selectItem(x, y) {
+ var index = listView.indexAt(x+contentX,y+contentY);
+ currentIndex = index;
+ top.itemSelected(index);
+ }
+
+ Rectangle {
+ id: scrollbar
+ anchors.right: listView.right
+ y: listView.visibleArea.yPosition * listView.height
+ width: 7
+ height: listView.visibleArea.heightRatio * listView.height
+ color: "black"
+ visible: listView.visibleArea.heightRatio < 0.99
+ }
+
+ delegate {
+ Rectangle {
+ id: entry
+
+ property bool selected: ListView.isCurrentItem ? true : false
+ objectName: "entry"
+ color: (highlight && ListView.isCurrentItem) ? "#ffeeaa" : "white"
+ border.width: 1
+ border.color: "darkgray"
+ width: parent.width
+ height: 40
+
+ Text {
+ id: entryText
+
+ anchors.top: entry.top
+ anchors.left: entry.left
+ anchors.right: entry.right
+ width: parent.width
+ anchors.leftMargin: 10
+ anchors.rightMargin: 10
+ anchors.topMargin: 10
+ text: modelText
+ font.pointSize: btStyle.uiFontPointSize
+ font.bold: highlight && entry.selected
+ }
+ }
+ }
+
+ MouseArea {
+ anchors.fill: listView
+ onClicked: itemSelected()
+
+ function itemSelected() {
+ listView.selectItem(mouseX, mouseY);
+ }
+ }
+ }
+}
diff --git a/src/mobile/qml/ListWorksView.qml b/src/mobile/qml/ListWorksView.qml
new file mode 100644
index 0000000..6e6dd13
--- /dev/null
+++ b/src/mobile/qml/ListWorksView.qml
@@ -0,0 +1,123 @@
+import QtQuick 2.1
+import BibleTime 1.0
+
+Rectangle {
+ id: top
+ property alias model: listView.model
+ property alias title: title.text
+
+ border.color: "black"
+ border.width: 2
+
+ signal itemSelected(int index)
+
+ Rectangle {
+ id: titleRect
+
+ border.color: "black"
+ border.width: 1
+ height:25
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.leftMargin: 3
+ anchors.rightMargin: 3
+ anchors.topMargin: 3
+
+ Text {
+ id: title
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.centerIn: parent
+ horizontalAlignment: Text.AlignCenter
+ verticalAlignment: Text.AlignBottom
+ style: Text.Sunken
+ font.pointSize: btStyle.uiFontPointSize
+ }
+ }
+
+ ListView {
+ id: listView
+ clip: true
+ anchors.top: titleRect.bottom
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.margins: 3
+
+ function itemSelected(index) {
+ top.itemSelected(index);
+ }
+
+ Rectangle {
+ id: scrollbar
+ anchors.right: listView.right
+ y: listView.visibleArea.yPosition * listView.height
+ width: 5
+ height: listView.visibleArea.heightRatio * listView.height
+ color: "black"
+ visible: listView.visibleArea.heightRatio < 0.99
+ }
+
+ delegate {
+ Rectangle {
+ id: entry
+
+ color: "white"
+ border.width: 1
+ border.color: ListView.isCurrentItem ? "#c0c0c0" : "#a0a0a0"
+ width: parent.width
+ height: 60
+
+ Image {
+ id: installedCheckmark
+
+ source: "checkmark.svg"
+ height: entry.height - 15
+ width: 25
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.leftMargin: 5
+ anchors.topMargin: 5
+ visible: installed == 1
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {listView.itemSelected(index)}
+ }
+
+ Text {
+ anchors.top: entry.top
+ anchors.left: installedCheckmark.right
+ anchors.right: entry.right
+ width: parent.width
+ height: parent.height/2 -4
+ anchors.leftMargin: 10
+ anchors.rightMargin: 10
+ anchors.topMargin: 5
+ text: title
+ font.pointSize: btStyle.textFontPointSize
+ }
+
+ Text {
+ anchors.bottom: entry.bottom
+ anchors.left: installedCheckmark.right
+ anchors.right: entry.right
+ width: parent.width
+ height: parent.height/2 -4
+ anchors.leftMargin: 35
+ anchors.rightMargin: 10
+ anchors.topMargin: 25
+ text: desc
+ elide: Text.ElideMiddle
+ font.pointSize: btStyle.textFontPointSize
+ }
+ }
+ }
+
+ BtStyle {
+ id: btStyle
+ }
+ }
+}
+
diff --git a/src/mobile/qml/MainToolbar.qml b/src/mobile/qml/MainToolbar.qml
new file mode 100644
index 0000000..66513b2
--- /dev/null
+++ b/src/mobile/qml/MainToolbar.qml
@@ -0,0 +1,27 @@
+import QtQuick 2.1
+import BibleTime 1.0
+
+Rectangle {
+ id: toolbar
+
+ signal buttonClicked
+
+ BtStyle {
+ id: btStyle
+ }
+
+ color: btStyle.toolbarColor
+ z:0
+
+ MenuButton {
+ id: menuButton
+
+ width: parent.height
+ height: parent.height
+ anchors.right: parent.right
+ anchors.top: parent.top
+ onButtonClicked: {
+ toolbar.buttonClicked()
+ }
+ }
+}
diff --git a/src/mobile/qml/MenuButton.qml b/src/mobile/qml/MenuButton.qml
new file mode 100644
index 0000000..b3ba458
--- /dev/null
+++ b/src/mobile/qml/MenuButton.qml
@@ -0,0 +1,30 @@
+import QtQuick 2.1
+import BibleTime 1.0
+
+Rectangle {
+ id: menuButton
+
+ signal buttonClicked
+
+ color: "black"
+
+ BtStyle {
+ id: btStyle
+ }
+
+ Column {
+ spacing:3
+
+ Rectangle { color: "white"; width:2; height:2 }
+ Rectangle { color: "white"; width:2; height:2 }
+ Rectangle { color: "white"; width:2; height:2 }
+
+ anchors.centerIn: parent
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ menuButton.buttonClicked()
+ }
+ }
+}
diff --git a/src/mobile/qml/MenuView.qml b/src/mobile/qml/MenuView.qml
new file mode 100644
index 0000000..01b5142
--- /dev/null
+++ b/src/mobile/qml/MenuView.qml
@@ -0,0 +1,28 @@
+import QtQuick 2.1
+
+Column {
+ id: menus
+
+ width:120
+ height:20 * listModel.count
+ anchors.top: mainToolbar.bottom
+ anchors.right: mainToolbar.right
+ z: 100
+ visible: false
+
+ Repeater {
+ model: listModel
+ delegate: Rectangle {
+ width:parent.width
+ height:24
+ color: btStyle.menu
+ border.color: btStyle.menuBorder
+ border.width: 1
+ Text {
+ anchors.centerIn: parent
+ text: title
+ color: btStyle.menuText
+ }
+ }
+ }
+}
diff --git a/src/mobile/qml/Menus.qml b/src/mobile/qml/Menus.qml
new file mode 100644
index 0000000..1a9e53b
--- /dev/null
+++ b/src/mobile/qml/Menus.qml
@@ -0,0 +1,61 @@
+import QtQuick 2.1
+import BibleTime 1.0
+
+Rectangle {
+ id: menu
+
+ property alias model: menusRepeater.model
+ property int fontPointSize: 15
+ property int menuHeight: 70
+ property int topMenuMargin: 150
+ property int leftMenuMargin: 50
+
+ signal menuSelected(string action)
+
+ visible: false
+ anchors.fill: parent
+ color: "#f0f0f0"
+
+ BtStyle {
+ id: btStyle
+ }
+
+ Component {
+ id: eachMenu
+
+ Rectangle {
+ width: menu.width
+ height: menuHeight
+ color: "white"
+ border.color: "#f0f0f0"
+ border.width: 2
+
+ Text {
+ text: title
+ font.pointSize: btStyle.uiFontPointSize
+ color: "black"
+ anchors.fill: parent
+ anchors.leftMargin: leftMenuMargin
+ verticalAlignment: Text.AlignVCenter
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ menu.menuSelected(action);
+ }
+ }
+ }
+ }
+ }
+
+ ListView {
+ id: menusRepeater
+
+ delegate: eachMenu
+ width: parent.width
+ anchors.fill: parent
+ anchors.topMargin: topMenuMargin
+
+ }
+}
+
diff --git a/src/mobile/qml/ModuleChooser.qml b/src/mobile/qml/ModuleChooser.qml
new file mode 100644
index 0000000..49d19d1
--- /dev/null
+++ b/src/mobile/qml/ModuleChooser.qml
@@ -0,0 +1,109 @@
+import QtQuick 2.1
+import BibleTime 1.0
+
+Rectangle {
+ id: moduleChooser
+
+ property alias categoryModel: categoryView.model
+ property alias languageModel: languageView.model
+ property alias worksModel: worksView.model
+ property alias categoryIndex: categoryView.currentIndex
+ property alias languageIndex: languageView.currentIndex
+ property alias moduleIndex: worksView.currentIndex
+ property int lastCategoryIndex: 0
+ property int lastLanguageIndex: 0
+ property int spacing: 5
+ property string selectedModule: ""
+ property string selectedCategory: ""
+
+ objectName: "moduleChooser"
+ color: "lightgray"
+ border.color: "black"
+ border.width: 2
+
+ onVisibleChanged: {
+ if (visible == true) {
+ moduleInterface.updateCategoryAndLanguageModels();
+ categoryIndex = lastCategoryIndex;
+ languageIndex = lastLanguageIndex;
+ }
+ }
+
+ onCategoryIndexChanged: {
+ if (visible == true) {
+ moduleInterface.updateWorksModel();
+ }
+ }
+
+ onLanguageIndexChanged: {
+ if (visible == true) {
+ moduleInterface.updateWorksModel();
+ }
+ }
+
+ signal categoryChanged(int index);
+ signal languageChanged(int index);
+ signal moduleSelected();
+
+ ModuleInterface {
+ id: moduleInterface
+ }
+
+ Grid {
+ id: grid
+ columns: 2
+ rows: 1
+ spacing: parent.spacing
+ width: parent.width - moduleChooser.spacing
+ height: parent.height/2.5
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.margins: parent.spacing
+
+ ListTextView {
+ id: categoryView
+
+ title: "Category"
+ width: grid.width/2 - grid.spacing
+ height: grid.height
+ onItemSelected: {
+ categoryChanged(currentIndex)
+ }
+ }
+
+ ListTextView {
+ id: languageView
+
+ title: "Language"
+ width: grid.width/2 - grid.spacing
+ height: grid.height
+ onItemSelected: {
+ languageChanged(currentIndex);
+ }
+ }
+ }
+
+ ListTextView {
+ id: worksView
+
+ title: "Work"
+ width: parent.width - 2 * parent.spacing
+ anchors.top: grid.bottom
+ anchors.left: parent.left
+ anchors.bottom: parent.bottom
+ anchors.margins: moduleChooser.spacing
+ highlight: false
+ onItemSelected: {
+ selectedModule = moduleInterface.module(index);
+ selectedCategory = moduleInterface.category(index);
+ moduleSelected();
+ moduleChooser.visible = false;
+ }
+ }
+
+// MouseArea {
+// anchors.fill: parent
+// onClicked: moduleChooser.cancel();
+// }
+}
+
diff --git a/src/mobile/qml/Progress.qml b/src/mobile/qml/Progress.qml
new file mode 100644
index 0000000..e5f75b3
--- /dev/null
+++ b/src/mobile/qml/Progress.qml
@@ -0,0 +1,63 @@
+import QtQuick 2.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Styles 1.0
+import BibleTime 1.0
+
+Rectangle {
+ id: installProgress
+
+ property alias minimumValue: progressBar.minimumValue
+ property alias value: progressBar.value
+ property alias maximumValue: progressBar.maximumValue
+ property alias text: label.text
+
+ color: btStyle.buttonBackground
+ border.color: "black"
+ border.width: 5
+
+ signal cancel()
+
+ BtStyle {
+ id: btStyle
+ }
+
+ Text {
+ id: label
+
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottom: progressBar.top
+ anchors.bottomMargin: 20
+ }
+
+ ProgressBar {
+ id: progressBar
+
+ anchors.centerIn: parent
+ width: parent.width - 100
+ height: 16
+ }
+
+ Rectangle {
+ color: "white"
+ border.color: "black"
+ border.width: 1
+ width: 100
+ height:30
+ anchors.top: progressBar.bottom
+ anchors.topMargin: 20
+ anchors.horizontalCenter: parent.horizontalCenter
+
+ Text {
+ anchors.centerIn: parent
+ text: "Cancel"
+
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ cancel();
+ }
+ }
+ }
+}
diff --git a/src/mobile/qml/Settings.qml b/src/mobile/qml/Settings.qml
new file mode 100644
index 0000000..391ce4c
--- /dev/null
+++ b/src/mobile/qml/Settings.qml
@@ -0,0 +1,93 @@
+import QtQuick 2.1
+import BibleTime 1.0
+
+Rectangle {
+ id: settings
+
+ property int finalHeight: 300
+
+ color: "white"
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ height: parent.height
+
+ onVisibleChanged: PropertyAnimation {
+ target: settings
+ property: "opacity"
+ from: 0
+ to: 1
+ duration: 200
+ easing.type: Easing.InOutCubic
+ }
+
+ BtStyle {
+ id: btStyle
+ }
+
+ ListModel {
+ id: settingsModel
+
+ ListElement { title: "Ui Font Size"; action: "uiSize" }
+ ListElement { title: "Window Arrangement"; action: "arrangement" }
+ }
+
+ ListView {
+ id: settingsList
+
+ anchors.fill: parent
+ anchors.topMargin: 100
+ model: settingsModel
+
+ delegate: Rectangle {
+ color: "white"
+ border.color: "lightgray"
+ border.width: 1
+ width: parent.width
+ height: children[0].height * 2.5
+
+ Text {
+ id: menuText
+ x: 40
+ anchors.verticalCenter: parent.verticalCenter
+ text: title
+ color: "black"
+ font.pointSize: btStyle.uiFontPointSize
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ if (action == "arrangement") {
+ windowArrangementMenus.visible = true;
+ settings.visible = false;
+ }
+ else if (action == "uiSize") {
+ uiFontPointSize.visible = true;
+ settings.visible = false;
+ console.log("y")
+ }
+ }
+ }
+ }
+ }
+
+ ImageButton {
+ id: backButton
+
+ icon: "leftarrow.svg"
+ height: 36
+ width: 56
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottomMargin: 8
+ visible: true
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ settings.visible = false;
+ }
+ }
+ }
+}
diff --git a/src/mobile/qml/TreeChooser.qml b/src/mobile/qml/TreeChooser.qml
new file mode 100644
index 0000000..5dc1eeb
--- /dev/null
+++ b/src/mobile/qml/TreeChooser.qml
@@ -0,0 +1,167 @@
+import QtQuick 2.1
+
+Rectangle {
+ id: treeChooser
+
+ property ListModel model: ListModel {
+ }
+ property string path: ""
+ property int pathCount: 0
+
+ color: "white"
+ border.width: 2
+ border.color: "black"
+
+ signal back()
+ signal next(string childText)
+ signal select(string childText)
+
+ Rectangle {
+ id: pathArea
+
+ border.color: "black"
+ border.width: 0
+ color: "white"
+
+ height: {20 * pathCount }
+ anchors.right: parent.right
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.margins: 4
+ visible: path.length > 0
+
+ function splitPath(path) {
+ var pathList = path.split("/");
+ var newPath = "";
+ var space = "";
+ var count = pathList.length;
+ treeChooser.pathCount = count;
+ // pathList[0] is empty
+ for (var i=1; i< count; ++i) {
+ var pathI = pathList[i];
+ newPath += space + pathI + "\n";
+ space += " ";
+ }
+ return newPath;
+ }
+
+ ImageButton {
+ id: backButton
+
+ icon: "leftarrow.svg"
+ height: 36
+ width: 56
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.right : parent.right
+ anchors.topMargin: 2
+ visible: true
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ treeChooser.back();
+ }
+ }
+ }
+
+ Text {
+ id: pathText
+
+ text: pathArea.splitPath(treeChooser.path)
+ font.pointSize: 12
+ height: parent.height
+// width: parent.width - backButton.width -50
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.right: backButton.left
+ anchors.leftMargin: 10
+ elide: Text.ElideRight
+ }
+ }
+
+ ListView {
+ id: listView
+
+ function next(index, name) {
+ treeChooser.next(name);
+ }
+
+ function select(index, name) {
+ treeChooser.select(name);
+ }
+
+ anchors.top: pathArea.bottom
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.topMargin: 30
+ anchors.leftMargin: 4
+ anchors.rightMargin: 4
+ anchors.bottomMargin: 4
+ boundsBehavior: Flickable.StopAtBounds
+ width: pathArea.width
+ model: treeChooser.model
+ delegate:
+ Rectangle {
+ id: entry
+
+ property string action: ""
+
+
+ border.color: "#eeeeee"
+ border.width: 1
+ width: parent.width
+ height: 40
+
+ Text {
+ id: entryText
+
+ font.pointSize: 12
+// anchors.fill: entry
+ anchors.top: entry.top
+ anchors.left: entry.left
+ anchors.right: entry.right
+ width: 340
+ anchors.leftMargin: 10
+ anchors.rightMargin: 10
+ anchors.topMargin: 10
+ text: name
+ elide: Text.ElideRight
+ }
+
+ ImageButton {
+ id: imageButton
+ icon: "rightarrow.svg"
+
+ height: parent.height-4
+ width: 56
+ anchors.right: parent.right
+ anchors.top: parent.top
+ anchors.topMargin: 2
+ visible: childcount > 0
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ listView.currentIndex = index
+ listView.next(index, name)
+ }
+ }
+ }
+
+ MouseArea {
+ anchors.left: parent.left
+ anchors.right: imageButton.left
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ onClicked: {
+ listView.currentIndex = index
+ listView.select(index, name)
+ }
+ }
+ }
+
+ snapMode: ListView.SnapToItem
+ focus: true
+ }
+}
diff --git a/src/mobile/qml/Window.qml b/src/mobile/qml/Window.qml
new file mode 100644
index 0000000..a14131f
--- /dev/null
+++ b/src/mobile/qml/Window.qml
@@ -0,0 +1,178 @@
+import QtQuick 2.1
+import BibleTime 1.0
+
+Rectangle {
+ id: windowView
+
+ property string title: toolbar.title
+
+ function setModule(module) {
+ btWindowInterface.moduleName = module;
+ }
+
+ function contextMenus() {
+// contextMenu.visible = true;
+ }
+
+ color: "black"
+
+ BtWindowInterface {
+ id: btWindowInterface
+ }
+
+ BtStyle {
+ id:btStyle
+ }
+
+ Rectangle {
+ id: toolbar
+
+ property string title: btWindowInterface.moduleName + " (" + btWindowInterface.reference + ")"
+
+ width: parent.width
+ height: 36
+ color: btStyle.toolbarColor
+ border.width: 1
+ border.color: "black"
+
+ Rectangle {
+ id: moduleDisplay
+
+ width: text.width +10
+ radius:btStyle.buttonRadius
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.topMargin: 4
+ anchors.leftMargin: 5
+ anchors.bottomMargin: 4
+ color: btStyle.toolbarButton
+ border.color: btStyle.buttonBorder
+ border.width: 1
+
+ Text {
+ id: text
+
+ anchors.centerIn: parent
+ anchors.leftMargin: 4
+ anchors.rightMargin: 4
+ font.pointSize: btStyle.uiFontPointSize
+ elide: Text.ElideMiddle
+ color: btStyle.toolbarButtonText
+ text: btWindowInterface.moduleName
+ }
+
+ MouseArea {
+ id: moduleMouseArea
+
+ anchors.fill: parent
+ onClicked: {
+ btWindowInterface.changeModule();
+ }
+ }
+ }
+
+
+ Rectangle {
+ id: referenceDisplay
+
+ width: {
+ var w1 = 300
+ var w2 = toolbar.width - moduleDisplay.width;
+ var w = Math.min(w1,w2);
+ return w - 15;
+ }
+ radius: btStyle.buttonRadius
+ anchors.left: moduleDisplay.right
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.topMargin: 4
+ anchors.bottomMargin: 4
+ anchors.leftMargin: 5
+ color: btStyle.toolbarButton
+ border.color: btStyle.buttonBorder
+ border.width: 1
+
+ Text {
+ id: referenceText
+ anchors.centerIn: parent
+ anchors.leftMargin: 6
+ anchors.rightMargin: 4
+ width: referenceDisplay.width - 4
+ font.pointSize: btStyle.uiFontPointSize
+ elide: Text.ElideMiddle
+ color: btStyle.toolbarButtonText
+ text: btWindowInterface.reference
+ }
+
+ MouseArea {
+ id: mouseArea
+
+ anchors.fill: parent
+ onClicked: {
+ btWindowInterface.changeReference();
+ }
+ }
+ }
+
+ }
+
+ Rectangle {
+ id: mainTextView
+
+ color: "white"
+ anchors.top: toolbar.bottom
+ anchors.left: windowView.left
+ anchors.right: windowView.right
+ anchors.bottom: windowView.bottom
+
+ ListView {
+ id: listView
+
+ clip: true
+ anchors.fill: parent
+ anchors.leftMargin: 8
+ anchors.rightMargin: 8
+ model: btWindowInterface.textModel
+ currentIndex: btWindowInterface.currentModelIndex
+ delegate: Text {
+ text: "<font color=\"blue\">" + ref + "</font> " + line
+ width: parent.width
+ color: "black"
+ font.pointSize: btStyle.textFontPointSize
+ wrapMode: Text.WordWrap
+ }
+
+ MouseArea {
+
+ anchors.fill: parent
+ onDoubleClicked: {
+ windowView.contextMenus();
+ }
+
+ onPressAndHold: {
+ windowView.contextMenus();
+
+ }
+ }
+ }
+ }
+
+ ListModel {
+ id: contextMenuModel
+
+ ListElement { title: "Text Font Size"; action: "textSize" }
+ }
+
+ ContextMenu {
+ id: contextMenu
+
+ function doAction(action) {
+ }
+
+ model: contextMenuModel
+ visible: false
+ Component.onCompleted: contextMenu.accepted.connect(contextMenu.doAction)
+ }
+
+}
diff --git a/src/mobile/qml/WindowManager.qml b/src/mobile/qml/WindowManager.qml
new file mode 100644
index 0000000..3a66219
--- /dev/null
+++ b/src/mobile/qml/WindowManager.qml
@@ -0,0 +1,291 @@
+import QtQuick 2.1
+import BibleTime 1.0
+
+
+Rectangle {
+ id: windowArea
+
+ property var windows: []
+ property int single: 0
+ property int tabLayout: 1
+ property int autoTile: 2
+ property int autoTileHor: 3
+ property int autoTileVer: 4
+ property int windowLayout: single
+
+ function setCurrentTabbedWindow(index) {
+ tabbedWindows.current = index;
+ }
+
+ function setWindowArrangement(arrangement) {
+ if (arrangement < single || arrangement > autoTileVer)
+ return;
+ windowLayout = arrangement;
+ layoutWindows();
+ }
+
+ function createWindowMenus() {
+ windowsModel.clear();
+ for (var i=0; i<windows.length; ++i) {
+ var window = windows[i];
+ windowsModel.append (
+ { title: window.title, action: i.toString() }
+ )
+ }
+ windowTitlesMenus.model = windowsModel
+ windowTitlesMenus.visible = true;
+ }
+
+
+ function newWindow() {
+ moduleChooser.moduleSelected.connect(openWindowSlot);
+ moduleChooser.visible = true;
+ }
+
+ function openWindowSlot() {
+ moduleChooser.moduleSelected.disconnect(openWindowSlot);
+ openWindow(moduleChooser.selectedCategory, moduleChooser.selectedModule)
+ }
+
+ function openWindow(category, module) {
+ if (category == "Bibles")
+ component = Qt.createComponent("Window.qml");
+ else if (category == "Commentaries")
+ component = Qt.createComponent("Window.qml");
+ else if (category == "Books")
+ component = Qt.createComponent("Window.qml");
+ else {
+ console.log(category, " are not yet supported.");
+ return;
+ }
+
+ window = component.createObject(null, {"width": 250, "height": 200});
+ window.setModule(module);
+
+ if (window == null) {
+ // Error Handling
+ console.log("Error creating object");
+ }
+ else {
+ windows.push(window)
+ layoutWindows();
+ var curWindow = windows.length -1;
+ selectWindow(curWindow);
+ }
+ }
+
+ function layoutTiles(rows, columns)
+ {
+ gridWindows.columns = columns;
+ gridWindows.rows = rows;
+ var width = gridWindows.width/columns -2;
+ var height = gridWindows.height/rows -2;
+
+ for (var i=0; i<windows.length; ++i) {
+ var window = windows[i];
+ window.anchors.fill = undefined
+ window.height = height;
+ window.width = width;
+ window.parent = gridWindows;
+ }
+ }
+
+ function arrangeSingleWindow() {
+ tabbedWindows.z = 1;
+ tabbedWindows.tabVisible = false;
+ for (var i=0; i<windows.length; ++i) {
+ var window = windows[i];
+ window.parent = tabbedWindowsStack;
+ window.anchors.fill = tabbedWindowsStack
+ }
+ }
+
+ function arrangeTabbedWindows() {
+ tabbedWindows.z = 1;
+ tabbedWindows.tabVisible = true;
+ for (var i=0; i<windows.length; ++i) {
+ var window = windows[i];
+ window.parent = tabbedWindowsStack;
+ window.anchors.fill = tabbedWindowsStack
+ }
+ }
+
+ function arrangeTiledWindows() {
+ gridWindows.z = 1;
+ var columns = 1;
+ var rows = 1;
+ var count = windows.length;
+
+ if (windowLayout == autoTile) {
+ if (count > 1) {
+ columns = 2
+ rows = Math.floor((count+1)/2);
+ }
+ }
+ else if (windowLayout == autoTileHor)
+ {
+ rows = count;
+ }
+ else if (windowLayout == autoTileVer)
+ {
+ columns = count;
+ }
+ layoutTiles(rows, columns);
+ }
+
+ function layoutWindows() {
+ tabbedWindows.z = -2;
+ gridWindows.z = -3;
+
+ if (windowLayout == single) {
+ arrangeSingleWindow();
+ }
+ else if (windowLayout == tabLayout) {
+ arrangeTabbedWindows();
+ }
+ else {
+ arrangeTiledWindows();
+ }
+ }
+
+ function selectWindow(n) {
+ if (windowLayout == tabLayout || windowLayout == single) {
+ tabbedWindows.current = n;
+ }
+ }
+
+// anchors.top: spacer.bottom
+// anchors.left: parent.left
+// anchors.right: parent.right
+// anchors.bottom: parent.bottom
+// color: "#646464"
+
+ Grid {
+ id: gridWindows
+
+ objectName: "gridWindows"
+ anchors.fill: parent
+ columns: 2
+ spacing: 2
+ z: 2
+ }
+
+ Item {
+ id: tabbedWindows
+
+ default property alias content: tabbedWindowsStack.children
+ property bool tabVisible: true
+ property int current: 0
+
+ function changeTabs() {
+ setOpacities();
+ }
+
+ function setOpacities() {
+ for (var i = 0; i < tabbedWindowsStack.children.length; ++i) {
+ tabbedWindowsStack.children[i].z = (i == current ? 1 : 0)
+ }
+ }
+
+ objectName: "tabbedWindows"
+ anchors.fill: parent
+ onCurrentChanged: changeTabs()
+ Component.onCompleted: changeTabs()
+
+ Row {
+ id: header
+
+ objectName: "header"
+
+ Repeater {
+ id: tabRepeater
+
+ function setColors() {
+ if (tabbedWindows.current == tabbedWindowsStack.index) {
+ tabImage.color = btStyle.windowTabSelected
+ tabText.color = btStyle.windowTabTextSelected
+ }
+ else {
+ tabImage.color = btStyle.windowTab
+ tabText.color = btStyle.windowTabText
+ }
+ }
+
+ model: tabbedWindowsStack.children.length
+ delegate: Rectangle {
+ id: tab
+
+ function calculateTabWidth() {
+ var tabWidth = (tabbedWindows.width) / tabbedWindowsStack.children.length;
+ return tabWidth;
+ }
+
+ visible: tabbedWindows.tabVisible
+ //width: (tabbedWindows.width) / tabbedWindowsStack.children.length;
+ width: {
+ calculateTabWidth()
+ }
+ height: 36
+
+ Rectangle {
+ id: tabBorder
+ width: parent.width; height: 1
+ anchors { bottom: parent.bottom; bottomMargin: 1 }
+ color: "#acb2c2"
+ }
+
+ Rectangle {
+ id: tabImage
+
+ anchors { fill: parent; leftMargin: 8; topMargin: 4; rightMargin: 8 }
+ color: {
+ if (tabbedWindows.current == index)
+ return btStyle.windowTabSelected
+ else
+ return btStyle.windowTab
+ }
+ border.color: btStyle.windowTab
+ border.width: 2
+
+ Text {
+ id: tabText
+
+ horizontalAlignment: Qt.AlignHCenter;
+ verticalAlignment: Qt.AlignVCenter
+ anchors.fill: parent
+ anchors.topMargin: 6
+ font.pointSize: btStyle.uiFontPointSize -3
+ text: tabbedWindowsStack.children[index].title
+ elide: Text.ElideLeft
+ color: {
+ if (tabbedWindows.current == index)
+ return btStyle.windowTabTextSelected
+ else
+ return btStyle.windowTabText
+ }
+ }
+ }
+
+ MouseArea {
+ id: tabMouseArea
+
+ anchors.fill: parent
+ onClicked: {
+ tabbedWindows.current = index
+ }
+ }
+ }
+ }
+ }
+
+ Item {
+ id: tabbedWindowsStack
+
+ objectName: "tabbedWindowsStack"
+ width: parent.width
+ anchors.top: header.bottom;
+ anchors.bottom: tabbedWindows.bottom
+ }
+ }
+
+}
diff --git a/src/mobile/qml/checkmark.svg b/src/mobile/qml/checkmark.svg
new file mode 100644
index 0000000..07a3ad8
--- /dev/null
+++ b/src/mobile/qml/checkmark.svg
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://web.resource.org/cc/"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="450" height="400" viewBox="85 145 450 400"
+ sodipodi:version="0.32"
+ inkscape:version="0.45"
+ sodipodi:docname="checkmark.svg">
+ <metadata>
+ <rdf:RDF>
+ <cc:Work rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <path
+ style="fill:#5fd35f;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 508.74477,226.99015 C 459.42189,193.17234 436.08559,163.59563 436.08559,163.59563 C 344.99984,217.26626 248.26757,407.83719 248.26757,407.83719 C 202.93454,344.01939 157.35384,326.21932 157.35384,326.21932 C 136.86236,353.60112 101.54091,390.09316 101.54091,390.09316 C 183.924,412.28062 253.07323,493.70015 253.07323,493.70015 C 402.5571,259.01322 508.74477,226.99015 508.74477,226.99015 z "
+ sodipodi:nodetypes="ccccccc" />
+ <path
+ sodipodi:type="arc"
+ style="opacity:0.2;fill:#999999;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0"
+ sodipodi:cx="238.57143"
+ sodipodi:cy="529.50507"
+ sodipodi:rx="64.285713"
+ sodipodi:ry="7.1428571"
+ d="M 302.03011,528.36301 A 64.285713,7.1428571 0 1 1 301.97855,528.32818"
+ sodipodi:start="6.1226078"
+ sodipodi:end="12.400852"
+ sodipodi:open="true"
+ transform="translate(8.5714285,-11.428571)" />
+ <path
+ style="opacity:0.27777782;fill:#5fd35f;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 518.74479,227.27587 C 469.42191,193.45806 446.08561,163.88135 446.08561,163.88135 C 354.99986,217.55198 258.26759,408.12291 258.26759,408.12291 C 212.93456,344.30511 167.35386,326.50504 167.35386,326.50504 C 146.86238,353.88684 111.54093,390.37888 111.54093,390.37888 C 193.92402,412.56634 263.07325,493.98587 263.07325,493.98587 C 412.55712,259.29894 518.74479,227.27587 518.74479,227.27587 z "
+ sodipodi:nodetypes="ccccccc" />
+</svg>
diff --git a/src/mobile/qml/leftarrow.svg b/src/mobile/qml/leftarrow.svg
new file mode 100644
index 0000000..6143c87
--- /dev/null
+++ b/src/mobile/qml/leftarrow.svg
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="900"
+ height="900"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.48.4 r9939"
+ sodipodi:docname="rightarrow.svg">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.74333333"
+ inkscape:cx="450"
+ inkscape:cy="450"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="in"
+ inkscape:window-width="1600"
+ inkscape:window-height="868"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1">
+ <inkscape:grid
+ type="xygrid"
+ id="grid2985"
+ empspacing="5"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="true" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-152.3622)">
+ <path
+ sodipodi:type="star"
+ style="fill:#4d4d4d;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ id="path2995"
+ sodipodi:sides="3"
+ sodipodi:cx="460"
+ sodipodi:cy="420"
+ sodipodi:r1="380.52594"
+ sodipodi:r2="190.26299"
+ sodipodi:arg1="0"
+ sodipodi:arg2="1.0471976"
+ inkscape:flatsided="true"
+ inkscape:rounded="0"
+ inkscape:randomized="0"
+ d="m 840.52594,420 -570.78891,329.54513 0,-659.090261 z"
+ transform="matrix(-1,0,0,-1,1014.9543,1026.7074)"
+ inkscape:transform-center-y="-2.9985352e-05"
+ inkscape:transform-center-x="95.131485" />
+ </g>
+</svg>
diff --git a/src/mobile/qml/main.qml b/src/mobile/qml/main.qml
new file mode 100644
index 0000000..d7597b1
--- /dev/null
+++ b/src/mobile/qml/main.qml
@@ -0,0 +1,270 @@
+import QtQuick 2.1
+import BibleTime 1.0
+
+Rectangle {
+ id: root
+
+ property int opacitypopup: 0
+ property QtObject component: null;
+ property Item window: null;
+
+ ListModel {
+ id: windowsModel
+
+ ListElement { title: ""; action: "" }
+ }
+
+ function installModules() {
+ installManager.openChooser();
+ }
+
+// width: 1280 // Nexus 7 (2012)
+// height: 800
+
+ width: 480 // Phone
+ height: 800
+
+ rotation: 0
+
+ MainToolbar {
+ id: mainToolbar
+
+ anchors.left: parent.left
+ anchors.top: parent.top
+ anchors.right: parent.right
+ height: 30
+ onButtonClicked: {
+ mainMenus.visible = ! mainMenus.visible;
+ }
+ }
+
+ Rectangle {
+ id: spacer
+
+ anchors.top: mainToolbar.bottom
+ height:2
+ width: parent.width
+ color: "#646464"
+ }
+
+ WindowManager {
+ id: windowManager
+
+ anchors.top: spacer.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ color: "#646464"
+
+ }
+
+ Settings {
+ id: settings
+
+ visible: false;
+ }
+
+ GridChooser {
+ id: gridChooser
+
+ objectName: "gridChooser"
+ width: parent.width
+ height: parent.height
+ visible: false
+ }
+
+ BtStyle {
+ id: btStyle
+ }
+
+ ModuleChooser {
+ id: moduleChooser
+
+ objectName: "moduleChooser"
+ visible: false
+ width: Math.min(parent.height, parent.width);
+ height: parent.height
+ anchors.centerIn: parent
+ }
+
+ TreeChooser {
+ id: treeChooser
+
+ objectName: "treeChooser"
+ width:480
+ height: parent.height
+ anchors.top: parent.top
+ anchors.horizontalCenter: parent.horizontalCenter
+ path: ""
+ visible: false
+ z: 100
+ }
+
+ InstallManager {
+ id: installManager
+ }
+
+ InstallManagerChooser {
+ id: installManagerChooser
+
+ objectName: "installManagerChooser"
+ width: Math.min(parent.height, parent.width);
+ height: parent.height
+ anchors.centerIn: parent
+ anchors.top: parent.top
+ visible: false
+ }
+
+ Progress {
+ id: progress
+
+ objectName: "progress"
+ value: 0.25
+ minimumValue: 0
+ maximumValue: 1
+ width:550
+ height: 200
+ anchors.centerIn: parent
+ anchors.top: parent.top
+ visible: false
+ }
+
+ ListModel {
+ id: mainMenusModel
+
+ ListElement { title: QT_TR_NOOP("New Window"); action: "newWindow" }
+ ListElement { title: QT_TR_NOOP("View Window"); action: "windows" }
+ ListElement { title: QT_TR_NOOP("Text Font Size"); action: "textFontSize"}
+ ListElement { title: QT_TR_NOOP("User Interface Font Size");action: "uiFontSize"}
+
+ //ListElement { title: QT_TR_NOOP("Settings"); action: "settings" }
+ ListElement { title: QT_TR_NOOP("Bookshelf Manager"); action: "install" }
+ // ListElement { title: QT_TR_NOOP("Gnome Style"); action: "gnomeStyle" }
+ // ListElement { title: QT_TR_NOOP("Android Style"); action: "androidStyle" }
+ }
+
+ Menus {
+ id: mainMenus
+
+ Component.onCompleted: menuSelected.connect(mainMenus.doAction)
+
+ function doAction(action) {
+ mainMenus.visible = false;
+ if (action == "newWindow") {
+ windowManager.newWindow();
+ }
+ else if (action == "windows") {
+ windowManager.createWindowMenus();
+ }
+ else if (action == "gnomeStyle") {
+ btStyle.setStyle(1)
+ }
+ else if (action == "androidStyle") {
+ btStyle.setStyle(2)
+ }
+ else if (action == "install") {
+ installModules();
+ }
+ else if (action == "settings") {
+ settings.visible = true;
+ }
+ else if (action == "textFontSize") {
+ textFontPointSize.visible = true;
+ }
+ else if (action == "uiFontSize") {
+ uiFontPointSize.visible = true;
+ }
+
+ }
+
+ model: mainMenusModel
+ topMenuMargin: 100
+ }
+
+ ListModel {
+ id: windowArrangementModel
+
+ ListElement { title: QT_TR_NOOP("Single"); action: "single" }
+ ListElement { title: QT_TR_NOOP("Tabbed"); action: "tabbed" }
+ ListElement { title: QT_TR_NOOP("Auto-tile"); action: "autoTile" }
+ ListElement { title: QT_TR_NOOP("Auto-tile horizontally"); action: "autoTileHor" }
+ ListElement { title: QT_TR_NOOP("Auto-tile vertically"); action: "autoTileVer" }
+ }
+
+ Menus {
+ id: windowArrangementMenus
+
+ Component.onCompleted: menuSelected.connect(windowArrangementMenus.doAction)
+
+ function doAction(action) {
+ windowArrangementMenus.visible = false;
+ if (action == "single") {
+ windowManager.setWindowArrangement(windowManager.single);
+ }
+ else if (action == "tabbed") {
+ windowManager.setWindowArrangement(windowManager.tabLayout);
+ }
+ else if (action == "autoTile") {
+ windowManager.setWindowArrangement(windowManager.autoTile);
+ }
+ else if (action == "autoTileHor") {
+ windowManager.setWindowArrangement(windowManager.autoTileHor);
+ }
+ else if (action == "autoTileVer") {
+ windowManager.setWindowArrangement(windowManager.autoTileVer);
+ }
+ }
+
+ model: windowArrangementModel
+ }
+
+ Menus {
+ id: windowTitlesMenus
+
+ model: windowsModel
+ visible: false
+ Component.onCompleted: menuSelected.connect(windowTitlesMenus.doAction)
+
+ function doAction(action) {
+ windowTitlesMenus.visible = false;
+ var index = Number(action)
+ windowManager.setCurrentTabbedWindow(index);
+ }
+ }
+
+ FontSizeSlider {
+ id: uiFontPointSize
+ visible: false
+ title: "User Interface Font Size"
+
+ onVisibleChanged: {
+ if (visible)
+ {
+ uiFontPointSize.current = btStyle.uiFontPointSize;
+ uiFontPointSize.previous = btStyle.uiFontPointSize;
+ }
+ }
+
+ onAccepted: {
+ btStyle.uiFontPointSize = pointSize
+ }
+ }
+
+ FontSizeSlider {
+ id: textFontPointSize
+ visible: false
+ title: "Text Font Size"
+
+ onVisibleChanged: {
+ if (visible)
+ {
+ textFontPointSize.current = btStyle.textFontPointSize;
+ textFontPointSize.previous = btStyle.textFontPointSize;
+ }
+ }
+
+ onAccepted: {
+ btStyle.textFontPointSize = pointSize;
+ }
+ }
+}
diff --git a/src/mobile/qml/rightarrow.svg b/src/mobile/qml/rightarrow.svg
new file mode 100644
index 0000000..e9fd5d1
--- /dev/null
+++ b/src/mobile/qml/rightarrow.svg
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="900"
+ height="900"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.48.4 r9939"
+ sodipodi:docname="New document 1">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.49497475"
+ inkscape:cx="21.09998"
+ inkscape:cy="433.47351"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ showgrid="true"
+ units="in"
+ inkscape:window-width="1600"
+ inkscape:window-height="868"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1">
+ <inkscape:grid
+ type="xygrid"
+ id="grid2985"
+ empspacing="5"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="true" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(0,-152.3622)">
+ <path
+ sodipodi:type="star"
+ style="fill:#4d4d4d;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
+ id="path2995"
+ sodipodi:sides="3"
+ sodipodi:cx="460"
+ sodipodi:cy="420"
+ sodipodi:r1="380.52594"
+ sodipodi:r2="190.26299"
+ sodipodi:arg1="0"
+ sodipodi:arg2="1.0471976"
+ inkscape:flatsided="true"
+ inkscape:rounded="0"
+ inkscape:randomized="0"
+ d="m 840.52594,420 -570.78891,329.54513 0,-659.090261 z"
+ transform="translate(-101.01525,164.48403)"
+ inkscape:transform-center-x="-95.131488" />
+ </g>
+</svg>
diff --git a/src/mobile/qml/tab.png b/src/mobile/qml/tab.png
new file mode 100644
index 0000000..ad80216
--- /dev/null
+++ b/src/mobile/qml/tab.png
Binary files differ
diff --git a/src/mobile/ui/btstyle.cpp b/src/mobile/ui/btstyle.cpp
new file mode 100644
index 0000000..ee22d15
--- /dev/null
+++ b/src/mobile/ui/btstyle.cpp
@@ -0,0 +1,334 @@
+
+#include "btstyle.h"
+#include <QList>
+#include <QPointer>
+#include "backend/config/btconfig.h"
+
+// BtStyle is a class that is registered at a QML item. It can be placed into
+// QML files and its properties are available to be used in QML. It contains
+// colors, sizes, etc. that affect the look of the UI. You can have multipe
+// instances of the item. Changing a property on one of them changes all of them
+/*
+ import BibleTime 1.0
+
+ BtStyle {
+ id: btStyle
+ }
+
+ Rectangle {
+ color: btStyle.button
+ }
+*/
+
+namespace btm {
+
+// Only one copy of properties so they are the same everywhere used.
+static QColor buttonColor = QColor();
+static QColor buttonBackground = QColor();
+static QColor buttonTextColor = QColor();
+static QColor buttonHighlightedText = QColor();
+static QColor buttonBorder = QColor();
+static int buttonRadius = 0;
+static QColor buttonGradient0;
+static QColor buttonGradient1;
+static QColor buttonGradient2;
+static QColor buttonGradient3;
+
+static QColor windowTab = QColor();
+static QColor windowTabSelected = QColor();
+static QColor windowTabText = QColor();
+static QColor windowTabTextSelected = QColor();
+
+static QColor menu = QColor();
+static QColor menuBorder = QColor();
+static QColor menuText = QColor();
+static int menuHeight = 0;
+
+static QColor toolbarColor = QColor();
+static QColor toolbarButton = QColor();
+static QColor toolbarButtonText = QColor();
+static double toolbarTextPointSize = 6;
+
+
+static QList<QPointer<BtStyle> > styles;
+
+static void emitChanged() {
+ for (int i=0; i<styles.count(); ++i) {
+ QPointer<BtStyle> style = styles.at(i);
+ if (style != 0)
+ style->changed();
+ }
+}
+
+void BtStyle::setStyle(int style) {
+ if (style == BtStyle::gnome) {
+ setButtonColor(QColor(0,0,0));
+ setButtonBackground(QColor(237, 237, 237));
+ setButtonTextColor(QColor(0,0,0));
+ setButtonHighlightedText(QColor(0,0,255));
+ setButtonBorder(QColor(80,80,0));
+ setButtonRadius(3);
+ setButtonGradient0(QColor(200,200,200));
+ setButtonGradient1(QColor(246,246,246));
+ setButtonGradient2(QColor(246,246,246));
+ setButtonGradient3(QColor(200,200,200));
+
+ setWindowTab(QColor(206,206,206));
+ setWindowTabSelected(QColor(255,255,255));
+ setWindowTabText(QColor(0,0,0));
+ setWindowTabTextSelected(QColor(0,0,0));
+
+ setMenu(QColor(255,255,255));
+ setMenuBorder(QColor(255,255,255));
+ setMenuText(QColor(0,0,0));
+ setMenuHeight(40);
+
+ setToolbarColor(QColor(237,237,237));
+ setToolbarButton(QColor(237,237,237));
+ setToolbarButtonText(QColor(0,0,0));
+ setToolbarTextPointSize(10);
+ }
+ else if (style == BtStyle::android) {
+ setButtonColor(QColor(0,0,0));
+ setButtonBackground(QColor(35,35,100));
+ setButtonTextColor(QColor(255,210,0));
+ setButtonHighlightedText(QColor(255,255,0));
+ setButtonBorder(QColor(80,80,0));
+ setButtonRadius(3);
+ setButtonGradient0(QColor(125,125,125));
+ setButtonGradient1(QColor(60,60,60));
+ setButtonGradient2(QColor(50,50,50));
+ setButtonGradient3(QColor(20,20,20));
+
+ setWindowTab(QColor(100,100,100));
+ setWindowTabSelected(QColor(255,255,255));
+ setWindowTabText(QColor(255,255,255));
+ setWindowTabTextSelected(QColor(0,0,0));
+
+ setMenu(QColor(255,255,255));
+ setMenuBorder(QColor(224,224,224));
+ setMenuText(QColor(0,0,0));
+ setMenuHeight(34);
+
+ setToolbarColor(QColor(120,120,120));
+ setToolbarButton(QColor(255,210,0));
+ setToolbarButtonText(QColor(0,0,0));
+ setToolbarTextPointSize(10);
+ }
+
+ emitChanged();
+}
+
+BtStyle::BtStyle(QObject* parent)
+ : QObject(parent) {
+ styles.append(this);
+}
+
+QColor BtStyle::getButtonColor() const {
+ return buttonColor;
+}
+void BtStyle::setButtonColor(const QColor& color) {
+ buttonColor = color;
+ emitChanged();
+}
+
+
+QColor BtStyle::getButtonBackground() const {
+ return buttonBackground;
+}
+void BtStyle::setButtonBackground(const QColor& color) {
+ buttonBackground = color;
+ emitChanged();
+}
+
+
+QColor BtStyle::getButtonTextColor() const {
+ return buttonTextColor;
+}
+void BtStyle::setButtonTextColor(const QColor& color) {
+ buttonTextColor = color;
+ emitChanged();
+}
+
+
+QColor BtStyle::getButtonHighlightedText() const {
+ return buttonHighlightedText;
+}
+void BtStyle::setButtonHighlightedText(const QColor& color) {
+ buttonHighlightedText = color;
+ emitChanged();
+}
+
+
+QColor BtStyle::getButtonBorder() const {
+ return buttonBorder;
+}
+void BtStyle::setButtonBorder(const QColor& color) {
+ buttonBorder = color;
+ emitChanged();
+}
+
+int BtStyle::getButtonRadius() const {
+ return buttonRadius;
+}
+void BtStyle::setButtonRadius(int radius) {
+ buttonRadius = radius;
+ emitChanged();
+}
+
+QColor BtStyle::getButtonGradient0() const {
+ return buttonGradient0;
+}
+void BtStyle::setButtonGradient0(const QColor& color) {
+ buttonGradient0 = color;
+ emitChanged();
+}
+
+QColor BtStyle::getButtonGradient1() const {
+ return buttonGradient1;
+}
+void BtStyle::setButtonGradient1(const QColor& color) {
+ buttonGradient1 = color;
+ emitChanged();
+}
+
+QColor BtStyle::getButtonGradient2() const {
+ return buttonGradient2;
+}
+void BtStyle::setButtonGradient2(const QColor& color) {
+ buttonGradient2 = color;
+ emitChanged();
+}
+
+QColor BtStyle::getButtonGradient3() const {
+ return buttonGradient3;
+}
+void BtStyle::setButtonGradient3(const QColor& color) {
+ buttonGradient3 = color;
+ emitChanged();
+}
+
+QColor BtStyle::getWindowTab() const {
+ return windowTab;
+}
+
+void BtStyle::setWindowTab(const QColor& color) {
+ windowTab = color;
+ emitChanged();
+}
+
+QColor BtStyle::getWindowTabSelected() const {
+ return windowTabSelected;
+}
+
+void BtStyle::setWindowTabSelected(const QColor& color) {
+ windowTabSelected = color;
+ emitChanged();
+}
+
+QColor BtStyle::getWindowTabText() const {
+ return windowTabText;
+}
+
+void BtStyle::setWindowTabText(const QColor& color) {
+ windowTabText = color;
+ emitChanged();
+}
+
+QColor BtStyle::getWindowTabTextSelected() const {
+ return windowTabTextSelected;
+}
+
+void BtStyle::setWindowTabTextSelected(const QColor& color) {
+ windowTabTextSelected = color;
+ emitChanged();
+}
+
+QColor BtStyle::getMenu() const {
+ return menu;
+}
+
+void BtStyle::setMenu(const QColor& color) {
+ menu = color;
+ emitChanged();
+}
+
+QColor BtStyle::getMenuBorder() const {
+ return menuBorder;
+}
+
+void BtStyle::setMenuBorder(const QColor& color) {
+ menuBorder = color;
+ emitChanged();
+}
+
+QColor BtStyle::getMenuText() const {
+ return menuText;
+}
+
+void BtStyle::setMenuText(const QColor& color) {
+ menuText = color;
+ emitChanged();
+}
+
+int BtStyle::getMenuHeight() const {
+ return menuHeight;
+}
+void BtStyle::setMenuHeight(int height) {
+ menuHeight = height;
+ emitChanged();
+}
+
+QColor BtStyle::getToolbarColor() const {
+ return toolbarColor;
+}
+void BtStyle::setToolbarColor(const QColor& color) {
+ toolbarColor = color;
+ emitChanged();
+}
+
+QColor BtStyle::getToolbarButton() const {
+ return toolbarButton;
+}
+void BtStyle::setToolbarButton(const QColor& color) {
+ toolbarButton = color;
+ emitChanged();
+}
+
+QColor BtStyle::getToolbarButtonText() const {
+ return toolbarButtonText;
+}
+void BtStyle::setToolbarButtonText(const QColor& color) {
+ toolbarButtonText = color;
+ emitChanged();
+}
+
+double BtStyle::getToolbarTextPointSize() const {
+ return toolbarTextPointSize;
+}
+
+void BtStyle::setToolbarTextPointSize(double pointSize) {
+ toolbarTextPointSize = pointSize;
+ emitChanged();
+}
+
+double BtStyle::getTextFontPointSize() const {
+ return btConfig().value<int>("ui/textFontSize",14);
+}
+
+void BtStyle::setTextFontPointSize(double pointSize) {
+ btConfig().setValue<int>("ui/textFontSize", pointSize);
+ emitChanged();
+}
+
+double BtStyle::getUiFontPointSize() const {
+ return btConfig().value<int>("ui/uiFontSize",14);
+}
+
+void BtStyle::setUiFontPointSize(double pointSize) {
+ btConfig().setValue<int>("ui/uiFontSize", pointSize);
+ emitChanged();
+}
+
+} // end namespace
+
diff --git a/src/mobile/ui/btstyle.h b/src/mobile/ui/btstyle.h
new file mode 100644
index 0000000..7f65c22
--- /dev/null
+++ b/src/mobile/ui/btstyle.h
@@ -0,0 +1,132 @@
+#ifndef BT_STYLE_H
+#define BT_STYLE_H
+
+#include <QObject>
+#include <QColor>
+
+namespace btm {
+
+class BtStyle : public QObject {
+ Q_OBJECT
+
+ Q_PROPERTY(QColor buttonColor READ getButtonColor NOTIFY changed)
+ Q_PROPERTY(QColor buttonBackground READ getButtonBackground NOTIFY changed)
+ Q_PROPERTY(QColor buttonTextColor READ getButtonTextColor NOTIFY changed)
+ Q_PROPERTY(QColor buttonHighlightedText READ getButtonHighlightedText NOTIFY changed)
+ Q_PROPERTY(QColor buttonBorder READ getButtonBorder NOTIFY changed)
+ Q_PROPERTY(int buttonRadius READ getButtonRadius NOTIFY changed)
+
+ Q_PROPERTY(QColor buttonGradient0 READ getButtonGradient0 NOTIFY changed)
+ Q_PROPERTY(QColor buttonGradient1 READ getButtonGradient1 NOTIFY changed)
+ Q_PROPERTY(QColor buttonGradient2 READ getButtonGradient2 NOTIFY changed)
+ Q_PROPERTY(QColor buttonGradient3 READ getButtonGradient3 NOTIFY changed)
+
+
+ Q_PROPERTY(QColor windowTab READ getWindowTab NOTIFY changed)
+ Q_PROPERTY(QColor windowTabSelected READ getWindowTabSelected NOTIFY changed)
+ Q_PROPERTY(QColor windowTabText READ getWindowTabText NOTIFY changed)
+ Q_PROPERTY(QColor windowTabTextSelected READ getWindowTabTextSelected NOTIFY changed)
+
+ Q_PROPERTY(QColor menu READ getMenu NOTIFY changed)
+ Q_PROPERTY(QColor menuBorder READ getMenuBorder NOTIFY changed)
+ Q_PROPERTY(QColor menuText READ getMenuText NOTIFY changed)
+ Q_PROPERTY(int menuHeight READ getMenuHeight() NOTIFY changed)
+
+ Q_PROPERTY(QColor toolbarColor READ getToolbarColor NOTIFY changed)
+ Q_PROPERTY(QColor toolbarButton READ getToolbarButton NOTIFY changed)
+ Q_PROPERTY(QColor toolbarButtonText READ getToolbarButtonText NOTIFY changed)
+ Q_PROPERTY(double toolbarTextPointSize READ getToolbarTextPointSize NOTIFY changed);
+
+ Q_PROPERTY(double textFontPointSize READ getTextFontPointSize WRITE setTextFontPointSize NOTIFY changed);
+ Q_PROPERTY(double uiFontPointSize READ getUiFontPointSize WRITE setUiFontPointSize NOTIFY changed);
+
+public:
+ Q_INVOKABLE void setStyle(int style);
+
+ enum Style {
+ gnome = 1,
+ android = 2
+ };
+
+
+ BtStyle(QObject *parent = 0);
+
+ QColor getButtonColor() const;
+ void setButtonColor(const QColor& color);
+
+ QColor getButtonBackground() const;
+ void setButtonBackground(const QColor& color);
+
+ QColor getButtonTextColor() const;
+ void setButtonTextColor(const QColor& color);
+
+ QColor getButtonHighlightedText() const;
+ void setButtonHighlightedText(const QColor& color);
+
+ QColor getButtonBorder() const;
+ void setButtonBorder(const QColor& color);
+
+ int getButtonRadius() const;
+ void setButtonRadius(int radius);
+
+ QColor getButtonGradient0() const;
+ void setButtonGradient0(const QColor& color);
+
+ QColor getButtonGradient1() const;
+ void setButtonGradient1(const QColor& color);
+
+ QColor getButtonGradient2() const;
+ void setButtonGradient2(const QColor& color);
+
+ QColor getButtonGradient3() const;
+ void setButtonGradient3(const QColor& color);
+
+ QColor getWindowTab() const;
+ void setWindowTab(const QColor& color);
+
+ QColor getWindowTabSelected() const;
+ void setWindowTabSelected(const QColor& color);
+
+ QColor getWindowTabText() const;
+ void setWindowTabText(const QColor& color);
+
+ QColor getWindowTabTextSelected() const;
+ void setWindowTabTextSelected(const QColor& color);
+
+ QColor getMenu() const;
+ void setMenu(const QColor& color);
+
+ QColor getMenuBorder() const;
+ void setMenuBorder(const QColor& color);
+
+ QColor getMenuText() const;
+ void setMenuText(const QColor& color);
+
+ int getMenuHeight() const;
+ void setMenuHeight(int height);
+
+ QColor getToolbarColor() const;
+ void setToolbarColor(const QColor& color);
+
+ QColor getToolbarButton() const;
+ void setToolbarButton(const QColor& color);
+
+ QColor getToolbarButtonText() const;
+ void setToolbarButtonText(const QColor& color);
+
+ double getToolbarTextPointSize() const;
+ void setToolbarTextPointSize(double pointSize);
+
+ double getTextFontPointSize() const;
+ void setTextFontPointSize(double pointSize);
+
+ double getUiFontPointSize() const;
+ void setUiFontPointSize(double pointSize);
+
+signals:
+ void changed();
+};
+
+} // end namespace
+
+#endif
diff --git a/src/mobile/ui/btwindowinterface.cpp b/src/mobile/ui/btwindowinterface.cpp
new file mode 100644
index 0000000..1016055
--- /dev/null
+++ b/src/mobile/ui/btwindowinterface.cpp
@@ -0,0 +1,257 @@
+
+#include "btwindowinterface.h"
+
+#include "backend/config/btconfig.h"
+#include "backend/drivers/cswordbiblemoduleinfo.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/keys/cswordkey.h"
+#include "backend/keys/cswordtreekey.h"
+#include "backend/managers/cswordbackend.h"
+#include "backend/rendering/centrydisplay.h"
+#include "backend/rendering/cdisplayrendering.h"
+#include "mobile/btmmain.h"
+#include "mobile/keychooser/versechooser.h"
+#include "mobile/keychooser/bookkeychooser.h"
+#include "mobile/ui/modulechooser.h"
+#include "mobile/ui/viewmanager.h"
+#include <QDebug>
+#include <QFile>
+#include <QObject>
+#include <QQmlContext>
+#include <QQmlEngine>
+#include <QQuickItem>
+#include <QStringList>
+
+
+namespace btm {
+
+BtWindowInterface::BtWindowInterface(QObject* parent)
+ : QObject(parent),
+ m_key(0),
+ m_textModel(new RoleItemModel()),
+ m_bookKeyChooser(0),
+ m_verseKeyChooser(0),
+ m_bibleTextModelBuilder(m_textModel),
+ m_bookTextModelBuilder(m_textModel){
+
+ QtQuick2ApplicationViewer* viewer = getViewManager()->getViewer();
+ m_verseKeyChooser = new VerseChooser(viewer, this);
+ bool ok = connect(m_verseKeyChooser, SIGNAL(referenceChanged()), this, SLOT(referenceChanged()));
+ Q_ASSERT(ok);
+
+ m_bookKeyChooser = new BookKeyChooser(viewer, this);
+ ok = connect(m_bookKeyChooser, SIGNAL(referenceChanged()), this, SLOT(referenceChanged()));
+ Q_ASSERT(ok);
+}
+
+static QString getKeyText(CSwordKey* key) {
+ QString keyText;
+ if ( ! key)
+ return keyText;
+
+ CSwordVerseKey* verseKey = dynamic_cast<CSwordVerseKey*>(key);
+ if (verseKey) {
+ keyText = verseKey->key();
+ return keyText;
+ }
+
+ CSwordTreeKey* treeKey = dynamic_cast<CSwordTreeKey*>(key);
+ if (treeKey) {
+ keyText = treeKey->key();
+ return keyText;
+ }
+ return keyText;
+}
+
+void BtWindowInterface::updateModel() {
+ QString moduleName= getModuleName();
+ QStringList moduleList = QStringList() << moduleName;
+ QList<const CSwordModuleInfo*> modules =
+ CSwordBackend::instance()->getConstPointerList(moduleList);
+ QString keyText = getKeyText(m_key);
+
+ m_textModel->clear();
+ if (modules.at(0)->type() == CSwordModuleInfo::Bible)
+ m_bibleTextModelBuilder.updateModel(modules, keyText);
+ else if (modules.at(0)->type() == CSwordModuleInfo::GenericBook)
+ m_bookTextModelBuilder.updateModel(modules, keyText);
+
+ emit currentModelIndexChanged();
+}
+
+int BtWindowInterface::getCurrentModelIndex() const {
+ return m_bibleTextModelBuilder.getCurrentModelIndex();
+}
+
+static bool moduleIsBibleOrCommentary(const CSwordModuleInfo* module) {
+ CSwordModuleInfo::Category category = module->category();
+ if (category == CSwordModuleInfo::Bibles ||
+ category == CSwordModuleInfo::Commentaries)
+ return true;
+ return false;
+}
+
+static bool moduleIsBook(const CSwordModuleInfo* module) {
+ CSwordModuleInfo::Category category = module->category();
+ if (category == CSwordModuleInfo::Books)
+ return true;
+ return false;
+}
+
+QString BtWindowInterface::getModuleName() const {
+ QString moduleName;
+ if (m_key)
+ moduleName = m_key->module()->name();
+ return moduleName;
+}
+
+void BtWindowInterface::setModuleName(const QString& moduleName) {
+ CSwordModuleInfo* m = CSwordBackend::instance()->findModuleByName(moduleName);
+ if (!m_key) {
+ m_key = CSwordKey::createInstance(m);
+ }
+ else {
+ if (moduleIsBibleOrCommentary(m) &&
+ moduleIsBibleOrCommentary(m_key->module())) {
+ m_key->setModule(m);
+ }
+ else if (moduleIsBook(m) &&
+ moduleIsBook(m_key->module())) {
+ m_key->setModule(m);
+ }
+
+ else {
+ delete m_key;
+ m_key = CSwordKey::createInstance(m);
+ }
+
+ }
+
+ CSwordTreeKey* treeKey = dynamic_cast<CSwordTreeKey*>(m_key);
+ if (treeKey)
+ treeKey->firstChild();
+
+ emit moduleChanged();
+ emit referenceChange();
+ updateModel();
+}
+
+QString BtWindowInterface::getReference() const {
+ QString reference;
+ if (m_key)
+ reference = m_key->key();
+ return reference;
+}
+
+void BtWindowInterface::changeModule() {
+ QtQuick2ApplicationViewer* viewer = getViewManager()->getViewer();
+ ModuleChooser* dlg = new ModuleChooser(viewer, this);
+ dlg->open();
+}
+
+static void parseKey(CSwordTreeKey* currentKey, QStringList* keyPath, QStringList* children)
+{
+ if (currentKey == 0)
+ return;
+
+ CSwordTreeKey localKey(*currentKey);
+
+ QString oldKey = localKey.key(); //string backup of key
+
+ if (oldKey.isEmpty()) { //don't set keys equal to "/", always use a key which may have content
+ localKey.firstChild();
+ oldKey = localKey.key();
+ }
+// const int oldOffset = localKey.getOffset(); //backup key position
+
+ QStringList siblings; //split up key
+ if (!oldKey.isEmpty()) {
+ siblings = oldKey.split('/', QString::SkipEmptyParts);
+ }
+
+ int depth = 0;
+ int index = 0;
+ localKey.root(); //start iteration at root node
+
+ while ( localKey.firstChild() && (depth < siblings.count()) ) {
+ QString key = localKey.key();
+ index = (depth == 0) ? -1 : 0;
+
+ bool found = false;
+ do { //look for matching sibling
+ ++index;
+ found = (localKey.getLocalNameUnicode() == siblings[depth]);
+ }
+ while (!found && localKey.nextSibling());
+
+ if (found)
+ key = localKey.key(); //found: change key to this level
+ else
+ localKey.setKey(key); //not found: restore old key
+
+ *keyPath << key;
+
+ //last iteration: get child entries
+ if (depth == siblings.count() - 1 && localKey.hasChildren()) {
+ localKey.firstChild();
+ ++depth;
+ do {
+ *children << localKey.getLocalNameUnicode();
+ }
+ while (localKey.nextSibling());
+ }
+ depth++;
+ }
+}
+
+void BtWindowInterface::changeReference() {
+ CSwordVerseKey* verseKey = dynamic_cast<CSwordVerseKey*>(m_key);
+ if (verseKey != 0) {
+ m_verseKeyChooser->open(verseKey);
+ }
+
+ CSwordTreeKey* treeKey = dynamic_cast<CSwordTreeKey*>(m_key);
+ if (treeKey != 0) {
+ QStringList keyPath;
+ QStringList children;
+ parseKey(treeKey, &keyPath, &children);
+ m_bookKeyChooser->open();
+ }
+}
+
+void BtWindowInterface::referenceChanged() {
+ emit referenceChange();
+ updateModel();
+}
+
+const CSwordModuleInfo* BtWindowInterface::module() const {
+ const CSwordModuleInfo* module = m_key->module();
+ return module;
+}
+
+CSwordKey* BtWindowInterface::getKey() const {
+ return m_key;
+}
+
+int BtWindowInterface::getFontSize() const {
+ const CLanguageMgr::Language* lang = module()->language();
+ BtConfig::FontSettingsPair fontPair = btConfig().getFontForLanguage(*lang);
+ QFont font = fontPair.second;
+ return font.pointSize();
+}
+
+void BtWindowInterface::setFontSize(int size) {
+ const CLanguageMgr::Language* lang = module()->language();
+ BtConfig::FontSettingsPair fontPair = btConfig().getFontForLanguage(*lang);
+ fontPair.second.setPointSize(size);
+ btConfig().setFontForLanguage(*lang, fontPair);
+ emit textChanged();
+}
+
+QVariant BtWindowInterface::getTextModel() {
+ QVariant var;
+ var.setValue(m_textModel);
+ return var;
+}
+
+} // end namespace
diff --git a/src/mobile/ui/btwindowinterface.h b/src/mobile/ui/btwindowinterface.h
new file mode 100644
index 0000000..c6c31b0
--- /dev/null
+++ b/src/mobile/ui/btwindowinterface.h
@@ -0,0 +1,73 @@
+#ifndef BT_WINDOW_INTERFACE_H
+#define BT_WINDOW_INTERFACE_H
+
+#include <QObject>
+#include <QString>
+#include "mobile/models/roleitemmodel.h"
+#include "mobile/models/bibletextmodelbuilder.h"
+#include "mobile/models/booktextmodelbuilder.h"
+
+class CSwordKey;
+class CSwordVerseKey;
+class CSwordModuleInfo;
+
+namespace btm {
+
+class BookKeyChooser;
+class VerseChooser;
+
+class BtWindowInterface : public QObject {
+
+ Q_OBJECT
+
+ Q_PROPERTY(QString moduleName READ getModuleName WRITE setModuleName NOTIFY moduleChanged)
+ Q_PROPERTY(QString reference READ getReference NOTIFY referenceChange)
+ Q_PROPERTY(int fontSize READ getFontSize WRITE setFontSize NOTIFY textChanged)
+ Q_PROPERTY(QVariant textModel READ getTextModel NOTIFY textModelChanged)
+ Q_PROPERTY(int currentModelIndex READ getCurrentModelIndex NOTIFY currentModelIndexChanged)
+
+public:
+ Q_INVOKABLE void changeModule();
+ Q_INVOKABLE void changeReference();
+
+ BtWindowInterface(QObject *parent = 0);
+
+ CSwordKey* getKey() const;
+
+ QString getModuleName() const;
+ void setModuleName(const QString& moduleName);
+
+ QString getReference() const;
+
+ int getCurrentModelIndex() const;
+
+ int getFontSize() const;
+ void setFontSize(int size);
+
+ QVariant getTextModel();
+
+signals:
+ void referenceChange();
+ void moduleChanged();
+ void textChanged();
+ void textModelChanged();
+ void currentModelIndexChanged();
+
+private slots:
+ void referenceChanged();
+
+private:
+ const CSwordModuleInfo* module() const;
+ void updateModel();
+
+ CSwordKey* m_key;
+ RoleItemModel* m_textModel;
+ BookKeyChooser* m_bookKeyChooser;
+ VerseChooser* m_verseKeyChooser;
+ BibleTextModelBuilder m_bibleTextModelBuilder;
+ BookTextModelBuilder m_bookTextModelBuilder;
+};
+
+} // end namespace
+
+#endif
diff --git a/src/mobile/ui/gridchooser.cpp b/src/mobile/ui/gridchooser.cpp
new file mode 100644
index 0000000..3836b18
--- /dev/null
+++ b/src/mobile/ui/gridchooser.cpp
@@ -0,0 +1,63 @@
+
+#include "gridchooser.h"
+
+#include "qtquick2applicationviewer.h"
+
+#include <algorithm>
+#include <cmath>
+#include <QEventLoop>
+#include <QQuickItem>
+#include <QQmlContext>
+#include <QDebug>
+#include <QCoreApplication>
+
+namespace btm {
+
+GridChooser::GridChooser(QtQuick2ApplicationViewer* viewer)
+ : viewer_(viewer),
+ gridChooserObject_(0) {
+ QQuickItem * rootObject = viewer_->rootObject();
+ if (rootObject != 0)
+ gridChooserObject_ = rootObject->findChild<QQuickItem*>("gridChooser");
+}
+
+GridChooser::~GridChooser() {
+}
+
+void GridChooser::open(const QStringList& stringList, const QString& highlight, const QString& title) {
+ Q_ASSERT(gridChooserObject_ != 0);
+ if (gridChooserObject_ == 0)
+ return;
+
+ gridChooserObject_->disconnect();
+ bool ok = connect(gridChooserObject_, SIGNAL(accepted(QString)),
+ this, SLOT(gridChooserAccepted(QString)));
+ Q_ASSERT(ok);
+ setProperties(stringList, highlight, title);
+}
+
+void GridChooser::setProperties(const QStringList& list, const QString& hightlight, const QString& title) {
+ QQmlContext* ctx = viewer_->rootContext();
+ ctx->setContextProperty("gridChooserModel",list);
+ gridChooserObject_->setProperty("selected",hightlight);
+ gridChooserObject_->setProperty("titleText",title);
+
+ int maxLength = 0;
+ for (int i = 0; i < list.count(); ++i) {
+ QString text = list.at(i);
+ maxLength = std::max(maxLength, text.length());
+ }
+ gridChooserObject_->setProperty("maxLength", maxLength);
+
+ gridChooserObject_->setProperty("visible",true);
+}
+
+void GridChooser::gridChooserAccepted(QString value) {
+ emit accepted(value);
+}
+
+void GridChooser::gridChooserCanceled() {
+ emit canceled();
+}
+
+} // end namespace
diff --git a/src/mobile/ui/gridchooser.h b/src/mobile/ui/gridchooser.h
new file mode 100644
index 0000000..8200f91
--- /dev/null
+++ b/src/mobile/ui/gridchooser.h
@@ -0,0 +1,43 @@
+#ifndef GRID_CHOOSER_H
+#define GRID_CHOOSER_H
+
+#include <QEventLoop>
+#include <QObject>
+#include <QList>
+
+class QtQuick2ApplicationViewer;
+class QQuickItem;
+class QStringList;
+class QEventLoop;
+
+namespace btm {
+
+class BtWindowInterface;
+
+class GridChooser : public QObject {
+ Q_OBJECT
+
+public:
+ GridChooser(QtQuick2ApplicationViewer* viewer);
+ ~GridChooser();
+ void open(const QStringList& stringList, const QString& highlight = QString(), const QString& title = QString());
+
+signals:
+ void accepted(const QString& value);
+ void canceled();
+
+private slots:
+ void gridChooserAccepted(QString value);
+ void gridChooserCanceled();
+
+private:
+ void setProperties(const QStringList& list, const QString& hightlight, const QString& title);
+
+ QtQuick2ApplicationViewer* viewer_;
+ QQuickItem* gridChooserObject_;
+ QEventLoop eventLoop_;
+};
+
+} // end namespace
+
+#endif
diff --git a/src/mobile/ui/modulechooser.cpp b/src/mobile/ui/modulechooser.cpp
new file mode 100644
index 0000000..bc3d582
--- /dev/null
+++ b/src/mobile/ui/modulechooser.cpp
@@ -0,0 +1,44 @@
+
+#include "modulechooser.h"
+
+#include "qtquick2applicationviewer.h"
+
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+#include "backend/managers/cswordbackend.h"
+#include <cmath>
+#include <QQuickItem>
+#include <QQmlProperty>
+#include "btwindowinterface.h"
+#include "mobile/util/findqmlobject.h"
+
+namespace btm {
+
+ModuleChooser::ModuleChooser(QtQuick2ApplicationViewer* viewer, BtWindowInterface* bibleVerse)
+ : viewer_(viewer),
+ bibleVerse_(bibleVerse) {
+}
+
+void ModuleChooser::open() {
+ QQuickItem* item = findQmlObject("moduleChooser");
+ Q_ASSERT(item != 0);
+ if (item == 0)
+ return;
+
+ item->setProperty("visible", true);
+ bool ok = connect(item, SIGNAL(moduleSelected()), this, SLOT(moduleSelectedSlot()));
+ Q_ASSERT(ok);
+}
+
+void ModuleChooser::moduleSelectedSlot() {
+ QQuickItem* item = findQmlObject("moduleChooser");
+ Q_ASSERT(item != 0);
+ if (item == 0)
+ return;
+
+ item->setProperty("visible", false);
+ QVariant v = item->property("selectedModule");
+ QString moduleName = v.toString();
+ bibleVerse_->setModuleName(moduleName);
+}
+
+} // end namespace
diff --git a/src/mobile/ui/modulechooser.h b/src/mobile/ui/modulechooser.h
new file mode 100644
index 0000000..4e261f9
--- /dev/null
+++ b/src/mobile/ui/modulechooser.h
@@ -0,0 +1,35 @@
+#ifndef MODULE_CHOOSER_H
+#define MODULE_CHOOSER_H
+
+#include <QObject>
+
+class QtQuick2ApplicationViewer;
+class QStringList;
+
+namespace btm {
+
+class GridChooser;
+
+class BtWindowInterface;
+
+class ModuleChooser : public QObject {
+ Q_OBJECT
+
+public:
+ ModuleChooser(QtQuick2ApplicationViewer* viewer, BtWindowInterface* bibleVerse);
+ void open();
+
+private slots:
+ void moduleSelectedSlot();
+
+private:
+ void showGridChooser(const QStringList& list);
+ void setProperties(const QStringList& list);
+
+ QtQuick2ApplicationViewer* viewer_;
+ BtWindowInterface* bibleVerse_;
+};
+
+} // end namespace
+
+#endif
diff --git a/src/mobile/ui/moduleinterface.cpp b/src/mobile/ui/moduleinterface.cpp
new file mode 100644
index 0000000..4d898b4
--- /dev/null
+++ b/src/mobile/ui/moduleinterface.cpp
@@ -0,0 +1,187 @@
+
+#include "moduleinterface.h"
+
+#include "qtquick2applicationviewer.h"
+
+#include "backend/bookshelfmodel/btbookshelftreemodel.h"
+#include "backend/managers/cswordbackend.h"
+#include "mobile/util/findqmlobject.h"
+#include <cmath>
+#include <QQuickItem>
+#include <QQmlProperty>
+#include <QQmlContext>
+#include <QDebug>
+#include <QQmlProperty>
+#include <QCoreApplication>
+#include "btwindowinterface.h"
+#include "gridchooser.h"
+
+namespace btm {
+
+ModuleInterface::ModuleInterface() {
+}
+
+enum TextRoles {
+ TextRole = Qt::UserRole + 1
+};
+
+typedef BtBookshelfModel::ModuleRole MRole;
+static const MRole HR(BtBookshelfModel::ModuleHiddenRole);
+static const MRole PR(BtBookshelfModel::ModulePointerRole);
+static const MRole IR(BtBookshelfModel::ModuleHasIndexRole);
+static const MRole CR(BtBookshelfModel::ModuleCategoryRole);
+
+static void setupTextModel(const QSet<QString>& modelSet, RoleItemModel* model) {
+
+ QHash<int, QByteArray> roleNames;
+ roleNames[TextRole] = "modelText";
+ model->setRoleNames(roleNames);
+
+ QStringList modelList = modelSet.toList();
+ modelList.sort();
+
+ model->clear();
+ for (int i=0; i< modelList.count(); ++i) {
+ QString source = modelList.at(i);
+ QStandardItem* item = new QStandardItem();
+ item->setData(source, TextRole);
+ model->appendRow(item);
+ }
+}
+
+static CSwordModuleInfo* getModule(BtBookshelfModel* bookshelfModel, const QModelIndex& index) {
+ QVariant var = bookshelfModel->data(index, PR);
+ CSwordModuleInfo* module = static_cast<CSwordModuleInfo*>(var.value<void*>());
+ return module;
+}
+
+void ModuleInterface::updateCategoryAndLanguageModels() {
+ QQuickItem* object = findQmlObject("moduleChooser");
+ if (object == 0)
+ return;
+
+ getCategoriesAndLanguages();
+ setupTextModel(m_categories, &m_categoryModel);
+ setupTextModel(m_languages, &m_languageModel);
+ object->setProperty("categoryModel", QVariant::fromValue(&m_categoryModel));
+ object->setProperty("languageModel", QVariant::fromValue(&m_languageModel));
+}
+
+void ModuleInterface::getCategoriesAndLanguages() {
+
+ m_categories.clear();
+ m_languages.clear();
+
+ QQuickItem* object = findQmlObject("moduleChooser");
+ if (object == 0)
+ return;
+
+ BtBookshelfModel* bookshelfModel = CSwordBackend::instance()->model();
+ if (bookshelfModel == 0)
+ return;
+ int count = bookshelfModel->rowCount();
+ for (int row=0; row<count; ++row) {
+ QModelIndex index = bookshelfModel->index(row);
+ CSwordModuleInfo* module = getModule(bookshelfModel, index);
+ CSwordModuleInfo::Category category = module->category();
+ QString categoryName = module->categoryName(category);
+ const CLanguageMgr::Language* language = module->language();
+ QString languageName = language->translatedName();
+ m_categories.insert(categoryName);
+ m_languages.insert(languageName);
+ }
+}
+
+void ModuleInterface::updateWorksModel() {
+ m_worksModel.clear();
+ m_modules.clear();
+
+ QString currentLang = currentLanguage();
+ QString currentCat = currentCategory();
+
+ QHash<int, QByteArray> roleNames;
+ roleNames[TextRole] = "modelText";
+ m_worksModel.setRoleNames(roleNames);
+
+ BtBookshelfModel* bookshelfModel = CSwordBackend::instance()->model();
+ if (bookshelfModel == 0)
+ return;
+ int count = bookshelfModel->rowCount();
+ for (int row=0; row<count; ++row) {
+ QModelIndex index = bookshelfModel->index(row);
+ CSwordModuleInfo* module = getModule(bookshelfModel, index);
+ CSwordModuleInfo::Category category = module->category();
+ QString categoryName = module->categoryName(category);
+ const CLanguageMgr::Language* language = module->language();
+ QString languageName = language->translatedName();
+ if (languageName == currentLang &&
+ categoryName == currentCat) {
+ m_modules << module;
+ QString moduleName = module->name();
+ QStandardItem* item = new QStandardItem();
+ item->setData(moduleName, TextRole);
+ m_worksModel.appendRow(item);
+ }
+ }
+
+ QQuickItem* object = findQmlObject("moduleChooser");
+ if (object == 0)
+ return;
+ object->setProperty("worksModel", QVariant::fromValue(&m_worksModel));
+}
+
+QString ModuleInterface::currentLanguage() const {
+ QQuickItem* object = findQmlObject("moduleChooser");
+ if (object == 0)
+ return "";
+ int row = object->property("languageIndex").toInt();
+ QModelIndex modelIndex = m_languageModel.index(row,0);
+ QString language = modelIndex.data(TextRole).toString();
+ return language;
+
+}
+
+QString ModuleInterface::currentCategory() const {
+ QQuickItem* object = findQmlObject("moduleChooser");
+ if (object == 0)
+ return "";
+ int row = object->property("categoryIndex").toInt();
+ QModelIndex modelIndex = m_categoryModel.index(row,0);
+ QString category = modelIndex.data(TextRole).toString();
+ return category;
+}
+
+QString ModuleInterface::category(int index) {
+ if (index < 0 || index >= m_modules.count())
+ return "";
+ CSwordModuleInfo* module = m_modules.at(index);
+ if (module == 0)
+ return "";
+ CSwordModuleInfo::Category category = module->category();
+ if (category == 0)
+ return "";
+ return module->categoryName(category);
+}
+
+QString ModuleInterface::language(int index) {
+ if (index < 0 || index >= m_modules.count())
+ return "";
+ CSwordModuleInfo* module = m_modules.at(index);
+ if (module == 0)
+ return "";
+ const CLanguageMgr::Language* language = module->language();
+ if (language == 0)
+ return "";
+ return language->translatedName();
+}
+
+QString ModuleInterface::module(int index) {
+ if (index < 0 || index >= m_modules.count())
+ return "";
+ CSwordModuleInfo* module = m_modules.at(index);
+ if (module == 0)
+ return "";
+ return module->name();
+}
+
+} // end namespace
diff --git a/src/mobile/ui/moduleinterface.h b/src/mobile/ui/moduleinterface.h
new file mode 100644
index 0000000..165c30f
--- /dev/null
+++ b/src/mobile/ui/moduleinterface.h
@@ -0,0 +1,48 @@
+#ifndef MODULE_INTERFACE_H
+#define MODULE_INTERFACE_H
+
+#include "mobile/models/roleitemmodel.h"
+#include <QObject>
+#include <QList>
+#include <QSet>
+#include <QString>
+
+class QQuickItem;
+class QStringList;
+class CSwordModuleInfo;
+
+namespace btm {
+
+class GridChooser;
+
+class BtWindowInterface;
+
+class ModuleInterface : public QObject {
+ Q_OBJECT
+
+public:
+ ModuleInterface();
+ Q_INVOKABLE void updateCategoryAndLanguageModels();
+ Q_INVOKABLE void updateWorksModel();
+ Q_INVOKABLE QString category(int index);
+ Q_INVOKABLE QString language(int index);
+ Q_INVOKABLE QString module(int index);
+
+private:
+ void getCategoriesAndLanguages();
+ void setProperties(const QStringList& list);
+ QString currentLanguage() const;
+ QString currentCategory() const;
+
+ QSet<QString> m_categories;
+ QSet<QString> m_languages;
+ RoleItemModel m_categoryModel;
+ RoleItemModel m_languageModel;
+ RoleItemModel m_worksModel;
+ QList<CSwordModuleInfo*> m_modules;
+
+};
+
+} // end namespace
+
+#endif
diff --git a/src/mobile/ui/qtquick2applicationviewer.cpp b/src/mobile/ui/qtquick2applicationviewer.cpp
new file mode 100644
index 0000000..b6077d8
--- /dev/null
+++ b/src/mobile/ui/qtquick2applicationviewer.cpp
@@ -0,0 +1,63 @@
+// checksum 0x56a9 version 0x80001
+/*
+ This file was generated by the Qt Quick 2 Application wizard of Qt Creator.
+ QtQuick2ApplicationViewer is a convenience class containing mobile device specific
+ code such as screen orientation handling. Also QML paths and debugging are
+ handled here.
+ It is recommended not to modify this file, since newer versions of Qt Creator
+ may offer an updated version of it.
+*/
+
+#include "qtquick2applicationviewer.h"
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
+#include <QtQml/QQmlEngine>
+
+class QtQuick2ApplicationViewerPrivate {
+ QString mainQmlFile;
+ friend class QtQuick2ApplicationViewer;
+ static QString adjustPath(const QString &path);
+};
+
+QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path) {
+#if defined(Q_OS_MAC)
+ if (!QDir::isAbsolutePath(path))
+ return QString::fromLatin1("%1/../Resources/%2")
+ .arg(QCoreApplication::applicationDirPath(), path);
+#elif defined(Q_OS_UNIX)
+ const QString pathInInstallDir =
+ QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path);
+ if (QFileInfo(pathInInstallDir).exists())
+ return pathInInstallDir;
+#endif
+ return path;
+}
+
+QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent)
+ : QQuickView(parent)
+ , d(new QtQuick2ApplicationViewerPrivate()) {
+ connect(engine(), SIGNAL(quit()), SLOT(close()));
+ setResizeMode(QQuickView::SizeRootObjectToView);
+}
+
+QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer() {
+ delete d;
+}
+
+void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file) {
+ d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file);
+ setSource(QUrl::fromLocalFile(d->mainQmlFile));
+}
+
+void QtQuick2ApplicationViewer::addImportPath(const QString &path) {
+ engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path));
+}
+
+void QtQuick2ApplicationViewer::showExpanded() {
+#if defined(Q_WS_SIMULATOR)
+ showFullScreen();
+#else
+ show();
+#endif
+}
diff --git a/src/mobile/ui/qtquick2applicationviewer.h b/src/mobile/ui/qtquick2applicationviewer.h
new file mode 100644
index 0000000..a3db59d
--- /dev/null
+++ b/src/mobile/ui/qtquick2applicationviewer.h
@@ -0,0 +1,32 @@
+// checksum 0xfde6 version 0x80001
+/*
+ This file was generated by the Qt Quick 2 Application wizard of Qt Creator.
+ QtQuick2ApplicationViewer is a convenience class containing mobile device specific
+ code such as screen orientation handling. Also QML paths and debugging are
+ handled here.
+ It is recommended not to modify this file, since newer versions of Qt Creator
+ may offer an updated version of it.
+*/
+
+#ifndef QTQUICK2APPLICATIONVIEWER_H
+#define QTQUICK2APPLICATIONVIEWER_H
+
+#include <QtQuick/QQuickView>
+
+class QtQuick2ApplicationViewer : public QQuickView {
+ Q_OBJECT
+
+public:
+ explicit QtQuick2ApplicationViewer(QWindow *parent = 0);
+ virtual ~QtQuick2ApplicationViewer();
+
+ void setMainQmlFile(const QString &file);
+ void addImportPath(const QString &path);
+
+ void showExpanded();
+
+private:
+ class QtQuick2ApplicationViewerPrivate *d;
+};
+
+#endif // QTQUICK2APPLICATIONVIEWER_H
diff --git a/src/mobile/ui/treechoosermodel.cpp b/src/mobile/ui/treechoosermodel.cpp
new file mode 100644
index 0000000..cc5e2a7
--- /dev/null
+++ b/src/mobile/ui/treechoosermodel.cpp
@@ -0,0 +1,22 @@
+
+#include "treechoosermodel.h"
+
+
+TreeChooserModel::TreeChooserModel(QObject *parent)
+ : QAbstractListModel(parent)
+{
+}
+
+QHash<int, QByteArray> TreeChooserModel::roleNames() const {
+ QHash<int, QByteArray> roles;
+ roles[NameRole] = "name";
+ roles[ChildCountRole] = "childCount";
+ return roles;
+}
+
+void TreeChooserModel::addEntry(const QString& name, int childCount) {
+ int count = rowCount();
+ beginInsertRows(count, count);
+ insertRow(count);
+ endInsertRows();
+}
diff --git a/src/mobile/ui/treechoosermodel.h b/src/mobile/ui/treechoosermodel.h
new file mode 100644
index 0000000..c1575ae
--- /dev/null
+++ b/src/mobile/ui/treechoosermodel.h
@@ -0,0 +1,20 @@
+#ifndef TREE_CHOOSER_MODEL_H
+#define TREE_CHOOSER_MODEL_H
+
+#include <QAbstractItemModel>
+
+class TreeChooserModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ enum TreeEntryRoles {
+ NameRole = Qt::UserRole + 1,
+ ChildCountRole
+ };
+
+ TreeChooserModel(QObject *parent = 0);
+ QHash<int, QByteArray> TreeChooserModel::roleNames() const;
+
+};
+
+#endif
diff --git a/src/mobile/ui/viewmanager.cpp b/src/mobile/ui/viewmanager.cpp
new file mode 100644
index 0000000..041699a
--- /dev/null
+++ b/src/mobile/ui/viewmanager.cpp
@@ -0,0 +1,52 @@
+
+#include "viewmanager.h"
+
+#include "qtquick2applicationviewer.h"
+
+#include "btstyle.h"
+#include <cmath>
+#include <QGuiApplication>
+#include <QJsonValue>
+#include <QQuickItem>
+#include <QQmlProperty>
+#include <QQmlContext>
+#include <QUrl>
+#include <QDebug>
+
+namespace btm {
+
+static QString qmlFilePath(const QString& parentName, const QString& fileName) {
+ QString filePath = QCoreApplication::applicationDirPath() + "/../share/";
+ filePath += parentName + "/";
+ filePath += fileName;
+ return filePath;
+}
+
+ViewManager::ViewManager()
+ : viewer_(new QtQuick2ApplicationViewer()) {
+ BtStyle style;
+ style.setStyle(BtStyle::gnome);
+ initialize_string_list_chooser_model();
+ initialize_main_qml();
+}
+
+void ViewManager::initialize_string_list_chooser_model() {
+ QQmlContext* ctx = viewer_->rootContext();
+ QStringList list = QStringList();
+ ctx->setContextProperty("gridChooserModel",list);
+}
+
+void ViewManager::initialize_main_qml() {
+ QString mainQml = qmlFilePath("qml", "main.qml");
+ viewer_->setMainQmlFile(mainQml);
+}
+
+void ViewManager::show() {
+ viewer_->showExpanded();
+}
+
+QtQuick2ApplicationViewer* ViewManager::getViewer() const {
+ return viewer_;
+}
+
+} // end namespace
diff --git a/src/mobile/ui/viewmanager.h b/src/mobile/ui/viewmanager.h
new file mode 100644
index 0000000..7c50d35
--- /dev/null
+++ b/src/mobile/ui/viewmanager.h
@@ -0,0 +1,34 @@
+#ifndef VIEW_MANAGER_H
+#define VIEW_MANAGER_H
+
+#include <QObject>
+#include <QList>
+
+class QtQuick2ApplicationViewer;
+class QStringList;
+
+namespace btm {
+class BtWindowInterface;
+}
+
+namespace btm {
+
+class ViewManager : public QObject {
+ Q_OBJECT
+
+public:
+ ViewManager();
+
+ void show();
+ QtQuick2ApplicationViewer* getViewer() const;
+
+private:
+ void initialize_main_qml();
+ void initialize_string_list_chooser_model();
+
+ QtQuick2ApplicationViewer* viewer_;
+};
+
+} // end namespace
+
+#endif
diff --git a/src/mobile/util/findqmlobject.cpp b/src/mobile/util/findqmlobject.cpp
new file mode 100644
index 0000000..25a317c
--- /dev/null
+++ b/src/mobile/util/findqmlobject.cpp
@@ -0,0 +1,34 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "mobile/util/findqmlobject.h"
+#include <QQuickItem>
+#include "mobile/btmmain.h"
+#include "mobile/ui/qtquick2applicationviewer.h"
+#include "mobile/ui/viewmanager.h"
+
+namespace btm {
+
+QQuickItem* findQmlObject(const QString& objectName) {
+
+ QtQuick2ApplicationViewer* viewer = getViewManager()->getViewer();
+ QQuickItem * rootObject = 0;
+ if (viewer != 0)
+ rootObject = viewer->rootObject();
+ QQuickItem* object = 0;
+ if (rootObject != 0)
+ object = rootObject->findChild<QQuickItem*>(objectName);
+ Q_ASSERT(object != 0);
+ return object;
+}
+
+}
diff --git a/src/mobile/util/findqmlobject.h b/src/mobile/util/findqmlobject.h
new file mode 100644
index 0000000..bfbbcac
--- /dev/null
+++ b/src/mobile/util/findqmlobject.h
@@ -0,0 +1,28 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef FIND_QML_OBJECT
+#define FIND_QML_OBJECT
+
+#include <QString>
+
+class QQuickItem;
+
+namespace btm {
+
+// Finds the named QML object that is located at the
+// top level of the QML objects.
+QQuickItem* findQmlObject(const QString& objectName);
+
+}
+
+#endif
diff --git a/src/mobile/util/messagedialog.cpp b/src/mobile/util/messagedialog.cpp
new file mode 100644
index 0000000..a68857a
--- /dev/null
+++ b/src/mobile/util/messagedialog.cpp
@@ -0,0 +1,36 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "messagedialog.h"
+
+#include <QMessageBox>
+#include <QString>
+
+
+namespace message {
+
+int showWarning(QWidget * /*parent*/,
+ const QString & /*title*/,
+ const QString & /*text*/,
+ QMessageBox::StandardButtons /*buttons*/,
+ QMessageBox::StandardButton /*defaultButton*/) {
+ // TODO - implement showWarning
+ return 0;
+}
+
+int showQuestion(QWidget * /*parent*/,
+ const QString & /*title*/,
+ const QString & /*text*/,
+ QMessageBox::StandardButtons /*buttons*/,
+ QMessageBox::StandardButton /*defaultButton*/) {
+ // TODO - implement showQuestion
+ return 0;
+}
+
+} // namespace message
diff --git a/src/mobile/util/messagedialog.h b/src/mobile/util/messagedialog.h
new file mode 100644
index 0000000..d56b9ea
--- /dev/null
+++ b/src/mobile/util/messagedialog.h
@@ -0,0 +1,36 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef UTIL_DIALOG_UTIL_H
+#define UTIL_DIALOG_UTIL_H
+
+#include <QString>
+#include <QMessageBox>
+
+class QWidget;
+
+namespace message {
+
+int showWarning(QWidget * parent,
+ const QString & title,
+ const QString & text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
+
+int showQuestion(QWidget * parent,
+ const QString & title,
+ const QString & text,
+ QMessageBox::StandardButtons buttons = QMessageBox::Ok,
+ QMessageBox::StandardButton defaultButton = QMessageBox::NoButton);
+
+} // namespace message
+
+#endif
diff --git a/src/util/btmodules.cpp b/src/util/btmodules.cpp
index 784fd2a..7ba31c6 100644
--- a/src/util/btmodules.cpp
+++ b/src/util/btmodules.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/util/btmodules.h b/src/util/btmodules.h
index 2532e42..cb99d1c 100644
--- a/src/util/btmodules.h
+++ b/src/util/btmodules.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/util/btsignal.h b/src/util/btsignal.h
index 6f05226..a680311 100644
--- a/src/util/btsignal.h
+++ b/src/util/btsignal.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -23,23 +25,23 @@
* have the signals work. Certain multiple inheritance classes which cannot
* have QObject as the first derived class, cannot use Qt signals.
*/
-class BtSignal : public QObject {
- Q_OBJECT
-
- public:
- inline BtSignal(QObject *parent = 0) : QObject(parent) {};
-
- /**
- Immediately emits the beforeChanged() signal.
- */
- inline void emitBeforeChanged() { emit beforeChanged(); }
- /**
- Immediately emits the changed() signal.
- */
- inline void emitChanged() { emit changed(); }
-
- signals:
- void beforeChanged();
- void changed();
+class BtSignal: public QObject {
+
+ Q_OBJECT
+
+public:
+
+ inline BtSignal(QObject *parent = 0)
+ : QObject(parent) {}
+
+ /**
+ Immediately emits the beforeChanged() signal.
+ */
+ inline void emitSignal() { emit signal(); }
+
+signals:
+
+ void signal();
+
};
#endif
diff --git a/src/util/cresmgr.cpp b/src/util/cresmgr.cpp
index 908c5f3..a122039 100644
--- a/src/util/cresmgr.cpp
+++ b/src/util/cresmgr.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -221,6 +221,12 @@ const char* actionName = "tipOfTheDay_action";
}//mainMenu::help
} //end of mainMenu
+namespace findWidget {
+const QString close_icon = "stop.svg";
+const QString previous_icon = "back.svg";
+const QString next_icon = "forward.svg";
+}
+
namespace searchdialog {
const QString icon = "find.svg";
const QString close_icon = "stop.svg";
diff --git a/src/util/cresmgr.h b/src/util/cresmgr.h
index 89bcfa5..b09c9fa 100644
--- a/src/util/cresmgr.h
+++ b/src/util/cresmgr.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -227,6 +229,12 @@ extern const char* actionName;
}
} //end of main menu
+namespace findWidget {
+extern const QString close_icon;
+extern const QString previous_icon;
+extern const QString next_icon;
+}
+
namespace searchdialog {
extern const QString icon;
extern const QString close_icon;
diff --git a/src/util/directory.cpp b/src/util/directory.cpp
index ddbbaaf..6ce80b4 100644
--- a/src/util/directory.cpp
+++ b/src/util/directory.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -23,46 +23,45 @@ namespace directory {
namespace {
-QDir cachedIconDir;
-QDir cachedJavascriptDir;
-QDir cachedLicenseDir;
-QDir cachedPicsDir;
-QDir cachedLocaleDir;
-QDir cachedHandbookDir;
-QDir cachedHowtoDir;
-QDir cachedDisplayTemplatesDir;
-QDir cachedUserDisplayTemplatesDir;
-QDir cachedUserBaseDir;
-QDir cachedUserHomeDir;
-QDir cachedUserHomeSwordDir;
-QDir cachedUserHomeSwordModsDir;
-QDir cachedUserSessionsDir;
-QDir cachedUserCacheDir;
-QDir cachedUserIndexDir;
-QDir cachedSwordPathDir;
-#ifdef Q_WS_WIN
-QDir cachedApplicationSwordDir; // Only Windows installs the sword directory which contains locales.d
-QDir cachedSharedSwordDir;
+QScopedPointer<QDir> cachedIconDir;
+QScopedPointer<QDir> cachedJavascriptDir;
+QScopedPointer<QDir> cachedLicenseDir;
+QScopedPointer<QDir> cachedPicsDir;
+QScopedPointer<QDir> cachedLocaleDir;
+QScopedPointer<QDir> cachedHandbookDir;
+QScopedPointer<QDir> cachedHowtoDir;
+QScopedPointer<QDir> cachedDisplayTemplatesDir;
+QScopedPointer<QDir> cachedUserDisplayTemplatesDir;
+QScopedPointer<QDir> cachedUserBaseDir;
+QScopedPointer<QDir> cachedUserHomeDir;
+QScopedPointer<QDir> cachedUserHomeSwordDir;
+QScopedPointer<QDir> cachedUserHomeSwordModsDir;
+QScopedPointer<QDir> cachedUserSessionsDir;
+QScopedPointer<QDir> cachedUserCacheDir;
+QScopedPointer<QDir> cachedUserIndexDir;
+QScopedPointer<QDir> cachedSwordPathDir;
+#ifdef Q_OS_WIN
+QScopedPointer<QDir> cachedApplicationSwordDir; // Only Windows installs the sword directory which contains locales.d
+QScopedPointer<QDir> cachedSharedSwordDir;
#endif
-#ifdef Q_WS_MAC
-QDir cachedSwordLocalesDir;
+#ifdef Q_OS_MAC
+QScopedPointer<QDir> cachedSwordLocalesDir;
#endif
-#ifdef Q_WS_WIN
-static const char* BIBLETIME = "Bibletime";
-static const char* SWORD_DIR = "Sword";
+#ifdef Q_OS_WIN
+static const char BIBLETIME[] = "Bibletime";
+static const char SWORD_DIR[] = "Sword";
#else
-#ifdef Q_WS_MAC
-static const char* BIBLETIME = "Library/Application Support/BibleTime";
-static const char* SWORD_DIR = "Library/Application Support/Sword";
+#ifdef Q_OS_MAC
+static const char BIBLETIME[] = "Library/Application Support/BibleTime";
+static const char SWORD_DIR[] = "Library/Application Support/Sword";
#else
-static const char* BIBLETIME = ".bibletime";
-static const char* SWORD_DIR = ".sword";
+static const char BIBLETIME[] = ".bibletime";
+static const char SWORD_DIR[] = ".sword";
#endif
#endif
-static const char* SWORD_PATH = "SWORD_PATH";
-static const char* UNSET_SWORD_PATH = "SWORD_PATH=";
+static const char SWORD_PATH[] = "SWORD_PATH";
} // anonymous namespace
bool initDirectoryCache() {
@@ -74,155 +73,155 @@ bool initDirectoryCache() {
return false;
}
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
- cachedApplicationSwordDir = wDir; // application sword dir for Windows only
- if (!cachedApplicationSwordDir.cd("share/sword") || !cachedApplicationSwordDir.isReadable()) {
+ cachedApplicationSwordDir.reset(new QDir(wDir)); // application sword dir for Windows only
+ if (!cachedApplicationSwordDir->cd("share/sword") || !cachedApplicationSwordDir->isReadable()) {
qWarning() << "Cannot find sword directory relative to" << QCoreApplication::applicationDirPath();
return false;
}
- cachedSharedSwordDir = QDir(getenv("ALLUSERSPROFILE")); // sword dir for Windows only
- if (!cachedSharedSwordDir.cd("Application Data")) {
+ cachedSharedSwordDir.reset(new QDir(qgetenv("ALLUSERSPROFILE"))); // sword dir for Windows only
+ if (!cachedSharedSwordDir->cd("Application Data")) {
qWarning() << "Cannot find ALLUSERSPROFILE\\Application Data";
return false;
}
- if (!cachedSharedSwordDir.cd(SWORD_DIR)) {
- if (!cachedSharedSwordDir.mkdir(SWORD_DIR) || !cachedSharedSwordDir.cd(SWORD_DIR)) {
+ if (!cachedSharedSwordDir->cd(SWORD_DIR)) {
+ if (!cachedSharedSwordDir->mkdir(SWORD_DIR) || !cachedSharedSwordDir->cd(SWORD_DIR)) {
qWarning() << "Cannot find ALLUSERSPROFILE\\Application Data\\Sword";
return false;
}
}
#endif
-#ifdef Q_WS_MAC
- cachedSwordLocalesDir = wDir; // application sword dir for Windows only
- if (!cachedSwordLocalesDir.cd("share/sword/locales.d") || !cachedSwordLocalesDir.isReadable()) {
+#ifdef Q_OS_MAC
+ cachedSwordLocalesDir.reset(new QDir(wDir)); // application sword dir for Windows only
+ if (!cachedSwordLocalesDir->cd("share/sword/locales.d") || !cachedSwordLocalesDir->isReadable()) {
qWarning() << "Cannot find sword locales directory relative to" << QCoreApplication::applicationDirPath();
return false;
}
#endif
- cachedSwordPathDir = QDir();
- char* swordPath = getenv(SWORD_PATH);
+ cachedSwordPathDir.reset(new QDir(wDir));
+ char* swordPath = qgetenv(SWORD_PATH).data();
if (swordPath != 0) {
- cachedSwordPathDir = QDir(swordPath);
+ cachedSwordPathDir.reset(new QDir(swordPath));
// We unset the SWORD_PATH so libsword finds paths correctly
- putenv((char*)UNSET_SWORD_PATH);
+ qputenv(SWORD_PATH, "");
}
- cachedIconDir = wDir; // Icon dir
- if (!cachedIconDir.cd("share/bibletime/icons") || !cachedIconDir.isReadable()) {
- qWarning() << "Cannot find icon directory relative to" << QCoreApplication::applicationDirPath();
+ cachedIconDir.reset(new QDir(wDir)); // Icon dir
+ if (!cachedIconDir->cd("share/bibletime/icons") || !cachedIconDir->isReadable()) {
+ qWarning() << "Cannot find icon directory relative to" << wDir.absolutePath();
return false;
}
- cachedJavascriptDir = wDir;
- if (!cachedJavascriptDir.cd("share/bibletime/javascript") || !cachedJavascriptDir.isReadable()) {
- qWarning() << "Cannot find javascript directory relative to" << QCoreApplication::applicationDirPath();
+ cachedJavascriptDir.reset(new QDir(wDir));
+ if (!cachedJavascriptDir->cd("share/bibletime/javascript") || !cachedJavascriptDir->isReadable()) {
+ qWarning() << "Cannot find javascript directory relative to" << wDir.absolutePath();
return false;
}
- cachedLicenseDir = wDir;
- if (!cachedLicenseDir.cd("share/bibletime/license") || !cachedLicenseDir.isReadable()) {
- qWarning() << "Cannot find license directory relative to" << QCoreApplication::applicationDirPath();
+ cachedLicenseDir.reset(new QDir(wDir));
+ if (!cachedLicenseDir->cd("share/bibletime/license") || !cachedLicenseDir->isReadable()) {
+ qWarning() << "Cannot find license directory relative to" << wDir.absolutePath();
return false;
}
- cachedPicsDir = wDir; //icon dir
- if (!cachedPicsDir.cd("share/bibletime/pics") || !cachedPicsDir.isReadable()) {
- qWarning() << "Cannot find icon directory relative to" << QCoreApplication::applicationDirPath();
+ cachedPicsDir.reset(new QDir(wDir));
+ if (!cachedPicsDir->cd("share/bibletime/pics") || !cachedPicsDir->isReadable()) {
+ qWarning() << "Cannot find pics directory relative to" << wDir.absolutePath();
return false;
}
- cachedLocaleDir = wDir;
- if (!cachedLocaleDir.cd("share/bibletime/locale")) {
- qWarning() << "Cannot find locale directory relative to" << QCoreApplication::applicationDirPath();
+ cachedLocaleDir.reset(new QDir(wDir));
+ if (!cachedLocaleDir->cd("share/bibletime/locale")) {
+ qWarning() << "Cannot find locale directory relative to" << wDir.absolutePath();
return false;
}
QString localeName(QLocale::system().name());
QString langCode(localeName.section('_', 0, 0));
- cachedHandbookDir = wDir;
- if (!cachedHandbookDir.cd("share/bibletime/docs/handbook/" + localeName)) {
- if (!cachedHandbookDir.cd("share/bibletime/docs/handbook/" + langCode)) {
- if (!cachedHandbookDir.cd("share/bibletime/docs/handbook/en/")) {
- qWarning() << "Cannot find handbook directory relative to" << QCoreApplication::applicationDirPath();
+ cachedHandbookDir.reset(new QDir(wDir));
+ if (!cachedHandbookDir->cd("share/bibletime/docs/handbook/" + localeName)) {
+ if (!cachedHandbookDir->cd("share/bibletime/docs/handbook/" + langCode)) {
+ if (!cachedHandbookDir->cd("share/bibletime/docs/handbook/en/")) {
+ qWarning() << "Cannot find handbook directory relative to" << wDir.absolutePath();
return false;
}
}
}
- cachedHowtoDir = wDir;
- if (!cachedHowtoDir.cd("share/bibletime/docs/howto/" + localeName)) {
- if (!cachedHowtoDir.cd("share/bibletime/docs/howto/" + langCode)) {
- if (!cachedHowtoDir.cd("share/bibletime/docs/howto/en/")) {
- qWarning() << "Cannot find handbook directory relative to" << QCoreApplication::applicationDirPath();
+ cachedHowtoDir.reset(new QDir(wDir));
+ if (!cachedHowtoDir->cd("share/bibletime/docs/howto/" + localeName)) {
+ if (!cachedHowtoDir->cd("share/bibletime/docs/howto/" + langCode)) {
+ if (!cachedHowtoDir->cd("share/bibletime/docs/howto/en/")) {
+ qWarning() << "Cannot find handbook directory relative to" << wDir.absolutePath();
return false;
}
}
}
- cachedDisplayTemplatesDir = wDir; //display templates dir
- if (!cachedDisplayTemplatesDir.cd("share/bibletime/display-templates/")) {
- qWarning() << "Cannot find display template directory relative to" << QCoreApplication::applicationDirPath();
+ cachedDisplayTemplatesDir.reset(new QDir(wDir)); //display templates dir
+ if (!cachedDisplayTemplatesDir->cd("share/bibletime/display-templates/")) {
+ qWarning() << "Cannot find display template directory relative to" << wDir.absolutePath();
return false;
}
- cachedUserHomeDir = QDir(getenv("HOME"));
+ cachedUserHomeDir.reset(new QDir(qgetenv("HOME")));
- cachedUserBaseDir = cachedUserHomeDir;
- if (!cachedUserBaseDir.cd(BIBLETIME)) {
- if (!cachedUserBaseDir.mkpath(BIBLETIME) || !cachedUserBaseDir.cd(BIBLETIME)) {
- qWarning() << "Could not create user setting directory.";
+ cachedUserBaseDir.reset(new QDir(*cachedUserHomeDir));
+ if (!cachedUserBaseDir->cd(BIBLETIME)) {
+ if (!cachedUserBaseDir->mkpath(BIBLETIME) || !cachedUserBaseDir->cd(BIBLETIME)) {
+ qWarning() << "Could not create user settings directory relative to" << cachedUserHomeDir->absolutePath();
return false;
}
}
- cachedUserHomeSwordDir = cachedUserHomeDir;
- if (!cachedUserHomeSwordDir.cd(SWORD_DIR)) {
- if (!cachedUserHomeSwordDir.mkpath(SWORD_DIR) || !cachedUserHomeSwordDir.cd(SWORD_DIR)) {
+ cachedUserHomeSwordDir.reset(new QDir(*cachedUserHomeDir));
+ if (!cachedUserHomeSwordDir->cd(SWORD_DIR)) {
+ if (!cachedUserHomeSwordDir->mkpath(SWORD_DIR) || !cachedUserHomeSwordDir->cd(SWORD_DIR)) {
qWarning() << "Could not create user home " << SWORD_DIR << " directory.";
return false;
}
}
- cachedUserHomeSwordModsDir = cachedUserHomeSwordDir;
- if (!cachedUserHomeSwordModsDir.cd("mods.d")) {
- if (!cachedUserHomeSwordModsDir.mkdir("mods.d") || !cachedUserHomeSwordModsDir.cd("mods.d")) {
+ cachedUserHomeSwordModsDir.reset(new QDir(*cachedUserHomeSwordDir));
+ if (!cachedUserHomeSwordModsDir->cd("mods.d")) {
+ if (!cachedUserHomeSwordModsDir->mkdir("mods.d") || !cachedUserHomeSwordModsDir->cd("mods.d")) {
qWarning() << "Could not create user home " << SWORD_DIR << " mods.d directory.";
return false;
}
}
- cachedUserSessionsDir = cachedUserBaseDir;
- if (!cachedUserSessionsDir.cd("sessions")) {
- if (!cachedUserSessionsDir.mkdir("sessions") || !cachedUserSessionsDir.cd("sessions")) {
+ cachedUserSessionsDir.reset(new QDir(*cachedUserBaseDir));
+ if (!cachedUserSessionsDir->cd("sessions")) {
+ if (!cachedUserSessionsDir->mkdir("sessions") || !cachedUserSessionsDir->cd("sessions")) {
qWarning() << "Could not create user sessions directory.";
return false;
}
}
- cachedUserCacheDir = cachedUserBaseDir;
- if (!cachedUserCacheDir.cd("cache")) {
- if (!cachedUserCacheDir.mkdir("cache") || !cachedUserCacheDir.cd("cache")) {
+ cachedUserCacheDir.reset(new QDir(*cachedUserBaseDir));
+ if (!cachedUserCacheDir->cd("cache")) {
+ if (!cachedUserCacheDir->mkdir("cache") || !cachedUserCacheDir->cd("cache")) {
qWarning() << "Could not create user cache directory.";
return false;
}
}
- cachedUserIndexDir = cachedUserBaseDir;
- if (!cachedUserIndexDir.cd("indices")) {
- if (!cachedUserIndexDir.mkdir("indices") || !cachedUserIndexDir.cd("indices")) {
+ cachedUserIndexDir.reset(new QDir(*cachedUserBaseDir));
+ if (!cachedUserIndexDir->cd("indices")) {
+ if (!cachedUserIndexDir->mkdir("indices") || !cachedUserIndexDir->cd("indices")) {
qWarning() << "Could not create user indices directory.";
return false;
}
}
- cachedUserDisplayTemplatesDir = cachedUserBaseDir;
- if (!cachedUserDisplayTemplatesDir.cd("display-templates")) {
- if (!cachedUserDisplayTemplatesDir.mkdir("display-templates") || !cachedUserDisplayTemplatesDir.cd("display-templates")) {
+ cachedUserDisplayTemplatesDir.reset(new QDir(*cachedUserBaseDir));
+ if (!cachedUserDisplayTemplatesDir->cd("display-templates")) {
+ if (!cachedUserDisplayTemplatesDir->mkdir("display-templates") || !cachedUserDisplayTemplatesDir->cd("display-templates")) {
qWarning() << "Could not create user display templates directory.";
return false;
}
@@ -240,14 +239,14 @@ void removeRecursive(const QString &dir) {
//remove all files in this dir
d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
const QFileInfoList fileList = d.entryInfoList();
- for (QFileInfoList::const_iterator it_file = fileList.begin(); it_file != fileList.end(); it_file++) {
+ for (QFileInfoList::const_iterator it_file = fileList.begin(); it_file != fileList.end(); ++it_file) {
d.remove( it_file->fileName() );
}
//remove all subdirs recursively
d.setFilter( QDir::Dirs | QDir::NoSymLinks );
const QFileInfoList dirList = d.entryInfoList();
- for (QFileInfoList::const_iterator it_dir = dirList.begin(); it_dir != dirList.end(); it_dir++) {
+ for (QFileInfoList::const_iterator it_dir = dirList.begin(); it_dir != dirList.end(); ++it_dir) {
if ( !it_dir->isDir() || it_dir->fileName() == "." || it_dir->fileName() == ".." ) {
continue;
}
@@ -268,14 +267,14 @@ unsigned long getDirSizeRecursive(const QString &dir) {
//First get the size of all files int this folder
d.setFilter(QDir::Files);
const QFileInfoList infoList = d.entryInfoList();
- for (QFileInfoList::const_iterator it = infoList.begin(); it != infoList.end(); it++) {
+ for (QFileInfoList::const_iterator it = infoList.begin(); it != infoList.end(); ++it) {
size += it->size();
}
//Then add the sizes of all subdirectories
d.setFilter(QDir::Dirs);
const QFileInfoList dirInfoList = d.entryInfoList();
- for (QFileInfoList::const_iterator it_dir = dirInfoList.begin(); it_dir != dirInfoList.end(); it_dir++) {
+ for (QFileInfoList::const_iterator it_dir = dirInfoList.begin(); it_dir != dirInfoList.end(); ++it_dir) {
if ( !it_dir->isDir() || it_dir->fileName() == "." || it_dir->fileName() == ".." ) {
continue;
}
@@ -309,7 +308,7 @@ void copyRecursive(const QString &src, const QString &dest) {
QString convertDirSeparators(const QString& path) {
QString result = path;
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
result.replace("/", "\\");
#else
result.replace("\\", "/");
@@ -317,127 +316,89 @@ QString convertDirSeparators(const QString& path) {
return result;
}
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
const QDir &getApplicationSwordDir() {
- return cachedApplicationSwordDir;
+ return *cachedApplicationSwordDir;
}
const QDir &getSharedSwordDir() {
- return cachedSharedSwordDir;
+ return *cachedSharedSwordDir;
}
#endif
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
const QDir &getSwordLocalesDir() {
- return cachedSwordLocalesDir;
+ return *cachedSwordLocalesDir;
}
#endif
const QDir &getSwordPathDir() {
- return cachedSwordPathDir;
+ return *cachedSwordPathDir;
}
const QDir &getIconDir() {
- return cachedIconDir;
+ return *cachedIconDir;
}
const QDir &getJavascriptDir() {
- return cachedJavascriptDir;
+ return *cachedJavascriptDir;
}
const QDir &getLicenseDir() {
- return cachedLicenseDir;
-}
-
-const QIcon &getIcon(const QString &name) {
- static QMap<QString, QIcon> iconCache;
- static QIcon nullIcon;
-
- QString plainName = name;
- if (plainName.endsWith(".svg", Qt::CaseInsensitive)) {
- plainName.chop(4);
- }
-
- QMap<QString, QIcon>::const_iterator i = iconCache.find(plainName);
- if (i != iconCache.end()) {
- return *i;
- }
-
- QString iconDir = getIconDir().canonicalPath();
- QString iconFileName = iconDir + "/" + plainName + ".svg";
- if (QFile(iconFileName).exists()) {
- return *iconCache.insert(plainName, QIcon(iconFileName));
- }
- else {
- iconFileName = iconDir + "/" + plainName + ".png";
- if (QFile(iconFileName).exists()) {
- return *iconCache.insert(plainName, QIcon(iconFileName));
- }
- else {
- if (plainName != "default") {
- qWarning() << "Cannot find icon file" << iconFileName
- << ", using default icon.";
- return getIcon("default");
- } else {
- qWarning() << "Cannot find default icon" << iconFileName
- << ", using null icon.";
- return nullIcon;
- }
- }
- }
+ return *cachedLicenseDir;
}
const QDir &getPicsDir() {
- return cachedPicsDir;
+ return *cachedPicsDir;
}
const QDir &getLocaleDir() {
- return cachedLocaleDir;
+ return *cachedLocaleDir;
}
const QDir &getHandbookDir() {
- return cachedHandbookDir;
+ return *cachedHandbookDir;
}
const QDir &getHowtoDir() {
- return cachedHowtoDir;
+ return *cachedHowtoDir;
}
const QDir &getDisplayTemplatesDir() {
- return cachedDisplayTemplatesDir;
+ return *cachedDisplayTemplatesDir;
}
const QDir &getUserBaseDir() {
- return cachedUserBaseDir;
+ return *cachedUserBaseDir;
}
const QDir &getUserHomeDir() {
- return cachedUserHomeDir;
+ return *cachedUserHomeDir;
}
const QDir &getUserHomeSwordDir() {
- return cachedUserHomeSwordDir;
+ return *cachedUserHomeSwordDir;
}
const QDir &getUserHomeSwordModsDir() {
- return cachedUserHomeSwordModsDir;
+ return *cachedUserHomeSwordModsDir;
}
const QDir &getUserSessionsDir() {
- return cachedUserSessionsDir;
+ return *cachedUserSessionsDir;
}
const QDir &getUserCacheDir() {
- return cachedUserCacheDir;
+ return *cachedUserCacheDir;
}
const QDir &getUserIndexDir() {
- return cachedUserIndexDir;
+ return *cachedUserIndexDir;
}
const QDir &getUserDisplayTemplatesDir() {
- return cachedUserDisplayTemplatesDir;
+ return *cachedUserDisplayTemplatesDir;
}
} // namespace directory
diff --git a/src/util/directory.h b/src/util/directory.h
index 6b64759..447cabf 100644
--- a/src/util/directory.h
+++ b/src/util/directory.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -60,7 +62,7 @@ void copyRecursive(const QString &src, const QString &dest);
*/
QString convertDirSeparators(const QString& path);
-#ifdef Q_WS_WIN // Windows only directories
+#ifdef Q_OS_WIN // Windows only directories
/** Return the path to the sword dir., Windows only
C:\Program Files\BibleTime\share\sword
@@ -72,7 +74,7 @@ const QDir &getSharedSwordDir();
#endif
-#ifdef Q_WS_MAC // Mac only directories
+#ifdef Q_OS_MAC // Mac only directories
/**
* Path to the Sword locales
@@ -93,9 +95,6 @@ const QDir &getJavascriptDir();
/** Return the path to the license. */
const QDir &getLicenseDir();
-/** Returns an icon with the given name */
-const QIcon &getIcon(const QString &name);
-
/** Return the path to the pictures. */
const QDir &getPicsDir();
diff --git a/src/util/exceptions.h b/src/util/exceptions.h
index d89ba06..3084ff8 100644
--- a/src/util/exceptions.h
+++ b/src/util/exceptions.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/util/geticon.cpp b/src/util/geticon.cpp
new file mode 100644
index 0000000..5658798
--- /dev/null
+++ b/src/util/geticon.cpp
@@ -0,0 +1,54 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "geticon.h"
+
+#include <QDebug>
+#include <QFile>
+#include <QMap>
+#include "util/directory.h"
+
+namespace util {
+
+static QMap<QString, QIcon> iconCache;
+static const QIcon nullIcon;
+
+const QIcon& getIcon(const QString & name) {
+ QString plainName(name);
+ if (plainName.endsWith(".svg", Qt::CaseInsensitive))
+ plainName.chop(4);
+
+ const QMap<QString, QIcon>::const_iterator i = iconCache.find(plainName);
+ if (i != iconCache.end())
+ return *i;
+
+ const QString iconDir = util::directory::getIconDir().canonicalPath();
+ QString iconFileName = iconDir + "/" + plainName + ".svg";
+ if (QFile(iconFileName).exists())
+ return *iconCache.insert(plainName, QIcon(iconFileName));
+
+ iconFileName = iconDir + "/" + plainName + ".png";
+ if (QFile(iconFileName).exists())
+ return *iconCache.insert(plainName, QIcon(iconFileName));
+
+ if (plainName != "default") {
+ qWarning() << "Cannot find icon file" << iconFileName
+ << ", using default icon.";
+ return getIcon("default");
+ }
+
+ qWarning() << "Cannot find default icon" << iconFileName
+ << ", using null icon.";
+ return nullIcon;
+}
+
+void clearIconCache() {
+ iconCache.clear();
+}
+}
diff --git a/src/util/geticon.h b/src/util/geticon.h
new file mode 100644
index 0000000..97a8c84
--- /dev/null
+++ b/src/util/geticon.h
@@ -0,0 +1,30 @@
+/*********
+*
+* 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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef GETICON_H
+#define GETICON_H
+
+#include <QIcon>
+#include <QString>
+
+namespace util {
+
+ /**
+ \param[in] name the name of the icon to return.
+ \returns a reference to the icon with the given name or to a NULL
+ icon if no such icon is found.
+ */
+ const QIcon & getIcon(const QString & name);
+
+ void clearIconCache();
+}
+
+#endif
diff --git a/src/util/htmlescape.h b/src/util/htmlescape.h
new file mode 100644
index 0000000..875cfaa
--- /dev/null
+++ b/src/util/htmlescape.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-2014 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef UTIL_HTMLESCAPE_H
+#define UTIL_HTMLESCAPE_H
+
+#include <QString>
+#if QT_VERSION < 0x050000
+#include <QTextDocument>
+#endif
+
+
+namespace util {
+
+inline QString htmlEscape(const QString & str) {
+#if QT_VERSION < 0x050000
+ return Qt::escape(str);
+#else
+ return str.toHtmlEscaped();
+#endif
+}
+
+} /* namespace util { */
+
+#endif /* UTIL_HTMLESCAPE_H */
diff --git a/src/util/macros.h b/src/util/macros.h
index aa451fd..853d5c7 100644
--- a/src/util/macros.h
+++ b/src/util/macros.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
diff --git a/src/util/tool.cpp b/src/util/tool.cpp
index b8ee486..ca8024a 100644
--- a/src/util/tool.cpp
+++ b/src/util/tool.cpp
@@ -2,7 +2,7 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2011 by the BibleTime developers.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -18,25 +18,38 @@
#include <QWidget>
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
+#include "bibletimeapp.h"
+#include "frontend/messagedialog.h"
#include "util/cresmgr.h"
#include "util/directory.h"
-#include "util/dialogutil.h"
+#include "util/geticon.h"
+
+
+namespace util {
+namespace tool {
/** Creates the file filename and put text into the file.
*/
-bool util::tool::savePlainFile( const QString& filename, const QString& text, const bool& forceOverwrite, QTextCodec* fileCodec) {
+bool savePlainFile(const QString & filename,
+ const QString & text,
+ const bool forceOverwrite,
+ QTextCodec * const fileCodec)
+{
+ Q_ASSERT(fileCodec);
+ Q_ASSERT(!filename.isEmpty());
+
QFile saveFile(filename);
- bool ret;
if (saveFile.exists()) {
- if (!forceOverwrite && util::showQuestion(0, QObject::tr("Overwrite File?"),
+ if (!forceOverwrite
+ && message::showQuestion(0, QObject::tr("Overwrite File?"),
QString::fromLatin1("<qt><b>%1</b><br/>%2</qt>")
.arg( QObject::tr("The file already exists.") )
.arg( QObject::tr("Do you want to overwrite it?")),
QMessageBox::Yes | QMessageBox::No,
- QMessageBox::No) == QMessageBox::No
- ) {
+ QMessageBox::No) == QMessageBox::No)
+ {
return false;
}
else { //either the user chose yes or forceOverwrite is set
@@ -44,37 +57,42 @@ bool util::tool::savePlainFile( const QString& filename, const QString& text, co
}
}
- if ( saveFile.open(QIODevice::ReadWrite) ) {
- QTextStream textstream( &saveFile );
+ if (saveFile.open(QIODevice::ReadWrite)) {
+ QTextStream textstream(&saveFile);
textstream.setCodec(fileCodec);
textstream << text;
+ textstream.flush();
saveFile.close();
- ret = true;
+ if (saveFile.error() == QFile::NoError)
+ return true;
+
+ QMessageBox::critical(0, QObject::tr("Error"),
+ QString::fromLatin1("<qt>%1<br/><b>%2</b></qt>")
+ .arg(QObject::tr("Error while writing to file."))
+ .arg(QObject::tr("Please check that enough disk space is available.")));
}
else {
QMessageBox::critical(0, QObject::tr("Error"),
QString::fromLatin1("<qt>%1<br/><b>%2</b></qt>")
- .arg( QObject::tr("The file couldn't be saved.") )
- .arg( QObject::tr("Please check permissions etc.")));
- saveFile.close();
- ret = false;
+ .arg(QObject::tr("The file couldn't be opened for saving."))
+ .arg(QObject::tr("Please check permissions etc.")));
}
- return ret;
+
+ return false;
}
-QIcon util::tool::getIconForModule(const CSwordModuleInfo *module) {
- namespace DU = util::directory;
- return DU::getIcon(getIconNameForModule(module));
+QIcon getIconForModule(const CSwordModuleInfo * const module) {
+ return util::getIcon(getIconNameForModule(module));
}
-QString util::tool::getIconNameForModule(const CSwordModuleInfo *module) {
+QString getIconNameForModule(const CSwordModuleInfo * const module) {
//qDebug() << "util::tool::getIconNameForModule";
- if (!module) return CResMgr::modules::book::icon_locked;
+ if (!module)
+ return CResMgr::modules::book::icon_locked;
- if (module->category() == CSwordModuleInfo::Cult) {
+ if (module->category() == CSwordModuleInfo::Cult)
return "stop.svg";
- }
switch (module->type()) {
case CSwordModuleInfo::Bible:
@@ -116,13 +134,19 @@ QString util::tool::getIconNameForModule(const CSwordModuleInfo *module) {
return CResMgr::modules::book::icon_unlocked;
}
-QLabel* util::tool::explanationLabel(QWidget *parent, const QString &heading, const QString &text) {
- QLabel *label = new QLabel(parent);
+QLabel * explanationLabel(QWidget * const parent,
+ const QString & heading,
+ const QString & text)
+{
+ QLabel * const label = new QLabel(parent);
initExplanationLabel(label, heading, text);
return label;
}
-void util::tool::initExplanationLabel(QLabel *label, const QString &heading, const QString &text) {
+void initExplanationLabel(QLabel * const label,
+ const QString & heading,
+ const QString & text)
+{
QString labelText;
if (!heading.isEmpty()) {
labelText += "<b>";
@@ -143,8 +167,7 @@ void util::tool::initExplanationLabel(QLabel *label, const QString &heading, con
label->setFrameStyle(QFrame::Box | QFrame::Sunken);
}
-/** No descriptions */
-bool util::tool::inHTMLTag(int pos, QString & text) {
+bool inHTMLTag(const int pos, const QString & text) {
int i1 = text.lastIndexOf("<", pos);
int i2 = text.lastIndexOf(">", pos);
int i3 = text.indexOf(">", pos);
@@ -159,14 +182,11 @@ bool util::tool::inHTMLTag(int pos, QString & text) {
// qWarning("%d > %d && %d < %d",i1,i2,i3,i4);
- if ( (i1 > i2) && (i3 < i4) )
- return true; //yes, we're in a tag
-
- return false;
+ return (i1 > i2) && (i3 < i4);
}
-QString util::tool::remoteModuleToolTip(const CSwordModuleInfo &module,
- const QString &localVer)
+QString remoteModuleToolTip(const CSwordModuleInfo & module,
+ const QString & localVer)
{
QString text = "<p style='white-space:pre'><b>";
text += module.name();
@@ -215,7 +235,13 @@ QString util::tool::remoteModuleToolTip(const CSwordModuleInfo &module,
}
-int util::tool::mWidth(const QWidget* widget, int m) {
- if (widget) return widget->fontMetrics().width(QString(m, 'M'));
- return QApplication::fontMetrics().width(QString(m, 'M'));
+int mWidth(const QWidget * const widget, const int mCount) {
+ const QString mString(mCount, 'M');
+ if (widget)
+ return widget->fontMetrics().width(mString);
+ return QApplication::fontMetrics().width(mString);
}
+
+
+} // namespace tool {
+} // namespace util {
diff --git a/src/util/tool.h b/src/util/tool.h
index 0d1981b..cb59495 100644
--- a/src/util/tool.h
+++ b/src/util/tool.h
@@ -1,8 +1,10 @@
/*********
*
+* 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.
+* Copyright 1999-2014 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
@@ -23,55 +25,89 @@ namespace util {
namespace tool {
/**
-* Creates the file filename and put the text of parameter "text" into the file.
-* @return True if saving was sucessful, otherwise false
+ Creates the file filename and save the given text into the file.
+
+ \param[in] filename the filename to save to.
+ \param[in] text the string data to save.
+ \param[in] forceOverwrite whether to force the overwrite.
+ \param[in] fileCodec the codec to use to save the given string data.
+ \note if the file exists, and forceOverwrite is false, a confirmation dialog
+ is shown to ask the user whether to overwrite the existing file.
+ \returns whether the file was properly saved.
*/
-bool savePlainFile( const QString& filename, const QString& text, const bool& forceOverwrite = false, QTextCodec* fileCodec = QTextCodec::codecForLocale());
+bool savePlainFile(const QString & filename,
+ const QString & text,
+ bool forceOverwrite = false,
+ QTextCodec * fileCodec = QTextCodec::codecForLocale());
/**
\param[in] module the module whose icon to return.
\returns the icon used for the a module.
*/
-QIcon getIconForModule(const CSwordModuleInfo *module);
+QIcon getIconForModule(const CSwordModuleInfo * module);
/**
\param[in] module the module whose icon name to return.
\returns the icon name used for the a module.
*/
-QString getIconNameForModule(const CSwordModuleInfo *module);
+QString getIconNameForModule(const CSwordModuleInfo * module);
/**
- Returns a new QLabel initialized by initExplanationLabel().
+ Creates a new explanation label.
+
+ \param[in] parent the parent widget.
+ \param[in] heading the heading of the label.
+ \param[in] text the text of the label.
+ \returns a new QLabel initialized by initExplanationLabel().
*/
-QLabel *explanationLabel(QWidget *parent, const QString &heading, const QString &text);
+QLabel * explanationLabel(QWidget * parent,
+ const QString & heading,
+ const QString & text);
/**
- Initializes a QLabel to explain difficult things of dialogs. The label should be used to
- explain difficult things of the GUI, e.g. in the options dialog pages.
+ \brief Initializes a QLabel to explain difficult things of dialogs.
+
+ The label should be used to explain difficult things of the GUI, e.g. in the
+ options dialog pages.
+
\param[in] label The label to initialize
\param[in] heading The heading for the label.
\param[in] text The text for the label.
*/
-void initExplanationLabel(QLabel *label, const QString &heading, const QString &text);
+void initExplanationLabel(QLabel * label,
+ const QString & heading,
+ const QString & text);
/**
-* Returns true if the character at position "pos" of text is inside an HTML tag. Returns false if it's not inside an HTML tag.
+ \returns whether the character at position "pos" of text is inside an HTML tag.
*/
-bool inHTMLTag(int pos, QString & text);
+bool inHTMLTag(int pos, const QString & text);
-/** Return the module's tooltip text for a remote module
-* @param module The module required for the tooltip
-* @return The tooltip text for the passed module
+/**
+ \param[in] module The module required for the tooltip
+ \returns the remote module's tooltip text.
*/
-QString remoteModuleToolTip(const CSwordModuleInfo &module,
- const QString &localVer);
+QString remoteModuleToolTip(const CSwordModuleInfo & module,
+ const QString & localVer);
/**
-* Returns the width in pixels for a string which has mCount 'M' letters, using the specified widget's font.
-* This can be used when setting the size for a widget. It may be better to roughly calculate the size based on some text width rather than use pixels directly.
+ \brief Calculates a maximum rendered text width for a widget and a string with
+ the a given length.
+
+ This function can be used for setting the size for a widget. It may be better
+ to roughly calculate the size based on some text width rather than use a hard-
+ coded value.
+
+ \param[in] widget the widget whose font metrics to use. If 0, then the font
+ metrics of the application are used.
+ \param[in] mCount the length of the string of 'M' characters to use for
+ calculating the width.
+
+ \returns the width in pixels.
*/
-int mWidth(const QWidget* widget, int mCount);
-}
-}
+int mWidth(const QWidget * widget, int mCount);
+
+} /* namespace tool { */
+} /* namespace util { */
#endif