summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:31 -0400
committerRoberto C. Sanchez <roberto@connexer.com>2014-10-21 22:48:31 -0400
commit294b5ec5834affa57641475946b8d2aeca53c577 (patch)
treeca25b634d0f24ab5b1fc38eb805e72e0e993e0f1 /src
parente8a196082586bb68e0bf254a8f6f4b8f39071f32 (diff)
Imported Upstream version 2.4
Diffstat (limited to 'src')
-rw-r--r--src/backend/bookshelfmodel/btbookshelfmodel.cpp74
-rw-r--r--src/backend/bookshelfmodel/btbookshelfmodel.h8
-rw-r--r--src/backend/bookshelfmodel/btbookshelftreemodel.cpp205
-rw-r--r--src/backend/bookshelfmodel/btbookshelftreemodel.h24
-rw-r--r--src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.cpp71
-rw-r--r--src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.h49
-rw-r--r--src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.cpp61
-rw-r--r--src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.h48
-rw-r--r--src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp6
-rw-r--r--src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h1
-rw-r--r--src/backend/bookshelfmodel/categoryitem.cpp8
-rw-r--r--src/backend/bookshelfmodel/categoryitem.h3
-rw-r--r--src/backend/bookshelfmodel/distributionitem.cpp1
-rw-r--r--src/backend/bookshelfmodel/distributionitem.h3
-rw-r--r--src/backend/bookshelfmodel/item.cpp9
-rw-r--r--src/backend/bookshelfmodel/item.h9
-rw-r--r--src/backend/bookshelfmodel/languageitem.cpp3
-rw-r--r--src/backend/bookshelfmodel/languageitem.h7
-rw-r--r--src/backend/bookshelfmodel/moduleitem.cpp3
-rw-r--r--src/backend/bookshelfmodel/moduleitem.h9
-rw-r--r--src/backend/btmoduletreeitem.cpp27
-rw-r--r--src/backend/btmoduletreeitem.h3
-rw-r--r--src/backend/config/cbtconfig.cpp25
-rw-r--r--src/backend/cswordmodulesearch.cpp17
-rw-r--r--src/backend/cswordmodulesearch.h16
-rw-r--r--src/backend/drivers/cswordbiblemoduleinfo.cpp13
-rw-r--r--src/backend/drivers/cswordbiblemoduleinfo.h6
-rw-r--r--src/backend/drivers/cswordbookmoduleinfo.cpp9
-rw-r--r--src/backend/drivers/cswordbookmoduleinfo.h5
-rw-r--r--src/backend/drivers/cswordcommentarymoduleinfo.cpp3
-rw-r--r--src/backend/drivers/cswordcommentarymoduleinfo.h4
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.cpp16
-rw-r--r--src/backend/drivers/cswordlexiconmoduleinfo.h5
-rw-r--r--src/backend/drivers/cswordmoduleinfo.cpp132
-rw-r--r--src/backend/drivers/cswordmoduleinfo.h49
-rw-r--r--src/backend/filters/bt_gbfhtml.cpp12
-rw-r--r--src/backend/filters/bt_gbfhtml.h8
-rw-r--r--src/backend/filters/bt_osishtml.cpp37
-rw-r--r--src/backend/filters/bt_osishtml.h4
-rw-r--r--src/backend/filters/bt_plainhtml.cpp11
-rw-r--r--src/backend/filters/bt_plainhtml.h5
-rw-r--r--src/backend/filters/bt_teihtml.cpp143
-rw-r--r--src/backend/filters/bt_teihtml.h34
-rw-r--r--src/backend/filters/bt_thmlhtml.cpp46
-rw-r--r--src/backend/filters/bt_thmlhtml.h3
-rw-r--r--src/backend/filters/bt_thmlplain.cpp3
-rw-r--r--src/backend/filters/bt_thmlplain.h2
-rw-r--r--src/backend/filters/osismorphsegmentation.cpp8
-rw-r--r--src/backend/filters/osismorphsegmentation.h2
-rw-r--r--src/backend/keys/cswordkey.cpp25
-rw-r--r--src/backend/keys/cswordkey.h2
-rw-r--r--src/backend/keys/cswordldkey.cpp8
-rw-r--r--src/backend/keys/cswordldkey.h13
-rw-r--r--src/backend/keys/cswordtreekey.cpp6
-rw-r--r--src/backend/keys/cswordtreekey.h6
-rw-r--r--src/backend/keys/cswordversekey.cpp17
-rw-r--r--src/backend/keys/cswordversekey.h9
-rw-r--r--src/backend/managers/btstringmgr.cpp3
-rw-r--r--src/backend/managers/btstringmgr.h6
-rw-r--r--src/backend/managers/cdisplaytemplatemgr.cpp31
-rw-r--r--src/backend/managers/cdisplaytemplatemgr.h9
-rw-r--r--src/backend/managers/clanguagemgr.cpp7
-rw-r--r--src/backend/managers/clanguagemgr.h7
-rw-r--r--src/backend/managers/creferencemanager.h110
-rw-r--r--src/backend/managers/cswordbackend.cpp233
-rw-r--r--src/backend/managers/cswordbackend.h25
-rw-r--r--src/backend/managers/referencemanager.cpp (renamed from src/backend/managers/creferencemanager.cpp)71
-rw-r--r--src/backend/managers/referencemanager.h106
-rw-r--r--src/backend/rendering/cbookdisplay.cpp16
-rw-r--r--src/backend/rendering/cbookdisplay.h8
-rw-r--r--src/backend/rendering/cchapterdisplay.cpp9
-rw-r--r--src/backend/rendering/cchapterdisplay.h3
-rw-r--r--src/backend/rendering/cdisplayrendering.cpp24
-rw-r--r--src/backend/rendering/cdisplayrendering.h3
-rw-r--r--src/backend/rendering/centrydisplay.cpp36
-rw-r--r--src/backend/rendering/centrydisplay.h12
-rw-r--r--src/backend/rendering/chtmlexportrendering.cpp15
-rw-r--r--src/backend/rendering/chtmlexportrendering.h5
-rw-r--r--src/backend/rendering/cplaintextexportrendering.cpp9
-rw-r--r--src/backend/rendering/cplaintextexportrendering.h3
-rw-r--r--src/backend/rendering/ctextrendering.cpp37
-rw-r--r--src/backend/rendering/ctextrendering.h9
-rw-r--r--src/bibletime.cpp64
-rw-r--r--src/bibletime.h61
-rw-r--r--src/bibletime_dbus.cpp16
-rw-r--r--src/bibletime_dbus_adaptor.cpp1
-rw-r--r--src/bibletime_dbus_adaptor.h6
-rw-r--r--src/bibletime_init.cpp241
-rw-r--r--src/bibletime_slots.cpp113
-rw-r--r--src/bibletimeapp.cpp3
-rw-r--r--src/bibletimeapp.h3
-rw-r--r--src/display-templates/Blue.tmpl20
-rw-r--r--src/display-templates/Crazy.tmpl19
-rw-r--r--src/display-templates/Green.tmpl24
-rw-r--r--src/display-templates/HighContrast.tmpl28
-rw-r--r--src/display-templates/Simple.tmpl4
-rw-r--r--src/frontend/bookshelfmanager/btconfigdialog.cpp27
-rw-r--r--src/frontend/bookshelfmanager/btconfigdialog.h5
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.cpp22
-rw-r--r--src/frontend/bookshelfmanager/btinstallmgr.h12
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp20
-rw-r--r--src/frontend/bookshelfmanager/btmodulemanagerdialog.h4
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp157
-rw-r--r--src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h23
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.cpp37
-rw-r--r--src/frontend/bookshelfmanager/indexpage/btindexpage.h2
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp129
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h7
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.cpp106
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.h3
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp166
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h10
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp37
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h13
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.cpp41
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallthread.h6
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcearea.cpp82
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcearea.h12
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp171
-rw-r--r--src/frontend/bookshelfmanager/installpage/btsourcewidget.h15
-rw-r--r--src/frontend/bookshelfmanager/instbackend.cpp128
-rw-r--r--src/frontend/bookshelfmanager/instbackend.h12
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.cpp53
-rw-r--r--src/frontend/bookshelfmanager/removepage/btremovepage.h7
-rw-r--r--src/frontend/btaboutmoduledialog.cpp14
-rw-r--r--src/frontend/btaboutmoduledialog.h5
-rw-r--r--src/frontend/btbookshelfdockwidget.cpp23
-rw-r--r--src/frontend/btbookshelfdockwidget.h10
-rw-r--r--src/frontend/cdragdrop.cpp7
-rw-r--r--src/frontend/cdragdrop.h4
-rw-r--r--src/frontend/cdragdropmgr.cpp262
-rw-r--r--src/frontend/cdragdropmgr.h160
-rw-r--r--src/frontend/cexportmanager.cpp46
-rw-r--r--src/frontend/cexportmanager.h11
-rw-r--r--src/frontend/cinfodisplay.cpp44
-rw-r--r--src/frontend/cinfodisplay.h10
-rw-r--r--src/frontend/cinputdialog.cpp19
-rw-r--r--src/frontend/cinputdialog.h4
-rw-r--r--src/frontend/cmdiarea.cpp122
-rw-r--r--src/frontend/cmdiarea.h116
-rw-r--r--src/frontend/cmodulechooserdialog.cpp42
-rw-r--r--src/frontend/cmodulechooserdialog.h7
-rw-r--r--src/frontend/cmoduleindexdialog.cpp29
-rw-r--r--src/frontend/cmoduleindexdialog.h27
-rw-r--r--src/frontend/cprinter.cpp12
-rw-r--r--src/frontend/cprinter.h5
-rw-r--r--src/frontend/crossrefrendering.cpp31
-rw-r--r--src/frontend/crossrefrendering.h20
-rw-r--r--src/frontend/display/btcolorwidget.cpp8
-rw-r--r--src/frontend/display/btcolorwidget.h21
-rw-r--r--src/frontend/display/btfontsizewidget.cpp6
-rw-r--r--src/frontend/display/btfontsizewidget.h19
-rw-r--r--src/frontend/display/bthtmlfindtext.cpp10
-rw-r--r--src/frontend/display/bthtmlfindtext.h3
-rw-r--r--src/frontend/display/bthtmljsobject.cpp31
-rw-r--r--src/frontend/display/bthtmljsobject.h3
-rw-r--r--src/frontend/display/bthtmlreaddisplay.cpp47
-rw-r--r--src/frontend/display/bthtmlreaddisplay.h11
-rw-r--r--src/frontend/display/cdisplay.cpp41
-rw-r--r--src/frontend/display/cdisplay.h12
-rw-r--r--src/frontend/display/chtmlwritedisplay.cpp36
-rw-r--r--src/frontend/display/chtmlwritedisplay.h16
-rw-r--r--src/frontend/display/cplainwritedisplay.cpp29
-rw-r--r--src/frontend/display/cplainwritedisplay.h16
-rw-r--r--src/frontend/display/creaddisplay.cpp21
-rw-r--r--src/frontend/display/creaddisplay.h10
-rw-r--r--src/frontend/display/cwritedisplay.cpp14
-rw-r--r--src/frontend/display/cwritedisplay.h11
-rw-r--r--src/frontend/displaywindow/btactioncollection.cpp12
-rw-r--r--src/frontend/displaywindow/btactioncollection.h10
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.cpp8
-rw-r--r--src/frontend/displaywindow/bttoolbarpopupaction.h4
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.cpp51
-rw-r--r--src/frontend/displaywindow/cbiblereadwindow.h19
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.cpp25
-rw-r--r--src/frontend/displaywindow/cbookreadwindow.h10
-rw-r--r--src/frontend/displaywindow/cbuttons.cpp26
-rw-r--r--src/frontend/displaywindow/cbuttons.h11
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.cpp28
-rw-r--r--src/frontend/displaywindow/ccommentaryreadwindow.h10
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.cpp61
-rw-r--r--src/frontend/displaywindow/cdisplaywindow.h28
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.cpp41
-rw-r--r--src/frontend/displaywindow/cdisplaywindowfactory.h28
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.cpp42
-rw-r--r--src/frontend/displaywindow/chtmlwritewindow.h11
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.cpp70
-rw-r--r--src/frontend/displaywindow/clexiconreadwindow.h12
-rw-r--r--src/frontend/displaywindow/cmodulechooserbar.cpp10
-rw-r--r--src/frontend/displaywindow/cmodulechooserbar.h8
-rw-r--r--src/frontend/displaywindow/cmodulechooserbutton.cpp31
-rw-r--r--src/frontend/displaywindow/cmodulechooserbutton.h9
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.cpp43
-rw-r--r--src/frontend/displaywindow/cplainwritewindow.h8
-rw-r--r--src/frontend/displaywindow/creadwindow.cpp34
-rw-r--r--src/frontend/displaywindow/creadwindow.h7
-rw-r--r--src/frontend/displaywindow/cwritewindow.cpp15
-rw-r--r--src/frontend/displaywindow/cwritewindow.h8
-rw-r--r--src/frontend/htmldialogs/btaboutdialog.cpp43
-rw-r--r--src/frontend/htmldialogs/btaboutdialog.h5
-rw-r--r--src/frontend/htmldialogs/bttabhtmldialog.cpp19
-rw-r--r--src/frontend/htmldialogs/bttabhtmldialog.h2
-rw-r--r--src/frontend/keychooser/bthistory.cpp42
-rw-r--r--src/frontend/keychooser/bthistory.h25
-rw-r--r--src/frontend/keychooser/cbookkeychooser.cpp17
-rw-r--r--src/frontend/keychooser/cbookkeychooser.h10
-rw-r--r--src/frontend/keychooser/cbooktreechooser.cpp23
-rw-r--r--src/frontend/keychooser/cbooktreechooser.h20
-rw-r--r--src/frontend/keychooser/ckeychooser.cpp22
-rw-r--r--src/frontend/keychooser/ckeychooser.h12
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.cpp25
-rw-r--r--src/frontend/keychooser/ckeychooserwidget.h12
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.cpp25
-rw-r--r--src/frontend/keychooser/clexiconkeychooser.h14
-rw-r--r--src/frontend/keychooser/cscrollbutton.cpp7
-rw-r--r--src/frontend/keychooser/cscrollbutton.h8
-rw-r--r--src/frontend/keychooser/cscrollerwidgetset.cpp8
-rw-r--r--src/frontend/keychooser/cscrollerwidgetset.h10
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp11
-rw-r--r--src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h2
-rw-r--r--src/frontend/keychooser/versekeychooser/btversekeymenu.cpp8
-rw-r--r--src/frontend/keychooser/versekeychooser/btversekeymenu.h1
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp33
-rw-r--r--src/frontend/keychooser/versekeychooser/cbiblekeychooser.h13
-rw-r--r--src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp49
-rw-r--r--src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h13
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp22
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkfolder.h4
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkitem.cpp21
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkitem.h4
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkitembase.cpp7
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkitembase.h9
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkloader.cpp28
-rw-r--r--src/frontend/mainindex/bookmarks/btbookmarkloader.h6
-rw-r--r--src/frontend/mainindex/bookmarks/cbookmarkindex.cpp123
-rw-r--r--src/frontend/mainindex/bookmarks/cbookmarkindex.h31
-rw-r--r--src/frontend/mainindex/bookshelf/actionenum.h24
-rw-r--r--src/frontend/mainindex/bookshelf/btindexfolder.cpp18
-rw-r--r--src/frontend/mainindex/bookshelf/btindexfolder.h29
-rw-r--r--src/frontend/mainindex/bookshelf/btindexitem.cpp18
-rw-r--r--src/frontend/mainindex/bookshelf/btindexitem.h47
-rw-r--r--src/frontend/mainindex/bookshelf/btindexmodule.cpp89
-rw-r--r--src/frontend/mainindex/bookshelf/btindexmodule.h38
-rw-r--r--src/frontend/mainindex/bookshelf/cbookshelfindex.cpp714
-rw-r--r--src/frontend/mainindex/bookshelf/cbookshelfindex.h206
-rw-r--r--src/frontend/mainindex/bookshelf/chidemodulechooserdialog.cpp68
-rw-r--r--src/frontend/mainindex/bookshelf/chidemodulechooserdialog.h42
-rw-r--r--src/frontend/mainindex/btbookshelfview.cpp1
-rw-r--r--src/frontend/mainindex/btbookshelfview.h1
-rw-r--r--src/frontend/profile/cprofile.cpp97
-rw-r--r--src/frontend/profile/cprofile.h35
-rw-r--r--src/frontend/profile/cprofilemgr.cpp11
-rw-r--r--src/frontend/profile/cprofilemgr.h9
-rw-r--r--src/frontend/profile/cprofilewindow.cpp12
-rw-r--r--src/frontend/profile/cprofilewindow.h13
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.cpp18
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisdialog.h9
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.cpp11
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisitem.h8
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.cpp10
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysislegenditem.h7
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.cpp21
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisscene.h16
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.cpp6
-rw-r--r--src/frontend/searchdialog/analysis/csearchanalysisview.h2
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.cpp61
-rw-r--r--src/frontend/searchdialog/btsearchoptionsarea.h14
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.cpp59
-rw-r--r--src/frontend/searchdialog/btsearchresultarea.h17
-rw-r--r--src/frontend/searchdialog/chistorycombobox.cpp6
-rw-r--r--src/frontend/searchdialog/chistorycombobox.h1
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.cpp91
-rw-r--r--src/frontend/searchdialog/cmoduleresultview.h21
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.cpp50
-rw-r--r--src/frontend/searchdialog/crangechooserdialog.h13
-rw-r--r--src/frontend/searchdialog/csearchdialog.cpp69
-rw-r--r--src/frontend/searchdialog/csearchdialog.h20
-rw-r--r--src/frontend/searchdialog/csearchmodulechooserdialog.cpp26
-rw-r--r--src/frontend/searchdialog/csearchmodulechooserdialog.h25
-rw-r--r--src/frontend/searchdialog/csearchresultview.cpp42
-rw-r--r--src/frontend/searchdialog/csearchresultview.h6
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.cpp19
-rw-r--r--src/frontend/settingsdialogs/btshortcutsdialog.h2
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.cpp22
-rw-r--r--src/frontend/settingsdialogs/btshortcutseditor.h4
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.cpp24
-rw-r--r--src/frontend/settingsdialogs/cacceleratorsettings.h16
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.cpp23
-rw-r--r--src/frontend/settingsdialogs/cconfigurationdialog.h30
-rw-r--r--src/frontend/settingsdialogs/cdisplaysettings.cpp25
-rw-r--r--src/frontend/settingsdialogs/cdisplaysettings.h3
-rw-r--r--src/frontend/settingsdialogs/cfontchooser.cpp13
-rw-r--r--src/frontend/settingsdialogs/cfontchooser.h32
-rw-r--r--src/frontend/settingsdialogs/clanguagesettings.cpp65
-rw-r--r--src/frontend/settingsdialogs/clanguagesettings.h35
-rw-r--r--src/frontend/settingsdialogs/clistwidget.cpp10
-rw-r--r--src/frontend/settingsdialogs/clistwidget.h21
-rw-r--r--src/frontend/settingsdialogs/cswordsettings.cpp48
-rw-r--r--src/frontend/settingsdialogs/cswordsettings.h29
-rw-r--r--src/main.cpp80
-rw-r--r--src/tests/backend/config/cbtconfig_test.cpp3
-rw-r--r--src/tests/bibletime_test.cpp1
-rw-r--r--src/tests/bibletime_test.h1
-rw-r--r--src/util/cpointers.cpp8
-rw-r--r--src/util/cpointers.h3
-rw-r--r--src/util/cresmgr.cpp7
-rw-r--r--src/util/cresmgr.h11
-rw-r--r--src/util/ctoolclass.h94
-rw-r--r--src/util/dialogutil.cpp85
-rw-r--r--src/util/dialogutil.h45
-rw-r--r--src/util/directory.cpp (renamed from src/util/directoryutil.cpp)393
-rw-r--r--src/util/directory.h135
-rw-r--r--src/util/directoryutil.h112
-rw-r--r--src/util/migrationutil.cpp36
-rw-r--r--src/util/migrationutil.h37
-rw-r--r--src/util/tool.cpp (renamed from src/util/ctoolclass.cpp)85
-rw-r--r--src/util/tool.h80
317 files changed, 4757 insertions, 5833 deletions
diff --git a/src/backend/bookshelfmodel/btbookshelfmodel.cpp b/src/backend/bookshelfmodel/btbookshelfmodel.cpp
index 99f83ba..6882b90 100644
--- a/src/backend/bookshelfmodel/btbookshelfmodel.cpp
+++ b/src/backend/bookshelfmodel/btbookshelfmodel.cpp
@@ -14,7 +14,8 @@
#include <QSet>
#include "util/cresmgr.h"
-#include "util/directoryutil.h"
+#include "util/directory.h"
+
BtBookshelfModel::BtBookshelfModel(QObject *parent)
: QAbstractListModel(parent) {
@@ -29,25 +30,35 @@ int BtBookshelfModel::rowCount(const QModelIndex &parent) const {
return m_data.size();
}
-QVariant BtBookshelfModel::data(const QModelIndex &index, int role) const {
- if (!index.isValid() || index.column() != 0 || index.parent().isValid()) {
- return QVariant();
- }
- int row(index.row());
- if (row >= m_data.size()) return QVariant();
-
+QVariant BtBookshelfModel::data(CSwordModuleInfo *module, int role) const {
switch (role) {
case ModuleNameRole: // Qt::DisplayRole
- return m_data.at(row)->name();
+ return module->name();
case ModuleIconRole: // Qt::DecorationRole
- return moduleIcon(m_data.at(row));
+ return moduleIcon(module);
case ModulePointerRole:
- return qVariantFromValue((void*) m_data.at(row));
+ return qVariantFromValue((void*) module);
+ case ModuleCategoryRole:
+ return QVariant::fromValue(module->category());
+ case ModuleLanguageRole:
+ return QVariant(); /// \todo Unimplemented
+ case ModuleHiddenRole:
+ return module->isHidden();
default:
return QVariant();
}
}
+QVariant BtBookshelfModel::data(const QModelIndex &index, int role) const {
+ if (!index.isValid() || index.column() != 0 || index.parent().isValid()) {
+ 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 &&
@@ -58,8 +69,25 @@ QVariant BtBookshelfModel::headerData(int section, Qt::Orientation orientation,
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)
+ {
+ /*
+ Emitting dataChanged here is actually mandatory, but were not doing it
+ directly. Since we're connected to the module, changing its hidden
+ state will emit a signal we catch in moduleHidden(), which in turn is
+ what will actually emit dataChanged().
+ */
+ return m_data.at(row)->setHidden(value.toBool());
+ }
+ return false;
+}
+
QIcon BtBookshelfModel::moduleIcon(const CSwordModuleInfo *m) {
- typedef util::filesystem::DirectoryUtil DU;
+ namespace DU = util::directory;
/// \todo Make CSwordModuleInfo::isLocked() const and remove const_cast:
CSwordModuleInfo *module(const_cast<CSwordModuleInfo*>(m));
@@ -101,7 +129,7 @@ QIcon BtBookshelfModel::moduleIcon(const CSwordModuleInfo *m) {
}
QIcon BtBookshelfModel::categoryIcon(const CSwordModuleInfo::Category &category) {
- typedef util::filesystem::DirectoryUtil DU;
+ namespace DU = util::directory;
switch (category) {
case CSwordModuleInfo::Bibles:
@@ -174,6 +202,8 @@ void BtBookshelfModel::addModule(CSwordModuleInfo * const module) {
const int index(m_data.size());
beginInsertRows(QModelIndex(), index, index);
m_data.append(module);
+ connect(module, SIGNAL(hiddenChanged(bool)),
+ this, SLOT(moduleHidden(bool)));
endInsertRows();
}
@@ -193,13 +223,11 @@ void BtBookshelfModel::addModules(const QSet<CSwordModuleInfo *> &modules) {
beginInsertRows(QModelIndex(), m_data.size(),
m_data.size() + newModules.size() - 1);
-#if QT_VERSION >= 0x040500
- m_data.append(newModules);
-#else
Q_FOREACH(CSwordModuleInfo *module, newModules) {
m_data.append(module);
+ connect(module, SIGNAL(hiddenChanged(bool)),
+ this, SLOT(moduleHidden(bool)));
}
-#endif
endInsertRows();
}
@@ -210,6 +238,8 @@ void BtBookshelfModel::removeModule(CSwordModuleInfo * const module,
if (index == -1) return;
beginRemoveRows(QModelIndex(), index, index);
+ disconnect(module, SIGNAL(hiddenChanged(bool)),
+ this, SLOT(moduleHidden(bool)));
m_data.removeAt(index);
endRemoveRows();
if (destroy) delete module;
@@ -236,3 +266,13 @@ CSwordModuleInfo* BtBookshelfModel::getModule(const QString &name) const {
}
return 0;
}
+
+void BtBookshelfModel::moduleHidden(bool) {
+ Q_ASSERT(qobject_cast<CSwordModuleInfo*>(sender()) != 0);
+
+ CSwordModuleInfo *module(static_cast<CSwordModuleInfo*>(sender()));
+ Q_ASSERT(m_data.count(module) == 1);
+
+ QModelIndex i(index(m_data.indexOf(module), 0));
+ emit dataChanged(i, i);
+}
diff --git a/src/backend/bookshelfmodel/btbookshelfmodel.h b/src/backend/bookshelfmodel/btbookshelfmodel.h
index 01fc260..16fdb13 100644
--- a/src/backend/bookshelfmodel/btbookshelfmodel.h
+++ b/src/backend/bookshelfmodel/btbookshelfmodel.h
@@ -17,6 +17,7 @@
#include "backend/drivers/cswordmoduleinfo.h"
+
class BtBookshelfModel: public QAbstractListModel {
Q_OBJECT
public:
@@ -26,6 +27,7 @@ class BtBookshelfModel: public QAbstractListModel {
ModulePointerRole = Qt::UserRole,
ModuleCategoryRole = Qt::UserRole + 1,
ModuleLanguageRole = Qt::UserRole + 2,
+ ModuleHiddenRole = Qt::UserRole + 3,
UserRole = Qt::UserRole + 100
};
@@ -33,9 +35,12 @@ class BtBookshelfModel: public QAbstractListModel {
virtual ~BtBookshelfModel();
virtual int rowCount(const QModelIndex &parent) const;
+ virtual QVariant data(CSwordModuleInfo *module, int role) const;
virtual QVariant data(const QModelIndex &index, int role) const;
virtual QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+ int role = ModuleHiddenRole);
inline CSwordModuleInfo *module(const QModelIndex &index) const {
return (CSwordModuleInfo *)
@@ -64,6 +69,9 @@ class BtBookshelfModel: public QAbstractListModel {
return m_data;
}
+ protected slots:
+ void moduleHidden(bool hidden);
+
protected:
QList<CSwordModuleInfo *> m_data;
};
diff --git a/src/backend/bookshelfmodel/btbookshelftreemodel.cpp b/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
index 8e457e7..5be1aec 100644
--- a/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
+++ b/src/backend/bookshelfmodel/btbookshelftreemodel.cpp
@@ -12,25 +12,26 @@
#include "backend/bookshelfmodel/btbookshelftreemodel.h"
-#include <QQueue>
#include <QSet>
#include "backend/bookshelfmodel/categoryitem.h"
#include "backend/bookshelfmodel/distributionitem.h"
#include "backend/bookshelfmodel/languageitem.h"
#include "backend/bookshelfmodel/moduleitem.h"
+
using namespace BookshelfModel;
BtBookshelfTreeModel::BtBookshelfTreeModel(QObject *parent)
: QAbstractItemModel(parent), m_sourceModel(0), m_rootItem(new RootItem),
- m_checkable(false), m_defaultChecked(false) {
+ m_defaultChecked(MODULE_HIDDEN), m_checkable(false) {
m_groupingOrder.push_back(GROUP_CATEGORY);
m_groupingOrder.push_back(GROUP_LANGUAGE);
}
BtBookshelfTreeModel::BtBookshelfTreeModel(const Grouping &g, QObject *parent)
: QAbstractItemModel(parent), m_sourceModel(0), m_rootItem(new RootItem),
- m_groupingOrder(g), m_checkable(false), m_defaultChecked(false) {
+ m_groupingOrder(g), m_defaultChecked(MODULE_HIDDEN), m_checkable(false)
+{
// Intentionally empty
}
@@ -79,8 +80,6 @@ QModelIndex BtBookshelfTreeModel::parent(const QModelIndex &index) const {
}
QVariant BtBookshelfTreeModel::data(const QModelIndex &index, int role) const {
- typedef util::filesystem::DirectoryUtil DU;
-
if (!index.isValid() || index.column() != 0) {
return QVariant();
}
@@ -89,22 +88,33 @@ QVariant BtBookshelfTreeModel::data(const QModelIndex &index, int role) const {
Q_ASSERT(i != 0);
switch (role) {
case Qt::DisplayRole:
- return i->name();
+ if (i->type() == Item::ITEM_MODULE) {
+ return parentData(static_cast<ModuleItem *>(i), role);
+ } else {
+ return i->name();
+ }
case Qt::CheckStateRole:
if (!m_checkable) break;
case BtBookshelfTreeModel::CheckStateRole:
return i->checkState();
case Qt::DecorationRole:
- return i->icon();
+ if (i->type() == Item::ITEM_MODULE) {
+ return parentData(static_cast<ModuleItem *>(i), role);
+ } else {
+ return i->icon();
+ }
case BtBookshelfModel::ModulePointerRole:
if (i->type() == Item::ITEM_MODULE) {
- ModuleItem *mi(dynamic_cast<ModuleItem *>(i));
- if (mi != 0) {
- return qVariantFromValue((void*) mi->moduleInfo());
- }
+ ModuleItem *mi(static_cast<ModuleItem *>(i));
+ return qVariantFromValue((void*) mi->moduleInfo());
}
return 0;
+ case BtBookshelfModel::ModuleHiddenRole:
+ return i->isHidden();
default:
+ if (i->type() == Item::ITEM_MODULE) {
+ return parentData(static_cast<ModuleItem *>(i), role);
+ }
break;
}
return QVariant();
@@ -115,37 +125,47 @@ bool BtBookshelfTreeModel::setData(const QModelIndex &itemIndex,
int role) {
typedef QPair<Item *, QModelIndex> IP;
- if (role == Qt::CheckStateRole) {
+ Qt::CheckState newState;
+ if (role == BtBookshelfModel::ModuleHiddenRole) {
+ newState = value.toBool() ? Qt::Checked : Qt::Unchecked;
+ } else if (role == Qt::CheckStateRole) {
bool ok;
- Qt::CheckState newState((Qt::CheckState) value.toInt(&ok));
- if (ok && newState != Qt::PartiallyChecked) {
- Item *i(static_cast<Item*>(itemIndex.internalPointer()));
- Q_ASSERT(i != 0);
- // Recursively (un)check all children:
- QList<IP> q;
- q.append(IP(i, itemIndex));
- while (!q.isEmpty()) {
- const IP p(q.takeFirst());
- Item *item(p.first);
- item->setCheckState(newState);
- emit dataChanged(p.second, p.second);
+ newState = (Qt::CheckState) value.toInt(&ok);
+ if (!ok || newState == Qt::PartiallyChecked) return false;
+ } else {
+ return false;
+ }
+
+ Item *item(static_cast<Item*>(itemIndex.internalPointer()));
+ Q_ASSERT(item != 0);
+ if (item->checkState() == newState) return false;
+
+ // Recursively (un)check all children:
+ QList<IP> q;
+ IP p(item, itemIndex);
+ for (;;) {
+ if (item->checkState() != newState) {
+ item->setCheckState(newState);
+ emit dataChanged(p.second, p.second);
+ if (item->type() == Item::ITEM_MODULE) {
+ ModuleItem *mi(static_cast<ModuleItem*>(item));
+ emit moduleChecked(mi->moduleInfo(), newState == Qt::Checked);
+ } 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;
+ p = q.takeFirst();
+ item = p.first;
+ }
- // Change check state of the item itself
- i->setCheckState(newState);
- emit dataChanged(itemIndex, itemIndex);
-
- // Recursively change parent check states.
- resetParentCheckStates(itemIndex.parent());
+ // Recursively change parent check states.
+ resetParentCheckStates(itemIndex.parent());
- return true;
- } // if (ok && newState != Qt::PartiallyChecked)
- } // if (role == Qt::CheckStateRole)
- return false;
+ return true;
}
Qt::ItemFlags BtBookshelfTreeModel::flags(const QModelIndex &index) const {
@@ -176,7 +196,7 @@ QVariant BtBookshelfTreeModel::headerData(int section,
return QVariant();
}
-void BtBookshelfTreeModel::setSourceModel(QAbstractListModel *sourceModel) {
+void BtBookshelfTreeModel::setSourceModel(QAbstractItemModel *sourceModel) {
if (m_sourceModel == sourceModel) return;
if (m_sourceModel != 0) {
@@ -186,6 +206,7 @@ void BtBookshelfTreeModel::setSourceModel(QAbstractListModel *sourceModel) {
beginRemoveRows(QModelIndex(), 0, m_rootItem->children().size() - 1);
delete m_rootItem;
m_modules.clear();
+ m_sourceIndexMap.clear();
m_rootItem = new RootItem;
endRemoveRows();
}
@@ -200,28 +221,25 @@ void BtBookshelfTreeModel::setSourceModel(QAbstractListModel *sourceModel) {
connect(sourceModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
this, SLOT(moduleDataChanged(QModelIndex, QModelIndex)));
- BtBookshelfModel *m(dynamic_cast<BtBookshelfModel*>(sourceModel));
- if (m != 0) {
- Q_FOREACH(CSwordModuleInfo *module, m->modules()) {
- addModule(module, m_defaultChecked);
- }
- }
- else {
- for (int i(0); i < sourceModel->rowCount(); i++) {
- CSwordModuleInfo *module(
- static_cast<CSwordModuleInfo *>(
- sourceModel->data(
- sourceModel->index(i),
- BtBookshelfModel::ModulePointerRole
- ).value<void*>()
- )
- );
- Q_ASSERT(module != 0);
- addModule(
- module,
- m_defaultChecked
- );
+ for (int i(0); i < sourceModel->rowCount(); i++) {
+ typedef BtBookshelfModel::ModuleRole MRole;
+ static const MRole HR(BtBookshelfModel::ModuleHiddenRole);
+ static const MRole PR(BtBookshelfModel::ModulePointerRole);
+ QModelIndex moduleIndex(sourceModel->index(i, 0));
+ CSwordModuleInfo *module(
+ static_cast<CSwordModuleInfo *>(
+ sourceModel->data(moduleIndex, PR).value<void*>()
+ )
+ );
+ Q_ASSERT(module != 0);
+ bool checked;
+ if (m_defaultChecked == MODULE_HIDDEN) {
+ checked = !sourceModel->data(moduleIndex, HR).toBool();
+ } else {
+ checked = (m_defaultChecked == CHECKED);
}
+ m_sourceIndexMap[module] = moduleIndex;
+ addModule(module, checked);
}
}
}
@@ -249,7 +267,7 @@ void BtBookshelfTreeModel::setGroupingOrder(const Grouping &groupingOrder) {
CSwordModuleInfo *module(
static_cast<CSwordModuleInfo *>(
m_sourceModel->data(
- m_sourceModel->index(i),
+ m_sourceModel->index(i, 0),
BtBookshelfModel::ModulePointerRole
).value<void*>()
)
@@ -295,6 +313,14 @@ QList<CSwordModuleInfo*> BtBookshelfTreeModel::checkedModules() const {
return modules;
}
+QVariant BtBookshelfTreeModel::parentData(BookshelfModel::ModuleItem *item,
+ int role) const
+{
+ CSwordModuleInfo* m(item->moduleInfo());
+ Q_ASSERT(m_sourceIndexMap.contains(m));
+ return m_sourceModel->data(m_sourceIndexMap.value(m), role);
+}
+
void BtBookshelfTreeModel::addModule(CSwordModuleInfo *module, bool checked) {
if (m_modules.contains(module)) return;
Grouping g(m_groupingOrder);
@@ -345,8 +371,9 @@ void BtBookshelfTreeModel::addModule(CSwordModuleInfo *module,
}
void BtBookshelfTreeModel::removeModule(CSwordModuleInfo *module) {
- Item *i(m_modules.value(module, 0));
- if (i == 0) return;
+ if (!m_modules.contains(module)) return;
+
+ Item *i(m_modules[module]);
// Set i to be the lowest item (including empty groups) to remove:
Q_ASSERT(i->parent() != 0);
@@ -354,22 +381,11 @@ void BtBookshelfTreeModel::removeModule(CSwordModuleInfo *module) {
i = i->parent();
}
Q_ASSERT(i != 0);
-
- // Calculate index of parent item:
- QModelIndex parentIndex;
- {
- QList<int> indexes;
- for (Item *j(i->parent()); j != m_rootItem; j = j->parent()) {
- Q_ASSERT(j != 0);
- indexes.push_back(j->childIndex());
- }
- while (!indexes.isEmpty()) {
- parentIndex = index(indexes.takeLast(), 0, parentIndex);
- }
- }
+ Q_ASSERT(i->parent() != 0);
// Remove item:
int index(i->childIndex());
+ QModelIndex parentIndex(getIndex(i->parent()));
beginRemoveRows(parentIndex, index, index);
i->parent()->deleteChildAt(index);
m_modules.remove(module);
@@ -388,6 +404,24 @@ Item *BtBookshelfTreeModel::getItem(const QModelIndex &index) const {
}
}
+QModelIndex BtBookshelfTreeModel::getIndex(const BookshelfModel::Item *item) {
+ Q_ASSERT(item != 0);
+
+ QList<int> indexes;
+ for (;;) {
+ int i(item->childIndex());
+ if (i < 0) break;
+ indexes.append(i);
+ item = item->parent();
+ }
+
+ QModelIndex i;
+ 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()));
@@ -445,11 +479,19 @@ void BtBookshelfTreeModel::moduleDataChanged(const QModelIndex &topLeft,
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(itemIndex.isValid());
- /// \todo There might be a better way to do this.
- bool checked(m_modules.value(module)->checkState() == Qt::Checked);
- removeModule(module);
- addModule(module, checked);
+ emit dataChanged(itemIndex, itemIndex);
+
+ /*
+ Also emit signals for parent items because the change might alter them
+ as well, e.g. isHidden()
+ */
+ do {
+ itemIndex = itemIndex.parent();
+ emit dataChanged(itemIndex, itemIndex);
+ } while (itemIndex.isValid());
}
}
@@ -457,13 +499,21 @@ 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);
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*>()));
- addModule(module, m_defaultChecked);
+ bool checked;
+ if (m_defaultChecked == MODULE_HIDDEN) {
+ checked = !m_sourceModel->data(moduleIndex, HR).toBool();
+ } else {
+ checked = (m_defaultChecked == CHECKED);
+ }
+ m_sourceIndexMap[module] = moduleIndex;
+ addModule(module, checked);
}
}
@@ -478,6 +528,7 @@ void BtBookshelfTreeModel::moduleRemoved(const QModelIndex &parent, int start,
CSwordModuleInfo *module((CSwordModuleInfo *) (data.value<void*>()));
removeModule(module);
+ m_sourceIndexMap.remove(module);
}
}
diff --git a/src/backend/bookshelfmodel/btbookshelftreemodel.h b/src/backend/bookshelfmodel/btbookshelftreemodel.h
index 84293e1..e73b154 100644
--- a/src/backend/bookshelfmodel/btbookshelftreemodel.h
+++ b/src/backend/bookshelfmodel/btbookshelftreemodel.h
@@ -16,9 +16,11 @@
#include <QAbstractItemModel>
#include <QMap>
+#include <QPersistentModelIndex>
#include "backend/bookshelfmodel/btbookshelfmodel.h"
#include "backend/bookshelfmodel/item.h"
+
namespace BookshelfModel {
class ModuleItem;
}
@@ -30,6 +32,7 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
Q_ENUMS(Group)
typedef QMap<CSwordModuleInfo*, BookshelfModel::ModuleItem*> ModuleItemMap;
+ typedef QMap<CSwordModuleInfo*, QPersistentModelIndex> SourceIndexMap;
public:
enum ModuleRole {
@@ -37,6 +40,7 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
UserRole = BtBookshelfModel::UserRole + 100
};
enum Group { GROUP_CATEGORY = 0, GROUP_LANGUAGE, GROUP_DISTRIBUTION };
+ enum CheckedBehavior { CHECKED, UNCHECKED, MODULE_HIDDEN };
typedef QList<Group> Grouping;
BtBookshelfTreeModel(QObject *parent = 0);
@@ -59,8 +63,8 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
virtual bool setData(const QModelIndex &index, const QVariant &value,
int role);
- void setSourceModel(QAbstractListModel *sourceModel);
- inline QAbstractListModel *sourceModel() const {
+ void setSourceModel(QAbstractItemModel *sourceModel);
+ inline QAbstractItemModel *sourceModel() const {
return m_sourceModel;
}
void setGroupingOrder(const Grouping &groupingOrder);
@@ -71,22 +75,24 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
inline bool checkable() const {
return m_checkable;
}
- inline void setDefaultChecked(bool defaultChecked) {
- m_defaultChecked = defaultChecked;
+ inline void setDefaultChecked(CheckedBehavior b) {
+ m_defaultChecked = b;
}
- inline bool defaultChecked() const {
+ inline CheckedBehavior defaultChecked() const {
return m_defaultChecked;
}
QList<CSwordModuleInfo*> checkedModules() const;
protected:
+ 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>
@@ -112,13 +118,17 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
void moduleInserted(const QModelIndex &parent, int start, int end);
void moduleRemoved(const QModelIndex &parent, int start, int end);
+ signals:
+ void moduleChecked(CSwordModuleInfo *module, bool checked);
+
protected:
- QAbstractListModel *m_sourceModel;
+ QAbstractItemModel *m_sourceModel;
BookshelfModel::Item *m_rootItem;
ModuleItemMap m_modules;
+ SourceIndexMap m_sourceIndexMap;
Grouping m_groupingOrder;
+ CheckedBehavior m_defaultChecked;
bool m_checkable;
- bool m_defaultChecked;
};
QDataStream &operator<<(QDataStream &os, const BtBookshelfTreeModel::Grouping &o);
diff --git a/src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.cpp b/src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.cpp
new file mode 100644
index 0000000..a969218
--- /dev/null
+++ b/src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.cpp
@@ -0,0 +1,71 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "backend/bookshelfmodel/btmodulecategoryfilterproxymodel.h"
+
+#include "backend/bookshelfmodel/btbookshelfmodel.h"
+
+
+typedef CSwordModuleInfo::Categories CS;
+
+BtModuleCategoryFilterProxyModel::BtModuleCategoryFilterProxyModel(
+ QObject *parent)
+ : QSortFilterProxyModel(parent), m_filter(CSwordModuleInfo::AllCategories),
+ m_enabled(true)
+{
+ setFilterRole(BtBookshelfModel::ModuleCategoryRole);
+}
+
+BtModuleCategoryFilterProxyModel::~BtModuleCategoryFilterProxyModel() {
+ // Intentionally empty
+}
+
+void BtModuleCategoryFilterProxyModel::setEnabled(bool enable) {
+ m_enabled = enable;
+ invalidateFilter();
+}
+
+void BtModuleCategoryFilterProxyModel::setShownCategories(CS cs) {
+ if (m_filter == cs) return;
+ m_filter = cs;
+ invalidateFilter();
+}
+
+void BtModuleCategoryFilterProxyModel::setHiddenCategories(CS cs) {
+ cs ^= CSwordModuleInfo::AllCategories;
+ if (m_filter == cs) return;
+ m_filter = cs;
+ invalidateFilter();
+}
+
+bool BtModuleCategoryFilterProxyModel::filterAcceptsRow(int row,
+ const QModelIndex &parent) const
+{
+ typedef CSwordModuleInfo::Category C;
+
+ if (!m_enabled) return true;
+
+ const QAbstractItemModel *m(sourceModel());
+ Q_ASSERT(m != 0);
+
+ QModelIndex itemIndex(m->index(row, filterKeyColumn(), parent));
+ int numChildren(m->rowCount(itemIndex));
+ if (numChildren == 0) {
+ return m_filter.testFlag(m->data(itemIndex, filterRole()).value<C>());
+ }
+ else {
+ for (int i(0); i < numChildren; i++) {
+ if (filterAcceptsRow(i, itemIndex)) return true;
+ }
+ return false;
+ }
+}
diff --git a/src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.h b/src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.h
new file mode 100644
index 0000000..7517986
--- /dev/null
+++ b/src/backend/bookshelfmodel/btmodulecategoryfilterproxymodel.h
@@ -0,0 +1,49 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BTMODULECATEGORYFILTERPROXYMODEL_H
+#define BTMODULECATEGORYFILTERPROXYMODEL_H
+
+#include <QSortFilterProxyModel>
+
+#include "backend/drivers/cswordmoduleinfo.h"
+
+
+class BtModuleCategoryFilterProxyModel: public QSortFilterProxyModel {
+ Q_OBJECT
+ public:
+ BtModuleCategoryFilterProxyModel(QObject *parent = 0);
+ virtual ~BtModuleCategoryFilterProxyModel();
+
+ inline bool enabled() const {
+ return m_enabled;
+ }
+ void setEnabled(bool enable);
+
+ inline CSwordModuleInfo::Categories shownCategories() const {
+ return m_filter;
+ }
+
+ inline CSwordModuleInfo::Categories hiddenCategories() const {
+ return ~m_filter & CSwordModuleInfo::AllCategories;
+ }
+ void setShownCategories(CSwordModuleInfo::Categories cs);
+ void setHiddenCategories(CSwordModuleInfo::Categories cs);
+
+ virtual bool filterAcceptsRow(int row, const QModelIndex &parent) const;
+
+ protected:
+ CSwordModuleInfo::Categories m_filter;
+ bool m_enabled;
+};
+
+#endif // BTMODULECATEGORYFILTERPROXYMODEL_H
diff --git a/src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.cpp b/src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.cpp
new file mode 100644
index 0000000..3a50300
--- /dev/null
+++ b/src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.cpp
@@ -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-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#include "backend/bookshelfmodel/btmodulehiddenfilterproxymodel.h"
+
+#include "backend/bookshelfmodel/btbookshelfmodel.h"
+
+
+BtModuleHiddenFilterProxyModel::BtModuleHiddenFilterProxyModel(QObject *parent)
+ : QSortFilterProxyModel(parent), m_enabled(true), m_showHidden(false),
+ m_showShown(true) {
+ setFilterRole(BtBookshelfModel::ModuleHiddenRole);
+}
+
+BtModuleHiddenFilterProxyModel::~BtModuleHiddenFilterProxyModel() {
+ // Intentionally empty
+}
+
+void BtModuleHiddenFilterProxyModel::setEnabled(bool enable) {
+ if (enable == m_enabled) return;
+ m_enabled = enable;
+ invalidateFilter();
+}
+
+void BtModuleHiddenFilterProxyModel::setShowHidden(bool show) {
+ if (m_showHidden == show) return;
+ m_showHidden = show;
+ invalidateFilter();
+}
+
+void BtModuleHiddenFilterProxyModel::setShowShown(bool show) {
+ if (m_showShown == show) return;
+ m_showShown = show;
+ invalidateFilter();
+}
+
+bool BtModuleHiddenFilterProxyModel::filterAcceptsRow(int row,
+ const QModelIndex &parent) const {
+ typedef Qt::CheckState CS;
+
+ if (!m_enabled) return true;
+
+ QAbstractItemModel *m(sourceModel());
+
+ QModelIndex i(m->index(row, filterKeyColumn(), parent));
+ if ((CS) m->data(i, filterRole()).toBool()) {
+ return m_showHidden;
+ }
+ else {
+ return m_showShown;
+ }
+}
diff --git a/src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.h b/src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.h
new file mode 100644
index 0000000..8871930
--- /dev/null
+++ b/src/backend/bookshelfmodel/btmodulehiddenfilterproxymodel.h
@@ -0,0 +1,48 @@
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+#ifndef BTMODULEHIDDENFILTERPROXYMODEL_H
+#define BTMODULEHIDDENFILTERPROXYMODEL_H
+
+#include <QSortFilterProxyModel>
+
+
+class BtModuleHiddenFilterProxyModel: public QSortFilterProxyModel {
+ Q_OBJECT
+ public:
+ BtModuleHiddenFilterProxyModel(QObject *parent = 0);
+ virtual ~BtModuleHiddenFilterProxyModel();
+
+ inline bool enabled() const {
+ return m_enabled;
+ }
+ void setEnabled(bool enable);
+
+ inline bool showHidden() const {
+ return m_showHidden;
+ }
+ void setShowHidden(bool show);
+
+ inline bool showShown() const {
+ return m_showShown;
+ }
+ void setShowShown(bool show);
+
+ virtual bool filterAcceptsRow(int row, const QModelIndex &parent) const;
+
+ protected:
+ bool m_enabled;
+ bool m_showHidden;
+ bool m_showShown;
+};
+
+#endif // BTMODULEHIDDENFILTERPROXYMODEL_H
diff --git a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp
index 31b93e1..1d20cdb 100644
--- a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp
+++ b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.cpp
@@ -12,8 +12,12 @@
#include "backend/bookshelfmodel/btmodulenamefilterproxymodel.h"
+#include "backend/bookshelfmodel/btbookshelfmodel.h"
+
+
BtModuleNameFilterProxyModel::BtModuleNameFilterProxyModel(QObject *parent)
: QSortFilterProxyModel(parent), m_enabled(true) {
+ setFilterRole(BtBookshelfModel::ModuleNameRole);
setFilterCaseSensitivity(Qt::CaseInsensitive);
}
@@ -28,7 +32,7 @@ bool BtModuleNameFilterProxyModel::filterAcceptsRow(int row,
const QAbstractItemModel *m(sourceModel());
Q_ASSERT(m != 0);
- QModelIndex itemIndex(m->index(row, 0, p));
+ QModelIndex itemIndex(m->index(row, filterKeyColumn(), p));
int numChildren(m->rowCount(itemIndex));
if (numChildren == 0) {
return QSortFilterProxyModel::filterAcceptsRow(row, p);
diff --git a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h
index e4499be..9b24dd6 100644
--- a/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h
+++ b/src/backend/bookshelfmodel/btmodulenamefilterproxymodel.h
@@ -15,6 +15,7 @@
#include <QSortFilterProxyModel>
+
class BtModuleNameFilterProxyModel: public QSortFilterProxyModel {
Q_OBJECT
public:
diff --git a/src/backend/bookshelfmodel/categoryitem.cpp b/src/backend/bookshelfmodel/categoryitem.cpp
index 3ce6e88..1788dfc 100644
--- a/src/backend/bookshelfmodel/categoryitem.cpp
+++ b/src/backend/bookshelfmodel/categoryitem.cpp
@@ -10,7 +10,8 @@
*
**********/
-#include "categoryitem.h"
+#include "backend/bookshelfmodel/categoryitem.h"
+
namespace BookshelfModel {
@@ -23,7 +24,10 @@ bool CategoryItem::operator<(const Item &other) const {
if (other.type() != ITEM_CATEGORY) {
return ITEM_CATEGORY < other.type();
}
- return m_category < static_cast<const CategoryItem &>(other).m_category;
+ 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;
}
} // namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/categoryitem.h b/src/backend/bookshelfmodel/categoryitem.h
index 40820a2..fcff12b 100644
--- a/src/backend/bookshelfmodel/categoryitem.h
+++ b/src/backend/bookshelfmodel/categoryitem.h
@@ -19,6 +19,7 @@
#include "backend/bookshelfmodel/btbookshelfmodel.h"
#include "backend/drivers/cswordmoduleinfo.h"
+
namespace BookshelfModel {
class CategoryItem: public Item {
@@ -41,7 +42,7 @@ class CategoryItem: public Item {
return BtBookshelfModel::categoryIcon(m_category);
}
- inline bool fitFor(CSwordModuleInfo *module) {
+ inline bool fitFor(CSwordModuleInfo *module) const {
return module->category() == m_category;
}
diff --git a/src/backend/bookshelfmodel/distributionitem.cpp b/src/backend/bookshelfmodel/distributionitem.cpp
index 4ae81c5..fee9c19 100644
--- a/src/backend/bookshelfmodel/distributionitem.cpp
+++ b/src/backend/bookshelfmodel/distributionitem.cpp
@@ -12,6 +12,7 @@
#include "backend/bookshelfmodel/distributionitem.h"
+
namespace BookshelfModel {
DistributionItem::DistributionItem(CSwordModuleInfo *module)
diff --git a/src/backend/bookshelfmodel/distributionitem.h b/src/backend/bookshelfmodel/distributionitem.h
index 44ae591..4ae1197 100644
--- a/src/backend/bookshelfmodel/distributionitem.h
+++ b/src/backend/bookshelfmodel/distributionitem.h
@@ -17,6 +17,7 @@
#include "backend/drivers/cswordmoduleinfo.h"
+
namespace BookshelfModel {
class DistributionItem: public Item {
@@ -33,7 +34,7 @@ class DistributionItem: public Item {
return m_distribution;
}
- inline bool fitFor(CSwordModuleInfo *module) {
+ inline bool fitFor(CSwordModuleInfo *module) const {
return module->config(CSwordModuleInfo::DistributionSource)
== m_distribution;
}
diff --git a/src/backend/bookshelfmodel/item.cpp b/src/backend/bookshelfmodel/item.cpp
index 8556274..ec2dcab 100644
--- a/src/backend/bookshelfmodel/item.cpp
+++ b/src/backend/bookshelfmodel/item.cpp
@@ -16,6 +16,7 @@
#include "backend/bookshelfmodel/distributionitem.h"
#include "backend/bookshelfmodel/languageitem.h"
+
namespace BookshelfModel {
Item::Item(Type type)
@@ -53,4 +54,12 @@ bool Item::operator<(const Item &other) const {
return name().localeAwareCompare(other.name()) < 0;
}
+bool Item::isHidden() const {
+ if (m_children.empty()) return true;
+ Q_FOREACH(Item *child, m_children) {
+ if (!child->isHidden()) return false;
+ }
+ return true;
+}
+
} // namespace BookshelfModel
diff --git a/src/backend/bookshelfmodel/item.h b/src/backend/bookshelfmodel/item.h
index b24b503..665343f 100644
--- a/src/backend/bookshelfmodel/item.h
+++ b/src/backend/bookshelfmodel/item.h
@@ -18,6 +18,7 @@
#include <QString>
#include <QtGlobal>
+
class CSwordModuleInfo;
namespace BookshelfModel {
@@ -71,9 +72,9 @@ class Item {
\brief Returns the index of this item under its parent.
\retval -1 if this item has no parent.
*/
- inline int childIndex() {
+ inline int childIndex() const {
if (m_parent == 0) return -1;
- return m_parent->m_children.indexOf(this);
+ return m_parent->m_children.indexOf(const_cast<Item*>(this));
}
/**
@@ -149,7 +150,7 @@ class Item {
\retval true If this item is a group and can contain the given module.
\retval false This item is not a group or a wrong group.
*/
- inline virtual bool fitFor(CSwordModuleInfo *module) {
+ inline virtual bool fitFor(CSwordModuleInfo *module) const {
Q_UNUSED(module);
return false;
}
@@ -159,6 +160,8 @@ class Item {
*/
virtual bool operator<(const Item &other) const;
+ virtual bool isHidden() const;
+
protected:
inline void setParent(Item *parent) {
Q_ASSERT(parent != 0);
diff --git a/src/backend/bookshelfmodel/languageitem.cpp b/src/backend/bookshelfmodel/languageitem.cpp
index 6758178..8d37891 100644
--- a/src/backend/bookshelfmodel/languageitem.cpp
+++ b/src/backend/bookshelfmodel/languageitem.cpp
@@ -10,7 +10,8 @@
*
**********/
-#include "languageitem.h"
+#include "backend/bookshelfmodel/languageitem.h"
+
namespace BookshelfModel {
diff --git a/src/backend/bookshelfmodel/languageitem.h b/src/backend/bookshelfmodel/languageitem.h
index 262ca65..b5696d9 100644
--- a/src/backend/bookshelfmodel/languageitem.h
+++ b/src/backend/bookshelfmodel/languageitem.h
@@ -17,7 +17,8 @@
#include "backend/bookshelfmodel/btbookshelfmodel.h"
#include "backend/drivers/cswordmoduleinfo.h"
-#include "util/directoryutil.h"
+#include "util/directory.h"
+
namespace BookshelfModel {
@@ -36,10 +37,10 @@ class LanguageItem: public Item {
}
inline QIcon icon() const {
- return util::filesystem::DirectoryUtil::getIcon("flag.svg");
+ return util::directory::getIcon("flag.svg");
}
- inline bool fitFor(CSwordModuleInfo *module) {
+ inline bool fitFor(CSwordModuleInfo *module) const {
return module->language() == m_language;
}
diff --git a/src/backend/bookshelfmodel/moduleitem.cpp b/src/backend/bookshelfmodel/moduleitem.cpp
index 8d02111..95e6f62 100644
--- a/src/backend/bookshelfmodel/moduleitem.cpp
+++ b/src/backend/bookshelfmodel/moduleitem.cpp
@@ -10,10 +10,11 @@
*
**********/
-#include "moduleitem.h"
+#include "backend/bookshelfmodel/moduleitem.h"
#include "util/cresmgr.h"
+
namespace BookshelfModel {
ModuleItem::ModuleItem(CSwordModuleInfo *module)
diff --git a/src/backend/bookshelfmodel/moduleitem.h b/src/backend/bookshelfmodel/moduleitem.h
index 40ecc79..9657423 100644
--- a/src/backend/bookshelfmodel/moduleitem.h
+++ b/src/backend/bookshelfmodel/moduleitem.h
@@ -18,6 +18,7 @@
#include "backend/bookshelfmodel/btbookshelfmodel.h"
#include "backend/drivers/cswordmoduleinfo.h"
+
namespace BookshelfModel {
class ModuleItem: public Item {
@@ -28,12 +29,8 @@ class ModuleItem: public Item {
return m_moduleInfo;
}
- inline QString name() const {
- return m_moduleInfo->name();
- }
-
- inline QIcon icon() const {
- return BtBookshelfModel::moduleIcon(m_moduleInfo);
+ inline bool isHidden() const {
+ return m_moduleInfo->isHidden();
}
protected:
diff --git a/src/backend/btmoduletreeitem.cpp b/src/backend/btmoduletreeitem.cpp
index d11ecbd..01e4446 100644
--- a/src/backend/btmoduletreeitem.cpp
+++ b/src/backend/btmoduletreeitem.cpp
@@ -7,19 +7,16 @@
*
**********/
-#include "btmoduletreeitem.h"
+#include "backend/btmoduletreeitem.h"
+#include <QDebug>
+#include <QList>
+#include <QString>
#include "backend/drivers/cswordmoduleinfo.h"
-#include "util/cpointers.h"
#include "backend/managers/cswordbackend.h"
+#include "util/cpointers.h"
#include "util/cresmgr.h"
-#include "util/ctoolclass.h"
-
-#include <QString>
-#include <QList>
-
-#include <QDebug>
-
+#include "util/tool.h"
//This ctor creates the root item and the tree.
@@ -68,7 +65,7 @@ BTModuleTreeItem::~BTModuleTreeItem() {
}
QList<BTModuleTreeItem*> BTModuleTreeItem::children() const {
- //qDebug("BTModuleTreeItem::children");
+ //qDebug() << "BTModuleTreeItem::children";
QList<BTModuleTreeItem*> childList;
if (m_firstChild) {
BTModuleTreeItem* child = m_firstChild;
@@ -81,7 +78,7 @@ QList<BTModuleTreeItem*> BTModuleTreeItem::children() const {
return childList;
}
-//TODO
+/// \todo
QString BTModuleTreeItem::iconName() const {
if (m_type == Category) {
switch ( m_category) {
@@ -114,10 +111,10 @@ QString BTModuleTreeItem::iconName() const {
}
}
else if (m_type == Module) {
- return CToolClass::getIconNameForModule(m_moduleInfo);
+ return util::tool::getIconNameForModule(m_moduleInfo);
}
else if (m_type == Language) {
- //TODO: don't hardcode here
+ /// \todo don't hardcode here
return "flag.svg";
}
@@ -126,7 +123,7 @@ QString BTModuleTreeItem::iconName() const {
void BTModuleTreeItem::create_tree(QList<BTModuleTreeItem::Filter*>& filters, BTModuleTreeItem::Grouping grouping) {
- qDebug("BTModuleTreeItem::create_tree");
+ qDebug() << "BTModuleTreeItem::create_tree";
static bool map_initialized = false;
static QMap<CSwordModuleInfo::Category, QString> CategoryNamesMap;
if (!map_initialized) {
@@ -218,7 +215,7 @@ BTModuleTreeItem* BTModuleTreeItem::create_parent_item(
}
void BTModuleTreeItem::sort_children(BTModuleTreeItem* parent) {
- //qDebug("BTModuleTreeItem::sort_children");
+ //qDebug() << "BTModuleTreeItem::sort_children";
// sort each child recursively depth-first
foreach(BTModuleTreeItem* item, parent->children()) {
diff --git a/src/backend/btmoduletreeitem.h b/src/backend/btmoduletreeitem.h
index b159c6f..5bcebf8 100644
--- a/src/backend/btmoduletreeitem.h
+++ b/src/backend/btmoduletreeitem.h
@@ -10,9 +10,8 @@
#ifndef BTMODULETREEITEM_H
#define BTMODULETREEITEM_H
-#include "backend/drivers/cswordmoduleinfo.h"
-
#include <QString>
+#include "backend/drivers/cswordmoduleinfo.h"
/**
diff --git a/src/backend/config/cbtconfig.cpp b/src/backend/config/cbtconfig.cpp
index db62863..98a2967 100644
--- a/src/backend/config/cbtconfig.cpp
+++ b/src/backend/config/cbtconfig.cpp
@@ -7,25 +7,23 @@
*
**********/
-#include "cbtconfig.h"
+#include "backend/config/cbtconfig.h"
-// Qt includes
#include <QDebug>
#include <QLocale>
#include <QSettings>
#include <QVariant>
#include <QWebSettings>
-
-// Sword includes
-#include <versekey.h> // For range configuration
-
-// BibleTime includes
#include "backend/btmoduletreeitem.h"
#include "backend/managers/cdisplaytemplatemgr.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/searchdialog/btsearchoptionsarea.h"
#include "util/cpointers.h"
-#include "util/directoryutil.h"
+#include "util/directory.h"
+
+// Sword includes:
+#include <versekey.h> // For range configuration
+
namespace CBTConfig {
namespace {
@@ -712,7 +710,7 @@ CSwordBackend::FilterOptions getFilterOptionDefaults() {
void setupAccelSettings(const keys type,
BtActionCollection * const actionCollection) {
- qDebug("CBTConfig::setupAccelSettings begin");
+ qDebug() << "CBTConfig::setupAccelSettings begin";
QString groupName;
switch (type) {
case allWindows:
@@ -745,12 +743,12 @@ void setupAccelSettings(const keys type,
actionCollection->setConfigGroup(groupName);
actionCollection->readSettings();
- qDebug("CBTConfig::setupAccelSettings end");
+ qDebug() << "CBTConfig::setupAccelSettings end";
}
void saveAccelSettings(const keys type,
BtActionCollection * const actionCollection) {
- qDebug("CBTConfig::saveAccelSettings begin");
+ qDebug() << "CBTConfig::saveAccelSettings begin";
QString groupName;
switch (type) {
case allWindows:
@@ -781,7 +779,7 @@ void saveAccelSettings(const keys type,
actionCollection->setConfigGroup(groupName);
actionCollection->writeSettings();
- qDebug("CBTConfig::saveAccelSettings end");
+ qDebug() << "CBTConfig::saveAccelSettings end";
}
@@ -800,7 +798,8 @@ void setModuleEncryptionKey(const QString &module, const QString &key) {
}
QSettings *getConfig() {
- static QSettings config(util::filesystem::DirectoryUtil::getUserBaseDir().absolutePath() + "/bibletimerc", QSettings::IniFormat);
+ namespace DU = util::directory;
+ static QSettings config(DU::getUserBaseDir().absolutePath() + "/bibletimerc", QSettings::IniFormat);
return &config;
}
diff --git a/src/backend/cswordmodulesearch.cpp b/src/backend/cswordmodulesearch.cpp
index 220cac9..9348295 100644
--- a/src/backend/cswordmodulesearch.cpp
+++ b/src/backend/cswordmodulesearch.cpp
@@ -7,17 +7,16 @@
*
**********/
-//BibleTime includes
-#include "cswordmodulesearch.h"
+#include "backend/cswordmodulesearch.h"
+#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
-#include "backend/config/cbtconfig.h"
-//Sword includes
-#include <swmodule.h>
-#include <swkey.h>
+// Sword includes:
#include <listkey.h>
+#include <swkey.h>
+#include <swmodule.h>
CSwordModuleSearch* CSwordModuleSearch::searcher = 0;
@@ -102,12 +101,6 @@ void CSwordModuleSearch::connectFinished( QObject *receiver, const char *member
QObject::connect(this, SIGNAL(finished()), receiver, member);
}
-/** Should be called when the search finished. */
-void CSwordModuleSearch::searchFinished() {
- //m_finishedSig.activate();
- emit finished();
-}
-
bool CSwordModuleSearch::modulesHaveIndices( const QList<CSwordModuleInfo*>& modules ) {
bool hasIndices = true;
QList<CSwordModuleInfo*>::const_iterator end_it = modules.end();
diff --git a/src/backend/cswordmodulesearch.h b/src/backend/cswordmodulesearch.h
index cc0c8c1..d40e9fa 100644
--- a/src/backend/cswordmodulesearch.h
+++ b/src/backend/cswordmodulesearch.h
@@ -7,24 +7,19 @@
*
**********/
-
-
#ifndef CSWORDMODULESEARCH_H
#define CSWORDMODULESEARCH_H
-//BibleTime - backend
-class CSwordModuleInfo;
-
-//BibleTime - utils
-#include "util/cpointers.h"
-
-//Qt includes
#include <QObject>
#include <QString>
+#include "util/cpointers.h"
-//Sword includes
+// Sword includes:
#include <listkey.h>
+
+class CSwordModuleInfo;
+
/**
* CSwordModuleSearch manages the search on Sword modules. It manages the thread(s)
* and manages the different modules.
@@ -72,7 +67,6 @@ class CSwordModuleSearch: public QObject, CPointers {
const sword::ListKey& searchScope() const;
void connectFinished( QObject * receiver, const char * member );
- void searchFinished();
/**
* Returns true if all of the specified modules have indices already built.
diff --git a/src/backend/drivers/cswordbiblemoduleinfo.cpp b/src/backend/drivers/cswordbiblemoduleinfo.cpp
index f00a580..4a65c4d 100644
--- a/src/backend/drivers/cswordbiblemoduleinfo.cpp
+++ b/src/backend/drivers/cswordbiblemoduleinfo.cpp
@@ -7,19 +7,16 @@
*
**********/
-//BibleTime includes
-#include "cswordbiblemoduleinfo.h"
-#include "backend/managers/cswordbackend.h"
-#include "backend/keys/cswordversekey.h"
+#include "backend/drivers/cswordbiblemoduleinfo.h"
-//Qt
+#include <boost/scoped_ptr.hpp>
#include <QFile>
+#include "backend/managers/cswordbackend.h"
+#include "backend/keys/cswordversekey.h"
-//Sword
+// Sword includes:
#include <versekey.h>
-#include <boost/scoped_ptr.hpp>
-
CSwordBibleModuleInfo::CSwordBibleModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend )
: CSwordModuleInfo(module, usedBackend),
diff --git a/src/backend/drivers/cswordbiblemoduleinfo.h b/src/backend/drivers/cswordbiblemoduleinfo.h
index 10d05bb..2780558 100644
--- a/src/backend/drivers/cswordbiblemoduleinfo.h
+++ b/src/backend/drivers/cswordbiblemoduleinfo.h
@@ -10,11 +10,11 @@
#ifndef CSWORDBIBLEMODULEINFO_H
#define CSWORDBIBLEMODULEINFO_H
-#include "cswordmoduleinfo.h"
-#include "backend/keys/cswordversekey.h"
+#include "backend/drivers/cswordmoduleinfo.h"
-//Qt
#include <QStringList>
+#include "backend/keys/cswordversekey.h"
+
/**
* This is the CModuleInfo imlementation for Bible modules managed by Sword.
diff --git a/src/backend/drivers/cswordbookmoduleinfo.cpp b/src/backend/drivers/cswordbookmoduleinfo.cpp
index b67015b..6371de1 100644
--- a/src/backend/drivers/cswordbookmoduleinfo.cpp
+++ b/src/backend/drivers/cswordbookmoduleinfo.cpp
@@ -7,13 +7,14 @@
*
**********/
-//BibleTime includes
-#include "cswordbookmoduleinfo.h"
+#include "backend/drivers/cswordbookmoduleinfo.h"
+
#include "backend/keys/cswordtreekey.h"
-//Sword includes
-#include <treekeyidx.h>
+// Sword includes:
#include <treekey.h>
+#include <treekeyidx.h>
+
CSwordBookModuleInfo::CSwordBookModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend )
: CSwordModuleInfo(module, usedBackend),
diff --git a/src/backend/drivers/cswordbookmoduleinfo.h b/src/backend/drivers/cswordbookmoduleinfo.h
index cd18efc..77adb29 100644
--- a/src/backend/drivers/cswordbookmoduleinfo.h
+++ b/src/backend/drivers/cswordbookmoduleinfo.h
@@ -10,11 +10,12 @@
#ifndef CSWORDGENBOOKMODULEINFO_H
#define CSWORDGENBOOKMODULEINFO_H
-#include "cswordmoduleinfo.h"
+#include "backend/drivers/cswordmoduleinfo.h"
-//Sword
+// Sword includes:
#include <treekeyidx.h>
+
/** Class for generic book support
* @author The BibleTime team
*/
diff --git a/src/backend/drivers/cswordcommentarymoduleinfo.cpp b/src/backend/drivers/cswordcommentarymoduleinfo.cpp
index bb19a23..8b74ffa 100644
--- a/src/backend/drivers/cswordcommentarymoduleinfo.cpp
+++ b/src/backend/drivers/cswordcommentarymoduleinfo.cpp
@@ -7,7 +7,8 @@
*
**********/
-#include "cswordcommentarymoduleinfo.h"
+#include "backend/drivers/cswordcommentarymoduleinfo.h"
+
CSwordCommentaryModuleInfo::CSwordCommentaryModuleInfo( sword::SWModule* module, CSwordBackend* const usedBackend)
: CSwordBibleModuleInfo(module, usedBackend) {}
diff --git a/src/backend/drivers/cswordcommentarymoduleinfo.h b/src/backend/drivers/cswordcommentarymoduleinfo.h
index eb9db83..a297538 100644
--- a/src/backend/drivers/cswordcommentarymoduleinfo.h
+++ b/src/backend/drivers/cswordcommentarymoduleinfo.h
@@ -10,8 +10,8 @@
#ifndef CSWORDCOMMENTARYMODULEINFO_H
#define CSWORDCOMMENTARYMODULEINFO_H
-//own includes
-#include "cswordbiblemoduleinfo.h"
+#include "backend/drivers/cswordbiblemoduleinfo.h"
+
/** Commentary module implementation.
* This CSwordModule implementation provides access to Sword's commentary modules.
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.cpp b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
index 28874b6..776be9c 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.cpp
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.cpp
@@ -7,19 +7,17 @@
*
**********/
-#include "cswordlexiconmoduleinfo.h"
-#include "util/directoryutil.h"
+#include "backend/drivers/cswordlexiconmoduleinfo.h"
-//Qt
+#include <algorithm>
#include <QFile>
#include <QDataStream>
#include <QTextCodec>
+#include "util/directory.h"
-//Sword
+// Sword includes:
#include <swmodule.h>
-//STL includes
-#include <algorithm>
//Change it once the format changed to make all systems rebuild their caches
#define CACHE_FORMAT "2"
@@ -45,6 +43,8 @@ CSwordLexiconModuleInfo::~CSwordLexiconModuleInfo() {
/** Returns the entries of the module. */
QStringList* CSwordLexiconModuleInfo::entries() {
+ namespace DU = util::directory;
+
if (!module()) {
return 0;
}
@@ -68,7 +68,7 @@ QStringList* CSwordLexiconModuleInfo::entries() {
return m_entryList;
}
- QString dir(util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath());
+ QString dir(DU::getUserCacheDir().absolutePath());
QFile f1(
QString(dir)
.append("/")
@@ -141,7 +141,7 @@ QStringList* CSwordLexiconModuleInfo::entries() {
if (m_entryList->count()) {
//create cache
- QString dir = util::filesystem::DirectoryUtil::getUserCacheDir().absolutePath();
+ QString dir(DU::getUserCacheDir().absolutePath());
//QFile f2( QString::fromLatin1("%1/%2").arg(dir).arg( name() ) );
QFile f2( QString(dir).append("/").append(name()) );
diff --git a/src/backend/drivers/cswordlexiconmoduleinfo.h b/src/backend/drivers/cswordlexiconmoduleinfo.h
index e5a5535..36d30fb 100644
--- a/src/backend/drivers/cswordlexiconmoduleinfo.h
+++ b/src/backend/drivers/cswordlexiconmoduleinfo.h
@@ -10,12 +10,11 @@
#ifndef CSWORDLEXICONMODULEINFO_H
#define CSWORDLEXICONMODULEINFO_H
-//own includes
-#include "cswordmoduleinfo.h"
+#include "backend/drivers/cswordmoduleinfo.h"
-//Qt includes
#include <QStringList>
+
/**
* The implementation of CModuleInfo for the Sword lexiccons and citionaries.
* @author The BibleTime team
diff --git a/src/backend/drivers/cswordmoduleinfo.cpp b/src/backend/drivers/cswordmoduleinfo.cpp
index 5861a2b..bafe098 100644
--- a/src/backend/drivers/cswordmoduleinfo.cpp
+++ b/src/backend/drivers/cswordmoduleinfo.cpp
@@ -7,48 +7,39 @@
*
**********/
-//BibleTime includes
-#include "cswordmoduleinfo.h"
-#include "cswordlexiconmoduleinfo.h"
-
-#include "backend/managers/cswordbackend.h"
-#include "backend/cswordmodulesearch.h"
-#include "backend/keys/cswordkey.h"
-#include "backend/rendering/centrydisplay.h"
-#include "backend/managers/clanguagemgr.h"
-
-#include "util/directoryutil.h"
-#include "util/cpointers.h"
-#include "util/exceptions.h"
-#include "backend/config/cbtconfig.h"
-
+#include "backend/drivers/cswordmoduleinfo.h"
#include <boost/scoped_ptr.hpp>
-
-//Qt includes
-#include <QRegExp>
+#include <CLucene.h>
+#include <CLucene/util/Misc.h>
+#include <CLucene/util/Reader.h>
+#include <QByteArray>
+#include <QCoreApplication>
+#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QList>
-#include <QByteArray>
-#include <QDebug>
+#include <QRegExp>
#include <QSettings>
-#include <QMessageBox>
-#include <QCoreApplication>
+#include "backend/config/cbtconfig.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 "util/directory.h"
+#include "util/cpointers.h"
+#include "util/exceptions.h"
+#include "util/dialogutil.h"
-//Sword includes
-#include <swbuf.h>
-#include <swkey.h>
+// Sword includes:
#include <listkey.h>
-#include <versekey.h>
+#include <swbuf.h>
#include <swconfig.h>
+#include <swkey.h>
#include <rtfhtml.h>
-
-//Lucence includes
-#include <CLucene.h>
-#include <CLucene/util/Reader.h>
-#include <CLucene/util/Misc.h>
-#include <CLucene/util/dirent.h>
+#include <versekey.h>
//Increment this, if the index format changes
@@ -63,7 +54,6 @@ CSwordModuleInfo::CSwordModuleInfo(sword::SWModule * module, CSwordBackend * con
m_module = module;
Q_ASSERT(module);
- m_hidden = false;
m_cancelIndexing = false;
m_searchResult.ClearList();
m_backend = usedBackend ? usedBackend : CPointers::backend();
@@ -72,6 +62,7 @@ CSwordModuleInfo::CSwordModuleInfo(sword::SWModule * module, CSwordBackend * con
m_dataCache.category = UnknownCategory;
m_dataCache.language = 0;
m_dataCache.hasVersion = !QString((*m_backend->getConfig())[module->Name()]["Version"]).isEmpty();
+ m_hidden = CBTConfig::get(CBTConfig::hiddenModules).contains(name());
if (backend()) {
if (hasVersion() && (minimumSwordVersion() > sword::SWVersion::currentVersion)) {
@@ -108,7 +99,7 @@ bool CSwordModuleInfo::unlock(const QString & unlockKey) {
CBTConfig::setModuleEncryptionKey(name(), unlockKey);
backend()->setCipherKey(m_module->Name(), unlockKey.toUtf8().constData());
- //TODO: write to Sword config as well
+ /// \todo write to Sword config as well
return true;
}
@@ -181,7 +172,7 @@ bool CSwordModuleInfo::unlockKeyIsValid() {
}
QString CSwordModuleInfo::getGlobalBaseIndexLocation() {
- return util::filesystem::DirectoryUtil::getUserIndexDir().absolutePath();
+ return util::directory::getUserIndexDir().absolutePath();
}
QString CSwordModuleInfo::getModuleBaseIndexLocation() const {
@@ -316,10 +307,10 @@ void CSwordModuleInfo::buildIndex() {
for (*m_module = sword::TOP; !(m_module->Error()) && !m_cancelIndexing; (*m_module)++) {
- // Also index Chapter 0 and Verse 0, because they might have information in the entry attributes
- // We used to just put their content into the textBuffer and continue to the next verse, but
- // with entry attributes this doesn't work any more.
- // Hits in the search dialog will show up as 1:1 (instead of 0)
+ // Also index Chapter 0 and Verse 0, because they might have information in the entry attributes
+ // We used to just put their content into the textBuffer and continue to the next verse, but
+ // with entry attributes this doesn't work any more.
+ // Hits in the search dialog will show up as 1:1 (instead of 0)
boost::scoped_ptr<lucene::document::Document> doc(new lucene::document::Document());
@@ -417,18 +408,19 @@ void CSwordModuleInfo::buildIndex() {
}
catch (...) {
qWarning("CLucene exception occurred while indexing");
- QMessageBox::warning(0, QCoreApplication::tr("Indexing aborted"), QCoreApplication::tr("An internal error occurred while building the index."));
+ util::showWarning(0, QCoreApplication::tr("Indexing aborted"), QCoreApplication::tr("An internal error occurred while building the index."));
deleteIndexForModule(name());
m_cancelIndexing = false;
}
}
void CSwordModuleInfo::deleteIndexForModule( QString name ) {
- util::filesystem::DirectoryUtil::removeRecursive( getGlobalBaseIndexLocation() + "/" + name );
+ util::directory::removeRecursive( getGlobalBaseIndexLocation() + "/" + name );
}
unsigned long CSwordModuleInfo::indexSize() const {
- return util::filesystem::DirectoryUtil::getDirSizeRecursive( getModuleBaseIndexLocation() );
+ namespace DU = util::directory;
+ return DU::getDirSizeRecursive( getModuleBaseIndexLocation() );
}
@@ -487,7 +479,7 @@ bool CSwordModuleInfo::searchIndexed(const QString& searchedText, sword::ListKey
}
catch (...) {
qWarning("CLucene exception occurred");
- QMessageBox::warning(0, QCoreApplication::tr("Search aborted"), QCoreApplication::tr("An internal error occurred while executing your search."));
+ util::showWarning(0, QCoreApplication::tr("Search aborted"), QCoreApplication::tr("An internal error occurred while executing your search."));
return false;
}
@@ -727,7 +719,7 @@ bool CSwordModuleInfo::deleteEntry(CSwordKey * const key) {
/** Returns the category of this module. See CSwordModuleInfo::Category for possible values. */
CSwordModuleInfo::Category CSwordModuleInfo::category() const {
- //qDebug("CSwordModuleInfo::category");
+ //qDebug() << "CSwordModuleInfo::category";
if (m_dataCache.category == CSwordModuleInfo::UnknownCategory) {
const QString cat(m_module->getConfigEntry("Category"));
//qDebug() << "the category was unknown, add a category "<< cat << "for module" << m_module->Name();
@@ -832,7 +824,7 @@ QString CSwordModuleInfo::aboutText() const {
text += QString("<br/><b>%1</b><br/><br/>")
.arg(tr("Take care, this work contains cult / questionable material!"));
- text += QString("<b>%1:</b><br>%2</font>")
+ text += QString("<b>%1:</b><br/>%2</font>")
.arg(tr("About"))
.arg(config(AboutInformation));
@@ -841,23 +833,14 @@ QString CSwordModuleInfo::aboutText() const {
ListConfigEntry entries;
entries.append(DistributionLicense);
-
entries.append(DistributionSource);
-
entries.append(DistributionNotes);
-
entries.append(TextSource);
-
entries.append(CopyrightNotes);
-
entries.append(CopyrightHolder);
-
entries.append(CopyrightDate);
-
entries.append(CopyrightContactName);
-
entries.append(CopyrightContactAddress);
-
entries.append(CopyrightContactEmail);
typedef QMap<CSwordModuleInfo::ConfigEntry, QString> MapConfigEntry;
@@ -865,23 +848,14 @@ QString CSwordModuleInfo::aboutText() const {
MapConfigEntry entryMap;
entryMap[DistributionLicense] = tr("Distribution license");
-
entryMap[DistributionSource] = tr("Distribution source");
-
entryMap[DistributionNotes] = tr("Distribution notes");
-
entryMap[TextSource] = tr("Text source");
-
entryMap[CopyrightNotes] = tr("Copyright notes");
-
entryMap[CopyrightHolder] = tr("Copyright holder");
-
entryMap[CopyrightDate] = tr("Copyright date");
-
entryMap[CopyrightContactName] = tr("Copyright contact name");
-
entryMap[CopyrightContactAddress] = tr("Copyright contact address");
-
entryMap[CopyrightContactEmail] = tr("Copyright contact email");
text += ("<hr><table>");
@@ -897,7 +871,6 @@ QString CSwordModuleInfo::aboutText() const {
}
-
text += "</table></font>";
return text;
@@ -946,24 +919,19 @@ QString CSwordModuleInfo::getFormattedConfigEntry(const QString& name) const {
return ret.isEmpty() ? QString::null : ret;
}
-void CSwordModuleInfo::setHidden(bool hidden) {
- //qDebug("CSwordModuleInfo::setHidden");
- QStringList hiddenModules = CBTConfig::get(CBTConfig::hiddenModules);
- if (hidden && !hiddenModules.contains(this->name())) {
- hiddenModules.append(this->name());
- CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
- }
- if (!hidden && hiddenModules.contains(this->name()) ) {
- hiddenModules.removeAll(this->name());
- CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
- }
-}
+bool CSwordModuleInfo::setHidden(bool hide) {
+ if (m_hidden == hide) return false;
-bool CSwordModuleInfo::isHidden() const {
- //qDebug("CSwordModuleInfo::isHidden");
- QStringList hiddenModules = CBTConfig::get(CBTConfig::hiddenModules);
- if (hiddenModules.contains(this->name())) {
- return true;
+ m_hidden = hide;
+ QStringList hiddenModules(CBTConfig::get(CBTConfig::hiddenModules));
+ if (hide) {
+ Q_ASSERT(!hiddenModules.contains(name()));
+ hiddenModules.append(name());
+ } else {
+ Q_ASSERT(hiddenModules.contains(name()));
+ hiddenModules.removeOne(name());
}
- return false;
+ CBTConfig::set(CBTConfig::hiddenModules, hiddenModules);
+ emit hiddenChanged(hide);
+ return true;
}
diff --git a/src/backend/drivers/cswordmoduleinfo.h b/src/backend/drivers/cswordmoduleinfo.h
index ba4b8f6..9f32b12 100644
--- a/src/backend/drivers/cswordmoduleinfo.h
+++ b/src/backend/drivers/cswordmoduleinfo.h
@@ -12,16 +12,17 @@
#include "backend/managers/clanguagemgr.h"
-//Qt
-#include <QString>
#include <QList>
+#include <QMetaType>
+#include <QString>
-//Sword
+// Sword includes:
#include <listkey.h>
-#include <swsearchable.h>
+#include <swdisp.h>
#include <swmodule.h>
+#include <swsearchable.h>
#include <swversion.h>
-#include <swdisp.h>
+
class CSwordBackend;
class CSwordKey;
@@ -125,16 +126,19 @@ class CSwordModuleInfo: public QObject {
featureMax = HebrewParse
};
enum Category {
- Bibles,
- Commentaries,
- Books,
- Lexicons,
- Glossary,
- DailyDevotional,
- Images,
- Cult, /**< The module is a cult / sect / questionable module */
- UnknownCategory /**< The category wasn't set or has an unknown value */
+ 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
@@ -258,7 +262,7 @@ class CSwordModuleInfo: public QObject {
*/
virtual bool snap() {
return false;
- };
+ }
bool has( const CSwordModuleInfo::Feature ) const;
bool has( const CSwordModuleInfo::FilterTypes ) const;
@@ -285,9 +289,14 @@ class CSwordModuleInfo: public QObject {
/**
* Returns true if this module is hidden (not to be shown with other modules in certain views).
*/
- bool isHidden() const;
+ inline bool isHidden() const { return m_hidden; }
- void setHidden(bool 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. See CSwordModuleInfo::Category for possible values.
@@ -308,7 +317,7 @@ class CSwordModuleInfo: public QObject {
public slots:
inline void cancelIndexing() {
m_cancelIndexing = true;
- };
+ }
protected:
friend class CSwordBackend;
@@ -327,6 +336,7 @@ class CSwordModuleInfo: public QObject {
QString getFormattedConfigEntry(const QString& name) const;
signals:
+ void hiddenChanged(bool);
void indexingFinished();
void indexingProgress(int);
@@ -355,6 +365,9 @@ class CSwordModuleInfo: public QObject {
bool m_cancelIndexing;
};
+Q_DECLARE_METATYPE(CSwordModuleInfo::Category);
+Q_DECLARE_OPERATORS_FOR_FLAGS(CSwordModuleInfo::Categories)
+
inline CSwordModuleInfo::ModuleType CSwordModuleInfo::type() const {
return CSwordModuleInfo::Unknown;
}
diff --git a/src/backend/filters/bt_gbfhtml.cpp b/src/backend/filters/bt_gbfhtml.cpp
index 6580bcd..8d6a36a 100644
--- a/src/backend/filters/bt_gbfhtml.cpp
+++ b/src/backend/filters/bt_gbfhtml.cpp
@@ -7,21 +7,17 @@
*
**********/
+#include "backend/filters/bt_gbfhtml.h"
-
-//BibleTime includes
-#include "bt_gbfhtml.h"
-
+#include <QRegExp>
+#include <QString>
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cswordbackend.h"
#include "util/cpointers.h"
-//Sword includes
+// Sword includes:
#include <utilxml.h>
-//Qt includes
-#include <QRegExp>
-#include <QString>
Filters::BT_GBFHTML::BT_GBFHTML() : sword::GBFHTML() {
diff --git a/src/backend/filters/bt_gbfhtml.h b/src/backend/filters/bt_gbfhtml.h
index ad23653..45e7e59 100644
--- a/src/backend/filters/bt_gbfhtml.h
+++ b/src/backend/filters/bt_gbfhtml.h
@@ -7,17 +7,13 @@
*
**********/
-
-
-/* $Header: /cvsroot/bibletime/bibletime/bibletime/backend/filters/bt_gbfhtml.h,v 1.24 2006/02/25 11:38:15 joachim Exp $ */
-/* $Revision: 1.24 $ */
-
#ifndef BT_GBFHTML_H
#define BT_GBFHTML_H
-//Sword includes
+// Sword includes:
#include <gbfhtml.h>
+
namespace Filters {
/** GBF to HTML filter,
diff --git a/src/backend/filters/bt_osishtml.cpp b/src/backend/filters/bt_osishtml.cpp
index 9026a94..7525aca 100644
--- a/src/backend/filters/bt_osishtml.cpp
+++ b/src/backend/filters/bt_osishtml.cpp
@@ -7,25 +7,20 @@
*
**********/
-//BibleTime includes
-#include "bt_osishtml.h"
-#include "backend/managers/clanguagemgr.h"
-#include "backend/managers/creferencemanager.h"
-#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/filters/bt_osishtml.h"
+#include <QString>
#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/clanguagemgr.h"
+#include "backend/managers/referencemanager.h"
#include "util/cpointers.h"
-//Sword
-#include <swmodule.h>
+// Sword includes:
#include <swbuf.h>
+#include <swmodule.h>
#include <utilxml.h>
-//Qt
-#include <QString>
-
-//KDE
-
Filters::BT_OSISHTML::BT_OSISHTML() : sword::OSISHTMLHREF() {
setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
@@ -39,7 +34,7 @@ Filters::BT_OSISHTML::BT_OSISHTML() : sword::OSISHTMLHREF() {
// addTokenSubstitute("divineName", "<span class=\"name\"><span class=\"divine\">");
// addTokenSubstitute("/divineName", "</span></span>");
- //TODO Move that down to the real tag handling, segs without the type morph would generate incorrect markup, as the end span is always inserted
+ /// \todo Move that down to the real tag handling, segs without the type morph would generate incorrect markup, as the end span is always inserted
// addTokenSubstitute("seg type=\"morph\"", "<span class=\"morphSegmentation\">");
// addTokenSubstitute("/seg", "</span>");
@@ -112,11 +107,11 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
if ((attrib = tag.getAttribute("lemma"))) {
char splitChar = '|';
const int countSplit1 = tag.getAttributePartCount("lemma", '|');
- const int countSplit2 = tag.getAttributePartCount("lemma", ' '); //TODO: not allowed, remove soon
+ const int countSplit2 = tag.getAttributePartCount("lemma", ' '); /// \todo not allowed, remove soon
int count = 0;
if (countSplit1 > countSplit2) { //| split char
- splitChar = '|'; //TODO: not allowed, remove soon
+ splitChar = '|'; /// \todo not allowed, remove soon
count = countSplit1;
}
else {
@@ -153,7 +148,7 @@ bool Filters::BT_OSISHTML::handleToken(sword::SWBuf &buf, const char *token, swo
if ((attrib = tag.getAttribute("morph"))) {
char splitChar = '|';
const int countSplit1 = tag.getAttributePartCount("morph", '|');
- const int countSplit2 = tag.getAttributePartCount("morph", ' '); //TODO: not allowed, remove soon
+ const int countSplit2 = tag.getAttributePartCount("morph", ' '); /// \todo not allowed, remove soon
int count = 0;
if (countSplit1 > countSplit2) { //| split char
@@ -574,7 +569,7 @@ void Filters::BT_OSISHTML::renderReference(const char *osisRef, sword::SWBuf &bu
}
if (mod) {
- CReferenceManager::ParseOptions options;
+ ReferenceManager::ParseOptions options;
options.refBase = QString::fromUtf8(myUserData->key->getText());
options.refDestinationModule = QString(mod->name());
options.sourceLanguage = QString(myModule->Lang());
@@ -582,14 +577,14 @@ void Filters::BT_OSISHTML::renderReference(const char *osisRef, sword::SWBuf &bu
buf.append("<a href=\"");
buf.append( //create the hyperlink with key and mod
- CReferenceManager::encodeHyperlink(
+ ReferenceManager::encodeHyperlink(
mod->name(),
- CReferenceManager::parseVerseReference(hrefRef, options),
- CReferenceManager::typeFromModule(mod->type())
+ ReferenceManager::parseVerseReference(hrefRef, options),
+ ReferenceManager::typeFromModule(mod->type())
).toUtf8().constData()
);
buf.append("\" crossrefs=\"");
- buf.append((const char*)CReferenceManager::parseVerseReference(ref, options).toUtf8().constData()); //ref must contain the osisRef module marker if there was any
+ buf.append((const char*)ReferenceManager::parseVerseReference(ref, options).toUtf8().constData()); //ref must contain the osisRef module marker if there was any
buf.append("\">");
}
// should we add something if there were no referenced module available?
diff --git a/src/backend/filters/bt_osishtml.h b/src/backend/filters/bt_osishtml.h
index 04b68ec..83bf0a9 100644
--- a/src/backend/filters/bt_osishtml.h
+++ b/src/backend/filters/bt_osishtml.h
@@ -10,10 +10,10 @@
#ifndef BT_OSISHTML_H
#define BT_OSISHTML_H
-//Sword includes
+// Sword includes:
+#include <osishtmlhref.h>
#include <swbuf.h>
#include <swmodule.h>
-#include <osishtmlhref.h>
namespace Filters {
diff --git a/src/backend/filters/bt_plainhtml.cpp b/src/backend/filters/bt_plainhtml.cpp
index d26d8ed..c70db79 100644
--- a/src/backend/filters/bt_plainhtml.cpp
+++ b/src/backend/filters/bt_plainhtml.cpp
@@ -7,7 +7,8 @@
*
**********/
-#include "bt_plainhtml.h"
+#include "backend/filters/bt_plainhtml.h"
+
Filters::BT_PLAINHTML::BT_PLAINHTML() : sword::SWFilter() {
}
@@ -32,7 +33,7 @@ char Filters::BT_PLAINHTML::processText(sword::SWBuf& text, const sword::SWKey*
continue;
}
else if ((*from == '\n')) { // only one new line
- text += "<BR>";
+ text += "<br/>";
continue;
}
else if (*from == '<') {
@@ -48,15 +49,15 @@ char Filters::BT_PLAINHTML::processText(sword::SWBuf& text, const sword::SWKey*
continue;
}
else if (*from == '{') { //footnote start
- text += "<FONT COLOR=\"#800000\"><SMALL> ("; /// \bug Possible color conflict
+ text += "<font color=\"#800000\"><small> ("; /// \bug Possible color conflict
continue;
}
else if (*from == '}') { //footnote end
- text += ") </SMALL></FONT>";
+ text += ") </small></font>";
continue;
}
else if ((*from == ' ') && (count > 5000)) {
- text += "<WBR>";
+ text += "<wbr/>";
count = 0;
continue;
}
diff --git a/src/backend/filters/bt_plainhtml.h b/src/backend/filters/bt_plainhtml.h
index 0430e51..c228660 100644
--- a/src/backend/filters/bt_plainhtml.h
+++ b/src/backend/filters/bt_plainhtml.h
@@ -10,9 +10,10 @@
#ifndef BT_PLAINHTML_H
#define BT_PLAINHTML_H
-//Sword includes
-#include <swfilter.h>
+// Sword includes:
#include <swbuf.h>
+#include <swfilter.h>
+
class SWKey;
class SWModule;
diff --git a/src/backend/filters/bt_teihtml.cpp b/src/backend/filters/bt_teihtml.cpp
new file mode 100644
index 0000000..340e8af
--- /dev/null
+++ b/src/backend/filters/bt_teihtml.cpp
@@ -0,0 +1,143 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#include "backend/filters/bt_teihtml.h"
+
+#include <QString>
+#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/clanguagemgr.h"
+#include "backend/managers/referencemanager.h"
+#include "util/cpointers.h"
+
+// Sword includes:
+#include <swbuf.h>
+#include <swmodule.h>
+#include <utilxml.h>
+
+
+
+Filters::BT_TEIHTML::BT_TEIHTML() : sword::TEIHTMLHREF() {
+ setPassThruUnknownEscapeString(true); //the HTML widget will render the HTML escape codes
+}
+
+bool Filters::BT_TEIHTML::handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData) {
+ // manually process if it wasn't a simple substitution
+
+ if (!substituteToken(buf, token)) {
+
+ sword::XMLTag tag(token);
+
+ if (0) {
+
+ }
+ else if (!strcmp(tag.getName(), "ref")) {
+
+ if (!tag.isEndTag() && !tag.isEmpty()) {
+
+ renderReference(tag.getAttribute("osisRef"), buf, userData);
+
+ }
+ else if (tag.isEndTag()) {
+ buf.append("</a>");
+ }
+ else { // empty reference marker
+ // -- what should we do? nothing for now.
+ }
+ }
+ // <hi> highlighted text
+ else if (!strcmp(tag.getName(), "hi")) {
+ const sword::SWBuf type = tag.getAttribute("rend");
+
+ if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ if (type == "bold") {
+ buf.append("<span class=\"bold\">");
+ }
+ else if (type == "illuminated") {
+ buf.append("<span class=\"illuminated\">");
+ }
+ else if (type == "italic") {
+ buf.append("<span class=\"italic\">");
+ }
+ else if (type == "line-through") {
+ buf.append("<span class=\"line-through\">");
+ }
+ else if (type == "normal") {
+ buf.append("<span class=\"normal\">");
+ }
+ else if (type == "small-caps") {
+ buf.append("<span class=\"small-caps\">");
+ }
+ else if (type == "underline") {
+ buf.append("<span class=\"underline\">");
+ }
+ else {
+ buf.append("<span>"); //don't break markup, </span> is inserted later
+ }
+ }
+ else if (tag.isEndTag()) { //all hi replacements are html spans
+ buf.append("</span>");
+ }
+ }
+ else { //all tokens handled by OSISHTMLHref will run through the filter now
+ return sword::TEIHTMLHREF::handleToken(buf, token, userData);
+ }
+ }
+
+ return false;
+}
+
+void Filters::BT_TEIHTML::renderReference(const char *osisRef, sword::SWBuf &buf, sword::BasicFilterUserData *myUserData) {
+ QString ref( osisRef );
+ QString hrefRef( ref );
+
+ if (!ref.isEmpty()) {
+ //find out the mod, using the current module makes sense if it's a bible or commentary because the refs link into a bible by default.
+ //If the osisRef is something like "ModuleID:key comes here" then the
+ // modulename is given, so we'll use that one
+
+ CSwordModuleInfo* mod = CBTConfig::get( CBTConfig::standardBible );
+
+ // Q_ASSERT(mod); There's no necessarily a module or standard Bible
+
+ //if the osisRef like "GerLut:key" contains a module, use that
+ int pos = ref.indexOf(":");
+
+ if ((pos >= 0) && ref.at(pos - 1).isLetter() && ref.at(pos + 1).isLetter()) {
+ QString newModuleName = ref.left(pos);
+ hrefRef = ref.mid(pos + 1);
+
+ if (CPointers::backend()->findModuleByName(newModuleName)) {
+ mod = CPointers::backend()->findModuleByName(newModuleName);
+ }
+ }
+
+ if (mod) {
+ ReferenceManager::ParseOptions options;
+ options.refBase = QString::fromUtf8(myUserData->key->getText());
+ options.refDestinationModule = QString(mod->name());
+ options.sourceLanguage = QString(mod->module()->Lang());
+ options.destinationLanguage = QString("en");
+
+ buf.append("<a href=\"");
+ buf.append( //create the hyperlink with key and mod
+ ReferenceManager::encodeHyperlink(
+ mod->name(),
+ ReferenceManager::parseVerseReference(hrefRef, options),
+ ReferenceManager::typeFromModule(mod->type())
+ ).toUtf8().constData()
+ );
+ buf.append("\" crossrefs=\"");
+ buf.append((const char*)ReferenceManager::parseVerseReference(ref, options).toUtf8().constData()); //ref must contain the osisRef module marker if there was any
+ buf.append("\">");
+ }
+ // should we add something if there were no referenced module available?
+ }
+}
+
diff --git a/src/backend/filters/bt_teihtml.h b/src/backend/filters/bt_teihtml.h
new file mode 100644
index 0000000..2160349
--- /dev/null
+++ b/src/backend/filters/bt_teihtml.h
@@ -0,0 +1,34 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef BT_TEIHTML_H
+#define BT_TEIHTML_H
+
+// Sword includes:
+#include <teihtmlhref.h>
+#include <swbuf.h>
+
+namespace Filters {
+
+/** BibleTime's TEI to HTMl filter.
+* This filter works on TEI tags and outputs HTML in the structure supported by BibleTime.
+*/
+
+class BT_TEIHTML : public sword::TEIHTMLHREF {
+
+ public:
+ BT_TEIHTML();
+ virtual bool handleToken(sword::SWBuf &buf, const char *token, sword::BasicFilterUserData *userData);
+ private:
+ void renderReference(const char *osisRef, sword::SWBuf &buf, sword::BasicFilterUserData *myUserData);
+};
+
+} //end of Filters namespace
+
+#endif
diff --git a/src/backend/filters/bt_thmlhtml.cpp b/src/backend/filters/bt_thmlhtml.cpp
index 4ee333d..478339c 100644
--- a/src/backend/filters/bt_thmlhtml.cpp
+++ b/src/backend/filters/bt_thmlhtml.cpp
@@ -7,25 +7,24 @@
*
**********/
-//BibleTime includes
-#include "bt_thmlhtml.h"
-#include "backend/managers/clanguagemgr.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/managers/creferencemanager.h"
+#include "backend/filters/bt_thmlhtml.h"
+#include <QString>
+#include <QRegExp>
+#include <QUrl>
+#include <QTextCodec>
#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/clanguagemgr.h"
+#include "backend/managers/referencemanager.h"
#include "util/cpointers.h"
-#include <boost/scoped_ptr.hpp>
-//Sword includes
+// Sword includes:
#include <swmodule.h>
+#include <utilstr.h>
#include <utilxml.h>
#include <versekey.h>
-#include <utilstr.h>
-//Qt includes
-#include <QString>
-#include <QRegExp>
Filters::BT_ThMLHTML::BT_ThMLHTML() {
setEscapeStringCaseSensitive(true);
@@ -258,7 +257,7 @@ bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, swo
CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
//Q_ASSERT(mod); tested later
if (mod) {
- CReferenceManager::ParseOptions options;
+ ReferenceManager::ParseOptions options;
options.refBase = QString::fromUtf8(myUserData->key->getText()); //current module key
options.refDestinationModule = QString(mod->name());
options.sourceLanguage = QString(myModule->Lang());
@@ -274,7 +273,7 @@ bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, swo
if (! oldRef.isEmpty() ) {
options.refBase = oldRef; //use the last ref as a base, e.g. Rom 1,2-3, when the next ref is only 3:3-10
}
- const QString completeRef( CReferenceManager::parseVerseReference((*it), options) );
+ const QString completeRef( ReferenceManager::parseVerseReference((*it), options) );
oldRef = completeRef; //use the parsed result as the base for the next ref.
@@ -284,10 +283,10 @@ bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, swo
buf.append("<a href=\"");
buf.append(
- CReferenceManager::encodeHyperlink(
+ ReferenceManager::encodeHyperlink(
mod->name(),
completeRef,
- CReferenceManager::typeFromModule(mod->type())
+ ReferenceManager::typeFromModule(mod->type())
).toUtf8().constData()
);
@@ -317,23 +316,23 @@ bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, swo
CSwordModuleInfo* mod = CBTConfig::get(CBTConfig::standardBible);
//Q_ASSERT(mod); tested later
- CReferenceManager::ParseOptions options;
+ ReferenceManager::ParseOptions options;
options.refBase = QString::fromUtf8(myUserData->key->getText());
options.sourceLanguage = myModule->Lang();
options.destinationLanguage = QString("en");
- const QString completeRef = CReferenceManager::parseVerseReference(QString::fromUtf8(ref), options);
+ const QString completeRef = ReferenceManager::parseVerseReference(QString::fromUtf8(ref), options);
if (mod) {
options.refDestinationModule = QString(mod->name());
buf.append("<span class=\"crossreference\">");
buf.append("<a href=\"");
buf.append(
- CReferenceManager::encodeHyperlink(
+ ReferenceManager::encodeHyperlink(
mod->name(),
completeRef,
- CReferenceManager::typeFromModule(mod->type())
+ ReferenceManager::typeFromModule(mod->type())
).toUtf8().constData()
);
buf.append("\" crossrefs=\"");
@@ -370,10 +369,11 @@ bool Filters::BT_ThMLHTML::handleToken(sword::SWBuf &buf, const char *token, swo
value++; //strip the first /
}
- buf.append("<img src=\"file:");
- buf.append(myUserData->module->getConfigEntry("AbsoluteDataPath"));
- buf.append('/');
- buf.append(value);
+ buf.append("<img src=\"");
+ QString absPath(QTextCodec::codecForLocale()->toUnicode(myUserData->module->getConfigEntry("AbsoluteDataPath")));
+ QString relPath(QString::fromUtf8(value));
+ QString url(QUrl::fromLocalFile(absPath.append('/').append(relPath)).toString());
+ buf.append(url.toUtf8().data());
buf.append("\" />");
}
else { // let unknown token pass thru
diff --git a/src/backend/filters/bt_thmlhtml.h b/src/backend/filters/bt_thmlhtml.h
index 25b168c..6a220b6 100644
--- a/src/backend/filters/bt_thmlhtml.h
+++ b/src/backend/filters/bt_thmlhtml.h
@@ -10,10 +10,11 @@
#ifndef BT_THMLHTML_H
#define BT_THMLHTML_H
-//Sword
+// Sword includes:
#include <swbuf.h>
#include <thmlhtml.h>
+
namespace Filters {
/** ThML to HTML filter.
diff --git a/src/backend/filters/bt_thmlplain.cpp b/src/backend/filters/bt_thmlplain.cpp
index 2cd3cf9..ecd7bbd 100644
--- a/src/backend/filters/bt_thmlplain.cpp
+++ b/src/backend/filters/bt_thmlplain.cpp
@@ -13,7 +13,8 @@
* ASCII rendered symbols.
*/
-#include "bt_thmlplain.h"
+#include "backend/filters/bt_thmlplain.h"
+
Filters::BT_ThMLPlain::BT_ThMLPlain() {
}
diff --git a/src/backend/filters/bt_thmlplain.h b/src/backend/filters/bt_thmlplain.h
index 7ef82d6..92c2c33 100644
--- a/src/backend/filters/bt_thmlplain.h
+++ b/src/backend/filters/bt_thmlplain.h
@@ -10,9 +10,11 @@
#ifndef BT_THMLPLAIN_H
#define BT_THMLPLAIN_H
+// Sword includes:
#include <swbuf.h>
#include <swfilter.h>
+
namespace Filters {
/** This filter converts ThML text to plain text
diff --git a/src/backend/filters/osismorphsegmentation.cpp b/src/backend/filters/osismorphsegmentation.cpp
index 26e7470..512fe2e 100644
--- a/src/backend/filters/osismorphsegmentation.cpp
+++ b/src/backend/filters/osismorphsegmentation.cpp
@@ -6,11 +6,13 @@
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "osismorphsegmentation.h"
-//Sword
+#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";
@@ -24,7 +26,7 @@ Filters::OSISMorphSegmentation::OSISMorphSegmentation() : sword::SWOptionFilter(
Filters::OSISMorphSegmentation::~OSISMorphSegmentation() {}
-char Filters::OSISMorphSegmentation::processText(sword::SWBuf &text, const sword::SWKey */*key*/, const sword::SWModule */*module*/) {
+char Filters::OSISMorphSegmentation::processText(sword::SWBuf &text, const sword::SWKey * /*key*/, const sword::SWModule * /*module*/) {
sword::SWBuf token;
bool intoken = false;
bool hide = false;
diff --git a/src/backend/filters/osismorphsegmentation.h b/src/backend/filters/osismorphsegmentation.h
index bc405f5..c5bbb18 100644
--- a/src/backend/filters/osismorphsegmentation.h
+++ b/src/backend/filters/osismorphsegmentation.h
@@ -10,9 +10,11 @@
#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.
diff --git a/src/backend/keys/cswordkey.cpp b/src/backend/keys/cswordkey.cpp
index 546c55e..24f4909 100644
--- a/src/backend/keys/cswordkey.cpp
+++ b/src/backend/keys/cswordkey.cpp
@@ -7,27 +7,24 @@
*
**********/
-#include "cswordkey.h"
+#include "backend/keys/cswordkey.h"
+#include <QRegExp>
+#include <QString>
+#include <QTextCodec>
#include "backend/drivers/cswordmoduleinfo.h"
-#include "cswordversekey.h"
-#include "cswordldkey.h"
-#include "cswordtreekey.h"
+#include "backend/keys/cswordldkey.h"
+#include "backend/keys/cswordtreekey.h"
+#include "backend/keys/cswordversekey.h"
-#include "util/ctoolclass.h"
-
-//Sword
-#include <swmodule.h>
+// Sword includes:
#include <swkey.h>
-#include <versekey.h>
+#include <swmodule.h>
#include <treekey.h>
#include <treekeyidx.h>
#include <utilstr.h>
+#include <versekey.h>
-//Qt
-#include <QRegExp>
-#include <QString>
-#include <QTextCodec>
CSwordKey::CSwordKey(CSwordModuleInfo* const module) : m_module(module) {}
@@ -77,7 +74,7 @@ QString CSwordKey::renderedText( const CSwordKey::TextRenderType mode ) {
//Q_ASSERT(!key().isNull());
if (!key().isNull()) { //we have valid text
- bool DoRender = (mode == ProcessEntryAttributesOnly) ? 0 : 1;
+ bool DoRender = (mode == ProcessEntryAttributesOnly) ? 0 : 1;
QString text = QString::fromUtf8( m_module->module()->RenderText(0, -1, DoRender) );
if (!DoRender) return QString::null;
diff --git a/src/backend/keys/cswordkey.h b/src/backend/keys/cswordkey.h
index af0075a..d1924d6 100644
--- a/src/backend/keys/cswordkey.h
+++ b/src/backend/keys/cswordkey.h
@@ -10,9 +10,9 @@
#ifndef CSWORDKEY_H
#define CSWORDKEY_H
-//Qt
#include <QString>
+
class CSwordModuleInfo;
class QTextCodec;
diff --git a/src/backend/keys/cswordldkey.cpp b/src/backend/keys/cswordldkey.cpp
index 4aa95cb..bc1e2c1 100644
--- a/src/backend/keys/cswordldkey.cpp
+++ b/src/backend/keys/cswordldkey.cpp
@@ -7,16 +7,16 @@
*
**********/
-#include "cswordldkey.h"
+#include "backend/keys/cswordldkey.h"
+
+#include <QTextCodec>
#include "backend/drivers/cswordlexiconmoduleinfo.h"
-//Sword includes
+// Sword includes:
#include <swmodule.h>
#include <swld.h>
#include <utilstr.h>
-//Qt includes
-#include <QTextCodec>
CSwordLDKey::CSwordLDKey( CSwordModuleInfo* module ) {
if ((m_module = dynamic_cast<CSwordLexiconModuleInfo*>(module))) {
diff --git a/src/backend/keys/cswordldkey.h b/src/backend/keys/cswordldkey.h
index 1cb3382..2e460d7 100644
--- a/src/backend/keys/cswordldkey.h
+++ b/src/backend/keys/cswordldkey.h
@@ -10,23 +10,24 @@
#ifndef CSWORDLDKEY_H
#define CSWORDLDKEY_H
-#include "cswordkey.h"
-class CSwordModuleInfo;
+#include "backend/keys/cswordkey.h"
-//Qt
#include <QString>
-//Sword includes
+// Sword includes:
#include <swkey.h>
+
+class CSwordModuleInfo;
+
/**
* This class is the implementation of CSwordKey used for dictionaries and lexicons.
*
* CSwordLDKey is the implementation of CKey for Lexicons and dictionaries.
* It provides a simple interface to set the current key,
* to get the text for the key and functions to get the next and previous items
- * of the used module in comparision to the current key.<BR>
- * Here's an example how to use this class:<BR>
+ * of the used module in comparision to the current key.<br/>
+ * Here's an example how to use this class:<br/>
* @code
* CSwordLexiconModuleInfo* m_module = backend()->findModuleByName("ISBE");
* CSwordLDKey ldKey(m_module);
diff --git a/src/backend/keys/cswordtreekey.cpp b/src/backend/keys/cswordtreekey.cpp
index e845bf6..e1ac9c3 100644
--- a/src/backend/keys/cswordtreekey.cpp
+++ b/src/backend/keys/cswordtreekey.cpp
@@ -7,12 +7,12 @@
*
**********/
-#include "cswordtreekey.h"
-#include "backend/drivers/cswordbookmoduleinfo.h"
+#include "backend/keys/cswordtreekey.h"
+#include <QDebug>
#include <QTextCodec>
+#include "backend/drivers/cswordbookmoduleinfo.h"
-#include <QDebug>
CSwordTreeKey::CSwordTreeKey( const CSwordTreeKey& k ) : CSwordKey(k), TreeKeyIdx(k) {}
diff --git a/src/backend/keys/cswordtreekey.h b/src/backend/keys/cswordtreekey.h
index c0c9e45..9a60d5b 100644
--- a/src/backend/keys/cswordtreekey.h
+++ b/src/backend/keys/cswordtreekey.h
@@ -10,12 +10,12 @@
#ifndef CSWORDTREEKEYIDX_H
#define CSWORDTREEKEYIDX_H
-//BibleTime
-#include "cswordkey.h"
+#include "backend/keys/cswordkey.h"
-//Sword
+// Sword includes:
#include <treekeyidx.h>
+
class CSwordModuleInfo;
/** BibleTime's implementation of Sword's TreeKeyIdx class.
diff --git a/src/backend/keys/cswordversekey.cpp b/src/backend/keys/cswordversekey.cpp
index 01cfd31..84c0b29 100644
--- a/src/backend/keys/cswordversekey.cpp
+++ b/src/backend/keys/cswordversekey.cpp
@@ -7,17 +7,19 @@
*
**********/
-#include "cswordversekey.h"
-#include "backend/drivers/cswordbiblemoduleinfo.h"
-#include "backend/drivers/cswordcommentarymoduleinfo.h"
+#include "backend/keys/cswordversekey.h"
-//Qt
#include <QStringList>
+#include <QDebug>
-//Sword
+#include "backend/drivers/cswordbiblemoduleinfo.h"
+#include "backend/drivers/cswordcommentarymoduleinfo.h"
+
+// Sword includes:
#include <swmodule.h>
#include <localemgr.h>
+
CSwordVerseKey::CSwordVerseKey( CSwordModuleInfo* const module ) :
CSwordKey(module) {
if ( CSwordBibleModuleInfo* bible = dynamic_cast<CSwordBibleModuleInfo*>(module) ) {
@@ -26,9 +28,12 @@ CSwordVerseKey::CSwordVerseKey( CSwordModuleInfo* const module ) :
key( bible->lowerBound().key() );
}
+ this->VerseKey::setAutoNormalize(true);
}
-CSwordVerseKey::CSwordVerseKey( const CSwordVerseKey& k ) : CSwordKey(k), VerseKey(k) {}
+CSwordVerseKey::CSwordVerseKey( const CSwordVerseKey& k ) : CSwordKey(k), VerseKey(k) {
+ this->VerseKey::setAutoNormalize(true);
+}
CSwordVerseKey::CSwordVerseKey( const VerseKey* const k, CSwordModuleInfo* const module ) : CSwordKey(module), VerseKey(*k) {}
diff --git a/src/backend/keys/cswordversekey.h b/src/backend/keys/cswordversekey.h
index 0f286dc..bfbfa25 100644
--- a/src/backend/keys/cswordversekey.h
+++ b/src/backend/keys/cswordversekey.h
@@ -10,15 +10,16 @@
#ifndef CSWORDVERSEKEY_H
#define CSWORDVERSEKEY_H
-#include "cswordkey.h"
-class CSwordModuleInfo;
+#include "backend/keys/cswordkey.h"
-//Qt
#include <QString>
-//Sword
+// Sword includes:
#include <versekey.h>
+
+class CSwordModuleInfo;
+
/**
* The CSwordKey implementation for verse based modules (Bibles and Commentaries)
*
diff --git a/src/backend/managers/btstringmgr.cpp b/src/backend/managers/btstringmgr.cpp
index a4fe381..a2abc7f 100644
--- a/src/backend/managers/btstringmgr.cpp
+++ b/src/backend/managers/btstringmgr.cpp
@@ -7,7 +7,8 @@
*
**********/
-#include "btstringmgr.h"
+#include "backend/managers/btstringmgr.h"
+
char* BTStringMgr::upperUTF8(char* text, unsigned int maxlen) const {
const int max = (maxlen > 0) ? maxlen : strlen(text);
diff --git a/src/backend/managers/btstringmgr.h b/src/backend/managers/btstringmgr.h
index 73b784d..7f44df8 100644
--- a/src/backend/managers/btstringmgr.h
+++ b/src/backend/managers/btstringmgr.h
@@ -10,11 +10,11 @@
#ifndef BTSTRINGMGR_H
#define BTSTRINGMGR_H
-//Sword includes
+#include <QString>
+
+// Sword includes:
#include <stringmgr.h>
-//Qt includes
-#include <QString>
/** Unicode string manager implementation.
* This is the StringManager implementation which works with QString.
diff --git a/src/backend/managers/cdisplaytemplatemgr.cpp b/src/backend/managers/cdisplaytemplatemgr.cpp
index 4722734..11d2a59 100644
--- a/src/backend/managers/cdisplaytemplatemgr.cpp
+++ b/src/backend/managers/cdisplaytemplatemgr.cpp
@@ -7,20 +7,19 @@
*
**********/
-#include "cdisplaytemplatemgr.h"
+#include "backend/managers/cdisplaytemplatemgr.h"
+#include <QDebug>
+#include <QFile>
+#include <QFileInfo>
+#include <QStringList>
+#include <QTextStream>
+#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/clanguagemgr.h"
-#include "backend/config/cbtconfig.h"
#include "util/cpointers.h"
-#include "util/directoryutil.h"
+#include "util/directory.h"
-//Qt
-#include <QStringList>
-#include <QFile>
-#include <QFileInfo>
-#include <QTextStream>
-#include <QDebug>
CDisplayTemplateMgr::CDisplayTemplateMgr() {
loadTemplates();
@@ -68,7 +67,7 @@ const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QStr
if (moduleCount >= 2) {
//create header for the modules
- qDebug("There were more than 1 module, create headers");
+ qDebug() << "There were more than 1 module, create headers";
QString header;
QList<CSwordModuleInfo*>::iterator end_it = settings.modules.end();
@@ -92,7 +91,7 @@ const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QStr
CLanguageMgr::LangMap langMap = CPointers::languageMgr()->availableLanguages();
qDebug() << "langMap length:" << langMap.count();
- qDebug("loop through langMap");
+ qDebug() << "loop through langMap";
foreach(const CLanguageMgr::Language* lang, langMap) {
//const CLanguageMgr::Language* lang = *it;
//qDebug() << "foreach, lang: ";
@@ -146,12 +145,14 @@ const QString CDisplayTemplateMgr::fillTemplate( const QString& name, const QStr
}
void CDisplayTemplateMgr::loadTemplates() {
+ namespace DU = util::directory;
+
QStringList files;
- foreach (QString file, util::filesystem::DirectoryUtil::getDisplayTemplatesDir().entryList(QStringList("*.tmpl"))) {
- files += util::filesystem::DirectoryUtil::getDisplayTemplatesDir().canonicalPath() + "/" + file;
+ foreach (QString file, DU::getDisplayTemplatesDir().entryList(QStringList("*.tmpl"))) {
+ files += DU::getDisplayTemplatesDir().canonicalPath() + "/" + file;
}
- foreach (QString file, util::filesystem::DirectoryUtil::getUserDisplayTemplatesDir().entryList(QStringList("*.tmpl"))) {
- files += util::filesystem::DirectoryUtil::getUserDisplayTemplatesDir().canonicalPath() + "/" + file;
+ foreach (QString file, DU::getUserDisplayTemplatesDir().entryList(QStringList("*.tmpl"))) {
+ files += DU::getUserDisplayTemplatesDir().canonicalPath() + "/" + file;
}
foreach (QString file, files) {
diff --git a/src/backend/managers/cdisplaytemplatemgr.h b/src/backend/managers/cdisplaytemplatemgr.h
index d048ecd..16725a5 100644
--- a/src/backend/managers/cdisplaytemplatemgr.h
+++ b/src/backend/managers/cdisplaytemplatemgr.h
@@ -10,21 +10,18 @@
#ifndef CDISPLAYTEMPLATEMGR_H
#define CDISPLAYTEMPLATEMGR_H
-//BibleTime include
-class CSwordModuleInfo;
-
-//Qt includes
#include <QMap>
#include <QString>
#include <QStringList>
+
+class CSwordModuleInfo;
+
/**
* Manages the display templates used in the filters and display classes.
* @author The BibleTime team
*/
-
class CDisplayTemplateMgr {
-
public:
/** Settings which are used to fill the content into the template.
*/
diff --git a/src/backend/managers/clanguagemgr.cpp b/src/backend/managers/clanguagemgr.cpp
index e7245e5..5c44405 100644
--- a/src/backend/managers/clanguagemgr.cpp
+++ b/src/backend/managers/clanguagemgr.cpp
@@ -7,15 +7,12 @@
*
**********/
-#include "clanguagemgr.h"
+#include "backend/managers/clanguagemgr.h"
#include "backend/drivers/cswordmoduleinfo.h"
-#include "cswordbackend.h"
-
+#include "backend/managers/cswordbackend.h"
#include "util/cpointers.h"
-//KDE
-
CLanguageMgr::Language::Language() {}
diff --git a/src/backend/managers/clanguagemgr.h b/src/backend/managers/clanguagemgr.h
index 6d3a5c3..de716c0 100644
--- a/src/backend/managers/clanguagemgr.h
+++ b/src/backend/managers/clanguagemgr.h
@@ -10,16 +10,15 @@
#ifndef CLANGUAGEMGR_H
#define CLANGUAGEMGR_H
-//Qt includes
+#include <QHash>
+#include <QList>
#include <QString>
#include <QStringList>
-#include <QList>
-#include <QHash>
+
/** Manages the languages of BibleTime and provides functions to work with them.
* @author The BibleTime team
*/
-
class CLanguageMgr {
public:
diff --git a/src/backend/managers/creferencemanager.h b/src/backend/managers/creferencemanager.h
deleted file mode 100644
index 85131d6..0000000
--- a/src/backend/managers/creferencemanager.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef CREFERENCEMANAGER_H
-#define CREFERENCEMANAGER_H
-
-#include "backend/drivers/cswordmoduleinfo.h"
-
-//Qt includes
-#include <QString>
-
-/** Contains static functions to work with references used for Drag & Drop and for hyperlinks used in our
- * rendered HTML code.
- * @author The BibleTime team
- */
-
-class CReferenceManager {
-
- public:
- enum Type {
- Bible, /**< Bibles */
- Commentary, /**< Commentary */
- Lexicon, /**< Lexicon */
- GenericBook, /**< Generic Book */
- MorphHebrew, /**< Module for hebrew morphology*/
- MorphGreek, /**< Module for greek morphology */
- StrongsHebrew, /**< Module for hebrew strongs */
- StrongsGreek, /**< Module for greek strongs */
- Unknown /**< Unknown */
- };
-
- /** Turn a hyperlink into module, key and type.
- * Decodes the given hyperlink into module, key and type.
- * @param hyperlink The hyperlink to decode
- * @param module The string which will contain the module name after decoding
- * @param key The string which will contain the key after decoding
- * @param type The type param will contain the reference type after decoding
- */
- static bool decodeHyperlink( const QString& hyperlink, QString& module, QString& key, Type& type);
- /**
- * Returns a hyperlink used to be embedded in the display windows.
- * At the moment the format is sword://module/key
- * @param module The module which is used to encode the hyperlink
- * @param key The key which is used to encode the hyperlink
- * @param type The type which is used to encode the hyperlink
- * @return The encoded hyperlink
- */
- static const QString encodeHyperlink( const QString module, const QString key, const Type type);
- /**
- * Puts a module Name and a Reference together in the 'draggable' form
- * (module)reference
- * @param module The name of the module
- * @param reference The key reference as text
- * @return The encoded reference using module and reference
- * @author Martin Gruner
- */
- static const QString encodeReference(const QString &module, const QString &reference);
- /**
- * decodes a 'draggable' reference into a modulename and a reference
- * @author Martin Gruner
- */
- static void decodeReference(QString &dragreference, QString &module, QString &reference);
- /**
- * Returns true if the parameter is a hyperlink.
- * @param hyperlink The string which is tested
- * @return True if the passed string is a hyperlink
- */
- static bool isHyperlink( const QString& hyperlink );
- /**
- * Returns the preferred module name for the given type.
- * @param type The type which is used to find the module
- * @return The default module name for the passed type
- */
- static const QString preferredModule( const Type type );
- /**
- * Returns the type of the passed module type
- * @param type The CSwordModuleInfo module typpe
- * @return The ReferenceManager type
- */
- static CReferenceManager::Type typeFromModule( const CSwordModuleInfo::ModuleType type );
-
-
- struct ParseOptions {
- QString refDestinationModule;
- QString refBase; /* only valid for verse based destination modules*/
- QString sourceLanguage; /* only valid for verse based destination modules*/
- QString destinationLanguage; /* only valid for verse based destination modules*/
-
- ParseOptions() {
- destinationLanguage = "en";
- };
- };
-
- /** Parses the given verse references using the given language and the module.
- * @param moduleName The name of the module to use. Required for the language checking before parsing the key.
- * @param ref The verse reference.
- * @param lang The language of the verse reference
- * @param newLang The language of the reference, which will be returned. For example: If BibleTime using an english environment parses a spanish ref (lang=es) the returned ref should be in english (newLang=en), because his english standard module only understands en.
- */
- static const QString parseVerseReference( const QString& ref, const ParseOptions& options);
-};
-
-#endif
-
diff --git a/src/backend/managers/cswordbackend.cpp b/src/backend/managers/cswordbackend.cpp
index 6420627..ee74e4a 100644
--- a/src/backend/managers/cswordbackend.cpp
+++ b/src/backend/managers/cswordbackend.cpp
@@ -7,43 +7,40 @@
*
**********/
-#include "cswordbackend.h"
+#include "backend/managers/cswordbackend.h"
-#include "backend/rendering/centrydisplay.h"
-#include "backend/rendering/cbookdisplay.h"
-#include "backend/rendering/cchapterdisplay.h"
+#include <QDebug>
+#include <QDir>
+#include <QFileInfo>
+#include <QSet>
+#include <QString>
+#include <QTextCodec>
+#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordbiblemoduleinfo.h"
+#include "backend/drivers/cswordbookmoduleinfo.h"
#include "backend/drivers/cswordcommentarymoduleinfo.h"
#include "backend/drivers/cswordlexiconmoduleinfo.h"
-#include "backend/drivers/cswordbookmoduleinfo.h"
-#include "backend/filters/bt_thmlhtml.h"
-#include "backend/filters/bt_thmlplain.h"
-#include "backend/filters/bt_osishtml.h"
#include "backend/filters/bt_gbfhtml.h"
+#include "backend/filters/bt_osishtml.h"
+#include "backend/filters/bt_teihtml.h"
#include "backend/filters/bt_plainhtml.h"
+#include "backend/filters/bt_thmlhtml.h"
+#include "backend/filters/bt_thmlplain.h"
#include "backend/filters/osismorphsegmentation.h"
+#include "backend/rendering/cbookdisplay.h"
+#include "backend/rendering/cchapterdisplay.h"
+#include "backend/rendering/centrydisplay.h"
+#include "util/directory.h"
-#include "backend/config/cbtconfig.h"
-
-#include "util/directoryutil.h"
-
-#include <dirent.h>
-
-//Qt
-#include <QString>
-#include <QDir>
-#include <QFileInfo>
-#include <QSet>
-#include <QDebug>
-
-//Sword
-#include <swdisp.h>
-#include <swfiltermgr.h>
+// Sword includes:
#include <encfiltmgr.h>
-#include <rtfhtml.h>
#include <filemgr.h>
-#include <utilstr.h>
+#include <rtfhtml.h>
+#include <swdisp.h>
+#include <swfiltermgr.h>
#include <swfilter.h>
+#include <utilstr.h>
+
using namespace Filters;
using namespace Rendering;
@@ -56,6 +53,7 @@ CSwordBackend::CSwordBackend()
m_filters.plain = new BT_PLAINHTML();
m_filters.thml = new BT_ThMLHTML();
m_filters.osis = new BT_OSISHTML();
+ m_filters.tei = new BT_TEIHTML();
m_displays.entry = new CEntryDisplay();
m_displays.chapter = new CChapterDisplay();
@@ -70,6 +68,7 @@ CSwordBackend::CSwordBackend(const QString& path, const bool augmentHome)
m_filters.plain = new BT_PLAINHTML();
m_filters.thml = new BT_ThMLHTML();
m_filters.osis = new BT_OSISHTML();
+ m_filters.tei = new BT_TEIHTML();
m_displays.entry = new CEntryDisplay();
m_displays.chapter = new CChapterDisplay();
@@ -85,6 +84,7 @@ CSwordBackend::~CSwordBackend() {
delete m_filters.plain;
delete m_filters.thml;
delete m_filters.osis;
+ delete m_filters.tei;
delete m_displays.book;
delete m_displays.chapter;
@@ -194,20 +194,24 @@ void CSwordBackend::AddRenderFilters(sword::SWModule *module, sword::ConfigEntMa
sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
moduleDriver = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
- if (sourceformat == "GBF") {
- module->AddRenderFilter(m_filters.gbf);
- noDriver = false;
- }
- else if (sourceformat == "PLAIN") {
- module->AddRenderFilter(m_filters.plain);
+ if (sourceformat == "OSIS") {
+ module->AddRenderFilter(m_filters.osis);
noDriver = false;
}
else if (sourceformat == "ThML") {
module->AddRenderFilter(m_filters.thml);
noDriver = false;
}
- else if (sourceformat == "OSIS") {
- module->AddRenderFilter(m_filters.osis);
+ else if (sourceformat == "TEI") {
+ module->AddRenderFilter(m_filters.tei);
+ noDriver = false;
+ }
+ else if (sourceformat == "GBF") {
+ module->AddRenderFilter(m_filters.gbf);
+ noDriver = false;
+ }
+ else if (sourceformat == "PLAIN") {
+ module->AddRenderFilter(m_filters.plain);
noDriver = false;
}
@@ -325,30 +329,20 @@ CSwordModuleInfo* CSwordBackend::findModuleByPointer(const CSwordModuleInfo* con
/** Returns our local config object to store the cipher keys etc. locally for each user. The values of the config are merged with the global config. */
bool CSwordBackend::moduleConfig(const QString& module, sword::SWConfig& moduleConfig) {
- sword::SectionMap::iterator section;
- DIR *dir = opendir(configPath);
-
- struct dirent *ent;
+ sword::SectionMap::iterator section;
+ QDir dir(QString::fromUtf8(configPath));
bool foundConfig = false;
- QString modFile;
-
- if (dir) { // find and update .conf file
- rewinddir(dir);
- while ((ent = readdir(dir)) && !foundConfig) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- modFile = QString(configPath);
- modFile.append("/");
- modFile.append( QString::fromLocal8Bit(ent->d_name) );
+ QFileInfoList list = dir.entryInfoList();
+ if (dir.isReadable()) {
+ for (int i = 0; i < list.size(); ++i) {
+ QFileInfo fileInfo = list.at(i);
- moduleConfig = sword::SWConfig( modFile.toLocal8Bit().constData() );
- section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
- foundConfig = ( section != moduleConfig.Sections.end() );
- }
+ moduleConfig = sword::SWConfig( fileInfo.absoluteFilePath().toLocal8Bit().constData() );
+ section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
+ foundConfig = ( section != moduleConfig.Sections.end() );
}
-
- closedir(dir);
}
else { //try to read mods.conf
moduleConfig = sword::SWConfig("");//global config
@@ -367,25 +361,17 @@ bool CSwordBackend::moduleConfig(const QString& module, sword::SWConfig& moduleC
if (!foundConfig && configType != 2) { //search in $HOME/.sword/
- QString myPath = util::filesystem::DirectoryUtil::getUserHomeDir().absolutePath();
- myPath.append("/.sword/mods.d");
- dir = opendir(myPath.toUtf8().constData());
-
- if (dir) {
- rewinddir(dir);
-
- while ((ent = readdir(dir)) && !foundConfig) {
- if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
- modFile = myPath;
- modFile.append('/');
- modFile.append(ent->d_name);
- moduleConfig = sword::SWConfig( modFile.toLocal8Bit().constData() );
- section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
- foundConfig = ( section != moduleConfig.Sections.end() );
- }
- }
+ QString myPath = util::directory::getUserHomeSwordModsDir().absolutePath();
+ dir.setPath(myPath);
- closedir(dir);
+ QFileInfoList list = dir.entryInfoList();
+ if (dir.isReadable()) {
+ for (int i = 0; i < list.size(); ++i) {
+ QFileInfo fileInfo = list.at(i);
+ moduleConfig = sword::SWConfig( fileInfo.absoluteFilePath().toLocal8Bit().constData() );
+ section = moduleConfig.Sections.find( module.toLocal8Bit().constData() );
+ foundConfig = ( section != moduleConfig.Sections.end() );
+ }
}
}
@@ -526,46 +512,91 @@ void CSwordBackend::reloadModules(SetupChangedReason reason) {
initModules(reason);
}
-const QStringList CSwordBackend::swordDirList() {
- QSet<QString> ret;
- const QString home = util::filesystem::DirectoryUtil::getUserHomeDir().absolutePath();
+// Get one or more shared sword config (sword.conf) files
+QStringList CSwordBackend::getSharedSwordConfigFiles() const
+{
+ QStringList configPath;
+#ifdef Q_WS_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");
+#else
+ // /etc/sword.conf, /usr/local/etc/sword.conf
+ configPath = QString(globalConfPath).split(":");
+#endif
+ return configPath;
+}
- //return a list of used Sword dirs. Useful for the installer
- QString configPath = QString("%1/.sword/sword.conf").arg(home);
+// Get the private sword directory
+QString CSwordBackend::getPrivateSwordConfigPath() const
+{
+ return util::directory::getUserHomeSwordDir().absolutePath();
+}
- if (!QFile(configPath).exists()) {
- configPath = globalConfPath; //e.g. /etc/sword.conf, /usr/local/etc/sword.conf
- }
+QString CSwordBackend::getPrivateSwordConfigFile() const
+{
+ QString file(getPrivateSwordConfigPath() + "/sword.conf");
+ return util::directory::convertDirSeparators(file);
+}
- QStringList configs = configPath.split(":");
+// 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;
+ QStringList configs;
+
+ if (QFile(getPrivateSwordConfigFile()).exists()) {
+ // Use the private sword.conf file:
+ configs << getPrivateSwordConfigFile();
+ } 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
+ ones will not be searched again.
+ */
+ configs = getSharedSwordConfigFiles();
+
+#ifdef Q_WS_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
+ shared path and it will not automatically come back.
+ */
+ swordDirSet << DU::convertDirSeparators(QString(getenv("SWORD_PATH")));
+#endif
+ }
- for (QStringList::const_iterator it = configs.begin(); it != configs.end(); ++it) {
+ // 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()) {
continue;
}
- //get all DataPath and AugmentPath entries from the config file and add them to the list
- sword::SWConfig conf( (*it).toUtf8().constData() );
- ret << conf["Install"]["DataPath"].c_str();
- sword::ConfigEntMap group = conf["Install"];
- sword::ConfigEntMap::iterator start = group.equal_range("AugmentPath").first;
- sword::ConfigEntMap::iterator end = group.equal_range("AugmentPath").second;
-
- for (sword::ConfigEntMap::const_iterator it = start; it != end; ++it) {
- ret << QDir(it->second.c_str()).absolutePath(); //added augment path
+ /*
+ Get all DataPath and AugmentPath entries from the config file and add
+ them to the list:
+ */
+ 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();
+ // Added augment path:
+ swordDirSet << QDir(QTextCodec::codecForLocale()->toUnicode(it->second.c_str())).absolutePath();
}
}
- if (!home.isEmpty()) {
- // This is added to the set if not there already. Notice that
- // this prevents duplication only if the QDir::absolutePath() returns
- // string without the prepended "/".
- ret << home + "/.sword";
- }
-
- return ret.values();
-}
+ // Add the private sword path to the set if not there already:
+ swordDirSet << getPrivateSwordConfigPath();
-void CSwordBackend::notifyChange(SetupChangedReason reason) {
- emit sigSwordSetupChanged(reason);
+ return swordDirSet.values();
}
diff --git a/src/backend/managers/cswordbackend.h b/src/backend/managers/cswordbackend.h
index 9169c33..3120694 100644
--- a/src/backend/managers/cswordbackend.h
+++ b/src/backend/managers/cswordbackend.h
@@ -10,17 +10,14 @@
#ifndef CSWORDBACKEND_H
#define CSWORDBACKEND_H
-//BibleTime includes
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/bookshelfmodel/btbookshelfmodel.h"
-
-//Qt includes
-#include <QObject>
#include <QMap>
+#include <QObject>
#include <QString>
#include <QStringList>
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/bookshelfmodel/btbookshelfmodel.h"
-//Sword includes
+// Sword includes:
#include <swmgr.h>
#include <swbuf.h>
#include <swmodule.h>
@@ -28,7 +25,6 @@
#include <localemgr.h>
#include <utilstr.h>
-//forward declarations
namespace Rendering {
class CEntryDisplay;
class CChapterDisplay;
@@ -43,7 +39,6 @@ class CBookDisplay;
* @author The BibleTime team
* @version $Id: cswordbackend.h,v 1.58 2007/03/14 21:32:47 joachim Exp $
*/
-
class CSwordBackend : public QObject, public sword::SWMgr {
Q_OBJECT
public:
@@ -219,12 +214,7 @@ class CSwordBackend : public QObject, public sword::SWMgr {
/** Sword prefix list.
* @return A list of all known Sword prefix dirs
*/
- const QStringList swordDirList();
-
- /** Emits the sigSwordSetupChanged signal.
- * This can be called directly from outside if there is no need to reload the backend.
- */
- void notifyChange(SetupChangedReason reason);
+ QStringList swordDirList() const;
signals:
void sigSwordSetupChanged(CSwordBackend::SetupChangedReason reason);
@@ -240,6 +230,10 @@ class CSwordBackend : public QObject, public sword::SWMgr {
*/
void filterInit();
+ QStringList getSharedSwordConfigFiles() const;
+ QString getPrivateSwordConfigPath() const;
+ QString getPrivateSwordConfigFile() const;
+
private:
// Filters
struct Filters {
@@ -247,6 +241,7 @@ class CSwordBackend : public QObject, public sword::SWMgr {
sword::SWFilter* plain;
sword::SWFilter* thml;
sword::SWFilter* osis;
+ sword::SWFilter* tei;
} m_filters;
struct Displays {
diff --git a/src/backend/managers/creferencemanager.cpp b/src/backend/managers/referencemanager.cpp
index 41f8954..4fc5e53 100644
--- a/src/backend/managers/creferencemanager.cpp
+++ b/src/backend/managers/referencemanager.cpp
@@ -7,20 +7,19 @@
*
**********/
-#include "creferencemanager.h"
-#include "backend/keys/cswordversekey.h"
+#include "backend/managers/referencemanager.h"
-#include "backend/config/cbtconfig.h"
-#include "util/cpointers.h"
+#include <algorithm>
-//QT
#include <QRegExp>
+#include <QDebug>
+#include "backend/config/cbtconfig.h"
+#include "backend/keys/cswordversekey.h"
+#include "util/cpointers.h"
-//stl
-#include <algorithm> // STL algorithms class library
/** Returns a hyperlink used to be imbedded in the display windows. At the moment the format is sword://module/key */
-const QString CReferenceManager::encodeHyperlink( const QString moduleName, const QString key, const CReferenceManager::Type type) {
+const QString ReferenceManager::encodeHyperlink( const QString moduleName, const QString key, const ReferenceManager::Type type) {
QString ret = QString::null;
switch (type) {
@@ -111,7 +110,7 @@ const QString CReferenceManager::encodeHyperlink( const QString moduleName, cons
}
/** Decodes the given hyperlink to module and key. */
-bool CReferenceManager::decodeHyperlink( const QString& hyperlink, QString& module, QString& key, CReferenceManager::Type& type ) {
+bool ReferenceManager::decodeHyperlink( const QString& hyperlink, QString& module, QString& key, ReferenceManager::Type& type ) {
/**
* We have to decide between three types of URLS: sword://Type/Module/Key, morph://Testament/key and strongs://Testament/Key
*/
@@ -130,19 +129,19 @@ bool CReferenceManager::decodeHyperlink( const QString& hyperlink, QString& modu
ref = ref.mid(8);
if (ref.left(5).toLower() == "bible") { //a bible hyperlink
- type = CReferenceManager::Bible;
+ type = ReferenceManager::Bible;
ref = ref.mid(6); //inclusive trailing slash
}
else if (ref.left(10).toLower() == "commentary") { // a Commentary hyperlink
- type = CReferenceManager::Commentary;
+ type = ReferenceManager::Commentary;
ref = ref.mid(11); //inclusive trailing slash
}
else if (ref.left(7).toLower() == "lexicon") { // a Lexicon hyperlink
- type = CReferenceManager::Lexicon;
+ type = ReferenceManager::Lexicon;
ref = ref.mid(8); //inclusive trailing slash
}
else if (ref.left(4).toLower() == "book") { // a Book hyperlink
- type = CReferenceManager::GenericBook;
+ type = ReferenceManager::GenericBook;
ref = ref.mid(5); //inclusive trailing slash
}
@@ -204,11 +203,11 @@ bool CReferenceManager::decodeHyperlink( const QString& hyperlink, QString& modu
switch (preType) {
case IsMorph:
- type = CReferenceManager::MorphHebrew;
+ type = ReferenceManager::MorphHebrew;
break;
case IsStrongs:
- type = CReferenceManager::StrongsHebrew;
+ type = ReferenceManager::StrongsHebrew;
break;
}
}
@@ -216,11 +215,11 @@ bool CReferenceManager::decodeHyperlink( const QString& hyperlink, QString& modu
switch (preType) {
case IsMorph:
- type = CReferenceManager::MorphGreek;
+ type = ReferenceManager::MorphGreek;
break;
case IsStrongs:
- type = CReferenceManager::StrongsGreek;
+ type = ReferenceManager::StrongsGreek;
break;
}
}
@@ -238,12 +237,12 @@ bool CReferenceManager::decodeHyperlink( const QString& hyperlink, QString& modu
return true;
}
-const QString CReferenceManager::encodeReference(const QString &module, const QString &reference) {
+const QString ReferenceManager::encodeReference(const QString &module, const QString &reference) {
//return QString("(%1)%2").arg(module).arg(reference);
return QString("(").append(module).append(")").append(reference);
}
-void CReferenceManager::decodeReference(QString &dragreference, QString &module, QString &reference) {
+void ReferenceManager::decodeReference(QString &dragreference, QString &module, QString &reference) {
const int pos = dragreference.indexOf(")");
const QString fallbackModule = dragreference.mid( 1, pos - 1);
dragreference = dragreference.mid(pos + 1);
@@ -253,57 +252,57 @@ void CReferenceManager::decodeReference(QString &dragreference, QString &module,
}
/** Returns true if the parameter is a hyperlink. */
-bool CReferenceManager::isHyperlink( const QString& hyperlink ) {
+bool ReferenceManager::isHyperlink( const QString& hyperlink ) {
return ( hyperlink.left(8) == "sword://")
|| (hyperlink.left(10) == "strongs://")
|| (hyperlink.left(8) == "morph://");
}
/** Returns the preferred module name for the given type. */
-const QString CReferenceManager::preferredModule( const CReferenceManager::Type type ) {
+const QString ReferenceManager::preferredModule( const ReferenceManager::Type type ) {
QString moduleName = QString::null;
CSwordModuleInfo* module = 0;
switch (type) {
- case CReferenceManager::Bible:
+ case ReferenceManager::Bible:
module = CBTConfig::get
( CBTConfig::standardBible );
break;
- case CReferenceManager::Commentary:
+ case ReferenceManager::Commentary:
module = CBTConfig::get
( CBTConfig::standardCommentary );
break;
- case CReferenceManager::Lexicon:
+ case ReferenceManager::Lexicon:
module = CBTConfig::get
( CBTConfig::standardLexicon );
break;
- case CReferenceManager::StrongsHebrew:
+ case ReferenceManager::StrongsHebrew:
module = CBTConfig::get
( CBTConfig::standardHebrewStrongsLexicon );
break;
- case CReferenceManager::StrongsGreek:
+ case ReferenceManager::StrongsGreek:
module = CBTConfig::get
( CBTConfig::standardGreekStrongsLexicon );
break;
- case CReferenceManager::MorphHebrew:
+ case ReferenceManager::MorphHebrew:
module = CBTConfig::get
( CBTConfig::standardHebrewMorphLexicon );
break;
- case CReferenceManager::MorphGreek:
+ case ReferenceManager::MorphGreek:
module = CBTConfig::get
( CBTConfig::standardGreekMorphLexicon );
@@ -319,28 +318,28 @@ const QString CReferenceManager::preferredModule( const CReferenceManager::Type
}
/** No descriptions */
-CReferenceManager::Type CReferenceManager::typeFromModule( const CSwordModuleInfo::ModuleType type) {
+ReferenceManager::Type ReferenceManager::typeFromModule( const CSwordModuleInfo::ModuleType type) {
switch (type) {
case CSwordModuleInfo::Bible:
- return CReferenceManager::Bible;
+ return ReferenceManager::Bible;
case CSwordModuleInfo::Commentary:
- return CReferenceManager::Commentary;
+ return ReferenceManager::Commentary;
case CSwordModuleInfo::Lexicon:
- return CReferenceManager::Lexicon;
+ return ReferenceManager::Lexicon;
case CSwordModuleInfo::GenericBook:
- return CReferenceManager::GenericBook;
+ return ReferenceManager::GenericBook;
default:
- return CReferenceManager::Unknown;
+ return ReferenceManager::Unknown;
}
}
/** Parses the given verse references using the given language and the module.*/
-const QString CReferenceManager::parseVerseReference( const QString& ref, const CReferenceManager::ParseOptions& options) {
+const QString ReferenceManager::parseVerseReference( const QString& ref, const ReferenceManager::ParseOptions& options) {
CSwordModuleInfo* const mod = CPointers::backend()->findModuleByName(options.refDestinationModule);
//Q_ASSERT(mod); tested later
@@ -351,7 +350,7 @@ const QString CReferenceManager::parseVerseReference( const QString& ref, const
}
if ((mod->type() != CSwordModuleInfo::Bible) && (mod->type() != CSwordModuleInfo::Commentary)) {
- qDebug("CReferenceManager: Only verse based modules are supported as ref destination module");
+ qDebug() << "CReferenceManager: Only verse based modules are supported as ref destination module";
return QString::null;
}
diff --git a/src/backend/managers/referencemanager.h b/src/backend/managers/referencemanager.h
new file mode 100644
index 0000000..a038130
--- /dev/null
+++ b/src/backend/managers/referencemanager.h
@@ -0,0 +1,106 @@
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
+#ifndef REFERENCEMANAGER_H
+#define REFERENCEMANAGER_H
+
+#include <QString>
+#include "backend/drivers/cswordmoduleinfo.h"
+
+
+/** Contains functions to work with references used for Drag & Drop and for hyperlinks used in our
+ * rendered HTML code.
+ */
+namespace ReferenceManager {
+enum Type {
+ Bible, /**< Bibles */
+ Commentary, /**< Commentary */
+ Lexicon, /**< Lexicon */
+ GenericBook, /**< Generic Book */
+ MorphHebrew, /**< Module for hebrew morphology*/
+ MorphGreek, /**< Module for greek morphology */
+ StrongsHebrew, /**< Module for hebrew strongs */
+ StrongsGreek, /**< Module for greek strongs */
+ Unknown /**< Unknown */
+};
+
+/** Turn a hyperlink into module, key and type.
+* Decodes the given hyperlink into module, key and type.
+* @param hyperlink The hyperlink to decode
+* @param module The string which will contain the module name after decoding
+* @param key The string which will contain the key after decoding
+* @param type The type param will contain the reference type after decoding
+*/
+bool decodeHyperlink( const QString& hyperlink, QString& module, QString& key, Type& type);
+/**
+* Returns a hyperlink used to be embedded in the display windows.
+* At the moment the format is sword://module/key
+* @param module The module which is used to encode the hyperlink
+* @param key The key which is used to encode the hyperlink
+* @param type The type which is used to encode the hyperlink
+* @return The encoded hyperlink
+*/
+const QString encodeHyperlink( const QString module, const QString key, const Type type);
+/**
+* Puts a module Name and a Reference together in the 'draggable' form
+* (module)reference
+* @param module The name of the module
+* @param reference The key reference as text
+* @return The encoded reference using module and reference
+* @author Martin Gruner
+*/
+const QString encodeReference(const QString &module, const QString &reference);
+/**
+* decodes a 'draggable' reference into a modulename and a reference
+* @author Martin Gruner
+*/
+void decodeReference(QString &dragreference, QString &module, QString &reference);
+/**
+* Returns true if the parameter is a hyperlink.
+* @param hyperlink The string which is tested
+* @return True if the passed string is a hyperlink
+*/
+bool isHyperlink( const QString& hyperlink );
+/**
+* Returns the preferred module name for the given type.
+* @param type The type which is used to find the module
+* @return The default module name for the passed type
+*/
+const QString preferredModule( const Type type );
+/**
+* Returns the type of the passed module type
+* @param type The CSwordModuleInfo module typpe
+* @return The ReferenceManager type
+*/
+ReferenceManager::Type typeFromModule( const CSwordModuleInfo::ModuleType type );
+
+
+struct ParseOptions {
+ QString refDestinationModule;
+ QString refBase; /* only valid for verse based destination modules*/
+ QString sourceLanguage; /* only valid for verse based destination modules*/
+ QString destinationLanguage; /* only valid for verse based destination modules*/
+
+ ParseOptions() {
+ destinationLanguage = "en";
+ };
+};
+
+/** Parses the given verse references using the given language and the module.
+* @param moduleName The name of the module to use. Required for the language checking before parsing the key.
+* @param ref The verse reference.
+* @param lang The language of the verse reference
+* @param newLang The language of the reference, which will be returned. For example: If BibleTime using an english environment parses a spanish ref (lang=es) the returned ref should be in english (newLang=en), because his english standard module only understands en.
+*/
+const QString parseVerseReference( const QString& ref, const ParseOptions& options);
+
+};
+
+#endif
+
diff --git a/src/backend/rendering/cbookdisplay.cpp b/src/backend/rendering/cbookdisplay.cpp
index 99990f8..f640628 100644
--- a/src/backend/rendering/cbookdisplay.cpp
+++ b/src/backend/rendering/cbookdisplay.cpp
@@ -7,14 +7,15 @@
*
**********/
-//Backend
-#include "cbookdisplay.h"
-#include "cdisplayrendering.h"
+#include "backend/rendering/cbookdisplay.h"
+
+#include <boost/scoped_ptr.hpp>
+#include <QtAlgorithms>
+
#include "backend/drivers/cswordbookmoduleinfo.h"
#include "backend/keys/cswordtreekey.h"
+#include "backend/rendering/cdisplayrendering.h"
-//Util
-#include <boost/scoped_ptr.hpp>
/** Returns the rendered text using the modules in the list and using the key parameter. The displayoptions and filter options are used, too. */
const QString Rendering::CBookDisplay::text( const QList<CSwordModuleInfo*>& modules, const QString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) {
@@ -46,6 +47,8 @@ const QString Rendering::CBookDisplay::text( const QList<CSwordModuleInfo*>& mod
const QString renderedText = render.renderKeyTree(tree);
key->setOffset( offset );
+
+ qDeleteAll(tree); // Dispose of the heap allocated objects pointed to in tree.
return renderedText;
};
@@ -75,6 +78,7 @@ const QString Rendering::CBookDisplay::text( const QList<CSwordModuleInfo*>& mod
const QString renderedText = render.renderKeyTree(tree);
key->setOffset( offset );
+ qDeleteAll(tree); // Dispose of the heap allocated objects pointed to in tree.
return renderedText;
};
@@ -91,6 +95,7 @@ const QString Rendering::CBookDisplay::text( const QList<CSwordModuleInfo*>& mod
const QString renderedText = render.renderKeyTree(tree);
key->setOffset( offset );
+ qDeleteAll(tree); // Dispose of the heap allocated objects pointed to in tree.
return renderedText;
};
};
@@ -109,6 +114,7 @@ const QString Rendering::CBookDisplay::text( const QList<CSwordModuleInfo*>& mod
key->setOffset( offset ); //restore key
+ qDeleteAll(tree); // Dispose of the heap allocated objects pointed to in tree.
return renderedText;
}
diff --git a/src/backend/rendering/cbookdisplay.h b/src/backend/rendering/cbookdisplay.h
index 35d7221..832249f 100644
--- a/src/backend/rendering/cbookdisplay.h
+++ b/src/backend/rendering/cbookdisplay.h
@@ -10,10 +10,10 @@
#ifndef RENDERINGCBOOKDISPLAY_H
#define RENDERINGCBOOKDISPLAY_H
-#include "centrydisplay.h"
-#include "ctextrendering.h"
-//TODO: It would be sufficient to forward declare CTextRendering and CTextRendering::KeyTree
-//but I don't know how :(
+#include "backend/rendering/centrydisplay.h"
+
+#include "backend/rendering/ctextrendering.h"
+
class CSwordTreeKey;
diff --git a/src/backend/rendering/cchapterdisplay.cpp b/src/backend/rendering/cchapterdisplay.cpp
index f96bada..74063cf 100644
--- a/src/backend/rendering/cchapterdisplay.cpp
+++ b/src/backend/rendering/cchapterdisplay.cpp
@@ -7,11 +7,12 @@
*
**********/
-//Backend
-#include "cchapterdisplay.h"
-#include "cdisplayrendering.h"
-#include "backend/keys/cswordversekey.h"
+#include "backend/rendering/cchapterdisplay.h"
+
#include "backend/drivers/cswordbiblemoduleinfo.h"
+#include "backend/keys/cswordversekey.h"
+#include "backend/rendering/cdisplayrendering.h"
+
const QString Rendering::CChapterDisplay::text( const QList<CSwordModuleInfo*>& modules, const QString& keyName, const CSwordBackend::DisplayOptions displayOptions, const CSwordBackend::FilterOptions filterOptions ) {
Q_ASSERT( modules.count() >= 1 );
diff --git a/src/backend/rendering/cchapterdisplay.h b/src/backend/rendering/cchapterdisplay.h
index 916f257..3b3d363 100644
--- a/src/backend/rendering/cchapterdisplay.h
+++ b/src/backend/rendering/cchapterdisplay.h
@@ -10,7 +10,8 @@
#ifndef RENDERINGCCHAPTERDISPLAY_H
#define RENDERINGCCHAPTERDISPLAY_H
-#include "centrydisplay.h"
+#include "backend/rendering/centrydisplay.h"
+
namespace Rendering {
diff --git a/src/backend/rendering/cdisplayrendering.cpp b/src/backend/rendering/cdisplayrendering.cpp
index e648303..cc3f7c9 100644
--- a/src/backend/rendering/cdisplayrendering.cpp
+++ b/src/backend/rendering/cdisplayrendering.cpp
@@ -7,19 +7,17 @@
*
**********/
-#include "cdisplayrendering.h"
+#include "backend/rendering/cdisplayrendering.h"
-#include "backend/managers/cdisplaytemplatemgr.h"
-#include "backend/managers/creferencemanager.h"
+#include <QString>
+#include <QRegExp>
+#include <QDebug>
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
-
+#include "backend/managers/cdisplaytemplatemgr.h"
+#include "backend/managers/referencemanager.h"
#include "util/cpointers.h"
-//Qt
-#include <QString>
-#include <QRegExp>
-#include <QDebug>
namespace Rendering {
@@ -88,8 +86,8 @@ const QString CDisplayRendering::entryLink( const KeyTreeItem& item, CSwordModul
else {
return QString("<a name=\"").append(keyToHTMLAnchor(item.key())).append("\" ")
.append("href=\"")
- .append(CReferenceManager::encodeHyperlink(
- module->name(), item.key(), CReferenceManager::typeFromModule(module->type()))
+ .append(ReferenceManager::encodeHyperlink(
+ module->name(), item.key(), ReferenceManager::typeFromModule(module->type()))
)
.append("\">").append(linkText).append("</a>\n");
}
@@ -108,7 +106,7 @@ const QString CDisplayRendering::keyToHTMLAnchor(const QString& key) {
const QString CDisplayRendering::finishText( const QString& oldText, KeyTree& tree ) {
QList<CSwordModuleInfo*> modules = collectModules(&tree);
- qDebug("CDisplayRendering::finishText");
+ qDebug() << "CDisplayRendering::finishText";
//marking words is very slow, we have to find a better solution
@@ -123,12 +121,12 @@ const QString CDisplayRendering::finishText( const QString& oldText, KeyTree& tr
while (pos != -1) { //word begin found
//qWarning("found word at %i in %i", pos, text.length());
int endPos = pos + 1;
- if (!CToolClass::inHTMLTag(pos+1, text)) { //the re has a positive look ahead which matches one char before the word start
+ if (!util::tool::inHTMLTag(pos+1, text)) { //the re has a positive look ahead which matches one char before the word start
//qWarning("matched %s", text.mid(pos+1, 4).latin1());
//find end of word and put a marker around it
endPos = text.find(QRegExp("\\b|[,.:]"), pos+1);
- if ((endPos != -1) && !CToolClass::inHTMLTag(endPos, text) && (endPos - pos >= 3)) { //reuire wordslonger than 3 chars
+ if ((endPos != -1) && !util::tool::inHTMLTag(endPos, text) && (endPos - pos >= 3)) { //reuire wordslonger than 3 chars
text.insert(endPos, "</span>");
text.insert(pos, "<span class=\"word\">");
diff --git a/src/backend/rendering/cdisplayrendering.h b/src/backend/rendering/cdisplayrendering.h
index d52d6b7..f66e556 100644
--- a/src/backend/rendering/cdisplayrendering.h
+++ b/src/backend/rendering/cdisplayrendering.h
@@ -10,7 +10,8 @@
#ifndef RENDERINGCDISPLAYRENDERING_H
#define RENDERINGCDISPLAYRENDERING_H
-#include "chtmlexportrendering.h"
+#include "backend/rendering/chtmlexportrendering.h"
+
namespace Rendering {
diff --git a/src/backend/rendering/centrydisplay.cpp b/src/backend/rendering/centrydisplay.cpp
index 89743e2..d3a6aac 100644
--- a/src/backend/rendering/centrydisplay.cpp
+++ b/src/backend/rendering/centrydisplay.cpp
@@ -7,22 +7,20 @@
*
**********/
-//BibleTime includes
-#include "centrydisplay.h"
+#include "backend/rendering/centrydisplay.h"
+#include <QApplication>
+#include <QRegExp>
+
+#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordbookmoduleinfo.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
-#include "backend/drivers/cswordbookmoduleinfo.h"
-#include "backend/managers/creferencemanager.h"
#include "backend/managers/cdisplaytemplatemgr.h"
-#include "cdisplayrendering.h"
+#include "backend/managers/referencemanager.h"
+#include "backend/rendering/cdisplayrendering.h"
+#include "backend/rendering/ctextrendering.h"
-#include "backend/config/cbtconfig.h"
-#include <boost/scoped_ptr.hpp>
-
-//Qt includes
-#include <QApplication>
-#include <QRegExp>
using namespace Rendering;
@@ -35,7 +33,8 @@ const QString CEntryDisplay::text( const QList<CSwordModuleInfo*>& modules, cons
//no highlighted key and no extra key link in the text
CTextRendering::KeyTreeItem::Settings normal_settings(false, CTextRendering::KeyTreeItem::Settings::CompleteShort);
CSwordModuleInfo* module = modules.first();
- QString result;
+
+ Rendering::CTextRendering::KeyTree tree;
//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) {
@@ -52,12 +51,19 @@ const QString CEntryDisplay::text( const QList<CSwordModuleInfo*>& modules, cons
if (k1.Chapter() == 1) { //1:1, also prepend 0:0 before that
k1.Chapter(0);
k1.Verse(0);
- if ( k1.rawText().length() > 0 ) result.append( render.renderSingleKey(k1.key(), modules, preverse_settings ) );
+ if ( k1.rawText().length() > 0 ) {
+ tree.append( new Rendering::CTextRendering::KeyTreeItem(k1.key(), modules, preverse_settings) );
+ }
k1.Chapter(1);
}
k1.Verse(0);
- if ( k1.rawText().length() > 0 ) result.append( render.renderSingleKey(k1.key(), modules, preverse_settings ) );
+ if ( k1.rawText().length() > 0 ) {
+ tree.append( new Rendering::CTextRendering::KeyTreeItem(k1.key(), modules, preverse_settings) );
+ }
}
}
- return result.append( render.renderSingleKey(keyName, modules, normal_settings) );
+ tree.append( new Rendering::CTextRendering::KeyTreeItem(keyName, modules, normal_settings) );
+ QString result(render.renderKeyTree(tree));
+ qDeleteAll(tree);
+ return result;
}
diff --git a/src/backend/rendering/centrydisplay.h b/src/backend/rendering/centrydisplay.h
index 0c451b4..5f410a5 100644
--- a/src/backend/rendering/centrydisplay.h
+++ b/src/backend/rendering/centrydisplay.h
@@ -10,18 +10,14 @@
#ifndef CENTRYDISPLAY_H
#define CENTRYDISPLAY_H
-//BibleTime
-//#include "ctextrendering.h"
-class CSwordModuleInfo;
-#include "backend/managers/cswordbackend.h"
-
#include "util/cpointers.h"
-//Sword
+#include <QString>
+#include "backend/managers/cswordbackend.h"
+
+// Sword includes:
#include <swdisp.h>
-//Qt
-#include <QString>
class CSwordModuleInfo;
diff --git a/src/backend/rendering/chtmlexportrendering.cpp b/src/backend/rendering/chtmlexportrendering.cpp
index 7a0833a..e6d0ff6 100644
--- a/src/backend/rendering/chtmlexportrendering.cpp
+++ b/src/backend/rendering/chtmlexportrendering.cpp
@@ -7,18 +7,17 @@
*
**********/
-#include "chtmlexportrendering.h"
+#include "backend/rendering/chtmlexportrendering.h"
-#include "backend/managers/cdisplaytemplatemgr.h"
-#include "backend/managers/clanguagemgr.h"
+#include <boost/scoped_ptr.hpp>
+#include <iostream>
+#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-
+#include "backend/managers/cdisplaytemplatemgr.h"
+#include "backend/managers/clanguagemgr.h"
#include "util/cpointers.h"
-#include <boost/scoped_ptr.hpp>
-#include <iostream>
namespace {
@@ -141,7 +140,7 @@ const QString CHTMLExportRendering::renderEntry( const KeyTreeItem& i, CSwordKey
for (; it != end; ++it) {
preverseHeading = QString::fromUtf8(it->second.c_str());
- //TODO: Take care of the heading type!
+ /// \todo Take care of the heading type!
if (!preverseHeading.isEmpty()) {
entry.append("<div ")
.append(langAttr)
diff --git a/src/backend/rendering/chtmlexportrendering.h b/src/backend/rendering/chtmlexportrendering.h
index 2240cda..065bb85 100644
--- a/src/backend/rendering/chtmlexportrendering.h
+++ b/src/backend/rendering/chtmlexportrendering.h
@@ -10,10 +10,11 @@
#ifndef RENDERINGCHTMLEXPORTRENDERING_H
#define RENDERINGCHTMLEXPORTRENDERING_H
-#include "backend/managers/cswordbackend.h"
-#include "ctextrendering.h"
+#include "backend/rendering/ctextrendering.h"
#include "backend/config/cbtconfig.h"
+#include "backend/managers/cswordbackend.h"
+
namespace Rendering {
diff --git a/src/backend/rendering/cplaintextexportrendering.cpp b/src/backend/rendering/cplaintextexportrendering.cpp
index dbcbff6..fdbf78d 100644
--- a/src/backend/rendering/cplaintextexportrendering.cpp
+++ b/src/backend/rendering/cplaintextexportrendering.cpp
@@ -7,12 +7,11 @@
*
**********/
-//Backend includes
-#include "cplaintextexportrendering.h"
-#include "backend/keys/cswordkey.h"
+#include "backend/rendering/cplaintextexportrendering.h"
-//Util
#include <boost/scoped_ptr.hpp>
+#include "backend/keys/cswordkey.h"
+
namespace Rendering {
@@ -38,7 +37,7 @@ const QString CPlainTextExportRendering::renderEntry( const KeyTreeItem& i, CSwo
key->module(*it);
key->key( i.key() );
- //ToDo: Check this code
+ /// \todo Check this code
entry.append(key->strippedText()).append("\n");
renderedText.append( entry );
}
diff --git a/src/backend/rendering/cplaintextexportrendering.h b/src/backend/rendering/cplaintextexportrendering.h
index acd6054..5ebbb24 100644
--- a/src/backend/rendering/cplaintextexportrendering.h
+++ b/src/backend/rendering/cplaintextexportrendering.h
@@ -10,7 +10,8 @@
#ifndef RENDERINGCPLAINTEXTEXPORTRENDERING_H
#define RENDERINGCPLAINTEXTEXPORTRENDERING_H
-#include "chtmlexportrendering.h"
+#include "backend/rendering/chtmlexportrendering.h"
+
namespace Rendering {
diff --git a/src/backend/rendering/ctextrendering.cpp b/src/backend/rendering/ctextrendering.cpp
index 5fce14b..645b5d6 100644
--- a/src/backend/rendering/ctextrendering.cpp
+++ b/src/backend/rendering/ctextrendering.cpp
@@ -7,24 +7,22 @@
*
**********/
-#include "ctextrendering.h"
+#include "backend/rendering/ctextrendering.h"
-//BibleTime
+#include <boost/scoped_ptr.hpp>
+
+#include <QRegExp>
+#include <QtAlgorithms>
+
+#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
-#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/managers/cdisplaytemplatemgr.h"
-#include "backend/managers/creferencemanager.h"
+#include "backend/managers/referencemanager.h"
-#include <boost/scoped_ptr.hpp>
-#include "util/ctoolclass.h"
-
-//Sword
+// Sword includes:
#include <swkey.h>
-//Qt
-#include <QRegExp>
-
using namespace Rendering;
@@ -229,8 +227,11 @@ const QString CTextRendering::renderKeyRange( const QString& start, const QStrin
//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 */
+ /**
+ \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->Chapter() == 0) { //range was 0:0-1:x, render 0:0 first and jump to 1:0
vk_start->Verse(0);
@@ -238,12 +239,12 @@ const QString CTextRendering::renderKeyRange( const QString& start, const QStrin
vk_start->Chapter(1);
vk_start->Verse(0);
}
- /// \bug Valgrind reports memory leak with allocation:
tree.append( new KeyTreeItem(vk_start->key(), modules, settings) );
ok = vk_start->next(CSwordVerseKey::UseVerse);
}
-
- return renderKeyTree(tree);
+ const QString renderedText = renderKeyTree(tree);
+ qDeleteAll(tree);
+ return renderedText;
}
return QString::null;
@@ -253,7 +254,9 @@ const QString CTextRendering::renderSingleKey( const QString& key, const QList<C
KeyTree tree;
tree.append( new KeyTreeItem(key, moduleList, settings) );
- return renderKeyTree(tree);
+ const QString renderedText = renderKeyTree(tree);
+ qDeleteAll(tree);
+ return renderedText;
}
diff --git a/src/backend/rendering/ctextrendering.h b/src/backend/rendering/ctextrendering.h
index 5d0531b..b6dd5e1 100644
--- a/src/backend/rendering/ctextrendering.h
+++ b/src/backend/rendering/ctextrendering.h
@@ -10,15 +10,12 @@
#ifndef CTEXTRENDERING_H
#define CTEXTRENDERING_H
-//BT includes
-class CSwordModuleInfo;
-//#include "util/autoptrvector.h"
-
-//QT includes
-#include <QString>
#include <QList>
+#include <QString>
+
class CSwordKey;
+class CSwordModuleInfo;
/**
* CTextRendering is BibleTime's place where the actual rendering takes place.
diff --git a/src/bibletime.cpp b/src/bibletime.cpp
index 7286844..687ec23 100644
--- a/src/bibletime.cpp
+++ b/src/bibletime.cpp
@@ -6,11 +6,29 @@
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
+
#include "bibletime.h"
+#include <cstdlib>
+#include <ctime>
+#include <QAction>
+#include <QApplication>
+#include <QCloseEvent>
+#include <QDebug>
+#include <QInputDialog>
+#include <QMdiSubWindow>
+#include <QSplashScreen>
+#include <QSplitter>
+#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordbiblemoduleinfo.h"
+#include "backend/drivers/cswordbookmoduleinfo.h"
+#include "backend/drivers/cswordcommentarymoduleinfo.h"
+#include "backend/drivers/cswordlexiconmoduleinfo.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/keys/cswordldkey.h"
+#include "backend/keys/cswordversekey.h"
#include "frontend/btaboutmoduledialog.h"
#include "frontend/cmdiarea.h"
-#include "frontend/mainindex/bookshelf/cbookshelfindex.h"
#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/displaywindow/cdisplaywindow.h"
#include "frontend/displaywindow/cdisplaywindowfactory.h"
@@ -18,39 +36,18 @@
#include "frontend/displaywindow/cwritewindow.h"
#include "frontend/keychooser/ckeychooser.h"
#include "frontend/searchdialog/csearchdialog.h"
-#include "backend/config/cbtconfig.h"
-
-#include "util/ctoolclass.h"
#include "util/cpointers.h"
#include "util/cresmgr.h"
-#include "util/directoryutil.h"
+#include "util/directory.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/drivers/cswordbiblemoduleinfo.h"
-#include "backend/drivers/cswordcommentarymoduleinfo.h"
-#include "backend/drivers/cswordlexiconmoduleinfo.h"
-#include "backend/drivers/cswordbookmoduleinfo.h"
-#include "backend/keys/cswordversekey.h"
-#include "backend/keys/cswordldkey.h"
-
-//Qt includes
-#include <QInputDialog>
-#include <QSplitter>
-#include <QDebug>
-#include <QAction>
-#include <QApplication>
-#include <QMdiSubWindow>
-#include <QCloseEvent>
-#include <QSplashScreen>
-
-#include <cstdlib>
-#include <ctime>
using namespace Profile;
BibleTime::BibleTime() {
+ namespace DU = util::directory;
+
QPixmap pm;
- if ( !pm.load( util::filesystem::DirectoryUtil::getPicsDir().canonicalPath().append( "/startuplogo.png")) ) {
+ if (!pm.load(DU::getPicsDir().canonicalPath().append( "/startuplogo.png"))) {
qWarning("Can't load startuplogo! Check your installation.");
}
QSplashScreen splash(pm);
@@ -67,7 +64,7 @@ BibleTime::BibleTime() {
initConnections();
readSettings();
setPlainCaption(QString());
- setWindowIcon( util::filesystem::DirectoryUtil::getIcon(CResMgr::mainWindow::icon) );
+ setWindowIcon(DU::getIcon(CResMgr::mainWindow::icon));
}
BibleTime::~BibleTime() {
@@ -77,7 +74,7 @@ BibleTime::~BibleTime() {
/** Saves the properties of BibleTime to the application wide configfile */
void BibleTime::saveSettings() {
- //TODO: how to write settings?
+ /// \todo how to write settings?
//accel()->writeSettings(CBTConfig::getConfig());
CBTConfig::set(CBTConfig::toolbar, m_viewToolbar_action->isChecked());
@@ -99,7 +96,7 @@ void BibleTime::saveSettings() {
/** Reads the settings from the configfile and sets the right properties. */
void BibleTime::readSettings() {
- qDebug("******************BibleTime::readSettings******************************");
+ qDebug() << "******************BibleTime::readSettings******************************";
// accel()->readSettings(CBTConfig::getConfig());
CBTConfig::setupAccelSettings(CBTConfig::application, m_actionCollection);
@@ -130,7 +127,7 @@ void BibleTime::readSettings() {
/** Creates a new presenter in the MDI area according to the type of the module. */
CDisplayWindow* BibleTime::createReadDisplayWindow(QList<CSwordModuleInfo*> modules, const QString& key) {
qApp->setOverrideCursor( QCursor(Qt::WaitCursor) );
- qDebug("BibleTime::createReadDisplayWindow(QList<CSwordModuleInfo*> modules, const QString& key)");
+ qDebug() << "BibleTime::createReadDisplayWindow(QList<CSwordModuleInfo*> modules, const QString& key)";
CDisplayWindow* displayWindow = CDisplayWindowFactory::createReadInstance(modules, m_mdi);
if ( displayWindow ) {
displayWindow->init();
@@ -247,7 +244,7 @@ void BibleTime::slot_aboutToQuit() {
/** Called before a window is closed */
bool BibleTime::queryClose() {
- qDebug("BibleTime::queryClose");
+ qDebug() << "BibleTime::queryClose";
bool ret = true;
foreach(QMdiSubWindow* subWindow, m_mdi->subWindowList()) {
@@ -312,3 +309,8 @@ void BibleTime::processCommandline() {
}
}
+bool BibleTime::event(QEvent* event) {
+ if (event->type() == QEvent::Close)
+ Search::CSearchDialog::closeDialog();
+ return QMainWindow::event(event);
+}
diff --git a/src/bibletime.h b/src/bibletime.h
index cb3c26d..42cf04f 100644
--- a/src/bibletime.h
+++ b/src/bibletime.h
@@ -10,29 +10,29 @@
#ifndef BIBLETIME_H
#define BIBLETIME_H
-#include "frontend/profile/cprofilemgr.h"
-#include "frontend/profile/cprofile.h"
-#include "frontend/displaywindow/cdisplaywindow.h"
-
-class CSwordModuleInfo;
+#include <QMainWindow>
#include <QList>
-#include <QMainWindow>
+#include "frontend/displaywindow/cdisplaywindow.h"
+#include "frontend/profile/cprofile.h"
+#include "frontend/profile/cprofilemgr.h"
+#include <QSignalMapper>
-class BtActionClass;
-class CMDIArea;
-class CDisplayWindow;
-class CBookmarkIndex;
-class CBookshelfIndex;
-class BtBookshelfDockWidget;
namespace InfoDisplay {
class CInfoDisplay;
}
+class BtActionClass;
+class BtBookshelfDockWidget;
+class CBookmarkIndex;
+class CDisplayWindow;
+class CMDIArea;
+class CSwordModuleInfo;
class QAction;
class QMenu;
class QToolBar;
class QSplitter;
+class QSignalMapper;
/**
* @page backend The structure of the backend
@@ -73,7 +73,7 @@ class QSplitter;
* The main index is implemented in the class CGroupManager, the items of the
* main index are implemented in the class CGroupManagerItem.
* Each CGroupManagerItem has a type() function which returns the type of
- * the object (Module, Bookmark or Group).<BR>
+ * the object (Module, Bookmark or Group).<br/>
* The display windows are all derived from the base class CPresenter.
* The display windows which handle Sword modules are all derived from the
* CSwordPresenter class.
@@ -81,14 +81,14 @@ class QSplitter;
* Bibles, CCommentaryPresenter for commentaries and CLexiconPresenter for
* lexicon and dictionaries.
* CSwordPresenter provides the essential base functions which are
- * reimplemented in the derived classes (for example CSwordPresenter::lookup).<BR>
+ * reimplemented in the derived classes (for example CSwordPresenter::lookup).<br/>
* </p><p>
* Another important part of the frontend are the keychoosers.
* They provide an interface to choose a key of a module.
* The interface for different module types is different.
* The base class is CKeyChooser which is the factory for the derived classes.
* Use the function CKeyChooser::createInstance to get the correct
- * keychooser implementation for the desired module.<BR>
+ * keychooser implementation for the desired module.<br/>
* </p>
*/
@@ -98,10 +98,10 @@ class QSplitter;
* BibleTime is devided in two major parts, the backend and the frontend.
* The backend is mainly a wrapper around Sword's classes to use Qt functionality
* to allow easy access to it's functionality and to have it in a (more or less :)
- * object oriented structure.</p><BR>
+ * object oriented structure.</p><br/>
* <p>
- * -Introduction to the backend: @ref backend<BR>
- * -Introduction to the frontend: @ref frontend.<BR>
+ * -Introduction to the backend: @ref backend<br/>
+ * -Introduction to the frontend: @ref frontend.<br/>
* The main class of BibleTime is called @ref BibleTime, which is the main window
* and initializes all important parts at startup. The text display windows
* belong to the @ref frontend.
@@ -119,7 +119,7 @@ class QSplitter;
* This is the general way of all BibleTime classes.
*/
class BibleTime : public QMainWindow {
- friend class CMDIArea;
+ friend class CDisplayWindow;
friend class BibleTimeDBusAdaptor;
Q_OBJECT
public:
@@ -189,6 +189,14 @@ class BibleTime : public QMainWindow {
protected: // Protected methods
/**
+ * Catch QMainWindow events
+ */
+ bool event(QEvent* event);
+ /**
+ * Initializes the sword.conf in the $HOME\Sword directory
+ */
+ void initSwordConfigFile();
+ /**
* Initializes the view of this widget
*/
void initView();
@@ -238,12 +246,17 @@ class BibleTime : public QMainWindow {
void searchInModule(CSwordModuleInfo *module);
void moduleUnlock(CSwordModuleInfo *module);
void moduleAbout(CSwordModuleInfo *module);
+ void quit();
/**
* Is called when the window menu is about to show ;-)
*/
void slotWindowMenuAboutToShow();
/**
+ * Is called when the open windows menu is about to show ;-)
+ */
+ void slotOpenWindowsMenuAboutToShow();
+ /**
* This slot is connected with the windowAutoTile_action object
*/
void slotAutoTileVertical();
@@ -272,6 +285,10 @@ class BibleTime : public QMainWindow {
*/
void slotToggleToolbar();
/**
+ * Used to set the active menu
+ */
+ void slotSetActiveSubWindow(QWidget* window);
+ /**
* Saves to the profile with the menu id ID
*/
void saveProfile(QAction* action);
@@ -342,6 +359,7 @@ class BibleTime : public QMainWindow {
// VIEW menu actions
QAction* m_viewToolbar_action;
QMenu* m_windowMenu;
+ QMenu* m_openWindowsMenu;
/** WINDOW menu actions */
QAction* m_windowCascade_action;
QAction* m_windowTileHorizontal_action;
@@ -350,6 +368,7 @@ class BibleTime : public QMainWindow {
QAction* m_windowAutoCascade_action;
QAction* m_windowAutoTileVertical_action;
QAction* m_windowAutoTileHorizontal_action;
+ QAction* m_windowClose_action;
QAction* m_windowCloseAll_action;
BtActionCollection* m_actionCollection;
@@ -359,6 +378,10 @@ class BibleTime : public QMainWindow {
QMenu* m_windowDeleteProfileMenu;
QAction* m_windowFullscreen_action;
+ /**
+ * Signal mapper to map windows to menu items.
+ */
+ QSignalMapper* m_windowMapper;
/// \todo remove?
// QList<QAction*> m_windowOpenWindowsList;
diff --git a/src/bibletime_dbus.cpp b/src/bibletime_dbus.cpp
index fae2751..44225bb 100644
--- a/src/bibletime_dbus.cpp
+++ b/src/bibletime_dbus.cpp
@@ -7,23 +7,19 @@
*
**********/
-
-//BibleTime includes
#include "bibletime.h"
-#include "frontend/cmdiarea.h"
+#include <QDebug>
+#include <QList>
+#include <QMdiSubWindow>
#include "backend/config/cbtconfig.h"
-
#include "backend/keys/cswordversekey.h"
+#include "frontend/cmdiarea.h"
-//Sword includes
+// Sword includes:
#include <versekey.h>
#include <listkey.h>
-//QT
-#include <QList>
-#include <QDebug>
-#include <QMdiSubWindow>
//helper function
void BibleTime::syncAllModulesByType(const CSwordModuleInfo::ModuleType type, const QString& key) {
@@ -38,7 +34,7 @@ void BibleTime::syncAllModulesByType(const CSwordModuleInfo::ModuleType type, co
void BibleTime::closeAllModuleWindows() {
qDebug() << "DBUS: close all windows now...";
- m_mdi->deleteAll();
+ m_mdi->closeAllSubWindows();
}
void BibleTime::syncAllBibles(const QString& key) {
diff --git a/src/bibletime_dbus_adaptor.cpp b/src/bibletime_dbus_adaptor.cpp
index 6bd72ec..c841e18 100644
--- a/src/bibletime_dbus_adaptor.cpp
+++ b/src/bibletime_dbus_adaptor.cpp
@@ -11,6 +11,7 @@
#include "bibletime_dbus_adaptor.h"
+
BibleTimeDBusAdaptor::BibleTimeDBusAdaptor(BibleTime *bibletime_ptr) :
QDBusAbstractAdaptor(bibletime_ptr),
m_bibletime(bibletime_ptr) {
diff --git a/src/bibletime_dbus_adaptor.h b/src/bibletime_dbus_adaptor.h
index 4116463..9bfcae3 100644
--- a/src/bibletime_dbus_adaptor.h
+++ b/src/bibletime_dbus_adaptor.h
@@ -14,12 +14,12 @@
#include "bibletime.h"
-//Qt includes
-#include <QString>
-#include <QStringList>
#ifndef NO_DBUS
#include <QDBusAbstractAdaptor>
#endif
+#include <QString>
+#include <QStringList>
+
class BibleTimeDBusAdaptor : QDBusAbstractAdaptor {
Q_OBJECT
diff --git a/src/bibletime_init.cpp b/src/bibletime_init.cpp
index dd68265..98db7d9 100644
--- a/src/bibletime_init.cpp
+++ b/src/bibletime_init.cpp
@@ -7,40 +7,38 @@
*
**********/
-//BibleTime includes
#include "bibletime.h"
-#include "util/cpointers.h"
-#include "util/cresmgr.h"
-#include "util/directoryutil.h"
+
+#include <QApplication>
+#include <QDebug>
+#include <QDockWidget>
+#include <QLabel>
+#include <QMenu>
+#include <QMenuBar>
+#include <QPointer>
+#include <QSplitter>
+#include <QToolBar>
+#include <QVBoxLayout>
+#include "backend/config/cbtconfig.h"
#include "backend/managers/btstringmgr.h"
-#include "backend/managers/cswordbackend.h"
#include "backend/managers/clanguagemgr.h"
+#include "backend/managers/cswordbackend.h"
#include "frontend/btbookshelfdockwidget.h"
-#include "frontend/displaywindow/btactioncollection.h"
-#include "frontend/profile/cprofilemgr.h"
-#include "frontend/profile/cprofile.h"
+#include "frontend/cinfodisplay.h"
#include "frontend/cmdiarea.h"
#include "frontend/cprinter.h"
-#include "backend/config/cbtconfig.h"
-#include "frontend/cinfodisplay.h"
-#include "frontend/mainindex/bookshelf/cbookshelfindex.h"
+#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/mainindex/bookmarks/cbookmarkindex.h"
+#include "frontend/profile/cprofile.h"
+#include "frontend/profile/cprofilemgr.h"
+#include "util/cpointers.h"
+#include "util/cresmgr.h"
+#include "util/directory.h"
-// Qt includes
-#include <QSplitter>
-#include <QPointer>
-#include <QLabel>
-#include <QVBoxLayout>
-#include <QMenu>
-#include <QMenuBar>
-#include <QToolBar>
-#include <QApplication>
-#include <QDebug>
-#include <QDockWidget>
-
-// Sword includes
+// Sword includes:
#include <swlog.h>
+
using namespace InfoDisplay;
using namespace Profile;
@@ -71,11 +69,14 @@ void BibleTime::initView() {
m_mdi->setFocusPolicy(Qt::ClickFocus);
}
-QAction* BibleTime::initAction(QAction* action, QString text, QString icon, QKeySequence accel,
- const QString& tooltip, const QString& actionName, const char* slot ) {
+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(util::filesystem::DirectoryUtil::getIcon(icon));
+ action->setIcon(DU::getIcon(icon));
action->setShortcut(accel);
if (tooltip != QString::null) action->setToolTip(tooltip);
m_actionCollection->addAction(actionName, action);
@@ -86,16 +87,18 @@ QAction* BibleTime::initAction(QAction* action, QString text, QString icon, QKey
// 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(util::filesystem::DirectoryUtil::getIcon("exit.svg"));
+ action->setIcon(DU::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(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainMenu::window::showFullscreen::icon));
+ action->setIcon(DU::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);
@@ -107,106 +110,113 @@ void BibleTime::insertKeyboardActions( BtActionCollection* const a ) {
action = new QAction(a);
action->setText(tr("Search in &open works..."));
- action->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainMenu::mainIndex::search::icon));
+ action->setIcon(DU::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(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainMenu::mainIndex::searchdefaultbible::icon));
+ action->setIcon(DU::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(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainMenu::window::saveToNewProfile::icon));
+ action->setIcon(DU::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(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainMenu::window::arrangementMode::manual::icon));
+ action->setIcon(DU::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(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTileVertical::icon));
+ action->setIcon(DU::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(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainMenu::window::arrangementMode::autoTileHorizontal::icon));
+ action->setIcon(DU::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-&cascade"));
- action->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainMenu::window::arrangementMode::autoCascade::icon));
+ action->setIcon(DU::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(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainMenu::window::cascade::icon));
+ action->setIcon(DU::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 &vertically"));
- action->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainMenu::window::tileVertical::icon));
+ action->setIcon(DU::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(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainMenu::window::tileHorizontal::icon));
+ action->setIcon(DU::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->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(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainMenu::window::closeAll::icon));
+ action->setIcon(DU::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(util::filesystem::DirectoryUtil::getIcon("configure.svg"));
+ action->setIcon(DU::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(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainMenu::settings::swordSetupDialog::icon));
+ action->setIcon(DU::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(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainMenu::help::handbook::icon));
+ action->setIcon(DU::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(util::filesystem::DirectoryUtil::getIcon(CResMgr::mainMenu::help::bibleStudyHowTo::icon));
+ action->setIcon(DU::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."));
+ 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);
action = new QAction(a);
@@ -219,6 +229,13 @@ void BibleTime::insertKeyboardActions( BtActionCollection* const a ) {
void BibleTime::initActions() {
m_actionCollection = new BtActionCollection(this);
+ /**
+ * Create the window to signal mapper and connect it up.
+ */
+ m_windowMapper = new QSignalMapper(this);
+ connect(m_windowMapper, SIGNAL(mapped(QWidget*)),
+ this, SLOT(slotSetActiveSubWindow(QWidget*)));
+
insertKeyboardActions(m_actionCollection);
// Main menus
@@ -239,7 +256,7 @@ void BibleTime::initActions() {
fileMenu->addAction(tmp);
m_mainToolBar->addAction(tmp);
m_mainToolBar->addSeparator();
- connect(tmp, SIGNAL(triggered()), this, SLOT(close()) );
+ connect(tmp, SIGNAL(triggered()), this, SLOT(quit()) );
m_windowFullscreen_action = m_actionCollection->action("toggleFullscreen");
m_windowFullscreen_action->setCheckable(true);
@@ -253,7 +270,6 @@ void BibleTime::initActions() {
viewMenu->addAction(m_viewToolbar_action);
connect(m_viewToolbar_action, SIGNAL(triggered()), this, SLOT(slotToggleToolbar()) );
-
QAction* action = m_bookshelfDock->toggleViewAction();
action->setText(tr("Show Bookshelf"));
viewMenu->addAction(action);
@@ -278,29 +294,35 @@ void BibleTime::initActions() {
searchMenu->addAction(tmp);
connect(tmp, SIGNAL(triggered()), this, SLOT(slotSearchDefaultBible()) );
- m_windowSaveProfileMenu = new QMenu(tr("&Save session"));
- m_windowMenu->addMenu(m_windowSaveProfileMenu);
-
- m_windowSaveToNewProfile_action = m_actionCollection->action("saveNewSession");
- m_windowMenu->addAction(m_windowSaveToNewProfile_action);
- connect(m_windowSaveToNewProfile_action, SIGNAL(triggered()), this, SLOT(saveToNewProfile()) );
+ /**
+ * Window Menu
+ */
+ m_openWindowsMenu = new QMenu(tr("O&pen Windows"), m_windowMenu);
+ m_windowMenu->addMenu(m_openWindowsMenu);
+ m_windowClose_action = m_actionCollection->action("closeWindow");
+ m_windowMenu->addAction(m_windowClose_action);
+ connect(m_windowClose_action, SIGNAL(triggered()), m_mdi, SLOT(closeActiveSubWindow()));
- m_windowLoadProfileMenu = new QMenu(tr("&Load session"));
- m_windowMenu->addMenu(m_windowLoadProfileMenu);
+ m_windowCloseAll_action = m_actionCollection->action("closeAllWindows");
+ m_windowMenu->addAction(m_windowCloseAll_action);
+ connect(m_windowCloseAll_action, SIGNAL(triggered()), m_mdi, SLOT(closeAllSubWindows()));
- m_windowDeleteProfileMenu = new QMenu(tr("&Delete session"));
- m_windowMenu->addMenu(m_windowDeleteProfileMenu);
+ m_windowMenu->addSeparator();
- QObject::connect(m_windowLoadProfileMenu, SIGNAL(triggered(QAction*)), SLOT(loadProfile(QAction*)));
- QObject::connect(m_windowSaveProfileMenu, SIGNAL(triggered(QAction*)), SLOT(saveProfile(QAction*)));
- QObject::connect(m_windowDeleteProfileMenu, SIGNAL(triggered(QAction*)), SLOT(deleteProfile(QAction*)));
+ // *** Window arrangement actions ***
- refreshProfileMenus();
+ m_windowCascade_action = m_actionCollection->action("cascade");
+ m_windowMenu->addAction(m_windowCascade_action);
+ connect(m_windowCascade_action, SIGNAL(triggered()), this, SLOT(slotCascade()) );
- m_windowMenu->addSeparator();
+ m_windowTileVertical_action = m_actionCollection->action("tileVertically");
+ m_windowMenu->addAction(m_windowTileVertical_action);
+ connect(m_windowTileVertical_action, SIGNAL(triggered()), this, SLOT(slotTileVertical()) );
-//--------------------------Window arrangement actions---------------------------------------
+ m_windowTileHorizontal_action = m_actionCollection->action("tileHorizontally");
+ m_windowMenu->addAction(m_windowTileHorizontal_action);
+ connect(m_windowTileHorizontal_action, SIGNAL(triggered()), this, SLOT(slotTileHorizontal()) );
QMenu* arrangementMenu = new QMenu(tr("&Arrangement mode"));
m_windowMenu->addMenu(arrangementMenu);
@@ -327,22 +349,26 @@ void BibleTime::initActions() {
arrangementMenu->addAction(m_windowAutoCascade_action);
connect(m_windowAutoCascade_action, SIGNAL(triggered()), this, SLOT(slotAutoCascade()) );
- m_windowCascade_action = m_actionCollection->action("cascade");
- m_windowMenu->addAction(m_windowCascade_action);
- connect(m_windowCascade_action, SIGNAL(triggered()), this, SLOT(slotCascade()) );
+ m_windowMenu->addSeparator();
- m_windowTileVertical_action = m_actionCollection->action("tileVertically");
- m_windowMenu->addAction(m_windowTileVertical_action);
- connect(m_windowTileVertical_action, SIGNAL(triggered()), this, SLOT(slotTileVertical()) );
+ m_windowSaveProfileMenu = new QMenu(tr("&Save session"));
+ m_windowMenu->addMenu(m_windowSaveProfileMenu);
- m_windowTileHorizontal_action = m_actionCollection->action("tileHorizontally");
- m_windowMenu->addAction(m_windowTileHorizontal_action);
- connect(m_windowTileHorizontal_action, SIGNAL(triggered()), this, SLOT(slotTileHorizontal()) );
+ m_windowSaveToNewProfile_action = m_actionCollection->action("saveNewSession");
+ m_windowMenu->addAction(m_windowSaveToNewProfile_action);
+ connect(m_windowSaveToNewProfile_action, SIGNAL(triggered()), this, SLOT(saveToNewProfile()) );
- m_windowCloseAll_action = m_actionCollection->action("closeAllWindows");
- m_windowMenu->addAction(m_windowCloseAll_action);
- connect(m_windowCloseAll_action, SIGNAL(triggered()), m_mdi, SLOT(deleteAll()));
+ m_windowLoadProfileMenu = new QMenu(tr("&Load session"));
+ m_windowMenu->addMenu(m_windowLoadProfileMenu);
+ m_windowDeleteProfileMenu = new QMenu(tr("&Delete session"));
+ m_windowMenu->addMenu(m_windowDeleteProfileMenu);
+
+ QObject::connect(m_windowLoadProfileMenu, SIGNAL(triggered(QAction*)), SLOT(loadProfile(QAction*)));
+ QObject::connect(m_windowSaveProfileMenu, SIGNAL(triggered(QAction*)), SLOT(saveProfile(QAction*)));
+ QObject::connect(m_windowDeleteProfileMenu, SIGNAL(triggered(QAction*)), SLOT(deleteProfile(QAction*)));
+
+ refreshProfileMenus();
tmp = m_actionCollection->action("setPreferences");
settingsMenu->addAction(tmp);
@@ -384,6 +410,13 @@ void BibleTime::initConnections() {
qWarning() << "Main window: can't find window menu";
}
+ if (m_openWindowsMenu) {
+ QObject::connect(m_openWindowsMenu, SIGNAL(aboutToShow()), this, SLOT(slotOpenWindowsMenuAboutToShow()));
+ }
+ else {
+ qWarning() << "Main window: can't find open windows menu";
+ }
+
bool ok;
ok = connect(m_bookmarksPage, SIGNAL(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)),
this, SLOT(createReadDisplayWindow(QList<CSwordModuleInfo*>, const QString&)));
@@ -404,9 +437,36 @@ void BibleTime::initConnections() {
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slot_aboutToQuit()));
}
+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_WS_WIN
+ namespace DU = util::directory;
+ QString configFile = util::directory::getUserHomeSwordDir().filePath("sword.conf");
+ QFile file(configFile);
+ if (file.exists()) {
+ return;
+ }
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ return;
+ }
+ QTextStream out(&file);
+ out << "\n";
+ out << "[Install]\n";
+ out << "DataPath=" << DU::convertDirSeparators( DU::getSharedSwordDir().absolutePath()) << "\n";
+ out << "LocalePath=" << DU::convertDirSeparators(DU::getApplicationSwordDir().absolutePath()) << "\n";
+ out << "\n";
+ file.close();
+#endif
+}
+
/** Initializes the backend */
void BibleTime::initBackends() {
- qDebug("BibleTime::initBackends");
+ qDebug() << "BibleTime::initBackends";
+
+ initSwordConfigFile();
sword::StringMgr::setSystemStringMgr( new BTStringMgr() );
sword::SWLog::getSystemLog()->setLogLevel(1);
@@ -419,12 +479,12 @@ void BibleTime::initBackends() {
if (errorCode != CSwordBackend::NoError) {
//show error message that initBackend failed
- //TODO:
+ /// \todo
// switch (errorCode) {
// case CSwordBackend::NoSwordConfig: //mods.d or mods.conf missing
// {
// KStartupLogo::hideSplash();
-// qDebug("case CSwordBackend::NoSwordConfig");
+// qDebug() << "case CSwordBackend::NoSwordConfig";
// BookshelfManager::CSwordSetupDialog dlg;
// dlg.showPart( BookshelfManager::CSwordSetupDialog::Sword );
// dlg.exec();
@@ -434,7 +494,7 @@ void BibleTime::initBackends() {
// case CSwordBackend::NoModules: //no modules installed, but config exists
// {
// KStartupLogo::hideSplash();
-// qDebug("case CSwordBackend::NoModules");
+// qDebug() << "case CSwordBackend::NoModules";
// BookshelfManager::CSwordSetupDialog dlg;
// dlg.showPart( BookshelfManager::CSwordSetupDialog::Install );
// dlg.exec();
@@ -444,7 +504,7 @@ void BibleTime::initBackends() {
// default: //unknown error
// {
// KStartupLogo::hideSplash();
-// qDebug("unknown error");
+// qDebug() << "unknown error";
// BookshelfManager::CSwordSetupDialog dlg;
// dlg.showPart( BookshelfManager::CSwordSetupDialog::Sword );
// dlg.exec();
@@ -457,23 +517,19 @@ void BibleTime::initBackends() {
// - delete all orphaned indexes (no module present) if autoDeleteOrphanedIndices is true
// - delete all indices of modules where hasIndex() returns false
//BookshelfManager::CManageIndicesWidget::deleteOrphanedIndices();
- //TODO: //backend::deleteOrphanedIndices();
+ /// \todo //backend::deleteOrphanedIndices();
}
void BibleTime::applyProfileSettings( CProfile* p ) {
- qDebug("BibleTime::applyProfileSettings");
+ qDebug() << "BibleTime::applyProfileSettings";
Q_ASSERT(p);
if (!p) return;
//first Main Window state
- m_windowFullscreen_action->setChecked( p->fullscreen() ); //set the fullscreen button state
- toggleFullscreen(); //either showFullscreen or showNormal
- if (p->maximized()) QMainWindow::showMaximized(); //if maximized, then also call showMaximized
- //Then Main Window geometry
- QMainWindow::resize( p->geometry().size() ); //Don't use QMainWindowInterface::resize
- QMainWindow::move( p->geometry().topLeft() );//Don't use QMainWindowInterface::move
restoreState(p->getMainwindowState());
+ restoreGeometry(p->getMainwindowGeometry());
+ m_windowFullscreen_action->setChecked(isFullScreen());
const CMDIArea::MDIArrangementMode newArrangementMode = p->getMDIArrangementMode();
//make sure actions are updated by calling the slot functions
@@ -499,14 +555,7 @@ void BibleTime::storeProfileSettings( CProfile* p ) {
if (!p || !m_windowFullscreen_action) return;
p->setMainwindowState(saveState());
- p->setFullscreen( m_windowFullscreen_action->isChecked() );
- p->setMaximized( this->QMainWindow::isMaximized() );
-
- QRect geometry;
- geometry.setTopLeft(pos());
- geometry.setSize(size());
- p->setGeometry(geometry);
-
+ p->setMainwindowGeometry(saveGeometry());
p->setMDIArrangementMode(m_mdi->getMDIArrangementMode());
}
diff --git a/src/bibletime_slots.cpp b/src/bibletime_slots.cpp
index aaf1b1d..973b8e6 100644
--- a/src/bibletime_slots.cpp
+++ b/src/bibletime_slots.cpp
@@ -7,40 +7,35 @@
*
**********/
-//own includes
#include "bibletime.h"
+#include <QAction>
+#include <QApplication>
+#include <QClipboard>
+#include <QDesktopServices>
+#include <QInputDialog>
+#include <QList>
+#include <QMdiSubWindow>
+#include <QMenu>
+#include <QProcess>
+#include <QtGlobal>
+#include <QToolBar>
+#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordversekey.h"
-
-#include "util/ctoolclass.h"
-#include "util/directoryutil.h"
-
+#include "frontend/cinfodisplay.h"
+#include "frontend/cinputdialog.h"
#include "frontend/cmdiarea.h"
+#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
+#include "frontend/displaywindow/cbiblereadwindow.h"
+#include "frontend/displaywindow/cdisplaywindow.h"
+#include "frontend/htmldialogs/btaboutdialog.h"
#include "frontend/profile/cprofilemgr.h"
#include "frontend/profile/cprofile.h"
#include "frontend/profile/cprofilewindow.h"
-#include "frontend/settingsdialogs/cconfigurationdialog.h"
-#include "backend/config/cbtconfig.h"
-#include "frontend/cinputdialog.h"
-#include "frontend/cinfodisplay.h"
-#include "frontend/displaywindow/cdisplaywindow.h"
-#include "frontend/displaywindow/cbiblereadwindow.h"
#include "frontend/searchdialog/csearchdialog.h"
-#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
-#include "frontend/htmldialogs/btaboutdialog.h"
+#include "frontend/settingsdialogs/cconfigurationdialog.h"
+#include "util/directory.h"
-//QT includes
-#include <QClipboard>
-#include <QInputDialog>
-#include <QList>
-#include <QAction>
-#include <QMenu>
-#include <QToolBar>
-#include <QApplication>
-#include <QProcess>
-#include <QMdiSubWindow>
-#include <QtGlobal>
-#include <QDesktopServices>
using namespace Profile;
@@ -69,7 +64,7 @@ using namespace Profile;
/** Opens the optionsdialog of BibleTime. */
void BibleTime::slotSettingsOptions() {
- qDebug("BibleTime::slotSettingsOptions");
+ qDebug() << "BibleTime::slotSettingsOptions";
CConfigurationDialog *dlg = new CConfigurationDialog(this, m_actionCollection);
QObject::connect(dlg, SIGNAL(signalSettingsChanged()), this, SLOT(slotSettingsChanged()) );
@@ -85,11 +80,11 @@ void BibleTime::saveConfigSettings() {
/** Is called when settings in the optionsdialog were changed (ok or apply) */
void BibleTime::slotSettingsChanged() {
- qDebug("BibleTime::slotSettingsChanged");
+ qDebug() << "BibleTime::slotSettingsChanged";
const QString language = CBTConfig::get(CBTConfig::language);
CPointers::backend()->booknameLanguage(language);
-// TODO: update the bookmarks after Bible bookname language has been changed
+// \todo update the bookmarks after Bible bookname language has been changed
// QTreeWidgetItemIterator it(m_mainIndex);
// while (*it) {
// CIndexItemBase* citem = dynamic_cast<CIndexItemBase*>(*it);
@@ -102,12 +97,12 @@ void BibleTime::slotSettingsChanged() {
refreshBibleTimeAccel();
refreshDisplayWindows();
refreshProfileMenus();
- qDebug("BibleTime::slotSettingsChanged");
+ qDebug() << "BibleTime::slotSettingsChanged";
}
/** Opens the sword setup dialog of BibleTime. */
void BibleTime::slotSwordSetupDialog() {
- //TODO: nonmodal dialog, memory management (one instance only!
+ /// \todo nonmodal dialog, memory management (one instance only!
//BtModuleManagerDialog *dlg = new BtModuleManagerDialog(this);
BtModuleManagerDialog* dlg = BtModuleManagerDialog::getInstance(this);
//disconnect first because it may be connected already
@@ -127,7 +122,7 @@ void BibleTime::slotSwordSetupChanged() {
these are the mainindex, the searchdialog, the displaywindows
But at first we have to reset the Sword backend to reload the modules
- TODO: should bookshelf manager be updated?
+ \todo should bookshelf manager be updated?
Should there be different signals/slots for visual changes,
i.e. grouping/hiding?
@@ -156,18 +151,24 @@ void BibleTime::slotWindowMenuAboutToShow() {
m_windowCascade_action->setEnabled(false);
m_windowTileVertical_action->setEnabled(false);
m_windowTileHorizontal_action->setEnabled(false);
+ m_windowClose_action->setEnabled(false);
m_windowCloseAll_action->setEnabled(false);
+ m_openWindowsMenu->setEnabled(false);
}
else if (m_mdi->subWindowList().count() == 1) {
- m_windowTileVertical_action->setEnabled( false );
- m_windowTileHorizontal_action->setEnabled( false );
- m_windowCascade_action->setEnabled( false );
- m_windowCloseAll_action->setEnabled( true );
+ m_windowTileVertical_action->setEnabled(false);
+ m_windowTileHorizontal_action->setEnabled(false);
+ m_windowCascade_action->setEnabled(false);
+ m_windowClose_action->setEnabled(true);
+ m_windowCloseAll_action->setEnabled(true);
+ m_openWindowsMenu->setEnabled(true);
// m_windowMenu->insertSeparator();
}
else {
slotUpdateWindowArrangementActions(0); //update the window tile/cascade states
- m_windowCloseAll_action->setEnabled( true );
+ m_windowClose_action->setEnabled(true);
+ m_windowCloseAll_action->setEnabled(true);
+ m_openWindowsMenu->setEnabled(true);
}
// QList<QAction*>::iterator end = m_windowOpenWindowsList.end();
@@ -204,6 +205,23 @@ void BibleTime::slotWindowMenuAboutToShow() {
// }
}
+/** Is called just before the open windows menu is ahown. */
+void BibleTime::slotOpenWindowsMenuAboutToShow() {
+ Q_ASSERT(m_openWindowsMenu);
+ if (!m_openWindowsMenu) {
+ return;
+ }
+ QList<QMdiSubWindow*> windows = m_mdi->usableWindowList();
+ m_openWindowsMenu->clear();
+ foreach (QMdiSubWindow *window, windows) {
+ QAction *openWindowAction = m_openWindowsMenu->addAction(window->windowTitle());
+ openWindowAction->setCheckable(true);
+ openWindowAction->setChecked(window == m_mdi->activeSubWindow());
+ connect(openWindowAction, SIGNAL(triggered()), m_windowMapper, SLOT(map()));
+ m_windowMapper->setMapping(openWindowAction, window);
+ }
+}
+
/** This slot is connected with the windowAutoTile_action object */
void BibleTime::slotUpdateWindowArrangementActions( QAction* clickedAction ) {
/* If a toggle action was clicked we see if it checked ot unchecked and
@@ -325,6 +343,13 @@ void BibleTime::slotToggleToolbar() {
}
}
+/** Sets the active window. */
+void BibleTime::slotSetActiveSubWindow(QWidget* window) {
+ if (!window)
+ return;
+ m_mdi->setActiveSubWindow(dynamic_cast<QMdiSubWindow*>(window));
+}
+
void BibleTime::slotSearchModules() {
//get the modules of the open windows
QList<CSwordModuleInfo*> modules;
@@ -350,13 +375,13 @@ void BibleTime::slotSearchDefaultBible() {
}
void BibleTime::openOnlineHelp_Handbook() {
- QString urlPath = "file://" + util::filesystem::DirectoryUtil::getHandbookDir().canonicalPath() + "/index.html";
- QDesktopServices::openUrl(QUrl(urlPath));
+ QString filePath(util::directory::getHandbookDir().canonicalPath() + "/index.html");
+ QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
}
void BibleTime::openOnlineHelp_Howto() {
- QString urlPath = "file://" + util::filesystem::DirectoryUtil::getHowtoDir().canonicalPath() + "/index.html";
- QDesktopServices::openUrl(QUrl(urlPath));
+ QString filePath(util::directory::getHowtoDir().canonicalPath() + "/index.html");
+ QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
}
void BibleTime::slotOpenAboutDialog() {
@@ -409,7 +434,7 @@ void BibleTime::loadProfile(QAction* action) {
CProfile* p = m_profileMgr.profile( profileName );
Q_ASSERT(p);
if ( p ) {
- m_mdi->deleteAll();
+ m_mdi->closeAllSubWindows();
loadProfile(p);
}
}
@@ -515,3 +540,9 @@ void BibleTime::refreshProfileMenus() {
m_windowDeleteProfileMenu->addAction(p->name());
}
}
+
+// Quit from BibleTime
+void BibleTime::quit() {
+ Search::CSearchDialog::closeDialog();
+ close();
+}
diff --git a/src/bibletimeapp.cpp b/src/bibletimeapp.cpp
index b6c8f59..73ac468 100644
--- a/src/bibletimeapp.cpp
+++ b/src/bibletimeapp.cpp
@@ -8,11 +8,10 @@
**********/
#include "bibletimeapp.h"
+
#include "backend/config/cbtconfig.h"
#include "util/cresmgr.h"
-//KDE includes
-//#include <dcopclient.h> #TODO: USE DBUS INSTEAD OF DCOP
BibleTimeApp::BibleTimeApp( int & argc, char ** argv ) : QApplication(argc, argv) {
// initDCOP();
diff --git a/src/bibletimeapp.h b/src/bibletimeapp.h
index 0b1a845..b3d5a0e 100644
--- a/src/bibletimeapp.h
+++ b/src/bibletimeapp.h
@@ -10,10 +10,9 @@
#ifndef BIBLETIMEAPP_H
#define BIBLETIMEAPP_H
-//BibleTime
+#include <QApplication>
#include "util/cpointers.h"
-#include <QApplication>
/** The BibleTimeApp class is used to clean up all instances of the backend and to delete all created module objects.
* @author The BibleTime team
diff --git a/src/display-templates/Blue.tmpl b/src/display-templates/Blue.tmpl
index df78897..66b7567 100644
--- a/src/display-templates/Blue.tmpl
+++ b/src/display-templates/Blue.tmpl
@@ -6,7 +6,7 @@
<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[ */
#LANG_CSS#
@@ -82,7 +82,7 @@ span.currententry {
}
/* Space between the columns of modules displayed side by side */
-td.entry + td.entry {
+td.entry + td.entry {
margin-left: 5px;
}
@@ -223,13 +223,15 @@ td.entry + td.entry {
font-style:italic;
}
.line-through {
+ text-decoration: line-through;
}
.normal {
}
-.small-caps{
+.small-caps {
+ font-variant: small-caps;
}
.underline {
- font-style:underline;
+ text-decoration: underline;
}
.inscription {
@@ -250,15 +252,15 @@ td.entry + td.entry {
font-variant: small-caps;
}
-.transchange {
- font-style:italic;
+.transchange {
+ font-style:italic;
}
.transchange > .added {
background-color:inherit;
}
-.transchange > .amplified {
+.transchange > .amplified {
}
-.transchange > .changed {
+.transchange > .changed {
}
.transchange > .deleted {
}
@@ -313,7 +315,7 @@ td.entry + td.entry {
padding:2px;
margin:0px;
text-align:left !important;
- font-weight:bold;
+ font-weight:bold;
}
#infodisplay .rangeheading {
diff --git a/src/display-templates/Crazy.tmpl b/src/display-templates/Crazy.tmpl
index 1ef3bff..b21527a 100644
--- a/src/display-templates/Crazy.tmpl
+++ b/src/display-templates/Crazy.tmpl
@@ -88,7 +88,7 @@ td.entry, td.currententry {
line-height:1.6em;
background-color:#D3E5FF;
/*border: thin solid black;*/
-
+
}
table .currententry:nth-child(1) {
@@ -220,14 +220,25 @@ so something like .alternative:before { content:"'"attr(alternative); } is possi
.bold {
font-weight: bold;
}
+
.illuminated { }
+
.italic {
font-style: italic;
}
-.line-through { }
+
+.line-through {
+ text-decoration: line-through;
+}
.normal { }
-.small-caps{ }
-.underline { }
+
+.small-caps{
+ font-variant: small-caps;
+}
+
+.underline {
+ text-decoration: underline;
+}
/* An inscription */
.inscription { }
diff --git a/src/display-templates/Green.tmpl b/src/display-templates/Green.tmpl
index f0d433d..033bcb2 100644
--- a/src/display-templates/Green.tmpl
+++ b/src/display-templates/Green.tmpl
@@ -6,7 +6,7 @@
<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[ */
@@ -27,7 +27,7 @@ body {
#content > table th {
padding: 0 0 2px 0;
- text-align: center;
+ text-align: center;
font-weight: bold;
font-size: 110%;
border-bottom: 1px solid #6B6B6B;
@@ -81,7 +81,7 @@ span.currententry {
/*Space between the columns of modules displayed side by side*/
-td.entry + td.entry {
+td.entry + td.entry {
margin-left: 5px;
}
@@ -206,13 +206,15 @@ td.entry + td.entry {
font-style:italic;
}
.line-through {
+ text-decoration: line-through;
}
.normal {
}
-.small-caps{
+.small-caps {
+ font-variant: small-caps;
}
.underline {
- font-style:underline;
+ text-decoration: underline;
}
.inscription {
@@ -233,15 +235,15 @@ td.entry + td.entry {
font-variant: small-caps;
}
-.transchange {
- font-style:italic;
+.transchange {
+ font-style:italic;
}
.transchange > .added {
background-color:inherit;
}
-.transchange > .amplified {
+.transchange > .amplified {
}
-.transchange > .changed {
+.transchange > .changed {
}
.transchange > .deleted {
}
@@ -253,7 +255,7 @@ 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,
+ 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;
}
@@ -292,7 +294,7 @@ td.entry + td.entry {
padding:2px;
margin:0px;
text-align:left;
- font-weight:bold;
+ font-weight:bold;
}
#infodisplay .rangeheading {
diff --git a/src/display-templates/HighContrast.tmpl b/src/display-templates/HighContrast.tmpl
index f70590a..1e1366d 100644
--- a/src/display-templates/HighContrast.tmpl
+++ b/src/display-templates/HighContrast.tmpl
@@ -6,11 +6,11 @@
<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[ */
-* {
+* {
/* To work around a KDE 3.2 bug / problem */
/* background-color:white; #this seems to break*/
}
@@ -30,7 +30,7 @@ body {
}
#content > table th {
padding: 0 0 2px 0;
- text-align: center;
+ text-align: center;
/*font-weight: bold;*/
font-size: 110%;
border-bottom: 1px solid #6B6B6B;
@@ -62,7 +62,7 @@ a:hover {
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!) */
@@ -79,12 +79,12 @@ div.entry, td.entry, td.currententry {
div.currententry {
}
span.currententry {
-
+
}
/*Space between the columns of modules displayed side by side*/
-td.entry + td.entry {
+td.entry + td.entry {
margin-left: 5px;
}
@@ -220,13 +220,15 @@ td.entry + td.entry {
font-style:italic;
}
.line-through {
+ text-decoration: line-through;
}
.normal {
}
-.small-caps{
+.small-caps {
+ font-variant: small-caps;
}
.underline {
- font-style:underline;
+ text-decoration: underline;
}
.inscription {
@@ -247,15 +249,15 @@ td.entry + td.entry {
font-variant: small-caps;
}
-.transchange {
- font-style:italic;
+.transchange {
+ font-style:italic;
}
.transchange > .added {
background-color:inherit;
}
-.transchange > .amplified {
+.transchange > .amplified {
}
-.transchange > .changed {
+.transchange > .changed {
}
.transchange > .deleted {
}
@@ -267,7 +269,7 @@ 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,
+ 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;
}
diff --git a/src/display-templates/Simple.tmpl b/src/display-templates/Simple.tmpl
index 756de3e..e6ac8ad 100644
--- a/src/display-templates/Simple.tmpl
+++ b/src/display-templates/Simple.tmpl
@@ -6,7 +6,7 @@
<meta name="GENERATOR" content="BibleTime " VERSION "" />
<meta name="AUTHOR" content="BibleTime " VERSION "" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-
+
<style type="text/css">
/* <![CDATA[ */
body {
@@ -25,7 +25,7 @@ body {
}
#content table th {
padding: 0 0 2px 0;
- text-align: center;
+ text-align: center;
font-weight: bold;
font-size: 115%;
}
diff --git a/src/frontend/bookshelfmanager/btconfigdialog.cpp b/src/frontend/bookshelfmanager/btconfigdialog.cpp
index 0fcbc5a..565765d 100644
--- a/src/frontend/bookshelfmanager/btconfigdialog.cpp
+++ b/src/frontend/bookshelfmanager/btconfigdialog.cpp
@@ -7,23 +7,22 @@
*
**********/
-
-#include "btconfigdialog.h"
-
-#include "util/directoryutil.h"
-#include "util/ctoolclass.h"
+#include "frontend/bookshelfmanager/btconfigdialog.h"
#include <QDialog>
-#include <QStackedWidget>
+#include <QDialogButtonBox>
+#include <QEvent>
+#include <QFrame>
+#include <QHBoxLayout>
+#include <QLabel>
#include <QListWidget>
#include <QListView>
#include <QListWidgetItem>
+#include <QStackedWidget>
#include <QVBoxLayout>
-#include <QHBoxLayout>
-#include <QLabel>
-#include <QDialogButtonBox>
-#include <QFrame>
-#include <QEvent>
+#include "util/directory.h"
+#include "util/tool.h"
+
BtConfigDialog::BtConfigDialog(QWidget* parent)
: QDialog(parent),
@@ -63,11 +62,13 @@ BtConfigDialog::BtConfigDialog(QWidget* parent)
BtConfigDialog::~BtConfigDialog() {}
void BtConfigDialog::addPage(BtConfigPage* pageWidget) {
+ namespace DU = util::directory;
+
// this is a friend
pageWidget->m_parentDialog = this;
QVBoxLayout* containerLayout = new QVBoxLayout;
- QLabel* headerLabel = CToolClass::explanationLabel(pageWidget, pageWidget->header(), pageWidget->label());
+ QLabel* headerLabel = util::tool::explanationLabel(pageWidget, pageWidget->header(), pageWidget->label());
containerLayout->addWidget(headerLabel);
containerLayout->addWidget(pageWidget);
QWidget* containerWidget = new QWidget(m_pageWidget);
@@ -76,7 +77,7 @@ void BtConfigDialog::addPage(BtConfigPage* pageWidget) {
QListWidgetItem* item = new QListWidgetItem(m_contentsList);
- item->setIcon(util::filesystem::DirectoryUtil::getIcon(pageWidget->iconName()));
+ item->setIcon(DU::getIcon(pageWidget->iconName()));
item->setText(pageWidget->header());
item->setTextAlignment(Qt::AlignHCenter);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
diff --git a/src/frontend/bookshelfmanager/btconfigdialog.h b/src/frontend/bookshelfmanager/btconfigdialog.h
index 8773a83..547cb4e 100644
--- a/src/frontend/bookshelfmanager/btconfigdialog.h
+++ b/src/frontend/bookshelfmanager/btconfigdialog.h
@@ -10,14 +10,13 @@
#ifndef BTCONFIGDIALOG_H
#define BTCONFIGDIALOG_H
-
#include <QDialog>
-#include <QWidget>
#include <QDebug>
+#include <QWidget>
-class BtConfigPage;
+class BtConfigPage;
class QListWidgetItem;
class QListWidget;
class QStackedWidget;
diff --git a/src/frontend/bookshelfmanager/btinstallmgr.cpp b/src/frontend/bookshelfmanager/btinstallmgr.cpp
index 799fa0d..ace804f 100644
--- a/src/frontend/bookshelfmanager/btinstallmgr.cpp
+++ b/src/frontend/bookshelfmanager/btinstallmgr.cpp
@@ -7,31 +7,27 @@
*
**********/
-//BibleTime includes
-#include "btinstallmgr.h"
+#include "frontend/bookshelfmanager/btinstallmgr.h"
-#include "frontend/bookshelfmanager/instbackend.h"
#include "backend/managers/cswordbackend.h"
-
-//Qt includes
-#include <QObject>
+#include "frontend/bookshelfmanager/instbackend.h"
+#include <QDebug>
#include <QList>
+#include <QObject>
#include <QString>
#include <QStringList>
-#include <QDebug>
-
-//sword includes
+// Sword includes:
#include <installmgr.h>
#include <ftptrans.h>
-using namespace sword;
+using namespace sword;
BtInstallMgr::BtInstallMgr()
: InstallMgr(instbackend::configPath().toLatin1(), this),
m_firstCallOfPreStatus(true) { //use this class also as status reporter
- qDebug("BtInstallMgr::BtInstallMgr");
+ qDebug() << "BtInstallMgr::BtInstallMgr";
this->setFTPPassive(true);
}
@@ -41,13 +37,13 @@ BtInstallMgr::~BtInstallMgr() {
}
bool BtInstallMgr::isUserDisclaimerConfirmed() const {
- // TODO: Check from config if it's been confirmed with "don't show this anymore" checked.
+ // \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) {
- //qDebug("BtInstallMgr::statusUpdate");
+ //qDebug() << "BtInstallMgr::statusUpdate";
if (dlnow > dltotal)
dlnow = dltotal;
diff --git a/src/frontend/bookshelfmanager/btinstallmgr.h b/src/frontend/bookshelfmanager/btinstallmgr.h
index 0561b96..7eff1ae 100644
--- a/src/frontend/bookshelfmanager/btinstallmgr.h
+++ b/src/frontend/bookshelfmanager/btinstallmgr.h
@@ -10,19 +10,19 @@
#ifndef NEWBTINSTALLMGR_H
#define NEWBTINSTALLMGR_H
-//sword includes
-#include <installmgr.h>
-#include <ftptrans.h>
-
-//Qt includes
#include <QObject>
+
#include <QList>
#include <QString>
#include <QStringList>
-class CSwordBackend;
+// Sword includes:
+#include <installmgr.h>
+#include <ftptrans.h>
+class CSwordBackend;
+
typedef QList<sword::InstallSource*> InstallSourceList;
/**
diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
index b361965..b261305 100644
--- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
+++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
@@ -7,21 +7,19 @@
*
**********/
-#include "btmodulemanagerdialog.h"
-
-#include "installpage/btinstallpage.h"
-#include "removepage/btremovepage.h"
-#include "indexpage/btindexpage.h"
+#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
+#include <QDialogButtonBox>
+#include "backend/config/cbtconfig.h"
+#include "backend/managers/cswordbackend.h"
+#include "frontend/bookshelfmanager/indexpage/btindexpage.h"
+#include "frontend/bookshelfmanager/installpage/btinstallpage.h"
+#include "frontend/bookshelfmanager/removepage/btremovepage.h"
#include "util/cpointers.h"
#include "util/dialogutil.h"
-#include "backend/managers/cswordbackend.h"
-#include "backend/config/cbtconfig.h"
-
-#include <QDialogButtonBox>
-static BtModuleManagerDialog* m_staticModuleManagerDialog = 0;
+static BtModuleManagerDialog *m_staticModuleManagerDialog = 0;
BtModuleManagerDialog* BtModuleManagerDialog::getInstance(QWidget* parent) {
if (!m_staticModuleManagerDialog) {
@@ -67,7 +65,7 @@ BtModuleManagerDialog::~BtModuleManagerDialog() {
// The QWidget close() sends close event, so does closing by the window X button.
void BtModuleManagerDialog::closeEvent(QCloseEvent*) {
- qDebug("BtModuleManagerDialog::closeEvent");
+ qDebug() << "BtModuleManagerDialog::closeEvent";
}
void BtModuleManagerDialog::loadDialogSettings() {
diff --git a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
index ff8c35f..c51efd2 100644
--- a/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
+++ b/src/frontend/bookshelfmanager/btmodulemanagerdialog.h
@@ -7,11 +7,11 @@
*
**********/
-
#ifndef BTMODULEMANAGERDIALOG_H
#define BTMODULEMANAGERDIALOG_H
-#include "btconfigdialog.h"
+#include "frontend/bookshelfmanager/btconfigdialog.h"
+
class QWidget;
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
index eca4498..47e274c 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.cpp
@@ -7,35 +7,33 @@
*
**********/
-//BT includes
-#include "cswordsetupinstallsourcesdialog.h"
-
-#include "frontend/bookshelfmanager/instbackend.h"
+#include "frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h"
#include <boost/scoped_ptr.hpp>
-
-//Qt includes
-#include <QLayout>
-#include <QLabel>
#include <QComboBox>
-#include <QLineEdit>
-#include <QPushButton>
-#include <QMessageBox>
+#include <QDir>
#include <QFileInfo>
+#include <QFileDialog>
#include <QGridLayout>
#include <QHBoxLayout>
+#include <QLabel>
+#include <QLayout>
+#include <QLineEdit>
+#include <QPushButton>
#include <QVBoxLayout>
-#include <QFileDialog>
-#include <QDir>
-
-
+#include <QDialogButtonBox>
+#include <QProgressDialog>
+#include <QApplication>
+#include <QDebug>
+#include "frontend/bookshelfmanager/instbackend.h"
+#include "util/dialogutil.h"
const QString PROTO_FILE( QObject::tr("Local") ); //Local path
const QString PROTO_FTP( QObject::tr("Remote") ); //Remote path
-
CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *parent*/)
- : QDialog() {
+ : QDialog(),
+ m_remoteListAdded(false) {
setWindowTitle(tr("New Installation Source"));
QVBoxLayout* mainLayout = new QVBoxLayout( this );
@@ -48,7 +46,7 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
captionLayout->addWidget( label );
m_captionEdit = new QLineEdit( this );
- m_captionEdit->setText("Crosswire Bible Society");
+ m_captionEdit->setText("CrossWire Bible Society");
captionLayout->addWidget( m_captionEdit );
mainLayout->addSpacing( 10 );
@@ -83,24 +81,22 @@ CSwordSetupInstallSourcesDialog::CSwordSetupInstallSourcesDialog(/*QWidget *pare
mainLayout->addSpacing( 10 );
- QHBoxLayout* buttonLayout = new QHBoxLayout( this );
- mainLayout->addLayout(buttonLayout);
- buttonLayout->addStretch();
- QPushButton* okButton = new QPushButton( tr("Ok"), this);
- QPushButton* discardButton = new QPushButton( tr("Discard"), this);
- buttonLayout->addWidget( discardButton);
- buttonLayout->addWidget( okButton);
- buttonLayout->addStretch();
-
- connect( okButton, SIGNAL( clicked() ), this, SLOT( slotOk() ) );
- connect( discardButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
+ QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel|QDialogButtonBox::Save, Qt::Horizontal, this);
+ util::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);
+ connect(getListButton, SIGNAL(clicked()), SLOT(slotGetListClicked()));
+ mainLayout->addWidget(buttonBox);
+ connect(buttonBox, SIGNAL(accepted()), SLOT(slotOk()));
+ connect(buttonBox, SIGNAL(rejected()), SLOT(reject()));
connect( m_protocolCombo, SIGNAL( activated(int) ), this, SLOT( slotProtocolChanged() ) );
-
}
+
void CSwordSetupInstallSourcesDialog::slotOk() {
//run a few tests to validate the input first
if ( m_captionEdit->text().trimmed().isEmpty() ) { //no caption
- QMessageBox::information( this, tr( "Error" ), tr("Please provide a caption."), QMessageBox::Retry);
+ util::showInformation( this, tr( "Error" ), tr("Please provide a caption."));
return;
}
@@ -108,25 +104,25 @@ void CSwordSetupInstallSourcesDialog::slotOk() {
//sword::InstallSource is = BTInstallMgr::Tool::RemoteConfig::source( &iMgr, m_captionEdit->text() );
sword::InstallSource is = instbackend::source(m_captionEdit->text());
if ( (QString)is.caption.c_str() == m_captionEdit->text() ) { //source already exists
- QMessageBox::information( this, tr( "Error" ),
- tr("A source with this caption already exists.<br>Please provide a different caption."), QMessageBox::Retry);
+ util::showInformation( this, tr( "Error" ),
+ tr("A source with this caption already exists.<br/>Please provide a different caption."));
return;
}
if ( m_protocolCombo->currentText() == PROTO_FTP &&
m_serverEdit->text().trimmed().isEmpty() ) { //no server name
- QMessageBox::information( this, tr( "Error" ), tr("Please provide a server name."), QMessageBox::Retry);
+ util::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
- QMessageBox::information( this, tr( "Error" ), tr("Please provide a valid, readable path."), QMessageBox::Retry);
+ util::showInformation( this, tr( "Error" ), tr("Please provide a valid, readable path."));
return;
}
else if ( m_pathEdit->text().isEmpty() ) {
- QMessageBox::information( this, tr( "Error" ), tr("Please provide a path."), QMessageBox::Retry);
+ util::showInformation( this, tr( "Error" ), tr("Please provide a path."));
}
}
@@ -155,28 +151,83 @@ void CSwordSetupInstallSourcesDialog::slotProtocolChanged() {
}
-sword::InstallSource CSwordSetupInstallSourcesDialog::getSource() {
+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);
+ if (answer == QMessageBox::No) {
+ return;
+ }
+ qDebug() << "Ok, create installmgr";
+ BtInstallMgr iMgr;
+
+ m_progressDialog = new QProgressDialog("", tr("Cancel"), 0 , 100, this);
+ m_progressDialog->setWindowTitle(tr("Downloading List"));
+ m_progressDialog->setMinimumDuration(0);
+ connect(m_progressDialog, SIGNAL(canceled()), SLOT(slotRefreshCanceled()));
+ m_currentInstallMgr = &iMgr; //for the progress dialog
+ // connect this directly to the dialog setValue(int) if possible
+ connect(&iMgr, SIGNAL(percentCompleted(const int, const int)), SLOT(slotRefreshProgress(const int, const int)));
+
+ m_progressDialog->show();
+ qApp->processEvents();
+ this->slotRefreshProgress(0, 0);
+ m_progressDialog->setLabelText(tr("Connecting..."));
+ m_progressDialog->setValue(0);
+ qApp->processEvents();
+ qWarning() << "Start downloading the list of sources";
+ int ret = iMgr.refreshRemoteSourceConfiguration();
+ bool success = false;
+ if ( !ret ) { //make sure the sources were updated sucessfully
+ qDebug() << "download succeeded";
+ success = true;
+ m_progressDialog->setValue(100); //make sure the dialog closes
+ m_remoteListAdded = true;
+ accept();
+ }
+ else {
+ qWarning("InstallMgr: getting remote list returned an error.");
+ success = false;
+ }
+ delete m_progressDialog;
+ m_progressDialog = 0;
+}
- boost::scoped_ptr<CSwordSetupInstallSourcesDialog> dlg( new CSwordSetupInstallSourcesDialog() );
- sword::InstallSource newSource(""); //empty, invalid Source
+void CSwordSetupInstallSourcesDialog::slotRefreshProgress(const int, const int current) {
+ if (m_progressDialog) {
+ if (m_progressDialog->labelText() != tr("Refreshing...")) {
+ m_progressDialog->setLabelText(tr("Refreshing..."));
+ }
+ m_progressDialog->setValue(current);
+ }
+ qApp->processEvents();
+}
- if (dlg->exec() == QDialog::Accepted) {
- if (dlg->m_protocolCombo->currentText() == PROTO_FTP) {
- newSource.type = "FTP";
- newSource.source = dlg->m_serverEdit->text().toUtf8();
+void CSwordSetupInstallSourcesDialog::slotRefreshCanceled() {
+ Q_ASSERT(m_currentInstallMgr);
+ if (m_currentInstallMgr) {
+ m_currentInstallMgr->terminate();
+ }
+ qApp->processEvents();
+}
- //a message to the user would be nice, but we're in message freeze right now (1.5.1)
- if (dlg->m_serverEdit->text().right(1) == "/") { //remove a trailing slash
- newSource.source = dlg->m_serverEdit->text().mid(0, dlg->m_serverEdit->text().length() - 1).toUtf8();
- }
- }
- else {
- newSource.type = "DIR";
- newSource.source = "local";
+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();
+ //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();
}
- newSource.caption = dlg->m_captionEdit->text().toUtf8();
- newSource.directory = dlg->m_pathEdit->text().toUtf8();
}
+ else {
+ newSource.type = "DIR";
+ newSource.source = "local";
+ }
+ newSource.caption = m_captionEdit->text().toUtf8();
+ newSource.directory = m_pathEdit->text().toUtf8();
+ newSource.uid = newSource.source;
+
return newSource;
}
diff --git a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
index d875cda..64c7f21 100644
--- a/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
+++ b/src/frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h
@@ -7,39 +7,44 @@
*
**********/
-
#ifndef CSWORDSETUPINSTALLSOURCESDIALOG_H
#define CSWORDSETUPINSTALLSOURCESDIALOG_H
-#include "frontend/bookshelfmanager/btinstallmgr.h"
-
#include <QDialog>
+#include "frontend/bookshelfmanager/btinstallmgr.h"
+
+// Sword includes:
#include <installmgr.h>
-class QLabel;
+
class QComboBox;
+class QLabel;
class QLineEdit;
-
-
+class QProgressDialog;
class CSwordSetupInstallSourcesDialog : public QDialog {
Q_OBJECT
public:
- static sword::InstallSource getSource();
-
- protected:
+ sword::InstallSource getSource();
+ bool wasRemoteListAdded() {return m_remoteListAdded;}
CSwordSetupInstallSourcesDialog();
protected slots:
void slotOk();
void slotProtocolChanged();
+ void slotGetListClicked();
+ void slotRefreshCanceled();
+ void slotRefreshProgress(const int, const int current);
private:
QLabel *m_serverLabel;
QLineEdit *m_captionEdit, *m_serverEdit, *m_pathEdit;
QComboBox *m_protocolCombo;
+ QProgressDialog* m_progressDialog;
+ BtInstallMgr* m_currentInstallMgr;
+ bool m_remoteListAdded;
};
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
index 2a628c9..df388dd 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.cpp
@@ -7,31 +7,28 @@
*
**********/
-#include "btindexpage.h"
+#include "frontend/bookshelfmanager/indexpage/btindexpage.h"
-#include "frontend/cmoduleindexdialog.h"
-#include "backend/config/cbtconfig.h"
-
-#include "util/ctoolclass.h"
-#include "util/cresmgr.h"
-#include "util/cpointers.h"
-#include "util/directoryutil.h"
-
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/managers/cswordbackend.h"
-
-//Qt includes
-#include <QVBoxLayout>
-#include <QHBoxLayout>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
#include <QCheckBox>
#include <QDir>
+#include <QHBoxLayout>
#include <QPushButton>
+#include <QTreeWidget>
+#include <QTreeWidgetItem>
+#include <QVBoxLayout>
+#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/cswordbackend.h"
+#include "frontend/cmoduleindexdialog.h"
+#include "util/directory.h"
+#include "util/cpointers.h"
+#include "util/cresmgr.h"
+#include "util/tool.h"
BtIndexPage::BtIndexPage()
: BtConfigPage() {
+ namespace DU = util::directory;
QVBoxLayout *vboxLayout;
QHBoxLayout *hboxLayout;
@@ -65,15 +62,15 @@ BtIndexPage::BtIndexPage()
// configure the list view
m_moduleList->setHeaderLabels( (QStringList(tr("Work")) << tr("Index size")) );
m_moduleList->setRootIsDecorated(true);
- m_moduleList->setColumnWidth(0, CToolClass::mWidth(m_moduleList, 20) );
+ m_moduleList->setColumnWidth(0, util::tool::mWidth(m_moduleList, 20) );
//m_moduleList->setTextAlignment(1, Qt::AlignRight); see doc...
m_moduleList->setSortingEnabled(false);
m_autoDeleteOrphanedIndicesBox->setChecked( CBTConfig::get( CBTConfig::autoDeleteOrphanedIndices ) );
// icons for our buttons
- m_createButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::indexpage::create_icon));
- m_deleteButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::indexpage::delete_icon));
+ m_createButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::indexpage::create_icon));
+ m_deleteButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::indexpage::delete_icon));
// connect our signals/slots
connect(m_createButton, SIGNAL(clicked()), this, SLOT(createIndices()));
diff --git a/src/frontend/bookshelfmanager/indexpage/btindexpage.h b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
index 139c4a7..aa13eb0 100644
--- a/src/frontend/bookshelfmanager/indexpage/btindexpage.h
+++ b/src/frontend/bookshelfmanager/indexpage/btindexpage.h
@@ -7,13 +7,13 @@
*
**********/
-
#ifndef BTINDEXPAGE_H
#define BTINDEXPAGE_H
#include "frontend/bookshelfmanager/btconfigdialog.h"
#include "backend/btmoduletreeitem.h"
+
class QCheckBox;
class QTreeWidget;
class QTreeWidgetItem;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
index 1668a87..8fd87ec 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.cpp
@@ -1,132 +1,29 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2009 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "btinstallmodulechooserdialog.h"
+#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h"
-#include "frontend/cmodulechooserdialog.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/btmoduletreeitem.h"
-
-#include <QString>
+#include <QBrush>
+#include <QDebug>
#include <QList>
-#include <QWidget>
+#include <QPushButton>
#include <QString>
#include <QTreeWidgetItem>
-#include <QBrush>
-#include <QPushButton>
-
-#include <QDebug>
+#include <QWidget>
+#include "backend/btmoduletreeitem.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "frontend/cmodulechooserdialog.h"
BtInstallModuleChooserDialog::BtInstallModuleChooserDialog(QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*>* empty)
: CModuleChooserDialog(parent, title, label, empty) {
- qDebug("BtInstallModuleChooserDialog::BtInstallModuleChooserDialog start");
+ qDebug() << "BtInstallModuleChooserDialog::BtInstallModuleChooserDialog start";
init();
okButton()->setText(tr("Install"));
m_nameList = QStringList();
@@ -163,16 +60,16 @@ void BtInstallModuleChooserDialog::initModuleItem(QString name, QTreeWidgetItem*
void BtInstallModuleChooserDialog::slotItemChecked(QTreeWidgetItem* item, int column) {
QString moduleName = item->text(0);
- qDebug("BtInstallModuleChooserDialog::slotItemChecked start");
+ qDebug() << "BtInstallModuleChooserDialog::slotItemChecked start";
// handle only non-toplevel items which has duplicates and where the first column was changed
if (item->parent() && column == 0 && (findModuleItemsByName(moduleName).count() > 1)) {
//prevent handling when the color is changed
if (item->data(1, Qt::UserRole).toBool() == false) {
- qDebug("was not updating");
+ qDebug() << "was not updating";
item->setData(1, Qt::UserRole, true);
}
else {
- qDebug("was updating");
+ qDebug() << "was updating";
item->setData(1, Qt::UserRole, false);
return;
}
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
index 788dbf5..06144ff 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h
@@ -12,17 +12,16 @@
#include "frontend/cmodulechooserdialog.h"
+#include <QList>
+#include <QMap>
#include <QObject>
#include <QString>
-#include <QMap>
-#include <QList>
-class BTModuleTreeItem;
+class BTModuleTreeItem;
class QWidget;
class QTreeWidgetItem;
-
/**
* Confirmation dialog for installation. Lets the user
* uncheck modules from the list.
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
index 4fe9c41..ecdf7e3 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
@@ -7,58 +7,48 @@
*
**********/
-
-#include "btinstallpage.h"
-
-#include "btinstallpathdialog.h"
-#include "btinstallprogressdialog.h"
-#include "btsourcewidget.h"
-#include "btsourcearea.h"
-
-#include "frontend/bookshelfmanager/btinstallmgr.h"
-#include "frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h"
-#include "frontend/bookshelfmanager/btconfigdialog.h"
-#include "frontend/bookshelfmanager/instbackend.h"
-#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
-
-#include "frontend/cmodulechooserdialog.h"
-
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/managers/cswordbackend.h"
-#include "backend/config/cbtconfig.h"
-
-#include "util/cpointers.h"
-#include "util/ctoolclass.h"
-#include "util/cresmgr.h"
-#include "util/directoryutil.h"
-
-#include <boost/scoped_ptr.hpp>
-
+#include "frontend/bookshelfmanager/installpage/btinstallpage.h"
#include <QAction>
#include <QApplication>
-#include <QWidget>
#include <QButtonGroup>
#include <QComboBox>
#include <QDialog>
+#include <QFileInfo>
#include <QHBoxLayout>
+#include <QHeaderView>
#include <QLabel>
+#include <QMessageBox>
+#include <QProgressBar>
+#include <QProgressDialog>
#include <QPushButton>
-#include <QToolButton>
#include <QSpacerItem>
-#include <QTabBar>
#include <QStackedWidget>
+#include <QTabBar>
+#include <QTimer>
#include <QTreeWidget>
#include <QTreeWidgetItem>
+#include <QToolButton>
#include <QVBoxLayout>
-#include <QFileInfo>
-#include <QMessageBox>
-#include <QProgressDialog>
-#include <QTimer>
-#include <QProgressBar>
-
-#include <QHeaderView>
+#include <QWidget>
+#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/cswordbackend.h"
+#include "frontend/bookshelfmanager/btconfigdialog.h"
+#include "frontend/bookshelfmanager/btinstallmgr.h"
+#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
+#include "frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h"
+#include "frontend/bookshelfmanager/installpage/btinstallpathdialog.h"
+#include "frontend/bookshelfmanager/installpage/btinstallprogressdialog.h"
+#include "frontend/bookshelfmanager/installpage/btsourcewidget.h"
+#include "frontend/bookshelfmanager/installpage/btsourcearea.h"
+#include "frontend/bookshelfmanager/instbackend.h"
+#include "frontend/cmodulechooserdialog.h"
+#include "util/directory.h"
+#include "util/cpointers.h"
+#include "util/cresmgr.h"
+// Sword includes:
#include <swversion.h>
@@ -68,13 +58,13 @@
BtInstallPage::BtInstallPage()
: BtConfigPage() {
- qDebug("BtInstallPage::BtInstallPage() start");
+ qDebug() << "BtInstallPage::BtInstallPage() start";
initView();
initConnections();
}
void BtInstallPage::setInstallEnabled(bool b) {
- qDebug("void BtInstallPage::setInstallEnabled(bool b) start");
+ qDebug() << "void BtInstallPage::setInstallEnabled(bool b) start";
m_installButton->setEnabled(b);
}
@@ -83,7 +73,9 @@ QString BtInstallPage::selectedInstallPath() {
}
void BtInstallPage::initView() {
- qDebug("void BtInstallPage::initView() start");
+ namespace DU = util::directory;
+
+ qDebug() << "void BtInstallPage::initView() start";
QVBoxLayout *mainLayout = new QVBoxLayout(this);
// installation path chooser
@@ -95,24 +87,24 @@ void BtInstallPage::initView() {
int right;
pathLayout->getContentsMargins(&left, &top, &right, &bottom);
pathLayout->setContentsMargins(left, top + 7, right, bottom + 7 );
- QSpacerItem *pathSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
- QLabel* pathLabel = new QLabel(tr("Install path:"));
+ QLabel* pathLabel = new QLabel(tr("Install folder:"));
m_pathCombo = new QComboBox();
- m_pathCombo->setToolTip(tr("The path where the new works will be installed"));
+ m_pathCombo->setMinimumContentsLength(20);
+ m_pathCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
+ m_pathCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
+ m_pathCombo->setToolTip(tr("The folder where the new works will be installed"));
+ m_pathCombo->view()->setTextElideMode(Qt::ElideMiddle);
initPathCombo(); // set the paths and the current path
- //m_configurePathButton = new QPushButton(tr("Configure...")); //TODO: icon only?
m_configurePathButton = new QToolButton(this);
- m_configurePathButton->setToolTip(tr("Configure paths where works are installed"));
- m_configurePathButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::installpage::path_icon));
+ m_configurePathButton->setToolTip(tr("Configure folders where works are installed and found"));
+ m_configurePathButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::path_icon));
- pathLayout->addItem(pathSpacer);
pathLayout->addWidget(pathLabel);
pathLayout->addWidget(m_pathCombo);
pathLayout->addWidget(m_configurePathButton);
mainLayout->addLayout(pathLayout);
// Source widget
- //QTabWidget* m_sourcesTabWidget;
m_sourceWidget = new BtSourceWidget(this);
mainLayout->addWidget(m_sourceWidget);
// Install button
@@ -122,7 +114,7 @@ void BtInstallPage::initView() {
installButtonLayout->addItem(installButtonSpacer);
m_installButton = new QPushButton(tr("Install..."), this);
m_installButton->setToolTip(tr("Install or update selected works"));
- m_installButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::installpage::install_icon));
+ m_installButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::install_icon));
m_installButton->setEnabled(false);
installButtonLayout->addWidget(m_installButton);
@@ -130,7 +122,7 @@ void BtInstallPage::initView() {
}
void BtInstallPage::initConnections() {
- qDebug("void BtInstallPage::initConnections() start");
+ qDebug() << "void BtInstallPage::initConnections() start";
QObject::connect(m_pathCombo, SIGNAL(activated(const QString&)), this , SLOT(slotPathChanged(const QString&)));
QObject::connect(m_configurePathButton, SIGNAL(clicked()), this, SLOT(slotEditPaths()));
QObject::connect(m_installButton, SIGNAL(clicked()), m_sourceWidget, SLOT(slotInstall()) );
@@ -140,14 +132,20 @@ void BtInstallPage::initConnections() {
}
void BtInstallPage::initPathCombo() {
- qDebug("void BtInstallPage::initPathCombo() start");
+ qDebug() << "void BtInstallPage::initPathCombo() start";
//populate the combo list
m_pathCombo->clear();
QStringList targets = instbackend::targetList();
for (QStringList::iterator it = targets.begin(); it != targets.end(); ++it) {
+ // Add the path only if it's writable
if ((*it).isEmpty()) continue;
- m_pathCombo->addItem(*it);
+ QDir dir(*it);
+ if (!dir.exists()) continue;
+ if (!dir.isReadable()) continue;
+ QFileInfo fi( dir.canonicalPath());
+ if (!fi.isWritable()) continue;
+ m_pathCombo->addItem(util::directory::convertDirSeparators(*it));
}
// choose the current value from config but check whether we have so many items
@@ -161,7 +159,7 @@ void BtInstallPage::slotPathChanged(const QString& /*pathText*/) {
}
void BtInstallPage::slotEditPaths() {
- qDebug("void BtInstallPage::slotEditPaths() start");
+ qDebug() << "void BtInstallPage::slotEditPaths() start";
BtInstallPathDialog* dlg = new BtInstallPathDialog();
int result = dlg->exec();
@@ -177,7 +175,7 @@ QString BtInstallPage::iconName() {
return CResMgr::bookshelfmgr::installpage::icon;
}
QString BtInstallPage::label() {
- // TODO: move the warning to a dialog which is shown when adding a source.
+ // \todo move the warning to a dialog which is shown when adding a source.
return tr("Install and update works. Add remote or local sources, refresh them, select the works to be installed/updated and click Install.<br/><b>WARNING:</b> If you live in a persecuted country and don't want to risk detection don't use remote sources.");
}
QString BtInstallPage::header() {
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.h b/src/frontend/bookshelfmanager/installpage/btinstallpage.h
index 41493f8..fde9919 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.h
@@ -10,16 +10,15 @@
#ifndef BTINSTALLPAGE_H
#define BTINSTALLPAGE_H
-
#include "frontend/bookshelfmanager/btconfigdialog.h"
#include <QString>
+// Sword includes:
#include <installmgr.h>
class BtSourceWidget;
-
class QComboBox;
class QPushButton;
class QToolButton;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
index 27b3d3a..c6175d5 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.cpp
@@ -7,32 +7,31 @@
*
**********/
-#include "btinstallpathdialog.h"
+#include "frontend/bookshelfmanager/installpage/btinstallpathdialog.h"
-#include "frontend/bookshelfmanager/instbackend.h"
-
-#include "util/ctoolclass.h"
-#include "util/dialogutil.h"
-#include "util/directoryutil.h"
-#include "util/cresmgr.h"
-
-#include <QString>
+#include <QDebug>
#include <QDialog>
+#include <QDialogButtonBox>
#include <QDir>
+#include <QFileDialog>
#include <QGridLayout>
+#include <QHeaderView>
#include <QLabel>
+#include <QPushButton>
+#include <QString>
#include <QTreeWidget>
#include <QTreeWidgetItem>
-#include <QPushButton>
-#include <QFileDialog>
-#include <QMessageBox>
-#include <QHeaderView>
-#include <QDialogButtonBox>
+#include "frontend/bookshelfmanager/instbackend.h"
+#include "util/dialogutil.h"
+#include "util/directory.h"
+#include "util/cresmgr.h"
+#include "util/tool.h"
-#include <QDebug>
BtInstallPathDialog::BtInstallPathDialog() {
- setWindowTitle(tr("Bookshelf Paths"));
+ namespace DU = util::directory;
+
+ setWindowTitle(tr("Bookshelf Folders"));
QVBoxLayout *mainLayout;
QHBoxLayout *viewLayout;
@@ -40,15 +39,17 @@ BtInstallPathDialog::BtInstallPathDialog() {
mainLayout = new QVBoxLayout(this);
viewLayout = new QHBoxLayout();
- QString l1 = tr("Works can be installed in one or more directories. After setting up directories here you can choose one of them in Install page.");
- QString l2 = tr("BibleTime and the Sword library find the modules from all of these directories. If the directory is removed here it still exists in the system with all the works in it. \".sword\" directory in your home directory is always used automatically and can't be removed or added.");
+ QString l1 = tr("Works can be installed in one or more folders. After setting up folders here you can choose one of them in Install page.");
+ /// \bug The following string has an extra space character:
+ QString l2 = tr("BibleTime and the SWORD library find the works from all of these folders. If a folder is removed here it still exists in the system with all the works in it.");
- QLabel* mainLabel = CToolClass::explanationLabel(this,
- tr("Configure bookshelf paths"), l1 + QString("<small><br><br>") + l2 + QString("</small>"));
+ QLabel* mainLabel = util::tool::explanationLabel(this,
+ tr("Configure bookshelf folders"), l1 + QString("<small><br/><br/>") + l2 + QString("</small>"));
mainLayout->addWidget(mainLabel);
QString swordConfPath = instbackend::swordConfigFilename();
- QLabel* confPathLabel = new QLabel(tr("Configuration file for the paths is: ").append("<b>%1</b>").arg(swordConfPath), this);
+ /// \todo After releasing 2.4, change the following line to: QLabel *confPathLabel = new QLabel(tr("Configuration file for the folders is: <b>%1</b>").arg(swordConfPath), this);
+ QLabel* confPathLabel = new QLabel(tr("Configuration file for the folders is: ").append("<b>%1</b>").arg(swordConfPath), this);
confPathLabel->setWordWrap(true);
mainLayout->addWidget(confPathLabel);
@@ -56,32 +57,40 @@ BtInstallPathDialog::BtInstallPathDialog() {
m_swordPathListBox = new QTreeWidget(this);
m_swordPathListBox->header()->hide();
- QDir swordDir = instbackend::swordDir();
+ QString rwfolderitem(tr("Folders where new works can be installed"));
+ m_writableItem = new QTreeWidgetItem(m_swordPathListBox, QStringList(rwfolderitem));;
+ m_writableItem->setFlags(Qt::ItemIsEnabled);
+ m_readableItem = new QTreeWidgetItem(m_swordPathListBox, QStringList(tr("Read-only folders")));;
+ m_readableItem->setFlags(Qt::ItemIsEnabled);
+ m_nonexistingItem = new QTreeWidgetItem(m_swordPathListBox, QStringList(tr("Nonexistent folders")));;
+ m_nonexistingItem->setFlags(Qt::ItemIsEnabled);
+
QStringList targets = instbackend::targetList();
+
foreach (QString pathname, targets) {
- if (pathname.isEmpty() || QDir(pathname) == swordDir) continue;
- new QTreeWidgetItem(m_swordPathListBox, QStringList(pathname) );
+ addPathToList(pathname);
}
+ updateTopLevelItems();
viewLayout->addWidget(m_swordPathListBox);
QVBoxLayout* buttonLayout = new QVBoxLayout();
m_addButton = new QPushButton(tr("Add..."), this);
- m_addButton->setToolTip(tr("Add new path"));
- m_addButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::paths::add_icon));
+ m_addButton->setToolTip(tr("Add new folder"));
+ m_addButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::paths::add_icon));
connect(m_addButton, SIGNAL(clicked()), this, SLOT(slotAddClicked()));
buttonLayout->addWidget(m_addButton);
m_editButton = new QPushButton(tr("Edit..."), this);
- m_editButton->setToolTip(tr("Edit the selected path"));
- m_editButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::paths::edit_icon));
+ m_editButton->setToolTip(tr("Edit the selected folder"));
+ m_editButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::paths::edit_icon));
connect(m_editButton, SIGNAL(clicked()), this, SLOT(slotEditClicked()));
buttonLayout->addWidget(m_editButton);
m_removeButton = new QPushButton(tr("Remove"), this);
- m_removeButton->setToolTip(tr("Remove the selected path"));
- m_removeButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::paths::remove_icon));
+ m_removeButton->setToolTip(tr("Remove the selected folder"));
+ m_removeButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::paths::remove_icon));
connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveClicked()));
buttonLayout->addWidget(m_removeButton);
@@ -98,12 +107,65 @@ BtInstallPathDialog::BtInstallPathDialog() {
mainLayout->addWidget(buttonBox);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
+ //clumsy way to set width. Could someone please fix Qt to have an easy way to set widget sizes?
+ int textWidth = fontMetrics().width(rwfolderitem.append("MMMMMMMMMM"));
+ int buttonWidth = m_addButton->width();
+ resize(textWidth + buttonWidth, size().height());
+}
+
+BtInstallPathDialog::~BtInstallPathDialog() {
+ m_swordPathListBox->invisibleRootItem()->takeChildren();
+ delete m_readableItem;
+ delete m_writableItem;
+ delete m_nonexistingItem;
+}
+
+void BtInstallPathDialog::updateTopLevelItems() {
+ qDebug() << "BtInstallPathDialog::updateTopLevelItems";
+ if (m_writableItem->childCount()) {
+ m_writableItem->setHidden(false);
+ m_swordPathListBox->expandItem(m_writableItem);
+ } else {
+ m_writableItem->setHidden(true);
+ }
+ if (m_readableItem->childCount()) {
+ m_readableItem->setHidden(false);
+ m_swordPathListBox->expandItem(m_readableItem);
+ } else {
+ m_readableItem->setHidden(true);
+ }
+ if (m_nonexistingItem->childCount()) {
+ m_nonexistingItem->setHidden(false);
+ m_swordPathListBox->expandItem(m_nonexistingItem);
+ } else {
+ m_nonexistingItem->setHidden(true);
+ }
+}
+
+void BtInstallPathDialog::addPathToList(QString pathname) {
+ if (pathname.isEmpty()) return;
+ QTreeWidgetItem* i = 0;
+ QDir dir(pathname);
+ if (!dir.exists()) {
+ i = new QTreeWidgetItem(m_nonexistingItem, QStringList(pathname) );
+ } else if (dir.isReadable()) {
+ const QFileInfo fi( dir.canonicalPath() );
+ if (fi.isWritable()) {
+ i = new QTreeWidgetItem(m_writableItem, QStringList(pathname) );
+ } else {
+ i = new QTreeWidgetItem(m_readableItem, QStringList(pathname) );
+ }
+ }
+ if (i && QDir(pathname) == instbackend::swordDir()) {
+ i->setFlags(Qt::NoItemFlags);
+ i->setToolTip(0, tr("This default folder in your home directory can't be removed"));
+ }
}
void BtInstallPathDialog::slotEditClicked() {
if (QTreeWidgetItem* i = m_swordPathListBox->currentItem()) {
- QString dirname = QFileDialog::getExistingDirectory(this, tr("Choose directory"), i->text(0), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
+ QString dirname = QFileDialog::getExistingDirectory(this, tr("Choose Folder"), i->text(0), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (dirname.isEmpty()) { // if user cancelled the dialog
return;
@@ -112,16 +174,19 @@ void BtInstallPathDialog::slotEditClicked() {
if (dir.isReadable()) {
const QFileInfo fi( dir.canonicalPath() );
if (!fi.exists() || !fi.isWritable()) {
- const int result = QMessageBox::warning(this, tr("Use Directory?"), tr("This directory is not writable, so works can not be installed here using BibleTime. Do you want to use this directory instead of the previous value?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+ 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);
if (result != QMessageBox::Yes) return;
}
- i->setText(0, dir.absolutePath()); // absolute, not canonical
+ //i->setText(0, dir.absolutePath()); // absolute, not canonical
+ addPathToList(dir.absolutePath());
+ delete i;
+ updateTopLevelItems();
}
}
}
void BtInstallPathDialog::slotAddClicked() {
- QString dirname = QFileDialog::getExistingDirectory(this, tr("Choose directory"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
+ QString dirname = QFileDialog::getExistingDirectory(this, tr("Choose Folder"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (dirname.isEmpty()) { // if user cancelled the dialog
return;
}
@@ -129,36 +194,39 @@ void BtInstallPathDialog::slotAddClicked() {
if (dir.isReadable()) {
const QFileInfo fi( dir.canonicalPath() );
if (!fi.exists() || !fi.isWritable()) {
- const int result = QMessageBox::warning(this, tr("Warning"), tr("This directory is not writable, so works can not be installed here using BibleTime. Do you still want to add it to the list of bookshelf directories?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
+ 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);
if (result != QMessageBox::Yes) {
return;
}
}
- new QTreeWidgetItem(m_swordPathListBox, QStringList(dir.canonicalPath()) );
+ addPathToList(util::directory::convertDirSeparators(dir.canonicalPath()));
+ updateTopLevelItems();
}
}
void BtInstallPathDialog::slotRemoveClicked() {
- QTreeWidgetItem* i = m_swordPathListBox->currentItem();
- if (i) {
+ qDebug() << "BtInstallPathDialog::slotRemoveClicked";
+ QTreeWidgetItem* i = m_swordPathListBox->selectedItems().value(0);
+ qDebug() << i;
+ if (i && i->parent() != m_swordPathListBox->invisibleRootItem()) {
+ qDebug() << "delete" << i;
delete i;
}
+ updateTopLevelItems();
}
void BtInstallPathDialog::writeSwordConfig() {
- qDebug("BtInstallPathDialog::writeSwordConfig");
- if (m_swordPathListBox->topLevelItemCount() >= 0) {
- QStringList targets;
- QTreeWidgetItemIterator it(m_swordPathListBox);
- while (*it) {
- if (!(*it)->text(0).isEmpty()) {
- targets << (*it)->text(0);
- }
- ++it;
+ qDebug() << "BtInstallPathDialog::writeSwordConfig";
+ QStringList targets;
+ QTreeWidgetItemIterator it(m_swordPathListBox, QTreeWidgetItemIterator::NoChildren|QTreeWidgetItemIterator::Enabled|QTreeWidgetItemIterator::NotHidden);
+ while (*it) {
+ if (!(*it)->text(0).isEmpty()) {
+ targets << (*it)->text(0);
}
- qDebug() << "save the target list" << targets;
- instbackend::setTargetList(targets); //creates new Sword config
+ ++it;
}
+ qDebug() << "save the target list" << targets;
+ instbackend::setTargetList(targets); //creates new Sword config
}
void BtInstallPathDialog::accept() {
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
index b2f18a1..e72da3c 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpathdialog.h
@@ -12,14 +12,16 @@
#include <QDialog>
+
class QPushButton;
class QTreeWidget;
-
+class QTreeWidgetItem;
class BtInstallPathDialog : public QDialog {
Q_OBJECT
public:
BtInstallPathDialog();
+ ~BtInstallPathDialog();
public slots:
virtual void accept();
@@ -31,13 +33,17 @@ class BtInstallPathDialog : public QDialog {
private:
void writeSwordConfig();
+ void updateTopLevelItems();
+ void addPathToList(QString path);
private:
QPushButton* m_editButton;
QPushButton* m_addButton;
QPushButton* m_removeButton;
QTreeWidget* m_swordPathListBox;
-
+ QTreeWidgetItem* m_writableItem;
+ QTreeWidgetItem* m_readableItem;
+ QTreeWidgetItem* m_nonexistingItem;
};
#endif
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
index 7883220..365d5c8 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.cpp
@@ -7,26 +7,22 @@
*
**********/
-#include "btinstallprogressdialog.h"
+#include "frontend/bookshelfmanager/installpage/btinstallprogressdialog.h"
-#include "btinstallthread.h"
-
-#include "util/ctoolclass.h"
-#include "util/cpointers.h"
-#include "backend/managers/cswordbackend.h"
-
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
+#include <QApplication>
+#include <QCloseEvent>
+#include <QDebug>
#include <QDialog>
#include <QHeaderView>
+#include <QMultiMap>
#include <QProgressBar>
#include <QPushButton>
+#include <QTreeWidget>
+#include <QTreeWidgetItem>
#include <QVBoxLayout>
-#include <QApplication>
-#include <QCloseEvent>
-#include <QMultiMap>
-
-#include <QDebug>
+#include "backend/managers/cswordbackend.h"
+#include "frontend/bookshelfmanager/installpage/btinstallthread.h"
+#include "util/cpointers.h"
BtInstallProgressDialog::BtInstallProgressDialog(QWidget* parent, QTreeWidget* selectedModulesTreeWidget, QString destination)
@@ -41,7 +37,7 @@ BtInstallProgressDialog::BtInstallProgressDialog(QWidget* parent, QTreeWidget* s
m_statusWidget->header()->setStretchLastSection(false);
m_statusWidget->header()->setResizeMode(1, QHeaderView::Stretch);
m_statusWidget->header()->setMovable(false);
- //m_statusWidget->setColumnWidth(1, CToolClass::mWidth(m_statusWidget, 2));
+ //m_statusWidget->setColumnWidth(1, util::tool::mWidth(m_statusWidget, 2));
foreach (QTreeWidgetItem* sourceItem, selectedModulesTreeWidget->invisibleRootItem()->takeChildren()) {
// create items and threads for modules under this source
@@ -125,7 +121,7 @@ void BtInstallProgressDialog::startThreads() {
t->start();
}
- qDebug("BtInstallProgressDialog::startThreads end");
+ qDebug() << "BtInstallProgressDialog::startThreads end";
}
BtInstallProgressDialog::~BtInstallProgressDialog() {}
@@ -133,7 +129,8 @@ BtInstallProgressDialog::~BtInstallProgressDialog() {}
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.
+ //status comes from the sword installer.
+ /// \todo Additionally we should check that there are files really installed.
if (status != 0) {
message = tr("Failed");
}
@@ -189,7 +186,7 @@ void BtInstallProgressDialog::oneItemStoppedOrCompleted(QString module, QString
}
void BtInstallProgressDialog::slotStopInstall() {
- qDebug("BtInstallProgressDialog::slotStopInstall");
+ qDebug() << "BtInstallProgressDialog::slotStopInstall";
// Clear the waiting threads map, stop all running threads.
@@ -205,7 +202,7 @@ void BtInstallProgressDialog::slotStopInstall() {
}
void BtInstallProgressDialog::slotStatusUpdated(QString module, int status) {
- //qDebug("BtInstallProgressDialog::slotStatusUpdated");
+ //qDebug() << "BtInstallProgressDialog::slotStatusUpdated";
//qDebug() << "module:" << module << "status:" << status;
// find the progress bar for this module and update the value
QWidget* itemWidget = m_statusWidget->itemWidget(getItem(module) , 1);
@@ -234,7 +231,7 @@ QTreeWidgetItem* BtInstallProgressDialog::getItem(QString moduleName) {
}
void BtInstallProgressDialog::closeEvent(QCloseEvent* event) {
- qDebug("BtInstallProgressDialog::closeEvent");
+ qDebug() << "BtInstallProgressDialog::closeEvent";
if (event->spontaneous()) {
event->ignore();
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
index 79c6331..1d8113a 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallprogressdialog.h
@@ -11,18 +11,15 @@
#define BTINSTALLPROGRESSDIALOG_H
#include <QDialog>
-#include <QString>
+
#include <QMultiMap>
+#include <QString>
-class QTreeWidget;
-class QTreeWidgetItem;
class BtInstallThread;
+class QTreeWidget;
+class QTreeWidgetItem;
-
-/**
-
-*/
class BtInstallProgressDialog : public QDialog {
Q_OBJECT
public:
@@ -50,7 +47,7 @@ class BtInstallProgressDialog : public QDialog {
private:
- //TODO: using maps is tedious and error prone. Find better solution for handling the modules
+ /// \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;
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp b/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
index 48e38ce..53ae071 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallthread.cpp
@@ -7,23 +7,22 @@
*
**********/
-#include "btinstallthread.h"
-
-#include "frontend/bookshelfmanager/btinstallmgr.h"
-#include "frontend/bookshelfmanager/instbackend.h"
-#include "util/cpointers.h"
-#include "backend/managers/cswordbackend.h"
+#include "frontend/bookshelfmanager/installpage/btinstallthread.h"
#include <QApplication>
+#include <QDebug>
+#include <QDir>
#include <QString>
#include <QThread>
-#include <QDir>
-
-#include <QDebug>
+#include "backend/managers/cswordbackend.h"
+#include "frontend/bookshelfmanager/btinstallmgr.h"
+#include "frontend/bookshelfmanager/instbackend.h"
+#include "util/cpointers.h"
-// sword
+// Sword includes:
#include <filemgr.h>
+
BtInstallThread::BtInstallThread(QObject* parent, QString moduleName, QString sourceName, QString destinationName)
: QThread(parent),
done(false),
@@ -44,12 +43,13 @@ void BtInstallThread::run() {
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.reset(new sword::InstallSource(instbackend::source(m_source)));
m_backendForSource.reset(instbackend::backend(*m_installSource));
//make sure target/mods.d and target/modules exist
- //TODO: move this to some common precondition
+ /// \todo move this to some common precondition
QDir dir(m_destination);
if (!dir.exists()) {
dir.mkdir(m_destination);
@@ -68,7 +68,7 @@ void BtInstallThread::run() {
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!!!
+ /// \todo silently removing without undo if the user cancels the update is WRONG!!!
removeModule();
// manager for the destination path
@@ -112,35 +112,36 @@ void BtInstallThread::slotStopInstall() {
qDebug() << "BtInstallThread::slotStopInstall 2";
//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(200);
+ int notRun = this->wait(25000);
if (notRun) {
this->terminate();
- this->wait(2);
+ 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;
}
qDebug() << "BtInstallThread::slotStopInstall 3";
// cleanup: remove the module, remove the temp files
- if (true) {
+ // if installation has already started
+ if (m_installSource.get() != 0) {
qDebug() << "BtInstallThread::slotStopInstall 4";
// 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);
}
+ emit installStopped(m_module, m_source);
}
}
void BtInstallThread::slotManagerStatusUpdated(int totalProgress, int /*fileProgress*/) {
- //qDebug("BtInstallThread::slotManagerStatusUpdated");
+ //qDebug() << "BtInstallThread::slotManagerStatusUpdated";
emit statusUpdated(m_module, totalProgress);
}
void BtInstallThread::slotDownloadStarted() {
- qDebug("BtInstallThread::slotDownloadStarted");
+ qDebug() << "BtInstallThread::slotDownloadStarted";
emit downloadStarted(m_module);
}
@@ -176,7 +177,7 @@ void BtInstallThread::removeModule() {
}
void BtInstallThread::removeTempFiles() {
- qDebug("BtInstallThread::removeTempFiles start");
+ qDebug() << "BtInstallThread::removeTempFiles start";
// (take the remote conf file for this module, take DataPath,
// take the absolute path of the InstallMgr)
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallthread.h b/src/frontend/bookshelfmanager/installpage/btinstallthread.h
index 8a8cb37..a50910f 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallthread.h
+++ b/src/frontend/bookshelfmanager/installpage/btinstallthread.h
@@ -10,11 +10,11 @@
#ifndef BTINSTALLTHREAD_H
#define BTINSTALLTHREAD_H
-#include "frontend/bookshelfmanager/btinstallmgr.h"
-
#include <QThread>
#include <boost/scoped_ptr.hpp>
+#include "frontend/bookshelfmanager/btinstallmgr.h"
+
class BtInstallProgressDialog;
@@ -78,7 +78,7 @@ class BtInstallThread : public QThread {
BtInstallMgr* m_iMgr;
//BtInstallMgr m_iMgr;
boost::scoped_ptr<sword::InstallSource> m_installSource;
- //TODO: it would be best to get the backend from the bookshelf manager install page
+ /// \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.
boost::scoped_ptr<CSwordBackend> m_backendForSource;
diff --git a/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp b/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp
index cfdc8bb..ca85822 100644
--- a/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btsourcearea.cpp
@@ -7,19 +7,7 @@
*
**********/
-#include "btsourcearea.h"
-
-#include "frontend/bookshelfmanager/instbackend.h"
-
-#include "util/ctoolclass.h"
-#include "util/cpointers.h"
-#include "util/cresmgr.h"
-#include "util/directoryutil.h"
-
-#include "backend/managers/cswordbackend.h"
-#include "frontend/btaboutmoduledialog.h"
-
-#include <installmgr.h>
+#include "frontend/bookshelfmanager/installpage/btsourcearea.h"
#include <QString>
#include <QWidget>
@@ -32,9 +20,19 @@
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QHeaderView>
-
#include <QDebug>
#include <QTime>
+#include "backend/managers/cswordbackend.h"
+#include "frontend/bookshelfmanager/instbackend.h"
+#include "frontend/btaboutmoduledialog.h"
+#include "util/directory.h"
+#include "util/cpointers.h"
+#include "util/cresmgr.h"
+#include "util/tool.h"
+
+// Sword includes:
+#include <installmgr.h>
+
// ****************************************************************
// ******** Installation source and module list widget ************
@@ -45,46 +43,40 @@ BtSourceArea::BtSourceArea(const QString& sourceName)
m_sourceName(sourceName),
m_treeAlreadyInitialized(false),
m_remoteBackend(0) { //important!
+ setObjectName(sourceName);
m_checkedModules = QMap<QString, bool>();
qDebug() << "BtSourceArea::BtSourceArea, " << m_sourceName;
initView();
}
BtSourceArea::~BtSourceArea() {
+ qDebug() << "BtSourceArea::~BtSourceArea" << m_sourceName;
delete m_remoteBackend;
}
void BtSourceArea::initView() {
- qDebug("BtSourceArea::initView");
+ namespace DU = util::directory;
+
+ qDebug() << "BtSourceArea::initView";
QVBoxLayout *mainLayout = new QVBoxLayout(this);
- //QHBoxLayout *refreshLabelLayout = new QHBoxLayout();
- //QLabel *refreshLabel = new QLabel(tr("Last refreshed:"));
- //m_refreshTimeLabel = new QLabel();
- //QSpacerItem *refreshLabelSpacer = new QSpacerItem(201, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
-
- //refreshLabelLayout->addWidget(refreshLabel);
- //refreshLabelLayout->addWidget(m_refreshTimeLabel);
- //refreshLabelLayout->addItem(refreshLabelSpacer);
- // TODO: or would it be better to integrate this information into the tooltip
- // of the source tab?
- //mainLayout->addLayout(refreshLabelLayout);
// source related button row
QHBoxLayout *sourceLayout = new QHBoxLayout();
m_refreshButton = new QPushButton(tr("Refresh..."));
m_refreshButton->setToolTip(tr("Refresh the list of works from this source"));
- m_refreshButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::installpage::refresh_icon));
+ m_refreshButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::refresh_icon));
//m_refreshButton->setEnabled(false);
QSpacerItem *sourceSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
//m_editButton = new QPushButton(tr("Edit..."));
- //m_editButton->setEnabled(false); // TODO after writing the edit widget
+ /// \todo after writing the edit widget:
+ //m_editButton->setEnabled(false);
m_deleteButton = new QPushButton(tr("Delete..."));
m_deleteButton->setToolTip(tr("Delete this source"));
- m_deleteButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::installpage::delete_icon));
+ m_deleteButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::delete_icon));
//m_deleteButton->setEnabled(false);
m_addButton = new QPushButton(tr("Add..."));
m_addButton->setToolTip(tr("Add new source"));
- m_addButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::installpage::add_icon));
+ m_addButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::add_icon));
sourceLayout->addWidget(m_refreshButton);
sourceLayout->addItem(sourceSpacer);
@@ -96,7 +88,7 @@ void BtSourceArea::initView() {
// There are no views for the stack yet, see initSources
m_view = new QTreeWidget(this);
m_view->setHeaderLabels(QStringList() << tr("Work") << tr("Description"));
- m_view->setColumnWidth(0, CToolClass::mWidth(m_view, 20));
+ m_view->setColumnWidth(0, util::tool::mWidth(m_view, 20));
mainLayout->addWidget(m_view);
connect(m_view, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), SLOT(slotItemDoubleClicked(QTreeWidgetItem*, int)));
@@ -104,6 +96,11 @@ void BtSourceArea::initView() {
connect(this, SIGNAL(signalCreateTree()), SLOT(slotCreateTree()), Qt::QueuedConnection);
}
+void BtSourceArea::prepareRemove() {
+ // don't create tree anymore, this will be removed
+ disconnect(this, SIGNAL(signalCreateTree()), this, SLOT(slotCreateTree()));
+}
+
QSize BtSourceArea::sizeHint() const {
return QSize(100, m_refreshButton->height() + (m_view->header()->height() * 5));
}
@@ -116,7 +113,7 @@ void BtSourceArea::initTreeFirstTime() {
}
void BtSourceArea::createModuleTree() {
- qDebug("BtSourceArea::createModuleTree start");
+ qDebug() << "BtSourceArea::createModuleTree start";
// Start creating tree with a queued connection.
// This makes showing the dialog possible even before the tree is initialized.
emit signalCreateTree();
@@ -133,8 +130,7 @@ void BtSourceArea::slotCreateTree() {
disconnect(m_view, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*, int)) );
m_view->clear();
- // TODO: if the tree already exists for this source,
- // maybe the selections should be preserved
+ /// \todo if the tree already exists for this source, maybe the selections should be preserved
m_checkedModules.clear();
sword::InstallSource is = instbackend::source(m_sourceName);
@@ -181,11 +177,13 @@ void BtSourceArea::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem
QString installedV;
if (!installedModule) {
- // possible TODO: save the module list of a source before refreshing,
- // compare after refreshing, mark the newly added modules
- //if not newly added:
- //state: installable (no indicator)
- //else: status: newly added, color yellow
+ /**
+ \todo maybe? save the module list of a source before refreshing,
+ compare after refreshing, mark the newly added modules if
+ not newly added:
+ state: installable (no indicator)
+ else: status: newly added, color yellow
+ */
} else { // the module is already installed
QBrush bg(QColor(255, 153, 153)); /// \bug Possible color conflict
widgetItem->setBackground(0, bg);
@@ -206,7 +204,7 @@ void BtSourceArea::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem
QString descr(mInfo->config(CSwordModuleInfo::Description));
- QString toolTipText = CToolClass::remoteModuleToolTip(mInfo, installedV);
+ QString toolTipText = util::tool::remoteModuleToolTip(mInfo, installedV);
widgetItem->setText(1, descr);
widgetItem->setToolTip(0, toolTipText);
@@ -226,7 +224,7 @@ QMap<QString, bool>* BtSourceArea::selectedModules() {
// when a module is checked/unchecked
void BtSourceArea::slotSelectionChanged(QTreeWidgetItem* item, int column) {
- //qDebug("BtSourceArea::slotSelectionChanged");
+ //qDebug() << "BtSourceArea::slotSelectionChanged";
// modify the internal list of selected (actually checked) modules
// if() leaves groups away
if (!item->childCount() && column == 0) {
@@ -269,7 +267,7 @@ bool BtSourceArea::InstalledFilter::filter(CSwordModuleInfo* mInfo) {
//qDebug() << "BtSourceArea::InstalledFilter::filter, module " << mInfo->name();
CSwordModuleInfo* const installedModule = CPointers::backend()->findModuleByName(mInfo->name());
if (installedModule) {
- //qDebug("already installed, check if it's an update...");
+ //qDebug() << "already installed, check if it's an update...";
const sword::SWVersion installedVersion(installedModule->config(CSwordModuleInfo::ModuleVersion).toLatin1());
const sword::SWVersion newVersion(mInfo->config(CSwordModuleInfo::ModuleVersion).toLatin1());
if (installedVersion >= newVersion) {
diff --git a/src/frontend/bookshelfmanager/installpage/btsourcearea.h b/src/frontend/bookshelfmanager/installpage/btsourcearea.h
index e39efef..ece20ed 100644
--- a/src/frontend/bookshelfmanager/installpage/btsourcearea.h
+++ b/src/frontend/bookshelfmanager/installpage/btsourcearea.h
@@ -10,15 +10,16 @@
#ifndef BTSOURCEAREA_H
#define BTSOURCEAREA_H
-#include "backend/btmoduletreeitem.h"
+#include <QWidget>
#include <boost/scoped_ptr.hpp>
+#include <QApplication>
+#include <QMap>
+#include "backend/btmoduletreeitem.h"
+// Sword includes:
#include <installmgr.h>
-#include <QWidget>
-#include <QMap>
-#include <QApplication>
class QTreeWidget;
class QTreeWidgetItem;
@@ -54,6 +55,7 @@ class BtSourceArea : public QWidget {
~BtSourceArea();
void initView();
+ void prepareRemove();
/** Reimplemented from QWidget. */
virtual QSize sizeHint() const;
void initTreeFirstTime();
@@ -89,8 +91,6 @@ class BtSourceArea : public QWidget {
QPushButton* m_editButton;
QPushButton* m_deleteButton;
QPushButton* m_addButton;
-
-
};
#endif
diff --git a/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp b/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp
index f18935a..8c43837 100644
--- a/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btsourcewidget.cpp
@@ -7,44 +7,42 @@
*
**********/
-#include "btsourcewidget.h"
+#include "frontend/bookshelfmanager/installpage/btsourcewidget.h"
-#include "btinstallpage.h"
-#include "btsourcearea.h"
-#include "btinstallprogressdialog.h"
-#include "btinstallmodulechooserdialog.h"
-
-#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
-#include "frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h"
-#include "frontend/bookshelfmanager/btinstallmgr.h"
-#include "frontend/bookshelfmanager/instbackend.h"
-
-
-#include <QString>
-#include <QWidget>
-#include <QTabWidget>
-#include <QMessageBox>
-#include <QProgressDialog>
-#include <QPushButton>
#include <QApplication>
#include <QFileInfo>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QProgressDialog>
+#include <QPushButton>
+#include <QString>
#include <QTabBar>
+#include <QTabWidget>
#include <QTreeWidget>
#include <QTreeWidgetItem>
-#include <QHBoxLayout>
-#include <QLabel>
+#include <QWidget>
+#include "frontend/bookshelfmanager/btinstallmgr.h"
+#include "frontend/bookshelfmanager/btmodulemanagerdialog.h"
+#include "frontend/bookshelfmanager/cswordsetupinstallsourcesdialog.h"
+#include "frontend/bookshelfmanager/installpage/btinstallmodulechooserdialog.h"
+#include "frontend/bookshelfmanager/installpage/btinstallpage.h"
+#include "frontend/bookshelfmanager/installpage/btinstallprogressdialog.h"
+#include "frontend/bookshelfmanager/installpage/btsourcearea.h"
+#include "frontend/bookshelfmanager/instbackend.h"
+#include "util/dialogutil.h"
-// ****************************************************************
-// ******** Tab Widget that holds source widgets ******************
-// ****************************************************************
+/**
+* Tab Widget that holds source widgets
+*/
BtSourceWidget::BtSourceWidget(BtInstallPage* parent)
: QTabWidget(parent),
m_page(parent) {
- qDebug("BtSourceWidget::BtSourceWidget start");
+ qDebug() << "BtSourceWidget::BtSourceWidget start";
initSources();
-
- // TODO: choose the page from config
+ // send queued event because "Delete" is initiated from tab which should be deleted
+ connect(this, SIGNAL(sigInitSources()), SLOT(initSources()), Qt::QueuedConnection);
+ /// \todo choose the page from config
}
@@ -58,56 +56,57 @@ QString BtSourceWidget::currentSourceName() {
}
void BtSourceWidget::initSourceConnections() {
- qDebug("void BtSourceWidget::initSourceConnections() start");
+ qDebug() << "void BtSourceWidget::initSourceConnections() start";
if (area()) {
connect(area()->m_refreshButton, SIGNAL(clicked()), SLOT(slotRefresh()));
//connect(area()->m_editButton, SIGNAL(clicked()), SLOT(slotEdit()));
- connect(area()->m_deleteButton, SIGNAL(clicked()), SLOT(slotDelete()));
+ connect(area()->m_deleteButton, SIGNAL(clicked()), SLOT(slotDelete()), Qt::QueuedConnection);
connect(area()->m_addButton, SIGNAL(clicked()), SLOT(slotAdd()));
connect(area(), SIGNAL(signalSelectionChanged(QString, int)), SLOT(slotModuleSelectionChanged(QString, int)) );
}
- qDebug("void BtSourceWidget::initSourceConnections() end");
+ qDebug() << "void BtSourceWidget::initSourceConnections() end";
}
void BtSourceWidget::slotEdit() {
- qDebug("BtSourceWidget::slotEdit");
- // open the source editor dialog
+ qDebug() << "BtSourceWidget::slotEdit";
+ /// \todo open the source editor dialog
// if the source was changed, init the sources
}
void BtSourceWidget::slotDelete() {
- qDebug("void BtSourceWidget::slotDelete() start");
+ qDebug() << "void BtSourceWidget::slotDelete() start";
// ask for confirmation
- int ret = QMessageBox::warning(this, tr("Delete Source?"),
- tr("Do you really want to delete this source?"),
- QMessageBox::Yes | QMessageBox::No);
+ int ret = util::showWarning(this, tr("Delete Source?"),
+ tr("Do you really want to delete this source?"),
+ QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::Yes) {
instbackend::deleteSource(currentSourceName());
-
- // remove the UI elements
- m_sourceNameList.removeAt(currentIndex());
- QWidget* w = currentWidget();
- removeTab(currentIndex());
- delete w;
+ initSources();
}
}
void BtSourceWidget::slotAdd() {
- qDebug("void BtSourceWidget::slotAdd() start");
- qDebug("open the old dialog, TODO: write new one");
- sword::InstallSource newSource = CSwordSetupInstallSourcesDialog::getSource();
- if ( !((QString)newSource.type.c_str()).isEmpty() ) { // we have a valid source to add
- instbackend::addSource(newSource);
- addSource(QString(newSource.caption.c_str()));
+
+ boost::scoped_ptr<CSwordSetupInstallSourcesDialog> dlg( new CSwordSetupInstallSourcesDialog() );
+ sword::InstallSource newSource(""); //empty, invalid Source
+
+ if (dlg->exec() == QDialog::Accepted) {
+ if (!dlg->wasRemoteListAdded()) {
+ newSource = dlg->getSource();
+ if ( !((QString)newSource.type.c_str()).isEmpty() ) { // we have a valid source to add
+ instbackend::addSource(newSource);
+ }
+ }
+ initSources();
}
}
void BtSourceWidget::slotRefresh() {
- qDebug("void BtSourceWidget::slotRefresh() start");
+ qDebug() << "void BtSourceWidget::slotRefresh() start";
// (re)build the module cache for the source
QString sourceName = currentSourceName();
@@ -117,18 +116,18 @@ void BtSourceWidget::slotRefresh() {
m_progressDialog->setWindowTitle(tr("Refreshing Source"));
m_progressDialog->setMinimumDuration(0);
- // TODO: get rid of the backend code, BtInstallMgr and progressdialog could handle this
+ /// \todo get rid of the backend code, BtInstallMgr and progressdialog could handle this
//write method BtInstallMgr::slotRefreshCanceled()
connect(m_progressDialog, SIGNAL(canceled()), SLOT(slotRefreshCanceled()));
// BACKEND CODE **********************************************************
// would this be possible: instbackend::refreshSource( arguments );
- qDebug("void BtSourceWidget::slotRefresh 1");
+ qDebug() << "void BtSourceWidget::slotRefresh 1";
BtInstallMgr iMgr;
m_currentInstallMgr = &iMgr; //for the progress dialog
sword::InstallSource is = instbackend::source(sourceName);
bool success = false;
- qDebug("void BtSourceWidget::slotRefresh 2");
+ qDebug() << "void BtSourceWidget::slotRefresh 2";
// connect this directly to the dialog setValue(int) if possible
connect(&iMgr, SIGNAL(percentCompleted(const int, const int)), SLOT(slotRefreshCompleted(const int, const int)));
@@ -139,11 +138,7 @@ void BtSourceWidget::slotRefresh() {
m_progressDialog->setLabelText(tr("Connecting..."));
m_progressDialog->setValue(0);
qApp->processEvents();
- //qApp->flush();
- //qApp->processEvents();
- //m_progressDialog->repaint();
- //qApp->processEvents();
- qDebug("void BtSourceWidget::slotRefresh 3");
+ qDebug() << "void BtSourceWidget::slotRefresh 3";
bool successful = iMgr.refreshRemoteSource( &is );
if (!successful ) { //make sure the sources were updated sucessfully
success = true;
@@ -164,14 +159,14 @@ void BtSourceWidget::slotRefresh() {
// rebuild the view tree and refresh the view
if (success) {
- qDebug("void BtSourceWidget::slotRefresh 4");
+ qDebug() << "void BtSourceWidget::slotRefresh 4";
area()->createModuleTree();
}
}
-//TODO: try to move this to BtInstallMgr
+/// \todo try to move this to BtInstallMgr
void BtSourceWidget::slotRefreshCanceled() {
- qDebug("BtSourceWidget::slotRefreshCanceled");
+ qDebug() << "BtSourceWidget::slotRefreshCanceled";
Q_ASSERT(m_currentInstallMgr);
if (m_currentInstallMgr) {
m_currentInstallMgr->terminate();
@@ -179,9 +174,9 @@ void BtSourceWidget::slotRefreshCanceled() {
qApp->processEvents();
}
-//TODO: try to move this to progress dialog
+/// \todo try to move this to progress dialog
void BtSourceWidget::slotRefreshCompleted(const int, const int current) {
- qDebug("BtSourceWidget::slotRefreshCompleted");
+ qDebug() << "BtSourceWidget::slotRefreshCompleted";
if (m_progressDialog) {
if (m_progressDialog->labelText() != tr("Refreshing...")) {
m_progressDialog->setLabelText(tr("Refreshing..."));
@@ -193,18 +188,32 @@ void BtSourceWidget::slotRefreshCompleted(const int, const int current) {
// init the tabbar, setup the module tree for the current source
void BtSourceWidget::initSources() {
- qDebug("void BtSourceWidget::initSources() start");
+ qDebug() << "void BtSourceWidget::initSources() start";
+
+ //first clear all sources
+ //int i = count();
+ for (int i = count()-1; i >= 0; i--) {
+ BtSourceArea* a = dynamic_cast<BtSourceArea*>(widget(i));
+ a->prepareRemove();
+ }
+ for (int i = count()-1; i >= 0; i--) {
+ qDebug() << "remove tab"<<tabText(i);
+ QWidget* w = widget(i);
+ removeTab(i);
+ delete w;
+ qDebug() << "deleted";
+ }
+ m_sourceNameList.clear();
// ***** Use the backend to get the list of sources *****
instbackend::initPassiveFtpMode();
QStringList sourceList = instbackend::sourceList();
-
+ qDebug() << "got the source list from backend:" << sourceList;
// Add a default entry, the Crosswire main repository
- // TODO: this is easy for the user, but should the edit dialog
- // open automatically?
if (!sourceList.count()) {
+ /// \todo Open a dialog which asks whether to get list from server and add sources
sword::InstallSource is("FTP"); //default return value
- is.caption = "Crosswire";
+ is.caption = "CrossWire Bible Society";
is.source = "ftp.crosswire.org";
is.directory = "/pub/sword/raw";
// passive ftp is not needed here, it's the default
@@ -214,7 +223,7 @@ void BtSourceWidget::initSources() {
sourceList = instbackend::sourceList();
//Q_ASSERT( sourceList.count() > 0 );
}
- qDebug("void BtSourceWidget::initSources 1");
+ qDebug() << "void BtSourceWidget::initSources 1";
// Add the sources to the widget
foreach (QString sourceName, sourceList) {
addSource(sourceName);
@@ -222,8 +231,8 @@ void BtSourceWidget::initSources() {
// connect this after the tabs have been created,
// otherwise the signal is caught too early.
QObject::connect(this, SIGNAL(currentChanged(int)), this, SLOT(slotTabSelected(int)));
- qDebug("void BtSourceWidget::initSources end");
- // TODO: select the current source from the config
+ qDebug() << "void BtSourceWidget::initSources end";
+ /// \todo select the current source from the config
// It's important to choose something because the tree is not initialized until now
setCurrentIndex(0);
slotTabSelected(0); // setting the index wasn't enough if there were only 1 tab
@@ -237,7 +246,7 @@ void BtSourceWidget::initSources() {
}
void BtSourceWidget::addSource(const QString& sourceName) {
- qDebug("void BtSourceWidget::addSource(const QString& sourceName) start");
+ qDebug() << "void BtSourceWidget::addSource(const QString& sourceName) start, with name" << sourceName;
// The source has already been added to the backend.
QString type;
@@ -254,10 +263,10 @@ void BtSourceWidget::addSource(const QString& sourceName) {
QFileInfo fi( is.directory.c_str() );
path = is.directory.c_str();
if (!(fi.isDir() )) {
- path = path + QString(" ") + tr("Not a directory!"); //TODO: change this
+ path = path + QString(" ") + tr("Not a directory!"); /// \todo change this
}
if (!fi.isReadable()) {
- path = path + QString(" ") + tr("Not readable!"); //TODO: change this
+ path = path + QString(" ") + tr("Not readable!"); /// \todo change this
}
}
@@ -265,7 +274,7 @@ void BtSourceWidget::addSource(const QString& sourceName) {
BtSourceArea* area = new BtSourceArea(sourceName);
int tabNumber = this->addTab(area, sourceName);
- // TODO: add "remote/local", server, path etc.
+ /// \todo add "remote/local", server, path etc.
QString toolTip(QString("<p style='white-space:pre'>") + sourceName + QString("<br/><b>") + type + QString("</b> ") + server + path + QString("</p>"));
tabBar()->setTabToolTip(tabNumber, toolTip);
@@ -273,13 +282,13 @@ void BtSourceWidget::addSource(const QString& sourceName) {
setCurrentIndex(tabNumber);
m_sourceNameList.append(sourceName);
initSourceConnections();
- qDebug("BtSourceWidget::addSource end");
+ qDebug() << "BtSourceWidget::addSource end";
}
//
void BtSourceWidget::slotModuleSelectionChanged(QString sourceName, int selectedCount) {
- //TODO: editing sources should update the map also
- qDebug("BtSourceWidget::slotModuleSelectionChanged start");
+ /// \todo editing sources should update the map also
+ qDebug() << "BtSourceWidget::slotModuleSelectionChanged start";
int overallCount = 0;
m_selectedModulesCountMap.insert(sourceName, selectedCount);
@@ -302,7 +311,7 @@ void BtSourceWidget::slotTabSelected(int /*index*/) {
}
void BtSourceWidget::slotInstall() {
- qDebug("void BtInstallPage::slotInstall start");
+ qDebug() << "void BtInstallPage::slotInstall start";
// check that the destination path is writable, do nothing if not and user doesn't want to continue
QDir dir = QDir(dynamic_cast<BtInstallPage*>(parent())->selectedInstallPath());
@@ -317,7 +326,7 @@ void BtSourceWidget::slotInstall() {
canWrite = false;
}
if (!canWrite) {
- const int result = QMessageBox::warning(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 = util::showWarning(this, tr("Warning"), tr("The destination directory is not writable or does not exist. Installation will fail unless this has first been fixed."), QMessageBox::Ignore | QMessageBox::Cancel, QMessageBox::Cancel);
if (result != QMessageBox::Ignore) {
return;
}
@@ -373,18 +382,18 @@ void BtSourceWidget::slotStopInstall(QTreeWidget* /*treeWidget*/) {
void BtSourceWidget::slotInstallAccepted(QList<CSwordModuleInfo*> /*modules*/, QTreeWidget* treeWidget) {
qDebug() << "BtSourceWidget::slotInstallAccepted";
- //TODO: first remove all modules which will be updated from the module list
+ /// \todo first remove all modules which will be updated from the module list
// but what modules? all with the same real name? (there may be _n modules...)
BtModuleManagerDialog* parentDialog = dynamic_cast<BtModuleManagerDialog*>(dynamic_cast<BtInstallPage*>(parent())->parentDialog());
BtInstallProgressDialog* dlg = new BtInstallProgressDialog(parentDialog, treeWidget, dynamic_cast<BtInstallPage*>(parent())->selectedInstallPath());
- if (!parentDialog) qDebug("error, wrong parent!");
+ if (!parentDialog) qDebug() << "error, wrong parent!";
m_page->setInstallEnabled(false);
// the progress dialog is now modal, it can be made modeless later.
dlg->exec();
- qDebug("BtSourceWidget::slotInstallAccepted end");
+ qDebug() << "BtSourceWidget::slotInstallAccepted end";
}
diff --git a/src/frontend/bookshelfmanager/installpage/btsourcewidget.h b/src/frontend/bookshelfmanager/installpage/btsourcewidget.h
index 46b7d0a..fbe8426 100644
--- a/src/frontend/bookshelfmanager/installpage/btsourcewidget.h
+++ b/src/frontend/bookshelfmanager/installpage/btsourcewidget.h
@@ -9,16 +9,16 @@
#ifndef BTSOURCEWIDGET_H
#define BTSOURCEWIDGET_H
-class CSwordModuleInfo;
-
#include <QTabWidget>
-#include <QString>
+
#include <QMap>
+#include <QString>
+
class BtInstallMgr;
class BtInstallPage;
class BtSourceArea;
-
+class CSwordModuleInfo;
class QProgressDialog;
class QTreeWidget;
@@ -46,13 +46,13 @@ class BtSourceWidget : public QTabWidget {
private:
void initSourceConnections();
- /** Add tabs/views for each source. */
- void initSources();
/** Add one source to tabs/stack. */
void addSource(const QString& sourceName);
private slots:
+ /** Add tabs/views for each source. */
+ void initSources();
void slotRefresh();
@@ -72,7 +72,8 @@ class BtSourceWidget : public QTabWidget {
void slotTabSelected(int index);
void slotInstallAccepted(QList<CSwordModuleInfo*> mi, QTreeWidget* treeWidget);
-
+ signals:
+ void sigInitSources();
private:
QStringList m_sourceNameList;
diff --git a/src/frontend/bookshelfmanager/instbackend.cpp b/src/frontend/bookshelfmanager/instbackend.cpp
index caf1e08..d671430 100644
--- a/src/frontend/bookshelfmanager/instbackend.cpp
+++ b/src/frontend/bookshelfmanager/instbackend.cpp
@@ -7,31 +7,26 @@
*
**********/
-#include "instbackend.h"
+#include "frontend/bookshelfmanager/instbackend.h"
-#include "frontend/bookshelfmanager/btinstallmgr.h"
-#include "backend/managers/cswordbackend.h"
-
-#include "util/cpointers.h"
-#include "util/directoryutil.h"
-
-//Qt includes
+#include <functional>
+#include <map>
+#include <QDebug>
+#include <QDir>
#include <QFile>
#include <QFileInfo>
-#include <QDir>
-#include <QMessageBox>
-
-#include <QDebug>
+#include <utility>
+#include "backend/managers/cswordbackend.h"
+#include "frontend/bookshelfmanager/btinstallmgr.h"
+#include "util/cpointers.h"
+#include "util/directory.h"
+#include "util/dialogutil.h"
-//Sword includes
+// Sword includes:
#include <filemgr.h>
#include <swconfig.h>
#include <swbuf.h>
-//Stl includes
-#include <functional>
-#include <map>
-#include <utility>
using namespace sword;
@@ -39,7 +34,7 @@ namespace instbackend {
/** Adds the source described by Source to the backend. */
bool addSource(sword::InstallSource& source) {
- qDebug("backend::addSource");
+ qDebug() << "backend::addSource";
SWConfig config(configFilename().toLatin1());
if (!strcmp(source.type, "FTP")) {
//make sure the path doesn't have a trailing slash, sword doesn't like it
@@ -58,7 +53,7 @@ bool addSource(sword::InstallSource& source) {
/** Returns the Source struct. */
sword::InstallSource source(QString name) {
- qDebug("backend::source");
+ qDebug() << "backend::source";
BtInstallMgr mgr;
InstallSourceMap::iterator source = mgr.sources.find(name.toLatin1().data());
if (source != mgr.sources.end()) {
@@ -93,7 +88,7 @@ sword::InstallSource source(QString name) {
/** Deletes the source. */
bool deleteSource(QString name) {
- qDebug("backend::deleteSource");
+ qDebug() << "backend::deleteSource";
sword::InstallSource is = source(name );
SWConfig config(configFilename().toLatin1());
@@ -105,28 +100,48 @@ bool deleteSource(QString name) {
: config["Sources"].equal_range("DIRSource");
ConfigEntMap::iterator it = range.first;
+ SWBuf sourceConfigEntry = is.getConfEnt();
+ bool notFound = true;
while (it != range.second) {
- if (it->second == is.getConfEnt()) {
- // qWarning("found the source!");
+ //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);
+ notFound = false;
break;
}
++it;
}
+ if (notFound) {
+ qDebug() << "source was not found, try without uid";
+ //try again without uid
+ QString sce(sourceConfigEntry.c_str());
+ QStringList l = sce.split('|');
+ l.removeLast();
+ sce = l.join("|").append("|");
+ it = range.first;
+ while (it != range.second) {
+ qDebug() << it->second;
+ if (it->second == sce) {
+ config["Sources"].erase(it);
+ break;
+ }
+ ++it;
+ }
+ }
config.Save();
- return true; //TODO: dummy
+ return true; /// \todo dummy
}
/** Refreshes the remote source module list. */
bool refreshSource(QString /*name*/) {
// not possible until manager and progressdialog work together
- return true; //TODO: dummy
+ return true; /// \todo dummy
}
/** Returns the moduleinfo list for the source. Delete the pointer after using. IS THIS POSSIBLE?*/
QList<CSwordModuleInfo*> moduleList(QString /*name*/) {
- QList<CSwordModuleInfo*> list; //TODO: dummy
+ QList<CSwordModuleInfo*> list; /// \todo dummy
return list;
}
@@ -135,10 +150,8 @@ bool isRemote(const sword::InstallSource& source) {
}
const QString configPath() {
- const char *envhomedir = getenv("HOME");
- QString confPath = QString(envhomedir ? envhomedir : ".");
- confPath.append("/.sword/InstallMgr");
-
+ QString confPath = util::directory::getUserHomeSwordDir().absolutePath();
+ confPath.append("/InstallMgr");
return confPath;
}
@@ -147,16 +160,18 @@ const QString configFilename() {
}
QStringList targetList() {
- qDebug("backend::targetList");
+ qDebug() << "backend::targetList";
QStringList names = CPointers::backend()->swordDirList();
return names;
}
bool setTargetList( const QStringList& targets ) {
- qDebug("backend::setTargetList");
+ namespace DU = util::directory;
+
+ qDebug() << "backend::setTargetList";
//saves a new Sword config using the provided target list
//QString filename = KGlobal::dirs()->saveLocation("data", "bibletime/") + "sword.conf"; //default is to assume the real location isn't writable
- //QString filename = util::filesystem::DirectoryUtil::getUserBaseDir().canonicalPath().append("/.sword/sword.conf");
+ //QString filename = util::DirectoryUtil::getUserBaseDir().canonicalPath().append("/.sword/sword.conf");
//bool directAccess = false;
QString filename = swordConfigFilename();
QFileInfo i(filename);
@@ -177,15 +192,30 @@ bool setTargetList( const QStringList& targets ) {
else {
// There is no way to save to the file
qWarning() << "The Sword config file is not writable!";
- QMessageBox::warning(0, QObject::tr("Can't write file"), QObject::tr("The Sword config file can't be written!"));
+ util::showWarning(0, QObject::tr("Can't write file"), QObject::tr("The Sword config file can't be written!"));
return false;
}
+
+ filename = util::directory::convertDirSeparators(filename);
SWConfig conf(filename.toLocal8Bit());
conf.Sections.clear();
+
+#ifdef Q_WS_WIN
+ // On Windows, add the sword directory to the config file.
+ QString swordPath = DU::convertDirSeparators( DU::getApplicationSwordDir().absolutePath());
+ conf["Install"].insert(
+ std::make_pair( SWBuf("LocalePath"), swordPath.toLocal8Bit().data() )
+ );
+#endif
+
bool setDataPath = false;
for (QStringList::const_iterator it = targets.begin(); it != targets.end(); ++it) {
- QString t = *it;
- if (t.contains( util::filesystem::DirectoryUtil::getUserHomeDir().canonicalPath().append("/.sword") )) {
+ QString t = DU::convertDirSeparators(*it);
+#ifdef Q_WS_WIN
+ if (t.contains(DU::convertDirSeparators(DU::getUserHomeDir().canonicalPath().append("\\Sword")))) {
+#else
+ if (t.contains(DU::getUserHomeDir().canonicalPath().append("/.sword"))) {
+#endif
//we don't want $HOME/.sword in the config
continue;
}
@@ -202,7 +232,7 @@ bool setTargetList( const QStringList& targets ) {
}
QStringList sourceList() {
- qDebug("backend::sourceList");
+ qDebug() << "backend::sourceList";
BtInstallMgr mgr;
Q_ASSERT(mgr.installConf);
@@ -233,23 +263,37 @@ QStringList sourceList() {
void initPassiveFtpMode() {
- qDebug("backend::initPassiveFtpMode");
+ qDebug() << "backend::initPassiveFtpMode";
SWConfig config(configFilename().toLatin1());
config["General"]["PassiveFTP"] = "true";
config.Save();
}
const QString swordConfigFilename() {
- qDebug("backend::swordConfigFilename");
- qDebug() << util::filesystem::DirectoryUtil::getUserHomeDir().absolutePath().append("/.sword/sword.conf");
- return util::filesystem::DirectoryUtil::getUserHomeDir().absolutePath().append("/.sword/sword.conf");
+ namespace DU = util::directory;
+
+ qDebug() << "backend::swordConfigFilename";
+#ifdef Q_WS_WIN
+ qDebug() << DU::getUserHomeDir().absolutePath().append("/Sword/sword.conf");
+ return DU::getUserHomeDir().absolutePath().append("/Sword/sword.conf");
+// return DU::getApplicationDir().absolutePath().append("/sword.conf");
+#else
+ qDebug() << DU::getUserHomeDir().absolutePath().append("/.sword/sword.conf");
+ return DU::getUserHomeDir().absolutePath().append("/.sword/sword.conf");
+#endif
}
const QDir swordDir() {
- return QDir(util::filesystem::DirectoryUtil::getUserHomeDir().absolutePath().append("/.sword/"));
+ namespace DU = util::directory;
+
+#ifdef Q_WS_WIN
+ return QDir(DU::getUserHomeDir().absolutePath().append("/Sword/"));
+#else
+ return QDir(DU::getUserHomeDir().absolutePath().append("/.sword/"));
+#endif
}
CSwordBackend* backend( const sword::InstallSource& is) {
- qDebug("backend::backend");
+ qDebug() << "backend::backend";
CSwordBackend* ret = 0;
if (isRemote(is)) {
ret = new CSwordBackend( QString(is.localShadow.c_str()), false );
diff --git a/src/frontend/bookshelfmanager/instbackend.h b/src/frontend/bookshelfmanager/instbackend.h
index 4f60ed9..3a98e5a 100644
--- a/src/frontend/bookshelfmanager/instbackend.h
+++ b/src/frontend/bookshelfmanager/instbackend.h
@@ -10,16 +10,16 @@
#ifndef INSTBACKEND_H
#define INSTBACKEND_H
-#include "backend/managers/cswordbackend.h"
-
-class CSwordModuleInfo;
-
-#include <QString>
#include <QDir>
+#include <QString>
+#include "backend/managers/cswordbackend.h"
+// Sword includes:
#include <installmgr.h>
+class CSwordModuleInfo;
+
namespace instbackend {
/** Adds the source to the backend. */
@@ -55,7 +55,7 @@ const QString configPath();
const QString configFilename();
/** Sets the passive mode for as default.
-* TODO: see if we can en/disable this per source.
+* \todo see if we can en/disable this per source.
*/
void initPassiveFtpMode();
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
index cd8f687..1cc6398 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
+++ b/src/frontend/bookshelfmanager/removepage/btremovepage.cpp
@@ -7,38 +7,35 @@
*
**********/
+#include "frontend/bookshelfmanager/removepage/btremovepage.h"
-#include "btremovepage.h"
-
-
+#include <QDebug>
+#include <QGridLayout>
+#include <QLabel>
+#include <QList>
+#include <QMultiMap>
+#include <QPushButton>
+#include <QString>
+#include <QTreeWidget>
+#include <QTreeWidgetItem>
#include "backend/btmoduletreeitem.h"
#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
-
-#include "util/ctoolclass.h"
+#include "util/directory.h"
+#include "util/dialogutil.h"
#include "util/cpointers.h"
-#include "util/directoryutil.h"
#include "util/cresmgr.h"
+#include "util/tool.h"
+// Sword includes:
#include <swmgr.h>
#include <installmgr.h>
-#include <QString>
-#include <QGridLayout>
-#include <QLabel>
-#include <QPushButton>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
-#include <QMessageBox>
-#include <QList>
-#include <QMultiMap>
-
-#include <QDebug>
-
-
BtRemovePage::BtRemovePage()
: BtConfigPage() {
+ namespace DU = util::directory;
+
QGridLayout* layout = new QGridLayout(this);
layout->setMargin(5);
@@ -48,13 +45,13 @@ BtRemovePage::BtRemovePage()
m_view = new QTreeWidget(this);
m_view->setHeaderLabels(QStringList() << tr("Work") << tr("Install path"));
- m_view->setColumnWidth(0, CToolClass::mWidth(m_view, 20));
+ m_view->setColumnWidth(0, util::tool::mWidth(m_view, 20));
layout->addWidget( m_view, 2, 0, 1, 2);
m_removeButton = new QPushButton(tr("Remove..."), this);
m_removeButton->setToolTip(tr("Remove the selected works"));
- m_removeButton->setIcon( util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::removepage::remove_icon) );
+ m_removeButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::removepage::remove_icon));
m_removeButton->setEnabled(false);
layout->addWidget(m_removeButton, 3, 1, Qt::AlignRight);
@@ -89,7 +86,7 @@ void BtRemovePage::populateModuleList() {
// receive signal when user checks modules
connect(m_view, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(slotSelectionChanged(QTreeWidgetItem*, int)) );
- qDebug("BtSourceArea::createModuleTree end");
+ qDebug() << "BtSourceArea::createModuleTree end";
}
void BtRemovePage::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem) {
@@ -111,11 +108,11 @@ void BtRemovePage::addToTree(BTModuleTreeItem* item, QTreeWidgetItem* widgetItem
widgetItem->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
widgetItem->setCheckState(0, Qt::Unchecked);
- //TODO: add the relevant information in to item or tooltip
+ /// \todo add the relevant information in to item or tooltip
// (install path, is still available from some source)
QString descr(mInfo->config(CSwordModuleInfo::AbsoluteDataPath));
- QString toolTipText = CToolClass::moduleToolTip(mInfo);
+ QString toolTipText = util::tool::moduleToolTip(mInfo);
widgetItem->setText(1, descr);
widgetItem->setToolTip(0, toolTipText);
widgetItem->setToolTip(1, descr);
@@ -139,7 +136,7 @@ void BtRemovePage::slotRemoveModules() {
.append("\n\n")
.append(tr("Do you really want to remove them from your system?"));
- if ((QMessageBox::question(this, tr("Remove Works?"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)) { //Yes was pressed.
+ if ((util::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 = CPointers::backend()->takeModulesFromList(moduleNames);
@@ -181,12 +178,12 @@ void BtRemovePage::slotRemoveModules() {
void BtRemovePage::slotSelectionChanged(QTreeWidgetItem* item, int column) {
- //qDebug("BtRemovePage::slotSelectionChanged");
+ //qDebug() << "BtRemovePage::slotSelectionChanged";
// modify the internal list of checked modules
// if() leaves groups away
if (!item->childCount() && column == 0) {
CSwordModuleInfo* mInfo = 0;
- //qDebug("BtRemovePage::slotSelectionChanged");
+ //qDebug() << "BtRemovePage::slotSelectionChanged";
foreach (CSwordModuleInfo* module, CPointers::backend()->moduleList()) {
if (module->name() == item->text(0) && module->config(CSwordModuleInfo::AbsoluteDataPath) == item->text(1)) {
mInfo = module;
@@ -213,7 +210,7 @@ void BtRemovePage::slotSelectionChanged(QTreeWidgetItem* item, int column) {
}
void BtRemovePage::slotItemDoubleClicked(QTreeWidgetItem* /*item*/, int /*column*/) {
- // TODO: Open the About dialog.
+ // \todo Open the About dialog.
}
void BtRemovePage::slotSwordSetupChanged() {
diff --git a/src/frontend/bookshelfmanager/removepage/btremovepage.h b/src/frontend/bookshelfmanager/removepage/btremovepage.h
index 782fcc0..920b1ee 100644
--- a/src/frontend/bookshelfmanager/removepage/btremovepage.h
+++ b/src/frontend/bookshelfmanager/removepage/btremovepage.h
@@ -7,23 +7,20 @@
*
**********/
-
#ifndef BTREMOVEPAGE_H
#define BTREMOVEPAGE_H
#include "frontend/bookshelfmanager/btconfigdialog.h"
-#include "backend/btmoduletreeitem.h"
-#include <QString>
#include <QMultiMap>
+#include <QString>
+#include "backend/btmoduletreeitem.h"
-//class BTModuleTreeItem;
class QTreeWidget;
class QTreeWidgetItem;
class QPushButton;
-
class BtRemovePage : public BtConfigPage {
Q_OBJECT
diff --git a/src/frontend/btaboutmoduledialog.cpp b/src/frontend/btaboutmoduledialog.cpp
index e67d42b..9241b71 100644
--- a/src/frontend/btaboutmoduledialog.cpp
+++ b/src/frontend/btaboutmoduledialog.cpp
@@ -2,20 +2,20 @@
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
-* Copyright 1999-2008 by the BibleTime developers.
+* Copyright 1999-2009 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "btaboutmoduledialog.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "util/dialogutil.h"
-
-#include <QWidget>
#include <QDialog>
+#include <QDialogButtonBox>
#include <QTextEdit>
#include <QVBoxLayout>
-#include <QDialogButtonBox>
+#include <QWidget>
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "frontend/btaboutmoduledialog.h"
+#include "util/dialogutil.h"
+
BTAboutModuleDialog::BTAboutModuleDialog(QWidget* parent, CSwordModuleInfo* info)
: QDialog(parent) {
diff --git a/src/frontend/btaboutmoduledialog.h b/src/frontend/btaboutmoduledialog.h
index c5ee7ca..65c0696 100644
--- a/src/frontend/btaboutmoduledialog.h
+++ b/src/frontend/btaboutmoduledialog.h
@@ -12,13 +12,14 @@
#include <QDialog>
+
class CSwordModuleInfo;
class QWidget;
/**
- Dialog to show the information about a module.
+ Dialog to show the information about a module.
- @author The BibleTime team <info@bibletime.info>
+ @author The BibleTime team <info@bibletime.info>
*/
class BTAboutModuleDialog : public QDialog {
Q_OBJECT
diff --git a/src/frontend/btbookshelfdockwidget.cpp b/src/frontend/btbookshelfdockwidget.cpp
index 9c6877d..bedebcb 100644
--- a/src/frontend/btbookshelfdockwidget.cpp
+++ b/src/frontend/btbookshelfdockwidget.cpp
@@ -26,7 +26,7 @@
#include <QVBoxLayout>
#include "backend/bookshelfmodel/btbookshelfmodel.h"
#include "backend/bookshelfmodel/btbookshelftreemodel.h"
-#include "backend/bookshelfmodel/btcheckstatefilterproxymodel.h"
+#include "backend/bookshelfmodel/btmodulehiddenfilterproxymodel.h"
#include "backend/bookshelfmodel/btmodulenamefilterproxymodel.h"
#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
@@ -35,7 +35,8 @@
#include "frontend/mainindex/btbookshelfview.h"
#include "util/cpointers.h"
#include "util/cresmgr.h"
-#include "util/directoryutil.h"
+#include "util/directory.h"
+
BtBookshelfDockWidget::BtBookshelfDockWidget(QWidget *parent, Qt::WindowFlags f)
: QDockWidget(parent, f) {
@@ -49,16 +50,16 @@ BtBookshelfDockWidget::BtBookshelfDockWidget(QWidget *parent, Qt::WindowFlags f)
QVariant v(settings->value("grouping"));
if (v.canConvert<BtBookshelfTreeModel::Grouping>()) {
m_bookshelfTreeModel = new BtBookshelfTreeModel(v.value<BtBookshelfTreeModel::Grouping>(), this);
- } else {
+ }
+ else {
m_bookshelfTreeModel = new BtBookshelfTreeModel(this);
}
}
settings->endGroup();
- m_bookshelfTreeModel->setDefaultChecked(true);
+ m_bookshelfTreeModel->setDefaultChecked(BtBookshelfTreeModel::MODULE_HIDDEN);
m_bookshelfTreeModel->setSourceModel(CPointers::backend()->model());
- m_filterProxyModel = new BtCheckStateFilterProxyModel(this);
- m_filterProxyModel->setFilterRole(BtBookshelfTreeModel::CheckStateRole);
+ m_filterProxyModel = new BtModuleHiddenFilterProxyModel(this);
m_filterProxyModel->setSourceModel(m_bookshelfTreeModel);
m_nameFilterProxyModel = new BtModuleNameFilterProxyModel(this);
m_nameFilterProxyModel->setSourceModel(m_filterProxyModel);
@@ -71,6 +72,8 @@ BtBookshelfDockWidget::BtBookshelfDockWidget(QWidget *parent, Qt::WindowFlags f)
QVBoxLayout *layout(new QVBoxLayout);
layout->setContentsMargins(0, 0, 0, 0);
QHBoxLayout *toolBar(new QHBoxLayout);
+ // Add a small margin between the edge of the window and the label (looks better)
+ toolBar->setContentsMargins(3,0,0,0);
m_nameFilterLabel = new QLabel(this);
toolBar->addWidget(m_nameFilterLabel);
@@ -107,6 +110,8 @@ BtBookshelfDockWidget::BtBookshelfDockWidget(QWidget *parent, Qt::WindowFlags f)
this, SLOT(showItemContextMenu(CSwordModuleInfo*, QPoint)));
connect(m_view, SIGNAL(moduleActivated(CSwordModuleInfo*)),
this, SIGNAL(moduleOpenTriggered(CSwordModuleInfo*)));
+ connect(m_bookshelfTreeModel, SIGNAL(moduleChecked(CSwordModuleInfo*,bool)),
+ this, SLOT(moduleChecked(CSwordModuleInfo*,bool)));
retranslateInterface();
}
@@ -130,7 +135,7 @@ bool BtBookshelfDockWidget::eventFilter(QObject *object, QEvent *event) {
}
void BtBookshelfDockWidget::initMenus() {
- typedef util::filesystem::DirectoryUtil DU;
+ namespace DU = util::directory;
namespace RM = CResMgr::mainIndex;
m_contextMenu = new QMenu(this);
@@ -235,6 +240,10 @@ void BtBookshelfDockWidget::retranslateInterface() {
m_itemAboutAction->setText(tr("&About..."));
}
+void BtBookshelfDockWidget::moduleChecked(CSwordModuleInfo *module, bool c) {
+ module->setHidden(!c);
+}
+
void BtBookshelfDockWidget::showContextMenu(QPoint pos) {
m_contextMenu->popup(pos);
}
diff --git a/src/frontend/btbookshelfdockwidget.h b/src/frontend/btbookshelfdockwidget.h
index 988bb3c..165ebae 100644
--- a/src/frontend/btbookshelfdockwidget.h
+++ b/src/frontend/btbookshelfdockwidget.h
@@ -15,10 +15,11 @@
#include <QDockWidget>
+
class CSwordModuleInfo;
class BtBookshelfView;
class BtBookshelfTreeModel;
-class BtCheckStateFilterProxyModel;
+class BtModuleHiddenFilterProxyModel;
class BtModuleNameFilterProxyModel;
class QAction;
class QActionGroup;
@@ -47,6 +48,7 @@ class BtBookshelfDockWidget: public QDockWidget {
void retranslateInterface();
protected slots:
+ void moduleChecked(CSwordModuleInfo *module, bool checked);
void showContextMenu(QPoint pos);
void groupingActionTriggered(QAction *action);
void showHideEnabled(bool enable);
@@ -55,9 +57,9 @@ class BtBookshelfDockWidget: public QDockWidget {
protected:
// Models:
- BtBookshelfTreeModel *m_bookshelfTreeModel;
- BtCheckStateFilterProxyModel *m_filterProxyModel;
- BtModuleNameFilterProxyModel *m_nameFilterProxyModel;
+ BtBookshelfTreeModel *m_bookshelfTreeModel;
+ BtModuleHiddenFilterProxyModel *m_filterProxyModel;
+ BtModuleNameFilterProxyModel *m_nameFilterProxyModel;
// Widgets:
QWidget *m_widget;
diff --git a/src/frontend/cdragdrop.cpp b/src/frontend/cdragdrop.cpp
index c217d51..d595162 100644
--- a/src/frontend/cdragdrop.cpp
+++ b/src/frontend/cdragdrop.cpp
@@ -7,13 +7,12 @@
*
**********/
+#include "frontend/cdragdrop.h"
-#include "cdragdrop.h"
-
-#include <QString>
#include <QByteArray>
-#include <QMimeData>
#include <QList>
+#include <QMimeData>
+#include <QString>
BTMimeData::BTMimeData() {}
diff --git a/src/frontend/cdragdrop.h b/src/frontend/cdragdrop.h
index 0380808..3c4481f 100644
--- a/src/frontend/cdragdrop.h
+++ b/src/frontend/cdragdrop.h
@@ -7,8 +7,6 @@
*
**********/
-
-
#ifndef CDRAGDROP_H
#define CDRAGDROP_H
@@ -26,7 +24,7 @@ class BookmarkItem {
/** Returns the key */
const QString& key() const {
return m_key;
- } ;
+ }
/** Returns the module name */
const QString& module() const {
return m_moduleName;
diff --git a/src/frontend/cdragdropmgr.cpp b/src/frontend/cdragdropmgr.cpp
deleted file mode 100644
index d2e2d00..0000000
--- a/src/frontend/cdragdropmgr.cpp
+++ /dev/null
@@ -1,262 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-
-
-#include "cdragdropmgr.h"
-
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/managers/cswordbackend.h"
-#include "backend/keys/cswordversekey.h"
-#include "util/cpointers.h"
-
-//Sword includes
-#include "versekey.h"
-
-//Qt includes
-#include <qevent.h>
-#include <qdom.h>
-//Added by qt3to4:
-#include <Q3CString>
-
-
-//This is the old old d'n'd system. Use cdragdrop instead.
-
-
-CDragDropMgr::BTDrag::BTDrag( const QString& xml, QWidget* dragSource, const char* name)
- : Q3TextDrag(xml, dragSource, name) {}
-;
-
-//static function to see whether we can decode tje given mime type
-bool CDragDropMgr::BTDrag::canDecode( const QMimeSource * mime ) {
- if ( mime->provides("BibleTime/DND") ) { //we can decode this type!
- return true;
- }
- return false; //not yet implemented
-};
-
-bool CDragDropMgr::BTDrag::provides( const char* type ) const {
- return (type == "BibleTime/DND"); //return only true if the type is BibleTime/DND
-};
-
-const char* CDragDropMgr::BTDrag::format( int i ) const {
- if ( i == 0) { //we support only one format!
- return "BibleTime/DND";
- };
- return 0;
-};
-
-bool CDragDropMgr::BTDrag::decode(const QMimeSource* e, QString& str) {
- if (canDecode(e)) {
- str = QString( e->encodedData( "BibleTime/DND" ) );
- return true;
- }
- return false;
-};
-
-bool CDragDropMgr::BTDrag::decode(const QMimeSource* e, QString& str, Q3CString& /*subtype*/) {
- return decode(e, str);
-};
-
-QByteArray CDragDropMgr::BTDrag::encodedData( const char* /*type*/ ) const {
- return Q3TextDrag::encodedData("text/plain"); //hack because QTextDrag only accepts text/plainand not our BibleTime/DND type
-};
-
-///////////////////////////// new class //////////////////////
-
-CDragDropMgr::Item::Item( const QString& text )
- : m_type(Text),
- m_bookmarkModuleName(QString::null),
- m_bookmarkKey(QString::null),
- m_bookmarkDescription(QString::null),
- m_text(text) {}
-
-CDragDropMgr::Item::Item( const QString& moduleName, const QString& key, const QString& description )
- : m_type(Bookmark),
- m_bookmarkModuleName(moduleName),
- m_bookmarkKey(key),
- m_bookmarkDescription(description),
- m_text(QString::null) {
- //we have to make sure the key is saved in it's english representation, so we convert it
- if (CSwordModuleInfo* mod = CPointers::backend()->findModuleByName( moduleName )) {
- if (mod->type() == CSwordModuleInfo::Bible || mod->type() == CSwordModuleInfo::Commentary) {
- CSwordVerseKey vk(0);
- vk.key( key );
- vk.setLocale("en");
-
- m_bookmarkKey = vk.key();
- // qWarning("english key of %s is %s", key.latin1(), m_bookmarkKey.latin1());
- }
- }
-}
-
-CDragDropMgr::Item::~Item() {}
-
-const CDragDropMgr::Item::Type& CDragDropMgr::Item::type() const {
- //returns the type of drag & drop action this item represents
- return m_type;
-}
-
-/** Returns the text which is used by this DragDrop Item, only valid if type() == Text */
-const QString& CDragDropMgr::Item::text() const {
- // Q_ASSERT(!m_text.isEmpty());
- return m_text;
-}
-
-/** Returns the key, ony valid if type() == Bookmark */
-const QString& CDragDropMgr::Item::bookmarkKey() const {
- // Q_ASSERT(!m_bookmarkKey.isEmpty());
- return m_bookmarkKey;
-}
-
-/** Returns the bookmark module, ony valid if type() == Bookmark */
-const QString& CDragDropMgr::Item::bookmarkModule() const {
- // Q_ASSERT(!m_bookmarkModuleName.isEmpty());
- return m_bookmarkModuleName;
-}
-
-/** Returns the bookmark description, ony valid if type() == Bookmark */
-const QString& CDragDropMgr::Item::bookmarkDescription() const {
- // Q_ASSERT(!m_bookmarkDescription.isEmpty());
- return m_bookmarkDescription;
-}
-
-////////////////////////////////// NEW CLASS //////////////////////////
-
-CDragDropMgr::CDragDropMgr() {}
-
-CDragDropMgr::~CDragDropMgr() {}
-
-const bool CDragDropMgr::canDecode( const QMimeSource* const mime ) {
- if (CDragDropMgr::BTDrag::canDecode(mime)) {
- return true;
- }
- else if ( Q3TextDrag::canDecode(mime) ) {
- qWarning("QTextDrag can decode this mime!");
- return true;
- };
- return false;
-};
-
-Q3DragObject* const CDragDropMgr::dragObject( CDragDropMgr::ItemList& items, QWidget* dragSource ) {
- if ( items.count() ) {
- //process the items and set the data to the dragobject we return later
- QDomDocument doc("DOC");
- doc.appendChild( doc.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) );
- QDomElement content = doc.createElement("BibleTimeDND");
- content.setAttribute("syntaxVersion", "1.0");
- doc.appendChild(content);
-
- CDragDropMgr::ItemList::iterator it;
- for ( it = items.begin(); it != items.end(); ++it ) {
- Item item = (*it);
- if (item.type() == Item::Bookmark) { //a bookmark was dragged
- //append the XML stuff for a bookmark
- QDomElement bookmark = doc.createElement("BOOKMARK");
- bookmark.setAttribute("key", item.bookmarkKey());
- bookmark.setAttribute("description", item.bookmarkDescription());
- bookmark.setAttribute("moduleName", item.bookmarkModule());
-
- content.appendChild(bookmark);
- }
- else if (item.type() == Item::Text) { //plain text was dragged
- //append the XML stuff for plain text
- QDomElement plainText = doc.createElement("TEXT");
- plainText.setAttribute("text", item.text());
-
- content.appendChild(plainText);
- }
- }
-
- BTDrag* dragObject = new BTDrag( doc.toString(), dragSource );
- // qWarning("DND data created: %s", (const char*)doc.toString().utf8());
- return dragObject;
- };
- return 0;
-};
-
-CDragDropMgr::ItemList CDragDropMgr::decode( const QMimeSource* const src) {
- //if the drag was started by another widget which doesn't use CDragDropMgr (a drag created by QTextDrag)
- if (canDecode(src) && Q3TextDrag::canDecode(src)) { //if we can decode but it's a QTextDrag and not a BTDrag object
- QString text;
- Q3TextDrag::decode(src, text);
- // qWarning(text.latin1());
-
- CDragDropMgr::ItemList dndItems;
- dndItems.append( Item(text) );
- return dndItems;
- }
- else if (!canDecode(src)) { //if we can't decode it
- return CDragDropMgr::ItemList();
- };
-
- QString xmlData;
- BTDrag::decode(src, xmlData);
-
- if (xmlData.isEmpty()) { //something went wrong!
- // qWarning("CDragDropMgr::decode: empty xml data!");
- return CDragDropMgr::ItemList();
- }
- // else {
- // qWarning("Drag&Drop data is: %s", xmlData.latin1());
- // }
-
- //we can handle the dropEvent and have xml data to work on!
- ItemList dndItems;
-
- QDomDocument doc;
- doc.setContent( xmlData );
-
- QDomElement document = doc.documentElement();
- if ( document.tagName() != "BibleTimeDND" ) { //BibleTime was used in syntax version 1.0
- qWarning("DragDropMgr::decode: Missing BibleTimeDND doc");
- return CDragDropMgr::ItemList();
- }
- // see if there's a section with the name MAINWINDOW
- QDomElement elem = document.firstChild().toElement();
- while (!elem.isNull()) {
- if (elem.tagName() == "BOOKMARK") { //we found a bookmark!
- // qWarning("found a bookmark!");
- const QString key = elem.hasAttribute("key") ? elem.attribute("key") : QString::null;
- const QString moduleName = elem.hasAttribute("moduleName") ? elem.attribute("moduleName") : QString::null;
- const QString description = elem.hasAttribute("description") ? elem.attribute("description") : QString::null;
-
- dndItems.append( CDragDropMgr::Item(moduleName, key, description) );
- }
- else if (elem.tagName() == "TEXT") { //we found a plain text passage!
- const QString text = elem.hasAttribute("text") ? elem.attribute("text") : QString::null;
- dndItems.append( CDragDropMgr::Item(text) );
- };
- elem = elem.nextSibling().toElement();
- };
-
- return dndItems;
-};
-
-/** Returns which type the given drop event has, if it's a mixed one (both bookmarks and plain text), which shouldn't happen, it return Item::Unknown. */
-CDragDropMgr::Item::Type CDragDropMgr::dndType( const QMimeSource* e ) {
- ItemList dndItems = decode(e);
- if (dndItems.isEmpty()) {//wrong dropEvent or something strange
- return Item::Unknown;
- };
-
- //check whether all items have the ssame type, if they do return the type
- //as soon as two items have different types return Item::Unknown
- ItemList::Iterator it;
- Item::Type type = Item::Unknown;
- for ( it = dndItems.begin(); it != dndItems.end(); ++it ) {
- if ( type == Item::Unknown) { //if Unknown is set this is the first loop, don't return Unknown
- type = (*it).type();
- }
- else if (type != (*it).type() ) {//items have different type, return Item::Unknown
- return Item::Unknown;
- };
- };
- return type;
-}
diff --git a/src/frontend/cdragdropmgr.h b/src/frontend/cdragdropmgr.h
deleted file mode 100644
index c57514d..0000000
--- a/src/frontend/cdragdropmgr.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-
-
-#ifndef CDRAGDROPMGR_H
-#define CDRAGDROPMGR_H
-
-//Qt includes
-#include <QString>
-#include <q3cstring.h>
-#include <q3dragobject.h>
-#include <q3valuelist.h>
-//Added by qt3to4:
-#include <QDropEvent>
-
-//forward declarations
-class QDropEvent;
-class QWidget;
-
-/** This class is the drag'n' drop manager for BibleTime.
- *
- * This d'n'd system is replaced with the new classes in cdragdrop.h/cpp. (cdragdropmgr will be deleted later.)
- *
- * The dnd is managed by XML code, which defines the type of the drag/drop, the items and the action (moe, copy etc.).
- * It's possible to create the XML code by passing a list of keys etc.
- *
- * Functions:
- * - dnd_type(), returns either CDragDropMgr::Action_Drag or CDragDropMgr::Action_Drop
- * - dnd_action(), returns either CDragDropMgr::Move or CDragDropMgr::Copy
- * - dnd_acceptDrop(), returns true or false. True if the drop could be handled by the CDragDropMgr class, otherwise false
- *
- *
- * The functions which create the XML stuff can't be reimplemented, too. Otherwise we could not guarantee for good XML code
- * which works everywhere.
- *
- * @author The BibleTime team
- */
-class CDragDropMgr {
- public:
- //The class which represents one single drag&drop entry (e.g. a bookmark or a portion of text)
- class Item {
- public:
- /**
- * The possible types of Drag&Drop actions.
- */
- enum Type {
- Bookmark = 0, /* A bookmark: Has a key, a module and a description*/
- Text, /* Simple text, e.g. can be dropped on a module to start a search in this module using the dropped text */
- Unknown /* For situatiosn like CDragDropMgr::dndType */
- };
- /**
- * This function returns the type of drag this item has
- */
- const CDragDropMgr::Item::Type& type() const;
- /**
- * Returns the key, ony valid if type() == Bookmark
- */
- const QString& bookmarkKey() const;
- /**
- * Returns the module name, ony valid if type() == Bookmark
- */
- const QString& bookmarkModule() const;
- /**
- * Returns the bookmark description, ony valid if type() == Bookmark
- */
- const QString& bookmarkDescription() const;
- /**
- * Returns the text which is used by this DragDrop Item, only valid if type() == Text
- */
- const QString& text() const;
-
- // protected:
- friend class CDragDropMgr;
- /*
- * We use protected constructor and destructor because creation of objects
- * of this class sould only be possible for CDragDropMgr
- */
-
- /** Constructor for a text item
- * This constructor automatically sets the type member to Text
- * This is also the default constructor
- */
- Item(const QString& text = QString::null );
- /** Constructor for a Bookmark item
- * This constructor automatically sets the type member to Bookmark
- */
- Item(const QString& moduleName, const QString& key, const QString& description);
- virtual ~Item();
-
- private:
- Type m_type; //the member to save the type of the action
- QString m_bookmarkModuleName; //the modules which is used by this item, only valid for type() == Bookmark
- QString m_bookmarkKey; //the key of a bookmark, only valid if type() == Bookmark
- QString m_bookmarkDescription; //the description of a bookmark, only valid if type() == Bookmark
- QString m_text; //the text of this item, only valid if type() == Text
- }
- ; //end of class CDragDropMgr::Item
-
- //the item list we're using
- typedef Q3ValueList<Item> ItemList;
-
- /** Return whether the drop should be accepted
- * This functions tests whether the drop should be accepted or not. It returns true if the drop object
- * is supported by the CDragDropMgr and if it cotains valid data. Oterwise this function returns false.
- */
- static const bool canDecode( const QMimeSource* const mime );
- /**
- * This function returns the drag object with the data which represents the items given as parameter
- * If the list is invalid or empty we return NULL.
- */
- static Q3DragObject* const dragObject( CDragDropMgr::ItemList& items, QWidget* dragSource );
-
- /**
- * Decodes the XML stuff we passed to the dragObject at creation time.
- * Returns a list of CDragDropMgr::Item objects.
- * If it's a wrong dropEvent we return an empty ist
- */
- static CDragDropMgr::ItemList decode( const QMimeSource* const src );
- /**
- * Returns which type the given drop event has, if it's a mixed one (both bookmarks and plain text),
- * which shouldn't happen, it return Item::Unknown.
- * It also returns Unknown if the drop event is not supported.
- */
- static CDragDropMgr::Item::Type dndType( const QMimeSource* e );
-
- protected:
- //The class which represents our XML drag object stuff
- class BTDrag : public Q3TextDrag {
- public:
- BTDrag( const QString& xml, QWidget* dragSource = 0, const char* name = 0);
- //reimplemented static publoc function to provide functionality for BibleTime XML drags
- static bool canDecode( const QMimeSource * e );
- virtual bool provides( const char* type ) const;
- virtual const char* format( int i = 0 ) const;
-
- virtual QByteArray encodedData( const char* type ) const;
-
- protected:
- friend class CDragDropMgr;
- //made protected because the BibleTime classes may not manage the data of BTDrag
- // virtual void setText(const QString& text);
-
- //made protected because the BibleTime classes should not manage the DRag&Drop stuff themself
- static bool decode(const QMimeSource* e, QString& str);
- static bool decode(const QMimeSource* e, QString& str, Q3CString& subtype);
- };
-
- //protected constructor and destructor because we do not allow inheritance, functionality is provided by static functions
- CDragDropMgr();
- virtual ~CDragDropMgr();
-};
-
-#endif
diff --git a/src/frontend/cexportmanager.cpp b/src/frontend/cexportmanager.cpp
index f1ceed6..008963a 100644
--- a/src/frontend/cexportmanager.cpp
+++ b/src/frontend/cexportmanager.cpp
@@ -7,39 +7,31 @@
*
**********/
+#include "frontend/cexportmanager.h"
-
-#include "cexportmanager.h"
-
+#include <boost/scoped_ptr.hpp>
+#include <QApplication>
+#include <QClipboard>
+#include <QFileDialog>
+#include <QList>
+#include <QProgressDialog>
+#include <QTextStream>
+#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/managers/creferencemanager.h"
+#include "backend/managers/referencemanager.h"
#include "backend/managers/cdisplaytemplatemgr.h"
#include "backend/rendering/centrydisplay.h"
#include "backend/rendering/chtmlexportrendering.h"
#include "backend/rendering/cplaintextexportrendering.h"
-
#include "frontend/cprinter.h"
+#include "util/tool.h"
-#include "util/ctoolclass.h"
-#include <boost/scoped_ptr.hpp>
-
-//Qt includes
-#include <QClipboard>
-#include <QList>
-#include <QProgressDialog>
-#include <QTextStream>
-#include <QApplication>
-#include <QFileDialog>
-
-//KDE includes
-
-
-//Sword includes
+// Sword includes:
#include <swkey.h>
#include <listkey.h>
+
using namespace Rendering;
using namespace Printing;
@@ -95,7 +87,7 @@ bool CExportManager::saveKey(CSwordKey* key, const Format format, const bool add
}
if (!progressWasCancelled()) {
- CToolClass::savePlainFile(filename, text, false, (format == HTML) ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale() );
+ util::tool::savePlainFile(filename, text, false, (format == HTML) ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale() );
closeProgressDialog();
return true;
}
@@ -143,7 +135,7 @@ bool CExportManager::saveKeyList(sword::ListKey* list, CSwordModuleInfo* module,
const QString text = render->renderKeyTree(tree);
if (!progressWasCancelled()) {
- CToolClass::savePlainFile(filename, text, false, (format == HTML) ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale() );
+ util::tool::savePlainFile(filename, text, false, (format == HTML) ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale() );
closeProgressDialog();
return true;
}
@@ -190,7 +182,7 @@ bool CExportManager::saveKeyList(QList<CSwordKey*>& list, const Format format, c
const QString text = render->renderKeyTree(tree);
if (!progressWasCancelled()) {
- CToolClass::savePlainFile(filename, text, false, (format == HTML) ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale() );
+ util::tool::savePlainFile(filename, text, false, (format == HTML) ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale() );
closeProgressDialog();
return true;
}
@@ -392,11 +384,11 @@ bool CExportManager::printKey( CSwordKey* key, CSwordBackend::DisplayOptions dis
bool CExportManager::printByHyperlink( const QString& hyperlink, CSwordBackend::DisplayOptions displayOptions, CSwordBackend::FilterOptions filterOptions ) {
QString moduleName;
QString keyName;
- CReferenceManager::Type type;
+ ReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(hyperlink, moduleName, keyName, type);
+ ReferenceManager::decodeHyperlink(hyperlink, moduleName, keyName, type);
if (moduleName.isEmpty()) {
- moduleName = CReferenceManager::preferredModule(type);
+ moduleName = ReferenceManager::preferredModule(type);
}
CPrinter::KeyTree tree;
diff --git a/src/frontend/cexportmanager.h b/src/frontend/cexportmanager.h
index 013cd88..ee8c2c4 100644
--- a/src/frontend/cexportmanager.h
+++ b/src/frontend/cexportmanager.h
@@ -10,16 +10,17 @@
#ifndef CEXPORTMANAGER_H
#define CEXPORTMANAGER_H
-#include "backend/config/cbtconfig.h"
-#include "backend/managers/cswordbackend.h"
#include "util/cpointers.h"
-#include <QString>
#include <QList>
+#include <QString>
+#include "backend/config/cbtconfig.h"
+#include "backend/managers/cswordbackend.h"
+
-class ListKey;
class CSwordKey;
class CSwordModuleInfo;
+class ListKey;
class QProgressDialog;
/** Contains the functions to export text to disk, clipboard or printer.
@@ -65,7 +66,7 @@ class CExportManager : CPointers {
const QString lineBreak( const Format format );
private:
- QString m_caption;
+ QString m_caption; ///< \todo Useless field
QString m_progressLabel;
bool m_showProgress;
CSwordBackend::FilterOptions m_filterOptions;
diff --git a/src/frontend/cinfodisplay.cpp b/src/frontend/cinfodisplay.cpp
index e9c2811..59aa452 100644
--- a/src/frontend/cinfodisplay.cpp
+++ b/src/frontend/cinfodisplay.cpp
@@ -7,34 +7,31 @@
*
**********/
-// BibleTime includes
-#include "cinfodisplay.h"
+#include "frontend/cinfodisplay.h"
+#include <boost/scoped_ptr.hpp>
+#include <QAction>
+#include <QDebug>
+#include <QLabel>
+#include <QLayout>
+#include <QRegExp>
+#include <QSize>
+#include <QVBoxLayout>
+#include <QtAlgorithms>
+
+#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
-#include "backend/managers/creferencemanager.h"
+#include "backend/managers/referencemanager.h"
#include "backend/managers/cdisplaytemplatemgr.h"
-
-#include "backend/config/cbtconfig.h"
#include "frontend/crossrefrendering.h"
-
#include "frontend/display/cdisplay.h"
#include "frontend/display/creaddisplay.h"
-#include <boost/scoped_ptr.hpp>
-
-// Sword includes
+// Sword includes:
#include <listkey.h>
-// Qt includes
-#include <QLayout>
-#include <QLabel>
-#include <QRegExp>
-#include <QVBoxLayout>
-#include <QAction>
-#include <QDebug>
-#include <QSize>
using namespace Rendering;
using namespace sword;
@@ -85,7 +82,7 @@ CInfoDisplay::~CInfoDisplay() {
}
void CInfoDisplay::lookupInfo(const QString &mod_name, const QString &key_text) {
- qDebug("CInfoDisplay::lookup");
+ qDebug() << "CInfoDisplay::lookup";
qDebug() << mod_name << key_text;
CSwordModuleInfo* m = CPointers::backend()->findModuleByName(mod_name);
Q_ASSERT(m);
@@ -288,13 +285,18 @@ const QString CInfoDisplay::decodeCrossReference( const QString& data ) {
// 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();
+ }
+
+ QString RenderedText = renderer.renderKeyTree(tree);
+ qDeleteAll(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(renderer.renderKeyTree(tree));
+ .arg(RenderedText);
}
/*!
@@ -426,7 +428,7 @@ const QString CInfoDisplay::decodeMorph( const QString& data ) {
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
+ /// \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);
break;
}
diff --git a/src/frontend/cinfodisplay.h b/src/frontend/cinfodisplay.h
index 18ffa96..61c9eaf 100644
--- a/src/frontend/cinfodisplay.h
+++ b/src/frontend/cinfodisplay.h
@@ -10,15 +10,13 @@
#ifndef CINFODISPLAY_H
#define CINFODISPLAY_H
-//Backend
-#include "backend/rendering/ctextrendering.h"
-
-//Qt includes
#include <QWidget>
-#include <QPair>
+
#include <QList>
+#include <QPair>
+#include "backend/rendering/ctextrendering.h"
+
-//class forward declarations
class CReadDisplay;
class QAction;
class QSize;
diff --git a/src/frontend/cinputdialog.cpp b/src/frontend/cinputdialog.cpp
index b44113a..5833965 100644
--- a/src/frontend/cinputdialog.cpp
+++ b/src/frontend/cinputdialog.cpp
@@ -7,23 +7,18 @@
*
**********/
+#include "frontend/cinputdialog.h"
-
-//own includes
-#include "cinputdialog.h"
-#include "util/dialogutil.h"
-
-//Qt includes
+#include <QDebug>
#include <QDialog>
-#include <QWidget>
+#include <QDialogButtonBox>
+#include <QHBoxLayout>
#include <QLabel>
-#include <QTextEdit>
#include <QPushButton>
-#include <QDialogButtonBox>
+#include <QTextEdit>
#include <QVBoxLayout>
-#include <QHBoxLayout>
-
-#include <QDebug>
+#include <QWidget>
+#include "util/dialogutil.h"
CInputDialog::CInputDialog
diff --git a/src/frontend/cinputdialog.h b/src/frontend/cinputdialog.h
index 209dc78..153c14e 100644
--- a/src/frontend/cinputdialog.h
+++ b/src/frontend/cinputdialog.h
@@ -7,14 +7,12 @@
*
**********/
-
-
#ifndef CINPUTDIALOG_H
#define CINPUTDIALOG_H
-
#include <QDialog>
+
class QTextEdit;
class QWidget;
diff --git a/src/frontend/cmdiarea.cpp b/src/frontend/cmdiarea.cpp
index 91f3eae..3745993 100644
--- a/src/frontend/cmdiarea.cpp
+++ b/src/frontend/cmdiarea.cpp
@@ -7,19 +7,25 @@
*
**********/
-#include "cmdiarea.h"
+#include "bibletime.h"
+#include "frontend/cmdiarea.h"
-//QT includes
-#include <QTimer>
#include <QEvent>
-#include <QWindowStateChangeEvent>
#include <QMdiSubWindow>
-#include <QDebug>
+#include <QTimer>
+#include <QWindowStateChangeEvent>
-CMDIArea::CMDIArea(QWidget *parent) : QMdiArea(parent),
- m_mdiArrangementMode(ArrangementModeManual) {
- setActivationOrder( CreationOrder ); //keep window order consistent
- connect(this, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(slotClientActivated(QMdiSubWindow*)));
+
+CMDIArea::CMDIArea(BibleTime *parent)
+ : QMdiArea(parent), m_mdiArrangementMode(ArrangementModeManual)
+{
+ Q_ASSERT(parent != 0);
+
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+
+ connect(this, SIGNAL(subWindowActivated(QMdiSubWindow*)),
+ this, SLOT(slotSubWindowActivated(QMdiSubWindow*)));
}
QMdiSubWindow* CMDIArea::addSubWindow(QWidget * widget, Qt::WindowFlags windowFlags) {
@@ -41,19 +47,11 @@ QMdiSubWindow* CMDIArea::addSubWindow(QWidget * widget, Qt::WindowFlags windowFl
return subWindow;
}
-void CMDIArea::deleteAll() {
- closeAllSubWindows();
-}
-
void CMDIArea::setMDIArrangementMode( const MDIArrangementMode newArrangementMode ) {
m_mdiArrangementMode = newArrangementMode;
triggerWindowUpdate();
}
-CMDIArea::MDIArrangementMode CMDIArea::getMDIArrangementMode(void) const {
- return m_mdiArrangementMode;
-}
-
void CMDIArea::myTileVertical() {
if (!updatesEnabled() || !usableWindowList().count() ) {
return;
@@ -71,7 +69,19 @@ void CMDIArea::myTileVertical() {
else {
setUpdatesEnabled(false);
QMdiSubWindow* active = activeSubWindow();
- QMdiArea::tileSubWindows();
+
+ const int widthForEach = width() / windows.count();
+ unsigned int x = 0;
+ foreach (QMdiSubWindow *window, windows) {
+ window->showNormal();
+
+ const int preferredWidth = window->minimumWidth() + window->baseSize().width();
+ const int actWidth = qMax(widthForEach, preferredWidth);
+
+ window->setGeometry(x, 0, actWidth, height());
+ x += actWidth;
+ }
+
if (active) active->setFocus();
setUpdatesEnabled(true);
}
@@ -95,7 +105,6 @@ void CMDIArea::myTileHorizontal() {
}
else {
setUpdatesEnabled(false);
-
QMdiSubWindow* active = activeSubWindow();
const int heightForEach = height() / windows.count();
@@ -109,7 +118,7 @@ void CMDIArea::myTileHorizontal() {
window->setGeometry( 0, y, width(), actHeight );
y += actHeight;
}
- active->setFocus();
+ if (active) active->setFocus();
setUpdatesEnabled(true);
}
emitWindowCaptionChanged();
@@ -161,11 +170,11 @@ void CMDIArea::myCascade() {
}
void CMDIArea::emitWindowCaptionChanged() {
- QString appCaption;
if (activeSubWindow()) {
- appCaption = activeSubWindow()->windowTitle();
+ emit sigSetToplevelCaption(activeSubWindow()->windowTitle());
+ } else {
+ emit sigSetToplevelCaption(QString());
}
- emit sigSetToplevelCaption(appCaption);
}
QList<QMdiSubWindow*> CMDIArea::usableWindowList() {
@@ -181,7 +190,7 @@ QList<QMdiSubWindow*> CMDIArea::usableWindowList() {
return ret;
}
-void CMDIArea::slotClientActivated(QMdiSubWindow* client) {
+void CMDIArea::slotSubWindowActivated(QMdiSubWindow* client) {
if (!client || !updatesEnabled()) {
return;
}
@@ -189,35 +198,56 @@ void CMDIArea::slotClientActivated(QMdiSubWindow* client) {
}
//resize event of the MDI area itself, update layout if necessary
-void CMDIArea::resizeEvent(QResizeEvent* /*e*/) {
- //do not call QMdiArea::resizeEvent(e), this would mess up our layout
+void CMDIArea::resizeEvent(QResizeEvent* e) {
+ // Do not call QMdiArea::resizeEvent(e), this would mess up our layout
+ // unless we are in manual mode
if (updatesEnabled()) triggerWindowUpdate();
+ if (m_mdiArrangementMode == ArrangementModeManual)
+ QMdiArea::resizeEvent(e);
}
//handle events of the client windows to update layout if necessary
bool CMDIArea::eventFilter(QObject *o, QEvent *e) {
- QMdiSubWindow* w = dynamic_cast<QMdiSubWindow*>(o);
- if (!w) return false; //let the event be handled by other filters too
-
- if (e->type() == QEvent::WindowStateChange) {
- Qt::WindowStates newState = w->windowState();
- Qt::WindowStates oldState = ((QWindowStateChangeEvent*)e)->oldState();
-
- //Do not handle window activation or deactivation here, it will produce wrong
- //results because this event is handled too early. Let slotClientActivated() handle this.
+ QMdiSubWindow *w(qobject_cast<QMdiSubWindow*>(o));
+
+ // Let the event be handled by other filters:
+ if (w == 0) return QMdiArea::eventFilter(o, e);
+
+ switch (e->type()) {
+ case QEvent::WindowStateChange:
+ {
+ Qt::WindowStates newState(w->windowState());
+ Qt::WindowStates oldState(((QWindowStateChangeEvent*)e)->oldState());
+
+ /*
+ Do not handle window activation or deactivation here, it will
+ produce wrong results because this event is handled too early. Let
+ slotSubWindowActivated() handle this.
+ */
+
+ // Check if subwindow was maximized or un-maximized:
+ if ((newState ^ oldState) & Qt::WindowMaximized) {
+ triggerWindowUpdate();
+ break;
+ }
- bool needsLayoutUpdate = false;
- //Window was maximized or un-maximized
- if ((newState ^ oldState) & Qt::WindowMaximized) needsLayoutUpdate = true;
- //Window was minimized or de-minimized
- if ((newState ^ oldState) & Qt::WindowMinimized) needsLayoutUpdate = true;
- //update Layout?
- if (needsLayoutUpdate) triggerWindowUpdate();
- }
- if (e->type() == QEvent::Close) {
- triggerWindowUpdate();
+ // Check if subwindow was minimized or de-minimized:
+ if ((newState ^ oldState) & Qt::WindowMinimized) {
+ triggerWindowUpdate();
+ }
+ break;
+ }
+ case QEvent::Close:
+ triggerWindowUpdate();
+ break;
+ case QEvent::WindowTitleChange:
+ emitWindowCaptionChanged();
+ break;
+ default:
+ break;
}
- return false; //let the event be handled by other filters too
+
+ return false; // Don't filter the event out
}
void CMDIArea::triggerWindowUpdate() {
diff --git a/src/frontend/cmdiarea.h b/src/frontend/cmdiarea.h
index 1420007..1fb1c7f 100644
--- a/src/frontend/cmdiarea.h
+++ b/src/frontend/cmdiarea.h
@@ -10,107 +10,111 @@
#ifndef CMDIAREA_H
#define CMDIAREA_H
-//Qt includes
#include <QMdiArea>
+
#include <QList>
+class BibleTime;
class CSwordModuleInfo;
-class QEvent;
-class QResizeEvent;
-class QMdiSubWindow;
-
-/** The MDI widget we use in BibleTime.
- * Enhances QMdiArea.
- */
-class CMDIArea : public QMdiArea {
+
+/**
+ A custom MDI area widget.
+*/
+class CMDIArea: public QMdiArea {
Q_OBJECT
Q_PROPERTY(MDIArrangementMode m_mdiArrangementMode READ getMDIArrangementMode WRITE setMDIArrangementMode)
public:
/**
- * The options you can set for this widget.
+ Possible MDI subwindow arrangement modes.
*/
enum MDIArrangementMode {
ArrangementModeTileVertical = 1,
ArrangementModeTileHorizontal = 2,
ArrangementModeCascade = 3,
- ArrangementModeManual = 4,
- MDIArrangementModeMIN = ArrangementModeTileVertical,
- MDIArrangementModeMAX = ArrangementModeManual
+ ArrangementModeManual = 4
};
- CMDIArea(QWidget *parent);
- /** Reimplementation
+
+ /**
+ \param[in] parent BibleTime main window used for parent widget.
*/
- virtual QMdiSubWindow* addSubWindow(QWidget* widget, Qt::WindowFlags windowFlags = 0);
+ CMDIArea(BibleTime *parent);
+
/**
+ Reimplementation of QMdiArea::addSubWindow().
+ */
+ QMdiSubWindow *addSubWindow(QWidget *widget, Qt::WindowFlags windowFlags = 0);
+
+ /**
+ Resets the MDI arrangement mode and arranges the windows.
+ \param[in] mode new MDI arrangement mode.
*/
- void setMDIArrangementMode( const MDIArrangementMode );
- /** */
- MDIArrangementMode getMDIArrangementMode(void) const;
+ void setMDIArrangementMode(const MDIArrangementMode mode);
+
/**
+ Returns the current MDI arrangement mode.
*/
- void emitWindowCaptionChanged();
+ inline MDIArrangementMode getMDIArrangementMode() const {
+ return m_mdiArrangementMode;
+ }
+
/**
* Forces an update of the currently chosen window arrangement.
*/
void triggerWindowUpdate();
- /** Lists all subWindows which are not minimized or hidden
- */
- QList<QMdiSubWindow*> usableWindowList();
- public slots:
/**
- * Called whan a client window was activated
+ Returns a lists of all subwindows which are not minimized or hidden.
*/
- void slotClientActivated(QMdiSubWindow* client);
+ QList<QMdiSubWindow*> usableWindowList();
+
+ public slots:
/**
- * Deletes all the presenters in the MDI area.
- */
- void deleteAll();
- /** Our own cascade version which, if only one window is left, shows this maximized.
- * Also necessary for autoCasacde feature
+ Our own cascade version which, if only one window is left, shows this
+ maximized. Also necessary for autoCascade feature.
*/
void myCascade();
- /** Our own cascade version which, if only one window is left, shows this maximized.
- * Also necessary for autoTile feature
+
+ /**
+ Our own cascade version which, if only one window is left, shows this
+ maximized. Also necessary for autoTile feature.
*/
void myTileVertical();
- /** Horizontal tile function
- * This function was taken from Qt's MDI example.
+
+ /**
+ Horizontal tile function. This function was taken from Qt's MDI
+ example.
*/
void myTileHorizontal();
- /**
- * Emits the signal to create a new display window in the MDI area.
- */
- inline void emitCreateDisplayWindow(QList<CSwordModuleInfo*> modules, const QString keyName);
- signals: // Signals
+ signals:
/**
* Emits a signal to set the acption of the toplevel widget.
*/
void sigSetToplevelCaption(const QString&);
- /**
- */
- void createReadDisplayWindow(QList<CSwordModuleInfo*> modules, const QString& keyName);
- private:
+ protected:
/**
- * Reimplementation
+ * Reimplementation of QWidget::resizeEvent().
*/
- virtual void resizeEvent(QResizeEvent* e);
+ void resizeEvent(QResizeEvent *e);
+
/**
- * Used to handle Events of MDI windows
- * */
- bool eventFilter( QObject *o, QEvent *e );
+ Reimplementation of QObject::eventFilter() used to handle some MDI
+ subwindow events.
+ */
+ bool eventFilter(QObject *o, QEvent *e);
+
+ void emitWindowCaptionChanged();
+
+ protected slots:
/**
- */
+ Called whan a subwindow was activated.
+ */
+ void slotSubWindowActivated(QMdiSubWindow *client);
+
+ protected:
MDIArrangementMode m_mdiArrangementMode;
};
-/** Emits the signal to create a new display window in the MDI area. */
-inline void CMDIArea::emitCreateDisplayWindow(QList<CSwordModuleInfo*> modules, const QString keyName) {
- emit createReadDisplayWindow(modules, keyName);
-}
-
-
#endif
diff --git a/src/frontend/cmodulechooserdialog.cpp b/src/frontend/cmodulechooserdialog.cpp
index 2107b2c..d2d7505 100644
--- a/src/frontend/cmodulechooserdialog.cpp
+++ b/src/frontend/cmodulechooserdialog.cpp
@@ -7,30 +7,28 @@
*
**********/
-#include "cmodulechooserdialog.h"
+#include "frontend/cmodulechooserdialog.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-#include "backend/managers/cswordbackend.h"
-#include "backend/btmoduletreeitem.h"
-
-#include "util/cpointers.h"
-#include "util/cresmgr.h"
-#include "util/ctoolclass.h"
-#include "util/dialogutil.h"
-#include "util/directoryutil.h"
-#include "backend/config/cbtconfig.h"
-
-#include <QDialog>
#include <QButtonGroup>
+#include <QDebug>
+#include <QDialog>
#include <QDialogButtonBox>
#include <QHBoxLayout>
+#include <QHeaderView>
+#include <QLabel>
#include <QSpacerItem>
+#include <QStringList>
#include <QTreeWidget>
#include <QVBoxLayout>
-#include <QStringList>
-#include <QDebug>
-#include <QHeaderView>
-#include <QLabel>
+#include "backend/btmoduletreeitem.h"
+#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/cswordbackend.h"
+#include "util/cpointers.h"
+#include "util/cresmgr.h"
+#include "util/tool.h"
+#include "util/dialogutil.h"
+#include "util/directory.h"
CModuleChooserDialog::CModuleChooserDialog( QWidget* parent, QString title, QString label, QList<CSwordModuleInfo*>* allModules)
@@ -58,7 +56,7 @@ void CModuleChooserDialog::init() {
/** Initializes the view of this dialog */
void CModuleChooserDialog::initView() {
- //TODO: choose the button text?
+ /// \todo choose the button text?
QVBoxLayout *vboxLayout;
QHBoxLayout *hboxLayout;
@@ -66,7 +64,7 @@ void CModuleChooserDialog::initView() {
vboxLayout = new QVBoxLayout(this);
- QLabel* label = CToolClass::explanationLabel(this, QString::null, m_labelText);
+ QLabel* label = util::tool::explanationLabel(this, QString::null, m_labelText);
vboxLayout->addWidget(label);
m_moduleChooser = new QTreeWidget(this);
@@ -94,7 +92,7 @@ void CModuleChooserDialog::initView() {
void CModuleChooserDialog::initTree() {
- //qDebug("CModuleChooserDialog::initTree");
+ //qDebug() << "CModuleChooserDialog::initTree";
// See BTModuleTreeItem documentation.
BTModuleTreeItem root(m_filters, m_grouping, &m_moduleList);
@@ -127,10 +125,10 @@ void CModuleChooserDialog::slotOk() {
for ( ; *it; ++it ) {
//add the module to list if the box is checked
if ((*it)->checkState(0) == Qt::Checked) {
- qDebug("was checked");
+ qDebug() << "was checked";
for (QList<CSwordModuleInfo*>::iterator all_iter(m_moduleList.begin()); all_iter != m_moduleList.end(); ++all_iter) {
if ((*all_iter)->name() == (*it)->text(0)) {
- qDebug("append");
+ qDebug() << "append";
mods.append(*all_iter);
break;
}
diff --git a/src/frontend/cmodulechooserdialog.h b/src/frontend/cmodulechooserdialog.h
index 1e5a777..e74d743 100644
--- a/src/frontend/cmodulechooserdialog.h
+++ b/src/frontend/cmodulechooserdialog.h
@@ -10,17 +10,16 @@
#ifndef CMODULECHOOSERDIALOG_H
#define CMODULECHOOSERDIALOG_H
-class CSwordModuleInfo;
-#include "backend/btmoduletreeitem.h"
-
#include <QDialog>
+
+#include "backend/btmoduletreeitem.h"
#include <QList>
#include <QTreeWidget>
+class CSwordModuleInfo;
class QDialogButtonBox;
-
/**
* Abstract dialog which lets the user select modules with checkboxes.
* The dialog will be destroyed after closing. Connect the modulesChanged() signal
diff --git a/src/frontend/cmoduleindexdialog.cpp b/src/frontend/cmoduleindexdialog.cpp
index d85e6b7..a32d1ea 100644
--- a/src/frontend/cmoduleindexdialog.cpp
+++ b/src/frontend/cmoduleindexdialog.cpp
@@ -7,27 +7,24 @@
*
**********/
-#include "cmoduleindexdialog.h"
+#include "frontend/cmoduleindexdialog.h"
-#include "util/cpointers.h"
+#include <QApplication>
+#include <QDebug>
+#include <QProgressDialog>
+#include <QString>
#include "backend/managers/cswordbackend.h"
+#include "util/cpointers.h"
+#include "util/dialogutil.h"
-#include <boost/scoped_ptr.hpp>
-
-//Qt includes
-#include <QString>
-#include <QProgressDialog>
-#include <QDebug>
-#include <QApplication>
-#include <QMessageBox>
CModuleIndexDialog* CModuleIndexDialog::getInstance() {
- qDebug("CModuleIndexDialog::getInstance");
+ qDebug() << "CModuleIndexDialog::getInstance";
static CModuleIndexDialog* instance = 0;
if (instance == 0) {
instance = new CModuleIndexDialog();
}
- qDebug("CModuleIndexDialog::getInstance end");
+ qDebug() << "CModuleIndexDialog::getInstance end";
return instance;
}
@@ -45,7 +42,7 @@ void CModuleIndexDialog::indexAllModules( const QList<CSwordModuleInfo*>& module
m_progress->raise();
foreach (CSwordModuleInfo* info, modules) {
- //TODO: how to cancel
+ /// \todo how to cancel
//QObject::connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged()), this, SLOT(swordSetupChanged()));
connect(this, SIGNAL(sigCancel()), info, SLOT(cancelIndexing()) );
connect(m_progress, SIGNAL(canceled()), info, SLOT(cancelIndexing()));
@@ -54,7 +51,7 @@ void CModuleIndexDialog::indexAllModules( const QList<CSwordModuleInfo*>& module
QString modname(info->name());
const QString labelText = tr("Creating index for work: %1").arg(modname);
m_progress->setLabelText(labelText);
- //todo: if we want to cancel indexing from
+ /// \todo if we want to cancel indexing from
info->buildIndex(); //waits until this module is finished
m_currentModuleIndex++;
@@ -96,7 +93,7 @@ void CModuleIndexDialog::slotFinished( ) {
// Modules may be removed
void CModuleIndexDialog::slotSwordSetupChanged() {
- qDebug("CModuleIndexDialog::slotSwordSetupChanged, TODO: cancel if modules are removed");
- QMessageBox::information(0, tr("Indexing Is Cancelled"), tr("Indexing is cancelled because modules are removed."));
+ qDebug() << "CModuleIndexDialog::slotSwordSetupChanged"; /// \todo cancel if modules are removed
+ util::showInformation(0, tr("Indexing Is Cancelled"), tr("Indexing is cancelled because modules are removed."));
emit sigCancel();
}
diff --git a/src/frontend/cmoduleindexdialog.h b/src/frontend/cmoduleindexdialog.h
index 3a19be2..b27b161 100644
--- a/src/frontend/cmoduleindexdialog.h
+++ b/src/frontend/cmoduleindexdialog.h
@@ -1,24 +1,19 @@
-//
-// C++ Interface: cmoduleindexdialog
-//
-// Description:
-//
-//
-// Author: The BibleTime team <info@bibletime.info>, (C) 2006-2007
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
#ifndef CMODULEINDEXDIALOG_H
#define CMODULEINDEXDIALOG_H
-class CSwordModuleInfo;
-
-//Qt includes
#include <QObject>
-//forward declaration
-//class KProgressDialog;
+
+class CSwordModuleInfo;
class QProgressDialog;
/**
diff --git a/src/frontend/cprinter.cpp b/src/frontend/cprinter.cpp
index 0a05a55..11988a9 100644
--- a/src/frontend/cprinter.cpp
+++ b/src/frontend/cprinter.cpp
@@ -7,16 +7,16 @@
*
**********/
-#include "cprinter.h"
+#include "frontend/cprinter.h"
-#include "backend/managers/cdisplaytemplatemgr.h"
+#include <QPrintDialog>
+#include <QPrinter>
+#include <QWebFrame>
+#include <QWebPage>
#include "backend/keys/cswordversekey.h"
+#include "backend/managers/cdisplaytemplatemgr.h"
#include "util/cpointers.h"
-#include <QWebPage>
-#include <QWebFrame>
-#include <QPrinter>
-#include <QPrintDialog>
namespace Printing {
diff --git a/src/frontend/cprinter.h b/src/frontend/cprinter.h
index d97563e..f119ec3 100644
--- a/src/frontend/cprinter.h
+++ b/src/frontend/cprinter.h
@@ -10,11 +10,12 @@
#ifndef CPRINTER_H
#define CPRINTER_H
-#include "backend/managers/cswordbackend.h"
+#include <QObject>
#include "backend/rendering/cdisplayrendering.h"
+
#include "backend/config/cbtconfig.h"
+#include "backend/managers/cswordbackend.h"
-#include <QObject>
class QWebPage;
diff --git a/src/frontend/crossrefrendering.cpp b/src/frontend/crossrefrendering.cpp
index 9785ee7..1d7ff63 100644
--- a/src/frontend/crossrefrendering.cpp
+++ b/src/frontend/crossrefrendering.cpp
@@ -1,31 +1,28 @@
-//
-// C++ Implementation: crossrefrendering
-//
-// Description:
-//
-//
-// Author: The BibleTime team <info@bibletime.info>, (C) 2004, 2007
-//
-// Copyright: See COPYING file that comes with this distribution
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
-
-#include "crossrefrendering.h"
+#include "frontend/crossrefrendering.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/keys/cswordversekey.h"
-#include "backend/managers/creferencemanager.h"
+#include "backend/managers/referencemanager.h"
+
namespace InfoDisplay {
-/**
- */
CrossRefRendering::CrossRefRendering( CSwordBackend::DisplayOptions displayOptions,
CSwordBackend::FilterOptions filterOptions
)
: CHTMLExportRendering(Settings(), displayOptions, filterOptions) {}
const QString CrossRefRendering::finishText( const QString& text, KeyTree& ) {
- // qDebug("CrossRefRendering::finishText");
+ // qDebug() << "CrossRefRendering::finishText";
return text;
}
@@ -74,10 +71,10 @@ const QString CrossRefRendering::entryLink( const KeyTreeItem& item, CSwordModul
// qWarning("rendering");
return QString("<a href=\"%1\">%2</a>")
.arg(
- CReferenceManager::encodeHyperlink(
+ ReferenceManager::encodeHyperlink(
module->name(),
item.key(),
- CReferenceManager::typeFromModule(module->type())
+ ReferenceManager::typeFromModule(module->type())
)
)
.arg(linkText);
diff --git a/src/frontend/crossrefrendering.h b/src/frontend/crossrefrendering.h
index a1e5607..561fd3e 100644
--- a/src/frontend/crossrefrendering.h
+++ b/src/frontend/crossrefrendering.h
@@ -1,20 +1,18 @@
-//
-// C++ Interface: crossrefrendering
-//
-// Description:
-//
-//
-// Author: The BibleTime team <info@bibletime.info>, (C) 2004, 2007
-//
-// Copyright: See COPYING file that comes with this distribution
-
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
#ifndef INFODISPLAYCROSSREFRENDERING_H
#define INFODISPLAYCROSSREFRENDERING_H
-//Backend includes
#include "backend/rendering/chtmlexportrendering.h"
+
namespace InfoDisplay {
class CrossRefRendering : public Rendering::CHTMLExportRendering {
diff --git a/src/frontend/display/btcolorwidget.cpp b/src/frontend/display/btcolorwidget.cpp
index 735f23f..37bea2d 100644
--- a/src/frontend/display/btcolorwidget.cpp
+++ b/src/frontend/display/btcolorwidget.cpp
@@ -7,11 +7,13 @@
*
**********/
-#include "btcolorwidget.h"
-#include <QPalette>
+#include "frontend/display/btcolorwidget.h"
+
#include <QColor>
-#include <QMouseEvent>
#include <QColorDialog>
+#include <QMouseEvent>
+#include <QPalette>
+
BtColorWidget::BtColorWidget(QWidget* parent)
: QFrame(parent) {
diff --git a/src/frontend/display/btcolorwidget.h b/src/frontend/display/btcolorwidget.h
index aac8615..0d8e8ad 100644
--- a/src/frontend/display/btcolorwidget.h
+++ b/src/frontend/display/btcolorwidget.h
@@ -1,19 +1,18 @@
-//
-// C++ Interface: BtColorWidget
-//
-// Description: A color choosing widget for the toolbar
-//
-//
-// Author: The BibleTime team <info@bibletime.info>, (C) 1999-2008
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
#ifndef BTCOLORWIDGET_H
#define BTCOLORWIDGET_H
#include <QFrame>
+
+
class QPaintEvent;
class BtColorWidget : public QFrame {
diff --git a/src/frontend/display/btfontsizewidget.cpp b/src/frontend/display/btfontsizewidget.cpp
index 9d45a6a..116d0d7 100644
--- a/src/frontend/display/btfontsizewidget.cpp
+++ b/src/frontend/display/btfontsizewidget.cpp
@@ -7,9 +7,11 @@
*
**********/
-#include "btfontsizewidget.h"
-#include <QFontDatabase>
+#include "frontend/display/btfontsizewidget.h"
+
#include <QCompleter>
+#include <QFontDatabase>
+
BtFontSizeWidget::BtFontSizeWidget(QWidget* parent)
: QComboBox(parent) {
diff --git a/src/frontend/display/btfontsizewidget.h b/src/frontend/display/btfontsizewidget.h
index 81cfa86..3db867d 100644
--- a/src/frontend/display/btfontsizewidget.h
+++ b/src/frontend/display/btfontsizewidget.h
@@ -1,14 +1,11 @@
-//
-// C++ Interface: BtFontSizeWidget
-//
-// Description: A font combobox widget for the toolbar
-//
-//
-// Author: The BibleTime team <info@bibletime.info>, (C) 1999-2008
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
#ifndef BTFONTSIZEWIDGET_H
#define BTFONTSIZEWIDGET_H
diff --git a/src/frontend/display/bthtmlfindtext.cpp b/src/frontend/display/bthtmlfindtext.cpp
index 9e0feff..70e8a5d 100644
--- a/src/frontend/display/bthtmlfindtext.cpp
+++ b/src/frontend/display/bthtmlfindtext.cpp
@@ -7,12 +7,14 @@
*
**********/
-#include "bthtmlfindtext.h"
-#include "bthtmlreaddisplay.h"
-#include "creaddisplay.h"
+#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"
-#include <QMdiSubWindow>
+
static BtHtmlFindText* dialog = 0;
diff --git a/src/frontend/display/bthtmlfindtext.h b/src/frontend/display/bthtmlfindtext.h
index 0500247..3c24489 100644
--- a/src/frontend/display/bthtmlfindtext.h
+++ b/src/frontend/display/bthtmlfindtext.h
@@ -10,7 +10,10 @@
#ifndef BTHTMLFINDTEXT_H
#define BTHTMLFINDTEXT_H
+/// \todo Qt Designer UI file!?
#include "ui_bthtmlfindtext.h"
+
+
class CMDIArea;
class QWebView;
diff --git a/src/frontend/display/bthtmljsobject.cpp b/src/frontend/display/bthtmljsobject.cpp
index b1b97a6..195564e 100644
--- a/src/frontend/display/bthtmljsobject.cpp
+++ b/src/frontend/display/bthtmljsobject.cpp
@@ -6,16 +6,19 @@
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "bthtmljsobject.h"
-#include "bthtmlreaddisplay.h"
-#include "frontend/cinfodisplay.h"
-#include "frontend/cdragdrop.h"
-#include "backend/managers/creferencemanager.h"
-#include "backend/managers/cswordbackend.h"
-#include "backend/keys/cswordkey.h"
-#include "backend/config/cbtconfig.h"
+
+#include "frontend/display/bthtmljsobject.h"
+
#include <boost/scoped_ptr.hpp>
#include <QObject>
+#include "backend/config/cbtconfig.h"
+#include "backend/keys/cswordkey.h"
+#include "backend/managers/referencemanager.h"
+#include "backend/managers/cswordbackend.h"
+#include "frontend/cdragdrop.h"
+#include "frontend/cinfodisplay.h"
+#include "frontend/display/bthtmlreaddisplay.h"
+
using namespace InfoDisplay;
@@ -49,14 +52,14 @@ void BtHtmlJsObject::mouseDownLeft(const QString& url, const int& x, const int&
void BtHtmlJsObject::mouseClick(const QString& url) {
m_dndData.mousePressed = false;
- if (!url.isEmpty() && CReferenceManager::isHyperlink(url)) {
+ if (!url.isEmpty() && ReferenceManager::isHyperlink(url)) {
QString module;
QString key;
- CReferenceManager::Type type;
+ ReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(url, module, key, type);
+ ReferenceManager::decodeHyperlink(url, module, key, type);
if (module.isEmpty()) {
- module = CReferenceManager::preferredModule( type );
+ module = ReferenceManager::preferredModule( type );
}
m_display->connectionsProxy()->emitReferenceClicked(module, key);
}
@@ -82,8 +85,8 @@ void BtHtmlJsObject::mouseMoveEvent(const QString& attributes, const int& x, con
// create a new bookmark drag!
QString moduleName = QString::null;
QString keyName = QString::null;
- CReferenceManager::Type type;
- if ( !CReferenceManager::decodeHyperlink(m_dndData.url, moduleName, keyName, type) )
+ ReferenceManager::Type type;
+ if ( !ReferenceManager::decodeHyperlink(m_dndData.url, moduleName, keyName, type) )
return;
drag = new QDrag(m_display->view());
BTMimeData* mimedata = new BTMimeData(moduleName, keyName, QString::null);
diff --git a/src/frontend/display/bthtmljsobject.h b/src/frontend/display/bthtmljsobject.h
index d418b71..c3536ff 100644
--- a/src/frontend/display/bthtmljsobject.h
+++ b/src/frontend/display/bthtmljsobject.h
@@ -6,12 +6,15 @@
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
+
#ifndef BTHTMLJSOBJECT_H
#define BTHTMLJSOBJECT_H
#include <QObject>
+
#include <QPoint>
+
class BtHtmlReadDisplay;
class BtHtmlJsObject: public QObject {
diff --git a/src/frontend/display/bthtmlreaddisplay.cpp b/src/frontend/display/bthtmlreaddisplay.cpp
index 7ce6f40..3d97fba 100644
--- a/src/frontend/display/bthtmlreaddisplay.cpp
+++ b/src/frontend/display/bthtmlreaddisplay.cpp
@@ -7,21 +7,22 @@
*
**********/
-#include "bthtmlreaddisplay.h"
-#include "bthtmljsobject.h"
-#include "frontend/displaywindow/cdisplaywindow.h"
-#include "frontend/displaywindow/creadwindow.h"
+#include "frontend/display/bthtmlreaddisplay.h"
+
+#include <boost/scoped_ptr.hpp>
+#include <QMenu>
+#include <QString>
+#include "backend/config/cbtconfig.h"
+#include "backend/keys/cswordkey.h"
+#include "backend/managers/referencemanager.h"
#include "frontend/cdragdrop.h"
#include "frontend/cinfodisplay.h"
-#include "backend/managers/creferencemanager.h"
-#include "backend/keys/cswordkey.h"
-#include "backend/config/cbtconfig.h"
-#include "util/ctoolclass.h"
+#include "frontend/display/bthtmljsobject.h"
+#include "frontend/displaywindow/cdisplaywindow.h"
+#include "frontend/displaywindow/creadwindow.h"
+#include "util/directory.h"
#include "util/cpointers.h"
-#include "util/directoryutil.h"
-#include <boost/scoped_ptr.hpp>
-#include <QString>
-#include <QMenu>
+
using namespace InfoDisplay;
@@ -55,9 +56,11 @@ BtHtmlReadDisplay::~BtHtmlReadDisplay() {
// Read javascript into memory once and create the c++ javascript object
void BtHtmlReadDisplay::initJavascript() {
+ namespace DU = util::directory;
+
// read bthtml.js javascript file once
if (javascript.size() == 0) {
- QString jsFile = util::filesystem::DirectoryUtil::getJavascriptDir().canonicalPath() + "/bthtml.js";
+ QString jsFile = DU::getJavascriptDir().canonicalPath() + "/bthtml.js";
QFile file(jsFile);
if (file.open(QFile::ReadOnly)) {
while (!file.atEnd()) {
@@ -98,7 +101,7 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD
if (module->type() == CSwordModuleInfo::Lexicon ||
module->type() == CSwordModuleInfo::Commentary ||
module->type() == CSwordModuleInfo::GenericBook) {
- //TODO: This is a BAD HACK, we have to fnd a better solution to manage the settings now
+ /// \todo This is a BAD HACK, we have to fnd a better solution to manage the settings now
CSwordBackend::FilterOptions filterOptions;
filterOptions.footnotes = false;
filterOptions.strongNumbers = false;
@@ -123,7 +126,7 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD
return QString::null;
}
else if (format == HTMLText) {
- // TODO: It does not appear this is ever called
+ // \todo It does not appear this is ever called
}
else { //plain text requested
return selectedText();
@@ -133,8 +136,8 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD
case AnchorOnly: {
QString moduleName;
QString keyName;
- CReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
+ ReferenceManager::Type type;
+ ReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
return keyName;
}
@@ -142,8 +145,8 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD
case AnchorTextOnly: {
QString moduleName;
QString keyName;
- CReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
+ ReferenceManager::Type type;
+ ReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
if (CSwordModuleInfo* module = backend()->findModuleByName(moduleName)) {
boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
@@ -157,14 +160,14 @@ const QString BtHtmlReadDisplay::text( const CDisplay::TextType format, const CD
case AnchorWithText: {
QString moduleName;
QString keyName;
- CReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
+ ReferenceManager::Type type;
+ ReferenceManager::decodeHyperlink(activeAnchor(), moduleName, keyName, type);
if (CSwordModuleInfo* module = backend()->findModuleByName(moduleName)) {
boost::scoped_ptr<CSwordKey> key( CSwordKey::createInstance(module) );
key->key( keyName );
- //TODO: This is a BAD HACK, we have to fnd a better solution to manage the settings now
+ /// \todo This is a BAD HACK, we have to fnd a better solution to manage the settings now
CSwordBackend::FilterOptions filterOptions;
filterOptions.footnotes = false;
filterOptions.strongNumbers = false;
diff --git a/src/frontend/display/bthtmlreaddisplay.h b/src/frontend/display/bthtmlreaddisplay.h
index 020a685..7c2d91f 100644
--- a/src/frontend/display/bthtmlreaddisplay.h
+++ b/src/frontend/display/bthtmlreaddisplay.h
@@ -10,18 +10,17 @@
#ifndef BTHTMLREADDISPLAY_H
#define BTHTMLREADDISPLAY_H
-//BibleTime includes
-#include "bthtmljsobject.h"
-#include "creaddisplay.h"
+#include "frontend/display/creaddisplay.h"
+#include <QWebPage>
-//Qt includes
#include <QDragEnterEvent>
#include <QDropEvent>
+#include <QPoint>
#include <QTimerEvent>
#include <QWebView>
-#include <QWebPage>
#include <QWebFrame>
-#include <QPoint>
+#include "frontend/display/bthtmljsobject.h"
+
class BtHtmlReadDisplayView;
class QScrollArea;
diff --git a/src/frontend/display/cdisplay.cpp b/src/frontend/display/cdisplay.cpp
index b66f8af..a63b55b 100644
--- a/src/frontend/display/cdisplay.cpp
+++ b/src/frontend/display/cdisplay.cpp
@@ -7,29 +7,22 @@
*
**********/
-#include "cdisplay.h"
+#include "frontend/display/cdisplay.h"
-#include "bthtmlreaddisplay.h"
-typedef BtHtmlReadDisplay HTMLREADDISPLAY;
-
-#include "cplainwritedisplay.h"
-#include "chtmlwritedisplay.h"
-
-#include "backend/managers/creferencemanager.h"
-
-#include "util/ctoolclass.h"
-
-
-//Qt includes
+#include <QApplication>
#include <QClipboard>
-#include <QMenu>
-#include <QTimer>
#include <QDebug>
-#include <QApplication>
#include <QFileDialog>
+#include <QMenu>
+#include <QTimer>
+#include "backend/managers/referencemanager.h"
+#include "frontend/display/bthtmlreaddisplay.h"
+#include "frontend/display/chtmlwritedisplay.h"
+#include "frontend/display/cplainwritedisplay.h"
+#include "util/tool.h"
-//KDE includes
+typedef BtHtmlReadDisplay HTMLREADDISPLAY;
CDisplayConnections::CDisplayConnections( CDisplay* display ) : m_display(display) {}
@@ -47,7 +40,7 @@ void CDisplayConnections::saveAsPlain() {
/** Emits the signal. */
void CDisplayConnections::emitReferenceClicked( const QString& module, const QString& key) {
- qDebug("CDisplayConnections::emitReferenceClicked");
+ qDebug() << "CDisplayConnections::emitReferenceClicked";
qDebug() << "Module: " << module << " key: " << key;
emit referenceClicked( module, key );
}
@@ -161,7 +154,7 @@ bool CDisplay::save( const CDisplay::TextType format, const CDisplay::TextPart p
const QString filename = QFileDialog::getSaveFileName(0, QObject::tr("Save document ..."), "", filter);
if (!filename.isEmpty()) {
- CToolClass::savePlainFile(filename, content);
+ util::tool::savePlainFile(filename, content);
}
return true;
}
@@ -169,10 +162,10 @@ bool CDisplay::save( const CDisplay::TextType format, const CDisplay::TextPart p
/** Emits the signal which used when a reference was clicked. */
void CDisplay::emitReferenceClicked( const QString& reference ) {
QString module, key;
- CReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(reference, module, key, type);
+ ReferenceManager::Type type;
+ ReferenceManager::decodeHyperlink(reference, module, key, type);
if (module.isEmpty()) {
- module = CReferenceManager::preferredModule( type );
+ module = ReferenceManager::preferredModule( type );
}
m_connections->emitReferenceClicked(module, key);
}
@@ -181,8 +174,8 @@ void CDisplay::emitReferenceClicked( const QString& reference ) {
void CDisplay::emitReferenceDropped( const QString& reference ) {
QString module;
QString key;
- CReferenceManager::Type type;
- CReferenceManager::decodeHyperlink(reference, module, key, type);
+ ReferenceManager::Type type;
+ ReferenceManager::decodeHyperlink(reference, module, key, type);
m_connections->emitReferenceDropped(key);
}
diff --git a/src/frontend/display/cdisplay.h b/src/frontend/display/cdisplay.h
index 0fdaa0e..b84c26e 100644
--- a/src/frontend/display/cdisplay.h
+++ b/src/frontend/display/cdisplay.h
@@ -7,27 +7,21 @@
*
**********/
-
-
#ifndef CDISPLAY_H
#define CDISPLAY_H
-//BibleTime includes
#include "util/cpointers.h"
-#include "backend/managers/cswordbackend.h"
-//Qt includes
#include <QMap>
+#include "backend/managers/cswordbackend.h"
class CDisplayConnections;
-class CReadWindow;
-class CWriteWindow;
-
class CDisplayWindow;
class CReadDisplay;
+class CReadWindow;
class CWriteDisplay;
-
+class CWriteWindow;
class QMenu;
/** The base class for all display widgets.
diff --git a/src/frontend/display/chtmlwritedisplay.cpp b/src/frontend/display/chtmlwritedisplay.cpp
index d238b0d..4d08666 100644
--- a/src/frontend/display/chtmlwritedisplay.cpp
+++ b/src/frontend/display/chtmlwritedisplay.cpp
@@ -7,22 +7,20 @@
*
**********/
+#include "frontend/display/chtmlwritedisplay.h"
-
-#include "chtmlwritedisplay.h"
-#include "btfontsizewidget.h"
-#include "btcolorwidget.h"
-#include "frontend/displaywindow/cwritewindow.h"
-#include "frontend/displaywindow/btactioncollection.h"
-#include "util/cresmgr.h"
-#include "util/directoryutil.h"
-
-#include <QMenu>
-#include <QToolTip>
-#include <QTextEdit>
#include <QFontComboBox>
#include <QMenu>
+#include <QTextEdit>
#include <QToolBar>
+#include <QToolTip>
+#include "frontend/display/btcolorwidget.h"
+#include "frontend/display/btfontsizewidget.h"
+#include "frontend/displaywindow/btactioncollection.h"
+#include "frontend/displaywindow/cwritewindow.h"
+#include "util/cresmgr.h"
+#include "util/directory.h"
+
class BtActionCollection;
@@ -137,6 +135,8 @@ void CHTMLWriteDisplay::slotFontFamilyChoosen(const QFont& font) {
}
void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * actions) {
+ namespace DU = util::directory;
+
//--------------------font chooser-------------------------
m_fontFamilyChooser = new QFontComboBox(this);
actions->addAction(CResMgr::displaywindows::writeWindow::fontFamily::actionName, m_fontFamilyChooser);
@@ -164,7 +164,7 @@ void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * action
//--------------------bold toggle-------------------------
m_actions.bold = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::boldText::icon),
+ DU::getIcon(CResMgr::displaywindows::writeWindow::boldText::icon),
tr("Bold"),
actions);
m_actions.bold->setCheckable(true);
@@ -177,7 +177,7 @@ void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * action
//--------------------italic toggle-------------------------
m_actions.italic = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::italicText::icon),
+ DU::getIcon(CResMgr::displaywindows::writeWindow::italicText::icon),
tr("Italic"),
actions );
m_actions.italic->setCheckable(true);
@@ -189,7 +189,7 @@ void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * action
//--------------------underline toggle-------------------------
m_actions.underline = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::underlinedText::icon),
+ DU::getIcon(CResMgr::displaywindows::writeWindow::underlinedText::icon),
tr("Underline"),
actions );
m_actions.underline->setCheckable(true);
@@ -204,7 +204,7 @@ void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * action
//--------------------align left toggle-------------------------
m_actions.alignLeft = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::alignLeft::icon),
+ DU::getIcon(CResMgr::displaywindows::writeWindow::alignLeft::icon),
tr("Left"), actions);
m_actions.alignLeft->setCheckable(true);
m_actions.alignLeft->setShortcut(CResMgr::displaywindows::writeWindow::alignLeft::accel);
@@ -215,7 +215,7 @@ void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * action
//--------------------align center toggle-------------------------
m_actions.alignCenter = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::alignCenter::icon),
+ DU::getIcon(CResMgr::displaywindows::writeWindow::alignCenter::icon),
tr("Center"), actions);
m_actions.alignCenter->setCheckable(true);
m_actions.alignCenter->setShortcut(CResMgr::displaywindows::writeWindow::alignCenter::accel);
@@ -226,7 +226,7 @@ void CHTMLWriteDisplay::setupToolbar(QToolBar * bar, BtActionCollection * action
//--------------------align right toggle-------------------------
m_actions.alignRight = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::alignRight::icon),
+ DU::getIcon(CResMgr::displaywindows::writeWindow::alignRight::icon),
tr("Right"), actions);
m_actions.alignRight->setCheckable(true);
m_actions.alignRight->setShortcut(CResMgr::displaywindows::writeWindow::alignRight::accel);
diff --git a/src/frontend/display/chtmlwritedisplay.h b/src/frontend/display/chtmlwritedisplay.h
index 5ea7527..56f3f53 100644
--- a/src/frontend/display/chtmlwritedisplay.h
+++ b/src/frontend/display/chtmlwritedisplay.h
@@ -10,18 +10,18 @@
#ifndef CHTMLWRITEDISPLAY_H
#define CHTMLWRITEDISPLAY_H
-//BibleTime includes
-#include "cplainwritedisplay.h"
+#include "frontend/display/cplainwritedisplay.h"
+
+class BtActionCollection;
+class BtColorWidget;
+class BtFontSizeWidget;
class CWriteWindow;
-class QMenu;
-class QWidget;
-class QToolBar;
class QAction;
class QFontComboBox;
-class BtFontSizeWidget;
-class BtColorWidget;
-class BtActionCollection;
+class QMenu;
+class QToolBar;
+class QWidget;
/** The WYSIWYG implementation of the write display interface.
* @author The BibleTime team
diff --git a/src/frontend/display/cplainwritedisplay.cpp b/src/frontend/display/cplainwritedisplay.cpp
index ff70c0a..720aa72 100644
--- a/src/frontend/display/cplainwritedisplay.cpp
+++ b/src/frontend/display/cplainwritedisplay.cpp
@@ -7,21 +7,20 @@
*
**********/
-#include "cplainwritedisplay.h"
-#include "frontend/displaywindow/btactioncollection.h"
-#include "frontend/cdragdrop.h"
-#include "frontend/displaywindow/cdisplaywindow.h"
-#include "frontend/displaywindow/cwritewindow.h"
-
-#include "backend/keys/cswordkey.h"
+#include "frontend/display/cplainwritedisplay.h"
#include <boost/scoped_ptr.hpp>
-
-//Qt includes
#include <QDragEnterEvent>
-#include <QDropEvent>
#include <QDragMoveEvent>
+#include <QDropEvent>
#include <QMenu>
+#include <QDebug>
+
+#include "backend/keys/cswordkey.h"
+#include "frontend/cdragdrop.h"
+#include "frontend/displaywindow/btactioncollection.h"
+#include "frontend/displaywindow/cdisplaywindow.h"
+#include "frontend/displaywindow/cwritewindow.h"
CPlainWriteDisplay::CPlainWriteDisplay(CWriteWindow* parentWindow, QWidget* parent) : QTextEdit(parentWindow ? parentWindow : parent), CWriteDisplay(parentWindow) {
@@ -50,12 +49,12 @@ void CPlainWriteDisplay::setText( const QString& newText ) {
}
bool CPlainWriteDisplay::hasSelection() {
- //TODO: test this
+ /// \todo test this
return textCursor().hasSelection();
}
QWidget* CPlainWriteDisplay::view() {
- qDebug("CPlainWriteDisplay::view()");
+ qDebug() << "CPlainWriteDisplay::view()";
return this;
}
@@ -128,11 +127,11 @@ void CPlainWriteDisplay::dragMoveEvent( QDragMoveEvent* e ) {
/** Reimplementation to manage drops of our drag and drop objects. */
void CPlainWriteDisplay::dropEvent( QDropEvent* e ) {
- //qDebug("CPlainWriteDisplay::dropEvent");
+ //qDebug() << "CPlainWriteDisplay::dropEvent";
const BTMimeData* mimedata = qobject_cast<const BTMimeData*>(e->mimeData());
if ( mimedata && mimedata->hasFormat("BibleTime/Bookmark") ) {
- //qDebug("format was bookmark");
+ //qDebug() << "format was bookmark";
e->acceptProposedAction();
BTMimeData::ItemList items = mimedata->bookmarks();
@@ -151,7 +150,7 @@ void CPlainWriteDisplay::dropEvent( QDropEvent* e ) {
}
}
else if ( e->mimeData()->hasFormat("text/plain")) {
- //qDebug("format was plain text");
+ //qDebug() << "format was plain text";
e->acceptProposedAction();
setTextCursor(cursorForPosition(e->pos()));
textCursor().insertText( e->mimeData()->text() );
diff --git a/src/frontend/display/cplainwritedisplay.h b/src/frontend/display/cplainwritedisplay.h
index 3968f74..30efc72 100644
--- a/src/frontend/display/cplainwritedisplay.h
+++ b/src/frontend/display/cplainwritedisplay.h
@@ -7,26 +7,20 @@
*
**********/
-
-
#ifndef CPLAINWRITEDISPLAY_H
#define CPLAINWRITEDISPLAY_H
-//Bibletime include files
-#include "cwritedisplay.h"
-
-//Qt includes
#include <QTextEdit>
+#include "frontend/display/cwritedisplay.h"
+class BtActionCollection;
class CHTMLWriteDisplay;
-
-class QWidget;
-class QMenu;
+class QDragEnterEvent;
class QDragMoveEvent;
class QDropEvent;
-class QDragEnterEvent;
-class BtActionCollection;
+class QMenu;
+class QWidget;
/** The write display implementation for plain source code editing.
* @author The BibleTime team
diff --git a/src/frontend/display/creaddisplay.cpp b/src/frontend/display/creaddisplay.cpp
index afe00cd..de0680b 100644
--- a/src/frontend/display/creaddisplay.cpp
+++ b/src/frontend/display/creaddisplay.cpp
@@ -7,29 +7,20 @@
*
**********/
+#include "frontend/display/creaddisplay.h"
-
-//BibleTime includes
-#include "creaddisplay.h"
-
-#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/drivers/cswordbiblemoduleinfo.h"
-#include "backend/drivers/cswordlexiconmoduleinfo.h"
#include "backend/drivers/cswordbookmoduleinfo.h"
+#include "backend/drivers/cswordlexiconmoduleinfo.h"
+#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/keys/cswordkey.h"
-#include "backend/keys/cswordversekey.h"
-#include "backend/keys/cswordtreekey.h"
#include "backend/keys/cswordldkey.h"
-
+#include "backend/keys/cswordtreekey.h"
+#include "backend/keys/cswordversekey.h"
+#include "frontend/cexportmanager.h"
#include "frontend/displaywindow/cdisplaywindow.h"
#include "frontend/displaywindow/creadwindow.h"
-#include "frontend/cexportmanager.h"
-
-#include <boost/scoped_ptr.hpp>
-
-//KDE includes
-
CReadDisplay::CReadDisplay(CReadWindow* readWindow) :
CDisplay(readWindow),
diff --git a/src/frontend/display/creaddisplay.h b/src/frontend/display/creaddisplay.h
index c94bd41..57524b5 100644
--- a/src/frontend/display/creaddisplay.h
+++ b/src/frontend/display/creaddisplay.h
@@ -7,20 +7,18 @@
*
**********/
-
-
#ifndef CREADDISPLAY_H
#define CREADDISPLAY_H
-#include "cdisplay.h"
-#include "backend/managers/cswordbackend.h"
+#include "frontend/display/cdisplay.h"
#include <QString>
+#include "backend/managers/cswordbackend.h"
+
-/**The base class for all read-only widgets like KHTMLView.
+/** The base class for all read-only widgets like KHTMLView.
*@author The BibleTime team
*/
-
class CReadDisplay : public CDisplay {
public:
/**
diff --git a/src/frontend/display/cwritedisplay.cpp b/src/frontend/display/cwritedisplay.cpp
index ddd9d8f..f30d217 100644
--- a/src/frontend/display/cwritedisplay.cpp
+++ b/src/frontend/display/cwritedisplay.cpp
@@ -7,15 +7,15 @@
*
**********/
-
-
-//BibleTime includes
-#include "cwritedisplay.h"
+#include "frontend/display/cwritedisplay.h"
#include "frontend/displaywindow/cwritewindow.h"
-CWriteDisplay::CWriteDisplay( CWriteWindow* writeWindow ) : CDisplay(writeWindow) {}
-
-CWriteDisplay::~CWriteDisplay() {}
+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
index 24dd29f..33ef5a5 100644
--- a/src/frontend/display/cwritedisplay.h
+++ b/src/frontend/display/cwritedisplay.h
@@ -7,21 +7,18 @@
*
**********/
-
-
#ifndef CWRITEDISPLAY_H
#define CWRITEDISPLAY_H
-#include "cdisplay.h"
+#include "frontend/display/cdisplay.h"
-class QToolBar;
-class BtActionCollection;
+class BtActionCollection;
+class QToolBar;
-/**The base class for all read/write-display classes.
+/** The base class for all read/write-display classes.
*@author The BibleTime team
*/
-
class CWriteDisplay : public CDisplay {
protected:
friend class CDisplay;
diff --git a/src/frontend/displaywindow/btactioncollection.cpp b/src/frontend/displaywindow/btactioncollection.cpp
index c9d5dd8..f1956d5 100644
--- a/src/frontend/displaywindow/btactioncollection.cpp
+++ b/src/frontend/displaywindow/btactioncollection.cpp
@@ -7,15 +7,17 @@
*
**********/
-#include "util/directoryutil.h"
-#include "backend/config/cbtconfig.h"
-#include "btactioncollection.h"
+#include "frontend/displaywindow/btactioncollection.h"
+
#include <QAction>
+#include <QDebug>
#include <QKeySequence>
#include <QSettings>
#include <QString>
#include <QStringList>
-#include <QDebug>
+#include "backend/config/cbtconfig.h"
+#include "util/directory.h"
+
class BtActionItem : public QObject {
public:
@@ -54,7 +56,7 @@ QAction* BtActionCollection::action(const QString& name) {
QAction* BtActionCollection::addAction(const QString& name, QAction* action) {
Q_ASSERT(action != 0);
- Q_ASSERT(m_actions[name] == 0); // TODO - replacing actions is ok???
+ Q_ASSERT(m_actions[name] == 0); /// \todo replacing actions is ok???
int count;
count = m_actions.count();
BtActionItem* item = new BtActionItem(this);
diff --git a/src/frontend/displaywindow/btactioncollection.h b/src/frontend/displaywindow/btactioncollection.h
index 4dde538..9a02958 100644
--- a/src/frontend/displaywindow/btactioncollection.h
+++ b/src/frontend/displaywindow/btactioncollection.h
@@ -6,18 +6,20 @@
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
+
#ifndef BT_ACTION_COLLECTION_H
#define BT_ACTION_COLLECTION_H
-#include <QMap>
-
#include <QObject>
+
#include <QList>
+#include <QMap>
-class QString;
+
+class BtActionItem;
class QAction;
class QKeySequence;
-class BtActionItem;
+class QString;
class BtActionCollection : public QObject {
Q_OBJECT
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.cpp b/src/frontend/displaywindow/bttoolbarpopupaction.cpp
index 5a7fd8c..49b145e 100644
--- a/src/frontend/displaywindow/bttoolbarpopupaction.cpp
+++ b/src/frontend/displaywindow/bttoolbarpopupaction.cpp
@@ -7,11 +7,13 @@
*
**********/
-#include "bttoolbarpopupaction.h"
-#include <QMenu>
-#include <QToolButton>
+#include "frontend/displaywindow/bttoolbarpopupaction.h"
+
#include <QAction>
#include <QEvent>
+#include <QMenu>
+#include <QToolButton>
+
class BtToolButton : public QToolButton {
public:
diff --git a/src/frontend/displaywindow/bttoolbarpopupaction.h b/src/frontend/displaywindow/bttoolbarpopupaction.h
index 06eb660..202a006 100644
--- a/src/frontend/displaywindow/bttoolbarpopupaction.h
+++ b/src/frontend/displaywindow/bttoolbarpopupaction.h
@@ -6,14 +6,16 @@
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
+
#ifndef BT_TOOLBAR_POPUP_ACTION_H
#define BT_TOOLBAR_POPUP_ACTION_H
#include <QWidgetAction>
+
+class QIcon;
class QMenu;
class QString;
-class QIcon;
class QToolButton;
// This class manages the toolbar display for going forward and backward in history.
diff --git a/src/frontend/displaywindow/cbiblereadwindow.cpp b/src/frontend/displaywindow/cbiblereadwindow.cpp
index 2da6360..7b346f7 100644
--- a/src/frontend/displaywindow/cbiblereadwindow.cpp
+++ b/src/frontend/displaywindow/cbiblereadwindow.cpp
@@ -7,41 +7,39 @@
*
**********/
+#include "frontend/displaywindow/cbiblereadwindow.h"
-#include "cbiblereadwindow.h"
-#include "btactioncollection.h"
-#include "ccommentaryreadwindow.h"
-#include "cbuttons.h"
-#include "backend/keys/cswordversekey.h"
+#include <cmath>
+#include <QAction>
+#include <QApplication>
+#include <QEvent>
+#include <QMdiSubWindow>
+#include <QMenu>
+#include <QTimer>
+#include <QWidget>
+#include <QDebug>
+
+#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordbiblemoduleinfo.h"
-#include "frontend/profile/cprofilewindow.h"
+#include "backend/keys/cswordversekey.h"
#include "frontend/cexportmanager.h"
-#include "backend/config/cbtconfig.h"
#include "frontend/cmdiarea.h"
#include "frontend/display/creaddisplay.h"
+#include "frontend/displaywindow/btactioncollection.h"
+#include "frontend/displaywindow/ccommentaryreadwindow.h"
+#include "frontend/displaywindow/cbuttons.h"
#include "frontend/keychooser/ckeychooser.h"
-#include "util/ctoolclass.h"
+#include "frontend/profile/cprofilewindow.h"
+#include "util/directory.h"
#include "util/cresmgr.h"
-#include "util/directoryutil.h"
-
-#include <math.h>
+#include "util/tool.h"
-//Qt includes
-#include <QWidget>
-#include <QTimer>
-#include <QEvent>
-#include <QApplication>
-#include <QMenu>
-#include <QMdiSubWindow>
-#include <QAction>
-#include <QMenu>
-#include <QMenu>
using namespace Profile;
CBibleReadWindow::CBibleReadWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea* parent)
: CLexiconReadWindow(moduleList, parent) {
- qDebug("CBibleReadWindow::CBibleReadWindow");
+ qDebug() << "CBibleReadWindow::CBibleReadWindow";
}
CBibleReadWindow::~CBibleReadWindow() {
@@ -135,11 +133,14 @@ void CBibleReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
a->addAction( "copyReferenceWithText", qaction);
qaction = new QAction(tr("Reference with text"), a);
+ a->addAction("printReferenceWithText", qaction);
+
+ qaction = new QAction(tr("Reference with text"), a);
a->addAction("saveReferenceWithText", qaction);
}
void CBibleReadWindow::initActions() {
- qDebug("CBibleReadWindow::initActions");
+ qDebug() << "CBibleReadWindow::initActions";
BtActionCollection* ac = actionCollection();
@@ -214,7 +215,7 @@ void CBibleReadWindow::initActions() {
QObject::connect(m_actions.save.chapterAsHTML, SIGNAL(triggered()), this, SLOT(saveChapterHTML()) );
addAction(m_actions.save.chapterAsHTML);
- m_actions.print.reference = m_actionCollection->action("saveReferenceWithText");
+ m_actions.print.reference = m_actionCollection->action("printReferenceWithText");
QObject::connect(m_actions.print.reference, SIGNAL(triggered()), this, SLOT(printAnchorWithText()) );
addAction(m_actions.print.reference);
@@ -242,7 +243,7 @@ void CBibleReadWindow::initView() {
/** Reimplementation. */
void CBibleReadWindow::setupPopupMenu() {
popup()->setTitle(tr("Bible window"));
- popup()->setIcon(CToolClass::getIconForModule(modules().first()) );
+ popup()->setIcon(util::tool::getIconForModule(modules().first()) );
popup()->addAction(m_actions.findText);
QKeySequence ks = m_actions.findText->shortcut();
QString keys = ks.toString();
diff --git a/src/frontend/displaywindow/cbiblereadwindow.h b/src/frontend/displaywindow/cbiblereadwindow.h
index 3b779e2..11f0275 100644
--- a/src/frontend/displaywindow/cbiblereadwindow.h
+++ b/src/frontend/displaywindow/cbiblereadwindow.h
@@ -7,33 +7,24 @@
*
**********/
-
-
#ifndef CBIBLEREADWINDOW_H
#define CBIBLEREADWINDOW_H
-//BibleTime includes
-#include "clexiconreadwindow.h"
+#include "frontend/displaywindow/clexiconreadwindow.h"
-
-class CTransliterationButton;
+class BtActionCollection;
class CSwordKey;
class CSwordVerseKey;
-
-class BtActionCollection;
+class CTransliterationButton;
class QAction;
+class QEvent;
class QMenu;
-
class QObject;
-class QEvent;
-
-
-/**The read display window for Bibles.
+/** The read display window for Bibles.
*@author The BibleTime team
*/
-
class CBibleReadWindow : public CLexiconReadWindow {
Q_OBJECT
public:
diff --git a/src/frontend/displaywindow/cbookreadwindow.cpp b/src/frontend/displaywindow/cbookreadwindow.cpp
index 1865a98..d852eb3 100644
--- a/src/frontend/displaywindow/cbookreadwindow.cpp
+++ b/src/frontend/displaywindow/cbookreadwindow.cpp
@@ -7,23 +7,24 @@
*
**********/
-#include "cbookreadwindow.h"
-#include "bttoolbarpopupaction.h"
-#include "btactioncollection.h"
-#include "cmodulechooserbar.h"
-#include "cbuttons.h"
+#include "frontend/displaywindow/cbookreadwindow.h"
+
+#include <QAction>
+#include <QMenu>
+#include <QSplitter>
+#include <QToolBar>
+#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordtreekey.h"
#include "frontend/display/cdisplay.h"
+#include "frontend/displaywindow/bttoolbarpopupaction.h"
+#include "frontend/displaywindow/btactioncollection.h"
+#include "frontend/displaywindow/cmodulechooserbar.h"
+#include "frontend/displaywindow/cbuttons.h"
#include "frontend/keychooser/cbooktreechooser.h"
#include "frontend/profile/cprofilewindow.h"
-#include "backend/config/cbtconfig.h"
-#include "util/ctoolclass.h"
#include "util/cresmgr.h"
+#include "util/tool.h"
-#include <QSplitter>
-#include <QToolBar>
-#include <QMenu>
-#include <QAction>
using namespace Profile;
@@ -114,7 +115,7 @@ void CBookReadWindow::initView() {
m_treeChooser->hide();
setCentralWidget( splitter );
- setWindowIcon(CToolClass::getIconForModule(modules().first()));
+ setWindowIcon(util::tool::getIconForModule(modules().first()));
}
void CBookReadWindow::initToolbars() {
diff --git a/src/frontend/displaywindow/cbookreadwindow.h b/src/frontend/displaywindow/cbookreadwindow.h
index 62d788d..b059aff 100644
--- a/src/frontend/displaywindow/cbookreadwindow.h
+++ b/src/frontend/displaywindow/cbookreadwindow.h
@@ -7,19 +7,15 @@
*
**********/
-
-
#ifndef CBOOKREADWINDOW_H
#define CBOOKREADWINDOW_H
-//BibleTime includes
-#include "clexiconreadwindow.h"
+#include "frontend/displaywindow/clexiconreadwindow.h"
-class QAction;
-class CBookTreeChooser;
class BtActionCollection;
-
+class CBookTreeChooser;
+class QAction;
/**
* @author The BibleTime team
diff --git a/src/frontend/displaywindow/cbuttons.cpp b/src/frontend/displaywindow/cbuttons.cpp
index fbe2443..46c262a 100644
--- a/src/frontend/displaywindow/cbuttons.cpp
+++ b/src/frontend/displaywindow/cbuttons.cpp
@@ -7,29 +7,24 @@
*
**********/
-//BibleTime includes
-#include "cbuttons.h"
+#include "frontend/displaywindow/cbuttons.h"
-#include "util/cresmgr.h"
-#include "util/cpointers.h"
-#include "util/directoryutil.h"
-
-//Qt includes
+#include <QHash>
+#include <QMenu>
#include <QString>
#include <QToolTip>
#include <QToolButton>
-#include <QHash>
-#include <QMenu>
-
-//KDE includes
-
-
+#include "util/directory.h"
+#include "util/cpointers.h"
+#include "util/cresmgr.h"
CDisplaySettingsButton::CDisplaySettingsButton(CSwordBackend::DisplayOptions *displaySettings, CSwordBackend::FilterOptions *moduleSettings, const QList<CSwordModuleInfo*>& useModules, QWidget *parent )
: QToolButton(parent) {
+ namespace DU = util::directory;
+
// qWarning("CDisplaySettingsButton::CDisplaySettingsButton");
- QToolButton::setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::displaySettings::icon));
+ QToolButton::setIcon(DU::getIcon(CResMgr::displaywindows::displaySettings::icon));
m_displaySettings = displaySettings;
m_moduleSettings = moduleSettings;
@@ -60,7 +55,6 @@ void CDisplaySettingsButton::reset(const QList<CSwordModuleInfo*>& useModules) {
void CDisplaySettingsButton::optionToggled(QAction* /*action*/) {
- qDebug("display settings option toggled");
//Take each Action and set the corresponding setting.
//Using QAction (QObject) property and OptionType enum is a dirty way to do this.
//See populateMenu().
@@ -187,5 +181,5 @@ bool CDisplaySettingsButton::itemStatus( const int index ) {
/** Sets the status to changed. The signal changed will be emitted. */
void CDisplaySettingsButton::setChanged() {
- emit sigChanged();
+ optionToggled(0);
}
diff --git a/src/frontend/displaywindow/cbuttons.h b/src/frontend/displaywindow/cbuttons.h
index 5f1d599..39dbbf9 100644
--- a/src/frontend/displaywindow/cbuttons.h
+++ b/src/frontend/displaywindow/cbuttons.h
@@ -7,19 +7,16 @@
*
**********/
-
-
#ifndef CBUTTONS_H
#define CBUTTONS_H
-//BibleTime includes
-#include "backend/managers/cswordbackend.h"
-class CSwordModuleInfo;
+#include <QToolButton>
-//QT includes
#include <QHash>
-#include <QToolButton>
+#include "backend/managers/cswordbackend.h"
+
+class CSwordModuleInfo;
class QMenu;
/** This class manages the display options of the selected modules.
diff --git a/src/frontend/displaywindow/ccommentaryreadwindow.cpp b/src/frontend/displaywindow/ccommentaryreadwindow.cpp
index fdd345e..4b4d3c2 100644
--- a/src/frontend/displaywindow/ccommentaryreadwindow.cpp
+++ b/src/frontend/displaywindow/ccommentaryreadwindow.cpp
@@ -7,23 +7,21 @@
*
**********/
-//BibleTime includes
-#include "ccommentaryreadwindow.h"
-#include "btactioncollection.h"
-#include "frontend/profile/cprofilewindow.h"
-#include "backend/config/cbtconfig.h"
-#include "frontend/keychooser/ckeychooser.h"
-#include "frontend/display/cdisplay.h"
-#include "frontend/display/creaddisplay.h"
-#include "backend/keys/cswordversekey.h"
-#include "util/ctoolclass.h"
-#include "util/cresmgr.h"
-#include "util/directoryutil.h"
+#include "frontend/displaywindow/ccommentaryreadwindow.h"
-#include <QMenu>
#include <QAction>
#include <QIcon>
+#include <QMenu>
#include <QToolBar>
+#include "backend/config/cbtconfig.h"
+#include "backend/keys/cswordversekey.h"
+#include "frontend/display/cdisplay.h"
+#include "frontend/display/creaddisplay.h"
+#include "frontend/displaywindow/btactioncollection.h"
+#include "frontend/keychooser/ckeychooser.h"
+#include "frontend/profile/cprofilewindow.h"
+#include "util/directory.h"
+#include "util/cresmgr.h"
using namespace Profile;
@@ -109,10 +107,12 @@ void CCommentaryReadWindow::storeProfileSettings( CProfileWindow* profileWindow
}
void CCommentaryReadWindow::initToolbars() {
+ namespace DU = util::directory;
+
CLexiconReadWindow::initToolbars();
m_syncButton = new QAction(
- QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon)),
+ QIcon(DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon)),
tr("Synchronize"),
actionCollection()
);
diff --git a/src/frontend/displaywindow/ccommentaryreadwindow.h b/src/frontend/displaywindow/ccommentaryreadwindow.h
index 21f4630..d75da67 100644
--- a/src/frontend/displaywindow/ccommentaryreadwindow.h
+++ b/src/frontend/displaywindow/ccommentaryreadwindow.h
@@ -7,21 +7,19 @@
*
**********/
-
#ifndef CCOMMENTARYREADWINDOW_H
#define CCOMMENTARYREADWINDOW_H
-//BibleTime includes
-#include "cbiblereadwindow.h"
+#include "frontend/displaywindow/cbiblereadwindow.h"
+
-class QAction;
-class CSwordVerseKey;
class BtActionCollection;
+class CSwordVerseKey;
+class QAction;
/**
*@author The BibleTime team
*/
-
class CCommentaryReadWindow : public CLexiconReadWindow {
Q_OBJECT
public:
diff --git a/src/frontend/displaywindow/cdisplaywindow.cpp b/src/frontend/displaywindow/cdisplaywindow.cpp
index 394e96b..4ba567a 100644
--- a/src/frontend/displaywindow/cdisplaywindow.cpp
+++ b/src/frontend/displaywindow/cdisplaywindow.cpp
@@ -7,27 +7,29 @@
*
**********/
-#include "cdisplaywindow.h"
-#include "bttoolbarpopupaction.h"
-#include "btactioncollection.h"
-#include "cmodulechooserbar.h"
-#include "cbuttons.h"
+#include "frontend/displaywindow/cdisplaywindow.h"
+
+#include <QCloseEvent>
+#include <QDebug>
+#include <QMenu>
+#include <QStringList>
+#include <QWidget>
+#include "backend/config/cbtconfig.h"
#include "backend/keys/cswordkey.h"
+#include "bibletime.h"
+#include "frontend/cmdiarea.h"
+#include "frontend/display/cdisplay.h"
+#include "frontend/displaywindow/bttoolbarpopupaction.h"
+#include "frontend/displaywindow/btactioncollection.h"
+#include "frontend/displaywindow/cmodulechooserbar.h"
+#include "frontend/displaywindow/cbuttons.h"
#include "frontend/keychooser/ckeychooser.h"
#include "frontend/keychooser/bthistory.h"
-#include "frontend/display/cdisplay.h"
-#include "frontend/cmdiarea.h"
#include "frontend/profile/cprofilewindow.h"
-#include "backend/config/cbtconfig.h"
#include "frontend/searchdialog/csearchdialog.h"
+#include "util/directory.h"
#include "util/cresmgr.h"
-#include "util/directoryutil.h"
-#include <QWidget>
-#include <QCloseEvent>
-#include <QStringList>
-#include <QDebug>
-#include <QMenu>
using namespace Profile;
@@ -44,7 +46,7 @@ CDisplayWindow::CDisplayWindow(QList<CSwordModuleInfo*> modules, CMDIArea *paren
m_mainToolBar(0),
m_popupMenu(0),
m_displayWidget(0) {
- qDebug("CDisplayWindow::CDisplayWindow");
+ qDebug() << "CDisplayWindow::CDisplayWindow";
setAttribute(Qt::WA_DeleteOnClose); //we want to destroy this window when it is closed
parent->addSubWindow(this);
m_actionCollection = new BtActionCollection(this);
@@ -86,13 +88,9 @@ QList<CSwordModuleInfo*> CDisplayWindow::modules() {
return mods;
}
-/** Set the window caption. */
-void CDisplayWindow::setCaption( const QString& ) {
- QWidget::setWindowTitle( windowCaption() );
- m_mdi->emitWindowCaptionChanged();
-}
-
void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
+ namespace DU = util::directory;
+
qDebug() << "CDisplayWindow::insertKeyboardActions: ac: " << a;
QAction* actn = new QAction(QIcon(), tr("Zoom in"), a);
@@ -123,13 +121,13 @@ void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
actn->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
a->addAction("openLocation", actn);
- actn = new QAction(QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::search::icon)),
+ actn = new QAction(QIcon(DU::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(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::backInHistory::icon)),
+ QIcon(DU::getIcon(CResMgr::displaywindows::general::backInHistory::icon)),
tr("Back in history"),
a
);
@@ -137,7 +135,7 @@ void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
a->addAction(CResMgr::displaywindows::general::backInHistory::actionName, action);
action = new BtToolBarPopupAction(
- QIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::general::forwardInHistory::icon)),
+ QIcon(DU::getIcon(CResMgr::displaywindows::general::forwardInHistory::icon)),
tr("Forward in history"),
a
);
@@ -146,7 +144,7 @@ void CDisplayWindow::insertKeyboardActions( BtActionCollection* a ) {
}
void CDisplayWindow::initActions() {
- qDebug("CDisplayWindow::initActions");
+ qDebug() << "CDisplayWindow::initActions";
BtActionCollection* ac = actionCollection();
@@ -320,7 +318,7 @@ void CDisplayWindow::setModuleChooserBar( CModuleChooserBar* bar ) {
/** Sets the modules. */
void CDisplayWindow::setModules( const QList<CSwordModuleInfo*>& newModules ) {
- qDebug("CDisplayWindow::setModules");
+ qDebug() << "CDisplayWindow::setModules";
m_modules.clear();
foreach (CSwordModuleInfo* mod, newModules) {
@@ -330,11 +328,11 @@ void CDisplayWindow::setModules( const QList<CSwordModuleInfo*>& newModules ) {
/** Initialize the window. Call this method from the outside, because calling this in the constructor is not possible! */
bool CDisplayWindow::init() {
- qDebug("CDisplayWindow::init");
+ qDebug() << "CDisplayWindow::init";
initView();
setMinimumSize( 100, 100 );
- setCaption(windowCaption());
+ setWindowTitle(windowCaption());
//setup focus stuff.
setFocusPolicy(Qt::ClickFocus);
parentWidget()->setFocusPolicy(Qt::ClickFocus);
@@ -403,7 +401,7 @@ void CDisplayWindow::lookupModKey( const QString& moduleName, const QString& key
return;
}
- //ToDo: check for containsRef compat
+ /// \todo check for containsRef compat
if (m && modules().contains(m)) {
key()->key(keyName);
keyChooser()->setKey(key()); //the key chooser does send an update signal
@@ -413,7 +411,10 @@ void CDisplayWindow::lookupModKey( const QString& moduleName, const QString& key
//create a new window for the given module
QList<CSwordModuleInfo*> mList;
mList.append(m);
- mdi()->emitCreateDisplayWindow(mList, keyName);
+
+ Q_ASSERT(qobject_cast<BibleTime*>(mdi()->parent()) != 0);
+ BibleTime *mainWindow(static_cast<BibleTime*>(mdi()->parent()));
+ mainWindow->createReadDisplayWindow(mList, keyName);
}
}
diff --git a/src/frontend/displaywindow/cdisplaywindow.h b/src/frontend/displaywindow/cdisplaywindow.h
index 5a32f9f..6164e94 100644
--- a/src/frontend/displaywindow/cdisplaywindow.h
+++ b/src/frontend/displaywindow/cdisplaywindow.h
@@ -10,35 +10,30 @@
#ifndef CDISPLAYWINDOW_H
#define CDISPLAYWINDOW_H
-//BibleTime includes
+#include <QMainWindow>
#include "util/cpointers.h"
-class CSwordModuleInfo;
+
+#include <QStringList>
#include "backend/managers/cswordbackend.h"
#include "frontend/profile/cprofilewindow.h"
-//Qt includes
-#include <QStringList>
-#include <QMainWindow>
-//Forward declarations
-class CMDIArea;
-class CReadWindow;
-class CWriteWindow;
-class CDisplaySettingsButton;
+class BtActionCollection;
class CDisplay;
+class CDisplaySettingsButton;
class CKeyChooser;
+class CMDIArea;
class CModuleChooserBar;
-class QCloseEvent;
-
-class QToolBar;
+class CReadWindow;
+class CSwordModuleInfo;
+class CWriteWindow;
class QCloseEvent;
class QMenu;
-class BtActionCollection;
+class QToolBar;
/** The base class for all display windows of BibleTime.
* @author The BibleTime team
*/
-
class CDisplayWindow : public QMainWindow, public CPointers {
Q_OBJECT
public:
@@ -64,9 +59,6 @@ class CDisplayWindow : public QMainWindow, public CPointers {
// Store the settings of this window in the given profile window.
virtual void applyProfileSettings( Profile::CProfileWindow* profileWindow ) = 0;
- // Set the window caption.
- virtual void setCaption( const QString& );
-
// Sets the new filter options of this window.
void setFilterOptions( CSwordBackend::FilterOptions& filterOptions );
diff --git a/src/frontend/displaywindow/cdisplaywindowfactory.cpp b/src/frontend/displaywindow/cdisplaywindowfactory.cpp
index 6581ffd..05fa963 100644
--- a/src/frontend/displaywindow/cdisplaywindowfactory.cpp
+++ b/src/frontend/displaywindow/cdisplaywindowfactory.cpp
@@ -1,32 +1,30 @@
-//
-// C++ Implementation: cdisplaywindowfactory
-//
-// Description:
-//
-//
-// Author: The BibleTime team <info@bibletime.info>, (C) 2007
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
-#include "cdisplaywindowfactory.h"
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
-#include "creadwindow.h"
-#include "cbiblereadwindow.h"
-#include "ccommentaryreadwindow.h"
-#include "clexiconreadwindow.h"
-#include "cbookreadwindow.h"
-#include "cwritewindow.h"
-#include "cplainwritewindow.h"
-#include "chtmlwritewindow.h"
+#include "frontend/displaywindow/cdisplaywindowfactory.h"
+#include <QDebug>
#include "backend/drivers/cswordmoduleinfo.h"
+#include "frontend/displaywindow/cbiblereadwindow.h"
+#include "frontend/displaywindow/cbookreadwindow.h"
+#include "frontend/displaywindow/ccommentaryreadwindow.h"
+#include "frontend/displaywindow/chtmlwritewindow.h"
+#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) {
- qDebug("CDisplayWindowFactory::createReadInstance");
+ qDebug() << "CDisplayWindowFactory::createReadInstance";
switch (modules.first()->type()) {
case CSwordModuleInfo::Bible:
return new CBibleReadWindow(modules, parent);
@@ -43,7 +41,6 @@ CReadWindow* CDisplayWindowFactory::createReadInstance(QList<CSwordModuleInfo*>
return 0;
}
-
CWriteWindow* CDisplayWindowFactory::createWriteInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent, const CDisplayWindow::WriteWindowType type) {
if (type == CDisplayWindow::HTMLWindow) {
return new CHTMLWriteWindow(modules, parent);
diff --git a/src/frontend/displaywindow/cdisplaywindowfactory.h b/src/frontend/displaywindow/cdisplaywindowfactory.h
index d8bf2a9..b4d856a 100644
--- a/src/frontend/displaywindow/cdisplaywindowfactory.h
+++ b/src/frontend/displaywindow/cdisplaywindowfactory.h
@@ -1,26 +1,24 @@
-//
-// C++ Interface: cdisplaywindowfactory
-//
-// Description:
-//
-//
-// Author: The BibleTime team <info@bibletime.info>, (C) 2007
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+
#ifndef CDISPLAYWINDOWFACTORY_H
#define CDISPLAYWINDOWFACTORY_H
-#include "cdisplaywindow.h"
-
-class CSwordModuleInfo;
+#include "frontend/displaywindow/cdisplaywindow.h"
+class CMDIArea;
class CReadWindow;
+class CSwordModuleInfo;
class CWriteWindow;
-class CMDIArea;
+/// \todo Make CDisplayWindowFactory a namespace instead?
class CDisplayWindowFactory {
public:
static CReadWindow* createReadInstance(QList<CSwordModuleInfo*> modules, CMDIArea* parent);
diff --git a/src/frontend/displaywindow/chtmlwritewindow.cpp b/src/frontend/displaywindow/chtmlwritewindow.cpp
index df4018e..31cb92b 100644
--- a/src/frontend/displaywindow/chtmlwritewindow.cpp
+++ b/src/frontend/displaywindow/chtmlwritewindow.cpp
@@ -7,26 +7,20 @@
*
**********/
+#include "frontend/displaywindow/chtmlwritewindow.h"
-
-#include "chtmlwritewindow.h"
-#include "btactioncollection.h"
-
-//frontend includes
+#include <QAction>
+#include <QToolBar>
+#include "backend/keys/cswordkey.h"
+#include "frontend/display/chtmlwritedisplay.h"
+#include "frontend/display/cwritedisplay.h"
+#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/keychooser/ckeychooser.h"
#include "frontend/profile/cprofilewindow.h"
-#include "frontend/display/cwritedisplay.h"
-#include "frontend/display/chtmlwritedisplay.h"
-
-#include "backend/keys/cswordkey.h"
-
+#include "util/directory.h"
+#include "util/dialogutil.h"
#include "util/cresmgr.h"
-#include "util/directoryutil.h"
-//Qt includes
-#include <QToolBar>
-#include <QMessageBox>
-#include <QAction>
using namespace Profile;
@@ -58,9 +52,11 @@ void CHTMLWriteWindow::initConnections() {
}
void CHTMLWriteWindow::initToolbars() {
+ namespace DU = util::directory;
+
//setup the main toolbar
m_actions.syncWindow = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
+ DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
tr("Sync with active Bible"),
actionCollection()
);
@@ -71,7 +67,7 @@ void CHTMLWriteWindow::initToolbars() {
mainToolBar()->addAction(m_actions.syncWindow);
m_actions.saveText = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
+ DU::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
tr("Save text"),
actionCollection()
);
@@ -83,7 +79,7 @@ void CHTMLWriteWindow::initToolbars() {
m_actions.deleteEntry = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
+ DU::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
tr("Delete current entry"),
actionCollection()
);
@@ -94,7 +90,7 @@ void CHTMLWriteWindow::initToolbars() {
mainToolBar()->addAction(m_actions.deleteEntry);
m_actions.restoreText = new QAction(
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
+ DU::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
tr("Restore original text"),
actionCollection()
);
@@ -159,9 +155,9 @@ void CHTMLWriteWindow::saveCurrentText( const QString& /*key*/ ) {
textChanged();
}
else {
- QMessageBox::critical( 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.") ) );
+ util::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.") ) );
}
}
diff --git a/src/frontend/displaywindow/chtmlwritewindow.h b/src/frontend/displaywindow/chtmlwritewindow.h
index 452a362..4d140cf 100644
--- a/src/frontend/displaywindow/chtmlwritewindow.h
+++ b/src/frontend/displaywindow/chtmlwritewindow.h
@@ -7,16 +7,13 @@
*
**********/
-
-
#ifndef CHTMLWRITEWINDOW_H
#define CHTMLWRITEWINDOW_H
-//BibleTime includes
-#include "cplainwritewindow.h"
+#include "frontend/displaywindow/cplainwritewindow.h"
-class QAction;
+class QAction;
/** The WYSIWYG implementation of the editor.
* @author The BibleTime team
@@ -38,7 +35,7 @@ class CHTMLWriteWindow : public CPlainWriteWindow {
virtual bool syncAllowed() const;
- protected: // Protected methods
+ protected:
/**
* Initialize the state of this widget.
*/
@@ -47,7 +44,7 @@ class CHTMLWriteWindow : public CPlainWriteWindow {
virtual void initToolbars();
virtual CDisplayWindow::WriteWindowType writeWindowType() {
return CDisplayWindow::HTMLWindow;
- };
+ }
protected slots:
/**
diff --git a/src/frontend/displaywindow/clexiconreadwindow.cpp b/src/frontend/displaywindow/clexiconreadwindow.cpp
index d06578e..2a5fb40 100644
--- a/src/frontend/displaywindow/clexiconreadwindow.cpp
+++ b/src/frontend/displaywindow/clexiconreadwindow.cpp
@@ -7,34 +7,36 @@
*
**********/
-//BibleTime includes
-#include "clexiconreadwindow.h"
-#include "btactioncollection.h"
-#include "cmodulechooserbar.h"
-#include "cbuttons.h"
-#include "bttoolbarpopupaction.h"
-#include "backend/keys/cswordkey.h"
-#include "backend/keys/cswordldkey.h"
+#include "frontend/displaywindow/clexiconreadwindow.h"
+
+#include <QAction>
+#include <QApplication>
+#include <QFile>
+#include <QFileDialog>
+#include <QMenu>
+#include <QDebug>
+
#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/display/bthtmlreaddisplay.h"
-#include "frontend/keychooser/ckeychooser.h"
+#include "frontend/displaywindow/btactioncollection.h"
+#include "frontend/displaywindow/bttoolbarpopupaction.h"
+#include "frontend/displaywindow/cbuttons.h"
+#include "frontend/displaywindow/cmodulechooserbar.h"
#include "frontend/keychooser/bthistory.h"
-#include "util/ctoolclass.h"
+#include "frontend/keychooser/ckeychooser.h"
+#include "util/directory.h"
#include "util/cresmgr.h"
-#include "util/directoryutil.h"
+#include "util/tool.h"
-#include <QMenu>
-#include <QApplication>
-#include <QFile>
-#include <QFileDialog>
-#include <QAction>
CLexiconReadWindow::CLexiconReadWindow(QList<CSwordModuleInfo*> moduleList, CMDIArea* parent)
: CReadWindow(moduleList, parent) {
- qDebug("CLexiconReadWindow::CLexiconReadWindow");
+ qDebug() << "CLexiconReadWindow::CLexiconReadWindow";
moduleList.first();
setKey( CSwordKey::createInstance(moduleList.first()) );
}
@@ -43,7 +45,7 @@ CLexiconReadWindow::~CLexiconReadWindow() {
}
void CLexiconReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
- qDebug("CLexiconReadWindow::insertKeyboardActions");
+ qDebug() << "CLexiconReadWindow::insertKeyboardActions";
QAction* qaction;
qaction = new QAction( tr("Next entry"), a);
qaction->setShortcut(CResMgr::displaywindows::lexiconWindow::nextEntry::accel);
@@ -77,7 +79,7 @@ void CLexiconReadWindow::insertKeyboardActions( BtActionCollection* const a ) {
}
void CLexiconReadWindow::initActions() {
- qDebug("CLexiconReadWindow::initActions");
+ qDebug() << "CLexiconReadWindow::initActions";
BtActionCollection* ac = actionCollection();
CReadWindow::initActions();
@@ -141,13 +143,13 @@ void CLexiconReadWindow::initActions() {
addAction(m_actions.print.entry);
// init with the user defined settings
- qDebug("call CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac); and end CLexiconReadWindow::initActions");
+ qDebug() << "call CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac); and end CLexiconReadWindow::initActions";
CBTConfig::setupAccelSettings(CBTConfig::lexiconWindow, ac);
}
/** No descriptions */
void CLexiconReadWindow::initConnections() {
- qDebug("CLexiconReadWindow::initConnections");
+ qDebug() << "CLexiconReadWindow::initConnections";
Q_ASSERT(keyChooser());
connect(keyChooser(), SIGNAL(keyChanged(CSwordKey*)), this, SLOT(lookupSwordKey(CSwordKey*)));
@@ -178,7 +180,7 @@ void CLexiconReadWindow::initConnections() {
}
void CLexiconReadWindow::initView() {
- qDebug("CLexiconReadWindow::initView");
+ qDebug() << "CLexiconReadWindow::initView";
setDisplayWidget( CDisplay::createReadInstance(this) );
setMainToolBar( new QToolBar(this) );
mainToolBar()->setAllowedAreas(Qt::TopToolBarArea);
@@ -193,7 +195,7 @@ void CLexiconReadWindow::initView() {
buttonsToolBar()->setAllowedAreas(Qt::TopToolBarArea);
buttonsToolBar()->setFloatable(false);
addToolBar(buttonsToolBar());
- setWindowIcon(CToolClass::getIconForModule(modules().first()));
+ setWindowIcon(util::tool::getIconForModule(modules().first()));
setCentralWidget( displayWidget()->view() );
}
@@ -212,13 +214,13 @@ void CLexiconReadWindow::initToolbars() {
}
setDisplaySettingsButton( new CDisplaySettingsButton( &displayOptions(), &filterOptions(), modules(), buttonsToolBar()) );
- //TODO: find the right place for the button
+ /// \todo find the right place for the button
buttonsToolBar()->addWidget(displaySettingsButton());
}
void CLexiconReadWindow::setupPopupMenu() {
popup()->setTitle(tr("Lexicon window"));
- popup()->setIcon(CToolClass::getIconForModule(modules().first()));
+ popup()->setIcon(util::tool::getIconForModule(modules().first()));
popup()->addAction(m_actions.findText);
popup()->addAction(m_actions.findStrongs);
popup()->addAction(m_actions.selectAll);
@@ -298,14 +300,14 @@ void CLexiconReadWindow::saveAsHTML() {
/** Saving the raw HTML for debugging purposes */
void CLexiconReadWindow::saveRawHTML() {
- //qDebug("CLexiconReadWindow::saveRawHTML");
+ //qDebug() << "CLexiconReadWindow::saveRawHTML";
QString savefilename = QFileDialog::getSaveFileName();
if (savefilename.isEmpty()) return;
QFile file(savefilename);
BtHtmlReadDisplay* disp = dynamic_cast<BtHtmlReadDisplay*>(displayWidget());
if (disp) {
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
- qDebug("could not open file");
+ qDebug() << "could not open file";
return;
}
QString source = disp->text();
@@ -315,7 +317,7 @@ void CLexiconReadWindow::saveRawHTML() {
file.flush();
}
else {
- qDebug("No htmlreaddisplay widget!");
+ qDebug() << "No htmlreaddisplay widget!";
}
}
@@ -327,12 +329,12 @@ void CLexiconReadWindow::saveAsPlain() {
}
void CLexiconReadWindow::slotFillBackHistory() {
- qDebug("CLexiconReadWindow::slotFillBackHistory");
+ qDebug() << "CLexiconReadWindow::slotFillBackHistory";
QMenu* menu = m_actions.backInHistory->popupMenu();
menu->clear();
- //TODO: take the history list and fill the menu
+ /// \todo take the history list and fill the menu
QListIterator<QAction*> it(keyChooser()->history()->getBackList());
while (it.hasNext()) {
menu->addAction(it.next());
@@ -340,11 +342,11 @@ void CLexiconReadWindow::slotFillBackHistory() {
}
void CLexiconReadWindow::slotFillForwardHistory() {
- qDebug("CLexiconReadWindow::slotFillForwardHistory");
+ qDebug() << "CLexiconReadWindow::slotFillForwardHistory";
QMenu* menu = m_actions.forwardInHistory->popupMenu();
menu->clear();
- //TODO: take the history list and fill the menu using addAction
+ /// \todo take the history list and fill the menu using addAction
QListIterator<QAction*> it(keyChooser()->history()->getFwList());
while (it.hasNext()) {
menu->addAction(it.next());
@@ -353,7 +355,7 @@ void CLexiconReadWindow::slotFillForwardHistory() {
void CLexiconReadWindow::slotUpdateHistoryButtons(bool backEnabled, bool fwEnabled) {
- qDebug("CLexiconReadWindow::slotUpdateHistoryButtons");
+ qDebug() << "CLexiconReadWindow::slotUpdateHistoryButtons";
Q_ASSERT(m_actions.backInHistory);
Q_ASSERT(keyChooser());
diff --git a/src/frontend/displaywindow/clexiconreadwindow.h b/src/frontend/displaywindow/clexiconreadwindow.h
index ee28c25..2a32cec 100644
--- a/src/frontend/displaywindow/clexiconreadwindow.h
+++ b/src/frontend/displaywindow/clexiconreadwindow.h
@@ -7,24 +7,24 @@
*
**********/
-
#ifndef CLEXICONREADWINDOW_H
#define CLEXICONREADWINDOW_H
-//BibleTime includes
-#include "creadwindow.h"
+#include "frontend/displaywindow/creadwindow.h"
+
#include "frontend/keychooser/ckeychooser.h"
+
+
+class BtActionCollection;
class BtToolBarPopupAction;
-class CSwordKey;
class CSwordLDKey;
-class BtActionCollection;
+class CSwordKey;
class QAction;
class QMenu;
/**
*@author The BibleTime team
*/
-
class CLexiconReadWindow : public CReadWindow {
Q_OBJECT
public:
diff --git a/src/frontend/displaywindow/cmodulechooserbar.cpp b/src/frontend/displaywindow/cmodulechooserbar.cpp
index 2e47851..0e6131a 100644
--- a/src/frontend/displaywindow/cmodulechooserbar.cpp
+++ b/src/frontend/displaywindow/cmodulechooserbar.cpp
@@ -7,14 +7,14 @@
*
**********/
-#include "cmodulechooserbar.h"
+#include "frontend/displaywindow/cmodulechooserbar.h"
-#include "cmodulechooserbutton.h"
-
-#include <QList>
-#include <QDebug>
#include <QAction>
+#include <QDebug>
+#include <QList>
#include <QToolBar>
+#include "frontend/displaywindow/cmodulechooserbutton.h"
+
CModuleChooserBar::CModuleChooserBar(QList<CSwordModuleInfo*> useModules, CSwordModuleInfo::ModuleType type, QWidget *parent)
: QToolBar(parent),
diff --git a/src/frontend/displaywindow/cmodulechooserbar.h b/src/frontend/displaywindow/cmodulechooserbar.h
index 1a9ce95..fbdd737 100644
--- a/src/frontend/displaywindow/cmodulechooserbar.h
+++ b/src/frontend/displaywindow/cmodulechooserbar.h
@@ -10,14 +10,12 @@
#ifndef CMODULECHOOSERBAR_H
#define CMODULECHOOSERBAR_H
-//BibleTime includes
-#include "backend/drivers/cswordmoduleinfo.h"
+#include <QToolBar>
+#include <QList>
+#include "backend/drivers/cswordmoduleinfo.h"
#include "util/cpointers.h"
-//Qt includes
-#include <QList>
-#include <QToolBar>
class CModuleChooserButton;
class QWidget;
diff --git a/src/frontend/displaywindow/cmodulechooserbutton.cpp b/src/frontend/displaywindow/cmodulechooserbutton.cpp
index 14760e0..0444cf6 100644
--- a/src/frontend/displaywindow/cmodulechooserbutton.cpp
+++ b/src/frontend/displaywindow/cmodulechooserbutton.cpp
@@ -7,33 +7,31 @@
*
**********/
-#include "cmodulechooserbutton.h"
-
-#include "cmodulechooserbar.h"
-
-#include "backend/managers/cswordbackend.h"
+#include "frontend/displaywindow/cmodulechooserbutton.h"
+#include <QDebug>
+#include <QHash>
+#include <QMenu>
+#include <QString>
+#include <QToolButton>
+#include <QToolTip>
#include "backend/config/cbtconfig.h"
-
+#include "backend/managers/cswordbackend.h"
+#include "frontend/displaywindow/cmodulechooserbar.h"
#include "util/cresmgr.h"
-#include "util/directoryutil.h"
+#include "util/directory.h"
-//Qt includes
-#include <QString>
-#include <QToolTip>
-#include <QHash>
-#include <QToolButton>
-#include <QMenu>
-#include <QtDebug>
CModuleChooserButton::CModuleChooserButton(CSwordModuleInfo* useModule, CSwordModuleInfo::ModuleType type, const int id, CModuleChooserBar *parent)
: QToolButton(parent),
m_id(id), m_popup(0), m_moduleChooserBar(parent) {
+ namespace DU = util::directory;
+
m_moduleType = type;
m_module = useModule;
m_hasModule = (m_module) ? true : false;
- setIcon( util::filesystem::DirectoryUtil::getIcon(iconName()) );
+ setIcon(DU::getIcon(iconName()));
setPopupMode(QToolButton::InstantPopup);
populateMenu();
@@ -81,6 +79,7 @@ int CModuleChooserButton::getId() const {
/** Is called after a module was selected in the popup */
void CModuleChooserButton::moduleChosen( QAction* action ) {
+ namespace DU = util::directory;
QListIterator<QMenu*> it(m_submenus);
while (it.hasNext()) {
@@ -106,7 +105,7 @@ void CModuleChooserButton::moduleChosen( QAction* action ) {
m_hasModule = true;
m_module = module();
- setIcon( util::filesystem::DirectoryUtil::getIcon(iconName()) );
+ setIcon(DU::getIcon(iconName()));
emit sigChanged();
if (m_module) {
diff --git a/src/frontend/displaywindow/cmodulechooserbutton.h b/src/frontend/displaywindow/cmodulechooserbutton.h
index 23646c9..4d62b67 100644
--- a/src/frontend/displaywindow/cmodulechooserbutton.h
+++ b/src/frontend/displaywindow/cmodulechooserbutton.h
@@ -10,17 +10,16 @@
#ifndef CMODULECHOOSERBUTTON_H
#define CMODULECHOOSERBUTTON_H
-//BibleTime includes
-class CSwordModuleInfo;
-#include "backend/btmoduletreeitem.h"
+#include <QToolButton>
#include "util/cpointers.h"
-//Qt includes
-#include <QToolButton>
#include <QList>
+#include "backend/btmoduletreeitem.h"
+
class QMenu;
class CModuleChooserBar;
+class CSwordModuleInfo;
/** The CModuleChooserButton displays a list of submenus sorted by language which contain the possible modules
* which can be displayed together with the first one.
diff --git a/src/frontend/displaywindow/cplainwritewindow.cpp b/src/frontend/displaywindow/cplainwritewindow.cpp
index dc97aec..6394998 100644
--- a/src/frontend/displaywindow/cplainwritewindow.cpp
+++ b/src/frontend/displaywindow/cplainwritewindow.cpp
@@ -7,25 +7,22 @@
*
**********/
-#include "cplainwritewindow.h"
-#include "btactioncollection.h"
+#include "frontend/displaywindow/cplainwritewindow.h"
+#include <QAction>
+#include <QDebug>
+#include <QRegExp>
+#include <QToolBar>
+#include "backend/config/cbtconfig.h"
+#include "backend/keys/cswordkey.h"
#include "frontend/display/cwritedisplay.h"
-
+#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/keychooser/ckeychooser.h"
#include "frontend/profile/cprofilewindow.h"
-#include "backend/config/cbtconfig.h"
-
-#include "backend/keys/cswordkey.h"
-
#include "util/cresmgr.h"
-#include "util/directoryutil.h"
+#include "util/directory.h"
+#include "util/dialogutil.h"
-#include <QRegExp>
-#include <QToolBar>
-#include <QMessageBox>
-#include <QDebug>
-#include <QAction>
using namespace Profile;
@@ -54,9 +51,11 @@ void CPlainWriteWindow::initView() {
}
void CPlainWriteWindow::initToolbars() {
+ namespace DU = util::directory;
+
m_actions.syncWindow = new QAction(
//KIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
+ DU::getIcon(CResMgr::displaywindows::commentaryWindow::syncWindow::icon),
tr("Sync with active Bible"),
actionCollection()
);
@@ -69,7 +68,7 @@ void CPlainWriteWindow::initToolbars() {
m_actions.saveText = new QAction(
//KIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
+ DU::getIcon(CResMgr::displaywindows::writeWindow::saveText::icon),
tr("Save text"),
actionCollection()
);
@@ -82,7 +81,7 @@ void CPlainWriteWindow::initToolbars() {
m_actions.deleteEntry = new QAction(
//KIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
+ DU::getIcon(CResMgr::displaywindows::writeWindow::deleteEntry::icon),
tr("Delete current entry"),
actionCollection()
);
@@ -95,7 +94,7 @@ void CPlainWriteWindow::initToolbars() {
m_actions.restoreText = new QAction(
//KIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
- util::filesystem::DirectoryUtil::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
+ DU::getIcon(CResMgr::displaywindows::writeWindow::restoreText::icon),
tr("Restore original text"),
actionCollection()
);
@@ -142,11 +141,11 @@ void CPlainWriteWindow::saveCurrentText( const QString& /*key*/ ) {
textChanged();
}
else {
- QMessageBox::critical( 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.") ) );
+ util::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.") ) );
}
}
diff --git a/src/frontend/displaywindow/cplainwritewindow.h b/src/frontend/displaywindow/cplainwritewindow.h
index a190f47..ec9fe5e 100644
--- a/src/frontend/displaywindow/cplainwritewindow.h
+++ b/src/frontend/displaywindow/cplainwritewindow.h
@@ -7,18 +7,14 @@
*
**********/
-
-
#ifndef CPLAINWRITEWINDOW_H
#define CPLAINWRITEWINDOW_H
-//BibleTime includes
-#include "cwritewindow.h"
+#include "frontend/displaywindow/cwritewindow.h"
-class QAction;
class BtActionCollection;
-
+class QAction;
class QString;
/** The write window class which offers a plain editor for source code editing.
diff --git a/src/frontend/displaywindow/creadwindow.cpp b/src/frontend/displaywindow/creadwindow.cpp
index 860fa72..b65cf8c 100644
--- a/src/frontend/displaywindow/creadwindow.cpp
+++ b/src/frontend/displaywindow/creadwindow.cpp
@@ -7,33 +7,31 @@
*
**********/
-//BibleTime includes
-#include "creadwindow.h"
-#include "btactioncollection.h"
+#include "frontend/displaywindow/creadwindow.h"
-#include "frontend/display/bthtmlreaddisplay.h"
-typedef BtHtmlReadDisplay HTMLREADDISPLAY;
-
-#include "backend/rendering/centrydisplay.h"
-#include "backend/rendering/cdisplayrendering.h"
+#include <QDebug>
+#include <QMdiSubWindow>
+#include <QResizeEvent>
#include "backend/keys/cswordkey.h"
#include "backend/keys/cswordversekey.h"
-
+#include "backend/rendering/cdisplayrendering.h"
+#include "backend/rendering/centrydisplay.h"
#include "frontend/cexportmanager.h"
#include "frontend/cmdiarea.h"
+#include "frontend/display/bthtmlreaddisplay.h"
+#include "frontend/displaywindow/btactioncollection.h"
#include "frontend/profile/cprofilewindow.h"
#include "frontend/searchdialog/csearchdialog.h"
-#include <QResizeEvent>
-#include <QMdiSubWindow>
-#include <QDebug>
using namespace Profile;
+typedef BtHtmlReadDisplay HTMLREADDISPLAY;
+
CReadWindow::CReadWindow(QList<CSwordModuleInfo*> modules, CMDIArea* parent)
: CDisplayWindow(modules, parent),
m_displayWidget(0) {
- qDebug("CReadWindow::CReadWindow");
+ qDebug() << "CReadWindow::CReadWindow";
// installEventFilter(this);
}
@@ -92,7 +90,7 @@ void CReadWindow::lookupSwordKey( CSwordKey* newKey ) {
key()->key(newKey->key());
}
- //next-TODO: how about options?
+ /// \todo next-TODO how about options?
Q_ASSERT(modules().first()->getDisplay());
CEntryDisplay* display = modules().first()->getDisplay();
if (display) { //do we have a display object?
@@ -106,7 +104,7 @@ void CReadWindow::lookupSwordKey( CSwordKey* newKey ) {
);
}
- setCaption( windowCaption() );
+ setWindowTitle(windowCaption());
// moving to anchor happens in slotMoveToAnchor which catches the completed() signal from KHTMLPart
@@ -114,7 +112,7 @@ void CReadWindow::lookupSwordKey( CSwordKey* newKey ) {
}
void CReadWindow::slotMoveToAnchor() {
- qDebug("CReadWindow::slotMoveToAnchor");
+ qDebug() << "CReadWindow::slotMoveToAnchor";
((CReadDisplay*)displayWidget())->moveToAnchor( Rendering::CDisplayRendering::keyToHTMLAnchor(key()->key()) );
}
@@ -195,7 +193,9 @@ void CReadWindow::openSearchStrongsDialog() {
QString searchText = QString::null;
if (displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma] != QString::null) {
- searchText.append("strong:").append(displayWidget()->getCurrentNodeInfo() [CDisplay::Lemma]);
+ Q_FOREACH(QString strongNumber, displayWidget()->getCurrentNodeInfo()[CDisplay::Lemma].split("|")) {
+ searchText.append("strong:").append( strongNumber ).append(" ");
+ }
}
Search::CSearchDialog::openDialog( modules(), searchText, 0 );
diff --git a/src/frontend/displaywindow/creadwindow.h b/src/frontend/displaywindow/creadwindow.h
index 6144b2d..1debe9f 100644
--- a/src/frontend/displaywindow/creadwindow.h
+++ b/src/frontend/displaywindow/creadwindow.h
@@ -7,13 +7,10 @@
*
**********/
-
-
#ifndef CREADWINDOW_H
#define CREADWINDOW_H
-//BibleTime includes
-#include "cdisplaywindow.h"
+#include "frontend/displaywindow/cdisplaywindow.h"
#include "frontend/display/cdisplay.h"
#include "frontend/display/creaddisplay.h"
@@ -22,11 +19,9 @@
class BtActionCollection;
class QResizeEvent;
-
/** The base class for all read-only display windows.
* @author The BibleTime team
*/
-
class CReadWindow : public CDisplayWindow {
Q_OBJECT
public:
diff --git a/src/frontend/displaywindow/cwritewindow.cpp b/src/frontend/displaywindow/cwritewindow.cpp
index c60d9cd..7496dd7 100644
--- a/src/frontend/displaywindow/cwritewindow.cpp
+++ b/src/frontend/displaywindow/cwritewindow.cpp
@@ -8,17 +8,14 @@
**********/
-#include "cwritewindow.h"
+#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 "frontend/display/cwritedisplay.h"
-
-
-#include <QMessageBox>
+#include "util/dialogutil.h"
using namespace Profile;
@@ -112,13 +109,13 @@ void CWriteWindow::lookupSwordKey( CSwordKey* newKey ) {
if ( modules().count() ) {
displayWidget()->setText( key()->rawText() );
}
- setCaption( windowCaption() );
+ setWindowTitle(windowCaption());
}
bool CWriteWindow::queryClose() {
//save the text if it has changed
if (m_writeDisplay->isModified()) {
- switch (QMessageBox::question( this, tr("Save Text?"), tr("Save text before closing?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes) ) {
+ 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 );
@@ -140,7 +137,7 @@ void CWriteWindow::beforeKeyChange(const QString& 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 (QMessageBox::question( this, tr("Save Text?"), tr("Save changed text?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) ) {
+ switch (util::showQuestion( this, tr("Save Text?"), tr("Save changed text?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) ) {
case QMessageBox::Yes: { //save the changes
saveCurrentText( key );
break;
diff --git a/src/frontend/displaywindow/cwritewindow.h b/src/frontend/displaywindow/cwritewindow.h
index e2ffc54..5d6a316 100644
--- a/src/frontend/displaywindow/cwritewindow.h
+++ b/src/frontend/displaywindow/cwritewindow.h
@@ -10,18 +10,16 @@
#ifndef CWRITEWINDOW_H
#define CWRITEWINDOW_H
-//BibleTime includes
-#include "cdisplaywindow.h"
+#include "frontend/displaywindow/cdisplaywindow.h"
+class BtActionCollection;
class CWriteDisplay;
class QString;
-class BtActionCollection;
-/**The base class for all write-only display windows.
+/** The base class for all write-only display windows.
*@author The BibleTime team
*/
-
class CWriteWindow : public CDisplayWindow {
Q_OBJECT
public:
diff --git a/src/frontend/htmldialogs/btaboutdialog.cpp b/src/frontend/htmldialogs/btaboutdialog.cpp
index 2c6f553..f8e6666 100644
--- a/src/frontend/htmldialogs/btaboutdialog.cpp
+++ b/src/frontend/htmldialogs/btaboutdialog.cpp
@@ -7,11 +7,13 @@
*
**********/
-#include "btaboutdialog.h"
+#include "frontend/htmldialogs/btaboutdialog.h"
-#include "util/directoryutil.h"
+#include "util/directory.h"
+
+// Sword includes:
+#include <swversion.h>
-#include "swversion.h"
// Forwards
static QString make_body(const QString& content);
@@ -99,8 +101,10 @@ void BtAboutDialog::init_contributors_tab() {
// sorted alphabetically (last name)
content += "<ul>";
content += "<li>Horatiu Alexe</li>";
- content += "<li>Jan B&ecarron;lohoubek</li>";
+ content += "<li>Jan B&#x11B;lohoubek</li>";
content += "<li>Chun-shek Chan</li>";
+ content += "<li>Nouhoun Y. Diarra</li>";
+ content += "<li>Rafael Fagundes</li>";
content += "<li>Ilpo Kantonen</li>";
content += "<li>Pavel Laukko</li>";
content += "<li>Piotr Markiewicz</li>";
@@ -111,8 +115,11 @@ void BtAboutDialog::init_contributors_tab() {
content += "<li>Jaak Ristioja</li>";
content += "<li>Igor Rykhlin</li>";
content += "<li>Vlad Savitsky</li>";
+ content += "<li>Henrik Sonesson</li>";
content += "<li>Johan van der Lingen</li>";
content += "<li>Jean Van Schaftingen</li>";
+ content += "<li>Roland Teschner</li>";
+ content += "<li>Giovanni Tedaldi</li>";
content += "<li>Dmitry Yurevich</li>";
content += "<li>Esteban Zeller</li>";
content += "</ul>";
@@ -149,21 +156,21 @@ void BtAboutDialog::init_qt_tab() {
content += make_br() + make_br();
content += make_center(make_bold("Qt"));
content += make_br();
- content += tr("This program uses Qt Open Source Edition version %1.").arg(qVersion());
- //content += qVersion();
+ content += tr("This program uses Qt version %1.").arg(qVersion());
content += make_br() + make_br();
- content += tr("Qt Open Source Edition is intended for the development of Open Source applications.");
- content += " ";
- content += tr("Qt is a C++ toolkit for cross-platform application development.");
+ content += tr("Qt is a cross-platform application and UI framework, created with C++ language. It has been released under the LGPL license.");
content += make_br() + make_br();
- content += tr("Please see ");
- content += make_link("http://qtsoftware.com/company/model/", "qtsoftware.com/company/model");
- content += tr(" for an overview of Qt licensing.");
+ content += make_link("http://qt.nokia.com/", "http://qt.nokia.com/");
+ //content += tr("Please see ");
+ //content += make_link("http://qtsoftware.com/company/model/", "qtsoftware.com/company/model");
+ //content += tr(" for an overview of Qt licensing.");
QString qt = make_html(make_head("") + make_body(content));
setHtml(qt);
}
void BtAboutDialog::init_lic_tab() {
+ namespace DU = util::directory;
+
selectTab(4);
setTabText(tr("License"));
@@ -173,12 +180,12 @@ void BtAboutDialog::init_lic_tab() {
text += tr("You can download and use (but not distribute) the program for personal, private, public or commercial purposes without restrictions.");
text += " ";
text += tr("You can give away or distribute the program if you also distribute the corresponding source code.");
- text += "<br><br>";
+ text += "<br/><br/>";
//text += tr("It is allowed to distribute software under GPL for a small fee, but it must be accompanied with the complete source code, and the fact that it is freely available with no cost must not be hidden.");
- //text += "<br><br>";
+ //text += "<br/><br/>";
text += tr("The complete legally binding license is below.");
- QFile licFile(util::filesystem::DirectoryUtil::getLicenseDir().path() + "/license.html");
+ QFile licFile(DU::getLicenseDir().path() + "/license.html");
if (licFile.open(QFile::ReadOnly)) {
QByteArray html;
while (!licFile.atEnd()) {
@@ -200,7 +207,7 @@ static QString make_center(const QString& content) {
}
static QString make_br() {
- return "<br>";
+ return "<br/>";
}
static QString make_bold(const QString& content) {
@@ -229,7 +236,9 @@ static QString make_version() {
}
static QString make_file_icon(const QString& icon) {
- QString dir = "<img src=file://" + util::filesystem::DirectoryUtil::getIconDir().path();
+ namespace DU = util::directory;
+
+ QString dir("<img src=file://" + DU::getIconDir().path());
return dir + "/" + icon + ".png >";
}
diff --git a/src/frontend/htmldialogs/btaboutdialog.h b/src/frontend/htmldialogs/btaboutdialog.h
index 6521f7f..2fed22a 100644
--- a/src/frontend/htmldialogs/btaboutdialog.h
+++ b/src/frontend/htmldialogs/btaboutdialog.h
@@ -10,14 +10,15 @@
#ifndef BTABOUTDIALOG_H
#define BTABOUTDIALOG_H
-#include "bttabhtmldialog.h"
+#include "frontend/htmldialogs/bttabhtmldialog.h"
+
class BtAboutDialog : public BtTabHtmlDialog {
Q_OBJECT
-
public:
BtAboutDialog(QWidget *parent = 0, Qt::WindowFlags wflags = Qt::Dialog);
~BtAboutDialog();
+
void init_bt_tab();
void init_contributors_tab();
void init_sword_tab();
diff --git a/src/frontend/htmldialogs/bttabhtmldialog.cpp b/src/frontend/htmldialogs/bttabhtmldialog.cpp
index 4d2b57c..74a2b20 100644
--- a/src/frontend/htmldialogs/bttabhtmldialog.cpp
+++ b/src/frontend/htmldialogs/bttabhtmldialog.cpp
@@ -7,18 +7,19 @@
*
**********/
-#include "bttabhtmldialog.h" // See this file for more documentation of BtTabHtmlDialog
-#include "util/dialogutil.h"
-#include "util/directoryutil.h"
+#include "frontend/htmldialogs/bttabhtmldialog.h"
+#include <QContextMenuEvent>
+#include <QDesktopServices>
#include <QDialog>
#include <QDialogButtonBox>
-#include <QVBoxLayout>
-#include <QWebView>
#include <QMenu>
#include <QTabWidget>
-#include <QDesktopServices>
-#include <QContextMenuEvent>
+#include <QVBoxLayout>
+#include <QWebView>
+#include "util/dialogutil.h"
+#include "util/directory.h"
+
BtTabHtmlDialog::BtTabHtmlDialog
(const QString& title, int tabs, QWidget *parent, Qt::WindowFlags wflags )
@@ -91,9 +92,11 @@ QWebView* BtTabHtmlDialog::webView() {
}
void BtTabHtmlDialog::setHtml(const QString& html, const QUrl& baseUrl) {
+ namespace DU = util::directory;
+
QUrl url = baseUrl;
if (url == QUrl()) {
- QString dir = "file://" + util::filesystem::DirectoryUtil::getIconDir().path();
+ QString dir("file://" + DU::getIconDir().path());
url.setUrl(dir);
}
webView()->setHtml(html, url);
diff --git a/src/frontend/htmldialogs/bttabhtmldialog.h b/src/frontend/htmldialogs/bttabhtmldialog.h
index 3ccdc0f..6e5ed20 100644
--- a/src/frontend/htmldialogs/bttabhtmldialog.h
+++ b/src/frontend/htmldialogs/bttabhtmldialog.h
@@ -11,10 +11,12 @@
#define BTTABDIALOG_H
#include <QDialog>
+
#include <QString>
#include <QUrl>
#include <QWebView>
+
class QTabWidget;
class QMenu;
diff --git a/src/frontend/keychooser/bthistory.cpp b/src/frontend/keychooser/bthistory.cpp
index 8b14ded..60d2a7b 100644
--- a/src/frontend/keychooser/bthistory.cpp
+++ b/src/frontend/keychooser/bthistory.cpp
@@ -1,24 +1,18 @@
-//
-// C++ Implementation: BTHistory
-//
-// Description:
-//
-//
-// Author: The BibleTime team <info@bibletime.info>, (C) 2007
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
-
-#include "bthistory.h"
-
-#include "backend/keys/cswordkey.h"
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2009 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
+#include "frontend/keychooser/bthistory.h"
#include <QAction>
-#include <QList>
-
#include <QDebug>
+#include <QList>
+#include "backend/keys/cswordkey.h"
BTHistory::BTHistory(QWidget* parent)
@@ -30,7 +24,7 @@ BTHistory::BTHistory(QWidget* parent)
}
void BTHistory::add(CSwordKey* newKey) {
- qDebug("BTHistory::add");
+ qDebug() << "BTHistory::add";
Q_ASSERT(newKey);
// Add new key Action after current index if we were not using the history functions,
// if it's not a duplicate and if it's not empty.
@@ -38,14 +32,14 @@ void BTHistory::add(CSwordKey* newKey) {
if (!newKey->key().isEmpty()) {
m_historyList.insert(++m_index, new QAction(newKey->key(), this));
}
- // TODO: history limit?
+ // \todo history limit?
sendChangedSignal();
}
Q_ASSERT(class_invariant());
}
void BTHistory::move(QAction* historyItem) {
- qDebug("BTHistory::move");
+ qDebug() << "BTHistory::move";
//Q_ASSERT(historyItem);
Q_ASSERT(m_historyList.count());
@@ -62,7 +56,7 @@ void BTHistory::move(QAction* historyItem) {
}
void BTHistory::back() {
- qDebug("BTHistory::back");
+ qDebug() << "BTHistory::back";
if ( m_index >= 1) {
move(m_historyList.at(m_index - 1));
}
@@ -70,7 +64,7 @@ void BTHistory::back() {
}
void BTHistory::fw() {
- qDebug("BTHistory::fw");
+ qDebug() << "BTHistory::fw";
if (m_index < (m_historyList.size() - 1)) {
move(m_historyList.at(m_index + 1));
}
@@ -78,7 +72,7 @@ void BTHistory::fw() {
}
QList<QAction*> BTHistory::getBackList() {
- qDebug("BTHistory::getBackList");
+ qDebug() << "BTHistory::getBackList";
QList<QAction*> list;
for (int i = m_index - 1; i >= 0; --i) {
@@ -91,7 +85,7 @@ QList<QAction*> BTHistory::getBackList() {
}
QList<QAction*> BTHistory::getFwList() {
- qDebug("BTHistory::getFwList");
+ qDebug() << "BTHistory::getFwList";
QList<QAction*> list;
//qDebug() << "historyList.size:" << m_historyList.size();
diff --git a/src/frontend/keychooser/bthistory.h b/src/frontend/keychooser/bthistory.h
index 9c09e10..df674d0 100644
--- a/src/frontend/keychooser/bthistory.h
+++ b/src/frontend/keychooser/bthistory.h
@@ -1,21 +1,19 @@
-//
-// C++ Interface: BTHistory
-//
-// Description:
-//
-//
-// Author: The BibleTime team <info@bibletime.info>, (C) 2007
-//
-// Copyright: See COPYING file that comes with this distribution
-//
-//
+/*********
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2008 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License version 2.0.
+*
+**********/
#ifndef BTHISTORY_H
#define BTHISTORY_H
-#include <QList>
#include <QObject>
+#include <QList>
+
class CSwordKey;
class QAction;
@@ -23,10 +21,9 @@ class QWidget;
class BTHistory: public QObject {
Q_OBJECT
-
public:
BTHistory(QWidget* parent);
- ~BTHistory() {};
+ ~BTHistory() {}
/**
* Return a list of Actions behind the current point, the first of the history list will be the
diff --git a/src/frontend/keychooser/cbookkeychooser.cpp b/src/frontend/keychooser/cbookkeychooser.cpp
index ca13baa..21216e4 100644
--- a/src/frontend/keychooser/cbookkeychooser.cpp
+++ b/src/frontend/keychooser/cbookkeychooser.cpp
@@ -6,19 +6,18 @@
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "cbookkeychooser.h"
-#include "bthistory.h"
+#include "frontend/keychooser/cbookkeychooser.h"
-#include "backend/keys/cswordtreekey.h"
-#include "backend/drivers/cswordbookmoduleinfo.h"
-#include "backend/config/cbtconfig.h"
-
-//Qt includes
-#include <QWidget>
+#include <QDebug>
#include <QHBoxLayout>
#include <QList>
-#include <QDebug>
+#include <QWidget>
+#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordbookmoduleinfo.h"
+#include "backend/keys/cswordtreekey.h"
+#include "frontend/keychooser/bthistory.h"
+
QMap<QObject*, int> boxes;
diff --git a/src/frontend/keychooser/cbookkeychooser.h b/src/frontend/keychooser/cbookkeychooser.h
index d32d6e9..f1ac69f 100644
--- a/src/frontend/keychooser/cbookkeychooser.h
+++ b/src/frontend/keychooser/cbookkeychooser.h
@@ -10,14 +10,14 @@
#ifndef CBOOKKEYCHOOSER_H
#define CBOOKKEYCHOOSER_H
-//BibleTime includes
-#include "ckeychooser.h"
-#include "ckeychooserwidget.h"
+#include "frontend/keychooser/ckeychooser.h"
#include <QList>
+#include "frontend/keychooser/ckeychooserwidget.h"
+
-class CSwordKey;
class CSwordBookModuleInfo;
+class CSwordKey;
class CSwordTreeKey;
namespace sword {
@@ -27,7 +27,7 @@ class TreeKeyIdx;
/** The keychooser implementation for books.
* @author The BibleTime team
*/
-class CBookKeyChooser : public CKeyChooser {
+class CBookKeyChooser : public CKeyChooser {
Q_OBJECT
public:
CBookKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key = 0, QWidget *parent = 0);
diff --git a/src/frontend/keychooser/cbooktreechooser.cpp b/src/frontend/keychooser/cbooktreechooser.cpp
index e348005..db55dca 100644
--- a/src/frontend/keychooser/cbooktreechooser.cpp
+++ b/src/frontend/keychooser/cbooktreechooser.cpp
@@ -6,21 +6,20 @@
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/
-#include "cbooktreechooser.h"
-#include "bthistory.h"
-
-#include "backend/keys/cswordtreekey.h"
-#include "backend/drivers/cswordbookmoduleinfo.h"
-#include "backend/config/cbtconfig.h"
+#include "frontend/keychooser/cbooktreechooser.h"
+#include <QApplication>
+#include <QDebug>
#include <QHBoxLayout>
+#include <QHeaderView>
#include <QTreeWidget>
#include <QTreeWidgetItem>
-#include <QHeaderView>
-#include <QApplication>
+#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordbookmoduleinfo.h"
+#include "backend/keys/cswordtreekey.h"
+#include "frontend/keychooser/bthistory.h"
-#include <QDebug>
CBookTreeChooser::CBookTreeChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent)
: CKeyChooser(modules, key, parent),
@@ -60,7 +59,7 @@ void CBookTreeChooser::setKey(CSwordKey* key) {
/** Sets a new key to this keychooser. Inherited from ckeychooser. */
void CBookTreeChooser::setKey(CSwordKey* newKey, const bool emitSignal) {
- qDebug("CBookTreeChooser::setKey");
+ qDebug() << "CBookTreeChooser::setKey";
if (m_key != newKey ) {
m_key = dynamic_cast<CSwordTreeKey*>(newKey);
@@ -131,13 +130,13 @@ void CBookTreeChooser::refreshContent() {
}
-//TODO: itemActivated is called too many times. As tested in GDB, the function
+/// \todo itemActivated is called too many times. As tested in GDB, the function
//is called twice with the pointer to the correct book and twice with a null
//pointer.
/** Slot for signal when item is selected by user. */
void CBookTreeChooser::itemActivated( QTreeWidgetItem* item ) {
- qDebug("CBookTreeChooser::itemActivated");
+ qDebug() << "CBookTreeChooser::itemActivated";
//Sometimes Qt calls this function with a null pointer.
if (item) {
m_key->key(item->text(1));
diff --git a/src/frontend/keychooser/cbooktreechooser.h b/src/frontend/keychooser/cbooktreechooser.h
index 943127b..01fd369 100644
--- a/src/frontend/keychooser/cbooktreechooser.h
+++ b/src/frontend/keychooser/cbooktreechooser.h
@@ -7,35 +7,27 @@
*
**********/
-
-
#ifndef CBOOKTREECHOOSER_H
#define CBOOKTREECHOOSER_H
+#include "frontend/keychooser/ckeychooser.h"
-/** The treechooser implementation for books.
- * @author The BibleTime team
- */
-//BibleTime includes
-#include "ckeychooser.h"
-#include "ckeychooserwidget.h"
-
+#include "frontend/keychooser/ckeychooserwidget.h"
-class CSwordKey;
-class CSwordBookModuleInfo;
-class CSwordTreeKey;
namespace sword {
class TreeKeyIdx;
}
-
+class CSwordBookModuleInfo;
+class CSwordKey;
+class CSwordTreeKey;
class QTreeWidget;
class QTreeWidgetItem;
/** The keychooser implementation for books.
* @author The BibleTime team
*/
-class CBookTreeChooser : public CKeyChooser {
+class CBookTreeChooser : public CKeyChooser {
Q_OBJECT
public:
CBookTreeChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key = 0, QWidget *parent = 0);
diff --git a/src/frontend/keychooser/ckeychooser.cpp b/src/frontend/keychooser/ckeychooser.cpp
index 11b4db3..905e125 100644
--- a/src/frontend/keychooser/ckeychooser.cpp
+++ b/src/frontend/keychooser/ckeychooser.cpp
@@ -7,29 +7,25 @@
*
**********/
+#include "frontend/keychooser/ckeychooser.h"
-
-#include "ckeychooser.h"
-
-#include "backend/drivers/cswordmoduleinfo.h"
+#include <QAction>
+#include <QDebug>
#include "backend/drivers/cswordbiblemoduleinfo.h"
#include "backend/drivers/cswordcommentarymoduleinfo.h"
#include "backend/drivers/cswordlexiconmoduleinfo.h"
-
+#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/keys/cswordkey.h"
+#include "frontend/keychooser/bthistory.h"
+#include "frontend/keychooser/cbookkeychooser.h"
+#include "frontend/keychooser/clexiconkeychooser.h"
+#include "frontend/keychooser/versekeychooser/cbiblekeychooser.h"
-#include "bthistory.h"
-#include "clexiconkeychooser.h"
-#include "versekeychooser/cbiblekeychooser.h"
-#include "cbookkeychooser.h"
-
-#include <QAction>
-#include <QDebug>
CKeyChooser::CKeyChooser(QList<CSwordModuleInfo*>, CSwordKey *, QWidget *parent)
: QWidget(parent),
m_history(0) {
- //qDebug("CKeyChooser::CKeyChooser");
+ //qDebug() << "CKeyChooser::CKeyChooser";
m_history = new BTHistory(this);
QObject::connect(history(), SIGNAL(historyMoved(QString&)), this, SLOT(setKey(QString&)));
}
diff --git a/src/frontend/keychooser/ckeychooser.h b/src/frontend/keychooser/ckeychooser.h
index 455da20..4441df0 100644
--- a/src/frontend/keychooser/ckeychooser.h
+++ b/src/frontend/keychooser/ckeychooser.h
@@ -7,23 +7,17 @@
*
**********/
-
-
#ifndef CKEYCHOOSER_H
#define CKEYCHOOSER_H
-
-class CSwordModuleInfo;
-
#include <QWidget>
+class BTHistory;
class CSwordKey;
+class CSwordModuleInfo;
class QAction;
-class BTHistory;
-
-
/**
* The base class for the KeyChooser.
* Do not use directly, create a KeyChooser with
@@ -32,10 +26,8 @@ class BTHistory;
*
* @author The BibleTime team
*/
-
class CKeyChooser : public QWidget {
Q_OBJECT
-
public:
/**
diff --git a/src/frontend/keychooser/ckeychooserwidget.cpp b/src/frontend/keychooser/ckeychooserwidget.cpp
index 88b7ed7..a11bd6f 100644
--- a/src/frontend/keychooser/ckeychooserwidget.cpp
+++ b/src/frontend/keychooser/ckeychooserwidget.cpp
@@ -7,20 +7,17 @@
*
**********/
+#include "frontend/keychooser/ckeychooserwidget.h"
-//BibleTime includes
-#include "ckeychooserwidget.h"
-
-#include "cscrollerwidgetset.h"
-
-//Qt includes
-#include <QString>
-#include <QWheelEvent>
+#include <QComboBox>
+#include <QDebug>
#include <QFocusEvent>
#include <QHBoxLayout>
-#include <QComboBox>
#include <QLineEdit>
-#include <QDebug>
+#include <QString>
+#include <QWheelEvent>
+#include "frontend/keychooser/cscrollerwidgetset.h"
+
class BtKeyLineEdit : public QLineEdit {
public:
@@ -133,7 +130,7 @@ void CKeyChooserWidget::reset(const int count, int index, bool do_emit) {
// return;
m_list.clear();
- for (int i = 1; i <= count; i++) { //TODO: CHECK
+ for (int i = 1; i <= count; i++) { /// \todo CHECK
m_list.append( QString::number(i) );
}
@@ -196,7 +193,7 @@ void CKeyChooserWidget::reset(QStringList *list, int index, bool do_emit) {
/** Initializes this widget. We need this function because we have more than one constructor. */
void CKeyChooserWidget::init() {
- qDebug("CKeyChooserWidget::init");
+ qDebug() << "CKeyChooserWidget::init";
oldKey = QString::null;
setFocusPolicy(Qt::WheelFocus);
@@ -237,7 +234,7 @@ void CKeyChooserWidget::init() {
/** Is called when the return key was presed in the combobox. */
void CKeyChooserWidget::slotReturnPressed( /*const QString& text*/) {
Q_ASSERT(comboBox()->lineEdit());
- qDebug("return pressed");
+ qDebug() << "return pressed";
QString text = comboBox()->lineEdit()->text();
for (int index = 0; index < comboBox()->count(); ++index) {
@@ -251,7 +248,7 @@ void CKeyChooserWidget::slotReturnPressed( /*const QString& text*/) {
/** Is called when the current item of the combo box was changed. */
void CKeyChooserWidget::slotComboChanged(int index) {
- qDebug("CKeyChooserWidget::slotComboChanged(int index)");
+ qDebug() << "CKeyChooserWidget::slotComboChanged(int index)";
if (!updatesEnabled()) {
return;
}
diff --git a/src/frontend/keychooser/ckeychooserwidget.h b/src/frontend/keychooser/ckeychooserwidget.h
index 4a141c1..1dab8b3 100644
--- a/src/frontend/keychooser/ckeychooserwidget.h
+++ b/src/frontend/keychooser/ckeychooserwidget.h
@@ -10,26 +10,26 @@
#ifndef CKEYCHOOSERWIDGET_H
#define CKEYCHOOSERWIDGET_H
+#include <QComboBox>
#include <QString>
#include <QStringList>
-#include <QComboBox>
+
+class CLexiconKeyChooser;
+class CScrollerWidgetSet;
class QWheelEvent;
class QHBoxLayout;
class QWidget;
class QObject;
class QEvent;
-class CLexiconKeyChooser;
-class CScrollerWidgetSet;
-/*
-* We use this class to conrtol the focus move in the combobox
+/**
+* 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();
/**
diff --git a/src/frontend/keychooser/clexiconkeychooser.cpp b/src/frontend/keychooser/clexiconkeychooser.cpp
index c1f3cb1..45fa0e2 100644
--- a/src/frontend/keychooser/clexiconkeychooser.cpp
+++ b/src/frontend/keychooser/clexiconkeychooser.cpp
@@ -7,25 +7,20 @@
*
**********/
+#include "frontend/keychooser/clexiconkeychooser.h"
-
-#include "clexiconkeychooser.h"
-
-#include "bthistory.h"
-#include "ckeychooserwidget.h"
-#include "cscrollbutton.h"
-
-#include "backend/drivers/cswordlexiconmoduleinfo.h"
-#include "backend/keys/cswordldkey.h"
-#include "backend/config/cbtconfig.h"
-#include "util/cresmgr.h"
-
-//STL headers
#include <algorithm>
#include <iterator>
#include <map>
-
#include <QHBoxLayout>
+#include <QDebug>
+#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordlexiconmoduleinfo.h"
+#include "backend/keys/cswordldkey.h"
+#include "frontend/keychooser/bthistory.h"
+#include "frontend/keychooser/ckeychooserwidget.h"
+#include "frontend/keychooser/cscrollbutton.h"
+#include "util/cresmgr.h"
CLexiconKeyChooser::CLexiconKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent)
@@ -70,7 +65,7 @@ CSwordKey* CLexiconKeyChooser::key() {
}
void CLexiconKeyChooser::setKey(CSwordKey* key) {
- qDebug("CLexiconKeyChooser::setKey");
+ qDebug() << "CLexiconKeyChooser::setKey";
if (!(m_key = dynamic_cast<CSwordLDKey*>(key))) {
return;
diff --git a/src/frontend/keychooser/clexiconkeychooser.h b/src/frontend/keychooser/clexiconkeychooser.h
index ea1137b..f93a148 100644
--- a/src/frontend/keychooser/clexiconkeychooser.h
+++ b/src/frontend/keychooser/clexiconkeychooser.h
@@ -7,22 +7,18 @@
*
**********/
-
-
#ifndef CLEXICONKEYCHOOSER_H
#define CLEXICONKEYCHOOSER_H
-
-#include "ckeychooser.h"
-class CSwordModuleInfo;
+#include "frontend/keychooser/ckeychooser.h"
class CKeyChooserWidget;
-class CSwordLexiconModuleInfo;
class CSwordLDKey;
-
-class QWidget;
+class CSwordLexiconModuleInfo;
+class CSwordModuleInfo;
class QHBoxLayout;
+class QWidget;
/**
* This class implements the KeyChooser for lexicons
@@ -32,7 +28,7 @@ class QHBoxLayout;
*
* @author The BibleTime team
*/
-class CLexiconKeyChooser : public CKeyChooser {
+class CLexiconKeyChooser : public CKeyChooser {
Q_OBJECT
public:
/**
diff --git a/src/frontend/keychooser/cscrollbutton.cpp b/src/frontend/keychooser/cscrollbutton.cpp
index 4303fb1..5154241 100644
--- a/src/frontend/keychooser/cscrollbutton.cpp
+++ b/src/frontend/keychooser/cscrollbutton.cpp
@@ -7,16 +7,17 @@
*
**********/
-#include "cscrollbutton.h"
+#include "frontend/keychooser/cscrollbutton.h"
#include <cmath>
-#include <QEvent>
#include <QApplication>
#include <QCursor>
-#include <QPoint>
+#include <QEvent>
#include <QMouseEvent>
+#include <QPoint>
#include <QWheelEvent>
+
CScrollButton::CScrollButton(QWidget *parent)
: QToolButton(parent), m_isLocked(false) {
setFocusPolicy(Qt::WheelFocus);
diff --git a/src/frontend/keychooser/cscrollbutton.h b/src/frontend/keychooser/cscrollbutton.h
index 54b82e6..f795b24 100644
--- a/src/frontend/keychooser/cscrollbutton.h
+++ b/src/frontend/keychooser/cscrollbutton.h
@@ -7,15 +7,15 @@
*
**********/
-#ifndef CSRCOLLBUTTON_H
-#define CSRCOLLBUTTON_H
+#ifndef CSCROLLBUTTON_H
+#define CSCROLLBUTTON_H
#include <QToolButton>
-class QMouseEvent;
-class QWidget;
+
class QMouseEvent;
class QWheelEvent;
+class QWidget;
/**
* This Class implements the direct chooser button used in the KeyChooser Widget.
diff --git a/src/frontend/keychooser/cscrollerwidgetset.cpp b/src/frontend/keychooser/cscrollerwidgetset.cpp
index 5f417a1..7c987cc 100644
--- a/src/frontend/keychooser/cscrollerwidgetset.cpp
+++ b/src/frontend/keychooser/cscrollerwidgetset.cpp
@@ -7,16 +7,14 @@
*
**********/
+#include "frontend/keychooser/cscrollerwidgetset.h"
-//BibleTime includes
-#include "cscrollbutton.h"
-#include "cscrollerwidgetset.h"
-
-//Qt includes
#include <QString>
#include <QToolButton>
#include <QVBoxLayout>
#include <QWheelEvent>
+#include "frontend/keychooser/cscrollbutton.h"
+
const unsigned int WIDTH = 16;
const unsigned int ARROW_HEIGHT = 12;
diff --git a/src/frontend/keychooser/cscrollerwidgetset.h b/src/frontend/keychooser/cscrollerwidgetset.h
index 90d87b6..ae81636 100644
--- a/src/frontend/keychooser/cscrollerwidgetset.h
+++ b/src/frontend/keychooser/cscrollerwidgetset.h
@@ -7,20 +7,16 @@
*
**********/
-
-
#ifndef CSCROLLERWIDGETSET_H
#define CSCROLLERWIDGETSET_H
-
#include <QWidget>
-class QVBoxLayout;
-class QToolButton;
-class QString;
-
class CScrollButton;
+class QString;
+class QToolButton;
+class QVBoxLayout;
/**
* This class implements the Scroller Widget-set, which
diff --git a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
index 2d59bed..1e8c292 100644
--- a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
+++ b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.cpp
@@ -7,12 +7,13 @@
*
**********/
-#include "btdropdownchooserbutton.h"
-#include "ckeyreferencewidget.h"
-#include "btversekeymenu.h"
+#include "frontend/keychooser/versekeychooser/btdropdownchooserbutton.h"
-#include <QWheelEvent>
#include <QDebug>
+#include <QWheelEvent>
+#include "frontend/keychooser/versekeychooser/btversekeymenu.h"
+#include "frontend/keychooser/versekeychooser/ckeyreferencewidget.h"
+
const unsigned int ARROW_HEIGHT = 15;
@@ -36,7 +37,7 @@ BtDropdownChooserButton::BtDropdownChooserButton(CKeyReferenceWidget* ref)
void BtDropdownChooserButton::mousePressEvent(QMouseEvent* e) {
- //qDebug("BtDropdownChooserButton::mousePressEvent");
+ //qDebug() << "BtDropdownChooserButton::mousePressEvent";
//recreate the menu
menu()->clear();
this->newList();
diff --git a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
index 12f2f65..e9dbdc2 100644
--- a/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
+++ b/src/frontend/keychooser/versekeychooser/btdropdownchooserbutton.h
@@ -10,9 +10,9 @@
#ifndef BTDROPDOWNCHOOSERBUTTON_H
#define BTDROPDOWNCHOOSERBUTTON_H
-
#include <QToolButton>
+
class CKeyReferenceWidget;
/**
diff --git a/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp b/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp
index 82a07b7..c06a18d 100644
--- a/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp
+++ b/src/frontend/keychooser/versekeychooser/btversekeymenu.cpp
@@ -7,19 +7,19 @@
*
**********/
-#include "btversekeymenu.h"
+#include "frontend/keychooser/versekeychooser/btversekeymenu.h"
+#include <QDebug>
#include <QMenu>
-#include <QTimerEvent>
#include <QMouseEvent>
+#include <QTimerEvent>
-#include <QDebug>
BtVerseKeyMenu::BtVerseKeyMenu(QWidget* parent)
: QMenu(parent),
m_timerId(0),
m_firstClickLock(true) {
- qDebug("BtVerseKeyMenu::BtVerseKeyMenu");
+ qDebug() << "BtVerseKeyMenu::BtVerseKeyMenu";
QObject::connect(this, SIGNAL(aboutToShow()), this, SLOT(startFirstClickDelayTimer()));
}
diff --git a/src/frontend/keychooser/versekeychooser/btversekeymenu.h b/src/frontend/keychooser/versekeychooser/btversekeymenu.h
index 29c0736..f47d0f5 100644
--- a/src/frontend/keychooser/versekeychooser/btversekeymenu.h
+++ b/src/frontend/keychooser/versekeychooser/btversekeymenu.h
@@ -12,6 +12,7 @@
#include <QMenu>
+
class QMouseEvent;
class QTimerEvent;
diff --git a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
index 493d9c4..7bcfbe1 100644
--- a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
+++ b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.cpp
@@ -7,21 +7,18 @@
*
**********/
-#include "cbiblekeychooser.h"
+#include "frontend/keychooser/versekeychooser/cbiblekeychooser.h"
-#include "../bthistory.h"
-#include "ckeyreferencewidget.h"
-#include "../cscrollbutton.h"
-
-#include "backend/keys/cswordversekey.h"
+#include <QDebug>
+#include <QHBoxLayout>
#include "backend/drivers/cswordbiblemoduleinfo.h"
#include "backend/drivers/cswordmoduleinfo.h"
-
+#include "backend/keys/cswordversekey.h"
+#include "frontend/keychooser/bthistory.h"
+#include "frontend/keychooser/cscrollbutton.h"
+#include "frontend/keychooser/versekeychooser/ckeyreferencewidget.h"
#include "util/cresmgr.h"
-#include <QHBoxLayout>
-#include <QDebug>
-
CBibleKeyChooser::CBibleKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *key, QWidget *parent) :
CKeyChooser(modules, key, parent),
@@ -42,6 +39,7 @@ CBibleKeyChooser::CBibleKeyChooser(QList<CSwordModuleInfo*> modules, CSwordKey *
setFocusProxy(w_ref);
layout->addWidget(w_ref);
+ connect(w_ref, SIGNAL(beforeChange(CSwordVerseKey *)), SLOT(beforeRefChange(CSwordVerseKey *)));
connect(w_ref, SIGNAL(changed(CSwordVerseKey *)), SLOT(refChanged(CSwordVerseKey *)));
setKey(m_key); //set the key without changing it, setKey(key()) would change it
@@ -63,14 +61,25 @@ void CBibleKeyChooser::setKey(CSwordKey* key) {
emit keyChanged(m_key);
}
+void CBibleKeyChooser::beforeRefChange(CSwordVerseKey* key) {
+ Q_ASSERT(m_key);
+
+ if (!updatesEnabled())
+ return;
+
+ if (m_key)
+ emit beforeKeyChange(m_key->key());
+
+}
+
void CBibleKeyChooser::refChanged(CSwordVerseKey* key) {
Q_ASSERT(m_key);
Q_ASSERT(key);
- if (!updatesEnabled()) return;
+ if (!updatesEnabled())
+ return;
setUpdatesEnabled(false);
- if (m_key) emit beforeKeyChange(m_key->key());
m_key = key;
emit keyChanged(m_key);
diff --git a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
index e412e60..9501099 100644
--- a/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
+++ b/src/frontend/keychooser/versekeychooser/cbiblekeychooser.h
@@ -7,16 +7,14 @@
*
**********/
-
-
#ifndef CBIBLEKEYCHOOSER_H
#define CBIBLEKEYCHOOSER_H
+#include "frontend/keychooser/ckeychooser.h"
-#include "../ckeychooser.h"
+#include <QList>
#include "backend/drivers/cswordbiblemoduleinfo.h"
-#include <QList>
class QWidget;
@@ -57,8 +55,11 @@ class CBibleKeyChooser : public CKeyChooser {
*/
virtual void setModules(const QList<CSwordModuleInfo*>& modules, const bool refresh = true);
/**
- * used to react to changes
- * @param index not used
+ * used to do actions before key changes
+ */
+ void beforeRefChange(CSwordVerseKey *key);
+ /**
+ * used to do actions after key changes
*/
void refChanged(CSwordVerseKey *key);
diff --git a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp
index 7cedfc0..067b4db 100644
--- a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp
+++ b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.cpp
@@ -7,31 +7,26 @@
*
**********/
-//BibleTime includes
-#include "ckeyreferencewidget.h"
+#include "frontend/keychooser/versekeychooser/ckeyreferencewidget.h"
-#include "../cscrollerwidgetset.h"
-#include "btdropdownchooserbutton.h"
-
-#include "backend/config/cbtconfig.h"
-
-#include "backend/keys/cswordversekey.h"
-
-#include "util/cresmgr.h"
-#include "util/directoryutil.h"
-
-//Qt includes
#include <QApplication>
#include <QDebug>
+#include <QEvent>
+#include <QFocusEvent>
#include <QHBoxLayout>
#include <QLineEdit>
-#include <QEvent>
#include <QMouseEvent>
#include <QPixmap>
#include <QString>
#include <QStringList>
#include <QToolButton>
-#include <QFocusEvent>
+#include "backend/config/cbtconfig.h"
+#include "backend/keys/cswordversekey.h"
+#include "frontend/keychooser/cscrollerwidgetset.h"
+#include "frontend/keychooser/versekeychooser/btdropdownchooserbutton.h"
+#include "util/cresmgr.h"
+#include "util/directory.h"
+
class BtLineEdit : public QLineEdit {
public:
@@ -54,6 +49,7 @@ CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVers
QWidget(parent),
m_key(key),
m_dropDownHoverTimer(this) {
+ namespace DU = util::directory;
updatelock = false;
m_module = mod;
@@ -61,7 +57,7 @@ CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVers
setFocusPolicy(Qt::WheelFocus);
QToolButton* clearRef = new QToolButton(this);
- clearRef->setIcon(util::filesystem::DirectoryUtil::getIcon("edit_clear_locationbar"));
+ clearRef->setIcon(DU::getIcon("edit_clear_locationbar"));
clearRef->setAutoRaise(true);
clearRef->setStyleSheet("QToolButton{margin:0px;}");
connect(clearRef, SIGNAL(clicked()), SLOT(slotClearRef()) );
@@ -243,32 +239,33 @@ void CKeyReferenceWidget::slotUpdateUnlock() {
}
void CKeyReferenceWidget::slotStepBook(int n) {
- CSwordVerseKey key = *m_key;
- n > 0 ? key.next( CSwordVerseKey::UseBook ) : key.previous( CSwordVerseKey::UseBook );
+ emit beforeChange(m_key);
+ n > 0 ? m_key->next( CSwordVerseKey::UseBook ) : m_key->previous( CSwordVerseKey::UseBook );
if (!updatelock)
- emit changed(&key); // does *m_key = key
+ emit changed(m_key);
updateText();
}
void CKeyReferenceWidget::slotStepChapter(int n) {
- CSwordVerseKey key = *m_key;
- n > 0 ? key.next( CSwordVerseKey::UseChapter ) : key.previous( CSwordVerseKey::UseChapter );
+ emit beforeChange(m_key);
+ n > 0 ? m_key->next( CSwordVerseKey::UseChapter ) : m_key->previous( CSwordVerseKey::UseChapter );
if (!updatelock)
- emit changed(&key); // does *m_key = key
+ emit changed(m_key);
updateText();
}
void CKeyReferenceWidget::slotStepVerse(int n) {
- CSwordVerseKey key = *m_key;
- n > 0 ? key.next( CSwordVerseKey::UseVerse ) : key.previous( CSwordVerseKey::UseVerse );
+ emit beforeChange(m_key);
+ n > 0 ? m_key->next( CSwordVerseKey::UseVerse ) : m_key->previous( CSwordVerseKey::UseVerse );
if (!updatelock)
- emit changed(&key); // does *m_key = key
+ emit changed(m_key);
updateText();
}
void CKeyReferenceWidget::slotChangeVerse(int n) {
if (m_key->Verse() != n) {
+ emit beforeChange(m_key);
m_key->Verse( n );
setKey( m_key );
}
@@ -278,6 +275,7 @@ void CKeyReferenceWidget::slotChangeVerse(int n) {
void CKeyReferenceWidget::slotChangeChapter(int n) {
if (m_key->Chapter() != n) {
+ emit beforeChange(m_key);
m_key->Chapter( n );
setKey( m_key );
}
@@ -288,6 +286,7 @@ void CKeyReferenceWidget::slotChangeChapter(int n) {
void CKeyReferenceWidget::slotChangeBook(QString bookname) {
if (m_key->book() != bookname) {
+ emit beforeChange(m_key);
m_key->book( bookname );
setKey( m_key );
}
diff --git a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h
index 95a188e..637530a 100644
--- a/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h
+++ b/src/frontend/keychooser/versekeychooser/ckeyreferencewidget.h
@@ -10,20 +10,18 @@
#ifndef CKEYREFERENCEWIDGET_H
#define CKEYREFERENCEWIDGET_H
-#include "../cscrollerwidgetset.h"
-#include "backend/drivers/cswordbiblemoduleinfo.h"
-
#include <QWidget>
+
#include <QTimer>
+#include "backend/drivers/cswordbiblemoduleinfo.h"
+#include "frontend/keychooser/cscrollerwidgetset.h"
+class BtDropdownChooserButton;
class CLexiconKeyChooser;
class CSwordVerseKey;
-class BtDropdownChooserButton;
-
class QLineEdit;
-
class CKeyReferenceWidget : public QWidget {
Q_OBJECT
public:
@@ -37,7 +35,8 @@ class CKeyReferenceWidget : public QWidget {
void setModule(CSwordBibleModuleInfo *m = 0);
bool eventFilter(QObject *o, QEvent *e);
- signals:
+signals:
+ void beforeChange(CSwordVerseKey* key);
void changed(CSwordVerseKey* key);
protected:
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp b/src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp
index cdfa870..2091a54 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp
+++ b/src/frontend/mainindex/bookmarks/btbookmarkfolder.cpp
@@ -7,18 +7,16 @@
*
**********/
+#include "frontend/mainindex/bookmarks/btbookmarkfolder.h"
-#include "btbookmarkfolder.h"
-#include "btbookmarkitembase.h"
-#include "btbookmarkitem.h"
-#include "btbookmarkloader.h"
-
-#include "util/cresmgr.h"
-#include "util/directoryutil.h"
-
+#include <QDebug>
#include <QFileDialog>
+#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
+#include "frontend/mainindex/bookmarks/btbookmarkitem.h"
+#include "frontend/mainindex/bookmarks/btbookmarkloader.h"
+#include "util/cresmgr.h"
+#include "util/directory.h"
-#include <QDebug>
BtBookmarkFolder::BtBookmarkFolder(QTreeWidgetItem* parent, QString name)
: BtBookmarkItemBase(parent) {
@@ -86,12 +84,14 @@ void BtBookmarkFolder::rename() {
}
void BtBookmarkFolder::update() {
+ namespace DU = util::directory;
+
qDebug() << "BtBookmarkFolder::update()";
BtBookmarkItemBase::update();
if (isExpanded() && childCount())
- setIcon(0, util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::openedFolder::icon));
+ setIcon(0, DU::getIcon(CResMgr::mainIndex::openedFolder::icon));
else
- setIcon(0, util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::closedFolder::icon));
+ setIcon(0, DU::getIcon(CResMgr::mainIndex::closedFolder::icon));
}
bool BtBookmarkFolder::hasDescendant(QTreeWidgetItem* item) const {
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkfolder.h b/src/frontend/mainindex/bookmarks/btbookmarkfolder.h
index d00222b..9f065f4 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkfolder.h
+++ b/src/frontend/mainindex/bookmarks/btbookmarkfolder.h
@@ -10,10 +10,10 @@
#ifndef BTBOOKMARKFOLDER_H
#define BTBOOKMARKFOLDER_H
-#include "btbookmarkitembase.h"
+#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
-#define CURRENT_SYNTAX_VERSION 1
+#define CURRENT_SYNTAX_VERSION 1
class BtBookmarkFolder : public BtBookmarkItemBase {
public:
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkitem.cpp b/src/frontend/mainindex/bookmarks/btbookmarkitem.cpp
index ba9632e..40dc79e 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkitem.cpp
+++ b/src/frontend/mainindex/bookmarks/btbookmarkitem.cpp
@@ -7,21 +7,18 @@
*
**********/
+#include "frontend/mainindex/bookmarks/btbookmarkitem.h"
-#include "btbookmarkitem.h"
-#include "btbookmarkfolder.h"
-
+#include <boost/scoped_ptr.hpp>
+#include <QDebug>
+#include "backend/config/cbtconfig.h"
#include "backend/drivers/cswordmoduleinfo.h"
#include "backend/keys/cswordversekey.h"
#include "frontend/cinputdialog.h"
-#include "util/cresmgr.h"
-#include "util/directoryutil.h"
-#include "backend/config/cbtconfig.h"
+#include "frontend/mainindex/bookmarks/btbookmarkfolder.h"
#include "util/cpointers.h"
-
-#include <QDebug>
-
-#include <boost/scoped_ptr.hpp>
+#include "util/cresmgr.h"
+#include "util/directory.h"
BtBookmarkItem::BtBookmarkItem(CSwordModuleInfo* module, QString key, QString& description)
@@ -141,8 +138,10 @@ QString BtBookmarkItem::englishKey() const {
}
void BtBookmarkItem::update() {
+ namespace DU = util::directory;
+
qDebug() << "BtBookmarkItem::update";
- setIcon(0, util::filesystem::DirectoryUtil::getIcon(CResMgr::mainIndex::bookmark::icon));
+ setIcon(0, DU::getIcon(CResMgr::mainIndex::bookmark::icon));
const QString title = QString::fromLatin1("%1 (%2)").arg(key()).arg(module() ? module()->name() : QObject::tr("unknown"));
setText(0, title);
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkitem.h b/src/frontend/mainindex/bookmarks/btbookmarkitem.h
index 1708627..6677f61 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkitem.h
+++ b/src/frontend/mainindex/bookmarks/btbookmarkitem.h
@@ -10,11 +10,11 @@
#ifndef BTBOOKMARKITEM_H
#define BTBOOKMARKITEM_H
-
-#include "btbookmarkitembase.h"
+#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
#include <QString>
+
class BtBookmarkFolder;
class CSwordModuleInfo;
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkitembase.cpp b/src/frontend/mainindex/bookmarks/btbookmarkitembase.cpp
index a4270a8..82241ce 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkitembase.cpp
+++ b/src/frontend/mainindex/bookmarks/btbookmarkitembase.cpp
@@ -7,11 +7,12 @@
*
**********/
-#include "btbookmarkitembase.h"
-#include "cbookmarkindex.h"
+#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
-#include <QTreeWidgetItem>
#include <QDropEvent>
+#include <QTreeWidgetItem>
+#include "frontend/mainindex/bookmarks/cbookmarkindex.h"
+
BtBookmarkItemBase::BtBookmarkItemBase() {}
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkitembase.h b/src/frontend/mainindex/bookmarks/btbookmarkitembase.h
index 326f760..78754f7 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkitembase.h
+++ b/src/frontend/mainindex/bookmarks/btbookmarkitembase.h
@@ -10,18 +10,17 @@
#ifndef BTBOOKMARKITEMBASE_H
#define BTBOOKMARKITEMBASE_H
-
#include <QTreeWidgetItem>
-#include <QString>
-#include <QMimeData>
+
#include <QDropEvent>
+#include <QMimeData>
+#include <QString>
-class CBookmarkIndex;
+class CBookmarkIndex;
class BtBookmarkItemBase : public QTreeWidgetItem {
public:
-
enum MenuAction {
NewFolder = 0,
ChangeFolder,
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkloader.cpp b/src/frontend/mainindex/bookmarks/btbookmarkloader.cpp
index f6f3913..ddf656e 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkloader.cpp
+++ b/src/frontend/mainindex/bookmarks/btbookmarkloader.cpp
@@ -7,24 +7,22 @@
*
**********/
-#include "btbookmarkloader.h"
+#include "frontend/mainindex/bookmarks/btbookmarkloader.h"
-#include "btbookmarkitem.h"
-#include "btbookmarkfolder.h"
-
-#include "util/ctoolclass.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-
-#include <QTreeWidgetItem>
+#include <QDebug>
#include <QDomElement>
#include <QDomNode>
#include <QDomDocument>
-#include <QTextStream>
#include <QFile>
#include <QIODevice>
#include <QTextCodec>
+#include <QTextStream>
+#include <QTreeWidgetItem>
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "frontend/mainindex/bookmarks/btbookmarkitem.h"
+#include "frontend/mainindex/bookmarks/btbookmarkfolder.h"
+#include "util/tool.h"
-#include <QDebug>
#define CURRENT_SYNTAX_VERSION 1
@@ -102,8 +100,10 @@ QTreeWidgetItem* BtBookmarkLoader::handleXmlElement(QDomElement& element, QTreeW
QString BtBookmarkLoader::loadXmlFromFile(QString fileName) {
+ namespace DU = util::directory;
+
if (fileName.isNull()) {
- fileName = util::filesystem::DirectoryUtil::getUserBaseDir().absolutePath() + "/bookmarks.xml";
+ fileName = DU::getUserBaseDir().absolutePath() + "/bookmarks.xml";
}
QFile file(fileName);
if (!file.exists())
@@ -122,9 +122,11 @@ QString BtBookmarkLoader::loadXmlFromFile(QString fileName) {
}
void BtBookmarkLoader::saveTreeFromRootItem(QTreeWidgetItem* rootItem, QString fileName, bool forceOverwrite) {
+ namespace DU = util::directory;
+
Q_ASSERT(rootItem);
if (fileName.isNull()) {
- fileName = util::filesystem::DirectoryUtil::getUserBaseDir().absolutePath() + "/bookmarks.xml";
+ fileName = DU::getUserBaseDir().absolutePath() + "/bookmarks.xml";
}
QDomDocument doc("DOC");
@@ -139,7 +141,7 @@ void BtBookmarkLoader::saveTreeFromRootItem(QTreeWidgetItem* rootItem, QString f
for (int i = 0; i < rootItem->childCount(); i++) {
saveItem(rootItem->child(i), content);
}
- CToolClass::savePlainFile(fileName, doc.toString(), forceOverwrite, QTextCodec::codecForName("UTF-8"));
+ util::tool::savePlainFile(fileName, doc.toString(), forceOverwrite, QTextCodec::codecForName("UTF-8"));
}
diff --git a/src/frontend/mainindex/bookmarks/btbookmarkloader.h b/src/frontend/mainindex/bookmarks/btbookmarkloader.h
index 7a981d9..3102ca2 100644
--- a/src/frontend/mainindex/bookmarks/btbookmarkloader.h
+++ b/src/frontend/mainindex/bookmarks/btbookmarkloader.h
@@ -10,11 +10,11 @@
#ifndef BTBOOKMARKLOADER_H
#define BTBOOKMARKLOADER_H
-#include "util/directoryutil.h"
+#include "util/directory.h"
-#include <QString>
-#include <QList>
#include <QDomElement>
+#include <QList>
+#include <QString>
class QTreeWidgetItem;
diff --git a/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp b/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp
index 6d35793..dda763b 100644
--- a/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp
+++ b/src/frontend/mainindex/bookmarks/cbookmarkindex.cpp
@@ -7,52 +7,44 @@
*
**********/
-//BibleTime includes
-#include "cbookmarkindex.h"
-
-#include "btbookmarkitembase.h"
-#include "btbookmarkitem.h"
-#include "btbookmarkfolder.h"
-#include "btbookmarkloader.h"
-
-#include "backend/managers/creferencemanager.h"
-#include "backend/drivers/cswordmoduleinfo.h"
-
-#include "frontend/searchdialog/csearchdialog.h"
-#include "backend/config/cbtconfig.h"
-#include "frontend/cinfodisplay.h"
-
-#include "frontend/cprinter.h"
-#include "frontend/cdragdrop.h"
-
-#include "util/cresmgr.h"
-#include "util/directoryutil.h"
-#include "util/ctoolclass.h"
+#include "frontend/mainindex/bookmarks/cbookmarkindex.h"
#include <boost/scoped_ptr.hpp>
-
-//Qt includes
-#include <QInputDialog>
+#include <QAction>
+#include <QApplication>
+#include <QCursor>
+#include <QDebug>
+#include <QDrag>
#include <QDragLeaveEvent>
#include <QDragMoveEvent>
#include <QDropEvent>
#include <QHeaderView>
-#include <QTimer>
-#include <QToolTip>
+#include <QInputDialog>
#include <QList>
-#include <QTreeWidget>
-#include <QTreeWidgetItem>
-#include <QCursor>
-#include <QMouseEvent>
-#include <QMessageBox>
#include <QMenu>
-#include <QAction>
-#include <QPaintEvent>
+#include <QMouseEvent>
#include <QPainter>
-#include <QApplication>
-#include <QDrag>
+#include <QPaintEvent>
+#include <QTimer>
+#include <QTreeWidget>
+#include <QTreeWidgetItem>
+#include <QToolTip>
+#include "backend/config/cbtconfig.h"
+#include "backend/drivers/cswordmoduleinfo.h"
+#include "backend/managers/referencemanager.h"
+#include "frontend/cdragdrop.h"
+#include "frontend/cinfodisplay.h"
+#include "frontend/cprinter.h"
+#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
+#include "frontend/mainindex/bookmarks/btbookmarkitem.h"
+#include "frontend/mainindex/bookmarks/btbookmarkfolder.h"
+#include "frontend/mainindex/bookmarks/btbookmarkloader.h"
+#include "frontend/searchdialog/csearchdialog.h"
+#include "util/cresmgr.h"
+#include "util/tool.h"
+#include "util/directory.h"
+#include "util/dialogutil.h"
-#include <QDebug>
CBookmarkIndex::CBookmarkIndex(QWidget *parent)
: QTreeWidget(parent),
@@ -74,7 +66,7 @@ CBookmarkIndex::~CBookmarkIndex() {
/** Initializes the view. */
void CBookmarkIndex::initView() {
- //qDebug("CBookmarkIndex::initView");
+ //qDebug() << "CBookmarkIndex::initView";
header()->hide();
@@ -123,7 +115,7 @@ void CBookmarkIndex::initView() {
m_popup->addAction(separator);
m_popup->addAction(m_actions.deleteEntries);
- //qDebug("CBookmarkIndex::initView end");
+ //qDebug() << "CBookmarkIndex::initView end";
}
/** Convenience function for creating a new QAction.
@@ -131,14 +123,15 @@ 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) {
- QAction* action = new QAction(util::filesystem::DirectoryUtil::getIcon(pix), text, parent);
+ namespace DU = util::directory;
+ QAction* action = new QAction(DU::getIcon(pix), text, parent);
QObject::connect(action, SIGNAL(triggered()), receiver, slot);
return action;
}
/** Initialize the SIGNAL<->SLOT connections */
void CBookmarkIndex::initConnections() {
- //qDebug("CBookmarkIndex::initConnections");
+ //qDebug() << "CBookmarkIndex::initConnections";
bool ok;
ok = connect(this, SIGNAL(itemActivated(QTreeWidgetItem*, int)), this, SLOT(slotExecuted(QTreeWidgetItem*)));
Q_ASSERT(ok);
@@ -156,14 +149,14 @@ void CBookmarkIndex::initConnections() {
* Hack to get single click and selection working. See slotExecuted.
*/
void CBookmarkIndex::mouseReleaseEvent(QMouseEvent* event) {
- //qDebug("CBookmarkIndex::mouseReleaseEvent");
+ //qDebug() << "CBookmarkIndex::mouseReleaseEvent";
m_mouseReleaseEventModifiers = event->modifiers();
QTreeWidget::mouseReleaseEvent(event);
}
/** Called when an item is clicked with mouse or activated with keyboard. */
void CBookmarkIndex::slotExecuted( QTreeWidgetItem* i ) {
- qDebug("CBookmarkIndex::slotExecuted");
+ qDebug() << "CBookmarkIndex::slotExecuted";
//HACK: checking the modifier keys from the last mouseReleaseEvent
//depends on executing order: mouseReleaseEvent first, then itemClicked signal
@@ -212,7 +205,7 @@ QMimeData* CBookmarkIndex::dragObject() {
}
void CBookmarkIndex::dragEnterEvent( QDragEnterEvent* event ) {
- //qDebug("CBookmarkIndex::dragEnterEvent");
+ //qDebug() << "CBookmarkIndex::dragEnterEvent";
setState(QAbstractItemView::DraggingState);
QTreeWidget::dragEnterEvent(event);
if (event->source() == this || event->mimeData()->hasFormat("BibleTime/Bookmark")) {
@@ -222,7 +215,7 @@ void CBookmarkIndex::dragEnterEvent( QDragEnterEvent* event ) {
void CBookmarkIndex::dragMoveEvent( QDragMoveEvent* event ) {
- //qDebug("CBookmarkIndex::dragMoveEvent");
+ //qDebug() << "CBookmarkIndex::dragMoveEvent";
// do this first, otherwise the event may be ignored
QTreeWidget::dragMoveEvent(event);
@@ -237,13 +230,15 @@ void CBookmarkIndex::dragMoveEvent( QDragMoveEvent* event ) {
}
void CBookmarkIndex::dragLeaveEvent( QDragLeaveEvent* ) {
- qDebug("CBookmarkIndex::dragLeaveEvent");
+ qDebug() << "CBookmarkIndex::dragLeaveEvent";
setState(QAbstractItemView::NoState); // not dragging anymore
viewport()->update(); // clear the arrow
}
void CBookmarkIndex::paintEvent(QPaintEvent* event) {
+ namespace DU = util::directory;
+
static QPixmap pix;
static int halfPixHeight;
static bool arrowInitialized = false;
@@ -251,14 +246,14 @@ void CBookmarkIndex::paintEvent(QPaintEvent* event) {
// Initialize the static variables, including the arrow pixmap
if (!arrowInitialized) {
arrowInitialized = true;
- int arrowSize = CToolClass::mWidth(this, 1);
+ int arrowSize = util::tool::mWidth(this, 1);
QString fileName;
- if (util::filesystem::DirectoryUtil::getIconDir().exists("pointing_arrow.svg")) {
- fileName = util::filesystem::DirectoryUtil::getIconDir().filePath("pointing_arrow.svg");
+ if (DU::getIconDir().exists("pointing_arrow.svg")) {
+ fileName = DU::getIconDir().filePath("pointing_arrow.svg");
}
else {
- if (util::filesystem::DirectoryUtil::getIconDir().exists("pointing_arrow.png")) {
- fileName = util::filesystem::DirectoryUtil::getIconDir().filePath("pointing_arrow.png");
+ if (DU::getIconDir().exists("pointing_arrow.png")) {
+ fileName = DU::getIconDir().filePath("pointing_arrow.png");
}
else {
qWarning() << "Picture file pointing_arrow.svg or .png not found!";
@@ -323,7 +318,7 @@ void CBookmarkIndex::paintEvent(QPaintEvent* event) {
void CBookmarkIndex::dropEvent( QDropEvent* event ) {
- qDebug("CBookmarkIndex::dropEvent");
+ qDebug() << "CBookmarkIndex::dropEvent";
//setState(QAbstractItemView::NoState);
// Try to prevent annoying timed autocollapsing. Remember to disconnect before return.
@@ -384,7 +379,7 @@ void CBookmarkIndex::dropEvent( QDropEvent* event ) {
if ( event->source() == this ) {
- qDebug("dropping internal drag");
+ qDebug() << "dropping internal drag";
event->accept();
bool bookmarksOnly = true;
@@ -436,7 +431,7 @@ void CBookmarkIndex::dropEvent( QDropEvent* event ) {
void CBookmarkIndex::createBookmarkFromDrop(QDropEvent* event, QTreeWidgetItem* parentItem, int indexInParent) {
- //qDebug("CBookmarkIndex::createBookmarkFromDrop");
+ //qDebug() << "CBookmarkIndex::createBookmarkFromDrop";
//take the bookmark data from the mime source
const BTMimeData* mdata = dynamic_cast<const BTMimeData*>(event->mimeData());
if (mdata) {
@@ -454,7 +449,7 @@ void CBookmarkIndex::createBookmarkFromDrop(QDropEvent* event, QTreeWidgetItem*
/** Load the tree from file */
void CBookmarkIndex::initTree() {
- qDebug("CBookmarkIndex::initTree");
+ qDebug() << "CBookmarkIndex::initTree";
BtBookmarkLoader loader;
addTopLevelItems(loader.loadTree());
@@ -502,7 +497,7 @@ QAction* CBookmarkIndex::action( BtBookmarkItemBase::MenuAction type ) const {
/** Shows the context menu at the given position. */
void CBookmarkIndex::contextMenu(const QPoint& p) {
- //qDebug("CBookmarkIndex::contextMenu");
+ //qDebug() << "CBookmarkIndex::contextMenu";
//setup menu entries depending on current selection
QTreeWidgetItem* i = itemAt(p);
QList<QTreeWidgetItem *> items = selectedItems();
@@ -566,12 +561,12 @@ void CBookmarkIndex::contextMenu(const QPoint& p) {
}
//finally, open the popup
m_popup->exec(mapToGlobal(p));
- //qDebug("CBookmarkIndex::contextMenu end");
+ //qDebug() << "CBookmarkIndex::contextMenu end";
}
/** Adds a new subfolder to the current item. */
void CBookmarkIndex::createNewFolder() {
- //qDebug("CBookmarkIndex::createNewFolder");
+ //qDebug() << "CBookmarkIndex::createNewFolder";
QList<QTreeWidgetItem*> selected = selectedItems();
if (selected.count() > 0) {
BtBookmarkFolder* i = dynamic_cast<BtBookmarkFolder*>(currentItem());
@@ -677,7 +672,7 @@ void CBookmarkIndex::deleteEntries(bool confirm) {
}
}
- if (QMessageBox::question(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) {
+ if (util::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) {
return;
}
}
@@ -697,7 +692,7 @@ a BibleTime mimedata object. It can be dragged and dropped to a text view or som
The internal drag is handled differently, it doesn't use the mimedata (see dropEvent()).
*/
void CBookmarkIndex::startDrag(Qt::DropActions) {
- qDebug("CBookmarkIndex::startDrag");
+ qDebug() << "CBookmarkIndex::startDrag";
QMimeData* mData = dragObject(); // create the data which can be used in other widgets
QDrag* drag = new QDrag(this);
@@ -739,10 +734,10 @@ bool CBookmarkIndex::isMultiAction( const BtBookmarkItemBase::MenuAction type )
/* Saves the bookmarks to the default bookmarks file. */
void CBookmarkIndex::saveBookmarks() {
- qDebug("CBookmarkIndex::saveBookmarks()");
+ qDebug() << "CBookmarkIndex::saveBookmarks()";
BtBookmarkLoader loader;
loader.saveTreeFromRootItem(invisibleRootItem());
- //qDebug("CBookmarkIndex::saveBookmarks end");
+ //qDebug() << "CBookmarkIndex::saveBookmarks end";
}
void CBookmarkIndex::mouseMoveEvent(QMouseEvent* event) {
@@ -751,7 +746,7 @@ void CBookmarkIndex::mouseMoveEvent(QMouseEvent* event) {
// Restart the mag timer if we have moved to another item and shift was not pressed.
QTreeWidgetItem* itemUnderPointer = itemAt(event->pos());
if (itemUnderPointer && (itemUnderPointer != m_previousEventItem) ) {
- //qDebug("CBookmarkIndex::mouseMoveEvent, moved onto another item");
+ //qDebug() << "CBookmarkIndex::mouseMoveEvent, moved onto another item";
if ( !(event->modifiers() & Qt::ShiftModifier)) {
m_magTimer.start(); // see the ctor for the timer properties
}
@@ -767,7 +762,7 @@ void CBookmarkIndex::mouseMoveEvent(QMouseEvent* event) {
}
void CBookmarkIndex::magTimeout() {
- //qDebug("CBookmarkIndex::magTimeout");
+ //qDebug() << "CBookmarkIndex::magTimeout";
QTreeWidgetItem* itemUnderPointer = 0;
if (underMouse()) {
@@ -777,7 +772,7 @@ void CBookmarkIndex::magTimeout() {
if (itemUnderPointer && (m_previousEventItem == itemUnderPointer)) {
BtBookmarkItem* bitem = dynamic_cast<BtBookmarkItem*>(itemUnderPointer);
if (bitem) {
- //qDebug("CBookmarkIndex::timerEvent: update the infodisplay");
+ //qDebug() << "CBookmarkIndex::timerEvent: update the infodisplay";
// Update the mag
if (bitem->module()) {
(CPointers::infoDisplay())->setInfo(
diff --git a/src/frontend/mainindex/bookmarks/cbookmarkindex.h b/src/frontend/mainindex/bookmarks/cbookmarkindex.h
index 748e75d..9da12a6 100644
--- a/src/frontend/mainindex/bookmarks/cbookmarkindex.h
+++ b/src/frontend/mainindex/bookmarks/cbookmarkindex.h
@@ -10,32 +10,28 @@
#ifndef CBOOKMARKINDEX_H
#define CBOOKMARKINDEX_H
-//BibleTime includes
-#include "btbookmarkitembase.h"
+#include "frontend/mainindex/bookmarks/btbookmarkitembase.h"
-class CSwordModuleInfo;
-#include "frontend/displaywindow/cdisplaywindow.h"
-
-#include "util/cpointers.h"
-
-//Qt includes
-#include <QTimer>
-#include <QToolTip>
#include <QList>
+#include <QTimer>
#include <QTreeWidget>
#include <QTreeWidgetItem>
+#include <QToolTip>
+#include "frontend/displaywindow/cdisplaywindow.h"
+#include "util/cpointers.h"
+
+class BTMimeData;
class CSearchDialog;
-class QWidget;
-class QDropEvent;
-class QDragMoveEvent;
+class CSwordModuleInfo;
+class QAction;
class QDragLeaveEvent;
-class BTMimeData;
+class QDragMoveEvent;
+class QDropEvent;
class QMenu;
-class QAction;
-class QPaintEvent;
-
class QMouseEvent;
+class QPaintEvent;
+class QWidget;
/**
* The widget which manages all bookmarks.
@@ -43,7 +39,6 @@ class QMouseEvent;
*/
class CBookmarkIndex : public QTreeWidget {
Q_OBJECT
-
public:
CBookmarkIndex(QWidget *parent);
virtual ~CBookmarkIndex();
diff --git a/src/frontend/mainindex/bookshelf/actionenum.h b/src/frontend/mainindex/bookshelf/actionenum.h
deleted file mode 100644
index e95f3d7..0000000
--- a/src/frontend/mainindex/bookshelf/actionenum.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef ACTIONENUM_H
-#define ACTIONENUM_H
-
-enum IndexAction {
- EditModule,
- UnlockModule,
- HideModules,
- ShowAllModules,
- SearchModules,
- UpdateModules,
- Grouping,
- AboutModule
-};
-
-#endif
diff --git a/src/frontend/mainindex/bookshelf/btindexfolder.cpp b/src/frontend/mainindex/bookshelf/btindexfolder.cpp
deleted file mode 100644
index 56cc5fc..0000000
--- a/src/frontend/mainindex/bookshelf/btindexfolder.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "btindexfolder.h"
-#include "backend/btmoduletreeitem.h"
-#include "util/directoryutil.h"
-
-BTIndexFolder::BTIndexFolder(BTModuleTreeItem* treeItem, QTreeWidgetItem* parent)
- : BTIndexItem(parent) {
- setText(0, treeItem->text());
- setIcon(0, util::filesystem::DirectoryUtil::getIcon(treeItem->iconName()));
-}
diff --git a/src/frontend/mainindex/bookshelf/btindexfolder.h b/src/frontend/mainindex/bookshelf/btindexfolder.h
deleted file mode 100644
index c85e31d..0000000
--- a/src/frontend/mainindex/bookshelf/btindexfolder.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BTINDEXFOLDER_H
-#define BTINDEXFOLDER_H
-
-#include "btindexitem.h"
-
-#include <QString>
-
-class BTModuleTreeItem;
-
-/**
- @author The BibleTime team <info@bibletime.info>
-*/
-class BTIndexFolder : public BTIndexItem {
- public:
- BTIndexFolder(BTModuleTreeItem* treeItem, QTreeWidgetItem* p);
-
- ~BTIndexFolder() {}
-};
-
-#endif
diff --git a/src/frontend/mainindex/bookshelf/btindexitem.cpp b/src/frontend/mainindex/bookshelf/btindexitem.cpp
deleted file mode 100644
index 859c150..0000000
--- a/src/frontend/mainindex/bookshelf/btindexitem.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#include "btindexitem.h"
-#include "cbookshelfindex.h"
-
-#include <QTreeWidgetItem>
-#include <QTreeWidget>
-
-
-BTIndexItem::BTIndexItem(QTreeWidgetItem* parent)
- : QTreeWidgetItem(parent) {}
diff --git a/src/frontend/mainindex/bookshelf/btindexitem.h b/src/frontend/mainindex/bookshelf/btindexitem.h
deleted file mode 100644
index 88609a3..0000000
--- a/src/frontend/mainindex/bookshelf/btindexitem.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License version 2.0.
-*
-**********/
-
-#ifndef BTINDEXITEM_H
-#define BTINDEXITEM_H
-
-#include "actionenum.h"
-
-#include <QTreeWidgetItem>
-#include <QString>
-
-class QMimeData;
-class QAction;
-
-
-/**
-@author The BibleTime team <info@bibletime.info>
-*/
-class BTIndexItem : public QTreeWidgetItem {
- public:
- /** Those menu actions which are item specific. */
-
- BTIndexItem(QTreeWidgetItem* parent);
- virtual ~BTIndexItem() {};
- /**
- * Enables the given action if it has the "indexActionType" property which this item supports.
- * Handles only those actions which may or may not be supported, not those which
- * are always supported by all items. If the action is not supported in the current state of the
- * item this function does nothing.
- */
- virtual bool enableAction(QAction*) const {
- return false;
- }
-
- //TODO: d'n'd functions so that view can delegate d'n'd to items?
- virtual bool acceptDrop(const QMimeData*) {
- return false;
- }
-};
-
-#endif
diff --git a/src/frontend/mainindex/bookshelf/btindexmodule.cpp b/src/frontend/mainindex/bookshelf/btindexmodule.cpp
deleted file mode 100644
index d8c2301..0000000
--- a/src/frontend/mainindex/bookshelf/btindexmodule.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/*********
-*
-* This file is part of BibleTime's source code, http://www.bibletime.info/.
-*
-* Copyright 1999-2008 by the BibleTime developers.
-* The BibleTime source code is licensed under the GNU General Public License ve